aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-01-07 09:11:44 -0500
committerTakashi Iwai <tiwai@suse.de>2013-01-12 02:44:03 -0500
commit0e614dd058ec8a426c16d2057fc814696c2381d9 (patch)
tree2c5d657b20e937a4d58c853c9d443f1432781f03
parentcd5be3f9de8945f782e1bbeffd080876eb2aa9f8 (diff)
ALSA: hda - Use direct path reference in assign_out_path_ctls()
Instead of looking through paths with the dac -> pin connection at each time, just pass the already parsed path index to assign_out_path_ctls(). This simplifies the code a bit. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_generic.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1b8fd4d6cae9..3f9439c39311 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -757,23 +757,26 @@ enum {
757 BAD_SHARED_VOL = 0x10, 757 BAD_SHARED_VOL = 0x10,
758}; 758};
759 759
760/* look for widgets in the path between the given NIDs appropriate for 760/* look for widgets in the given path which are appropriate for
761 * volume and mute controls, and assign the values to ctls[]. 761 * volume and mute controls, and assign the values to ctls[].
762 * 762 *
763 * When no appropriate widget is found in the path, the badness value 763 * When no appropriate widget is found in the path, the badness value
764 * is incremented depending on the situation. The function returns the 764 * is incremented depending on the situation. The function returns the
765 * total badness for both volume and mute controls. 765 * total badness for both volume and mute controls.
766 */ 766 */
767static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, 767static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path)
768 hda_nid_t dac)
769{ 768{
770 struct nid_path *path = snd_hda_get_nid_path(codec, dac, pin);
771 hda_nid_t nid; 769 hda_nid_t nid;
772 unsigned int val; 770 unsigned int val;
773 int badness = 0; 771 int badness = 0;
774 772
775 if (!path) 773 if (!path)
776 return BAD_SHARED_VOL * 2; 774 return BAD_SHARED_VOL * 2;
775
776 if (path->ctls[NID_PATH_VOL_CTL] ||
777 path->ctls[NID_PATH_MUTE_CTL])
778 return 0; /* already evaluated */
779
777 nid = look_for_out_vol_nid(codec, path); 780 nid = look_for_out_vol_nid(codec, path);
778 if (nid) { 781 if (nid) {
779 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 782 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
@@ -866,8 +869,9 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
866 struct nid_path *path; 869 struct nid_path *path;
867 hda_nid_t pin = pins[i]; 870 hda_nid_t pin = pins[i];
868 871
869 if (dacs[i]) { 872 path = snd_hda_get_path_from_idx(codec, path_idx[i]);
870 badness += assign_out_path_ctls(codec, pin, dacs[i]); 873 if (path) {
874 badness += assign_out_path_ctls(codec, path);
871 continue; 875 continue;
872 } 876 }
873 877
@@ -916,9 +920,8 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
916 print_nid_path("output", path); 920 print_nid_path("output", path);
917 path->active = true; 921 path->active = true;
918 path_idx[i] = snd_hda_get_path_idx(codec, path); 922 path_idx[i] = snd_hda_get_path_idx(codec, path);
923 badness += assign_out_path_ctls(codec, path);
919 } 924 }
920 if (dac)
921 badness += assign_out_path_ctls(codec, pin, dac);
922 } 925 }
923 926
924 return badness; 927 return badness;
@@ -1001,6 +1004,7 @@ static int fill_multi_ios(struct hda_codec *codec,
1001 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); 1004 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin);
1002 unsigned int location = get_defcfg_location(defcfg); 1005 unsigned int location = get_defcfg_location(defcfg);
1003 int badness = 0; 1006 int badness = 0;
1007 struct nid_path *path;
1004 1008
1005 old_pins = spec->multi_ios; 1009 old_pins = spec->multi_ios;
1006 if (old_pins >= 2) 1010 if (old_pins >= 2)
@@ -1012,7 +1016,6 @@ static int fill_multi_ios(struct hda_codec *codec,
1012 1016
1013 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 1017 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
1014 for (i = 0; i < cfg->num_inputs; i++) { 1018 for (i = 0; i < cfg->num_inputs; i++) {
1015 struct nid_path *path;
1016 hda_nid_t nid = cfg->inputs[i].pin; 1019 hda_nid_t nid = cfg->inputs[i].pin;
1017 hda_nid_t dac = 0; 1020 hda_nid_t dac = 0;
1018 1021
@@ -1067,9 +1070,10 @@ static int fill_multi_ios(struct hda_codec *codec,
1067 } 1070 }
1068 1071
1069 /* assign volume and mute controls */ 1072 /* assign volume and mute controls */
1070 for (i = old_pins; i < spec->multi_ios; i++) 1073 for (i = old_pins; i < spec->multi_ios; i++) {
1071 badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, 1074 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]);
1072 spec->multi_io[i].dac); 1075 badness += assign_out_path_ctls(codec, path);
1076 }
1073 1077
1074 return badness; 1078 return badness;
1075} 1079}