aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/oxygen_mixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-14 08:56:01 +0100
committerJaroslav Kysela <perex@perex.cz>2008-01-31 17:29:57 +0100
commit01a3affb2eebfd6c996c36d82bbbc6040eb3a7f1 (patch)
treea80f44ba4a5d6997d932a7d80e9b517064eb2555 /sound/pci/oxygen/oxygen_mixer.c
parent7113e95812f508bff10f95f2e52ce6ee8cda1875 (diff)
downloadmrst-s0i3-test-01a3affb2eebfd6c996c36d82bbbc6040eb3a7f1.tar.gz
mrst-s0i3-test-01a3affb2eebfd6c996c36d82bbbc6040eb3a7f1.tar.xz
mrst-s0i3-test-01a3affb2eebfd6c996c36d82bbbc6040eb3a7f1.zip
[ALSA] oxygen: use an array of snd_kcontrol pointers
Use an array for the pointers to known controls so that it is easier to add more. 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.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index ca72799bea2..f7350faada1 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -586,15 +586,22 @@ static const struct snd_kcontrol_new controls[] = {
static void oxygen_any_ctl_free(struct snd_kcontrol *ctl)
{
struct oxygen *chip = ctl->private_data;
+ unsigned int i;
/* I'm too lazy to write a function for each control :-) */
- chip->spdif_pcm_ctl = NULL;
- chip->spdif_input_bits_ctl = NULL;
+ for (i = 0; i < ARRAY_SIZE(chip->controls); ++i)
+ chip->controls[i] = NULL;
}
int oxygen_mixer_init(struct oxygen *chip)
{
- unsigned int i;
+ static const char *const known_ctl_names[CONTROL_COUNT] = {
+ [CONTROL_SPDIF_PCM] =
+ SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
+ [CONTROL_SPDIF_INPUT_BITS] =
+ SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),
+ };
+ unsigned int i, j;
struct snd_kcontrol *ctl;
int err;
@@ -610,15 +617,11 @@ int oxygen_mixer_init(struct oxygen *chip)
err = snd_ctl_add(chip->card, ctl);
if (err < 0)
return err;
- if (!strcmp(ctl->id.name,
- SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM))) {
- chip->spdif_pcm_ctl = ctl;
- ctl->private_free = oxygen_any_ctl_free;
- } else if (!strcmp(ctl->id.name,
- SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
- chip->spdif_input_bits_ctl = ctl;
- ctl->private_free = oxygen_any_ctl_free;
- }
+ for (j = 0; j < CONTROL_COUNT; ++j)
+ if (!strcmp(ctl->id.name, known_ctl_names[j])) {
+ chip->controls[j] = ctl;
+ ctl->private_free = oxygen_any_ctl_free;
+ }
}
return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0;
}