From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org, Sakari Ailus <sakari.ailus@iki.fi>,
Lars-Peter Clausen <lars@metafoo.de>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Martin Kepplinger <martink@posteo.de>,
Ricardo Ribalda <ribalda@kernel.org>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Manivannan Sadhasivam <mani@kernel.org>,
Michael Riesch <michael.riesch@wolfvision.net>,
Jacopo Mondi <jacopo@jmondi.org>,
Bingbu Cao <bingbu.cao@intel.com>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Hans de Goede <hansg@kernel.org>,
Tianshu Qiu <tian.shu.qiu@intel.com>,
Steve Longerbeam <slongerbeam@gmail.com>,
Nicholas Roth <nicholas@rothemail.net>,
Benjamin Mugnier <benjamin.mugnier@foss.st.com>,
Sylvain Petinot <sylvain.petinot@foss.st.com>,
Tim Harvey <tharvey@gateworks.com>,
Maxime Ripard <mripard@kernel.org>,
Eugen Hristev <eugen.hristev@collabora.com>,
Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
Dafna Hirschfeld <dafna@fastmail.com>,
Yong Deng <yong.deng@magewell.com>,
Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
Benoit Parrot <bparrot@ti.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Shuah Khan <skhan@linuxfoundation.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hugues Fruchet <hugues.fruchet@foss.st.com>,
Alain Volmat <alain.volmat@foss.st.com>
Subject: Re: [PATCH v4 1/1] media: v4l2-subdev: Rename .init_cfg() operation to .init_state()
Date: Wed, 29 Nov 2023 16:01:22 +0200 [thread overview]
Message-ID: <20231129140122.GE18109@pendragon.ideasonboard.com> (raw)
In-Reply-To: <a3bfe0e7-45de-41ce-b720-078f69cdcd69@xs4all.nl>
Hi Hans,
On Tue, Nov 28, 2023 at 09:55:06AM +0100, Hans Verkuil wrote:
> On 27/11/2023 10:07, Laurent Pinchart wrote:
> > The subdev .init_cfg() operation is affected by two issues:
> >
> > - It has long been extended to initialize a whole v4l2_subdev_state
> > instead of just a v4l2_subdev_pad_config, but its name has stuck
> > around.
> >
> > - Despite operating on a whole subdev state and not being directly
> > exposed to the subdev users (either in-kernel or through the userspace
> > API), .init_cfg() is categorized as a subdev pad operation.
> >
> > This participates in making the subdev API confusing for new developers.
> > Fix it by renaming the operation to .init_state(), and make it a subdev
> > internal operation.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Acked-by: Michael Riesch <michael.riesch@wolfvision.net> # for imx415
> > Acked-by: Shuah Khan <skhan@linuxfoundation.org> # for vimc
> > ---
> > Changes since v3:
> >
> > - Rebase on top of the new stm32-dcmipp driver
> > - Fix uninitialized variable in __v4l2_subdev_state_alloc() due to bad
> > rebase
> >
> > Changes since v2:
> >
> > - Rebase on top of the latest media tree
> >
> > Changes since v1:
> >
> > - Fix compilation of the vsp1 driver
> > ---
>
> <snip>
>
> > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_entity.c b/drivers/media/platform/renesas/vsp1/vsp1_entity.c
> > index 0280b8ff7ba9..0a5a7f9cc870 100644
> > --- a/drivers/media/platform/renesas/vsp1/vsp1_entity.c
> > +++ b/drivers/media/platform/renesas/vsp1/vsp1_entity.c
> > @@ -170,33 +170,6 @@ vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
> > }
> > }
> >
> > -/*
> > - * vsp1_entity_init_cfg - Initialize formats on all pads
> > - * @subdev: V4L2 subdevice
> > - * @sd_state: V4L2 subdev state
> > - *
> > - * Initialize all pad formats with default values in the given subdev state.
> > - * This function can be used as a handler for the subdev pad::init_cfg
> > - * operation.
> > - */
> > -int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
> > - struct v4l2_subdev_state *sd_state)
> > -{
> > - unsigned int pad;
> > -
> > - for (pad = 0; pad < subdev->entity.num_pads - 1; ++pad) {
> > - struct v4l2_subdev_format format = {
> > - .pad = pad,
> > - .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY
> > - : V4L2_SUBDEV_FORMAT_ACTIVE,
> > - };
> > -
> > - v4l2_subdev_call(subdev, pad, set_fmt, sd_state, &format);
> > - }
> > -
> > - return 0;
> > -}
> > -
> > /*
> > * vsp1_subdev_get_pad_format - Subdev pad get_fmt handler
> > * @subdev: V4L2 subdevice
> > @@ -424,6 +397,29 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
> > return ret;
> > }
> >
> > +static int vsp1_entity_init_state(struct v4l2_subdev *subdev,
> > + struct v4l2_subdev_state *sd_state)
> > +{
> > + unsigned int pad;
> > +
> > + /* Initialize all pad formats with default values. */
> > + for (pad = 0; pad < subdev->entity.num_pads - 1; ++pad) {
> > + struct v4l2_subdev_format format = {
> > + .pad = pad,
> > + .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY
> > + : V4L2_SUBDEV_FORMAT_ACTIVE,
> > + };
> > +
> > + v4l2_subdev_call(subdev, pad, set_fmt, sd_state, &format);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static const struct v4l2_subdev_internal_ops vsp1_entity_internal_ops = {
> > + .init_state = vsp1_entity_init_state,
> > +};
> > +
> > /* -----------------------------------------------------------------------------
> > * Media Operations
> > */
> > @@ -658,6 +654,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
> > /* Initialize the V4L2 subdev. */
> > subdev = &entity->subdev;
> > v4l2_subdev_init(subdev, ops);
> > + subdev->internal_ops = &vsp1_entity_internal_ops;
> >
> > subdev->entity.function = function;
> > subdev->entity.ops = &vsp1->media_ops;
> > @@ -666,7 +663,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
> > snprintf(subdev->name, sizeof(subdev->name), "%s %s",
> > dev_name(vsp1->dev), name);
> >
> > - vsp1_entity_init_cfg(subdev, NULL);
> > + vsp1_entity_init_state(subdev, NULL);
>
> This is the only media driver that calls init_cfg/state directly.
> That's a bit unexpected, and perhaps this could use a comment. That
> can be a follow-up patch as well.
I have already posted a patch series to drop all this and use the V4L2
subdev active state API. That is hopefully better than a comment :-)
There are actually quite a few sensor drivers that don't use the active
state, and call the .init_cfg() handler at probe time to initialize
their private copy of the active state. All this should eventually go
away as drivers are converter. I try to keep an eye when reviewing new
code and push all new drivers to use the subdev active state.
> >
> > /*
> > * Allocate the subdev state to store formats and selection
>
> In any case, you can add my:
>
> Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>
> to this patch.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-11-29 14:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 9:07 [PATCH v4 0/1] media: v4l2-subdev: Make .init_cfg() an internal operation Laurent Pinchart
2023-11-27 9:07 ` [PATCH v4 1/1] media: v4l2-subdev: Rename .init_cfg() operation to .init_state() Laurent Pinchart
2023-11-27 9:38 ` Tomi Valkeinen
2023-11-27 9:48 ` Philipp Zabel
2023-11-27 10:03 ` Alain Volmat
2023-11-27 11:27 ` Tommaso Merciai
2023-11-27 11:33 ` Laurent Pinchart
2023-11-27 11:48 ` Tommaso Merciai
2023-11-28 8:55 ` Hans Verkuil
2023-11-29 14:01 ` Laurent Pinchart [this message]
2023-11-29 13:51 ` Paul Kocialkowski
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=20231129140122.GE18109@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=alain.volmat@foss.st.com \
--cc=benjamin.mugnier@foss.st.com \
--cc=bingbu.cao@intel.com \
--cc=bparrot@ti.com \
--cc=dafna@fastmail.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=eugen.hristev@collabora.com \
--cc=hansg@kernel.org \
--cc=hugues.fruchet@foss.st.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jacopo@jmondi.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=lars@metafoo.de \
--cc=linux-media@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martink@posteo.de \
--cc=mchehab@kernel.org \
--cc=michael.riesch@wolfvision.net \
--cc=mripard@kernel.org \
--cc=nicholas@rothemail.net \
--cc=p.zabel@pengutronix.de \
--cc=paul.kocialkowski@bootlin.com \
--cc=ribalda@kernel.org \
--cc=rmfrfs@gmail.com \
--cc=sakari.ailus@iki.fi \
--cc=skhan@linuxfoundation.org \
--cc=slongerbeam@gmail.com \
--cc=sylvain.petinot@foss.st.com \
--cc=tharvey@gateworks.com \
--cc=tian.shu.qiu@intel.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=yong.deng@magewell.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