This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: rockchip: rga: use pixelformat to find format
Author:  Michael Tretter <m.tret...@pengutronix.de>
Date:    Fri Oct 13 13:00:29 2023 +0200

Use the pixelformat instead of the v4l2_format to find the rga_fmt. This
avoids knowing the structure and type of v4l2_format in rga_fmt_find and
simplifies the function.

Also cleanup the users of the function. In try_fmt always return the
found pixel format to make sure that the pixel format is always set.
Thus, we can be sure that we will find the rga_fmt in s_fmt and can drop
the check if a given format has been found.

Signed-off-by: Michael Tretter <m.tret...@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 drivers/media/platform/rockchip/rga/rga.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

---

diff --git a/drivers/media/platform/rockchip/rga/rga.c 
b/drivers/media/platform/rockchip/rga/rga.c
index 792084918798..8ae68890a8f7 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -320,12 +320,12 @@ static struct rga_fmt formats[] = {
 
 #define NUM_FORMATS ARRAY_SIZE(formats)
 
-static struct rga_fmt *rga_fmt_find(struct v4l2_format *f)
+static struct rga_fmt *rga_fmt_find(u32 pixelformat)
 {
        unsigned int i;
 
        for (i = 0; i < NUM_FORMATS; i++) {
-               if (formats[i].fourcc == f->fmt.pix.pixelformat)
+               if (formats[i].fourcc == pixelformat)
                        return &formats[i];
        }
        return NULL;
@@ -474,11 +474,11 @@ static int vidioc_try_fmt(struct file *file, void *prv, 
struct v4l2_format *f)
 {
        struct rga_fmt *fmt;
 
-       fmt = rga_fmt_find(f);
-       if (!fmt) {
+       fmt = rga_fmt_find(f->fmt.pix.pixelformat);
+       if (!fmt)
                fmt = &formats[0];
-               f->fmt.pix.pixelformat = fmt->fourcc;
-       }
+
+       f->fmt.pix.pixelformat = fmt->fourcc;
 
        f->fmt.pix.field = V4L2_FIELD_NONE;
 
@@ -504,7 +504,6 @@ static int vidioc_s_fmt(struct file *file, void *prv, 
struct v4l2_format *f)
        struct rockchip_rga *rga = ctx->rga;
        struct vb2_queue *vq;
        struct rga_frame *frm;
-       struct rga_fmt *fmt;
        int ret = 0;
 
        /* Adjust all values accordingly to the hardware capabilities
@@ -521,13 +520,10 @@ static int vidioc_s_fmt(struct file *file, void *prv, 
struct v4l2_format *f)
        frm = rga_get_frame(ctx, f->type);
        if (IS_ERR(frm))
                return PTR_ERR(frm);
-       fmt = rga_fmt_find(f);
-       if (!fmt)
-               return -EINVAL;
        frm->width = f->fmt.pix.width;
        frm->height = f->fmt.pix.height;
        frm->size = f->fmt.pix.sizeimage;
-       frm->fmt = fmt;
+       frm->fmt = rga_fmt_find(f->fmt.pix.pixelformat);
        frm->stride = f->fmt.pix.bytesperline;
        frm->colorspace = f->fmt.pix.colorspace;
 

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to