[v2] ALSA: hda - Fixes inverted Conexant GPIO mic mute led
diff mbox series

Message ID 20190818212302.27430-1-jeronimo@borque.com.ar
State New
Headers show
Series
  • [v2] ALSA: hda - Fixes inverted Conexant GPIO mic mute led
Related show

Commit Message

Jerónimo Borque Aug. 18, 2019, 9:23 p.m. UTC
From: Jeronimo Borque <jeronimo@borque.com.ar>

"enabled" parameter historically referred to the device input or
output, not to the led indicator. After the changes added with the led
helper functions the mic mute led logic refers to the led and not to
the mic input which caused led indicator to be negated.
Fixing logic in cxt_update_gpio_led and updated
cxt_fixup_gpio_mute_hook
Also updated debug messages to ease further debugging if necessary.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jeronimo Borque <jeronimo@borque.com.ar>
---
 sound/pci/hda/patch_conexant.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Jerónimo Borque Aug. 19, 2019, 12:01 a.m. UTC | #1
I'm sorry. I've sent a wrong patch file.
I'll resubmit the right patch shortly.
Thanks,
Jerónimo

El dom., 18 de ago. de 2019 a la(s) 18:23, <jeronimo@borque.com.ar>
escribió:

> From: Jeronimo Borque <jeronimo@borque.com.ar>
>
> "enabled" parameter historically referred to the device input or
> output, not to the led indicator. After the changes added with the led
> helper functions the mic mute led logic refers to the led and not to
> the mic input which caused led indicator to be negated.
> Fixing logic in cxt_update_gpio_led and updated
> cxt_fixup_gpio_mute_hook
> Also updated debug messages to ease further debugging if necessary.
>
> Suggested-by: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Jeronimo Borque <jeronimo@borque.com.ar>
> ---
>  sound/pci/hda/patch_conexant.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/sound/pci/hda/patch_conexant.c
> b/sound/pci/hda/patch_conexant.c
> index 14298ef45b21..d1c93dfa158b 100644
> --- a/sound/pci/hda/patch_conexant.c
> +++ b/sound/pci/hda/patch_conexant.c
> @@ -611,18 +611,20 @@ static void cxt_fixup_hp_gate_mic_jack(struct
> hda_codec *codec,
>
>  /* update LED status via GPIO */
>  static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int
> mask,
> -                               bool enabled)
> +                               bool led_on)
>  {
>         struct conexant_spec *spec = codec->spec;
>         unsigned int oldval = spec->gpio_led;
>
>         if (spec->mute_led_polarity)
> -               enabled = !enabled;
> +               led_on = !led_on;
>
> -       if (enabled)
> -               spec->gpio_led &= ~mask;
> -       else
> +       if (led_on)
>                 spec->gpio_led |= mask;
> +       else
> +               spec->gpio_led &= ~mask;
> +       codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n
> +                       mask, led_on, spec->gpio_led);
>         if (spec->gpio_led != oldval)
>                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
>                                     spec->gpio_led);
> @@ -633,8 +635,8 @@ static void cxt_fixup_gpio_mute_hook(void
> *private_data, int enabled)
>  {
>         struct hda_codec *codec = private_data;
>         struct conexant_spec *spec = codec->spec;
> -
> -       cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
> +       /* muted -> LED on */
> +       cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, !enabled);
>  }
>
>  /* turn on/off mic-mute LED via GPIO per capture hook */
> @@ -656,7 +658,6 @@ static void cxt_fixup_mute_led_gpio(struct hda_codec
> *codec,
>                 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03 },
>                 {}
>         };
> -       codec_info(codec, "action: %d gpio_led: %d\n", action,
> spec->gpio_led);
>
>         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
>                 spec->gen.vmaster_mute.hook = cxt_fixup_gpio_mute_hook;
> --
> 2.21.0
>
>

Patch
diff mbox series

diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 14298ef45b21..d1c93dfa158b 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -611,18 +611,20 @@  static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec,
 
 /* update LED status via GPIO */
 static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask,
-				bool enabled)
+				bool led_on)
 {
 	struct conexant_spec *spec = codec->spec;
 	unsigned int oldval = spec->gpio_led;
 
 	if (spec->mute_led_polarity)
-		enabled = !enabled;
+		led_on = !led_on;
 
-	if (enabled)
-		spec->gpio_led &= ~mask;
-	else
+	if (led_on)
 		spec->gpio_led |= mask;
+	else
+		spec->gpio_led &= ~mask;
+	codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n
+			mask, led_on, spec->gpio_led);
 	if (spec->gpio_led != oldval)
 		snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
 				    spec->gpio_led);
@@ -633,8 +635,8 @@  static void cxt_fixup_gpio_mute_hook(void *private_data, int enabled)
 {
 	struct hda_codec *codec = private_data;
 	struct conexant_spec *spec = codec->spec;
-
-	cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
+	/* muted -> LED on */
+	cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, !enabled);
 }
 
 /* turn on/off mic-mute LED via GPIO per capture hook */
@@ -656,7 +658,6 @@  static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
 		{ 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03 },
 		{}
 	};
-	codec_info(codec, "action: %d gpio_led: %d\n", action, spec->gpio_led);
 
 	if (action == HDA_FIXUP_ACT_PRE_PROBE) {
 		spec->gen.vmaster_mute.hook = cxt_fixup_gpio_mute_hook;