1 /******************************************************************************
5 * Audio driver for EasyCAP USB2.0 Video Capture Device DC60 *
8 ******************************************************************************/
11 * Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
14 * This is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * The software is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this software; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 /*****************************************************************************/
33 #ifndef CONFIG_EASYCAP_OSS
34 /*--------------------------------------------------------------------------*/
36 * PARAMETERS USED WHEN REGISTERING THE AUDIO INTERFACE
38 /*--------------------------------------------------------------------------*/
39 static const struct snd_pcm_hardware alsa_hardware
= {
40 .info
= SNDRV_PCM_INFO_BLOCK_TRANSFER
|
42 SNDRV_PCM_INFO_INTERLEAVED
|
43 SNDRV_PCM_INFO_MMAP_VALID
,
44 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
45 .rates
= SNDRV_PCM_RATE_32000
| SNDRV_PCM_RATE_48000
,
50 .buffer_bytes_max
= PAGE_SIZE
*
51 PAGES_PER_AUDIO_FRAGMENT
*
53 .period_bytes_min
= PAGE_SIZE
* PAGES_PER_AUDIO_FRAGMENT
,
54 .period_bytes_max
= PAGE_SIZE
* PAGES_PER_AUDIO_FRAGMENT
* 2,
55 .periods_min
= AUDIO_FRAGMENT_MANY
,
56 .periods_max
= AUDIO_FRAGMENT_MANY
* 2,
60 /*****************************************************************************/
61 /*---------------------------------------------------------------------------*/
63 * ON COMPLETION OF AN AUDIO URB ITS DATA IS COPIED TO THE DAM BUFFER
64 * PROVIDED peasycap->audio_idle IS ZERO. REGARDLESS OF THIS BEING TRUE,
65 * IT IS RESUBMITTED PROVIDED peasycap->audio_isoc_streaming IS NOT ZERO.
67 /*---------------------------------------------------------------------------*/
69 easycap_alsa_complete(struct urb
*purb
)
71 struct easycap
*peasycap
;
72 struct snd_pcm_substream
*pss
;
73 struct snd_pcm_runtime
*prt
;
74 int dma_bytes
, fragment_bytes
;
78 int i
, j
, more
, much
, rc
;
81 s16 oldaudio
, newaudio
, delta
;
87 SAY("ERROR: purb is NULL\n");
90 peasycap
= purb
->context
;
92 SAY("ERROR: peasycap is NULL\n");
95 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
96 SAY("ERROR: bad peasycap\n");
100 if (peasycap
->audio_idle
) {
101 JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n",
102 peasycap
->audio_idle
, peasycap
->audio_isoc_streaming
);
103 if (peasycap
->audio_isoc_streaming
)
106 /*---------------------------------------------------------------------------*/
107 pss
= peasycap
->psubstream
;
113 dma_bytes
= (int)prt
->dma_bytes
;
116 fragment_bytes
= 4 * ((int)prt
->period_size
);
117 if (0 == fragment_bytes
)
119 /* -------------------------------------------------------------------------*/
121 if ((-ESHUTDOWN
== purb
->status
) || (-ENOENT
== purb
->status
)) {
122 JOM(16, "urb status -ESHUTDOWN or -ENOENT\n");
125 SAM("ERROR: non-zero urb status: -%s: %d\n",
126 strerror(purb
->status
), purb
->status
);
129 /*---------------------------------------------------------------------------*/
131 * PROCEED HERE WHEN NO ERROR
133 /*---------------------------------------------------------------------------*/
136 oldaudio
= peasycap
->oldaudio
;
139 for (i
= 0; i
< purb
->number_of_packets
; i
++) {
140 if (purb
->iso_frame_desc
[i
].status
< 0) {
142 strerror(purb
->iso_frame_desc
[i
].status
),
143 purb
->iso_frame_desc
[i
].status
);
145 if (purb
->iso_frame_desc
[i
].status
) {
146 JOM(12, "discarding audio samples because "
147 "%i=purb->iso_frame_desc[i].status\n",
148 purb
->iso_frame_desc
[i
].status
);
151 more
= purb
->iso_frame_desc
[i
].actual_length
;
153 peasycap
->audio_mt
++;
157 SAM("MISTAKE: more is negative\n");
161 if (peasycap
->audio_mt
) {
162 JOM(12, "%4i empty audio urb frames\n",
164 peasycap
->audio_mt
= 0;
167 p1
= (u8
*)(purb
->transfer_buffer
+
168 purb
->iso_frame_desc
[i
].offset
);
171 * COPY more BYTES FROM ISOC BUFFER
172 * TO THE DMA BUFFER, CONVERTING
173 * 8-BIT MONO TO 16-BIT SIGNED
174 * LITTLE-ENDIAN SAMPLES IF NECESSARY
177 much
= dma_bytes
- peasycap
->dma_fill
;
179 SAM("MISTAKE: much is negative\n");
183 peasycap
->dma_fill
= 0;
184 peasycap
->dma_next
= fragment_bytes
;
185 JOM(8, "wrapped dma buffer\n");
187 if (!peasycap
->microphone
) {
190 memcpy(prt
->dma_area
+ peasycap
->dma_fill
,
197 JOM(8, "MISTAKE? much"
198 " is not divisible by 16\n");
199 if (much
> (16 * more
))
201 p2
= (u8
*)(prt
->dma_area
+ peasycap
->dma_fill
);
203 for (j
= 0; j
< (much
/ 16); j
++) {
204 newaudio
= ((int) *p1
) - 128;
205 newaudio
= 128 * newaudio
;
207 delta
= (newaudio
- oldaudio
) / 4;
208 tmp
= oldaudio
+ delta
;
210 for (k
= 0; k
< 4; k
++) {
211 *p2
= (0x00FF & tmp
);
212 *(p2
+ 1) = (0xFF00 & tmp
) >> 8;
214 *p2
= (0x00FF & tmp
);
215 *(p2
+ 1) = (0xFF00 & tmp
) >> 8;
224 if (much
> (2 * more
))
226 p2
= (u8
*)(prt
->dma_area
+ peasycap
->dma_fill
);
228 for (j
= 0; j
< (much
/ 2); j
++) {
229 tmp
= ((int) *p1
) - 128;
231 *p2
= (0x00FF & tmp
);
232 *(p2
+ 1) = (0xFF00 & tmp
) >> 8;
239 peasycap
->dma_fill
+= much
;
240 if (peasycap
->dma_fill
>= peasycap
->dma_next
) {
241 isfragment
= peasycap
->dma_fill
/ fragment_bytes
;
242 if (0 > isfragment
) {
243 SAM("MISTAKE: isfragment is negative\n");
246 peasycap
->dma_read
= (isfragment
- 1) * fragment_bytes
;
247 peasycap
->dma_next
= (isfragment
+ 1) * fragment_bytes
;
248 if (dma_bytes
< peasycap
->dma_next
)
249 peasycap
->dma_next
= fragment_bytes
;
251 if (0 <= peasycap
->dma_read
) {
252 JOM(8, "snd_pcm_period_elapsed(), %i="
253 "isfragment\n", isfragment
);
254 snd_pcm_period_elapsed(pss
);
260 peasycap
->oldaudio
= oldaudio
;
264 /*---------------------------------------------------------------------------*/
268 /*---------------------------------------------------------------------------*/
270 if (peasycap
->audio_isoc_streaming
== 0)
273 rc
= usb_submit_urb(purb
, GFP_ATOMIC
);
275 if ((-ENODEV
!= rc
) && (-ENOENT
!= rc
)) {
276 SAM("ERROR: while %i=audio_idle, usb_submit_urb failed "
277 "with rc: -%s :%d\n",
278 peasycap
->audio_idle
, strerror(rc
), rc
);
280 if (0 < peasycap
->audio_isoc_streaming
)
281 peasycap
->audio_isoc_streaming
--;
285 /*****************************************************************************/
286 static int easycap_alsa_open(struct snd_pcm_substream
*pss
)
288 struct snd_pcm
*psnd_pcm
;
289 struct snd_card
*psnd_card
;
290 struct easycap
*peasycap
;
294 SAY("ERROR: pss is NULL\n");
299 SAY("ERROR: psnd_pcm is NULL\n");
302 psnd_card
= psnd_pcm
->card
;
304 SAY("ERROR: psnd_card is NULL\n");
308 peasycap
= psnd_card
->private_data
;
310 SAY("ERROR: peasycap is NULL\n");
313 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
314 SAY("ERROR: bad peasycap\n");
317 if (peasycap
->psnd_card
!= psnd_card
) {
318 SAM("ERROR: bad peasycap->psnd_card\n");
321 if (peasycap
->psubstream
) {
322 SAM("ERROR: bad peasycap->psubstream\n");
325 pss
->private_data
= peasycap
;
326 peasycap
->psubstream
= pss
;
327 pss
->runtime
->hw
= peasycap
->alsa_hardware
;
328 pss
->runtime
->private_data
= peasycap
;
329 pss
->private_data
= peasycap
;
331 if (0 != easycap_sound_setup(peasycap
)) {
332 JOM(4, "ending unsuccessfully\n");
335 JOM(4, "ending successfully\n");
338 /*****************************************************************************/
339 static int easycap_alsa_close(struct snd_pcm_substream
*pss
)
341 struct easycap
*peasycap
;
345 SAY("ERROR: pss is NULL\n");
348 peasycap
= snd_pcm_substream_chip(pss
);
350 SAY("ERROR: peasycap is NULL\n");
353 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
354 SAY("ERROR: bad peasycap\n");
357 pss
->private_data
= NULL
;
358 peasycap
->psubstream
= NULL
;
359 JOT(4, "ending successfully\n");
362 /*****************************************************************************/
363 static int easycap_alsa_vmalloc(struct snd_pcm_substream
*pss
, size_t sz
)
365 struct snd_pcm_runtime
*prt
;
369 SAY("ERROR: pss is NULL\n");
374 SAY("ERROR: substream.runtime is NULL\n");
378 if (prt
->dma_bytes
> sz
)
380 vfree(prt
->dma_area
);
382 prt
->dma_area
= vmalloc(sz
);
388 /*****************************************************************************/
389 static int easycap_alsa_hw_params(struct snd_pcm_substream
*pss
,
390 struct snd_pcm_hw_params
*phw
)
394 JOT(4, "%i\n", (params_buffer_bytes(phw
)));
396 SAY("ERROR: pss is NULL\n");
399 rc
= easycap_alsa_vmalloc(pss
, params_buffer_bytes(phw
));
404 /*****************************************************************************/
405 static int easycap_alsa_hw_free(struct snd_pcm_substream
*pss
)
407 struct snd_pcm_runtime
*prt
;
411 SAY("ERROR: pss is NULL\n");
416 SAY("ERROR: substream.runtime is NULL\n");
420 JOT(8, "prt->dma_area = %p\n", prt
->dma_area
);
421 vfree(prt
->dma_area
);
422 prt
->dma_area
= NULL
;
424 JOT(8, "dma_area already freed\n");
427 /*****************************************************************************/
428 static int easycap_alsa_prepare(struct snd_pcm_substream
*pss
)
430 struct easycap
*peasycap
;
431 struct snd_pcm_runtime
*prt
;
435 SAY("ERROR: pss is NULL\n");
439 peasycap
= snd_pcm_substream_chip(pss
);
441 SAY("ERROR: peasycap is NULL\n");
444 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
445 SAY("ERROR: bad peasycap\n");
449 JOM(16, "ALSA decides %8i Hz=rate\n", pss
->runtime
->rate
);
450 JOM(16, "ALSA decides %8ld =period_size\n", pss
->runtime
->period_size
);
451 JOM(16, "ALSA decides %8i =periods\n", pss
->runtime
->periods
);
452 JOM(16, "ALSA decides %8ld =buffer_size\n", pss
->runtime
->buffer_size
);
453 JOM(16, "ALSA decides %8zd =dma_bytes\n", pss
->runtime
->dma_bytes
);
454 JOM(16, "ALSA decides %8ld =boundary\n", pss
->runtime
->boundary
);
455 JOM(16, "ALSA decides %8i =period_step\n", pss
->runtime
->period_step
);
456 JOM(16, "ALSA decides %8i =sample_bits\n", pss
->runtime
->sample_bits
);
457 JOM(16, "ALSA decides %8i =frame_bits\n", pss
->runtime
->frame_bits
);
458 JOM(16, "ALSA decides %8ld =min_align\n", pss
->runtime
->min_align
);
459 JOM(12, "ALSA decides %8ld =hw_ptr_base\n", pss
->runtime
->hw_ptr_base
);
460 JOM(12, "ALSA decides %8ld =hw_ptr_interrupt\n",
461 pss
->runtime
->hw_ptr_interrupt
);
463 if (prt
->dma_bytes
!= 4 * ((int)prt
->period_size
) * ((int)prt
->periods
)) {
464 SAY("MISTAKE: unexpected ALSA parameters\n");
469 /*****************************************************************************/
470 static int easycap_alsa_ack(struct snd_pcm_substream
*pss
)
474 /*****************************************************************************/
475 static int easycap_alsa_trigger(struct snd_pcm_substream
*pss
, int cmd
)
477 struct easycap
*peasycap
;
480 JOT(4, "%i=cmd cf %i=START %i=STOP\n", cmd
, SNDRV_PCM_TRIGGER_START
,
481 SNDRV_PCM_TRIGGER_STOP
);
483 SAY("ERROR: pss is NULL\n");
486 peasycap
= snd_pcm_substream_chip(pss
);
488 SAY("ERROR: peasycap is NULL\n");
491 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
492 SAY("ERROR: bad peasycap\n");
497 case SNDRV_PCM_TRIGGER_START
: {
498 peasycap
->audio_idle
= 0;
501 case SNDRV_PCM_TRIGGER_STOP
: {
502 peasycap
->audio_idle
= 1;
510 /*****************************************************************************/
511 static snd_pcm_uframes_t
easycap_alsa_pointer(struct snd_pcm_substream
*pss
)
513 struct easycap
*peasycap
;
514 snd_pcm_uframes_t offset
;
518 SAY("ERROR: pss is NULL\n");
521 peasycap
= snd_pcm_substream_chip(pss
);
523 SAY("ERROR: peasycap is NULL\n");
526 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
527 SAY("ERROR: bad peasycap\n");
530 if ((0 != peasycap
->audio_eof
) || (0 != peasycap
->audio_idle
)) {
531 JOM(8, "returning -EIO because "
532 "%i=audio_idle %i=audio_eof\n",
533 peasycap
->audio_idle
, peasycap
->audio_eof
);
536 /*---------------------------------------------------------------------------*/
537 if (0 > peasycap
->dma_read
) {
538 JOM(8, "returning -EBUSY\n");
541 offset
= ((snd_pcm_uframes_t
)peasycap
->dma_read
)/4;
542 JOM(8, "ALSA decides %8i =hw_ptr_base\n", (int)pss
->runtime
->hw_ptr_base
);
543 JOM(8, "ALSA decides %8i =hw_ptr_interrupt\n",
544 (int)pss
->runtime
->hw_ptr_interrupt
);
545 JOM(8, "%7i=offset %7i=dma_read %7i=dma_next\n",
546 (int)offset
, peasycap
->dma_read
, peasycap
->dma_next
);
549 /*****************************************************************************/
551 easycap_alsa_page(struct snd_pcm_substream
*pss
, unsigned long offset
)
553 return vmalloc_to_page(pss
->runtime
->dma_area
+ offset
);
555 /*****************************************************************************/
557 static struct snd_pcm_ops easycap_alsa_pcm_ops
= {
558 .open
= easycap_alsa_open
,
559 .close
= easycap_alsa_close
,
560 .ioctl
= snd_pcm_lib_ioctl
,
561 .hw_params
= easycap_alsa_hw_params
,
562 .hw_free
= easycap_alsa_hw_free
,
563 .prepare
= easycap_alsa_prepare
,
564 .ack
= easycap_alsa_ack
,
565 .trigger
= easycap_alsa_trigger
,
566 .pointer
= easycap_alsa_pointer
,
567 .page
= easycap_alsa_page
,
570 /*****************************************************************************/
571 /*---------------------------------------------------------------------------*/
573 * THE FUNCTION snd_card_create() HAS THIS_MODULE AS AN ARGUMENT. THIS
574 * MEANS MODULE easycap. BEWARE.
576 /*---------------------------------------------------------------------------*/
577 int easycap_alsa_probe(struct easycap
*peasycap
)
580 struct snd_card
*psnd_card
;
581 struct snd_pcm
*psnd_pcm
;
584 SAY("ERROR: peasycap is NULL\n");
587 if (memcmp(&peasycap
->telltale
[0], TELLTALE
, strlen(TELLTALE
))) {
588 SAY("ERROR: bad peasycap\n");
591 if (0 > peasycap
->minor
) {
592 SAY("ERROR: no minor\n");
596 peasycap
->alsa_hardware
= alsa_hardware
;
597 if (peasycap
->microphone
) {
598 peasycap
->alsa_hardware
.rates
= SNDRV_PCM_RATE_32000
;
599 peasycap
->alsa_hardware
.rate_min
= 32000;
600 peasycap
->alsa_hardware
.rate_max
= 32000;
602 peasycap
->alsa_hardware
.rates
= SNDRV_PCM_RATE_48000
;
603 peasycap
->alsa_hardware
.rate_min
= 48000;
604 peasycap
->alsa_hardware
.rate_max
= 48000;
607 if (0 != snd_card_create(SNDRV_DEFAULT_IDX1
, "easycap_alsa",
608 THIS_MODULE
, 0, &psnd_card
)) {
609 SAY("ERROR: Cannot do ALSA snd_card_create()\n");
613 sprintf(&psnd_card
->id
[0], "EasyALSA%i", peasycap
->minor
);
614 strcpy(&psnd_card
->driver
[0], EASYCAP_DRIVER_DESCRIPTION
);
615 strcpy(&psnd_card
->shortname
[0], "easycap_alsa");
616 sprintf(&psnd_card
->longname
[0], "%s", &psnd_card
->shortname
[0]);
618 psnd_card
->dev
= &peasycap
->pusb_device
->dev
;
619 psnd_card
->private_data
= peasycap
;
620 peasycap
->psnd_card
= psnd_card
;
622 rc
= snd_pcm_new(psnd_card
, "easycap_pcm", 0, 0, 1, &psnd_pcm
);
624 SAM("ERROR: Cannot do ALSA snd_pcm_new()\n");
625 snd_card_free(psnd_card
);
629 snd_pcm_set_ops(psnd_pcm
, SNDRV_PCM_STREAM_CAPTURE
,
630 &easycap_alsa_pcm_ops
);
631 psnd_pcm
->info_flags
= 0;
632 strcpy(&psnd_pcm
->name
[0], &psnd_card
->id
[0]);
633 psnd_pcm
->private_data
= peasycap
;
634 peasycap
->psnd_pcm
= psnd_pcm
;
635 peasycap
->psubstream
= NULL
;
637 rc
= snd_card_register(psnd_card
);
639 SAM("ERROR: Cannot do ALSA snd_card_register()\n");
640 snd_card_free(psnd_card
);
644 SAM("registered %s\n", &psnd_card
->id
[0]);
647 #endif /*! CONFIG_EASYCAP_OSS */
649 /*****************************************************************************/
650 /*****************************************************************************/
651 /*****************************************************************************/
652 /*****************************************************************************/
653 /*****************************************************************************/
654 /*****************************************************************************/
655 /*---------------------------------------------------------------------------*/
657 * COMMON AUDIO INITIALIZATION
659 /*---------------------------------------------------------------------------*/
661 easycap_sound_setup(struct easycap
*peasycap
)
665 JOM(4, "starting initialization\n");
668 SAY("ERROR: peasycap is NULL.\n");
671 if (!peasycap
->pusb_device
) {
672 SAM("ERROR: peasycap->pusb_device is NULL\n");
675 JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap
->pusb_device
);
677 rc
= audio_setup(peasycap
);
678 JOM(8, "audio_setup() returned %i\n", rc
);
680 if (!peasycap
->pusb_device
) {
681 SAM("ERROR: peasycap->pusb_device has become NULL\n");
684 /*---------------------------------------------------------------------------*/
685 if (!peasycap
->pusb_device
) {
686 SAM("ERROR: peasycap->pusb_device has become NULL\n");
689 rc
= usb_set_interface(peasycap
->pusb_device
, peasycap
->audio_interface
,
690 peasycap
->audio_altsetting_on
);
691 JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap
->audio_interface
,
692 peasycap
->audio_altsetting_on
, rc
);
694 rc
= wakeup_device(peasycap
->pusb_device
);
695 JOM(8, "wakeup_device() returned %i\n", rc
);
697 peasycap
->audio_eof
= 0;
698 peasycap
->audio_idle
= 0;
700 peasycap
->timeval1
.tv_sec
= 0;
701 peasycap
->timeval1
.tv_usec
= 0;
703 submit_audio_urbs(peasycap
);
705 JOM(4, "finished initialization\n");
708 /*****************************************************************************/
709 /*---------------------------------------------------------------------------*/
711 * SUBMIT ALL AUDIO URBS.
713 /*---------------------------------------------------------------------------*/
715 submit_audio_urbs(struct easycap
*peasycap
)
717 struct data_urb
*pdata_urb
;
719 struct list_head
*plist_head
;
720 int j
, isbad
, nospc
, m
, rc
;
724 SAY("ERROR: peasycap is NULL\n");
727 if (!peasycap
->purb_audio_head
) {
728 SAM("ERROR: peasycap->urb_audio_head uninitialized\n");
731 if (!peasycap
->pusb_device
) {
732 SAM("ERROR: peasycap->pusb_device is NULL\n");
736 if (peasycap
->audio_isoc_streaming
) {
737 JOM(4, "already streaming audio urbs\n");
741 JOM(4, "initial submission of all audio urbs\n");
742 rc
= usb_set_interface(peasycap
->pusb_device
,
743 peasycap
->audio_interface
,
744 peasycap
->audio_altsetting_on
);
745 JOM(8, "usb_set_interface(.,%i,%i) returned %i\n",
746 peasycap
->audio_interface
,
747 peasycap
->audio_altsetting_on
, rc
);
752 list_for_each(plist_head
, peasycap
->purb_audio_head
) {
753 pdata_urb
= list_entry(plist_head
, struct data_urb
, list_head
);
754 if (pdata_urb
&& pdata_urb
->purb
) {
755 purb
= pdata_urb
->purb
;
756 isbuf
= pdata_urb
->isbuf
;
759 purb
->dev
= peasycap
->pusb_device
;
760 purb
->pipe
= usb_rcvisocpipe(peasycap
->pusb_device
,
761 peasycap
->audio_endpointnumber
);
762 purb
->transfer_flags
= URB_ISO_ASAP
;
763 purb
->transfer_buffer
= peasycap
->audio_isoc_buffer
[isbuf
].pgo
;
764 purb
->transfer_buffer_length
= peasycap
->audio_isoc_buffer_size
;
765 #ifdef CONFIG_EASYCAP_OSS
766 purb
->complete
= easyoss_complete
;
767 #else /* CONFIG_EASYCAP_OSS */
768 purb
->complete
= easycap_alsa_complete
;
769 #endif /* CONFIG_EASYCAP_OSS */
770 purb
->context
= peasycap
;
771 purb
->start_frame
= 0;
772 purb
->number_of_packets
= peasycap
->audio_isoc_framesperdesc
;
773 for (j
= 0; j
< peasycap
->audio_isoc_framesperdesc
; j
++) {
774 purb
->iso_frame_desc
[j
].offset
= j
* peasycap
->audio_isoc_maxframesize
;
775 purb
->iso_frame_desc
[j
].length
= peasycap
->audio_isoc_maxframesize
;
778 rc
= usb_submit_urb(purb
, GFP_KERNEL
);
781 SAM("ERROR: usb_submit_urb() failed"
782 " for urb with rc: -%s: %d\n",
792 SAM("-ENOSPC=usb_submit_urb() for %i urbs\n", nospc
);
793 SAM("..... possibly inadequate USB bandwidth\n");
794 peasycap
->audio_eof
= 1;
797 JOM(4, "attempting cleanup instead of submitting\n");
798 list_for_each(plist_head
, (peasycap
->purb_audio_head
)) {
799 pdata_urb
= list_entry(plist_head
, struct data_urb
, list_head
);
800 if (pdata_urb
&& pdata_urb
->purb
)
801 usb_kill_urb(pdata_urb
->purb
);
803 peasycap
->audio_isoc_streaming
= 0;
805 peasycap
->audio_isoc_streaming
= m
;
806 JOM(4, "submitted %i audio urbs\n", m
);
811 /*****************************************************************************/
812 /*---------------------------------------------------------------------------*/
814 * KILL ALL AUDIO URBS.
816 /*---------------------------------------------------------------------------*/
818 kill_audio_urbs(struct easycap
*peasycap
)
821 struct list_head
*plist_head
;
822 struct data_urb
*pdata_urb
;
825 SAY("ERROR: peasycap is NULL\n");
829 if (!peasycap
->audio_isoc_streaming
) {
830 JOM(8, "%i=audio_isoc_streaming, no audio urbs killed\n",
831 peasycap
->audio_isoc_streaming
);
835 if (!peasycap
->purb_audio_head
) {
836 SAM("ERROR: peasycap->purb_audio_head is NULL\n");
840 peasycap
->audio_isoc_streaming
= 0;
841 JOM(4, "killing audio urbs\n");
843 list_for_each(plist_head
, (peasycap
->purb_audio_head
)) {
844 pdata_urb
= list_entry(plist_head
, struct data_urb
, list_head
);
845 if (pdata_urb
&& pdata_urb
->purb
) {
846 usb_kill_urb(pdata_urb
->purb
);
850 JOM(4, "%i audio urbs killed\n", m
);
854 /*****************************************************************************/