From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dan Scally <dan.scally@ideasonboard.com>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
Sakari Ailus <sakari.ailus@iki.fi>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Stefan Klug <stefan.klug@ideasonboard.com>,
Paul Elder <paul.elder@ideasonboard.com>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Umang Jain <umang.jain@ideasonboard.com>,
Dafna Hirschfeld <dafna@fastmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>
Subject: Re: [PATCH 4/8] media: rkisp1: Add support for ext format
Date: Wed, 12 Jun 2024 17:51:49 +0300 [thread overview]
Message-ID: <20240612145149.GA16379@pendragon.ideasonboard.com> (raw)
In-Reply-To: <f6279fd6-abe6-440b-9acc-e8641bba5252@ideasonboard.com>
On Wed, Jun 12, 2024 at 11:46:17AM +0100, Daniel Scally wrote:
> Hi Jacopo, thanks for the patch
>
> On 05/06/2024 17:54, Jacopo Mondi wrote:
> > Add support to the rkisp1 driver for the extensible parameters format.
> >
> > Allow the driver to enumerate the existing and the new format and
> > implement support for the try_fmt and s_fmt operations.
> >
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> Isn't this too early in the set? I'd expect this to come after the
> actual support for handling the extensible buffers was done.
Agreed.
> > ---
> > .../platform/rockchip/rkisp1/rkisp1-common.h | 1 +
> > .../platform/rockchip/rkisp1/rkisp1-params.c | 87 +++++++++++++++++--
> > 2 files changed, 79 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> > index 2a715f964f6e..0bddae8dbdb1 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h
> > @@ -383,6 +383,7 @@ struct rkisp1_params {
> > spinlock_t config_lock; /* locks the buffers list 'params' */
> > struct list_head params;
> >
> > + struct v4l2_meta_format metafmt;
This could be turned to a static const pointer, pointing to an entry
from rkisp1_params_formats, as none of the fields can be further
modified by userspace once a format is selected. Up to you.
> > enum v4l2_quantization quantization;
> > enum v4l2_ycbcr_encoding ycbcr_encoding;
> > enum rkisp1_fmt_raw_pat_type raw_type;
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> > index 1f449f29b241..6f99c7dad758 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> > @@ -33,6 +33,34 @@
> > #define RKISP1_ISP_CC_COEFF(n) \
> > (RKISP1_CIF_ISP_CC_COEFF_0 + (n) * 4)
> >
> > +enum rkisp1_params_formats {
> > + RKISP1_PARAMS_FIXED,
> > + RKISP1_PARAMS_EXTENSIBLE,
> > + RKISP1_PARAMS_NUM_FMT,
> > +};
> > +
> > +static const struct v4l2_meta_format rkisp1_params_formats[] = {
> > + [RKISP1_PARAMS_FIXED] = {
> > + .dataformat = V4L2_META_FMT_RK_ISP1_PARAMS,
> > + .buffersize = sizeof(struct rkisp1_params_cfg),
> > + },
> > + [RKISP1_PARAMS_EXTENSIBLE] = {
> > + .dataformat = V4L2_META_FMT_RK_ISP1_EXT_PARAMS,
> > + .buffersize = sizeof(struct rkisp1_ext_params_cfg),
> > + },
> > +};
> > +
> > +static const struct v4l2_meta_format *
> > +rkisp1_params_get_format_info(u32 dataformat)
> > +{
> > + for (unsigned int i = 0; i < RKISP1_PARAMS_NUM_FMT; i++) {
Use ARRAY_SIZE(rkisp1_params_formats) instead of RKISP1_PARAMS_NUM_FMT,
that's safer. Same below, and drop RKISP1_PARAMS_NUM_FMT
> > + 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)
> > {
> > @@ -1742,11 +1770,13 @@ static int rkisp1_params_enum_fmt_meta_out(struct file *file, void *priv,
> > struct v4l2_fmtdesc *f)
> > {
> > struct video_device *video = video_devdata(file);
> > + const struct v4l2_meta_format *metafmt;
> >
> > - if (f->index > 0 || f->type != video->queue->type)
> > + if (f->index >= RKISP1_PARAMS_NUM_FMT || f->type != video->queue->type)
> > return -EINVAL;
> >
> > - f->pixelformat = V4L2_META_FMT_RK_ISP1_PARAMS;
> > + metafmt = &rkisp1_params_formats[f->index];
> > + f->pixelformat = metafmt->dataformat;
You could drop the metafmt variable:
f->pixelformat = rkisp1_params_formats[f->index].dataformat;
> >
> > return 0;
> > }
> > @@ -1755,14 +1785,44 @@ static int rkisp1_params_g_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;
> >
> > memset(meta, 0, sizeof(*meta));
> > - meta->dataformat = V4L2_META_FMT_RK_ISP1_PARAMS;
> > - meta->buffersize = sizeof(struct rkisp1_params_cfg);
> > + *meta = params->metafmt;
You can drop the memset now that you assign the whole structure.
> > +
> > + 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;
> > +
> > + *meta = *rkisp1_params_get_format_info(meta->dataformat);
> > + params->metafmt = *meta;
> >
> > return 0;
> > }
> > @@ -1792,8 +1852,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,
> > @@ -1805,13 +1865,16 @@ static int rkisp1_params_vb2_queue_setup(struct vb2_queue *vq,
> > unsigned int sizes[],
> > struct device *alloc_devs[])
> > {
> > + struct rkisp1_params *params = vq->drv_priv;
> > + size_t buf_size = params->metafmt.buffersize;
> > +
> > *num_buffers = clamp_t(u32, *num_buffers,
> > RKISP1_ISP_PARAMS_REQ_BUFS_MIN,
> > RKISP1_ISP_PARAMS_REQ_BUFS_MAX);
> >
> > *num_planes = 1;
> >
> > - sizes[0] = sizeof(struct rkisp1_params_cfg);
> > + sizes[0] = buf_size;
>
> sizes[0] = params->metafmt.buffersize; would save a variable - up to you.
>
> >
> > return 0;
> > }
> > @@ -1831,10 +1894,14 @@ static void rkisp1_params_vb2_buf_queue(struct vb2_buffer *vb)
> >
> > static int rkisp1_params_vb2_buf_prepare(struct vb2_buffer *vb)
> > {
> > - if (vb2_plane_size(vb, 0) < sizeof(struct rkisp1_params_cfg))
> > + struct vb2_queue *vq = vb->vb2_queue;
> > + struct rkisp1_params *params = vq->drv_priv;
> > + size_t buf_size = params->metafmt.buffersize;
> > +
> > + if (vb2_plane_size(vb, 0) < buf_size)
> > return -EINVAL;
> >
> > - vb2_set_plane_payload(vb, 0, sizeof(struct rkisp1_params_cfg));
> > + vb2_set_plane_payload(vb, 0, buf_size);
> >
> > return 0;
> > }
> > @@ -1929,6 +1996,8 @@ int rkisp1_params_register(struct rkisp1_device *rkisp1)
> > else
> > params->ops = &rkisp1_v10_params_ops;
> >
> > + params->metafmt = rkisp1_params_formats[RKISP1_PARAMS_FIXED];
> > +
> > video_set_drvdata(vdev, params);
> >
> > node->pad.flags = MEDIA_PAD_FL_SOURCE;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2024-06-12 14:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 16:54 [PATCH 0/8] media: rkisp1: Implement support for extensible parameters Jacopo Mondi
2024-06-05 16:54 ` [PATCH 1/8] uapi: rkisp1-config: Add extensible parameters format Jacopo Mondi
2024-06-12 10:02 ` Dan Scally
2024-06-12 12:56 ` Laurent Pinchart
2024-06-12 13:49 ` Dan Scally
2024-06-12 14:56 ` Laurent Pinchart
2024-06-19 12:44 ` Jacopo Mondi
2024-06-19 15:49 ` Laurent Pinchart
2024-06-05 16:54 ` [PATCH 2/8] uapi: videodev2: Add V4L2_META_FMT_RK_ISP1_EXT_PARAMS Jacopo Mondi
2024-06-12 10:00 ` Dan Scally
2024-06-12 14:35 ` Laurent Pinchart
2024-06-12 15:09 ` Dan Scally
2024-06-20 9:31 ` Paul Elder
2024-06-05 16:54 ` [PATCH 3/8] media: rkisp1: Remove cached format info Jacopo Mondi
2024-06-12 10:06 ` Dan Scally
2024-06-12 14:47 ` Laurent Pinchart
2024-06-20 9:41 ` Paul Elder
2024-06-05 16:54 ` [PATCH 4/8] media: rkisp1: Add support for ext format Jacopo Mondi
2024-06-12 10:46 ` Dan Scally
2024-06-12 14:51 ` Laurent Pinchart [this message]
2024-06-05 16:54 ` [PATCH 5/8] media: rkisp1: Implement extensible params support Jacopo Mondi
2024-06-12 13:50 ` Dan Scally
2024-06-12 15:42 ` Laurent Pinchart
2024-06-19 15:46 ` Jacopo Mondi
2024-06-19 16:09 ` Laurent Pinchart
2024-06-05 16:54 ` [PATCH 6/8] media: rkisp1: Propagate pre/post-config errors Jacopo Mondi
2024-06-12 13:35 ` Dan Scally
2024-06-12 15:46 ` Laurent Pinchart
2024-06-05 16:54 ` [PATCH 7/8] media: rkisp1: Add struct rkisp1_params_buffer Jacopo Mondi
2024-06-12 13:52 ` Dan Scally
2024-06-05 16:54 ` [PATCH 8/8] media: rkisp1: Copy and validate parameters buffer Jacopo Mondi
2024-06-12 14:28 ` Dan Scally
2024-06-12 16:20 ` Laurent Pinchart
2024-06-19 14:22 ` Jacopo Mondi
2024-06-19 15:44 ` Laurent Pinchart
2024-06-19 15:55 ` Jacopo Mondi
2024-06-19 16:11 ` Laurent Pinchart
2024-06-19 16:20 ` Jacopo Mondi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612145149.GA16379@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dafna@fastmail.com \
--cc=dan.scally@ideasonboard.com \
--cc=heiko@sntech.de \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jacopo.mondi@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=paul.elder@ideasonboard.com \
--cc=sakari.ailus@iki.fi \
--cc=stefan.klug@ideasonboard.com \
--cc=umang.jain@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.