ALSA: hda - Clean up multi-channel mixer name assignment in patch_realtek.c
Change alc_get_line_out_pfx() in patch_realtek.c to provide the channel specific name and assign the index so that each caller doesn't have to set the channel name by itself. Also, check the multi-io case with the primary hp-out; for the multi-io channels, assign the channel name instead of "Headphone" with indices. This makes the mixer names more intuitive and reduces confusion. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1af7c5f0d4
commit
6843ca16f5
1 changed files with 36 additions and 56 deletions
|
@ -5359,11 +5359,15 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *alc_get_line_out_pfx(struct alc_spec *spec,
|
static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
|
||||||
bool can_be_master)
|
bool can_be_master, int *index)
|
||||||
{
|
{
|
||||||
struct auto_pin_cfg *cfg = &spec->autocfg;
|
struct auto_pin_cfg *cfg = &spec->autocfg;
|
||||||
|
static const char * const chname[4] = {
|
||||||
|
"Front", "Surround", NULL /*CLFE*/, "Side"
|
||||||
|
};
|
||||||
|
|
||||||
|
*index = 0;
|
||||||
if (cfg->line_outs == 1 && !spec->multi_ios &&
|
if (cfg->line_outs == 1 && !spec->multi_ios &&
|
||||||
!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
|
!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
|
||||||
return "Master";
|
return "Master";
|
||||||
|
@ -5374,23 +5378,23 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec,
|
||||||
return "Speaker";
|
return "Speaker";
|
||||||
break;
|
break;
|
||||||
case AUTO_PIN_HP_OUT:
|
case AUTO_PIN_HP_OUT:
|
||||||
|
/* for multi-io case, only the primary out */
|
||||||
|
if (ch && spec->multi_ios)
|
||||||
|
break;
|
||||||
|
*index = ch;
|
||||||
return "Headphone";
|
return "Headphone";
|
||||||
default:
|
default:
|
||||||
if (cfg->line_outs == 1 && !spec->multi_ios)
|
if (cfg->line_outs == 1 && !spec->multi_ios)
|
||||||
return "PCM";
|
return "PCM";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return chname[ch];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add playback controls from the parsed DAC table */
|
/* add playback controls from the parsed DAC table */
|
||||||
static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
|
static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
const struct auto_pin_cfg *cfg)
|
const struct auto_pin_cfg *cfg)
|
||||||
{
|
{
|
||||||
static const char * const chname[4] = {
|
|
||||||
"Front", "Surround", NULL /*CLFE*/, "Side"
|
|
||||||
};
|
|
||||||
const char *pfx = alc_get_line_out_pfx(spec, false);
|
|
||||||
hda_nid_t nid;
|
hda_nid_t nid;
|
||||||
int i, err, noutputs;
|
int i, err, noutputs;
|
||||||
|
|
||||||
|
@ -5399,10 +5403,13 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
noutputs += spec->multi_ios;
|
noutputs += spec->multi_ios;
|
||||||
|
|
||||||
for (i = 0; i < noutputs; i++) {
|
for (i = 0; i < noutputs; i++) {
|
||||||
|
const char *name;
|
||||||
|
int index;
|
||||||
if (!spec->multiout.dac_nids[i])
|
if (!spec->multiout.dac_nids[i])
|
||||||
continue;
|
continue;
|
||||||
nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
|
nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
|
||||||
if (!pfx && i == 2) {
|
name = alc_get_line_out_pfx(spec, i, false, &index);
|
||||||
|
if (!name) {
|
||||||
/* Center/LFE */
|
/* Center/LFE */
|
||||||
err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
||||||
"Center",
|
"Center",
|
||||||
|
@ -5429,12 +5436,6 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
const char *name = pfx;
|
|
||||||
int index = i;
|
|
||||||
if (!name) {
|
|
||||||
name = chname[i];
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
||||||
name, index,
|
name, index,
|
||||||
HDA_COMPOSE_AMP_VAL(nid, 3, 0,
|
HDA_COMPOSE_AMP_VAL(nid, 3, 0,
|
||||||
|
@ -12257,17 +12258,18 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
{
|
{
|
||||||
const char *pfx;
|
const char *pfx;
|
||||||
int vbits;
|
int vbits;
|
||||||
int i, err;
|
int i, index, 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->private_dac_nids[0] = 2;
|
spec->private_dac_nids[0] = 2;
|
||||||
|
|
||||||
pfx = alc_get_line_out_pfx(spec, true);
|
|
||||||
if (!pfx)
|
|
||||||
pfx = "Front";
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
|
pfx = alc_get_line_out_pfx(spec, i, true, &index);
|
||||||
|
if (!pfx)
|
||||||
|
pfx = "PCM";
|
||||||
|
err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx,
|
||||||
|
index);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
|
if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
|
||||||
|
@ -12287,10 +12289,11 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
|
vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
|
||||||
alc262_check_volbit(cfg->speaker_pins[0]) |
|
alc262_check_volbit(cfg->speaker_pins[0]) |
|
||||||
alc262_check_volbit(cfg->hp_pins[0]);
|
alc262_check_volbit(cfg->hp_pins[0]);
|
||||||
if (vbits == 1 || vbits == 2)
|
|
||||||
pfx = "Master"; /* only one mixer is used */
|
|
||||||
vbits = 0;
|
vbits = 0;
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
|
pfx = alc_get_line_out_pfx(spec, i, true, &index);
|
||||||
|
if (!pfx)
|
||||||
|
pfx = "PCM";
|
||||||
err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
|
err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
|
||||||
&vbits, i);
|
&vbits, i);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -16035,10 +16038,6 @@ static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
const struct auto_pin_cfg *cfg)
|
const struct auto_pin_cfg *cfg)
|
||||||
{
|
{
|
||||||
struct alc_spec *spec = codec->spec;
|
struct alc_spec *spec = codec->spec;
|
||||||
static const char * const chname[4] = {
|
|
||||||
"Front", "Surround", NULL /*CLFE*/, "Side"
|
|
||||||
};
|
|
||||||
const char *pfx = alc_get_line_out_pfx(spec, true);
|
|
||||||
hda_nid_t nid;
|
hda_nid_t nid;
|
||||||
int i, err, noutputs;
|
int i, err, noutputs;
|
||||||
|
|
||||||
|
@ -16047,10 +16046,13 @@ static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
noutputs += spec->multi_ios;
|
noutputs += spec->multi_ios;
|
||||||
|
|
||||||
for (i = 0; i < noutputs; i++) {
|
for (i = 0; i < noutputs; i++) {
|
||||||
|
const char *name;
|
||||||
|
int index;
|
||||||
nid = spec->multiout.dac_nids[i];
|
nid = spec->multiout.dac_nids[i];
|
||||||
if (!nid)
|
if (!nid)
|
||||||
continue;
|
continue;
|
||||||
if (!pfx && i == 2) {
|
name = alc_get_line_out_pfx(spec, i, true, &index);
|
||||||
|
if (!name) {
|
||||||
/* Center/LFE */
|
/* Center/LFE */
|
||||||
err = alc861_create_out_sw(codec, "Center", nid, 1);
|
err = alc861_create_out_sw(codec, "Center", nid, 1);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -16059,12 +16061,6 @@ static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
const char *name = pfx;
|
|
||||||
int index = i;
|
|
||||||
if (!name) {
|
|
||||||
name = chname[i];
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
err = __alc861_create_out_sw(codec, name, nid, index, 3);
|
err = __alc861_create_out_sw(codec, name, nid, index, 3);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
@ -17178,10 +17174,6 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
|
||||||
static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
|
static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
const struct auto_pin_cfg *cfg)
|
const struct auto_pin_cfg *cfg)
|
||||||
{
|
{
|
||||||
static const char * const chname[4] = {
|
|
||||||
"Front", "Surround", "CLFE", "Side"
|
|
||||||
};
|
|
||||||
const char *pfx = alc_get_line_out_pfx(spec, true);
|
|
||||||
hda_nid_t nid_v, nid_s;
|
hda_nid_t nid_v, nid_s;
|
||||||
int i, err, noutputs;
|
int i, err, noutputs;
|
||||||
|
|
||||||
|
@ -17190,6 +17182,8 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
noutputs += spec->multi_ios;
|
noutputs += spec->multi_ios;
|
||||||
|
|
||||||
for (i = 0; i < noutputs; i++) {
|
for (i = 0; i < noutputs; i++) {
|
||||||
|
const char *name;
|
||||||
|
int index;
|
||||||
if (!spec->multiout.dac_nids[i])
|
if (!spec->multiout.dac_nids[i])
|
||||||
continue;
|
continue;
|
||||||
nid_v = alc861vd_idx_to_mixer_vol(
|
nid_v = alc861vd_idx_to_mixer_vol(
|
||||||
|
@ -17199,7 +17193,8 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
alc880_dac_to_idx(
|
alc880_dac_to_idx(
|
||||||
spec->multiout.dac_nids[i]));
|
spec->multiout.dac_nids[i]));
|
||||||
|
|
||||||
if (!pfx && i == 2) {
|
name = alc_get_line_out_pfx(spec, i, true, &index);
|
||||||
|
if (!name) {
|
||||||
/* Center/LFE */
|
/* Center/LFE */
|
||||||
err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
||||||
"Center",
|
"Center",
|
||||||
|
@ -17226,12 +17221,6 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
const char *name = pfx;
|
|
||||||
int index = i;
|
|
||||||
if (!name) {
|
|
||||||
name = chname[i];
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
|
||||||
name, index,
|
name, index,
|
||||||
HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
|
HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
|
||||||
|
@ -19030,10 +19019,6 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
const struct auto_pin_cfg *cfg)
|
const struct auto_pin_cfg *cfg)
|
||||||
{
|
{
|
||||||
struct alc_spec *spec = codec->spec;
|
struct alc_spec *spec = codec->spec;
|
||||||
static const char * const chname[4] = {
|
|
||||||
"Front", "Surround", NULL /*CLFE*/, "Side"
|
|
||||||
};
|
|
||||||
const char *pfx = alc_get_line_out_pfx(spec, true);
|
|
||||||
hda_nid_t nid, mix, pin;
|
hda_nid_t nid, mix, pin;
|
||||||
int i, err, noutputs;
|
int i, err, noutputs;
|
||||||
|
|
||||||
|
@ -19042,6 +19027,8 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
noutputs += spec->multi_ios;
|
noutputs += spec->multi_ios;
|
||||||
|
|
||||||
for (i = 0; i < noutputs; i++) {
|
for (i = 0; i < noutputs; i++) {
|
||||||
|
const char *name;
|
||||||
|
int index;
|
||||||
nid = spec->multiout.dac_nids[i];
|
nid = spec->multiout.dac_nids[i];
|
||||||
if (!nid)
|
if (!nid)
|
||||||
continue;
|
continue;
|
||||||
|
@ -19052,7 +19039,8 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
mix = alc_auto_dac_to_mix(codec, pin, nid);
|
mix = alc_auto_dac_to_mix(codec, pin, nid);
|
||||||
if (!mix)
|
if (!mix)
|
||||||
continue;
|
continue;
|
||||||
if (!pfx && i == 2) {
|
name = alc_get_line_out_pfx(spec, i, true, &index);
|
||||||
|
if (!name) {
|
||||||
/* Center/LFE */
|
/* Center/LFE */
|
||||||
err = alc662_add_vol_ctl(spec, "Center", nid, 1);
|
err = alc662_add_vol_ctl(spec, "Center", nid, 1);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -19067,12 +19055,6 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
const char *name = pfx;
|
|
||||||
int index = i;
|
|
||||||
if (!name) {
|
|
||||||
name = chname[i];
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
|
err = __alc662_add_vol_ctl(spec, name, nid, index, 3);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
@ -19361,8 +19343,6 @@ static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
|
||||||
spec->multi_ios = num_pins;
|
spec->multi_ios = num_pins;
|
||||||
spec->ext_channel_count = 2;
|
spec->ext_channel_count = 2;
|
||||||
spec->multiout.num_dacs = num_pins + 1;
|
spec->multiout.num_dacs = num_pins + 1;
|
||||||
/* for avoiding multi HP mixers */
|
|
||||||
cfg->line_out_type = AUTO_PIN_LINE_OUT;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue