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
72 #if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
73 #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
74 #define USE_CHANNELS_MIN 2
75 #define USE_CHANNELS_MAX 2
76 #define USE_RATE SNDRV_PCM_RATE_48000
77 #define USE_RATE_MIN 48000
78 #define USE_RATE_MAX 48000
83 #ifndef MAX_BUFFER_SIZE
84 #define MAX_BUFFER_SIZE (64*1024)
87 #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
90 #define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000
91 #define USE_RATE_MIN 5500
92 #define USE_RATE_MAX 48000
94 #ifndef USE_CHANNELS_MIN
95 #define USE_CHANNELS_MIN 1
97 #ifndef USE_CHANNELS_MAX
98 #define USE_CHANNELS_MAX 2
100 #ifndef USE_PERIODS_MIN
101 #define USE_PERIODS_MIN 1
103 #ifndef USE_PERIODS_MAX
104 #define USE_PERIODS_MAX 1024
107 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
108 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
109 static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
110 static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
111 static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
112 //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
114 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
115 MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
116 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
117 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
118 MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
119 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
120 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
121 MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
122 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
123 MODULE_PARM(pcm_devs, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
124 MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
125 MODULE_PARM_SYNTAX(pcm_devs, SNDRV_ENABLED ",allows:{{0,4}},default:1,dialog:list");
126 MODULE_PARM(pcm_substreams, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
127 MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
128 MODULE_PARM_SYNTAX(pcm_substreams, SNDRV_ENABLED ",allows:{{1,16}},default:8,dialog:list");
129 //MODULE_PARM(midi_devs, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
130 //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
131 //MODULE_PARM_SYNTAX(midi_devs, SNDRV_ENABLED ",allows:{{0,2}},default:8,dialog:list");
133 #define MIXER_ADDR_MASTER 0
134 #define MIXER_ADDR_LINE 1
135 #define MIXER_ADDR_MIC 2
136 #define MIXER_ADDR_SYNTH 3
137 #define MIXER_ADDR_CD 4
138 #define MIXER_ADDR_LAST 4
140 typedef struct snd_card_dummy {
142 spinlock_t mixer_lock;
143 int mixer_volume[MIXER_ADDR_LAST+1][2];
144 int capture_source[MIXER_ADDR_LAST+1][2];
147 typedef struct snd_card_dummy_pcm {
148 snd_card_dummy_t *dummy;
150 struct timer_list timer;
151 unsigned int pcm_size;
152 unsigned int pcm_count;
153 unsigned int pcm_bps; /* bytes per second */
154 unsigned int pcm_jiffie; /* bytes per one jiffie */
155 unsigned int pcm_irq_pos; /* IRQ position */
156 unsigned int pcm_buf_pos; /* position in buffer */
157 snd_pcm_substream_t *substream;
158 } snd_card_dummy_pcm_t;
160 static snd_card_t *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
163 static int snd_card_dummy_playback_ioctl(snd_pcm_substream_t * substream,
167 return snd_pcm_lib_ioctl(substream, cmd, arg);
170 static int snd_card_dummy_capture_ioctl(snd_pcm_substream_t * substream,
174 return snd_pcm_lib_ioctl(substream, cmd, arg);
177 static void snd_card_dummy_pcm_timer_start(snd_pcm_substream_t * substream)
179 snd_pcm_runtime_t *runtime = substream->runtime;
180 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
182 dpcm->timer.expires = 1 + jiffies;
183 add_timer(&dpcm->timer);
186 static void snd_card_dummy_pcm_timer_stop(snd_pcm_substream_t * substream)
188 snd_pcm_runtime_t *runtime = substream->runtime;
189 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
191 del_timer(&dpcm->timer);
194 static int snd_card_dummy_playback_trigger(snd_pcm_substream_t * substream,
197 if (cmd == SNDRV_PCM_TRIGGER_START) {
198 snd_card_dummy_pcm_timer_start(substream);
199 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
200 snd_card_dummy_pcm_timer_stop(substream);
207 static int snd_card_dummy_capture_trigger(snd_pcm_substream_t * substream,
210 if (cmd == SNDRV_PCM_TRIGGER_START) {
211 snd_card_dummy_pcm_timer_start(substream);
212 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
213 snd_card_dummy_pcm_timer_stop(substream);
220 static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream)
222 snd_pcm_runtime_t *runtime = substream->runtime;
223 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
226 bps = runtime->rate * runtime->channels;
227 bps *= snd_pcm_format_width(runtime->format);
232 dpcm->pcm_jiffie = bps / HZ;
233 dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
234 dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
235 dpcm->pcm_irq_pos = 0;
236 dpcm->pcm_buf_pos = 0;
240 static int snd_card_dummy_playback_prepare(snd_pcm_substream_t * substream)
242 return snd_card_dummy_pcm_prepare(substream);
245 static int snd_card_dummy_capture_prepare(snd_pcm_substream_t * substream)
247 return snd_card_dummy_pcm_prepare(substream);
250 static void snd_card_dummy_pcm_timer_function(unsigned long data)
252 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, (void *)data, return);
254 dpcm->timer.expires = 1 + jiffies;
255 add_timer(&dpcm->timer);
256 spin_lock_irq(&dpcm->lock);
257 dpcm->pcm_irq_pos += dpcm->pcm_jiffie;
258 dpcm->pcm_buf_pos += dpcm->pcm_jiffie;
259 dpcm->pcm_buf_pos %= dpcm->pcm_size;
260 if (dpcm->pcm_irq_pos >= dpcm->pcm_count) {
261 dpcm->pcm_irq_pos %= dpcm->pcm_count;
262 snd_pcm_period_elapsed(dpcm->substream);
264 spin_unlock_irq(&dpcm->lock);
267 static snd_pcm_uframes_t snd_card_dummy_playback_pointer(snd_pcm_substream_t * substream)
269 snd_pcm_runtime_t *runtime = substream->runtime;
270 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
272 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
275 static snd_pcm_uframes_t snd_card_dummy_capture_pointer(snd_pcm_substream_t * substream)
277 snd_pcm_runtime_t *runtime = substream->runtime;
278 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return -ENXIO);
280 return bytes_to_frames(runtime, dpcm->pcm_buf_pos);
283 static snd_pcm_hardware_t snd_card_dummy_playback =
285 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
286 SNDRV_PCM_INFO_MMAP_VALID),
287 .formats = USE_FORMATS,
289 .rate_min = USE_RATE_MIN,
290 .rate_max = USE_RATE_MAX,
291 .channels_min = USE_CHANNELS_MIN,
292 .channels_max = USE_CHANNELS_MAX,
293 .buffer_bytes_max = MAX_BUFFER_SIZE,
294 .period_bytes_min = 64,
295 .period_bytes_max = MAX_BUFFER_SIZE,
296 .periods_min = USE_PERIODS_MIN,
297 .periods_max = USE_PERIODS_MAX,
301 static snd_pcm_hardware_t snd_card_dummy_capture =
303 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
304 SNDRV_PCM_INFO_MMAP_VALID),
305 .formats = USE_FORMATS,
307 .rate_min = USE_RATE_MIN,
308 .rate_max = USE_RATE_MAX,
309 .channels_min = USE_CHANNELS_MIN,
310 .channels_max = USE_CHANNELS_MAX,
311 .buffer_bytes_max = MAX_BUFFER_SIZE,
312 .period_bytes_min = 64,
313 .period_bytes_max = MAX_BUFFER_SIZE,
314 .periods_min = USE_PERIODS_MIN,
315 .periods_max = USE_PERIODS_MAX,
319 static void snd_card_dummy_runtime_free(snd_pcm_runtime_t *runtime)
321 snd_card_dummy_pcm_t *dpcm = snd_magic_cast(snd_card_dummy_pcm_t, runtime->private_data, return);
322 snd_magic_kfree(dpcm);
325 static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream)
327 snd_pcm_runtime_t *runtime = substream->runtime;
328 snd_card_dummy_pcm_t *dpcm;
330 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
333 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
334 snd_magic_kfree(dpcm);
337 init_timer(&dpcm->timer);
338 dpcm->timer.data = (unsigned long) dpcm;
339 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
340 spin_lock_init(&dpcm->lock);
341 dpcm->substream = substream;
342 runtime->private_data = dpcm;
343 runtime->private_free = snd_card_dummy_runtime_free;
344 runtime->hw = snd_card_dummy_playback;
345 if (substream->pcm->device & 1) {
346 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
347 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
349 if (substream->pcm->device & 2)
350 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
354 static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream)
356 snd_pcm_runtime_t *runtime = substream->runtime;
357 snd_card_dummy_pcm_t *dpcm;
359 dpcm = snd_magic_kcalloc(snd_card_dummy_pcm_t, 0, GFP_KERNEL);
362 if ((runtime->dma_area = snd_malloc_pages_fallback(MAX_BUFFER_SIZE, GFP_KERNEL, &runtime->dma_bytes)) == NULL) {
363 snd_magic_kfree(dpcm);
366 memset(runtime->dma_area, 0, runtime->dma_bytes);
367 init_timer(&dpcm->timer);
368 dpcm->timer.data = (unsigned long) dpcm;
369 dpcm->timer.function = snd_card_dummy_pcm_timer_function;
370 spin_lock_init(&dpcm->lock);
371 dpcm->substream = substream;
372 runtime->private_data = dpcm;
373 runtime->private_free = snd_card_dummy_runtime_free;
374 runtime->hw = snd_card_dummy_capture;
375 if (substream->pcm->device == 1) {
376 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
377 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
379 if (substream->pcm->device & 2)
380 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
384 static int snd_card_dummy_playback_close(snd_pcm_substream_t * substream)
386 snd_pcm_runtime_t *runtime = substream->runtime;
388 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
392 static int snd_card_dummy_capture_close(snd_pcm_substream_t * substream)
394 snd_pcm_runtime_t *runtime = substream->runtime;
396 snd_free_pages(runtime->dma_area, runtime->dma_bytes);
400 static snd_pcm_ops_t snd_card_dummy_playback_ops = {
401 .open = snd_card_dummy_playback_open,
402 .close = snd_card_dummy_playback_close,
403 .ioctl = snd_card_dummy_playback_ioctl,
404 .prepare = snd_card_dummy_playback_prepare,
405 .trigger = snd_card_dummy_playback_trigger,
406 .pointer = snd_card_dummy_playback_pointer,
409 static snd_pcm_ops_t snd_card_dummy_capture_ops = {
410 .open = snd_card_dummy_capture_open,
411 .close = snd_card_dummy_capture_close,
412 .ioctl = snd_card_dummy_capture_ioctl,
413 .prepare = snd_card_dummy_capture_prepare,
414 .trigger = snd_card_dummy_capture_trigger,
415 .pointer = snd_card_dummy_capture_pointer,
418 static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int substreams)
423 if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm)) < 0)
425 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops);
426 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops);
427 pcm->private_data = dummy;
429 strcpy(pcm->name, "Dummy PCM");
433 #define DUMMY_VOLUME(xname, xindex, addr) \
434 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
435 .info = snd_dummy_volume_info, \
436 .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
437 .private_value = addr }
439 static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
441 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
443 uinfo->value.integer.min = -50;
444 uinfo->value.integer.max = 100;
448 static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
450 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
452 int addr = kcontrol->private_value;
454 spin_lock_irqsave(&dummy->mixer_lock, flags);
455 ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0];
456 ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1];
457 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
461 static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
463 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
465 int change, addr = kcontrol->private_value;
468 left = ucontrol->value.integer.value[0];
473 right = ucontrol->value.integer.value[1];
478 spin_lock_irqsave(&dummy->mixer_lock, flags);
479 change = dummy->mixer_volume[addr][0] != left ||
480 dummy->mixer_volume[addr][1] != right;
481 dummy->mixer_volume[addr][0] = left;
482 dummy->mixer_volume[addr][1] = right;
483 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
487 #define DUMMY_CAPSRC(xname, xindex, addr) \
488 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
489 .info = snd_dummy_capsrc_info, \
490 .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
491 .private_value = addr }
493 static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo)
495 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
497 uinfo->value.integer.min = 0;
498 uinfo->value.integer.max = 1;
502 static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
504 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
506 int addr = kcontrol->private_value;
508 spin_lock_irqsave(&dummy->mixer_lock, flags);
509 ucontrol->value.integer.value[0] = dummy->capture_source[addr][0];
510 ucontrol->value.integer.value[1] = dummy->capture_source[addr][1];
511 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
515 static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
517 snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
519 int change, addr = kcontrol->private_value;
522 left = ucontrol->value.integer.value[0] & 1;
523 right = ucontrol->value.integer.value[1] & 1;
524 spin_lock_irqsave(&dummy->mixer_lock, flags);
525 change = dummy->capture_source[addr][0] != left &&
526 dummy->capture_source[addr][1] != right;
527 dummy->capture_source[addr][0] = left;
528 dummy->capture_source[addr][1] = right;
529 spin_unlock_irqrestore(&dummy->mixer_lock, flags);
533 #define DUMMY_CONTROLS (sizeof(snd_dummy_controls)/sizeof(snd_kcontrol_new_t))
535 static snd_kcontrol_new_t snd_dummy_controls[] = {
536 DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
537 DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
538 DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
539 DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_MASTER),
540 DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
541 DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_MASTER),
542 DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
543 DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MASTER),
544 DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
545 DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_MASTER)
548 int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
550 snd_card_t *card = dummy->card;
554 snd_assert(dummy != NULL, return -EINVAL);
555 spin_lock_init(&dummy->mixer_lock);
556 strcpy(card->mixername, "Dummy Mixer");
558 for (idx = 0; idx < DUMMY_CONTROLS; idx++) {
559 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy))) < 0)
565 static int __init snd_card_dummy_probe(int dev)
568 struct snd_card_dummy *dummy;
573 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
574 sizeof(struct snd_card_dummy));
577 dummy = (struct snd_card_dummy *)card->private_data;
579 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
580 if (pcm_substreams[dev] < 1)
581 pcm_substreams[dev] = 1;
582 if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS)
583 pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
584 if ((err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev])) < 0)
587 if ((err = snd_card_dummy_new_mixer(dummy)) < 0)
589 strcpy(card->driver, "Dummy");
590 strcpy(card->shortname, "Dummy");
591 sprintf(card->longname, "Dummy %i", dev + 1);
592 if ((err = snd_card_register(card)) == 0) {
593 snd_dummy_cards[dev] = card;
601 static int __init alsa_card_dummy_init(void)
605 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) {
606 if (snd_card_dummy_probe(dev) < 0) {
608 printk(KERN_ERR "Dummy soundcard #%i not found or device busy\n", dev + 1);
616 printk(KERN_ERR "Dummy soundcard not found or device busy\n");
623 static void __exit alsa_card_dummy_exit(void)
627 for (idx = 0; idx < SNDRV_CARDS; idx++)
628 snd_card_free(snd_dummy_cards[idx]);
631 module_init(alsa_card_dummy_init)
632 module_exit(alsa_card_dummy_exit)
636 /* format is: snd-dummy=enable,index,id,
637 pcm_devs,pcm_substreams */
639 static int __init alsa_card_dummy_setup(char *str)
641 static unsigned __initdata nr_dev = 0;
643 if (nr_dev >= SNDRV_CARDS)
645 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
646 get_option(&str,&index[nr_dev]) == 2 &&
647 get_id(&str,&id[nr_dev]) == 2 &&
648 get_option(&str,&pcm_devs[nr_dev]) == 2 &&
649 get_option(&str,&pcm_substreams[nr_dev]) == 2);
654 __setup("snd-dummy=", alsa_card_dummy_setup);
656 #endif /* ifndef MODULE */