From nobody Tue Feb 10 07:40:27 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9DC35CB6F for ; Tue, 27 Jan 2026 14:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524812; cv=none; b=N5bNCJQRRE+vmTjZqO2wgTyvPdr8fMgrqTaHdF4p5EGQZMLgJx4044ctuNp0NWJWqaBZXsJfYiVrw+yJD9MG+VpHxRnE1cTOsT9yaYX81CIFTJWRE2JDdMX3zGyPnSjsvgb36xcCJron3wwjM5a87yrMqeGN6roTdep5DZMHJ58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524812; c=relaxed/simple; bh=JOwvDeJCyzrvK5jl/gxmF1CyRNmJLl778mr+and9tyU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qAmNNNwOOCzMFLnCCWMeDdcOPAbtUuWWOPCv5lOS1zfTxCrmZGLzb89Y8YtZdC3vCjJN3pHEDawi32uYDPfEfyj1IrVTpsUsl6r9LjsgLQNXmHUXMYsOqQT3YR41MC4ktMuljVOCDFxSt7Jy3tHIwdm44qlcl34uYwc9VHXGZH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=peter.mobile.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1vkkEi-0007YT-FO; Tue, 27 Jan 2026 15:40:08 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 27 Jan 2026 15:39:16 +0100 Subject: [PATCH v3 07/27] media: rockchip: rga: use stride for offset calculation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-spu-rga3-v3-7-77b273067beb@pengutronix.de> References: <20260127-spu-rga3-v3-0-77b273067beb@pengutronix.de> In-Reply-To: <20260127-spu-rga3-v3-0-77b273067beb@pengutronix.de> To: Jacob Chen , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de, =?utf-8?q?Sven_P=C3=BCschel?= X-Mailer: b4 0.14.3 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.pueschel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Use the stride instead of the width for the offset calculation. This ensures that the bytesperline value doesn't need to match the width value of the image. Furthermore this patch removes the dependency on the uv_factor property and instead reuses the v4l2_format_info to determine the correct division factor. Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga-buf.c | 14 +++++++++----- drivers/media/platform/rockchip/rga/rga.c | 16 ---------------- drivers/media/platform/rockchip/rga/rga.h | 1 - 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/= platform/rockchip/rga/rga-buf.c index bb575873f2b24..65fc0d5b4aa10 100644 --- a/drivers/media/platform/rockchip/rga/rga-buf.c +++ b/drivers/media/platform/rockchip/rga/rga-buf.c @@ -14,7 +14,6 @@ #include #include =20 -#include "rga-hw.h" #include "rga.h" =20 static ssize_t fill_descriptors(struct rga_dma_desc *desc, size_t max_desc, @@ -95,14 +94,19 @@ static int rga_buf_init(struct vb2_buffer *vb) return 0; } =20 -static int get_plane_offset(struct rga_frame *f, int plane) +static int get_plane_offset(struct rga_frame *f, + const struct v4l2_format_info *info, + int plane) { + u32 stride =3D f->pix.plane_fmt[0].bytesperline; + if (plane =3D=3D 0) return 0; if (plane =3D=3D 1) - return f->width * f->height; + return stride * f->height; if (plane =3D=3D 2) - return f->width * f->height + (f->width * f->height / f->fmt->uv_factor); + return stride * f->height + + (stride * f->height / info->hdiv / info->vdiv); =20 return -EINVAL; } @@ -148,7 +152,7 @@ static int rga_buf_prepare(struct vb2_buffer *vb) /* Fill the remaining planes */ info =3D v4l2_format_info(f->fmt->fourcc); for (i =3D info->mem_planes; i < info->comp_planes; i++) - offsets[i] =3D get_plane_offset(f, i); + offsets[i] =3D get_plane_offset(f, info, i); =20 rbuf->offset.y_off =3D offsets[0]; rbuf->offset.u_off =3D offsets[1]; diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/rockchip/rga/rga.c index 338c7796490bc..da4d5bec7a0a5 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -190,7 +190,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_ALPHA_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR8888, .depth =3D 32, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -199,7 +198,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR8888, .depth =3D 32, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -208,7 +206,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_XBGR8888, .depth =3D 32, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -217,7 +214,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_RGB888, .depth =3D 24, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -226,7 +222,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_RGB888, .depth =3D 24, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -235,7 +230,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR4444, .depth =3D 16, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -244,7 +238,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR1555, .depth =3D 16, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -253,7 +246,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_BGR565, .depth =3D 16, - .uv_factor =3D 1, .y_div =3D 1, .x_div =3D 1, }, @@ -262,7 +254,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, .depth =3D 12, - .uv_factor =3D 4, .y_div =3D 2, .x_div =3D 1, }, @@ -271,7 +262,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422SP, .depth =3D 16, - .uv_factor =3D 2, .y_div =3D 1, .x_div =3D 1, }, @@ -280,7 +270,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, .depth =3D 12, - .uv_factor =3D 4, .y_div =3D 2, .x_div =3D 1, }, @@ -289,7 +278,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, .depth =3D 12, - .uv_factor =3D 4, .y_div =3D 2, .x_div =3D 1, }, @@ -298,7 +286,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422SP, .depth =3D 16, - .uv_factor =3D 2, .y_div =3D 1, .x_div =3D 1, }, @@ -307,7 +294,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420P, .depth =3D 12, - .uv_factor =3D 4, .y_div =3D 2, .x_div =3D 2, }, @@ -316,7 +302,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422P, .depth =3D 16, - .uv_factor =3D 2, .y_div =3D 1, .x_div =3D 2, }, @@ -325,7 +310,6 @@ static struct rga_fmt formats[] =3D { .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420P, .depth =3D 12, - .uv_factor =3D 4, .y_div =3D 2, .x_div =3D 2, }, diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/plat= form/rockchip/rga/rga.h index 2db10acecb405..477cf5b62bbb2 100644 --- a/drivers/media/platform/rockchip/rga/rga.h +++ b/drivers/media/platform/rockchip/rga/rga.h @@ -17,7 +17,6 @@ struct rga_fmt { u32 fourcc; int depth; - u8 uv_factor; u8 y_div; u8 x_div; u8 color_swap; --=20 2.52.0