diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-03-10 09:41:05 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-03-10 10:13:23 -0400 |
commit | b880c74adf7e79b97de710a152ea82f292f9abc7 (patch) | |
tree | 0793f8387973592fcd0e0e69bbb45f8dd64cdf5f /sound/pci | |
parent | dd5746a85cb21ea5b3afca0b569586a05aa56846 (diff) |
ALSA: hda - Create "Capture Source" control dynamically in patch_conexant.c
Create "Capture Source" control dynamically for Conexant codecs.
If only one capture item is available, don't create such a control
since it's just useless.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index e1476d6d8b39..d5d736ff7c6c 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -463,6 +463,17 @@ static void conexant_free(struct hda_codec *codec) | |||
463 | kfree(codec->spec); | 463 | kfree(codec->spec); |
464 | } | 464 | } |
465 | 465 | ||
466 | static struct snd_kcontrol_new cxt_capture_mixers[] = { | ||
467 | { | ||
468 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
469 | .name = "Capture Source", | ||
470 | .info = conexant_mux_enum_info, | ||
471 | .get = conexant_mux_enum_get, | ||
472 | .put = conexant_mux_enum_put | ||
473 | }, | ||
474 | {} | ||
475 | }; | ||
476 | |||
466 | static const char *slave_vols[] = { | 477 | static const char *slave_vols[] = { |
467 | "Headphone Playback Volume", | 478 | "Headphone Playback Volume", |
468 | "Speaker Playback Volume", | 479 | "Speaker Playback Volume", |
@@ -522,6 +533,12 @@ static int conexant_build_controls(struct hda_codec *codec) | |||
522 | return err; | 533 | return err; |
523 | } | 534 | } |
524 | 535 | ||
536 | if (spec->input_mux) { | ||
537 | err = snd_hda_add_new_ctls(codec, cxt_capture_mixers); | ||
538 | if (err < 0) | ||
539 | return err; | ||
540 | } | ||
541 | |||
525 | return 0; | 542 | return 0; |
526 | } | 543 | } |
527 | 544 | ||
@@ -753,13 +770,6 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec, | |||
753 | } | 770 | } |
754 | 771 | ||
755 | static struct snd_kcontrol_new cxt5045_mixers[] = { | 772 | static struct snd_kcontrol_new cxt5045_mixers[] = { |
756 | { | ||
757 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
758 | .name = "Capture Source", | ||
759 | .info = conexant_mux_enum_info, | ||
760 | .get = conexant_mux_enum_get, | ||
761 | .put = conexant_mux_enum_put | ||
762 | }, | ||
763 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), | 773 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), |
764 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), | 774 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), |
765 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), | 775 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), |
@@ -793,13 +803,6 @@ static struct snd_kcontrol_new cxt5045_benq_mixers[] = { | |||
793 | }; | 803 | }; |
794 | 804 | ||
795 | static struct snd_kcontrol_new cxt5045_mixers_hp530[] = { | 805 | static struct snd_kcontrol_new cxt5045_mixers_hp530[] = { |
796 | { | ||
797 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
798 | .name = "Capture Source", | ||
799 | .info = conexant_mux_enum_info, | ||
800 | .get = conexant_mux_enum_get, | ||
801 | .put = conexant_mux_enum_put | ||
802 | }, | ||
803 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), | 806 | HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), |
804 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), | 807 | HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), |
805 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), | 808 | HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), |
@@ -1170,20 +1173,6 @@ static struct hda_channel_mode cxt5047_modes[1] = { | |||
1170 | { 2, NULL }, | 1173 | { 2, NULL }, |
1171 | }; | 1174 | }; |
1172 | 1175 | ||
1173 | static struct hda_input_mux cxt5047_capture_source = { | ||
1174 | .num_items = 1, | ||
1175 | .items = { | ||
1176 | { "Mic", 0x2 }, | ||
1177 | } | ||
1178 | }; | ||
1179 | |||
1180 | static struct hda_input_mux cxt5047_hp_capture_source = { | ||
1181 | .num_items = 1, | ||
1182 | .items = { | ||
1183 | { "ExtMic", 0x2 }, | ||
1184 | } | ||
1185 | }; | ||
1186 | |||
1187 | static struct hda_input_mux cxt5047_toshiba_capture_source = { | 1176 | static struct hda_input_mux cxt5047_toshiba_capture_source = { |
1188 | .num_items = 2, | 1177 | .num_items = 2, |
1189 | .items = { | 1178 | .items = { |
@@ -1321,13 +1310,6 @@ static struct snd_kcontrol_new cxt5047_mixers[] = { | |||
1321 | }; | 1310 | }; |
1322 | 1311 | ||
1323 | static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = { | 1312 | static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = { |
1324 | { | ||
1325 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1326 | .name = "Capture Source", | ||
1327 | .info = conexant_mux_enum_info, | ||
1328 | .get = conexant_mux_enum_get, | ||
1329 | .put = conexant_mux_enum_put | ||
1330 | }, | ||
1331 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), | 1313 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), |
1332 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), | 1314 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), |
1333 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), | 1315 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
@@ -1349,13 +1331,6 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = { | |||
1349 | }; | 1331 | }; |
1350 | 1332 | ||
1351 | static struct snd_kcontrol_new cxt5047_hp_mixers[] = { | 1333 | static struct snd_kcontrol_new cxt5047_hp_mixers[] = { |
1352 | { | ||
1353 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1354 | .name = "Capture Source", | ||
1355 | .info = conexant_mux_enum_info, | ||
1356 | .get = conexant_mux_enum_get, | ||
1357 | .put = conexant_mux_enum_put | ||
1358 | }, | ||
1359 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), | 1334 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), |
1360 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT), | 1335 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT), |
1361 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), | 1336 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
@@ -1614,7 +1589,6 @@ static int patch_cxt5047(struct hda_codec *codec) | |||
1614 | spec->num_adc_nids = 1; | 1589 | spec->num_adc_nids = 1; |
1615 | spec->adc_nids = cxt5047_adc_nids; | 1590 | spec->adc_nids = cxt5047_adc_nids; |
1616 | spec->capsrc_nids = cxt5047_capsrc_nids; | 1591 | spec->capsrc_nids = cxt5047_capsrc_nids; |
1617 | spec->input_mux = &cxt5047_capture_source; | ||
1618 | spec->num_mixers = 1; | 1592 | spec->num_mixers = 1; |
1619 | spec->mixers[0] = cxt5047_mixers; | 1593 | spec->mixers[0] = cxt5047_mixers; |
1620 | spec->num_init_verbs = 1; | 1594 | spec->num_init_verbs = 1; |
@@ -1633,7 +1607,6 @@ static int patch_cxt5047(struct hda_codec *codec) | |||
1633 | codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; | 1607 | codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; |
1634 | break; | 1608 | break; |
1635 | case CXT5047_LAPTOP_HP: | 1609 | case CXT5047_LAPTOP_HP: |
1636 | spec->input_mux = &cxt5047_hp_capture_source; | ||
1637 | spec->num_init_verbs = 2; | 1610 | spec->num_init_verbs = 2; |
1638 | spec->init_verbs[1] = cxt5047_hp_init_verbs; | 1611 | spec->init_verbs[1] = cxt5047_hp_init_verbs; |
1639 | spec->mixers[0] = cxt5047_hp_mixers; | 1612 | spec->mixers[0] = cxt5047_hp_mixers; |