* [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support
@ 2025-04-17 21:57 Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 1/4] media: rkvdec: h264: Limit minimum profile to constrained baseline Nicolas Dufresne
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-17 21:57 UTC (permalink / raw)
To: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Nicolas Dufresne, Sebastian Fricke, Jonas Karlman,
Christopher Obbard
This series add H.264 High 10 and 4:2:2 profile support to the Rockchip
Video Decoder driver.
Patch 1 limits the minimum profile to constrained baseline due to
unsupported features in the full baseline profile.
Patch 2 refactors code to support filtering of CAPTURE formats based
on the image format returned from a new get_image_fmt() ops.
Patch 3 adds final bits to support H.264 High 10 and 4:2:2 profiles.
Tested with Fluster on a Libre Computer Renegade Elite (RK3399).
Decoder: GStreamer
Commit: 8c7ad20e4e82296ed9916f53c201e110c629f0f5
JVT-AVC_V1: 129/135
JVT-FR-EXT: 65/69
JVT-Professional_profiles: 12/38
JVT-MVC: 0/20 (not supported)
JVT-SVC: 38/185 (temporal only)
In summary, all tests that are 4:2:2 sub-sampled are now passing with
the exception of the following that display some unexplained artifacts.
- Hi422FREXT17_SONY_A
- Hi422FREXT19_SONY_A
This score also includes 4:2:0 10bit tests, that may have been reported
as failing due to lack of userspace support for NV15 format. It also
includes results from test suite that did not exists before (Pro, MVC
and SVC).
Changes in v9:
- Moved v4l2_m2m_ctx init before the controls
- Removed unneeded changes in try_ctrl ops
- Link to v8: https://lore.kernel.org/r/20250417-b4-rkvdec_h264_high10_and_422_support-v8-0-423fe0a2ee7e@collabora.com
Changes in v8:
- Removed patches that got applied from v7
- Move the constrained-baseline fix first
- Move the format checks into s_ctrl only
- Simplify the checks
- Retest against a newer GStreamer version with NV16 and NV20 support.
- Test against the new fluster suite Professions, SVC and MVC.
Link to v7: https://lore.kernel.org/linux-media/20250225-rkvdec_h264_high10_and_422_support-v7-0-7992a68a4910@collabora.com/
Changes in v7:
- Split out the change with the minimum profile
- s/v4l2_format_plane_width/v4l2_format_plane_stride/
- Move V4L2_PIX_FMT_NV15/V4L2_PIX_FMT_NV20 documentation as suggested
- Change return value from int to bool on rkvdec_image_fmt_match
- Add reviewed-by tags
Link to v6: https://lore.kernel.org/linux-media/20240909192522.1076704-1-jonas@kwiboo.se/
Changes in v6:
- Change to use fmt_idx instead of j++ tucked inside a condition (Dan)
- Add patch to fix enumerated frame sizes returned to userspace (Alex)
- Fluster test score is same as v4 and v5, see [4] and [5]
Link to v5: https://lore.kernel.org/linux-media/20240618194647.742037-1-jonas@kwiboo.se/
Changes in v5:
- Drop Remove SPS validation at streaming start patch
- Move buffer align from rkvdec_fill_decoded_pixfmt to min/step_width
- Use correct profiles for V4L2_CID_MPEG_VIDEO_H264_PROFILE
- Collect r-b and t-b tags
- Fluster test score is same as v4, see [4] and [5]
Link to v4: https://lore.kernel.org/linux-media/20231105165521.3592037-1-jonas@kwiboo.se/
Changes in v4:
- Fix failed v4l2-compliance tests related to CAPTURE queue
- Rework CAPTURE format filter anv validate to use an image format
- Run fluster test suite JVT-FR-EXT [4] and JVT-AVC_V1 [5]
Link to v3: https://lore.kernel.org/linux-media/20231029183427.1781554-1-jonas@kwiboo.se/
Changes in v3:
- Drop merged patches
- Use bpp and bpp_div instead of prior misuse of block_w/block_h
- New patch to use values from SPS/PPS control to configure the HW
- New patch to remove an unnecessary call to validate sps at streaming start
- Reworked pixel format validation
Link to v2: https://lore.kernel.org/linux-media/20200706215430.22859-1-jonas@kwiboo.se/
Changes in v2:
- Collect r-b tags
- SPS pic width and height in mbs validation moved to rkvdec_try_ctrl
- New patch to not override output buffer sizeimage
- Reworked pixel format validation
- Only align decoded buffer instead of changing frmsize step_width
Link to v1: https://lore.kernel.org/linux-media/20200701215616.30874-1-jonas@kwiboo.se/
To fully runtime test this series you may need FFmpeg patches from [1]
and fluster patches from [2], this series is also available at [3].
[1] https://github.com/Kwiboo/FFmpeg/commits/v4l2request-2024-v2-rkvdec/
[2] https://github.com/Kwiboo/fluster/commits/ffmpeg-v4l2request-rkvdec/
[3] https://github.com/Kwiboo/linux-rockchip/commits/linuxtv-rkvdec-high-10-v6/
[4] https://gist.github.com/Kwiboo/f4ac15576b2c72887ae2bc5d58b5c865
[5] https://gist.github.com/Kwiboo/459a1c8f1dcb56e45dc7a7a29cc28adf
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
Jonas Karlman (2):
media: rkvdec: Add get_image_fmt ops
media: rkvdec: h264: Support High 10 and 4:2:2 profiles
Nicolas Dufresne (1):
media: rkvdec: Initialize the m2m context before the controls
Sebastian Fricke (1):
media: rkvdec: h264: Limit minimum profile to constrained baseline
drivers/staging/media/rkvdec/rkvdec-h264.c | 37 ++++++++++---
drivers/staging/media/rkvdec/rkvdec.c | 89 ++++++++++++++++++++++++------
drivers/staging/media/rkvdec/rkvdec.h | 5 ++
3 files changed, 105 insertions(+), 26 deletions(-)
---
base-commit: 3105a6d6088a79d091990f2107f67ad7fa04ee8d
change-id: 20250416-b4-rkvdec_h264_high10_and_422_support-381a74151162
Best regards,
--
Nicolas Dufresne <nicolas.dufresne@collabora.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v9 1/4] media: rkvdec: h264: Limit minimum profile to constrained baseline
2025-04-17 21:57 [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
@ 2025-04-17 21:57 ` Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 2/4] media: rkvdec: Initialize the m2m context before the controls Nicolas Dufresne
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-17 21:57 UTC (permalink / raw)
To: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Nicolas Dufresne, Sebastian Fricke
From: Sebastian Fricke <sebastian.fricke@collabora.com>
Neither the hardware nor the kernel API support FMO/ASO features
required by the full baseline profile. Therefore limit the minimum
profile to the constrained baseline profile explicitly.
Suggested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
drivers/staging/media/rkvdec/rkvdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index dd7e57a902640d363d26be887cb535c2668d5b15..65c6f1d07a493e017ae941780b823d41314a49b8 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -150,7 +150,7 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
},
{
.cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE,
- .cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,
+ .cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE,
.cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
.cfg.menu_skip_mask =
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v9 2/4] media: rkvdec: Initialize the m2m context before the controls
2025-04-17 21:57 [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 1/4] media: rkvdec: h264: Limit minimum profile to constrained baseline Nicolas Dufresne
@ 2025-04-17 21:57 ` Nicolas Dufresne
2025-04-17 21:58 ` [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops Nicolas Dufresne
2025-04-17 21:58 ` [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Nicolas Dufresne
3 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-17 21:57 UTC (permalink / raw)
To: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Nicolas Dufresne
Setting up the control handler calls into .s_ctrl ops. While validating
the controls the ops may need to access some of the context state, which
could lead to a crash if not properly initialized.
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
drivers/staging/media/rkvdec/rkvdec.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index 65c6f1d07a493e017ae941780b823d41314a49b8..7b780392bb6a63cc954655ef940e87146d2b852f 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -871,24 +871,24 @@ static int rkvdec_open(struct file *filp)
rkvdec_reset_decoded_fmt(ctx);
v4l2_fh_init(&ctx->fh, video_devdata(filp));
- ret = rkvdec_init_ctrls(ctx);
- if (ret)
- goto err_free_ctx;
-
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rkvdec->m2m_dev, ctx,
rkvdec_queue_init);
if (IS_ERR(ctx->fh.m2m_ctx)) {
ret = PTR_ERR(ctx->fh.m2m_ctx);
- goto err_cleanup_ctrls;
+ goto err_free_ctx;
}
+ ret = rkvdec_init_ctrls(ctx);
+ if (ret)
+ goto err_cleanup_m2m_ctx;
+
filp->private_data = &ctx->fh;
v4l2_fh_add(&ctx->fh);
return 0;
-err_cleanup_ctrls:
- v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
+err_cleanup_m2m_ctx:
+ v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
err_free_ctx:
kfree(ctx);
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops
2025-04-17 21:57 [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 1/4] media: rkvdec: h264: Limit minimum profile to constrained baseline Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 2/4] media: rkvdec: Initialize the m2m context before the controls Nicolas Dufresne
@ 2025-04-17 21:58 ` Nicolas Dufresne
2025-04-18 6:22 ` Jonas Karlman
2025-04-17 21:58 ` [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Nicolas Dufresne
3 siblings, 1 reply; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-17 21:58 UTC (permalink / raw)
To: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Nicolas Dufresne, Jonas Karlman
From: Jonas Karlman <jonas@kwiboo.se>
Add support for a get_image_fmt() ops that returns the required image
format.
The CAPTURE format is reset when the required image format changes and
the buffer queue is not busy.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Co-developed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
drivers/staging/media/rkvdec/rkvdec.c | 35 +++++++++++++++++++++++++++++++++++
drivers/staging/media/rkvdec/rkvdec.h | 2 ++
2 files changed, 37 insertions(+)
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index 7b780392bb6a63cc954655ef940e87146d2b852f..6c6fe411f48772419e1810d869ab40d168848e65 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc,
return false;
}
+static bool rkvdec_fmt_changed(struct rkvdec_ctx *ctx,
+ enum rkvdec_image_fmt image_fmt)
+{
+ if (image_fmt == RKVDEC_IMG_FMT_ANY)
+ return false;
+
+ return ctx->image_fmt != image_fmt;
+}
+
static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
struct v4l2_pix_format_mplane *pix_mp)
{
@@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
return 0;
}
+static int rkvdec_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+ struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
+ const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
+ enum rkvdec_image_fmt image_fmt;
+ struct vb2_queue *vq;
+
+ /* Check if this change requires a capture format reset */
+ if (!desc->ops->get_image_fmt)
+ return 0;
+
+ image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
+ if (rkvdec_fmt_changed(ctx, image_fmt)) {
+ vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
+ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
+ if (vb2_is_busy(vq))
+ return -EBUSY;
+
+ ctx->image_fmt = image_fmt;
+ rkvdec_reset_decoded_fmt(ctx);
+ }
+
+ return 0;
+}
+
static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
.try_ctrl = rkvdec_try_ctrl,
+ .s_ctrl = rkvdec_s_ctrl,
};
static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
index 6f8cf50c5d99aad2f52e321f54f3ca17166ddf98..e466a2753ccfc13738e0a672bc578e521af2c3f2 100644
--- a/drivers/staging/media/rkvdec/rkvdec.h
+++ b/drivers/staging/media/rkvdec/rkvdec.h
@@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
struct vb2_v4l2_buffer *dst_buf,
enum vb2_buffer_state result);
int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
+ enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx,
+ struct v4l2_ctrl *ctrl);
};
enum rkvdec_image_fmt {
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles
2025-04-17 21:57 [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
` (2 preceding siblings ...)
2025-04-17 21:58 ` [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops Nicolas Dufresne
@ 2025-04-17 21:58 ` Nicolas Dufresne
2025-04-22 21:20 ` Nicolas Dufresne
3 siblings, 1 reply; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-17 21:58 UTC (permalink / raw)
To: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Nicolas Dufresne, Jonas Karlman, Christopher Obbard
From: Jonas Karlman <jonas@kwiboo.se>
Add support and enable decoding of H264 High 10 and 4:2:2 profiles.
Decoded CAPTURE buffer width is aligned to 64 pixels to accommodate HW
requirement of 10-bit format buffers, fixes decoding of all the 4:2:2
and 10bit 4:2:2 flusters tests except two stream that present some
visual artifacts.
- Hi422FREXT17_SONY_A
- Hi422FREXT19_SONY_A
The get_image_fmt() ops is implemented to select an image format
required for the provided SPS control, and returns RKVDEC_IMG_FMT_ANY
for other controls.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
drivers/staging/media/rkvdec/rkvdec-h264.c | 37 ++++++++++++++++++++++-------
drivers/staging/media/rkvdec/rkvdec.c | 38 +++++++++++++++++++++++-------
drivers/staging/media/rkvdec/rkvdec.h | 3 +++
3 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c
index 8bce8902b8dda39bb2058c8504bd52ccae6b4204..d14b4d173448dbcce4ab978a83806064b100ca24 100644
--- a/drivers/staging/media/rkvdec/rkvdec-h264.c
+++ b/drivers/staging/media/rkvdec/rkvdec-h264.c
@@ -1027,24 +1027,42 @@ static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx,
return 0;
}
+static enum rkvdec_image_fmt rkvdec_h264_get_image_fmt(struct rkvdec_ctx *ctx,
+ struct v4l2_ctrl *ctrl)
+{
+ const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
+
+ if (ctrl->id != V4L2_CID_STATELESS_H264_SPS)
+ return RKVDEC_IMG_FMT_ANY;
+
+ if (sps->bit_depth_luma_minus8 == 0) {
+ if (sps->chroma_format_idc == 2)
+ return RKVDEC_IMG_FMT_422_8BIT;
+ else
+ return RKVDEC_IMG_FMT_420_8BIT;
+ } else if (sps->bit_depth_luma_minus8 == 2) {
+ if (sps->chroma_format_idc == 2)
+ return RKVDEC_IMG_FMT_422_10BIT;
+ else
+ return RKVDEC_IMG_FMT_420_10BIT;
+ }
+
+ return RKVDEC_IMG_FMT_ANY;
+}
+
static int rkvdec_h264_validate_sps(struct rkvdec_ctx *ctx,
const struct v4l2_ctrl_h264_sps *sps)
{
unsigned int width, height;
- /*
- * TODO: The hardware supports 10-bit and 4:2:2 profiles,
- * but it's currently broken in the driver.
- * Reject them for now, until it's fixed.
- */
- if (sps->chroma_format_idc > 1)
- /* Only 4:0:0 and 4:2:0 are supported */
+ if (sps->chroma_format_idc > 2)
+ /* Only 4:0:0, 4:2:0 and 4:2:2 are supported */
return -EINVAL;
if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8)
/* Luma and chroma bit depth mismatch */
return -EINVAL;
- if (sps->bit_depth_luma_minus8 != 0)
- /* Only 8-bit is supported */
+ if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2)
+ /* Only 8-bit and 10-bit is supported */
return -EINVAL;
width = (sps->pic_width_in_mbs_minus1 + 1) * 16;
@@ -1190,4 +1208,5 @@ const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = {
.stop = rkvdec_h264_stop,
.run = rkvdec_h264_run,
.try_ctrl = rkvdec_h264_try_ctrl,
+ .get_image_fmt = rkvdec_h264_get_image_fmt,
};
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index 6c6fe411f48772419e1810d869ab40d168848e65..26f8b8cfcf64f872de73b49b9da9df22ce22d98b 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -186,9 +186,10 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
{
.cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE,
.cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE,
- .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+ .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422_INTRA,
.cfg.menu_skip_mask =
- BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
+ BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED) |
+ BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PREDICTIVE),
.cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,
},
{
@@ -203,11 +204,23 @@ static const struct rkvdec_ctrls rkvdec_h264_ctrls = {
.num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs),
};
-static const struct rkvdec_decoded_fmt_desc rkvdec_h264_vp9_decoded_fmts[] = {
+static const struct rkvdec_decoded_fmt_desc rkvdec_h264_decoded_fmts[] = {
{
.fourcc = V4L2_PIX_FMT_NV12,
.image_fmt = RKVDEC_IMG_FMT_420_8BIT,
},
+ {
+ .fourcc = V4L2_PIX_FMT_NV15,
+ .image_fmt = RKVDEC_IMG_FMT_420_10BIT,
+ },
+ {
+ .fourcc = V4L2_PIX_FMT_NV16,
+ .image_fmt = RKVDEC_IMG_FMT_422_8BIT,
+ },
+ {
+ .fourcc = V4L2_PIX_FMT_NV20,
+ .image_fmt = RKVDEC_IMG_FMT_422_10BIT,
+ },
};
static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = {
@@ -230,21 +243,28 @@ static const struct rkvdec_ctrls rkvdec_vp9_ctrls = {
.num_ctrls = ARRAY_SIZE(rkvdec_vp9_ctrl_descs),
};
+static const struct rkvdec_decoded_fmt_desc rkvdec_vp9_decoded_fmts[] = {
+ {
+ .fourcc = V4L2_PIX_FMT_NV12,
+ .image_fmt = RKVDEC_IMG_FMT_420_8BIT,
+ },
+};
+
static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
{
.fourcc = V4L2_PIX_FMT_H264_SLICE,
.frmsize = {
- .min_width = 48,
+ .min_width = 64,
.max_width = 4096,
- .step_width = 16,
+ .step_width = 64,
.min_height = 48,
.max_height = 2560,
.step_height = 16,
},
.ctrls = &rkvdec_h264_ctrls,
.ops = &rkvdec_h264_fmt_ops,
- .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
- .decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
+ .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts),
+ .decoded_fmts = rkvdec_h264_decoded_fmts,
.subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF,
},
{
@@ -259,8 +279,8 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
},
.ctrls = &rkvdec_vp9_ctrls,
.ops = &rkvdec_vp9_fmt_ops,
- .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
- .decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
+ .num_decoded_fmts = ARRAY_SIZE(rkvdec_vp9_decoded_fmts),
+ .decoded_fmts = rkvdec_vp9_decoded_fmts,
}
};
diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
index e466a2753ccfc13738e0a672bc578e521af2c3f2..9a9f4fced7a184b952d341d75c7faedaa75163d6 100644
--- a/drivers/staging/media/rkvdec/rkvdec.h
+++ b/drivers/staging/media/rkvdec/rkvdec.h
@@ -80,6 +80,9 @@ struct rkvdec_coded_fmt_ops {
enum rkvdec_image_fmt {
RKVDEC_IMG_FMT_ANY = 0,
RKVDEC_IMG_FMT_420_8BIT,
+ RKVDEC_IMG_FMT_420_10BIT,
+ RKVDEC_IMG_FMT_422_8BIT,
+ RKVDEC_IMG_FMT_422_10BIT,
};
struct rkvdec_decoded_fmt_desc {
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops
2025-04-17 21:58 ` [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops Nicolas Dufresne
@ 2025-04-18 6:22 ` Jonas Karlman
2025-04-18 12:28 ` Nicolas Dufresne
0 siblings, 1 reply; 9+ messages in thread
From: Jonas Karlman @ 2025-04-18 6:22 UTC (permalink / raw)
To: Nicolas Dufresne
Cc: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, linux-rockchip, linux-staging, linux-kernel
Hi Nicolas,
On 2025-04-17 23:58, Nicolas Dufresne wrote:
> From: Jonas Karlman <jonas@kwiboo.se>
>
> Add support for a get_image_fmt() ops that returns the required image
> format.
>
> The CAPTURE format is reset when the required image format changes and
> the buffer queue is not busy.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Co-developed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> drivers/staging/media/rkvdec/rkvdec.c | 35 +++++++++++++++++++++++++++++++++++
> drivers/staging/media/rkvdec/rkvdec.h | 2 ++
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
> index 7b780392bb6a63cc954655ef940e87146d2b852f..6c6fe411f48772419e1810d869ab40d168848e65 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.c
> +++ b/drivers/staging/media/rkvdec/rkvdec.c
> @@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc,
> return false;
> }
>
> +static bool rkvdec_fmt_changed(struct rkvdec_ctx *ctx,
> + enum rkvdec_image_fmt image_fmt)
Just a small nitpick:
Maybe this function should be called rkvdec_image_fmt_changed() and
could be moved closer to rkvdec_image_fmt_match() as those two are
related to image_fmt and not the pixfmt/fourcc.
Regards,
Jonas
> +{
> + if (image_fmt == RKVDEC_IMG_FMT_ANY)
> + return false;
> +
> + return ctx->image_fmt != image_fmt;
> +}
> +
> static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
> struct v4l2_pix_format_mplane *pix_mp)
> {
> @@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
> return 0;
> }
>
> +static int rkvdec_s_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
> + const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
> + enum rkvdec_image_fmt image_fmt;
> + struct vb2_queue *vq;
> +
> + /* Check if this change requires a capture format reset */
> + if (!desc->ops->get_image_fmt)
> + return 0;
> +
> + image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
> + if (rkvdec_fmt_changed(ctx, image_fmt)) {
> + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
> + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
> + if (vb2_is_busy(vq))
> + return -EBUSY;
> +
> + ctx->image_fmt = image_fmt;
> + rkvdec_reset_decoded_fmt(ctx);
> + }
> +
> + return 0;
> +}
> +
> static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
> .try_ctrl = rkvdec_try_ctrl,
> + .s_ctrl = rkvdec_s_ctrl,
> };
>
> static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
> diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
> index 6f8cf50c5d99aad2f52e321f54f3ca17166ddf98..e466a2753ccfc13738e0a672bc578e521af2c3f2 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.h
> +++ b/drivers/staging/media/rkvdec/rkvdec.h
> @@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
> struct vb2_v4l2_buffer *dst_buf,
> enum vb2_buffer_state result);
> int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
> + enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx,
> + struct v4l2_ctrl *ctrl);
> };
>
> enum rkvdec_image_fmt {
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops
2025-04-18 6:22 ` Jonas Karlman
@ 2025-04-18 12:28 ` Nicolas Dufresne
2025-04-18 15:11 ` Jonas Karlman
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-18 12:28 UTC (permalink / raw)
To: Jonas Karlman
Cc: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, linux-rockchip, linux-staging, linux-kernel
Le vendredi 18 avril 2025 à 08:22 +0200, Jonas Karlman a écrit :
> Hi Nicolas,
>
> On 2025-04-17 23:58, Nicolas Dufresne wrote:
> > From: Jonas Karlman <jonas@kwiboo.se>
> >
> > Add support for a get_image_fmt() ops that returns the required image
> > format.
> >
> > The CAPTURE format is reset when the required image format changes and
> > the buffer queue is not busy.
> >
> > Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> > Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > Co-developed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > ---
> > drivers/staging/media/rkvdec/rkvdec.c | 35 +++++++++++++++++++++++++++++++++++
> > drivers/staging/media/rkvdec/rkvdec.h | 2 ++
> > 2 files changed, 37 insertions(+)
> >
> > diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
> > index 7b780392bb6a63cc954655ef940e87146d2b852f..6c6fe411f48772419e1810d869ab40d168848e65 100644
> > --- a/drivers/staging/media/rkvdec/rkvdec.c
> > +++ b/drivers/staging/media/rkvdec/rkvdec.c
> > @@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc,
> > return false;
> > }
> >
> > +static bool rkvdec_fmt_changed(struct rkvdec_ctx *ctx,
> > + enum rkvdec_image_fmt image_fmt)
>
> Just a small nitpick:
>
> Maybe this function should be called rkvdec_image_fmt_changed() and
> could be moved closer to rkvdec_image_fmt_match() as those two are
> related to image_fmt and not the pixfmt/fourcc.
Applied locally. With this change, may I have your Rb ?
thanks,
Nicolas
>
> Regards,
> Jonas
>
> > +{
> > + if (image_fmt == RKVDEC_IMG_FMT_ANY)
> > + return false;
> > +
> > + return ctx->image_fmt != image_fmt;
> > +}
> > +
> > static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
> > struct v4l2_pix_format_mplane *pix_mp)
> > {
> > @@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
> > return 0;
> > }
> >
> > +static int rkvdec_s_ctrl(struct v4l2_ctrl *ctrl)
> > +{
> > + struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
> > + const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
> > + enum rkvdec_image_fmt image_fmt;
> > + struct vb2_queue *vq;
> > +
> > + /* Check if this change requires a capture format reset */
> > + if (!desc->ops->get_image_fmt)
> > + return 0;
> > +
> > + image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
> > + if (rkvdec_fmt_changed(ctx, image_fmt)) {
> > + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
> > + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
> > + if (vb2_is_busy(vq))
> > + return -EBUSY;
> > +
> > + ctx->image_fmt = image_fmt;
> > + rkvdec_reset_decoded_fmt(ctx);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
> > .try_ctrl = rkvdec_try_ctrl,
> > + .s_ctrl = rkvdec_s_ctrl,
> > };
> >
> > static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
> > diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
> > index 6f8cf50c5d99aad2f52e321f54f3ca17166ddf98..e466a2753ccfc13738e0a672bc578e521af2c3f2 100644
> > --- a/drivers/staging/media/rkvdec/rkvdec.h
> > +++ b/drivers/staging/media/rkvdec/rkvdec.h
> > @@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
> > struct vb2_v4l2_buffer *dst_buf,
> > enum vb2_buffer_state result);
> > int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
> > + enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx,
> > + struct v4l2_ctrl *ctrl);
> > };
> >
> > enum rkvdec_image_fmt {
> >
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops
2025-04-18 12:28 ` Nicolas Dufresne
@ 2025-04-18 15:11 ` Jonas Karlman
0 siblings, 0 replies; 9+ messages in thread
From: Jonas Karlman @ 2025-04-18 15:11 UTC (permalink / raw)
To: Nicolas Dufresne
Cc: Ezequiel Garcia, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, linux-rockchip, linux-staging, linux-kernel
Hi Nicolas,
On 2025-04-18 14:28, Nicolas Dufresne wrote:
> Le vendredi 18 avril 2025 à 08:22 +0200, Jonas Karlman a écrit :
>> Hi Nicolas,
>>
>> On 2025-04-17 23:58, Nicolas Dufresne wrote:
>>> From: Jonas Karlman <jonas@kwiboo.se>
>>>
>>> Add support for a get_image_fmt() ops that returns the required image
>>> format.
>>>
>>> The CAPTURE format is reset when the required image format changes and
>>> the buffer queue is not busy.
>>>
>>> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
>>> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
>>> Co-developed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
>>> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
>>> ---
>>> drivers/staging/media/rkvdec/rkvdec.c | 35 +++++++++++++++++++++++++++++++++++
>>> drivers/staging/media/rkvdec/rkvdec.h | 2 ++
>>> 2 files changed, 37 insertions(+)
>>>
>>> diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
>>> index 7b780392bb6a63cc954655ef940e87146d2b852f..6c6fe411f48772419e1810d869ab40d168848e65 100644
>>> --- a/drivers/staging/media/rkvdec/rkvdec.c
>>> +++ b/drivers/staging/media/rkvdec/rkvdec.c
>>> @@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc,
>>> return false;
>>> }
>>>
>>> +static bool rkvdec_fmt_changed(struct rkvdec_ctx *ctx,
>>> + enum rkvdec_image_fmt image_fmt)
>>
>> Just a small nitpick:
>>
>> Maybe this function should be called rkvdec_image_fmt_changed() and
>> could be moved closer to rkvdec_image_fmt_match() as those two are
>> related to image_fmt and not the pixfmt/fourcc.
>
> Applied locally. With this change, may I have your Rb ?
Sure, and thanks for helping getting this old series to land :-)
Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Regards,
Jonas
>
> thanks,
> Nicolas
>
>>
>> Regards,
>> Jonas
>>
>>> +{
>>> + if (image_fmt == RKVDEC_IMG_FMT_ANY)
>>> + return false;
>>> +
>>> + return ctx->image_fmt != image_fmt;
>>> +}
>>> +
>>> static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
>>> struct v4l2_pix_format_mplane *pix_mp)
>>> {
>>> @@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
>>> return 0;
>>> }
>>>
>>> +static int rkvdec_s_ctrl(struct v4l2_ctrl *ctrl)
>>> +{
>>> + struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
>>> + const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
>>> + enum rkvdec_image_fmt image_fmt;
>>> + struct vb2_queue *vq;
>>> +
>>> + /* Check if this change requires a capture format reset */
>>> + if (!desc->ops->get_image_fmt)
>>> + return 0;
>>> +
>>> + image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
>>> + if (rkvdec_fmt_changed(ctx, image_fmt)) {
>>> + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
>>> + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
>>> + if (vb2_is_busy(vq))
>>> + return -EBUSY;
>>> +
>>> + ctx->image_fmt = image_fmt;
>>> + rkvdec_reset_decoded_fmt(ctx);
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
>>> static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
>>> .try_ctrl = rkvdec_try_ctrl,
>>> + .s_ctrl = rkvdec_s_ctrl,
>>> };
>>>
>>> static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
>>> diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
>>> index 6f8cf50c5d99aad2f52e321f54f3ca17166ddf98..e466a2753ccfc13738e0a672bc578e521af2c3f2 100644
>>> --- a/drivers/staging/media/rkvdec/rkvdec.h
>>> +++ b/drivers/staging/media/rkvdec/rkvdec.h
>>> @@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
>>> struct vb2_v4l2_buffer *dst_buf,
>>> enum vb2_buffer_state result);
>>> int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
>>> + enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx,
>>> + struct v4l2_ctrl *ctrl);
>>> };
>>>
>>> enum rkvdec_image_fmt {
>>>
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles
2025-04-17 21:58 ` [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Nicolas Dufresne
@ 2025-04-22 21:20 ` Nicolas Dufresne
0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Dufresne @ 2025-04-22 21:20 UTC (permalink / raw)
To: Hans Verkuil
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Jonas Karlman, Christopher Obbard, Ezequiel Garcia,
Mauro Carvalho Chehab, Greg Kroah-Hartman
Hi Hans,
since you raised concern on this one when I tried to pull, looking
forward your Ack or Rb.
regards,
Nicolas
Le jeudi 17 avril 2025 à 17:58 -0400, Nicolas Dufresne a écrit :
> From: Jonas Karlman <jonas@kwiboo.se>
>
> Add support and enable decoding of H264 High 10 and 4:2:2 profiles.
>
> Decoded CAPTURE buffer width is aligned to 64 pixels to accommodate
> HW
> requirement of 10-bit format buffers, fixes decoding of all the 4:2:2
> and 10bit 4:2:2 flusters tests except two stream that present some
> visual artifacts.
>
> - Hi422FREXT17_SONY_A
> - Hi422FREXT19_SONY_A
>
> The get_image_fmt() ops is implemented to select an image format
> required for the provided SPS control, and returns RKVDEC_IMG_FMT_ANY
> for other controls.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Christopher Obbard <chris.obbard@collabora.com>
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> ---
> drivers/staging/media/rkvdec/rkvdec-h264.c | 37
> ++++++++++++++++++++++-------
> drivers/staging/media/rkvdec/rkvdec.c | 38
> +++++++++++++++++++++++-------
> drivers/staging/media/rkvdec/rkvdec.h | 3 +++
> 3 files changed, 60 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c
> b/drivers/staging/media/rkvdec/rkvdec-h264.c
> index
> 8bce8902b8dda39bb2058c8504bd52ccae6b4204..d14b4d173448dbcce4ab978a838
> 06064b100ca24 100644
> --- a/drivers/staging/media/rkvdec/rkvdec-h264.c
> +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c
> @@ -1027,24 +1027,42 @@ static int rkvdec_h264_adjust_fmt(struct
> rkvdec_ctx *ctx,
> return 0;
> }
>
> +static enum rkvdec_image_fmt rkvdec_h264_get_image_fmt(struct
> rkvdec_ctx *ctx,
> + struct
> v4l2_ctrl *ctrl)
> +{
> + const struct v4l2_ctrl_h264_sps *sps = ctrl-
> >p_new.p_h264_sps;
> +
> + if (ctrl->id != V4L2_CID_STATELESS_H264_SPS)
> + return RKVDEC_IMG_FMT_ANY;
> +
> + if (sps->bit_depth_luma_minus8 == 0) {
> + if (sps->chroma_format_idc == 2)
> + return RKVDEC_IMG_FMT_422_8BIT;
> + else
> + return RKVDEC_IMG_FMT_420_8BIT;
> + } else if (sps->bit_depth_luma_minus8 == 2) {
> + if (sps->chroma_format_idc == 2)
> + return RKVDEC_IMG_FMT_422_10BIT;
> + else
> + return RKVDEC_IMG_FMT_420_10BIT;
> + }
> +
> + return RKVDEC_IMG_FMT_ANY;
> +}
> +
> static int rkvdec_h264_validate_sps(struct rkvdec_ctx *ctx,
> const struct v4l2_ctrl_h264_sps
> *sps)
> {
> unsigned int width, height;
>
> - /*
> - * TODO: The hardware supports 10-bit and 4:2:2 profiles,
> - * but it's currently broken in the driver.
> - * Reject them for now, until it's fixed.
> - */
> - if (sps->chroma_format_idc > 1)
> - /* Only 4:0:0 and 4:2:0 are supported */
> + if (sps->chroma_format_idc > 2)
> + /* Only 4:0:0, 4:2:0 and 4:2:2 are supported */
> return -EINVAL;
> if (sps->bit_depth_luma_minus8 != sps-
> >bit_depth_chroma_minus8)
> /* Luma and chroma bit depth mismatch */
> return -EINVAL;
> - if (sps->bit_depth_luma_minus8 != 0)
> - /* Only 8-bit is supported */
> + if (sps->bit_depth_luma_minus8 != 0 && sps-
> >bit_depth_luma_minus8 != 2)
> + /* Only 8-bit and 10-bit is supported */
> return -EINVAL;
>
> width = (sps->pic_width_in_mbs_minus1 + 1) * 16;
> @@ -1190,4 +1208,5 @@ const struct rkvdec_coded_fmt_ops
> rkvdec_h264_fmt_ops = {
> .stop = rkvdec_h264_stop,
> .run = rkvdec_h264_run,
> .try_ctrl = rkvdec_h264_try_ctrl,
> + .get_image_fmt = rkvdec_h264_get_image_fmt,
> };
> diff --git a/drivers/staging/media/rkvdec/rkvdec.c
> b/drivers/staging/media/rkvdec/rkvdec.c
> index
> 6c6fe411f48772419e1810d869ab40d168848e65..26f8b8cfcf64f872de73b49b9da
> 9df22ce22d98b 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.c
> +++ b/drivers/staging/media/rkvdec/rkvdec.c
> @@ -186,9 +186,10 @@ static const struct rkvdec_ctrl_desc
> rkvdec_h264_ctrl_descs[] = {
> {
> .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE,
> .cfg.min =
> V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE,
> - .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
> + .cfg.max =
> V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422_INTRA,
> .cfg.menu_skip_mask =
> - BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
> + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED) |
> + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PR
> EDICTIVE),
> .cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN,
> },
> {
> @@ -203,11 +204,23 @@ static const struct rkvdec_ctrls
> rkvdec_h264_ctrls = {
> .num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs),
> };
>
> -static const struct rkvdec_decoded_fmt_desc
> rkvdec_h264_vp9_decoded_fmts[] = {
> +static const struct rkvdec_decoded_fmt_desc
> rkvdec_h264_decoded_fmts[] = {
> {
> .fourcc = V4L2_PIX_FMT_NV12,
> .image_fmt = RKVDEC_IMG_FMT_420_8BIT,
> },
> + {
> + .fourcc = V4L2_PIX_FMT_NV15,
> + .image_fmt = RKVDEC_IMG_FMT_420_10BIT,
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_NV16,
> + .image_fmt = RKVDEC_IMG_FMT_422_8BIT,
> + },
> + {
> + .fourcc = V4L2_PIX_FMT_NV20,
> + .image_fmt = RKVDEC_IMG_FMT_422_10BIT,
> + },
> };
>
> static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = {
> @@ -230,21 +243,28 @@ static const struct rkvdec_ctrls
> rkvdec_vp9_ctrls = {
> .num_ctrls = ARRAY_SIZE(rkvdec_vp9_ctrl_descs),
> };
>
> +static const struct rkvdec_decoded_fmt_desc
> rkvdec_vp9_decoded_fmts[] = {
> + {
> + .fourcc = V4L2_PIX_FMT_NV12,
> + .image_fmt = RKVDEC_IMG_FMT_420_8BIT,
> + },
> +};
> +
> static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
> {
> .fourcc = V4L2_PIX_FMT_H264_SLICE,
> .frmsize = {
> - .min_width = 48,
> + .min_width = 64,
> .max_width = 4096,
> - .step_width = 16,
> + .step_width = 64,
> .min_height = 48,
> .max_height = 2560,
> .step_height = 16,
> },
> .ctrls = &rkvdec_h264_ctrls,
> .ops = &rkvdec_h264_fmt_ops,
> - .num_decoded_fmts =
> ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
> - .decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
> + .num_decoded_fmts =
> ARRAY_SIZE(rkvdec_h264_decoded_fmts),
> + .decoded_fmts = rkvdec_h264_decoded_fmts,
> .subsystem_flags =
> VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF,
> },
> {
> @@ -259,8 +279,8 @@ static const struct rkvdec_coded_fmt_desc
> rkvdec_coded_fmts[] = {
> },
> .ctrls = &rkvdec_vp9_ctrls,
> .ops = &rkvdec_vp9_fmt_ops,
> - .num_decoded_fmts =
> ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts),
> - .decoded_fmts = rkvdec_h264_vp9_decoded_fmts,
> + .num_decoded_fmts =
> ARRAY_SIZE(rkvdec_vp9_decoded_fmts),
> + .decoded_fmts = rkvdec_vp9_decoded_fmts,
> }
> };
>
> diff --git a/drivers/staging/media/rkvdec/rkvdec.h
> b/drivers/staging/media/rkvdec/rkvdec.h
> index
> e466a2753ccfc13738e0a672bc578e521af2c3f2..9a9f4fced7a184b952d341d75c7
> faedaa75163d6 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.h
> +++ b/drivers/staging/media/rkvdec/rkvdec.h
> @@ -80,6 +80,9 @@ struct rkvdec_coded_fmt_ops {
> enum rkvdec_image_fmt {
> RKVDEC_IMG_FMT_ANY = 0,
> RKVDEC_IMG_FMT_420_8BIT,
> + RKVDEC_IMG_FMT_420_10BIT,
> + RKVDEC_IMG_FMT_422_8BIT,
> + RKVDEC_IMG_FMT_422_10BIT,
> };
>
> struct rkvdec_decoded_fmt_desc {
--
Nicolas Dufresne
Principal Engineer at Collabora
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-04-22 21:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 21:57 [PATCH v9 0/4] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 1/4] media: rkvdec: h264: Limit minimum profile to constrained baseline Nicolas Dufresne
2025-04-17 21:57 ` [PATCH v9 2/4] media: rkvdec: Initialize the m2m context before the controls Nicolas Dufresne
2025-04-17 21:58 ` [PATCH v9 3/4] media: rkvdec: Add get_image_fmt ops Nicolas Dufresne
2025-04-18 6:22 ` Jonas Karlman
2025-04-18 12:28 ` Nicolas Dufresne
2025-04-18 15:11 ` Jonas Karlman
2025-04-17 21:58 ` [PATCH v9 4/4] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Nicolas Dufresne
2025-04-22 21:20 ` Nicolas Dufresne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox