13 #include <linux/module.h>
15 #include <linux/device.h>
18 #include <linux/slab.h>
34 #define dprintk(level, fmt, arg...) do { \
36 printk(KERN_INFO "%s/1: " fmt, chip->core->name , ## arg); \
64 static unsigned int debug;
80 dprintk(1,
"Starting audio DMA\n");
97 dprintk(1,
"Stopping audio DMA\n");
109 dprintk(2,
"Freeing buffer\n");
113 substream->
runtime->dma_bytes = 0;
120 dprintk(2,
"Allocating buffer\n");
122 if (substream->
runtime->dma_area) {
123 if (substream->
runtime->dma_bytes > size)
126 dsp_buffer_free(substream);
130 if (!substream->
runtime->dma_area)
146 #define DEFAULT_FIFO_SIZE 4096
161 .period_bytes_min = 64,
162 .period_bytes_max = 12544,
165 .buffer_bytes_max = 62720 * 8,
184 runtime->
hw = snd_tm6000_digital_hw;
189 dprintk(1,
"Error opening PCM!\n");
209 static int tm6000_fillbuf(
struct tm6000_core *core,
char *
buf,
int size)
214 int period_elapsed = 0;
215 unsigned int stride, buf_pos;
221 if (!size || !substream) {
222 dprintk(1,
"substream was NULL\n");
227 if (!runtime || !runtime->
dma_area) {
228 dprintk(1,
"runtime was NULL\n");
236 dprintk(1,
"stride is zero\n");
240 length = size / stride;
242 dprintk(1,
"%s: length was zero\n", __func__);
246 dprintk(1,
"Copying %d bytes at %p[%d] - buf size=%d x %d\n", size,
254 length * stride - cnt * stride);
259 snd_pcm_stream_lock(substream);
271 snd_pcm_stream_unlock(substream);
287 size = params_period_bytes(hw_params) *
params_periods(hw_params);
289 rc = dsp_buffer_alloc(substream, size);
309 dsp_buffer_free(substream);
337 dprintk(1,
"starting capture");
338 _tm6000_start_audio_dma(chip);
340 dprintk(1,
"stopping capture");
341 _tm6000_stop_audio_dma(chip);
392 .open = snd_tm6000_pcm_open,
393 .close = snd_tm6000_close,
395 .hw_params = snd_tm6000_hw_params,
396 .hw_free = snd_tm6000_hw_free,
397 .prepare = snd_tm6000_prepare,
398 .trigger = snd_tm6000_card_trigger,
399 .pointer = snd_tm6000_pointer,
400 .page = snd_pcm_get_vmalloc_page,
442 dev->
udev->bus->busnum, dev->
udev->devnum);
444 sprintf(component,
"USB%04x:%04x",
461 rc =
snd_pcm_new(card,
"TM6000 Audio", 0, 0, 1, &pcm);
488 static int tm6000_audio_fini(
struct tm6000_core *dev)
512 .name =
"TM6000 Audio Extension",
513 .init = tm6000_audio_init,
514 .fini = tm6000_audio_fini,
515 .fillbuf = tm6000_fillbuf,
518 static int __init tm6000_alsa_register(
void)
523 static void __exit tm6000_alsa_unregister(
void)