]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: rockchip: rga: remove size from rga_frame
authorSven Püschel <s.pueschel@pengutronix.de>
Wed, 20 May 2026 22:44:27 +0000 (00:44 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 10:32:21 +0000 (12:32 +0200)
The size member is only used for the mmu page table mapping.
Therefore avoid storing the value and instead only calculate it
in place. This also avoids the calculation entirely when an external
iommu is used.

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 cd6904d5fe5a6d9cf193c8265f92386d815827ed..092c2bdf6b67207e9c47b89d479ad1642f163df8 100644 (file)
@@ -79,6 +79,8 @@ static int rga_buf_init(struct vb2_buffer *vb)
        struct rockchip_rga *rga = ctx->rga;
        struct rga_frame *f = rga_get_frame(ctx, vb->vb2_queue->type);
        size_t n_desc = 0;
+       u32 size = 0;
+       u8 i;
 
        if (IS_ERR(f))
                return PTR_ERR(f);
@@ -86,7 +88,9 @@ static int rga_buf_init(struct vb2_buffer *vb)
        if (!rga_has_internal_iommu(rga))
                return 0;
 
-       n_desc = DIV_ROUND_UP(f->size, PAGE_SIZE);
+       for (i = 0; i < f->pix.num_planes; i++)
+               size += f->pix.plane_fmt[i].sizeimage;
+       n_desc = DIV_ROUND_UP(size, PAGE_SIZE);
 
        rbuf->n_desc = n_desc;
        rbuf->dma_desc = dma_alloc_coherent(rga->dev,
index cda3cecb1ce8c9df70185802cbcdd3e6e227831a..e44e81814b7cbb93110d5a008468ab451375df5e 100644 (file)
@@ -268,7 +268,6 @@ static int rga_open(struct file *file)
        };
 
        def_frame.stride = (def_width * def_frame.fmt->depth) >> 3;
-       def_frame.size = def_frame.stride * def_height;
 
        ctx = kzalloc_obj(*ctx);
        if (!ctx)
@@ -481,9 +480,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
        frm = rga_get_frame(ctx, f->type);
        if (IS_ERR(frm))
                return PTR_ERR(frm);
-       frm->size = 0;
-       for (i = 0; i < pix_fmt->num_planes; i++)
-               frm->size += pix_fmt->plane_fmt[i].sizeimage;
        frm->fmt = rga_fmt_find(rga, pix_fmt->pixelformat);
        frm->stride = pix_fmt->plane_fmt[0].bytesperline;
 
@@ -508,10 +504,10 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
        ctx->cmdbuf_dirty = true;
 
        v4l2_dbg(debug, 1, &rga->v4l2_dev,
-                "[%s] fmt - %p4cc %dx%d (stride %d, sizeimage %d)\n",
+                "[%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, frm->size);
+                 frm->stride);
 
        for (i = 0; i < pix_fmt->num_planes; i++) {
                v4l2_dbg(debug, 1, &rga->v4l2_dev,
index b180df5c48370ae7b9235a7201e6674fc414109f..d47c6821ce2c93c9218dea54b7a4e6ebd9c73fde 100644 (file)
@@ -34,7 +34,6 @@ struct rga_frame {
 
        /* Variables that can calculated once and reused */
        u32 stride;
-       u32 size;
 };
 
 struct rga_dma_desc {