* Re: [PATCH v5] platform/x86: add lenovo wmi camera button driver
[not found] <1vk29ojvhrf-1vk4tk6plf0@nsmail7.0.0--kylin--1>
@ 2024-03-08 16:15 ` Armin Wolf
2024-03-10 4:52 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Armin Wolf @ 2024-03-08 16:15 UTC (permalink / raw)
To: 艾超, hdegoede, ilpo.jarvinen, linux-kernel,
platform-driver-x86
Cc: dmitry.torokhov, linux-input
Am 08.03.24 um 09:40 schrieb 艾超:
> Hi
>
> thanks for your help.
>
> > Is there a way to determine the current state of the camera switch
> without having
> > to wait for an WMI event?
>
> There is no other way to detemine the current state of the camera
> switch without
>
> a WMI event.
>
>
> > If its not possible to determine the current state of the camera
> switch, then your
> > driver has to defer the initialization of the input device until it
> knows the current
> > state of the camera switch. Otherwise the initial switch state
> reported by the
> > input device might be wrong.
>
> > In this case, that means your driver must initialize the input
> device when receiving
> > a valid WMI event for the first time.
>
> > Basically when your driver receives a WMI event, it has to check if
> the input device
> > is already initialized. If this is not the case, then the input
> device is initialized.
> > Please protect this check and the input device initialization with a
> mutex, since WMI
> > event handling is multithreaded.
>
>
> This Camera is a UVC device, and the Carema device is already
> initialized before the WMI
>
> event . Whether the camera switch is on or off, we can used lsusb to
> check the Camera.
>
> This wmi-camera driver only need to report the current state of the
> camera switch.
>
>
> Thanks.
>
> Ai Chao
>
I see, so userspace will notice when the camera is disabled. Since the camera disappears from
the USB bus when the switch is activated, i wonder if SW_CAMERA_LENS_COVER is the right thing
to use in this case after all.
I CCed the maintainer of the input subsystem so that he can maybe provide some advise.
I for example would, taking the above information above the UVC device into account, say that
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLE is more suitable. Then userspace has to
keep track of the camera state (through lsusb for example).
Maybe someone knowing the input subsystem can provide some advise on what to do in this case?
Thanks,
Armin Wolf
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v5] platform/x86: add lenovo wmi camera button driver
2024-03-08 16:15 ` [PATCH v5] platform/x86: add lenovo wmi camera button driver Armin Wolf
@ 2024-03-10 4:52 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2024-03-10 4:52 UTC (permalink / raw)
To: Armin Wolf
Cc: 艾超, hdegoede, ilpo.jarvinen, linux-kernel,
platform-driver-x86, linux-input
On Fri, Mar 08, 2024 at 05:15:48PM +0100, Armin Wolf wrote:
> Am 08.03.24 um 09:40 schrieb 艾超:
>
> > Hi
> >
> > thanks for your help.
> >
> > > Is there a way to determine the current state of the camera switch
> > without having
> > > to wait for an WMI event?
> >
> > There is no other way to detemine the current state of the camera
> > switch without
> >
> > a WMI event.
> >
> >
> > > If its not possible to determine the current state of the camera
> > switch, then your
> > > driver has to defer the initialization of the input device until it
> > knows the current
> > > state of the camera switch. Otherwise the initial switch state
> > reported by the
> > > input device might be wrong.
> >
> > > In this case, that means your driver must initialize the input
> > device when receiving
> > > a valid WMI event for the first time.
> >
> > > Basically when your driver receives a WMI event, it has to check if
> > the input device
> > > is already initialized. If this is not the case, then the input
> > device is initialized.
> > > Please protect this check and the input device initialization with a
> > mutex, since WMI
> > > event handling is multithreaded.
> >
> >
> > This Camera is a UVC device, and the Carema device is already
> > initialized before the WMI
> >
> > event . Whether the camera switch is on or off, we can used lsusb to
> > check the Camera.
It depends on which drivers are built-in and which are modules. The fact
that on one distribution WMI happens to enumerate after PCI/USB is just
a stroke of luck.
> >
> > This wmi-camera driver only need to report the current state of the
> > camera switch.
> >
> >
> > Thanks.
> >
> > Ai Chao
> >
> I see, so userspace will notice when the camera is disabled. Since the camera disappears from
> the USB bus when the switch is activated, i wonder if SW_CAMERA_LENS_COVER is the right thing
> to use in this case after all.
>
> I CCed the maintainer of the input subsystem so that he can maybe provide some advise.
> I for example would, taking the above information above the UVC device into account, say that
> KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLE is more suitable. Then userspace has to
> keep track of the camera state (through lsusb for example).
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLE is supposed to affect
all cameras connected to the system (HUTRR72: "The proposal is to add a
set of new Usage IDs to the Consumer Page (0x0C) to control programmatic
access to *all* camera devices connected to a computer." - emphasis
mine).
SW_CAMERA_LENS_COVER is useful when camera is always present but may be
covered.
If I understand this correctly the camera disappears from the bus and
reappears again when enabled. In this case why do you need the key event
at all? Are you planning on having a "stub" for the camera so that
userspace believes that the camera is always present but may be not
operational?
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-10 4:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1vk29ojvhrf-1vk4tk6plf0@nsmail7.0.0--kylin--1>
2024-03-08 16:15 ` [PATCH v5] platform/x86: add lenovo wmi camera button driver Armin Wolf
2024-03-10 4:52 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).