From 8aeda93df9caffa10bb10550554269253162e9a9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Nov 2011 14:34:20 +0100 Subject: [PATCH] --- yaml --- r: 284215 b: refs/heads/master c: 358b6e62b86f6313d114e0f6b7d8f8adaf85ed9c h: refs/heads/master i: 284213: 8a88b59dcb1c52e2655379f8d85f5ec948662b69 284211: da2225b3d42d0d9a0373064f23bb5551a4252af0 284207: 616f7ba3894ce18e15f000b5c56365a1dbca30ef v: v3 --- [refs] | 2 +- trunk/sound/pci/hda/hda_codec.c | 52 ++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index c52cffcb5344..7b1cce661eac 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d6018bb566f6eef277184278b105e04705e8aeb6 +refs/heads/master: 358b6e62b86f6313d114e0f6b7d8f8adaf85ed9c diff --git a/trunk/sound/pci/hda/hda_codec.c b/trunk/sound/pci/hda/hda_codec.c index b703e25b6241..de3325e79087 100644 --- a/trunk/sound/pci/hda/hda_codec.c +++ b/trunk/sound/pci/hda/hda_codec.c @@ -5066,6 +5066,16 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, } 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 */ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, int num_pins, int *indexp) @@ -5075,19 +5085,17 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, }; int i; - for (i = 0; i < num_pins; i++) { - if (pins[i] == nid) { - if (num_pins == 1) - return ""; - if (num_pins > ARRAY_SIZE(channel_sfx)) { - if (indexp) - *indexp = i; - return ""; - } - return channel_sfx[i]; - } + i = find_idx_in_nid_list(nid, pins, num_pins); + if (i < 0) + return NULL; + if (num_pins == 1) + return ""; + if (num_pins > ARRAY_SIZE(channel_sfx)) { + if (indexp) + *indexp = i; + return ""; } - return NULL; + return channel_sfx[i]; } static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, @@ -5115,14 +5123,17 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, /* try to give a unique suffix if needed */ sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, indexp); - if (!sfx) - sfx = check_output_sfx(nid, cfg->hp_pins, cfg->hp_outs, - indexp); if (!sfx) sfx = check_output_sfx(nid, cfg->speaker_pins, cfg->speaker_outs, 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 = ""; + } } snprintf(label, maxlen, "%s%s%s", pfx, name, sfx); return 1; @@ -5171,11 +5182,10 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, else name = "SPDIF"; if (cfg && indexp) { - for (i = 0; i < cfg->dig_outs; i++) - if (cfg->dig_out_pins[i] == nid) { - *indexp = i; - break; - } + i = find_idx_in_nid_list(nid, cfg->dig_out_pins, + cfg->dig_outs); + if (i >= 0) + *indexp = i; } break; default: