Commit 05c3b36e authored by David Henningsson's avatar David Henningsson Committed by Takashi Iwai

ALSA: HDA: Fix jack creation for codecs with front and rear Line In

If a codec has both a front and a rear Line In, two controls both
named "Line Jack" will be created, which causes parsing to fail.
While a long term solution might be to name the jacks differently,
this extra check is consistent with what is already being done in many
auto-parsers, and will also protect against other cases when two
inputs have the same label.

BugLink: https://bugs.launchpad.net/bugs/923409Signed-off-by: default avatarDavid Henningsson <david.henningsson@canonical.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 31150f23
...@@ -282,7 +282,8 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, ...@@ -282,7 +282,8 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl); EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl);
static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg,
char *lastname, int *lastidx)
{ {
unsigned int def_conf, conn; unsigned int def_conf, conn;
char name[44]; char name[44];
...@@ -298,6 +299,10 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, ...@@ -298,6 +299,10 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
return 0; return 0;
snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx); snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx);
if (!strcmp(name, lastname) && idx == *lastidx)
idx++;
strncpy(lastname, name, 44);
*lastidx = idx;
err = snd_hda_jack_add_kctl(codec, nid, name, idx); err = snd_hda_jack_add_kctl(codec, nid, name, idx);
if (err < 0) if (err < 0)
return err; return err;
...@@ -311,41 +316,42 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, ...@@ -311,41 +316,42 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg)
{ {
const hda_nid_t *p; const hda_nid_t *p;
int i, err; int i, err, lastidx = 0;
char lastname[44] = "";
for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) { for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) {
err = add_jack_kctl(codec, *p, cfg); err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
} }
for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) { for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) {
if (*p == *cfg->line_out_pins) /* might be duplicated */ if (*p == *cfg->line_out_pins) /* might be duplicated */
break; break;
err = add_jack_kctl(codec, *p, cfg); err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
} }
for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) { for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) {
if (*p == *cfg->line_out_pins) /* might be duplicated */ if (*p == *cfg->line_out_pins) /* might be duplicated */
break; break;
err = add_jack_kctl(codec, *p, cfg); err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
} }
for (i = 0; i < cfg->num_inputs; i++) { for (i = 0; i < cfg->num_inputs; i++) {
err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg); err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
} }
for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) { for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) {
err = add_jack_kctl(codec, *p, cfg); err = add_jack_kctl(codec, *p, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
} }
err = add_jack_kctl(codec, cfg->dig_in_pin, cfg); err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
err = add_jack_kctl(codec, cfg->mono_out_pin, cfg); err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, lastname, &lastidx);
if (err < 0) if (err < 0)
return err; return err;
return 0; return 0;
......
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