]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/video/em28xx/em28xx-core.c
V4L/DVB (7610): em28xx: Select reg wait time based on chip ID
[karo-tx-linux.git] / drivers / media / video / em28xx / em28xx-core.c
1 /*
2    em28xx-core.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
3
4    Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5                       Markus Rechberger <mrechberger@gmail.com>
6                       Mauro Carvalho Chehab <mchehab@infradead.org>
7                       Sascha Sommer <saschasommer@freenet.de>
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include <linux/init.h>
25 #include <linux/list.h>
26 #include <linux/module.h>
27 #include <linux/usb.h>
28 #include <linux/vmalloc.h>
29
30 #include "em28xx.h"
31
32 /* #define ENABLE_DEBUG_ISOC_FRAMES */
33
34 static unsigned int core_debug;
35 module_param(core_debug,int,0644);
36 MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
37
38 #define em28xx_coredbg(fmt, arg...) do {\
39         if (core_debug) \
40                 printk(KERN_INFO "%s %s :"fmt, \
41                          dev->name, __func__ , ##arg); } while (0)
42
43 static unsigned int reg_debug;
44 module_param(reg_debug,int,0644);
45 MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
46
47 #define em28xx_regdbg(fmt, arg...) do {\
48         if (reg_debug) \
49                 printk(KERN_INFO "%s %s :"fmt, \
50                          dev->name, __func__ , ##arg); } while (0)
51
52 static int alt = EM28XX_PINOUT;
53 module_param(alt, int, 0644);
54 MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
55
56 /* FIXME */
57 #define em28xx_isocdbg(fmt, arg...) do {\
58         if (core_debug) \
59                 printk(KERN_INFO "%s %s :"fmt, \
60                          dev->name, __func__ , ##arg); } while (0)
61
62 /*
63  * em28xx_read_reg_req()
64  * reads data from the usb device specifying bRequest
65  */
66 int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
67                                    char *buf, int len)
68 {
69         int ret, byte;
70
71         if (dev->state & DEV_DISCONNECTED)
72                 return(-ENODEV);
73
74         em28xx_regdbg("req=%02x, reg=%02x ", req, reg);
75
76         ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
77                               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78                               0x0000, reg, buf, len, HZ);
79
80         if (reg_debug) {
81                 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret);
82                 for (byte = 0; byte < len; byte++)
83                         printk(KERN_INFO " %02x", (unsigned char)buf[byte]);
84
85                 printk(KERN_INFO "\n");
86         }
87
88         return ret;
89 }
90
91 /*
92  * em28xx_read_reg_req()
93  * reads data from the usb device specifying bRequest
94  */
95 int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
96 {
97         u8 val;
98         int ret;
99
100         if (dev->state & DEV_DISCONNECTED)
101                 return(-ENODEV);
102
103         em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
104
105         ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
106                               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
107                               0x0000, reg, &val, 1, HZ);
108
109         if (reg_debug)
110                 printk(ret < 0 ? " failed!\n" :
111                                  "%02x\n", (unsigned char) val);
112
113         if (ret < 0)
114                 return ret;
115
116         return val;
117 }
118
119 int em28xx_read_reg(struct em28xx *dev, u16 reg)
120 {
121         return em28xx_read_reg_req(dev, USB_REQ_GET_STATUS, reg);
122 }
123
124 /*
125  * em28xx_write_regs_req()
126  * sends data to the usb device, specifying bRequest
127  */
128 int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
129                                  int len)
130 {
131         int ret;
132
133         /*usb_control_msg seems to expect a kmalloced buffer */
134         unsigned char *bufs;
135
136         if (dev->state & DEV_DISCONNECTED)
137                 return(-ENODEV);
138
139         bufs = kmalloc(len, GFP_KERNEL);
140
141         em28xx_regdbg("req=%02x reg=%02x:", req, reg);
142
143         if (reg_debug) {
144                 int i;
145                 for (i = 0; i < len; ++i)
146                         printk(KERN_INFO " %02x", (unsigned char)buf[i]);
147                 printk(KERN_INFO "\n");
148         }
149
150         if (!bufs)
151                 return -ENOMEM;
152         memcpy(bufs, buf, len);
153         ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req,
154                               USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
155                               0x0000, reg, bufs, len, HZ);
156         if (dev->wait_after_write)
157                 msleep(dev->wait_after_write);
158
159         kfree(bufs);
160         return ret;
161 }
162
163 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len)
164 {
165         return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len);
166 }
167
168 /*
169  * em28xx_write_reg_bits()
170  * sets only some bits (specified by bitmask) of a register, by first reading
171  * the actual value
172  */
173 static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
174                                  u8 bitmask)
175 {
176         int oldval;
177         u8 newval;
178
179         oldval = em28xx_read_reg(dev, reg);
180
181         if (oldval < 0)
182                 return oldval;
183
184         newval = (((u8) oldval) & ~bitmask) | (val & bitmask);
185         return em28xx_write_regs(dev, reg, &newval, 1);
186 }
187
188 /*
189  * em28xx_write_ac97()
190  * write a 16 bit value to the specified AC97 address (LSB first!)
191  */
192 static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
193 {
194         int ret, i;
195         u8 addr = reg & 0x7f;
196
197         ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2);
198         if (ret < 0)
199                 return ret;
200
201         ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1);
202         if (ret < 0)
203                 return ret;
204
205         /* Wait up to 50 ms for AC97 command to complete */
206         for (i = 0; i < 10; i++) {
207                 ret = em28xx_read_reg(dev, AC97BUSY_REG);
208                 if (ret < 0)
209                         return ret;
210
211                 if (!(ret & 0x01))
212                         return 0;
213                 msleep(5);
214         }
215         em28xx_warn("AC97 command still being executed: not handled properly!\n");
216         return 0;
217 }
218
219 static int em28xx_set_audio_source(struct em28xx *dev)
220 {
221         static char *enable  = "\x08\x08";
222         static char *disable = "\x08\x88";
223         char *video = enable, *line = disable;
224         int ret;
225         u8 input;
226
227         if (dev->is_em2800) {
228                 if (dev->ctl_ainput)
229                         input = EM2800_AUDIO_SRC_LINE;
230                 else
231                         input = EM2800_AUDIO_SRC_TUNER;
232
233                 ret = em28xx_write_regs(dev, EM2800_AUDIOSRC_REG, &input, 1);
234                 if (ret < 0)
235                         return ret;
236         }
237
238         if (dev->has_msp34xx)
239                 input = EM28XX_AUDIO_SRC_TUNER;
240         else {
241                 switch (dev->ctl_ainput) {
242                 case EM28XX_AMUX_VIDEO:
243                         input = EM28XX_AUDIO_SRC_TUNER;
244                         break;
245                 case EM28XX_AMUX_LINE_IN:
246                         input = EM28XX_AUDIO_SRC_LINE;
247                         break;
248                 case EM28XX_AMUX_AC97_VIDEO:
249                         input = EM28XX_AUDIO_SRC_LINE;
250                         break;
251                 case EM28XX_AMUX_AC97_LINE_IN:
252                         input = EM28XX_AUDIO_SRC_LINE;
253                         video = disable;
254                         line  = enable;
255                         break;
256                 }
257         }
258
259         ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
260         if (ret < 0)
261                 return ret;
262         msleep(5);
263
264         /* Sets AC97 mixer registers
265            This is seems to be needed, even for non-ac97 configs
266          */
267         ret = em28xx_write_ac97(dev, VIDEO_AC97, video);
268         if (ret < 0)
269                 return ret;
270
271         ret = em28xx_write_ac97(dev, LINE_IN_AC97, line);
272
273         return ret;
274 }
275
276 int em28xx_audio_analog_set(struct em28xx *dev)
277 {
278         int ret;
279         char s[2] = { 0x00, 0x00 };
280         u8 xclk = 0x07;
281
282         s[0] |= 0x1f - dev->volume;
283         s[1] |= 0x1f - dev->volume;
284
285         /* Mute */
286         s[1] |= 0x80;
287         ret = em28xx_write_ac97(dev, MASTER_AC97, s);
288
289         if (ret < 0)
290                 return ret;
291
292         if (dev->has_12mhz_i2s)
293                 xclk |= 0x20;
294
295         if (!dev->mute)
296                 xclk |= 0x80;
297
298         ret = em28xx_write_reg_bits(dev, XCLK_REG, xclk, 0xa7);
299         if (ret < 0)
300                 return ret;
301         msleep(10);
302
303         /* Selects the proper audio input */
304         ret = em28xx_set_audio_source(dev);
305
306         /* Unmute device */
307         if (!dev->mute)
308                 s[1] &= ~0x80;
309         ret = em28xx_write_ac97(dev, MASTER_AC97, s);
310
311         return ret;
312 }
313 EXPORT_SYMBOL_GPL(em28xx_audio_analog_set);
314
315 int em28xx_colorlevels_set_default(struct em28xx *dev)
316 {
317         em28xx_write_regs(dev, YGAIN_REG, "\x10", 1);   /* contrast */
318         em28xx_write_regs(dev, YOFFSET_REG, "\x00", 1); /* brightness */
319         em28xx_write_regs(dev, UVGAIN_REG, "\x10", 1);  /* saturation */
320         em28xx_write_regs(dev, UOFFSET_REG, "\x00", 1);
321         em28xx_write_regs(dev, VOFFSET_REG, "\x00", 1);
322         em28xx_write_regs(dev, SHARPNESS_REG, "\x00", 1);
323
324         em28xx_write_regs(dev, GAMMA_REG, "\x20", 1);
325         em28xx_write_regs(dev, RGAIN_REG, "\x20", 1);
326         em28xx_write_regs(dev, GGAIN_REG, "\x20", 1);
327         em28xx_write_regs(dev, BGAIN_REG, "\x20", 1);
328         em28xx_write_regs(dev, ROFFSET_REG, "\x00", 1);
329         em28xx_write_regs(dev, GOFFSET_REG, "\x00", 1);
330         return em28xx_write_regs(dev, BOFFSET_REG, "\x00", 1);
331 }
332
333 int em28xx_capture_start(struct em28xx *dev, int start)
334 {
335         int rc;
336         /* FIXME: which is the best order? */
337         /* video registers are sampled by VREF */
338         rc = em28xx_write_reg_bits(dev, USBSUSP_REG,
339                                    start ? 0x10 : 0x00, 0x10);
340         if (rc < 0)
341                 return rc;
342
343         if (!start) {
344                 /* disable video capture */
345                 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x27", 1);
346                 return rc;
347         }
348
349         /* enable video capture */
350         rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
351
352         if (dev->mode == EM28XX_ANALOG_MODE)
353                 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x67", 1);
354         else
355                 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x37", 1);
356
357         msleep(6);
358
359         return rc;
360 }
361
362 int em28xx_outfmt_set_yuv422(struct em28xx *dev)
363 {
364         em28xx_write_regs(dev, OUTFMT_REG, "\x34", 1);
365         em28xx_write_regs(dev, VINMODE_REG, "\x10", 1);
366         return em28xx_write_regs(dev, VINCTRL_REG, "\x11", 1);
367 }
368
369 static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
370                                   u8 ymin, u8 ymax)
371 {
372         em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n",
373                         xmin, ymin, xmax, ymax);
374
375         em28xx_write_regs(dev, XMIN_REG, &xmin, 1);
376         em28xx_write_regs(dev, XMAX_REG, &xmax, 1);
377         em28xx_write_regs(dev, YMIN_REG, &ymin, 1);
378         return em28xx_write_regs(dev, YMAX_REG, &ymax, 1);
379 }
380
381 static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
382                                    u16 width, u16 height)
383 {
384         u8 cwidth = width;
385         u8 cheight = height;
386         u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
387
388         em28xx_coredbg("em28xx Area Set: (%d,%d)\n",
389                         (width | (overflow & 2) << 7),
390                         (height | (overflow & 1) << 8));
391
392         em28xx_write_regs(dev, HSTART_REG, &hstart, 1);
393         em28xx_write_regs(dev, VSTART_REG, &vstart, 1);
394         em28xx_write_regs(dev, CWIDTH_REG, &cwidth, 1);
395         em28xx_write_regs(dev, CHEIGHT_REG, &cheight, 1);
396         return em28xx_write_regs(dev, OFLOW_REG, &overflow, 1);
397 }
398
399 static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
400 {
401         u8 mode;
402         /* the em2800 scaler only supports scaling down to 50% */
403         if (dev->is_em2800)
404                 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
405         else {
406                 u8 buf[2];
407                 buf[0] = h;
408                 buf[1] = h >> 8;
409                 em28xx_write_regs(dev, HSCALELOW_REG, (char *)buf, 2);
410                 buf[0] = v;
411                 buf[1] = v >> 8;
412                 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2);
413                 /* it seems that both H and V scalers must be active
414                    to work correctly */
415                 mode = (h || v)? 0x30: 0x00;
416         }
417         return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30);
418 }
419
420 /* FIXME: this only function read values from dev */
421 int em28xx_resolution_set(struct em28xx *dev)
422 {
423         int width, height;
424         width = norm_maxw(dev);
425         height = norm_maxh(dev) >> 1;
426
427         em28xx_outfmt_set_yuv422(dev);
428         em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
429         em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2);
430         return em28xx_scaler_set(dev, dev->hscale, dev->vscale);
431 }
432
433 int em28xx_set_alternate(struct em28xx *dev)
434 {
435         int errCode, prev_alt = dev->alt;
436         int i;
437         unsigned int min_pkt_size = dev->width * 2 + 4;
438
439         /* When image size is bigger than a certain value,
440            the frame size should be increased, otherwise, only
441            green screen will be received.
442          */
443         if (dev->width * 2 * dev->height > 720 * 240 * 2)
444                 min_pkt_size *= 2;
445
446         for (i = 0; i < dev->num_alt; i++) {
447                 /* stop when the selected alt setting offers enough bandwidth */
448                 if (dev->alt_max_pkt_size[i] >= min_pkt_size) {
449                         dev->alt = i;
450                         break;
451                 /* otherwise make sure that we end up with the maximum bandwidth
452                    because the min_pkt_size equation might be wrong...
453                 */
454                 } else if (dev->alt_max_pkt_size[i] >
455                            dev->alt_max_pkt_size[dev->alt])
456                         dev->alt = i;
457         }
458
459         if (dev->alt != prev_alt) {
460                 em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
461                                 min_pkt_size, dev->alt);
462                 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt];
463                 em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
464                                dev->alt, dev->max_pkt_size);
465                 errCode = usb_set_interface(dev->udev, 0, dev->alt);
466                 if (errCode < 0) {
467                         em28xx_errdev("cannot change alternate number to %d (error=%i)\n",
468                                         dev->alt, errCode);
469                         return errCode;
470                 }
471         }
472         return 0;
473 }
474
475 /* ------------------------------------------------------------------
476         URB control
477    ------------------------------------------------------------------*/
478
479 /*
480  * IRQ callback, called by URB callback
481  */
482 static void em28xx_irq_callback(struct urb *urb)
483 {
484         struct em28xx_dmaqueue  *dma_q = urb->context;
485         struct em28xx *dev = container_of(dma_q, struct em28xx, vidq);
486         int rc, i;
487
488         /* Copy data from URB */
489         spin_lock(&dev->slock);
490         rc = dev->isoc_ctl.isoc_copy(dev, urb);
491         spin_unlock(&dev->slock);
492
493         /* Reset urb buffers */
494         for (i = 0; i < urb->number_of_packets; i++) {
495                 urb->iso_frame_desc[i].status = 0;
496                 urb->iso_frame_desc[i].actual_length = 0;
497         }
498         urb->status = 0;
499
500         urb->status = usb_submit_urb(urb, GFP_ATOMIC);
501         if (urb->status) {
502                 em28xx_err("urb resubmit failed (error=%i)\n",
503                         urb->status);
504         }
505 }
506
507 /*
508  * Stop and Deallocate URBs
509  */
510 void em28xx_uninit_isoc(struct em28xx *dev)
511 {
512         struct urb *urb;
513         int i;
514
515         em28xx_isocdbg("em28xx: called em28xx_uninit_isoc\n");
516
517         dev->isoc_ctl.nfields = -1;
518         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
519                 urb = dev->isoc_ctl.urb[i];
520                 if (urb) {
521                         usb_kill_urb(urb);
522                         usb_unlink_urb(urb);
523                         if (dev->isoc_ctl.transfer_buffer[i]) {
524                                 usb_buffer_free(dev->udev,
525                                         urb->transfer_buffer_length,
526                                         dev->isoc_ctl.transfer_buffer[i],
527                                         urb->transfer_dma);
528                         }
529                         usb_free_urb(urb);
530                         dev->isoc_ctl.urb[i] = NULL;
531                 }
532                 dev->isoc_ctl.transfer_buffer[i] = NULL;
533         }
534
535         kfree(dev->isoc_ctl.urb);
536         kfree(dev->isoc_ctl.transfer_buffer);
537
538         dev->isoc_ctl.urb = NULL;
539         dev->isoc_ctl.transfer_buffer = NULL;
540         dev->isoc_ctl.num_bufs = 0;
541
542         em28xx_capture_start(dev, 0);
543 }
544 EXPORT_SYMBOL_GPL(em28xx_uninit_isoc);
545
546 /*
547  * Allocate URBs and start IRQ
548  */
549 int em28xx_init_isoc(struct em28xx *dev, int max_packets,
550                      int num_bufs, int max_pkt_size,
551                      int (*isoc_copy) (struct em28xx *dev, struct urb *urb),
552                      int cap_type)
553 {
554         struct em28xx_dmaqueue *dma_q = &dev->vidq;
555         int i;
556         int sb_size, pipe;
557         struct urb *urb;
558         int j, k;
559         int rc;
560
561         em28xx_isocdbg("em28xx: called em28xx_prepare_isoc\n");
562
563         /* De-allocates all pending stuff */
564         em28xx_uninit_isoc(dev);
565
566         dev->isoc_ctl.isoc_copy = isoc_copy;
567         dev->isoc_ctl.num_bufs = num_bufs;
568
569         dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
570         if (!dev->isoc_ctl.urb) {
571                 em28xx_errdev("cannot alloc memory for usb buffers\n");
572                 return -ENOMEM;
573         }
574
575         dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
576                                               GFP_KERNEL);
577         if (!dev->isoc_ctl.urb) {
578                 em28xx_errdev("cannot allocate memory for usbtransfer\n");
579                 kfree(dev->isoc_ctl.urb);
580                 return -ENOMEM;
581         }
582
583         dev->isoc_ctl.max_pkt_size = max_pkt_size;
584         dev->isoc_ctl.buf = NULL;
585
586         sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
587
588         /* allocate urbs and transfer buffers */
589         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
590                 urb = usb_alloc_urb(max_packets, GFP_KERNEL);
591                 if (!urb) {
592                         em28xx_err("cannot alloc isoc_ctl.urb %i\n", i);
593                         em28xx_uninit_isoc(dev);
594                         return -ENOMEM;
595                 }
596                 dev->isoc_ctl.urb[i] = urb;
597
598                 dev->isoc_ctl.transfer_buffer[i] = usb_buffer_alloc(dev->udev,
599                         sb_size, GFP_KERNEL, &urb->transfer_dma);
600                 if (!dev->isoc_ctl.transfer_buffer[i]) {
601                         em28xx_err("unable to allocate %i bytes for transfer"
602                                         " buffer %i%s\n",
603                                         sb_size, i,
604                                         in_interrupt()?" while in int":"");
605                         em28xx_uninit_isoc(dev);
606                         return -ENOMEM;
607                 }
608                 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
609
610                 /* FIXME: this is a hack - should be
611                         'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK'
612                         should also be using 'desc.bInterval'
613                  */
614                 pipe = usb_rcvisocpipe(dev->udev,
615                         cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84);
616
617                 usb_fill_int_urb(urb, dev->udev, pipe,
618                                  dev->isoc_ctl.transfer_buffer[i], sb_size,
619                                  em28xx_irq_callback, dma_q, 1);
620
621                 urb->number_of_packets = max_packets;
622                 urb->transfer_flags = URB_ISO_ASAP;
623
624                 k = 0;
625                 for (j = 0; j < max_packets; j++) {
626                         urb->iso_frame_desc[j].offset = k;
627                         urb->iso_frame_desc[j].length =
628                                                 dev->isoc_ctl.max_pkt_size;
629                         k += dev->isoc_ctl.max_pkt_size;
630                 }
631         }
632
633         init_waitqueue_head(&dma_q->wq);
634
635         em28xx_capture_start(dev, cap_type);
636
637         /* submit urbs and enables IRQ */
638         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
639                 rc = usb_submit_urb(dev->isoc_ctl.urb[i], GFP_ATOMIC);
640                 if (rc) {
641                         em28xx_err("submit of urb %i failed (error=%i)\n", i,
642                                    rc);
643                         em28xx_uninit_isoc(dev);
644                         return rc;
645                 }
646         }
647
648         return 0;
649 }
650 EXPORT_SYMBOL_GPL(em28xx_init_isoc);