blob: f387d53e50397526d70b8a7409916dcabfdd924a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Dummy soundcard
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02003 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
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.
9 *
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.
14 *
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
18 *
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/init.h>
Takashi Iwai6e65c1c2005-11-17 16:01:56 +010022#include <linux/err.h>
23#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/jiffies.h>
25#include <linux/slab.h>
26#include <linux/time.h>
27#include <linux/wait.h>
Takashi Iwaic631d032009-09-03 15:59:26 +020028#include <linux/hrtimer.h>
29#include <linux/math64.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/moduleparam.h>
31#include <sound/core.h>
32#include <sound/control.h>
Takashi Iwaifb567a82006-08-23 13:07:19 +020033#include <sound/tlv.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <sound/pcm.h>
35#include <sound/rawmidi.h>
36#include <sound/initval.h>
37
Jaroslav Kyselac1017a42007-10-15 09:50:19 +020038MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
Linus Torvalds1da177e2005-04-16 15:20:36 -070039MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
40MODULE_LICENSE("GPL");
41MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}");
42
43#define MAX_PCM_DEVICES 4
44#define MAX_PCM_SUBSTREAMS 16
45#define MAX_MIDI_DEVICES 2
46
47#if 0 /* emu10k1 emulation */
48#define MAX_BUFFER_SIZE (128 * 1024)
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +010049static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 int err;
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +020052 err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
53 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 return err;
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +020055 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX);
Mariusz Kozlowskie78521f2008-10-19 10:34:22 +020056 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 return err;
58 return 0;
59}
60#define add_playback_constraints emu10k1_playback_constraints
61#endif
62
63#if 0 /* RME9652 emulation */
64#define MAX_BUFFER_SIZE (26 * 64 * 1024)
65#define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
66#define USE_CHANNELS_MIN 26
67#define USE_CHANNELS_MAX 26
68#define USE_PERIODS_MIN 2
69#define USE_PERIODS_MAX 2
70#endif
71
72#if 0 /* ICE1712 emulation */
73#define MAX_BUFFER_SIZE (256 * 1024)
74#define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE
75#define USE_CHANNELS_MIN 10
76#define USE_CHANNELS_MAX 10
77#define USE_PERIODS_MIN 1
78#define USE_PERIODS_MAX 1024
79#endif
80
81#if 0 /* UDA1341 emulation */
82#define MAX_BUFFER_SIZE (16380)
83#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
84#define USE_CHANNELS_MIN 2
85#define USE_CHANNELS_MAX 2
86#define USE_PERIODS_MIN 2
87#define USE_PERIODS_MAX 255
88#endif
89
90#if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
91#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
92#define USE_CHANNELS_MIN 2
93#define USE_CHANNELS_MAX 2
94#define USE_RATE SNDRV_PCM_RATE_48000
95#define USE_RATE_MIN 48000
96#define USE_RATE_MAX 48000
97#endif
98
Jaroslav Kysela2ad5dd82006-01-03 14:27:21 +010099#if 0 /* CA0106 */
100#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE
101#define USE_CHANNELS_MIN 2
102#define USE_CHANNELS_MAX 2
103#define USE_RATE (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000)
104#define USE_RATE_MIN 48000
105#define USE_RATE_MAX 192000
106#define MAX_BUFFER_SIZE ((65536-64)*8)
107#define MAX_PERIOD_SIZE (65536-64)
108#define USE_PERIODS_MIN 2
109#define USE_PERIODS_MAX 8
110#endif
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/* defaults */
114#ifndef MAX_BUFFER_SIZE
115#define MAX_BUFFER_SIZE (64*1024)
116#endif
Jaroslav Kysela2ad5dd82006-01-03 14:27:21 +0100117#ifndef MAX_PERIOD_SIZE
118#define MAX_PERIOD_SIZE MAX_BUFFER_SIZE
119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#ifndef USE_FORMATS
121#define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
122#endif
123#ifndef USE_RATE
124#define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000
125#define USE_RATE_MIN 5500
126#define USE_RATE_MAX 48000
127#endif
128#ifndef USE_CHANNELS_MIN
129#define USE_CHANNELS_MIN 1
130#endif
131#ifndef USE_CHANNELS_MAX
132#define USE_CHANNELS_MAX 2
133#endif
134#ifndef USE_PERIODS_MIN
135#define USE_PERIODS_MIN 1
136#endif
137#ifndef USE_PERIODS_MAX
138#define USE_PERIODS_MAX 1024
139#endif
140#ifndef add_playback_constraints
141#define add_playback_constraints(x) 0
142#endif
143#ifndef add_capture_constraints
144#define add_capture_constraints(x) 0
145#endif
146
147static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
148static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
149static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
150static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
151static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
152//static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
Takashi Iwaic631d032009-09-03 15:59:26 +0200153#ifdef CONFIG_HIGH_RES_TIMERS
154static int hrtimer = 1;
155#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
157module_param_array(index, int, NULL, 0444);
158MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
159module_param_array(id, charp, NULL, 0444);
160MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
161module_param_array(enable, bool, NULL, 0444);
162MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
163module_param_array(pcm_devs, int, NULL, 0444);
164MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
165module_param_array(pcm_substreams, int, NULL, 0444);
166MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
167//module_param_array(midi_devs, int, NULL, 0444);
168//MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
Takashi Iwaic631d032009-09-03 15:59:26 +0200169#ifdef CONFIG_HIGH_RES_TIMERS
170module_param(hrtimer, bool, 0644);
171MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source.");
172#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Clemens Ladischf7a92752005-12-07 09:13:42 +0100174static struct platform_device *devices[SNDRV_CARDS];
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176#define MIXER_ADDR_MASTER 0
177#define MIXER_ADDR_LINE 1
178#define MIXER_ADDR_MIC 2
179#define MIXER_ADDR_SYNTH 3
180#define MIXER_ADDR_CD 4
181#define MIXER_ADDR_LAST 4
182
Takashi Iwaic631d032009-09-03 15:59:26 +0200183struct dummy_timer_ops {
184 int (*create)(struct snd_pcm_substream *);
185 void (*free)(struct snd_pcm_substream *);
186 int (*prepare)(struct snd_pcm_substream *);
187 int (*start)(struct snd_pcm_substream *);
188 int (*stop)(struct snd_pcm_substream *);
189 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *);
190};
191
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100192struct snd_dummy {
193 struct snd_card *card;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100194 struct snd_pcm *pcm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 spinlock_t mixer_lock;
196 int mixer_volume[MIXER_ADDR_LAST+1][2];
197 int capture_source[MIXER_ADDR_LAST+1][2];
Takashi Iwaic631d032009-09-03 15:59:26 +0200198 const struct dummy_timer_ops *timer_ops;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100199};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Takashi Iwaic631d032009-09-03 15:59:26 +0200201/*
202 * system timer interface
203 */
204
205struct dummy_systimer_pcm {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 spinlock_t lock;
207 struct timer_list timer;
Ahmet İnan53463a82008-02-21 07:55:30 +0100208 unsigned int pcm_buffer_size;
209 unsigned int pcm_period_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 unsigned int pcm_bps; /* bytes per second */
Ahmet İnan53463a82008-02-21 07:55:30 +0100211 unsigned int pcm_hz; /* HZ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 unsigned int pcm_irq_pos; /* IRQ position */
213 unsigned int pcm_buf_pos; /* position in buffer */
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100214 struct snd_pcm_substream *substream;
215};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Takashi Iwaic631d032009-09-03 15:59:26 +0200217static int dummy_systimer_start(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218{
Takashi Iwaic631d032009-09-03 15:59:26 +0200219 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
220 spin_lock(&dpcm->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 dpcm->timer.expires = 1 + jiffies;
222 add_timer(&dpcm->timer);
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100223 spin_unlock(&dpcm->lock);
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100224 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225}
226
Takashi Iwaic631d032009-09-03 15:59:26 +0200227static int dummy_systimer_stop(struct snd_pcm_substream *substream)
228{
229 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
230 spin_lock(&dpcm->lock);
231 del_timer(&dpcm->timer);
232 spin_unlock(&dpcm->lock);
233 return 0;
234}
235
236static int dummy_systimer_prepare(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100238 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwaic631d032009-09-03 15:59:26 +0200239 struct dummy_systimer_pcm *dpcm = runtime->private_data;
Roel Kluin369b2402008-04-16 19:30:30 +0200240 int bps;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Roel Kluin369b2402008-04-16 19:30:30 +0200242 bps = snd_pcm_format_width(runtime->format) * runtime->rate *
243 runtime->channels / 8;
244
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 if (bps <= 0)
246 return -EINVAL;
Roel Kluin369b2402008-04-16 19:30:30 +0200247
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 dpcm->pcm_bps = bps;
Ahmet İnan53463a82008-02-21 07:55:30 +0100249 dpcm->pcm_hz = HZ;
250 dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
251 dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 dpcm->pcm_irq_pos = 0;
253 dpcm->pcm_buf_pos = 0;
Ahmet İnan53463a82008-02-21 07:55:30 +0100254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 return 0;
256}
257
Takashi Iwaic631d032009-09-03 15:59:26 +0200258static void dummy_systimer_callback(unsigned long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259{
Takashi Iwaic631d032009-09-03 15:59:26 +0200260 struct dummy_systimer_pcm *dpcm = (struct dummy_systimer_pcm *)data;
Takashi Iwaib32425a2005-11-18 18:52:14 +0100261 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Takashi Iwaib32425a2005-11-18 18:52:14 +0100263 spin_lock_irqsave(&dpcm->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 dpcm->timer.expires = 1 + jiffies;
265 add_timer(&dpcm->timer);
Ahmet İnan53463a82008-02-21 07:55:30 +0100266 dpcm->pcm_irq_pos += dpcm->pcm_bps;
Ahmet İnan470f23b2008-02-28 12:46:32 +0100267 dpcm->pcm_buf_pos += dpcm->pcm_bps;
268 dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
Ahmet İnan53463a82008-02-21 07:55:30 +0100269 if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
270 dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
Takashi Iwaib32425a2005-11-18 18:52:14 +0100271 spin_unlock_irqrestore(&dpcm->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 snd_pcm_period_elapsed(dpcm->substream);
Takashi Iwaib32425a2005-11-18 18:52:14 +0100273 } else
274 spin_unlock_irqrestore(&dpcm->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275}
276
Takashi Iwaic631d032009-09-03 15:59:26 +0200277static snd_pcm_uframes_t
278dummy_systimer_pointer(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100280 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwaic631d032009-09-03 15:59:26 +0200281 struct dummy_systimer_pcm *dpcm = runtime->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Ahmet İnan470f23b2008-02-28 12:46:32 +0100283 return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284}
285
Takashi Iwaic631d032009-09-03 15:59:26 +0200286static int dummy_systimer_create(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287{
Takashi Iwaic631d032009-09-03 15:59:26 +0200288 struct dummy_systimer_pcm *dpcm;
289
290 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
291 if (!dpcm)
292 return -ENOMEM;
293 substream->runtime->private_data = dpcm;
294 init_timer(&dpcm->timer);
295 dpcm->timer.data = (unsigned long) dpcm;
296 dpcm->timer.function = dummy_systimer_callback;
297 spin_lock_init(&dpcm->lock);
298 dpcm->substream = substream;
299 return 0;
300}
301
302static void dummy_systimer_free(struct snd_pcm_substream *substream)
303{
304 kfree(substream->runtime->private_data);
305}
306
307static struct dummy_timer_ops dummy_systimer_ops = {
308 .create = dummy_systimer_create,
309 .free = dummy_systimer_free,
310 .prepare = dummy_systimer_prepare,
311 .start = dummy_systimer_start,
312 .stop = dummy_systimer_stop,
313 .pointer = dummy_systimer_pointer,
314};
315
316#ifdef CONFIG_HIGH_RES_TIMERS
317/*
318 * hrtimer interface
319 */
320
321struct dummy_hrtimer_pcm {
322 ktime_t base_time;
323 ktime_t period_time;
324 atomic_t running;
325 struct hrtimer timer;
326 struct tasklet_struct tasklet;
327 struct snd_pcm_substream *substream;
328};
329
330static void dummy_hrtimer_pcm_elapsed(unsigned long priv)
331{
332 struct dummy_hrtimer_pcm *dpcm = (struct dummy_hrtimer_pcm *)priv;
333 if (atomic_read(&dpcm->running))
334 snd_pcm_period_elapsed(dpcm->substream);
335}
336
337static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer)
338{
339 struct dummy_hrtimer_pcm *dpcm;
340
341 dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer);
342 if (!atomic_read(&dpcm->running))
343 return HRTIMER_NORESTART;
344 tasklet_schedule(&dpcm->tasklet);
345 hrtimer_forward_now(timer, dpcm->period_time);
346 return HRTIMER_RESTART;
347}
348
349static int dummy_hrtimer_start(struct snd_pcm_substream *substream)
350{
351 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
352
353 dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer);
354 hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL);
355 atomic_set(&dpcm->running, 1);
356 return 0;
357}
358
359static int dummy_hrtimer_stop(struct snd_pcm_substream *substream)
360{
361 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
362
363 atomic_set(&dpcm->running, 0);
364 hrtimer_cancel(&dpcm->timer);
365 return 0;
366}
367
368static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm)
369{
370 tasklet_kill(&dpcm->tasklet);
371}
372
373static snd_pcm_uframes_t
374dummy_hrtimer_pointer(struct snd_pcm_substream *substream)
375{
376 struct snd_pcm_runtime *runtime = substream->runtime;
377 struct dummy_hrtimer_pcm *dpcm = runtime->private_data;
378 u64 delta;
379 u32 pos;
380
381 delta = ktime_us_delta(hrtimer_cb_get_time(&dpcm->timer),
382 dpcm->base_time);
383 delta = div_u64(delta * runtime->rate + 999999, 1000000);
384 div_u64_rem(delta, runtime->buffer_size, &pos);
385 return pos;
386}
387
388static int dummy_hrtimer_prepare(struct snd_pcm_substream *substream)
389{
390 struct snd_pcm_runtime *runtime = substream->runtime;
391 struct dummy_hrtimer_pcm *dpcm = runtime->private_data;
392 unsigned int period, rate;
393 long sec;
394 unsigned long nsecs;
395
396 dummy_hrtimer_sync(dpcm);
397 period = runtime->period_size;
398 rate = runtime->rate;
399 sec = period / rate;
400 period %= rate;
401 nsecs = div_u64((u64)period * 1000000000UL + rate - 1, rate);
402 dpcm->period_time = ktime_set(sec, nsecs);
403
404 return 0;
405}
406
407static int dummy_hrtimer_create(struct snd_pcm_substream *substream)
408{
409 struct dummy_hrtimer_pcm *dpcm;
410
411 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
412 if (!dpcm)
413 return -ENOMEM;
414 substream->runtime->private_data = dpcm;
415 hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
416 dpcm->timer.function = dummy_hrtimer_callback;
417 dpcm->substream = substream;
418 atomic_set(&dpcm->running, 0);
419 tasklet_init(&dpcm->tasklet, dummy_hrtimer_pcm_elapsed,
420 (unsigned long)dpcm);
421 return 0;
422}
423
424static void dummy_hrtimer_free(struct snd_pcm_substream *substream)
425{
426 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
427 dummy_hrtimer_sync(dpcm);
428 kfree(dpcm);
429}
430
431static struct dummy_timer_ops dummy_hrtimer_ops = {
432 .create = dummy_hrtimer_create,
433 .free = dummy_hrtimer_free,
434 .prepare = dummy_hrtimer_prepare,
435 .start = dummy_hrtimer_start,
436 .stop = dummy_hrtimer_stop,
437 .pointer = dummy_hrtimer_pointer,
438};
439
440#endif /* CONFIG_HIGH_RES_TIMERS */
441
442/*
443 * PCM interface
444 */
445
446static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
447{
448 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
449
450 switch (cmd) {
451 case SNDRV_PCM_TRIGGER_START:
452 case SNDRV_PCM_TRIGGER_RESUME:
453 return dummy->timer_ops->start(substream);
454 case SNDRV_PCM_TRIGGER_STOP:
455 case SNDRV_PCM_TRIGGER_SUSPEND:
456 return dummy->timer_ops->stop(substream);
457 }
458 return -EINVAL;
459}
460
461static int dummy_pcm_prepare(struct snd_pcm_substream *substream)
462{
463 struct snd_pcm_runtime *runtime = substream->runtime;
464 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
465
466 snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
467 bytes_to_samples(runtime, runtime->dma_bytes));
468 return dummy->timer_ops->prepare(substream);
469}
470
471static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream)
472{
473 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
474
475 return dummy->timer_ops->pointer(substream);
476}
477
478static struct snd_pcm_hardware dummy_pcm_hardware = {
479 .info = (SNDRV_PCM_INFO_MMAP |
480 SNDRV_PCM_INFO_INTERLEAVED |
481 SNDRV_PCM_INFO_RESUME |
482 SNDRV_PCM_INFO_MMAP_VALID),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 .formats = USE_FORMATS,
484 .rates = USE_RATE,
485 .rate_min = USE_RATE_MIN,
486 .rate_max = USE_RATE_MAX,
487 .channels_min = USE_CHANNELS_MIN,
488 .channels_max = USE_CHANNELS_MAX,
489 .buffer_bytes_max = MAX_BUFFER_SIZE,
490 .period_bytes_min = 64,
Takashi Iwaie05d6962006-08-17 17:12:19 +0200491 .period_bytes_max = MAX_PERIOD_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 .periods_min = USE_PERIODS_MIN,
493 .periods_max = USE_PERIODS_MAX,
494 .fifo_size = 0,
495};
496
Takashi Iwaic631d032009-09-03 15:59:26 +0200497static int dummy_pcm_hw_params(struct snd_pcm_substream *substream,
498 struct snd_pcm_hw_params *hw_params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499{
Takashi Iwaic631d032009-09-03 15:59:26 +0200500 return snd_pcm_lib_malloc_pages(substream,
501 params_buffer_bytes(hw_params));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502}
503
Takashi Iwaic631d032009-09-03 15:59:26 +0200504static int dummy_pcm_hw_free(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505{
506 return snd_pcm_lib_free_pages(substream);
507}
508
Takashi Iwaic631d032009-09-03 15:59:26 +0200509static int dummy_pcm_open(struct snd_pcm_substream *substream)
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100510{
Takashi Iwaic631d032009-09-03 15:59:26 +0200511 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100512 struct snd_pcm_runtime *runtime = substream->runtime;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 int err;
514
Takashi Iwaic631d032009-09-03 15:59:26 +0200515 dummy->timer_ops = &dummy_systimer_ops;
516#ifdef CONFIG_HIGH_RES_TIMERS
517 if (hrtimer)
518 dummy->timer_ops = &dummy_hrtimer_ops;
519#endif
520
521 err = dummy->timer_ops->create(substream);
522 if (err < 0)
523 return err;
524
525 runtime->hw = dummy_pcm_hardware;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 if (substream->pcm->device & 1) {
527 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
528 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
529 }
530 if (substream->pcm->device & 2)
Takashi Iwaic631d032009-09-03 15:59:26 +0200531 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP |
532 SNDRV_PCM_INFO_MMAP_VALID);
533
534 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
535 err = add_playback_constraints(substream->runtime);
536 else
537 err = add_capture_constraints(substream->runtime);
538 if (err < 0) {
539 dummy->timer_ops->free(substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 return 0;
543}
544
Takashi Iwaic631d032009-09-03 15:59:26 +0200545static int dummy_pcm_close(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546{
Takashi Iwaic631d032009-09-03 15:59:26 +0200547 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
548 dummy->timer_ops->free(substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 return 0;
550}
551
Takashi Iwaic631d032009-09-03 15:59:26 +0200552static struct snd_pcm_ops dummy_pcm_ops = {
553 .open = dummy_pcm_open,
554 .close = dummy_pcm_close,
555 .ioctl = snd_pcm_lib_ioctl,
556 .hw_params = dummy_pcm_hw_params,
557 .hw_free = dummy_pcm_hw_free,
558 .prepare = dummy_pcm_prepare,
559 .trigger = dummy_pcm_trigger,
560 .pointer = dummy_pcm_pointer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561};
562
Prarit Bhargava788c6042007-02-13 13:11:11 +0100563static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device,
564 int substreams)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100566 struct snd_pcm *pcm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 int err;
568
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200569 err = snd_pcm_new(dummy->card, "Dummy PCM", device,
570 substreams, substreams, &pcm);
571 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 return err;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100573 dummy->pcm = pcm;
Takashi Iwaic631d032009-09-03 15:59:26 +0200574 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &dummy_pcm_ops);
575 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &dummy_pcm_ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 pcm->private_data = dummy;
577 pcm->info_flags = 0;
578 strcpy(pcm->name, "Dummy PCM");
579 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
580 snd_dma_continuous_data(GFP_KERNEL),
581 0, 64*1024);
582 return 0;
583}
584
585#define DUMMY_VOLUME(xname, xindex, addr) \
Takashi Iwaifb567a82006-08-23 13:07:19 +0200586{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
587 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
588 .name = xname, .index = xindex, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 .info = snd_dummy_volume_info, \
590 .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
Takashi Iwaifb567a82006-08-23 13:07:19 +0200591 .private_value = addr, \
592 .tlv = { .p = db_scale_dummy } }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100594static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596{
597 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
598 uinfo->count = 2;
599 uinfo->value.integer.min = -50;
600 uinfo->value.integer.max = 100;
601 return 0;
602}
603
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100604static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100607 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 int addr = kcontrol->private_value;
609
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100610 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0];
612 ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1];
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100613 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 return 0;
615}
616
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100617static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol,
618 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100620 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 int change, addr = kcontrol->private_value;
622 int left, right;
623
624 left = ucontrol->value.integer.value[0];
625 if (left < -50)
626 left = -50;
627 if (left > 100)
628 left = 100;
629 right = ucontrol->value.integer.value[1];
630 if (right < -50)
631 right = -50;
632 if (right > 100)
633 right = 100;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100634 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 change = dummy->mixer_volume[addr][0] != left ||
636 dummy->mixer_volume[addr][1] != right;
637 dummy->mixer_volume[addr][0] = left;
638 dummy->mixer_volume[addr][1] = right;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100639 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 return change;
641}
642
Takashi Iwai0cb29ea2007-01-29 15:33:49 +0100643static const DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0);
Takashi Iwaifb567a82006-08-23 13:07:19 +0200644
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645#define DUMMY_CAPSRC(xname, xindex, addr) \
646{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
647 .info = snd_dummy_capsrc_info, \
648 .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
649 .private_value = addr }
650
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200651#define snd_dummy_capsrc_info snd_ctl_boolean_stereo_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100653static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100656 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 int addr = kcontrol->private_value;
658
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100659 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 ucontrol->value.integer.value[0] = dummy->capture_source[addr][0];
661 ucontrol->value.integer.value[1] = dummy->capture_source[addr][1];
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100662 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 return 0;
664}
665
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100666static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100668 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 int change, addr = kcontrol->private_value;
670 int left, right;
671
672 left = ucontrol->value.integer.value[0] & 1;
673 right = ucontrol->value.integer.value[1] & 1;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100674 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 change = dummy->capture_source[addr][0] != left &&
676 dummy->capture_source[addr][1] != right;
677 dummy->capture_source[addr][0] = left;
678 dummy->capture_source[addr][1] = right;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100679 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 return change;
681}
682
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100683static struct snd_kcontrol_new snd_dummy_controls[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
685DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
686DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200687DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_SYNTH),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200689DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200691DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200693DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694};
695
Prarit Bhargava788c6042007-02-13 13:11:11 +0100696static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100698 struct snd_card *card = dummy->card;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 unsigned int idx;
700 int err;
701
Takashi Iwai5e246b82008-08-08 17:12:47 +0200702 if (snd_BUG_ON(!dummy))
703 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 spin_lock_init(&dummy->mixer_lock);
705 strcpy(card->mixername, "Dummy Mixer");
706
707 for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200708 err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy));
709 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 return err;
711 }
712 return 0;
713}
714
Prarit Bhargava788c6042007-02-13 13:11:11 +0100715static int __devinit snd_dummy_probe(struct platform_device *devptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100717 struct snd_card *card;
718 struct snd_dummy *dummy;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 int idx, err;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100720 int dev = devptr->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721
Takashi Iwaibd7dd772008-12-28 16:45:02 +0100722 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
723 sizeof(struct snd_dummy), &card);
724 if (err < 0)
725 return err;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100726 dummy = card->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 dummy->card = card;
728 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
729 if (pcm_substreams[dev] < 1)
730 pcm_substreams[dev] = 1;
731 if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS)
732 pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200733 err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]);
734 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 goto __nodev;
736 }
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200737 err = snd_card_dummy_new_mixer(dummy);
738 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 goto __nodev;
740 strcpy(card->driver, "Dummy");
741 strcpy(card->shortname, "Dummy");
742 sprintf(card->longname, "Dummy %i", dev + 1);
Takashi Iwai16dab542005-09-05 17:17:58 +0200743
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100744 snd_card_set_dev(card, &devptr->dev);
Takashi Iwai16dab542005-09-05 17:17:58 +0200745
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200746 err = snd_card_register(card);
747 if (err == 0) {
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100748 platform_set_drvdata(devptr, card);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 return 0;
750 }
751 __nodev:
752 snd_card_free(card);
753 return err;
754}
755
Prarit Bhargava788c6042007-02-13 13:11:11 +0100756static int __devexit snd_dummy_remove(struct platform_device *devptr)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100757{
758 snd_card_free(platform_get_drvdata(devptr));
759 platform_set_drvdata(devptr, NULL);
760 return 0;
761}
762
763#ifdef CONFIG_PM
764static int snd_dummy_suspend(struct platform_device *pdev, pm_message_t state)
765{
766 struct snd_card *card = platform_get_drvdata(pdev);
767 struct snd_dummy *dummy = card->private_data;
768
769 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
770 snd_pcm_suspend_all(dummy->pcm);
771 return 0;
772}
773
774static int snd_dummy_resume(struct platform_device *pdev)
775{
776 struct snd_card *card = platform_get_drvdata(pdev);
777
778 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
779 return 0;
780}
781#endif
782
783#define SND_DUMMY_DRIVER "snd_dummy"
784
785static struct platform_driver snd_dummy_driver = {
786 .probe = snd_dummy_probe,
Prarit Bhargava788c6042007-02-13 13:11:11 +0100787 .remove = __devexit_p(snd_dummy_remove),
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100788#ifdef CONFIG_PM
789 .suspend = snd_dummy_suspend,
790 .resume = snd_dummy_resume,
791#endif
792 .driver = {
793 .name = SND_DUMMY_DRIVER
794 },
795};
796
Randy Dunlapc12aad62007-06-25 12:08:01 +0200797static void snd_dummy_unregister_all(void)
Clemens Ladischf7a92752005-12-07 09:13:42 +0100798{
799 int i;
800
801 for (i = 0; i < ARRAY_SIZE(devices); ++i)
802 platform_device_unregister(devices[i]);
803 platform_driver_unregister(&snd_dummy_driver);
804}
805
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806static int __init alsa_card_dummy_init(void)
807{
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100808 int i, cards, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200810 err = platform_driver_register(&snd_dummy_driver);
811 if (err < 0)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100812 return err;
813
814 cards = 0;
Takashi Iwai8278ca82006-02-20 11:57:34 +0100815 for (i = 0; i < SNDRV_CARDS; i++) {
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100816 struct platform_device *device;
Takashi Iwai8278ca82006-02-20 11:57:34 +0100817 if (! enable[i])
818 continue;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100819 device = platform_device_register_simple(SND_DUMMY_DRIVER,
820 i, NULL, 0);
Rene Hermana182ee92006-04-13 12:57:11 +0200821 if (IS_ERR(device))
822 continue;
Rene Herman71524472006-04-13 12:58:06 +0200823 if (!platform_get_drvdata(device)) {
824 platform_device_unregister(device);
825 continue;
826 }
Clemens Ladischf7a92752005-12-07 09:13:42 +0100827 devices[i] = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 cards++;
829 }
830 if (!cards) {
831#ifdef MODULE
832 printk(KERN_ERR "Dummy soundcard not found or device busy\n");
833#endif
Rene Hermana182ee92006-04-13 12:57:11 +0200834 snd_dummy_unregister_all();
835 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 }
837 return 0;
838}
839
840static void __exit alsa_card_dummy_exit(void)
841{
Clemens Ladischf7a92752005-12-07 09:13:42 +0100842 snd_dummy_unregister_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843}
844
845module_init(alsa_card_dummy_init)
846module_exit(alsa_card_dummy_exit)