* [PATCH v3 1/5] media: verisilicon: Size the VP8 segment map for the largest frame
2026-11-30 21:53 [PATCH v3 0/5] media: verisilicon: Keep the CAPTURE format in line with the decoder Arun Iyengar via B4 Relay
@ 2026-11-30 21:53 ` Arun Iyengar via B4 Relay
2026-11-30 22:39 ` Nicolas Dufresne
2026-11-30 21:53 ` [PATCH v3 2/5] media: verisilicon: Set need_postproc before resetting the CAPTURE format Arun Iyengar via B4 Relay
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 21:53 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
The segment map is sized at STREAMON, but the CAPTURE format can grow
while streaming and overrun it. Size it for the largest frame, as VP9
does.
Fixes: bbd267daf4fc ("media: verisilicon: vp9: Allow to change resolution while streaming")
Cc: stable@vger.kernel.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_vp8.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_vp8.c b/drivers/media/platform/verisilicon/hantro_vp8.c
index 65648c017e76..19a89722bf05 100644
--- a/drivers/media/platform/verisilicon/hantro_vp8.c
+++ b/drivers/media/platform/verisilicon/hantro_vp8.c
@@ -150,8 +150,8 @@ int hantro_vp8_dec_init(struct hantro_ctx *ctx)
int ret;
/* segment map table size calculation */
- mb_width = DIV_ROUND_UP(ctx->dst_fmt.width, 16);
- mb_height = DIV_ROUND_UP(ctx->dst_fmt.height, 16);
+ mb_width = DIV_ROUND_UP(ctx->vpu_src_fmt->frmsize.max_width, 16);
+ mb_height = DIV_ROUND_UP(ctx->vpu_src_fmt->frmsize.max_height, 16);
segment_map_size = round_up(DIV_ROUND_UP(mb_width * mb_height, 4), 64);
/*
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 1/5] media: verisilicon: Size the VP8 segment map for the largest frame
2026-11-30 21:53 ` [PATCH v3 1/5] media: verisilicon: Size the VP8 segment map for the largest frame Arun Iyengar via B4 Relay
@ 2026-11-30 22:39 ` Nicolas Dufresne
0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Dufresne @ 2026-11-30 22:39 UTC (permalink / raw)
To: aiyengar1990, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable
[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]
Le lundi 30 novembre 2026 à 21:53 +0000, Arun Iyengar via B4 Relay a écrit :
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> The segment map is sized at STREAMON, but the CAPTURE format can grow
> while streaming and overrun it. Size it for the largest frame, as VP9
> does.
Its shouldn't really grow while streaming, I wonder if some VP9 feature didn't
leak into VP8 and if we shouldn't simply protect VP8 against that, instead of
supported something that will break anyway, and just use more memory for no good
reason.
Nicolas
>
> Fixes: bbd267daf4fc ("media: verisilicon: vp9: Allow to change resolution while streaming")
> Cc: stable@vger.kernel.org
> Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> ---
> drivers/media/platform/verisilicon/hantro_vp8.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_vp8.c b/drivers/media/platform/verisilicon/hantro_vp8.c
> index 65648c017e76..19a89722bf05 100644
> --- a/drivers/media/platform/verisilicon/hantro_vp8.c
> +++ b/drivers/media/platform/verisilicon/hantro_vp8.c
> @@ -150,8 +150,8 @@ int hantro_vp8_dec_init(struct hantro_ctx *ctx)
> int ret;
>
> /* segment map table size calculation */
> - mb_width = DIV_ROUND_UP(ctx->dst_fmt.width, 16);
> - mb_height = DIV_ROUND_UP(ctx->dst_fmt.height, 16);
> + mb_width = DIV_ROUND_UP(ctx->vpu_src_fmt->frmsize.max_width, 16);
> + mb_height = DIV_ROUND_UP(ctx->vpu_src_fmt->frmsize.max_height, 16);
> segment_map_size = round_up(DIV_ROUND_UP(mb_width * mb_height, 4), 64);
>
> /*
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] media: verisilicon: Set need_postproc before resetting the CAPTURE format
2026-11-30 21:53 [PATCH v3 0/5] media: verisilicon: Keep the CAPTURE format in line with the decoder Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 1/5] media: verisilicon: Size the VP8 segment map for the largest frame Arun Iyengar via B4 Relay
@ 2026-11-30 21:53 ` Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 3/5] media: verisilicon: Size reference frames by the stream bit depth Arun Iyengar via B4 Relay
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 21:53 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
hantro_reset_raw_fmt() sets bit_depth and need_postproc only after
hantro_set_fmt_cap(), so hantro_try_fmt() sizes the format with the old
values: after AV1 film grain is turned off, the CAPTURE buffers lack the
motion vector area. Set them first and restore them on error.
Fixes: 80c7373a456e ("media: verisilicon: Conditionally ignore native formats")
Cc: stable@vger.kernel.org
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_v4l2.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 8d9545423c65..bf5f608bdbe8 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -449,6 +449,8 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth, bool need_postproc)
{
const struct hantro_fmt *raw_vpu_fmt;
struct v4l2_pix_format_mplane raw_fmt, *encoded_fmt;
+ bool old_need_postproc = ctx->need_postproc;
+ int old_bit_depth = ctx->bit_depth;
int ret;
raw_vpu_fmt = hantro_get_default_fmt(ctx, false, bit_depth, need_postproc);
@@ -465,14 +467,17 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth, bool need_postproc)
hantro_reset_fmt(&raw_fmt, raw_vpu_fmt);
raw_fmt.width = encoded_fmt->width;
raw_fmt.height = encoded_fmt->height;
+
+ ctx->bit_depth = bit_depth;
+ ctx->need_postproc = need_postproc;
if (ctx->is_encoder)
ret = hantro_set_fmt_out(ctx, &raw_fmt, need_postproc);
else
ret = hantro_set_fmt_cap(ctx, &raw_fmt);
- if (!ret) {
- ctx->bit_depth = bit_depth;
- ctx->need_postproc = need_postproc;
+ if (ret) {
+ ctx->bit_depth = old_bit_depth;
+ ctx->need_postproc = old_need_postproc;
}
return ret;
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v3 3/5] media: verisilicon: Size reference frames by the stream bit depth
2026-11-30 21:53 [PATCH v3 0/5] media: verisilicon: Keep the CAPTURE format in line with the decoder Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 1/5] media: verisilicon: Size the VP8 segment map for the largest frame Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 2/5] media: verisilicon: Set need_postproc before resetting the CAPTURE format Arun Iyengar via B4 Relay
@ 2026-11-30 21:53 ` Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 4/5] media: verisilicon: Keep the CAPTURE format at the stream's " Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 5/5] media: verisilicon: Set the bit depth again when its control is rewritten Arun Iyengar via B4 Relay
4 siblings, 0 replies; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 21:53 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
The reference format takes its depth from the CAPTURE format. With an
8-bit post-processed CAPTURE format (NV12) on a 10-bit stream, the
reference buffers are sized for 8 bits and the decoder overruns them.
Use ctx->bit_depth instead.
Fixes: db300ab0e9d3 ("media: verisilicon: Store reference frames pixels format")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_v4l2.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index bf5f608bdbe8..315954e090f9 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -131,9 +131,8 @@ static int
hantro_set_reference_frames_format(struct hantro_ctx *ctx)
{
const struct hantro_fmt *fmt;
- int dst_bit_depth = hantro_get_format_depth(ctx->vpu_dst_fmt->fourcc);
- fmt = hantro_get_default_fmt(ctx, false, dst_bit_depth, HANTRO_AUTO_POSTPROC);
+ fmt = hantro_get_default_fmt(ctx, false, ctx->bit_depth, HANTRO_AUTO_POSTPROC);
if (!fmt)
return -EINVAL;
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v3 4/5] media: verisilicon: Keep the CAPTURE format at the stream's bit depth
2026-11-30 21:53 [PATCH v3 0/5] media: verisilicon: Keep the CAPTURE format in line with the decoder Arun Iyengar via B4 Relay
` (2 preceding siblings ...)
2026-11-30 21:53 ` [PATCH v3 3/5] media: verisilicon: Size reference frames by the stream bit depth Arun Iyengar via B4 Relay
@ 2026-11-30 21:53 ` Arun Iyengar via B4 Relay
2026-11-30 21:53 ` [PATCH v3 5/5] media: verisilicon: Set the bit depth again when its control is rewritten Arun Iyengar via B4 Relay
4 siblings, 0 replies; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 21:53 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
S_FMT and TRY_FMT on the decoder CAPTURE queue accept formats ENUM_FMT
hides: an 8-bit format for a 10-bit stream, which the decoder overruns,
or a native format while the post-processor is needed. Replace such a
format with the stream's default one.
Fixes: 8d03c2ab881b ("media: hantro: Support format filtering by depth")
Fixes: 80c7373a456e ("media: verisilicon: Conditionally ignore native formats")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_v4l2.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 315954e090f9..d7385bcf47f2 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -341,6 +341,15 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
pix_mp->pixelformat = fmt->fourcc;
}
+ if (!coded && !ctx->is_encoder &&
+ (!hantro_check_depth_match(fmt, ctx->bit_depth) ||
+ (ctx->need_postproc && !fmt->postprocessed))) {
+ fmt = hantro_get_default_fmt(ctx, false, ctx->bit_depth, ctx->need_postproc);
+ if (!fmt)
+ return -EINVAL;
+ pix_mp->pixelformat = fmt->fourcc;
+ }
+
if (coded) {
pix_mp->num_planes = 1;
vpu_fmt = fmt;
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v3 5/5] media: verisilicon: Set the bit depth again when its control is rewritten
2026-11-30 21:53 [PATCH v3 0/5] media: verisilicon: Keep the CAPTURE format in line with the decoder Arun Iyengar via B4 Relay
` (3 preceding siblings ...)
2026-11-30 21:53 ` [PATCH v3 4/5] media: verisilicon: Keep the CAPTURE format at the stream's " Arun Iyengar via B4 Relay
@ 2026-11-30 21:53 ` Arun Iyengar via B4 Relay
4 siblings, 0 replies; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 21:53 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Andrzej Pietrasiewicz, Hans Verkuil,
Jernej Skrabec, Ezequiel Garcia
Cc: linux-media, linux-rockchip, linux-kernel, stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
S_FMT on OUTPUT resets the CAPTURE format to 8 bits, but rewriting an
unchanged 10-bit HEVC SPS, VP9 frame or AV1 sequence control skips
s_ctrl, so the format stays 8-bit. Mark these controls EXECUTE_ON_WRITE;
every write of them then also sends a V4L2_EVENT_CTRL value change.
Fixes: 3c32d94c9c52 ("media: verisilicon: Do not change context bit depth before validating the format")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_drv.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 5c962847fdf5..aaafe13585a5 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -564,6 +564,7 @@ static const struct hantro_ctrl controls[] = {
.cfg = {
.id = V4L2_CID_STATELESS_HEVC_SPS,
.ops = &hantro_hevc_ctrl_ops,
+ .flags = V4L2_CTRL_FLAG_EXECUTE_ON_WRITE,
},
}, {
.codec = HANTRO_HEVC_DECODER,
@@ -585,6 +586,7 @@ static const struct hantro_ctrl controls[] = {
.cfg = {
.id = V4L2_CID_STATELESS_VP9_FRAME,
.ops = &hantro_vp9_ctrl_ops,
+ .flags = V4L2_CTRL_FLAG_EXECUTE_ON_WRITE,
},
}, {
.codec = HANTRO_VP9_DECODER,
@@ -607,6 +609,7 @@ static const struct hantro_ctrl controls[] = {
.cfg = {
.id = V4L2_CID_STATELESS_AV1_SEQUENCE,
.ops = &hantro_av1_ctrl_ops,
+ .flags = V4L2_CTRL_FLAG_EXECUTE_ON_WRITE,
},
}, {
.codec = HANTRO_AV1_DECODER,
@@ -621,6 +624,7 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
int allowed_codecs)
{
int i, num_ctrls = ARRAY_SIZE(controls);
+ struct v4l2_ctrl *ctrl;
v4l2_ctrl_handler_init(&ctx->ctrl_handler, num_ctrls);
@@ -628,8 +632,8 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
if (!(allowed_codecs & controls[i].codec))
continue;
- v4l2_ctrl_new_custom(&ctx->ctrl_handler,
- &controls[i].cfg, NULL);
+ ctrl = v4l2_ctrl_new_custom(&ctx->ctrl_handler,
+ &controls[i].cfg, NULL);
if (ctx->ctrl_handler.error) {
vpu_err("Adding control (%d) failed %d\n",
controls[i].cfg.id,
@@ -637,6 +641,9 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
return ctx->ctrl_handler.error;
}
+
+ /* v4l2_ctrl_new_custom() drops cfg.flags of standard controls. */
+ ctrl->flags |= controls[i].cfg.flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
}
return v4l2_ctrl_handler_setup(&ctx->ctrl_handler);
}
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread