3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <sound/driver.h>
22 #include <linux/init.h>
23 #include <linux/jiffies.h>
24 #include <linux/slab.h>
25 #include <linux/time.h>
26 #include <linux/wait.h>
27 #include <linux/moduleparam.h>
28 #include <sound/core.h>
29 #include <sound/control.h>
30 #include <sound/pcm.h>
31 #include <sound/rawmidi.h>
32 #include <sound/initval.h>
34 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
35 MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
36 MODULE_LICENSE("GPL");
37 MODULE_CLASSES("{sound}");
38 MODULE_DEVICES("{{ALSA,Dummy soundcard}}");
40 #define MAX_PCM_DEVICES 4
41 #define MAX_PCM_SUBSTREAMS 16
42 #define MAX_MIDI_DEVICES 2
44 #if 0 /* emu10k1 emulation */
45 #define MAX_BUFFER_SIZE (128 * 1024)
46 static int emu10k1_playback_constraints(snd_pcm_runtime_t *runtime)
49 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
51 if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0)
55 #define add_playback_constraints emu10k1_playback_constraints
58 #if 0 /* RME9652 emulation */
59 #define MAX_BUFFER_SIZE (26 * 64 * 1024)
60 #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
61 #define USE_CHANNELS_MIN 26
62 #define USE_CHANNELS_MAX 26
63 #define USE_PERIODS_MIN 2
64 #define USE_PERIODS_MAX 2
67 #if 0 /* ICE1712 emulation */
68 #define MAX_BUFFER_SIZE (256 * 1024)
69 #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
70 #define USE_CHANNELS_MIN 10
71 #define USE_CHANNELS_MAX 10
72 #define USE_PERIODS_MIN 1
73 #define USE_PERIODS_MAX 1024
76 #if 0 /* UDA1341 emulation */
77 #define MAX_BUFFER_SIZE (16380)
78 #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
79 #define USE_CHANNELS_MIN 2
80 #define USE_CHANNELS_MAX 2
81 #define USE_PERIODS_MIN 2
82 #define USE_PERIODS_MAX 255
85 #if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
86 #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
87 #define USE_CHANNELS_MIN 2
88 #define USE_CHANNELS_MAX 2
89 #define USE_RATE SNDRV_PCM_RATE_48000
90 #define USE_RATE_MIN 48000
91 #define USE_RATE_MAX 48000
96 #ifndef MAX_BUFFER_SIZE
97 #define MAX_BUFFER_SIZE (64*1024)
100 #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
103 #define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000
104 #define USE_RATE_MIN 5500
105 #define USE_RATE_MAX 48000
107 #ifndef USE_CHANNELS_MIN
108 #define USE_CHANNELS_MIN 1
110 #ifndef USE_CHANNELS_MAX
111 #define USE_CHANNELS_MAX 2
113 #ifndef USE_PERIODS_MIN
114 #define USE_PERIODS_MIN 1
116 #ifndef USE_PERIODS_MAX
117 #define USE_PERIODS_MAX 1024
119 #ifndef add_playback_constraints
120 #define add_playback_constraints(x) 0
122 #ifndef add_capture_constraints
123 #define add_capture_constraints(x) 0
126 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
127 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
128 static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
129 static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
130 static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
131 //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
132 static int boot_devs;
134 module_param_array(index, int, boot_devs, 0444);
135 MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
136 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
137 module_param_array(id, charp, boot_devs, 0444);
138 MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
139 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
140 module_param_array(enable, bool, boot_devs, 0444);
141 MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
142 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
143 module_param_array(pcm_devs, int, boot_devs, 0444);
144 MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
145 MODULE_PARM_SYNTAX(pcm_devs, SNDRV_ENABLED ",allows:{{0,4}},default:1,dialog:list");
146 module_param_array(pcm_substreams, int, boot_devs, 0444);
147 MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
148 MODULE_PARM_SYNTAX(pcm_substreams, SNDRV_ENABLED ",allows:{{1,16}},default:8,dialog:list");
149 //module_param_array(midi_devs, int, boot_devs, 0444);
150 //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
151 //MODULE_PARM_SYNTAX(midi_devs, SNDRV_ENABLED ",allows:{{0,2}},default:8,dialog:list");
153 #define MIXER_ADDR_MASTER 0
154 #define MIXER_ADDR_LINE 1
155 #define MIXER_ADDR_MIC 2
156 #define MIXER_ADDR_SYNTH 3
157 #define MIXER_ADDR_CD 4
158 #define MIXER_ADDR_LAST 4
160 typedef struct snd_card_dummy {
162 spinlock_t mixer_lock;
163 int mixer_volume[MIXER_ADDR_LAST+1][2];
164 int capture_source[MIXER_ADDR_LAST+1][2];
167 typedef struct snd_card_dummy_pcm {
168 snd_card_dummy_t *dummy;
170 struct timer_list timer;
171 unsigned int pcm_size;
172 unsigned int pcm_count;
173 unsigned int pcm_bps; /* bytes per second */
174 unsigned int pcm_jiffie; /* bytes per one jiffie */
175 unsigned int pcm_irq_pos; /* IRQ position */
176 unsigned int pcm_buf_pos; /* position in buffer */
177 snd_pcm_substream_t *substream;
178 } snd_card_dummy_pcm_t;
180 static snd_card_t *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
183 static int snd_card_dummy_playback_ioctl(snd_pcm_substream_t * substream,
187 return snd_pcm_lib_ioctl(substream, cmd, arg);
190 static int snd_card_dummy_capture_ioctl(snd_pcm_substream_t * substream,
194 return snd_pcm_lib_ioctl(substream, cmd, arg);
197 static void snd_card_dummy_pcm_timer_start(snd_pcm_substream_t * substream)
199 snd_pcm_runtime_t *runtime = substream->runtime;
200 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
202 dpcm->timer.expires = 1 + jiffies;
203 add_timer(&dpcm->timer);
206 static void snd_card_dummy_pcm_timer_stop(snd_pcm_substream_t * substream)
208 snd_pcm_runtime_t *runtime = substream->runtime;
209 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
211 del_timer(&dpcm->timer);
214 static int snd_card_dummy_playback_trigger(snd_pcm_substream_t * substream,
217 if (cmd == SNDRV_PCM_TRIGGER_START) {
218 snd_card_dummy_pcm_timer_start(substream);
219 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
220 snd_card_dummy_pcm_timer_stop(substream);
227 static int snd_card_dummy_capture_trigger(snd_pcm_substream_t * substream,
230 if (cmd == SNDRV_PCM_TRIGGER_START) {
231 snd_card_dummy_pcm_timer_start(substream);
232 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
233 snd_card_dummy_pcm_timer_stop(substream);
240 static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream)
242 snd_pcm_runtime_t *runtime = substream->runtime;
243 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
246 bps = runtime->rate * runtime->channels;
247 bps *= snd_pcm_format_width(runtime->format);
252 dpcm->pcm_jiffie = bps / HZ;
253 dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
254 dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
255 dpcm->pcm_irq_pos = 0;
256 dpcm->pcm_buf_pos = 0;
260 static int snd_card_dummy_playback_prepare(snd_pcm_substream_t * substream)
262 return snd_card_dummy_pcm_prepare(substream);
265 static int snd_card_dummy_capture_prepare(snd_pcm_substream_t * substream)
267 return snd_card_dummy_pcm_prepare(substream);
270 static void snd_card_dummy_pcm_timer_function(unsigned long data)
272 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, (void *)data, return);
274 dpcm->timer.expires = 1 + jiffies;
275 add_timer(&dpcm->timer);
276 spin_lock_irq(&dpcm->lock);
277 dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
278 dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
279 dpcm->pcm_buf_pos %= dpcm->pcm_size;
280 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
281 dpcm->pcm_irq_pos %= dpcm->pcm_count;
282 snd_pcm_period_elapsed(dpcm->substream);
284 spin_unlock_irq(&dpcm->lock);
287 static snd_pcm_uframes_t snd_card_dummy_playback_pointer(snd_pcm_substream_t * substream)
289 snd_pcm_runtime_t *runtime = substream->runtime;
290 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
292 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
295 static snd_pcm_uframes_t snd_card_dummy_capture_pointer(snd_pcm_substream_t * substream)
297 snd_pcm_runtime_t *runtime = substream->runtime;
298 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
300 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
303 static snd_pcm_hardware_t snd_card_dummy_playback =
305 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
306 SNDRV_PCM_INFO_MMAP_VALID),
307 .formats = USE_FORMATS,
309 .rate_min = USE_RATE_MIN,
310 .rate_max = USE_RATE_MAX,
311 .channels_min = USE_CHANNELS_MIN,
312 .channels_max = USE_CHANNELS_MAX,
313 .buffer_bytes_max = MAX_BUFFER_SIZE,
314 .period_bytes_min = 64,
315 .period_bytes_max = MAX_BUFFER_SIZE,
316 .periods_min = USE_PERIODS_MIN,
317 .periods_max = USE_PERIODS_MAX,
321 static snd_pcm_hardware_t snd_card_dummy_capture =
323 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
324 SNDRV_PCM_INFO_MMAP_VALID),
325 .formats = USE_FORMATS,
327 .rate_min = USE_RATE_MIN,
328 .rate_max = USE_RATE_MAX,
329 .channels_min = USE_CHANNELS_MIN,
330 .channels_max = USE_CHANNELS_MAX,
331 .buffer_bytes_max = MAX_BUFFER_SIZE,
332 .period_bytes_min = 64,
333 .period_bytes_max = MAX_BUFFER_SIZE,
334 .periods_min = USE_PERIODS_MIN,
335 .periods_max = USE_PERIODS_MAX,
339 static void snd_card_dummy_runtime_free(snd_pcm_runtime_t *runtime)
341 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
342 snd_magic_kfree(dpcm);
345 static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream)
347 snd_pcm_runtime_t *runtime = substream->runtime;
348 snd_card_dummy_pcm_t *dpcm;
351 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
354 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
355 snd_magic_kfree(dpcm);
358 init_timer(&dpcm->timer);
359 dpcm->timer.data = (unsigned long) dpcm;
360 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
361 spin_lock_init(&dpcm->lock);
362 dpcm->substream = substream;
363 runtime->private_data = dpcm;
364 runtime->private_free = snd_card_dummy_runtime_free;
365 runtime->hw = snd_card_dummy_playback;
366 if (substream->pcm->device & 1) {
367 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
368 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
370 if (substream->pcm->device & 2)
371 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
372 if ((err = add_playback_constraints(runtime)) < 0) {
373 snd_magic_kfree(dpcm);
380 static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream)
382 snd_pcm_runtime_t *runtime = substream->runtime;
383 snd_card_dummy_pcm_t *dpcm;
386 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
389 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
390 snd_magic_kfree(dpcm);
393 memset(runtime->dma_area, 0, runtime->dma_bytes);
394 init_timer(&dpcm->timer);
395 dpcm->timer.data = (unsigned long) dpcm;
396 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
397 spin_lock_init(&dpcm->lock);
398 dpcm->substream = substream;
399 runtime->private_data = dpcm;
400 runtime->private_free = snd_card_dummy_runtime_free;
401 runtime->hw = snd_card_dummy_capture;
402 if (substream->pcm->device == 1) {
403 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
404 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
406 if (substream->pcm->device & 2)
407 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
408 if ((err = add_capture_constraints(runtime)) < 0) {
409 snd_magic_kfree(dpcm);
416 static int snd_card_dummy_playback_close(snd_pcm_substream_t * substream)
418 snd_pcm_runtime_t *runtime = substream->runtime;
420 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
424 static int snd_card_dummy_capture_close(snd_pcm_substream_t * substream)
426 snd_pcm_runtime_t *runtime = substream->runtime;
428 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
432 static snd_pcm_ops_t snd_card_dummy_playback_ops = {
433 .open = snd_card_dummy_playback_open,
434 .close = snd_card_dummy_playback_close,
435 .ioctl = snd_card_dummy_playback_ioctl,
436 .prepare = snd_card_dummy_playback_prepare,
437 .trigger = snd_card_dummy_playback_trigger,
438 .pointer = snd_card_dummy_playback_pointer,
441 static snd_pcm_ops_t snd_card_dummy_capture_ops = {
442 .open = snd_card_dummy_capture_open,
443 .close = snd_card_dummy_capture_close,
444 .ioctl = snd_card_dummy_capture_ioctl,
445 .prepare = snd_card_dummy_capture_prepare,
446 .trigger = snd_card_dummy_capture_trigger,
447 .pointer = snd_card_dummy_capture_pointer,
450 static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int substreams)
455 if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm)) < 0)
457 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops);
458 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops);
459 pcm->private_data = dummy;
461 strcpy(pcm->name, "Dummy PCM");
465 #define DUMMY_VOLUME(xname, xindex, addr) \
466 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
467 .info = snd_dummy_volume_info, \
468 .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
469 .private_value = addr }
471 static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
473 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
475 uinfo->value.integer.min = -50;
476 uinfo->value.integer.max = 100;
480 static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
482 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
484 int addr = kcontrol->private_value;
486 spin_lock_irqsave(&dummy->mixer_lock, flags);
487 ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0];
488 ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1];
489 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
493 static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
495 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
497 int change, addr = kcontrol->private_value;
500 left = ucontrol->value.integer.value[0];
505 right = ucontrol->value.integer.value[1];
510 spin_lock_irqsave(&dummy->mixer_lock, flags);
511 change = dummy->mixer_volume[addr][0] != left ||
512 dummy->mixer_volume[addr][1] != right;
513 dummy->mixer_volume[addr][0] = left;
514 dummy->mixer_volume[addr][1] = right;
515 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
519 #define DUMMY_CAPSRC(xname, xindex, addr) \
520 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
521 .info = snd_dummy_capsrc_info, \
522 .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
523 .private_value = addr }
525 static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
527 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
529 uinfo->value.integer.min = 0;
530 uinfo->value.integer.max = 1;
534 static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
536 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
538 int addr = kcontrol->private_value;
540 spin_lock_irqsave(&dummy->mixer_lock, flags);
541 ucontrol->value.integer.value[0] = dummy->capture_source[addr][0];
542 ucontrol->value.integer.value[1] = dummy->capture_source[addr][1];
543 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
547 static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
549 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
551 int change, addr = kcontrol->private_value;
554 left = ucontrol->value.integer.value[0] & 1;
555 right = ucontrol->value.integer.value[1] & 1;
556 spin_lock_irqsave(&dummy->mixer_lock, flags);
557 change = dummy->capture_source[addr][0] != left &&
558 dummy->capture_source[addr][1] != right;
559 dummy->capture_source[addr][0] = left;
560 dummy->capture_source[addr][1] = right;
561 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
565 #define DUMMY_CONTROLS (sizeof(snd_dummy_controls)/sizeof(snd_kcontrol_new_t))
567 static snd_kcontrol_new_t snd_dummy_controls[] = {
568 DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
569 DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
570 DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
571 DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_MASTER),
572 DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
573 DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_MASTER),
574 DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
575 DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MASTER),
576 DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
577 DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_MASTER)
580 int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
582 snd_card_t *card = dummy->card;
586 snd_assert(dummy != NULL, return -EINVAL);
587 spin_lock_init(&dummy->mixer_lock);
588 strcpy(card->mixername, "Dummy Mixer");
590 for (idx = 0; idx < DUMMY_CONTROLS; idx++) {
591 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy))) < 0)
597 static int __init snd_card_dummy_probe(int dev)
600 struct snd_card_dummy *dummy;
605 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
606 sizeof(struct snd_card_dummy));
609 dummy = (struct snd_card_dummy *)card->private_data;
611 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
612 if (pcm_substreams[dev] < 1)
613 pcm_substreams[dev] = 1;
614 if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS)
615 pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
616 if ((err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev])) < 0)
619 if ((err = snd_card_dummy_new_mixer(dummy)) < 0)
621 strcpy(card->driver, "Dummy");
622 strcpy(card->shortname, "Dummy");
623 sprintf(card->longname, "Dummy %i", dev + 1);
624 if ((err = snd_card_register(card)) == 0) {
625 snd_dummy_cards[dev] = card;
633 static int __init alsa_card_dummy_init(void)
637 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) {
638 if (snd_card_dummy_probe(dev) < 0) {
640 printk(KERN_ERR "Dummy soundcard #%i not found or device busy\n", dev + 1);
648 printk(KERN_ERR "Dummy soundcard not found or device busy\n");
655 static void __exit alsa_card_dummy_exit(void)
659 for (idx = 0; idx < SNDRV_CARDS; idx++)
660 snd_card_free(snd_dummy_cards[idx]);
663 module_init(alsa_card_dummy_init)
664 module_exit(alsa_card_dummy_exit)