]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: rockchip: rga: align stride to 4 bytes
authorSven Püschel <s.pueschel@pengutronix.de>
Wed, 20 May 2026 22:44:20 +0000 (00:44 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 10:32:20 +0000 (12:32 +0200)
Add an alignment setting to rga_hw to set the desired stride alignment.
As the RGA2 register for the stride counts in word units, the code
already divides the bytesperline value by 4 when writing it into the
register. Therefore fix the alignment to a multiple of 4 to avoid
potential off by one errors due from the division.

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-hw.c
drivers/media/platform/rockchip/rga/rga.c
drivers/media/platform/rockchip/rga/rga.h

index 9881c14f908d5340347b52f686195e251aec1884..dac3cb6aa17d3a0c5fee69b07b3e5b17aba5d40f 100644 (file)
@@ -580,6 +580,7 @@ const struct rga_hw rga2_hw = {
        .max_width = MAX_WIDTH,
        .min_height = MIN_HEIGHT,
        .max_height = MAX_HEIGHT,
+       .stride_alignment = 4,
 
        .start = rga_hw_start,
        .handle_irq = rga_handle_irq,
index bf6bbcbfc869b8daa477cf2d748d12155b091a18..d080cb672740b621ae02309f457b5068653e9c7c 100644 (file)
@@ -234,10 +234,10 @@ static int rga_open(struct file *file)
        ctx->in = def_frame;
        ctx->out = def_frame;
 
-       v4l2_fill_pixfmt_mp(&ctx->in.pix,
-                           ctx->in.fmt->fourcc, def_width, def_height);
-       v4l2_fill_pixfmt_mp(&ctx->out.pix,
-                           ctx->out.fmt->fourcc, def_width, def_height);
+       v4l2_fill_pixfmt_mp_aligned(&ctx->in.pix, ctx->in.fmt->fourcc,
+                                   def_width, def_height, rga->hw->stride_alignment);
+       v4l2_fill_pixfmt_mp_aligned(&ctx->out.pix, ctx->out.fmt->fourcc,
+                                   def_width, def_height, rga->hw->stride_alignment);
 
        if (mutex_lock_interruptible(&rga->mutex)) {
                ret = -ERESTARTSYS;
@@ -393,7 +393,8 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                fmt = &hw->formats[0];
 
        v4l2_apply_frmsize_constraints(&pix_fmt->width, &pix_fmt->height, &frmsize);
-       v4l2_fill_pixfmt_mp(pix_fmt, fmt->fourcc, pix_fmt->width, pix_fmt->height);
+       v4l2_fill_pixfmt_mp_aligned(pix_fmt, fmt->fourcc,
+                                   pix_fmt->width, pix_fmt->height, hw->stride_alignment);
        pix_fmt->field = V4L2_FIELD_NONE;
 
        return 0;
index 04aeb7b429523fc84c0f581c6c891f38746f1524..38518146910a6f8c9f84ea4e0a302243bc219263 100644 (file)
@@ -150,6 +150,7 @@ struct rga_hw {
        size_t cmdbuf_size;
        u32 min_width, min_height;
        u32 max_width, max_height;
+       u8 stride_alignment;
 
        void (*start)(struct rockchip_rga *rga,
                      struct rga_vb_buffer *src, struct rga_vb_buffer *dst);