Add Rockchip VPU JPEG encoder
Subsystems (5)
v7 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.
Please, see the previous versions of this cover letter for more information.
This series should apply cleanly on top of
git://linuxtv.org/hverkuil/media_tree.git br-cedrus tag.
If everyone is happy with this series, I'd like to route the devicetree changes through the rockchip tree, and the rest via the media subsystem.
Compliance
==========
(Same results as v3)
v4l2-compliance SHA: d0f4ea7ddab6d0244c4fe1e960bb2aaeefb911b9, 64 bits
Compliance test for device /dev/video0:
Driver Info:
Driver name : rockchip-vpu Card type : rockchip,rk3399-vpu-enc 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
Media Driver Info:
Driver name : rockchip-vpu Model : rockchip-vpu Serial : Bus info : Media version : 4.18.0 Hardware revision: 0x00000000 (0) Driver version : 4.18.0 Interface Info: ID : 0x0300000c Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : rockchip,rk3399-vpu-enc-source Function : V4L2 I/O Pad 0x01000002 : Source Link 0x02000008: to remote pad 0x1000005 of entity 'rockchip,rk3399-vpu-enc-proc': Data, Enabled, Immutable
Required ioctls:
test MC information (see 'Media Driver Info' above): OK 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)
test blocking wait: OK
test MMAP: OK
test USERPTR: OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total: 48, Succeeded: 48, Failed: 0, Warnings: 0
v7:
- Fix checkpatch --strict issues.
- Fix extra blank line in binding doc.
v6:
- As agreed with Hans change the quantization control
to support only strict baseline JPEGs, with 8-bit coefficients.
v5:
- Make coefficients 2-byte wide, to support 8-bit and 16-bit precision coefficient. Also, add a 'precision' field, to allow the user to specifiy the coefficient precision.
- Minor style changes as requested by Hans.
- Get rid of all the unused leftover code.
- Move driver to staging. The driver will support video encoding, via the request API. So let's use staging until the controls are stabilized.
v4:
- Change luma and chroma array controls, with a compound control, as suggested by Paul.
v3:
- Refactor driver to allow a more elegant integration with other codec modes (h264 decoding, jpeg decoding, etc). Each variant can now be encoders, decoders or both.
- Register driver in the media controller framework,
in preparation for the Request API.
- Set values for JPEG quantization controls in the core, as suggested by Tomasz and Hans.
- Move pm_runtime_get/put to run/done, reducing power consumption. This was possible thanks to Miouyouyou, who pointed out the power domains missing [1].
- Use bulk clock API for simpler code.
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 JPEG encoder driver
Shunqian Zheng (2):
media: Add JPEG_RAW format
media: Add controls for JPEG quantization tables
.../bindings/media/rockchip-vpu.txt | 29 + .../media/uapi/v4l/extended-controls.rst | 25 + .../media/uapi/v4l/pixfmt-compressed.rst | 9 + .../media/videodev2.h.rst.exceptions | 1 + MAINTAINERS | 7 + arch/arm/boot/dts/rk3288.dtsi | 14 +- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +- drivers/media/v4l2-core/v4l2-ctrls.c | 8 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rockchip/vpu/Kconfig | 13 + drivers/staging/media/rockchip/vpu/Makefile | 9 + drivers/staging/media/rockchip/vpu/TODO | 9 + .../media/rockchip/vpu/rk3288_vpu_hw.c | 125 ++++ .../rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c | 127 ++++ .../media/rockchip/vpu/rk3288_vpu_regs.h | 442 +++++++++++++ .../media/rockchip/vpu/rk3399_vpu_hw.c | 125 ++++ .../rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c | 155 +++++ .../media/rockchip/vpu/rk3399_vpu_regs.h | 600 +++++++++++++++++ .../staging/media/rockchip/vpu/rockchip_vpu.h | 278 ++++++++ .../media/rockchip/vpu/rockchip_vpu_common.h | 31 + .../media/rockchip/vpu/rockchip_vpu_drv.c | 527 +++++++++++++++ .../media/rockchip/vpu/rockchip_vpu_enc.c | 606 ++++++++++++++++++ .../media/rockchip/vpu/rockchip_vpu_hw.h | 65 ++ include/uapi/linux/v4l2-controls.h | 10 + include/uapi/linux/videodev2.h | 2 + 27 files changed, 3233 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vpu.txt create mode 100644 drivers/staging/media/rockchip/vpu/Kconfig create mode 100644 drivers/staging/media/rockchip/vpu/Makefile create mode 100644 drivers/staging/media/rockchip/vpu/TODO create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_regs.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_common.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_hw.h
Signature · 1 line
2.19.0.rc2
A message that is not in the archive (sent off-list or not yet received): 20181005001226.12789-1-ezequiel-ZGY8ohtN/[email protected]
PATCH v7 1/6 dt-bindings: Document the Rockchip VPU bindings
Add devicetree binding documentation for Rockchip Video Processing Unit IP.
--- .../bindings/media/rockchip-vpu.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vpu.txt
Documentation/devicetree/bindings/media/rockchip-vpu.txt new file +29 -0
@@ -0,0 +1,29 @@ +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.19.0.rc2
PATCH v7 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.
Fix the VPU IOMMU node, which was disabled and lacking its power domain property.
--- arch/arm/boot/dts/rk3288.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm/boot/dts/rk3288.dtsi +13 -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>;
@@ -1230,8 +1242,8 @@ interrupt-names = "vpu_mmu"; clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; clock-names = "aclk", "iface"; + power-domains = <&power RK3288_PD_VIDEO>; #iommu-cells = <0>; - status = "disabled"; }; hevc_mmu: iommu@ff9c0440 {
Signature · 1 line
2.19.0.rc2
A message that is not in the archive (sent off-list or not yet received): 20181005001226.12789-3-ezequiel-ZGY8ohtN/[email protected]
Re: [PATCH v7 2/6] ARM: dts: rockchip: add VPU device node for RK3288
Am Freitag, 5. Oktober 2018, 02:12:22 CEST schrieb Ezequiel Garcia:
Quoted 6 lines
Add the Video Processing Unit node for RK3288 SoC.
Fix the VPU IOMMU node, which was disabled and lacking its power domain property.
Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>
applied for 4.20 (may possibly move to 4.21 though) after moving power-domain* below (#)iommu* to keep alphabetical sorting.
Thanks
Heiko
Re: [PATCH v7 2/6] ARM: dts: rockchip: add VPU device node for RK3288
Am Freitag, 5. Oktober 2018, 14:04:04 CEST schrieb Heiko Stuebner:
Quoted 11 lines
Am Freitag, 5. Oktober 2018, 02:12:22 CEST schrieb Ezequiel Garcia:
Quoted 6 lines
Add the Video Processing Unit node for RK3288 SoC.
Fix the VPU IOMMU node, which was disabled and lacking its power domain property.
Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>applied for 4.20 (may possibly move to 4.21 though) after moving power-domain* below (#)iommu* to keep alphabetical sorting.
as Mauro did have additional comments and the pull request is still open, I've dropped the 2 dts patches from my tree again for now.
We'll revisit once the code changes moved again.
Heiko
PATCH v7 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.
Also, fix the VPU IOMMU node, which was disabled and lacking its power domain property.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +13 -1
@@ -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>;
@@ -1205,8 +1217,8 @@ interrupt-names = "vpu_mmu"; clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>; clock-names = "aclk", "iface"; + power-domains = <&power RK3399_PD_VCODEC>; #iommu-cells = <0>; - status = "disabled"; }; vdec_mmu: iommu@ff660480 {
Signature · 1 line
2.19.0.rc2
A message that is not in the archive (sent off-list or not yet received): 20181005001226.12789-4-ezequiel-ZGY8ohtN/[email protected]
Re: [PATCH v7 3/6] arm64: dts: rockchip: add VPU device node for RK3399
Am Freitag, 5. Oktober 2018, 02:12:23 CEST schrieb Ezequiel Garcia:
Quoted 6 lines
Add the Video Processing Unit node for the RK3399 SoC.
Also, fix the VPU IOMMU node, which was disabled and lacking its power domain property.
Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>
applied for 4.20 (may possibly move to 4.21 though) after moving power-domain* below (#)iommu* to keep alphabetical sorting.
Thanks
Heiko
PATCH v7 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
@@ -1301,6 +1301,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
@@ -627,6 +627,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.19.0.rc2
A message that is not in the archive (sent off-list or not yet received): 20181005001226.12789-5-ezequiel-ZGY8ohtN/[email protected]
Re: [PATCH v7 4/6] media: Add JPEG_RAW format
Em Thu, 4 Oct 2018 21:12:24 -0300
Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]> escreveu:
Quoted 20 lines
From: Shunqian Zheng <[email protected]>
Add
V4L2_PIX_FMT_JPEG_RAWformat that does not contain JPEG header in the output frame.Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- 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 +0
-0@@ -23,6 +23,15 @@ Compressed Formats - 'JPEG' - TBD. See also :ref:`VIDIOC_G_JPEGCOMP <VIDIOC_G_JPEGCOMP>`,
Documentation/media/uapi/v4l/pixfmt-compressed.rst Compressed Formats · line 34
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-compressed.rst +9
-0: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`.
IMO, it is not very clear when someone should use V4L2_CID_JPEG or V4L2_PIX_FMT_JPEG_RAW. Some drivers do add a JPEG header internally.
Also, if we're now starting to accept headerless JPEG images, you should very patch libv4l as well, in order to accept this new format.
Regards,
Thanks,
Mauro
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v7 4/6] media: Add JPEG_RAW format
Quoted 28 lines · Mauro Carvalho Chehab
Em Thu, 4 Oct 2018 21:12:24 -0300
Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]> escreveu:Quoted 25 lines
From: Shunqian Zheng <[email protected]>
Add
V4L2_PIX_FMT_JPEG_RAWformat that does not contain JPEG header in the output frame.Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- 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 +4
-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'
Quoted 9 lines
Documentation/media/uapi/v4l/pixfmt-compressed.rst Compressed Formats · line 34
Quoted 5 lines
Documentation/media/uapi/v4l/pixfmt-compressed.rst +5
-0+ - 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`.IMO, it is not very clear when someone should use
V4L2_CID_JPEGorV4L2_PIX_FMT_JPEG_RAW. Some drivers do add a JPEG header internally.
For device drivers, if the hardware can parse JPEG frames, then V4L2_PIX_FMT_JPEG should be used. Otherwise, if the hardware can only accept a parsed JPEG (i.e. payload and tables), then only V4L2_PIX_FMT_JPEG_RAW should be supported.
Parsing headers in the driver is discouraged by the stateful codec API specification.
With the Request API in place, and the stateful and stateless specs, device driver writers should be now using the right model for each type of hardware.
There are exceptions, though. If the hardware handles full JPEG frames, but requires some extra parsing on the OS side, then the driver should be using V4L2_PIX_FMT_JPEG, and doing some extra parsing. For instance, mtk-jpeg seems to work like this.
Quoted 3 lines
Also, if we're now starting to accept headerless JPEG images, you should very patch libv4l as well, in order to accept this new format.
Right.
Thanks,
Eze
A message that is not in the archive (sent off-list or not yet received): 90ef806ecfab6e93dc08e4acdce11cc2e15df637.camel-ZGY8ohtN/[email protected]
Re: [PATCH v7 4/6] media: Add JPEG_RAW format
Em Fri, 05 Oct 2018 08:53:14 -0300
Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]> escreveu:
Quoted 39 lines · Mauro Carvalho Chehab
Quoted 28 lines
Em Thu, 4 Oct 2018 21:12:24 -0300
Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]> escreveu:Quoted 25 lines
From: Shunqian Zheng <[email protected]>
Add
V4L2_PIX_FMT_JPEG_RAWformat that does not contain JPEG header in the output frame.Signed-off-by Shunqian Zheng <[email protected]>Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>--- 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 +4
-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'Quoted 9 lines
Documentation/media/uapi/v4l/pixfmt-compressed.rst Compressed Formats · line 34
Quoted 5 lines
Documentation/media/uapi/v4l/pixfmt-compressed.rst +5
-0+ - 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`.IMO, it is not very clear when someone should use
V4L2_CID_JPEGorV4L2_PIX_FMT_JPEG_RAW. Some drivers do add a JPEG header internally.
Quoted 4 lines
For device drivers, if the hardware can parse JPEG frames, then
V4L2_PIX_FMT_JPEGshould be used. Otherwise, if the hardware can only accept a parsed JPEG (i.e. payload and tables), then onlyV4L2_PIX_FMT_JPEG_RAWshould be supported.
It seems you're talking here about V4L2 output devices. I'm more concerned about its usage on V4L2 capture devices.
Yet, it should be possible to use it with both, as formats should be generic enough to work on both directions.
Quoted 2 lines
Parsing headers in the driver is discouraged by the stateful codec API specification.
True, but we do parsing/adding headers for some formats in Kernel space, as this is a way to abstract the hardware for applications.
That's specially true for MPEG and JPEG formats.
Quoted 8 lines
With the Request API in place, and the stateful and stateless specs, device driver writers should be now using the right model for each type of hardware.
There are exceptions, though. If the hardware handles full JPEG frames, but requires some extra parsing on the OS side, then the driver should be using
V4L2_PIX_FMT_JPEG, and doing some extra parsing. For instance, mtk-jpeg seems to work like this.
Actually, all existing drivers do this.
I'm not saying that this the right/best model, but it is the way it is. Changing it is possible, but only if it can be done in a driver-independent way and userspace code inside a library exists to support it.
Quoted 9 lines
Quoted 4 lines
Also, if we're now starting to accept headerless JPEG images, you should very patch libv4l as well, in order to accept this new format.
Right.
Thanks,
Eze
Thanks,
Mauro
PATCH v7 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_QUANTIZATION compound control to allow userspace configure the JPEG quantization tables.
--- .../media/uapi/v4l/extended-controls.rst | 25 +++++++++++++++++++ .../media/videodev2.h.rst.exceptions | 1 + drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++++++ include/uapi/linux/v4l2-controls.h | 10 ++++++++ include/uapi/linux/videodev2.h | 1 + 5 files changed, 45 insertions(+)
Documentation/media/uapi/v4l/extended-controls.rst +25 -0
@@ -3530,7 +3530,32 @@ 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_QUANTIZATION (struct)`` + Specifies the luma and chroma quantization matrices for encoding + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. + This control supports 8-bit quantization coefficients, for + the baseline profile, as specified by :ref:`itu-t81`. + Coefficients must be set in JPEG zigzag scan order. + + +.. c:type:: struct v4l2_ctrl_jpeg_quantization + +.. cssclass:: longtable + +.. flat-table:: struct v4l2_ctrl_jpeg_quantization + :header-rows: 0 + :stub-columns: 0 + :widths: 1 1 2 + + * - __u8 + - ``luma_quantization_matrix[64]`` + - Sets the luma quantization table. + + * - __u8 + - ``chroma_quantization_matrix[64]`` + - Sets the chroma quantization table. .. flat-table:: :header-rows: 0
Documentation/media/videodev2.h.rst.exceptions +1 -0
@@ -131,6 +131,7 @@ replace symbol V4L2_CTRL_TYPE_U32 :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_U8 :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS :c:type:`v4l2_ctrl_type` replace symbol V4L2_CTRL_TYPE_MPEG2_QUANTIZATION :c:type:`v4l2_ctrl_type` +replace symbol V4L2_CTRL_TYPE_JPEG_QUANTIZATION :c:type:`v4l2_ctrl_type` # V4L2 capability defines replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities
drivers/media/v4l2-core/v4l2-ctrls.c +8 -0
@@ -1001,6 +1001,7 @@ 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_QUANTIZATION :return "JPEG Quantization Tables" ;/* Image source controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */
@@ -1288,6 +1289,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_DETECT_MD_REGION_GRID : *type =V4L2_CTRL_TYPE_U8 ;break ; +case V4L2_CID_JPEG_QUANTIZATION : + *type =V4L2_CTRL_TYPE_JPEG_QUANTIZATION ; +break ;case V4L2_CID_DETECT_MD_THRESHOLD_GRID : *type =V4L2_CTRL_TYPE_U16 ;break ;
@@ -1667,6 +1671,7 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,return 0 ;case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : +case V4L2_CTRL_TYPE_JPEG_QUANTIZATION :return 0 ;default :
@@ -2249,6 +2254,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION : elem_size =sizeof (struct v4l2_ctrl_mpeg2_quantization );break ; +case V4L2_CTRL_TYPE_JPEG_QUANTIZATION : + elem_size =sizeof (struct v4l2_ctrl_jpeg_quantization ); +break ;default :if (type <V4L2_CTRL_COMPOUND_TYPES ) elem_size =sizeof (s32);
include/uapi/linux/v4l2-controls.h +10 -0
@@ -990,6 +990,16 @@ 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_QUANTIZATION (V4L2_CID_JPEG_CLASS_BASE + 5) +struct v4l2_ctrl_jpeg_quantization { +/* ITU-T.81 specifies two quantization coefficient precisions: +* 8-bit for baseline profile, +* 8-bit or 16-bit for extended profile. +* This control only supports the former, for the baseline profile. +*/ +__u8 luma_quantization_matrix[64 ]; +__u8 chroma_quantization_matrix[64 ]; +};/* Image source controls */ #define V4L2_CID_IMAGE_SOURCE_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900)
include/uapi/linux/videodev2.h +1 -0
@@ -1660,6 +1660,7 @@ enum v4l2_ctrl_type {V4L2_CTRL_TYPE_U32 =0x0102 ,V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS =0x0103 ,V4L2_CTRL_TYPE_MPEG2_QUANTIZATION =0x0104 , + V4L2_CTRL_TYPE_JPEG_QUANTIZATION = 0x0105, };/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
Signature · 1 line
2.19.0.rc2
PATCH v7 6/6 media: add Rockchip VPU JPEG encoder 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/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/rockchip/vpu/Kconfig | 13 + drivers/staging/media/rockchip/vpu/Makefile | 9 + drivers/staging/media/rockchip/vpu/TODO | 9 + .../media/rockchip/vpu/rk3288_vpu_hw.c | 125 ++++ .../rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c | 127 ++++ .../media/rockchip/vpu/rk3288_vpu_regs.h | 442 +++++++++++++ .../media/rockchip/vpu/rk3399_vpu_hw.c | 125 ++++ .../rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c | 155 +++++ .../media/rockchip/vpu/rk3399_vpu_regs.h | 600 +++++++++++++++++ .../staging/media/rockchip/vpu/rockchip_vpu.h | 278 ++++++++ .../media/rockchip/vpu/rockchip_vpu_common.h | 31 + .../media/rockchip/vpu/rockchip_vpu_drv.c | 527 +++++++++++++++ .../media/rockchip/vpu/rockchip_vpu_enc.c | 606 ++++++++++++++++++ .../media/rockchip/vpu/rockchip_vpu_hw.h | 65 ++ 17 files changed, 3122 insertions(+) create mode 100644 drivers/staging/media/rockchip/vpu/Kconfig create mode 100644 drivers/staging/media/rockchip/vpu/Makefile create mode 100644 drivers/staging/media/rockchip/vpu/TODO create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rk3399_vpu_regs.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_common.h create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c create mode 100644 drivers/staging/media/rockchip/vpu/rockchip_vpu_hw.h
MAINTAINERS +7 -0
@@ -12459,6 +12459,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/staging/media/platform/rockchip/vpu/ +F: Documentation/devicetree/bindings/media/rockchip-vpu.txt + ROCKER DRIVER M: Jiri Pirko <[email protected]> L: [email protected]
drivers/staging/media/Kconfig +2 -0
@@ -31,6 +31,8 @@ source "drivers/staging/media/mt9t031/Kconfig" source "drivers/staging/media/omap4iss/Kconfig" +source "drivers/staging/media/rockchip/vpu/Kconfig" + source "drivers/staging/media/sunxi/Kconfig" source "drivers/staging/media/tegra-vde/Kconfig"
drivers/staging/media/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ obj-$(CONFIG_VIDEO_SUNXI) += sunxi/ obj-$(CONFIG_TEGRA_VDE) += tegra-vde/ obj-$(CONFIG_VIDEO_ZORAN) += zoran/ +obj-$(CONFIG_VIDEO_ROCKCHIP_VPU) += rockchip/vpu/
drivers/staging/media/rockchip/vpu/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +config VIDEO_ROCKCHIP_VPU + tristate "Rockchip VPU driver" + depends on ARCH_ROCKCHIP || COMPILE_TEST + depends on VIDEO_DEV && VIDEO_V4L2 && MEDIA_CONTROLLER + 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. +
drivers/staging/media/rockchip/vpu/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +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_jpeg_enc.o \ + rk3399_vpu_hw.o \ + rk3399_vpu_hw_jpeg_enc.o
drivers/staging/media/rockchip/vpu/TODO new file +9 -0
@@ -0,0 +1,9 @@ +This driver is in staging until the V4L controls stabilize. + +Given the V4L controls are part of the uABI, it's better +to have the driver in staging, so users are aware of this +driver having an unstable interface. + +Having proper userspace support for drivers like this that +use JPEG_RAW and similar formats is also a requirement +for moving out of staging.
drivers/staging/media/rockchip/vpu/rk3288_vpu_hw.c new file +125 -0
125 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rk3288_vpu_hw_jpeg_enc.c new file +127 -0
127 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rk3288_vpu_regs.h new file +442 -0
442 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rk3399_vpu_hw.c new file +125 -0
125 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rk3399_vpu_hw_jpeg_enc.c new file +155 -0
155 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rk3399_vpu_regs.h new file +600 -0
600 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rockchip_vpu.h new file +278 -0
278 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rockchip_vpu_common.h new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Rockchip VPU codec driver +* +* Copyright (C) 2018 Rockchip Electronics Co., Ltd. +* Alpha Lin <[email protected]> +* Jeffy Chen <[email protected]> +* +* Copyright (C) 2018 Google, Inc. +* Tomasz Figa <[email protected]> +* +* Based on s5p-mfc driver by Samsung Electronics Co., Ltd. +* Copyright (C) 2011 Samsung Electronics Co., Ltd. +*/ + +#ifndef ROCKCHIP_VPU_COMMON_H_ +#define ROCKCHIP_VPU_COMMON_H_ + +#include "rockchip_vpu.h" + +extern const struct v4l2_ioctl_ops rockchip_vpu_enc_ioctl_ops; +extern const struct vb2_ops rockchip_vpu_enc_queue_ops; + +void *rockchip_vpu_find_control (struct rockchip_vpu_ctx *ctx, +unsigned int id); +void rockchip_vpu_enc_reset_src_fmt (struct rockchip_vpu_dev *vpu, +struct rockchip_vpu_ctx *ctx); +void rockchip_vpu_enc_reset_dst_fmt (struct rockchip_vpu_dev *vpu, +struct rockchip_vpu_ctx *ctx); + +#endif /* ROCKCHIP_VPU_COMMON_H_ */
drivers/staging/media/rockchip/vpu/rockchip_vpu_drv.c new file +527 -0
527 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rockchip_vpu_enc.c new file +606 -0
534 lines not on this page · raw message
drivers/staging/media/rockchip/vpu/rockchip_vpu_hw.h new file +65 -0
65 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.19.0.rc2
Part of the diff is not shown here. View the raw message.