Skip to contentSkip to conversation

Extend RAW format support for rzg2l-cru driver

PATCH Superseded Daniel Scally 5 participants 24 messages Sep 20, 2024 – Oct 2, 2024

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Extend RAW format support for rzg2l-cru driver

Hi All

This series adds new pixel formats representing the 64-bit packed format that's used by the Camera Receiver Unit in RZ/G2L and V2H SoCs. Support for capturing those formats is then added to the rzg2l-cru driver itself.

The series is based on top of the v2 of Prabhakar's recent set titled "media: platform: rzg2l-cru: CSI-2 and CRU enhancements"

Thanks
Dan

Daniel Scally (4):
media: v4l2: Add Renesas Camera Receiver Unit pixel formats
media: platform: rzg2l-cru: Use v4l2_get_link_freq()
media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()
media: platform: rzg2l-cru: Add support for RAW10/12/14 data

 .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
 .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |   3 -
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   |  37 +++--
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     |  88 +++++++++--
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  |  21 +--
 drivers/media/v4l2-core/v4l2-common.c         |  12 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
 include/uapi/linux/videodev2.h                |  16 ++
 9 files changed, 280 insertions(+), 53 deletions(-)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 media: v4l2: Add Renesas Camera Receiver Unit pixel formats

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

---
 .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
 .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-common.c         |  12 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
 include/uapi/linux/videodev2.h                |  16 ++
 5 files changed, 184 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst
Documentation/userspace-api/media/v4l/pixfmt-bayer.rst +1 -0
index ed3eb432967d..658068364ea1 100644
@@ -31,3 +31,4 @@ orders. See also `the Wikipedia article on Bayer filter
     pixfmt-srggb14
     pixfmt-srggb14p
     pixfmt-srggb16
+    pixfmt-srggbnn-cru
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +143 -0

143 lines not on this page · raw message

drivers/media/v4l2-core/v4l2-common.c +12 -0
index 0a2f4f0d0a07..ca78d26071c7 100644
@@ -329,10 +329,22 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
 		{ .format = V4L2_PIX_FMT_SGBRG10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGRBG10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SRGGB10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SBGGR12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGBRG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGRBG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SRGGB12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 	};
 	unsigned int i;
 
drivers/media/v4l2-core/v4l2-ioctl.c +12 -0
index e14db67be97c..9db0ec4a5d77 100644
@@ -1408,6 +1408,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG10DPCM8:	descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break;
 	case V4L2_PIX_FMT_SGRBG10DPCM8:	descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break;
 	case V4L2_PIX_FMT_SRGGB10DPCM8:	descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR10:	descr = "10-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG10:	descr = "10-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG10:	descr = "10-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB10:	descr = "10-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR12:	descr = "12-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG12:	descr = "12-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG12:	descr = "12-bit Bayer GRGR/BGBG"; break;
@@ -1416,6 +1420,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG12P:	descr = "12-bit Bayer GBGB/RGRG Packed"; break;
 	case V4L2_PIX_FMT_SGRBG12P:	descr = "12-bit Bayer GRGR/BGBG Packed"; break;
 	case V4L2_PIX_FMT_SRGGB12P:	descr = "12-bit Bayer RGRG/GBGB Packed"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR12:	descr = "12-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG12:	descr = "12-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG12:	descr = "12-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB12:	descr = "12-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR14:	descr = "14-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG14:	descr = "14-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG14:	descr = "14-bit Bayer GRGR/BGBG"; break;
@@ -1424,6 +1432,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG14P:	descr = "14-bit Bayer GBGB/RGRG Packed"; break;
 	case V4L2_PIX_FMT_SGRBG14P:	descr = "14-bit Bayer GRGR/BGBG Packed"; break;
 	case V4L2_PIX_FMT_SRGGB14P:	descr = "14-bit Bayer RGRG/GBGB Packed"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR14:	descr = "14-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG14:	descr = "14-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG14:	descr = "14-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB14:	descr = "14-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR16:	descr = "16-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG16:	descr = "16-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG16:	descr = "16-bit Bayer GRGR/BGBG"; break;
include/uapi/linux/videodev2.h +16 -0
index 725e86c4bbbd..8f0e3d8215ab 100644
@@ -828,6 +828,22 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B') /* PiSP 8-bit mode 2 compressed BGGR bayer */
 #define V4L2_PIX_FMT_PISP_COMP2_MONO	v4l2_fourcc('P', 'C', '2', 'M') /* PiSP 8-bit mode 2 compressed monochrome */
 
+/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels */
+#define V4L2_PIX_FMT_CRU_SBGGR10	v4l2_fourcc('C', '1', '0', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG10	v4l2_fourcc('C', '1', '0', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG10	v4l2_fourcc('C', '1', '0', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB10	v4l2_fourcc('C', '1', '0', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR12	v4l2_fourcc('C', '1', '2', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG12	v4l2_fourcc('C', '1', '2', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG12	v4l2_fourcc('C', '1', '2', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB12	v4l2_fourcc('C', '1', '2', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR14	v4l2_fourcc('C', '1', '4', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG14	v4l2_fourcc('C', '1', '4', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG14	v4l2_fourcc('C', '1', '4', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB14	v4l2_fourcc('C', '1', '4', 'R')
+
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
 #define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

Hi Dan

Quoted 51 lines · Daniel Scally

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

---
 .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
 .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-common.c         |  12 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
 include/uapi/linux/videodev2.h                |  16 ++
 5 files changed, 184 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst
Documentation/userspace-api/media/v4l/pixfmt-bayer.rst +1 -0
index ed3eb432967d..658068364ea1 100644
@@ -31,3 +31,4 @@ orders. See also `the Wikipedia article on Bayer filter
     pixfmt-srggb14
     pixfmt-srggb14p
     pixfmt-srggb16
+    pixfmt-srggbnn-cru
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +17 -0
new file mode 100644
index 000000000000..a169b7bbef79
@@ -0,0 +1,143 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
+
+******************************************************************************************************************************************
+V4L2_PIX_FMT_CRU_SBGGRnn ('CnnB'), V4L2_PIX_FMT_CRU_SGBRGnn ('CnnG'), V4L2_PIX_FMT_CRU_SGRBGnn ('Cnng'), V4L2_PIX_FMT_CRU_SRGGBnn ('CnnR')
+******************************************************************************************************************************************
+
+========================================================
+Renesas Camera Receiver Unit 64-bit packed pixel formats
+========================================================
+
+| V4L2_PIX_FMT_CRU_SBGGR10 (C10B)
+| V4L2_PIX_FMT_CRU_SGBRG10 (C10G)
+| V4L2_PIX_FMT_CRU_SGRBG10 (C10g)
+| V4L2_PIX_FMT_CRU_SRGGB10 (C10R)
+| V4L2_PIX_FMT_CRU_SBGGR12 (C12B)
+| V4L2_PIX_FMT_CRU_SGBRG12 (C12G)
+| V4L2_PIX_FMT_CRU_SGRBG12 (C12g)

Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst line 27

Quoted 10 lines
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +10 -0
+| V4L2_PIX_FMT_CRU_SRGGB12 (C12R)
+| V4L2_PIX_FMT_CRU_SBGGR14 (C14B)
+| V4L2_PIX_FMT_CRU_SGBRG14 (C14G)
+| V4L2_PIX_FMT_CRU_SGRBG14 (C14g)
+| V4L2_PIX_FMT_CRU_SRGGB14 (C14R)
+
+Description
+===========
+
+These pixel formats are some of the available output formats for the Camera

I would drop "some of the available" for

These pixel formats are some the Bayer RAW output formats for the Camera

Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst line 35

Quoted 8 lines
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +8 -0
+Receiver Unit in the Renesas RZ/G2L and V2H SoCs. They are raw sRGB / Bayer
+formats which pack pixels contiguously into 64-bit units, with the 4 or 8 most
+significant bits padded.
+
+The packing format is similar to the IPU3 packing formats defined in
+:ref:`v4l2-pix-fmt-ipu3-sbggr10`, albeit with the packing performed over a much
+shorter window.
+

That's true, not sure if mentioning it in documentation helps much

Quoted 98 lines
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +98 -0
+**Byte Order**
+
+.. flat-table:: RGB formats
+    :header-rows:  2
+    :stub-columns: 0
+    :widths: 36 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
+    :fill-cells:
+
+    * - :rspan:`1` Pixel Format Code
+      - :cspan:`63` Data organization
+    * - 63
+      - 62
+      - 61
+      - 60
+      - 59
+      - 58
+      - 57
+      - 56
+      - 55
+      - 54
+      - 53
+      - 52
+      - 51
+      - 50
+      - 49
+      - 48
+      - 47
+      - 46
+      - 45
+      - 44
+      - 43
+      - 42
+      - 41
+      - 40
+      - 39
+      - 38
+      - 37
+      - 36
+      - 35
+      - 34
+      - 33
+      - 32
+      - 31
+      - 30
+      - 29
+      - 28
+      - 27
+      - 26
+      - 25
+      - 24
+      - 23
+      - 22
+      - 21
+      - 20
+      - 19
+      - 18
+      - 17
+      - 16
+      - 15
+      - 14
+      - 13
+      - 12
+      - 11
+      - 10
+      - 9
+      - 8
+      - 7
+      - 6
+      - 5
+      - 4
+      - 3
+      - 2
+      - 1
+      - 0
+    * - V4L2_PIX_FMT_CRU_SBGGR10
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`9` P5
+      - :cspan:`9` P4
+      - :cspan:`9` P3
+      - :cspan:`9` P2
+      - :cspan:`9` P1
+      - :cspan:`9` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR12
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`11` P4
+      - :cspan:`11` P3
+      - :cspan:`11` P2
+      - :cspan:`11` P1
+      - :cspan:`11` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR14
+      - 0
+      - 0

Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst line 143

Quoted 10 lines
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +10 -0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`13` P3
+      - :cspan:`13` P2
+      - :cspan:`13` P1
+      - :cspan:`13` P0

I like these tables

Quoted 14 lines
drivers/media/v4l2-core/v4l2-common.c +4 -0
index 0a2f4f0d0a07..ca78d26071c7 100644
@@ -329,10 +329,22 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
 		{ .format = V4L2_PIX_FMT_SGBRG10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGRBG10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SRGGB10DPCM8,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB10,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SBGGR12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGBRG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c const struct v4l2_format_info *v4l2_format_info(u32 format) · line 347

Quoted 10 lines
drivers/media/v4l2-core/v4l2-common.c +8 -0
 		{ .format = V4L2_PIX_FMT_SGRBG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SRGGB12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB12,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB14,	.pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

These seems right to me

Quoted 54 lines
drivers/media/v4l2-core/v4l2-common.c +0 -0
 	};
 	unsigned int i;
 
drivers/media/v4l2-core/v4l2-ioctl.c +12 -0
index e14db67be97c..9db0ec4a5d77 100644
@@ -1408,6 +1408,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG10DPCM8:	descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break;
 	case V4L2_PIX_FMT_SGRBG10DPCM8:	descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break;
 	case V4L2_PIX_FMT_SRGGB10DPCM8:	descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR10:	descr = "10-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG10:	descr = "10-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG10:	descr = "10-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB10:	descr = "10-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR12:	descr = "12-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG12:	descr = "12-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG12:	descr = "12-bit Bayer GRGR/BGBG"; break;
@@ -1416,6 +1420,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG12P:	descr = "12-bit Bayer GBGB/RGRG Packed"; break;
 	case V4L2_PIX_FMT_SGRBG12P:	descr = "12-bit Bayer GRGR/BGBG Packed"; break;
 	case V4L2_PIX_FMT_SRGGB12P:	descr = "12-bit Bayer RGRG/GBGB Packed"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR12:	descr = "12-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG12:	descr = "12-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG12:	descr = "12-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB12:	descr = "12-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR14:	descr = "14-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG14:	descr = "14-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG14:	descr = "14-bit Bayer GRGR/BGBG"; break;
@@ -1424,6 +1432,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG14P:	descr = "14-bit Bayer GBGB/RGRG Packed"; break;
 	case V4L2_PIX_FMT_SGRBG14P:	descr = "14-bit Bayer GRGR/BGBG Packed"; break;
 	case V4L2_PIX_FMT_SRGGB14P:	descr = "14-bit Bayer RGRG/GBGB Packed"; break;
+	case V4L2_PIX_FMT_CRU_SBGGR14:	descr = "14-bit Bayer BGGR CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGBRG14:	descr = "14-bit Bayer GBRG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SGRBG14:	descr = "14-bit Bayer GRBG CRU Packed"; break;
+	case V4L2_PIX_FMT_CRU_SRGGB14:	descr = "14-bit Bayer RGGB CRU Packed"; break;
 	case V4L2_PIX_FMT_SBGGR16:	descr = "16-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG16:	descr = "16-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG16:	descr = "16-bit Bayer GRGR/BGBG"; break;
include/uapi/linux/videodev2.h +6 -0
index 725e86c4bbbd..8f0e3d8215ab 100644
@@ -828,6 +828,22 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B') /* PiSP 8-bit mode 2 compressed BGGR bayer */
 #define V4L2_PIX_FMT_PISP_COMP2_MONO	v4l2_fourcc('P', 'C', '2', 'M') /* PiSP 8-bit mode 2 compressed monochrome */
 
+/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels */
+#define V4L2_PIX_FMT_CRU_SBGGR10	v4l2_fourcc('C', '1', '0', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG10	v4l2_fourcc('C', '1', '0', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG10	v4l2_fourcc('C', '1', '0', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB10	v4l2_fourcc('C', '1', '0', 'R')
+

include/uapi/linux/videodev2.h struct v4l2_pix_format { · line 846

Quoted 10 lines
include/uapi/linux/videodev2.h +10 -0
+#define V4L2_PIX_FMT_CRU_SBGGR12	v4l2_fourcc('C', '1', '2', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG12	v4l2_fourcc('C', '1', '2', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG12	v4l2_fourcc('C', '1', '2', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB12	v4l2_fourcc('C', '1', '2', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR14	v4l2_fourcc('C', '1', '4', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG14	v4l2_fourcc('C', '1', '4', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG14	v4l2_fourcc('C', '1', '4', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB14	v4l2_fourcc('C', '1', '4', 'R')
+

These seems correct to me as well

Thanks
j

Quoted 7 lines
include/uapi/linux/videodev2.h +0 -1
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
 #define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
--

2.34.1

#3 lore raw

RE: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

In reply to Daniel Scally

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

Which path are you referring here?

In the full bypass mode, the data will be stored according to MIPI standard so 32bit.

In (non)-Image Processing case the data is packed into 256-bits.

I maybe misunderstanding here can you please clarify.

Quoted 340 lines
---
 .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
 .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-common.c         |  12 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
 include/uapi/linux/videodev2.h                |  16 ++
 5 files changed, 184 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-

cru.rst

Documentation/userspace-api/media/v4l/pixfmt-bayer.rst +1 -0
index ed3eb432967d..658068364ea1 100644
@@ -31,3 +31,4 @@ orders. See also `the Wikipedia article on Bayer filter
     pixfmt-srggb14
     pixfmt-srggb14p
     pixfmt-srggb16
+    pixfmt-srggbnn-cru
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +44 -0
new file mode 100644
index 000000000000..a169b7bbef79
@@ -0,0 +1,143 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
+
+***********************************************************************
+*******************************************************************
+V4L2_PIX_FMT_CRU_SBGGRnn ('CnnB'), V4L2_PIX_FMT_CRU_SGBRGnn ('CnnG'),
+V4L2_PIX_FMT_CRU_SGRBGnn ('Cnng'), V4L2_PIX_FMT_CRU_SRGGBnn ('CnnR')
+***********************************************************************
+*******************************************************************
+
+========================================================
+Renesas Camera Receiver Unit 64-bit packed pixel formats
+========================================================
+
+| V4L2_PIX_FMT_CRU_SBGGR10 (C10B)
+| V4L2_PIX_FMT_CRU_SGBRG10 (C10G)
+| V4L2_PIX_FMT_CRU_SGRBG10 (C10g)
+| V4L2_PIX_FMT_CRU_SRGGB10 (C10R)
+| V4L2_PIX_FMT_CRU_SBGGR12 (C12B)
+| V4L2_PIX_FMT_CRU_SGBRG12 (C12G)
+| V4L2_PIX_FMT_CRU_SGRBG12 (C12g)
+| V4L2_PIX_FMT_CRU_SRGGB12 (C12R)
+| V4L2_PIX_FMT_CRU_SBGGR14 (C14B)
+| V4L2_PIX_FMT_CRU_SGBRG14 (C14G)
+| V4L2_PIX_FMT_CRU_SGRBG14 (C14g)
+| V4L2_PIX_FMT_CRU_SRGGB14 (C14R)
+
+Description
+===========
+
+These pixel formats are some of the available output formats for the
+Camera Receiver Unit in the Renesas RZ/G2L and V2H SoCs. They are raw
+sRGB / Bayer formats which pack pixels contiguously into 64-bit units,
+with the 4 or 8 most significant bits padded.
+
+The packing format is similar to the IPU3 packing formats defined in
+:ref:`v4l2-pix-fmt-ipu3-sbggr10`, albeit with the packing performed
+over a much shorter window.
+
+**Byte Order**
+
+.. flat-table:: RGB formats
+    :header-rows:  2
+    :stub-columns: 0
+    :widths: 36 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +102 -0
+    :fill-cells:
+
+    * - :rspan:`1` Pixel Format Code
+      - :cspan:`63` Data organization
+    * - 63
+      - 62
+      - 61
+      - 60
+      - 59
+      - 58
+      - 57
+      - 56
+      - 55
+      - 54
+      - 53
+      - 52
+      - 51
+      - 50
+      - 49
+      - 48
+      - 47
+      - 46
+      - 45
+      - 44
+      - 43
+      - 42
+      - 41
+      - 40
+      - 39
+      - 38
+      - 37
+      - 36
+      - 35
+      - 34
+      - 33
+      - 32
+      - 31
+      - 30
+      - 29
+      - 28
+      - 27
+      - 26
+      - 25
+      - 24
+      - 23
+      - 22
+      - 21
+      - 20
+      - 19
+      - 18
+      - 17
+      - 16
+      - 15
+      - 14
+      - 13
+      - 12
+      - 11
+      - 10
+      - 9
+      - 8
+      - 7
+      - 6
+      - 5
+      - 4
+      - 3
+      - 2
+      - 1
+      - 0
+    * - V4L2_PIX_FMT_CRU_SBGGR10
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`9` P5
+      - :cspan:`9` P4
+      - :cspan:`9` P3
+      - :cspan:`9` P2
+      - :cspan:`9` P1
+      - :cspan:`9` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR12
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`11` P4
+      - :cspan:`11` P3
+      - :cspan:`11` P2
+      - :cspan:`11` P1
+      - :cspan:`11` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR14
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`13` P3
+      - :cspan:`13` P2
+      - :cspan:`13` P1
+      - :cspan:`13` P0
drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-common.c +0 -0

core/v4l2-common.c
index 0a2f4f0d0a07..ca78d26071c7 100644

drivers/media/v4l2-core/v4l2-common.c +1 -0
@@ -329,10 +329,22 @@ const struct v4l2_format_info *v4l2_format_info(u32
 format)
 		{ .format = V4L2_PIX_FMT_SGBRG10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SGRBG10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
 		{ .format = V4L2_PIX_FMT_SRGGB10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SBGGR12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SGBRG12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SGRBG12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SRGGB12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +0 -0
 	};
 	unsigned int i;
drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-ioctl.c +0 -0

core/v4l2-ioctl.c
index e14db67be97c..9db0ec4a5d77 100644

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1408,6 +1408,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
 	case V4L2_PIX_FMT_SGBRG10DPCM8:	descr = "8-bit Bayer GBGB/RGRG
 (DPCM)"; break;
 	case V4L2_PIX_FMT_SGRBG10DPCM8:	descr = "8-bit Bayer GRGR/BGBG
 (DPCM)"; break;
 	case V4L2_PIX_FMT_SRGGB10DPCM8:	descr = "8-bit Bayer RGRG/GBGB

(DPCM)"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR10:	descr = "10-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG10:	descr = "10-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG10:	descr = "10-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB10:	descr = "10-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR12: descr = "12-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG12: descr = "12-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG12: descr = "12-bit Bayer GRGR/BGBG";
break;

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1416,6 +1420,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
 	case V4L2_PIX_FMT_SGBRG12P:	descr = "12-bit Bayer GBGB/RGRG
 Packed"; break;
 	case V4L2_PIX_FMT_SGRBG12P:	descr = "12-bit Bayer GRGR/BGBG
 Packed"; break;
 	case V4L2_PIX_FMT_SRGGB12P:	descr = "12-bit Bayer RGRG/GBGB

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR12:	descr = "12-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG12:	descr = "12-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG12:	descr = "12-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB12:	descr = "12-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR14: descr = "14-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG14: descr = "14-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG14: descr = "14-bit Bayer GRGR/BGBG";
break;

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1424,6 +1432,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
 	case V4L2_PIX_FMT_SGBRG14P:	descr = "14-bit Bayer GBGB/RGRG
 Packed"; break;
 	case V4L2_PIX_FMT_SGRBG14P:	descr = "14-bit Bayer GRGR/BGBG
 Packed"; break;
 	case V4L2_PIX_FMT_SRGGB14P:	descr = "14-bit Bayer RGRG/GBGB

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR14:	descr = "14-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG14:	descr = "14-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG14:	descr = "14-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB14:	descr = "14-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG";
break;

(quoted diff) +0 -0

b/include/uapi/linux/videodev2.h index 725e86c4bbbd..8f0e3d8215ab 100644

include/uapi/linux/videodev2.h +16 -0
@@ -828,6 +828,22 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B')
 /* PiSP 8-bit mode 2 compressed BGGR bayer */
 #define V4L2_PIX_FMT_PISP_COMP2_MONO	v4l2_fourcc('P', 'C', '2', 'M')
 /* PiSP 8-bit mode 2 compressed monochrome */
 
+/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels
 */
+#define V4L2_PIX_FMT_CRU_SBGGR10	v4l2_fourcc('C', '1', '0', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG10	v4l2_fourcc('C', '1', '0', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG10	v4l2_fourcc('C', '1', '0', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB10	v4l2_fourcc('C', '1', '0', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR12	v4l2_fourcc('C', '1', '2', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG12	v4l2_fourcc('C', '1', '2', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG12	v4l2_fourcc('C', '1', '2', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB12	v4l2_fourcc('C', '1', '2', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR14	v4l2_fourcc('C', '1', '4', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG14	v4l2_fourcc('C', '1', '4', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG14	v4l2_fourcc('C', '1', '4', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB14	v4l2_fourcc('C', '1', '4', 'R')
+
Quoted 7 lines

/* SDR formats - used only for Software Defined Radio devices */
#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ
u8 */
#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ
u16le */
--
2.34.1

Cheers,
Prabhakar

author
#4 lore raw

Re: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

Morning Prabhakar

Quoted 13 lines · Prabhakar Mahadev Lad

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

Quoted 7 lines

Which path are you referring here?

In the full bypass mode, the data will be stored according to MIPI standard so 32bit.

In (non)-Image Processing case the data is packed into 256-bits.

I maybe misunderstanding here can you please clarify.

It's not the full bypass mode, but the formats labelled RAW10/12/14 in Table 9.1-14 of the RZ/G2L documentation. The table describes up to 256-bits, but the packing for the RAW formats seems to be in 64-bit units that are repeated 4 times. As I understand it it's the same path as for the RAW8 output enabled in your recent series.

Thanks

Dan

Quoted 350 lines
Quoted 341 lines
---
  .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
  .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
  drivers/media/v4l2-core/v4l2-common.c         |  12 ++
  drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
  include/uapi/linux/videodev2.h                |  16 ++
  5 files changed, 184 insertions(+)

create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-
cru.rst

Documentation/userspace-api/media/v4l/pixfmt-bayer.rst +1 -0
index ed3eb432967d..658068364ea1 100644
@@ -31,3 +31,4 @@ orders. See also `the Wikipedia article on Bayer filter
      pixfmt-srggb14
      pixfmt-srggb14p
      pixfmt-srggb16
+    pixfmt-srggbnn-cru
Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +44 -0
new file mode 100644
index 000000000000..a169b7bbef79
@@ -0,0 +1,143 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
+
+***********************************************************************
+*******************************************************************
+V4L2_PIX_FMT_CRU_SBGGRnn ('CnnB'), V4L2_PIX_FMT_CRU_SGBRGnn ('CnnG'),
+V4L2_PIX_FMT_CRU_SGRBGnn ('Cnng'), V4L2_PIX_FMT_CRU_SRGGBnn ('CnnR')
+***********************************************************************
+*******************************************************************
+
+========================================================
+Renesas Camera Receiver Unit 64-bit packed pixel formats
+========================================================
+
+| V4L2_PIX_FMT_CRU_SBGGR10 (C10B)
+| V4L2_PIX_FMT_CRU_SGBRG10 (C10G)
+| V4L2_PIX_FMT_CRU_SGRBG10 (C10g)
+| V4L2_PIX_FMT_CRU_SRGGB10 (C10R)
+| V4L2_PIX_FMT_CRU_SBGGR12 (C12B)
+| V4L2_PIX_FMT_CRU_SGBRG12 (C12G)
+| V4L2_PIX_FMT_CRU_SGRBG12 (C12g)
+| V4L2_PIX_FMT_CRU_SRGGB12 (C12R)
+| V4L2_PIX_FMT_CRU_SBGGR14 (C14B)
+| V4L2_PIX_FMT_CRU_SGBRG14 (C14G)
+| V4L2_PIX_FMT_CRU_SGRBG14 (C14g)
+| V4L2_PIX_FMT_CRU_SRGGB14 (C14R)
+
+Description
+===========
+
+These pixel formats are some of the available output formats for the
+Camera Receiver Unit in the Renesas RZ/G2L and V2H SoCs. They are raw
+sRGB / Bayer formats which pack pixels contiguously into 64-bit units,
+with the 4 or 8 most significant bits padded.
+
+The packing format is similar to the IPU3 packing formats defined in
+:ref:`v4l2-pix-fmt-ipu3-sbggr10`, albeit with the packing performed
+over a much shorter window.
+
+**Byte Order**
+
+.. flat-table:: RGB formats
+    :header-rows:  2
+    :stub-columns: 0
+    :widths: 36 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Documentation/userspace-api/media/v4l/pixfmt-srggbnn-cru.rst new file +102 -0
+    :fill-cells:
+
+    * - :rspan:`1` Pixel Format Code
+      - :cspan:`63` Data organization
+    * - 63
+      - 62
+      - 61
+      - 60
+      - 59
+      - 58
+      - 57
+      - 56
+      - 55
+      - 54
+      - 53
+      - 52
+      - 51
+      - 50
+      - 49
+      - 48
+      - 47
+      - 46
+      - 45
+      - 44
+      - 43
+      - 42
+      - 41
+      - 40
+      - 39
+      - 38
+      - 37
+      - 36
+      - 35
+      - 34
+      - 33
+      - 32
+      - 31
+      - 30
+      - 29
+      - 28
+      - 27
+      - 26
+      - 25
+      - 24
+      - 23
+      - 22
+      - 21
+      - 20
+      - 19
+      - 18
+      - 17
+      - 16
+      - 15
+      - 14
+      - 13
+      - 12
+      - 11
+      - 10
+      - 9
+      - 8
+      - 7
+      - 6
+      - 5
+      - 4
+      - 3
+      - 2
+      - 1
+      - 0
+    * - V4L2_PIX_FMT_CRU_SBGGR10
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`9` P5
+      - :cspan:`9` P4
+      - :cspan:`9` P3
+      - :cspan:`9` P2
+      - :cspan:`9` P1
+      - :cspan:`9` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR12
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`11` P4
+      - :cspan:`11` P3
+      - :cspan:`11` P2
+      - :cspan:`11` P1
+      - :cspan:`11` P0
+    * - V4L2_PIX_FMT_CRU_SBGGR14
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - 0
+      - :cspan:`13` P3
+      - :cspan:`13` P2
+      - :cspan:`13` P1
+      - :cspan:`13` P0
drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-common.c +0 -0

core/v4l2-common.c
index 0a2f4f0d0a07..ca78d26071c7 100644

drivers/media/v4l2-core/v4l2-common.c +1 -0
@@ -329,10 +329,22 @@ const struct v4l2_format_info *v4l2_format_info(u32
 format)
  		{ .format = V4L2_PIX_FMT_SGBRG10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
  		{ .format = V4L2_PIX_FMT_SGRBG10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
  		{ .format = V4L2_PIX_FMT_SRGGB10DPCM8,	.pixel_enc =
 V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0,
 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB10,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 6, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SBGGR12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SGBRG12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SGRBG12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_SRGGB12, .pixel_enc =
V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB12,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 5, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SBGGR14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGBRG14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SGRBG14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },

drivers/media/v4l2-core/v4l2-common.c +1 -0
+		{ .format = V4L2_PIX_FMT_CRU_SRGGB14,	.pixel_enc =

V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 8, 0, 0, 0 }, .bpp_div = { 4, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
};
unsigned int i;

drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-ioctl.c +0 -0

core/v4l2-ioctl.c
index e14db67be97c..9db0ec4a5d77 100644

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1408,6 +1408,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
  	case V4L2_PIX_FMT_SGBRG10DPCM8:	descr = "8-bit Bayer GBGB/RGRG
 (DPCM)"; break;
  	case V4L2_PIX_FMT_SGRBG10DPCM8:	descr = "8-bit Bayer GRGR/BGBG
 (DPCM)"; break;
  	case V4L2_PIX_FMT_SRGGB10DPCM8:	descr = "8-bit Bayer RGRG/GBGB

(DPCM)"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR10:	descr = "10-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG10:	descr = "10-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG10:	descr = "10-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB10:	descr = "10-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR12: descr = "12-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG12: descr = "12-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG12: descr = "12-bit Bayer GRGR/BGBG";
break;

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1416,6 +1420,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
  	case V4L2_PIX_FMT_SGBRG12P:	descr = "12-bit Bayer GBGB/RGRG
 Packed"; break;
  	case V4L2_PIX_FMT_SGRBG12P:	descr = "12-bit Bayer GRGR/BGBG
 Packed"; break;
  	case V4L2_PIX_FMT_SRGGB12P:	descr = "12-bit Bayer RGRG/GBGB

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR12:	descr = "12-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG12:	descr = "12-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG12:	descr = "12-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB12:	descr = "12-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR14: descr = "14-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG14: descr = "14-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG14: descr = "14-bit Bayer GRGR/BGBG";
break;

drivers/media/v4l2-core/v4l2-ioctl.c +0 -0
@@ -1424,6 +1432,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc
 *fmt)
  	case V4L2_PIX_FMT_SGBRG14P:	descr = "14-bit Bayer GBGB/RGRG
 Packed"; break;
  	case V4L2_PIX_FMT_SGRBG14P:	descr = "14-bit Bayer GRGR/BGBG
 Packed"; break;
  	case V4L2_PIX_FMT_SRGGB14P:	descr = "14-bit Bayer RGRG/GBGB

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SBGGR14:	descr = "14-bit Bayer BGGR CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGBRG14:	descr = "14-bit Bayer GBRG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SGRBG14:	descr = "14-bit Bayer GRBG CRU

Packed"; break;

drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
+	case V4L2_PIX_FMT_CRU_SRGGB14:	descr = "14-bit Bayer RGGB CRU

Packed"; break;
case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR";
break;
case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG";
break;
case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG";
break;

(quoted diff) +0 -0

b/include/uapi/linux/videodev2.h index 725e86c4bbbd..8f0e3d8215ab 100644

include/uapi/linux/videodev2.h +16 -0
@@ -828,6 +828,22 @@ struct v4l2_pix_format {
  #define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B')
 /* PiSP 8-bit mode 2 compressed BGGR bayer */
  #define V4L2_PIX_FMT_PISP_COMP2_MONO	v4l2_fourcc('P', 'C', '2', 'M')
 /* PiSP 8-bit mode 2 compressed monochrome */
 
+/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels
 */
+#define V4L2_PIX_FMT_CRU_SBGGR10	v4l2_fourcc('C', '1', '0', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG10	v4l2_fourcc('C', '1', '0', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG10	v4l2_fourcc('C', '1', '0', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB10	v4l2_fourcc('C', '1', '0', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR12	v4l2_fourcc('C', '1', '2', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG12	v4l2_fourcc('C', '1', '2', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG12	v4l2_fourcc('C', '1', '2', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB12	v4l2_fourcc('C', '1', '2', 'R')
+
+#define V4L2_PIX_FMT_CRU_SBGGR14	v4l2_fourcc('C', '1', '4', 'B')
+#define V4L2_PIX_FMT_CRU_SGBRG14	v4l2_fourcc('C', '1', '4', 'G')
+#define V4L2_PIX_FMT_CRU_SGRBG14	v4l2_fourcc('C', '1', '4', 'g')
+#define V4L2_PIX_FMT_CRU_SRGGB14	v4l2_fourcc('C', '1', '4', 'R')
+
Quoted 7 lines

/* SDR formats - used only for Software Defined Radio devices */
#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ
u8 */
#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ
u16le */
--
2.34.1

Cheers,
Prabhakar

#5 lore raw

Re: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

Hi Dan,

Quoted 23 lines · Dan Scally

Morning Prabhakar

Quoted 19 lines · Prabhakar Mahadev Lad

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

Which path are you referring here?

In the full bypass mode, the data will be stored according to MIPI standard so 32bit.

In (non)-Image Processing case the data is packed into 256-bits.

Quoted 8 lines
Quoted 1 line

I maybe misunderstanding here can you please clarify.

It's not the full bypass mode, but the formats labelled RAW10/12/14 in Table 9.1-14 of the RZ/G2L documentation. The table describes up to 256-bits, but the packing for the RAW formats seems to be in 64-bit units that are repeated 4 times. As I understand it it's the same path as for the RAW8 output enabled in your recent series.

Thanks for the explanation, I agree with the changes.

Cheers,
Prabhakar

#6 lore raw

RE: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

In reply to Daniel Scally

Hi Dan,

Quoted 18 lines

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

---
 .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
 .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-common.c         |  12 ++
 drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
 include/uapi/linux/videodev2.h                |  16 ++
 5 files changed, 184 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-
Quoted 2 lines

cru.rst

When trying to build the htmldocs I get the below warnings, is this expected?

linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb14

Cheers,
Prabhakar

author
#7 lore raw

Re: [PATCH 1/4] media: v4l2: Add Renesas Camera Receiver Unit pixel formats

Hi Prabhakar

Quoted 22 lines · Prabhakar Mahadev Lad

Hi Dan,

Quoted 17 lines

From: Daniel Scally <[email protected]>

The Renesas Camera Receiver Unit in the RZ/G2L and RZ/V2H SoCs can output RAW data captured from an image sensor without conversion to an RGB/YUV format. In that case the data are packed into 64-bit blocks, with a variable amount of padding in the most significant bits depending on the bitdepth of the data. Add new V4L2 pixel format codes for the new formats, along with documentation to describe them.

---
  .../userspace-api/media/v4l/pixfmt-bayer.rst  |   1 +
  .../media/v4l/pixfmt-srggbnn-cru.rst          | 143 ++++++++++++++++++
  drivers/media/v4l2-core/v4l2-common.c         |  12 ++
  drivers/media/v4l2-core/v4l2-ioctl.c          |  12 ++
  include/uapi/linux/videodev2.h                |  16 ++
  5 files changed, 184 insertions(+)
Quoted 3 lines

create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-srggbnn-
cru.rst

Quoted 1 line

When trying to build the htmldocs I get the below warnings, is this expected?

Oops - no, sorry, not sure how I missed those! When you've posted your next version I'll rebase this series on top, and I'll fix these warnings then.

Thanks

Dan

Quoted 16 lines

linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb10 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb12 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sbggr14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgbrg14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-sgrbg14 linux/Documentation/output/videodev2.h.rst:6: WARNING: undefined label: v4l2-pix-fmt-cru-srggb14

Cheers,
Prabhakar

#8 lore raw

PATCH 2/4 media: platform: rzg2l-cru: Use v4l2_get_link_freq()

In reply to Daniel Scally

From: Daniel Scally <[email protected]>

The rzg2l_csi2_calc_mbps() function currently tries to calculate the link frequency for a CSI2 bus using the V4L2_CID_PIXEL_RATE control of the remote subdevice. Switch the function to v4l2_get_link_freq() which correctly targets V4L2_CID_LINK_FREQ before falling back on V4L2_CID_PIXEL_RATE if the former is unavailable.

---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 25 ++++++++-----------
 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +10 -15
index d46f0bd10cec..9609ca2a2f67 100644
@@ -242,28 +242,23 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2 *csi2)
 	const struct rzg2l_csi2_format *format;
 	const struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_subdev_state *state;
-	struct v4l2_ctrl *ctrl;
 	u64 mbps;
 
-	/* Read the pixel rate control from remote. */
-	ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE);
-	if (!ctrl) {
-		dev_err(csi2->dev, "no pixel rate control in subdev %s\n",
-			source->name);
-		return -EINVAL;
-	}
-
 	state = v4l2_subdev_lock_and_get_active_state(&csi2->subdev);
 	fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK);
 	format = rzg2l_csi2_code_to_fmt(fmt->code);
 	v4l2_subdev_unlock_state(state);
 
-	/*
-	 * Calculate hsfreq in Mbps
-	 * hsfreq = (pixel_rate * bits_per_sample) / number_of_lanes
-	 */
-	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * format->bpp;
-	do_div(mbps, csi2->lanes * 1000000);
+	/* Read the link frequency from remote subdevice. */
+	mbps = v4l2_get_link_freq(source->ctrl_handler, format->bpp,
+				  csi2->lanes);
+	if (mbps < 0) {
+		dev_err(csi2->dev, "can't retrieve link freq from subdev %s\n",
+			source->name);
+		return -EINVAL;
+	}
+
+	do_div(mbps, 1000000);
 
 	return mbps;
 }
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/4
#9 lore raw

Re: [PATCH 2/4] media: platform: rzg2l-cru: Use v4l2_get_link_freq()

Hi Dan

Quoted 9 lines · Daniel Scally

From: Daniel Scally <[email protected]>

The rzg2l_csi2_calc_mbps() function currently tries to calculate the link frequency for a CSI2 bus using the V4L2_CID_PIXEL_RATE control of the remote subdevice. Switch the function to v4l2_get_link_freq() which correctly targets V4L2_CID_LINK_FREQ before falling back on V4L2_CID_PIXEL_RATE if the former is unavailable.

Seems correct, Prabhakar maybe could test to confirm this still works with drivers that use PIXEL_RATE

Quoted 51 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 25 ++++++++-----------
 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +10 -16
index d46f0bd10cec..9609ca2a2f67 100644
@@ -242,28 +242,23 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2 *csi2)
 	const struct rzg2l_csi2_format *format;
 	const struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_subdev_state *state;
-	struct v4l2_ctrl *ctrl;
 	u64 mbps;
 
-	/* Read the pixel rate control from remote. */
-	ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE);
-	if (!ctrl) {
-		dev_err(csi2->dev, "no pixel rate control in subdev %s\n",
-			source->name);
-		return -EINVAL;
-	}
-
 	state = v4l2_subdev_lock_and_get_active_state(&csi2->subdev);
 	fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK);
 	format = rzg2l_csi2_code_to_fmt(fmt->code);
 	v4l2_subdev_unlock_state(state);
 
-	/*
-	 * Calculate hsfreq in Mbps
-	 * hsfreq = (pixel_rate * bits_per_sample) / number_of_lanes
-	 */
-	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * format->bpp;
-	do_div(mbps, csi2->lanes * 1000000);
+	/* Read the link frequency from remote subdevice. */
+	mbps = v4l2_get_link_freq(source->ctrl_handler, format->bpp,
+				  csi2->lanes);
+	if (mbps < 0) {
+		dev_err(csi2->dev, "can't retrieve link freq from subdev %s\n",
+			source->name);
+		return -EINVAL;
+	}
+
+	do_div(mbps, 1000000);
 
 	return mbps;
 }
--

2.34.1

Reviewed-by on v1 2/4
#10 lore raw

Re: [PATCH 2/4] media: platform: rzg2l-cru: Use v4l2_get_link_freq()

In reply to Daniel Scally

Hi Dan,

Thank you for the patch.

Quoted 9 lines · Daniel Scally

From: Daniel Scally <[email protected]>

The rzg2l_csi2_calc_mbps() function currently tries to calculate the link frequency for a CSI2 bus using the V4L2_CID_PIXEL_RATE control of the remote subdevice. Switch the function to v4l2_get_link_freq() which correctly targets V4L2_CID_LINK_FREQ before falling back on V4L2_CID_PIXEL_RATE if the former is unavailable.

Quoted 47 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 25 ++++++++-----------
 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +10 -15
index d46f0bd10cec..9609ca2a2f67 100644
@@ -242,28 +242,23 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2 *csi2)
 	const struct rzg2l_csi2_format *format;
 	const struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_subdev_state *state;
-	struct v4l2_ctrl *ctrl;
 	u64 mbps;
 
-	/* Read the pixel rate control from remote. */
-	ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE);
-	if (!ctrl) {
-		dev_err(csi2->dev, "no pixel rate control in subdev %s\n",
-			source->name);
-		return -EINVAL;
-	}
-
 	state = v4l2_subdev_lock_and_get_active_state(&csi2->subdev);
 	fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK);
 	format = rzg2l_csi2_code_to_fmt(fmt->code);
 	v4l2_subdev_unlock_state(state);
 
-	/*
-	 * Calculate hsfreq in Mbps
-	 * hsfreq = (pixel_rate * bits_per_sample) / number_of_lanes
-	 */
-	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * format->bpp;
-	do_div(mbps, csi2->lanes * 1000000);
+	/* Read the link frequency from remote subdevice. */
+	mbps = v4l2_get_link_freq(source->ctrl_handler, format->bpp,
+				  csi2->lanes);
+	if (mbps < 0) {
+		dev_err(csi2->dev, "can't retrieve link freq from subdev %s\n",
+			source->name);
+		return -EINVAL;
+	}
+
+	do_div(mbps, 1000000);
 
 	return mbps;
 }
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by Tested-by on v1 2/4
#11 lore raw

RE: [PATCH 2/4] media: platform: rzg2l-cru: Use v4l2_get_link_freq()

In reply to Daniel Scally

Hi Daniel,

Thank you for the patch.

Quoted 8 lines

From: Daniel Scally <[email protected]>

The rzg2l_csi2_calc_mbps() function currently tries to calculate the link frequency for a CSI2 bus using the V4L2_CID_PIXEL_RATE control of the remote subdevice. Switch the function to v4l2_get_link_freq() which correctly targets V4L2_CID_LINK_FREQ before falling back on V4L2_CID_PIXEL_RATE if the former is unavailable.

Quoted 5 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 25 ++++++++-----------
 1 file changed, 10 insertions(+), 15 deletions(-)

Cheers,
Prabhakar

Quoted 48 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +10 -15
index d46f0bd10cec..9609ca2a2f67 100644
@@ -242,28 +242,23 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2
 *csi2)
 	const struct rzg2l_csi2_format *format;
 	const struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_subdev_state *state;
-	struct v4l2_ctrl *ctrl;
 	u64 mbps;
 
-	/* Read the pixel rate control from remote. */
-	ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE);
-	if (!ctrl) {
-		dev_err(csi2->dev, "no pixel rate control in subdev %s\n",
-			source->name);
-		return -EINVAL;
-	}
-
 	state = v4l2_subdev_lock_and_get_active_state(&csi2->subdev);
 	fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK);
 	format = rzg2l_csi2_code_to_fmt(fmt->code);
 	v4l2_subdev_unlock_state(state);
 
-	/*
-	 * Calculate hsfreq in Mbps
-	 * hsfreq = (pixel_rate * bits_per_sample) / number_of_lanes
-	 */
-	mbps = v4l2_ctrl_g_ctrl_int64(ctrl) * format->bpp;
-	do_div(mbps, csi2->lanes * 1000000);
+	/* Read the link frequency from remote subdevice. */
+	mbps = v4l2_get_link_freq(source->ctrl_handler, format->bpp,
+				  csi2->lanes);
+	if (mbps < 0) {
+		dev_err(csi2->dev, "can't retrieve link freq from subdev
 %s\n",
+			source->name);
+		return -EINVAL;
+	}
+
+	do_div(mbps, 1000000);
 

return mbps;
}
--
2.34.1

#12 lore raw

PATCH 3/4 media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

In reply to Daniel Scally

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +0 -3
index dc50a5feb3de..858098b8a13f 100644
@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
  * @code: Media bus code
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
  * @icndmr: ICnDMR register value
  */
 struct rzg2l_cru_ip_format {
 	u32 code;
 	u32 format;
 	u32 datatype;
-	u8 bpp;
 	u32 icndmr;
 };
 
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
 struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
 
 const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format);
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index);
 int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);
 
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -16
index 9bb192655f25..f2fea3a63444 100644
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
 		.format = V4L2_PIX_FMT_UYVY,
 		.datatype = MIPI_CSI2_DT_YUV422_8B,
-		.bpp = 2,
 		.icndmr = ICnDMR_YCMODE_UYVY,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
 		.format = V4L2_PIX_FMT_SBGGR8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
 		.format = V4L2_PIX_FMT_SGBRG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
 		.format = V4L2_PIX_FMT_SGRBG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
 		.format = V4L2_PIX_FMT_SRGGB8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 };
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
 	return NULL;
 }
 
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
-		if (rzg2l_cru_ip_formats[i].format == format)
-			return rzg2l_cru_ip_formats[i].bpp;
-
-	return 0;
-}
-
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index)
 {
 	if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +2 -19
index 61e2f23053ee..01b39a2395df 100644
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
  * V4L2 stuff
  */
 
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
-{
-	u8 bpp;
-
-	bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
-	if (WARN_ON(!bpp))
-		return 0;
-
-	return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
-{
-	return pix->bytesperline * pix->height;
-}
 
 static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 				   struct v4l2_pix_format *pix)
 {
-	if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+	if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
 		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
 
 	switch (pix->field) {
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
 			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
 
-	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
-	pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+	v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
 
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 3/4
#13 lore raw

Re: [PATCH 3/4] media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

Hi Dan

Quoted 137 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +0 -3
index dc50a5feb3de..858098b8a13f 100644
@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
  * @code: Media bus code
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
  * @icndmr: ICnDMR register value
  */
 struct rzg2l_cru_ip_format {
 	u32 code;
 	u32 format;
 	u32 datatype;
-	u8 bpp;
 	u32 icndmr;
 };
 
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
 struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
 
 const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format);
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index);
 int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);
 
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -16
index 9bb192655f25..f2fea3a63444 100644
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
 		.format = V4L2_PIX_FMT_UYVY,
 		.datatype = MIPI_CSI2_DT_YUV422_8B,
-		.bpp = 2,
 		.icndmr = ICnDMR_YCMODE_UYVY,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
 		.format = V4L2_PIX_FMT_SBGGR8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
 		.format = V4L2_PIX_FMT_SGBRG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
 		.format = V4L2_PIX_FMT_SGRBG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
 		.format = V4L2_PIX_FMT_SRGGB8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 };
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
 	return NULL;
 }
 
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
-		if (rzg2l_cru_ip_formats[i].format == format)
-			return rzg2l_cru_ip_formats[i].bpp;
-
-	return 0;
-}
-
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index)
 {
 	if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +1 -17
index 61e2f23053ee..01b39a2395df 100644
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
  * V4L2 stuff
  */
 
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
-{
-	u8 bpp;
-
-	bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
-	if (WARN_ON(!bpp))
-		return 0;
-
-	return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
-{
-	return pix->bytesperline * pix->height;
-}
 
 static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 				   struct v4l2_pix_format *pix)
 {
-	if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+	if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
 		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
 
 	switch (pix->field) {

drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru, · line 827

Quoted 6 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +1 -2
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
 			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
 
-	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
-	pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+	v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);

Looks good to me

Thanks
j

Quoted 7 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +0 -1
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
--

2.34.1

Reviewed-by on v1 3/4
#14 lore raw

Re: [PATCH 3/4] media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

In reply to Daniel Scally

Hi Dan,

Thank you for the patch.

Quoted 7 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

Quoted 5 lines

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

Quoted 134 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +0 -3
index dc50a5feb3de..858098b8a13f 100644
@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
  * @code: Media bus code
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
  * @icndmr: ICnDMR register value
  */
 struct rzg2l_cru_ip_format {
 	u32 code;
 	u32 format;
 	u32 datatype;
-	u8 bpp;
 	u32 icndmr;
 };
 
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
 struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
 
 const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format);
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index);
 int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);
 
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -16
index 9bb192655f25..f2fea3a63444 100644
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
 		.format = V4L2_PIX_FMT_UYVY,
 		.datatype = MIPI_CSI2_DT_YUV422_8B,
-		.bpp = 2,
 		.icndmr = ICnDMR_YCMODE_UYVY,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
 		.format = V4L2_PIX_FMT_SBGGR8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
 		.format = V4L2_PIX_FMT_SGBRG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
 		.format = V4L2_PIX_FMT_SGRBG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
 		.format = V4L2_PIX_FMT_SRGGB8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 };
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
 	return NULL;
 }
 
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
-		if (rzg2l_cru_ip_formats[i].format == format)
-			return rzg2l_cru_ip_formats[i].bpp;
-
-	return 0;
-}
-
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index)
 {
 	if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +2 -19
index 61e2f23053ee..01b39a2395df 100644
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
  * V4L2 stuff
  */
 
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
-{
-	u8 bpp;
-
-	bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
-	if (WARN_ON(!bpp))
-		return 0;
-
-	return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
-{
-	return pix->bytesperline * pix->height;
-}
 
 static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 				   struct v4l2_pix_format *pix)
 {
-	if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+	if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
 		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
 
 	switch (pix->field) {
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
 			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
 
-	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
-	pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+	v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
 
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by Tested-by on v1 3/4
#15 lore raw

RE: [PATCH 3/4] media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

In reply to Daniel Scally

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

Quoted 7 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)

This patch doesn't apply cleanly on top of media-stage + [0]

[0] https://lore.kernel.org/all/[email protected]/

Cheers,
Prabhakar

Quoted 137 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +0 -2
index dc50a5feb3de..858098b8a13f 100644
@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
  * @code: Media bus code
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
  * @icndmr: ICnDMR register value
  */
 struct rzg2l_cru_ip_format {
 	u32 code;
 	u32 format;
 	u32 datatype;
-	u8 bpp;
 	u32 icndmr;
 };
 
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct

rzg2l_cru_dev *cru); struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);

const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int
code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format); int rzg2l_cru_ip_index_to_pix_fmt(u32 index); int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -5
index 9bb192655f25..f2fea3a63444 100644
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format
 rzg2l_cru_ip_formats[] = {
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
 		.format = V4L2_PIX_FMT_UYVY,
 		.datatype = MIPI_CSI2_DT_YUV422_8B,
-		.bpp = 2,
 		.icndmr = ICnDMR_YCMODE_UYVY,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
 		.format = V4L2_PIX_FMT_SBGGR8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
 		.format = V4L2_PIX_FMT_SGBRG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
 		.format = V4L2_PIX_FMT_SGRBG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
 		.format = V4L2_PIX_FMT_SRGGB8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},

};

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -10
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format
 *rzg2l_cru_ip_code_to_fmt(unsigned int code)
 	return NULL;
 }
 
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format) -{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
-		if (rzg2l_cru_ip_formats[i].format == format)
-			return rzg2l_cru_ip_formats[i].bpp;
-
-	return 0;
-}
-
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index)  {
 	if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats)) diff --git

a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c index 61e2f23053ee..01b39a2395df 100644

drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +2 -17
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev
 *cru)
  * V4L2 stuff
  */
 
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix) -{
-	u8 bpp;
-
-	bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
-	if (WARN_ON(!bpp))
-		return 0;
-
-	return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix) -{
-	return pix->bytesperline * pix->height;
-}
 
 static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 				   struct v4l2_pix_format *pix)
 {
-	if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+	if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
 		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
 
 	switch (pix->field) {
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct
 rzg2l_cru_dev *cru,
 	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH,
 1,
 			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2,
 0);
 
-	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
-	pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+	v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +0 -1
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
--

2.34.1

#16 lore raw

Re: [PATCH 3/4] media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

Quoted 21 lines · Prabhakar Mahadev Lad

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

Quoted 7 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)
Quoted 6 lines

This patch doesn't apply cleanly on top of media-stage + [0]

[0] https://lore.kernel.org/all/[email protected]/

Is it fine with you to wait for v3 of your series and rebase this one on top ?

Quoted 134 lines
Quoted 134 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h +0 -2
index dc50a5feb3de..858098b8a13f 100644
@@ -68,14 +68,12 @@ struct rzg2l_cru_ip {
  * @code: Media bus code
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @datatype: MIPI CSI2 data type
- * @bpp: bytes per pixel
  * @icndmr: ICnDMR register value
  */
 struct rzg2l_cru_ip_format {
 	u32 code;
 	u32 format;
 	u32 datatype;
-	u8 bpp;
 	u32 icndmr;
 };
 
@@ -169,7 +167,6 @@ void rzg2l_cru_ip_subdev_unregister(struct

rzg2l_cru_dev *cru); struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);

const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int
code);
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format); int rzg2l_cru_ip_index_to_pix_fmt(u32 index); int rzg2l_cru_ip_pix_fmt_to_icndmr(u32 format);

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +0 -15
index 9bb192655f25..f2fea3a63444 100644
@@ -16,35 +16,30 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.code = MEDIA_BUS_FMT_UYVY8_1X16,
 		.format = V4L2_PIX_FMT_UYVY,
 		.datatype = MIPI_CSI2_DT_YUV422_8B,
-		.bpp = 2,
 		.icndmr = ICnDMR_YCMODE_UYVY,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SBGGR8_1X8,
 		.format = V4L2_PIX_FMT_SBGGR8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGBRG8_1X8,
 		.format = V4L2_PIX_FMT_SGBRG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SGRBG8_1X8,
 		.format = V4L2_PIX_FMT_SGRBG8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 	{
 		.code = MEDIA_BUS_FMT_SRGGB8_1X8,
 		.format = V4L2_PIX_FMT_SRGGB8,
 		.datatype = MIPI_CSI2_DT_RAW8,
-		.bpp = 1,
 		.icndmr = 0,
 	},
 };
@@ -60,17 +55,6 @@ const struct rzg2l_cru_ip_format
 *rzg2l_cru_ip_code_to_fmt(unsigned int code)
 	return NULL;
 }
 
-u8 rzg2l_cru_ip_pix_fmt_to_bpp(u32 format) -{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++)
-		if (rzg2l_cru_ip_formats[i].format == format)
-			return rzg2l_cru_ip_formats[i].bpp;
-
-	return 0;
-}
-
 int rzg2l_cru_ip_index_to_pix_fmt(u32 index)  {
 	if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats)) diff --git

a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c index 61e2f23053ee..01b39a2395df 100644

drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +2 -17
@@ -800,27 +800,11 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev
 *cru)
  * V4L2 stuff
  */
 
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix) -{
-	u8 bpp;
-
-	bpp = rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat);
-
-	if (WARN_ON(!bpp))
-		return 0;
-
-	return pix->width * bpp;
-}
-
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix) -{
-	return pix->bytesperline * pix->height;
-}
 
 static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
 				   struct v4l2_pix_format *pix)
 {
-	if (!rzg2l_cru_ip_pix_fmt_to_bpp(pix->pixelformat))
+	if (rzg2l_cru_ip_pix_fmt_to_icndmr(pix->pixelformat) < 0)
 		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
 
 	switch (pix->field) {
@@ -840,8 +824,7 @@ static void rzg2l_cru_format_align(struct
 rzg2l_cru_dev *cru,
 	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH,
 1,
 			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2,
 0);
 
-	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
-	pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+	v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +0 -0
 	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
 		pix->width, pix->height, pix->bytesperline, pix->sizeimage);
Signature · 3 lines
Regards,

Laurent Pinchart
#17 lore raw

Re: [PATCH 3/4] media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()

Hi Laurent,

Quoted 26 lines · Laurent Pinchart
Quoted 24 lines · Prabhakar Mahadev Lad

Hi Daniel,

Thank you for the patch.

Quoted 9 lines

From: Daniel Scally <[email protected]>

Rather than open-code a calculation of the format's bytesperline and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it easier to support the CRU packed pixel formats without over complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format and the rzg2l_cru_ip_pix_fmt_to_bpp() function superfluous - remove them both.

Quoted 7 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-cru.h    |  3 ---
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 16 --------------
 .../platform/renesas/rzg2l-cru/rzg2l-video.c  | 21 ++-----------------
 3 files changed, 2 insertions(+), 38 deletions(-)
Quoted 7 lines
Quoted 3 lines

This patch doesn't apply cleanly on top of media-stage + [0]

[0] https://lore.kernel.org/all/[email protected]/

Is it fine with you to wait for v3 of your series and rebase this one on top ?

Yep, sounds good to me.

Cheers,
Prabhakar

#18 lore raw

PATCH 4/4 media: platform: rzg2l-cru: Add support for RAW10/12/14 data

In reply to Daniel Scally

From: Daniel Scally <[email protected]>

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 12 ++++
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 72 +++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +12 -0
index 9609ca2a2f67..6b83f317919f 100644
@@ -192,6 +192,18 @@ static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = {
 	{ .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, },
+	{ .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SBGGR12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGBRG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGRBG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SRGGB12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SBGGR14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGBRG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGRBG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SRGGB14_1X14, .bpp = 14, },
 };
 
 static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +72 -0

78 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#19 lore raw

Re: [PATCH 4/4] media: platform: rzg2l-cru: Add support for RAW10/12/14 data

Hi Dan

Quoted 6 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

Maybe I'm missing something for some previous series, but I see rzg2l_cru_csi2_setup() programming ICnMC with the UserDefined data type ?

Quoted 115 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 12 ++++
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 72 +++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +12 -0
index 9609ca2a2f67..6b83f317919f 100644
@@ -192,6 +192,18 @@ static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = {
 	{ .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, },
+	{ .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SBGGR12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGBRG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGRBG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SRGGB12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SBGGR14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGBRG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGRBG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SRGGB14_1X14, .bpp = 14, },
 };
 
 static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +72 -1
index f2fea3a63444..65b1cf9e553f 100644
@@ -42,6 +42,78 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.datatype = MIPI_CSI2_DT_RAW8,
 		.icndmr = 0,
 	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SBGGR10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGBRG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGRBG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SRGGB10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SBGGR12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGBRG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGRBG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SRGGB12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SBGGR14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGBRG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGRBG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SRGGB14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
 };
 
 const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
--

2.34.1

#20 lore raw

Re: [PATCH 4/4] media: platform: rzg2l-cru: Add support for RAW10/12/14 data

Quoted 5 lines · Jacopo Mondi

Hi Dan

Quoted 2 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Quoted 8 lines
Quoted 4 lines

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

Maybe I'm missing something for some previous series, but I see rzg2l_cru_csi2_setup() programming ICnMC with the UserDefined data type ?

The function should use rzg2l_cru_ip_format.datatype << 16 (with an appropriate register macro). I think I've commented on that in a previous CRU patch series from Prabhakar, but I don't recall if the comment has been addressed yet.

Quoted 111 lines
Quoted 111 lines
---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 12 ++++
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 72 +++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +12 -0
index 9609ca2a2f67..6b83f317919f 100644
@@ -192,6 +192,18 @@ static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = {
 	{ .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, },
+	{ .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SBGGR12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGBRG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGRBG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SRGGB12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SBGGR14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGBRG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGRBG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SRGGB14_1X14, .bpp = 14, },
 };
 
 static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +72 -0
index f2fea3a63444..65b1cf9e553f 100644
@@ -42,6 +42,78 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
 		.datatype = MIPI_CSI2_DT_RAW8,
 		.icndmr = 0,
 	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SBGGR10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGBRG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGRBG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SRGGB10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SBGGR12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGBRG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGRBG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SRGGB12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SBGGR14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGBRG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGRBG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SRGGB14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
 };
 
 const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
Signature · 3 lines
Regards,

Laurent Pinchart
#21 lore raw

RE: [PATCH 4/4] media: platform: rzg2l-cru: Add support for RAW10/12/14 data

Hi,

Quoted 11 lines · Jacopo Mondi
Quoted 10 lines

Hi Dan

Quoted 6 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

Quoted 9 lines
Quoted 3 lines

Maybe I'm missing something for some previous series, but I see rzg2l_cru_csi2_setup() programming ICnMC with the UserDefined data type ?

The function should use rzg2l_cru_ip_format.datatype << 16 (with an appropriate register macro). I think I've commented on that in a previous CRU patch series from Prabhakar, but I don't recall if the comment has been addressed yet.

The comments has been addressed in patch [0](the series needs to be reviewed).

[0] https://lore.kernel.org/all/[email protected]/

Cheers,
Prabhakar

#22 lore raw

Re: [PATCH 4/4] media: platform: rzg2l-cru: Add support for RAW10/12/14 data

Quoted 17 lines · Prabhakar Mahadev Lad

Hi,

Quoted 15 lines · Jacopo Mondi
Quoted 13 lines

Hi Dan

Quoted 6 lines · Daniel Scally

From: Daniel Scally <[email protected]>

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

Maybe I'm missing something for some previous series, but I see rzg2l_cru_csi2_setup() programming ICnMC with the UserDefined data type ?

Quoted 8 lines
Quoted 5 lines

The function should use rzg2l_cru_ip_format.datatype << 16 (with an appropriate register macro). I think I've commented on that in a previous CRU patch series from Prabhakar, but I don't recall if the comment has been addressed yet.

The comments has been addressed in patch [0](the series needs to be reviewed).

[0] https://lore.kernel.org/all/[email protected]/

Done :-)

A v3 is needed, I think it will be the final version.

Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by on v1 4/4
#23 lore raw

RE: [PATCH 4/4] media: platform: rzg2l-cru: Add support for RAW10/12/14 data

In reply to Daniel Scally

Hi Daniel,

Thank you for the patch.

Quoted 105 lines

From: Daniel Scally <[email protected]>

Add support to the rzg2l-cru driver to capture 10/12/14 bit bayer data and output it into the CRU's 64-bit packed pixel format.

---
 .../platform/renesas/rzg2l-cru/rzg2l-csi2.c   | 12 ++++
 .../platform/renesas/rzg2l-cru/rzg2l-ip.c     | 72 +++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +12 -0
index 9609ca2a2f67..6b83f317919f 100644
@@ -192,6 +192,18 @@ static const struct rzg2l_csi2_format
 rzg2l_csi2_formats[] = {
 	{ .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, },
 	{ .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, },
+	{ .code = MEDIA_BUS_FMT_SBGGR10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGBRG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SGRBG10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SRGGB10_1X10, .bpp = 10, },
+	{ .code = MEDIA_BUS_FMT_SBGGR12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGBRG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SGRBG12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SRGGB12_1X12, .bpp = 12, },
+	{ .code = MEDIA_BUS_FMT_SBGGR14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGBRG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SGRBG14_1X14, .bpp = 14, },
+	{ .code = MEDIA_BUS_FMT_SRGGB14_1X14, .bpp = 14, },
 };
 

static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd) diff
--git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index f2fea3a63444..65b1cf9e553f 100644

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +59 -0
@@ -42,6 +42,78 @@ static const struct rzg2l_cru_ip_format
 rzg2l_cru_ip_formats[] = {
 		.datatype = MIPI_CSI2_DT_RAW8,
 		.icndmr = 0,
 	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SBGGR10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGBRG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SGRBG10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB10_1X10,
+		.format = V4L2_PIX_FMT_CRU_SRGGB10,
+		.datatype = MIPI_CSI2_DT_RAW10,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SBGGR12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGBRG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SGRBG12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB12_1X12,
+		.format = V4L2_PIX_FMT_CRU_SRGGB12,
+		.datatype = MIPI_CSI2_DT_RAW12,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SBGGR14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SBGGR14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGBRG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGBRG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c static const struct rzg2l_cru_ip_format · line 114

Quoted 10 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +10 -0
+	},
+	{
+		.code = MEDIA_BUS_FMT_SGRBG14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SGRBG14,
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
+	{
+		.code = MEDIA_BUS_FMT_SRGGB14_1X14,
+		.format = V4L2_PIX_FMT_CRU_SRGGB14,

With comments clarified on patch 1/4

Cheers,
Prabhakar

Quoted 9 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +3 -0
+		.datatype = MIPI_CSI2_DT_RAW14,
+		.icndmr = 0,
+	},
 };
 

const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int
code)
--
2.34.1