Add Rockchip VPU JPEG encoder
Subsystems (4)
v2 cover Add Rockchip VPU JPEG encoder
This series adds support for JPEG encoding via the VPU block present in Rockchip platforms. Currently, support for RK3288 and RK3399 is included.
The hardware produces a Raw JPEG format (i.e. works as a JPEG accelerator). It requires quantization tables provided by the application, and uses standard huffman tables, as recommended by the JPEG specification.
In order to support this, the series introduces a new pixel format, and a new pair of controls, V4L2_CID_JPEG_{LUMA,CHROMA}_QUANTIZATION allowing userspace to specify the quantization tables.
Userspace is then responsible to add the required headers and tables to the produced raw payload, to produce a JPEG image.
Compliance
==========
There is an outstanding compliance issue, related to a blocking dqbuf, but I cannot see where is the issue, nor if the issue is in the core or in the driver.
# v4l2-compliance -d 0 -s v4l2-compliance SHA: 81ea4a243b63d7bb1fec580910c553af4ae072c1, 64 bits
Compliance test for device /dev/video0:
Driver Info:
Driver name : rockchip-vpu Card type : rockchip-vpu Bus info : platform: rockchip-vpu Driver version : 4.18.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
Required ioctls:
test VIDIOC_QUERYCAP: 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 test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 2 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 (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
fail: v4l2-test-buffers.cpp(1225): pid != pid_streamoff
fail: v4l2-test-buffers.cpp(1258): testBlockingDQBuf(node, q)
test blocking wait: FAIL
test MMAP: OK
test USERPTR: OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total: 47, Succeeded: 46, Failed: 1, Warnings: 0
v2:
- Add devicetree binding documentation and devicetree changes
- Add documentation to added pixel format and controls
- Address Hans' review comments
- Get rid of unused running_ctx field
- Fix wrong planar pixel format depths
- Other minor changes for v4l2-compliance
- Drop .crop support, we will add support for the selector API later, if needed.
Ezequiel Garcia (4):
dt-bindings: Document the Rockchip VPU bindings
ARM: dts: rockchip: add VPU device node for RK3288
arm64: dts: rockchip: add VPU device node for RK3399
media: add Rockchip VPU driver
Shunqian Zheng (2):
media: Add JPEG_RAW format
media: Add controls for jpeg quantization tables
.../bindings/media/rockchip-vpu.txt | 30 + .../media/uapi/v4l/extended-controls.rst | 9 + .../media/uapi/v4l/pixfmt-compressed.rst | 9 + MAINTAINERS | 7 + arch/arm/boot/dts/rk3288.dtsi | 13 +- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 + drivers/media/platform/Kconfig | 13 + drivers/media/platform/Makefile | 1 + drivers/media/platform/rockchip/vpu/Makefile | 8 + .../platform/rockchip/vpu/rk3288_vpu_hw.c | 122 +++ .../rockchip/vpu/rk3288_vpu_hw_jpege.c | 154 ++++ .../platform/rockchip/vpu/rk3288_vpu_regs.h | 442 +++++++++++ .../platform/rockchip/vpu/rk3399_vpu_hw.c | 122 +++ .../rockchip/vpu/rk3399_vpu_hw_jpege.c | 181 +++++ .../platform/rockchip/vpu/rk3399_vpu_regs.h | 601 +++++++++++++++ .../platform/rockchip/vpu/rockchip_vpu.h | 272 +++++++ .../platform/rockchip/vpu/rockchip_vpu_drv.c | 404 ++++++++++ .../platform/rockchip/vpu/rockchip_vpu_enc.c | 715 ++++++++++++++++++ .../platform/rockchip/vpu/rockchip_vpu_enc.h | 25 + .../platform/rockchip/vpu/rockchip_vpu_hw.h | 67 ++ drivers/media/v4l2-core/v4l2-ctrls.c | 4 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/v4l2-controls.h | 3 + include/uapi/linux/videodev2.h | 1 + 24 files changed, 3215 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vpu.txt create mode 100644 drivers/media/platform/rockchip/vpu/Makefile create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_hw.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_hw_jpege.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_regs.h create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_hw.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_hw_jpege.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_regs.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_drv.c create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.c create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_hw.h
Signature · 1 line
2.18.0
A message that is not in the archive (sent off-list or not yet received): 20180802200010.24365-1-ezequiel-ZGY8ohtN/[email protected]
PATCH v2 1/6 dt-bindings: Document the Rockchip VPU bindings
Add devicetree binding documentation for Rockchip Video Processing Unit IP.
--- .../bindings/media/rockchip-vpu.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vpu.txt
Documentation/devicetree/bindings/media/rockchip-vpu.txt new file +30 -0
@@ -0,0 +1,30 @@ +device-tree bindings for rockchip VPU codec + +Rockchip (Video Processing Unit) present in various Rockchip platforms, +such as RK3288 and RK3399. + +Required properties: +- compatible: value should be one of the following + "rockchip,rk3288-vpu"; + "rockchip,rk3399-vpu"; +- interrupts: encoding and decoding interrupt specifiers +- interrupt-names: should be "vepu" and "vdpu" +- clocks: phandle to VPU aclk, hclk clocks +- clock-names: should be "aclk" and "hclk" +- power-domains: phandle to power domain node +- iommus: phandle to a iommu node + +Example: +SoC-specific DT entry: + vpu: video-codec@ff9a0000 { + compatible = "rockchip,rk3288-vpu"; + reg = <0x0 0xff9a0000 0x0 0x800>; + interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "vepu", "vdpu"; + clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; + clock-names = "aclk", "hclk"; + power-domains = <&power RK3288_PD_VIDEO>; + iommus = <&vpu_mmu>; + }; +
Signature · 1 line
2.18.0
A message that is not in the archive (sent off-list or not yet received): 20180802200010.24365-2-ezequiel-ZGY8ohtN/[email protected]
Rob Herring
Reviewed-byRe: [PATCH v2 1/6] dt-bindings: Document the Rockchip VPU bindings
Quoted 8 lines · Ezequiel Garcia
Add devicetree binding documentation for Rockchip Video Processing Unit IP.
Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- .../bindings/media/rockchip-vpu.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vpu.txt
PATCH v2 2/6 ARM: dts: rockchip: add VPU device node for RK3288
In reply to a message not in the archiveAdd the Video Processing Unit node for RK3288 SoC. Also, enable the VPU IOMMU node, as it's needed for any user that wants to use the VPU with the IOMMU.
--- arch/arm/boot/dts/rk3288.dtsi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
arch/arm/boot/dts/rk3288.dtsi +12 -1
@@ -1223,6 +1223,18 @@ }; }; + vpu: video-codec@ff9a0000 { + compatible = "rockchip,rk3288-vpu"; + reg = <0x0 0xff9a0000 0x0 0x800>; + interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "vepu", "vdpu"; + clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; + clock-names = "aclk", "hclk"; + power-domains = <&power RK3288_PD_VIDEO>; + iommus = <&vpu_mmu>; + }; + vpu_mmu: iommu@ff9a0800 { compatible = "rockchip,iommu"; reg = <0x0 0xff9a0800 0x0 0x100>;
@@ -1231,7 +1243,6 @@ clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; clock-names = "aclk", "iface"; #iommu-cells = <0>; - status = "disabled"; }; hevc_mmu: iommu@ff9c0440 {
Signature · 1 line
2.18.0
PATCH v2 3/6 arm64: dts: rockchip: add VPU device node for RK3399
In reply to a message not in the archiveAdd the Video Processing Unit node for the RK3399 SoC.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +12 -0
@@ -1198,6 +1198,18 @@ status = "disabled"; }; + vpu: video-codec@ff650000 { + compatible = "rockchip,rk3399-vpu"; + reg = <0x0 0xff650000 0x0 0x800>; + interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH 0>, + <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH 0>; + interrupt-names = "vepu", "vdpu"; + clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; + clock-names = "aclk", "hclk"; + power-domains = <&power RK3399_PD_VCODEC>; + iommus = <&vpu_mmu>; + }; + vpu_mmu: iommu@ff650800 { compatible = "rockchip,iommu"; reg = <0x0 0xff650800 0x0 0x40>;
Signature · 1 line
2.18.0
PATCH v2 4/6 media: Add JPEG_RAW format
In reply to a message not in the archiveFrom: Shunqian Zheng <[email protected]>
Add V4L2_PIX_FMT_JPEG_RAW format that does not contain JPEG header in the output frame.
--- Documentation/media/uapi/v4l/pixfmt-compressed.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/videodev2.h | 1 + 3 files changed, 11 insertions(+)
Documentation/media/uapi/v4l/pixfmt-compressed.rst +9 -0
@@ -23,6 +23,15 @@ Compressed Formats - 'JPEG' - TBD. See also :ref:`VIDIOC_G_JPEGCOMP <VIDIOC_G_JPEGCOMP>`, :ref:`VIDIOC_S_JPEGCOMP <VIDIOC_G_JPEGCOMP>`. + * .. _V4L2-PIX-FMT-JPEG-RAW: + + - ``V4L2_PIX_FMT_JPEG_RAW`` + - 'Raw JPEG' + - Raw JPEG bitstream, containing a compressed payload. This format + contains an image scan, i.e. without any metadata or headers. + The user is expected to set the needed metadata such as + quantization and entropy encoding tables, via ``V4L2_CID_JPEG`` + controls, see :ref:`jpeg-control-id`. * .. _V4L2-PIX-FMT-MPEG: - ``V4L2_PIX_FMT_MPEG``
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1296,6 +1296,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)/* Max description length mask: descr = "0123456789012345678901234567890" */ case V4L2_PIX_FMT_MJPEG : descr ="Motion-JPEG" ;break ;case V4L2_PIX_FMT_JPEG : descr ="JFIF JPEG" ;break ; +case V4L2_PIX_FMT_JPEG_RAW : descr ="Raw JPEG" ;break ;case V4L2_PIX_FMT_DV : descr ="1394" ;break ;case V4L2_PIX_FMT_MPEG : descr ="MPEG-1/2/4" ;break ;case V4L2_PIX_FMT_H264 : descr ="H.264" ;break ;
include/uapi/linux/videodev2.h +1 -0
@@ -621,6 +621,7 @@ struct v4l2_pix_format {/* compressed formats */ #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G')/* Motion-JPEG */ #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')/* JFIF JPEG */ +#define V4L2_PIX_FMT_JPEG_RAW v4l2_fourcc('J', 'P', 'G', 'R')/* JFIF JPEG RAW without headers */ #define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd')/* 1394 */ #define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G')/* MPEG-1/2/4 Multiplexed */ #define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4')/* H264 with start codes */
Signature · 1 line
2.18.0
PATCH v2 5/6 media: Add controls for jpeg quantization tables
In reply to a message not in the archiveFrom: Shunqian Zheng <[email protected]>
Add V4L2_CID_JPEG_LUMA/CHROMA_QUANTIZATION controls to allow userspace configure the JPEG quantization tables.
--- Documentation/media/uapi/v4l/extended-controls.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 16 insertions(+)
Documentation/media/uapi/v4l/extended-controls.rst +9 -0
@@ -3354,6 +3354,15 @@ JPEG Control IDs Specify which JPEG markers are included in compressed stream. This control is valid only for encoders. +.. _jpeg-quant-tables-control: + +``V4L2_CID_JPEG_LUMA_QUANTIZATION (__u8 matrix)`` + Sets the luma quantization table to be used for encoding + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. This table is + expected to be in JPEG zigzag order, as per the JPEG specification. + +``V4L2_CID_JPEG_CHROMA_QUANTIZATION (__u8 matrix)`` + Sets the chroma quantization table. .. flat-table::
drivers/media/v4l2-core/v4l2-ctrls.c +4 -0
@@ -999,6 +999,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_JPEG_RESTART_INTERVAL :return "Restart Interval" ;case V4L2_CID_JPEG_COMPRESSION_QUALITY :return "Compression Quality" ;case V4L2_CID_JPEG_ACTIVE_MARKER :return "Active Markers" ; +case V4L2_CID_JPEG_LUMA_QUANTIZATION :return "Luminance Quantization Matrix" ; +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :return "Chrominance Quantization Matrix" ;/* Image source controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1284,6 +1286,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *flags |=V4L2_CTRL_FLAG_READ_ONLY ;break ;case V4L2_CID_DETECT_MD_REGION_GRID : +case V4L2_CID_JPEG_LUMA_QUANTIZATION : +case V4L2_CID_JPEG_CHROMA_QUANTIZATION : *type =V4L2_CTRL_TYPE_U8 ;break ;case V4L2_CID_DETECT_MD_THRESHOLD_GRID :
include/uapi/linux/v4l2-controls.h +3 -0
@@ -987,6 +987,9 @@ enum v4l2_jpeg_chroma_subsampling {#define V4L2_JPEG_ACTIVE_MARKER_DQT (1 << 17)#define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18) +#define V4L2_CID_JPEG_LUMA_QUANTIZATION (V4L2_CID_JPEG_CLASS_BASE + 5) +#define V4L2_CID_JPEG_CHROMA_QUANTIZATION (V4L2_CID_JPEG_CLASS_BASE + 6) +/* Image source controls */ #define V4L2_CID_IMAGE_SOURCE_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900)
Signature · 1 line
2.18.0
A message that is not in the archive (sent off-list or not yet received): 20180802200010.24365-6-ezequiel-ZGY8ohtN/[email protected]
Re: [PATCH v2 5/6] media: Add controls for jpeg quantization tables
Hi Ezequiel,
Quoted 6 lines · Ezequiel Garcia
From: Shunqian Zheng <[email protected]>
Add V4L2_CID_JPEG_LUMA/CHROMA_QUANTIZATION controls to allow userspace configure the JPEG quantization tables.
Quoted 7 lines
Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- Documentation/media/uapi/v4l/extended-controls.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 16 insertions(+)
Thanks for this series and sorry for being late with review. Please see my comments inline.
Quoted 6 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0
Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3362
Quoted 9 lines
Documentation/media/uapi/v4l/extended-controls.rst +6
-0@@ -3354,6 +3354,15 @@ JPEG Control IDs Specify which JPEG markers are included in compressed stream. This control is valid only for encoders. +.. _jpeg-quant-tables-control: + +``V4L2_CID_JPEG_LUMA_QUANTIZATION (__u8 matrix)`` + Sets the luma quantization table to be used for encoding + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. This table is + expected to be in JPEG zigzag order, as per the JPEG specification.
Should we also specify this to be 8x8?
Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3366
Quoted 4 lines
Documentation/media/uapi/v4l/extended-controls.rst +3
-0+ +``V4L2_CID_JPEG_CHROMA_QUANTIZATION (__u8 matrix)`` + Sets the chroma quantization table.
nit: I guess we aff something like
"See also V4L2_CID_JPEG_LUMA_QUANTIZATION for details."
to avoid repeating the V4L2_PIX_FMT_JPEG_RAW and zigzag order bits? Or maybe just repeating is better?
Quoted 16 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0.. flat-table::drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -999,6 +999,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_JPEG_RESTART_INTERVAL :return "Restart Interval" ;case V4L2_CID_JPEG_COMPRESSION_QUALITY :return "Compression Quality" ;case V4L2_CID_JPEG_ACTIVE_MARKER :return "Active Markers" ; +case V4L2_CID_JPEG_LUMA_QUANTIZATION :return "Luminance Quantization Matrix" ; +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :return "Chrominance Quantization Matrix" ;/* Image source controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */
drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, · line 1290
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -1284,6 +1286,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *flags |=V4L2_CTRL_FLAG_READ_ONLY ;break ;case V4L2_CID_DETECT_MD_REGION_GRID : +case V4L2_CID_JPEG_LUMA_QUANTIZATION : +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :
It looks like with this setup, the driver has to explicitly set dims to { 8, 8 } and min/max to 0/255.
At least for min and max, we could set them here. For dims, i don't see it handled in generic code, so I guess we can leave it to the driver now and add move into generic code, if another driver shows up. Hans, what do you think?
Best regards,
Tomasz
A message that is not in the archive (sent off-list or not yet received): CAAFQd5C4jTfdB5Zmk6LQwTOBB2hs14ensZ+J-ZdTcQzzBNKn0A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v2 5/6] media: Add controls for jpeg quantization tables
Quoted 75 lines · Tomasz Figa
Hi Ezequiel,
Quoted 6 lines · Ezequiel Garcia
From: Shunqian Zheng <[email protected]>
Add V4L2_CID_JPEG_LUMA/CHROMA_QUANTIZATION controls to allow userspace configure the JPEG quantization tables.
Quoted 7 lines
Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- Documentation/media/uapi/v4l/extended-controls.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 16 insertions(+)Thanks for this series and sorry for being late with review. Please see my comments inline.
Quoted 6 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3362
Quoted 9 lines
Documentation/media/uapi/v4l/extended-controls.rst +6
-0@@ -3354,6 +3354,15 @@ JPEG Control IDs Specify which JPEG markers are included in compressed stream. This control is valid only for encoders. +.. _jpeg-quant-tables-control: + +``V4L2_CID_JPEG_LUMA_QUANTIZATION (__u8 matrix)`` + Sets the luma quantization table to be used for encoding + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. This table is + expected to be in JPEG zigzag order, as per the JPEG specification.Should we also specify this to be 8x8?
Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3366
Quoted 4 lines
Documentation/media/uapi/v4l/extended-controls.rst +3
-0+ +``V4L2_CID_JPEG_CHROMA_QUANTIZATION (__u8 matrix)`` + Sets the chroma quantization table.nit: I guess we aff something like
"See also
V4L2_CID_JPEG_LUMA_QUANTIZATIONfor details."to avoid repeating the
V4L2_PIX_FMT_JPEG_RAWand zigzag order bits? Or maybe just repeating is better?Quoted 16 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0.. flat-table::drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -999,6 +999,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_JPEG_RESTART_INTERVAL :return "Restart Interval" ;case V4L2_CID_JPEG_COMPRESSION_QUALITY :return "Compression Quality" ;case V4L2_CID_JPEG_ACTIVE_MARKER :return "Active Markers" ; +case V4L2_CID_JPEG_LUMA_QUANTIZATION :return "Luminance Quantization Matrix" ; +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :return "Chrominance Quantization Matrix" ;/* Image source controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, · line 1290
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -1284,6 +1286,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *flags |=V4L2_CTRL_FLAG_READ_ONLY ;break ;case V4L2_CID_DETECT_MD_REGION_GRID : +case V4L2_CID_JPEG_LUMA_QUANTIZATION : +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :It looks like with this setup, the driver has to explicitly set dims to { 8, 8 } and min/max to 0/255.
Quoted 4 lines
At least for min and max, we could set them here. For dims, i don't see it handled in generic code, so I guess we can leave it to the driver now and add move into generic code, if another driver shows up. Hans, what do you think?
I noticed this when reviewing. I have a slight preference for setting the dims and min/max in the core. It's pretty standard how this should behave after all.
Regards,
Hans
Re: [PATCH v2 5/6] media: Add controls for jpeg quantization tables
In reply to a message not in the archiveQuoted 29 lines · Tomasz Figa
Hi Ezequiel,
Quoted 6 lines · Ezequiel Garcia
From: Shunqian Zheng <[email protected]>
Add V4L2_CID_JPEG_LUMA/CHROMA_QUANTIZATION controls to allow userspace configure the JPEG quantization tables.
Quoted 7 lines
Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- Documentation/media/uapi/v4l/extended-controls.rst | 9 +++++++++ drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 3 +++ 3 files changed, 16 insertions(+)Thanks for this series and sorry for being late with review. Please see my comments inline.
Quoted 9 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0@@ -3354,6 +3354,15 @@ JPEG Control IDs Specify which JPEG markers are included in compressed stream. This control is valid only for encoders.
Quoted 9 lines
Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3362
Quoted 6 lines
Documentation/media/uapi/v4l/extended-controls.rst +6
-0+.. _jpeg-quant-tables-control: + +``V4L2_CID_JPEG_LUMA_QUANTIZATION (__u8 matrix)`` + Sets the luma quantization table to be used for encoding + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. This table is + expected to be in JPEG zigzag order, as per the JPEG specification.Should we also specify this to be 8x8?
Yes, could be.
Quoted 5 lines
Documentation/media/uapi/v4l/extended-controls.rst JPEG Control IDs · line 3366
Quoted 4 lines
Documentation/media/uapi/v4l/extended-controls.rst +3
-0+ +``V4L2_CID_JPEG_CHROMA_QUANTIZATION (__u8 matrix)`` + Sets the chroma quantization table.
Quoted 7 lines
nit: I guess we aff something like
"See also
V4L2_CID_JPEG_LUMA_QUANTIZATIONfor details."to avoid repeating the
V4L2_PIX_FMT_JPEG_RAWand zigzag order bits? Or maybe just repeating is better?
In spec documentation I usually find it's clearer for readers to see stuff repeated. Better to have an excess of clarity :-)
Quoted 25 lines
Quoted 16 lines
Documentation/media/uapi/v4l/extended-controls.rst +0
-0.. flat-table::drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -999,6 +999,8 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_JPEG_RESTART_INTERVAL :return "Restart Interval" ;case V4L2_CID_JPEG_COMPRESSION_QUALITY :return "Compression Quality" ;case V4L2_CID_JPEG_ACTIVE_MARKER :return "Active Markers" ; +case V4L2_CID_JPEG_LUMA_QUANTIZATION :return "Luminance Quantization Matrix" ; +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :return "Chrominance Quantization Matrix" ;/* Image source controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ drivers/media/v4l2-core/v4l2-ctrls.c void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, · line 1290
Quoted 5 lines
drivers/media/v4l2-core/v4l2-ctrls.c +2
-0@@ -1284,6 +1286,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *flags |=V4L2_CTRL_FLAG_READ_ONLY ;break ;case V4L2_CID_DETECT_MD_REGION_GRID : +case V4L2_CID_JPEG_LUMA_QUANTIZATION : +case V4L2_CID_JPEG_CHROMA_QUANTIZATION :It looks like with this setup, the driver has to explicitly set dims to { 8, 8 } and min/max to 0/255.
Quoted 5 lines
At least for min and max, we could set them here. For dims, i don't see it handled in generic code, so I guess we can leave it to the driver now and add move into generic code, if another driver shows up. Hans, what do you think?
Since Hans agrees to move this to the core, let's give it a try. I'll address this in v3.
Thanks for the feedback!
Eze
PATCH v2 6/6 media: add Rockchip VPU driver
In reply to a message not in the archiveAdd a mem2mem driver for the VPU available on Rockchip SoCs. Currently only JPEG encoding is supported, for RK3399 and RK3288 platforms.
--- MAINTAINERS | 7 + drivers/media/platform/Kconfig | 13 + drivers/media/platform/Makefile | 1 + drivers/media/platform/rockchip/vpu/Makefile | 8 + .../platform/rockchip/vpu/rk3288_vpu_hw.c | 122 +++ .../rockchip/vpu/rk3288_vpu_hw_jpege.c | 154 ++++ .../platform/rockchip/vpu/rk3288_vpu_regs.h | 442 +++++++++++ .../platform/rockchip/vpu/rk3399_vpu_hw.c | 122 +++ .../rockchip/vpu/rk3399_vpu_hw_jpege.c | 181 +++++ .../platform/rockchip/vpu/rk3399_vpu_regs.h | 601 +++++++++++++++ .../platform/rockchip/vpu/rockchip_vpu.h | 272 +++++++ .../platform/rockchip/vpu/rockchip_vpu_drv.c | 404 ++++++++++ .../platform/rockchip/vpu/rockchip_vpu_enc.c | 715 ++++++++++++++++++ .../platform/rockchip/vpu/rockchip_vpu_enc.h | 25 + .../platform/rockchip/vpu/rockchip_vpu_hw.h | 67 ++ 15 files changed, 3134 insertions(+) create mode 100644 drivers/media/platform/rockchip/vpu/Makefile create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_hw.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_hw_jpege.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3288_vpu_regs.h create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_hw.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_hw_jpege.c create mode 100644 drivers/media/platform/rockchip/vpu/rk3399_vpu_regs.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_drv.c create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.c create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.h create mode 100644 drivers/media/platform/rockchip/vpu/rockchip_vpu_hw.h
MAINTAINERS +7 -0
@@ -12414,6 +12414,13 @@ S: Maintained F: drivers/media/platform/rockchip/rga/ F: Documentation/devicetree/bindings/media/rockchip-rga.txt +ROCKCHIP VPU CODEC DRIVER +M: Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]> +L: [email protected] +S: Maintained +F: drivers/media/platform/rockchip/vpu/ +F: Documentation/devicetree/bindings/media/rockchip-vpu.txt + ROCKER DRIVER M: Jiri Pirko <[email protected]> L: [email protected]
drivers/media/platform/Kconfig +13 -0
@@ -448,6 +448,19 @@ config VIDEO_ROCKCHIP_RGA To compile this driver as a module choose m here. +config VIDEO_ROCKCHIP_VPU + tristate "Rockchip VPU driver" + depends on VIDEO_DEV && VIDEO_V4L2 + depends on ARCH_ROCKCHIP || COMPILE_TEST + select VIDEOBUF2_DMA_CONTIG + select V4L2_MEM2MEM_DEV + default n + help + Support for the Video Processing Unit present on Rockchip SoC, + which accelerates video and image encoding and decoding. + To compile this driver as a module, choose M here: the module + will be called rockchip-vpu. + config VIDEO_TI_VPE tristate "TI VPE (Video Processing Engine) driver" depends on VIDEO_DEV && VIDEO_V4L2
drivers/media/platform/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o obj-$(CONFIG_VIDEO_RENESAS_VSP1) += vsp1/ obj-$(CONFIG_VIDEO_ROCKCHIP_RGA) += rockchip/rga/ +obj-$(CONFIG_VIDEO_ROCKCHIP_VPU) += rockchip/vpu/ obj-y += omap/
drivers/media/platform/rockchip/vpu/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +obj-$(CONFIG_VIDEO_ROCKCHIP_VPU) += rockchip-vpu.o + +rockchip-vpu-y += rockchip_vpu_drv.o \ + rockchip_vpu_enc.o \ + rk3288_vpu_hw.o \ + rk3288_vpu_hw_jpege.o \ + rk3399_vpu_hw.o \ + rk3399_vpu_hw_jpege.o
drivers/media/platform/rockchip/vpu/rk3288_vpu_hw.c new file +122 -0
122 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rk3288_vpu_hw_jpege.c new file +154 -0
154 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rk3288_vpu_regs.h new file +442 -0
442 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rk3399_vpu_hw.c new file +122 -0
122 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rk3399_vpu_hw_jpege.c new file +181 -0
181 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rk3399_vpu_regs.h new file +601 -0
601 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rockchip_vpu.h new file +272 -0
272 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rockchip_vpu_drv.c new file +404 -0
404 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.c new file +715 -0
655 lines not on this page · raw message
drivers/media/platform/rockchip/vpu/rockchip_vpu_enc.h new file +25 -0
Lines of this file are not shown. View the raw message.
drivers/media/platform/rockchip/vpu/rockchip_vpu_hw.h new file +67 -0
67 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.18.0
Part of the diff is not shown here. View the raw message.
Quoted 109 lines · Ezequiel Garcia
This series adds support for JPEG encoding via the VPU block present in Rockchip platforms. Currently, support for RK3288 and RK3399 is included.
The hardware produces a Raw JPEG format (i.e. works as a JPEG accelerator). It requires quantization tables provided by the application, and uses standard huffman tables, as recommended by the JPEG specification.
In order to support this, the series introduces a new pixel format, and a new pair of controls, V4L2_CID_JPEG_{LUMA,CHROMA}_QUANTIZATION allowing userspace to specify the quantization tables.
Userspace is then responsible to add the required headers and tables to the produced raw payload, to produce a JPEG image.
Compliance
==========There is an outstanding compliance issue, related to a blocking dqbuf, but I cannot see where is the issue, nor if the issue is in the core or in the driver.
# v4l2-compliance -d 0 -s v4l2-compliance SHA: 81ea4a243b63d7bb1fec580910c553af4ae072c1, 64 bitsCompliance test for device
/dev/video0:Driver Info:
Driver name : rockchip-vpu Card type : rockchip-vpu Bus info : platform: rockchip-vpu Driver version : 4.18.0 Capabilities : 0x84204000Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps :0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix FormatRequired ioctls:
testVIDIOC_QUERYCAP: OKAllow for multiple opens:
test second/dev/video0open: OK
testVIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OKDebug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) testVIDIOC_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) testVIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) testVIDIOC_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: 0Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) testVIDIOC_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: 0Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) testVIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK testVIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 2 Private Controls: 0Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) testVIDIOC_G_FBUF: OK (Not Supported) testVIDIOC_G_FMT: OK
testVIDIOC_TRY_FMT: OK
testVIDIOC_S_FMT: OK
testVIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OKCodec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) testVIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK testVIDIOC_EXPBUF: OK
Quoted 8 lines
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported) fail: v4l2-test-buffers.cpp(1225): pid != pid_streamoff fail: v4l2-test-buffers.cpp(1258): testBlockingDQBuf(node, q) test blocking wait: FAIL
Hans,
Any thoughts on where is this failure coming from and how to fix it?
Thanks!
Eze