27 #include <linux/kernel.h>
41 static unsigned int pcm_debug;
45 #define dprintk(fmt, arg...) \
48 pr_info("ivtv-alsa-pcm %s: " fmt, __func__, ##arg); \
65 .buffer_bytes_max = 62720 * 8,
66 .period_bytes_min = 64,
67 .period_bytes_max = 12544,
79 int period_elapsed = 0;
82 dprintk(
"ivtv alsa announce ptr=%p data=%p num_bytes=%zd\n", itvsc,
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 ivtv *itv = to_ivtv(v4l2_dev);
159 snd_ivtv_lock(itvsc);
169 snd_ivtv_unlock(itvsc);
176 snd_ivtv_unlock(itvsc);
181 runtime->
hw = snd_ivtv_hw_capture;
191 snd_ivtv_unlock(itvsc);
200 struct ivtv *itv = to_ivtv(v4l2_dev);
204 snd_ivtv_lock(itvsc);
212 snd_ivtv_unlock(itvsc);
218 unsigned int cmd,
void *
arg)
223 snd_ivtv_lock(itvsc);
225 snd_ivtv_unlock(itvsc);
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(&itvsc->
slock, flags);
300 spin_unlock_irqrestore(&itvsc->
slock, flags);
313 static struct snd_pcm_ops snd_ivtv_pcm_capture_ops = {
314 .open = snd_ivtv_pcm_capture_open,
315 .close = snd_ivtv_pcm_capture_close,
316 .ioctl = snd_ivtv_pcm_ioctl,
317 .hw_params = snd_ivtv_pcm_hw_params,
318 .hw_free = snd_ivtv_pcm_hw_free,
319 .prepare = snd_ivtv_pcm_prepare,
320 .trigger = snd_ivtv_pcm_trigger,
321 .pointer = snd_ivtv_pcm_pointer,
322 .page = snd_pcm_get_vmalloc_page,
330 struct ivtv *itv = to_ivtv(v4l2_dev);
339 IVTV_ALSA_ERR(
"%s: snd_ivtv_pcm_create() failed with err %d\n",
347 &snd_ivtv_pcm_capture_ops);