diff options
| -rw-r--r-- | sound/pci/hda/hda_auto_parser.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index a98e25ebfd63..4ec6dc88b7f8 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c | |||
| @@ -498,6 +498,38 @@ static const char *check_output_sfx(hda_nid_t nid, const hda_nid_t *pins, | |||
| 498 | return channel_sfx[i]; | 498 | return channel_sfx[i]; |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | static const char *check_output_pfx(struct hda_codec *codec, hda_nid_t nid) | ||
| 502 | { | ||
| 503 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
| 504 | int attr = snd_hda_get_input_pin_attr(def_conf); | ||
| 505 | |||
| 506 | /* check the location */ | ||
| 507 | switch (attr) { | ||
| 508 | case INPUT_PIN_ATTR_DOCK: | ||
| 509 | return "Dock "; | ||
| 510 | case INPUT_PIN_ATTR_FRONT: | ||
| 511 | return "Front "; | ||
| 512 | } | ||
| 513 | return ""; | ||
| 514 | } | ||
| 515 | |||
| 516 | static int get_hp_label_index(struct hda_codec *codec, hda_nid_t nid, | ||
| 517 | const hda_nid_t *pins, int num_pins) | ||
| 518 | { | ||
| 519 | int i, j, idx = 0; | ||
| 520 | |||
| 521 | const char *pfx = check_output_pfx(codec, nid); | ||
| 522 | |||
| 523 | i = find_idx_in_nid_list(nid, pins, num_pins); | ||
| 524 | if (i < 0) | ||
| 525 | return -1; | ||
| 526 | for (j = 0; j < i; j++) | ||
| 527 | if (pfx == check_output_pfx(codec, pins[j])) | ||
| 528 | idx++; | ||
| 529 | |||
| 530 | return idx; | ||
| 531 | } | ||
| 532 | |||
| 501 | static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | 533 | static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, |
| 502 | const struct auto_pin_cfg *cfg, | 534 | const struct auto_pin_cfg *cfg, |
| 503 | const char *name, char *label, int maxlen, | 535 | const char *name, char *label, int maxlen, |
| @@ -505,20 +537,13 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | |||
| 505 | { | 537 | { |
| 506 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 538 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 507 | int attr = snd_hda_get_input_pin_attr(def_conf); | 539 | int attr = snd_hda_get_input_pin_attr(def_conf); |
| 508 | const char *pfx = "", *sfx = ""; | 540 | const char *pfx, *sfx = ""; |
| 509 | 541 | ||
| 510 | /* handle as a speaker if it's a fixed line-out */ | 542 | /* handle as a speaker if it's a fixed line-out */ |
| 511 | if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) | 543 | if (!strcmp(name, "Line Out") && attr == INPUT_PIN_ATTR_INT) |
| 512 | name = "Speaker"; | 544 | name = "Speaker"; |
| 513 | /* check the location */ | 545 | pfx = check_output_pfx(codec, nid); |
| 514 | switch (attr) { | 546 | |
| 515 | case INPUT_PIN_ATTR_DOCK: | ||
| 516 | pfx = "Dock "; | ||
| 517 | break; | ||
| 518 | case INPUT_PIN_ATTR_FRONT: | ||
| 519 | pfx = "Front "; | ||
| 520 | break; | ||
| 521 | } | ||
| 522 | if (cfg) { | 547 | if (cfg) { |
| 523 | /* try to give a unique suffix if needed */ | 548 | /* try to give a unique suffix if needed */ |
| 524 | sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, | 549 | sfx = check_output_sfx(nid, cfg->line_out_pins, cfg->line_outs, |
| @@ -528,8 +553,8 @@ static int fill_audio_out_name(struct hda_codec *codec, hda_nid_t nid, | |||
| 528 | indexp); | 553 | indexp); |
| 529 | if (!sfx) { | 554 | if (!sfx) { |
| 530 | /* don't add channel suffix for Headphone controls */ | 555 | /* don't add channel suffix for Headphone controls */ |
| 531 | int idx = find_idx_in_nid_list(nid, cfg->hp_pins, | 556 | int idx = get_hp_label_index(codec, nid, cfg->hp_pins, |
| 532 | cfg->hp_outs); | 557 | cfg->hp_outs); |
| 533 | if (idx >= 0) | 558 | if (idx >= 0) |
| 534 | *indexp = idx; | 559 | *indexp = idx; |
| 535 | sfx = ""; | 560 | sfx = ""; |
