mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: johannes.goede@oss.qualcomm.com
To: Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: "Cédric Bellegarde" <cedric.bellegarde@adishatz.org>,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	phone-devel@vger.kernel.org,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Hans Verkuil" <hans@jjverkuil.nl>
Subject: Re: [PATCH] media: v4l2-async: link ancillary device runtime PM to the sensor's
Date: Mon, 30 Nov 2026 18:07:15 +0100	[thread overview]
Message-ID: <4ebba595-7343-4cab-9e78-7aa07535cbbd@oss.qualcomm.com> (raw)
In-Reply-To: <CAPY8ntCb21q85iGgjemUJnHbKkjWvhMraweaUHiKzEWoxW+kAg@mail.gmail.com>

Hi Dave,

On 30-Nov-26 17:38, Dave Stevenson wrote:
> Hi Sakari and others.
> 
> On Fri, 27 Nov 2026 at 17:33, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
>>
>> Hi Cédric,
>>
>> On Thu, Nov 26, 2026 at 07:23:32AM +0100, Cédric Bellegarde wrote:
>>> Hello,
>>>
>>> Le 25/09/2026 à 13:15, Sakari Ailus a écrit :
>>>> Hi Kieran,
>>>>
>>>> On Wed, Sep 23, 2026 at 07:58:21AM +0100, Kieran Bingham wrote:
>>>>> Quoting Sakari Ailus (2026-09-23 07:34:54)
>>>>>> Hi C�dric,
>>>>>>
>>>>>> On Tue, Sep 22, 2026 at 09:39:12PM +0200, C�dric Bellegarde wrote:
>>>>>>> When a sensor's fwnode references an ancillary lens or flash device
>>>>>>> (e.g. via the "lens-focus" or "flash-leds" properties),
>>>>>>> v4l2_async_create_ancillary_links() already creates a media controller
>>>>>>> link between the two entities, but their runtime PM states remain
>>>>>>> independent.
>>>>>>>
>>>>>>> This is a problem for devices such as VCM lens actuators, which are
>>>>>>> typically spring-loaded: holding a position away from the spring's
>>>>>>> rest point requires continuous power, and the position is not retained
>>>>>>> once power is cut. If such an actuator is allowed to runtime-suspend
>>>>>>> independently of the sensor, the lens can drift back to its rest
>>>>>>> position during an otherwise active capture session.
>>>>>>>
>>>>>>> Add V4L2_SUBDEV_FL_PM_LINK to allow an ancillary subdevice to request
>>>>>>> that its runtime PM state be linked to the associated sensor.
>>>>>>
>>>>>> Interesting idea.
>>>>>>
>>>>>> The IPU bridge has created such a device link between the VCM and the
>>>>>> sensor as on some ACPI systems the VCM is in fact relying on the power
>>>>>> resources of the sensor. But to do this everywhere?
>>>>>
>>>>> Same on any Raspberry Pi camera module. The VCM is powered by the same
>>>>> enable lines as the Sensor there I think which has made things
>>>>> interesting in handling VCMs for those devices.
>>>>
>>>> Yes, this has been an issue in DT for a long time. :-( I'm not sure if this
>>>> approach could extend into a solution for that though.
> 
> It was a related issue that I've cheated on downstream. I added a
> regulator notifier hook so that if the shared regulator is powered up
> then the lens position is restored to the programmed position, so you
> can capture in-focus images without worrying about the lens driver
> subdev.
> If only the lens driver subdev is opened then that will power up the
> sensor as well, but normally it'll sit in standby mode until told to
> do otherwise over I2C.
> 
> I know it's not acceptable to mainline as I'm relying on there being a
> common regulator, but it was a pragmatic solution for those not using
> libcamera on the Pi.
> 
> I'd not noticed that libcamera keeps the lens node open, so I guess we
> will still get hit by that issue and it'll keep the regulators powered
> up but the sensor in standby.
> 
>>>>>
>>>>>
>>>>>> VCMs traditionally have been powered through opening their sub-device node
>>>>>> and that hasn't been exactly neat API-wise. It has been practical still,
>>>>>> AFAIK, as in order to control the VCM, you have to have a sub-device node
>>>>>> open.
>>>>>
>>>>> This is an issue though, as libcamera opens the device nodes and holds
>>>>> the file descriptor when it has a camera. This means that even if the
>>>>> camera isn't streaming, the VCM is powered on and causes power
>>>>> consumption on mobile devices which people then attribute to pipewire.
>>>>
>>>> A practical fix for that could be to set the current to 0 when streaming is
>>>> off.
>>>
>>> For the zero-current route: lens subdevs have no s_stream, so how would the
>>> VCM driver learn that streaming stopped? The device link gets this from
>>
>> libcamera would have to do that. I don't see why it couldn't.
> 
> I'm going to play devil's advocate here. This is still "Video 4 Linux
> 2", not "Video for Libcamera 2" (I'm waiting for the proposal of a
> name change).
> Mandating that the use of a VCM requires using libcamera would be quite a step.
> Then again it's libcamera that is keeping the lens driver open and
> causing problems in the first place, so fixing it there is likely
> valid.
> 
> It's worth noting that devices like DW9817 are bidirectional driver
> ICs for +/-100mA drive. So the zero current V4L2_CID_FOCUS_ABSOLUTE
> value would be 512 (of 0-1023) and not 0.
> Is it better to add a new control to the VCM subdev that gives
> userspace a device agnostic zero current power down? The driver can
> then take whatever steps to adopt a minimal current state is
> appropriate for the particular driver IC (probably with ramping to
> avoid "ticks" as lenses hit endstops).

Interesting timing on your reply, I just did a top-level reply
today in this thread with what hopefully can be a solution which works
for everyone:

https://lore.kernel.org/linux-media/462ca475-5b95-4804-83b9-15e7040a9997@oss.qualcomm.com/

TL;DR: I believe that the sensor + VCM should be treated as a single
entity from a power-management pov, with all power-management controlled
by the sensor driver.

The idea being that proper sensor drivers already turn the sensor on
when streaming and off when they are done streaming and with a runtime-pm
link we can simply make the runtime-pm framework turn on the VCM when
ever the sensor runtime-resumes.

See my reply for some more details.

Regards,

Hans



  reply	other threads:[~2026-11-30 17:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 19:39 Cédric Bellegarde
2026-09-23  6:34 ` Sakari Ailus
2026-09-23  6:58   ` Kieran Bingham
2026-09-25 11:15     ` Sakari Ailus
2026-11-26  6:23       ` Cédric Bellegarde
2026-11-27 17:33         ` Sakari Ailus
2026-11-30 16:38           ` Dave Stevenson
2026-11-30 17:07             ` johannes.goede [this message]
2026-11-30 14:42 ` Hans de Goede

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=4ebba595-7343-4cab-9e78-7aa07535cbbd@oss.qualcomm.com \
    --to=johannes.goede@oss.qualcomm.com \
    --cc=cedric.bellegarde@adishatz.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hans@jjverkuil.nl \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.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®