Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / media / usb / cx231xx / cx231xx-audio.c
blobd96236d786d1819e6c3eb0d62d7c6614203b584a
1 /*
2 * Conexant Cx231xx audio extension
4 * Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
5 * Based on em28xx driver
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include "cx231xx.h"
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/sound.h>
23 #include <linux/spinlock.h>
24 #include <linux/soundcard.h>
25 #include <linux/slab.h>
26 #include <linux/vmalloc.h>
27 #include <linux/proc_fs.h>
28 #include <linux/module.h>
29 #include <sound/core.h>
30 #include <sound/pcm.h>
31 #include <sound/pcm_params.h>
32 #include <sound/info.h>
33 #include <sound/initval.h>
34 #include <sound/control.h>
35 #include <media/v4l2-common.h>
37 static int debug;
38 module_param(debug, int, 0644);
39 MODULE_PARM_DESC(debug, "activates debug info");
41 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
43 static int cx231xx_isoc_audio_deinit(struct cx231xx *dev)
45 int i;
47 dev_dbg(dev->dev, "Stopping isoc\n");
49 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
50 if (dev->adev.urb[i]) {
51 if (!irqs_disabled())
52 usb_kill_urb(dev->adev.urb[i]);
53 else
54 usb_unlink_urb(dev->adev.urb[i]);
56 usb_free_urb(dev->adev.urb[i]);
57 dev->adev.urb[i] = NULL;
59 kfree(dev->adev.transfer_buffer[i]);
60 dev->adev.transfer_buffer[i] = NULL;
64 return 0;
67 static int cx231xx_bulk_audio_deinit(struct cx231xx *dev)
69 int i;
71 dev_dbg(dev->dev, "Stopping bulk\n");
73 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
74 if (dev->adev.urb[i]) {
75 if (!irqs_disabled())
76 usb_kill_urb(dev->adev.urb[i]);
77 else
78 usb_unlink_urb(dev->adev.urb[i]);
80 usb_free_urb(dev->adev.urb[i]);
81 dev->adev.urb[i] = NULL;
83 kfree(dev->adev.transfer_buffer[i]);
84 dev->adev.transfer_buffer[i] = NULL;
88 return 0;
91 static void cx231xx_audio_isocirq(struct urb *urb)
93 struct cx231xx *dev = urb->context;
94 int i;
95 unsigned int oldptr;
96 int period_elapsed = 0;
97 int status;
98 unsigned char *cp;
99 unsigned int stride;
100 struct snd_pcm_substream *substream;
101 struct snd_pcm_runtime *runtime;
103 if (dev->state & DEV_DISCONNECTED)
104 return;
106 switch (urb->status) {
107 case 0: /* success */
108 case -ETIMEDOUT: /* NAK */
109 break;
110 case -ECONNRESET: /* kill */
111 case -ENOENT:
112 case -ESHUTDOWN:
113 return;
114 default: /* error */
115 dev_dbg(dev->dev, "urb completition error %d.\n",
116 urb->status);
117 break;
120 if (atomic_read(&dev->stream_started) == 0)
121 return;
123 if (dev->adev.capture_pcm_substream) {
124 substream = dev->adev.capture_pcm_substream;
125 runtime = substream->runtime;
126 stride = runtime->frame_bits >> 3;
128 for (i = 0; i < urb->number_of_packets; i++) {
129 int length = urb->iso_frame_desc[i].actual_length /
130 stride;
131 cp = (unsigned char *)urb->transfer_buffer +
132 urb->iso_frame_desc[i].offset;
134 if (!length)
135 continue;
137 oldptr = dev->adev.hwptr_done_capture;
138 if (oldptr + length >= runtime->buffer_size) {
139 unsigned int cnt;
141 cnt = runtime->buffer_size - oldptr;
142 memcpy(runtime->dma_area + oldptr * stride, cp,
143 cnt * stride);
144 memcpy(runtime->dma_area, cp + cnt * stride,
145 length * stride - cnt * stride);
146 } else {
147 memcpy(runtime->dma_area + oldptr * stride, cp,
148 length * stride);
151 snd_pcm_stream_lock(substream);
153 dev->adev.hwptr_done_capture += length;
154 if (dev->adev.hwptr_done_capture >=
155 runtime->buffer_size)
156 dev->adev.hwptr_done_capture -=
157 runtime->buffer_size;
159 dev->adev.capture_transfer_done += length;
160 if (dev->adev.capture_transfer_done >=
161 runtime->period_size) {
162 dev->adev.capture_transfer_done -=
163 runtime->period_size;
164 period_elapsed = 1;
166 snd_pcm_stream_unlock(substream);
168 if (period_elapsed)
169 snd_pcm_period_elapsed(substream);
171 urb->status = 0;
173 status = usb_submit_urb(urb, GFP_ATOMIC);
174 if (status < 0) {
175 dev_err(dev->dev,
176 "resubmit of audio urb failed (error=%i)\n",
177 status);
179 return;
182 static void cx231xx_audio_bulkirq(struct urb *urb)
184 struct cx231xx *dev = urb->context;
185 unsigned int oldptr;
186 int period_elapsed = 0;
187 int status;
188 unsigned char *cp;
189 unsigned int stride;
190 struct snd_pcm_substream *substream;
191 struct snd_pcm_runtime *runtime;
193 if (dev->state & DEV_DISCONNECTED)
194 return;
196 switch (urb->status) {
197 case 0: /* success */
198 case -ETIMEDOUT: /* NAK */
199 break;
200 case -ECONNRESET: /* kill */
201 case -ENOENT:
202 case -ESHUTDOWN:
203 return;
204 default: /* error */
205 dev_dbg(dev->dev, "urb completition error %d.\n",
206 urb->status);
207 break;
210 if (atomic_read(&dev->stream_started) == 0)
211 return;
213 if (dev->adev.capture_pcm_substream) {
214 substream = dev->adev.capture_pcm_substream;
215 runtime = substream->runtime;
216 stride = runtime->frame_bits >> 3;
218 if (1) {
219 int length = urb->actual_length /
220 stride;
221 cp = (unsigned char *)urb->transfer_buffer;
223 oldptr = dev->adev.hwptr_done_capture;
224 if (oldptr + length >= runtime->buffer_size) {
225 unsigned int cnt;
227 cnt = runtime->buffer_size - oldptr;
228 memcpy(runtime->dma_area + oldptr * stride, cp,
229 cnt * stride);
230 memcpy(runtime->dma_area, cp + cnt * stride,
231 length * stride - cnt * stride);
232 } else {
233 memcpy(runtime->dma_area + oldptr * stride, cp,
234 length * stride);
237 snd_pcm_stream_lock(substream);
239 dev->adev.hwptr_done_capture += length;
240 if (dev->adev.hwptr_done_capture >=
241 runtime->buffer_size)
242 dev->adev.hwptr_done_capture -=
243 runtime->buffer_size;
245 dev->adev.capture_transfer_done += length;
246 if (dev->adev.capture_transfer_done >=
247 runtime->period_size) {
248 dev->adev.capture_transfer_done -=
249 runtime->period_size;
250 period_elapsed = 1;
252 snd_pcm_stream_unlock(substream);
254 if (period_elapsed)
255 snd_pcm_period_elapsed(substream);
257 urb->status = 0;
259 status = usb_submit_urb(urb, GFP_ATOMIC);
260 if (status < 0) {
261 dev_err(dev->dev,
262 "resubmit of audio urb failed (error=%i)\n",
263 status);
265 return;
268 static int cx231xx_init_audio_isoc(struct cx231xx *dev)
270 int i, errCode;
271 int sb_size;
273 dev_dbg(dev->dev,
274 "%s: Starting ISO AUDIO transfers\n", __func__);
276 if (dev->state & DEV_DISCONNECTED)
277 return -ENODEV;
279 sb_size = CX231XX_ISO_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size;
281 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
282 struct urb *urb;
283 int j, k;
285 dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
286 if (!dev->adev.transfer_buffer[i])
287 return -ENOMEM;
289 memset(dev->adev.transfer_buffer[i], 0x80, sb_size);
290 urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC);
291 if (!urb) {
292 for (j = 0; j < i; j++) {
293 usb_free_urb(dev->adev.urb[j]);
294 kfree(dev->adev.transfer_buffer[j]);
296 return -ENOMEM;
299 urb->dev = dev->udev;
300 urb->context = dev;
301 urb->pipe = usb_rcvisocpipe(dev->udev,
302 dev->adev.end_point_addr);
303 urb->transfer_flags = URB_ISO_ASAP;
304 urb->transfer_buffer = dev->adev.transfer_buffer[i];
305 urb->interval = 1;
306 urb->complete = cx231xx_audio_isocirq;
307 urb->number_of_packets = CX231XX_ISO_NUM_AUDIO_PACKETS;
308 urb->transfer_buffer_length = sb_size;
310 for (j = k = 0; j < CX231XX_ISO_NUM_AUDIO_PACKETS;
311 j++, k += dev->adev.max_pkt_size) {
312 urb->iso_frame_desc[j].offset = k;
313 urb->iso_frame_desc[j].length = dev->adev.max_pkt_size;
315 dev->adev.urb[i] = urb;
318 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
319 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
320 if (errCode < 0) {
321 cx231xx_isoc_audio_deinit(dev);
322 return errCode;
326 return errCode;
329 static int cx231xx_init_audio_bulk(struct cx231xx *dev)
331 int i, errCode;
332 int sb_size;
334 dev_dbg(dev->dev,
335 "%s: Starting BULK AUDIO transfers\n", __func__);
337 if (dev->state & DEV_DISCONNECTED)
338 return -ENODEV;
340 sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size;
342 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
343 struct urb *urb;
344 int j;
346 dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
347 if (!dev->adev.transfer_buffer[i])
348 return -ENOMEM;
350 memset(dev->adev.transfer_buffer[i], 0x80, sb_size);
351 urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
352 if (!urb) {
353 for (j = 0; j < i; j++) {
354 usb_free_urb(dev->adev.urb[j]);
355 kfree(dev->adev.transfer_buffer[j]);
357 return -ENOMEM;
360 urb->dev = dev->udev;
361 urb->context = dev;
362 urb->pipe = usb_rcvbulkpipe(dev->udev,
363 dev->adev.end_point_addr);
364 urb->transfer_flags = 0;
365 urb->transfer_buffer = dev->adev.transfer_buffer[i];
366 urb->complete = cx231xx_audio_bulkirq;
367 urb->transfer_buffer_length = sb_size;
369 dev->adev.urb[i] = urb;
373 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
374 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
375 if (errCode < 0) {
376 cx231xx_bulk_audio_deinit(dev);
377 return errCode;
381 return errCode;
384 static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
385 size_t size)
387 struct snd_pcm_runtime *runtime = subs->runtime;
388 struct cx231xx *dev = snd_pcm_substream_chip(subs);
390 dev_dbg(dev->dev, "Allocating vbuffer\n");
391 if (runtime->dma_area) {
392 if (runtime->dma_bytes > size)
393 return 0;
395 vfree(runtime->dma_area);
397 runtime->dma_area = vmalloc(size);
398 if (!runtime->dma_area)
399 return -ENOMEM;
401 runtime->dma_bytes = size;
403 return 0;
406 static const struct snd_pcm_hardware snd_cx231xx_hw_capture = {
407 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
408 SNDRV_PCM_INFO_MMAP |
409 SNDRV_PCM_INFO_INTERLEAVED |
410 SNDRV_PCM_INFO_MMAP_VALID,
412 .formats = SNDRV_PCM_FMTBIT_S16_LE,
414 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT,
416 .rate_min = 48000,
417 .rate_max = 48000,
418 .channels_min = 2,
419 .channels_max = 2,
420 .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */
421 .period_bytes_min = 64, /* 12544/2, */
422 .period_bytes_max = 12544,
423 .periods_min = 2,
424 .periods_max = 98, /* 12544, */
427 static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream)
429 struct cx231xx *dev = snd_pcm_substream_chip(substream);
430 struct snd_pcm_runtime *runtime = substream->runtime;
431 int ret = 0;
433 dev_dbg(dev->dev,
434 "opening device and trying to acquire exclusive lock\n");
436 if (dev->state & DEV_DISCONNECTED) {
437 dev_err(dev->dev,
438 "Can't open. the device was removed.\n");
439 return -ENODEV;
442 /* set alternate setting for audio interface */
443 /* 1 - 48000 samples per sec */
444 mutex_lock(&dev->lock);
445 if (dev->USE_ISO)
446 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1);
447 else
448 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0);
449 mutex_unlock(&dev->lock);
450 if (ret < 0) {
451 dev_err(dev->dev,
452 "failed to set alternate setting !\n");
454 return ret;
457 runtime->hw = snd_cx231xx_hw_capture;
459 mutex_lock(&dev->lock);
460 /* inform hardware to start streaming */
461 ret = cx231xx_capture_start(dev, 1, Audio);
463 dev->adev.users++;
464 mutex_unlock(&dev->lock);
466 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
467 dev->adev.capture_pcm_substream = substream;
468 runtime->private_data = dev;
470 return 0;
473 static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
475 int ret;
476 struct cx231xx *dev = snd_pcm_substream_chip(substream);
478 dev_dbg(dev->dev, "closing device\n");
480 /* inform hardware to stop streaming */
481 mutex_lock(&dev->lock);
482 ret = cx231xx_capture_start(dev, 0, Audio);
484 /* set alternate setting for audio interface */
485 /* 1 - 48000 samples per sec */
486 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0);
487 if (ret < 0) {
488 dev_err(dev->dev,
489 "failed to set alternate setting !\n");
491 mutex_unlock(&dev->lock);
492 return ret;
495 dev->adev.users--;
496 if (substream->runtime->dma_area) {
497 dev_dbg(dev->dev, "freeing\n");
498 vfree(substream->runtime->dma_area);
499 substream->runtime->dma_area = NULL;
501 mutex_unlock(&dev->lock);
503 if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
504 dev_dbg(dev->dev, "audio users: %d\n", dev->adev.users);
505 dev_dbg(dev->dev, "disabling audio stream!\n");
506 dev->adev.shutdown = 0;
507 dev_dbg(dev->dev, "released lock\n");
508 if (atomic_read(&dev->stream_started) > 0) {
509 atomic_set(&dev->stream_started, 0);
510 schedule_work(&dev->wq_trigger);
513 return 0;
516 static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream,
517 struct snd_pcm_hw_params *hw_params)
519 struct cx231xx *dev = snd_pcm_substream_chip(substream);
520 int ret;
522 dev_dbg(dev->dev, "Setting capture parameters\n");
524 ret = snd_pcm_alloc_vmalloc_buffer(substream,
525 params_buffer_bytes(hw_params));
526 #if 0
527 /* TODO: set up cx231xx audio chip to deliver the correct audio format,
528 current default is 48000hz multiplexed => 96000hz mono
529 which shouldn't matter since analogue TV only supports mono */
530 unsigned int channels, rate, format;
532 format = params_format(hw_params);
533 rate = params_rate(hw_params);
534 channels = params_channels(hw_params);
535 #endif
537 return ret;
540 static int snd_cx231xx_hw_capture_free(struct snd_pcm_substream *substream)
542 struct cx231xx *dev = snd_pcm_substream_chip(substream);
544 dev_dbg(dev->dev, "Stop capture, if needed\n");
546 if (atomic_read(&dev->stream_started) > 0) {
547 atomic_set(&dev->stream_started, 0);
548 schedule_work(&dev->wq_trigger);
551 return 0;
554 static int snd_cx231xx_prepare(struct snd_pcm_substream *substream)
556 struct cx231xx *dev = snd_pcm_substream_chip(substream);
558 dev->adev.hwptr_done_capture = 0;
559 dev->adev.capture_transfer_done = 0;
561 return 0;
564 static void audio_trigger(struct work_struct *work)
566 struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger);
568 if (atomic_read(&dev->stream_started)) {
569 dev_dbg(dev->dev, "starting capture");
570 if (is_fw_load(dev) == 0)
571 cx25840_call(dev, core, load_fw);
572 if (dev->USE_ISO)
573 cx231xx_init_audio_isoc(dev);
574 else
575 cx231xx_init_audio_bulk(dev);
576 } else {
577 dev_dbg(dev->dev, "stopping capture");
578 cx231xx_isoc_audio_deinit(dev);
582 static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream,
583 int cmd)
585 struct cx231xx *dev = snd_pcm_substream_chip(substream);
586 int retval = 0;
588 if (dev->state & DEV_DISCONNECTED)
589 return -ENODEV;
591 spin_lock(&dev->adev.slock);
592 switch (cmd) {
593 case SNDRV_PCM_TRIGGER_START:
594 atomic_set(&dev->stream_started, 1);
595 break;
596 case SNDRV_PCM_TRIGGER_STOP:
597 atomic_set(&dev->stream_started, 0);
598 break;
599 default:
600 retval = -EINVAL;
601 break;
603 spin_unlock(&dev->adev.slock);
605 schedule_work(&dev->wq_trigger);
607 return retval;
610 static snd_pcm_uframes_t snd_cx231xx_capture_pointer(struct snd_pcm_substream
611 *substream)
613 struct cx231xx *dev;
614 unsigned long flags;
615 snd_pcm_uframes_t hwptr_done;
617 dev = snd_pcm_substream_chip(substream);
619 spin_lock_irqsave(&dev->adev.slock, flags);
620 hwptr_done = dev->adev.hwptr_done_capture;
621 spin_unlock_irqrestore(&dev->adev.slock, flags);
623 return hwptr_done;
626 static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
627 unsigned long offset)
629 void *pageptr = subs->runtime->dma_area + offset;
631 return vmalloc_to_page(pageptr);
634 static const struct snd_pcm_ops snd_cx231xx_pcm_capture = {
635 .open = snd_cx231xx_capture_open,
636 .close = snd_cx231xx_pcm_close,
637 .ioctl = snd_pcm_lib_ioctl,
638 .hw_params = snd_cx231xx_hw_capture_params,
639 .hw_free = snd_cx231xx_hw_capture_free,
640 .prepare = snd_cx231xx_prepare,
641 .trigger = snd_cx231xx_capture_trigger,
642 .pointer = snd_cx231xx_capture_pointer,
643 .page = snd_pcm_get_vmalloc_page,
646 static int cx231xx_audio_init(struct cx231xx *dev)
648 struct cx231xx_audio *adev = &dev->adev;
649 struct snd_pcm *pcm;
650 struct snd_card *card;
651 static int devnr;
652 int err;
653 struct usb_interface *uif;
654 int i, isoc_pipe = 0;
656 if (dev->has_alsa_audio != 1) {
657 /* This device does not support the extension (in this case
658 the device is expecting the snd-usb-audio module or
659 doesn't have analog audio support at all) */
660 return 0;
663 dev_dbg(dev->dev,
664 "probing for cx231xx non standard usbaudio\n");
666 err = snd_card_new(dev->dev, index[devnr], "Cx231xx Audio",
667 THIS_MODULE, 0, &card);
668 if (err < 0)
669 return err;
671 spin_lock_init(&adev->slock);
672 err = snd_pcm_new(card, "Cx231xx Audio", 0, 0, 1, &pcm);
673 if (err < 0)
674 goto err_free_card;
676 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
677 &snd_cx231xx_pcm_capture);
678 pcm->info_flags = 0;
679 pcm->private_data = dev;
680 strcpy(pcm->name, "Conexant cx231xx Capture");
681 strcpy(card->driver, "Cx231xx-Audio");
682 strcpy(card->shortname, "Cx231xx Audio");
683 strcpy(card->longname, "Conexant cx231xx Audio");
685 INIT_WORK(&dev->wq_trigger, audio_trigger);
687 err = snd_card_register(card);
688 if (err < 0)
689 goto err_free_card;
691 adev->sndcard = card;
692 adev->udev = dev->udev;
694 /* compute alternate max packet sizes for Audio */
695 uif =
696 dev->udev->actconfig->interface[dev->current_pcb_config.
697 hs_config_info[0].interface_info.
698 audio_index + 1];
700 if (uif->altsetting[0].desc.bNumEndpoints < isoc_pipe + 1) {
701 err = -ENODEV;
702 goto err_free_card;
705 adev->end_point_addr =
706 uif->altsetting[0].endpoint[isoc_pipe].desc.
707 bEndpointAddress;
709 adev->num_alt = uif->num_altsetting;
710 dev_info(dev->dev,
711 "audio EndPoint Addr 0x%x, Alternate settings: %i\n",
712 adev->end_point_addr, adev->num_alt);
713 adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL);
714 if (!adev->alt_max_pkt_size) {
715 err = -ENOMEM;
716 goto err_free_card;
719 for (i = 0; i < adev->num_alt; i++) {
720 u16 tmp;
722 if (uif->altsetting[i].desc.bNumEndpoints < isoc_pipe + 1) {
723 err = -ENODEV;
724 goto err_free_pkt_size;
727 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
728 wMaxPacketSize);
729 adev->alt_max_pkt_size[i] =
730 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
731 dev_dbg(dev->dev,
732 "audio alternate setting %i, max size= %i\n", i,
733 adev->alt_max_pkt_size[i]);
736 return 0;
738 err_free_pkt_size:
739 kfree(adev->alt_max_pkt_size);
740 err_free_card:
741 snd_card_free(card);
743 return err;
746 static int cx231xx_audio_fini(struct cx231xx *dev)
748 if (dev == NULL)
749 return 0;
751 if (dev->has_alsa_audio != 1) {
752 /* This device does not support the extension (in this case
753 the device is expecting the snd-usb-audio module or
754 doesn't have analog audio support at all) */
755 return 0;
758 if (dev->adev.sndcard) {
759 snd_card_free(dev->adev.sndcard);
760 kfree(dev->adev.alt_max_pkt_size);
761 dev->adev.sndcard = NULL;
764 return 0;
767 static struct cx231xx_ops audio_ops = {
768 .id = CX231XX_AUDIO,
769 .name = "Cx231xx Audio Extension",
770 .init = cx231xx_audio_init,
771 .fini = cx231xx_audio_fini,
774 static int __init cx231xx_alsa_register(void)
776 return cx231xx_register_extension(&audio_ops);
779 static void __exit cx231xx_alsa_unregister(void)
781 cx231xx_unregister_extension(&audio_ops);
784 MODULE_LICENSE("GPL");
785 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
786 MODULE_DESCRIPTION("Cx231xx Audio driver");
788 module_init(cx231xx_alsa_register);
789 module_exit(cx231xx_alsa_unregister);