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

Subject: media: rkisp1: Implement s_fmt/try_fmt
Author:  Jacopo Mondi <jacopo.mo...@ideasonboard.com>
Date:    Thu Aug 8 22:41:00 2024 +0200

Implement in the rkisp1 driver support for the s_fmt and try_fmt
operation to allow userspace to select between the extensible
and the fixed parameters formats.

Implement enum_mbus_code to enumerate the fixed and the extensible
formats and disallow changing the data format while the queue is busy.

Signed-off-by: Jacopo Mondi <jacopo.mo...@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
Reviewed-by: Paul Elder <paul.el...@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bing...@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ai...@linux.intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>

 .../media/platform/rockchip/rkisp1/rkisp1-params.c | 58 +++++++++++++++++++---
 1 file changed, 50 insertions(+), 8 deletions(-)

---

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c 
b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
index b48adff49307..85ef92f3f364 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
@@ -75,6 +75,17 @@ static const struct v4l2_meta_format rkisp1_params_formats[] 
= {
        },
 };
 
+static const struct v4l2_meta_format *
+rkisp1_params_get_format_info(u32 dataformat)
+{
+       for (unsigned int i = 0; i < ARRAY_SIZE(rkisp1_params_formats); i++) {
+               if (rkisp1_params_formats[i].dataformat == dataformat)
+                       return &rkisp1_params_formats[i];
+       }
+
+       return &rkisp1_params_formats[RKISP1_PARAMS_FIXED];
+}
+
 static inline void
 rkisp1_param_set_bits(struct rkisp1_params *params, u32 reg, u32 bit_mask)
 {
@@ -2244,12 +2255,12 @@ static int rkisp1_params_enum_fmt_meta_out(struct file 
*file, void *priv,
                                           struct v4l2_fmtdesc *f)
 {
        struct video_device *video = video_devdata(file);
-       struct rkisp1_params *params = video_get_drvdata(video);
 
-       if (f->index > 0 || f->type != video->queue->type)
+       if (f->index >= ARRAY_SIZE(rkisp1_params_formats) ||
+           f->type != video->queue->type)
                return -EINVAL;
 
-       f->pixelformat = params->metafmt->dataformat;
+       f->pixelformat = rkisp1_params_formats[f->index].dataformat;
 
        return 0;
 }
@@ -2264,9 +2275,40 @@ static int rkisp1_params_g_fmt_meta_out(struct file 
*file, void *fh,
        if (f->type != video->queue->type)
                return -EINVAL;
 
-       memset(meta, 0, sizeof(*meta));
-       meta->dataformat = params->metafmt->dataformat;
-       meta->buffersize = params->metafmt->buffersize;
+       *meta = *params->metafmt;
+
+       return 0;
+}
+
+static int rkisp1_params_try_fmt_meta_out(struct file *file, void *fh,
+                                         struct v4l2_format *f)
+{
+       struct video_device *video = video_devdata(file);
+       struct v4l2_meta_format *meta = &f->fmt.meta;
+
+       if (f->type != video->queue->type)
+               return -EINVAL;
+
+       *meta = *rkisp1_params_get_format_info(meta->dataformat);
+
+       return 0;
+}
+
+static int rkisp1_params_s_fmt_meta_out(struct file *file, void *fh,
+                                       struct v4l2_format *f)
+{
+       struct video_device *video = video_devdata(file);
+       struct rkisp1_params *params = video_get_drvdata(video);
+       struct v4l2_meta_format *meta = &f->fmt.meta;
+
+       if (f->type != video->queue->type)
+               return -EINVAL;
+
+       if (vb2_is_busy(video->queue))
+               return -EBUSY;
+
+       params->metafmt = rkisp1_params_get_format_info(meta->dataformat);
+       *meta = *params->metafmt;
 
        return 0;
 }
@@ -2296,8 +2338,8 @@ static const struct v4l2_ioctl_ops rkisp1_params_ioctl = {
        .vidioc_streamoff = vb2_ioctl_streamoff,
        .vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
        .vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
-       .vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
-       .vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
+       .vidioc_s_fmt_meta_out = rkisp1_params_s_fmt_meta_out,
+       .vidioc_try_fmt_meta_out = rkisp1_params_try_fmt_meta_out,
        .vidioc_querycap = rkisp1_params_querycap,
        .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
        .vidioc_unsubscribe_event = v4l2_event_unsubscribe,

Reply via email to