Re: [PATCH v2 05/22] media: rockchip: rga: use stride for offset calculation
From: Nicolas Dufresne <hidden>
Date: 2025-12-24 15:00:37
Also in:
linux-devicetree, linux-media, linux-rockchip, lkml
Le mercredi 03 décembre 2025 à 16:52 +0100, Sven Püschel a écrit :
quoted hunk ↗ jump to hunk
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üschel <redacted> --- drivers/media/platform/rockchip/rga/rga-buf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c index 730bdf98565a5..b5e6b1b527ca8 100644 --- a/drivers/media/platform/rockchip/rga/rga-buf.c +++ b/drivers/media/platform/rockchip/rga/rga-buf.c@@ -14,7 +14,6 @@#include <media/videobuf2-dma-sg.h> #include <media/videobuf2-v4l2.h> -#include "rga-hw.h" #include "rga.h" static ssize_t fill_descriptors(struct rga_dma_desc *desc, size_t max_desc,@@ -92,14 +91,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);
This was the only user of uv_factor, please cleanup rga.h/rga.c. I see there is also redudant x_div/y_div, with this similar code re-implemented in rga_get_addr_offset(), can you check for v3 if we can cleanup some more ? One thought though is that this code is already hidden inside v4l2-common, perhaps you could just expose it, this ensure that we don't accidently have different information when configuring the HW and communicating with the user. Nicolas
quoted hunk ↗ jump to hunk
return -EINVAL; }@@ -145,7 +149,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];
Attachments
- signature.asc [application/pgp-signature] 228 bytes