提交 668b9652 编写于 作者: T Takashi Iwai

ALSA: hda - Create multiple HP / speaker controls with index

Create multiple "Headphone" and "Speaker" controls with non-zero index
numbers instead of "Headphone2", etc.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 7a411ee0
...@@ -1227,10 +1227,7 @@ static const char *slave_vols[] = { ...@@ -1227,10 +1227,7 @@ static const char *slave_vols[] = {
"LFE Playback Volume", "LFE Playback Volume",
"Side Playback Volume", "Side Playback Volume",
"Headphone Playback Volume", "Headphone Playback Volume",
"Headphone2 Playback Volume",
"Speaker Playback Volume", "Speaker Playback Volume",
"External Speaker Playback Volume",
"Speaker2 Playback Volume",
NULL NULL
}; };
...@@ -1241,10 +1238,7 @@ static const char *slave_sws[] = { ...@@ -1241,10 +1238,7 @@ static const char *slave_sws[] = {
"LFE Playback Switch", "LFE Playback Switch",
"Side Playback Switch", "Side Playback Switch",
"Headphone Playback Switch", "Headphone Playback Switch",
"Headphone2 Playback Switch",
"Speaker Playback Switch", "Speaker Playback Switch",
"External Speaker Playback Switch",
"Speaker2 Playback Switch",
"IEC958 Playback Switch", "IEC958 Playback Switch",
NULL NULL
}; };
...@@ -2976,8 +2970,8 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) ...@@ -2976,8 +2970,8 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
} }
/* create volume control/switch for the given prefx type */ /* create volume control/switch for the given prefx type */
static int create_controls(struct hda_codec *codec, const char *pfx, static int create_controls_idx(struct hda_codec *codec, const char *pfx,
hda_nid_t nid, int chs) int idx, hda_nid_t nid, int chs)
{ {
struct sigmatel_spec *spec = codec->spec; struct sigmatel_spec *spec = codec->spec;
char name[32]; char name[32];
...@@ -3001,19 +2995,22 @@ static int create_controls(struct hda_codec *codec, const char *pfx, ...@@ -3001,19 +2995,22 @@ static int create_controls(struct hda_codec *codec, const char *pfx,
} }
sprintf(name, "%s Playback Volume", pfx); sprintf(name, "%s Playback Volume", pfx);
err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
spec->volume_offset)); spec->volume_offset));
if (err < 0) if (err < 0)
return err; return err;
sprintf(name, "%s Playback Switch", pfx); sprintf(name, "%s Playback Switch", pfx);
err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
if (err < 0) if (err < 0)
return err; return err;
return 0; return 0;
} }
#define create_controls(codec, pfx, nid, chs) \
create_controls_idx(codec, pfx, 0, nid, chs)
static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
{ {
if (spec->multiout.num_dacs > 4) { if (spec->multiout.num_dacs > 4) {
...@@ -3051,12 +3048,6 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, ...@@ -3051,12 +3048,6 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
static const char *chname[4] = { static const char *chname[4] = {
"Front", "Surround", NULL /*CLFE*/, "Side" "Front", "Surround", NULL /*CLFE*/, "Side"
}; };
static const char *hp_pfxs[] = {
"Headphone", "Headphone2", "Headphone3", "Headphone4"
};
static const char *speaker_pfxs[] = {
"Speaker", "External Speaker", "Speaker2", "Speaker3"
};
hda_nid_t nid; hda_nid_t nid;
int i, err; int i, err;
unsigned int wid_caps; unsigned int wid_caps;
...@@ -3087,18 +3078,22 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, ...@@ -3087,18 +3078,22 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
} else { } else {
const char *name; const char *name;
int idx;
switch (type) { switch (type) {
case AUTO_PIN_HP_OUT: case AUTO_PIN_HP_OUT:
name = hp_pfxs[i]; name = "Headphone";
idx = i;
break; break;
case AUTO_PIN_SPEAKER_OUT: case AUTO_PIN_SPEAKER_OUT:
name = speaker_pfxs[i]; name = "Speaker";
idx = i;
break; break;
default: default:
name = chname[i]; name = chname[i];
idx = 0;
break; break;
} }
err = create_controls(codec, name, nid, 3); err = create_controls_idx(codec, name, idx, nid, 3);
if (err < 0) if (err < 0)
return err; return err;
if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册