]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: rockchip: rga: use stride for offset calculation
authorSven Püschel <s.pueschel@pengutronix.de>
Wed, 20 May 2026 22:44:13 +0000 (00:44 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 10:32:19 +0000 (12:32 +0200)
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 <nicolas.dufresne@collabora.com>
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/rockchip/rga/rga-buf.c
drivers/media/platform/rockchip/rga/rga.c
drivers/media/platform/rockchip/rga/rga.h

index bb575873f2b249930f3831870f7f4c7dbbf2b32a..65fc0d5b4aa1016dee11826a9757e13c94bd8c5b 100644 (file)
@@ -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,
@@ -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];
index 4e710a050cb7c97256d3448692c238eec414b862..c07207edffdb6f58df09a0ddb9d060e014a2aa51 100644 (file)
@@ -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,
        },
index 2db10acecb40576fd8aeb40e1db238aca026e8af..477cf5b62bbb276346b2862de805c3ed303cabbe 100644 (file)
@@ -17,7 +17,6 @@
 struct rga_fmt {
        u32 fourcc;
        int depth;
-       u8 uv_factor;
        u8 y_div;
        u8 x_div;
        u8 color_swap;