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/version.h>
23 #include <linux/init.h>
24 #include <linux/jiffies.h>
25 #include <linux/slab.h>
26 #include <linux/time.h>
27 #include <linux/wait.h>
28 #include <sound/core.h>
29 #include <sound/control.h>
30 #include <sound/pcm.h>
31 #include <sound/rawmidi.h>
33 #include <sound/initval.h>
35 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36 MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
37 MODULE_LICENSE("GPL");
38 MODULE_CLASSES("{sound}");
39 MODULE_DEVICES("{{ALSA,Dummy soundcard}}");
41 #define MAX_PCM_DEVICES 4
42 #define MAX_PCM_SUBSTREAMS 16
43 #define MAX_MIDI_DEVICES 2
45 #if 0 /* RME9652 emulation */
46 #define MAX_BUFFER_SIZE (26 * 64 * 1024)
47 #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
48 #define USE_CHANNELS_MIN 26
49 #define USE_CHANNELS_MAX 26
50 #define USE_PERIODS_MIN 2
51 #define USE_PERIODS_MAX 2
54 #if 0 /* ICE1712 emulation */
55 #define MAX_BUFFER_SIZE (256 * 1024)
56 #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
57 #define USE_CHANNELS_MIN 10
58 #define USE_CHANNELS_MAX 10
59 #define USE_PERIODS_MIN 1
60 #define USE_PERIODS_MAX 1024
63 #if 0 /* UDA1341 emulation */
64 #define MAX_BUFFER_SIZE (16380)
65 #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
66 #define USE_CHANNELS_MIN 2
67 #define USE_CHANNELS_MAX 2
68 #define USE_PERIODS_MIN 2
69 #define USE_PERIODS_MAX 255
74 #ifndef MAX_BUFFER_SIZE
75 #define MAX_BUFFER_SIZE (64*1024)
78 #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
80 #ifndef USE_CHANNELS_MIN
81 #define USE_CHANNELS_MIN 1
83 #ifndef USE_CHANNELS_MAX
84 #define USE_CHANNELS_MAX 2
86 #ifndef USE_PERIODS_MIN
87 #define USE_PERIODS_MIN 1
89 #ifndef USE_PERIODS_MAX
90 #define USE_PERIODS_MAX 1024
93 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
94 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
95 static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
96 static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
97 static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
98 //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
100 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
101 MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
102 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
103 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
104 MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
105 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
106 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
107 MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
108 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
109 MODULE_PARM(pcm_devs, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
110 MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
111 MODULE_PARM_SYNTAX(pcm_devs, SNDRV_ENABLED ",allows:{{0,4}},default:1,dialog:list");
112 MODULE_PARM(pcm_substreams, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
113 MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
114 MODULE_PARM_SYNTAX(pcm_substreams, SNDRV_ENABLED ",allows:{{1,16}},default:8,dialog:list");
115 //MODULE_PARM(midi_devs, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
116 //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
117 //MODULE_PARM_SYNTAX(midi_devs, SNDRV_ENABLED ",allows:{{0,2}},default:8,dialog:list");
119 #define MIXER_ADDR_MASTER 0
120 #define MIXER_ADDR_LINE 1
121 #define MIXER_ADDR_MIC 2
122 #define MIXER_ADDR_SYNTH 3
123 #define MIXER_ADDR_CD 4
124 #define MIXER_ADDR_LAST 4
126 typedef struct snd_card_dummy {
128 spinlock_t mixer_lock;
129 int mixer_volume[MIXER_ADDR_LAST+1][2];
130 int capture_source[MIXER_ADDR_LAST+1][2];
133 typedef struct snd_card_dummy_pcm {
134 snd_card_dummy_t *dummy;
136 struct timer_list timer;
137 unsigned int pcm_size;
138 unsigned int pcm_count;
139 unsigned int pcm_bps; /* bytes per second */
140 unsigned int pcm_jiffie; /* bytes per one jiffie */
141 unsigned int pcm_irq_pos; /* IRQ position */
142 unsigned int pcm_buf_pos; /* position in buffer */
143 snd_pcm_substream_t *substream;
144 } snd_card_dummy_pcm_t;
146 static snd_card_t *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
149 static int snd_card_dummy_playback_ioctl(snd_pcm_substream_t * substream,
153 return snd_pcm_lib_ioctl(substream, cmd, arg);
156 static int snd_card_dummy_capture_ioctl(snd_pcm_substream_t * substream,
160 return snd_pcm_lib_ioctl(substream, cmd, arg);
163 static void snd_card_dummy_pcm_timer_start(snd_pcm_substream_t * substream)
165 snd_pcm_runtime_t *runtime = substream->runtime;
166 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
168 dpcm->timer.expires = 1 + jiffies;
169 add_timer(&dpcm->timer);
172 static void snd_card_dummy_pcm_timer_stop(snd_pcm_substream_t * substream)
174 snd_pcm_runtime_t *runtime = substream->runtime;
175 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
177 del_timer(&dpcm->timer);
180 static int snd_card_dummy_playback_trigger(snd_pcm_substream_t * substream,
183 if (cmd == SNDRV_PCM_TRIGGER_START) {
184 snd_card_dummy_pcm_timer_start(substream);
185 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
186 snd_card_dummy_pcm_timer_stop(substream);
193 static int snd_card_dummy_capture_trigger(snd_pcm_substream_t * substream,
196 if (cmd == SNDRV_PCM_TRIGGER_START) {
197 snd_card_dummy_pcm_timer_start(substream);
198 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
199 snd_card_dummy_pcm_timer_stop(substream);
206 static int snd_card_dummy_pcm_prepare(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 -ENXIO);
212 bps = runtime->rate * runtime->channels;
213 bps *= snd_pcm_format_width(runtime->format);
218 dpcm->pcm_jiffie = bps / HZ;
219 dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
220 dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
221 dpcm->pcm_irq_pos = 0;
222 dpcm->pcm_buf_pos = 0;
226 static int snd_card_dummy_playback_prepare(snd_pcm_substream_t * substream)
228 return snd_card_dummy_pcm_prepare(substream);
231 static int snd_card_dummy_capture_prepare(snd_pcm_substream_t * substream)
233 return snd_card_dummy_pcm_prepare(substream);
236 static void snd_card_dummy_pcm_timer_function(unsigned long data)
238 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, (void *)data, return);
240 dpcm->timer.expires = 1 + jiffies;
241 add_timer(&dpcm->timer);
242 spin_lock_irq(&dpcm->lock);
243 dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
244 dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
245 dpcm->pcm_buf_pos %= dpcm->pcm_size;
246 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
247 dpcm->pcm_irq_pos %= dpcm->pcm_count;
248 snd_pcm_period_elapsed(dpcm->substream);
250 spin_unlock_irq(&dpcm->lock);
253 static snd_pcm_uframes_t snd_card_dummy_playback_pointer(snd_pcm_substream_t * substream)
255 snd_pcm_runtime_t *runtime = substream->runtime;
256 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
258 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
261 static snd_pcm_uframes_t snd_card_dummy_capture_pointer(snd_pcm_substream_t * substream)
263 snd_pcm_runtime_t *runtime = substream->runtime;
264 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
266 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
269 static snd_pcm_hardware_t snd_card_dummy_playback =
271 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
272 SNDRV_PCM_INFO_MMAP_VALID),
273 .formats = USE_FORMATS,
274 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
277 .channels_min = USE_CHANNELS_MIN,
278 .channels_max = USE_CHANNELS_MAX,
279 .buffer_bytes_max = MAX_BUFFER_SIZE,
280 .period_bytes_min = 64,
281 .period_bytes_max = MAX_BUFFER_SIZE,
282 .periods_min = USE_PERIODS_MIN,
283 .periods_max = USE_PERIODS_MAX,
287 static snd_pcm_hardware_t snd_card_dummy_capture =
289 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
290 SNDRV_PCM_INFO_MMAP_VALID),
291 .formats = USE_FORMATS,
292 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
295 .channels_min = USE_CHANNELS_MIN,
296 .channels_max = USE_CHANNELS_MAX,
297 .buffer_bytes_max = MAX_BUFFER_SIZE,
298 .period_bytes_min = 64,
299 .period_bytes_max = MAX_BUFFER_SIZE,
300 .periods_min = USE_PERIODS_MIN,
301 .periods_max = USE_PERIODS_MAX,
305 static void snd_card_dummy_runtime_free(snd_pcm_runtime_t *runtime)
307 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
308 snd_magic_kfree(dpcm);
311 static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream)
313 snd_pcm_runtime_t *runtime = substream->runtime;
314 snd_card_dummy_pcm_t *dpcm;
316 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
319 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
320 snd_magic_kfree(dpcm);
323 init_timer(&dpcm->timer);
324 dpcm->timer.data = (unsigned long) dpcm;
325 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
326 spin_lock_init(&dpcm->lock);
327 dpcm->substream = substream;
328 runtime->private_data = dpcm;
329 runtime->private_free = snd_card_dummy_runtime_free;
330 runtime->hw = snd_card_dummy_playback;
331 if (substream->pcm->device & 1) {
332 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
333 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
335 if (substream->pcm->device & 2)
336 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
340 static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream)
342 snd_pcm_runtime_t *runtime = substream->runtime;
343 snd_card_dummy_pcm_t *dpcm;
345 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
348 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
349 snd_magic_kfree(dpcm);
352 memset(runtime->dma_area, 0, runtime->dma_bytes);
353 init_timer(&dpcm->timer);
354 dpcm->timer.data = (unsigned long) dpcm;
355 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
356 spin_lock_init(&dpcm->lock);
357 dpcm->substream = substream;
358 runtime->private_data = dpcm;
359 runtime->private_free = snd_card_dummy_runtime_free;
360 runtime->hw = snd_card_dummy_capture;
361 if (substream->pcm->device == 1) {
362 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
363 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
365 if (substream->pcm->device & 2)
366 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
370 static int snd_card_dummy_playback_close(snd_pcm_substream_t * substream)
372 snd_pcm_runtime_t *runtime = substream->runtime;
374 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
378 static int snd_card_dummy_capture_close(snd_pcm_substream_t * substream)
380 snd_pcm_runtime_t *runtime = substream->runtime;
382 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
386 static snd_pcm_ops_t snd_card_dummy_playback_ops = {
387 .open = snd_card_dummy_playback_open,
388 .close = snd_card_dummy_playback_close,
389 .ioctl = snd_card_dummy_playback_ioctl,
390 .prepare = snd_card_dummy_playback_prepare,
391 .trigger = snd_card_dummy_playback_trigger,
392 .pointer = snd_card_dummy_playback_pointer,
395 static snd_pcm_ops_t snd_card_dummy_capture_ops = {
396 .open = snd_card_dummy_capture_open,
397 .close = snd_card_dummy_capture_close,
398 .ioctl = snd_card_dummy_capture_ioctl,
399 .prepare = snd_card_dummy_capture_prepare,
400 .trigger = snd_card_dummy_capture_trigger,
401 .pointer = snd_card_dummy_capture_pointer,
404 static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int substreams)
409 if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm)) < 0)
411 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops);
412 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops);
413 pcm->private_data = dummy;
415 strcpy(pcm->name, "Dummy PCM");
419 #define DUMMY_VOLUME(xname, xindex, addr) \
420 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
421 .info = snd_dummy_volume_info, \
422 .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
423 .private_value = addr }
425 static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
427 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
429 uinfo->value.integer.min = -50;
430 uinfo->value.integer.max = 100;
434 static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
436 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
438 int addr = kcontrol->private_value;
440 spin_lock_irqsave(&dummy->mixer_lock, flags);
441 ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0];
442 ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1];
443 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
447 static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
449 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
451 int change, addr = kcontrol->private_value;
454 left = ucontrol->value.integer.value[0];
459 right = ucontrol->value.integer.value[1];
464 spin_lock_irqsave(&dummy->mixer_lock, flags);
465 change = dummy->mixer_volume[addr][0] != left ||
466 dummy->mixer_volume[addr][1] != right;
467 dummy->mixer_volume[addr][0] = left;
468 dummy->mixer_volume[addr][1] = right;
469 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
473 #define DUMMY_CAPSRC(xname, xindex, addr) \
474 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
475 .info = snd_dummy_capsrc_info, \
476 .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
477 .private_value = addr }
479 static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
481 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
483 uinfo->value.integer.min = 0;
484 uinfo->value.integer.max = 1;
488 static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
490 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
492 int addr = kcontrol->private_value;
494 spin_lock_irqsave(&dummy->mixer_lock, flags);
495 ucontrol->value.integer.value[0] = dummy->capture_source[addr][0];
496 ucontrol->value.integer.value[1] = dummy->capture_source[addr][1];
497 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
501 static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
503 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
505 int change, addr = kcontrol->private_value;
508 left = ucontrol->value.integer.value[0] & 1;
509 right = ucontrol->value.integer.value[1] & 1;
510 spin_lock_irqsave(&dummy->mixer_lock, flags);
511 change = dummy->capture_source[addr][0] != left &&
512 dummy->capture_source[addr][1] != right;
513 dummy->capture_source[addr][0] = left;
514 dummy->capture_source[addr][1] = right;
515 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
519 #define DUMMY_CONTROLS (sizeof(snd_dummy_controls)/sizeof(snd_kcontrol_new_t))
521 static snd_kcontrol_new_t snd_dummy_controls[] = {
522 DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
523 DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
524 DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
525 DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_MASTER),
526 DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
527 DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_MASTER),
528 DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
529 DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MASTER),
530 DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
531 DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_MASTER)
534 int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
536 snd_card_t *card = dummy->card;
540 snd_assert(dummy != NULL, return -EINVAL);
541 spin_lock_init(&dummy->mixer_lock);
542 strcpy(card->mixername, "Dummy Mixer");
544 for (idx = 0; idx < DUMMY_CONTROLS; idx++) {
545 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy))) < 0)
551 static int __init snd_card_dummy_probe(int dev)
554 struct snd_card_dummy *dummy;
559 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
560 sizeof(struct snd_card_dummy));
563 dummy = (struct snd_card_dummy *)card->private_data;
565 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
566 if (pcm_substreams[dev] < 1)
567 pcm_substreams[dev] = 1;
568 if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS)
569 pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
570 if ((err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev])) < 0)
573 if ((err = snd_card_dummy_new_mixer(dummy)) < 0)
575 strcpy(card->driver, "Dummy");
576 strcpy(card->shortname, "Dummy");
577 sprintf(card->longname, "Dummy %i", dev + 1);
578 if ((err = snd_card_register(card)) == 0) {
579 snd_dummy_cards[dev] = card;
587 static int __init alsa_card_dummy_init(void)
591 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) {
592 if (snd_card_dummy_probe(dev) < 0) {
594 printk(KERN_ERR "Dummy soundcard #%i not found or device busy\n", dev + 1);
602 printk(KERN_ERR "Dummy soundcard not found or device busy\n");
609 static void __exit alsa_card_dummy_exit(void)
613 for (idx = 0; idx < SNDRV_CARDS; idx++)
614 snd_card_free(snd_dummy_cards[idx]);
617 module_init(alsa_card_dummy_init)
618 module_exit(alsa_card_dummy_exit)
622 /* format is: snd-dummy=enable,index,id,
623 pcm_devs,pcm_substreams */
625 static int __init alsa_card_dummy_setup(char *str)
627 static unsigned __initdata nr_dev = 0;
629 if (nr_dev >= SNDRV_CARDS)
631 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
632 get_option(&str,&index[nr_dev]) == 2 &&
633 get_id(&str,&id[nr_dev]) == 2 &&
634 get_option(&str,&pcm_devs[nr_dev]) == 2 &&
635 get_option(&str,&pcm_substreams[nr_dev]) == 2);
640 __setup("snd-dummy=", alsa_card_dummy_setup);
642 #endif /* ifndef MODULE */