aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-14 02:56:01 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:29:57 -0500
commit01a3affb2eebfd6c996c36d82bbbc6040eb3a7f1 (patch)
treea80f44ba4a5d6997d932a7d80e9b517064eb2555 /sound/pci
parent7113e95812f508bff10f95f2e52ce6ee8cda1875 (diff)
[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')
-rw-r--r--sound/pci/oxygen/oxygen.h9
-rw-r--r--sound/pci/oxygen/oxygen_lib.c4
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c27
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c8
4 files changed, 28 insertions, 20 deletions
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 248f7ed22fda..a10c37788059 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -15,6 +15,12 @@
15#define PCM_AC97 5 15#define PCM_AC97 5
16#define PCM_COUNT 6 16#define PCM_COUNT 6
17 17
18enum {
19 CONTROL_SPDIF_PCM,
20 CONTROL_SPDIF_INPUT_BITS,
21 CONTROL_COUNT
22};
23
18#define OXYGEN_PCI_SUBID(sv, sd) \ 24#define OXYGEN_PCI_SUBID(sv, sd) \
19 .vendor = PCI_VENDOR_ID_CMEDIA, \ 25 .vendor = PCI_VENDOR_ID_CMEDIA, \
20 .device = 0x8788, \ 26 .device = 0x8788, \
@@ -50,8 +56,7 @@ struct oxygen {
50 u32 spdif_bits; 56 u32 spdif_bits;
51 u32 spdif_pcm_bits; 57 u32 spdif_pcm_bits;
52 struct snd_pcm_substream *streams[PCM_COUNT]; 58 struct snd_pcm_substream *streams[PCM_COUNT];
53 struct snd_kcontrol *spdif_pcm_ctl; 59 struct snd_kcontrol *controls[CONTROL_COUNT];
54 struct snd_kcontrol *spdif_input_bits_ctl;
55 struct work_struct spdif_input_bits_work; 60 struct work_struct spdif_input_bits_work;
56}; 61};
57 62
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 9cd4be2593ab..5b77c9439c36 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -114,7 +114,7 @@ static void oxygen_spdif_input_bits_changed(struct work_struct *work)
114 } 114 }
115 } 115 }
116 116
117 if (chip->spdif_input_bits_ctl) { 117 if (chip->controls[CONTROL_SPDIF_INPUT_BITS]) {
118 spin_lock_irq(&chip->reg_lock); 118 spin_lock_irq(&chip->reg_lock);
119 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_CHANGE; 119 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_CHANGE;
120 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 120 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
@@ -122,7 +122,7 @@ static void oxygen_spdif_input_bits_changed(struct work_struct *work)
122 spin_unlock_irq(&chip->reg_lock); 122 spin_unlock_irq(&chip->reg_lock);
123 123
124 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 124 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
125 &chip->spdif_input_bits_ctl->id); 125 &chip->controls[CONTROL_SPDIF_INPUT_BITS]->id);
126 } 126 }
127} 127}
128 128
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index ca72799bea27..f7350faada1a 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[] = {
586static void oxygen_any_ctl_free(struct snd_kcontrol *ctl) 586static void oxygen_any_ctl_free(struct snd_kcontrol *ctl)
587{ 587{
588 struct oxygen *chip = ctl->private_data; 588 struct oxygen *chip = ctl->private_data;
589 unsigned int i;
589 590
590 /* I'm too lazy to write a function for each control :-) */ 591 /* I'm too lazy to write a function for each control :-) */
591 chip->spdif_pcm_ctl = NULL; 592 for (i = 0; i < ARRAY_SIZE(chip->controls); ++i)
592 chip->spdif_input_bits_ctl = NULL; 593 chip->controls[i] = NULL;
593} 594}
594 595
595int oxygen_mixer_init(struct oxygen *chip) 596int oxygen_mixer_init(struct oxygen *chip)
596{ 597{
597 unsigned int i; 598 static const char *const known_ctl_names[CONTROL_COUNT] = {
599 [CONTROL_SPDIF_PCM] =
600 SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
601 [CONTROL_SPDIF_INPUT_BITS] =
602 SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),
603 };
604 unsigned int i, j;
598 struct snd_kcontrol *ctl; 605 struct snd_kcontrol *ctl;
599 int err; 606 int err;
600 607
@@ -610,15 +617,11 @@ int oxygen_mixer_init(struct oxygen *chip)
610 err = snd_ctl_add(chip->card, ctl); 617 err = snd_ctl_add(chip->card, ctl);
611 if (err < 0) 618 if (err < 0)
612 return err; 619 return err;
613 if (!strcmp(ctl->id.name, 620 for (j = 0; j < CONTROL_COUNT; ++j)
614 SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM))) { 621 if (!strcmp(ctl->id.name, known_ctl_names[j])) {
615 chip->spdif_pcm_ctl = ctl; 622 chip->controls[j] = ctl;
616 ctl->private_free = oxygen_any_ctl_free; 623 ctl->private_free = oxygen_any_ctl_free;
617 } else if (!strcmp(ctl->id.name, 624 }
618 SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
619 chip->spdif_input_bits_ctl = ctl;
620 ctl->private_free = oxygen_any_ctl_free;
621 }
622 } 625 }
623 return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0; 626 return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0;
624} 627}
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index d4a1d73718e3..5f67a799a034 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -209,11 +209,11 @@ static int oxygen_open(struct snd_pcm_substream *substream,
209 chip->pcm_active |= 1 << channel; 209 chip->pcm_active |= 1 << channel;
210 if (channel == PCM_SPDIF) { 210 if (channel == PCM_SPDIF) {
211 chip->spdif_pcm_bits = chip->spdif_bits; 211 chip->spdif_pcm_bits = chip->spdif_bits;
212 chip->spdif_pcm_ctl->vd[0].access &= 212 chip->controls[CONTROL_SPDIF_PCM]->vd[0].access &=
213 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; 213 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
214 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | 214 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
215 SNDRV_CTL_EVENT_MASK_INFO, 215 SNDRV_CTL_EVENT_MASK_INFO,
216 &chip->spdif_pcm_ctl->id); 216 &chip->controls[CONTROL_SPDIF_PCM]->id);
217 } 217 }
218 mutex_unlock(&chip->mutex); 218 mutex_unlock(&chip->mutex);
219 219
@@ -258,11 +258,11 @@ static int oxygen_close(struct snd_pcm_substream *substream)
258 mutex_lock(&chip->mutex); 258 mutex_lock(&chip->mutex);
259 chip->pcm_active &= ~(1 << channel); 259 chip->pcm_active &= ~(1 << channel);
260 if (channel == PCM_SPDIF) { 260 if (channel == PCM_SPDIF) {
261 chip->spdif_pcm_ctl->vd[0].access |= 261 chip->controls[CONTROL_SPDIF_PCM]->vd[0].access |=
262 SNDRV_CTL_ELEM_ACCESS_INACTIVE; 262 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
263 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | 263 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
264 SNDRV_CTL_EVENT_MASK_INFO, 264 SNDRV_CTL_EVENT_MASK_INFO,
265 &chip->spdif_pcm_ctl->id); 265 &chip->controls[CONTROL_SPDIF_PCM]->id);
266 } 266 }
267 if (channel == PCM_SPDIF || channel == PCM_MULTICH) 267 if (channel == PCM_SPDIF || channel == PCM_MULTICH)
268 oxygen_update_spdif_source(chip); 268 oxygen_update_spdif_source(chip);