aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-08-10 11:12:15 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:58:45 -0400
commitcca3b3718ca96dca51daf1129ac03003bcede751 (patch)
tree32dc0ee54e783fe0021f26061dfbdd37beef4d1f /sound/pci
parent47fd830acf0b6b5bc75db55d0f2cc64f59a23b5f (diff)
[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: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_analog.c34
-rw-r--r--sound/pci/hda/patch_conexant.c68
-rw-r--r--sound/pci/hda/patch_realtek.c35
-rw-r--r--sound/pci/hda/patch_sigmatel.c89
4 files changed, 56 insertions, 170 deletions
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index febc2053f08e..f9390a544ea4 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1127,23 +1127,14 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1127} 1127}
1128 1128
1129/* bind volumes of both NID 0x05 and 0x06 */ 1129/* bind volumes of both NID 0x05 and 0x06 */
1130static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol, 1130static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1131 struct snd_ctl_elem_value *ucontrol) 1131 .ops = &snd_hda_bind_vol,
1132{ 1132 .values = {
1133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1133 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1134 long *valp = ucontrol->value.integer.value; 1134 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1135 int change; 1135 0
1136 1136 },
1137 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, 1137};
1138 HDA_AMP_VOLMASK, valp[0]);
1139 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1140 HDA_AMP_VOLMASK, valp[1]);
1141 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1142 HDA_AMP_VOLMASK, valp[0]);
1143 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1144 HDA_AMP_VOLMASK, valp[1]);
1145 return change;
1146}
1147 1138
1148/* mute internal speaker if HP is plugged */ 1139/* mute internal speaker if HP is plugged */
1149static void ad1981_hp_automute(struct hda_codec *codec) 1140static void ad1981_hp_automute(struct hda_codec *codec)
@@ -1204,14 +1195,7 @@ static struct hda_input_mux ad1981_hp_capture_source = {
1204}; 1195};
1205 1196
1206static struct snd_kcontrol_new ad1981_hp_mixers[] = { 1197static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1207 { 1198 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1209 .name = "Master Playback Volume",
1210 .info = snd_hda_mixer_amp_volume_info,
1211 .get = snd_hda_mixer_amp_volume_get,
1212 .put = ad1981_hp_master_vol_put,
1213 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1214 },
1215 { 1199 {
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 .name = "Master Playback Switch", 1201 .name = "Master Playback Switch",
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index ebf83275756e..080e3001d9c5 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -483,23 +483,14 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
483} 483}
484 484
485/* bind volumes of both NID 0x10 and 0x11 */ 485/* bind volumes of both NID 0x10 and 0x11 */
486static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol, 486static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
487 struct snd_ctl_elem_value *ucontrol) 487 .ops = &snd_hda_bind_vol,
488{ 488 .values = {
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 489 HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
490 long *valp = ucontrol->value.integer.value; 490 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
491 int change; 491 0
492 492 },
493 change = snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 493};
494 HDA_AMP_VOLMASK, valp[0]);
495 change |= snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0,
496 HDA_AMP_VOLMASK, valp[1]);
497 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0,
498 HDA_AMP_VOLMASK, valp[0]);
499 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0,
500 HDA_AMP_VOLMASK, valp[1]);
501 return change;
502}
503 494
504/* toggle input of built-in and mic jack appropriately */ 495/* toggle input of built-in and mic jack appropriately */
505static void cxt5045_hp_automic(struct hda_codec *codec) 496static void cxt5045_hp_automic(struct hda_codec *codec)
@@ -567,14 +558,7 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
567 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT), 558 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
568 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT), 559 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
569 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT), 560 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
570 { 561 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
571 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
572 .name = "Master Playback Volume",
573 .info = snd_hda_mixer_amp_volume_info,
574 .get = snd_hda_mixer_amp_volume_get,
575 .put = cxt5045_hp_master_vol_put,
576 .private_value = HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
577 },
578 { 562 {
579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
580 .name = "Master Playback Switch", 564 .name = "Master Playback Switch",
@@ -897,23 +881,14 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
897} 881}
898 882
899/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */ 883/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
900static int cxt5047_hp_master_vol_put(struct snd_kcontrol *kcontrol, 884static struct hda_bind_ctls cxt5047_bind_master_vol = {
901 struct snd_ctl_elem_value *ucontrol) 885 .ops = &snd_hda_bind_vol,
902{ 886 .values = {
903 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 887 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
904 long *valp = ucontrol->value.integer.value; 888 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
905 int change; 889 0
906 890 },
907 change = snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 891};
908 HDA_AMP_VOLMASK, valp[0]);
909 change |= snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0,
910 HDA_AMP_VOLMASK, valp[1]);
911 snd_hda_codec_amp_update(codec, 0x13, 0, HDA_OUTPUT, 0,
912 HDA_AMP_VOLMASK, valp[0]);
913 snd_hda_codec_amp_update(codec, 0x13, 1, HDA_OUTPUT, 0,
914 HDA_AMP_VOLMASK, valp[1]);
915 return change;
916}
917 892
918/* mute internal speaker if HP is plugged */ 893/* mute internal speaker if HP is plugged */
919static void cxt5047_hp_automute(struct hda_codec *codec) 894static void cxt5047_hp_automute(struct hda_codec *codec)
@@ -1035,14 +1010,7 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1035 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1010 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1036 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1011 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 1012 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1038 { 1013 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1040 .name = "Master Playback Volume",
1041 .info = snd_hda_mixer_amp_volume_info,
1042 .get = snd_hda_mixer_amp_volume_get,
1043 .put = cxt5047_hp_master_vol_put,
1044 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1045 },
1046 { 1014 {
1047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1048 .name = "Master Playback Switch", 1016 .name = "Master Playback Switch",
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 29119fd4017d..ebbabeb32930 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7408,23 +7408,14 @@ static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7408} 7408}
7409 7409
7410/* bind volumes of both NID 0x0c and 0x0d */ 7410/* bind volumes of both NID 0x0c and 0x0d */
7411static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, 7411static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7412 struct snd_ctl_elem_value *ucontrol) 7412 .ops = &snd_hda_bind_vol,
7413{ 7413 .values = {
7414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 7414 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7415 long *valp = ucontrol->value.integer.value; 7415 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7416 int change; 7416 0
7417 7417 },
7418 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, 7418};
7419 HDA_AMP_VOLMASK, valp[0]);
7420 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7421 HDA_AMP_VOLMASK, valp[1]);
7422 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7423 HDA_AMP_VOLMASK, valp[0]);
7424 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7425 HDA_AMP_VOLMASK, valp[1]);
7426 return change;
7427}
7428 7419
7429/* bind hp and internal speaker mute (with plug check) */ 7420/* bind hp and internal speaker mute (with plug check) */
7430static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 7421static 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,
7446} 7437}
7447 7438
7448static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { 7439static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7449 { 7440 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
7450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7451 .name = "Master Playback Volume",
7452 .info = snd_hda_mixer_amp_volume_info,
7453 .get = snd_hda_mixer_amp_volume_get,
7454 .put = alc262_fujitsu_master_vol_put,
7455 .tlv = { .c = snd_hda_mixer_amp_tlv },
7456 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7457 },
7458 { 7441 {
7459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7460 .name = "Master Playback Switch", 7443 .name = "Master Playback Switch",
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 1690726c1e13..bf5d91b63d15 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2400,63 +2400,28 @@ static struct hda_verb vaio_ar_init[] = {
2400}; 2400};
2401 2401
2402/* bind volumes of both NID 0x02 and 0x05 */ 2402/* bind volumes of both NID 0x02 and 0x05 */
2403static int vaio_master_vol_put(struct snd_kcontrol *kcontrol, 2403static struct hda_bind_ctls vaio_bind_master_vol = {
2404 struct snd_ctl_elem_value *ucontrol) 2404 .ops = &snd_hda_bind_vol,
2405{ 2405 .values = {
2406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2406 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2407 long *valp = ucontrol->value.integer.value; 2407 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2408 int change; 2408 0
2409 2409 },
2410 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, 2410};
2411 HDA_AMP_VOLMASK, valp[0]);
2412 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
2413 HDA_AMP_VOLMASK, valp[1]);
2414 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
2415 HDA_AMP_VOLMASK, valp[0]);
2416 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
2417 HDA_AMP_VOLMASK, valp[1]);
2418 return change;
2419}
2420 2411
2421/* bind volumes of both NID 0x02 and 0x05 */ 2412/* bind volumes of both NID 0x02 and 0x05 */
2422static int vaio_master_sw_put(struct snd_kcontrol *kcontrol, 2413static struct hda_bind_ctls vaio_bind_master_sw = {
2423 struct snd_ctl_elem_value *ucontrol) 2414 .ops = &snd_hda_bind_sw,
2424{ 2415 .values = {
2425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2416 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2426 long *valp = ucontrol->value.integer.value; 2417 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2427 int change; 2418 0,
2428 2419 },
2429 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, 2420};
2430 HDA_AMP_MUTE,
2431 (valp[0] ? 0 : HDA_AMP_MUTE));
2432 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
2433 HDA_AMP_MUTE,
2434 (valp[1] ? 0 : HDA_AMP_MUTE));
2435 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
2436 HDA_AMP_MUTE, (valp[0] ? 0 : HDA_AMP_MUTE));
2437 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
2438 HDA_AMP_MUTE, (valp[1] ? 0 : HDA_AMP_MUTE));
2439 return change;
2440}
2441 2421
2442static struct snd_kcontrol_new vaio_mixer[] = { 2422static struct snd_kcontrol_new vaio_mixer[] = {
2443 { 2423 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2424 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2445 .name = "Master Playback Volume",
2446 .info = snd_hda_mixer_amp_volume_info,
2447 .get = snd_hda_mixer_amp_volume_get,
2448 .put = vaio_master_vol_put,
2449 .tlv = { .c = snd_hda_mixer_amp_tlv },
2450 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2451 },
2452 {
2453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2454 .name = "Master Playback Switch",
2455 .info = snd_hda_mixer_amp_switch_info,
2456 .get = snd_hda_mixer_amp_switch_get,
2457 .put = vaio_master_sw_put,
2458 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2459 },
2460 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ 2425 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2461 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 2426 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2462 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 2427 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
@@ -2472,22 +2437,8 @@ static struct snd_kcontrol_new vaio_mixer[] = {
2472}; 2437};
2473 2438
2474static struct snd_kcontrol_new vaio_ar_mixer[] = { 2439static struct snd_kcontrol_new vaio_ar_mixer[] = {
2475 { 2440 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2441 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2477 .name = "Master Playback Volume",
2478 .info = snd_hda_mixer_amp_volume_info,
2479 .get = snd_hda_mixer_amp_volume_get,
2480 .put = vaio_master_vol_put,
2481 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2482 },
2483 {
2484 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2485 .name = "Master Playback Switch",
2486 .info = snd_hda_mixer_amp_switch_info,
2487 .get = snd_hda_mixer_amp_switch_get,
2488 .put = vaio_master_sw_put,
2489 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2490 },
2491 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ 2442 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2492 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 2443 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2493 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 2444 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),