提交 1a6f11e0 编写于 作者: M Mauro Carvalho Chehab

V4L/DVB (6950): Lindent em28xx-audio.c

Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 a52932b4
...@@ -44,33 +44,35 @@ ...@@ -44,33 +44,35 @@
#include "em28xx.h" #include "em28xx.h"
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
static int em28xx_cmd(struct em28xx *dev, int cmd,int arg); static int em28xx_cmd(struct em28xx *dev, int cmd, int arg);
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) size_t size)
{ {
struct snd_pcm_runtime *runtime = subs->runtime; struct snd_pcm_runtime *runtime = subs->runtime;
if(runtime->dma_area){ if (runtime->dma_area) {
if(runtime->dma_bytes > size) if (runtime->dma_bytes > size)
return 0; return 0;
vfree(runtime->dma_area); vfree(runtime->dma_area);
} }
runtime->dma_area = vmalloc(size); runtime->dma_area = vmalloc(size);
if(!runtime ->dma_area) if (!runtime->dma_area)
return -ENOMEM; return -ENOMEM;
runtime->dma_bytes = size; runtime->dma_bytes = size;
return 0; return 0;
} }
static struct snd_pcm_hardware snd_em28xx_hw_capture = { static struct snd_pcm_hardware snd_em28xx_hw_capture = {
.info = SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID, .info =
SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID,
.formats = SNDRV_PCM_FMTBIT_S16_LE, .formats = SNDRV_PCM_FMTBIT_S16_LE,
.rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT,
.rate_min = 48000, .rate_min = 48000,
.rate_max = 48000, .rate_max = 48000,
.channels_min = 2, .channels_min = 2,
.channels_max = 2, .channels_max = 2,
.buffer_bytes_max = 62720*8, /* just about the value in usbaudio.c */ .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */
.period_bytes_min = 64, //12544/2, .period_bytes_min = 64, //12544/2,
.period_bytes_max = 12544, .period_bytes_max = 12544,
.periods_min = 2, .periods_min = 2,
...@@ -84,12 +86,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -84,12 +86,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
struct em28xx *dev = snd_pcm_substream_chip(substream); struct em28xx *dev = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
printk("opening radio device and trying to acquire exclusive lock\n"); printk("opening radio device and trying to acquire exclusive lock\n");
switch(dev->mode){ switch (dev->mode) {
case TUNER_STUB_DVBC_TV: case TUNER_STUB_DVBC_TV:
case TUNER_STUB_DVBT_TV: case TUNER_STUB_DVBT_TV:
case TUNER_STUB_ATSC_TV: case TUNER_STUB_ATSC_TV:
/* digital has no support for analog audio */ /* digital has no support for analog audio */
if (ret != 0 ) { if (ret != 0) {
printk("device is already in use by DVB-T\n"); printk("device is already in use by DVB-T\n");
return -EINVAL; return -EINVAL;
} else { } else {
...@@ -101,10 +103,11 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -101,10 +103,11 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
tuner.type = V4L2_TUNER_RADIO; tuner.type = V4L2_TUNER_RADIO;
/* enable GPIO for analog TV */ /* enable GPIO for analog TV */
dev->em28xx_gpio_control(dev, EM28XX_MODE, (void*)mode); dev->em28xx_gpio_control(dev, EM28XX_MODE,
(void *)mode);
dev->mode = mode; dev->mode = mode;
/* upload firmware */ /* upload firmware */
tuner_run_cmd(dev->tobj, TUNER_CMD_INIT, (void*)mode); tuner_run_cmd(dev->tobj, TUNER_CMD_INIT, (void *)mode);
/* required for devices which have kerneldriver dependencies */ /* required for devices which have kerneldriver dependencies */
// em28xx_config(dev); // em28xx_config(dev);
...@@ -120,7 +123,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -120,7 +123,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
printk("em28xx-audio: %d mode\n", mode); printk("em28xx-audio: %d mode\n", mode);
tuner_run_cmd(dev->tobj, TUNER_CMD_G_MODE, &mode); tuner_run_cmd(dev->tobj, TUNER_CMD_G_MODE, &mode);
printk("retrieved mode from tuner: %d\n",mode); printk("retrieved mode from tuner: %d\n", mode);
} }
break; break;
...@@ -131,11 +134,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -131,11 +134,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
break; break;
case TUNER_STUB_RADIO: case TUNER_STUB_RADIO:
/* check current mode and put a hard lock onto it */ /* check current mode and put a hard lock onto it */
printk("em28xx-audio: device is currently in analogue FM mode\n"); printk
("em28xx-audio: device is currently in analogue FM mode\n");
/* unmute by default here */ /* unmute by default here */
dev->em28xx_write_regs(dev, 0x0f, "\x87", 1); dev->em28xx_write_regs(dev, 0x0f, "\x87", 1);
ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1); ret = dev->em28xx_acquire(dev, EM28XX_RADIO, 1);
if ( ret == 0 ) if (ret == 0)
printk("device is locked in fmradio mode now\n"); printk("device is locked in fmradio mode now\n");
break; break;
default: default:
...@@ -143,7 +147,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) ...@@ -143,7 +147,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
} }
runtime->hw = snd_em28xx_hw_capture; runtime->hw = snd_em28xx_hw_capture;
if(dev->alt == 0 && dev->adev->users == 0 ) { if (dev->alt == 0 && dev->adev->users == 0) {
int errCode; int errCode;
dev->alt = 7; dev->alt = 7;
errCode = usb_set_interface(dev->udev, 0, 7); errCode = usb_set_interface(dev->udev, 0, 7);
...@@ -163,7 +167,7 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) ...@@ -163,7 +167,7 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
dev->adev->users--; dev->adev->users--;
/* decrease audio reference */ /* decrease audio reference */
switch(dev->mode) { switch (dev->mode) {
case TUNER_STUB_ANALOG_TV: case TUNER_STUB_ANALOG_TV:
amode = EM28XX_VIDEO; amode = EM28XX_VIDEO;
break; break;
...@@ -171,40 +175,43 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) ...@@ -171,40 +175,43 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
amode = EM28XX_RADIO; amode = EM28XX_RADIO;
break; break;
default: default:
printk("invalid mode: %d\n",dev->mode); printk("invalid mode: %d\n", dev->mode);
break; break;
} }
dev->em28xx_acquire(dev, amode, 0); dev->em28xx_acquire(dev, amode, 0);
if(dev->adev->users == 0 && dev->adev->shutdown == 1) { if (dev->adev->users == 0 && dev->adev->shutdown == 1) {
printk("audio users: %d\n",dev->adev->users); printk("audio users: %d\n", dev->adev->users);
printk("disabling audio stream!\n"); printk("disabling audio stream!\n");
dev->adev->shutdown = 0; dev->adev->shutdown = 0;
printk("released lock\n"); printk("released lock\n");
em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,0); em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0);
} }
return 0; return 0;
} }
static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{ {
unsigned int channels, rate, format; unsigned int channels, rate, format;
int ret; int ret;
ret = snd_pcm_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); ret =
snd_pcm_alloc_vmalloc_buffer(substream,
params_buffer_bytes(hw_params));
format = params_format(hw_params); format = params_format(hw_params);
rate = params_rate(hw_params); rate = params_rate(hw_params);
channels = params_channels(hw_params); channels = params_channels(hw_params);
/* TODO: set up em28xx audio chip to deliver the correct audio format, current default is 48000hz multiplexed => 96000hz mono /* TODO: set up em28xx audio chip to deliver the correct audio format, current default is 48000hz multiplexed => 96000hz mono
which shouldn't matter since analogue TV only supports mono*/ which shouldn't matter since analogue TV only supports mono */
return 0; return 0;
} }
static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream) static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream)
{ {
struct em28xx *dev = snd_pcm_substream_chip(substream); struct em28xx *dev = snd_pcm_substream_chip(substream);
if(dev->adev->capture_stream==STREAM_ON){ if (dev->adev->capture_stream == STREAM_ON) {
em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,0); em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0);
} }
return 0; return 0;
} }
...@@ -214,15 +221,16 @@ static int snd_em28xx_prepare(struct snd_pcm_substream *substream) ...@@ -214,15 +221,16 @@ static int snd_em28xx_prepare(struct snd_pcm_substream *substream)
return 0; return 0;
} }
static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream,
int cmd)
{ {
struct em28xx *dev = snd_pcm_substream_chip(substream); struct em28xx *dev = snd_pcm_substream_chip(substream);
switch(cmd){ switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
em28xx_cmd(dev,EM28XX_CAPTURE_STREAM_EN,1); em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1);
return 0; return 0;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
dev->adev->shutdown=1; dev->adev->shutdown = 1;
return 0; return 0;
default: default:
return -EINVAL; return -EINVAL;
...@@ -231,7 +239,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, int c ...@@ -231,7 +239,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, int c
static void em28xx_audio_isocirq(struct urb *urb) static void em28xx_audio_isocirq(struct urb *urb)
{ {
struct em28xx *dev=urb->context; struct em28xx *dev = urb->context;
int i; int i;
unsigned int oldptr; unsigned int oldptr;
unsigned long flags; unsigned long flags;
...@@ -241,50 +249,61 @@ static void em28xx_audio_isocirq(struct urb *urb) ...@@ -241,50 +249,61 @@ static void em28xx_audio_isocirq(struct urb *urb)
unsigned int stride; unsigned int stride;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
if(dev->adev->capture_pcm_substream){ if (dev->adev->capture_pcm_substream) {
substream=dev->adev->capture_pcm_substream; substream = dev->adev->capture_pcm_substream;
runtime=substream->runtime; runtime = substream->runtime;
stride = runtime->frame_bits >> 3; stride = runtime->frame_bits >> 3;
for(i=0;i<urb->number_of_packets;i++){ for (i = 0; i < urb->number_of_packets; i++) {
int length=urb->iso_frame_desc[i].actual_length/stride; int length =
cp=(unsigned char *) urb->transfer_buffer + urb->iso_frame_desc[i].offset; urb->iso_frame_desc[i].actual_length / stride;
cp = (unsigned char *)urb->transfer_buffer +
urb->iso_frame_desc[i].offset;
if(!length) if (!length)
continue; continue;
spin_lock_irqsave(&dev->adev->slock, flags); spin_lock_irqsave(&dev->adev->slock, flags);
oldptr = dev->adev->hwptr_done_capture; oldptr = dev->adev->hwptr_done_capture;
dev->adev->hwptr_done_capture +=length; dev->adev->hwptr_done_capture += length;
if(dev->adev->hwptr_done_capture >= runtime->buffer_size) if (dev->adev->hwptr_done_capture >=
dev->adev->hwptr_done_capture -= runtime->buffer_size; runtime->buffer_size)
dev->adev->hwptr_done_capture -=
runtime->buffer_size;
dev->adev->capture_transfer_done += length; dev->adev->capture_transfer_done += length;
if(dev->adev->capture_transfer_done >= runtime->period_size){ if (dev->adev->capture_transfer_done >=
dev->adev->capture_transfer_done -= runtime->period_size; runtime->period_size) {
period_elapsed=1; dev->adev->capture_transfer_done -=
runtime->period_size;
period_elapsed = 1;
} }
spin_unlock_irqrestore(&dev->adev->slock, flags); spin_unlock_irqrestore(&dev->adev->slock, flags);
if(oldptr + length >= runtime->buffer_size){ if (oldptr + length >= runtime->buffer_size) {
unsigned int cnt = runtime->buffer_size-oldptr-1; unsigned int cnt =
memcpy(runtime->dma_area+oldptr*stride, cp , cnt*stride); runtime->buffer_size - oldptr - 1;
memcpy(runtime->dma_area, cp + cnt, length*stride - cnt*stride); memcpy(runtime->dma_area + oldptr * stride, cp,
cnt * stride);
memcpy(runtime->dma_area, cp + cnt,
length * stride - cnt * stride);
} else { } else {
memcpy(runtime->dma_area+oldptr*stride, cp, length*stride); memcpy(runtime->dma_area + oldptr * stride, cp,
length * stride);
} }
} }
if(period_elapsed){ if (period_elapsed) {
snd_pcm_period_elapsed(substream); snd_pcm_period_elapsed(substream);
} }
} }
urb->status = 0; urb->status = 0;
if(dev->adev->shutdown) if (dev->adev->shutdown)
return; return;
if((status = usb_submit_urb(urb, GFP_ATOMIC))){ if ((status = usb_submit_urb(urb, GFP_ATOMIC))) {
em28xx_errdev("resubmit of audio urb failed (error=%i)\n", status); em28xx_errdev("resubmit of audio urb failed (error=%i)\n",
status);
} }
return; return;
} }
...@@ -292,10 +311,10 @@ static void em28xx_audio_isocirq(struct urb *urb) ...@@ -292,10 +311,10 @@ static void em28xx_audio_isocirq(struct urb *urb)
static int em28xx_isoc_audio_deinit(struct em28xx *dev) static int em28xx_isoc_audio_deinit(struct em28xx *dev)
{ {
int i; int i;
for(i=0;i<EM28XX_AUDIO_BUFS;i++){ for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
usb_kill_urb(dev->adev->urb[i]); usb_kill_urb(dev->adev->urb[i]);
usb_free_urb(dev->adev->urb[i]); usb_free_urb(dev->adev->urb[i]);
dev->adev->urb[i]=NULL; dev->adev->urb[i] = NULL;
} }
return 0; return 0;
} }
...@@ -304,40 +323,42 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) ...@@ -304,40 +323,42 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
{ {
int i; int i;
int errCode; int errCode;
const int sb_size=EM28XX_NUM_AUDIO_PACKETS * EM28XX_AUDIO_MAX_PACKET_SIZE; const int sb_size =
EM28XX_NUM_AUDIO_PACKETS * EM28XX_AUDIO_MAX_PACKET_SIZE;
for(i=0;i<EM28XX_AUDIO_BUFS;i++){ for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
struct urb *urb; struct urb *urb;
int j,k; int j, k;
dev->adev->transfer_buffer[i]=kmalloc(sb_size,GFP_ATOMIC); dev->adev->transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
if(!dev->adev->transfer_buffer[i]){ if (!dev->adev->transfer_buffer[i]) {
return -ENOMEM; return -ENOMEM;
} }
memset(dev->adev->transfer_buffer[i],0x80,sb_size); memset(dev->adev->transfer_buffer[i], 0x80, sb_size);
urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS,GFP_ATOMIC); urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
if(urb){ if (urb) {
urb->dev=dev->udev; urb->dev = dev->udev;
urb->context=dev; urb->context = dev;
urb->pipe=usb_rcvisocpipe(dev->udev,0x83); urb->pipe = usb_rcvisocpipe(dev->udev, 0x83);
urb->transfer_flags = URB_ISO_ASAP; urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = dev->adev->transfer_buffer[i]; urb->transfer_buffer = dev->adev->transfer_buffer[i];
urb->interval=1; urb->interval = 1;
urb->complete = em28xx_audio_isocirq; urb->complete = em28xx_audio_isocirq;
urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS;
urb->transfer_buffer_length = sb_size; urb->transfer_buffer_length = sb_size;
for(j=k=0; j<EM28XX_NUM_AUDIO_PACKETS;j++,k+=EM28XX_AUDIO_MAX_PACKET_SIZE){ for (j = k = 0; j < EM28XX_NUM_AUDIO_PACKETS;
j++, k += EM28XX_AUDIO_MAX_PACKET_SIZE) {
urb->iso_frame_desc[j].offset = k; urb->iso_frame_desc[j].offset = k;
urb->iso_frame_desc[j].length=EM28XX_AUDIO_MAX_PACKET_SIZE; urb->iso_frame_desc[j].length =
EM28XX_AUDIO_MAX_PACKET_SIZE;
} }
dev->adev->urb[i]=urb; dev->adev->urb[i] = urb;
} else { } else {
return -ENOMEM; return -ENOMEM;
} }
} }
for(i=0;i<EM28XX_AUDIO_BUFS;i++){ for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC); errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC);
if (errCode){ if (errCode) {
em28xx_isoc_audio_deinit(dev); em28xx_isoc_audio_deinit(dev);
return errCode; return errCode;
} }
...@@ -345,19 +366,19 @@ static int em28xx_init_audio_isoc(struct em28xx *dev) ...@@ -345,19 +366,19 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
return 0; return 0;
} }
static int em28xx_cmd(struct em28xx *dev, int cmd, int arg)
static int em28xx_cmd(struct em28xx *dev, int cmd,int arg)
{ {
switch(cmd){ switch (cmd) {
case EM28XX_CAPTURE_STREAM_EN: case EM28XX_CAPTURE_STREAM_EN:
if(dev->adev->capture_stream == STREAM_OFF && arg==1){ if (dev->adev->capture_stream == STREAM_OFF && arg == 1) {
dev->adev->capture_stream=STREAM_ON; dev->adev->capture_stream = STREAM_ON;
em28xx_init_audio_isoc(dev); em28xx_init_audio_isoc(dev);
} else if (dev->adev->capture_stream==STREAM_ON && arg==0){ } else if (dev->adev->capture_stream == STREAM_ON && arg == 0) {
dev->adev->capture_stream=STREAM_OFF; dev->adev->capture_stream = STREAM_OFF;
em28xx_isoc_audio_deinit(dev); em28xx_isoc_audio_deinit(dev);
} else { } else {
printk("An underrun occured very likely... ignoring it\n"); printk
("An underrun occured very likely... ignoring it\n");
} }
return 0; return 0;
default: default:
...@@ -365,7 +386,8 @@ static int em28xx_cmd(struct em28xx *dev, int cmd,int arg) ...@@ -365,7 +386,8 @@ static int em28xx_cmd(struct em28xx *dev, int cmd,int arg)
} }
} }
static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream
*substream)
{ {
struct em28xx *dev; struct em28xx *dev;
snd_pcm_uframes_t hwptr_done; snd_pcm_uframes_t hwptr_done;
...@@ -393,7 +415,6 @@ static struct snd_pcm_ops snd_em28xx_pcm_capture = { ...@@ -393,7 +415,6 @@ static struct snd_pcm_ops snd_em28xx_pcm_capture = {
.page = snd_pcm_get_vmalloc_page, .page = snd_pcm_get_vmalloc_page,
}; };
static int em28xx_audio_init(struct em28xx *dev) static int em28xx_audio_init(struct em28xx *dev)
{ {
struct em28xx_audio *adev; struct em28xx_audio *adev;
...@@ -404,45 +425,45 @@ static int em28xx_audio_init(struct em28xx *dev) ...@@ -404,45 +425,45 @@ static int em28xx_audio_init(struct em28xx *dev)
int err; int err;
printk("em28xx-audio.c: probing for em28x1 non standard usbaudio\n"); printk("em28xx-audio.c: probing for em28x1 non standard usbaudio\n");
printk("em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n"); printk("em28xx-audio.c: Copyright (C) 2006 Markus Rechberger\n");
adev=kzalloc(sizeof(*adev),GFP_KERNEL); adev = kzalloc(sizeof(*adev), GFP_KERNEL);
if(!adev){ if (!adev) {
printk("em28xx-audio.c: out of memory\n"); printk("em28xx-audio.c: out of memory\n");
return -1; return -1;
} }
card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE,0); card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0);
if(card==NULL){ if (card == NULL) {
kfree(adev); kfree(adev);
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&adev->slock); spin_lock_init(&adev->slock);
ret=snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); ret = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_em28xx_pcm_capture);
pcm->info_flags = 0; pcm->info_flags = 0;
pcm->private_data = dev; pcm->private_data = dev;
strcpy(pcm->name,"Empia 28xx Capture"); strcpy(pcm->name, "Empia 28xx Capture");
strcpy(card->driver, "Empia Em28xx Audio"); strcpy(card->driver, "Empia Em28xx Audio");
strcpy(card->shortname, "Em28xx Audio"); strcpy(card->shortname, "Em28xx Audio");
strcpy(card->longname,"Empia Em28xx Audio"); strcpy(card->longname, "Empia Em28xx Audio");
if((err = snd_card_register(card))<0){ if ((err = snd_card_register(card)) < 0) {
snd_card_free(card); snd_card_free(card);
return -ENOMEM; return -ENOMEM;
} }
adev->sndcard=card; adev->sndcard = card;
adev->udev=dev->udev; adev->udev = dev->udev;
dev->adev=adev; dev->adev = adev;
return 0; return 0;
} }
static int em28xx_audio_fini(struct em28xx *dev) static int em28xx_audio_fini(struct em28xx *dev)
{ {
if(dev==NULL) if (dev == NULL)
return 0; return 0;
if(dev->adev){ if (dev->adev) {
snd_card_free(dev->adev->sndcard); snd_card_free(dev->adev->sndcard);
kfree(dev->adev); kfree(dev->adev);
dev->adev=NULL; dev->adev = NULL;
} }
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册