From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B47ADFF886D for ; Tue, 28 Apr 2026 09:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tL+NqYfoXXhxAsfm48dTED3mFcnXQMPdFim48qetq44=; b=Lbkf9MeYn89etgWeHsn784hoGq laE2lJDCCrpSgmf2P3UgEDOxKOX9KJFiWIIL6JaEyCOnl/p+R/O+h0vrvVbz/9LBMw9WpORBrV07h DfzSsoDgk7hAkxZupcOe5jCEL49THYikU4G6WfQSjyqixixehlypAyLe6l+y5JD5nsSK/bQwbsUA1 UZXRjAm8+W9JNctoMrROWNbb0k8erpWOJ1uDVqUuo0jKUcRefrAtt71UF90BsGVNBsLLcJ/1ZGDU6 SUCpUWEdScwXF5cAxItzfSOpNLWEGCDYXkLGPWyhTQIuq21cw2BjGb2T+66XimcTVYP//yT2U7HuV 1WqIFWOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wHeKb-00000000yiK-3SYU; Tue, 28 Apr 2026 09:02:13 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wHeK3-00000000xz7-1oi7 for linux-arm-kernel@bombadil.infradead.org; Tue, 28 Apr 2026 09:01:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=tL+NqYfoXXhxAsfm48dTED3mFcnXQMPdFim48qetq44=; b=PurbKSmlRdVz4T1HHS6xDLGE05 bIYe415LKF51pnP9gGrszXvScfSJqvg7M7Om0Bjd/OEBZMX2C7UVVuZ2fBzrd0NcboS0vSQ5zijg2 +LYCkimJjQIGudVymG3y1UWMCzEf+IgKWUrBwL5JbguIKBCwMbI43sHn6buXZOc5L6vXX+G/rZIeP gvQmbRl5FknmXnackprw5t21DDJWRa4YFVgWL/sgpg/eaTrLFtACcgcA3GSLXUdIvMcWz08iN6e3u /g0b+u1CxzLFl36bx1NAOshlIYGEGNZT7dhvQudzpF5GaDmB2Re8aEHwFN/GagfUy0u/H1b5VuGii c+jmzLHg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wHeJt-00000002VUh-2zBa for linux-arm-kernel@lists.infradead.org; Tue, 28 Apr 2026 09:01:38 +0000 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 1wHeJC-0004Lz-0Z; Tue, 28 Apr 2026 11:00:46 +0200 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 28 Apr 2026 11:00:43 +0200 Subject: [PATCH v5 08/29] media: rockchip: rga: use stride for offset calculation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260428-spu-rga3-v5-8-eb7f5d019d86@pengutronix.de> References: <20260428-spu-rga3-v5-0-eb7f5d019d86@pengutronix.de> In-Reply-To: <20260428-spu-rga3-v5-0-eb7f5d019d86@pengutronix.de> To: Jacob Chen , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Hans Verkuil 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, nicolas@ndufresne.ca, sebastian.reichel@collabora.com, =?utf-8?q?Sven_P=C3=BCschel?= , Nicolas Dufresne X-Mailer: b4 0.15.2 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260428_100129_887892_C64DBBBF X-CRM114-Status: GOOD ( 15.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Reviewed-by: Nicolas Dufresne Signed-off-by: Sven Püschel --- 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 -#include "rga-hw.h" #include "rga.h" 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; } -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 = f->pix.plane_fmt[0].bytesperline; + if (plane == 0) return 0; if (plane == 1) - return f->width * f->height; + return stride * f->height; if (plane == 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); return -EINVAL; } @@ -148,7 +152,7 @@ static int rga_buf_prepare(struct vb2_buffer *vb) /* Fill the remaining planes */ info = v4l2_format_info(f->fmt->fourcc); for (i = info->mem_planes; i < info->comp_planes; i++) - offsets[i] = get_plane_offset(f, i); + offsets[i] = get_plane_offset(f, info, i); rbuf->offset.y_off = offsets[0]; rbuf->offset.u_off = offsets[1]; diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c index 4e710a050cb7c..c07207edffdb6 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[] = { .color_swap = RGA_COLOR_ALPHA_SWAP, .hw_format = RGA_COLOR_FMT_ABGR8888, .depth = 32, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -199,7 +198,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_ABGR8888, .depth = 32, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -208,7 +206,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_XBGR8888, .depth = 32, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -217,7 +214,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_RGB888, .depth = 24, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -226,7 +222,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_RGB888, .depth = 24, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -235,7 +230,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_ABGR4444, .depth = 16, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -244,7 +238,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_ABGR1555, .depth = 16, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -253,7 +246,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_BGR565, .depth = 16, - .uv_factor = 1, .y_div = 1, .x_div = 1, }, @@ -262,7 +254,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_UV_SWAP, .hw_format = RGA_COLOR_FMT_YUV420SP, .depth = 12, - .uv_factor = 4, .y_div = 2, .x_div = 1, }, @@ -271,7 +262,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_UV_SWAP, .hw_format = RGA_COLOR_FMT_YUV422SP, .depth = 16, - .uv_factor = 2, .y_div = 1, .x_div = 1, }, @@ -280,7 +270,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_YUV420SP, .depth = 12, - .uv_factor = 4, .y_div = 2, .x_div = 1, }, @@ -289,7 +278,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_YUV420SP, .depth = 12, - .uv_factor = 4, .y_div = 2, .x_div = 1, }, @@ -298,7 +286,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_YUV422SP, .depth = 16, - .uv_factor = 2, .y_div = 1, .x_div = 1, }, @@ -307,7 +294,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_YUV420P, .depth = 12, - .uv_factor = 4, .y_div = 2, .x_div = 2, }, @@ -316,7 +302,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_NONE_SWAP, .hw_format = RGA_COLOR_FMT_YUV422P, .depth = 16, - .uv_factor = 2, .y_div = 1, .x_div = 2, }, @@ -325,7 +310,6 @@ static struct rga_fmt formats[] = { .color_swap = RGA_COLOR_UV_SWAP, .hw_format = RGA_COLOR_FMT_YUV420P, .depth = 12, - .uv_factor = 4, .y_div = 2, .x_div = 2, }, diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/platform/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; -- 2.54.0