aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-04-27 09:14:23 -0400
committerTakashi Iwai <tiwai@suse.de>2011-04-27 09:46:40 -0400
commit604401a92cb3b93047c199f68a068ccbc5fb70fa (patch)
tree239b1f79b925fe67d9efdc2bfb707db39fd02f45 /sound/pci/hda/patch_realtek.c
parentcb34c207af4944e9c93e2b462e351430f15daad6 (diff)
ALSA: hda - Minor update for alc662-parser functions
Allow alc662_dac_to_mix() and alc662_look_for_dac() to parse down the selector widget that is found in ALC880-type codecs, and rename them to alc_auto_*() accordingly. This is for the next coming multi-io extensions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index e631874a3e32..0ed95dd9d641 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -19135,9 +19135,9 @@ static struct alc_config_preset alc662_presets[] = {
19135 */ 19135 */
19136 19136
19137/* convert from MIX nid to DAC */ 19137/* convert from MIX nid to DAC */
19138static hda_nid_t alc662_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) 19138static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
19139{ 19139{
19140 hda_nid_t list[4]; 19140 hda_nid_t list[5];
19141 int i, num; 19141 int i, num;
19142 19142
19143 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); 19143 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
@@ -19148,33 +19148,45 @@ static hda_nid_t alc662_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
19148 return 0; 19148 return 0;
19149} 19149}
19150 19150
19151/* go down to the selector widget before the mixer */
19152static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
19153{
19154 hda_nid_t srcs[5];
19155 int num = snd_hda_get_connections(codec, pin, srcs,
19156 ARRAY_SIZE(srcs));
19157 if (num != 1 ||
19158 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
19159 return pin;
19160 return srcs[0];
19161}
19162
19151/* get MIX nid connected to the given pin targeted to DAC */ 19163/* get MIX nid connected to the given pin targeted to DAC */
19152static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, 19164static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19153 hda_nid_t dac) 19165 hda_nid_t dac)
19154{ 19166{
19155 hda_nid_t mix[5]; 19167 hda_nid_t mix[5];
19156 int i, num; 19168 int i, num;
19157 19169
19170 pin = alc_go_down_to_selector(codec, pin);
19158 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); 19171 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19159 for (i = 0; i < num; i++) { 19172 for (i = 0; i < num; i++) {
19160 if (alc662_mix_to_dac(codec, mix[i]) == dac) 19173 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
19161 return mix[i]; 19174 return mix[i];
19162 } 19175 }
19163 return 0; 19176 return 0;
19164} 19177}
19165 19178
19166/* look for an empty DAC slot */ 19179/* look for an empty DAC slot */
19167static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin) 19180static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19168{ 19181{
19169 struct alc_spec *spec = codec->spec; 19182 struct alc_spec *spec = codec->spec;
19170 hda_nid_t srcs[5]; 19183 hda_nid_t srcs[5];
19171 int i, j, num; 19184 int i, j, num;
19172 19185
19186 pin = alc_go_down_to_selector(codec, pin);
19173 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); 19187 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19174 if (num < 0)
19175 return 0;
19176 for (i = 0; i < num; i++) { 19188 for (i = 0; i < num; i++) {
19177 hda_nid_t nid = alc662_mix_to_dac(codec, srcs[i]); 19189 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
19178 if (!nid) 19190 if (!nid)
19179 continue; 19191 continue;
19180 for (j = 0; j < spec->multiout.num_dacs; j++) 19192 for (j = 0; j < spec->multiout.num_dacs; j++)
@@ -19196,7 +19208,7 @@ static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19196 19208
19197 spec->multiout.dac_nids = spec->private_dac_nids; 19209 spec->multiout.dac_nids = spec->private_dac_nids;
19198 for (i = 0; i < cfg->line_outs; i++) { 19210 for (i = 0; i < cfg->line_outs; i++) {
19199 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]); 19211 dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
19200 if (!dac) 19212 if (!dac)
19201 continue; 19213 continue;
19202 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; 19214 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
@@ -19243,7 +19255,7 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19243 nid = spec->multiout.dac_nids[i]; 19255 nid = spec->multiout.dac_nids[i];
19244 if (!nid) 19256 if (!nid)
19245 continue; 19257 continue;
19246 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid); 19258 mix = alc_auto_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19247 if (!mix) 19259 if (!mix)
19248 continue; 19260 continue;
19249 if (!pfx && i == 2) { 19261 if (!pfx && i == 2) {
@@ -19289,7 +19301,7 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
19289 19301
19290 if (!pin) 19302 if (!pin)
19291 return 0; 19303 return 0;
19292 nid = alc662_look_for_dac(codec, pin); 19304 nid = alc_auto_look_for_dac(codec, pin);
19293 if (!nid) { 19305 if (!nid) {
19294 /* the corresponding DAC is already occupied */ 19306 /* the corresponding DAC is already occupied */
19295 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) 19307 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
@@ -19299,7 +19311,7 @@ static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
19299 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); 19311 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19300 } 19312 }
19301 19313
19302 mix = alc662_dac_to_mix(codec, pin, nid); 19314 mix = alc_auto_dac_to_mix(codec, pin, nid);
19303 if (!mix) 19315 if (!mix)
19304 return 0; 19316 return 0;
19305 err = alc662_add_vol_ctl(spec, pfx, nid, 3); 19317 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
@@ -19325,7 +19337,7 @@ static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19325 alc_set_pin_output(codec, nid, pin_type); 19337 alc_set_pin_output(codec, nid, pin_type);
19326 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); 19338 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19327 for (i = 0; i < num; i++) { 19339 for (i = 0; i < num; i++) {
19328 if (alc662_mix_to_dac(codec, srcs[i]) != dac) 19340 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
19329 continue; 19341 continue;
19330 /* need the manual connection? */ 19342 /* need the manual connection? */
19331 if (num > 1) 19343 if (num > 1)