media: visiting YUV tiled formats
cover media: visiting YUV tiled formats
A small set cleaning and unifying the way we handle YUV tiled formats, which are found on decoders.
Ezequiel Garcia (3):
media: Rename V4L2_PIX_FMT_SUNXI_TILED_NV12 to V4L2_PIX_FMT_NV12_32L32
media: Group tiled NV12 pixel formats
media: Add NV12_4L4 tiled format
.../media/v4l/pixfmt-reserved.rst | 14 -------------- .../media/v4l/pixfmt-yuv-planar.rst | 19 ++++++++++++++++--- drivers/media/v4l2-core/v4l2-common.c | 3 +++ drivers/media/v4l2-core/v4l2-ioctl.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 2 +- .../staging/media/sunxi/cedrus/cedrus_hw.c | 2 +- .../staging/media/sunxi/cedrus/cedrus_video.c | 4 ++-- include/uapi/linux/videodev2.h | 14 +++++++++++--- 8 files changed, 35 insertions(+), 25 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/3 media: Rename V4L2_PIX_FMT_SUNXI_TILED_NV12 to V4L2_PIX_FMT_NV12_32L32
The V4L2_PIX_FMT_SUNXI_TILED_NV12 format is actually a fairly common NV12 tiled format, with 32x32 linear tiles. Rename the format and move its documentation together with the other tiled NV12 formats.
Follow GStreamer's nomenclature (NV12_32L32) and keep V4L2_PIX_FMT_SUNXI_TILED_NV12 for application compatibility.
--- .../userspace-api/media/v4l/pixfmt-reserved.rst | 14 -------------- .../userspace-api/media/v4l/pixfmt-yuv-planar.rst | 13 ++++++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ++-- include/uapi/linux/videodev2.h | 9 ++++++++- 7 files changed, 23 insertions(+), 23 deletions(-)
Documentation/userspace-api/media/v4l/pixfmt-reserved.rst +0 -14
@@ -246,20 +246,6 @@ please make a proposal on the linux-media mailing list. It is an opaque intermediate format and the MDP hardware must be used to convert ``V4L2_PIX_FMT_MT21C`` to ``V4L2_PIX_FMT_NV12M``, ``V4L2_PIX_FMT_YUV420M`` or ``V4L2_PIX_FMT_YVU420``. - * .. _V4L2-PIX-FMT-SUNXI-TILED-NV12: - - - ``V4L2_PIX_FMT_SUNXI_TILED_NV12`` - - 'ST12' - - Two-planar NV12-based format used by the video engine found on Allwinner - (codenamed sunxi) platforms, with 32x32 tiles for the luminance plane - and 32x64 tiles for the chrominance plane. The data in each tile is - stored in linear order, within the tile bounds. Each tile follows the - previous one linearly in memory (from left to right, top to bottom). - - The associated buffer dimensions are aligned to match an integer number - of tiles, resulting in 32-aligned resolutions for the luminance plane - and 16-aligned resolutions for the chrominance plane (with 2x2 - subsampling). .. raw:: latex
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +10 -3
@@ -254,14 +254,16 @@ of the luma plane. .. _V4L2-PIX-FMT-NV12MT: .. _V4L2-PIX-FMT-NV12MT-16X16: +.. _V4L2-PIX-FMT-NV12-32L32: -NV12MT and MV12MT_16X16 ------------------------ +Tiled NV12 +---------- Semi-planar YUV 4:2:0 formats, using macroblock tiling. The chroma plane is subsampled by 2 in each direction. Chroma lines contain half the number of pixels and the same number of bytes as luma lines, and the chroma plane -contains half the number of lines of the luma plane. +contains half the number of lines of the luma plane. Each tile follows the +previous one linearly in memory (from left to right, top to bottom). ``V4L2_PIX_FMT_NV12MT_16X16`` stores pixel in 2D 16x16 macroblocks, and stores macroblocks linearly in memory. The line stride and image height must be
@@ -276,6 +278,11 @@ If the vertical resolution is an odd number of macroblocks, the last row of macroblocks is stored in linear order. The layouts of the luma and chroma planes are identical. +``V4L2_PIX_FMT_NV12_32L32`` stores pixel in 2D 32x32 macroblocks, and stores +macroblocks linearly in memory. The line stride and image height must be +aligned to a multiple of 32. The layouts of the luma and chroma planes are +identical. + .. _nv12mt: .. kernel-figure:: nv12mt.svg
drivers/media/v4l2-core/v4l2-ioctl.c +1 -1
@@ -1288,6 +1288,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_NV61M : descr ="Y/CrCb 4:2:2 (N-C)" ;break ;case V4L2_PIX_FMT_NV12MT : descr ="Y/CbCr 4:2:0 (64x32 MB, N-C)" ;break ;case V4L2_PIX_FMT_NV12MT_16X16 : descr ="Y/CbCr 4:2:0 (16x16 MB, N-C)" ;break ; +case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/CbCr 4:2:0 (32x32 linear, 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 ;
@@ -1415,7 +1416,6 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_SE401 : descr ="GSPCA SE401" ;break ;case V4L2_PIX_FMT_S5C_UYVY_JPG : descr ="S5C73MX interleaved UYVY/JPEG" ;break ;case V4L2_PIX_FMT_MT21C : descr ="Mediatek Compressed Format" ;break ; -case V4L2_PIX_FMT_SUNXI_TILED_NV12 : descr ="Sunxi Tiled NV12 Format" ;break ;default :if (fmt->description[0 ])return ;
drivers/staging/media/sunxi/cedrus/cedrus.c +1 -1
@@ -282,7 +282,7 @@ static int cedrus_open(struct file *file) ret =PTR_ERR (ctx->fh.m2m_ctx); goto err_ctrls; } - ctx->dst_fmt.pixelformat =V4L2_PIX_FMT_SUNXI_TILED_NV12 ; + ctx->dst_fmt.pixelformat =V4L2_PIX_FMT_NV12_32L32 ;cedrus_prepare_format (&ctx->dst_fmt); ctx->src_fmt.pixelformat =V4L2_PIX_FMT_MPEG2_SLICE ;/*
drivers/staging/media/sunxi/cedrus/cedrus_hw.c +1 -1
@@ -99,7 +99,7 @@ void cedrus_dst_format_set(struct cedrus_dev *dev,cedrus_write (dev,VE_PRIMARY_FB_LINE_STRIDE , reg);break ; -case V4L2_PIX_FMT_SUNXI_TILED_NV12 : +case V4L2_PIX_FMT_NV12_32L32 :default : reg =VE_PRIMARY_OUT_FMT_TILED_32_NV12 ;cedrus_write (dev,VE_PRIMARY_OUT_FMT , reg);
drivers/staging/media/sunxi/cedrus/cedrus_video.c +2 -2
@@ -56,7 +56,7 @@ static struct cedrus_format cedrus_formats[] = { .capabilities = CEDRUS_CAPABILITY_VP8_DEC, }, { - .pixelformat = V4L2_PIX_FMT_SUNXI_TILED_NV12, + .pixelformat = V4L2_PIX_FMT_NV12_32L32, .directions = CEDRUS_DECODE_DST, }, {
@@ -124,7 +124,7 @@ void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt) sizeimage =max_t (u32,SZ_1K , sizeimage);break ; -case V4L2_PIX_FMT_SUNXI_TILED_NV12 : +case V4L2_PIX_FMT_NV12_32L32 :/* 32-aligned stride. */ bytesperline =ALIGN (width,32 );
include/uapi/linux/videodev2.h +8 -1
@@ -627,6 +627,9 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4')/* 24 YUV444 planar */ #define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2')/* 24 YVU444 planar */ +/* Tiled YUV formats */ +#define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2')/* Tiled NV12 32x32 macroblocks in linear order */ +/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */ #define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G')/* 8 GBGB.. RGRG.. */
@@ -734,7 +737,6 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ')/* Depth data 16-bit */ #define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1')/* Mediatek compressed block mode */ #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I')/* Intel Planar Greyscale 10-bit and Depth 16-bit */ -#define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2')/* Sunxi Tiled NV12 Format */ #define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4')/* Intel 4-bit packed depth confidence information */ #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4')/* BTTV 8-bit dithered RGB */
@@ -2615,4 +2617,9 @@ struct v4l2_create_buffers {#define BASE_VIDIOC_PRIVATE 192/* 192-255 are private */ +/* Deprecated definitions kept for backwards compability */ +#ifdef __KERNEL__ +#define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2')/* Sunxi Tiled NV12 Format */ +#endif +#endif /* _UAPI__LINUX_VIDEODEV2_H */
Signature · 1 line
2.32.0
PATCH 2/3 media: Group tiled NV12 pixel formats
In reply to Ezequiel GarciaLet's get all the NV12 tiled pixel formats together for clarity and consistency.
--- include/uapi/linux/videodev2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/videodev2.h +2 -2
@@ -608,8 +608,6 @@ struct v4l2_pix_format {#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_NV12MT v4l2_fourcc('T', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ -#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 16x16 macroblocks */ /* three planes - Y Cb, Cr */ #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9')/* 9 YUV 4:1:0 */
@@ -628,6 +626,8 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2')/* 24 YVU444 planar */ /* Tiled YUV formats */ +#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 16x16 macroblocks */ #define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2')/* Tiled NV12 32x32 macroblocks in linear order */ /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
Signature · 1 line
2.32.0
PATCH 3/3 media: Add NV12_4L4 tiled format
In reply to Ezequiel GarciaThis format is produced by VeriSilicon Hantro G2 and VC8000D cores. It is a simple 4x4 tiling layout in a linear way.
The pixel format was introduced by GStreamer using FourCC VT12, so let's stick to it.
--- Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst | 6 ++++++ drivers/media/v4l2-core/v4l2-common.c | 3 +++ include/uapi/linux/videodev2.h | 1 + 3 files changed, 10 insertions(+)
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +6 -0
@@ -255,6 +255,7 @@ of the luma plane. .. _V4L2-PIX-FMT-NV12MT: .. _V4L2-PIX-FMT-NV12MT-16X16: .. _V4L2-PIX-FMT-NV12-32L32: +.. _V4L2-PIX-FMT-NV12-4L4: Tiled NV12 ----------
@@ -283,6 +284,11 @@ macroblocks linearly in memory. The line stride and image height must be aligned to a multiple of 32. The layouts of the luma and chroma planes are identical. +``V4L2_PIX_FMT_NV12_4L4`` stores pixel in 2D 4x4 macroblocks, and stores +macroblocks linearly in memory. The line stride and image height must be +aligned to a multiple of 4. The layouts of the luma and chroma planes are +identical. + .. _nv12mt: .. kernel-figure:: nv12mt.svg
drivers/media/v4l2-core/v4l2-common.c +3 -0
@@ -275,6 +275,9 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_YUV422P, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_GREY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + /* Tiled YUV formats */ + { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 }, + /* YUV planar formats, non contiguous variant */ { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 2 }, { .format = V4L2_PIX_FMT_YVU420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 2 },
include/uapi/linux/videodev2.h +1 -0
@@ -629,6 +629,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 16x16 macroblocks */ #define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2')/* Tiled NV12 32x32 macroblocks in linear order */ +#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2')/* Tiled NV12 4x4 macroblocks in linear order */ /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1')/* 8 BGBG.. GRGR.. */
Signature · 1 line
2.32.0