Linux 4.19.133
[linux/fpc-iii.git] / drivers / media / usb / cx231xx / cx231xx-audio.c
blob32ee7b3f21c9b5cecc00d5b7fd4445be7d69dea3
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 completion 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 unsigned long flags;
130 int length = urb->iso_frame_desc[i].actual_length /
131 stride;
132 cp = (unsigned char *)urb->transfer_buffer +
133 urb->iso_frame_desc[i].offset;
135 if (!length)
136 continue;
138 oldptr = dev->adev.hwptr_done_capture;
139 if (oldptr + length >= runtime->buffer_size) {
140 unsigned int cnt;
142 cnt = runtime->buffer_size - oldptr;
143 memcpy(runtime->dma_area + oldptr * stride, cp,
144 cnt * stride);
145 memcpy(runtime->dma_area, cp + cnt * stride,
146 length * stride - cnt * stride);
147 } else {
148 memcpy(runtime->dma_area + oldptr * stride, cp,
149 length * stride);
152 snd_pcm_stream_lock_irqsave(substream, flags);
154 dev->adev.hwptr_done_capture += length;
155 if (dev->adev.hwptr_done_capture >=
156 runtime->buffer_size)
157 dev->adev.hwptr_done_capture -=
158 runtime->buffer_size;
160 dev->adev.capture_transfer_done += length;
161 if (dev->adev.capture_transfer_done >=
162 runtime->period_size) {
163 dev->adev.capture_transfer_done -=
164 runtime->period_size;
165 period_elapsed = 1;
167 snd_pcm_stream_unlock_irqrestore(substream, flags);
169 if (period_elapsed)
170 snd_pcm_period_elapsed(substream);
172 urb->status = 0;
174 status = usb_submit_urb(urb, GFP_ATOMIC);
175 if (status < 0) {
176 dev_err(dev->dev,
177 "resubmit of audio urb failed (error=%i)\n",
178 status);
180 return;
183 static void cx231xx_audio_bulkirq(struct urb *urb)
185 struct cx231xx *dev = urb->context;
186 unsigned int oldptr;
187 int period_elapsed = 0;
188 int status;
189 unsigned char *cp;
190 unsigned int stride;
191 struct snd_pcm_substream *substream;
192 struct snd_pcm_runtime *runtime;
194 if (dev->state & DEV_DISCONNECTED)
195 return;
197 switch (urb->status) {
198 case 0: /* success */
199 case -ETIMEDOUT: /* NAK */
200 break;
201 case -ECONNRESET: /* kill */
202 case -ENOENT:
203 case -ESHUTDOWN:
204 return;
205 default: /* error */
206 dev_dbg(dev->dev, "urb completion error %d.\n",
207 urb->status);
208 break;
211 if (atomic_read(&dev->stream_started) == 0)
212 return;
214 if (dev->adev.capture_pcm_substream) {
215 substream = dev->adev.capture_pcm_substream;
216 runtime = substream->runtime;
217 stride = runtime->frame_bits >> 3;
219 if (1) {
220 unsigned long flags;
221 int length = urb->actual_length /
222 stride;
223 cp = (unsigned char *)urb->transfer_buffer;
225 oldptr = dev->adev.hwptr_done_capture;
226 if (oldptr + length >= runtime->buffer_size) {
227 unsigned int cnt;
229 cnt = runtime->buffer_size - oldptr;
230 memcpy(runtime->dma_area + oldptr * stride, cp,
231 cnt * stride);
232 memcpy(runtime->dma_area, cp + cnt * stride,
233 length * stride - cnt * stride);
234 } else {
235 memcpy(runtime->dma_area + oldptr * stride, cp,
236 length * stride);
239 snd_pcm_stream_lock_irqsave(substream, flags);
241 dev->adev.hwptr_done_capture += length;
242 if (dev->adev.hwptr_done_capture >=
243 runtime->buffer_size)
244 dev->adev.hwptr_done_capture -=
245 runtime->buffer_size;
247 dev->adev.capture_transfer_done += length;
248 if (dev->adev.capture_transfer_done >=
249 runtime->period_size) {
250 dev->adev.capture_transfer_done -=
251 runtime->period_size;
252 period_elapsed = 1;
254 snd_pcm_stream_unlock_irqrestore(substream, flags);
256 if (period_elapsed)
257 snd_pcm_period_elapsed(substream);
259 urb->status = 0;
261 status = usb_submit_urb(urb, GFP_ATOMIC);
262 if (status < 0) {
263 dev_err(dev->dev,
264 "resubmit of audio urb failed (error=%i)\n",
265 status);
267 return;
270 static int cx231xx_init_audio_isoc(struct cx231xx *dev)
272 int i, errCode;
273 int sb_size;
275 dev_dbg(dev->dev,
276 "%s: Starting ISO AUDIO transfers\n", __func__);
278 if (dev->state & DEV_DISCONNECTED)
279 return -ENODEV;
281 sb_size = CX231XX_ISO_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size;
283 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
284 struct urb *urb;
285 int j, k;
287 dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
288 if (!dev->adev.transfer_buffer[i])
289 return -ENOMEM;
291 memset(dev->adev.transfer_buffer[i], 0x80, sb_size);
292 urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC);
293 if (!urb) {
294 for (j = 0; j < i; j++) {
295 usb_free_urb(dev->adev.urb[j]);
296 kfree(dev->adev.transfer_buffer[j]);
298 return -ENOMEM;
301 urb->dev = dev->udev;
302 urb->context = dev;
303 urb->pipe = usb_rcvisocpipe(dev->udev,
304 dev->adev.end_point_addr);
305 urb->transfer_flags = URB_ISO_ASAP;
306 urb->transfer_buffer = dev->adev.transfer_buffer[i];
307 urb->interval = 1;
308 urb->complete = cx231xx_audio_isocirq;
309 urb->number_of_packets = CX231XX_ISO_NUM_AUDIO_PACKETS;
310 urb->transfer_buffer_length = sb_size;
312 for (j = k = 0; j < CX231XX_ISO_NUM_AUDIO_PACKETS;
313 j++, k += dev->adev.max_pkt_size) {
314 urb->iso_frame_desc[j].offset = k;
315 urb->iso_frame_desc[j].length = dev->adev.max_pkt_size;
317 dev->adev.urb[i] = urb;
320 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
321 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
322 if (errCode < 0) {
323 cx231xx_isoc_audio_deinit(dev);
324 return errCode;
328 return errCode;
331 static int cx231xx_init_audio_bulk(struct cx231xx *dev)
333 int i, errCode;
334 int sb_size;
336 dev_dbg(dev->dev,
337 "%s: Starting BULK AUDIO transfers\n", __func__);
339 if (dev->state & DEV_DISCONNECTED)
340 return -ENODEV;
342 sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size;
344 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
345 struct urb *urb;
346 int j;
348 dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
349 if (!dev->adev.transfer_buffer[i])
350 return -ENOMEM;
352 memset(dev->adev.transfer_buffer[i], 0x80, sb_size);
353 urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
354 if (!urb) {
355 for (j = 0; j < i; j++) {
356 usb_free_urb(dev->adev.urb[j]);
357 kfree(dev->adev.transfer_buffer[j]);
359 return -ENOMEM;
362 urb->dev = dev->udev;
363 urb->context = dev;
364 urb->pipe = usb_rcvbulkpipe(dev->udev,
365 dev->adev.end_point_addr);
366 urb->transfer_flags = 0;
367 urb->transfer_buffer = dev->adev.transfer_buffer[i];
368 urb->complete = cx231xx_audio_bulkirq;
369 urb->transfer_buffer_length = sb_size;
371 dev->adev.urb[i] = urb;
375 for (i = 0; i < CX231XX_AUDIO_BUFS; i++) {
376 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
377 if (errCode < 0) {
378 cx231xx_bulk_audio_deinit(dev);
379 return errCode;
383 return errCode;
386 static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
387 size_t size)
389 struct snd_pcm_runtime *runtime = subs->runtime;
390 struct cx231xx *dev = snd_pcm_substream_chip(subs);
392 dev_dbg(dev->dev, "Allocating vbuffer\n");
393 if (runtime->dma_area) {
394 if (runtime->dma_bytes > size)
395 return 0;
397 vfree(runtime->dma_area);
399 runtime->dma_area = vmalloc(size);
400 if (!runtime->dma_area)
401 return -ENOMEM;
403 runtime->dma_bytes = size;
405 return 0;
408 static const struct snd_pcm_hardware snd_cx231xx_hw_capture = {
409 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
410 SNDRV_PCM_INFO_MMAP |
411 SNDRV_PCM_INFO_INTERLEAVED |
412 SNDRV_PCM_INFO_MMAP_VALID,
414 .formats = SNDRV_PCM_FMTBIT_S16_LE,
416 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT,
418 .rate_min = 48000,
419 .rate_max = 48000,
420 .channels_min = 2,
421 .channels_max = 2,
422 .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */
423 .period_bytes_min = 64, /* 12544/2, */
424 .period_bytes_max = 12544,
425 .periods_min = 2,
426 .periods_max = 98, /* 12544, */
429 static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream)
431 struct cx231xx *dev = snd_pcm_substream_chip(substream);
432 struct snd_pcm_runtime *runtime = substream->runtime;
433 int ret = 0;
435 dev_dbg(dev->dev,
436 "opening device and trying to acquire exclusive lock\n");
438 if (dev->state & DEV_DISCONNECTED) {
439 dev_err(dev->dev,
440 "Can't open. the device was removed.\n");
441 return -ENODEV;
444 /* set alternate setting for audio interface */
445 /* 1 - 48000 samples per sec */
446 mutex_lock(&dev->lock);
447 if (dev->USE_ISO)
448 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1);
449 else
450 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0);
451 mutex_unlock(&dev->lock);
452 if (ret < 0) {
453 dev_err(dev->dev,
454 "failed to set alternate setting !\n");
456 return ret;
459 runtime->hw = snd_cx231xx_hw_capture;
461 mutex_lock(&dev->lock);
462 /* inform hardware to start streaming */
463 ret = cx231xx_capture_start(dev, 1, Audio);
465 dev->adev.users++;
466 mutex_unlock(&dev->lock);
468 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
469 dev->adev.capture_pcm_substream = substream;
470 runtime->private_data = dev;
472 return 0;
475 static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
477 int ret;
478 struct cx231xx *dev = snd_pcm_substream_chip(substream);
480 dev_dbg(dev->dev, "closing device\n");
482 /* inform hardware to stop streaming */
483 mutex_lock(&dev->lock);
484 ret = cx231xx_capture_start(dev, 0, Audio);
486 /* set alternate setting for audio interface */
487 /* 1 - 48000 samples per sec */
488 ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0);
489 if (ret < 0) {
490 dev_err(dev->dev,
491 "failed to set alternate setting !\n");
493 mutex_unlock(&dev->lock);
494 return ret;
497 dev->adev.users--;
498 if (substream->runtime->dma_area) {
499 dev_dbg(dev->dev, "freeing\n");
500 vfree(substream->runtime->dma_area);
501 substream->runtime->dma_area = NULL;
503 mutex_unlock(&dev->lock);
505 if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
506 dev_dbg(dev->dev, "audio users: %d\n", dev->adev.users);
507 dev_dbg(dev->dev, "disabling audio stream!\n");
508 dev->adev.shutdown = 0;
509 dev_dbg(dev->dev, "released lock\n");
510 if (atomic_read(&dev->stream_started) > 0) {
511 atomic_set(&dev->stream_started, 0);
512 schedule_work(&dev->wq_trigger);
515 return 0;
518 static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream,
519 struct snd_pcm_hw_params *hw_params)
521 struct cx231xx *dev = snd_pcm_substream_chip(substream);
522 int ret;
524 dev_dbg(dev->dev, "Setting capture parameters\n");
526 ret = snd_pcm_alloc_vmalloc_buffer(substream,
527 params_buffer_bytes(hw_params));
528 #if 0
529 /* TODO: set up cx231xx audio chip to deliver the correct audio format,
530 current default is 48000hz multiplexed => 96000hz mono
531 which shouldn't matter since analogue TV only supports mono */
532 unsigned int channels, rate, format;
534 format = params_format(hw_params);
535 rate = params_rate(hw_params);
536 channels = params_channels(hw_params);
537 #endif
539 return ret;
542 static int snd_cx231xx_hw_capture_free(struct snd_pcm_substream *substream)
544 struct cx231xx *dev = snd_pcm_substream_chip(substream);
546 dev_dbg(dev->dev, "Stop capture, if needed\n");
548 if (atomic_read(&dev->stream_started) > 0) {
549 atomic_set(&dev->stream_started, 0);
550 schedule_work(&dev->wq_trigger);
553 return 0;
556 static int snd_cx231xx_prepare(struct snd_pcm_substream *substream)
558 struct cx231xx *dev = snd_pcm_substream_chip(substream);
560 dev->adev.hwptr_done_capture = 0;
561 dev->adev.capture_transfer_done = 0;
563 return 0;
566 static void audio_trigger(struct work_struct *work)
568 struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger);
570 if (atomic_read(&dev->stream_started)) {
571 dev_dbg(dev->dev, "starting capture");
572 if (is_fw_load(dev) == 0)
573 cx25840_call(dev, core, load_fw);
574 if (dev->USE_ISO)
575 cx231xx_init_audio_isoc(dev);
576 else
577 cx231xx_init_audio_bulk(dev);
578 } else {
579 dev_dbg(dev->dev, "stopping capture");
580 cx231xx_isoc_audio_deinit(dev);
584 static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream,
585 int cmd)
587 struct cx231xx *dev = snd_pcm_substream_chip(substream);
588 int retval = 0;
590 if (dev->state & DEV_DISCONNECTED)
591 return -ENODEV;
593 spin_lock(&dev->adev.slock);
594 switch (cmd) {
595 case SNDRV_PCM_TRIGGER_START:
596 atomic_set(&dev->stream_started, 1);
597 break;
598 case SNDRV_PCM_TRIGGER_STOP:
599 atomic_set(&dev->stream_started, 0);
600 break;
601 default:
602 retval = -EINVAL;
603 break;
605 spin_unlock(&dev->adev.slock);
607 schedule_work(&dev->wq_trigger);
609 return retval;
612 static snd_pcm_uframes_t snd_cx231xx_capture_pointer(struct snd_pcm_substream
613 *substream)
615 struct cx231xx *dev;
616 unsigned long flags;
617 snd_pcm_uframes_t hwptr_done;
619 dev = snd_pcm_substream_chip(substream);
621 spin_lock_irqsave(&dev->adev.slock, flags);
622 hwptr_done = dev->adev.hwptr_done_capture;
623 spin_unlock_irqrestore(&dev->adev.slock, flags);
625 return hwptr_done;
628 static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
629 unsigned long offset)
631 void *pageptr = subs->runtime->dma_area + offset;
633 return vmalloc_to_page(pageptr);
636 static const struct snd_pcm_ops snd_cx231xx_pcm_capture = {
637 .open = snd_cx231xx_capture_open,
638 .close = snd_cx231xx_pcm_close,
639 .ioctl = snd_pcm_lib_ioctl,
640 .hw_params = snd_cx231xx_hw_capture_params,
641 .hw_free = snd_cx231xx_hw_capture_free,
642 .prepare = snd_cx231xx_prepare,
643 .trigger = snd_cx231xx_capture_trigger,
644 .pointer = snd_cx231xx_capture_pointer,
645 .page = snd_pcm_get_vmalloc_page,
648 static int cx231xx_audio_init(struct cx231xx *dev)
650 struct cx231xx_audio *adev = &dev->adev;
651 struct snd_pcm *pcm;
652 struct snd_card *card;
653 static int devnr;
654 int err;
655 struct usb_interface *uif;
656 int i, isoc_pipe = 0;
658 if (dev->has_alsa_audio != 1) {
659 /* This device does not support the extension (in this case
660 the device is expecting the snd-usb-audio module or
661 doesn't have analog audio support at all) */
662 return 0;
665 dev_dbg(dev->dev,
666 "probing for cx231xx non standard usbaudio\n");
668 err = snd_card_new(dev->dev, index[devnr], "Cx231xx Audio",
669 THIS_MODULE, 0, &card);
670 if (err < 0)
671 return err;
673 spin_lock_init(&adev->slock);
674 err = snd_pcm_new(card, "Cx231xx Audio", 0, 0, 1, &pcm);
675 if (err < 0)
676 goto err_free_card;
678 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
679 &snd_cx231xx_pcm_capture);
680 pcm->info_flags = 0;
681 pcm->private_data = dev;
682 strcpy(pcm->name, "Conexant cx231xx Capture");
683 strcpy(card->driver, "Cx231xx-Audio");
684 strcpy(card->shortname, "Cx231xx Audio");
685 strcpy(card->longname, "Conexant cx231xx Audio");
687 INIT_WORK(&dev->wq_trigger, audio_trigger);
689 err = snd_card_register(card);
690 if (err < 0)
691 goto err_free_card;
693 adev->sndcard = card;
694 adev->udev = dev->udev;
696 /* compute alternate max packet sizes for Audio */
697 uif =
698 dev->udev->actconfig->interface[dev->current_pcb_config.
699 hs_config_info[0].interface_info.
700 audio_index + 1];
702 if (uif->altsetting[0].desc.bNumEndpoints < isoc_pipe + 1) {
703 err = -ENODEV;
704 goto err_free_card;
707 adev->end_point_addr =
708 uif->altsetting[0].endpoint[isoc_pipe].desc.
709 bEndpointAddress;
711 adev->num_alt = uif->num_altsetting;
712 dev_info(dev->dev,
713 "audio EndPoint Addr 0x%x, Alternate settings: %i\n",
714 adev->end_point_addr, adev->num_alt);
715 adev->alt_max_pkt_size = kmalloc_array(32, adev->num_alt, GFP_KERNEL);
716 if (!adev->alt_max_pkt_size) {
717 err = -ENOMEM;
718 goto err_free_card;
721 for (i = 0; i < adev->num_alt; i++) {
722 u16 tmp;
724 if (uif->altsetting[i].desc.bNumEndpoints < isoc_pipe + 1) {
725 err = -ENODEV;
726 goto err_free_pkt_size;
729 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
730 wMaxPacketSize);
731 adev->alt_max_pkt_size[i] =
732 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
733 dev_dbg(dev->dev,
734 "audio alternate setting %i, max size= %i\n", i,
735 adev->alt_max_pkt_size[i]);
738 return 0;
740 err_free_pkt_size:
741 kfree(adev->alt_max_pkt_size);
742 err_free_card:
743 snd_card_free(card);
745 return err;
748 static int cx231xx_audio_fini(struct cx231xx *dev)
750 if (dev == NULL)
751 return 0;
753 if (dev->has_alsa_audio != 1) {
754 /* This device does not support the extension (in this case
755 the device is expecting the snd-usb-audio module or
756 doesn't have analog audio support at all) */
757 return 0;
760 if (dev->adev.sndcard) {
761 snd_card_free(dev->adev.sndcard);
762 kfree(dev->adev.alt_max_pkt_size);
763 dev->adev.sndcard = NULL;
766 return 0;
769 static struct cx231xx_ops audio_ops = {
770 .id = CX231XX_AUDIO,
771 .name = "Cx231xx Audio Extension",
772 .init = cx231xx_audio_init,
773 .fini = cx231xx_audio_fini,
776 static int __init cx231xx_alsa_register(void)
778 return cx231xx_register_extension(&audio_ops);
781 static void __exit cx231xx_alsa_unregister(void)
783 cx231xx_unregister_extension(&audio_ops);
786 MODULE_LICENSE("GPL");
787 MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>");
788 MODULE_DESCRIPTION("Cx231xx Audio driver");
790 module_init(cx231xx_alsa_register);
791 module_exit(cx231xx_alsa_unregister);