blob: aee7c04d49e524679d694e37709b680e2cb03e11 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Dummy soundcard
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02004 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/init.h>
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01008#include <linux/err.h>
9#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/jiffies.h>
11#include <linux/slab.h>
12#include <linux/time.h>
13#include <linux/wait.h>
Takashi Iwaic631d032009-09-03 15:59:26 +020014#include <linux/hrtimer.h>
15#include <linux/math64.h>
Paul Gortmaker65a77212011-07-15 13:13:37 -040016#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <sound/core.h>
18#include <sound/control.h>
Takashi Iwaifb567a82006-08-23 13:07:19 +020019#include <sound/tlv.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <sound/pcm.h>
21#include <sound/rawmidi.h>
Takashi Iwai9b151fe2009-09-08 14:30:49 +020022#include <sound/info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <sound/initval.h>
24
Jaroslav Kyselac1017a42007-10-15 09:50:19 +020025MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
Linus Torvalds1da177e2005-04-16 15:20:36 -070026MODULE_DESCRIPTION("Dummy soundcard (/dev/null)");
27MODULE_LICENSE("GPL");
28MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}");
29
30#define MAX_PCM_DEVICES 4
Takashi Iwaib888d1c2009-09-08 18:15:17 +020031#define MAX_PCM_SUBSTREAMS 128
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#define MAX_MIDI_DEVICES 2
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034/* defaults */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#define MAX_BUFFER_SIZE (64*1024)
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +010036#define MIN_PERIOD_SIZE 64
Jaroslav Kysela2ad5dd82006-01-03 14:27:21 +010037#define MAX_PERIOD_SIZE MAX_BUFFER_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000
40#define USE_RATE_MIN 5500
41#define USE_RATE_MAX 48000
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define USE_CHANNELS_MIN 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#define USE_CHANNELS_MAX 2
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define USE_PERIODS_MIN 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define USE_PERIODS_MAX 1024
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
Rusty Russella67ff6a2011-12-15 13:49:36 +103049static bool enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +010050static char *model[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = NULL};
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
52static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8};
53//static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
Takashi Iwaic631d032009-09-03 15:59:26 +020054#ifdef CONFIG_HIGH_RES_TIMERS
Rusty Russella67ff6a2011-12-15 13:49:36 +103055static bool hrtimer = 1;
Takashi Iwaic631d032009-09-03 15:59:26 +020056#endif
Rusty Russella67ff6a2011-12-15 13:49:36 +103057static bool fake_buffer = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59module_param_array(index, int, NULL, 0444);
60MODULE_PARM_DESC(index, "Index value for dummy soundcard.");
61module_param_array(id, charp, NULL, 0444);
62MODULE_PARM_DESC(id, "ID string for dummy soundcard.");
63module_param_array(enable, bool, NULL, 0444);
64MODULE_PARM_DESC(enable, "Enable this dummy soundcard.");
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +010065module_param_array(model, charp, NULL, 0444);
66MODULE_PARM_DESC(model, "Soundcard model.");
Linus Torvalds1da177e2005-04-16 15:20:36 -070067module_param_array(pcm_devs, int, NULL, 0444);
68MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver.");
69module_param_array(pcm_substreams, int, NULL, 0444);
Takashi Iwai23aebca42009-11-02 14:10:59 +010070MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-128) for dummy driver.");
Linus Torvalds1da177e2005-04-16 15:20:36 -070071//module_param_array(midi_devs, int, NULL, 0444);
72//MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
Takashi Iwaia68c4d12009-09-04 12:19:36 +020073module_param(fake_buffer, bool, 0444);
74MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations.");
Takashi Iwaic631d032009-09-03 15:59:26 +020075#ifdef CONFIG_HIGH_RES_TIMERS
Takashi Iwaiddce57a2016-02-02 15:27:36 +010076module_param(hrtimer, bool, 0644);
Takashi Iwaic631d032009-09-03 15:59:26 +020077MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source.");
78#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Clemens Ladischf7a92752005-12-07 09:13:42 +010080static struct platform_device *devices[SNDRV_CARDS];
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define MIXER_ADDR_MASTER 0
83#define MIXER_ADDR_LINE 1
84#define MIXER_ADDR_MIC 2
85#define MIXER_ADDR_SYNTH 3
86#define MIXER_ADDR_CD 4
87#define MIXER_ADDR_LAST 4
88
Takashi Iwaic631d032009-09-03 15:59:26 +020089struct dummy_timer_ops {
90 int (*create)(struct snd_pcm_substream *);
91 void (*free)(struct snd_pcm_substream *);
92 int (*prepare)(struct snd_pcm_substream *);
93 int (*start)(struct snd_pcm_substream *);
94 int (*stop)(struct snd_pcm_substream *);
95 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *);
96};
97
Takashi Iwaiddce57a2016-02-02 15:27:36 +010098#define get_dummy_ops(substream) \
99 (*(const struct dummy_timer_ops **)(substream)->runtime->private_data)
100
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100101struct dummy_model {
102 const char *name;
103 int (*playback_constraints)(struct snd_pcm_runtime *runtime);
104 int (*capture_constraints)(struct snd_pcm_runtime *runtime);
105 u64 formats;
106 size_t buffer_bytes_max;
107 size_t period_bytes_min;
108 size_t period_bytes_max;
109 unsigned int periods_min;
110 unsigned int periods_max;
111 unsigned int rates;
112 unsigned int rate_min;
113 unsigned int rate_max;
114 unsigned int channels_min;
115 unsigned int channels_max;
116};
117
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100118struct snd_dummy {
119 struct snd_card *card;
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100120 struct dummy_model *model;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100121 struct snd_pcm *pcm;
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100122 struct snd_pcm_hardware pcm_hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 spinlock_t mixer_lock;
124 int mixer_volume[MIXER_ADDR_LAST+1][2];
125 int capture_source[MIXER_ADDR_LAST+1][2];
Clemens Ladisch16e43462012-10-20 12:21:36 +0200126 int iobox;
127 struct snd_kcontrol *cd_volume_ctl;
128 struct snd_kcontrol *cd_switch_ctl;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100129};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Takashi Iwaic631d032009-09-03 15:59:26 +0200131/*
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100132 * card models
133 */
134
135static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime)
136{
137 int err;
138 err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
139 if (err < 0)
140 return err;
141 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX);
142 if (err < 0)
143 return err;
144 return 0;
145}
146
Takashi Iwaie4c28682015-05-26 12:51:35 +0200147static struct dummy_model model_emu10k1 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100148 .name = "emu10k1",
149 .playback_constraints = emu10k1_playback_constraints,
150 .buffer_bytes_max = 128 * 1024,
151};
152
Takashi Iwaie4c28682015-05-26 12:51:35 +0200153static struct dummy_model model_rme9652 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100154 .name = "rme9652",
155 .buffer_bytes_max = 26 * 64 * 1024,
156 .formats = SNDRV_PCM_FMTBIT_S32_LE,
157 .channels_min = 26,
158 .channels_max = 26,
159 .periods_min = 2,
160 .periods_max = 2,
161};
162
Takashi Iwaie4c28682015-05-26 12:51:35 +0200163static struct dummy_model model_ice1712 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100164 .name = "ice1712",
165 .buffer_bytes_max = 256 * 1024,
166 .formats = SNDRV_PCM_FMTBIT_S32_LE,
167 .channels_min = 10,
168 .channels_max = 10,
169 .periods_min = 1,
170 .periods_max = 1024,
171};
172
Takashi Iwaie4c28682015-05-26 12:51:35 +0200173static struct dummy_model model_uda1341 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100174 .name = "uda1341",
175 .buffer_bytes_max = 16380,
176 .formats = SNDRV_PCM_FMTBIT_S16_LE,
177 .channels_min = 2,
178 .channels_max = 2,
179 .periods_min = 2,
180 .periods_max = 255,
181};
182
Takashi Iwaie4c28682015-05-26 12:51:35 +0200183static struct dummy_model model_ac97 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100184 .name = "ac97",
185 .formats = SNDRV_PCM_FMTBIT_S16_LE,
186 .channels_min = 2,
187 .channels_max = 2,
188 .rates = SNDRV_PCM_RATE_48000,
189 .rate_min = 48000,
190 .rate_max = 48000,
191};
192
Takashi Iwaie4c28682015-05-26 12:51:35 +0200193static struct dummy_model model_ca0106 = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100194 .name = "ca0106",
195 .formats = SNDRV_PCM_FMTBIT_S16_LE,
196 .buffer_bytes_max = ((65536-64)*8),
197 .period_bytes_max = (65536-64),
198 .periods_min = 2,
199 .periods_max = 8,
200 .channels_min = 2,
201 .channels_max = 2,
202 .rates = SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000,
203 .rate_min = 48000,
204 .rate_max = 192000,
205};
206
Takashi Iwaie4c28682015-05-26 12:51:35 +0200207static struct dummy_model *dummy_models[] = {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100208 &model_emu10k1,
209 &model_rme9652,
210 &model_ice1712,
211 &model_uda1341,
212 &model_ac97,
213 &model_ca0106,
214 NULL
215};
216
217/*
Takashi Iwaic631d032009-09-03 15:59:26 +0200218 * system timer interface
219 */
220
221struct dummy_systimer_pcm {
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100222 /* ops must be the first item */
223 const struct dummy_timer_ops *timer_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 spinlock_t lock;
225 struct timer_list timer;
Takashi Iwaib1420372009-09-03 16:01:06 +0200226 unsigned long base_time;
227 unsigned int frac_pos; /* fractional sample position (based HZ) */
Takashi Iwaib5d10782009-09-04 08:45:11 +0200228 unsigned int frac_period_rest;
Takashi Iwaib1420372009-09-03 16:01:06 +0200229 unsigned int frac_buffer_size; /* buffer_size * HZ */
230 unsigned int frac_period_size; /* period_size * HZ */
231 unsigned int rate;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200232 int elapsed;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100233 struct snd_pcm_substream *substream;
234};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Takashi Iwaib1420372009-09-03 16:01:06 +0200236static void dummy_systimer_rearm(struct dummy_systimer_pcm *dpcm)
237{
Roman Kollar2a52b6e2015-01-19 10:42:54 +0100238 mod_timer(&dpcm->timer, jiffies +
239 (dpcm->frac_period_rest + dpcm->rate - 1) / dpcm->rate);
Takashi Iwaib1420372009-09-03 16:01:06 +0200240}
241
242static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm)
243{
244 unsigned long delta;
245
246 delta = jiffies - dpcm->base_time;
247 if (!delta)
248 return;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200249 dpcm->base_time += delta;
250 delta *= dpcm->rate;
251 dpcm->frac_pos += delta;
Takashi Iwaib1420372009-09-03 16:01:06 +0200252 while (dpcm->frac_pos >= dpcm->frac_buffer_size)
253 dpcm->frac_pos -= dpcm->frac_buffer_size;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200254 while (dpcm->frac_period_rest <= delta) {
255 dpcm->elapsed++;
256 dpcm->frac_period_rest += dpcm->frac_period_size;
257 }
258 dpcm->frac_period_rest -= delta;
Takashi Iwaib1420372009-09-03 16:01:06 +0200259}
260
Takashi Iwaic631d032009-09-03 15:59:26 +0200261static int dummy_systimer_start(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
Takashi Iwaic631d032009-09-03 15:59:26 +0200263 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
264 spin_lock(&dpcm->lock);
Takashi Iwaib1420372009-09-03 16:01:06 +0200265 dpcm->base_time = jiffies;
266 dummy_systimer_rearm(dpcm);
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100267 spin_unlock(&dpcm->lock);
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100268 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269}
270
Takashi Iwaic631d032009-09-03 15:59:26 +0200271static int dummy_systimer_stop(struct snd_pcm_substream *substream)
272{
273 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
274 spin_lock(&dpcm->lock);
275 del_timer(&dpcm->timer);
276 spin_unlock(&dpcm->lock);
277 return 0;
278}
279
280static int dummy_systimer_prepare(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100282 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwaic631d032009-09-03 15:59:26 +0200283 struct dummy_systimer_pcm *dpcm = runtime->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwaib1420372009-09-03 16:01:06 +0200285 dpcm->frac_pos = 0;
286 dpcm->rate = runtime->rate;
287 dpcm->frac_buffer_size = runtime->buffer_size * HZ;
288 dpcm->frac_period_size = runtime->period_size * HZ;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200289 dpcm->frac_period_rest = dpcm->frac_period_size;
290 dpcm->elapsed = 0;
Ahmet Ä°nan53463a82008-02-21 07:55:30 +0100291
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 return 0;
293}
294
Kees Cookbc47ba92017-10-24 08:34:29 -0700295static void dummy_systimer_callback(struct timer_list *t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
Kees Cookbc47ba92017-10-24 08:34:29 -0700297 struct dummy_systimer_pcm *dpcm = from_timer(dpcm, t, timer);
Takashi Iwaib32425a2005-11-18 18:52:14 +0100298 unsigned long flags;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200299 int elapsed = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
Takashi Iwaib32425a2005-11-18 18:52:14 +0100301 spin_lock_irqsave(&dpcm->lock, flags);
Takashi Iwaib1420372009-09-03 16:01:06 +0200302 dummy_systimer_update(dpcm);
303 dummy_systimer_rearm(dpcm);
Takashi Iwaib5d10782009-09-04 08:45:11 +0200304 elapsed = dpcm->elapsed;
305 dpcm->elapsed = 0;
Takashi Iwaib1420372009-09-03 16:01:06 +0200306 spin_unlock_irqrestore(&dpcm->lock, flags);
Takashi Iwaib5d10782009-09-04 08:45:11 +0200307 if (elapsed)
308 snd_pcm_period_elapsed(dpcm->substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Takashi Iwaic631d032009-09-03 15:59:26 +0200311static snd_pcm_uframes_t
312dummy_systimer_pointer(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
Takashi Iwaib1420372009-09-03 16:01:06 +0200314 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
Takashi Iwaib5d10782009-09-04 08:45:11 +0200315 snd_pcm_uframes_t pos;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
Takashi Iwaib1420372009-09-03 16:01:06 +0200317 spin_lock(&dpcm->lock);
318 dummy_systimer_update(dpcm);
Takashi Iwaib5d10782009-09-04 08:45:11 +0200319 pos = dpcm->frac_pos / HZ;
Takashi Iwaib1420372009-09-03 16:01:06 +0200320 spin_unlock(&dpcm->lock);
Takashi Iwaib5d10782009-09-04 08:45:11 +0200321 return pos;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322}
323
Takashi Iwaic631d032009-09-03 15:59:26 +0200324static int dummy_systimer_create(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
Takashi Iwaic631d032009-09-03 15:59:26 +0200326 struct dummy_systimer_pcm *dpcm;
327
328 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
329 if (!dpcm)
330 return -ENOMEM;
331 substream->runtime->private_data = dpcm;
Kees Cookbc47ba92017-10-24 08:34:29 -0700332 timer_setup(&dpcm->timer, dummy_systimer_callback, 0);
Takashi Iwaic631d032009-09-03 15:59:26 +0200333 spin_lock_init(&dpcm->lock);
334 dpcm->substream = substream;
335 return 0;
336}
337
338static void dummy_systimer_free(struct snd_pcm_substream *substream)
339{
340 kfree(substream->runtime->private_data);
341}
342
Julia Lawalld8c5ed72015-12-30 12:28:49 +0100343static const struct dummy_timer_ops dummy_systimer_ops = {
Takashi Iwaic631d032009-09-03 15:59:26 +0200344 .create = dummy_systimer_create,
345 .free = dummy_systimer_free,
346 .prepare = dummy_systimer_prepare,
347 .start = dummy_systimer_start,
348 .stop = dummy_systimer_stop,
349 .pointer = dummy_systimer_pointer,
350};
351
352#ifdef CONFIG_HIGH_RES_TIMERS
353/*
354 * hrtimer interface
355 */
356
357struct dummy_hrtimer_pcm {
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100358 /* ops must be the first item */
359 const struct dummy_timer_ops *timer_ops;
Takashi Iwaic631d032009-09-03 15:59:26 +0200360 ktime_t base_time;
361 ktime_t period_time;
362 atomic_t running;
363 struct hrtimer timer;
Takashi Iwaic631d032009-09-03 15:59:26 +0200364 struct snd_pcm_substream *substream;
365};
366
Takashi Iwaic631d032009-09-03 15:59:26 +0200367static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer)
368{
369 struct dummy_hrtimer_pcm *dpcm;
370
371 dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer);
372 if (!atomic_read(&dpcm->running))
373 return HRTIMER_NORESTART;
Thomas Gleixnerb03bbbe2017-12-21 11:42:03 +0100374 /*
375 * In cases of XRUN and draining, this calls .trigger to stop PCM
376 * substream.
377 */
378 snd_pcm_period_elapsed(dpcm->substream);
379 if (!atomic_read(&dpcm->running))
380 return HRTIMER_NORESTART;
381
Takashi Iwaic631d032009-09-03 15:59:26 +0200382 hrtimer_forward_now(timer, dpcm->period_time);
383 return HRTIMER_RESTART;
384}
385
386static int dummy_hrtimer_start(struct snd_pcm_substream *substream)
387{
388 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
389
390 dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer);
Thomas Gleixnerb03bbbe2017-12-21 11:42:03 +0100391 hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL_SOFT);
Takashi Iwaic631d032009-09-03 15:59:26 +0200392 atomic_set(&dpcm->running, 1);
393 return 0;
394}
395
396static int dummy_hrtimer_stop(struct snd_pcm_substream *substream)
397{
398 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
399
400 atomic_set(&dpcm->running, 0);
Thomas Gleixnerb03bbbe2017-12-21 11:42:03 +0100401 if (!hrtimer_callback_running(&dpcm->timer))
402 hrtimer_cancel(&dpcm->timer);
Takashi Iwaic631d032009-09-03 15:59:26 +0200403 return 0;
404}
405
406static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm)
407{
Takashi Iwaid5dbbe62016-06-24 15:15:26 +0200408 hrtimer_cancel(&dpcm->timer);
Takashi Iwaic631d032009-09-03 15:59:26 +0200409}
410
411static snd_pcm_uframes_t
412dummy_hrtimer_pointer(struct snd_pcm_substream *substream)
413{
414 struct snd_pcm_runtime *runtime = substream->runtime;
415 struct dummy_hrtimer_pcm *dpcm = runtime->private_data;
416 u64 delta;
417 u32 pos;
418
419 delta = ktime_us_delta(hrtimer_cb_get_time(&dpcm->timer),
420 dpcm->base_time);
421 delta = div_u64(delta * runtime->rate + 999999, 1000000);
422 div_u64_rem(delta, runtime->buffer_size, &pos);
423 return pos;
424}
425
426static int dummy_hrtimer_prepare(struct snd_pcm_substream *substream)
427{
428 struct snd_pcm_runtime *runtime = substream->runtime;
429 struct dummy_hrtimer_pcm *dpcm = runtime->private_data;
430 unsigned int period, rate;
431 long sec;
432 unsigned long nsecs;
433
434 dummy_hrtimer_sync(dpcm);
435 period = runtime->period_size;
436 rate = runtime->rate;
437 sec = period / rate;
438 period %= rate;
439 nsecs = div_u64((u64)period * 1000000000UL + rate - 1, rate);
440 dpcm->period_time = ktime_set(sec, nsecs);
441
442 return 0;
443}
444
445static int dummy_hrtimer_create(struct snd_pcm_substream *substream)
446{
447 struct dummy_hrtimer_pcm *dpcm;
448
449 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
450 if (!dpcm)
451 return -ENOMEM;
452 substream->runtime->private_data = dpcm;
Thomas Gleixnerb03bbbe2017-12-21 11:42:03 +0100453 hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
Takashi Iwaic631d032009-09-03 15:59:26 +0200454 dpcm->timer.function = dummy_hrtimer_callback;
455 dpcm->substream = substream;
456 atomic_set(&dpcm->running, 0);
Takashi Iwaic631d032009-09-03 15:59:26 +0200457 return 0;
458}
459
460static void dummy_hrtimer_free(struct snd_pcm_substream *substream)
461{
462 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
463 dummy_hrtimer_sync(dpcm);
464 kfree(dpcm);
465}
466
Julia Lawalld8c5ed72015-12-30 12:28:49 +0100467static const struct dummy_timer_ops dummy_hrtimer_ops = {
Takashi Iwaic631d032009-09-03 15:59:26 +0200468 .create = dummy_hrtimer_create,
469 .free = dummy_hrtimer_free,
470 .prepare = dummy_hrtimer_prepare,
471 .start = dummy_hrtimer_start,
472 .stop = dummy_hrtimer_stop,
473 .pointer = dummy_hrtimer_pointer,
474};
475
476#endif /* CONFIG_HIGH_RES_TIMERS */
477
478/*
479 * PCM interface
480 */
481
482static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
483{
Takashi Iwaic631d032009-09-03 15:59:26 +0200484 switch (cmd) {
485 case SNDRV_PCM_TRIGGER_START:
486 case SNDRV_PCM_TRIGGER_RESUME:
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100487 return get_dummy_ops(substream)->start(substream);
Takashi Iwaic631d032009-09-03 15:59:26 +0200488 case SNDRV_PCM_TRIGGER_STOP:
489 case SNDRV_PCM_TRIGGER_SUSPEND:
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100490 return get_dummy_ops(substream)->stop(substream);
Takashi Iwaic631d032009-09-03 15:59:26 +0200491 }
492 return -EINVAL;
493}
494
495static int dummy_pcm_prepare(struct snd_pcm_substream *substream)
496{
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100497 return get_dummy_ops(substream)->prepare(substream);
Takashi Iwaic631d032009-09-03 15:59:26 +0200498}
499
500static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream)
501{
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100502 return get_dummy_ops(substream)->pointer(substream);
Takashi Iwaic631d032009-09-03 15:59:26 +0200503}
504
Bhumika Goyalb6c0b712017-08-17 14:45:51 +0530505static const struct snd_pcm_hardware dummy_pcm_hardware = {
Takashi Iwaic631d032009-09-03 15:59:26 +0200506 .info = (SNDRV_PCM_INFO_MMAP |
507 SNDRV_PCM_INFO_INTERLEAVED |
508 SNDRV_PCM_INFO_RESUME |
509 SNDRV_PCM_INFO_MMAP_VALID),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .formats = USE_FORMATS,
511 .rates = USE_RATE,
512 .rate_min = USE_RATE_MIN,
513 .rate_max = USE_RATE_MAX,
514 .channels_min = USE_CHANNELS_MIN,
515 .channels_max = USE_CHANNELS_MAX,
516 .buffer_bytes_max = MAX_BUFFER_SIZE,
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100517 .period_bytes_min = MIN_PERIOD_SIZE,
Takashi Iwaie05d6962006-08-17 17:12:19 +0200518 .period_bytes_max = MAX_PERIOD_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 .periods_min = USE_PERIODS_MIN,
520 .periods_max = USE_PERIODS_MAX,
521 .fifo_size = 0,
522};
523
Takashi Iwaic631d032009-09-03 15:59:26 +0200524static int dummy_pcm_hw_params(struct snd_pcm_substream *substream,
525 struct snd_pcm_hw_params *hw_params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200527 if (fake_buffer) {
528 /* runtime->dma_bytes has to be set manually to allow mmap */
529 substream->runtime->dma_bytes = params_buffer_bytes(hw_params);
530 return 0;
531 }
Takashi Iwaic631d032009-09-03 15:59:26 +0200532 return snd_pcm_lib_malloc_pages(substream,
533 params_buffer_bytes(hw_params));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534}
535
Takashi Iwaic631d032009-09-03 15:59:26 +0200536static int dummy_pcm_hw_free(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537{
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200538 if (fake_buffer)
539 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 return snd_pcm_lib_free_pages(substream);
541}
542
Takashi Iwaic631d032009-09-03 15:59:26 +0200543static int dummy_pcm_open(struct snd_pcm_substream *substream)
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100544{
Takashi Iwaic631d032009-09-03 15:59:26 +0200545 struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100546 struct dummy_model *model = dummy->model;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100547 struct snd_pcm_runtime *runtime = substream->runtime;
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100548 const struct dummy_timer_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 int err;
550
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100551 ops = &dummy_systimer_ops;
Takashi Iwaic631d032009-09-03 15:59:26 +0200552#ifdef CONFIG_HIGH_RES_TIMERS
553 if (hrtimer)
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100554 ops = &dummy_hrtimer_ops;
Takashi Iwaic631d032009-09-03 15:59:26 +0200555#endif
556
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100557 err = ops->create(substream);
Takashi Iwaic631d032009-09-03 15:59:26 +0200558 if (err < 0)
559 return err;
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100560 get_dummy_ops(substream) = ops;
Takashi Iwaic631d032009-09-03 15:59:26 +0200561
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100562 runtime->hw = dummy->pcm_hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 if (substream->pcm->device & 1) {
564 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED;
565 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
566 }
567 if (substream->pcm->device & 2)
Takashi Iwaic631d032009-09-03 15:59:26 +0200568 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP |
569 SNDRV_PCM_INFO_MMAP_VALID);
570
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100571 if (model == NULL)
572 return 0;
573
574 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
575 if (model->playback_constraints)
576 err = model->playback_constraints(substream->runtime);
577 } else {
578 if (model->capture_constraints)
579 err = model->capture_constraints(substream->runtime);
580 }
Takashi Iwaic631d032009-09-03 15:59:26 +0200581 if (err < 0) {
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100582 get_dummy_ops(substream)->free(substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 return 0;
586}
587
Takashi Iwaic631d032009-09-03 15:59:26 +0200588static int dummy_pcm_close(struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589{
Takashi Iwaiddce57a2016-02-02 15:27:36 +0100590 get_dummy_ops(substream)->free(substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 return 0;
592}
593
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200594/*
595 * dummy buffer handling
596 */
597
598static void *dummy_page[2];
599
600static void free_fake_buffer(void)
601{
602 if (fake_buffer) {
603 int i;
604 for (i = 0; i < 2; i++)
605 if (dummy_page[i]) {
606 free_page((unsigned long)dummy_page[i]);
607 dummy_page[i] = NULL;
608 }
609 }
610}
611
612static int alloc_fake_buffer(void)
613{
614 int i;
615
616 if (!fake_buffer)
617 return 0;
618 for (i = 0; i < 2; i++) {
619 dummy_page[i] = (void *)get_zeroed_page(GFP_KERNEL);
620 if (!dummy_page[i]) {
621 free_fake_buffer();
622 return -ENOMEM;
623 }
624 }
625 return 0;
626}
627
628static int dummy_pcm_copy(struct snd_pcm_substream *substream,
Takashi Iwaid53611d2017-05-10 20:15:40 +0200629 int channel, unsigned long pos,
630 void __user *dst, unsigned long bytes)
631{
632 return 0; /* do nothing */
633}
634
635static int dummy_pcm_copy_kernel(struct snd_pcm_substream *substream,
636 int channel, unsigned long pos,
637 void *dst, unsigned long bytes)
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200638{
639 return 0; /* do nothing */
640}
641
642static int dummy_pcm_silence(struct snd_pcm_substream *substream,
Takashi Iwaid53611d2017-05-10 20:15:40 +0200643 int channel, unsigned long pos,
644 unsigned long bytes)
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200645{
646 return 0; /* do nothing */
647}
648
649static struct page *dummy_pcm_page(struct snd_pcm_substream *substream,
650 unsigned long offset)
651{
652 return virt_to_page(dummy_page[substream->stream]); /* the same page */
653}
654
Takashi Iwaic631d032009-09-03 15:59:26 +0200655static struct snd_pcm_ops dummy_pcm_ops = {
656 .open = dummy_pcm_open,
657 .close = dummy_pcm_close,
658 .ioctl = snd_pcm_lib_ioctl,
659 .hw_params = dummy_pcm_hw_params,
660 .hw_free = dummy_pcm_hw_free,
661 .prepare = dummy_pcm_prepare,
662 .trigger = dummy_pcm_trigger,
663 .pointer = dummy_pcm_pointer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664};
665
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200666static struct snd_pcm_ops dummy_pcm_ops_no_buf = {
667 .open = dummy_pcm_open,
668 .close = dummy_pcm_close,
669 .ioctl = snd_pcm_lib_ioctl,
670 .hw_params = dummy_pcm_hw_params,
671 .hw_free = dummy_pcm_hw_free,
672 .prepare = dummy_pcm_prepare,
673 .trigger = dummy_pcm_trigger,
674 .pointer = dummy_pcm_pointer,
Takashi Iwaid53611d2017-05-10 20:15:40 +0200675 .copy_user = dummy_pcm_copy,
676 .copy_kernel = dummy_pcm_copy_kernel,
677 .fill_silence = dummy_pcm_silence,
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200678 .page = dummy_pcm_page,
679};
680
Bill Pembertonfbbb01a2012-12-06 12:35:27 -0500681static int snd_card_dummy_pcm(struct snd_dummy *dummy, int device,
682 int substreams)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100684 struct snd_pcm *pcm;
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200685 struct snd_pcm_ops *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 int err;
687
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200688 err = snd_pcm_new(dummy->card, "Dummy PCM", device,
689 substreams, substreams, &pcm);
690 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 return err;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +0100692 dummy->pcm = pcm;
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200693 if (fake_buffer)
694 ops = &dummy_pcm_ops_no_buf;
695 else
696 ops = &dummy_pcm_ops;
697 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, ops);
698 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 pcm->private_data = dummy;
700 pcm->info_flags = 0;
701 strcpy(pcm->name, "Dummy PCM");
Takashi Iwaia68c4d12009-09-04 12:19:36 +0200702 if (!fake_buffer) {
703 snd_pcm_lib_preallocate_pages_for_all(pcm,
704 SNDRV_DMA_TYPE_CONTINUOUS,
705 snd_dma_continuous_data(GFP_KERNEL),
706 0, 64*1024);
707 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 return 0;
709}
710
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200711/*
712 * mixer interface
713 */
714
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715#define DUMMY_VOLUME(xname, xindex, addr) \
Takashi Iwaifb567a82006-08-23 13:07:19 +0200716{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
717 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
718 .name = xname, .index = xindex, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .info = snd_dummy_volume_info, \
720 .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
Takashi Iwaifb567a82006-08-23 13:07:19 +0200721 .private_value = addr, \
722 .tlv = { .p = db_scale_dummy } }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100724static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726{
727 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
728 uinfo->count = 2;
729 uinfo->value.integer.min = -50;
730 uinfo->value.integer.max = 100;
731 return 0;
732}
733
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100734static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol,
735 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100737 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 int addr = kcontrol->private_value;
739
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100740 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0];
742 ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1];
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100743 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 return 0;
745}
746
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100747static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100750 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 int change, addr = kcontrol->private_value;
752 int left, right;
753
754 left = ucontrol->value.integer.value[0];
755 if (left < -50)
756 left = -50;
757 if (left > 100)
758 left = 100;
759 right = ucontrol->value.integer.value[1];
760 if (right < -50)
761 right = -50;
762 if (right > 100)
763 right = 100;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100764 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 change = dummy->mixer_volume[addr][0] != left ||
766 dummy->mixer_volume[addr][1] != right;
767 dummy->mixer_volume[addr][0] = left;
768 dummy->mixer_volume[addr][1] = right;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100769 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 return change;
771}
772
Takashi Iwai0cb29ea2007-01-29 15:33:49 +0100773static const DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0);
Takashi Iwaifb567a82006-08-23 13:07:19 +0200774
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775#define DUMMY_CAPSRC(xname, xindex, addr) \
776{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
777 .info = snd_dummy_capsrc_info, \
778 .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
779 .private_value = addr }
780
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200781#define snd_dummy_capsrc_info snd_ctl_boolean_stereo_info
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100783static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol,
784 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100786 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 int addr = kcontrol->private_value;
788
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100789 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 ucontrol->value.integer.value[0] = dummy->capture_source[addr][0];
791 ucontrol->value.integer.value[1] = dummy->capture_source[addr][1];
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100792 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 return 0;
794}
795
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100796static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100798 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 int change, addr = kcontrol->private_value;
800 int left, right;
801
802 left = ucontrol->value.integer.value[0] & 1;
803 right = ucontrol->value.integer.value[1] & 1;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100804 spin_lock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 change = dummy->capture_source[addr][0] != left &&
806 dummy->capture_source[addr][1] != right;
807 dummy->capture_source[addr][0] = left;
808 dummy->capture_source[addr][1] = right;
Takashi Iwaic8eb6ba2005-11-17 10:20:23 +0100809 spin_unlock_irq(&dummy->mixer_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 return change;
811}
812
Clemens Ladisch16e43462012-10-20 12:21:36 +0200813static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
814 struct snd_ctl_elem_info *info)
815{
Colin Ian Kinga4a1b732017-11-27 12:58:51 +0000816 static const char *const names[] = { "None", "CD Player" };
Clemens Ladisch16e43462012-10-20 12:21:36 +0200817
818 return snd_ctl_enum_info(info, 1, 2, names);
819}
820
821static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
822 struct snd_ctl_elem_value *value)
823{
824 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
825
826 value->value.enumerated.item[0] = dummy->iobox;
827 return 0;
828}
829
830static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
831 struct snd_ctl_elem_value *value)
832{
833 struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
834 int changed;
835
836 if (value->value.enumerated.item[0] > 1)
837 return -EINVAL;
838
839 changed = value->value.enumerated.item[0] != dummy->iobox;
840 if (changed) {
841 dummy->iobox = value->value.enumerated.item[0];
842
843 if (dummy->iobox) {
844 dummy->cd_volume_ctl->vd[0].access &=
845 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
846 dummy->cd_switch_ctl->vd[0].access &=
847 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
848 } else {
849 dummy->cd_volume_ctl->vd[0].access |=
850 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
851 dummy->cd_switch_ctl->vd[0].access |=
852 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
853 }
854
855 snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
856 &dummy->cd_volume_ctl->id);
857 snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
858 &dummy->cd_switch_ctl->id);
859 }
860
861 return changed;
862}
863
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100864static struct snd_kcontrol_new snd_dummy_controls[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
866DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
867DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200868DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_SYNTH),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200870DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
Takashi Iwaie05d6962006-08-17 17:12:19 +0200872DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
Clemens Ladisch16e43462012-10-20 12:21:36 +0200874DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
875{
876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
877 .name = "External I/O Box",
878 .info = snd_dummy_iobox_info,
879 .get = snd_dummy_iobox_get,
880 .put = snd_dummy_iobox_put,
881},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882};
883
Bill Pembertonfbbb01a2012-12-06 12:35:27 -0500884static int snd_card_dummy_new_mixer(struct snd_dummy *dummy)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +0100886 struct snd_card *card = dummy->card;
Clemens Ladisch16e43462012-10-20 12:21:36 +0200887 struct snd_kcontrol *kcontrol;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 unsigned int idx;
889 int err;
890
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 spin_lock_init(&dummy->mixer_lock);
892 strcpy(card->mixername, "Dummy Mixer");
Clemens Ladisch16e43462012-10-20 12:21:36 +0200893 dummy->iobox = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894
895 for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
Clemens Ladisch16e43462012-10-20 12:21:36 +0200896 kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
897 err = snd_ctl_add(card, kcontrol);
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +0200898 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 return err;
Clemens Ladisch16e43462012-10-20 12:21:36 +0200900 if (!strcmp(kcontrol->id.name, "CD Volume"))
901 dummy->cd_volume_ctl = kcontrol;
902 else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
903 dummy->cd_switch_ctl = kcontrol;
904
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 }
906 return 0;
907}
908
Takashi Iwai129a4c92015-05-29 07:47:50 +0200909#if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_PROC_FS)
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200910/*
911 * proc interface
912 */
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100913static void print_formats(struct snd_dummy *dummy,
914 struct snd_info_buffer *buffer)
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200915{
916 int i;
917
918 for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) {
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100919 if (dummy->pcm_hw.formats & (1ULL << i))
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200920 snd_iprintf(buffer, " %s", snd_pcm_format_name(i));
921 }
922}
923
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100924static void print_rates(struct snd_dummy *dummy,
925 struct snd_info_buffer *buffer)
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200926{
927 static int rates[] = {
928 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
929 64000, 88200, 96000, 176400, 192000,
930 };
931 int i;
932
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100933 if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_CONTINUOUS)
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200934 snd_iprintf(buffer, " continuous");
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100935 if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_KNOT)
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200936 snd_iprintf(buffer, " knot");
937 for (i = 0; i < ARRAY_SIZE(rates); i++)
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100938 if (dummy->pcm_hw.rates & (1 << i))
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200939 snd_iprintf(buffer, " %d", rates[i]);
940}
941
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100942#define get_dummy_int_ptr(dummy, ofs) \
943 (unsigned int *)((char *)&((dummy)->pcm_hw) + (ofs))
944#define get_dummy_ll_ptr(dummy, ofs) \
945 (unsigned long long *)((char *)&((dummy)->pcm_hw) + (ofs))
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200946
947struct dummy_hw_field {
948 const char *name;
949 const char *format;
950 unsigned int offset;
951 unsigned int size;
952};
953#define FIELD_ENTRY(item, fmt) { \
954 .name = #item, \
955 .format = fmt, \
956 .offset = offsetof(struct snd_pcm_hardware, item), \
957 .size = sizeof(dummy_pcm_hardware.item) }
958
959static struct dummy_hw_field fields[] = {
960 FIELD_ENTRY(formats, "%#llx"),
961 FIELD_ENTRY(rates, "%#x"),
962 FIELD_ENTRY(rate_min, "%d"),
963 FIELD_ENTRY(rate_max, "%d"),
964 FIELD_ENTRY(channels_min, "%d"),
965 FIELD_ENTRY(channels_max, "%d"),
966 FIELD_ENTRY(buffer_bytes_max, "%ld"),
967 FIELD_ENTRY(period_bytes_min, "%ld"),
968 FIELD_ENTRY(period_bytes_max, "%ld"),
969 FIELD_ENTRY(periods_min, "%d"),
970 FIELD_ENTRY(periods_max, "%d"),
971};
972
973static void dummy_proc_read(struct snd_info_entry *entry,
974 struct snd_info_buffer *buffer)
975{
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100976 struct snd_dummy *dummy = entry->private_data;
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200977 int i;
978
979 for (i = 0; i < ARRAY_SIZE(fields); i++) {
980 snd_iprintf(buffer, "%s ", fields[i].name);
981 if (fields[i].size == sizeof(int))
982 snd_iprintf(buffer, fields[i].format,
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100983 *get_dummy_int_ptr(dummy, fields[i].offset));
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200984 else
985 snd_iprintf(buffer, fields[i].format,
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100986 *get_dummy_ll_ptr(dummy, fields[i].offset));
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200987 if (!strcmp(fields[i].name, "formats"))
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100988 print_formats(dummy, buffer);
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200989 else if (!strcmp(fields[i].name, "rates"))
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100990 print_rates(dummy, buffer);
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200991 snd_iprintf(buffer, "\n");
992 }
993}
994
995static void dummy_proc_write(struct snd_info_entry *entry,
996 struct snd_info_buffer *buffer)
997{
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +0100998 struct snd_dummy *dummy = entry->private_data;
Takashi Iwai9b151fe2009-09-08 14:30:49 +0200999 char line[64];
1000
1001 while (!snd_info_get_line(buffer, line, sizeof(line))) {
1002 char item[20];
1003 const char *ptr;
1004 unsigned long long val;
1005 int i;
1006
1007 ptr = snd_info_get_str(item, line, sizeof(item));
1008 for (i = 0; i < ARRAY_SIZE(fields); i++) {
1009 if (!strcmp(item, fields[i].name))
1010 break;
1011 }
1012 if (i >= ARRAY_SIZE(fields))
1013 continue;
1014 snd_info_get_str(item, ptr, sizeof(item));
Jingoo Hanb785a492013-07-19 16:24:59 +09001015 if (kstrtoull(item, 0, &val))
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001016 continue;
1017 if (fields[i].size == sizeof(int))
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +01001018 *get_dummy_int_ptr(dummy, fields[i].offset) = val;
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001019 else
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +01001020 *get_dummy_ll_ptr(dummy, fields[i].offset) = val;
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001021 }
1022}
1023
Bill Pembertonfbbb01a2012-12-06 12:35:27 -05001024static void dummy_proc_init(struct snd_dummy *chip)
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001025{
Takashi Iwai815d8082019-02-04 15:58:33 +01001026 snd_card_rw_proc_new(chip->card, "dummy_pcm", chip,
1027 dummy_proc_read, dummy_proc_write);
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001028}
1029#else
1030#define dummy_proc_init(x)
Takashi Iwai129a4c92015-05-29 07:47:50 +02001031#endif /* CONFIG_SND_DEBUG && CONFIG_SND_PROC_FS */
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001032
Bill Pembertonfbbb01a2012-12-06 12:35:27 -05001033static int snd_dummy_probe(struct platform_device *devptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034{
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +01001035 struct snd_card *card;
1036 struct snd_dummy *dummy;
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +01001037 struct dummy_model *m = NULL, **mdl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 int idx, err;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001039 int dev = devptr->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040
Takashi Iwai5872f3f2014-01-29 12:59:08 +01001041 err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
1042 sizeof(struct snd_dummy), &card);
Takashi Iwaibd7dd772008-12-28 16:45:02 +01001043 if (err < 0)
1044 return err;
Takashi Iwai4a4d2cf2005-11-17 14:27:28 +01001045 dummy = card->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 dummy->card = card;
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +01001047 for (mdl = dummy_models; *mdl && model[dev]; mdl++) {
1048 if (strcmp(model[dev], (*mdl)->name) == 0) {
1049 printk(KERN_INFO
1050 "snd-dummy: Using model '%s' for card %i\n",
1051 (*mdl)->name, card->number);
1052 m = dummy->model = *mdl;
1053 break;
1054 }
1055 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
1057 if (pcm_substreams[dev] < 1)
1058 pcm_substreams[dev] = 1;
1059 if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS)
1060 pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +02001061 err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]);
1062 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 goto __nodev;
1064 }
Jaroslav Kyselad5e1ca02010-02-02 17:48:51 +01001065
1066 dummy->pcm_hw = dummy_pcm_hardware;
1067 if (m) {
1068 if (m->formats)
1069 dummy->pcm_hw.formats = m->formats;
1070 if (m->buffer_bytes_max)
1071 dummy->pcm_hw.buffer_bytes_max = m->buffer_bytes_max;
1072 if (m->period_bytes_min)
1073 dummy->pcm_hw.period_bytes_min = m->period_bytes_min;
1074 if (m->period_bytes_max)
1075 dummy->pcm_hw.period_bytes_max = m->period_bytes_max;
1076 if (m->periods_min)
1077 dummy->pcm_hw.periods_min = m->periods_min;
1078 if (m->periods_max)
1079 dummy->pcm_hw.periods_max = m->periods_max;
1080 if (m->rates)
1081 dummy->pcm_hw.rates = m->rates;
1082 if (m->rate_min)
1083 dummy->pcm_hw.rate_min = m->rate_min;
1084 if (m->rate_max)
1085 dummy->pcm_hw.rate_max = m->rate_max;
1086 if (m->channels_min)
1087 dummy->pcm_hw.channels_min = m->channels_min;
1088 if (m->channels_max)
1089 dummy->pcm_hw.channels_max = m->channels_max;
1090 }
1091
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +02001092 err = snd_card_dummy_new_mixer(dummy);
1093 if (err < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 goto __nodev;
1095 strcpy(card->driver, "Dummy");
1096 strcpy(card->shortname, "Dummy");
1097 sprintf(card->longname, "Dummy %i", dev + 1);
Takashi Iwai16dab542005-09-05 17:17:58 +02001098
Takashi Iwai9b151fe2009-09-08 14:30:49 +02001099 dummy_proc_init(dummy);
1100
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +02001101 err = snd_card_register(card);
1102 if (err == 0) {
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001103 platform_set_drvdata(devptr, card);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 return 0;
1105 }
1106 __nodev:
1107 snd_card_free(card);
1108 return err;
1109}
1110
Bill Pembertonfbbb01a2012-12-06 12:35:27 -05001111static int snd_dummy_remove(struct platform_device *devptr)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001112{
1113 snd_card_free(platform_get_drvdata(devptr));
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001114 return 0;
1115}
1116
Takashi Iwaid34e4e02012-08-09 15:47:15 +02001117#ifdef CONFIG_PM_SLEEP
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001118static int snd_dummy_suspend(struct device *pdev)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001119{
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001120 struct snd_card *card = dev_get_drvdata(pdev);
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001121
1122 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001123 return 0;
1124}
1125
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001126static int snd_dummy_resume(struct device *pdev)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001127{
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001128 struct snd_card *card = dev_get_drvdata(pdev);
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001129
1130 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
1131 return 0;
1132}
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001133
1134static SIMPLE_DEV_PM_OPS(snd_dummy_pm, snd_dummy_suspend, snd_dummy_resume);
1135#define SND_DUMMY_PM_OPS &snd_dummy_pm
1136#else
1137#define SND_DUMMY_PM_OPS NULL
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001138#endif
1139
1140#define SND_DUMMY_DRIVER "snd_dummy"
1141
1142static struct platform_driver snd_dummy_driver = {
1143 .probe = snd_dummy_probe,
Bill Pembertonfbbb01a2012-12-06 12:35:27 -05001144 .remove = snd_dummy_remove,
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001145 .driver = {
Takashi Iwai8bf01d82012-07-02 10:50:24 +02001146 .name = SND_DUMMY_DRIVER,
Takashi Iwai284e7ca2012-07-02 11:22:40 +02001147 .pm = SND_DUMMY_PM_OPS,
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001148 },
1149};
1150
Randy Dunlapc12aad62007-06-25 12:08:01 +02001151static void snd_dummy_unregister_all(void)
Clemens Ladischf7a92752005-12-07 09:13:42 +01001152{
1153 int i;
1154
1155 for (i = 0; i < ARRAY_SIZE(devices); ++i)
1156 platform_device_unregister(devices[i]);
1157 platform_driver_unregister(&snd_dummy_driver);
Takashi Iwaia68c4d12009-09-04 12:19:36 +02001158 free_fake_buffer();
Clemens Ladischf7a92752005-12-07 09:13:42 +01001159}
1160
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161static int __init alsa_card_dummy_init(void)
1162{
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001163 int i, cards, err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164
Jaroslav Kysela1a11cb62008-08-15 12:59:02 +02001165 err = platform_driver_register(&snd_dummy_driver);
1166 if (err < 0)
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001167 return err;
1168
Takashi Iwaia68c4d12009-09-04 12:19:36 +02001169 err = alloc_fake_buffer();
1170 if (err < 0) {
1171 platform_driver_unregister(&snd_dummy_driver);
1172 return err;
1173 }
1174
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001175 cards = 0;
Takashi Iwai8278ca82006-02-20 11:57:34 +01001176 for (i = 0; i < SNDRV_CARDS; i++) {
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001177 struct platform_device *device;
Takashi Iwai8278ca82006-02-20 11:57:34 +01001178 if (! enable[i])
1179 continue;
Takashi Iwai6e65c1c2005-11-17 16:01:56 +01001180 device = platform_device_register_simple(SND_DUMMY_DRIVER,
1181 i, NULL, 0);
Rene Hermana182ee92006-04-13 12:57:11 +02001182 if (IS_ERR(device))
1183 continue;
Rene Herman71524472006-04-13 12:58:06 +02001184 if (!platform_get_drvdata(device)) {
1185 platform_device_unregister(device);
1186 continue;
1187 }
Clemens Ladischf7a92752005-12-07 09:13:42 +01001188 devices[i] = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 cards++;
1190 }
1191 if (!cards) {
1192#ifdef MODULE
1193 printk(KERN_ERR "Dummy soundcard not found or device busy\n");
1194#endif
Rene Hermana182ee92006-04-13 12:57:11 +02001195 snd_dummy_unregister_all();
1196 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 }
1198 return 0;
1199}
1200
1201static void __exit alsa_card_dummy_exit(void)
1202{
Clemens Ladischf7a92752005-12-07 09:13:42 +01001203 snd_dummy_unregister_all();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204}
1205
1206module_init(alsa_card_dummy_init)
1207module_exit(alsa_card_dummy_exit)