From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 441BC606A32F for ; Sat, 5 Dec 2026 09:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HLxdBXL8; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kiyXqeel DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References: Message-Id:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=TyC2crS1ORvXZoWWqHDpZ3pPlzzbDeKZGBB6XK/DYNk=; b=HLxdBXL8p6PwvBrky5tnLkBuKt 65MOrepSJNEUTD+XzcpWvOt0QjV8JHgSujKJyYGCqEln1tD059u5oPy5J7c4bl3XriWE2x0jTIs7V IYvNnRI0hX7k8Mhcf2hY3jLDDZbmGASJRRQpu0AvwQAW86yGCj0XDuCahqmwvZG+feZGWnbyI744i FJ6KQV9CBbGmo5FTy45dvv7wlnGXZwbvZn5wyDHA/DwalUe+7teCOk5Q6w0+jI3d9cKCps6bshkrc qHm23GPZ2Rc0IsgXLE1YRnxFtgGvLpL4yAvP366eOnO7VbZEVh1UDTHjW3VKCtvDwvrVNz8vSteok cTwhyinQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZmMJ-00000002FIl-1B6q; Sat, 05 Dec 2026 09:47:11 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZmMH-00000002FHl-1jnX; Sat, 05 Dec 2026 09:47:09 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id D267443E56; Sat, 5 Dec 2026 09:47:08 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796464028; b=YHlIIHF8tIdDusHJM9Owd3H//Mzr719OQ0YCIdSB4/gOEd4fn4iNlwHxRpupEpijfrr8 BAtyDCZ49a4fzeN8q8Guwh1Qu/aPJtgEQ50j63h69LNFmFmW20i38D+RxJVh6D5/SvPj/ 89ouQi8N1RGnnnD2P1EUMuHcP283waU6Gq/1oQMisMZ5vt3pSJzjaTT+pkVNznOp/uh8G +ZTmgThX+ObKGMNSJUQuxFpfQnH5YKgblivcWOGoeuEBMBXqikeCdynvDatLnzqBUBlXX 3C+ISIxR4zEJpszTChhRCOT0BsNHvu5N1nkvUOe5Z9vy6yDn+t1beFptrVExi4ITzmA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796464028; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=q2UM0cNGCS5hOVQofXRsNKAjurJCFvW57i4Ae+1nqzA=; b=YU8c8FXc79nEt7tBGpV77f1ivwSp42Jr5alsx/0xmtGUulVXnm87hH6ZxmadAA0pfdVt rUdUmswL/Jr4hq5Y5U18zNT2fsfTLYzMnnKtltEnBjerPGc8TUqKGM8HQz5tdIGokv4kK 8SLvqRiShBLh+9H+ScN9tcC8m07eUr3FA0FT2jjQMiEpx9yOKieEs5ehoVcfsB3ABZOJB ApWItpX7txGVi9vAN5NglYvO3d+RM83sYJMmDbH9xTKGQ6ikNLad36zOofB2w+XEmeXvH O9Zret0lcAy+DpPypdUw8iFkrOVwnDblUj28luGddRsR+wDGP+fVzKYzpJA239nkV0A== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 02C3D1F00936; Sat, 5 Dec 2026 09:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796464028; bh=q2UM0cNGCS5hOVQofXRsNKAjurJCFvW57i4Ae+1nqzA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=kiyXqeelTNtab89T31pJNbyHX3mO3+QeNL8q0l3+bJxONAZpu4uCgKLRdX6xm0+6f S3u0UmFiyhcU5IP00cYz4619aPV3wLCf5uE7/yRmw4oAC2LVd/QI2yApEFX4qepdvl xzC0mrhtBCxWvO7HoUL+9XxhlRZUDprjB3qMzFCm3UXHoDAAcZE73OrGEchues3hzb jNp/0UySmnx4HjuWN3GwHGKhiV/9GBkbOfhyh0xjjZOMLWOkildIsO10XPgdd8t/4e NHx5ihSskxEeYmYo7NkCOcjHE0VsmQ9nK2MXfuxlxK2ZjJ5vn9P6szEqMVsoOhvxMv S9KYgpe+sbfyw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 870015027E; Sat, 5 Dec 2026 09:47:07 +0000 (UTC) From: Arun Iyengar via B4 Relay Date: Sat, 05 Dec 2026 09:47:06 +0000 Subject: [PATCH v2 1/2] media: verisilicon: Match the VPU981 line stride X-Archived-By: MIME-Version: 1.0 Message-Id: <20261205-av1-ref-stride-v2-1-e8bd05192673@gmail.com> References: <20261205-av1-ref-stride-v2-0-e8bd05192673@gmail.com> In-Reply-To: <20261205-av1-ref-stride-v2-0-e8bd05192673@gmail.com> To: Nicolas Dufresne , Benjamin Gaignard , Philipp Zabel , Mauro Carvalho Chehab , Heiko Stuebner , Hans Verkuil 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 X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796464026; l=6254; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=Kdy8Ola7nrO5IgG82BZsJw1CI0Eu6cKNm+/CfPmgrXM=; b=XQULIC4jRCFE29wtrg0sXCJM9JMTERdAe8igiw5U/z0Xvqji180Gt44SNj0GWfzjW9Q1MNpoG /CzCKPvIa1YBjypEU9xB8yLyDqUD0ia8cR52aGpuHt/BotzkhRVkpNH X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 X-Original-From: Arun Iyengar X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: aiyengar1990@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_REPLYTO_END_DIGIT, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Arun Iyengar 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 --- For stable: before 7d5e38c070e2 the check is in rockchip_vpu981_av1_dec_prepare_run(); change ctx->dst_fmt to ctx->ref_fmt 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 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip