Commit 358b6e62 authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarTakashi Iwai <tiwai@suse.de>
parent d6018bb5
...@@ -5066,6 +5066,16 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, ...@@ -5066,6 +5066,16 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec,
} }
EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label);
/* return the position of NID in the list, or -1 if not found */
static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
{
int i;
for (i = 0; i < nums; i++)
if (list[i] == nid)
return i;
return -1;
}
/* get a unique suffix or an index number */ /* get a unique suffix or an index number */
static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
int num_pins, int *indexp) int num_pins, int *indexp)
...@@ -5075,8 +5085,9 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, ...@@ -5075,8 +5085,9 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
}; };
int i; int i;
for (i = 0; i < num_pins; i++) { i = find_idx_in_nid_list(nid, pins, num_pins);
if (pins[i] == nid) { if (i < 0)
return NULL;
if (num_pins == 1) if (num_pins == 1)
return ""; return "";
if (num_pins > ARRAY_SIZE(channel_sfx)) { if (num_pins > ARRAY_SIZE(channel_sfx)) {
...@@ -5085,9 +5096,6 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, ...@@ -5085,9 +5096,6 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins,
return ""; return "";
} }
return channel_sfx[i]; return channel_sfx[i];
}
}
return NULL;
} }
static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
...@@ -5115,15 +5123,18 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, ...@@ -5115,15 +5123,18 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid,
/* try to give a unique suffix if needed */ /* try to give a unique suffix if needed */
sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs,
indexp); indexp);
if (!sfx)
sfx = check_output_sfx(nid, cfg->hp_pins, cfg->hp_outs,
indexp);
if (!sfx) if (!sfx)
sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs,
indexp); indexp);
if (!sfx) if (!sfx) {
/* don't add channel suffix for Headphone controls */
int idx = find_idx_in_nid_list(nid, cfg->hp_pins,
cfg->hp_outs);
if (idx >= 0)
*indexp = idx;
sfx = ""; sfx = "";
} }
}
snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); snprintf(label, maxlen, "%s%s%s", pfx, name, sfx);
return 1; return 1;
} }
...@@ -5171,11 +5182,10 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, ...@@ -5171,11 +5182,10 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
else else
name = "SPDIF"; name = "SPDIF";
if (cfg && indexp) { if (cfg && indexp) {
for (i = 0; i < cfg->dig_outs; i++) i = find_idx_in_nid_list(nid, cfg->dig_out_pins,
if (cfg->dig_out_pins[i] == nid) { cfg->dig_outs);
if (i >= 0)
*indexp = i; *indexp = i;
break;
}
} }
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment