Commit c3fc1f50 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Improve auto-cfg mixer name for ALC262

Similar improvements for ALC262 codec like previous two commits:
assign a better name, either Master or Speaker, for the primary output
controls.

However, in the case of ALC262 codec, the necessary changes are larger
than others because we need to check the possibility of different mixer
amps depending on the pins.  The pin 0x16 is mono, and bound with the
dedicated mixer 0x0e while other pins are bound with 0x0c.  Thus, there
are two possible volumes.

When only one of them is used, we can name it as "Master".  OTOH, when
both are used at the same time, they have to be named uniquely.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 23112d6d
...@@ -10790,80 +10790,106 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { ...@@ -10790,80 +10790,106 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
{ } /* end */ { } /* end */
}; };
/* We use two mixers depending on the output pin; 0x16 is a mono output
* and thus it's bound with a different mixer.
* This function returns which mixer amp should be used.
*/
static int alc262_check_volbit(hda_nid_t nid)
{
if (!nid)
return 0;
else if (nid == 0x16)
return 2;
else
return 1;
}
static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
const char *pfx, int *vbits)
{
char name[32];
unsigned long val;
int vbit;
vbit = alc262_check_volbit(nid);
if (!vbit)
return 0;
if (*vbits & vbit) /* a volume control for this mixer already there */
return 0;
*vbits |= vbit;
snprintf(name, sizeof(name), "%s Playback Volume", pfx);
if (vbit == 2)
val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
else
val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
}
static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
const char *pfx)
{
char name[32];
unsigned long val;
if (!nid)
return 0;
snprintf(name, sizeof(name), "%s Playback Switch", pfx);
if (nid == 0x16)
val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
else
val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
}
/* add playback controls from the parsed DAC table */ /* add playback controls from the parsed DAC table */
static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg)
{ {
hda_nid_t nid; const char *pfx;
int vbits;
int err; int err;
spec->multiout.num_dacs = 1; /* only use one dac */ spec->multiout.num_dacs = 1; /* only use one dac */
spec->multiout.dac_nids = spec->private_dac_nids; spec->multiout.dac_nids = spec->private_dac_nids;
spec->multiout.dac_nids[0] = 2; spec->multiout.dac_nids[0] = 2;
nid = cfg->line_out_pins[0]; if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
if (nid) { pfx = "Master";
err = add_control(spec, ALC_CTL_WIDGET_VOL, else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
"Front Playback Volume", pfx = "Speaker";
HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); else
if (err < 0) pfx = "Front";
return err; err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
err = add_control(spec, ALC_CTL_WIDGET_MUTE, if (err < 0)
"Front Playback Switch", return err;
HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
if (err < 0) if (err < 0)
return err; return err;
} err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
if (err < 0)
return err;
nid = cfg->speaker_pins[0]; vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
if (nid) { alc262_check_volbit(cfg->speaker_pins[0]) |
if (nid == 0x16) { alc262_check_volbit(cfg->hp_pins[0]);
err = add_control(spec, ALC_CTL_WIDGET_VOL, if (vbits == 1 || vbits == 2)
"Speaker Playback Volume", pfx = "Master"; /* only one mixer is used */
HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
HDA_OUTPUT)); pfx = "Speaker";
if (err < 0) else
return err; pfx = "Front";
err = add_control(spec, ALC_CTL_WIDGET_MUTE, vbits = 0;
"Speaker Playback Switch", err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
HDA_COMPOSE_AMP_VAL(nid, 2, 0, if (err < 0)
HDA_OUTPUT)); return err;
if (err < 0) err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
return err; &vbits);
} else { if (err < 0)
err = add_control(spec, ALC_CTL_WIDGET_MUTE, return err;
"Speaker Playback Switch", err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
HDA_COMPOSE_AMP_VAL(nid, 3, 0, &vbits);
HDA_OUTPUT)); if (err < 0)
if (err < 0) return err;
return err;
}
}
nid = cfg->hp_pins[0];
if (nid) {
/* spec->multiout.hp_nid = 2; */
if (nid == 0x16) {
err = add_control(spec, ALC_CTL_WIDGET_VOL,
"Headphone Playback Volume",
HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
HDA_OUTPUT));
if (err < 0)
return err;
err = add_control(spec, ALC_CTL_WIDGET_MUTE,
"Headphone Playback Switch",
HDA_COMPOSE_AMP_VAL(nid, 2, 0,
HDA_OUTPUT));
if (err < 0)
return err;
} else {
err = add_control(spec, ALC_CTL_WIDGET_MUTE,
"Headphone Playback Switch",
HDA_COMPOSE_AMP_VAL(nid, 3, 0,
HDA_OUTPUT));
if (err < 0)
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