Commit 5e26dfd0 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA: hda - simplify usage of HDA_SUBDEV_AMP_FLAG

The HDA_SUBDEV_NID_FLAG is duplicate for amplifier control elements. Move
get_amp_nid_() call to the snd_hda_ctl_add() function.
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 9e3fd871
...@@ -1733,11 +1733,14 @@ int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, ...@@ -1733,11 +1733,14 @@ int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
unsigned short flags = 0; unsigned short flags = 0;
struct hda_nid_item *item; struct hda_nid_item *item;
if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) {
flags |= HDA_NID_ITEM_AMP; flags |= HDA_NID_ITEM_AMP;
if (nid == 0)
nid = get_amp_nid_(kctl->private_value);
}
if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0) if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0)
nid = kctl->id.subdevice & 0xffff; nid = kctl->id.subdevice & 0xffff;
if (kctl->id.subdevice & 0xf0000000) if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG))
kctl->id.subdevice = 0; kctl->id.subdevice = 0;
err = snd_ctl_add(codec->bus->card, kctl); err = snd_ctl_add(codec->bus->card, kctl);
if (err < 0) if (err < 0)
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
/* mono volume with index (index=0,1,...) (channel=1,2) */ /* mono volume with index (index=0,1,...) (channel=1,2) */
#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | (nid), \ .subdevice = HDA_SUBDEV_AMP_FLAG, \
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
/* mono mute switch with index (index=0,1,...) (channel=1,2) */ /* mono mute switch with index (index=0,1,...) (channel=1,2) */
#define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | (nid), \ .subdevice = HDA_SUBDEV_AMP_FLAG, \
.info = snd_hda_mixer_amp_switch_info, \ .info = snd_hda_mixer_amp_switch_info, \
.get = snd_hda_mixer_amp_switch_get, \ .get = snd_hda_mixer_amp_switch_get, \
.put = snd_hda_mixer_amp_switch_put, \ .put = snd_hda_mixer_amp_switch_put, \
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
/* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */ /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */
#define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | (nid), \ .subdevice = HDA_SUBDEV_AMP_FLAG, \
.info = snd_hda_mixer_amp_switch_info, \ .info = snd_hda_mixer_amp_switch_info, \
.get = snd_hda_mixer_amp_switch_get, \ .get = snd_hda_mixer_amp_switch_get, \
.put = snd_hda_mixer_amp_switch_put_beep, \ .put = snd_hda_mixer_amp_switch_put_beep, \
......
...@@ -209,9 +209,7 @@ static int ad198x_build_controls(struct hda_codec *codec) ...@@ -209,9 +209,7 @@ static int ad198x_build_controls(struct hda_codec *codec)
if (!kctl) if (!kctl)
return -ENOMEM; return -ENOMEM;
kctl->private_value = spec->beep_amp; kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, err = snd_hda_ctl_add(codec, 0, kctl);
get_amp_nid_(spec->beep_amp),
kctl);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -832,7 +830,7 @@ static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = { ...@@ -832,7 +830,7 @@ static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x1a, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = ad1986a_hp_master_sw_put, .put = ad1986a_hp_master_sw_put,
...@@ -2602,9 +2600,7 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name, ...@@ -2602,9 +2600,7 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name,
if (! knew->name) if (! knew->name)
return -ENOMEM; return -ENOMEM;
if (get_amp_nid_(val)) if (get_amp_nid_(val))
knew->subdevice = HDA_SUBDEV_NID_FLAG | knew->subdevice = HDA_SUBDEV_AMP_FLAG;
HDA_SUBDEV_AMP_FLAG |
get_amp_nid_(val);
knew->private_value = val; knew->private_value = val;
return 0; return 0;
} }
...@@ -3758,7 +3754,7 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { ...@@ -3758,7 +3754,7 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x21, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = ad1884a_mobile_master_sw_put, .put = ad1884a_mobile_master_sw_put,
...@@ -3787,7 +3783,7 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { ...@@ -3787,7 +3783,7 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x21, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = ad1884a_mobile_master_sw_put, .put = ad1884a_mobile_master_sw_put,
...@@ -4129,7 +4125,7 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = { ...@@ -4129,7 +4125,7 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
/* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x21, .subdevice = HDA_SUBDEV_AMP_FLAG,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
......
...@@ -501,7 +501,7 @@ static int add_mute(struct hda_codec *codec, const char *name, int index, ...@@ -501,7 +501,7 @@ static int add_mute(struct hda_codec *codec, const char *name, int index,
snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]);
*kctlp = snd_ctl_new1(&knew, codec); *kctlp = snd_ctl_new1(&knew, codec);
(*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG;
return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); return snd_hda_ctl_add(codec, 0, *kctlp);
} }
static int add_volume(struct hda_codec *codec, const char *name, static int add_volume(struct hda_codec *codec, const char *name,
...@@ -515,7 +515,7 @@ static int add_volume(struct hda_codec *codec, const char *name, ...@@ -515,7 +515,7 @@ static int add_volume(struct hda_codec *codec, const char *name,
snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]);
*kctlp = snd_ctl_new1(&knew, codec); *kctlp = snd_ctl_new1(&knew, codec);
(*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG;
return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); return snd_hda_ctl_add(codec, 0, *kctlp);
} }
static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
......
...@@ -2178,7 +2178,7 @@ static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { ...@@ -2178,7 +2178,7 @@ static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_TLV_READ |
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x10, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_volume_info, .info = snd_hda_mixer_amp_volume_info,
.get = snd_hda_mixer_amp_volume_get, .get = snd_hda_mixer_amp_volume_get,
.put = snd_hda_mixer_amp_volume_put, .put = snd_hda_mixer_amp_volume_put,
......
...@@ -2482,8 +2482,7 @@ static int alc_build_controls(struct hda_codec *codec) ...@@ -2482,8 +2482,7 @@ static int alc_build_controls(struct hda_codec *codec)
if (!kctl) if (!kctl)
return -ENOMEM; return -ENOMEM;
kctl->private_value = spec->beep_amp; kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, err = snd_hda_ctl_add(codec, 0, kctl);
get_amp_nid_(spec->beep_amp), kctl);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -4414,9 +4413,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, ...@@ -4414,9 +4413,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
if (!knew->name) if (!knew->name)
return -ENOMEM; return -ENOMEM;
if (get_amp_nid_(val)) if (get_amp_nid_(val))
knew->subdevice = HDA_SUBDEV_NID_FLAG | knew->subdevice = HDA_SUBDEV_AMP_FLAG;
HDA_SUBDEV_AMP_FLAG |
get_amp_nid_(val);
knew->private_value = val; knew->private_value = val;
return 0; return 0;
} }
...@@ -10921,7 +10918,7 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { ...@@ -10921,7 +10918,7 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc262_fujitsu_master_sw_put, .put = alc262_fujitsu_master_sw_put,
...@@ -10962,7 +10959,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { ...@@ -10962,7 +10959,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x1b, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc262_lenovo_3000_master_sw_put, .put = alc262_lenovo_3000_master_sw_put,
...@@ -12139,7 +12136,7 @@ static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { ...@@ -12139,7 +12136,7 @@ static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc268_acer_master_sw_put, .put = alc268_acer_master_sw_put,
...@@ -12155,7 +12152,7 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = { ...@@ -12155,7 +12152,7 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc268_acer_master_sw_put, .put = alc268_acer_master_sw_put,
...@@ -12173,7 +12170,7 @@ static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = { ...@@ -12173,7 +12170,7 @@ static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc268_acer_master_sw_put, .put = alc268_acer_master_sw_put,
...@@ -13126,7 +13123,7 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { ...@@ -13126,7 +13123,7 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc268_acer_master_sw_put, .put = alc268_acer_master_sw_put,
...@@ -13147,7 +13144,7 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = { ...@@ -13147,7 +13144,7 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
{ {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch", .name = "Master Playback Switch",
.subdevice = HDA_SUBDEV_NID_FLAG | HDA_SUBDEV_AMP_FLAG | 0x14, .subdevice = HDA_SUBDEV_AMP_FLAG,
.info = snd_hda_mixer_amp_switch_info, .info = snd_hda_mixer_amp_switch_info,
.get = snd_hda_mixer_amp_switch_get, .get = snd_hda_mixer_amp_switch_get,
.put = alc268_acer_master_sw_put, .put = alc268_acer_master_sw_put,
......
...@@ -2685,7 +2685,7 @@ static struct snd_kcontrol_new * ...@@ -2685,7 +2685,7 @@ static struct snd_kcontrol_new *
stac_control_new(struct sigmatel_spec *spec, stac_control_new(struct sigmatel_spec *spec,
struct snd_kcontrol_new *ktemp, struct snd_kcontrol_new *ktemp,
const char *name, const char *name,
hda_nid_t nid) unsigned int subdev)
{ {
struct snd_kcontrol_new *knew; struct snd_kcontrol_new *knew;
...@@ -2701,9 +2701,7 @@ stac_control_new(struct sigmatel_spec *spec, ...@@ -2701,9 +2701,7 @@ stac_control_new(struct sigmatel_spec *spec,
spec->kctls.alloced--; spec->kctls.alloced--;
return NULL; return NULL;
} }
if (nid) knew->subdevice = subdev;
knew->subdevice = HDA_SUBDEV_NID_FLAG |
HDA_SUBDEV_AMP_FLAG | nid;
return knew; return knew;
} }
...@@ -2713,7 +2711,7 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec, ...@@ -2713,7 +2711,7 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
unsigned long val) unsigned long val)
{ {
struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
get_amp_nid_(val)); HDA_SUBDEV_AMP_FLAG);
if (!knew) if (!knew)
return -ENOMEM; return -ENOMEM;
knew->index = idx; knew->index = idx;
......
...@@ -458,9 +458,7 @@ static int via_add_control(struct via_spec *spec, int type, const char *name, ...@@ -458,9 +458,7 @@ static int via_add_control(struct via_spec *spec, int type, const char *name,
if (!knew->name) if (!knew->name)
return -ENOMEM; return -ENOMEM;
if (get_amp_nid_(val)) if (get_amp_nid_(val))
knew->subdevice = HDA_SUBDEV_NID_FLAG | knew->subdevice = HDA_SUBDEV_AMP_FLAG;
HDA_SUBDEV_AMP_FLAG |
get_amp_nid_(val);
knew->private_value = val; knew->private_value = val;
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