* [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit
@ 2023-07-22 7:44 Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,1/3] media: mediatek: vcodec: Add capture format to support 10bit tile mode Yunfei Dong
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Yunfei Dong @ 2023-07-22 7:44 UTC (permalink / raw)
To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
Cc: Chen-Yu Tsai, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, Yunfei Dong, Mingjia Zhang, linux-media, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
From: Yunfei Dong <yunfei.dong@mediatek.corp-partner.google.com>
Define two capture formats V4L2_PIX_FMT_MT2110R and
V4L2_PIX_FMT_MT2110T to support 10bit in mt8195, mt8199 and more.
Getting the size of each plane again when user space set 10bit
syntax to driver.
V4L2_PIX_FMT_MT2110R is used for H264, and V4L2_PIX_FMT_MT2110T
is used for AV1/VP9/HEVC.
patch 1 Add driver to support 10bit
patch 2 Add capture format V4L2_PIX_FMT_MT2110T to support 10bit tile mode
patch 3 Add capture format V4L2_PIX_FMT_MT2110R to support 10bit raster mode
---
- compared with v1:
- Fix set non sps return -EINVAL issue.
- Driver test pass in mt8195/mt8188 with tast and Youtube.
- Run v4l2 compliance in mt8195/mt8188 pass.
- fluster test as below:
- h264: (JVT-FR-EXT: 29/69 JVT-AVC_V1: 95/135)
- h265: (JCT-VC-HEVC_V1: 142/147)
- vp9 : (VP9-TEST-VECTORS: 1/6 VP9-TEST-VECTORS: 276/305)
- av1 : (CHROMIUM-10bit-AV1-TEST-VECTORS: 22/23 CHROMIUM-8bit-AV1-TEST-VECTORS: 11/13
- AV1-TEST-VECTORS: Ran 237/239)
- send the first version v1:
- Run 10bit VP9/AV1 fluster test pass.
- Will return error when the 10bit parameter no correctly in function mtk_vdec_s_ctrl.
---
Reference series:
[1]: this series depends on v6 which is send by Yunfei Dong.
message-id: 20230704131349.8354-1-yunfei.dong@mediatek.com
Mingjia Zhang (3):
media: mediatek: vcodec: Add capture format to support 10bit tile mode
media: mediatek: vcodec: Add capture format to support 10bit raster
mode
media: mediatek: vcodec: Add driver to support 10bit
.../media/v4l/pixfmt-reserved.rst | 13 ++
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 ++-
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 144 +++++++++++++++++-
drivers/media/v4l2-core/v4l2-common.c | 4 +
drivers/media/v4l2-core/v4l2-ioctl.c | 2 +
include/uapi/linux/videodev2.h | 2 +
7 files changed, 188 insertions(+), 4 deletions(-)
--
2.18.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2,1/3] media: mediatek: vcodec: Add capture format to support 10bit tile mode
2023-07-22 7:44 [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
@ 2023-07-22 7:44 ` Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,2/3] media: mediatek: vcodec: Add capture format to support 10bit raster mode Yunfei Dong
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Yunfei Dong @ 2023-07-22 7:44 UTC (permalink / raw)
To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
Cc: Chen-Yu Tsai, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, Yunfei Dong, Mingjia Zhang, linux-media, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
From: Mingjia Zhang <mingjia.zhang@mediatek.com>
Define one uncompressed capture format V4L2_PIX_FMT_MT2110T in order to
support 10bit for AV1/VP9/HEVC in mt8195.
Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
Documentation/userspace-api/media/v4l/pixfmt-reserved.rst | 7 +++++++
drivers/media/v4l2-core/v4l2-common.c | 2 ++
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
4 files changed, 11 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
index 58f6ae25b2e7..0bc69639baaa 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
@@ -275,6 +275,13 @@ please make a proposal on the linux-media mailing list.
Decoder's implementation can be found here,
`aspeed_codec <https://github.com/AspeedTech-BMC/aspeed_codec/>`__
+ * .. _V4L2-PIX-FMT-MT2110T:
+
+ - ``V4L2_PIX_FMT_MT2110T``
+ - 'MT2110T'
+ - This format is two-planar 10-Bit tile mode and having similitude with
+ ``V4L2_PIX_FMT_MM21`` in term of alignment and tiling. Used for VP9, AV1
+ and HEVC.
.. raw:: latex
\normalsize
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index bee1535b04d3..869fc09a210b 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -262,6 +262,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
{ .format = V4L2_PIX_FMT_VYUY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .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 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_YUV48_12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 6, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
+ { .format = V4L2_PIX_FMT_MT2110T, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2,
+ .block_w = { 16, 8, 0, 0 }, .block_h = { 32, 16, 0, 0 }},
/* 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 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 },
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 01ba27f2ef87..f465c0e3d6e3 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1508,6 +1508,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_QC10C: descr = "QCOM Compressed 10-bit Format"; break;
case V4L2_PIX_FMT_AJPG: descr = "Aspeed JPEG"; break;
case V4L2_PIX_FMT_AV1_FRAME: descr = "AV1 Frame"; break;
+ case V4L2_PIX_FMT_MT2110T: descr = "Mediatek 10bit Tile Mode"; break;
default:
if (fmt->description[0])
return;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 3af6a82d0cad..8c7d71afbdc7 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -796,6 +796,7 @@ 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_MM21 v4l2_fourcc('M', 'M', '2', '1') /* Mediatek 8-bit block mode, two non-contiguous planes */
+#define V4L2_PIX_FMT_MT2110T v4l2_fourcc('M', 'T', '2', 'T') /* Mediatek 10-bit block tile 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_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 */
--
2.18.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2,2/3] media: mediatek: vcodec: Add capture format to support 10bit raster mode
2023-07-22 7:44 [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,1/3] media: mediatek: vcodec: Add capture format to support 10bit tile mode Yunfei Dong
@ 2023-07-22 7:44 ` Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,3/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
2023-07-24 19:53 ` [PATCH v2,0/3] " Nicolas Dufresne
3 siblings, 0 replies; 7+ messages in thread
From: Yunfei Dong @ 2023-07-22 7:44 UTC (permalink / raw)
To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
Cc: Chen-Yu Tsai, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, Yunfei Dong, Mingjia Zhang, linux-media, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
From: Mingjia Zhang <mingjia.zhang@mediatek.com>
Define one uncompressed capture format V4L2_PIX_FMT_MT2110R in order to
support 10bit for H264 in mt8195.
Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
Documentation/userspace-api/media/v4l/pixfmt-reserved.rst | 6 ++++++
drivers/media/v4l2-core/v4l2-common.c | 2 ++
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/videodev2.h | 1 +
4 files changed, 10 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
index 0bc69639baaa..296ad2025e8d 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
@@ -282,6 +282,12 @@ please make a proposal on the linux-media mailing list.
- This format is two-planar 10-Bit tile mode and having similitude with
``V4L2_PIX_FMT_MM21`` in term of alignment and tiling. Used for VP9, AV1
and HEVC.
+ * .. _V4L2-PIX-FMT-MT2110R:
+
+ - ``V4L2_PIX_FMT_MT2110R``
+ - 'MT2110R'
+ - This format is two-planar 10-Bit raster mode and having similitude with
+ ``V4L2_PIX_FMT_MM21`` in term of alignment and tiling. Used for AVC.
.. raw:: latex
\normalsize
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 869fc09a210b..3a4b15a98e02 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -264,6 +264,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
{ .format = V4L2_PIX_FMT_YUV48_12, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 6, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 },
{ .format = V4L2_PIX_FMT_MT2110T, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2,
.block_w = { 16, 8, 0, 0 }, .block_h = { 32, 16, 0, 0 }},
+ { .format = V4L2_PIX_FMT_MT2110R, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 2, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2,
+ .block_w = { 16, 8, 0, 0 }, .block_h = { 32, 16, 0, 0 }},
/* 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 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 },
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index f465c0e3d6e3..f4d9d6279094 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1509,6 +1509,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_AJPG: descr = "Aspeed JPEG"; break;
case V4L2_PIX_FMT_AV1_FRAME: descr = "AV1 Frame"; break;
case V4L2_PIX_FMT_MT2110T: descr = "Mediatek 10bit Tile Mode"; break;
+ case V4L2_PIX_FMT_MT2110R: descr = "Mediatek 10bit Raster Mode"; break;
default:
if (fmt->description[0])
return;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 8c7d71afbdc7..78260e5d9985 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -797,6 +797,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_MT21C v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode */
#define V4L2_PIX_FMT_MM21 v4l2_fourcc('M', 'M', '2', '1') /* Mediatek 8-bit block mode, two non-contiguous planes */
#define V4L2_PIX_FMT_MT2110T v4l2_fourcc('M', 'T', '2', 'T') /* Mediatek 10-bit block tile mode */
+#define V4L2_PIX_FMT_MT2110R v4l2_fourcc('M', 'T', '2', 'R') /* Mediatek 10-bit block raster 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_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 */
--
2.18.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2,3/3] media: mediatek: vcodec: Add driver to support 10bit
2023-07-22 7:44 [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,1/3] media: mediatek: vcodec: Add capture format to support 10bit tile mode Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,2/3] media: mediatek: vcodec: Add capture format to support 10bit raster mode Yunfei Dong
@ 2023-07-22 7:44 ` Yunfei Dong
2023-07-24 19:53 ` [PATCH v2,0/3] " Nicolas Dufresne
3 siblings, 0 replies; 7+ messages in thread
From: Yunfei Dong @ 2023-07-22 7:44 UTC (permalink / raw)
To: Nícolas F . R . A . Prado, Nicolas Dufresne, Hans Verkuil,
AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
Cc: Chen-Yu Tsai, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, Yunfei Dong, Mingjia Zhang, linux-media, devicetree,
linux-kernel, linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
From: Mingjia Zhang <mingjia.zhang@mediatek.com>
Adding to support capture formats V4L2_PIX_FMT_MT2110T and
V4L2_PIX_FMT_MT2110R for 10bit playback. Need to get the size
of each plane again when user space setting syntax to get 10bit
information.
V4L2_PIX_FMT_MT2110T for AV1/VP9/HEVC.
V4L2_PIX_FMT_MT2110R for H264.
Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.com>
Co-developed-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 ++-
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
.../vcodec/decoder/mtk_vcodec_dec_stateless.c | 144 +++++++++++++++++-
3 files changed, 167 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
index 5acb7dff18f2..91ed576d6821 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
@@ -37,7 +37,9 @@ static bool mtk_vdec_get_cap_fmt(struct mtk_vcodec_dec_ctx *ctx, int format_inde
{
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
const struct mtk_video_fmt *fmt;
+ struct mtk_q_data *q_data;
int num_frame_count = 0, i;
+ bool ret = false;
fmt = &dec_pdata->vdec_formats[format_index];
for (i = 0; i < *dec_pdata->num_formats; i++) {
@@ -47,10 +49,26 @@ static bool mtk_vdec_get_cap_fmt(struct mtk_vcodec_dec_ctx *ctx, int format_inde
num_frame_count++;
}
- if (num_frame_count == 1 || fmt->fourcc == V4L2_PIX_FMT_MM21)
+ if (num_frame_count == 1 || (!ctx->is_10bit_bitstream && fmt->fourcc == V4L2_PIX_FMT_MM21))
return true;
- return false;
+ q_data = &ctx->q_data[MTK_Q_DATA_SRC];
+ switch (q_data->fmt->fourcc) {
+ case V4L2_PIX_FMT_H264_SLICE:
+ if (ctx->is_10bit_bitstream && fmt->fourcc == V4L2_PIX_FMT_MT2110R)
+ ret = true;
+ break;
+ case V4L2_PIX_FMT_VP9_FRAME:
+ case V4L2_PIX_FMT_AV1_FRAME:
+ case V4L2_PIX_FMT_HEVC_SLICE:
+ if (ctx->is_10bit_bitstream && fmt->fourcc == V4L2_PIX_FMT_MT2110T)
+ ret = true;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_dec_ctx *ctx,
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
index aa49969c54c1..6c318de25a55 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
@@ -31,6 +31,7 @@ enum mtk_vdec_format_types {
MTK_VDEC_FORMAT_AV1_FRAME = 0x800,
MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000,
MTK_VCODEC_INNER_RACING = 0x20000,
+ MTK_VDEC_IS_SUPPORT_10BIT = 0x40000,
};
/*
@@ -160,6 +161,8 @@ struct mtk_vcodec_dec_pdata {
* @hw_id: hardware index used to identify different hardware.
*
* @msg_queue: msg queue used to store lat buffer information.
+ *
+ * @is_10bit_bitstream: set to true if it's 10bit bitstream
*/
struct mtk_vcodec_dec_ctx {
enum mtk_instance_type type;
@@ -202,6 +205,8 @@ struct mtk_vcodec_dec_ctx {
int hw_id;
struct vdec_msg_queue msg_queue;
+
+ bool is_10bit_bitstream;
};
/**
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
index 99a84c7e1901..e29c9c58f3da 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
@@ -200,7 +200,7 @@ static const struct mtk_stateless_control mtk_stateless_controls[] = {
#define NUM_CTRLS ARRAY_SIZE(mtk_stateless_controls)
-static struct mtk_video_fmt mtk_video_formats[7];
+static struct mtk_video_fmt mtk_video_formats[9];
static struct mtk_video_fmt default_out_format;
static struct mtk_video_fmt default_cap_format;
@@ -387,6 +387,138 @@ static int mtk_vdec_flush_decoder(struct mtk_vcodec_dec_ctx *ctx)
return vdec_if_decode(ctx, NULL, NULL, &res_chg);
}
+static int mtk_vcodec_get_pic_info(struct mtk_vcodec_dec_ctx *ctx)
+{
+ struct mtk_q_data *q_data;
+ int ret = 0;
+
+ q_data = &ctx->q_data[MTK_Q_DATA_DST];
+ if (q_data->fmt->num_planes == 1) {
+ mtk_v4l2_vdec_err(ctx, "[%d]Error!! 10bit mode not support one plane", ctx->id);
+ return -EINVAL;
+ }
+
+ ctx->capture_fourcc = q_data->fmt->fourcc;
+ ret = vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo);
+ if (ret) {
+ mtk_v4l2_vdec_err(ctx, "[%d]Error!! Get GET_PARAM_PICTURE_INFO Fail", ctx->id);
+ return ret;
+ }
+
+ ctx->last_decoded_picinfo = ctx->picinfo;
+
+ q_data->sizeimage[0] = ctx->picinfo.fb_sz[0];
+ q_data->bytesperline[0] = ctx->picinfo.buf_w * 5 / 4;
+
+ q_data->sizeimage[1] = ctx->picinfo.fb_sz[1];
+ q_data->bytesperline[1] = ctx->picinfo.buf_w * 5 / 4;
+
+ q_data->coded_width = ctx->picinfo.buf_w;
+ q_data->coded_height = ctx->picinfo.buf_h;
+ mtk_v4l2_vdec_dbg(1, ctx, "[%d] wxh=%dx%d pic wxh=%dx%d sz[0]=0x%x sz[1]=0x%x",
+ ctx->id, ctx->picinfo.buf_w, ctx->picinfo.buf_h,
+ ctx->picinfo.pic_w, ctx->picinfo.pic_h,
+ q_data->sizeimage[0], q_data->sizeimage[1]);
+
+ return ret;
+}
+
+static int mtk_vdec_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+ struct mtk_vcodec_dec_ctx *ctx = ctrl_to_dec_ctx(ctrl);
+ struct v4l2_ctrl_h264_sps *h264;
+ struct v4l2_ctrl_hevc_sps *h265;
+ struct v4l2_ctrl_vp9_frame *frame;
+ struct v4l2_ctrl_av1_sequence *seq;
+ struct v4l2_ctrl *hdr_ctrl;
+ const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
+ const struct mtk_video_fmt *fmt;
+ int i = 0, ret = 0;
+
+ hdr_ctrl = ctrl;
+ if (!hdr_ctrl || !hdr_ctrl->p_new.p)
+ return -EINVAL;
+
+ switch (hdr_ctrl->id) {
+ case V4L2_CID_STATELESS_H264_SPS:
+ h264 = (struct v4l2_ctrl_h264_sps *)hdr_ctrl->p_new.p;
+
+ if (h264->bit_depth_chroma_minus8 == 2 && h264->bit_depth_luma_minus8 == 2) {
+ ctx->is_10bit_bitstream = true;
+ } else if (h264->bit_depth_chroma_minus8 != 0 &&
+ h264->bit_depth_luma_minus8 != 0) {
+ mtk_v4l2_vdec_err(ctx, "H264: chroma_minus8:%d, luma_minus8:%d",
+ h264->bit_depth_chroma_minus8,
+ h264->bit_depth_luma_minus8);
+ return -EINVAL;
+ }
+ break;
+ case V4L2_CID_STATELESS_HEVC_SPS:
+ h265 = (struct v4l2_ctrl_hevc_sps *)hdr_ctrl->p_new.p;
+
+ if (h265->bit_depth_chroma_minus8 == 2 && h265->bit_depth_luma_minus8 == 2) {
+ ctx->is_10bit_bitstream = true;
+ } else if (h265->bit_depth_chroma_minus8 != 0 &&
+ h265->bit_depth_luma_minus8 != 0) {
+ mtk_v4l2_vdec_err(ctx, "HEVC: chroma_minus8:%d, luma_minus8:%d",
+ h265->bit_depth_chroma_minus8,
+ h265->bit_depth_luma_minus8);
+ return -EINVAL;
+ }
+ break;
+ case V4L2_CID_STATELESS_VP9_FRAME:
+ frame = (struct v4l2_ctrl_vp9_frame *)hdr_ctrl->p_new.p;
+
+ if (frame->bit_depth == 10) {
+ ctx->is_10bit_bitstream = true;
+ } else if (frame->bit_depth != 8) {
+ mtk_v4l2_vdec_err(ctx, "VP9: bit_depth:%d", frame->bit_depth);
+ return -EINVAL;
+ }
+ break;
+ case V4L2_CID_STATELESS_AV1_SEQUENCE:
+ seq = (struct v4l2_ctrl_av1_sequence *)hdr_ctrl->p_new.p;
+
+ if (seq->bit_depth == 10) {
+ ctx->is_10bit_bitstream = true;
+ } else if (seq->bit_depth != 8) {
+ mtk_v4l2_vdec_err(ctx, "AV1: bit_depth:%d", seq->bit_depth);
+ return -EINVAL;
+ }
+ break;
+ default:
+ mtk_v4l2_vdec_dbg(3, ctx, "Not supported to set ctrl id: 0x%x\n", hdr_ctrl->id);
+ return ret;
+ }
+
+ if (!ctx->is_10bit_bitstream)
+ return ret;
+
+ for (i = 0; i < *dec_pdata->num_formats; i++) {
+ fmt = &dec_pdata->vdec_formats[i];
+ if (fmt->fourcc == V4L2_PIX_FMT_MT2110R &&
+ hdr_ctrl->id == V4L2_CID_STATELESS_H264_SPS) {
+ ctx->q_data[MTK_Q_DATA_DST].fmt = fmt;
+ break;
+ }
+
+ if (fmt->fourcc == V4L2_PIX_FMT_MT2110T &&
+ (hdr_ctrl->id == V4L2_CID_STATELESS_HEVC_SPS ||
+ hdr_ctrl->id == V4L2_CID_STATELESS_VP9_FRAME ||
+ hdr_ctrl->id == V4L2_CID_STATELESS_AV1_SEQUENCE)) {
+ ctx->q_data[MTK_Q_DATA_DST].fmt = fmt;
+ break;
+ }
+ }
+ ret = mtk_vcodec_get_pic_info(ctx);
+
+ return ret;
+}
+
+static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = {
+ .s_ctrl = mtk_vdec_s_ctrl,
+};
+
static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_dec_ctx *ctx)
{
unsigned int i;
@@ -399,7 +531,7 @@ static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_dec_ctx *ctx)
for (i = 0; i < NUM_CTRLS; i++) {
struct v4l2_ctrl_config cfg = mtk_stateless_controls[i].cfg;
-
+ cfg.ops = &mtk_vcodec_dec_ctrl_ops;
v4l2_ctrl_new_custom(&ctx->ctrl_hdl, &cfg, NULL);
if (ctx->ctrl_hdl.error) {
mtk_v4l2_vdec_err(ctx, "Adding control %d failed %d", i,
@@ -466,6 +598,8 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
break;
case V4L2_PIX_FMT_MM21:
case V4L2_PIX_FMT_MT21C:
+ case V4L2_PIX_FMT_MT2110T:
+ case V4L2_PIX_FMT_MT2110R:
mtk_video_formats[count_formats].fourcc = fourcc;
mtk_video_formats[count_formats].type = MTK_FMT_FRAME;
mtk_video_formats[count_formats].num_planes = 2;
@@ -491,6 +625,12 @@ static void mtk_vcodec_get_supported_formats(struct mtk_vcodec_dec_ctx *ctx)
mtk_vcodec_add_formats(V4L2_PIX_FMT_MT21C, ctx);
cap_format_count++;
}
+ if (ctx->dev->dec_capability & MTK_VDEC_IS_SUPPORT_10BIT) {
+ mtk_vcodec_add_formats(V4L2_PIX_FMT_MT2110T, ctx);
+ cap_format_count++;
+ mtk_vcodec_add_formats(V4L2_PIX_FMT_MT2110R, ctx);
+ cap_format_count++;
+ }
if (ctx->dev->dec_capability & MTK_VDEC_FORMAT_MM21) {
mtk_vcodec_add_formats(V4L2_PIX_FMT_MM21, ctx);
cap_format_count++;
--
2.18.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit
2023-07-22 7:44 [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
` (2 preceding siblings ...)
2023-07-22 7:44 ` [PATCH v2,3/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
@ 2023-07-24 19:53 ` Nicolas Dufresne
2023-07-29 3:31 ` Yunfei Dong (董云飞)
2023-09-12 1:32 ` Yunfei Dong (董云飞)
3 siblings, 2 replies; 7+ messages in thread
From: Nicolas Dufresne @ 2023-07-24 19:53 UTC (permalink / raw)
To: Yunfei Dong, Nícolas F . R . A . Prado, Hans Verkuil,
AngeloGioacchino Del Regno, Benjamin Gaignard, Nathan Hebert
Cc: Chen-Yu Tsai, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, Mingjia Zhang, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
Hi Yunfei.
Le samedi 22 juillet 2023 à 15:44 +0800, Yunfei Dong a écrit :
> From: Yunfei Dong <yunfei.dong@mediatek.corp-partner.google.com>
>
> Define two capture formats V4L2_PIX_FMT_MT2110R and
> V4L2_PIX_FMT_MT2110T to support 10bit in mt8195, mt8199 and more.
> Getting the size of each plane again when user space set 10bit
> syntax to driver.
>
> V4L2_PIX_FMT_MT2110R is used for H264, and V4L2_PIX_FMT_MT2110T
> is used for AV1/VP9/HEVC.
>
> patch 1 Add driver to support 10bit
> patch 2 Add capture format V4L2_PIX_FMT_MT2110T to support 10bit tile mode
> patch 3 Add capture format V4L2_PIX_FMT_MT2110R to support 10bit raster mode
> ---
> - compared with v1:
> - Fix set non sps return -EINVAL issue.
> - Driver test pass in mt8195/mt8188 with tast and Youtube.
> - Run v4l2 compliance in mt8195/mt8188 pass.
> - fluster test as below:
> - h264: (JVT-FR-EXT: 29/69 JVT-AVC_V1: 95/135)
> - h265: (JCT-VC-HEVC_V1: 142/147)
> - vp9 : (VP9-TEST-VECTORS: 1/6 VP9-TEST-VECTORS: 276/305)
> - av1 : (CHROMIUM-10bit-AV1-TEST-VECTORS: 22/23 CHROMIUM-8bit-AV1-TEST-VECTORS: 11/13
> - AV1-TEST-VECTORS: Ran 237/239)
Thanks for the fluster reports, I cannot confirm this yet, since it does not
apply. Note that you have forgot to provide V4L2 compliance report as requested.
>
> - send the first version v1:
> - Run 10bit VP9/AV1 fluster test pass.
> - Will return error when the 10bit parameter no correctly in function mtk_vdec_s_ctrl.
> ---
>
> Reference series:
> [1]: this series depends on v6 which is send by Yunfei Dong.
> message-id: 20230704131349.8354-1-yunfei.dong@mediatek.com
>
> Mingjia Zhang (3):
> media: mediatek: vcodec: Add capture format to support 10bit tile mode
> media: mediatek: vcodec: Add capture format to support 10bit raster
> mode
> media: mediatek: vcodec: Add driver to support 10bit
>
> .../media/v4l/pixfmt-reserved.rst | 13 ++
> .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 ++-
> .../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
> .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 144 +++++++++++++++++-
vcodec/decoder directory no longer exists. Can you rebase your work please ?
Nicolas
> drivers/media/v4l2-core/v4l2-common.c | 4 +
> drivers/media/v4l2-core/v4l2-ioctl.c | 2 +
> include/uapi/linux/videodev2.h | 2 +
> 7 files changed, 188 insertions(+), 4 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit
2023-07-24 19:53 ` [PATCH v2,0/3] " Nicolas Dufresne
@ 2023-07-29 3:31 ` Yunfei Dong (董云飞)
2023-09-12 1:32 ` Yunfei Dong (董云飞)
1 sibling, 0 replies; 7+ messages in thread
From: Yunfei Dong (董云飞) @ 2023-07-29 3:31 UTC (permalink / raw)
To: nhebert@chromium.org, benjamin.gaignard@collabora.com,
nfraprado@collabora.com, angelogioacchino.delregno@collabora.com,
nicolas.dufresne@collabora.com, hverkuil-cisco@xs4all.nl
Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
frkoenig@chromium.org, stevecho@chromium.org, wenst@chromium.org,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
daniel@ffwll.ch, Mingjia Zhang (张明佳),
Project_Global_Chrome_Upstream_Group, hsinyi@chromium.org,
linux-arm-kernel@lists.infradead.org
Hi Nicolas,
Thanks for your review.
On Mon, 2023-07-24 at 15:53 -0400, Nicolas Dufresne wrote:
> Hi Yunfei.
>
> Le samedi 22 juillet 2023 à 15:44 +0800, Yunfei Dong a écrit :
> > From: Yunfei Dong <yunfei.dong@mediatek.corp-partner.google.com>
> >
> > Define two capture formats V4L2_PIX_FMT_MT2110R and
> > V4L2_PIX_FMT_MT2110T to support 10bit in mt8195, mt8199 and more.
> > Getting the size of each plane again when user space set 10bit
> > syntax to driver.
> >
> > V4L2_PIX_FMT_MT2110R is used for H264, and V4L2_PIX_FMT_MT2110T
> > is used for AV1/VP9/HEVC.
> >
> > patch 1 Add driver to support 10bit
> > patch 2 Add capture format V4L2_PIX_FMT_MT2110T to support 10bit
> > tile mode
> > patch 3 Add capture format V4L2_PIX_FMT_MT2110R to support 10bit
> > raster mode
> > ---
> > - compared with v1:
> > - Fix set non sps return -EINVAL issue.
> > - Driver test pass in mt8195/mt8188 with tast and Youtube.
> > - Run v4l2 compliance in mt8195/mt8188 pass.
> > - fluster test as below:
> > - h264: (JVT-FR-EXT: 29/69 JVT-AVC_V1: 95/135)
> > - h265: (JCT-VC-HEVC_V1: 142/147)
> > - vp9 : (VP9-TEST-VECTORS: 1/6 VP9-TEST-VECTORS: 276/305)
> > - av1 : (CHROMIUM-10bit-AV1-TEST-VECTORS: 22/23 CHROMIUM-8bit-
> > AV1-TEST-VECTORS: 11/13
> > - AV1-TEST-VECTORS: Ran 237/239)
>
> Thanks for the fluster reports, I cannot confirm this yet, since it
> does not
> apply. Note that you have forgot to provide V4L2 compliance report as
> requested.
>
I will add the compliance reulst in patch v3. The compliance result is
pass.
> >
> > - send the first version v1:
> > - Run 10bit VP9/AV1 fluster test pass.
> > - Will return error when the 10bit parameter no correctly in
> > function mtk_vdec_s_ctrl.
> > ---
> >
> > Reference series:
> > [1]: this series depends on v6 which is send by Yunfei Dong.
> > message-id: 20230704131349.8354-1-yunfei.dong@mediatek.com
> >
> > Mingjia Zhang (3):
> > media: mediatek: vcodec: Add capture format to support 10bit tile
> > mode
> > media: mediatek: vcodec: Add capture format to support 10bit
> > raster
> > mode
> > media: mediatek: vcodec: Add driver to support 10bit
> >
> > .../media/v4l/pixfmt-reserved.rst | 13 ++
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 ++-
> > .../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 144
> > +++++++++++++++++-
>
> vcodec/decoder directory no longer exists. Can you rebase your work
> please ?
>
This patch series is based on patch 'separate encoder and decoder'.
vcodec/decoder folder is added in that patch.
> Nicolas
>
Best Regards,
Yunfei Dong
> > drivers/media/v4l2-core/v4l2-common.c | 4 +
> > drivers/media/v4l2-core/v4l2-ioctl.c | 2 +
> > include/uapi/linux/videodev2.h | 2 +
> > 7 files changed, 188 insertions(+), 4 deletions(-)
> >
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit
2023-07-24 19:53 ` [PATCH v2,0/3] " Nicolas Dufresne
2023-07-29 3:31 ` Yunfei Dong (董云飞)
@ 2023-09-12 1:32 ` Yunfei Dong (董云飞)
1 sibling, 0 replies; 7+ messages in thread
From: Yunfei Dong (董云飞) @ 2023-09-12 1:32 UTC (permalink / raw)
To: nhebert@chromium.org, benjamin.gaignard@collabora.com,
nfraprado@collabora.com, angelogioacchino.delregno@collabora.com,
nicolas.dufresne@collabora.com, hverkuil-cisco@xs4all.nl
Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
frkoenig@chromium.org, stevecho@chromium.org, wenst@chromium.org,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
daniel@ffwll.ch, Mingjia Zhang (张明佳),
Project_Global_Chrome_Upstream_Group, hsinyi@chromium.org,
linux-arm-kernel@lists.infradead.org
Hi Nicolas,
Thanks for your review.
On Mon, 2023-07-24 at 15:53 -0400, Nicolas Dufresne wrote:
> Hi Yunfei.
>
> Le samedi 22 juillet 2023 à 15:44 +0800, Yunfei Dong a écrit :
> > From: Yunfei Dong <yunfei.dong@mediatek.corp-partner.google.com>
> >
> > Define two capture formats V4L2_PIX_FMT_MT2110R and
> > V4L2_PIX_FMT_MT2110T to support 10bit in mt8195, mt8199 and more.
> > Getting the size of each plane again when user space set 10bit
> > syntax to driver.
> >
> > V4L2_PIX_FMT_MT2110R is used for H264, and V4L2_PIX_FMT_MT2110T
> > is used for AV1/VP9/HEVC.
> >
> > patch 1 Add driver to support 10bit
> > patch 2 Add capture format V4L2_PIX_FMT_MT2110T to support 10bit
> > tile mode
> > patch 3 Add capture format V4L2_PIX_FMT_MT2110R to support 10bit
> > raster mode
> > ---
> > - compared with v1:
> > - Fix set non sps return -EINVAL issue.
> > - Driver test pass in mt8195/mt8188 with tast and Youtube.
> > - Run v4l2 compliance in mt8195/mt8188 pass.
> > - fluster test as below:
> > - h264: (JVT-FR-EXT: 29/69 JVT-AVC_V1: 95/135)
> > - h265: (JCT-VC-HEVC_V1: 142/147)
> > - vp9 : (VP9-TEST-VECTORS: 1/6 VP9-TEST-VECTORS: 276/305)
> > - av1 : (CHROMIUM-10bit-AV1-TEST-VECTORS: 22/23 CHROMIUM-8bit-
> > AV1-TEST-VECTORS: 11/13
> > - AV1-TEST-VECTORS: Ran 237/239)
>
> Thanks for the fluster reports, I cannot confirm this yet, since it
> does not
> apply. Note that you have forgot to provide V4L2 compliance report as
> requested.
>
I will add the compliance reulst in patch v3. The compliance result is
pass.
> >
> > - send the first version v1:
> > - Run 10bit VP9/AV1 fluster test pass.
> > - Will return error when the 10bit parameter no correctly in
> > function mtk_vdec_s_ctrl.
> > ---
> >
> > Reference series:
> > [1]: this series depends on v6 which is send by Yunfei Dong.
> > message-id: 20230704131349.8354-1-yunfei.dong@mediatek.com
> >
> > Mingjia Zhang (3):
> > media: mediatek: vcodec: Add capture format to support 10bit tile
> > mode
> > media: mediatek: vcodec: Add capture format to support 10bit
> > raster
> > mode
> > media: mediatek: vcodec: Add driver to support 10bit
> >
> > .../media/v4l/pixfmt-reserved.rst | 13 ++
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 22 ++-
> > .../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
> > .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 144
> > +++++++++++++++++-
>
> vcodec/decoder directory no longer exists. Can you rebase your work
> please ?
>
This patch series is based on patch 'separate encoder and decoder'.
vcodec/decoder folder is added in that patch.
Best Regards,
Yunfei Dong
> Nicolas
>
> > drivers/media/v4l2-core/v4l2-common.c | 4 +
> > drivers/media/v4l2-core/v4l2-ioctl.c | 2 +
> > include/uapi/linux/videodev2.h | 2 +
> > 7 files changed, 188 insertions(+), 4 deletions(-)
> >
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-09-12 3:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22 7:44 [PATCH v2,0/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,1/3] media: mediatek: vcodec: Add capture format to support 10bit tile mode Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,2/3] media: mediatek: vcodec: Add capture format to support 10bit raster mode Yunfei Dong
2023-07-22 7:44 ` [PATCH v2,3/3] media: mediatek: vcodec: Add driver to support 10bit Yunfei Dong
2023-07-24 19:53 ` [PATCH v2,0/3] " Nicolas Dufresne
2023-07-29 3:31 ` Yunfei Dong (董云飞)
2023-09-12 1:32 ` Yunfei Dong (董云飞)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).