Commit 1af7fef0 authored by Hans de Goede's avatar Hans de Goede

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: 8af9fa37 ("platform/x86: dell-privacy: Add support for Dell hardware privacy")
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20221221220724.119594-1-hdegoede@redhat.com
parent 01fd7e78
...@@ -61,7 +61,7 @@ static const struct key_entry dell_wmi_keymap_type_0012[] = { ...@@ -61,7 +61,7 @@ static const struct key_entry dell_wmi_keymap_type_0012[] = {
/* privacy mic mute */ /* privacy mic mute */
{ KE_KEY, 0x0001, { KEY_MICMUTE } }, { KE_KEY, 0x0001, { KEY_MICMUTE } },
/* privacy camera mute */ /* privacy camera mute */
{ KE_SW, 0x0002, { SW_CAMERA_LENS_COVER } }, { KE_VSW, 0x0002, { SW_CAMERA_LENS_COVER } },
{ KE_END, 0}, { KE_END, 0},
}; };
...@@ -115,11 +115,15 @@ bool dell_privacy_process_event(int type, int code, int status) ...@@ -115,11 +115,15 @@ bool dell_privacy_process_event(int type, int code, int status)
switch (code) { switch (code) {
case DELL_PRIVACY_AUDIO_EVENT: /* Mic mute */ case DELL_PRIVACY_AUDIO_EVENT: /* Mic mute */
case DELL_PRIVACY_CAMERA_EVENT: /* Camera mute */
priv->last_status = status; priv->last_status = status;
sparse_keymap_report_entry(priv->input_dev, key, 1, true); sparse_keymap_report_entry(priv->input_dev, key, 1, true);
ret = true; ret = true;
break; break;
case DELL_PRIVACY_CAMERA_EVENT: /* Camera mute */
priv->last_status = status;
sparse_keymap_report_entry(priv->input_dev, key, !(status & CAMERA_STATUS), false);
ret = true;
break;
default: default:
dev_dbg(&priv->wdev->dev, "unknown event type 0x%04x 0x%04x\n", type, code); dev_dbg(&priv->wdev->dev, "unknown event type 0x%04x 0x%04x\n", type, code);
} }
...@@ -304,6 +308,11 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context) ...@@ -304,6 +308,11 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
dev_set_drvdata(&wdev->dev, priv); dev_set_drvdata(&wdev->dev, priv);
priv->wdev = wdev; priv->wdev = wdev;
ret = get_current_status(priv->wdev);
if (ret)
return ret;
/* create evdev passing interface */ /* create evdev passing interface */
priv->input_dev = devm_input_allocate_device(&wdev->dev); priv->input_dev = devm_input_allocate_device(&wdev->dev);
if (!priv->input_dev) if (!priv->input_dev)
...@@ -331,11 +340,12 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context) ...@@ -331,11 +340,12 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
priv->input_dev->name = "Dell Privacy Driver"; priv->input_dev->name = "Dell Privacy Driver";
priv->input_dev->id.bustype = BUS_HOST; priv->input_dev->id.bustype = BUS_HOST;
ret = input_register_device(priv->input_dev); /* Report initial camera-cover status */
if (ret) if (priv->features_present & BIT(DELL_PRIVACY_TYPE_CAMERA))
return ret; input_report_switch(priv->input_dev, SW_CAMERA_LENS_COVER,
!(priv->last_status & CAMERA_STATUS));
ret = get_current_status(priv->wdev); ret = input_register_device(priv->input_dev);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment