Skip to content

Commit 6dc485f

Browse files
committed
platform/x86: dell-privacy: Only register SW_CAMERA_LENS_COVER if present
Unlike keys where userspace only reacts to keypresses, userspace may act on switches in both (0 and 1) of their positions. For example if a SW_TABLET_MODE switch is registered then GNOME will not automatically show the onscreen keyboard when a text field gets focus on touchscreen devices when SW_TABLET_MODE reports 0 and when SW_TABLET_MODE reports 1 libinput will block (filter out) builtin keyboard and touchpad events. So to avoid unwanted side-effects EV_SW type inputs should only be registered if they are actually present, only register SW_CAMERA_LENS_COVER if it is actually there. Fixes: 8af9fa3 ("platform/x86: dell-privacy: Add support for Dell hardware privacy") Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1af7fef commit 6dc485f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

drivers/platform/x86/dell/dell-wmi-privacy.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
296296
{
297297
struct privacy_wmi_data *priv;
298298
struct key_entry *keymap;
299-
int ret, i;
299+
int ret, i, j;
300300

301301
ret = wmi_has_guid(DELL_PRIVACY_GUID);
302302
if (!ret)
@@ -327,9 +327,20 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
327327
/* remap the keymap code with Dell privacy key type 0x12 as prefix
328328
* KEY_MICMUTE scancode will be reported as 0x120001
329329
*/
330-
for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) {
331-
keymap[i] = dell_wmi_keymap_type_0012[i];
332-
keymap[i].code |= (0x0012 << 16);
330+
for (i = 0, j = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) {
331+
/*
332+
* Unlike keys where only presses matter, userspace may act
333+
* on switches in both of their positions. Only register
334+
* SW_CAMERA_LENS_COVER if it is actually there.
335+
*/
336+
if (dell_wmi_keymap_type_0012[i].type == KE_VSW &&
337+
dell_wmi_keymap_type_0012[i].sw.code == SW_CAMERA_LENS_COVER &&
338+
!(priv->features_present & BIT(DELL_PRIVACY_TYPE_CAMERA)))
339+
continue;
340+
341+
keymap[j] = dell_wmi_keymap_type_0012[i];
342+
keymap[j].code |= (0x0012 << 16);
343+
j++;
333344
}
334345
ret = sparse_keymap_setup(priv->input_dev, keymap, NULL);
335346
kfree(keymap);

0 commit comments

Comments
 (0)