dummy.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) dummy.c (53463a8302d0c3148c4c64c034312215e76429c2)
1/*
2 * Dummy soundcard
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 *
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.

--- 167 unchanged lines hidden (view full) ---

176 int mixer_volume[MIXER_ADDR_LAST+1][2];
177 int capture_source[MIXER_ADDR_LAST+1][2];
178};
179
180struct snd_dummy_pcm {
181 struct snd_dummy *dummy;
182 spinlock_t lock;
183 struct timer_list timer;
1/*
2 * Dummy soundcard
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 *
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.

--- 167 unchanged lines hidden (view full) ---

176 int mixer_volume[MIXER_ADDR_LAST+1][2];
177 int capture_source[MIXER_ADDR_LAST+1][2];
178};
179
180struct snd_dummy_pcm {
181 struct snd_dummy *dummy;
182 spinlock_t lock;
183 struct timer_list timer;
184 unsigned int pcm_size;
185 unsigned int pcm_count;
184 unsigned int pcm_buffer_size;
185 unsigned int pcm_period_size;
186 unsigned int pcm_bps; /* bytes per second */
186 unsigned int pcm_bps; /* bytes per second */
187 unsigned int pcm_jiffie; /* bytes per one jiffie */
187 unsigned int pcm_hz; /* HZ */
188 unsigned int pcm_irq_pos; /* IRQ position */
189 unsigned int pcm_buf_pos; /* position in buffer */
190 struct snd_pcm_substream *substream;
191};
192
193
194static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm)
195{

--- 37 unchanged lines hidden (view full) ---

233 unsigned int bps;
234
235 bps = runtime->rate * runtime->channels;
236 bps *= snd_pcm_format_width(runtime->format);
237 bps /= 8;
238 if (bps <= 0)
239 return -EINVAL;
240 dpcm->pcm_bps = bps;
188 unsigned int pcm_irq_pos; /* IRQ position */
189 unsigned int pcm_buf_pos; /* position in buffer */
190 struct snd_pcm_substream *substream;
191};
192
193
194static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm)
195{

--- 37 unchanged lines hidden (view full) ---

233 unsigned int bps;
234
235 bps = runtime->rate * runtime->channels;
236 bps *= snd_pcm_format_width(runtime->format);
237 bps /= 8;
238 if (bps <= 0)
239 return -EINVAL;
240 dpcm->pcm_bps = bps;
241 dpcm->pcm_jiffie = bps / HZ;
242 dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
243 dpcm->pcm_count = snd_pcm_lib_period_bytes(substream);
241 dpcm->pcm_hz = HZ;
242 dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
243 dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
244 dpcm->pcm_irq_pos = 0;
245 dpcm->pcm_buf_pos = 0;
244 dpcm->pcm_irq_pos = 0;
245 dpcm->pcm_buf_pos = 0;
246
247 snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
248 bytes_to_samples(runtime, runtime->dma_bytes));
249
246 return 0;
247}
248
249static void snd_card_dummy_pcm_timer_function(unsigned long data)
250{
251 struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data;
252 unsigned long flags;
253
254 spin_lock_irqsave(&dpcm->lock, flags);
255 dpcm->timer.expires = 1 + jiffies;
256 add_timer(&dpcm->timer);
250 return 0;
251}
252
253static void snd_card_dummy_pcm_timer_function(unsigned long data)
254{
255 struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data;
256 unsigned long flags;
257
258 spin_lock_irqsave(&dpcm->lock, flags);
259 dpcm->timer.expires = 1 + jiffies;
260 add_timer(&dpcm->timer);
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;
261 dpcm->pcm_irq_pos += dpcm->pcm_bps;
262 if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
263 dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
264 dpcm->pcm_buf_pos += dpcm->pcm_period_size;
265 dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size;
262 spin_unlock_irqrestore(&dpcm->lock, flags);
263 snd_pcm_period_elapsed(dpcm->substream);
264 } else
265 spin_unlock_irqrestore(&dpcm->lock, flags);
266}
267
268static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream)
269{

--- 432 unchanged lines hidden ---
266 spin_unlock_irqrestore(&dpcm->lock, flags);
267 snd_pcm_period_elapsed(dpcm->substream);
268 } else
269 spin_unlock_irqrestore(&dpcm->lock, flags);
270}
271
272static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream)
273{

--- 432 unchanged lines hidden ---