aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-11-21 08:34:20 -0500
committerTakashi Iwai <tiwai@suse.de>2011-11-21 08:34:20 -0500
commit358b6e62b86f6313d114e0f6b7d8f8adaf85ed9c (patch)
tree2c5c88efdcadf28553741124825c1f901ff7e0b8 /sound
parentd6018bb566f6eef277184278b105e04705e8aeb6 (diff)
ALSA: hda - Don't add channel suffix for headphone pin labels
The multiple headphone pins are usually handled as copied from the same source, not as individual channels like front and surround. Thus it'd be more correct to avoid the channel suffix for "Headphone" pin labels in snd_hda_get_pin_label() but give an index number instead. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_codec.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index b703e25b6241..de3325e79087 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -5066,6 +5066,16 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
5066} 5066}
5067EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); 5067EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
5068 5068
5069/* return the position of NID in the list, or -1 if not found */
5070static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
5071{
5072 int i;
5073 for (i = 0; i < nums; i++)
5074 if (list[i] == nid)
5075 return i;
5076 return -1;
5077}
5078
5069/* get a unique suffix or an index number */ 5079/* get a unique suffix or an index number */
5070static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, 5080static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
5071 int num_pins, int *indexp) 5081 int num_pins, int *indexp)
@@ -5075,19 +5085,17 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
5075 }; 5085 };
5076 int i; 5086 int i;
5077 5087
5078 for (i = 0; i < num_pins; i++) { 5088 i = find_idx_in_nid_list(nid, pins, num_pins);
5079 if (pins[i] == nid) { 5089 if (i < 0)
5080 if (num_pins == 1) 5090 return NULL;
5081 return ""; 5091 if (num_pins == 1)
5082 if (num_pins > ARRAY_SIZE(channel_sfx)) { 5092 return "";
5083 if (indexp) 5093 if (num_pins > ARRAY_SIZE(channel_sfx)) {
5084 *indexp = i; 5094 if (indexp)
5085 return ""; 5095 *indexp = i;
5086 } 5096 return "";
5087 return channel_sfx[i];
5088 }
5089 } 5097 }
5090 return NULL; 5098 return channel_sfx[i];
5091} 5099}
5092 5100
5093static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, 5101static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
@@ -5116,13 +5124,16 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
5116 sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, 5124 sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs,
5117 indexp); 5125 indexp);
5118 if (!sfx) 5126 if (!sfx)
5119 sfx = check_output_sfx(nid, cfg->hp_pins, cfg->hp_outs,
5120 indexp);
5121 if (!sfx)
5122 sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, 5127 sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs,
5123 indexp); 5128 indexp);
5124 if (!sfx) 5129 if (!sfx) {
5130 /* don't add channel suffix for Headphone controls */
5131 int idx = find_idx_in_nid_list(nid, cfg->hp_pins,
5132 cfg->hp_outs);
5133 if (idx >= 0)
5134 *indexp = idx;
5125 sfx = ""; 5135 sfx = "";
5136 }
5126 } 5137 }
5127 snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); 5138 snprintf(label, maxlen, "%s%s%s", pfx, name, sfx);
5128 return 1; 5139 return 1;
@@ -5171,11 +5182,10 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
5171 else 5182 else
5172 name = "SPDIF"; 5183 name = "SPDIF";
5173 if (cfg && indexp) { 5184 if (cfg && indexp) {
5174 for (i = 0; i < cfg->dig_outs; i++) 5185 i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
5175 if (cfg->dig_out_pins[i] == nid) { 5186 cfg->dig_outs);
5176 *indexp = i; 5187 if (i >= 0)
5177 break; 5188 *indexp = i;
5178 }
5179 } 5189 }
5180 break; 5190 break;
5181 default: 5191 default: