Add V4L2 M2M Driver for E5010 JPEG Encoder
Devarsh Thakkar
maintainerv7 cover Add V4L2 M2M Driver for E5010 JPEG Encoder
Resending this V7 series to have proper linking of patches in the series with cover-letter while doing git send-email.
Original cover letter:
This adds support for V4L2 M2M based driver for E5010 JPEG Encoder which is a stateful JPEG encoder from Imagination technologies and is present in TI AM62A SoC.
While adding support for it, following additional framework changes were made:
- Moved reference quantization and huffman tables provided in ITU-T-REC-T.81 to v4l2-jpeg.c as suggested in mailing list [1].
- Add macros to round to closest integer (either higher or lower) while rounding in order of 2.
v4l2-compliance test :
E5010 JPEG Encoder Manual tests :
Performance:
Functionality:
Compression Quality:
Multi Instance:
Crop support:
Runtime PM:
[1]:
https://lore.kernel.org/all/[email protected]/
Changelog:V6->V7:
- Fix cropping support
- Move reference huffman and quantization tables to v4l2-jpeg.c
- Fix suspend/resume use-case
- Add Reviewed-by
V5->V6:
- Fix sparse warnings
V4->V5:
- Sort the #includes in driver file alphabetically
- Rename huffman and quantization tables to not use '_'
- Add Reviewed-by tag
V3->V4:
- Use ti-specific compatible ti,am62a-jpeg-enc as secondary one in dt-binding
- Remove clock-names as only single clock in dt-binding
- Fix issue with default params setting
- Correct v4l2 error prints
- Simplify register write functions with single statement return values
- Remove unrequired error checks from get_queue()
- Drop explicit device_caps setting as it is already taken care by v4l2 core
- Remove unrequired multiplanar checks and memset from s_fmt, g_fmt callback functions
- Fix try_fmt callback to not update the queues
- Remove unrequired contiguous format attribute from queue_init
- Use dynamic allocation for video_device and remove unrequired assignments in probe()
- Remove unrequired checks from queue_setup function
- Return queued buffers back if start_streaming fails
- Use ARRAY_SIZE in place of hard-coding
- Use huffman and quantization tables from reference header file
V2->V3:
- Add DONOTMERGE patches for dts and defconfig
- Update driver with below changes :
- Correct license headers
- Use more generic name core instead of jasper for base registers
- Add Comment for forward declarations
- Simplify quantization table calculations
- Use v4l2_apply_frmsize_constraints for updating framesize and remove unrequired functions
- Place TODO at top of file and in commit message too
- Use dev_err_probe helper in probe function
- Fix return value checking for failure scenarios in probe function
- Use v4l2_err/info/warn helpers instead of dev_err/info/warn helpers
- Fix unexpected indentation
- Correct commit message
- Update dt-bindings with below changes :
- Add vendor specific compatible
- Fix commit title and message
- Update reg names
- Update clocks to 1
- Fix dts example with proper naming
V1->V2:
- Send dt-bindings and driver together
Patch-Diff between the series :
V3->V4 Range diff :
https://gist.github.com/devarsht/22a744d999080de6e813bcfb5a596272
V4->V5 Range diff :
https://gist.github.com/devarsht/298790af819f299a0a05fec89371097b
V5->V6 Range diff :
https://gist.github.com/devarsht/c89180ac2b0d2814614f2b59d0705c19
V6->V7 Range diff :
https://gist.github.com/devarsht/1db185b1e187eaf397e9e4c37066777e
Previous patch series:
V2: https://lore.kernel.org/all/[email protected]/
V3: https://lore.kernel.org/all/[email protected]/
V4: https://lore.kernel.org/all/[email protected]/
V5: https://lore.kernel.org/all/[email protected]/
V6: https://lore.kernel.org/all/[email protected]/
Devarsh Thakkar (8):
media: dt-bindings: Add Imagination E5010 JPEG Encoder
media: imagination: Add E5010 JPEG Encoder driver
media: v4l2-jpeg: Export reference quantization and huffman tables
media: imagination: Use exported tables from v4l2-jpeg core
media: verisilcon : Use exported tables from v4l2-jpeg for hantro
codec
math.h Add macros to round to closest specified power of 2
media: imagination: Round to closest multiple for cropping region
gpu: ipu-v3: Use generic macro for rounding to nearest multiple
.../bindings/media/img,e5010-jpeg-enc.yaml | 75 + MAINTAINERS | 7 + drivers/gpu/ipu-v3/ipu-image-convert.c | 4 +- drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/imagination/Kconfig | 12 + drivers/media/platform/imagination/Makefile | 3 + .../platform/imagination/e5010-core-regs.h | 585 ++++++ .../platform/imagination/e5010-jpeg-enc-hw.c | 267 +++ .../platform/imagination/e5010-jpeg-enc-hw.h | 42 + .../platform/imagination/e5010-jpeg-enc.c | 1646 +++++++++++++++++ .../platform/imagination/e5010-jpeg-enc.h | 168 ++ .../platform/imagination/e5010-mmu-regs.h | 311 ++++ .../media/platform/verisilicon/hantro_jpeg.c | 128 +- drivers/media/v4l2-core/v4l2-jpeg.c | 162 +- include/linux/math.h | 36 + include/media/v4l2-jpeg.h | 11 + 17 files changed, 3341 insertions(+), 118 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/img,e5010-jpeg-enc.yaml create mode 100644 drivers/media/platform/imagination/Kconfig create mode 100644 drivers/media/platform/imagination/Makefile create mode 100644 drivers/media/platform/imagination/e5010-core-regs.h create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc-hw.c create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc-hw.h create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc.c create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc.h create mode 100644 drivers/media/platform/imagination/e5010-mmu-regs.h
Signature · 1 line
2.39.1
Devarsh Thakkar
maintainerPATCH RESEND v7 1/8 media: dt-bindings: Add Imagination E5010 JPEG Encoder
Add dt-bindings for Imagination E5010 JPEG Encoder [1] which is implemented as stateful V4L2 M2M driver.
The device supports baseline encoding with two different quantization tables and compression ratio as demanded.
Minimum resolution supported is 64x64 and Maximum resolution supported is 8192x8192.
[1]: AM62A TRM (Section 7.6 is for JPEG Encoder)
---
V2: No change
V3:
- Add vendor specific compatible
- Update reg names
- Update clocks to 1
- Fix dts example with proper naming
V4:
- Use ti-specific compatible ti,am62a-jpeg-enc as secondary one
- Update commit message and title
- Remove clock-names as only single clock
V5:
- Add Reviewed-By tag
V6:
- No change
V7:
- No change
--- .../bindings/media/img,e5010-jpeg-enc.yaml | 75 +++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/img,e5010-jpeg-enc.yaml
Documentation/devicetree/bindings/media/img,e5010-jpeg-enc.yaml new file +75 -0
@@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/img,e5010-jpeg-enc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Imagination E5010 JPEG Encoder + +maintainers: + - Devarsh Thakkar <[email protected]> + +description: | + The E5010 is a JPEG encoder from Imagination Technologies implemented on + TI's AM62A SoC. It is capable of real time encoding of YUV420 and YUV422 + inputs to JPEG and M-JPEG. It supports baseline JPEG Encoding up to + 8Kx8K resolution. + +properties: + compatible: + oneOf: + - items: + - const: ti,am62a-jpeg-enc + - const: img,e5010-jpeg-enc + - const: img,e5010-jpeg-enc + + reg: + items: + - description: The E5010 core register region + - description: The E5010 mmu register region + + reg-names: + items: + - const: core + - const: mmu + + power-domains: + maxItems: 1 + + resets: + maxItems: 1 + + clocks: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/soc/ti,sci_pm_domain.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + jpeg-encoder@fd20000 { + compatible = "img,e5010-jpeg-enc"; + reg = <0x00 0xfd20000 0x00 0x100>, + <0x00 0xfd20200 0x00 0x200>; + reg-names = "core", "mmu"; + clocks = <&k3_clks 201 0>; + power-domains = <&k3_pds 201 TI_SCI_PD_EXCLUSIVE>; + interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>; + }; + };
MAINTAINERS +5 -0
@@ -10762,6 +10762,11 @@ S: Maintained F: Documentation/devicetree/bindings/auxdisplay/img,ascii-lcd.yaml F: drivers/auxdisplay/img-ascii-lcd.c +IMGTEC JPEG ENCODER DRIVER +M: Devarsh Thakkar <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/media/img,e5010-jpeg-enc.yaml + IMGTEC IR DECODER DRIVER S: Orphan F: drivers/media/rc/img-ir/
Signature · 1 line
2.39.1
Devarsh Thakkar
maintainerPATCH RESEND v7 2/8 media: imagination: Add E5010 JPEG Encoder driver
In reply to Devarsh ThakkarThis adds support for stateful V4L2 M2M based driver for Imagination E5010 JPEG Encoder [1] which supports baseline encoding with two different quantization tables and compression ratio as demanded.
Support for both contiguous and non-contiguous YUV420 and YUV422 semiplanar formats is added along with alignment restrictions as required by the hardware.
System and runtime PM hooks are added in the driver along with v4l2 crop and selection API support.
Minimum resolution supported is 64x64 and
Maximum resolution supported is 8192x8192.
All v4l2-compliance tests are passing [2] :
v4l2-compliance -s -f -a -d /dev/video0 -e /dev/video1
Total for e5010 device /dev/video0: 79, Succeeded: 79, Failed: 0,
Warnings: 0
NOTE: video1 here is VIVID test pattern generator
Also tests [3] were run manually to verify below driver features:
- Runtime Power Management
- Multi-instance JPEG Encoding
- DMABUF import, export support
- NV12, NV21, NV16, NV61 video format support
- Compression quality S_CTRL
- Cropping support using S_SELECTION
Existing V4L2 M2M based JPEG drivers namely s5p-jpeg, imx-jpeg and rcar_jpu were referred while making this.
TODO:
Add MMU and memory tiling support
[1]: AM62A TRM (Section 7.6 is for JPEG Encoder) :
[2]: v4l2-compliance test :
[3]: E5010 JPEG Encoder Manual tests :
Performance:
Functionality:
Compression Quality:
Multi Instance:
Crop support:
Runtime PM:
---
V2:
No change
V3:
- Correct license headers
- Use more generic name core instead of jasper for base registers
- Add Comment for forward declarations
- Simplify quantization table calculations
- Use v4l2_apply_frmsize_constraints for updating framesize and remove unrequired functions
- Place TODO at top of file and in commit message too
- Use dev_err_probe helper in probe function
- Fix return value checking for failure scenarios in probe function
- Use v4l2_err/info/warn helpers instead of dev_err/info/warn helpers
- Fix unexpected indentation
- Correct commit message
- Remove dependency on ARCH_K3 as driver is not specific to that
V4:
- Fix issue with default params setting
- Correct v4l2 error prints
- Simplify register write functions with single statement return values
- Remove unrequired error checks from get_queue()
- Drop explicit device_caps setting as it is already taken care by v4l2 core
- Remove unrequired multiplanar checks and memset from s_fmt, g_fmt callback
functions
- Fix try_fmt callback to not update the queues
- Remove unrequired contiguous format attribute from queue_init
- Use dynamic allocation for video_device and remove unrequired assignments in probe()
- Remove unrequired checks from queue_setup function
- Return queued buffers back if start_streaming fails
- Use ARRAY_SIZE in place of hard-coding
- Use huffman and quantization tables from reference header file
V5:
- Sort the #includes alphabetically in e5010-jpeg-enc.c
- Update commit message to point to V5 test reports
V6:
- Fix sparse warnings and maintain uniform usage of dev ptr to avoid future such bugs. No more errors received as shown below :
`smatch/smatch_scripts/kchecker
drivers/media/platform/imagination/e5010*.c
CHECK scripts/mod/empty.c CALL scripts/checksyscalls.sh CHECK arch/arm64/kernel/vdso/vgettimeofday.c CC [M] drivers/media/platform/imagination/e5010-jpeg-enc.o CHECK drivers/media/platform/imagination/e5010-jpeg-enc.c`
- Drop Reviewed-by: Benjamin Gaignard <[email protected]> as patchset got updated to fix sparse warnings mentinoed at
https://lore.kernel.org/all/[email protected]/#t
V7:
- Add cropping support, fix S_SELECTION and G_SELECTION ioctls
- Fix PM use-case: Re-enable hardware on system resume before resuming the v4l2 m2m jobs
- Re-instate Reviewed-by tag as discussed afterwards in mailing list
Link to previous patch revisions:
V3:
https://lore.kernel.org/all/[email protected]/
V4:
https://lore.kernel.org/all/[email protected]/
V5:
https://lore.kernel.org/all/[email protected]/
V6:
https://lore.kernel.org/all/[email protected]/
--- MAINTAINERS | 2 + drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/imagination/Kconfig | 12 + drivers/media/platform/imagination/Makefile | 3 + .../platform/imagination/e5010-core-regs.h | 585 ++++++ .../platform/imagination/e5010-jpeg-enc-hw.c | 267 +++ .../platform/imagination/e5010-jpeg-enc-hw.h | 42 + .../platform/imagination/e5010-jpeg-enc.c | 1748 +++++++++++++++++ .../platform/imagination/e5010-jpeg-enc.h | 168 ++ .../platform/imagination/e5010-mmu-regs.h | 311 +++ 11 files changed, 3140 insertions(+) create mode 100644 drivers/media/platform/imagination/Kconfig create mode 100644 drivers/media/platform/imagination/Makefile create mode 100644 drivers/media/platform/imagination/e5010-core-regs.h create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc-hw.c create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc-hw.h create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc.c create mode 100644 drivers/media/platform/imagination/e5010-jpeg-enc.h create mode 100644 drivers/media/platform/imagination/e5010-mmu-regs.h
MAINTAINERS +2 -0
@@ -10764,8 +10764,10 @@ F: drivers/auxdisplay/img-ascii-lcd.c IMGTEC JPEG ENCODER DRIVER M: Devarsh Thakkar <[email protected]> +L: [email protected] S: Supported F: Documentation/devicetree/bindings/media/img,e5010-jpeg-enc.yaml +F: drivers/media/platform/imagination/e5010* IMGTEC IR DECODER DRIVER S: Orphan
drivers/media/platform/Kconfig +1 -0
@@ -70,6 +70,7 @@ source "drivers/media/platform/atmel/Kconfig" source "drivers/media/platform/broadcom/Kconfig" source "drivers/media/platform/cadence/Kconfig" source "drivers/media/platform/chips-media/Kconfig" +source "drivers/media/platform/imagination/Kconfig" source "drivers/media/platform/intel/Kconfig" source "drivers/media/platform/marvell/Kconfig" source "drivers/media/platform/mediatek/Kconfig"
drivers/media/platform/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-y += atmel/ obj-y += broadcom/ obj-y += cadence/ obj-y += chips-media/ +obj-y += imagination/ obj-y += intel/ obj-y += marvell/ obj-y += mediatek/
drivers/media/platform/imagination/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0 +config VIDEO_E5010_JPEG_ENC + tristate "Imagination E5010 JPEG Encoder Driver" + depends on VIDEO_DEV + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_VMALLOC + select V4L2_MEM2MEM_DEV + help + This is a video4linux2 M2M driver for Imagination E5010 JPEG encoder, + which supports JPEG and MJPEG baseline encoding of YUV422 and YUV420 + semiplanar video formats, with resolution ranging from 64x64 to 8K x 8K + pixels. The module will be named as e5010_jpeg_enc.
drivers/media/platform/imagination/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +e5010_jpeg_enc-objs := e5010-jpeg-enc-hw.o e5010-jpeg-enc.o +obj-$(CONFIG_VIDEO_E5010_JPEG_ENC) += e5010_jpeg_enc.o
drivers/media/platform/imagination/e5010-core-regs.h new file +585 -0
585 lines not on this page · raw message
drivers/media/platform/imagination/e5010-jpeg-enc-hw.c new file +267 -0
267 lines not on this page · raw message
drivers/media/platform/imagination/e5010-jpeg-enc-hw.h new file +42 -0
42 lines not on this page · raw message
drivers/media/platform/imagination/e5010-jpeg-enc.c new file +1748 -0
1,748 lines not on this page · raw message
drivers/media/platform/imagination/e5010-jpeg-enc.h new file +168 -0
168 lines not on this page · raw message
drivers/media/platform/imagination/e5010-mmu-regs.h new file +311 -0
151 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.1
Part of the diff is not shown here. View the raw message.
Quoted 8 lines · Devarsh Thakkar
Resending this V7 series to have proper linking of patches in the series with cover-letter while doing git send-email.
Original cover letter:
This adds support for V4L2 M2M based driver for E5010 JPEG Encoder which is a stateful JPEG encoder from Imagination technologies and is present in TI AM62A SoC.
Quoted 6 lines
While adding support for it, following additional framework changes were made:
- Moved reference quantization and huffman tables provided in ITU-T-REC-T.81 tov4l2-jpeg.cas suggested in mailing list [1].
- Add macros to round to closest integer (either higher or lower) while rounding in order of 2.
Nice, now it's chained!
But all my comments to the previous mails are still applicable here.
Signature · 2 lines
With Best Regards, Andy Shevchenko