aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_conexant.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-12-03 06:29:14 -0500
committerTakashi Iwai <tiwai@suse.de>2010-12-03 06:32:02 -0500
commita3de8ab8853c5a14e881f0a01aa31e3dc87fc304 (patch)
tree3a0b40a992c5c9f1c7085bf84d9aa5d93ab86661 /sound/pci/hda/patch_conexant.c
parent4c98ec1170b9c03d5e0f57688ce9f5cecffbd22b (diff)
ALSA: hda - Clean up cxt5066 port-D handling & co
Instead of hard-coded magic numbers, properly define and use macros for improve the readability. Also, dell_automute is handled samely as thinkpad, since it also sets port_d_mode, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_conexant.c')
-rw-r--r--sound/pci/hda/patch_conexant.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index e652b34b1bd9..cb15ac9ee137 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -2111,6 +2111,11 @@ static struct hda_channel_mode cxt5066_modes[1] = {
2111 { 2, NULL }, 2111 { 2, NULL },
2112}; 2112};
2113 2113
2114#define HP_PRESENT_PORT_A (1 << 0)
2115#define HP_PRESENT_PORT_D (1 << 1)
2116#define hp_port_a_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_A)
2117#define hp_port_d_present(spec) ((spec)->hp_present & HP_PRESENT_PORT_D)
2118
2114static void cxt5066_update_speaker(struct hda_codec *codec) 2119static void cxt5066_update_speaker(struct hda_codec *codec)
2115{ 2120{
2116 struct conexant_spec *spec = codec->spec; 2121 struct conexant_spec *spec = codec->spec;
@@ -2120,24 +2125,20 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
2120 spec->hp_present, spec->cur_eapd); 2125 spec->hp_present, spec->cur_eapd);
2121 2126
2122 /* Port A (HP) */ 2127 /* Port A (HP) */
2123 pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0; 2128 pinctl = (hp_port_a_present(spec) && spec->cur_eapd) ? PIN_HP : 0;
2124 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2129 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2125 pinctl); 2130 pinctl);
2126 2131
2127 /* Port D (HP/LO) */ 2132 /* Port D (HP/LO) */
2128 if (spec->dell_automute) { 2133 pinctl = spec->cur_eapd ? spec->port_d_mode : 0;
2129 /* DELL AIO Port Rule: PortA> PortD> IntSpk */ 2134 if (spec->dell_automute || spec->thinkpad) {
2130 pinctl = (!(spec->hp_present & 1) && spec->cur_eapd) 2135 /* Mute if Port A is connected */
2131 ? PIN_OUT : 0; 2136 if (hp_port_a_present(spec))
2132 } else if (spec->thinkpad) {
2133 if (spec->cur_eapd)
2134 pinctl = spec->port_d_mode;
2135 /* Mute dock line-out if Port A (laptop HP) is present */
2136 if (spec->hp_present& 1)
2137 pinctl = 0; 2137 pinctl = 0;
2138 } else { 2138 } else {
2139 pinctl = ((spec->hp_present & 2) && spec->cur_eapd) 2139 /* Thinkpad/Dell doesn't give pin-D status */
2140 ? spec->port_d_mode : 0; 2140 if (!hp_port_d_present(spec))
2141 pinctl = 0;
2141 } 2142 }
2142 snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2143 snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2143 pinctl); 2144 pinctl);
@@ -2379,8 +2380,8 @@ static void cxt5066_hp_automute(struct hda_codec *codec)
2379 /* Port D */ 2380 /* Port D */
2380 portD = snd_hda_jack_detect(codec, 0x1c); 2381 portD = snd_hda_jack_detect(codec, 0x1c);
2381 2382
2382 spec->hp_present = !!(portA); 2383 spec->hp_present = portA ? HP_PRESENT_PORT_A : 0;
2383 spec->hp_present |= portD ? 2 : 0; 2384 spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0;
2384 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 2385 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
2385 portA, portD, spec->hp_present); 2386 portA, portD, spec->hp_present);
2386 cxt5066_update_speaker(codec); 2387 cxt5066_update_speaker(codec);