From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Benjamin Gaignard <benjamin.gaignard@collabora.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Hans Verkuil <hverkuil@kernel.org>
Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org,
Arun Iyengar <aiyengar1990@gmail.com>
Subject: [PATCH 1/2] media: verisilicon: Match the VPU981 line stride
Date: Fri, 04 Dec 2026 07:12:31 +0000 [thread overview]
Message-ID: <20261204-av1-ref-stride-v1-1-5d86fb6d6858@gmail.com> (raw)
In-Reply-To: <20261204-av1-ref-stride-v1-0-5d86fb6d6858@gmail.com>
From: Arun Iyengar <aiyengar1990@gmail.com>
The VPU981 writes its 4x4 tile rows with a line stride of
ALIGN(ALIGN(width, 8) * depth, 128) / 8 bytes. The driver took the
stride from the width rounded up to 16 pixels, without alignment:
- 10-bit widths that are not a multiple of 64 got a shorter stride, so
the luma overran the chroma and the chroma the motion vectors.
av1-1-b10-23-film_grain-50 (352x288) decodes wrong from its second
frame.
- 10-bit widths that are not a multiple of 16 can get a longer one:
NV15_4L4 at 328x288 has bytesperline 420, the decoder uses 416.
Align the 4L4 strides to 16 bytes and round the AV1 and 4L4 widths up to
8 pixels. The post-processed formats keep their 16 pixel step, so check
the frame size against the reference format, which can now be narrower.
Fixes: 003afda97c65 ("media: verisilicon: Enable AV1 decoder on rk3588")
Cc: stable@vger.kernel.org # 7.2+
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
For stable: hantro_av1.c and its size check are not in 7.4 or older;
drop that hunk there.
---
drivers/media/platform/verisilicon/hantro.h | 2 ++
drivers/media/platform/verisilicon/hantro_av1.c | 8 ++++----
drivers/media/platform/verisilicon/hantro_v4l2.c | 10 ++++++----
drivers/media/platform/verisilicon/rockchip_vpu_hw.c | 8 +++++---
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 1efa032506e1..8597a8611d8d 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -285,6 +285,7 @@ struct hantro_ctx {
* @frmsize: Supported range of frame sizes (only for bitstream formats).
* @postprocessed: Indicates if this format needs the post-processor.
* @match_depth: Indicates if format bit depth must match video bit depth
+ * @stride_align: Byte alignment of the line stride written by the decoder
*/
struct hantro_fmt {
char *name;
@@ -296,6 +297,7 @@ struct hantro_fmt {
struct v4l2_frmsize_stepwise frmsize;
bool postprocessed;
bool match_depth;
+ u8 stride_align;
};
struct hantro_reg {
diff --git a/drivers/media/platform/verisilicon/hantro_av1.c b/drivers/media/platform/verisilicon/hantro_av1.c
index 2e79de145f48..d83a182f8a28 100644
--- a/drivers/media/platform/verisilicon/hantro_av1.c
+++ b/drivers/media/platform/verisilicon/hantro_av1.c
@@ -413,13 +413,13 @@ int hantro_av1_prepare_run(struct hantro_ctx *ctx)
/*
* The frame size comes from userspace. The decoder writes a frame of
* that size, upscaled to upscaled_width, into buffers that are made
- * for the CAPTURE format, so the frame has to fit in that format. As
+ * for the reference format, so the frame has to fit in that format. As
* the format is within the limits of the decoder, this also keeps the
* frame height in the range the tile column buffers can be sized for.
*/
- if (ctrls->frame->frame_width_minus_1 >= ctx->dst_fmt.width ||
- ctrls->frame->frame_height_minus_1 >= ctx->dst_fmt.height ||
- ctrls->frame->upscaled_width > ctx->dst_fmt.width)
+ if (ctrls->frame->frame_width_minus_1 >= ctx->ref_fmt.width ||
+ ctrls->frame->frame_height_minus_1 >= ctx->ref_fmt.height ||
+ ctrls->frame->upscaled_width > ctx->ref_fmt.width)
return -EINVAL;
ctrls->film_grain =
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 8d9545423c65..d6e5834e39ab 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -141,8 +141,9 @@ hantro_set_reference_frames_format(struct hantro_ctx *ctx)
ctx->ref_fmt.height = ctx->src_fmt.height;
v4l2_apply_frmsize_constraints(&ctx->ref_fmt.width, &ctx->ref_fmt.height, &fmt->frmsize);
- return v4l2_fill_pixfmt_mp(&ctx->ref_fmt, fmt->fourcc,
- ctx->ref_fmt.width, ctx->ref_fmt.height);
+ return v4l2_fill_pixfmt_mp_aligned(&ctx->ref_fmt, fmt->fourcc,
+ ctx->ref_fmt.width, ctx->ref_fmt.height,
+ fmt->stride_align ?: 1);
}
const struct hantro_fmt *
@@ -364,8 +365,9 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
if (!coded) {
/* Fill remaining fields */
- v4l2_fill_pixfmt_mp(pix_mp, fmt->fourcc, pix_mp->width,
- pix_mp->height);
+ v4l2_fill_pixfmt_mp_aligned(pix_mp, fmt->fourcc, pix_mp->width,
+ pix_mp->height,
+ fmt->stride_align ?: 1);
if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_H264_SLICE &&
!hantro_needs_postproc(ctx, fmt))
pix_mp->plane_fmt[0].sizeimage +=
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
index 614d54e3a8ef..1248f9086ff1 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu_hw.c
@@ -330,10 +330,11 @@ static const struct hantro_fmt rockchip_vpu981_dec_fmts[] = {
.fourcc = V4L2_PIX_FMT_NV12_4L4,
.codec_mode = HANTRO_MODE_NONE,
.match_depth = true,
+ .stride_align = 16,
.frmsize = {
.min_width = ROCKCHIP_VPU981_MIN_SIZE,
.max_width = FMT_4K_WIDTH,
- .step_width = MB_DIM,
+ .step_width = 8,
.min_height = ROCKCHIP_VPU981_MIN_SIZE,
.max_height = FMT_4K_HEIGHT,
.step_height = MB_DIM,
@@ -343,10 +344,11 @@ static const struct hantro_fmt rockchip_vpu981_dec_fmts[] = {
.fourcc = V4L2_PIX_FMT_NV15_4L4,
.codec_mode = HANTRO_MODE_NONE,
.match_depth = true,
+ .stride_align = 16,
.frmsize = {
.min_width = ROCKCHIP_VPU981_MIN_SIZE,
.max_width = FMT_4K_WIDTH,
- .step_width = MB_DIM,
+ .step_width = 8,
.min_height = ROCKCHIP_VPU981_MIN_SIZE,
.max_height = FMT_4K_HEIGHT,
.step_height = MB_DIM,
@@ -359,7 +361,7 @@ static const struct hantro_fmt rockchip_vpu981_dec_fmts[] = {
.frmsize = {
.min_width = ROCKCHIP_VPU981_MIN_SIZE,
.max_width = FMT_4K_WIDTH,
- .step_width = MB_DIM,
+ .step_width = 8,
.min_height = ROCKCHIP_VPU981_MIN_SIZE,
.max_height = FMT_4K_HEIGHT,
.step_height = MB_DIM,
--
2.55.0
next prev parent reply other threads:[~2026-12-04 7:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 7:12 [PATCH 0/2] media: verisilicon: Fix the VPU981 line stride and minimum size Arun Iyengar via B4 Relay
2026-12-04 7:12 ` Arun Iyengar via B4 Relay [this message]
2026-12-04 7:12 ` [PATCH 2/2] media: verisilicon: av1: Lower the VPU981 minimum size to 16x16 Arun Iyengar via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204-av1-ref-stride-v1-1-5d86fb6d6858@gmail.com \
--to=devnull+aiyengar1990.gmail.com@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=benjamin.gaignard@collabora.com \
--cc=heiko@sntech.de \
--cc=hverkuil@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox