From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org, Sakari Ailus <sakari.ailus@iki.fi>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Hans de Goede <hansg@kernel.org>
Subject: Re: [RFC PATCH v1 3/4] media: v4l2-subdev: Store frame interval in subdev state
Date: Tue, 24 Oct 2023 10:38:08 +0300 [thread overview]
Message-ID: <20231024073808.GA5121@pendragon.ideasonboard.com> (raw)
In-Reply-To: <ae1af16e-eb25-4c37-8d6e-16a910a4fa9a@ideasonboard.com>
Hi Tomi,
On Tue, Oct 24, 2023 at 10:21:18AM +0300, Tomi Valkeinen wrote:
> On 24/10/2023 03:51, Laurent Pinchart wrote:
> > Subdev states store all standard pad configuration data, except for
> > frame intervals. Fix it by adding interval fields in the
> > v4l2_subdev_pad_config and v4l2_subdev_stream_config structures, with
> > corresponding accessor functions and a helper function to implement the
> > .get_frame_interval() operation.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > drivers/media/v4l2-core/v4l2-subdev.c | 44 +++++++++++++++++++++
> > include/media/v4l2-subdev.h | 57 +++++++++++++++++++++++++++
> > 2 files changed, 101 insertions(+)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> > index c45d60a87701..518f2f35c68d 100644
> > --- a/drivers/media/v4l2-core/v4l2-subdev.c
> > +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> > @@ -1618,6 +1618,29 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
> > }
> > EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
> >
> > +int v4l2_subdev_get_frame_interval(struct v4l2_subdev *sd,
> > + struct v4l2_subdev_state *state,
> > + struct v4l2_subdev_frame_interval *fi)
> > +{
> > + struct v4l2_fract *interval;
> > +
> > + if (sd->flags & V4L2_SUBDEV_FL_STREAMS)
> > + interval = v4l2_subdev_state_get_stream_interval(state, fi->pad,
> > + fi->stream);
> > + else if (fi->pad < sd->entity.num_pads && fi->stream == 0)
> > + interval = v4l2_subdev_get_pad_interval(sd, state, fi->pad);
> > + else
> > + interval = NULL;
> > +
> > + if (!interval)
> > + return -EINVAL;
> > +
> > + fi->interval = *interval;
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(v4l2_subdev_get_frame_interval);
> > +
> > int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
> > struct v4l2_subdev_state *state,
> > const struct v4l2_subdev_krouting *routing)
> > @@ -1761,6 +1784,27 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
> > }
> > EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
> >
> > +struct v4l2_fract *
> > +v4l2_subdev_state_get_stream_interval(struct v4l2_subdev_state *state,
> > + unsigned int pad, u32 stream)
> > +{
> > + struct v4l2_subdev_stream_configs *stream_configs;
> > + unsigned int i;
> > +
> > + lockdep_assert_held(state->lock);
> > +
> > + stream_configs = &state->stream_configs;
> > +
> > + for (i = 0; i < stream_configs->num_configs; ++i) {
> > + if (stream_configs->configs[i].pad == pad &&
> > + stream_configs->configs[i].stream == stream)
> > + return &stream_configs->configs[i].interval;
> > + }
> > +
> > + return NULL;
> > +}
> > +EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_interval);
> > +
> > int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
> > u32 pad, u32 stream, u32 *other_pad,
> > u32 *other_stream)
> > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> > index 962b546d0e3b..363f9a8a084c 100644
> > --- a/include/media/v4l2-subdev.h
> > +++ b/include/media/v4l2-subdev.h
> > @@ -681,11 +681,13 @@ struct v4l2_subdev_ir_ops {
> > * @format: &struct v4l2_mbus_framefmt
> > * @crop: &struct v4l2_rect to be used for crop
> > * @compose: &struct v4l2_rect to be used for compose
> > + * @interval: frame interval
> > */
> > struct v4l2_subdev_pad_config {
> > struct v4l2_mbus_framefmt format;
> > struct v4l2_rect crop;
> > struct v4l2_rect compose;
> > + struct v4l2_fract interval;
> > };
> >
> > /**
> > @@ -697,6 +699,7 @@ struct v4l2_subdev_pad_config {
> > * @fmt: &struct v4l2_mbus_framefmt
> > * @crop: &struct v4l2_rect to be used for crop
> > * @compose: &struct v4l2_rect to be used for compose
> > + * @interval: frame interval
> > *
> > * This structure stores configuration for a stream.
> > */
> > @@ -708,6 +711,7 @@ struct v4l2_subdev_stream_config {
> > struct v4l2_mbus_framefmt fmt;
> > struct v4l2_rect crop;
> > struct v4l2_rect compose;
> > + struct v4l2_fract interval;
> > };
> >
> > /**
> > @@ -1199,6 +1203,26 @@ v4l2_subdev_get_pad_compose(struct v4l2_subdev *sd,
> > return &state->pads[pad].compose;
> > }
> >
> > +/**
> > + * v4l2_subdev_get_pad_interval - ancillary routine to get
> > + * &struct v4l2_subdev_pad_config->interval
> > + *
> > + * @sd: pointer to &struct v4l2_subdev
> > + * @state: pointer to &struct v4l2_subdev_state.
> > + * @pad: index of the pad in the &struct v4l2_subdev_state->pads array.
> > + */
> > +static inline struct v4l2_fract *
> > +v4l2_subdev_get_pad_interval(struct v4l2_subdev *sd,
> > + struct v4l2_subdev_state *state,
> > + unsigned int pad)
> > +{
> > + if (WARN_ON(!state))
> > + return NULL;
> > + if (WARN_ON(pad >= sd->entity.num_pads))
> > + pad = 0;
> > + return &state->pads[pad].interval;
> > +}
> > +
> > /*
> > * Temprary helpers until uses of v4l2_subdev_get_try_* functions have been
> > * renamed
> > @@ -1489,6 +1513,24 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd)
> > int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
> > struct v4l2_subdev_format *format);
> >
> > +/**
> > + * v4l2_subdev_get_frame_interval() - Fill frame interval based on state
> > + * @sd: subdevice
> > + * @state: subdevice state
> > + * @fi: pointer to &struct v4l2_subdev_frame_interval
> > + *
> > + * Fill @fi->interval field based on the information in the @fi struct.
> > + *
> > + * This function can be used by the subdev drivers which support active state to
> > + * implement v4l2_subdev_pad_ops.get_frame_interval if the subdev driver does
> > + * not need to do anything special in their get_frame_interval op.
>
> What would the "something special" be? Can we instead just say that the
> framework will return the frame interval from the state for drivers that
> support active state (similar to get-routing)? Or perhaps that's not a
> wise thing to do for old operations...
I've copied that text from v4l2_subdev_get_fmt(). I'm fine changing it,
if both say the same. If you send a patch to improve the documentation
of v4l2_subdev_get_fmt(), I'll update this patch :-)
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-10-24 7:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 0:51 [RFC PATCH v1 0/4] media: v4l2-subdev: Improve frame interval handling Laurent Pinchart
2023-10-24 0:51 ` [RFC PATCH v1 1/4] media: v4l2-subdev: Turn .[gs]_frame_interval into pad operations Laurent Pinchart
2023-10-24 0:51 ` [RFC PATCH v1 2/4] media: v4l2-subdev: Add which field to struct v4l2_subdev_frame_interval Laurent Pinchart
2023-10-24 7:11 ` Tomi Valkeinen
2023-11-26 0:08 ` Laurent Pinchart
2023-10-24 0:51 ` [RFC PATCH v1 3/4] media: v4l2-subdev: Store frame interval in subdev state Laurent Pinchart
2023-10-24 7:21 ` Tomi Valkeinen
2023-10-24 7:38 ` Laurent Pinchart [this message]
2023-10-24 7:40 ` Tomi Valkeinen
2023-11-27 10:39 ` Laurent Pinchart
2023-10-24 0:51 ` [RFC PATCH v1 4/4] media: i2c: thp7312: " Laurent Pinchart
2023-10-24 7:31 ` [RFC PATCH v1 0/4] media: v4l2-subdev: Improve frame interval handling Tomi Valkeinen
2023-10-24 7:39 ` Laurent Pinchart
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=20231024073808.GA5121@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hansg@kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@iki.fi \
--cc=tomi.valkeinen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox