Commit cca3b371 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] hda-codec - Clean up bind-controls

We have already a generic bind-control helper, so let's clean up the codes
using it.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 47fd830a
......@@ -1127,23 +1127,14 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
}
/* bind volumes of both NID 0x05 and 0x06 */
static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
return change;
}
static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
.ops = &snd_hda_bind_vol,
.values = {
HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
0
},
};
/* mute internal speaker if HP is plugged */
static void ad1981_hp_automute(struct hda_codec *codec)
......@@ -1204,14 +1195,7 @@ static struct hda_input_mux ad1981_hp_capture_source = {
};
static struct snd_kcontrol_new ad1981_hp_mixers[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = ad1981_hp_master_vol_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
......
......@@ -483,23 +483,14 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
}
/* bind volumes of both NID 0x10 and 0x11 */
static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
return change;
}
static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
.ops = &snd_hda_bind_vol,
.values = {
HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
0
},
};
/* toggle input of built-in and mic jack appropriately */
static void cxt5045_hp_automic(struct hda_codec *codec)
......@@ -567,14 +558,7 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = cxt5045_hp_master_vol_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
......@@ -897,23 +881,14 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
}
/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
return change;
}
static struct hda_bind_ctls cxt5047_bind_master_vol = {
.ops = &snd_hda_bind_vol,
.values = {
HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
0
},
};
/* mute internal speaker if HP is plugged */
static void cxt5047_hp_automute(struct hda_codec *codec)
......@@ -1035,14 +1010,7 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = cxt5047_hp_master_vol_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
......
......@@ -7408,23 +7408,14 @@ static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
}
/* bind volumes of both NID 0x0c and 0x0d */
static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
return change;
}
static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
.ops = &snd_hda_bind_vol,
.values = {
HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
0
},
};
/* bind hp and internal speaker mute (with plug check) */
static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
......@@ -7446,15 +7437,7 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
}
static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = alc262_fujitsu_master_vol_put,
.tlv = { .c = snd_hda_mixer_amp_tlv },
.private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
......
......@@ -2400,63 +2400,28 @@ static struct hda_verb vaio_ar_init[] = {
};
/* bind volumes of both NID 0x02 and 0x05 */
static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[0]);
snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
HDA_AMP_VOLMASK, valp[1]);
return change;
}
static struct hda_bind_ctls vaio_bind_master_vol = {
.ops = &snd_hda_bind_vol,
.values = {
HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
0
},
};
/* bind volumes of both NID 0x02 and 0x05 */
static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
long *valp = ucontrol->value.integer.value;
int change;
change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
HDA_AMP_MUTE,
(valp[0] ? 0 : HDA_AMP_MUTE));
change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
HDA_AMP_MUTE,
(valp[1] ? 0 : HDA_AMP_MUTE));
snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
HDA_AMP_MUTE, (valp[0] ? 0 : HDA_AMP_MUTE));
snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
HDA_AMP_MUTE, (valp[1] ? 0 : HDA_AMP_MUTE));
return change;
}
static struct hda_bind_ctls vaio_bind_master_sw = {
.ops = &snd_hda_bind_sw,
.values = {
HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
0,
},
};
static struct snd_kcontrol_new vaio_mixer[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = vaio_master_vol_put,
.tlv = { .c = snd_hda_mixer_amp_tlv },
.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
.info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get,
.put = vaio_master_sw_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
/* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
......@@ -2472,22 +2437,8 @@ static struct snd_kcontrol_new vaio_mixer[] = {
};
static struct snd_kcontrol_new vaio_ar_mixer[] = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
.info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get,
.put = vaio_master_vol_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
.info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get,
.put = vaio_master_sw_put,
.private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
},
HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
/* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
......
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