Skip to contentSkip to conversation

ASoC: rt715:add Mic Mute LED control support

PATCH Superseded Perry Yuan 4 participants 10 messages Dec 28, 2020 – Jan 13, 2021

Subsystems (4)
lore
Share & tools
lore

Perry Yuan

author
#0 lore raw

PATCH v2 2/2 ASoC: rt715:add Mic Mute LED control support

From: Perry Yuan <[email protected]>

Some new Dell system is going to support audio internal micphone privacy setting from hardware level with micmute led state changing When micmute hotkey pressed by user, soft mute will need to be enabled firstly in case of pop noise, and codec driver need to react to mic mute event to EC notifying that SW mute is completed. Then EC will do the HW mute physically.

This patch allow codec rt715 driver to ack EC when micmute key pressed through this micphone led control interface like hda_generic provided.

---
 sound/soc/codecs/rt715-sdca.c | 19 ++++++++++++++++++-
 sound/soc/codecs/rt715-sdca.h |  1 +
 sound/soc/codecs/rt715.c      | 19 ++++++++++++++++++-
 sound/soc/codecs/rt715.h      |  1 +
 4 files changed, 38 insertions(+), 2 deletions(-)
sound/soc/codecs/rt715-sdca.c +18 -1
index b43ac8559e45..e168ef6efcf5 100644
@@ -12,6 +12,7 @@
 #include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/leds.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm.h>
 #include <linux/soundwire/sdw.h>
@@ -268,6 +269,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
 	unsigned int reg2 = mc->rreg;
 	unsigned int reg = mc->reg;
 	unsigned int max = mc->max;
+	unsigned int val0, val1;
 	int err;
 
 	val = ucontrol->value.integer.value[0];
@@ -286,7 +288,22 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
 		if (err < 0)
 			return err;
 	}
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		}
+	}
+#endif
 	return 0;
 }
 
sound/soc/codecs/rt715-sdca.h +1 -0
index 840c237895dd..2ab8724ae50b 100644
@@ -31,6 +31,7 @@ struct rt715_sdca_priv {
 	int l_is_unmute;
 	int r_is_unmute;
 	int hw_sdw_ver;
+	int micmute_led;
 };
 
 struct rt715_sdw_stream_data {
sound/soc/codecs/rt715.c +18 -1
index cdcba70146da..faa4dee6b39a 100644
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
+#include <linux/leds.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm.h>
 #include <linux/soundwire/sdw.h>
@@ -88,13 +89,29 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol,
 		RT715_SET_GAIN_MIX_ADC2_L};
 	unsigned int addr_h, addr_l, val_h, val_ll, val_lr;
 	unsigned int read_ll, read_rl, i, j, loop_cnt;
+	unsigned int val0, val1;
 
 	if (strstr(ucontrol->id.name, "Main Capture Switch") ||
 		strstr(ucontrol->id.name, "Main Capture Volume"))
 		loop_cnt = 4;
 	else
 		loop_cnt = 1;
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/*  Privacy micmute led trigger for  muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		}
+	}
+#endif
 	for (j = 0; j < loop_cnt; j++) {
 		/* Can't use update bit function, so read the original value first */
 		if (loop_cnt == 1) {
sound/soc/codecs/rt715.h +1 -0
index 009a8266f606..2d3b5b299514 100644
@@ -22,6 +22,7 @@ struct rt715_priv {
 	struct sdw_bus_params params;
 	bool hw_init;
 	bool first_hw_init;
+	int micmute_led;
 };
 
 struct sdw_stream_data {
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 4 lines · Perry Yuan

From: Perry Yuan <[email protected]>

Some new Dell system is going to support audio internal micphone privacy setting from hardware level with micmute led state changing

I'm missing patch 1 of this series - what's the story with dependencies and so on?

#2 lore raw
Quoted 9 lines

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Tuesday, December 29, 2020 8:41 PM
To: Yuan, Perry
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Limonciello, Mario
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

Quoted 8 lines
Quoted 4 lines · Perry Yuan

From: Perry Yuan <[email protected]>

Some new Dell system is going to support audio internal micphone privacy setting from hardware level with micmute led state changing

I'm missing patch 1 of this series - what's the story with dependencies and so on?

HI Mark:
Sorry to make this confused.
The two patches are not in the same module, I use different cc list for each patch. I will send another v3 looping all the cc list and some new improvement.

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
index 91e6176cdfbd..9d5cc2454b3e 100644
@@ -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
index 581475f59819..18c430456de7 100644
@@ -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
index 70edc5bb3a14..ea0c8a8099ff 100644
@@ -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
new file mode 100644
index 000000000000..9fa01d084f7d
@@ -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
index bbdb3e860892..4b22bd21fc42 100644
@@ -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]);

--
2.25.1

#3 lore raw
Quoted 25 lines

-----Original Message-----
From: Yuan, Perry <[email protected]>
Sent: Monday, January 4, 2021 3:10
To: Mark Brown
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Limonciello, Mario
Subject: RE: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

Quoted 9 lines

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Tuesday, December 29, 2020 8:41 PM
To: Yuan, Perry
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Limonciello, Mario
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

Quoted 7 lines
Quoted 4 lines · Perry Yuan

From: Perry Yuan <[email protected]>

Some new Dell system is going to support audio internal micphone privacy setting from hardware level with micmute led state changing

I'm missing patch 1 of this series - what's the story with dependencies and

Quoted 9 lines

so

Quoted 1 line

on?

HI Mark:
Sorry to make this confused.
The two patches are not in the same module, I use different cc list for each patch.
I will send another v3 looping all the cc list and some new improvement.

Since the patches span subsystems and have a dependency, once reviewers are happy I think we'll have to get an agreement of which subsystem to bring them through. So yes, please keep all CC list the same for both patches for now when you submit v3.

#4 lore raw
In reply to Perry Yuan
Quoted 22 lines
sound/soc/codecs/rt715-sdca.c +7 -1
@@ -268,6 +269,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
  	unsigned int reg2 = mc->rreg;
  	unsigned int reg = mc->reg;
  	unsigned int max = mc->max;
+	unsigned int val0, val1;
  	int err;
 
  	val = ucontrol->value.integer.value[0];
@@ -286,7 +288,22 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
  		if (err < 0)
  			return err;
  	}
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 10 lines
sound/soc/codecs/rt715-sdca.c +10 -0
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON : LED_OFF);
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in non-Dell platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

#5 lore raw

Hi

Quoted 51 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: 2021年1月12日 2:07
To: Yuan, Perry; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Limonciello, Mario; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

[EXTERNAL EMAIL]

Review static int rt715_sdca_put_volsw(struct snd_kcontrol

Quoted 1 line
(quoted diff) +0 -0
@@ -268,6 +269,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol

*kcontrol,

Quoted 11 lines
sound/soc/codecs/rt715-sdca.c +1 -0
  	unsigned int reg2 = mc->rreg;
  	unsigned int reg = mc->reg;
  	unsigned int max = mc->max;
+	unsigned int val0, val1;
  	int err;
 
  	val = ucontrol->value.integer.value[0]; @@ -286,7 +288,22 @@ static

int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
if (err < 0)
return err;
}

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt715-sdca.c +9 -1
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 4 lines
sound/soc/codecs/rt715-sdca.c +4 -0
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 3 lines
sound/soc/codecs/rt715-sdca.c +3 -0
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in non-Dell platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Quoted 2 lines

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

The current mic mute led setting path is not common used for other vendors, just Dell platform support this mic mute led set operation.

Do you think that I need to add one DMI quirk in the next version ? If so, I can add that.

Perry Yuan
Dell | Client Software Group | CDC Linux OS

#6 lore raw
Quoted 55 lines
Quoted 43 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: 2021年1月12日 2:07
To: Yuan, Perry; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Limonciello, Mario; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

[EXTERNAL EMAIL]

Review static int rt715_sdca_put_volsw(struct snd_kcontrol

Quoted 1 line
(quoted diff) +0 -0
@@ -268,6 +269,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol

*kcontrol,

Quoted 11 lines
sound/soc/codecs/rt715-sdca.c +1 -0
  	unsigned int reg2 = mc->rreg;
  	unsigned int reg = mc->reg;
  	unsigned int max = mc->max;
+	unsigned int val0, val1;
  	int err;
 
  	val = ucontrol->value.integer.value[0]; @@ -286,7 +288,22 @@ static

int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
if (err < 0)
return err;
}

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt715-sdca.c +9 -1
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 4 lines
sound/soc/codecs/rt715-sdca.c +4 -0
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

Quoted 5 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 3 lines
sound/soc/codecs/rt715-sdca.c +3 -0
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in

non-Dell

Quoted 5 lines

platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

Quoted 8 lines

The current mic mute led setting path is not common used for other vendors, just Dell platform
support this mic mute led set operation.

Do you think that I need to add one DMI quirk in the next version ? If so, I can add that.

In the HDA audio case this is modeled off of, the code runs whether or not a vendor has support for a mic mute LED. The calls to ledtrig_audio_set should be a no-op. I agree with @Pierre-Louis Bossart in this case, we should just be running it whether or not dell-privacy is compiled in. If another vendor chooses to add LED support they'll just need to set up their ledtrig supported backend and not change codec code.

#7 lore raw
Quoted 79 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: 2021年1月12日 22:48
To: Yuan, Perry; Pierre-Louis Bossart; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: RE: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

Quoted 57 lines
Quoted 47 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: 2021年1月12日 2:07
To: Yuan, Perry; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Limonciello, Mario; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

[EXTERNAL EMAIL]

Quoted 2 lines
(quoted diff) +0 -0
@@ -268,6 +269,7 @@ static int rt715_sdca_put_volsw(struct

snd_kcontrol

*kcontrol,

Quoted 11 lines
  	unsigned int reg2 = mc->rreg;
  	unsigned int reg = mc->reg;
  	unsigned int max = mc->max;
sound/soc/codecs/rt715-sdca.c +1 -0
+	unsigned int val0, val1;
  	int err;
 
  	val = ucontrol->value.integer.value[0]; @@ -286,7 +288,22 @@

static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
if (err < 0)
return err;
}

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt715-sdca.c +9 -1
-
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 4 lines
sound/soc/codecs/rt715-sdca.c +4 -0
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

Quoted 6 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 3 lines
sound/soc/codecs/rt715-sdca.c +3 -0
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in

non-Dell

Quoted 3 lines

platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Quoted 10 lines
Quoted 2 lines

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

The current mic mute led setting path is not common used for other vendors, just Dell platform support this mic mute led set operation.

Do you think that I need to add one DMI quirk in the next version ? If so, I can add that.

Quoted 6 lines

In the HDA audio case this is modeled off of, the code runs whether or not a vendor has support for a mic mute LED. The calls to ledtrig_audio_set should be a no-op. I agree with @Pierre-Louis Bossart in this case, we should just be running it whether or not dell-privacy is compiled in. If another vendor chooses to add LED support they'll just need to set up their ledtrig supported backend and not change codec code.

Hi @Pierre-Louis Bossart
Seems like that we have two way to go.
* DMI quirks,seems like that it needs to maintain the quirk list when vendors have new system to support.
* We just set the mic mute led state unconditionally .

Which way would you prefer for next patch review?

#8 lore raw
Quoted 45 lines
Quoted 38 lines
Quoted 26 lines
Quoted 16 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 10 lines
sound/soc/codecs/rt715-sdca.c +9 -0
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 4 lines
sound/soc/codecs/rt715-sdca.c +4 -0
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

Quoted 6 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 3 lines
sound/soc/codecs/rt715-sdca.c +3 -0
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in

non-Dell

Quoted 3 lines

platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Quoted 10 lines
Quoted 2 lines

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

The current mic mute led setting path is not common used for other vendors, just Dell platform support this mic mute led set operation.

Do you think that I need to add one DMI quirk in the next version ? If so, I can add that.

Quoted 6 lines

In the HDA audio case this is modeled off of, the code runs whether or not a vendor has support for a mic mute LED. The calls to ledtrig_audio_set should be a no-op. I agree with @Pierre-Louis Bossart in this case, we should just be running it whether or not dell-privacy is compiled in. If another vendor chooses to add LED support they'll just need to set up their ledtrig supported backend and not change codec code.

Quoted 6 lines

Hi @Pierre-Louis Bossart
Seems like that we have two way to go.
* DMI quirks,seems like that it needs to maintain the quirk list when vendors have new system to support.
* We just set the mic mute led state unconditionally .

Which way would you prefer for next patch review?

Maintaining quirks is a hassle, it's much simpler and consistent with HDaudio if the leds are set unconditionally. Thanks!

#9 lore raw
Quoted 62 lines

-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: 2021年1月13日 10:42
To: Yuan, Perry; Limonciello, Mario; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/2] ASoC: rt715:add Mic Mute LED control support

[EXTERNAL EMAIL]

Quoted 37 lines
Quoted 37 lines
Quoted 35 lines
Quoted 15 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 9 lines
sound/soc/codecs/rt715-sdca.c +9 -0
+#if IS_ENABLED(CONFIG_DELL_PRIVACY)
+	/* Privacy LED Trigger State Changed by muted/unmute switch */
+	if (mc->invert) {
+		val0 = ucontrol->value.integer.value[0];
+		val1 = ucontrol->value.integer.value[1];
+		if (val0 == 1 && val1 == 1) {
+			rt715->micmute_led = LED_OFF;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,

Quoted 4 lines
sound/soc/codecs/rt715-sdca.c +4 -0
+		} else if (val0 == 0 && val1 == 0) {
+			rt715->micmute_led = LED_ON;
+			ledtrig_audio_set(LED_AUDIO_MICMUTE,
+					rt715->micmute_led ? LED_ON :

LED_OFF);

Quoted 6 lines

sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 306

Quoted 3 lines
sound/soc/codecs/rt715-sdca.c +3 -0
+		}
+	}
+#endif

Should this be activated for specific DMI quirks? This driver is used in

non-Dell

Quoted 5 lines

platforms (I am thinking of Intel RVPs or Realtek daughterboards), I am not sure if a build-time behavior change makes sense.

Or conversely could we just set the LEDs unconditionally if doing so is harmless?

The current mic mute led setting path is not common used for other vendors, just Dell platform support this mic mute led set operation.

Do you think that I need to add one DMI quirk in the next version ? If so, I can add that.

Quoted 6 lines
Quoted 6 lines

In the HDA audio case this is modeled off of, the code runs whether or not a vendor has support for a mic mute LED. The calls to ledtrig_audio_set should be a no-op. I agree with @Pierre-Louis Bossart in this case, we should just be running it whether or not dell-privacy is compiled in. If another vendor chooses to add LED support they'll just need to set up their ledtrig supported backend and not

change codec code.

Quoted 4 lines

Hi @Pierre-Louis Bossart
Seems like that we have two way to go.
* DMI quirks,seems like that it needs to maintain the quirk list when vendors

Quoted 7 lines

have new system to support.

Quoted 3 lines

* We just set the mic mute led state unconditionally .

Which way would you prefer for next patch review?

Maintaining quirks is a hassle, it's much simpler and consistent with HDaudio if the leds are set unconditionally. Thanks!

Thank you for your confirm.
I will take this to next patch V4.

Perry Yuan
Dell | Client Software Group | CDC Linux OS