mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tommaso Merciai <tomm.merciai@gmail.com>,
	jacopo.mondi@ideasonboard.com, martin.hecht@avnet.eu,
	linuxfancy@googlegroups.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Marco Felsch <m.felsch@pengutronix.de>,
	Gerald Loacker <gerald.loacker@wolfvision.net>,
	Nicholas Roth <nicholas@rothemail.net>,
	Shawn Tu <shawnx.tu@intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Benjamin Mugnier <benjamin.mugnier@foss.st.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Subject: Re: [PATCH v2 2/2] media: i2c: Add support for alvium camera
Date: Tue, 13 Jun 2023 12:00:34 +0000	[thread overview]
Message-ID: <ZIhaYk1v69Sp+Xqd@kekkonen.localdomain> (raw)
In-Reply-To: <20230602043126.GM22609@pendragon.ideasonboard.com>

Hi Laurent, Tommaso,

On Fri, Jun 02, 2023 at 07:31:26AM +0300, Laurent Pinchart wrote:
> > > > > > diff --git a/drivers/media/i2c/alvium.c b/drivers/media/i2c/alvium.c
> > > > > > new file mode 100644
> > > > > > index 000000000000..e77fb6bda64b
> > > > > > --- /dev/null
> > > > > > +++ b/drivers/media/i2c/alvium.c
> > > > > > @@ -0,0 +1,3547 @@
> 
> [snip]
> 
> > > > > > +static int alvium_probe(struct i2c_client *client)
> > > > > > +{
> > > > > > +	struct device *dev = &client->dev;
> > > > > > +	struct v4l2_subdev *sd;
> > > > > > +	struct alvium_dev *alvium;
> > > > > > +	int ret;
> > > > > > +
> > > > > > +	alvium = devm_kzalloc(dev, sizeof(*alvium), GFP_KERNEL);
> > > > > > +	if (!alvium)
> > > > > > +		return -ENOMEM;
> > > > > > +
> > > > > > +	alvium->i2c_client = client;
> > > > > > +	ret = alvium_get_dt_data(alvium);
> > > > > > +	if (ret)
> > > > > > +		return ret;
> > > > > > +
> > > > > > +	mutex_init(&alvium->lock);
> > > > > > +
> > > > > > +	sd = &alvium->sd;
> > > > > > +
> > > > > > +	/* init alvium sd */
> > > > > > +	v4l2_i2c_subdev_init(sd, client, &alvium_subdev_ops);
> > > > > > +
> > > > > > +	sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
> > > > > > +	alvium->pad.flags = MEDIA_PAD_FL_SOURCE;
> > > > > > +	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
> > > > > > +	sd->entity.ops = &alvium_sd_media_ops;
> > > > > > +
> > > > > > +	ret = media_entity_pads_init(&sd->entity, 1, &alvium->pad);
> > > > > > +	if (ret)
> > > > > > +		return ret;
> > > > > > +
> > > > > > +	sd->dev = dev;
> > > > > > +
> > > > > > +	ret = alvium_power_on(alvium);
> > > > > 
> > > > > The driver should use runtime PM (with autosuspend), and power on/off in
> > > > > the .s_stream() handler.
> > > > 
> > > > Can we delay the pm implementation as a future patchset?
> > > > Alvium pm would be tricky (cause is the boot time of the camera)
> > > > and if is possible I want work on pm later.
> > > > Let me know. Thanks! :)
> > > 
> > > With autosuspend the camera can remain powered up between stream stop
> > > and stream start, if they happen quickly enough. An autosuspend delay of
> > > a few seconds is usually a good value. It should be fairly easy to
> > > implement runtime PM support, you just need to
> > > 
> > > - Call alvium_power_on() from the runtime PM resume handler and
> > >   alvium_power_off() from the runtime PM suspend handler.
> > > 
> > > - Call pm_runtime_resume_and_get() and stream on time, and
> > >   pm_runtime_mark_last_busy() and pm_runtime_put_autosuspend() at stream
> > >   stop time.
> > > 
> > > - Initialize runtime PM at probe time (and clean up at remove time).
> > >   There's a bit of boilerplate code needed to get that right, but it's
> > >   not difficult. You can copy it from the imx290 driver.
> > 
> > Back to you to clarify this point.
> > 
> > Plan as you suggest is handling pm of camera using external
> > regulator. Problem is that the boot time of the camera is around 5s.
> 
> 5s ? Ouch !!
> 
> This has two consequences:
> 
> - Just probing the camera would take 5s, which is insanely long.
> - There will be a 5s delay when starting video capture.
> 
> There's no 5s delay in the current code, so I assume things work fine
> because the power regulator is always on, and turned on 5s or more
> before the driver is loaded. That's pretty fragile.
> 
> That camera is clearly not a good fit for an embedded system that cares
> about power consumption and performance, but we still have to support
> it. The probe time issue isn't something we can fix, a 5s delay is
> required.
> 
> The stream start issue can be alleviated by keeping the camera on, or
> offering a way for userspace to turn it on ahead of stream start.
> Runtime PM autosuspend will help with the former, and I would push the
> autosuspend delay up as a result of the huge camera boot time. We don't
> have a good solution of the latter at the moment, it used to be that
> opening video nodes would power up the whole pipeline, but that has been
> dropped some time ago in V4L2. Another API extension for this kind of

And that was never a good solution.

> use cases would be useful I think. Sakari, any opinion ?

I'd approach this with autosuspend, but going forward we could research
adding an API for V4L2 sub-devices to access PM QoS. This way the device
could be powered down while the user would have a way to ensure resuming
the device wouldn't take excessively long.

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2023-06-13 12:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 17:39 [PATCH v2 0/2] " Tommaso Merciai
2023-05-26 17:39 ` [PATCH v2 1/2] media: dt-bindings: alvium: add document YAML binding Tommaso Merciai
2023-05-26 19:00   ` Conor Dooley
2023-05-29  7:22     ` Tommaso Merciai
2023-05-28 21:16   ` Sakari Ailus
2023-05-29  6:39     ` Laurent Pinchart
2023-05-29  6:43       ` Laurent Pinchart
2023-05-31 10:20         ` Tommaso Merciai
2023-05-31 11:06           ` Laurent Pinchart
2023-05-31 14:01             ` Tommaso Merciai
2023-05-31 14:36               ` Laurent Pinchart
2023-05-29  7:57       ` Tommaso Merciai
2023-05-29  8:07         ` Laurent Pinchart
2023-05-29  7:41     ` Tommaso Merciai
2023-05-29  7:51       ` Laurent Pinchart
2023-05-30 15:53   ` Krzysztof Kozlowski
2023-05-26 17:39 ` [PATCH v2 2/2] media: i2c: Add support for alvium camera Tommaso Merciai
2023-05-26 18:39   ` Christophe JAILLET
2023-05-29 10:08     ` Tommaso Merciai
2023-05-29 12:34       ` Christophe JAILLET
2023-05-29 13:26         ` Tommaso Merciai
2023-05-29  7:40   ` Laurent Pinchart
2023-05-31 10:13     ` Tommaso Merciai
2023-05-31 11:33       ` Laurent Pinchart
2023-05-31 14:19         ` Tommaso Merciai
2023-05-31 14:42           ` Laurent Pinchart
2023-05-31 15:12             ` Tommaso Merciai
2023-06-01 17:05         ` Tommaso Merciai
2023-06-02  4:31           ` Laurent Pinchart
2023-06-13 12:00             ` Sakari Ailus [this message]
2023-06-13 13:24               ` Tommaso Merciai
2023-05-30 20:56   ` kernel test robot

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=ZIhaYk1v69Sp+Xqd@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=broonie@kernel.org \
    --cc=gerald.loacker@wolfvision.net \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxfancy@googlegroups.com \
    --cc=m.felsch@pengutronix.de \
    --cc=martin.hecht@avnet.eu \
    --cc=mchehab@kernel.org \
    --cc=nicholas@rothemail.net \
    --cc=robh+dt@kernel.org \
    --cc=shawnx.tu@intel.com \
    --cc=tomm.merciai@gmail.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

all inboxes | Powered by JetHome®