media: hantro: Add 10-bit support
Subsystems (4)
Jernej Skrabec
maintainerv3 cover media: hantro: Add 10-bit support
This series adds support for 10-bit format handling in Hantro driver. Most patches adjust postproc behaviour to be more universal. There is a lot of assumptions, which need to be replaced with more generalized.
Tested on Allwinner H6. Tested with vp92-2-20-10bit-yuv420.webm sample, which produces correct checksum.
Please take a look.
Best regards,
Jernej
Changes fron v2:
- rebased on media-stage/master
- added P010 4L4 format documentation
- added t-b and r-b tags
Changes from RFC:
- fixed typo in function name
- removed merged patch (P010 format)
- removed broken patch (sunxi frequency change)
- added new patch (media: hantro: postproc: Properly calculate chroma offset)
- added r-b from Ezequiel
Ezequiel Garcia (1):
media: Add P010 tiled format
Jernej Skrabec (6):
media: hantro: Support format filtering by depth
media: hantro: postproc: Fix buffer size calculation
media: hantro: postproc: Fix legacy regs configuration
media: hantro: postproc: Properly calculate chroma offset
media: hantro: Store VP9 bit depth in context
media: hantro: sunxi: Enable 10-bit decoding
.../media/v4l/pixfmt-yuv-planar.rst | 18 +++++-- drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/staging/media/hantro/hantro.h | 4 ++ drivers/staging/media/hantro/hantro_drv.c | 23 +++++++++ .../staging/media/hantro/hantro_g2_vp9_dec.c | 8 --- .../staging/media/hantro/hantro_postproc.c | 38 +++++++++++--- drivers/staging/media/hantro/hantro_v4l2.c | 50 +++++++++++++++++-- drivers/staging/media/hantro/hantro_v4l2.h | 3 ++ drivers/staging/media/hantro/sunxi_vpu_hw.c | 27 ++++++++++ include/uapi/linux/videodev2.h | 1 + 11 files changed, 151 insertions(+), 23 deletions(-)
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 1/7 media: Add P010 tiled format
From: Ezequiel Garcia <[email protected]>
Add P010 tiled format
--- .../media/v4l/pixfmt-yuv-planar.rst | 18 +++++++++++++++--- 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, 18 insertions(+), 3 deletions(-)
Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +15 -3
@@ -116,6 +116,13 @@ All components are stored with the same number of bits per component. - Cb, Cr - Yes - Linear + * - V4L2_PIX_FMT_P010_4L4 + - 'T010' + - 10 + - 4:2:0 + - Cb, Cr + - Yes + - 4x4 tiles * - V4L2_PIX_FMT_NV16 - 'NV16' - 8
@@ -528,11 +535,12 @@ number of lines as the luma plane. - Cr\ :sub:`33` .. _V4L2_PIX_FMT_P010: +.. _V4L2-PIX-FMT-P010-4L4: -P010 ----- +P010 and tiled P010 +------------------- -Like NV12 with 10 bits per component, expanded to 16 bits. +P010 is like NV12 with 10 bits per component, expanded to 16 bits. Data in the 10 high bits, zeros in the 6 low bits, arranged in little endian order. .. flat-table:: Sample 4x4 P010 Image
@@ -570,6 +578,10 @@ 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_P010_4L4`` stores pixels in 4x4 tiles, and stores tiles linearly +in memory. The line stride must be aligned to multiple of 8 and image height to +a multiple of 4. The layouts of the luma and chroma planes are identical. + .. raw:: latex \endgroup
drivers/media/v4l2-core/v4l2-common.c +1 -0
@@ -278,6 +278,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)/* 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 }, + { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 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 },
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -1310,6 +1310,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/CbCr 4:2:0 (4x4 Linear)" ;break ;case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/CbCr 4:2:0 (16x16 Linear)" ;break ;case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/CbCr 4:2:0 (32x32 Linear)" ;break ; +case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/CbCr 4:2:0 (4x4 Linear)" ;break ;case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ;
include/uapi/linux/videodev2.h +1 -0
@@ -630,6 +630,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2')/* 12 Y/CbCr 4:2:0 4x4 tiles */ #define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 16x16 tiles */ #define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2')/* 12 Y/CbCr 4:2:0 32x32 tiles */ +#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0')/* 12 Y/CbCr 4:2:0 10-bit 4x4 macroblocks */ /* Tiled YUV formats, non contiguous planes */ #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 64x32 tiles */
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 2/7 media: hantro: Support format filtering by depth
In reply to Jernej SkrabecIn preparation for supporting 10-bit formats, add mechanism which will filter formats based on pixel depth.
Hantro G2 supports only one decoding format natively and that is based on bit depth of current video frame. Additionally, it makes no sense to upconvert bitness, so filter those out too.
--- drivers/staging/media/hantro/hantro.h | 4 ++ drivers/staging/media/hantro/hantro_v4l2.c | 48 ++++++++++++++++++++-- drivers/staging/media/hantro/hantro_v4l2.h | 1 + 3 files changed, 50 insertions(+), 3 deletions(-)
drivers/staging/media/hantro/hantro.h +4 -0
@@ -227,6 +227,7 @@ struct hantro_dev {* * @ctrl_handler: Control handler used to register controls. * @jpeg_quality: User-specified JPEG compression quality. +* @bit_depth: Bit depth of current frame * * @codec_ops: Set of operations related to codec mode. * @postproc: Post-processing context.
@@ -252,6 +253,7 @@ struct hantro_ctx {struct v4l2_ctrl_handler ctrl_handler;int jpeg_quality; +int bit_depth;const struct hantro_codec_ops *codec_ops;struct hantro_postproc_ctx postproc;
@@ -277,6 +279,7 @@ struct hantro_ctx {* @enc_fmt: Format identifier for encoder registers. * @frmsize: Supported range of frame sizes (only for bitstream formats). * @postprocessed: Indicates if this format needs the post-processor. +* @match_depth: Indicates if format bit depth must match video bit depth */ struct hantro_fmt {char *name;
@@ -287,6 +290,7 @@ struct hantro_fmt {enum hantro_enc_fmt enc_fmt;struct v4l2_frmsize_stepwise frmsize;bool postprocessed; +bool match_depth; };struct hantro_reg {
drivers/staging/media/hantro/hantro_v4l2.c +45 -3
77 lines not on this page · raw message
drivers/staging/media/hantro/hantro_v4l2.h +1 -0
@@ -22,5 +22,6 @@ extern const struct v4l2_ioctl_ops hantro_ioctl_ops;extern const struct vb2_ops hantro_queue_ops;void hantro_reset_fmts (struct hantro_ctx *ctx); +int hantro_get_format_depth (u32 fourcc);#endif /* HANTRO_V4L2_H_ */
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 3/7 media: hantro: postproc: Fix buffer size calculation
In reply to Jernej SkrabecWhen allocating aux buffers for postprocessing, it's assumed that base buffer size is the same as that of output. Coincidentally, that's true most of the time, but not always. 10-bit source also needs aux buffer size which is appropriate for 10-bit native format, even if the output format is 8-bit. Similarly, mv sizes and other extra buffer size also depends on source width/height, not destination.
--- .../staging/media/hantro/hantro_postproc.c | 24 +++++++++++++------ drivers/staging/media/hantro/hantro_v4l2.c | 2 +- drivers/staging/media/hantro/hantro_v4l2.h | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-)
drivers/staging/media/hantro/hantro_postproc.c +17 -7
@@ -12,6 +12,7 @@#include "hantro_hw.h" #include "hantro_g1_regs.h" #include "hantro_g2_regs.h" +#include "hantro_v4l2.h" #define HANTRO_PP_REG_WRITE (vpu, reg_name, val) \ { \
@@ -174,18 +175,27 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;struct vb2_queue *cap_queue = &m2m_ctx->cap_q_ctx.q;unsigned int num_buffers = cap_queue->num_buffers; +struct v4l2_pix_format_mplane pix_mp; +const struct hantro_fmt *fmt;unsigned int i, buf_size; - buf_size = ctx->dst_fmt.plane_fmt[0 ].sizeimage; +/* this should always pick native format */ + fmt =hantro_get_default_fmt (ctx, false); +if (!fmt) +return -EINVAL ; +v4l2_fill_pixfmt_mp (&pix_mp, fmt->fourcc, ctx->src_fmt.width, + ctx->src_fmt.height); + + buf_size = pix_mp.plane_fmt[0 ].sizeimage;if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_H264_SLICE ) - buf_size +=hantro_h264_mv_size (ctx->dst_fmt.width, - ctx->dst_fmt.height); + buf_size +=hantro_h264_mv_size (pix_mp.width, + pix_mp.height);else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_VP9_FRAME ) - buf_size +=hantro_vp9_mv_size (ctx->dst_fmt.width, - ctx->dst_fmt.height); + buf_size +=hantro_vp9_mv_size (pix_mp.width, + pix_mp.height);else if (ctx->vpu_src_fmt->fourcc ==V4L2_PIX_FMT_HEVC_SLICE ) - buf_size +=hantro_hevc_mv_size (ctx->dst_fmt.width, - ctx->dst_fmt.height); + buf_size +=hantro_hevc_mv_size (pix_mp.width, + pix_mp.height);for (i =0 ; i < num_buffers; ++i) {struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];
drivers/staging/media/hantro/hantro_v4l2.c +1 -1
@@ -118,7 +118,7 @@ hantro_find_format(const struct hantro_ctx *ctx, u32 fourcc)return NULL ; } -static const struct hantro_fmt * +const struct hantro_fmt *hantro_get_default_fmt (const struct hantro_ctx *ctx,bool bitstream) {const struct hantro_fmt *formats;
drivers/staging/media/hantro/hantro_v4l2.h +2 -0
@@ -23,5 +23,7 @@ extern const struct vb2_ops hantro_queue_ops;void hantro_reset_fmts (struct hantro_ctx *ctx);int hantro_get_format_depth (u32 fourcc); +const struct hantro_fmt * +hantro_get_default_fmt (const struct hantro_ctx *ctx,bool bitstream);#endif /* HANTRO_V4L2_H_ */
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 4/7 media: hantro: postproc: Fix legacy regs configuration
In reply to Jernej SkrabecSome postproc legacy registers were set in VP9 code. Move them to postproc and fix their value.
--- drivers/staging/media/hantro/hantro_g2_vp9_dec.c | 8 -------- drivers/staging/media/hantro/hantro_postproc.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/staging/media/hantro/hantro_g2_vp9_dec.c +0 -8
@@ -515,16 +515,8 @@ static void config_bit_depth(struct hantro_ctx *ctx, const struct v4l2_ctrl_vp9_frame *dec_params) {if (ctx->dev->variant->legacy_regs) { -u8 pp_shift =0 ; -hantro_reg_write (ctx->dev, &g2_bit_depth_y, dec_params->bit_depth);hantro_reg_write (ctx->dev, &g2_bit_depth_c, dec_params->bit_depth); -hantro_reg_write (ctx->dev, &g2_rs_out_bit_depth, dec_params->bit_depth); - -if (dec_params->bit_depth >8 ) - pp_shift =16 - dec_params->bit_depth; - -hantro_reg_write (ctx->dev, &g2_pp_pix_shift, pp_shift);hantro_reg_write (ctx->dev, &g2_pix_shift,0 ); }else {hantro_reg_write (ctx->dev, &g2_bit_depth_y_minus8, dec_params->bit_depth -8 );
drivers/staging/media/hantro/hantro_postproc.c +10 -0
@@ -130,6 +130,16 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx)hantro_write_addr (vpu,G2_RS_OUT_LUMA_ADDR , dst_dma);hantro_write_addr (vpu,G2_RS_OUT_CHROMA_ADDR , dst_dma + chroma_offset); } +if (ctx->dev->variant->legacy_regs) { +int out_depth =hantro_get_format_depth (ctx->dst_fmt.pixelformat); +u8 pp_shift =0 ; + +if (out_depth >8 ) + pp_shift =16 - out_depth; + +hantro_reg_write (ctx->dev, &g2_rs_out_bit_depth, out_depth); +hantro_reg_write (ctx->dev, &g2_pp_pix_shift, pp_shift); + }hantro_reg_write (vpu, &g2_out_rs_e,1 ); }
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 5/7 media: hantro: postproc: Properly calculate chroma offset
In reply to Jernej SkrabecCurrently chroma offset calculation assumes only 1 byte per luma, with no consideration for stride.
Take necessary information from destination pixel format which makes calculation completely universal.
--- drivers/staging/media/hantro/hantro_postproc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_postproc.c +3 -1
@@ -113,12 +113,14 @@ static void hantro_postproc_g2_enable(struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *dst_buf; -size_t chroma_offset = ctx->dst_fmt.width * ctx->dst_fmt.height;int down_scale =down_scale_factor (ctx); +size_t chroma_offset;dma_addr_t dst_dma; dst_buf =hantro_get_dst_buf (ctx); dst_dma =vb2_dma_contig_plane_dma_addr (&dst_buf->vb2_buf,0 ); + chroma_offset = ctx->dst_fmt.plane_fmt[0 ].bytesperline * + ctx->dst_fmt.height;if (down_scale) {hantro_reg_write (vpu, &g2_down_scale_e,1 );
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 6/7 media: hantro: Store VP9 bit depth in context
In reply to Jernej SkrabecNow that we have proper infrastructure for postprocessing 10-bit formats, store VP9 bit depth in context.
--- drivers/staging/media/hantro/hantro_drv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/staging/media/hantro/hantro_drv.c +23 -0
@@ -324,6 +324,24 @@ static int hantro_hevc_s_ctrl(struct v4l2_ctrl *ctrl)return 0 ; } +static int hantro_vp9_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct hantro_ctx *ctx; + + ctx =container_of (ctrl->handler, + struct hantro_ctx, ctrl_handler); + +switch (ctrl->id) { +case V4L2_CID_STATELESS_VP9_FRAME : + ctx->bit_depth = ctrl->p_new.p_vp9_frame->bit_depth; +break ; +default : +return -EINVAL ; + } + +return 0 ; +} +static const struct v4l2_ctrl_ops hantro_ctrl_ops = { .try_ctrl = hantro_try_ctrl, };
@@ -336,6 +354,10 @@ static const struct v4l2_ctrl_ops hantro_hevc_ctrl_ops = { .s_ctrl = hantro_hevc_s_ctrl, }; +static const struct v4l2_ctrl_ops hantro_vp9_ctrl_ops = { + .s_ctrl = hantro_vp9_s_ctrl, +}; +#define HANTRO_JPEG_ACTIVE_MARKERS (V4L2_JPEG_ACTIVE_MARKER_APP0 | \ V4L2_JPEG_ACTIVE_MARKER_COM | \ V4L2_JPEG_ACTIVE_MARKER_DQT | \
@@ -503,6 +525,7 @@ static const struct hantro_ctrl controls[] = { .codec = HANTRO_VP9_DECODER, .cfg = { .id = V4L2_CID_STATELESS_VP9_FRAME, + .ops = &hantro_vp9_ctrl_ops, }, }, { .codec = HANTRO_VP9_DECODER,
Signature · 1 line
2.37.0
Jernej Skrabec
maintainerPATCH v3 7/7 media: hantro: sunxi: Enable 10-bit decoding
In reply to Jernej SkrabecNow that infrastructure for 10-bit decoding exists, enable it for Allwinner H6.
--- drivers/staging/media/hantro/sunxi_vpu_hw.c | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/staging/media/hantro/sunxi_vpu_hw.c +27 -0
@@ -23,12 +23,39 @@ static const struct hantro_fmt sunxi_vpu_postproc_fmts[] = { .step_height = 32, }, }, + { + .fourcc = V4L2_PIX_FMT_P010, + .codec_mode = HANTRO_MODE_NONE, + .postprocessed = true, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_UHD_WIDTH, + .step_width = 32, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_UHD_HEIGHT, + .step_height = 32, + }, + }, }; static const struct hantro_fmt sunxi_vpu_dec_fmts[] = { { .fourcc = V4L2_PIX_FMT_NV12_4L4, .codec_mode = HANTRO_MODE_NONE, + .match_depth = true, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_UHD_WIDTH, + .step_width = 32, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_UHD_HEIGHT, + .step_height = 32, + }, + }, + { + .fourcc = V4L2_PIX_FMT_P010_4L4, + .codec_mode = HANTRO_MODE_NONE, + .match_depth = true, .frmsize = { .min_width = FMT_MIN_WIDTH, .max_width = FMT_UHD_WIDTH,
Signature · 1 line
2.37.0
Jernej,
Quoted 10 lines · Jernej Skrabec
This series adds support for 10-bit format handling in Hantro driver. Most patches adjust postproc behaviour to be more universal. There is a lot of assumptions, which need to be replaced with more generalized.
Tested on Allwinner H6. Tested with vp92-2-20-10bit-yuv420.webm sample, which produces correct checksum.
Please take a look.
Looks really good.
Thanks for working on this.
Ezequiel
Quoted 42 lines
Best regards,
JernejChanges fron v2:
- rebased on media-stage/master
- added P010 4L4 format documentation
- added t-b and r-b tagsChanges from RFC:
- fixed typo in function name
- removed merged patch (P010 format)
- removed broken patch (sunxi frequency change)
- added new patch (media: hantro: postproc: Properly calculate chroma offset)
- added r-b from EzequielEzequiel Garcia (1):
media: Add P010 tiled formatJernej Skrabec (6):
media: hantro: Support format filtering by depth
media: hantro: postproc: Fix buffer size calculation
media: hantro: postproc: Fix legacy regs configuration
media: hantro: postproc: Properly calculate chroma offset
media: hantro: Store VP9 bit depth in context
media: hantro: sunxi: Enable 10-bit decoding.../media/v4l/pixfmt-yuv-planar.rst | 18 +++++-- drivers/media/v4l2-core/v4l2-common.c | 1 + drivers/media/v4l2-core/v4l2-ioctl.c | 1 + drivers/staging/media/hantro/hantro.h | 4 ++ drivers/staging/media/hantro/hantro_drv.c | 23 +++++++++ .../staging/media/hantro/hantro_g2_vp9_dec.c | 8 --- .../staging/media/hantro/hantro_postproc.c | 38 +++++++++++--- drivers/staging/media/hantro/hantro_v4l2.c | 50 +++++++++++++++++-- drivers/staging/media/hantro/hantro_v4l2.h | 3 ++ drivers/staging/media/hantro/sunxi_vpu_hw.c | 27 ++++++++++ include/uapi/linux/videodev2.h | 1 + 11 files changed, 151 insertions(+), 23 deletions(-)--
2.37.0
Re: [PATCH v3 1/7] media: Add P010 tiled format
In reply to Jernej SkrabecHi Ezequiel, Benjamin,
Le mercredi 06 juillet 2022 à 20:28 +0200, Jernej Skrabec a écrit :
Quoted 5 lines
From: Ezequiel Garcia <[email protected]>
Add P010 tiled format
Tested-by Benjamin Gaignard <[email protected]>
I just tested Hantro G2 myself, and that highlights that this was not really tested. I believe no-one had written software detiler to verify this, so tested meant something like "its producing data". In fact, it seems that P010_4L4 is not a pixel formats, at least not one covered by Hantro driver.
I've dumped the tiled data, and the per tile format is not made of 16bit components, but instead its similar to Rockchip format, where 4 pixels are packed over. As part of the AV1 driver writing, I made a detiler for that format.
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3447
Let's be more careful next time, pixels formats are frozen into our API, and there is a lot of them already, lets not invent any.
Hans, what should we do about this one ? I can split off the NV12_10LE40_4L4 format from the AV1 patchset, and port G2 to use that instead. That would leave behind P010_4L4 as unused (actually unexistant). Any better ideas ? Perhaps we could steal the fourcc, its not terribly meaningful, and make P010_4L4 an alias ?
Nicolas
Quoted 91 lines
Signed-off-by Ezequiel Garcia <[email protected]>[rebased, updated pixel format name and added description]Signed-off-by Jernej Skrabec <[email protected]>--- .../media/v4l/pixfmt-yuv-planar.rst | 18 +++++++++++++++--- 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, 18 insertions(+), 3 deletions(-)Documentation/userspace-api/media/v4l/pixfmt-yuv-planar.rst +15
-3@@ -116,6 +116,13 @@ All components are stored with the same number of bits per component. - Cb, Cr - Yes - Linear + * - V4L2_PIX_FMT_P010_4L4 + - 'T010' + - 10 + - 4:2:0 + - Cb, Cr + - Yes + - 4x4 tiles * - V4L2_PIX_FMT_NV16 - 'NV16' - 8@@ -528,11 +535,12 @@ number of lines as the luma plane. - Cr\ :sub:`33` .. _V4L2_PIX_FMT_P010: +.. _V4L2-PIX-FMT-P010-4L4: -P010 ----- +P010 and tiled P010 +------------------- -Like NV12 with 10 bits per component, expanded to 16 bits. +P010 is like NV12 with 10 bits per component, expanded to 16 bits. Data in the 10 high bits, zeros in the 6 low bits, arranged in little endian order. .. flat-table:: Sample 4x4 P010 Image@@ -570,6 +578,10 @@ 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_P010_4L4`` stores pixels in 4x4 tiles, and stores tiles linearly +in memory. The line stride must be aligned to multiple of 8 and image height to +a multiple of 4. The layouts of the luma and chroma planes are identical. + .. raw:: latex \endgroupdrivers/media/v4l2-core/v4l2-common.c +1
-0@@ -278,6 +278,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)/* 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 }, + { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 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 },drivers/media/v4l2-core/v4l2-ioctl.c +1
-0@@ -1310,6 +1310,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_NV12_4L4 : descr ="Y/CbCr 4:2:0 (4x4 Linear)" ;break ;case V4L2_PIX_FMT_NV12_16L16 : descr ="Y/CbCr 4:2:0 (16x16 Linear)" ;break ;case V4L2_PIX_FMT_NV12_32L32 : descr ="Y/CbCr 4:2:0 (32x32 Linear)" ;break ; +case V4L2_PIX_FMT_P010_4L4 : descr ="10-bit Y/CbCr 4:2:0 (4x4 Linear)" ;break ;case V4L2_PIX_FMT_NV12M : descr ="Y/CbCr 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV21M : descr ="Y/CrCb 4:2:0 (N-C)" ;break ;case V4L2_PIX_FMT_NV16M : descr ="Y/CbCr 4:2:2 (N-C)" ;break ;include/uapi/linux/videodev2.h +1
-0@@ -630,6 +630,7 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2')/* 12 Y/CbCr 4:2:0 4x4 tiles */ #define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 16x16 tiles */ #define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2')/* 12 Y/CbCr 4:2:0 32x32 tiles */ +#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0')/* 12 Y/CbCr 4:2:0 10-bit 4x4 macroblocks */ /* Tiled YUV formats, non contiguous planes */ #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2')/* 12 Y/CbCr 4:2:0 64x32 tiles */