Skip to contentSkip to conversation

Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

PATCH In review Mirela Rabulea (OSS) 5 participants 14 messages Mar 11, 2021 – Mar 12, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v9 cover Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

From: Mirela Rabulea <[email protected]>

This patch set adds the V4L2 driver for i.MX8QXP/QM JPEG encoder/decoder and it's dependencies.
The driver was tested on i.MX8QXP, using a unit test application and the v4l2-compliance tool, including the streaming tests for decoder & encoder.

The output of latest v4l2-compliance on i.MX8QXP, decoder & encoder:

root@imx8qxpmek:/unit_tests/JPEG# ./v4l2-compliance -d /dev/video0 -s
v4l2-compliance 1.21.0-4740, 64 bits, 64-bit time_t
v4l2-compliance SHA: f253495fa6de 2021-03-06 15:32:09

Compliance test for mxc-jpeg codec device /dev/video0:

Driver Info:

	Driver name      : mxc-jpeg codec
	Card type        : mxc-jpeg codec
	Bus info         : platform:58400000.jpegdec
	Driver version   : 5.12.0
	Capabilities     : 0x84204000

Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected JPEG Decoder

Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK (Not Supported)
test blocking wait: OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (no poll): OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (select): OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported) test USERPTR (select): OK (Not Supported) test DMABUF: Cannot test, specify --expbuf-device

Total for mxc-jpeg codec device /dev/video0: 52, Succeeded: 52, Failed: 0, Warnings: 0

root@imx8qxpmek:/unit_tests/JPEG# ./v4l2-compliance -d /dev/video1 -s
v4l2-compliance 1.21.0-4740, 64 bits, 64-bit time_t
v4l2-compliance SHA: f253495fa6de 2021-03-06 15:32:09

Compliance test for mxc-jpeg codec device /dev/video1:

Driver Info:

	Driver name      : mxc-jpeg codec
	Card type        : mxc-jpeg codec
	Bus info         : platform:58450000.jpegenc
	Driver version   : 5.12.0
	Capabilities     : 0x84204000

Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected JPEG Encoder

Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK (Not Supported)
test blocking wait: OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (no poll): OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (select): OK
Video Capture Multiplanar: Captured 58 buffers test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported) test USERPTR (select): OK (Not Supported) test DMABUF: Cannot test, specify --expbuf-device

Total for mxc-jpeg codec device /dev/video1: 52, Succeeded: 52, Failed: 0, Warnings: 0

Mirela Rabulea (8):
media: v4l: Add packed YUV444 24bpp pixel format
media: dt-bindings: Add bindings for i.MX8QXP/QM JPEG driver
media: Add parsing for APP14 data segment in jpeg helpers
media: Quit parsing stream if doesn't start with SOI
media: Avoid parsing quantization and huffman tables
media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder
arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes Add maintainer for IMX jpeg v4l2 driver

 .../bindings/media/nxp,imx8-jpeg.yaml         |   84 +
 .../media/v4l/pixfmt-packed-yuv.rst           |   10 +
 MAINTAINERS                                   |    8 +
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi    |   35 +
 drivers/media/platform/Kconfig                |    2 +
 drivers/media/platform/Makefile               |    1 +
 drivers/media/platform/imx-jpeg/Kconfig       |   11 +
 drivers/media/platform/imx-jpeg/Makefile      |    3 +
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c |  168 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h |  140 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg.c    | 2122 +++++++++++++++++
 drivers/media/platform/imx-jpeg/mxc-jpeg.h    |  180 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |    1 +
 drivers/media/v4l2-core/v4l2-jpeg.c           |   57 +-
 include/media/v4l2-jpeg.h                     |   20 +
 include/uapi/linux/videodev2.h                |    1 +
 16 files changed, 2837 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml
 create mode 100644 drivers/media/platform/imx-jpeg/Kconfig
 create mode 100644 drivers/media/platform/imx-jpeg/Makefile
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v9 1/8 media: v4l: Add packed YUV444 24bpp pixel format

From: Mirela Rabulea <[email protected]>

The added format is V4L2_PIX_FMT_YUV24, this is a packed YUV 4:4:4 format, with 8 bits for each component, 24 bits per sample.

This format is used by the i.MX 8QuadMax and i.MX 8DualXPlus/8QuadXPlus JPEG encoder/decoder.

---
 .../userspace-api/media/v4l/pixfmt-packed-yuv.rst      | 10 ++++++++++
 drivers/media/v4l2-core/v4l2-ioctl.c                   |  1 +
 include/uapi/linux/videodev2.h                         |  1 +
 3 files changed, 12 insertions(+)
Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst +10 -0
index 560fd2ead8ca..65520c3af7cf 100644
@@ -220,6 +220,16 @@ the second byte and Y'\ :sub:`7-0` in the third byte.
       - Y'\ :sub:`7-0`
       - X\ :sub:`7-0`
 
+    * .. _V4L2-PIX-FMT-YUV24:
+
+      - ``V4L2_PIX_FMT_YUV24``
+      - 'YUV3'
+
+      - Y'\ :sub:`7-0`
+      - Cb\ :sub:`7-0`
+      - Cr\ :sub:`7-0`
+      - -\
+
 .. note::
 
     - The alpha component is expected to contain a meaningful value that can be
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
index 31d1342e61e8..9a160283b3ae 100644
@@ -1304,6 +1304,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_YUV444:	descr = "16-bit A/XYUV 4-4-4-4"; break;
 	case V4L2_PIX_FMT_YUV555:	descr = "16-bit A/XYUV 1-5-5-5"; break;
 	case V4L2_PIX_FMT_YUV565:	descr = "16-bit YUV 5-6-5"; break;
+	case V4L2_PIX_FMT_YUV24:	descr = "24-bit YUV 4:4:4 8-8-8"; break;
 	case V4L2_PIX_FMT_YUV32:	descr = "32-bit A/XYUV 8-8-8-8"; break;
 	case V4L2_PIX_FMT_AYUV32:	descr = "32-bit AYUV 8-8-8-8"; break;
 	case V4L2_PIX_FMT_XYUV32:	descr = "32-bit XYUV 8-8-8-8"; break;
include/uapi/linux/videodev2.h +1 -0
index 79dbde3bcf8d..9e4359be04eb 100644
@@ -586,6 +586,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_YUV444  v4l2_fourcc('Y', '4', '4', '4') /* 16  xxxxyyyy uuuuvvvv */
 #define V4L2_PIX_FMT_YUV555  v4l2_fourcc('Y', 'U', 'V', 'O') /* 16  YUV-5-5-5     */
 #define V4L2_PIX_FMT_YUV565  v4l2_fourcc('Y', 'U', 'V', 'P') /* 16  YUV-5-6-5     */
+#define V4L2_PIX_FMT_YUV24   v4l2_fourcc('Y', 'U', 'V', '3') /* 24  YUV-8-8-8     */
 #define V4L2_PIX_FMT_YUV32   v4l2_fourcc('Y', 'U', 'V', '4') /* 32  YUV-8-8-8-8   */
 #define V4L2_PIX_FMT_AYUV32  v4l2_fourcc('A', 'Y', 'U', 'V') /* 32  AYUV-8-8-8-8  */
 #define V4L2_PIX_FMT_XYUV32  v4l2_fourcc('X', 'Y', 'U', 'V') /* 32  XYUV-8-8-8-8  */
Signature · 1 line
2.17.1
#2 lore raw

PATCH v9 2/8 media: dt-bindings: Add bindings for i.MX8QXP/QM JPEG driver

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

Add bindings documentation for i.MX8QXP/QM JPEG decoder & encoder driver.

---
 .../bindings/media/nxp,imx8-jpeg.yaml         | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml
Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml new file +84 -0
new file mode 100644
index 000000000000..5d13cbb5251b
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/nxp,imx8-jpeg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: i.MX8QXP/QM JPEG decoder/encoder Device Tree Bindings
+
+maintainers:
+  - Mirela Rabulea <[email protected]>
+
+description: |-
+  The JPEG decoder/encoder present in iMX8QXP and iMX8QM SoCs is an
+  ISO/IEC 10918-1 JPEG standard compliant decoder/encoder, for Baseline
+  and Extended Sequential DCT modes.
+
+properties:
+  compatible:
+    items:
+      - enum:
+            # JPEG decoder
+          - nxp,imx8qxp-jpgdec
+            # JPEG encoder
+          - nxp,imx8qxp-jpgenc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: |
+      There are 4 slots available in the IP, which the driver may use
+      If a certain slot is used, it should have an associated interrupt
+      The interrupt with index i is assumed to be for slot i
+    minItems: 1               # At least one slot is needed by the driver
+    maxItems: 4               # The IP has 4 slots available for use
+
+  power-domains:
+    description:
+      List of phandle and PM domain specifier as documented in
+      Documentation/devicetree/bindings/power/power_domain.txt
+    minItems: 2               # Wrapper and 1 slot
+    maxItems: 5               # Wrapper and 4 slots
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - power-domains
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/firmware/imx/rsrc.h>
+
+    jpegdec: jpegdec@58400000 {
+        compatible = "nxp,imx8qxp-jpgdec";
+        reg = <0x58400000 0x00050000 >;
+        interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH>;
+        power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>,
+                        <&pd IMX_SC_R_MJPEG_DEC_S0>,
+                        <&pd IMX_SC_R_MJPEG_DEC_S1>,
+                        <&pd IMX_SC_R_MJPEG_DEC_S2>,
+                        <&pd IMX_SC_R_MJPEG_DEC_S3>;
+    };
+
+    jpegenc: jpegenc@58450000 {
+        compatible = "nxp,imx8qxp-jpgenc";
+        reg = <0x58450000 0x00050000 >;
+        interrupts = <GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 306 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH>;
+        power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>,
+                        <&pd IMX_SC_R_MJPEG_ENC_S0>,
+                        <&pd IMX_SC_R_MJPEG_ENC_S1>,
+                        <&pd IMX_SC_R_MJPEG_ENC_S2>,
+                        <&pd IMX_SC_R_MJPEG_ENC_S3>;
+    };
+...
Signature · 1 line
2.17.1
#3 lore raw

PATCH v9 3/8 media: Add parsing for APP14 data segment in jpeg helpers

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

According to Rec. ITU-T T.872 (06/2012) 6.5.3
APP14 segment is for color encoding, it contains a transform flag, which may have values of 0, 1 and 2 and are interpreted as follows:
0 - CMYK for images that are encoded with four components
- RGB for images that are encoded with three components
1 - An image encoded with three components using YCbCr colour encoding. 2 - An image encoded with four components using YCCK colour encoding.

This is used in imx-jpeg decoder, to distinguish between YUV444 and RGB24.

---
 drivers/media/v4l2-core/v4l2-jpeg.c | 42 ++++++++++++++++++++++++++++-
 include/media/v4l2-jpeg.h           | 20 ++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-jpeg.c +41 -1
index 9071b6cc6d0e..ede40f2a5456 100644
@@ -45,6 +45,7 @@ MODULE_LICENSE("GPL");
 #define DHP	0xffde	/* hierarchical progression */
 #define EXP	0xffdf	/* expand reference */
 #define APP0	0xffe0	/* application data */
+#define APP14	0xffee	/* application data for colour encoding */
 #define APP15	0xffef
 #define JPG0	0xfff0	/* extensions */
 #define JPG13	0xfffd
@@ -444,6 +445,39 @@ static int jpeg_skip_segment(struct jpeg_stream *stream)
 	return jpeg_skip(stream, len - 2);
 }
 
+/* Rec. ITU-T T.872 (06/2012) 6.5.3 */
+static int jpeg_parse_app14_data(struct jpeg_stream *stream,
+				 enum v4l2_jpeg_app14_tf *tf)
+{
+	int ret;
+	int lp;
+	int skip;
+
+	lp = jpeg_get_word_be(stream);
+	if (lp < 0)
+		return lp;
+
+	/* Check for "Adobe\0" in Ap1..6 */
+	if (stream->curr + 6 > stream->end ||
+	    strncmp(stream->curr, "Adobe\0", 6))
+		return -EINVAL;
+
+	/* get to Ap12 */
+	ret = jpeg_skip(stream, 11);
+	if (ret < 0)
+		return ret;
+
+	ret = jpeg_get_byte(stream);
+	if (ret < 0)
+		return ret;
+
+	*tf = ret;
+
+	/* skip the rest of the segment, this ensures at least it is complete */
+	skip = lp - 2 - 11;
+	return jpeg_skip(stream, skip);
+}
+
 /**
  * v4l2_jpeg_parse_header - locate marker segments and optionally parse headers
  * @buf: address of the JPEG buffer, should start with a SOI marker
@@ -476,6 +510,9 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
 	if (marker != SOI)
 		return -EINVAL;
 
+	/* init value to signal if this marker is not present */
+	out->app14_tf = V4L2_JPEG_APP14_TF_UNKNOWN;
+
 	/* loop through marker segments */
 	while ((marker = jpeg_next_marker(&stream)) >= 0) {
 		switch (marker) {
@@ -519,7 +556,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
 			ret = jpeg_parse_restart_interval(&stream,
 							&out->restart_interval);
 			break;
-
+		case APP14:
+			ret = jpeg_parse_app14_data(&stream,
+						    &out->app14_tf);
+			break;
 		case SOS:
 			ret = jpeg_reference_segment(&stream, &out->sos);
 			if (ret < 0)
include/media/v4l2-jpeg.h +20 -0
index ddba2a56c321..bae5a68bab6a 100644
@@ -87,6 +87,24 @@ struct v4l2_jpeg_scan_header {
 	/* Ss, Se, Ah, and Al are not used by any driver */
 };
 
+/**
+ * enum v4l2_jpeg_app14_tf - APP14 transform flag
+ * According to Rec. ITU-T T.872 (06/2012) 6.5.3
+ * APP14 segment is for color encoding, it contains a transform flag,
+ * which may have values of 0, 1 and 2 and are interpreted as follows:
+ * @V4L2_JPEG_APP14_TF_CMYK_RGB: CMYK for images encoded with four components
+ *                               RGB for images encoded with three components
+ * @V4L2_JPEG_APP14_TF_YCBCR: an image encoded with three components using YCbCr
+ * @V4L2_JPEG_APP14_TF_YCCK: an image encoded with four components using YCCK
+ * @V4L2_JPEG_APP14_TF_UNKNOWN: indicate app14 is not present
+ */
+enum v4l2_jpeg_app14_tf {
+	V4L2_JPEG_APP14_TF_CMYK_RGB	= 0,
+	V4L2_JPEG_APP14_TF_YCBCR	= 1,
+	V4L2_JPEG_APP14_TF_YCCK		= 2,
+	V4L2_JPEG_APP14_TF_UNKNOWN	= -1,
+};
+
 /**
  * struct v4l2_jpeg_header - parsed JPEG header
  * @sof: pointer to frame header and size
@@ -100,6 +118,7 @@ struct v4l2_jpeg_scan_header {
  *                  order, optional
  * @restart_interval: number of MCU per restart interval, Ri
  * @ecs_offset: buffer offset in bytes to the entropy coded segment
+ * @app14_tf: transform flag from app14 data
  *
  * When this structure is passed to v4l2_jpeg_parse_header, the optional scan,
  * quantization_tables, and huffman_tables pointers must be initialized to NULL
@@ -119,6 +138,7 @@ struct v4l2_jpeg_header {
 	struct v4l2_jpeg_reference *huffman_tables;
 	u16 restart_interval;
 	size_t ecs_offset;
+	enum v4l2_jpeg_app14_tf app14_tf;
 };
 
 int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out);
Signature · 1 line
2.17.1
#4 lore raw

PATCH v9 4/8 media: Quit parsing stream if doesn't start with SOI

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

In the case we get an invalid stream, such as from v4l2-compliance streaming test, jpeg_next_marker will end up parsing the entire stream. The standard describes the high level syntax of a jpeg as starting with SOI, ending with EOI, so return error if the very first 2 bytes are not SOI.

---
 drivers/media/v4l2-core/v4l2-jpeg.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-jpeg.c +2 -5
index ede40f2a5456..c4c0d6dd4577 100644
@@ -503,11 +503,8 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
 	out->num_dht = 0;
 	out->num_dqt = 0;
 
-	/* the first marker must be SOI */
-	marker = jpeg_next_marker(&stream);
-	if (marker < 0)
-		return marker;
-	if (marker != SOI)
+	/* the first bytes must be SOI, B.2.1 High-level syntax */
+	if (jpeg_get_word_be(&stream) != SOI)
 		return -EINVAL;
 
 	/* init value to signal if this marker is not present */
Signature · 1 line
2.17.1
#5 lore raw

PATCH v9 5/8 media: Avoid parsing quantization and huffman tables

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

These are optional in struct v4l2_jpeg_header, so skip DHT/DQT segment parsing if huffman_tables/quantization_tables were not requested by user, to save time.
However, do count them (num_dht/num_dqt).

---
 drivers/media/v4l2-core/v4l2-jpeg.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/media/v4l2-core/v4l2-jpeg.c +8 -0
index c4c0d6dd4577..c2513b775f6a 100644
@@ -537,6 +537,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
 					&out->dht[out->num_dht++ % 4]);
 			if (ret < 0)
 				return ret;
+			if (!out->huffman_tables) {
+				ret = jpeg_skip_segment(&stream);
+				break;
+			}
 			ret = jpeg_parse_huffman_tables(&stream,
 							out->huffman_tables);
 			break;
@@ -545,6 +549,10 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
 					&out->dqt[out->num_dqt++ % 4]);
 			if (ret < 0)
 				return ret;
+			if (!out->quantization_tables) {
+				ret = jpeg_skip_segment(&stream);
+				break;
+			}
 			ret = jpeg_parse_quantization_tables(&stream,
 					out->frame.precision,
 					out->quantization_tables);
Signature · 1 line
2.17.1
#6 lore raw

PATCH v9 6/8 media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

V4L2 driver for the JPEG encoder/decoder from i.MX8QXP/i.MX8QM application processors.
The multi-planar buffers API is used.

Baseline and extended sequential jpeg decoding is supported. Progressive jpeg decoding is not supported by the IP. Supports encode and decode of various formats:

     YUV444, YUV422, YUV420, RGB, ARGB, Gray

YUV420 is the only multi-planar format supported. Minimum resolution is 64 x 64, maximum 8192 x 8192.
The alignment requirements for the resolution depend on the format, multiple of 16 resolutions should work for all formats.

v4l2-compliance tests are passing, including the
streaming tests, "v4l2-compliance -s"

---
Changes in v9:
Added comment to clearly state this driver will only support full-range quantization for YUV Squash the jpeg helper patch (former patch 9) into this one
Simplified 2 dev_dbg's, to avoid kernel test robot warning:
dma_addr_t type is ong long unsigned int for arm64, versus unsigned int for powerpc64 which is used by kernel test robot)

I have received feedback on this patch over time from:
Hans Verkuil, Philipp Zabel, Laurentiu Palcu, Ezequiel Garcia Thanks everyone for taking the time to review.

I got one explicit Reviewed-by from Philipp, for the jpeg helpers integration, from former patch 9 which was squashed here.

Full change log here:

Changes in v8:
Fixes after feedback from Hans:
-Use v4l2_disable_ioctl() to disable the VIDIOC_(TRY)_ENCODER_CMD ioctls
for the decoder and the VIDIOC_(TRY)_DECODER_CMD ioctls for the encoder, and drop the checks from mxc_jpeg_decoder_cmd/mxc_jpeg_encoder_cmd
-Fix mxc_jpeg_queue_setup for CREATE_BUFS situation,
return 0 to avoid overwriting sizes array.
-Fold release_active_buffers into mxc_jpeg_stop_streaming,
fix it so it does not touch internal vb2_queue data structures, use vim2m_stop_streaming as model.
-Always set V4L2_FIELD_NONE in mxc_jpeg_buf_out_validate -Rename decoder -> codec in mxc_jpeg_querycap,
since this driver is used for both encoder and decoder.
-Drop buffer index out of range check from mxc_jpeg_qbuf,
since it is done inside vb2_queue_or_prepare_buf.
In fact, drop mxc_jpeg_qbuf alltogether, just use v4l2_m2m_ioctl_qbuf.
-Move the setting of V4L2_FIELD_NONE from to mxc_jpeg_dqbuf
to mxc_jpeg_buf_prepare()
-Replace mxc_jpeg_try_decoder_cmd with v4l2_m2m_ioctl_try_decoder_cmd
Also replace mxc_jpeg_try_encoder_cmd with v4l2_m2m_ioctl_try_encoder_cmd

Changes in v7:
Add print_mxc_buf() to replace print_buf_preview() and print_nbuf_to_eoi(), and inside, use the print_hex_dump() from printk.h, also, print all the planes.

Changes in v5:
Fixes after feedback from Laurentiu, Hans:
Properly indented data blocks for encoder configuration stream
one tab to the right.
Remove fourcc_to_str, instead just print the format directly (%c%c%c%c)
Use the "debug" module parameter instead of "mxc_jpeg_tracing".
Change return type for get_byte function (end of jpeg stream was not properly detected, visible only with corrupted stream)
Use NULL instead of 0 for NULL pointers.
Add a check to exit jpeg parse if stream does not start with SOI (slow run on v4l2-compliance streaming tests otherwise, the same problem was fixed in jpeg helpers) Change compatible name to match patch 3
Fix colorspace information to sRGB for both output & capture (latest v4l2-compliance fail)
Squashed patch 7 (v4l2-compliance streaming test fix for decoder)

Changes in v4:
The main change is using the common jpeg helpers in imx-jpeg (feedback from Ezequiel) Patch 7 - new, fixed a problem with v4l2-compliance streaming tests on decoder small update: VFL_TYPE_VIDEO-> VFL_TYPE_GRABBER and 2 typos

Changes in v2:
Fix v4l2-compliance streaming tests, "v4l2-compliance -s"

Fixup some whitespaces in mxc_jpeg_ioctl_ops.
Fixed one inconsistent indentation reported by kernel test robot

 drivers/media/platform/Kconfig                |    2 +
 drivers/media/platform/Makefile               |    1 +
 drivers/media/platform/imx-jpeg/Kconfig       |   11 +
 drivers/media/platform/imx-jpeg/Makefile      |    3 +
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c |  168 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h |  140 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg.c    | 2122 +++++++++++++++++
 drivers/media/platform/imx-jpeg/mxc-jpeg.h    |  180 ++
 8 files changed, 2627 insertions(+)
 create mode 100644 drivers/media/platform/imx-jpeg/Kconfig
 create mode 100644 drivers/media/platform/imx-jpeg/Makefile
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.h
drivers/media/platform/Kconfig +2 -0
index 1ddb5d6354cf..ac07db1a5104 100644
@@ -239,6 +239,8 @@ config VIDEO_IMX_PXP
 	  The i.MX Pixel Pipeline is a memory-to-memory engine for scaling,
 	  color space conversion, and rotation.
 
+source "drivers/media/platform/imx-jpeg/Kconfig"
+
 config VIDEO_MEDIATEK_JPEG
 	tristate "Mediatek JPEG Codec driver"
 	depends on MTK_IOMMU_V1 || MTK_IOMMU || COMPILE_TEST
drivers/media/platform/Makefile +1 -0
index 9d4d6370908d..eedc14aafb32 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_VIDEO_MX2_EMMAPRP)		+= mx2_emmaprp.o
 obj-$(CONFIG_VIDEO_CODA)		+= coda/
 
 obj-$(CONFIG_VIDEO_IMX_PXP)		+= imx-pxp.o
+obj-$(CONFIG_VIDEO_IMX8_JPEG)		+= imx-jpeg/
 
 obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)	+= m2m-deinterlace.o
 
drivers/media/platform/imx-jpeg/Kconfig new file +11 -0
new file mode 100644
index 000000000000..d875f7c88cda
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+config VIDEO_IMX8_JPEG
+	tristate "IMX8 JPEG Encoder/Decoder"
+	depends on VIDEO_DEV && VIDEO_V4L2
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	select V4L2_JPEG_HELPER
+	default m
+	help
+	  This is a video4linux2 driver for the i.MX8 QXP/QM integrated
+	  JPEG encoder/decoder.
drivers/media/platform/imx-jpeg/Makefile new file +3 -0
new file mode 100644
index 000000000000..bf19c82e61b4
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+mxc-jpeg-encdec-objs := mxc-jpeg-hw.o mxc-jpeg.o
+obj-$(CONFIG_VIDEO_IMX8_JPEG) += mxc-jpeg-encdec.o
drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c new file +168 -0

168 lines not on this page · raw message

drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h new file +140 -0

140 lines not on this page · raw message

drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +2122 -0

2,122 lines not on this page · raw message

drivers/media/platform/imx-jpeg/mxc-jpeg.h new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

Thank you for the patch! Perhaps something to improve:

Hi "Mirela,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on shawnguo/for-next robh/for-next linus/master v5.12-rc2 next-20210310] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mirela-Rabulea-OSS/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210311-083324
base:   git://linuxtv.org/media_tree.git master
config: microblaze-randconfig-r021-20210308 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c6db61a15ca1a173f200f4a2344b3198652d64a6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mirela-Rabulea-OSS/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210311-083324 git checkout c6db61a15ca1a173f200f4a2344b3198652d64a6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/media/platform/imx-jpeg/mxc-jpeg.c: In function 'mxc_jpeg_probe':

>> drivers/media/platform/imx-jpeg/mxc-jpeg.c:1967:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    1967 |  mode = (int)(u64)of_id->data;
         |              ^

vim +1967 drivers/media/platform/imx-jpeg/mxc-jpeg.c

1954
1955 static int mxc_jpeg_probe(struct platform_device *pdev)
1956 {
1957 struct mxc_jpeg_dev *jpeg;
1958 struct device *dev = &pdev->dev;
1959 struct resource *res;
1960 int dec_irq;
1961 int ret;
1962 int mode;
1963 const struct of_device_id *of_id;
1964 unsigned int slot;
1965
1966 of_id = of_match_node(mxc_jpeg_match, dev->of_node);

> 1967		mode = (int)(u64)of_id->data;
  1968	
  1969		jpeg = devm_kzalloc(dev, sizeof(struct mxc_jpeg_dev), GFP_KERNEL);
  1970		if (!jpeg)
  1971			return -ENOMEM;
  1972	
  1973		mutex_init(&jpeg->lock);
  1974		spin_lock_init(&jpeg->hw_lock);
  1975	
  1976		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
  1977		if (ret) {
  1978			dev_err(&pdev->dev, "No suitable DMA available.\n");
  1979			goto err_irq;
  1980		}
  1981	
  1982		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1983		jpeg->base_reg = devm_ioremap_resource(&pdev->dev, res);
  1984		if (IS_ERR(jpeg->base_reg))
  1985			return PTR_ERR(jpeg->base_reg);
  1986	
  1987		for (slot = 0; slot < MXC_MAX_SLOTS; slot++) {
  1988			dec_irq = platform_get_irq(pdev, slot);
  1989			if (dec_irq < 0) {
  1990				dev_err(&pdev->dev, "Failed to get irq %d\n", dec_irq);
  1991				ret = dec_irq;
  1992				goto err_irq;
  1993			}
  1994			ret = devm_request_irq(&pdev->dev, dec_irq, mxc_jpeg_dec_irq,
  1995					       0, pdev->name, jpeg);
  1996			if (ret) {
  1997				dev_err(&pdev->dev, "Failed to request irq %d (%d)\n",
  1998					dec_irq, ret);
  1999				goto err_irq;
  2000			}
  2001		}
  2002	
  2003		jpeg->pdev = pdev;
  2004		jpeg->dev = dev;
  2005		jpeg->mode = mode;
  2006	
  2007		ret = mxc_jpeg_attach_pm_domains(jpeg);
  2008		if (ret < 0) {
  2009			dev_err(dev, "failed to attach power domains %d\n", ret);
  2010			return ret;
  2011		}
  2012	
  2013		/* v4l2 */
  2014		ret = v4l2_device_register(dev, &jpeg->v4l2_dev);
  2015		if (ret) {
  2016			dev_err(dev, "failed to register v4l2 device\n");
  2017			goto err_register;
  2018		}
  2019		jpeg->m2m_dev = v4l2_m2m_init(&mxc_jpeg_m2m_ops);
  2020		if (IS_ERR(jpeg->m2m_dev)) {
  2021			dev_err(dev, "failed to register v4l2 device\n");
  2022			goto err_m2m;
  2023		}
  2024	
  2025		jpeg->dec_vdev = video_device_alloc();
  2026		if (!jpeg->dec_vdev) {
  2027			dev_err(dev, "failed to register v4l2 device\n");
  2028			goto err_vdev_alloc;
  2029		}
  2030		if (mode == MXC_JPEG_ENCODE)
  2031			snprintf(jpeg->dec_vdev->name,
  2032				 sizeof(jpeg->dec_vdev->name),
  2033				 "%s-enc", MXC_JPEG_NAME);
  2034		else
  2035			snprintf(jpeg->dec_vdev->name,
  2036				 sizeof(jpeg->dec_vdev->name),
  2037				 "%s-dec", MXC_JPEG_NAME);
  2038	
  2039		jpeg->dec_vdev->fops = &mxc_jpeg_fops;
  2040		jpeg->dec_vdev->ioctl_ops = &mxc_jpeg_ioctl_ops;
  2041		jpeg->dec_vdev->minor = -1;
  2042		jpeg->dec_vdev->release = video_device_release;
  2043		jpeg->dec_vdev->lock = &jpeg->lock; /* lock for ioctl serialization */
  2044		jpeg->dec_vdev->v4l2_dev = &jpeg->v4l2_dev;
  2045		jpeg->dec_vdev->vfl_dir = VFL_DIR_M2M;
  2046		jpeg->dec_vdev->device_caps = V4L2_CAP_STREAMING |
  2047						V4L2_CAP_VIDEO_M2M_MPLANE;
  2048		if (mode == MXC_JPEG_ENCODE) {
  2049			v4l2_disable_ioctl(jpeg->dec_vdev, VIDIOC_DECODER_CMD);
  2050			v4l2_disable_ioctl(jpeg->dec_vdev, VIDIOC_TRY_DECODER_CMD);
  2051		} else {
  2052			v4l2_disable_ioctl(jpeg->dec_vdev, VIDIOC_ENCODER_CMD);
  2053			v4l2_disable_ioctl(jpeg->dec_vdev, VIDIOC_TRY_ENCODER_CMD);
  2054		}
  2055		ret = video_register_device(jpeg->dec_vdev, VFL_TYPE_VIDEO, -1);
  2056		if (ret) {
  2057			dev_err(dev, "failed to register video device\n");
  2058			goto err_vdev_register;
  2059		}
  2060		video_set_drvdata(jpeg->dec_vdev, jpeg);
  2061		if (mode == MXC_JPEG_ENCODE)
  2062			v4l2_info(&jpeg->v4l2_dev,
  2063				  "encoder device registered as /dev/video%d (%d,%d)\n",
  2064				  jpeg->dec_vdev->num, VIDEO_MAJOR,
  2065				  jpeg->dec_vdev->minor);
  2066		else
  2067			v4l2_info(&jpeg->v4l2_dev,
  2068				  "decoder device registered as /dev/video%d (%d,%d)\n",
  2069				  jpeg->dec_vdev->num, VIDEO_MAJOR,
  2070				  jpeg->dec_vdev->minor);

2071
2072 platform_set_drvdata(pdev, jpeg);
2073
2074 return 0;
2075
2076 err_vdev_register:
2077 video_device_release(jpeg->dec_vdev);
2078
2079 err_vdev_alloc:
2080 v4l2_m2m_release(jpeg->m2m_dev);
2081
2082 err_m2m:
2083 v4l2_device_unregister(&jpeg->v4l2_dev);
2084
2085 err_register:
2086 err_irq:
2087 return ret;
2088 }
2089

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw

Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

In reply to Mirela Rabulea (OSS)

Hi Mirela,

On 11/03/2021 01:28, Mirela Rabulea (OSS) wrote:

<snip>

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 147

Quoted 4 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +4 -0
+static const struct of_device_id mxc_jpeg_match[] = {
+	{
+		.compatible = "nxp,imx8qxp-jpgdec",
+		.data       = (void *)MXC_JPEG_DECODE,

Don't do this, just say:

static const int mxc_decode_mode = MXC_JPEG_DECODE; static const int mxc_encode_mode = MXC_JPEG_ENCODE;

and point to that:

		.data = &mxc_decode_mode;

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 151

Quoted 4 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +4 -0
+	},
+	{
+		.compatible = "nxp,imx8qxp-jpgenc",
+		.data       = (void *)MXC_JPEG_ENCODE,
		.data = &mxc_encode_mode;
Quoted 3 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +3 -0
+	},
+	{ },
+};

<snip>

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 1967

Quoted 13 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +13 -0
+static int mxc_jpeg_probe(struct platform_device *pdev)
+{
+	struct mxc_jpeg_dev *jpeg;
+	struct device *dev = &pdev->dev;
+	struct resource *res;
+	int dec_irq;
+	int ret;
+	int mode;
+	const struct of_device_id *of_id;
+	unsigned int slot;
+
+	of_id = of_match_node(mxc_jpeg_match, dev->of_node);
+	mode = (int)(u64)of_id->data;

and this becomes:

	mode = *(const int *)of_id->data;

This will solve the kernel test robot warning, and for that matter the same gcc warnings I get when I compile.

Just post a v9.1 for this patch, everything else looks good.

Regards,

Hans

maintainer
#9 lore raw

Re: [EXT] Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

Quoted 51 lines · Hans Verkuil

Caution: EXT Email

Hi Mirela,

On 11/03/2021 01:28, Mirela Rabulea (OSS) wrote:

<snip>

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 147

Quoted 4 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +4 -0
+static const struct of_device_id mxc_jpeg_match[] = {
+     {
+             .compatible = "nxp,imx8qxp-jpgdec",
+             .data       = (void *)MXC_JPEG_DECODE,

Don't do this, just say:

static const int mxc_decode_mode = MXC_JPEG_DECODE; static const int mxc_encode_mode = MXC_JPEG_ENCODE;

and point to that:

                .data = &mxc_decode_mode;

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 151

Quoted 4 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +4 -0
+     },
+     {
+             .compatible = "nxp,imx8qxp-jpgenc",
+             .data       = (void *)MXC_JPEG_ENCODE,
                .data = &mxc_encode_mode;
Quoted 3 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +3 -0
+     },
+     { },
+};

<snip>

drivers/media/platform/imx-jpeg/mxc-jpeg.c line 1967

Quoted 13 lines
drivers/media/platform/imx-jpeg/mxc-jpeg.c new file +13 -0
+static int mxc_jpeg_probe(struct platform_device *pdev)
+{
+     struct mxc_jpeg_dev *jpeg;
+     struct device *dev = &pdev->dev;
+     struct resource *res;
+     int dec_irq;
+     int ret;
+     int mode;
+     const struct of_device_id *of_id;
+     unsigned int slot;
+
+     of_id = of_match_node(mxc_jpeg_match, dev->of_node);
+     mode = (int)(u64)of_id->data;

and this becomes:

Quoted 4 lines
        mode = *(const int *)of_id->data;

This will solve the kernel test robot warning, and for that matter the same gcc warnings I get when I compile.

Hi Hans,
thanks for the suggestion, I missed that warning among the verbosity from the other ones. Perhaps for the future it would be usefull for me to try and replicate the kernel test robot environment.

I sent v9.1 just for this patch.

Regards,
Mirela

Quoted 6 lines

Just post a v9.1 for this patch, everything else looks good.

Regards,

Hans

#10 lore raw

PATCH v9 7/8 arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

Add jpeg decoder/encoder nodes, for now on imx8qxp only. The same should work on imx8qm, but it was not tested.

---
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm64/boot/dts/freescale/imx8qxp.dtsi +35 -0
index 1d522de7b017..4f2b3edd7850 100644
@@ -629,4 +629,39 @@
 			};
 		};
 	};
+
+	img_subsys: bus@58000000 {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0x58000000 0x0 0x58000000 0x1000000>;
+
+		jpegdec: jpegdec@58400000 {
+			compatible = "nxp,imx8qxp-jpgdec";
+			reg = <0x58400000 0x00050000 >;
+			interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>,
+					<&pd IMX_SC_R_MJPEG_DEC_S0>,
+					<&pd IMX_SC_R_MJPEG_DEC_S1>,
+					<&pd IMX_SC_R_MJPEG_DEC_S2>,
+					<&pd IMX_SC_R_MJPEG_DEC_S3>;
+		};
+
+		jpegenc: jpegenc@58450000 {
+			compatible = "nxp,imx8qxp-jpgenc";
+			reg = <0x58450000 0x00050000 >;
+			interrupts = <GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 306 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>,
+					<&pd IMX_SC_R_MJPEG_ENC_S0>,
+					<&pd IMX_SC_R_MJPEG_ENC_S1>,
+					<&pd IMX_SC_R_MJPEG_ENC_S2>,
+					<&pd IMX_SC_R_MJPEG_ENC_S3>;
+		};
+	};
 };
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH v9 7/8] arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes

Hi Mirela,

Quoted 4 lines · Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

Add jpeg decoder/encoder nodes, for now on imx8qxp only. The same should work on imx8qm, but it was not tested.

FYI: I've posted a pull request for this driver, and once it is merged in our media tree this patch can be merged for 5.13 by whoever handles these dts patches.

Thank you for all your work on this!

Regards,

Hans

Quoted 51 lines
---
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm64/boot/dts/freescale/imx8qxp.dtsi +35 -0
index 1d522de7b017..4f2b3edd7850 100644
@@ -629,4 +629,39 @@
 			};
 		};
 	};
+
+	img_subsys: bus@58000000 {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0x58000000 0x0 0x58000000 0x1000000>;
+
+		jpegdec: jpegdec@58400000 {
+			compatible = "nxp,imx8qxp-jpgdec";
+			reg = <0x58400000 0x00050000 >;
+			interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>,
+					<&pd IMX_SC_R_MJPEG_DEC_S0>,
+					<&pd IMX_SC_R_MJPEG_DEC_S1>,
+					<&pd IMX_SC_R_MJPEG_DEC_S2>,
+					<&pd IMX_SC_R_MJPEG_DEC_S3>;
+		};
+
+		jpegenc: jpegenc@58450000 {
+			compatible = "nxp,imx8qxp-jpgenc";
+			reg = <0x58450000 0x00050000 >;
+			interrupts = <GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 306 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>,
+					<&pd IMX_SC_R_MJPEG_ENC_S0>,
+					<&pd IMX_SC_R_MJPEG_ENC_S1>,
+					<&pd IMX_SC_R_MJPEG_ENC_S2>,
+					<&pd IMX_SC_R_MJPEG_ENC_S3>;
+		};
+	};
 };
#12 lore raw

RE: [PATCH v9 7/8] arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes

In reply to Mirela Rabulea (OSS)
Quoted 7 lines

From: Mirela Rabulea (OSS) <[email protected]>
Sent: Thursday, March 11, 2021 8:29 AM

Add jpeg decoder/encoder nodes, for now on imx8qxp only. The same should work on imx8qm, but it was not tested.

Please rebase to latest shawn/for-next branch and add the necessary clocks.
I can help review when resend.

Regards
Aisheng

Quoted 52 lines
---
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 35
++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm64/boot/dts/freescale/imx8qxp.dtsi +35 -1
index 1d522de7b017..4f2b3edd7850 100644
@@ -629,4 +629,39 @@
 			};
 		};
 	};
+
+	img_subsys: bus@58000000 {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0x58000000 0x0 0x58000000 0x1000000>;
+
+		jpegdec: jpegdec@58400000 {
+			compatible = "nxp,imx8qxp-jpgdec";
+			reg = <0x58400000 0x00050000 >;
+			interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_DEC_MP>,
+					<&pd IMX_SC_R_MJPEG_DEC_S0>,
+					<&pd IMX_SC_R_MJPEG_DEC_S1>,
+					<&pd IMX_SC_R_MJPEG_DEC_S2>,
+					<&pd IMX_SC_R_MJPEG_DEC_S3>;
+		};
+
+		jpegenc: jpegenc@58450000 {
+			compatible = "nxp,imx8qxp-jpgenc";
+			reg = <0x58450000 0x00050000 >;
+			interrupts = <GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 306 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pd IMX_SC_R_MJPEG_ENC_MP>,
+					<&pd IMX_SC_R_MJPEG_ENC_S0>,
+					<&pd IMX_SC_R_MJPEG_ENC_S1>,
+					<&pd IMX_SC_R_MJPEG_ENC_S2>,
+					<&pd IMX_SC_R_MJPEG_ENC_S3>;
+		};
+	};
 };
--

2.17.1

#13 lore raw

PATCH v9 8/8 Add maintainer for IMX jpeg v4l2 driver

In reply to Mirela Rabulea (OSS)

From: Mirela Rabulea <[email protected]>

The driver is located in drivers/media/platform/imx-jpeg, and it applies to the JPEG decoder from i.MX QXP and QM.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index f032f45bc951..37adf5783725 100644
@@ -12923,6 +12923,14 @@ L:	[email protected] (moderated for non-subscribers)
 S:	Supported
 F:	drivers/nfc/nxp-nci
 
+NXP i.MX 8QXP/8QM JPEG V4L2 DRIVER
+M:	Mirela Rabulea <[email protected]>
+R:	NXP Linux Team <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/imx8-jpeg.yaml
+F:	drivers/media/platform/imx-jpeg
+
 OBJAGG
 M:	Jiri Pirko <[email protected]>
 L:	[email protected]
Signature · 1 line
2.17.1