Lenovo WMI camera driver, switching to SW_CAMERA_LENS_COVER ?
Hi Ai,
I have been looking into all the different way the kernel is currently communicating to userspace that a camera is disabled by some form of on/off switch / privacy control, see:
https://lore.kernel.org/linuxa-media/[email protected]/
As I mention there my proposal is to standardize on SW_CAMERA_LENS_COVER. This assumes that the button which generates the WMI events actually enables / disables the camera the hardware level.
The problem with the current KEY_CAMERA_ACCESS_ENABLE / KEY_CAMERA_ACCESS_DISABLE events is that looking at the HUTRR72 specification from which these come it talks about:
"Enables programmatic access to camera device" which suggests that it is a request to the OS / desktop- environment to block camera access at the software level, rather then reporting back that a hw-level block is in place.
One problem with moving to a EV_SW like SW_CAMERA_LENS_COVER is that that needs to report the correct value right away.
Is there a way to get the initial state of the camera through the WMI interface so that we can report the correct as soon as we register the input evdev device with SW_CAMERA_LENS_COVER capability ?
Otherwise we could use the same solution which the hp-wmi driver uses which is to delay registering the input device until the first event (since then we do know the state), see:
and the caller of camera_shutter_input_setup().
Regards,
Hans
Am 11.11.24 um 15:33 schrieb Hans de Goede:
Quoted 6 lines
Hi Ai,
I have been looking into all the different way the kernel is currently communicating to userspace that a camera is disabled by some form of on/off switch / privacy control, see:
Quoted 6 lines
https://lore.kernel.org/linuxa-media/[email protected]/
As I mention there my proposal is to standardize on
SW_CAMERA_LENS_COVER. This assumes that the button which generates the WMI events actually enables / disables the camera the hardware level.
Hi,
i think SW_CAMERA_LENS_COVER is misleading here, since AFAIK the camera completely disappears from the USB bus. With a proper lens cover however, the camera would still be accessible for querying things like supported resolutions, etc.
Also i believe that the intent of the buttons handled by this driver is to disable access to all cameras connected to the system, so KEY_CAMERA_ACCESS_ENABLE / KEY_CAMERA_ACCESS_DISABLE is necessary here if external USB cameras are connected.
Thanks,
Armin Wolf
Quoted 29 lines
The problem with the current
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLEevents is that looking at the HUTRR72 specification from which these come it talks about:
"Enables programmatic access to camera device" which suggests that it is a request to the OS / desktop- environment to block camera access at the software level, rather then reporting back that a hw-level block is in place.One problem with moving to a
EV_SWlikeSW_CAMERA_LENS_COVERis that that needs to report the correct value right away.Is there a way to get the initial state of the camera through the WMI interface so that we can report the correct as soon as we register the input evdev device with
SW_CAMERA_LENS_COVERcapability ?Otherwise we could use the same solution which the hp-wmi driver uses which is to delay registering the input device until the first event (since then we do know the state), see:
and the caller of
camera_shutter_input_setup().Regards,
Hans
Hi Armin, ai,
I'm answering to both your replies in one go here since they are related. This also re-adds the list for Ai's reply which dropped the list from the Cc.
Quoted 8 lines · 艾超
We have discussed this question(initial state of the camera) with the
hardware enginner about
SW_CAMERA_LENS_COVER.Driver need a WMI events to report current camera state to desktop-environment,
and no need to get the old camera state. Whether the camera lens cover on/off , the camera streaming is normal.
Ok, so this means that if lenovo-wmi switch gets moved to use SW_CAMERA_LENS_COVER it will need to do the same thing as which hp-wmi is doing and delay registering the input device with the SW_CAMERA_LENS_COVER capability until the first idea.
Do I understand correctly that the GPIO triggering the WMI events is attached to the mechanical lens cover and basically reports the location of the cover ?
In that case switching to SW_CAMERA_LENS_COVER would definitely be the right thing to do.
Quoted 15 lines · Armin Wolf
Am 11.11.24 um 15:33 schrieb Hans de Goede:
Quoted 6 lines
Hi Ai,
I have been looking into all the different way the kernel is currently communicating to userspace that a camera is disabled by some form of on/off switch / privacy control, see:
Quoted 6 lines
https://lore.kernel.org/linuxa-media/[email protected]/
As I mention there my proposal is to standardize on
SW_CAMERA_LENS_COVER. This assumes that the button which generates the WMI events actually enables / disables the camera the hardware level.
Quoted 5 lines
Hi,
i think
SW_CAMERA_LENS_COVERis misleading here, since AFAIK the camera completely disappears from the USB bus. With a proper lens cover however, the camera would still be accessible for querying things like supported resolutions, etc.
As Ai mentions above the camera keeps streaming normally looking ay the original commit message for the driver which says:
"""
Add lenovo WMI camera button driver to support camera button. The Camera button is a GPIO device. This driver receives ACPI notifications when the camera button is switched on/off. This driver is used in Lenovo A70, it is a Computer integrated machine.
"""
We are talking about a GPIO attached to some sort of on/off contact here not normal keypresses. And this is for a so called All-In-One device (a monitor with a PC builtin) e.g. something like this:
https://c1.neweggimages.com/ProductImageCompressAll1280/83-265-019-01.jpg
Notice how there is a camera-cover which the user can slide over the cam, I presume the GPIO reports the position of the camera.\
Ai can you confirm this?
Also note that these AIO devices use normal keyboards which typically do not have any camera on/off key. So I really believe that this WMI driver is for a physical switch co-located with the camera itself and thus reporting SW_CAMERA_LENS_COVER is the right thing to do.
Armin, You are right that there are cases where the camera completely drops of the USB bus when some laptop camera hotkey gets pressed on laptop keyboards. But I do not believe that that is the case here.
Quoted 3 lines
Also i believe that the intent of the buttons handled by this driver is to disable access to all cameras connected to the system, so
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLEis necessary here if external USB cameras are connected.
As you say on laptops these keys sometimes drop the camera completely from the USB bus, so the key clearly works on the internal camera not all cameras.
What to do in those cases is a bit offtopic here, but even there I would like to see us move to SW_CAMERA_LENS_COVER especially since sometimes there is no info when we get the key press event if the camera was added or removed. So what I would like to do there is have some in kernel helper to look for an internal USB camera and if there is none report SW_CAMERA_LENS_COVER=1 and then when the camera comes back report SW_CAMERA_LENS_COVER=0 at the moment on these laptops we just report "KEY_CAMERA" which really is not helpful for userspace.
Userspace could do the look for internal camera thing itself but I would rather solve this once in the kernel and use SW_CAMERA_LENS_COVER consistently everywhere. I know dropping the camera from the bus is not technically a lens-cover but the important thing is to let userspace camera using apps know that they need to ask the user to enable the camera.
ATM this is a bit of a mess mixing SW_CAMERA_LENS_COVER + KEY_CAMERA + KEY_CAMERA_ACCESS_[DIS|EN]ABLE and I would like to try fixing this before userspace starts relying on the current broken status quo.
Regards,
Hans
Am 18.11.24 um 16:02 schrieb Hans de Goede:
Quoted 19 lines
Hi Armin, ai,
I'm answering to both your replies in one go here since they are related. This also re-adds the list for Ai's reply which dropped the list from the Cc.
Quoted 8 lines · 艾超
We have discussed this question(initial state of the camera) with the
hardware enginner about
SW_CAMERA_LENS_COVER.Driver need a WMI events to report current camera state to desktop-environment,
and no need to get the old camera state. Whether the camera lens cover on/off , the camera streaming is normal.
Ok, so this means that if lenovo-wmi switch gets moved to use
SW_CAMERA_LENS_COVERit will need to do the same thing as which hp-wmi is doing and delay registering the input device with theSW_CAMERA_LENS_COVERcapability until the first idea.
Quoted 5 lines
Do I understand correctly that the GPIO triggering the WMI events is attached to the mechanical lens cover and basically reports the location of the cover ?
In that case switching to
SW_CAMERA_LENS_COVERwould definitely be the right thing to do.
I believe that the GPIO is connected to a general "Enable/Disable cameras" button, but if the GPIO is indeed connected to some sort of lens cover then i agree with sending "SW_CAMERA_LENS_COVER".
Quoted 74 lines · Armin Wolf
Quoted 14 lines
Am 11.11.24 um 15:33 schrieb Hans de Goede:
Quoted 6 lines
Hi Ai,
I have been looking into all the different way the kernel is currently communicating to userspace that a camera is disabled by some form of on/off switch / privacy control, see:
Quoted 6 lines
https://lore.kernel.org/linuxa-media/[email protected]/
As I mention there my proposal is to standardize on
SW_CAMERA_LENS_COVER. This assumes that the button which generates the WMI events actually enables / disables the camera the hardware level.Quoted 5 lines
Hi,
i think
SW_CAMERA_LENS_COVERis misleading here, since AFAIK the camera completely disappears from the USB bus. With a proper lens cover however, the camera would still be accessible for querying things like supported resolutions, etc.As Ai mentions above the camera keeps streaming normally looking ay the original commit message for the driver which says:
"""
Add lenovo WMI camera button driver to support camera button. The Camera button is a GPIO device. This driver receives ACPI notifications when the camera button is switched on/off. This driver is used in Lenovo A70, it is a Computer integrated machine.
"""We are talking about a GPIO attached to some sort of on/off contact here not normal keypresses. And this is for a so called All-In-One device (a monitor with a PC builtin) e.g. something like this:
https://c1.neweggimages.com/ProductImageCompressAll1280/83-265-019-01.jpg
Notice how there is a camera-cover which the user can slide over the cam, I presume the GPIO reports the position of the camera.\
Ai can you confirm this?
Also note that these AIO devices use normal keyboards which typically do not have any camera on/off key. So I really believe that this WMI driver is for a physical switch co-located with the camera itself and thus reporting
SW_CAMERA_LENS_COVERis the right thing to do.Armin, You are right that there are cases where the camera completely drops of the USB bus when some laptop camera hotkey gets pressed on laptop keyboards. But I do not believe that that is the case here.
Quoted 3 lines
Also i believe that the intent of the buttons handled by this driver is to disable access to all cameras connected to the system, so
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLEis necessary here if external USB cameras are connected.As you say on laptops these keys sometimes drop the camera completely from the USB bus, so the key clearly works on the internal camera not all cameras.
What to do in those cases is a bit offtopic here, but even there I would like to see us move to
SW_CAMERA_LENS_COVERespecially since sometimes there is no info when we get the key press event if the camera was added or removed. So what I would like to do there is have some in kernel helper to look for an internal USB camera and if there is none report SW_CAMERA_LENS_COVER=1 and then when the camera comes back report SW_CAMERA_LENS_COVER=0 at the moment on these laptops we just report "KEY_CAMERA" which really is not helpful for userspace.Userspace could do the look for internal camera thing itself but I would rather solve this once in the kernel and use
SW_CAMERA_LENS_COVERconsistently everywhere. I know dropping the camera from the bus is not technically a lens-cover but the important thing is to let userspace camera using apps know that they need to ask the user to enable the camera.
Quoted 8 lines
ATM this is a bit of a mess mixing
SW_CAMERA_LENS_COVER+KEY_CAMERA+ KEY_CAMERA_ACCESS_[DIS|EN]ABLE and I would like to try fixing this before userspace starts relying on the current broken status quo.Regards,
Hans
I agree with you here regarding the "dropping the camera of the bus" type of devices.
However we might need to differentiate between buttons which are designed to:
- disable all cameras (like some sort of configuration shortcut)
- notify that the camera was disabled (and possible dropped of the bus)
In the first case i would continue to use KEY_CAMERA_ACCESS_[DIS|EN]ABLE, while in the second case we could indeed use SW_CAMERA_LENS_COVER. The point is that we need to know the purpose of the button/event.
Thanks,
Armin Wolf
Hi Armin,
Quoted 115 lines · Armin Wolf
Am 18.11.24 um 16:02 schrieb Hans de Goede:
Quoted 19 lines
Hi Armin, ai,
I'm answering to both your replies in one go here since they are related. This also re-adds the list for Ai's reply which dropped the list from the Cc.
Quoted 8 lines · 艾超
We have discussed this question(initial state of the camera) with the
hardware enginner about
SW_CAMERA_LENS_COVER.Driver need a WMI events to report current camera state to desktop-environment,
and no need to get the old camera state. Whether the camera lens cover on/off , the camera streaming is normal.
Ok, so this means that if lenovo-wmi switch gets moved to use
SW_CAMERA_LENS_COVERit will need to do the same thing as which hp-wmi is doing and delay registering the input device with theSW_CAMERA_LENS_COVERcapability until the first idea.Quoted 5 lines
Do I understand correctly that the GPIO triggering the WMI events is attached to the mechanical lens cover and basically reports the location of the cover ?
In that case switching to
SW_CAMERA_LENS_COVERwould definitely be the right thing to do.I believe that the GPIO is connected to a general "Enable/Disable cameras" button, but if the GPIO is indeed connected to some sort of lens cover then i agree with sending "
SW_CAMERA_LENS_COVER".Quoted 74 lines · Armin Wolf
Quoted 14 lines
Am 11.11.24 um 15:33 schrieb Hans de Goede:
Quoted 6 lines
Hi Ai,
I have been looking into all the different way the kernel is currently communicating to userspace that a camera is disabled by some form of on/off switch / privacy control, see:
Quoted 6 lines
https://lore.kernel.org/linuxa-media/[email protected]/
As I mention there my proposal is to standardize on
SW_CAMERA_LENS_COVER. This assumes that the button which generates the WMI events actually enables / disables the camera the hardware level.Quoted 5 lines
Hi,
i think
SW_CAMERA_LENS_COVERis misleading here, since AFAIK the camera completely disappears from the USB bus. With a proper lens cover however, the camera would still be accessible for querying things like supported resolutions, etc.As Ai mentions above the camera keeps streaming normally looking ay the original commit message for the driver which says:
"""
Add lenovo WMI camera button driver to support camera button. The Camera button is a GPIO device. This driver receives ACPI notifications when the camera button is switched on/off. This driver is used in Lenovo A70, it is a Computer integrated machine.
"""We are talking about a GPIO attached to some sort of on/off contact here not normal keypresses. And this is for a so called All-In-One device (a monitor with a PC builtin) e.g. something like this:
https://c1.neweggimages.com/ProductImageCompressAll1280/83-265-019-01.jpg
Notice how there is a camera-cover which the user can slide over the cam, I presume the GPIO reports the position of the camera.\
Ai can you confirm this?
Also note that these AIO devices use normal keyboards which typically do not have any camera on/off key. So I really believe that this WMI driver is for a physical switch co-located with the camera itself and thus reporting
SW_CAMERA_LENS_COVERis the right thing to do.Armin, You are right that there are cases where the camera completely drops of the USB bus when some laptop camera hotkey gets pressed on laptop keyboards. But I do not believe that that is the case here.
Quoted 3 lines
Also i believe that the intent of the buttons handled by this driver is to disable access to all cameras connected to the system, so
KEY_CAMERA_ACCESS_ENABLE/KEY_CAMERA_ACCESS_DISABLEis necessary here if external USB cameras are connected.As you say on laptops these keys sometimes drop the camera completely from the USB bus, so the key clearly works on the internal camera not all cameras.
What to do in those cases is a bit offtopic here, but even there I would like to see us move to
SW_CAMERA_LENS_COVERespecially since sometimes there is no info when we get the key press event if the camera was added or removed. So what I would like to do there is have some in kernel helper to look for an internal USB camera and if there is none report SW_CAMERA_LENS_COVER=1 and then when the camera comes back report SW_CAMERA_LENS_COVER=0 at the moment on these laptops we just report "KEY_CAMERA" which really is not helpful for userspace.Userspace could do the look for internal camera thing itself but I would rather solve this once in the kernel and use
SW_CAMERA_LENS_COVERconsistently everywhere. I know dropping the camera from the bus is not technically a lens-cover but the important thing is to let userspace camera using apps know that they need to ask the user to enable the camera.Quoted 8 lines
ATM this is a bit of a mess mixing
SW_CAMERA_LENS_COVER+KEY_CAMERA+ KEY_CAMERA_ACCESS_[DIS|EN]ABLE and I would like to try fixing this before userspace starts relying on the current broken status quo.Regards,
Hans
I agree with you here regarding the "dropping the camera of the bus" type of devices.
Quoted 8 lines
However we might need to differentiate between buttons which are designed to:
- disable all cameras (like some sort of configuration shortcut)
- notify that the camera was disabled (and possible dropped of the bus)
In the first case i would continue to use KEY_CAMERA_ACCESS_[DIS|EN]ABLE, while in the second case we could indeed use
SW_CAMERA_LENS_COVER.
I agree.
Quoted 2 lines
The point is that we need to know the purpose of the button/event.
For ACPI / WMI / EC drivers it will pretty much always be about the device's internal camera.
I would only expect "disable all cameras (like some sort of configuration shortcut)" to be seen on some external keyboards, not on laptop builtin keyboards.
On some of the laptops they camera on/off hotkey even has a little LED in there to indicate when the camera is turned off just like the mute LED sometimes found in mic / speaker mute hotkeys.
Regards,
Hans