[03/10] media: Add Y212 video format
Commit Message
Y212 is a YUV format with 12-bits per component like YUYV,
expanded to 16bits.
Data in the 12 high bits, zeros in the 4 low bits,
arranged in little endian order.
Signed-off-by: Ming Qian <ming.qian@nxp.com>
---
.../media/v4l/pixfmt-packed-yuv.rst | 42 +++++++++++++++++++
drivers/media/v4l2-core/v4l2-common.c | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
4 files changed, 45 insertions(+)
Comments
On 20/12/2022 04:11, Ming Qian wrote:
> Y212 is a YUV format with 12-bits per component like YUYV,
> expanded to 16bits.
> Data in the 12 high bits, zeros in the 4 low bits,
> arranged in little endian order.
>
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> ---
> .../media/v4l/pixfmt-packed-yuv.rst | 42 +++++++++++++++++++
> drivers/media/v4l2-core/v4l2-common.c | 1 +
> drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
> include/uapi/linux/videodev2.h | 1 +
> 4 files changed, 45 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst
> index bf283a1b5581..39ded0b1e65c 100644
> --- a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst
> +++ b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst
> @@ -341,6 +341,48 @@ components horizontally by 2, storing 2 pixels in 4 bytes.
>
> \normalsize
>
> +The next lists the packed YUV 4:2:2 formats with more than 8 bits per component.
> +expand the bits per component to 16 bits, data in the high bits, zeros in the low bits,
> +arranged in little endian order. storing 2 pixels in 8 bytes.
> +
> +.. raw:: latex
> +
> + \footnotesize
> +
> +.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|
> +
> +.. flat-table:: Packed YUV 4:2:2 Formats (more than 8bpc)
> + :header-rows: 1
> + :stub-columns: 0
> +
> + * - Identifier
> + - Code
> + - Byte 1-0
> + - Byte 3-2
> + - Byte 5-4
> + - Byte 7-6
> + - Byte 9-8
> + - Byte 11-10
> + - Byte 13-12
> + - Byte 15-14
> + * .. _V4L2-PIX-FMT-Y212:
> +
> + - ``V4L2_PIX_FMT_Y212``
> + - 'Y212'
> +
> + - Y'\ :sub:`0`
> + - Cb\ :sub:`0`
> + - Y'\ :sub:`1`
> + - Cr\ :sub:`0`
> + - Y'\ :sub:`2`
> + - Cb\ :sub:`2`
> + - Y'\ :sub:`3`
> + - Cr\ :sub:`2`
> +
> +.. raw:: latex
> +
> + \normalsize
> +
> **Color Sample Location:**
> Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
> horizontally.
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index a5e8ba370d33..21ace56fac04 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -258,6 +258,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
> { .format = V4L2_PIX_FMT_YVYU, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
> { .format = V4L2_PIX_FMT_UYVY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
> { .format = V4L2_PIX_FMT_VYUY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
> + { .format = V4L2_PIX_FMT_Y212, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
>
> /* YUV planar formats */
> { .format = V4L2_PIX_FMT_NV12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 },
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 0ee730aa6cc7..4d5f722b674a 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1342,6 +1342,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
> case V4L2_PIX_FMT_YUV420: descr = "Planar YUV 4:2:0"; break;
> case V4L2_PIX_FMT_HI240: descr = "8-bit Dithered RGB (BTTV)"; break;
> case V4L2_PIX_FMT_M420: descr = "YUV 4:2:0 (M420)"; break;
> + case V4L2_PIX_FMT_Y212: descr = "12-bit Depth YUYV 4:2:2"; break;
> case V4L2_PIX_FMT_NV12: descr = "Y/UV 4:2:0"; break;
> case V4L2_PIX_FMT_NV21: descr = "Y/VU 4:2:0"; break;
> case V4L2_PIX_FMT_NV16: descr = "Y/UV 4:2:2"; break;
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index 3d8f89bff33c..b8a501dccfa4 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -618,6 +618,7 @@ struct v4l2_pix_format {
> #define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */
> #define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */
> #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
> +#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 12-bit per component */
This definitely needs to be renamed to prevent repeating the 'P010' mistake.
It's a YUYV format, so perhaps: _YUYV_12?
You definitely need to have 'YUYV' in the name in order to deal with different
YUV orders.
Regards,
Hans
>
> /* two planes -- one Y, one Cr + Cb interleaved */
> #define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
Hi Hans, Ming,
Le vendredi 27 janvier 2023 à 15:37 +0100, Hans Verkuil a écrit :
> On 20/12/2022 04:11, Ming Qian wrote:
> > Y212 is a YUV format with 12-bits per component like YUYV,
> > expanded to 16bits.
> > Data in the 12 high bits, zeros in the 4 low bits,
> > arranged in little endian order.
> >
> >
[...]
> > @@ -618,6 +618,7 @@ struct v4l2_pix_format {
> > #define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */
> > #define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */
> > #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
> > +#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 12-bit per component */
>
> This definitely needs to be renamed to prevent repeating the 'P010' mistake.
>
> It's a YUYV format, so perhaps: _YUYV_12?
>
> You definitely need to have 'YUYV' in the name in order to deal with different
> YUV orders.
Hans, it seems you already accepted this exact same format from
Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com> / [PATCH v3 2/7] media:
Add Y210, Y212 and Y216 formats.
Tomi omitted to update v4l2-common.c file. Ming, do you mind keeping this part
of your patch (adding Y210/Y216 support), this way we'd get that properly
implemented.
Nicolas
p.s. We can alternatively change our mind as this is not final yet I think.
[...]
Hi Nicolas,
>-----Original Message-----
>From: Nicolas Dufresne <nicolas@ndufresne.ca>
>Sent: 2023年2月22日 23:31
>To: Hans Verkuil <hverkuil-cisco@xs4all.nl>; Ming Qian
><ming.qian@nxp.com>; mchehab@kernel.org; Mirela Rabulea (OSS)
><mirela.rabulea@oss.nxp.com>
>Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
>festevam@gmail.com; X.H. Bao <xiahong.bao@nxp.com>; dl-linux-imx <linux-
>imx@nxp.com>; linux-media@vger.kernel.org; linux-kernel@vger.kernel.org;
>devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org
>Subject: [EXT] Re: [PATCH 03/10] media: Add Y212 video format
>
>Caution: EXT Email
>
>Hi Hans, Ming,
>
>Le vendredi 27 janvier 2023 à 15:37 +0100, Hans Verkuil a écrit :
>> On 20/12/2022 04:11, Ming Qian wrote:
>> > Y212 is a YUV format with 12-bits per component like YUYV, expanded
>> > to 16bits.
>> > Data in the 12 high bits, zeros in the 4 low bits, arranged in
>> > little endian order.
>> >
>> >
>
>[...]
>
>> > @@ -618,6 +618,7 @@ struct v4l2_pix_format { #define
>> > V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32
>> > YUVA-8-8-8-8 */ #define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V',
>'X') /* 32 YUVX-8-8-8-8 */
>> > #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV
>4:2:0 2 lines y, 1 line uv interleaved */
>> > +#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 12-
>bit per component */
>>
>> This definitely needs to be renamed to prevent repeating the 'P010' mistake.
>>
>> It's a YUYV format, so perhaps: _YUYV_12?
>>
>> You definitely need to have 'YUYV' in the name in order to deal with
>> different YUV orders.
>
>Hans, it seems you already accepted this exact same format from Tomi
>Valkeinen <tomi.valkeinen+renesas@ideasonboard.com> / [PATCH v3 2/7]
>media:
>Add Y210, Y212 and Y216 formats.
>
>Tomi omitted to update v4l2-common.c file. Ming, do you mind keeping this
>part of your patch (adding Y210/Y216 support), this way we'd get that
>properly implemented.
>
>Nicolas
>
>p.s. We can alternatively change our mind as this is not final yet I think.
>
I saw this patch too, and I planed to make a v4 patch to apply the Y212 format directly.
And I'm glad to keep the part that add the new defined format in v4l2-common.c
Ming
>[...]
@@ -341,6 +341,48 @@ components horizontally by 2, storing 2 pixels in 4 bytes.
\normalsize
+The next lists the packed YUV 4:2:2 formats with more than 8 bits per component.
+expand the bits per component to 16 bits, data in the high bits, zeros in the low bits,
+arranged in little endian order. storing 2 pixels in 8 bytes.
+
+.. raw:: latex
+
+ \footnotesize
+
+.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|
+
+.. flat-table:: Packed YUV 4:2:2 Formats (more than 8bpc)
+ :header-rows: 1
+ :stub-columns: 0
+
+ * - Identifier
+ - Code
+ - Byte 1-0
+ - Byte 3-2
+ - Byte 5-4
+ - Byte 7-6
+ - Byte 9-8
+ - Byte 11-10
+ - Byte 13-12
+ - Byte 15-14
+ * .. _V4L2-PIX-FMT-Y212:
+
+ - ``V4L2_PIX_FMT_Y212``
+ - 'Y212'
+
+ - Y'\ :sub:`0`
+ - Cb\ :sub:`0`
+ - Y'\ :sub:`1`
+ - Cr\ :sub:`0`
+ - Y'\ :sub:`2`
+ - Cb\ :sub:`2`
+ - Y'\ :sub:`3`
+ - Cr\ :sub:`2`
+
+.. raw:: latex
+
+ \normalsize
+
**Color Sample Location:**
Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
horizontally.
@@ -258,6 +258,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
{ .format = V4L2_PIX_FMT_YVYU, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_UYVY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_VYUY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
+ { .format = V4L2_PIX_FMT_Y212, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 },
/* YUV planar formats */
{ .format = V4L2_PIX_FMT_NV12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 },
@@ -1342,6 +1342,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_YUV420: descr = "Planar YUV 4:2:0"; break;
case V4L2_PIX_FMT_HI240: descr = "8-bit Dithered RGB (BTTV)"; break;
case V4L2_PIX_FMT_M420: descr = "YUV 4:2:0 (M420)"; break;
+ case V4L2_PIX_FMT_Y212: descr = "12-bit Depth YUYV 4:2:2"; break;
case V4L2_PIX_FMT_NV12: descr = "Y/UV 4:2:0"; break;
case V4L2_PIX_FMT_NV21: descr = "Y/VU 4:2:0"; break;
case V4L2_PIX_FMT_NV16: descr = "Y/UV 4:2:2"; break;
@@ -618,6 +618,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */
#define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */
#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
+#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 12-bit per component */
/* two planes -- one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */