public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	Yunke Cao <yunkec@chromium.org>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH v2 0/6] media: uvcvideo: Implement the Privacy GPIO as a subdevice
Date: Sun, 10 Nov 2024 13:46:08 +0100	[thread overview]
Message-ID: <20241110134608.6e82f851@foz.lan> (raw)
In-Reply-To: <CANiDSCvYo8=x_QAeg0_S=_H=R1EgM9xLUy4DXURcuEadYcQjQQ@mail.gmail.com>

Em Sun, 10 Nov 2024 11:32:16 +0100
Ricardo Ribalda <ribalda@chromium.org> escreveu:

> Hi Mauro
> 
> On Sun, 10 Nov 2024 at 11:03, Mauro Carvalho Chehab
> <mchehab+huawei@kernel.org> wrote:
> >
> > Em Sat, 9 Nov 2024 17:29:54 +0100
> > Ricardo Ribalda <ribalda@chromium.org> escreveu:
> >  
> > > >
> > > > I think that should sort the issue, assuming that 1. above holds true.
> > > >
> > > > One downside is that this stops UVC button presses from working when
> > > > not streaming. But userspace will typically only open the /dev/video#
> > > > node if it plans to stream anyways so there should not be much of
> > > > a difference wrt button press behavior.  
> > >
> > > I do not personally use the button, but it is currently implemented as
> > > a standard HID device.  
> >
> > IMO, controlling the privacy via evdev is the best approach then. There's
> > no need for a RW control neither at subdev or at device level. It could
> > make sense a Read only to allow apps to read, but still it shall be up to
> > the Kernel to protect the stream if the button is pressed.
> >  
> > > Making it only work during streamon() might be
> > > a bit weird.
> > > I am afraid that if there is a button we should keep the current behaviour.  
> >
> > Privacy matters only when streaming. IMO the Kernel check for it needs to
> > be done at DQBUF time and at read() calls, as one can enable/disable the
> > camera while doing videoconf calls. I do that a lot with app "soft" buttons,
> > and on devices that physically support cutting the video.
> >
> > I don't trust myself privacy soft buttons, specially when handled in userspace,
> > so what I have are webcam covers (and a small stick glued at a laptop camera
> > that has a too small sensor for a webcam cover). I only remove the cover/stick
> > when I want to participate on videoconf with video enabled with the builtin
> > camera.
> >
> > Regards  
> 
> I think we are mixing up concepts here.
> 
> On one side we have the uvc button. You can see one here
> https://www.sellpy.dk/item/2Yk1ZULbki?utm_source=google&utm_medium=cpc&utm_campaign=17610409619&gad_source=1&gclid=Cj0KCQiA0MG5BhD1ARIsAEcZtwR9-09ZtTIVNbVknrZCtCd7ezVM8YFw1yQXfs81FWhofg9eW-iBrsIaAopVEALw_wcB
> That button is not represented as a hid device. We do not know how the
> user will use this button. They could even use it to start an app when
> pressed.

Old cameras have a <snapshot> button. Maybe that's the case of the device
you're pointing, as it looks some non-uvc Logitech cameras I have myself.

> On the other side we have  the privacy gpio. The chassis has a switch
> that is connected to the camera and to the SOC. You can see one here:
> https://support.hp.com/ie-en/document/ish_3960099-3335046-16 .We link
> the camera with a gpio via the acpi table. When the user flips the
> button, the camera produces black frames and the SOC gets an IRQ. 

OK, so the hardware warrants black frames. Sounds a more secure
implementation.

> The IRQ is used to display a message like "Camera off" and the value of
> the GPIO can be checked when an app is running to tell the user:
> "Camera not available, flip the privacy button if you want to use it."

So, it is not really a privacy gpio/control. It is instead a privacy
notification control.

I would better name it to clearly indicate what it is about.

> Userspace cannot change the value of the gpio. It is read-only,
> userspace cannot override the privacy switch. The privacy gpio is
> represented with a control in /dev/videoX This patchset wants to move
> it to /dev/v4l2-subdevX

Well, if it is really a gpio pin, kernel (and eventually userspace) can force
it to pullup (or pulldown) state, forcing one of the states. If, instead is 
an output-only pin, kernel/userspace can't control it at all.

> To make things more complicated. Recently some cameras are starting to
> have their own privacy control without the need of an external gpio.
> This is also represented as a control in /dev/videoX.

IMO, both privacy notification events shall be reported the same way,
no matter if they use GPIO, an input pin or something else.

> Now that we have these 3 concepts in place:
> 
> Today a uvc camera is powered up when /dev/videoX is open(), not when
> it is streaming.

Ideally, the part of the hardware responsible for streaming shall be
powered on only while streaming. I agree with Hans de Goede: better
have this fixed before the privacy notification patches.

> This means that if we want to get an event for the
> privacy gpio we have to powerup the camera, which results in power
> consumption. This can be fixed by moving the control to a subdevice
> (technically the gpio is not part of the camera, so it makes sense).

Ok, but as you said, not all cameras implement it as a separate gpio.

> If we only powerup the camera during streamon we will break the uvc
> button, and the async controls.

Why? IMO, it shall use regmap in a way that the register settings
will be sent to the device only when the camera control hardware is
powered up. On a complex device, there are likely at least two power
up hardware: the camera control logic and the streaming logic.

Not sure if both are visible via UVC spec, though.

Thanks,
Mauro

  parent reply	other threads:[~2024-11-10 12:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 20:25 [PATCH v2 0/6] media: uvcvideo: Implement the Privacy GPIO as a subdevice Ricardo Ribalda
2024-11-08 20:25 ` [PATCH v2 1/6] media: uvcvideo: Factor out gpio functions to its own file Ricardo Ribalda
2024-11-08 20:25 ` [PATCH v2 2/6] media: uvcvideo: Re-implement privacy GPIO as a separate subdevice Ricardo Ribalda
2024-11-08 20:25 ` [PATCH v2 3/6] Revert "media: uvcvideo: Allow entity-defined get_info and get_cur" Ricardo Ribalda
2024-11-08 20:25 ` [PATCH v2 4/6] media: uvcvideo: Create ancillary link for GPIO subdevice Ricardo Ribalda
2024-11-10 10:05   ` Sakari Ailus
2024-11-08 20:25 ` [PATCH v2 5/6] media: v4l2-core: Add new MEDIA_ENT_F_GPIO Ricardo Ribalda
2024-11-08 20:25 ` [PATCH v2 6/6] media: uvcvideo: Use MEDIA_ENT_F_GPIO for the GPIO entity Ricardo Ribalda
2024-11-09 14:04 ` [PATCH v2 0/6] media: uvcvideo: Implement the Privacy GPIO as a subdevice Mauro Carvalho Chehab
2024-11-09 14:57   ` Ricardo Ribalda
2024-11-09 15:37 ` Hans de Goede
2024-11-09 16:29   ` Ricardo Ribalda
2024-11-10 10:02     ` Mauro Carvalho Chehab
2024-11-10 10:29       ` Hans Verkuil
2024-11-10 10:37         ` Ricardo Ribalda
2024-11-10 10:47           ` Hans Verkuil
2024-11-10 12:48           ` Mauro Carvalho Chehab
2024-11-10 10:32       ` Ricardo Ribalda
2024-11-10 10:59         ` Ricardo Ribalda
2024-11-10 12:46         ` Mauro Carvalho Chehab [this message]
2024-11-10 16:01           ` Ricardo Ribalda
2024-11-10 15:14     ` Laurent Pinchart
2024-11-10 16:04       ` Ricardo Ribalda
2024-11-25 12:31         ` Hans de Goede
2024-11-25 12:56           ` Laurent Pinchart
2024-11-25 13:35             ` Hans de Goede
2024-11-10 16:07       ` Ricardo Ribalda
2024-11-25 12:39         ` Hans de Goede
2024-11-25 12:58           ` Laurent Pinchart
2024-11-25 13:44             ` Hans de Goede
2024-11-25 13:50               ` Ricardo Ribalda
2024-11-11 12:03     ` Hans de Goede
2024-11-25 12:25     ` Hans de Goede
2024-11-25 12:49       ` Laurent Pinchart
2024-11-25 13:29         ` Hans de Goede
2024-11-26 17:22           ` Laurent Pinchart
2024-11-25 13:39       ` Ricardo Ribalda
2024-11-25 14:02         ` Hans de Goede
2024-11-26 16:22           ` Ricardo Ribalda
2024-11-26 17:18             ` Laurent Pinchart
2024-11-26 17:29               ` Ricardo Ribalda
2024-11-10 15:08   ` Laurent Pinchart
2024-11-11 12:59 ` Hans de Goede
2024-11-11 14:35   ` Hans de Goede
2024-11-12 17:31   ` Ricardo Ribalda
2024-11-13 15:19     ` 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=20241110134608.6e82f851@foz.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yunkec@chromium.org \
    /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