Skip to content

Commit e0b652a

Browse files
tiwaigregkh
authored andcommitted
ALSA: hda - Fix GPIO LED setup for IDT 92HD75 codecs
commit f1a7374 upstream. Some HP laptops with IDT 92HD75 codecs may use a GPIO > 4 for the mute LED, but currently the driver doesn't check this properly, and confuses the mute LED behavior. This ended up with the silent output on some HP laptops due to having another GPIO used as external amp control. This patch fixes the problem by checking the max GPIO count and comparing with the given value from DMI entry instead of magic fixed value 4 and 8, and adding a new field to indicate the VREF mute-LED behavior. Reported-and-tested-by: Vitaliy Kulikov <Vitaliy.Kulikov@idt.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 72a8cf9 commit e0b652a

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

‎sound/pci/hda/patch_sigmatel.c‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct sigmatel_spec {
214214
unsigned int gpio_mute;
215215
unsigned int gpio_led;
216216
unsigned int gpio_led_polarity;
217+
unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
217218
unsigned int vref_led;
218219

219220
/* stream */
@@ -4298,12 +4299,10 @@ static void stac_store_hints(struct hda_codec *codec)
42984299
spec->eapd_switch = val;
42994300
get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
43004301
if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4301-
if (spec->gpio_led <= 8) {
4302-
spec->gpio_mask |= spec->gpio_led;
4303-
spec->gpio_dir |= spec->gpio_led;
4304-
if (spec->gpio_led_polarity)
4305-
spec->gpio_data |= spec->gpio_led;
4306-
}
4302+
spec->gpio_mask |= spec->gpio_led;
4303+
spec->gpio_dir |= spec->gpio_led;
4304+
if (spec->gpio_led_polarity)
4305+
spec->gpio_data |= spec->gpio_led;
43074306
}
43084307
}
43094308

@@ -4893,8 +4892,14 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
48934892
if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
48944893
&spec->gpio_led_polarity,
48954894
&spec->gpio_led) == 2) {
4896-
if (spec->gpio_led < 4)
4895+
unsigned int max_gpio;
4896+
max_gpio = snd_hda_param_read(codec, codec->afg,
4897+
AC_PAR_GPIO_CAP);
4898+
max_gpio &= AC_GPIO_IO_COUNT;
4899+
if (spec->gpio_led < max_gpio)
48974900
spec->gpio_led = 1 << spec->gpio_led;
4901+
else
4902+
spec->vref_mute_led_nid = spec->gpio_led;
48984903
return 1;
48994904
}
49004905
if (sscanf(dev->name, "HP_Mute_LED_%d",
@@ -5023,15 +5028,12 @@ static int stac92xx_pre_resume(struct hda_codec *codec)
50235028
struct sigmatel_spec *spec = codec->spec;
50245029

50255030
/* sync mute LED */
5026-
if (spec->gpio_led) {
5027-
if (spec->gpio_led <= 8) {
5028-
stac_gpio_set(codec, spec->gpio_mask,
5029-
spec->gpio_dir, spec->gpio_data);
5030-
} else {
5031-
stac_vrefout_set(codec,
5032-
spec->gpio_led, spec->vref_led);
5033-
}
5034-
}
5031+
if (spec->vref_mute_led_nid)
5032+
stac_vrefout_set(codec, spec->vref_mute_led_nid,
5033+
spec->vref_led);
5034+
else if (spec->gpio_led)
5035+
stac_gpio_set(codec, spec->gpio_mask,
5036+
spec->gpio_dir, spec->gpio_data);
50355037
return 0;
50365038
}
50375039

@@ -5042,7 +5044,7 @@ static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
50425044
struct sigmatel_spec *spec = codec->spec;
50435045

50445046
if (power_state == AC_PWRST_D3) {
5045-
if (spec->gpio_led > 8) {
5047+
if (spec->vref_mute_led_nid) {
50465048
/* with vref-out pin used for mute led control
50475049
* codec AFG is prevented from D3 state
50485050
*/
@@ -5095,7 +5097,7 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
50955097
}
50965098
}
50975099
/*polarity defines *not* muted state level*/
5098-
if (spec->gpio_led <= 8) {
5100+
if (!spec->vref_mute_led_nid) {
50995101
if (muted)
51005102
spec->gpio_data &= ~spec->gpio_led; /* orange */
51015103
else
@@ -5113,7 +5115,8 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
51135115
muted_lvl = spec->gpio_led_polarity ?
51145116
AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
51155117
spec->vref_led = muted ? muted_lvl : notmtd_lvl;
5116-
stac_vrefout_set(codec, spec->gpio_led, spec->vref_led);
5118+
stac_vrefout_set(codec, spec->vref_mute_led_nid,
5119+
spec->vref_led);
51175120
}
51185121
return 0;
51195122
}
@@ -5634,7 +5637,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
56345637

56355638
#ifdef CONFIG_SND_HDA_POWER_SAVE
56365639
if (spec->gpio_led) {
5637-
if (spec->gpio_led <= 8) {
5640+
if (!spec->vref_mute_led_nid) {
56385641
spec->gpio_mask |= spec->gpio_led;
56395642
spec->gpio_dir |= spec->gpio_led;
56405643
spec->gpio_data |= spec->gpio_led;
@@ -5955,7 +5958,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
59555958

59565959
#ifdef CONFIG_SND_HDA_POWER_SAVE
59575960
if (spec->gpio_led) {
5958-
if (spec->gpio_led <= 8) {
5961+
if (!spec->vref_mute_led_nid) {
59595962
spec->gpio_mask |= spec->gpio_led;
59605963
spec->gpio_dir |= spec->gpio_led;
59615964
spec->gpio_data |= spec->gpio_led;

0 commit comments

Comments
 (0)