From nobody Tue Feb 10 06:25:24 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 D6FF5364EB2 for ; Tue, 27 Jan 2026 14:40:48 +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=1769524850; cv=none; b=GKnF2uxjZkuGXO7qlWYUiaIAoIkISWmnz5kRjyHdy+yJ4RX+hD/CDynq6K/HHk4MeXIkeh6TARvDpo32H2qxCsrcS52P8aC/Jy9NR6v7DHc2l8fA9R1wyQ0xu2toJ+C7jSVMUcHUQe7lLcvUWTwTSBgHpqMG7g6CBiWV4GQ68FU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524850; c=relaxed/simple; bh=82OxQEPMx3A5useUzoN54EOJjdkBs6evsd2RYUAhzq4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U6zitg/SGHn5IK/h3i/D09C0cXSgAXWSeMt5S4UwNLucA1uERU4xVR2/a45Z95mmCJUi5VFlqICf7V1AE48JqZdpicC7j9kdYgYKQCCDLaB9A7ipUa/y++rX2G5kBMF1Khi0pwY0pE21pmAV9Ds8L57WTxEWfsc9HnKKDAtgZkE= 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 1vkkFK-0007YT-Pu; Tue, 27 Jan 2026 15:40:47 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 27 Jan 2026 15:39:31 +0100 Subject: [PATCH v3 22/27] media: rockchip: rga: remove stride from rga_frame 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-22-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?= , Nicolas Dufresne 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 Remove the stride variable from rga_frame. Despite the comment it didn't involve any calculation and is just a copy of the plane_fmt[0].bytesperline value. Therefore avoid this struct member and use the bytesperline value directly in the places where it is required. Also drop the dependency on the depth format member, which was only used to calculate the stride of the default format. This is already done by the v4l2_fill_pixfmt_mp_aligned helper and used as stride in try_fmt. Therefore using it's value also for the default format stride is just more consistent. Reviewed-by: Nicolas Dufresne Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga-hw.c | 36 ++++++++++--------------= ---- drivers/media/platform/rockchip/rga/rga.c | 5 +--- drivers/media/platform/rockchip/rga/rga.h | 4 ---- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga-hw.c b/drivers/media/p= latform/rockchip/rga/rga-hw.c index 2013b59701d12..5d993cf69963d 100644 --- a/drivers/media/platform/rockchip/rga/rga-hw.c +++ b/drivers/media/platform/rockchip/rga/rga-hw.c @@ -44,7 +44,7 @@ rga_get_corner_addrs(struct rga_frame *frm, struct rga_ad= drs *addrs, struct rga_addrs *lt, *lb, *rt, *rb; const struct v4l2_format_info *format_info; unsigned int x_div =3D 0, - y_div =3D 0, uv_stride =3D 0, pixel_width =3D 0; + y_div =3D 0, y_stride =3D 0, uv_stride =3D 0, pixel_width =3D 0; =20 lt =3D &corner_addrs.left_top; lb =3D &corner_addrs.left_bottom; @@ -61,14 +61,15 @@ rga_get_corner_addrs(struct rga_frame *frm, struct rga_= addrs *addrs, else x_div =3D 1; y_div =3D format_info->vdiv; - uv_stride =3D frm->stride / x_div; - pixel_width =3D frm->stride / frm->pix.width; + y_stride =3D frm->pix.plane_fmt[0].bytesperline; + uv_stride =3D y_stride / x_div; + pixel_width =3D y_stride / frm->pix.width; =20 - lt->y_addr =3D addrs->y_addr + y * frm->stride + x * pixel_width; + lt->y_addr =3D addrs->y_addr + y * y_stride + x * pixel_width; lt->u_addr =3D addrs->u_addr + (y / y_div) * uv_stride + x / x_div; lt->v_addr =3D addrs->v_addr + (y / y_div) * uv_stride + x / x_div; =20 - lb->y_addr =3D lt->y_addr + (h - 1) * frm->stride; + lb->y_addr =3D lt->y_addr + (h - 1) * y_stride; lb->u_addr =3D lt->u_addr + (h / y_div - 1) * uv_stride; lb->v_addr =3D lt->v_addr + (h / y_div - 1) * uv_stride; =20 @@ -169,6 +170,7 @@ static void rga_cmd_set_trans_info(struct rga_ctx *ctx) union rga_src_act_info src_act_info; union rga_dst_vir_info dst_vir_info; union rga_dst_act_info dst_act_info; + u32 in_stride, out_stride; =20 src_h =3D ctx->in.crop.height; src_w =3D ctx->in.crop.width; @@ -291,13 +293,15 @@ static void rga_cmd_set_trans_info(struct rga_ctx *ct= x) * Calculate the framebuffer virtual strides and active size, * note that the step of vir_stride / vir_width is 4 byte words */ - src_vir_info.data.vir_stride =3D ctx->in.stride >> 2; - src_vir_info.data.vir_width =3D ctx->in.stride >> 2; + in_stride =3D ctx->in.pix.plane_fmt[0].bytesperline; + src_vir_info.data.vir_stride =3D in_stride >> 2; + src_vir_info.data.vir_width =3D in_stride >> 2; =20 src_act_info.data.act_height =3D src_h - 1; src_act_info.data.act_width =3D src_w - 1; =20 - dst_vir_info.data.vir_stride =3D ctx->out.stride >> 2; + out_stride =3D ctx->out.pix.plane_fmt[0].bytesperline; + dst_vir_info.data.vir_stride =3D out_stride >> 2; dst_act_info.data.act_height =3D dst_h - 1; dst_act_info.data.act_width =3D dst_w - 1; =20 @@ -481,97 +485,81 @@ static struct rga_fmt formats[] =3D { .fourcc =3D V4L2_PIX_FMT_ARGB32, .color_swap =3D RGA_COLOR_ALPHA_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR8888, - .depth =3D 32, }, { .fourcc =3D V4L2_PIX_FMT_ABGR32, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR8888, - .depth =3D 32, }, { .fourcc =3D V4L2_PIX_FMT_XBGR32, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_XBGR8888, - .depth =3D 32, }, { .fourcc =3D V4L2_PIX_FMT_RGB24, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_RGB888, - .depth =3D 24, }, { .fourcc =3D V4L2_PIX_FMT_BGR24, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_RGB888, - .depth =3D 24, }, { .fourcc =3D V4L2_PIX_FMT_ARGB444, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR4444, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_ARGB555, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_ABGR1555, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_RGB565, .color_swap =3D RGA_COLOR_RB_SWAP, .hw_format =3D RGA_COLOR_FMT_BGR565, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_NV21, .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, - .depth =3D 12, }, { .fourcc =3D V4L2_PIX_FMT_NV61, .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422SP, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_NV12, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, - .depth =3D 12, }, { .fourcc =3D V4L2_PIX_FMT_NV12M, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420SP, - .depth =3D 12, }, { .fourcc =3D V4L2_PIX_FMT_NV16, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422SP, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_YUV420, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420P, - .depth =3D 12, }, { .fourcc =3D V4L2_PIX_FMT_YUV422P, .color_swap =3D RGA_COLOR_NONE_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV422P, - .depth =3D 16, }, { .fourcc =3D V4L2_PIX_FMT_YVU420, .color_swap =3D RGA_COLOR_UV_SWAP, .hw_format =3D RGA_COLOR_FMT_YUV420P, - .depth =3D 12, }, }; =20 diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/rockchip/rga/rga.c index 59463c7f26b6f..30d09ec77afca 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -220,8 +220,6 @@ static int rga_open(struct file *file) .fmt =3D &rga->hw->formats[0], }; =20 - def_frame.stride =3D (def_width * def_frame.fmt->depth) >> 3; - ctx =3D kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; @@ -459,7 +457,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, = struct v4l2_format *f) if (IS_ERR(frm)) return PTR_ERR(frm); frm->fmt =3D rga_fmt_find(rga, pix_fmt->pixelformat); - frm->stride =3D pix_fmt->plane_fmt[0].bytesperline; =20 /* * Copy colorimetry from output to capture as required by the @@ -484,7 +481,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, = struct v4l2_format *f) "[%s] fmt - %p4cc %dx%d (stride %d)\n", V4L2_TYPE_IS_OUTPUT(f->type) ? "OUTPUT" : "CAPTURE", &frm->fmt->fourcc, pix_fmt->width, pix_fmt->height, - frm->stride); + pix_fmt->plane_fmt[0].bytesperline); =20 for (i =3D 0; i < pix_fmt->num_planes; i++) { v4l2_dbg(debug, 1, &rga->v4l2_dev, diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/plat= form/rockchip/rga/rga.h index 2838fc7785f72..d203b7dae2b03 100644 --- a/drivers/media/platform/rockchip/rga/rga.h +++ b/drivers/media/platform/rockchip/rga/rga.h @@ -19,7 +19,6 @@ =20 struct rga_fmt { u32 fourcc; - int depth; u8 color_swap; u8 hw_format; }; @@ -31,9 +30,6 @@ struct rga_frame { /* Image format */ struct rga_fmt *fmt; struct v4l2_pix_format_mplane pix; - - /* Variables that can calculated once and reused */ - u32 stride; }; =20 struct rga_dma_desc { --=20 2.52.0