aboutsummaryrefslogtreecommitdiff
path: root/sound/pci/oxygen/oxygen_mixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-16 08:28:17 +0100
committerJaroslav Kysela <perex@perex.cz>2008-01-31 17:29:59 +0100
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 aa3a5c53d60..8b08e6d02cc 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[] = {
.info = spdif_info,
.get = spdif_input_default_get,
},
+};
+
+static const struct snd_kcontrol_new ac97_controls[] = {
AC97_VOLUME("Mic Capture Volume", AC97_MIC),
AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1),
AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0),
@@ -617,7 +620,9 @@ static void oxygen_any_ctl_free(struct snd_kcontrol *ctl)
chip->controls[i] = NULL;
}
-int oxygen_mixer_init(struct oxygen *chip)
+static int add_controls(struct oxygen *chip,
+ const struct snd_kcontrol_new controls[],
+ unsigned int count)
{
static const char *const known_ctl_names[CONTROL_COUNT] = {
[CONTROL_SPDIF_PCM] =
@@ -633,7 +638,7 @@ int oxygen_mixer_init(struct oxygen *chip)
struct snd_kcontrol *ctl;
int err;
- for (i = 0; i < ARRAY_SIZE(controls); ++i) {
+ for (i = 0; i < count; ++i) {
ctl = snd_ctl_new1(&controls[i], chip);
if (!ctl)
return -ENOMEM;
@@ -651,5 +656,21 @@ int oxygen_mixer_init(struct oxygen *chip)
ctl->private_free = oxygen_any_ctl_free;
}
}
+ return 0;
+}
+
+int oxygen_mixer_init(struct oxygen *chip)
+{
+ int err;
+
+ err = add_controls(chip, controls, ARRAY_SIZE(controls));
+ if (err < 0)
+ return err;
+ if (chip->has_ac97_0) {
+ err = add_controls(chip, ac97_controls,
+ ARRAY_SIZE(ac97_controls));
+ if (err < 0)
+ return err;
+ }
return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0;
}