History

media: v4l2: Add NV15 and NV20 pixel formats

Add NV15 and NV20 pixel formats used by the Rockchip Video Decoder for 10-bit buffers. NV15 and NV20 is 10-bit 4:2:0/4:2:2 semi-planar YUV formats similar to NV12 and NV16, using 10-bit components with no padding between each component. Instead, a group of 4 luminance/chrominance samples are stored over 5 bytes in little endian order: YYYY = UVUV = 4 * 10 bits = 40 bits = 5 bytes The '15' and '20' suffix refers to the optimum effective bits per pixel which is achieved when the total number of luminance samples is a multiple of 8 for NV15 and 4 for NV20.

Jonas Karlman committed 1 year ago

Commit dcbe2ae1 parent 22f572c4 files · +134 −0Browse files

Unified · Split

4 files
  1. Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +128 −0
  2. drivers/media/v4l2-core/v4l2-common.c +2 −0
  3. drivers/media/v4l2-core/v4l2-ioctl.c +2 −0
  4. include/uapi/linux/videodev2.h +2 −0
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst+128−0
@@ -137,6 +137,13 @@ All components are stored with the same number of bits per component. · 136 unmodified lines
137137 - Cb, Cr
138138 - No
139139 - Linear
140+ * - V4L2_PIX_FMT_NV15
141+ - 'NV15'
142+ - 10
143+ - 4:2:0
144+ - Cb, Cr
145+ - Yes
146+ - Linear
140147 * - V4L2_PIX_FMT_NV15_4L4
141148 - 'VT15'
142149 - 15
@@ -186,6 +193,13 @@ All components are stored with the same number of bits per component. · 43 unmodified lines
186193 - Cr, Cb
187194 - No
188195 - Linear
196+ * - V4L2_PIX_FMT_NV20
197+ - 'NV20'
198+ - 10
199+ - 4:2:2
200+ - Cb, Cr
201+ - Yes
202+ - Linear
189203 * - V4L2_PIX_FMT_NV24
190204 - 'NV24'
191205 - 8
@@ -302,6 +316,57 @@ of the luma plane. · 110 unmodified lines
302316 - Cr\ :sub:`11`
303317
304318
319+.. _V4L2-PIX-FMT-NV15:
320+
321+NV15
322+----
323+
324+Semi-planar 10-bit YUV 4:2:0 format similar to NV12, using 10-bit components
325+with no padding between each component. A group of 4 components are stored over
326+5 bytes in little endian order.
327+
328+.. flat-table:: Sample 4x4 NV15 Image (1 byte per cell)
329+ :header-rows: 0
330+ :stub-columns: 0
331+
332+ * - start + 0:
333+ - Y'\ :sub:`00[7:0]`
334+ - Y'\ :sub:`01[5:0]`\ Y'\ :sub:`00[9:8]`
335+ - Y'\ :sub:`02[3:0]`\ Y'\ :sub:`01[9:6]`
336+ - Y'\ :sub:`03[1:0]`\ Y'\ :sub:`02[9:4]`
337+ - Y'\ :sub:`03[9:2]`
338+ * - start + 5:
339+ - Y'\ :sub:`10[7:0]`
340+ - Y'\ :sub:`11[5:0]`\ Y'\ :sub:`10[9:8]`
341+ - Y'\ :sub:`12[3:0]`\ Y'\ :sub:`11[9:6]`
342+ - Y'\ :sub:`13[1:0]`\ Y'\ :sub:`12[9:4]`
343+ - Y'\ :sub:`13[9:2]`
344+ * - start + 10:
345+ - Y'\ :sub:`20[7:0]`
346+ - Y'\ :sub:`21[5:0]`\ Y'\ :sub:`20[9:8]`
347+ - Y'\ :sub:`22[3:0]`\ Y'\ :sub:`21[9:6]`
348+ - Y'\ :sub:`23[1:0]`\ Y'\ :sub:`22[9:4]`
349+ - Y'\ :sub:`23[9:2]`
350+ * - start + 15:
351+ - Y'\ :sub:`30[7:0]`
352+ - Y'\ :sub:`31[5:0]`\ Y'\ :sub:`30[9:8]`
353+ - Y'\ :sub:`32[3:0]`\ Y'\ :sub:`31[9:6]`
354+ - Y'\ :sub:`33[1:0]`\ Y'\ :sub:`32[9:4]`
355+ - Y'\ :sub:`33[9:2]`
356+ * - start + 20:
357+ - Cb\ :sub:`00[7:0]`
358+ - Cr\ :sub:`00[5:0]`\ Cb\ :sub:`00[9:8]`
359+ - Cb\ :sub:`01[3:0]`\ Cr\ :sub:`00[9:6]`
360+ - Cr\ :sub:`01[1:0]`\ Cb\ :sub:`01[9:4]`
361+ - Cr\ :sub:`01[9:2]`
362+ * - start + 25:
363+ - Cb\ :sub:`10[7:0]`
364+ - Cr\ :sub:`10[5:0]`\ Cb\ :sub:`10[9:8]`
365+ - Cb\ :sub:`11[3:0]`\ Cr\ :sub:`10[9:6]`
366+ - Cr\ :sub:`11[1:0]`\ Cb\ :sub:`11[9:4]`
367+ - Cr\ :sub:`11[9:2]`
368+
369+
305370 .. _V4L2-PIX-FMT-NV12MT:
306371 .. _V4L2-PIX-FMT-NV12MT-16X16:
307372 .. _V4L2-PIX-FMT-NV12-4L4:
@@ -631,6 +696,69 @@ number of lines as the luma plane. · 323 unmodified lines
631696 - Cr\ :sub:`32`
632697
633698
699+.. _V4L2-PIX-FMT-NV20:
700+
701+NV20
702+----
703+
704+Semi-planar 10-bit YUV 4:2:2 format similar to NV16, using 10-bit components
705+with no padding between each component. A group of 4 components are stored over
706+5 bytes in little endian order.
707+
708+.. flat-table:: Sample 4x4 NV20 Image (1 byte per cell)
709+ :header-rows: 0
710+ :stub-columns: 0
711+
712+ * - start + 0:
713+ - Y'\ :sub:`00[7:0]`
714+ - Y'\ :sub:`01[5:0]`\ Y'\ :sub:`00[9:8]`
715+ - Y'\ :sub:`02[3:0]`\ Y'\ :sub:`01[9:6]`
716+ - Y'\ :sub:`03[1:0]`\ Y'\ :sub:`02[9:4]`
717+ - Y'\ :sub:`03[9:2]`
718+ * - start + 5:
719+ - Y'\ :sub:`10[7:0]`
720+ - Y'\ :sub:`11[5:0]`\ Y'\ :sub:`10[9:8]`
721+ - Y'\ :sub:`12[3:0]`\ Y'\ :sub:`11[9:6]`
722+ - Y'\ :sub:`13[1:0]`\ Y'\ :sub:`12[9:4]`
723+ - Y'\ :sub:`13[9:2]`
724+ * - start + 10:
725+ - Y'\ :sub:`20[7:0]`
726+ - Y'\ :sub:`21[5:0]`\ Y'\ :sub:`20[9:8]`
727+ - Y'\ :sub:`22[3:0]`\ Y'\ :sub:`21[9:6]`
728+ - Y'\ :sub:`23[1:0]`\ Y'\ :sub:`22[9:4]`
729+ - Y'\ :sub:`23[9:2]`
730+ * - start + 15:
731+ - Y'\ :sub:`30[7:0]`
732+ - Y'\ :sub:`31[5:0]`\ Y'\ :sub:`30[9:8]`
733+ - Y'\ :sub:`32[3:0]`\ Y'\ :sub:`31[9:6]`
734+ - Y'\ :sub:`33[1:0]`\ Y'\ :sub:`32[9:4]`
735+ - Y'\ :sub:`33[9:2]`
736+ * - start + 20:
737+ - Cb\ :sub:`00[7:0]`
738+ - Cr\ :sub:`00[5:0]`\ Cb\ :sub:`00[9:8]`
739+ - Cb\ :sub:`01[3:0]`\ Cr\ :sub:`00[9:6]`
740+ - Cr\ :sub:`01[1:0]`\ Cb\ :sub:`01[9:4]`
741+ - Cr\ :sub:`01[9:2]`
742+ * - start + 25:
743+ - Cb\ :sub:`10[7:0]`
744+ - Cr\ :sub:`10[5:0]`\ Cb\ :sub:`10[9:8]`
745+ - Cb\ :sub:`11[3:0]`\ Cr\ :sub:`10[9:6]`
746+ - Cr\ :sub:`11[1:0]`\ Cb\ :sub:`11[9:4]`
747+ - Cr\ :sub:`11[9:2]`
748+ * - start + 30:
749+ - Cb\ :sub:`20[7:0]`
750+ - Cr\ :sub:`20[5:0]`\ Cb\ :sub:`20[9:8]`
751+ - Cb\ :sub:`21[3:0]`\ Cr\ :sub:`20[9:6]`
752+ - Cr\ :sub:`21[1:0]`\ Cb\ :sub:`21[9:4]`
753+ - Cr\ :sub:`21[9:2]`
754+ * - start + 35:
755+ - Cb\ :sub:`30[7:0]`
756+ - Cr\ :sub:`30[5:0]`\ Cb\ :sub:`30[9:8]`
757+ - Cb\ :sub:`31[3:0]`\ Cr\ :sub:`30[9:6]`
758+ - Cr\ :sub:`31[1:0]`\ Cb\ :sub:`31[9:4]`
759+ - Cr\ :sub:`31[9:2]`
760+
761+
634762 .. _V4L2-PIX-FMT-NV24:
635763 .. _V4L2-PIX-FMT-NV42:
636764
drivers/media/v4l2-core/v4l2-common.c+2−0
@@ -277,8 +277,10 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) · 276 unmodified lines
277277 /* YUV planar formats */
278278 { .format = V4L2_PIX_FMT_NV12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 },
279279 { .format = V4L2_PIX_FMT_NV21, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 },
280+ { .format = V4L2_PIX_FMT_NV15, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2 },
280281 { .format = V4L2_PIX_FMT_NV16, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 1 },
281282 { .format = V4L2_PIX_FMT_NV61, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 1 },
283+ { .format = V4L2_PIX_FMT_NV20, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 1 },
282284 { .format = V4L2_PIX_FMT_NV24, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
283285 { .format = V4L2_PIX_FMT_NV42, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
284286 { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 1 },
drivers/media/v4l2-core/v4l2-ioctl.c+2−0
@@ -1363,8 +1363,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) · 1362 unmodified lines
13631363 case V4L2_PIX_FMT_YUV48_12: descr = "12-bit YUV 4:4:4 Packed"; break;
13641364 case V4L2_PIX_FMT_NV12: descr = "Y/UV 4:2:0"; break;
13651365 case V4L2_PIX_FMT_NV21: descr = "Y/VU 4:2:0"; break;
1366+ case V4L2_PIX_FMT_NV15: descr = "10-bit Y/UV 4:2:0 (Packed)"; break;
13661367 case V4L2_PIX_FMT_NV16: descr = "Y/UV 4:2:2"; break;
13671368 case V4L2_PIX_FMT_NV61: descr = "Y/VU 4:2:2"; break;
1369+ case V4L2_PIX_FMT_NV20: descr = "10-bit Y/UV 4:2:2 (Packed)"; break;
13681370 case V4L2_PIX_FMT_NV24: descr = "Y/UV 4:4:4"; break;
13691371 case V4L2_PIX_FMT_NV42: descr = "Y/VU 4:4:4"; break;
13701372 case V4L2_PIX_FMT_P010: descr = "10-bit Y/UV 4:2:0"; break;
include/uapi/linux/videodev2.h+2−0
@@ -651,8 +651,10 @@ struct v4l2_pix_format { · 650 unmodified lines
651651 /* two planes -- one Y, one Cr + Cb interleaved */
652652 #define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
653653 #define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
654+#define V4L2_PIX_FMT_NV15 v4l2_fourcc('N', 'V', '1', '5') /* 15 Y/CbCr 4:2:0 10-bit packed */
654655 #define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
655656 #define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
657+#define V4L2_PIX_FMT_NV20 v4l2_fourcc('N', 'V', '2', '0') /* 20 Y/CbCr 4:2:2 10-bit packed */
656658 #define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */
657659 #define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */
658660 #define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 Y/CbCr 4:2:0 10-bit per component */