[PATCH 2/4] media: verisilicon: Set need_postproc before resetting the CAPTURE format
From: Arun Iyengar via B4 Relay
Date: Fri Nov 13 2026 - 19:15:03 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
hantro_reset_raw_fmt() stores need_postproc only after
hantro_set_fmt_cap(), so hantro_try_fmt() sizes the new format with the
old value. When an AV1 stream drops film grain, the post-processor goes
away but the CAPTURE format still lacks the motion vector area the
decoder then writes after the picture.
Set the bit depth and need_postproc first and restore them on error.
The next patch needs the bit depth set there too.
Found by Sashiko in its review of hantro-dec-size-check v1.
Fixes: 80c7373a456e ("media: verisilicon: Conditionally ignore native formats")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/platform/verisilicon/hantro_v4l2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 83af9fa1ce94..2baab4cf3bbf 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,18 @@ 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;
+
+ /* hantro_try_fmt() uses these. */
+ 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