Add V4L2 driver for i.MX8 JPEG Encoder/Decoder
Subsystems (4)
v8 cover Add V4L2 driver for i.MX8 JPEG Encoder/Decoder
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@imx8qxpc0mek:/unit_tests/JPEG# ./v4l2-compliance -d /dev/video0 -s v4l2-compliance 1.21.0-4707, 64 bits, 64-bit time_t v4l2-compliance SHA: bf8d28efe5a3 2021-02-17 14:52:38
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 : 1291.0.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@imx8qxpc0mek:/unit_tests/JPEG# ./v4l2-compliance -d /dev/video1 -s v4l2-compliance 1.21.0-4707, 64 bits, 64-bit time_t v4l2-compliance SHA: bf8d28efe5a3 2021-02-17 14:52:38
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 : 1291.0.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 (9):
media: v4l: Add packed YUV444 24bpp pixel format
media: dt-bindings: Add bindings for i.MX8QXP/QM JPEG driver
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
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: Use v4l2 jpeg helpers in mxc-jpeg
.../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 | 2117 +++++++++++++++++ drivers/media/platform/imx-jpeg/mxc-jpeg.h | 180 ++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/media/v4l2-core/v4l2-jpeg.c | 59 +- include/media/v4l2-jpeg.h | 20 + include/uapi/linux/videodev2.h | 1 + 16 files changed, 2833 insertions(+), 7 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.25.1
PATCH v8 1/9 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
@@ -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
@@ -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
@@ -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.25.1
PATCH v8 2/9 media: dt-bindings: Add bindings for i.MX8QXP/QM JPEG driver
In reply to Mirela RabuleaFrom: 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
@@ -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.25.1
PATCH v8 3/9 media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder
In reply to Mirela RabuleaFrom: 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 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
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 | 10 + 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 | 2241 +++++++++++++++++ drivers/media/platform/imx-jpeg/mxc-jpeg.h | 184 ++ 8 files changed, 2749 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
@@ -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
@@ -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 +10 -0
@@ -0,0 +1,10 @@ +# 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 + 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
@@ -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 +2241 -0
2,241 lines not on this page · raw message
drivers/media/platform/imx-jpeg/mxc-jpeg.h new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v8 3/9] 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 robh/for-next linus/master v5.11 next-20210222] [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/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210223-031832 base: git://linuxtv.org/media_tree.git master config: i386-randconfig-s001-20210222 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.3-229-g60c1f270-dirty # https://github.com/0day-ci/linux/commit/6e821067180472a0ae64a91440bd234c86040310 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mirela-Rabulea/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210223-031832 git checkout 6e821067180472a0ae64a91440bd234c86040310 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/printk.h:409,
from include/linux/kernel.h:16,
from drivers/media/platform/imx-jpeg/mxc-jpeg.c:43:
drivers/media/platform/imx-jpeg/mxc-jpeg.c: In function 'mxc_jpeg_config_enc_desc':
>> drivers/media/platform/imx-jpeg/mxc-jpeg.c:891:21: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'dma_addr_t' {aka 'unsigned int'} [-Wformat=]
891 | dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle);
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:129:15: note: in definition of macro '__dynamic_func_call'
129 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:161:2: note: in expansion of macro '_dynamic_func_call'
161 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:2: note: in expansion of macro 'dynamic_dev_dbg'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:23: note: in expansion of macro 'dev_fmt'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/media/platform/imx-jpeg/mxc-jpeg.c:891:2: note: in expansion of macro 'dev_dbg'
891 | dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle);
| ^~~~~~~
drivers/media/platform/imx-jpeg/mxc-jpeg.c:891:38: note: format string is defined here
891 | dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle);
| ~~~^
| |
| long long unsigned int
| %x
In file included from include/linux/printk.h:409,
from include/linux/kernel.h:16,
from drivers/media/platform/imx-jpeg/mxc-jpeg.c:43:
drivers/media/platform/imx-jpeg/mxc-jpeg.c:893:21: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'dma_addr_t' {aka 'unsigned int'} [-Wformat=]
893 | dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:129:15: note: in definition of macro '__dynamic_func_call'
129 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:161:2: note: in expansion of macro '_dynamic_func_call'
161 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:2: note: in expansion of macro 'dynamic_dev_dbg'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:23: note: in expansion of macro 'dev_fmt'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/media/platform/imx-jpeg/mxc-jpeg.c:893:2: note: in expansion of macro 'dev_dbg'
893 | dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
| ^~~~~~~
drivers/media/platform/imx-jpeg/mxc-jpeg.c:893:38: note: format string is defined here
893 | dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
| ~~~^
| |
| long long unsigned int
| %x
drivers/media/platform/imx-jpeg/mxc-jpeg.c: In function 'mxc_jpeg_probe':
>> drivers/media/platform/imx-jpeg/mxc-jpeg.c:2086:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2086 | mode = (int)(u64)of_id->data;
| ^vim +891 drivers/media/platform/imx-jpeg/mxc-jpeg.c
840
841 static void mxc_jpeg_config_enc_desc(struct vb2_buffer *out_buf,
842 struct mxc_jpeg_ctx *ctx,
843 struct vb2_buffer *src_buf,
844 struct vb2_buffer *dst_buf)
845 {
846 struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
847 void __iomem *reg = jpeg->base_reg;
848 unsigned int slot = ctx->slot;
849 struct mxc_jpeg_desc *desc = jpeg->slot_data[slot].desc;
850 struct mxc_jpeg_desc *cfg_desc = jpeg->slot_data[slot].cfg_desc;
851 dma_addr_t desc_handle = jpeg->slot_data[slot].desc_handle;
852 dma_addr_t cfg_desc_handle = jpeg->slot_data[slot].cfg_desc_handle;
853 void *cfg_stream_vaddr = jpeg->slot_data[slot].cfg_stream_vaddr;
854 struct mxc_jpeg_q_data *q_data;
855 enum mxc_jpeg_image_format img_fmt;
856 int w, h;
857
858 q_data = mxc_jpeg_get_q_data(ctx, src_buf->vb2_queue->type);
859
860 jpeg->slot_data[slot].cfg_stream_size =
861 mxc_jpeg_setup_cfg_stream(cfg_stream_vaddr,
862 q_data->fmt->fourcc,
863 q_data->w_adjusted,
864 q_data->h_adjusted);
865
866 /* chain the config descriptor with the encoding descriptor */
867 cfg_desc->next_descpt_ptr = desc_handle | MXC_NXT_DESCPT_EN;
868
869 cfg_desc->buf_base0 = jpeg->slot_data[slot].cfg_stream_handle;
870 cfg_desc->buf_base1 = 0;
871 cfg_desc->line_pitch = 0;
872 cfg_desc->stm_bufbase = 0; /* no output expected */
873 cfg_desc->stm_bufsize = 0x0;
874 cfg_desc->imgsize = 0;
875 cfg_desc->stm_ctrl = STM_CTRL_CONFIG_MOD(1);
876
877 desc->next_descpt_ptr = 0; /* end of chain */
878
879 /* use adjusted resolution for CAST IP job */
880 w = q_data->w_adjusted;
881 h = q_data->h_adjusted;
882 mxc_jpeg_set_res(desc, w, h);
883 mxc_jpeg_set_line_pitch(desc, w * (q_data->fmt->depth / 8));
884 mxc_jpeg_set_bufsize(desc, desc->line_pitch * h);
885 img_fmt = mxc_jpeg_fourcc_to_imgfmt(q_data->fmt->fourcc);
886 if (img_fmt == MXC_JPEG_INVALID)
887 dev_err(jpeg->dev, "No valid image format detected\n");
888 desc->stm_ctrl = STM_CTRL_CONFIG_MOD(0) |
889 STM_CTRL_IMAGE_FORMAT(img_fmt);
890 mxc_jpeg_addrs(desc, src_buf, dst_buf, 0);
> 891 dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle); 892 print_descriptor_info(jpeg->dev, cfg_desc);
893 dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
894 print_descriptor_info(jpeg->dev, desc);
895 print_wrapper_info(jpeg->dev, reg);
896 print_cast_status(jpeg->dev, reg, MXC_JPEG_ENCODE);
897
898 /* validate the configuration descriptor */
899 mxc_jpeg_set_desc(cfg_desc_handle, reg, slot);
900 }
901
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH v8 3/9] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder
In reply to Mirela RabuleaThank 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-rc1 next-20210303] [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/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210223-031832 base: git://linuxtv.org/media_tree.git master config: powerpc64-randconfig-r004-20210303 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a7cad6680b4087eff8994f1f99ac40c661a6621f)
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
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/6e821067180472a0ae64a91440bd234c86040310
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mirela-Rabulea/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210223-031832 git checkout 6e821067180472a0ae64a91440bd234c86040310
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:236:1: note: expanded from here
__do_insb
^
arch/powerpc/include/asm/io.h:556:56: note: expanded from macro '__do_insb'
#define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:238:1: note: expanded from here
__do_insw
^
arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:240:1: note: expanded from here
__do_insl
^
arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:3:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:5:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
In file included from drivers/media/platform/imx-jpeg/mxc-jpeg.c:45:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:619:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
__do_##name al; \
^~~~~~~~~~~~~~
<scratch space>:7:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~~~~~~~~~~~~~~~~~^
>> drivers/media/platform/imx-jpeg/mxc-jpeg.c:891:45: warning: format specifies type 'unsigned long long' but the argument has type 'dma_addr_t' (aka 'unsigned int') [-Wformat]
dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle);
~~~~ ^~~~~~~~~~~~~~~
%x
include/linux/dev_printk.h:123:39: note: expanded from macro 'dev_dbg'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dynamic_debug.h:162:19: note: expanded from macro 'dynamic_dev_dbg'
dev, fmt, ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dynamic_debug.h:147:56: note: expanded from macro '_dynamic_func_call'
__dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:129:15: note: expanded from macro '__dynamic_func_call'
func(&id, ##__VA_ARGS__); \
^~~~~~~~~~~
drivers/media/platform/imx-jpeg/mxc-jpeg.c:893:45: warning: format specifies type 'unsigned long long' but the argument has type 'dma_addr_t' (aka 'unsigned int') [-Wformat]
dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
~~~~ ^~~~~~~~~~~
%x
include/linux/dev_printk.h:123:39: note: expanded from macro 'dev_dbg'
dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dynamic_debug.h:162:19: note: expanded from macro 'dynamic_dev_dbg'
dev, fmt, ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dynamic_debug.h:147:56: note: expanded from macro '_dynamic_func_call'
__dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/dynamic_debug.h:129:15: note: expanded from macro '__dynamic_func_call'
func(&id, ##__VA_ARGS__); \
^~~~~~~~~~~8 warnings generated.
vim +891 drivers/media/platform/imx-jpeg/mxc-jpeg.c
840
841 static void mxc_jpeg_config_enc_desc(struct vb2_buffer *out_buf,
842 struct mxc_jpeg_ctx *ctx,
843 struct vb2_buffer *src_buf,
844 struct vb2_buffer *dst_buf)
845 {
846 struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
847 void __iomem *reg = jpeg->base_reg;
848 unsigned int slot = ctx->slot;
849 struct mxc_jpeg_desc *desc = jpeg->slot_data[slot].desc;
850 struct mxc_jpeg_desc *cfg_desc = jpeg->slot_data[slot].cfg_desc;
851 dma_addr_t desc_handle = jpeg->slot_data[slot].desc_handle;
852 dma_addr_t cfg_desc_handle = jpeg->slot_data[slot].cfg_desc_handle;
853 void *cfg_stream_vaddr = jpeg->slot_data[slot].cfg_stream_vaddr;
854 struct mxc_jpeg_q_data *q_data;
855 enum mxc_jpeg_image_format img_fmt;
856 int w, h;
857
858 q_data = mxc_jpeg_get_q_data(ctx, src_buf->vb2_queue->type);
859
860 jpeg->slot_data[slot].cfg_stream_size =
861 mxc_jpeg_setup_cfg_stream(cfg_stream_vaddr,
862 q_data->fmt->fourcc,
863 q_data->w_adjusted,
864 q_data->h_adjusted);
865
866 /* chain the config descriptor with the encoding descriptor */
867 cfg_desc->next_descpt_ptr = desc_handle | MXC_NXT_DESCPT_EN;
868
869 cfg_desc->buf_base0 = jpeg->slot_data[slot].cfg_stream_handle;
870 cfg_desc->buf_base1 = 0;
871 cfg_desc->line_pitch = 0;
872 cfg_desc->stm_bufbase = 0; /* no output expected */
873 cfg_desc->stm_bufsize = 0x0;
874 cfg_desc->imgsize = 0;
875 cfg_desc->stm_ctrl = STM_CTRL_CONFIG_MOD(1);
876
877 desc->next_descpt_ptr = 0; /* end of chain */
878
879 /* use adjusted resolution for CAST IP job */
880 w = q_data->w_adjusted;
881 h = q_data->h_adjusted;
882 mxc_jpeg_set_res(desc, w, h);
883 mxc_jpeg_set_line_pitch(desc, w * (q_data->fmt->depth / 8));
884 mxc_jpeg_set_bufsize(desc, desc->line_pitch * h);
885 img_fmt = mxc_jpeg_fourcc_to_imgfmt(q_data->fmt->fourcc);
886 if (img_fmt == MXC_JPEG_INVALID)
887 dev_err(jpeg->dev, "No valid image format detected\n");
888 desc->stm_ctrl = STM_CTRL_CONFIG_MOD(0) |
889 STM_CTRL_IMAGE_FORMAT(img_fmt);
890 mxc_jpeg_addrs(desc, src_buf, dst_buf, 0);
> 891 dev_dbg(jpeg->dev, "cfg_desc - 0x%llx:\n", cfg_desc_handle); 892 print_descriptor_info(jpeg->dev, cfg_desc);
893 dev_dbg(jpeg->dev, "enc desc - 0x%llx:\n", desc_handle);
894 print_descriptor_info(jpeg->dev, desc);
895 print_wrapper_info(jpeg->dev, reg);
896 print_cast_status(jpeg->dev, reg, MXC_JPEG_ENCODE);
897
898 /* validate the configuration descriptor */
899 mxc_jpeg_set_desc(cfg_desc_handle, reg, slot);
900 }
901
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v8 4/9 arm64: dts: imx8qxp: Add jpeg encoder/decoder nodes
In reply to Mirela RabuleaFrom: 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
@@ -629,4 +629,39 @@ map0 { }; }; }; + + 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.25.1
PATCH v8 5/9 Add maintainer for IMX jpeg v4l2 driver
In reply to Mirela RabuleaFrom: 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
@@ -12911,6 +12911,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.25.1
PATCH v8 6/9 media: Add parsing for APP14 data segment in jpeg helpers
In reply to Mirela RabuleaFrom: 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.
---
Changes in v8:
Simplified end of jpeg_parse_app14_data, and added one more comment Added Reviewed-by: Philipp Zabel <[email protected]>
drivers/media/v4l2-core/v4l2-jpeg.c | 44 +++++++++++++++++++++++++++-- include/media/v4l2-jpeg.h | 20 +++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-jpeg.c +42 -2
@@ -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,8 +445,41 @@ 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); +} +/** -* jpeg_parse_header - locate marker segments and optionally parse headers +* v4l2_jpeg_parse_header - locate marker segments and optionally parse headers * @buf: address of the JPEG buffer, should start with a SOI marker * @len: length of the JPEG buffer * @out: returns marker segment positions and optionally parsed headers
@@ -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
@@ -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.25.1
PATCH v8 7/9 media: Quit parsing stream if doesn't start with SOI
In reply to Mirela RabuleaFrom: 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
@@ -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.25.1
PATCH v8 8/9 media: Avoid parsing quantization and huffman tables
In reply to Mirela RabuleaFrom: 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
@@ -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.25.1
PATCH v8 9/9 media: imx-jpeg: Use v4l2 jpeg helpers in mxc-jpeg
In reply to Mirela RabuleaFrom: Mirela Rabulea <[email protected]>
Use v4l2_jpeg_parse_header in mxc_jpeg_parse, remove the old parsing way, which was duplicated in other jpeg drivers.
---
Changes in v8:
Move the app14_tf fixup in mxc_jpeg_get_image_format() and let this function
return the correct format
Print subsampling and number of components in case fourcc couldn't be identified Added Reviewed-by: Philipp Zabel <[email protected]>
drivers/media/platform/imx-jpeg/Kconfig | 1 + drivers/media/platform/imx-jpeg/mxc-jpeg.c | 284 ++++++--------------- drivers/media/platform/imx-jpeg/mxc-jpeg.h | 26 +- 3 files changed, 92 insertions(+), 219 deletions(-)
drivers/media/platform/imx-jpeg/Kconfig +1 -0
@@ -4,6 +4,7 @@ config VIDEO_IMX8_JPEG 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
drivers/media/platform/imx-jpeg/mxc-jpeg.c +80 -204
404 lines not on this page · raw message
drivers/media/platform/imx-jpeg/mxc-jpeg.h +11 -15
@@ -42,6 +42,8 @@ enum mxc_jpeg_mode {* struct jpeg_fmt - driver's internal color format data * @name: format description * @fourcc: fourcc code, 0 if not applicable +* @subsampling subsampling of jpeg components +* @nc: number of color components * @depth: number of bits per pixel * @colplanes: number of color planes (1 for packed formats) * @h_align: horizontal alignment order (align to 2^h_align)
@@ -49,13 +51,15 @@ enum mxc_jpeg_mode {* @flags: flags describing format applicability */ struct mxc_jpeg_fmt { -char *name; -u32 fourcc; -int depth; -int colplanes; -int h_align; -int v_align; -u32 flags; +char *name; +u32 fourcc; +enum v4l2_jpeg_chroma_subsampling subsampling; +int nc; +int depth; +int colplanes; +int h_align; +int v_align; +u32 flags; };struct mxc_jpeg_desc {
@@ -117,14 +121,6 @@ struct mxc_jpeg_dev {struct device_link **pd_link; }; -/* JPEG marker identifiers */ -#define SOF0 0xC0 -#define SOF1 0xC1 -#define SOF2 0xC2 -#define SOS 0xDA -#define DHT 0xC4 -#define APP14 0xEE -/** * struct mxc_jpeg_sof_comp - JPEG Start Of Frame component fields * @id: component id
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v8 9/9] media: imx-jpeg: Use v4l2 jpeg helpers in mxc-jpeg
I love your patch! Perhaps something to improve:
Hi Mirela,
I love your 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.11 next-20210222] [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/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210223-031832 base: git://linuxtv.org/media_tree.git master config: x86_64-randconfig-m001-20210222 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/media/platform/imx-jpeg/mxc-jpeg.c:1220 mxc_jpeg_parse() warn: inconsistent indenting
vim +1220 drivers/media/platform/imx-jpeg/mxc-jpeg.c
1190
1191 static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx,
1192 u8 *src_addr, u32 size, bool *dht_needed)
1193 {
1194 struct device *dev = ctx->mxc_jpeg->dev;
1195 struct mxc_jpeg_q_data *q_data_out, *q_data_cap;
1196 enum v4l2_buf_type cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1197 bool src_chg = false;
1198 u32 fourcc;
1199 struct v4l2_jpeg_header header;
1200 struct mxc_jpeg_sof *psof = NULL;
1201 struct mxc_jpeg_sos *psos = NULL;
1202 int ret;
1203
1204 memset(&header, 0, sizeof(header));
1205 ret = v4l2_jpeg_parse_header((void *)src_addr, size, &header);
1206 if (ret < 0) {
1207 dev_err(dev, "Error parsing JPEG stream markers\n");
1208 return ret;
1209 }
1210
1211 /* if DHT marker present, no need to inject default one */
1212 *dht_needed = (header.num_dht == 0);
1213
1214 q_data_out = mxc_jpeg_get_q_data(ctx,
1215 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
1216 if (q_data_out->w == 0 && q_data_out->h == 0) {
1217 dev_warn(dev, "Invalid user resolution 0x0");
1218 dev_warn(dev, "Keeping resolution from JPEG: %dx%d",
1219 header.frame.width, header.frame.height);
> 1220 q_data_out->w = header.frame.width;
1221 q_data_out->h = header.frame.height;
1222 } else if (header.frame.width != q_data_out->w ||
1223 header.frame.height != q_data_out->h) {
1224 dev_err(dev,
1225 "Resolution mismatch: %dx%d (JPEG) versus %dx%d(user)",
1226 header.frame.width, header.frame.height,
1227 q_data_out->w, q_data_out->h);
1228 return -EINVAL;
1229 }
1230 if (header.frame.width % 8 != 0 || header.frame.height % 8 != 0) {
1231 dev_err(dev, "JPEG width or height not multiple of 8: %dx%d\n",
1232 header.frame.width, header.frame.height);
1233 return -EINVAL;
1234 }
1235 if (header.frame.width > MXC_JPEG_MAX_WIDTH ||
1236 header.frame.height > MXC_JPEG_MAX_HEIGHT) {
1237 dev_err(dev, "JPEG width or height should be <= 8192: %dx%d\n",
1238 header.frame.width, header.frame.height);
1239 return -EINVAL;
1240 }
1241 if (header.frame.width < MXC_JPEG_MIN_WIDTH ||
1242 header.frame.height < MXC_JPEG_MIN_HEIGHT) {
1243 dev_err(dev, "JPEG width or height should be > 64: %dx%d\n",
1244 header.frame.width, header.frame.height);
1245 return -EINVAL;
1246 }
1247 if (header.frame.num_components > V4L2_JPEG_MAX_COMPONENTS) {
1248 dev_err(dev, "JPEG number of components should be <=%d",
1249 V4L2_JPEG_MAX_COMPONENTS);
1250 return -EINVAL;
1251 }
1252 /* check and, if necessary, patch component IDs*/
1253 psof = (struct mxc_jpeg_sof *)header.sof.start;
1254 psos = (struct mxc_jpeg_sos *)header.sos.start;
1255 if (!mxc_jpeg_valid_comp_id(dev, psof, psos))
1256 dev_warn(dev, "JPEG component ids should be 0-3 or 1-4");
1257
1258 fourcc = mxc_jpeg_get_image_format(dev, header);
1259 if (fourcc == 0)
1260 return -EINVAL;
1261
1262 /*
1263 * set-up the capture queue with the pixelformat and resolution
1264 * detected from the jpeg output stream
1265 */
1266 q_data_cap = mxc_jpeg_get_q_data(ctx, cap_type);
1267 if (q_data_cap->w != header.frame.width ||
1268 q_data_cap->h != header.frame.height)
1269 src_chg = true;
1270 q_data_cap->w = header.frame.width;
1271 q_data_cap->h = header.frame.height;
1272 q_data_cap->fmt = mxc_jpeg_find_format(ctx, fourcc);
1273 q_data_cap->w_adjusted = q_data_cap->w;
1274 q_data_cap->h_adjusted = q_data_cap->h;
1275 /*
1276 * align up the resolution for CAST IP,
1277 * but leave the buffer resolution unchanged
1278 */
1279 v4l_bound_align_image(&q_data_cap->w_adjusted,
1280 q_data_cap->w_adjusted, /* adjust up */
1281 MXC_JPEG_MAX_WIDTH,
1282 q_data_cap->fmt->h_align,
1283 &q_data_cap->h_adjusted,
1284 q_data_cap->h_adjusted, /* adjust up */
1285 MXC_JPEG_MAX_HEIGHT,
1286 q_data_cap->fmt->v_align,
1287 0); 1288 dev_dbg(dev, "Detected jpeg res=(%dx%d)->(%dx%d), pixfmt=%c%c%c%c\n",
1289 q_data_cap->w, q_data_cap->h,
1290 q_data_cap->w_adjusted, q_data_cap->h_adjusted,
1291 (fourcc & 0xff),
1292 (fourcc >> 8) & 0xff,
1293 (fourcc >> 16) & 0xff,
1294 (fourcc >> 24) & 0xff);
1295
1296 /* setup bytesperline/sizeimage for capture queue */
1297 mxc_jpeg_bytesperline(q_data_cap, header.frame.precision);
1298 mxc_jpeg_sizeimage(q_data_cap);
1299
1300 /*
1301 * if the CAPTURE format was updated with new values, regardless of
1302 * whether they match the values set by the client or not, signal
1303 * a source change event
1304 */
1305 if (src_chg)
1306 notify_src_chg(ctx);
1307
1308 return 0;
1309 }
1310
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org