platform/x86: dell-privacy: Add support for Dell hardware privacy
PATCH v2 1/2 platform/x86: dell-privacy: Add support for Dell hardware privacy
From: Perry Yuan <[email protected]>
add support for dell privacy driver for the dell units equipped hardware privacy design, which protect users privacy
of audio and camera from hardware level. once the audio or camera privacy mode enabled, any applications will not get any audio or video stream.
when user pressed ctrl+F4 hotkey, audio privacy mode will be enabled,Micmute led will be also changed accordingly. The micmute led is fully controlled by hardware & EC. and camera mute hotkey is ctrl+F9.currently design only emmit SW_CAMERA_LENS_COVER event while the camera LENS shutter will be changed by EC & HW control.
*The flow is like this:
1) User presses key. HW does stuff with this key (timeout is started)
2) Event is emitted from FW
3) Event received by dell-privacy
4) KEY_MICMUTE emitted from dell-privacy
5) Userland picks up key and modifies kcontrol for SW mute
6) Codec kernel driver catches and calls ledtrig_audio_set, like this:
ledtrig_audio_set(LED_AUDIO_MICMUTE, rt715->micmute_led ? LED_ON :LED_OFF);
7) If "LED" is set to on dell-privacy notifies ec, and timeout is cancelled,HW mic mute activated.
---
v1 -> v2:
* query EC handle from EC driver directly.
* fix some code style.
* add KEY_END to keymap array.
* clean platform device when cleanup called
* use hexadecimal format for log print in dev_dbg
* remove __set_bit for the report keys from probe.
* fix keymap leak
* add err_free_keymap in dell_privacy_wmi_probe
* wmi driver will be unregistered if privacy_acpi_init() fails
* add sysfs attribute files for user space query.
* add leds micmute driver to privacy acpi
* add more design info the commit info
---
--- drivers/platform/x86/Kconfig | 17 ++ drivers/platform/x86/Makefile | 4 +- drivers/platform/x86/dell-laptop.c | 29 ++- drivers/platform/x86/dell-privacy-acpi.c | 165 ++++++++++++ drivers/platform/x86/dell-privacy-wmi.c | 309 +++++++++++++++++++++++ drivers/platform/x86/dell-privacy-wmi.h | 33 +++ drivers/platform/x86/dell-wmi.c | 26 +- 7 files changed, 567 insertions(+), 16 deletions(-) create mode 100644 drivers/platform/x86/dell-privacy-acpi.c create mode 100644 drivers/platform/x86/dell-privacy-wmi.c create mode 100644 drivers/platform/x86/dell-privacy-wmi.h
drivers/platform/x86/Kconfig +17 -0
@@ -491,6 +491,23 @@ config DELL_WMI_LED This adds support for the Latitude 2100 and similar notebooks that have an external LED. +config DELL_PRIVACY + tristate "Dell Hardware Privacy Support" + depends on ACPI + depends on ACPI_WMI + depends on INPUT + depends on DELL_LAPTOP + depends on LEDS_TRIGGER_AUDIO + select DELL_WMI + help + This driver provides support for the "Dell Hardware Privacy" feature + of Dell laptops. + Support for a micmute and camera mute privacy will be provided as + hardware button Ctrl+F4 and Ctrl+F9 hotkey + + To compile this driver as a module, choose M here: the module will + be called dell_privacy. + config AMILO_RFKILL tristate "Fujitsu-Siemens Amilo rfkill support" depends on RFKILL
drivers/platform/x86/Makefile +3 -1
@@ -51,7 +51,9 @@ obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o obj-$(CONFIG_DELL_WMI_SYSMAN) += dell-wmi-sysman/ - +obj-$(CONFIG_DELL_PRIVACY) += dell-privacy.o +dell-privacy-objs := dell-privacy-wmi.o \ + dell-privacy-acpi.o # Fujitsu obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o obj-$(CONFIG_FUJITSU_LAPTOP) += fujitsu-laptop.o
drivers/platform/x86/dell-laptop.c +20 -9
@@ -30,6 +30,7 @@#include <acpi/video.h> #include "dell-rbtn.h" #include "dell-smbios.h" +#include "dell-privacy-wmi.h" struct quirk_entry {bool touchpad_led;
@@ -90,6 +91,7 @@ static struct rfkill *wifi_rfkill;static struct rfkill *bluetooth_rfkill;static struct rfkill *wwan_rfkill;static bool force_rfkill; +static bool privacy_valid;module_param (force_rfkill, bool,0444 );MODULE_PARM_DESC (force_rfkill,"enable rfkill on non whitelisted models" );
@@ -1587,10 +1589,10 @@ static ssize_t kbd_led_timeout_store(struct device *dev,switch (unit) {case KBD_TIMEOUT_DAYS : value *=24 ; - fallthrough; +/* fall through */ case KBD_TIMEOUT_HOURS : value *=60 ; - fallthrough; +/* fall through */ case KBD_TIMEOUT_MINUTES : value *=60 ; unit =KBD_TIMEOUT_SECONDS ;
@@ -2205,11 +2207,18 @@ static int __init dell_init(void)dell_laptop_register_notifier (&dell_laptop_notifier);if (dell_smbios_find_token (GLOBAL_MIC_MUTE_DISABLE ) && -dell_smbios_find_token (GLOBAL_MIC_MUTE_ENABLE )) { - micmute_led_cdev.brightness =ledtrig_audio_get (LED_AUDIO_MICMUTE ); - ret =led_classdev_register (&platform_device->dev, &micmute_led_cdev); -if (ret <0 ) - goto fail_led; +dell_smbios_find_token (GLOBAL_MIC_MUTE_ENABLE )) { +#if IS_ENABLED (CONFIG_DELL_PRIVACY ) + ret =dell_privacy_valid (); +if (!ret) + privacy_valid = true; +#endif +if (!privacy_valid) { + micmute_led_cdev.brightness =ledtrig_audio_get (LED_AUDIO_MICMUTE ); + ret =led_classdev_register (&platform_device->dev, &micmute_led_cdev); +if (ret <0 ) + goto fail_led; + } }if (acpi_video_get_backlight_type () != acpi_backlight_vendor)
@@ -2257,7 +2266,8 @@ static int __init dell_init(void) fail_get_brightness:backlight_device_unregister (dell_backlight_device); fail_backlight: -led_classdev_unregister (&micmute_led_cdev); +if (!privacy_valid) +led_classdev_unregister (&micmute_led_cdev); fail_led:dell_cleanup_rfkill (); fail_rfkill:
@@ -2278,7 +2288,8 @@ static void __exit dell_exit(void)touchpad_led_exit ();kbd_led_exit ();backlight_device_unregister (dell_backlight_device); -led_classdev_unregister (&micmute_led_cdev); +if (!privacy_valid) +led_classdev_unregister (&micmute_led_cdev);dell_cleanup_rfkill ();if (platform_device) {platform_device_unregister (platform_device);
drivers/platform/x86/dell-privacy-acpi.c new file +165 -0
165 lines not on this page · raw message
drivers/platform/x86/dell-privacy-wmi.c new file +309 -0
309 lines not on this page · raw message
drivers/platform/x86/dell-privacy-wmi.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Dell privacy notification driver +* +* Copyright (C) 2021 Dell Inc. All Rights Reserved. +*/ + +#ifndef _DELL_PRIVACY_WMI_H_ +#define _DELL_PRIVACY_WMI_H_ + +#if IS_ENABLED (CONFIG_DELL_PRIVACY ) +int dell_privacy_valid (void ); +void dell_privacy_process_event (int type,int code,int status); +#else /* CONFIG_DELL_PRIVACY */ +static inline int dell_privacy_valid (void ) +{ +return -ENODEV ; +} + +static inline void dell_privacy_process_event (int type,int code,int status) +{} +#endif /* CONFIG_DELL_PRIVACY */ + +int dell_privacy_acpi_init (void ); +void dell_privacy_acpi_exit (void ); + +/* DELL Privacy Type */ +enum { +DELL_PRIVACY_TYPE_UNKNOWN =0x0 , +DELL_PRIVACY_TYPE_AUDIO , +DELL_PRIVACY_TYPE_CAMERA , +}; +#endif
drivers/platform/x86/dell-wmi.c +20 -6
@@ -27,6 +27,7 @@#include <acpi/video.h> #include "dell-smbios.h" #include "dell-wmi-descriptor.h" +#include "dell-privacy-wmi.h" MODULE_AUTHOR ("Matthew Garrett <[email protected]>" );MODULE_AUTHOR ("Pali Rohár <[email protected]>" );
@@ -381,6 +382,7 @@ static void dell_wmi_notify(struct wmi_device *wdev,u16 *buffer_entry, *buffer_end;acpi_size buffer_size;int len, i; +int err;if (obj->type !=ACPI_TYPE_BUFFER ) {pr_warn ("bad response type %x\n" , obj->type);
@@ -427,18 +429,30 @@ static void dell_wmi_notify(struct wmi_device *wdev,switch (buffer_entry[1 ]) {case 0x0000 :/* One key pressed or event occurred */ -case 0x0012 :/* Event with extended data occurred */ -if (len >2 ) -dell_wmi_process_key (wdev, buffer_entry[1 ], - buffer_entry[2 ]); -/* Extended data is currently ignored */ -break ;case 0x0010 :/* Sequence of keys pressed */ case 0x0011 :/* Sequence of events occurred */ for (i =2 ; i < len; ++i)dell_wmi_process_key (wdev, buffer_entry[1 ], buffer_entry[i]);break ; +case 0x0012 : +#if IS_ENABLED (CONFIG_DELL_PRIVACY ) + err =dell_privacy_valid (); +if (err ==0 ) { +dell_privacy_process_event (buffer_entry[1 ], + buffer_entry[3 ], buffer_entry[4 ]); + }else { +if (len >2 ) +dell_wmi_process_key (wdev, buffer_entry[1 ], + buffer_entry[2 ]); + } +#else +/* Extended data is currently ignored */ +if (len >2 ) +dell_wmi_process_key (wdev, buffer_entry[1 ], + buffer_entry[2 ]); +#endif +break ;default :/* Unknown event */ pr_info ("Unknown WMI event type 0x%x\n" , (int )buffer_entry[1 ]);
Signature · 1 line
2.25.1