ASoC: rt715:add micmute led state control supports
Subsystems (4)
PATCH v6 2/2 ASoC: rt715:add micmute led state control supports
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(embedded controller) notifying that SW mute is completed Then EC will do the hardware mute physically within the timeout reached
This patch allow codec rt715 and rt715 sdca driver to change the local micmute led state. Dell privacy led trigger driver will ack EC when micmute key pressed through this micphone led control interface like hda_generic provided ACPI method defined in dell-privacy micmute led trigger will be called for notifying the EC that software mute has been completed, then hardware audio circuit solution controlled by EC will switch the audio input source off/on
--------
v5 -> v6:
* addresed review comments from Jaroslav
* add quirks for micmute led control as short term solution to control micmute led state change
v4 -> v5:
* rebase to latest 5.12 rc4 upstream kernel
v3 -> v4:
* remove unused debug log
* remove compile flag of DELL privacy
* move the micmute_led to local from rt715_priv
* when Jaroslav upstream his gerneric LED trigger driver,I will rebase this patch,please consider merge this at first
https://lore.kernel.org/alsa-devel/[email protected]/
v2 -> v3:
* simplify the patch to reuse some val value
* add more detail to the commit info
v1 -> v2:
* fix some format issue
--------
--- sound/soc/codecs/rt715-sdca.c | 41 ++++++++++++++++++++++++++++++++++- sound/soc/codecs/rt715.c | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-)
sound/soc/codecs/rt715-sdca.c +40 -1
@@ -11,12 +11,14 @@#include <linux/moduleparam.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> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/platform_device.h> +#include <linux/dmi.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h>
@@ -344,6 +346,34 @@ static int rt715_sdca_get_volsw(struct snd_kcontrol *kcontrol,return 0 ; } +static bool micmute_led_set; +static int dmi_matched (const struct dmi_system_id *dmi) +{ + micmute_led_set =1 ; +return 1 ; +} + +/* Some systems will need to use this to trigger mic mute LED state changed */ +static const struct dmi_system_id micmute_led_dmi_table[] = { + { + .callback = dmi_matched, + .ident ="Dell Latitude 9420" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude 9420" ), + }, + }, + { + .callback = dmi_matched, + .ident ="Dell Latitude 9520" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Dell Inc." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Latitude 9520" ), + }, + }, + {}, +}; +static int rt715_sdca_put_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -358,6 +388,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,unsigned int mask = (1 <<fls (max)) -1 ;unsigned int invert = p->invert;int err; +bool micmute_led;for (i =0 ; i <4 ; i++) {if (ucontrol->value.integer.value[i] != rt715->kctl_switch_orig[i]) {
@@ -393,7 +424,15 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,if (err <0 )return err; } - +/* Micmute LED state changed by muted/unmute switch */ +dmi_check_system (micmute_led_dmi_table); +if (invert && micmute_led_set) { +if (ucontrol->value.integer.value[0 ] || ucontrol->value.integer.value[1 ]) + micmute_led =LED_OFF ; +else + micmute_led =LED_ON ; +ledtrig_audio_set (LED_AUDIO_MICMUTE , micmute_led); + }return k_changed; }
sound/soc/codecs/rt715.c +41 -0
71 lines not on this page · raw message
Signature · 1 line
2.25.1
Mark Brown
maintainersound/soc/codecs/rt715-sdca.c static int rt715_sdca_get_volsw(struct snd_kcontrol *kcontrol, · line 354
Quoted 6 lines · Perry Yuan
sound/soc/codecs/rt715-sdca.c +6
-0+static bool micmute_led_set; +static int dmi_matched (const struct dmi_system_id *dmi) +{ + micmute_led_set =1 ; +return 1 ; +}
This isn't how we usually record DMI quirks, usually we'd query once on probe and store the data in the driver data struct - see other users for examples.
sound/soc/codecs/rt715-sdca.c static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol, · line 391
Quoted 5 lines
sound/soc/codecs/rt715-sdca.c +2
-0@@ -358,6 +388,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,unsigned int mask = (1 <<fls (max)) -1 ; +dmi_check_system (micmute_led_dmi_table); +if (invert && micmute_led_set) {
This check for invert is odd and could probably use a comment.
Hi Mark:
Quoted 24 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: 2021年4月7日 23:16
To: Yuan, Perry
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Limonciello, Mario; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Dell Client Kernel
Subject: Re: [PATCH v6 2/2] ASoC: rt715:add micmute led state control supportssound/soc/codecs/rt715-sdca.c static int rt715_sdca_get_volsw(struct snd_kcontrol *kcontrol, · line 354
Quoted 5 lines · Perry Yuan
sound/soc/codecs/rt715-sdca.c +5
-0+static bool micmute_led_set; +static int dmi_matched (const struct dmi_system_id *dmi) { + micmute_led_set =1 ; +return 1 ; +}This isn't how we usually record DMI quirks, usually we'd query once on probe and store the data in the driver data struct - see other users for examples.
Quoted 8 lines
Review static int rt715_sdca_put_volsw(struct snd_kcontrol
Quoted 1 line
(quoted diff) +0
-0@@ -358,6 +388,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol*kcontrol,
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 +2
-0unsigned int mask = (1 <<fls (max)) -1 ; +dmi_check_system (micmute_led_dmi_table); +if (invert && micmute_led_set) {This check for invert is odd and could probably use a comment.
Thanks for your review.
I add one short comments for the reason in V7 patch.
I tried not to use the invert , the LED state and mute state will be not matching
So it has to use the invert to check if the mute state changed. Then notifiy the led trigger driver to set the new led state.
Perry