Message ID | cover.1671071730.git.ming.qian@nxp.com |
---|---|
Headers | show |
Series | media: imx-jpeg: Add support for 12 bit extended | expand |
On 20/12/2022 04:11, Ming Qian wrote: > P012 is a YUV format with 12-bits per component with interleaved UV, > like NV12, expanded to 16 bits. > Data in the 12 high bits, zeros in the 4 low bits, > arranged in little endian order. > And P012M has two non contiguous planes. > > Signed-off-by: Ming Qian <ming.qian@nxp.com> > --- > .../media/v4l/pixfmt-yuv-planar.rst | 94 +++++++++++++++++++ > drivers/media/v4l2-core/v4l2-common.c | 2 + > drivers/media/v4l2-core/v4l2-ioctl.c | 2 + > include/uapi/linux/videodev2.h | 2 + > 4 files changed, 100 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst b/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst > index f1d5bb7b806d..aa37c3de8808 100644 > --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst > +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst > @@ -123,6 +123,20 @@ All components are stored with the same number of bits per component. > - Cb, Cr > - Yes > - 4x4 tiles > + * - V4L2_PIX_FMT_P012 > + - 'P012' > + - 12 > + - 4:2:0 > + - Cb, Cr > + - Yes > + - Linear > + * - V4L2_PIX_FMT_P012M > + - 'PM12' > + - 12 > + - 4:2:0 > + - Cb, Cr > + - Yes > + - Linear > * - V4L2_PIX_FMT_NV16 > - 'NV16' > - 8 > @@ -586,6 +600,86 @@ Data in the 10 high bits, zeros in the 6 low bits, arranged in little endian ord > - Cb\ :sub:`11` > - Cr\ :sub:`11` > > +.. _V4L2-PIX-FMT-P012: > +.. _V4L2-PIX-FMT-P012M: > + > +P012 and P012M > +-------------- > + > +P012 is like NV12 with 12 bits per component, expanded to 16 bits. > +Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order. > + > +.. flat-table:: Sample 4x4 P012 Image > + :header-rows: 0 > + :stub-columns: 0 > + > + * - start + 0: > + - Y'\ :sub:`00` > + - Y'\ :sub:`01` > + - Y'\ :sub:`02` > + - Y'\ :sub:`03` > + * - start + 8: > + - Y'\ :sub:`10` > + - Y'\ :sub:`11` > + - Y'\ :sub:`12` > + - Y'\ :sub:`13` > + * - start + 16: > + - Y'\ :sub:`20` > + - Y'\ :sub:`21` > + - Y'\ :sub:`22` > + - Y'\ :sub:`23` > + * - start + 24: > + - Y'\ :sub:`30` > + - Y'\ :sub:`31` > + - Y'\ :sub:`32` > + - Y'\ :sub:`33` > + * - start + 32: > + - Cb\ :sub:`00` > + - Cr\ :sub:`00` > + - Cb\ :sub:`01` > + - Cr\ :sub:`01` > + * - start + 40: > + - Cb\ :sub:`10` > + - Cr\ :sub:`10` > + - Cb\ :sub:`11` > + - Cr\ :sub:`11` > + > +.. flat-table:: Sample 4x4 P012M Image > + :header-rows: 0 > + :stub-columns: 0 > + > + * - start0 + 0: > + - Y'\ :sub:`00` > + - Y'\ :sub:`01` > + - Y'\ :sub:`02` > + - Y'\ :sub:`03` > + * - start0 + 8: > + - Y'\ :sub:`10` > + - Y'\ :sub:`11` > + - Y'\ :sub:`12` > + - Y'\ :sub:`13` > + * - start0 + 16: > + - Y'\ :sub:`20` > + - Y'\ :sub:`21` > + - Y'\ :sub:`22` > + - Y'\ :sub:`23` > + * - start0 + 24: > + - Y'\ :sub:`30` > + - Y'\ :sub:`31` > + - Y'\ :sub:`32` > + - Y'\ :sub:`33` > + * - > + * - start1 + 0: > + - Cb\ :sub:`00` > + - Cr\ :sub:`00` > + - Cb\ :sub:`01` > + - Cr\ :sub:`01` > + * - start1 + 8: > + - Cb\ :sub:`10` > + - Cr\ :sub:`10` > + - Cb\ :sub:`11` > + - Cr\ :sub:`11` > + > > Fully Planar YUV Formats > ======================== > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c > index 40f56e044640..a5e8ba370d33 100644 > --- a/drivers/media/v4l2-core/v4l2-common.c > +++ b/drivers/media/v4l2-core/v4l2-common.c > @@ -267,6 +267,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) > { .format = V4L2_PIX_FMT_NV24, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > { .format = V4L2_PIX_FMT_NV42, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, > + { .format = V4L2_PIX_FMT_P012, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 }, > > { .format = V4L2_PIX_FMT_YUV410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 }, > { .format = V4L2_PIX_FMT_YVU410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 }, > @@ -292,6 +293,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) > { .format = V4L2_PIX_FMT_NV21M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 }, > { .format = V4L2_PIX_FMT_NV16M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, > { .format = V4L2_PIX_FMT_NV61M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, > + { .format = V4L2_PIX_FMT_P012M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 }, > > /* Bayer RGB formats */ > { .format = V4L2_PIX_FMT_SBGGR8, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c > index 8e0a0ff62a70..067dbdd0a9ef 100644 > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > @@ -1348,6 +1348,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) > case V4L2_PIX_FMT_NV24: descr = "Y/UV 4:4:4"; break; > case V4L2_PIX_FMT_NV42: descr = "Y/VU 4:4:4"; break; > case V4L2_PIX_FMT_P010: descr = "10-bit Y/UV 4:2:0"; break; > + case V4L2_PIX_FMT_P012: descr = "12-bit Y/UV 4:2:0"; break; > case V4L2_PIX_FMT_NV12_4L4: descr = "Y/UV 4:2:0 (4x4 Linear)"; break; > case V4L2_PIX_FMT_NV12_16L16: descr = "Y/UV 4:2:0 (16x16 Linear)"; break; > case V4L2_PIX_FMT_NV12_32L32: descr = "Y/UV 4:2:0 (32x32 Linear)"; break; > @@ -1358,6 +1359,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) > case V4L2_PIX_FMT_NV61M: descr = "Y/VU 4:2:2 (N-C)"; break; > case V4L2_PIX_FMT_NV12MT: descr = "Y/UV 4:2:0 (64x32 MB, N-C)"; break; > case V4L2_PIX_FMT_NV12MT_16X16: descr = "Y/UV 4:2:0 (16x16 MB, N-C)"; break; > + case V4L2_PIX_FMT_P012M: descr = "12-bit Y/UV 4:2:0 (N-C)"; break; > case V4L2_PIX_FMT_YUV420M: descr = "Planar YUV 4:2:0 (N-C)"; break; > case V4L2_PIX_FMT_YVU420M: descr = "Planar YVU 4:2:0 (N-C)"; break; > case V4L2_PIX_FMT_YUV422M: descr = "Planar YUV 4:2:2 (N-C)"; break; > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 1befd181a4cc..5448aa3b7858 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -626,12 +626,14 @@ struct v4l2_pix_format { > #define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */ > #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */ > #define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 Y/CbCr 4:2:0 10-bit per component */ > +#define V4L2_PIX_FMT_P012 v4l2_fourcc('P', '0', '1', '2') /* 24 Y/CbCr 4:2:0 12-bit per component */ > > /* two non contiguous planes - one Y, one Cr + Cb interleaved */ > #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */ > #define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 Y/CrCb 4:2:0 */ > #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr 4:2:2 */ > #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb 4:2:2 */ > +#define V4L2_PIX_FMT_P012M v4l2_fourcc('P', 'M', '1', '2') /* 24 Y/CbCr 4:2:0 12-bit per component */ The name of the V4L2_PIX_FMT_ defines in this series are hard to decode. In this case is it derived from V4L2_PIX_FMT_P010, which really should have been named differently, but it's too late now :-( So I guess we'll stick with this naming, but it's not obvious what 'P012' means without referring to documentation. Oh well. Regards, Hans > > /* three planes - Y Cb, Cr */ > #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
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 */
On 20/12/2022 04:11, Ming Qian wrote: > B312 is a reversed RGB format with 12 bits per component like BGR24, > 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> > --- > .../userspace-api/media/v4l/pixfmt-rgb.rst | 35 +++++++++++++++++++ > drivers/media/v4l2-core/v4l2-common.c | 1 + > drivers/media/v4l2-core/v4l2-ioctl.c | 1 + > include/uapi/linux/videodev2.h | 3 ++ > 4 files changed, 40 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst > index 30f51cd33f99..f7785c93292a 100644 > --- a/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst > +++ b/Documentation/userspace-api/media/v4l/pixfmt-rgb.rst > @@ -763,6 +763,41 @@ nomenclature that instead use the order of components as seen in a 24- or > \normalsize > > > +More Than 8 Bits Per Component > +============================== > + > +These formats store an RGB triplet in six or eighth bytes, 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. > + > +.. raw:: latex > + > + \small > + > +.. flat-table:: RGB Formats With More Than 8 Bits Per Component > + :header-rows: 1 > + :stub-columns: 0 > + > + * - Identifier > + - Code > + - Byte 1-0 > + - Byte 3-2 > + - Byte 5-4 > + - Byte 7-6 > + * .. _V4L2-PIX-FMT-B312: > + > + - ``V4L2_PIX_FMT_B312`` > + - 'B312' > + > + - B\ :sub:`15-4` > + - G\ :sub:`15-4` > + - R\ :sub:`15-4` > + - > + > +.. raw:: latex > + > + \normalsize > + > Deprecated RGB Formats > ====================== > > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c > index 332d4b11bc1b..0cc58abae562 100644 > --- a/drivers/media/v4l2-core/v4l2-common.c > +++ b/drivers/media/v4l2-core/v4l2-common.c > @@ -252,6 +252,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) > { .format = V4L2_PIX_FMT_RGB565, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > { .format = V4L2_PIX_FMT_RGB555, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > { .format = V4L2_PIX_FMT_BGR666, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > + { .format = V4L2_PIX_FMT_B312, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 6, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, > > /* YUV packed formats */ > { .format = V4L2_PIX_FMT_YUYV, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 2, .vdiv = 1 }, > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c > index 5b97d7e5dbbf..8c3d40d3acf5 100644 > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > @@ -1298,6 +1298,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) > case V4L2_PIX_FMT_BGRX32: descr = "32-bit XBGR 8-8-8-8"; break; > case V4L2_PIX_FMT_RGBA32: descr = "32-bit RGBA 8-8-8-8"; break; > case V4L2_PIX_FMT_RGBX32: descr = "32-bit RGBX 8-8-8-8"; break; > + case V4L2_PIX_FMT_B312: descr = "12-bit Depth BGR"; break; > case V4L2_PIX_FMT_GREY: descr = "8-bit Greyscale"; break; > case V4L2_PIX_FMT_Y4: descr = "4-bit Greyscale"; break; > case V4L2_PIX_FMT_Y6: descr = "6-bit Greyscale"; break; > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h > index 3475331737af..c67f895210de 100644 > --- a/include/uapi/linux/videodev2.h > +++ b/include/uapi/linux/videodev2.h > @@ -577,6 +577,9 @@ struct v4l2_pix_format { > #define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */ > #define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */ > > +/* RGB formats (6 or 8 bytes per pixel) */ > +#define V4L2_PIX_FMT_B312 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */ BGR24_12 Regards, Hans > + > /* Grey formats */ > #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ > #define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */
>From: Hans Verkuil <hverkuil-cisco@xs4all.nl> >Sent: 2023年1月27日 22:32 >To: 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 01/10] media: Add P012 and P012M video format > >Caution: EXT Email > >On 20/12/2022 04:11, Ming Qian wrote: >> P012 is a YUV format with 12-bits per component with interleaved UV, >> like NV12, expanded to 16 bits. >> Data in the 12 high bits, zeros in the 4 low bits, arranged in little >> endian order. >> And P012M has two non contiguous planes. >> >> Signed-off-by: Ming Qian <ming.qian@nxp.com> >> --- >> .../media/v4l/pixfmt-yuv-planar.rst | 94 +++++++++++++++++++ >> drivers/media/v4l2-core/v4l2-common.c | 2 + >> drivers/media/v4l2-core/v4l2-ioctl.c | 2 + >> include/uapi/linux/videodev2.h | 2 + >> 4 files changed, 100 insertions(+) >> >> diff --git >> a/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst >> b/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst >> index f1d5bb7b806d..aa37c3de8808 100644 >> --- a/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst >> +++ b/Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst >> @@ -123,6 +123,20 @@ All components are stored with the same number >of bits per component. >> - Cb, Cr >> - Yes >> - 4x4 tiles >> + * - V4L2_PIX_FMT_P012 >> + - 'P012' >> + - 12 >> + - 4:2:0 >> + - Cb, Cr >> + - Yes >> + - Linear >> + * - V4L2_PIX_FMT_P012M >> + - 'PM12' >> + - 12 >> + - 4:2:0 >> + - Cb, Cr >> + - Yes >> + - Linear >> * - V4L2_PIX_FMT_NV16 >> - 'NV16' >> - 8 >> @@ -586,6 +600,86 @@ Data in the 10 high bits, zeros in the 6 low bits, >arranged in little endian ord >> - Cb\ :sub:`11` >> - Cr\ :sub:`11` >> >> +.. _V4L2-PIX-FMT-P012: >> +.. _V4L2-PIX-FMT-P012M: >> + >> +P012 and P012M >> +-------------- >> + >> +P012 is like NV12 with 12 bits per component, expanded to 16 bits. >> +Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian >order. >> + >> +.. flat-table:: Sample 4x4 P012 Image >> + :header-rows: 0 >> + :stub-columns: 0 >> + >> + * - start + 0: >> + - Y'\ :sub:`00` >> + - Y'\ :sub:`01` >> + - Y'\ :sub:`02` >> + - Y'\ :sub:`03` >> + * - start + 8: >> + - Y'\ :sub:`10` >> + - Y'\ :sub:`11` >> + - Y'\ :sub:`12` >> + - Y'\ :sub:`13` >> + * - start + 16: >> + - Y'\ :sub:`20` >> + - Y'\ :sub:`21` >> + - Y'\ :sub:`22` >> + - Y'\ :sub:`23` >> + * - start + 24: >> + - Y'\ :sub:`30` >> + - Y'\ :sub:`31` >> + - Y'\ :sub:`32` >> + - Y'\ :sub:`33` >> + * - start + 32: >> + - Cb\ :sub:`00` >> + - Cr\ :sub:`00` >> + - Cb\ :sub:`01` >> + - Cr\ :sub:`01` >> + * - start + 40: >> + - Cb\ :sub:`10` >> + - Cr\ :sub:`10` >> + - Cb\ :sub:`11` >> + - Cr\ :sub:`11` >> + >> +.. flat-table:: Sample 4x4 P012M Image >> + :header-rows: 0 >> + :stub-columns: 0 >> + >> + * - start0 + 0: >> + - Y'\ :sub:`00` >> + - Y'\ :sub:`01` >> + - Y'\ :sub:`02` >> + - Y'\ :sub:`03` >> + * - start0 + 8: >> + - Y'\ :sub:`10` >> + - Y'\ :sub:`11` >> + - Y'\ :sub:`12` >> + - Y'\ :sub:`13` >> + * - start0 + 16: >> + - Y'\ :sub:`20` >> + - Y'\ :sub:`21` >> + - Y'\ :sub:`22` >> + - Y'\ :sub:`23` >> + * - start0 + 24: >> + - Y'\ :sub:`30` >> + - Y'\ :sub:`31` >> + - Y'\ :sub:`32` >> + - Y'\ :sub:`33` >> + * - >> + * - start1 + 0: >> + - Cb\ :sub:`00` >> + - Cr\ :sub:`00` >> + - Cb\ :sub:`01` >> + - Cr\ :sub:`01` >> + * - start1 + 8: >> + - Cb\ :sub:`10` >> + - Cr\ :sub:`10` >> + - Cb\ :sub:`11` >> + - Cr\ :sub:`11` >> + >> >> Fully Planar YUV Formats >> ======================== >> diff --git a/drivers/media/v4l2-core/v4l2-common.c >> b/drivers/media/v4l2-core/v4l2-common.c >> index 40f56e044640..a5e8ba370d33 100644 >> --- a/drivers/media/v4l2-core/v4l2-common.c >> +++ b/drivers/media/v4l2-core/v4l2-common.c >> @@ -267,6 +267,7 @@ const struct v4l2_format_info >*v4l2_format_info(u32 format) >> { .format = V4L2_PIX_FMT_NV24, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, >0 }, .hdiv = 1, .vdiv = 1 }, >> { .format = V4L2_PIX_FMT_NV42, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, >0 }, .hdiv = 1, .vdiv = 1 }, >> { .format = V4L2_PIX_FMT_P010, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, >0 }, .hdiv = 2, .vdiv = 1 }, >> + { .format = V4L2_PIX_FMT_P012, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, >0 }, .hdiv = 2, .vdiv = 2 }, >> >> { .format = V4L2_PIX_FMT_YUV410, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, >0 }, .hdiv = 4, .vdiv = 4 }, >> { .format = V4L2_PIX_FMT_YVU410, .pixel_enc = >> V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, >0 }, .hdiv = 4, .vdiv = 4 }, @@ -292,6 +293,7 @@ const struct v4l2_format_info >*v4l2_format_info(u32 format) >> { .format = V4L2_PIX_FMT_NV21M, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, >0 }, .hdiv = 2, .vdiv = 2 }, >> { .format = V4L2_PIX_FMT_NV16M, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, >0 }, .hdiv = 2, .vdiv = 1 }, >> { .format = V4L2_PIX_FMT_NV61M, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 1, 2, 0, >0 }, .hdiv = 2, .vdiv = 1 }, >> + { .format = V4L2_PIX_FMT_P012M, .pixel_enc = >V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 2, 4, 0, >0 }, .hdiv = 2, .vdiv = 2 }, >> >> /* Bayer RGB formats */ >> { .format = V4L2_PIX_FMT_SBGGR8, .pixel_enc = >V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, >0 }, .hdiv = 1, .vdiv = 1 }, >> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c >> b/drivers/media/v4l2-core/v4l2-ioctl.c >> index 8e0a0ff62a70..067dbdd0a9ef 100644 >> --- a/drivers/media/v4l2-core/v4l2-ioctl.c >> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c >> @@ -1348,6 +1348,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc >*fmt) >> case V4L2_PIX_FMT_NV24: descr = "Y/UV 4:4:4"; break; >> case V4L2_PIX_FMT_NV42: descr = "Y/VU 4:4:4"; break; >> case V4L2_PIX_FMT_P010: descr = "10-bit Y/UV 4:2:0"; break; >> + case V4L2_PIX_FMT_P012: descr = "12-bit Y/UV 4:2:0"; break; >> case V4L2_PIX_FMT_NV12_4L4: descr = "Y/UV 4:2:0 (4x4 Linear)"; >break; >> case V4L2_PIX_FMT_NV12_16L16: descr = "Y/UV 4:2:0 (16x16 Linear)"; >break; >> case V4L2_PIX_FMT_NV12_32L32: descr = "Y/UV 4:2:0 (32x32 Linear)"; >break; >> @@ -1358,6 +1359,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc >*fmt) >> case V4L2_PIX_FMT_NV61M: descr = "Y/VU 4:2:2 (N-C)"; break; >> case V4L2_PIX_FMT_NV12MT: descr = "Y/UV 4:2:0 (64x32 MB, N-C)"; >break; >> case V4L2_PIX_FMT_NV12MT_16X16: descr = "Y/UV 4:2:0 (16x16 MB, >> N-C)"; break; >> + case V4L2_PIX_FMT_P012M: descr = "12-bit Y/UV 4:2:0 (N-C)"; break; >> case V4L2_PIX_FMT_YUV420M: descr = "Planar YUV 4:2:0 (N-C)"; >break; >> case V4L2_PIX_FMT_YVU420M: descr = "Planar YVU 4:2:0 (N-C)"; >break; >> case V4L2_PIX_FMT_YUV422M: descr = "Planar YUV 4:2:2 (N-C)"; >break; >> diff --git a/include/uapi/linux/videodev2.h >> b/include/uapi/linux/videodev2.h index 1befd181a4cc..5448aa3b7858 >> 100644 >> --- a/include/uapi/linux/videodev2.h >> +++ b/include/uapi/linux/videodev2.h >> @@ -626,12 +626,14 @@ struct v4l2_pix_format { >> #define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr >4:4:4 */ >> #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb >4:4:4 */ >> #define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 Y/CbCr >4:2:0 10-bit per component */ >> +#define V4L2_PIX_FMT_P012 v4l2_fourcc('P', '0', '1', '2') /* 24 Y/CbCr >4:2:0 12-bit per component */ >> >> /* two non contiguous planes - one Y, one Cr + Cb interleaved */ >> #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr >4:2:0 */ >> #define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 Y/CrCb >4:2:0 */ >> #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 Y/CbCr >4:2:2 */ >> #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 Y/CrCb >4:2:2 */ >> +#define V4L2_PIX_FMT_P012M v4l2_fourcc('P', 'M', '1', '2') /* 24 Y/CbCr >4:2:0 12-bit per component */ > >The name of the V4L2_PIX_FMT_ defines in this series are hard to decode. > >In this case is it derived from V4L2_PIX_FMT_P010, which really should have >been named differently, but it's too late now :-( > >So I guess we'll stick with this naming, but it's not obvious what 'P012' means >without referring to documentation. > >Oh well. > >Regards, > > Hans Hi Hans, I'll update the format name, as you know, the P012 is following the P010, as they are almost the same, and the Y212 comes from gstreamer (GST_VIDEO_FORMAT_Y212_LE), then I did some naming like that. I'll correct them in v2 patch. Ming > >> >> /* three planes - Y Cb, Cr */ >> #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 >*/
Le lundi 30 janvier 2023 à 08:15 +0000, Ming Qian a écrit : > > > diff --git a/include/uapi/linux/videodev2.h > > > b/include/uapi/linux/videodev2.h index 1befd181a4cc..5448aa3b7858 > > > 100644 > > > --- a/include/uapi/linux/videodev2.h > > > +++ b/include/uapi/linux/videodev2.h > > > @@ -626,12 +626,14 @@ struct v4l2_pix_format { > > > #define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 > > > Y/CbCr > > 4:4:4 */ > > > #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 > > > Y/CrCb > > 4:4:4 */ > > > #define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 > > > Y/CbCr > > 4:2:0 10-bit per component */ > > > +#define V4L2_PIX_FMT_P012 v4l2_fourcc('P', '0', '1', '2') /* 24 > > > Y/CbCr > > 4:2:0 12-bit per component */ > > > > > > /* two non contiguous planes - one Y, one Cr + Cb interleaved */ > > > #define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 > > > Y/CbCr > > 4:2:0 */ > > > #define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 > > > Y/CrCb > > 4:2:0 */ > > > #define V4L2_PIX_FMT_NV16M v4l2_fourcc('N', 'M', '1', '6') /* 16 > > > Y/CbCr > > 4:2:2 */ > > > #define V4L2_PIX_FMT_NV61M v4l2_fourcc('N', 'M', '6', '1') /* 16 > > > Y/CrCb > > 4:2:2 */ > > > +#define V4L2_PIX_FMT_P012M v4l2_fourcc('P', 'M', '1', '2') /* 24 > > > Y/CbCr > > 4:2:0 12-bit per component */ > > > > The name of the V4L2_PIX_FMT_ defines in this series are hard to decode. > > > > In this case is it derived from V4L2_PIX_FMT_P010, which really should have > > been named differently, but it's too late now :-( > > > > So I guess we'll stick with this naming, but it's not obvious what 'P012' > > means > > without referring to documentation. > > > > Oh well. > > > > Regards, > > > > Hans > > Hi Hans, > I'll update the format name, as you know, the P012 is following the P010, > as they are almost the same, and the Y212 comes from gstreamer > (GST_VIDEO_FORMAT_Y212_LE), then I did some naming like that. > I'll correct them in v2 patch. I agree these naming are not obvious. In GStreamer, appart from the _LE part, we've had this historical tendency to just stick with Microsoft names when they exist. Though Microsoft only define 10 and 16bits (P010/P016, Y210 and Y216). In this case, the 12 has is derived from it. https://learn.microsoft.com/en-us/windows/win32/medfound/10-bit-and-16-bit-yuv-video-formats While P010 is very commonly seen, I don't know if Y210/Y212/Y216 is a great idea. It is a 16bit component width version of YUYV, which as we know exist in all sort of swizzling. So the Microsoft name will be hard to extend to other component order. My argument of keeping it this way though is that it matches the other copy of pixel formats definition that exist in Linux, which is drm_fourcc.h. Nicolas
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. [...]