Skip to contentSkip to conversation

media: imagination: Add E5010 JPEG Encoder driver

PATCH Superseded Devarsh Thakkar 1 participant 1 message May 9, 2024

Subsystems (2)

v7 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Devarsh Thakkar

author maintainer
#0 lore raw

PATCH v7 2/8 media: imagination: Add E5010 JPEG Encoder driver

This 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
index 6f0f077e0427..db575642acbb 100644
@@ -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
index 2d79bfc68c15..6feeebab4b06 100644
@@ -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
index da17301f7439..11a2f2d0c1a1 100644
@@ -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
new file mode 100644
index 000000000000..d8d79266ad5d
@@ -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
new file mode 100644
index 000000000000..d45b85b88575
@@ -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.