aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-03-22 09:53:50 -0400
committerTakashi Iwai <tiwai@suse.de>2013-03-22 09:53:50 -0400
commit98bd11152b5b8725b26d803dfdf205dc989d9832 (patch)
tree205b5de14c187db4695e2c71ed19117b6173bb88 /sound/pci/hda
parent10d7410790afd0d8bbe0bce72d82ccc7474df4ff (diff)
ALSA: hda - Allow codec drivers to give own badness tables
The standard badness values don't seem to fit to all preferences. Some configuration prefer the side output over the headphone, some want the speaker over the surround, etc. This patch moves the badness table pointers into hda_gen_spec, so that the codec driver can override them. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/hda_generic.c26
-rw-r--r--sound/pci/hda/hda_generic.h17
2 files changed, 29 insertions, 14 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 98c8627b2afb..326302fcab44 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -1062,16 +1062,7 @@ static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path)
1062 return badness; 1062 return badness;
1063} 1063}
1064 1064
1065struct badness_table { 1065const struct badness_table hda_main_out_badness = {
1066 int no_primary_dac; /* no primary DAC */
1067 int no_dac; /* no secondary DACs */
1068 int shared_primary; /* primary DAC is shared with main output */
1069 int shared_surr; /* secondary DAC shared with main or primary */
1070 int shared_clfe; /* third DAC shared with main or primary */
1071 int shared_surr_main; /* secondary DAC sahred with main/DAC0 */
1072};
1073
1074static struct badness_table main_out_badness = {
1075 .no_primary_dac = BAD_NO_PRIMARY_DAC, 1066 .no_primary_dac = BAD_NO_PRIMARY_DAC,
1076 .no_dac = BAD_NO_DAC, 1067 .no_dac = BAD_NO_DAC,
1077 .shared_primary = BAD_NO_PRIMARY_DAC, 1068 .shared_primary = BAD_NO_PRIMARY_DAC,
@@ -1079,8 +1070,9 @@ static struct badness_table main_out_badness = {
1079 .shared_clfe = BAD_SHARED_CLFE, 1070 .shared_clfe = BAD_SHARED_CLFE,
1080 .shared_surr_main = BAD_SHARED_SURROUND, 1071 .shared_surr_main = BAD_SHARED_SURROUND,
1081}; 1072};
1073EXPORT_SYMBOL_HDA(hda_main_out_badness);
1082 1074
1083static struct badness_table extra_out_badness = { 1075const struct badness_table hda_extra_out_badness = {
1084 .no_primary_dac = BAD_NO_DAC, 1076 .no_primary_dac = BAD_NO_DAC,
1085 .no_dac = BAD_NO_DAC, 1077 .no_dac = BAD_NO_DAC,
1086 .shared_primary = BAD_NO_EXTRA_DAC, 1078 .shared_primary = BAD_NO_EXTRA_DAC,
@@ -1088,6 +1080,7 @@ static struct badness_table extra_out_badness = {
1088 .shared_clfe = BAD_SHARED_EXTRA_SURROUND, 1080 .shared_clfe = BAD_SHARED_EXTRA_SURROUND,
1089 .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, 1081 .shared_surr_main = BAD_NO_EXTRA_SURR_DAC,
1090}; 1082};
1083EXPORT_SYMBOL_HDA(hda_extra_out_badness);
1091 1084
1092/* get the DAC of the primary output corresponding to the given array index */ 1085/* get the DAC of the primary output corresponding to the given array index */
1093static hda_nid_t get_primary_out(struct hda_codec *codec, int idx) 1086static hda_nid_t get_primary_out(struct hda_codec *codec, int idx)
@@ -1518,7 +1511,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
1518 1511
1519 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, 1512 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins,
1520 spec->private_dac_nids, spec->out_paths, 1513 spec->private_dac_nids, spec->out_paths,
1521 &main_out_badness); 1514 spec->main_out_badness);
1522 1515
1523 if (fill_mio_first && 1516 if (fill_mio_first &&
1524 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 1517 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
@@ -1533,7 +1526,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
1533 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, 1526 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins,
1534 spec->multiout.hp_out_nid, 1527 spec->multiout.hp_out_nid,
1535 spec->hp_paths, 1528 spec->hp_paths,
1536 &extra_out_badness); 1529 spec->extra_out_badness);
1537 if (err < 0) 1530 if (err < 0)
1538 return err; 1531 return err;
1539 badness += err; 1532 badness += err;
@@ -1543,7 +1536,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
1543 cfg->speaker_pins, 1536 cfg->speaker_pins,
1544 spec->multiout.extra_out_nid, 1537 spec->multiout.extra_out_nid,
1545 spec->speaker_paths, 1538 spec->speaker_paths,
1546 &extra_out_badness); 1539 spec->extra_out_badness);
1547 if (err < 0) 1540 if (err < 0)
1548 return err; 1541 return err;
1549 badness += err; 1542 badness += err;
@@ -4180,6 +4173,11 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
4180 cfg = &spec->autocfg; 4173 cfg = &spec->autocfg;
4181 } 4174 }
4182 4175
4176 if (!spec->main_out_badness)
4177 spec->main_out_badness = &hda_main_out_badness;
4178 if (!spec->extra_out_badness)
4179 spec->extra_out_badness = &hda_extra_out_badness;
4180
4183 fill_all_dac_nids(codec); 4181 fill_all_dac_nids(codec);
4184 4182
4185 if (!cfg->line_outs) { 4183 if (!cfg->line_outs) {
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
index 39d83943f25d..54e665160379 100644
--- a/sound/pci/hda/hda_generic.h
+++ b/sound/pci/hda/hda_generic.h
@@ -76,6 +76,19 @@ enum {
76 HDA_GEN_PCM_ACT_CLOSE, 76 HDA_GEN_PCM_ACT_CLOSE,
77}; 77};
78 78
79/* DAC assignment badness table */
80struct badness_table {
81 int no_primary_dac; /* no primary DAC */
82 int no_dac; /* no secondary DACs */
83 int shared_primary; /* primary DAC is shared with main output */
84 int shared_surr; /* secondary DAC shared with main or primary */
85 int shared_clfe; /* third DAC shared with main or primary */
86 int shared_surr_main; /* secondary DAC sahred with main/DAC0 */
87};
88
89extern const struct badness_table hda_main_out_badness;
90extern const struct badness_table hda_extra_out_badness;
91
79struct hda_gen_spec { 92struct hda_gen_spec {
80 char stream_name_analog[32]; /* analog PCM stream */ 93 char stream_name_analog[32]; /* analog PCM stream */
81 const struct hda_pcm_stream *stream_analog_playback; 94 const struct hda_pcm_stream *stream_analog_playback;
@@ -223,6 +236,10 @@ struct hda_gen_spec {
223 unsigned int have_aamix_ctl:1; 236 unsigned int have_aamix_ctl:1;
224 unsigned int hp_mic_jack_modes:1; 237 unsigned int hp_mic_jack_modes:1;
225 238
239 /* badness tables for output path evaluations */
240 const struct badness_table *main_out_badness;
241 const struct badness_table *extra_out_badness;
242
226 /* loopback mixing mode */ 243 /* loopback mixing mode */
227 bool aamix_mode; 244 bool aamix_mode;
228 245