@@ -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;
}
@@ -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>
@@ -25,6 +26,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>
+#include <linux/dmi.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -70,6 +72,34 @@ static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h,
pr_err("Failed to get L channel gain.\n");
}
+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"),
+ },
+ },
+ {},
+};
+
/* For Verb-Set Amplifier Gain (Verb ID = 3h) */
static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -88,6 +118,7 @@ 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;
+ bool micmute_led;
if (strstr(ucontrol->id.name, "Main Capture Switch") ||
strstr(ucontrol->id.name, "Main Capture Volume"))
@@ -185,6 +216,16 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol,
if (dapm->bias_level <= SND_SOC_BIAS_STANDBY)
regmap_write(rt715->regmap,
RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
+
+ /* Micmute LED state changed by muted/unmute switch */
+ dmi_check_system(micmute_led_dmi_table);
+ if (mc->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 0;
}