aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/oxygen_mixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-16 02:28:17 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:59 -0500
commit31c77643a06313b3a26f4c38c75ceec2a89ad31a (patch)
treeb38b6be831ebf4ebd20df512b1544938a3cbd224 /sound/pci/oxygen/oxygen_mixer.c
parent12b74c80cc20dec27b9f9eeb24ee86170c34e5a1 (diff)
[ALSA] oxygen: make AC97 codec optional
Only initialize and create mixer controls for the first AC97 codec when one has actually been detected. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen_mixer.c')
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index aa3a5c53d605..8b08e6d02cc9 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -597,6 +597,9 @@ static const struct snd_kcontrol_new controls[] = {
597 .info = spdif_info, 597 .info = spdif_info,
598 .get = spdif_input_default_get, 598 .get = spdif_input_default_get,
599 }, 599 },
600};
601
602static const struct snd_kcontrol_new ac97_controls[] = {
600 AC97_VOLUME("Mic Capture Volume", AC97_MIC), 603 AC97_VOLUME("Mic Capture Volume", AC97_MIC),
601 AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1), 604 AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1),
602 AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0), 605 AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0),
@@ -617,7 +620,9 @@ static void oxygen_any_ctl_free(struct snd_kcontrol *ctl)
617 chip->controls[i] = NULL; 620 chip->controls[i] = NULL;
618} 621}
619 622
620int oxygen_mixer_init(struct oxygen *chip) 623static int add_controls(struct oxygen *chip,
624 const struct snd_kcontrol_new controls[],
625 unsigned int count)
621{ 626{
622 static const char *const known_ctl_names[CONTROL_COUNT] = { 627 static const char *const known_ctl_names[CONTROL_COUNT] = {
623 [CONTROL_SPDIF_PCM] = 628 [CONTROL_SPDIF_PCM] =
@@ -633,7 +638,7 @@ int oxygen_mixer_init(struct oxygen *chip)
633 struct snd_kcontrol *ctl; 638 struct snd_kcontrol *ctl;
634 int err; 639 int err;
635 640
636 for (i = 0; i < ARRAY_SIZE(controls); ++i) { 641 for (i = 0; i < count; ++i) {
637 ctl = snd_ctl_new1(&controls[i], chip); 642 ctl = snd_ctl_new1(&controls[i], chip);
638 if (!ctl) 643 if (!ctl)
639 return -ENOMEM; 644 return -ENOMEM;
@@ -651,5 +656,21 @@ int oxygen_mixer_init(struct oxygen *chip)
651 ctl->private_free = oxygen_any_ctl_free; 656 ctl->private_free = oxygen_any_ctl_free;
652 } 657 }
653 } 658 }
659 return 0;
660}
661
662int oxygen_mixer_init(struct oxygen *chip)
663{
664 int err;
665
666 err = add_controls(chip, controls, ARRAY_SIZE(controls));
667 if (err < 0)
668 return err;
669 if (chip->has_ac97_0) {
670 err = add_controls(chip, ac97_controls,
671 ARRAY_SIZE(ac97_controls));
672 if (err < 0)
673 return err;
674 }
654 return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0; 675 return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0;
655} 676}