diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-04-20 06:34:50 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-04-20 06:38:48 -0400 |
commit | cdd03cedc5b55da017fcdeff7d47cac2639cded8 (patch) | |
tree | b0b8b8360eb22f79b81ded6ef9981639be15010d /sound/pci/hda | |
parent | d39801105722c9aef9eae180656190c399c576a9 (diff) |
ALSA: hda - Introduce snd_hda_set_pin_ctl*() helper functions
For setting the pin-control values more safely to match with the
actual pin capability bits, a copule of new helper functions,
snd_hda_set_pin_ctl() and snd_hda_set_pin_ctl_cache(), are
introduced. These are simple replacement of the codec verb write with
AC_VERB_SET_PIN_WIDGET but do more sanity checks and filter out
superfluous pin-control bits if they don't fit with the corresponding
pin capabilities.
Some codecs are screwed up or ignore the command when such a wrong bit
is set. These helpers will avoid such secret errors.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 26 | ||||
-rw-r--r-- | sound/pci/hda/hda_local.h | 38 | ||||
-rw-r--r-- | sound/pci/hda/patch_analog.c | 8 | ||||
-rw-r--r-- | sound/pci/hda/patch_ca0110.c | 6 | ||||
-rw-r--r-- | sound/pci/hda/patch_ca0132.c | 7 | ||||
-rw-r--r-- | sound/pci/hda/patch_cirrus.c | 21 | ||||
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 44 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 49 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 20 | ||||
-rw-r--r-- | sound/pci/hda/patch_via.c | 23 |
10 files changed, 125 insertions, 117 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 7a8fcc4c15f8..2d9716e7a116 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -4795,6 +4795,32 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, | |||
4795 | } | 4795 | } |
4796 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup); | 4796 | EXPORT_SYMBOL_HDA(snd_hda_multi_out_analog_cleanup); |
4797 | 4797 | ||
4798 | int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, | ||
4799 | unsigned int val, bool cached) | ||
4800 | { | ||
4801 | if (val) { | ||
4802 | unsigned int cap = snd_hda_query_pin_caps(codec, pin); | ||
4803 | if (val & AC_PINCTL_OUT_EN) { | ||
4804 | if (!(cap & AC_PINCAP_OUT)) | ||
4805 | val &= ~(AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | ||
4806 | else if ((val & AC_PINCTL_HP_EN) && | ||
4807 | !(cap & AC_PINCAP_HP_DRV)) | ||
4808 | val &= ~AC_PINCTL_HP_EN; | ||
4809 | } | ||
4810 | if (val & AC_PINCTL_IN_EN) { | ||
4811 | if (!(cap & AC_PINCAP_IN)) | ||
4812 | val &= ~(AC_PINCTL_IN_EN | AC_PINCTL_VREFEN); | ||
4813 | } | ||
4814 | } | ||
4815 | if (cached) | ||
4816 | return snd_hda_codec_update_cache(codec, pin, 0, | ||
4817 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
4818 | else | ||
4819 | return snd_hda_codec_write(codec, pin, 0, | ||
4820 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
4821 | } | ||
4822 | EXPORT_SYMBOL_HDA(_snd_hda_set_pin_ctl); | ||
4823 | |||
4798 | /* | 4824 | /* |
4799 | * Helper for automatic pin configuration | 4825 | * Helper for automatic pin configuration |
4800 | */ | 4826 | */ |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 0ec9248165bc..17d425775c99 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -502,6 +502,44 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | |||
502 | #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) | 502 | #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) |
503 | #define PIN_HP_AMP (AC_PINCTL_HP_EN) | 503 | #define PIN_HP_AMP (AC_PINCTL_HP_EN) |
504 | 504 | ||
505 | int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, | ||
506 | unsigned int val, bool cached); | ||
507 | |||
508 | /** | ||
509 | * _snd_hda_set_pin_ctl - Set a pin-control value safely | ||
510 | * @codec: the codec instance | ||
511 | * @pin: the pin NID to set the control | ||
512 | * @val: the pin-control value (AC_PINCTL_* bits) | ||
513 | * | ||
514 | * This function sets the pin-control value to the given pin, but | ||
515 | * filters out the invalid pin-control bits when the pin has no such | ||
516 | * capabilities. For example, when PIN_HP is passed but the pin has no | ||
517 | * HP-drive capability, the HP bit is omitted. | ||
518 | * | ||
519 | * The function doesn't check the input VREF capability bits, though. | ||
520 | * Also, this function is only for analog pins, not for HDMI pins. | ||
521 | */ | ||
522 | static inline int | ||
523 | snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val) | ||
524 | { | ||
525 | return _snd_hda_set_pin_ctl(codec, pin, val, false); | ||
526 | } | ||
527 | |||
528 | /** | ||
529 | * snd_hda_set_pin_ctl_cache - Set a pin-control value safely | ||
530 | * @codec: the codec instance | ||
531 | * @pin: the pin NID to set the control | ||
532 | * @val: the pin-control value (AC_PINCTL_* bits) | ||
533 | * | ||
534 | * Just like snd_hda_set_pin_ctl() but write to cache as well. | ||
535 | */ | ||
536 | static inline int | ||
537 | snd_hda_set_pin_ctl_cache(struct hda_codec *codec, hda_nid_t pin, | ||
538 | unsigned int val) | ||
539 | { | ||
540 | return _snd_hda_set_pin_ctl(codec, pin, val, true); | ||
541 | } | ||
542 | |||
505 | /* | 543 | /* |
506 | * get widget capabilities | 544 | * get widget capabilities |
507 | */ | 545 | */ |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 7143393927da..38163abeea92 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -1742,9 +1742,7 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
1742 | if (! ad198x_eapd_put(kcontrol, ucontrol)) | 1742 | if (! ad198x_eapd_put(kcontrol, ucontrol)) |
1743 | return 0; | 1743 | return 0; |
1744 | /* change speaker pin appropriately */ | 1744 | /* change speaker pin appropriately */ |
1745 | snd_hda_codec_write(codec, 0x05, 0, | 1745 | snd_hda_set_pin_ctl(codec, 0x05, spec->cur_eapd ? PIN_OUT : 0); |
1746 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1747 | spec->cur_eapd ? PIN_OUT : 0); | ||
1748 | /* toggle HP mute appropriately */ | 1746 | /* toggle HP mute appropriately */ |
1749 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, | 1747 | snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, |
1750 | HDA_AMP_MUTE, | 1748 | HDA_AMP_MUTE, |
@@ -3103,7 +3101,7 @@ static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, | |||
3103 | int dac_idx) | 3101 | int dac_idx) |
3104 | { | 3102 | { |
3105 | /* set as output */ | 3103 | /* set as output */ |
3106 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | 3104 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
3107 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | 3105 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
3108 | switch (nid) { | 3106 | switch (nid) { |
3109 | case 0x11: /* port-A - DAC 03 */ | 3107 | case 0x11: /* port-A - DAC 03 */ |
@@ -3165,7 +3163,7 @@ static void ad1988_auto_init_analog_input(struct hda_codec *codec) | |||
3165 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); | 3163 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); |
3166 | break; | 3164 | break; |
3167 | } | 3165 | } |
3168 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 3166 | snd_hda_set_pin_ctl(codec, nid, |
3169 | type == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); | 3167 | type == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); |
3170 | if (nid != AD1988_PIN_CD_NID) | 3168 | if (nid != AD1988_PIN_CD_NID) |
3171 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 3169 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 09ccfabb4a17..646dc976f4bd 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c | |||
@@ -341,8 +341,7 @@ static int ca0110_build_pcms(struct hda_codec *codec) | |||
341 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | 341 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) |
342 | { | 342 | { |
343 | if (pin) { | 343 | if (pin) { |
344 | snd_hda_codec_write(codec, pin, 0, | 344 | snd_hda_set_pin_ctl(codec, pin, PIN_HP); |
345 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
346 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) | 345 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) |
347 | snd_hda_codec_write(codec, pin, 0, | 346 | snd_hda_codec_write(codec, pin, 0, |
348 | AC_VERB_SET_AMP_GAIN_MUTE, | 347 | AC_VERB_SET_AMP_GAIN_MUTE, |
@@ -356,8 +355,7 @@ static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | |||
356 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) | 355 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) |
357 | { | 356 | { |
358 | if (pin) { | 357 | if (pin) { |
359 | snd_hda_codec_write(codec, pin, 0, | 358 | snd_hda_set_pin_ctl(codec, pin, PIN_VREF80); |
360 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80); | ||
361 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) | 359 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) |
362 | snd_hda_codec_write(codec, pin, 0, | 360 | snd_hda_codec_write(codec, pin, 0, |
363 | AC_VERB_SET_AMP_GAIN_MUTE, | 361 | AC_VERB_SET_AMP_GAIN_MUTE, |
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 21d91d580da8..ea63333f41fe 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
@@ -239,8 +239,7 @@ enum get_set { | |||
239 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | 239 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) |
240 | { | 240 | { |
241 | if (pin) { | 241 | if (pin) { |
242 | snd_hda_codec_write(codec, pin, 0, | 242 | snd_hda_set_pin_ctl(codec, pin, PIN_HP); |
243 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
244 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) | 243 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) |
245 | snd_hda_codec_write(codec, pin, 0, | 244 | snd_hda_codec_write(codec, pin, 0, |
246 | AC_VERB_SET_AMP_GAIN_MUTE, | 245 | AC_VERB_SET_AMP_GAIN_MUTE, |
@@ -254,9 +253,7 @@ static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | |||
254 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) | 253 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) |
255 | { | 254 | { |
256 | if (pin) { | 255 | if (pin) { |
257 | snd_hda_codec_write(codec, pin, 0, | 256 | snd_hda_set_pin_ctl(codec, pin, PIN_VREF80); |
258 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
259 | PIN_VREF80); | ||
260 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) | 257 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) |
261 | snd_hda_codec_write(codec, pin, 0, | 258 | snd_hda_codec_write(codec, pin, 0, |
262 | AC_VERB_SET_AMP_GAIN_MUTE, | 259 | AC_VERB_SET_AMP_GAIN_MUTE, |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index c83ccdba1e5a..778e4b9dd88c 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -933,8 +933,7 @@ static void cs_automute(struct hda_codec *codec) | |||
933 | pin_ctl = 0; | 933 | pin_ctl = 0; |
934 | 934 | ||
935 | nid = cfg->speaker_pins[i]; | 935 | nid = cfg->speaker_pins[i]; |
936 | snd_hda_codec_write(codec, nid, 0, | 936 | snd_hda_set_pin_ctl(codec, nid, pin_ctl); |
937 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_ctl); | ||
938 | } | 937 | } |
939 | if (spec->gpio_eapd_hp) { | 938 | if (spec->gpio_eapd_hp) { |
940 | unsigned int gpio = hp_present ? | 939 | unsigned int gpio = hp_present ? |
@@ -948,16 +947,14 @@ static void cs_automute(struct hda_codec *codec) | |||
948 | /* mute HPs if spdif jack (SENSE_B) is present */ | 947 | /* mute HPs if spdif jack (SENSE_B) is present */ |
949 | for (i = 0; i < cfg->hp_outs; i++) { | 948 | for (i = 0; i < cfg->hp_outs; i++) { |
950 | nid = cfg->hp_pins[i]; | 949 | nid = cfg->hp_pins[i]; |
951 | snd_hda_codec_write(codec, nid, 0, | 950 | snd_hda_set_pin_ctl(codec, nid, |
952 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
953 | (spdif_present && spec->sense_b) ? 0 : PIN_HP); | 951 | (spdif_present && spec->sense_b) ? 0 : PIN_HP); |
954 | } | 952 | } |
955 | 953 | ||
956 | /* SPDIF TX on/off */ | 954 | /* SPDIF TX on/off */ |
957 | if (cfg->dig_outs) { | 955 | if (cfg->dig_outs) { |
958 | nid = cfg->dig_out_pins[0]; | 956 | nid = cfg->dig_out_pins[0]; |
959 | snd_hda_codec_write(codec, nid, 0, | 957 | snd_hda_set_pin_ctl(codec, nid, |
960 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
961 | spdif_present ? PIN_OUT : 0); | 958 | spdif_present ? PIN_OUT : 0); |
962 | 959 | ||
963 | } | 960 | } |
@@ -1024,13 +1021,11 @@ static void init_output(struct hda_codec *codec) | |||
1024 | 1021 | ||
1025 | /* set appropriate pin controls */ | 1022 | /* set appropriate pin controls */ |
1026 | for (i = 0; i < cfg->line_outs; i++) | 1023 | for (i = 0; i < cfg->line_outs; i++) |
1027 | snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, | 1024 | snd_hda_set_pin_ctl(codec, cfg->line_out_pins[i], PIN_OUT); |
1028 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
1029 | /* HP */ | 1025 | /* HP */ |
1030 | for (i = 0; i < cfg->hp_outs; i++) { | 1026 | for (i = 0; i < cfg->hp_outs; i++) { |
1031 | hda_nid_t nid = cfg->hp_pins[i]; | 1027 | hda_nid_t nid = cfg->hp_pins[i]; |
1032 | snd_hda_codec_write(codec, nid, 0, | 1028 | snd_hda_set_pin_ctl(codec, nid, PIN_HP); |
1033 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
1034 | if (!cfg->speaker_outs) | 1029 | if (!cfg->speaker_outs) |
1035 | continue; | 1030 | continue; |
1036 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { | 1031 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { |
@@ -1041,8 +1036,7 @@ static void init_output(struct hda_codec *codec) | |||
1041 | 1036 | ||
1042 | /* Speaker */ | 1037 | /* Speaker */ |
1043 | for (i = 0; i < cfg->speaker_outs; i++) | 1038 | for (i = 0; i < cfg->speaker_outs; i++) |
1044 | snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, | 1039 | snd_hda_set_pin_ctl(codec, cfg->speaker_pins[i], PIN_OUT); |
1045 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
1046 | 1040 | ||
1047 | /* SPDIF is enabled on presence detect for CS421x */ | 1041 | /* SPDIF is enabled on presence detect for CS421x */ |
1048 | if (spec->hp_detect || spec->spdif_detect) | 1042 | if (spec->hp_detect || spec->spdif_detect) |
@@ -1069,8 +1063,7 @@ static void init_input(struct hda_codec *codec) | |||
1069 | if (caps & AC_PINCAP_VREF_80) | 1063 | if (caps & AC_PINCAP_VREF_80) |
1070 | ctl = PIN_VREF80; | 1064 | ctl = PIN_VREF80; |
1071 | } | 1065 | } |
1072 | snd_hda_codec_write(codec, pin, 0, | 1066 | snd_hda_set_pin_ctl(codec, pin, ctl); |
1073 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | ||
1074 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, | 1067 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, |
1075 | AC_VERB_SET_AMP_GAIN_MUTE, | 1068 | AC_VERB_SET_AMP_GAIN_MUTE, |
1076 | AMP_IN_MUTE(spec->adc_idx[i])); | 1069 | AMP_IN_MUTE(spec->adc_idx[i])); |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 6e04c2bf06de..afa510f0b993 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -1602,17 +1602,13 @@ static void cxt5051_update_speaker(struct hda_codec *codec) | |||
1602 | unsigned int pinctl; | 1602 | unsigned int pinctl; |
1603 | /* headphone pin */ | 1603 | /* headphone pin */ |
1604 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | 1604 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; |
1605 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1605 | snd_hda_set_pin_ctl(codec, 0x16, pinctl); |
1606 | pinctl); | ||
1607 | /* speaker pin */ | 1606 | /* speaker pin */ |
1608 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | 1607 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
1609 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1608 | snd_hda_set_pin_ctl(codec, 0x1a, pinctl); |
1610 | pinctl); | ||
1611 | /* on ideapad there is an additional speaker (subwoofer) to mute */ | 1609 | /* on ideapad there is an additional speaker (subwoofer) to mute */ |
1612 | if (spec->ideapad) | 1610 | if (spec->ideapad) |
1613 | snd_hda_codec_write(codec, 0x1b, 0, | 1611 | snd_hda_set_pin_ctl(codec, 0x1b, pinctl); |
1614 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1615 | pinctl); | ||
1616 | } | 1612 | } |
1617 | 1613 | ||
1618 | /* turn on/off EAPD (+ mute HP) as a master switch */ | 1614 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
@@ -1997,8 +1993,7 @@ static void cxt5066_update_speaker(struct hda_codec *codec) | |||
1997 | 1993 | ||
1998 | /* Port A (HP) */ | 1994 | /* Port A (HP) */ |
1999 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; | 1995 | pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0; |
2000 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1996 | snd_hda_set_pin_ctl(codec, 0x19, pinctl); |
2001 | pinctl); | ||
2002 | 1997 | ||
2003 | /* Port D (HP/LO) */ | 1998 | /* Port D (HP/LO) */ |
2004 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; | 1999 | pinctl = spec->cur_eapd ? spec->port_d_mode : 0; |
@@ -2011,13 +2006,11 @@ static void cxt5066_update_speaker(struct hda_codec *codec) | |||
2011 | if (!hp_port_d_present(spec)) | 2006 | if (!hp_port_d_present(spec)) |
2012 | pinctl = 0; | 2007 | pinctl = 0; |
2013 | } | 2008 | } |
2014 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2009 | snd_hda_set_pin_ctl(codec, 0x1c, pinctl); |
2015 | pinctl); | ||
2016 | 2010 | ||
2017 | /* CLASS_D AMP */ | 2011 | /* CLASS_D AMP */ |
2018 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | 2012 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
2019 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2013 | snd_hda_set_pin_ctl(codec, 0x1f, pinctl); |
2020 | pinctl); | ||
2021 | } | 2014 | } |
2022 | 2015 | ||
2023 | /* turn on/off EAPD (+ mute HP) as a master switch */ | 2016 | /* turn on/off EAPD (+ mute HP) as a master switch */ |
@@ -2048,8 +2041,7 @@ static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) | |||
2048 | /* Even though port F is the DC input, the bias is controlled on port B. | 2041 | /* Even though port F is the DC input, the bias is controlled on port B. |
2049 | * we also leave that port as an active input (but unselected) in DC mode | 2042 | * we also leave that port as an active input (but unselected) in DC mode |
2050 | * just in case that is necessary to make the bias setting take effect. */ | 2043 | * just in case that is necessary to make the bias setting take effect. */ |
2051 | return snd_hda_codec_write_cache(codec, 0x1a, 0, | 2044 | return snd_hda_set_pin_ctl_cache(codec, 0x1a, |
2052 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2053 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); | 2045 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); |
2054 | } | 2046 | } |
2055 | 2047 | ||
@@ -2082,14 +2074,14 @@ static void cxt5066_olpc_select_mic(struct hda_codec *codec) | |||
2082 | } | 2074 | } |
2083 | 2075 | ||
2084 | /* disable DC (port F) */ | 2076 | /* disable DC (port F) */ |
2085 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | 2077 | snd_hda_set_pin_ctl(codec, 0x1e, 0); |
2086 | 2078 | ||
2087 | /* external mic, port B */ | 2079 | /* external mic, port B */ |
2088 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2080 | snd_hda_set_pin_ctl(codec, 0x1a, |
2089 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); | 2081 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); |
2090 | 2082 | ||
2091 | /* internal mic, port C */ | 2083 | /* internal mic, port C */ |
2092 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2084 | snd_hda_set_pin_ctl(codec, 0x1b, |
2093 | spec->ext_mic_present ? 0 : PIN_VREF80); | 2085 | spec->ext_mic_present ? 0 : PIN_VREF80); |
2094 | } | 2086 | } |
2095 | 2087 | ||
@@ -3358,9 +3350,7 @@ static void do_automute(struct hda_codec *codec, int num_pins, | |||
3358 | struct conexant_spec *spec = codec->spec; | 3350 | struct conexant_spec *spec = codec->spec; |
3359 | int i; | 3351 | int i; |
3360 | for (i = 0; i < num_pins; i++) | 3352 | for (i = 0; i < num_pins; i++) |
3361 | snd_hda_codec_write(codec, pins[i], 0, | 3353 | snd_hda_set_pin_ctl(codec, pins[i], on ? PIN_OUT : 0); |
3362 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
3363 | on ? PIN_OUT : 0); | ||
3364 | if (spec->pin_eapd_ctrls) | 3354 | if (spec->pin_eapd_ctrls) |
3365 | cx_auto_turn_eapd(codec, num_pins, pins, on); | 3355 | cx_auto_turn_eapd(codec, num_pins, pins, on); |
3366 | } | 3356 | } |
@@ -3977,8 +3967,7 @@ static void cx_auto_init_output(struct hda_codec *codec) | |||
3977 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & | 3967 | if (snd_hda_query_pin_caps(codec, cfg->hp_pins[i]) & |
3978 | AC_PINCAP_HP_DRV) | 3968 | AC_PINCAP_HP_DRV) |
3979 | val |= AC_PINCTL_HP_EN; | 3969 | val |= AC_PINCTL_HP_EN; |
3980 | snd_hda_codec_write(codec, cfg->hp_pins[i], 0, | 3970 | snd_hda_set_pin_ctl(codec, cfg->hp_pins[i], val); |
3981 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
3982 | } | 3971 | } |
3983 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); | 3972 | mute_outputs(codec, cfg->hp_outs, cfg->hp_pins); |
3984 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); | 3973 | mute_outputs(codec, cfg->line_outs, cfg->line_out_pins); |
@@ -4036,8 +4025,7 @@ static void cx_auto_init_input(struct hda_codec *codec) | |||
4036 | type = PIN_VREF80; | 4025 | type = PIN_VREF80; |
4037 | else | 4026 | else |
4038 | type = PIN_IN; | 4027 | type = PIN_IN; |
4039 | snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, | 4028 | snd_hda_set_pin_ctl(codec, cfg->inputs[i].pin, type); |
4040 | AC_VERB_SET_PIN_WIDGET_CONTROL, type); | ||
4041 | } | 4029 | } |
4042 | 4030 | ||
4043 | if (spec->auto_mic) { | 4031 | if (spec->auto_mic) { |
@@ -4064,11 +4052,9 @@ static void cx_auto_init_digital(struct hda_codec *codec) | |||
4064 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4052 | struct auto_pin_cfg *cfg = &spec->autocfg; |
4065 | 4053 | ||
4066 | if (spec->multiout.dig_out_nid) | 4054 | if (spec->multiout.dig_out_nid) |
4067 | snd_hda_codec_write(codec, cfg->dig_out_pins[0], 0, | 4055 | snd_hda_set_pin_ctl(codec, cfg->dig_out_pins[0], PIN_OUT); |
4068 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
4069 | if (spec->dig_in_nid) | 4056 | if (spec->dig_in_nid) |
4070 | snd_hda_codec_write(codec, cfg->dig_in_pin, 0, | 4057 | snd_hda_set_pin_ctl(codec, cfg->dig_in_pin, PIN_IN); |
4071 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | ||
4072 | } | 4058 | } |
4073 | 4059 | ||
4074 | static int cx_auto_init(struct hda_codec *codec) | 4060 | static int cx_auto_init(struct hda_codec *codec) |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index e65e35433055..9560b8e1e85c 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -319,13 +319,16 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, | |||
319 | 319 | ||
320 | /* for shared I/O, change the pin-control accordingly */ | 320 | /* for shared I/O, change the pin-control accordingly */ |
321 | if (spec->shared_mic_hp) { | 321 | if (spec->shared_mic_hp) { |
322 | unsigned int val; | ||
323 | hda_nid_t pin = spec->autocfg.inputs[1].pin; | ||
322 | /* NOTE: this assumes that there are only two inputs, the | 324 | /* NOTE: this assumes that there are only two inputs, the |
323 | * first is the real internal mic and the second is HP jack. | 325 | * first is the real internal mic and the second is HP jack. |
324 | */ | 326 | */ |
325 | snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0, | 327 | if (spec->cur_mux[adc_idx]) |
326 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 328 | val = PIN_VREF80; |
327 | spec->cur_mux[adc_idx] ? | 329 | else |
328 | PIN_VREF80 : PIN_HP); | 330 | val = PIN_HP; |
331 | snd_hda_set_pin_ctl(codec, pin, val); | ||
329 | spec->automute_speaker = !spec->cur_mux[adc_idx]; | 332 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
330 | call_update_outputs(codec); | 333 | call_update_outputs(codec); |
331 | } | 334 | } |
@@ -394,7 +397,7 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, | |||
394 | else if (pincap & AC_PINCAP_VREF_GRD) | 397 | else if (pincap & AC_PINCAP_VREF_GRD) |
395 | val = PIN_VREFGRD; | 398 | val = PIN_VREFGRD; |
396 | } | 399 | } |
397 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); | 400 | snd_hda_set_pin_ctl(codec, nid, val); |
398 | } | 401 | } |
399 | 402 | ||
400 | /* | 403 | /* |
@@ -517,9 +520,7 @@ static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, | |||
517 | } else | 520 | } else |
518 | val = 0; | 521 | val = 0; |
519 | val |= pin_bits; | 522 | val |= pin_bits; |
520 | snd_hda_codec_write(codec, nid, 0, | 523 | snd_hda_set_pin_ctl(codec, nid, val); |
521 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
522 | val); | ||
523 | break; | 524 | break; |
524 | case ALC_AUTOMUTE_AMP: | 525 | case ALC_AUTOMUTE_AMP: |
525 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 526 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
@@ -1621,8 +1622,7 @@ static void alc_auto_init_digital(struct hda_codec *codec) | |||
1621 | pin = spec->autocfg.dig_out_pins[i]; | 1622 | pin = spec->autocfg.dig_out_pins[i]; |
1622 | if (!pin) | 1623 | if (!pin) |
1623 | continue; | 1624 | continue; |
1624 | snd_hda_codec_write(codec, pin, 0, | 1625 | snd_hda_set_pin_ctl(codec, pin, PIN_OUT); |
1625 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
1626 | if (!i) | 1626 | if (!i) |
1627 | dac = spec->multiout.dig_out_nid; | 1627 | dac = spec->multiout.dig_out_nid; |
1628 | else | 1628 | else |
@@ -1635,9 +1635,7 @@ static void alc_auto_init_digital(struct hda_codec *codec) | |||
1635 | } | 1635 | } |
1636 | pin = spec->autocfg.dig_in_pin; | 1636 | pin = spec->autocfg.dig_in_pin; |
1637 | if (pin) | 1637 | if (pin) |
1638 | snd_hda_codec_write(codec, pin, 0, | 1638 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
1639 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1640 | PIN_IN); | ||
1641 | } | 1639 | } |
1642 | 1640 | ||
1643 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ | 1641 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
@@ -2856,8 +2854,7 @@ static int alc_auto_create_shared_input(struct hda_codec *codec) | |||
2856 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, | 2854 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
2857 | unsigned int pin_type) | 2855 | unsigned int pin_type) |
2858 | { | 2856 | { |
2859 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 2857 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
2860 | pin_type); | ||
2861 | /* unmute pin */ | 2858 | /* unmute pin */ |
2862 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) | 2859 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
2863 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 2860 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
@@ -3998,9 +3995,7 @@ static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) | |||
3998 | snd_hda_codec_read(codec, nid, 0, | 3995 | snd_hda_codec_read(codec, nid, 0, |
3999 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 3996 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
4000 | if (output) { | 3997 | if (output) { |
4001 | snd_hda_codec_update_cache(codec, nid, 0, | 3998 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
4002 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
4003 | PIN_OUT); | ||
4004 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | 3999 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
4005 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 4000 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
4006 | HDA_AMP_MUTE, 0); | 4001 | HDA_AMP_MUTE, 0); |
@@ -4009,9 +4004,8 @@ static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) | |||
4009 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | 4004 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
4010 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 4005 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
4011 | HDA_AMP_MUTE, HDA_AMP_MUTE); | 4006 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
4012 | snd_hda_codec_update_cache(codec, nid, 0, | 4007 | snd_hda_set_pin_ctl_cache(codec, nid, |
4013 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 4008 | spec->multi_io[idx].ctl_in); |
4014 | spec->multi_io[idx].ctl_in); | ||
4015 | } | 4009 | } |
4016 | return 0; | 4010 | return 0; |
4017 | } | 4011 | } |
@@ -5171,8 +5165,7 @@ static void alc889_fixup_mbp_vref(struct hda_codec *codec, | |||
5171 | val = snd_hda_codec_read(codec, nids[i], 0, | 5165 | val = snd_hda_codec_read(codec, nids[i], 0, |
5172 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 5166 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
5173 | val |= AC_PINCTL_VREF_80; | 5167 | val |= AC_PINCTL_VREF_80; |
5174 | snd_hda_codec_write(codec, nids[i], 0, | 5168 | snd_hda_set_pin_ctl(codec, nids[i], val); |
5175 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
5176 | spec->keep_vref_in_automute = 1; | 5169 | spec->keep_vref_in_automute = 1; |
5177 | break; | 5170 | break; |
5178 | } | 5171 | } |
@@ -5193,8 +5186,7 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec, | |||
5193 | val = snd_hda_codec_read(codec, nids[i], 0, | 5186 | val = snd_hda_codec_read(codec, nids[i], 0, |
5194 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 5187 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
5195 | val |= AC_PINCTL_VREF_50; | 5188 | val |= AC_PINCTL_VREF_50; |
5196 | snd_hda_codec_write(codec, nids[i], 0, | 5189 | snd_hda_set_pin_ctl(codec, nids[i], val); |
5197 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
5198 | } | 5190 | } |
5199 | spec->keep_vref_in_automute = 1; | 5191 | spec->keep_vref_in_automute = 1; |
5200 | } | 5192 | } |
@@ -5943,9 +5935,7 @@ static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) | |||
5943 | { | 5935 | { |
5944 | struct hda_codec *codec = private_data; | 5936 | struct hda_codec *codec = private_data; |
5945 | unsigned int pinval = enabled ? 0x20 : 0x24; | 5937 | unsigned int pinval = enabled ? 0x20 : 0x24; |
5946 | snd_hda_codec_update_cache(codec, 0x19, 0, | 5938 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
5947 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
5948 | pinval); | ||
5949 | } | 5939 | } |
5950 | 5940 | ||
5951 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, | 5941 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
@@ -6342,8 +6332,7 @@ static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, | |||
6342 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) | 6332 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
6343 | val |= AC_PINCTL_IN_EN; | 6333 | val |= AC_PINCTL_IN_EN; |
6344 | val |= AC_PINCTL_VREF_50; | 6334 | val |= AC_PINCTL_VREF_50; |
6345 | snd_hda_codec_write(codec, 0x0f, 0, | 6335 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
6346 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); | ||
6347 | spec->keep_vref_in_automute = 1; | 6336 | spec->keep_vref_in_automute = 1; |
6348 | } | 6337 | } |
6349 | 6338 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 4742cac26aa9..21de62b7c991 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -681,8 +681,7 @@ static int stac_vrefout_set(struct hda_codec *codec, | |||
681 | pinctl &= ~AC_PINCTL_VREFEN; | 681 | pinctl &= ~AC_PINCTL_VREFEN; |
682 | pinctl |= (new_vref & AC_PINCTL_VREFEN); | 682 | pinctl |= (new_vref & AC_PINCTL_VREFEN); |
683 | 683 | ||
684 | error = snd_hda_codec_write_cache(codec, nid, 0, | 684 | error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl); |
685 | AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); | ||
686 | if (error < 0) | 685 | if (error < 0) |
687 | return error; | 686 | return error; |
688 | 687 | ||
@@ -706,8 +705,7 @@ static unsigned int stac92xx_vref_set(struct hda_codec *codec, | |||
706 | else | 705 | else |
707 | pincfg |= AC_PINCTL_IN_EN; | 706 | pincfg |= AC_PINCTL_IN_EN; |
708 | 707 | ||
709 | error = snd_hda_codec_write_cache(codec, nid, 0, | 708 | error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg); |
710 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); | ||
711 | if (error < 0) | 709 | if (error < 0) |
712 | return error; | 710 | return error; |
713 | else | 711 | else |
@@ -2524,8 +2522,7 @@ static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, | |||
2524 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) | 2522 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
2525 | 2523 | ||
2526 | { | 2524 | { |
2527 | snd_hda_codec_write_cache(codec, nid, 0, | 2525 | snd_hda_set_pin_ctl_cache(codec, nid, pin_type); |
2528 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | ||
2529 | } | 2526 | } |
2530 | 2527 | ||
2531 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info | 2528 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
@@ -4460,8 +4457,7 @@ static void stac92xx_shutup_pins(struct hda_codec *codec) | |||
4460 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); | 4457 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
4461 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); | 4458 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); |
4462 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) | 4459 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) |
4463 | snd_hda_codec_write(codec, pin->nid, 0, | 4460 | snd_hda_set_pin_ctl(codec, pin->nid, 0); |
4464 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4465 | } | 4461 | } |
4466 | } | 4462 | } |
4467 | 4463 | ||
@@ -4517,9 +4513,7 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4517 | 4513 | ||
4518 | pin_ctl |= flag; | 4514 | pin_ctl |= flag; |
4519 | if (old_ctl != pin_ctl) | 4515 | if (old_ctl != pin_ctl) |
4520 | snd_hda_codec_write_cache(codec, nid, 0, | 4516 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl); |
4521 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
4522 | pin_ctl); | ||
4523 | } | 4517 | } |
4524 | 4518 | ||
4525 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | 4519 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
@@ -4528,9 +4522,7 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4528 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, | 4522 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
4529 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | 4523 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
4530 | if (pin_ctl & flag) | 4524 | if (pin_ctl & flag) |
4531 | snd_hda_codec_write_cache(codec, nid, 0, | 4525 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag); |
4532 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
4533 | pin_ctl & ~flag); | ||
4534 | } | 4526 | } |
4535 | 4527 | ||
4536 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | 4528 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 06214fdc9486..8ee531aeda6e 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -532,8 +532,7 @@ static void init_output_pin(struct hda_codec *codec, hda_nid_t pin, | |||
532 | { | 532 | { |
533 | if (!pin) | 533 | if (!pin) |
534 | return; | 534 | return; |
535 | snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 535 | snd_hda_set_pin_ctl(codec, pin, pin_type); |
536 | pin_type); | ||
537 | if (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD) | 536 | if (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD) |
538 | snd_hda_codec_write(codec, pin, 0, | 537 | snd_hda_codec_write(codec, pin, 0, |
539 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | 538 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
@@ -666,8 +665,7 @@ static void via_auto_init_analog_input(struct hda_codec *codec) | |||
666 | ctl = PIN_VREF50; | 665 | ctl = PIN_VREF50; |
667 | else | 666 | else |
668 | ctl = PIN_IN; | 667 | ctl = PIN_IN; |
669 | snd_hda_codec_write(codec, nid, 0, | 668 | snd_hda_set_pin_ctl(codec, nid, ctl); |
670 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | ||
671 | } | 669 | } |
672 | 670 | ||
673 | /* init input-src */ | 671 | /* init input-src */ |
@@ -1006,9 +1004,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, | |||
1006 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 1004 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
1007 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | 1005 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
1008 | parm |= out_in; | 1006 | parm |= out_in; |
1009 | snd_hda_codec_write(codec, nid, 0, | 1007 | snd_hda_set_pin_ctl(codec, nid, parm); |
1010 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1011 | parm); | ||
1012 | if (out_in == AC_PINCTL_OUT_EN) { | 1008 | if (out_in == AC_PINCTL_OUT_EN) { |
1013 | mute_aa_path(codec, 1); | 1009 | mute_aa_path(codec, 1); |
1014 | notify_aa_path_ctls(codec); | 1010 | notify_aa_path_ctls(codec); |
@@ -1647,8 +1643,7 @@ static void toggle_output_mutes(struct hda_codec *codec, int num_pins, | |||
1647 | parm &= ~AC_PINCTL_OUT_EN; | 1643 | parm &= ~AC_PINCTL_OUT_EN; |
1648 | else | 1644 | else |
1649 | parm |= AC_PINCTL_OUT_EN; | 1645 | parm |= AC_PINCTL_OUT_EN; |
1650 | snd_hda_codec_write(codec, pins[i], 0, | 1646 | snd_hda_set_pin_ctl(codec, pins[i], parm); |
1651 | AC_VERB_SET_PIN_WIDGET_CONTROL, parm); | ||
1652 | } | 1647 | } |
1653 | } | 1648 | } |
1654 | 1649 | ||
@@ -1709,8 +1704,7 @@ static void via_gpio_control(struct hda_codec *codec) | |||
1709 | 1704 | ||
1710 | if (gpio_data == 0x02) { | 1705 | if (gpio_data == 0x02) { |
1711 | /* unmute line out */ | 1706 | /* unmute line out */ |
1712 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, | 1707 | snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], |
1713 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1714 | PIN_OUT); | 1708 | PIN_OUT); |
1715 | if (vol_counter & 0x20) { | 1709 | if (vol_counter & 0x20) { |
1716 | /* decrease volume */ | 1710 | /* decrease volume */ |
@@ -1728,9 +1722,7 @@ static void via_gpio_control(struct hda_codec *codec) | |||
1728 | } | 1722 | } |
1729 | } else if (!(gpio_data & 0x02)) { | 1723 | } else if (!(gpio_data & 0x02)) { |
1730 | /* mute line out */ | 1724 | /* mute line out */ |
1731 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, | 1725 | snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], 0); |
1732 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1733 | 0); | ||
1734 | } | 1726 | } |
1735 | } | 1727 | } |
1736 | 1728 | ||
@@ -2757,8 +2749,7 @@ static void via_auto_init_dig_in(struct hda_codec *codec) | |||
2757 | struct via_spec *spec = codec->spec; | 2749 | struct via_spec *spec = codec->spec; |
2758 | if (!spec->dig_in_nid) | 2750 | if (!spec->dig_in_nid) |
2759 | return; | 2751 | return; |
2760 | snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0, | 2752 | snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); |
2761 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | ||
2762 | } | 2753 | } |
2763 | 2754 | ||
2764 | /* initialize the unsolicited events */ | 2755 | /* initialize the unsolicited events */ |