27 #include <linux/kernel.h>
41 static unsigned int pcm_debug;
45 #define dprintk(fmt, arg...) do { \
47 printk(KERN_INFO "cx18-alsa-pcm %s: " fmt, \
65 .buffer_bytes_max = 62720 * 8,
66 .period_bytes_min = 64,
67 .period_bytes_max = 12544,
79 int period_elapsed = 0;
82 dprintk(
"cx18 alsa announce ptr=%p data=%p num_bytes=%zd\n", cxsc,
86 if (substream ==
NULL) {
87 dprintk(
"substream was NULL\n");
92 if (runtime ==
NULL) {
103 length = num_bytes / stride;
105 dprintk(
"%s: length was zero\n", __func__);
110 dprintk(
"dma area was NULL - ignoring\n");
121 length * stride - cnt * stride);
126 snd_pcm_stream_lock(substream);
142 snd_pcm_stream_unlock(substream);
153 struct cx18 *cx = to_cx18(v4l2_dev);
169 snd_cx18_unlock(cxsc);
176 snd_cx18_unlock(cxsc);
181 runtime->
hw = snd_cx18_hw_capture;
191 snd_cx18_unlock(cxsc);
200 struct cx18 *cx = to_cx18(v4l2_dev);
212 snd_cx18_unlock(cxsc);
218 unsigned int cmd,
void *
arg)
225 snd_cx18_unlock(cxsc);
235 dprintk(
"Allocating vbuffer\n");
254 dprintk(
"%s called\n", __func__);
256 return snd_pcm_alloc_vmalloc_buffer(substream,
266 if (substream->
runtime->dma_area) {
267 dprintk(
"freeing pcm capture region\n");
271 spin_unlock_irqrestore(&cxsc->
slock, flags);
300 spin_unlock_irqrestore(&cxsc->
slock, flags);
313 static struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
314 .open = snd_cx18_pcm_capture_open,
315 .close = snd_cx18_pcm_capture_close,
316 .ioctl = snd_cx18_pcm_ioctl,
317 .hw_params = snd_cx18_pcm_hw_params,
318 .hw_free = snd_cx18_pcm_hw_free,
319 .prepare = snd_cx18_pcm_prepare,
320 .trigger = snd_cx18_pcm_trigger,
321 .pointer = snd_cx18_pcm_pointer,
322 .page = snd_pcm_get_vmalloc_page,
330 struct cx18 *cx = to_cx18(v4l2_dev);
339 CX18_ALSA_ERR(
"%s: snd_cx18_pcm_create() failed with err %d\n",
347 &snd_cx18_pcm_capture_ops);