Skip to content

Commit 1af7fef

Browse files
committed
platform/x86: dell-privacy: Fix SW_CAMERA_LENS_COVER reporting
Use KE_VSW instead of KE_SW for the SW_CAMERA_LENS_COVER key_entry and get the value of the switch from the status field when handling SW_CAMERA_LENS_COVER events, instead of always reporting 0. Also correctly set the initial SW_CAMERA_LENS_COVER value. 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 01fd7e7 commit 1af7fef

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static const struct key_entry dell_wmi_keymap_type_0012[] = {
6161
/* privacy mic mute */
6262
{ KE_KEY, 0x0001, { KEY_MICMUTE } },
6363
/* privacy camera mute */
64-
{ KE_SW, 0x0002, { SW_CAMERA_LENS_COVER } },
64+
{ KE_VSW, 0x0002, { SW_CAMERA_LENS_COVER } },
6565
{ KE_END, 0},
6666
};
6767

@@ -115,11 +115,15 @@ bool dell_privacy_process_event(int type, int code, int status)
115115

116116
switch (code) {
117117
case DELL_PRIVACY_AUDIO_EVENT: /* Mic mute */
118-
case DELL_PRIVACY_CAMERA_EVENT: /* Camera mute */
119118
priv->last_status = status;
120119
sparse_keymap_report_entry(priv->input_dev, key, 1, true);
121120
ret = true;
122121
break;
122+
case DELL_PRIVACY_CAMERA_EVENT: /* Camera mute */
123+
priv->last_status = status;
124+
sparse_keymap_report_entry(priv->input_dev, key, !(status & CAMERA_STATUS), false);
125+
ret = true;
126+
break;
123127
default:
124128
dev_dbg(&priv->wdev->dev, "unknown event type 0x%04x 0x%04x\n", type, code);
125129
}
@@ -304,6 +308,11 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
304308

305309
dev_set_drvdata(&wdev->dev, priv);
306310
priv->wdev = wdev;
311+
312+
ret = get_current_status(priv->wdev);
313+
if (ret)
314+
return ret;
315+
307316
/* create evdev passing interface */
308317
priv->input_dev = devm_input_allocate_device(&wdev->dev);
309318
if (!priv->input_dev)
@@ -331,11 +340,12 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
331340
priv->input_dev->name = "Dell Privacy Driver";
332341
priv->input_dev->id.bustype = BUS_HOST;
333342

334-
ret = input_register_device(priv->input_dev);
335-
if (ret)
336-
return ret;
343+
/* Report initial camera-cover status */
344+
if (priv->features_present & BIT(DELL_PRIVACY_TYPE_CAMERA))
345+
input_report_switch(priv->input_dev, SW_CAMERA_LENS_COVER,
346+
!(priv->last_status & CAMERA_STATUS));
337347

338-
ret = get_current_status(priv->wdev);
348+
ret = input_register_device(priv->input_dev);
339349
if (ret)
340350
return ret;
341351

0 commit comments

Comments
 (0)