Commit b0cda373 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mauro Carvalho Chehab

media: cx18: Clean up ALSA PCM API usages

With the recent	change in ALSA PCM core, the whole open-coded vmalloc
buffer handling	in this	driver can be dropped by replacing with	the
managed buffer allocation.

Cc: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent aeb64ff3
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/vmalloc.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
...@@ -213,55 +212,6 @@ static int snd_cx18_pcm_ioctl(struct snd_pcm_substream *substream, ...@@ -213,55 +212,6 @@ static int snd_cx18_pcm_ioctl(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
size_t size)
{
struct snd_pcm_runtime *runtime = subs->runtime;
dprintk("Allocating vbuffer\n");
if (runtime->dma_area) {
if (runtime->dma_bytes > size)
return 0;
vfree(runtime->dma_area);
}
runtime->dma_area = vmalloc(size);
if (!runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
return 0;
}
static int snd_cx18_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
dprintk("%s called\n", __func__);
return snd_pcm_alloc_vmalloc_buffer(substream,
params_buffer_bytes(params));
}
static int snd_cx18_pcm_hw_free(struct snd_pcm_substream *substream)
{
struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream);
unsigned long flags;
unsigned char *dma_area = NULL;
spin_lock_irqsave(&cxsc->slock, flags);
if (substream->runtime->dma_area) {
dprintk("freeing pcm capture region\n");
dma_area = substream->runtime->dma_area;
substream->runtime->dma_area = NULL;
}
spin_unlock_irqrestore(&cxsc->slock, flags);
vfree(dma_area);
return 0;
}
static int snd_cx18_pcm_prepare(struct snd_pcm_substream *substream) static int snd_cx18_pcm_prepare(struct snd_pcm_substream *substream)
{ {
struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream); struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream);
...@@ -291,24 +241,13 @@ snd_pcm_uframes_t snd_cx18_pcm_pointer(struct snd_pcm_substream *substream) ...@@ -291,24 +241,13 @@ snd_pcm_uframes_t snd_cx18_pcm_pointer(struct snd_pcm_substream *substream)
return hwptr_done; return hwptr_done;
} }
static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
unsigned long offset)
{
void *pageptr = subs->runtime->dma_area + offset;
return vmalloc_to_page(pageptr);
}
static const struct snd_pcm_ops snd_cx18_pcm_capture_ops = { static const struct snd_pcm_ops snd_cx18_pcm_capture_ops = {
.open = snd_cx18_pcm_capture_open, .open = snd_cx18_pcm_capture_open,
.close = snd_cx18_pcm_capture_close, .close = snd_cx18_pcm_capture_close,
.ioctl = snd_cx18_pcm_ioctl, .ioctl = snd_cx18_pcm_ioctl,
.hw_params = snd_cx18_pcm_hw_params,
.hw_free = snd_cx18_pcm_hw_free,
.prepare = snd_cx18_pcm_prepare, .prepare = snd_cx18_pcm_prepare,
.trigger = snd_cx18_pcm_trigger, .trigger = snd_cx18_pcm_trigger,
.pointer = snd_cx18_pcm_pointer, .pointer = snd_cx18_pcm_pointer,
.page = snd_pcm_get_vmalloc_page,
}; };
int snd_cx18_pcm_create(struct snd_cx18_card *cxsc) int snd_cx18_pcm_create(struct snd_cx18_card *cxsc)
...@@ -334,6 +273,7 @@ int snd_cx18_pcm_create(struct snd_cx18_card *cxsc) ...@@ -334,6 +273,7 @@ int snd_cx18_pcm_create(struct snd_cx18_card *cxsc)
snd_pcm_set_ops(sp, SNDRV_PCM_STREAM_CAPTURE, snd_pcm_set_ops(sp, SNDRV_PCM_STREAM_CAPTURE,
&snd_cx18_pcm_capture_ops); &snd_cx18_pcm_capture_ops);
snd_pcm_set_managed_buffer_all(sp, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
sp->info_flags = 0; sp->info_flags = 0;
sp->private_data = cxsc; sp->private_data = cxsc;
strscpy(sp->name, cx->card_name, sizeof(sp->name)); strscpy(sp->name, cx->card_name, sizeof(sp->name));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment