]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/video/em28xx/em28xx-core.c
77f64900717def904061ea83b222ca37c73ab10b
[linux-2.6-omap-h63xx.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(" %02x", (unsigned char)buf[byte]);
84                 }
85                 printk("\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 (" %02x", (unsigned char)buf[i]);
147                 printk ("\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         msleep(5);              /* FIXME: magic number */
157         kfree(bufs);
158         return ret;
159 }
160
161 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len)
162 {
163         return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len);
164 }
165
166 /*
167  * em28xx_write_reg_bits()
168  * sets only some bits (specified by bitmask) of a register, by first reading
169  * the actual value
170  */
171 static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
172                                  u8 bitmask)
173 {
174         int oldval;
175         u8 newval;
176         if ((oldval = em28xx_read_reg(dev, reg)) < 0)
177                 return oldval;
178         newval = (((u8) oldval) & ~bitmask) | (val & bitmask);
179         return em28xx_write_regs(dev, reg, &newval, 1);
180 }
181
182 /*
183  * em28xx_write_ac97()
184  * write a 16 bit value to the specified AC97 address (LSB first!)
185  */
186 static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
187 {
188         int ret, i;
189         u8 addr = reg & 0x7f;
190         if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0)
191                 return ret;
192         if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0)
193                 return ret;
194
195         /* Wait up to 50 ms for AC97 command to complete */
196         for (i = 0; i < 10; i++) {
197                 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0)
198                         return ret;
199                 if (!(ret & 0x01))
200                         return 0;
201                 msleep(5);
202         }
203         em28xx_warn ("AC97 command still being executed: not handled properly!\n");
204         return 0;
205 }
206
207 static int em28xx_set_audio_source(struct em28xx *dev)
208 {
209         static char *enable  = "\x08\x08";
210         static char *disable = "\x08\x88";
211         char *video = enable, *line = disable;
212         int ret;
213         u8 input;
214
215         if (dev->is_em2800) {
216                 if (dev->ctl_ainput)
217                         input = EM2800_AUDIO_SRC_LINE;
218                 else
219                         input = EM2800_AUDIO_SRC_TUNER;
220
221                 ret = em28xx_write_regs(dev, EM2800_AUDIOSRC_REG, &input, 1);
222                 if (ret < 0)
223                         return ret;
224         }
225
226         if (dev->has_msp34xx)
227                 input = EM28XX_AUDIO_SRC_TUNER;
228         else {
229                 switch (dev->ctl_ainput) {
230                 case EM28XX_AMUX_VIDEO:
231                         input = EM28XX_AUDIO_SRC_TUNER;
232                         break;
233                 case EM28XX_AMUX_LINE_IN:
234                         input = EM28XX_AUDIO_SRC_LINE;
235                         break;
236                 case EM28XX_AMUX_AC97_VIDEO:
237                         input = EM28XX_AUDIO_SRC_LINE;
238                         break;
239                 case EM28XX_AMUX_AC97_LINE_IN:
240                         input = EM28XX_AUDIO_SRC_LINE;
241                         video = disable;
242                         line  = enable;
243                         break;
244                 }
245         }
246
247         ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
248         if (ret < 0)
249                 return ret;
250         msleep(5);
251
252         /* Sets AC97 mixer registers
253            This is seems to be needed, even for non-ac97 configs
254          */
255         ret = em28xx_write_ac97(dev, VIDEO_AC97, video);
256         if (ret < 0)
257                 return ret;
258
259         ret = em28xx_write_ac97(dev, LINE_IN_AC97, line);
260
261         return ret;
262 }
263
264 int em28xx_audio_analog_set(struct em28xx *dev)
265 {
266         int ret;
267         char s[2] = { 0x00, 0x00 };
268         u8 xclk = 0x07;
269
270         s[0] |= 0x1f - dev->volume;
271         s[1] |= 0x1f - dev->volume;
272
273         /* Mute */
274         s[1] |= 0x80;
275         ret = em28xx_write_ac97(dev, MASTER_AC97, s);
276
277         if (ret < 0)
278                 return ret;
279
280         if (dev->has_12mhz_i2s)
281                 xclk |= 0x20;
282
283         if (!dev->mute)
284                 xclk |= 0x80;
285
286         ret = em28xx_write_reg_bits(dev, XCLK_REG, xclk, 0xa7);
287         if (ret < 0)
288                 return ret;
289         msleep(10);
290
291         /* Selects the proper audio input */
292         ret = em28xx_set_audio_source(dev);
293
294         /* Unmute device */
295         if (!dev->mute)
296                 s[1] &= ~0x80;
297         ret = em28xx_write_ac97(dev, MASTER_AC97, s);
298
299         return ret;
300 }
301 EXPORT_SYMBOL_GPL(em28xx_audio_analog_set);
302
303 int em28xx_colorlevels_set_default(struct em28xx *dev)
304 {
305         em28xx_write_regs(dev, YGAIN_REG, "\x10", 1);   /* contrast */
306         em28xx_write_regs(dev, YOFFSET_REG, "\x00", 1); /* brightness */
307         em28xx_write_regs(dev, UVGAIN_REG, "\x10", 1);  /* saturation */
308         em28xx_write_regs(dev, UOFFSET_REG, "\x00", 1);
309         em28xx_write_regs(dev, VOFFSET_REG, "\x00", 1);
310         em28xx_write_regs(dev, SHARPNESS_REG, "\x00", 1);
311
312         em28xx_write_regs(dev, GAMMA_REG, "\x20", 1);
313         em28xx_write_regs(dev, RGAIN_REG, "\x20", 1);
314         em28xx_write_regs(dev, GGAIN_REG, "\x20", 1);
315         em28xx_write_regs(dev, BGAIN_REG, "\x20", 1);
316         em28xx_write_regs(dev, ROFFSET_REG, "\x00", 1);
317         em28xx_write_regs(dev, GOFFSET_REG, "\x00", 1);
318         return em28xx_write_regs(dev, BOFFSET_REG, "\x00", 1);
319 }
320
321 int em28xx_capture_start(struct em28xx *dev, int start)
322 {
323         int rc;
324         /* FIXME: which is the best order? */
325         /* video registers are sampled by VREF */
326         rc = em28xx_write_reg_bits(dev, USBSUSP_REG,
327                                    start ? 0x10 : 0x00, 0x10);
328         if (rc < 0)
329                 return rc;
330
331         if (!start) {
332                 /* disable video capture */
333                 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x27", 1);
334                 return rc;
335         }
336
337         /* enable video capture */
338         rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
339
340         if (dev->mode == EM28XX_ANALOG_MODE)
341                 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x67", 1);
342         else
343                 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x37", 1);
344
345         msleep (6);
346
347         return rc;
348 }
349
350 int em28xx_outfmt_set_yuv422(struct em28xx *dev)
351 {
352         em28xx_write_regs(dev, OUTFMT_REG, "\x34", 1);
353         em28xx_write_regs(dev, VINMODE_REG, "\x10", 1);
354         return em28xx_write_regs(dev, VINCTRL_REG, "\x11", 1);
355 }
356
357 static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
358                                   u8 ymin, u8 ymax)
359 {
360         em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax);
361
362         em28xx_write_regs(dev, XMIN_REG, &xmin, 1);
363         em28xx_write_regs(dev, XMAX_REG, &xmax, 1);
364         em28xx_write_regs(dev, YMIN_REG, &ymin, 1);
365         return em28xx_write_regs(dev, YMAX_REG, &ymax, 1);
366 }
367
368 static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
369                                    u16 width, u16 height)
370 {
371         u8 cwidth = width;
372         u8 cheight = height;
373         u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
374
375         em28xx_coredbg("em28xx Area Set: (%d,%d)\n", (width | (overflow & 2) << 7),
376                         (height | (overflow & 1) << 8));
377
378         em28xx_write_regs(dev, HSTART_REG, &hstart, 1);
379         em28xx_write_regs(dev, VSTART_REG, &vstart, 1);
380         em28xx_write_regs(dev, CWIDTH_REG, &cwidth, 1);
381         em28xx_write_regs(dev, CHEIGHT_REG, &cheight, 1);
382         return em28xx_write_regs(dev, OFLOW_REG, &overflow, 1);
383 }
384
385 static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
386 {
387         u8 mode;
388         /* the em2800 scaler only supports scaling down to 50% */
389         if(dev->is_em2800)
390                 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
391         else {
392                 u8 buf[2];
393                 buf[0] = h;
394                 buf[1] = h >> 8;
395                 em28xx_write_regs(dev, HSCALELOW_REG, (char *)buf, 2);
396                 buf[0] = v;
397                 buf[1] = v >> 8;
398                 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2);
399                 /* it seems that both H and V scalers must be active to work correctly */
400                 mode = (h || v)? 0x30: 0x00;
401         }
402         return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30);
403 }
404
405 /* FIXME: this only function read values from dev */
406 int em28xx_resolution_set(struct em28xx *dev)
407 {
408         int width, height;
409         width = norm_maxw(dev);
410         height = norm_maxh(dev) >> 1;
411
412         em28xx_outfmt_set_yuv422(dev);
413         em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
414         em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2);
415         return em28xx_scaler_set(dev, dev->hscale, dev->vscale);
416 }
417
418 int em28xx_set_alternate(struct em28xx *dev)
419 {
420         int errCode, prev_alt = dev->alt;
421         int i;
422         unsigned int min_pkt_size = dev->width * 2 + 4;
423
424         /* When image size is bigger than a certain value,
425            the frame size should be increased, otherwise, only
426            green screen will be received.
427          */
428         if (dev->width * 2 * dev->height > 720 * 240 * 2)
429                 min_pkt_size *= 2;
430
431         for (i = 0; i < dev->num_alt; i++) {
432                 /* stop when the selected alt setting offers enough bandwidth */
433                 if (dev->alt_max_pkt_size[i] >= min_pkt_size) {
434                         dev->alt = i;
435                         break;
436                 /* otherwise make sure that we end up with the maximum bandwidth
437                    because the min_pkt_size equation might be wrong...
438                 */
439                 } else if (dev->alt_max_pkt_size[i] >
440                            dev->alt_max_pkt_size[dev->alt])
441                         dev->alt = i;
442         }
443
444         if (dev->alt != prev_alt) {
445                 em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
446                                 min_pkt_size, dev->alt);
447                 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt];
448                 em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
449                                dev->alt, dev->max_pkt_size);
450                 errCode = usb_set_interface(dev->udev, 0, dev->alt);
451                 if (errCode < 0) {
452                         em28xx_errdev ("cannot change alternate number to %d (error=%i)\n",
453                                         dev->alt, errCode);
454                         return errCode;
455                 }
456         }
457         return 0;
458 }
459
460 /* ------------------------------------------------------------------
461         URB control
462    ------------------------------------------------------------------*/
463
464 /*
465  * IRQ callback, called by URB callback
466  */
467 static void em28xx_irq_callback(struct urb *urb)
468 {
469         struct em28xx_dmaqueue  *dma_q = urb->context;
470         struct em28xx *dev = container_of(dma_q, struct em28xx, vidq);
471         int rc, i;
472
473         /* Copy data from URB */
474         spin_lock(&dev->slock);
475         rc = dev->isoc_ctl.isoc_copy(dev, urb);
476         spin_unlock(&dev->slock);
477
478         /* Reset urb buffers */
479         for (i = 0; i < urb->number_of_packets; i++) {
480                 urb->iso_frame_desc[i].status = 0;
481                 urb->iso_frame_desc[i].actual_length = 0;
482         }
483         urb->status = 0;
484
485         urb->status = usb_submit_urb(urb, GFP_ATOMIC);
486         if (urb->status) {
487                 em28xx_err("urb resubmit failed (error=%i)\n",
488                         urb->status);
489         }
490 }
491
492 /*
493  * Stop and Deallocate URBs
494  */
495 void em28xx_uninit_isoc(struct em28xx *dev)
496 {
497         struct urb *urb;
498         int i;
499
500         em28xx_isocdbg("em28xx: called em28xx_uninit_isoc\n");
501
502         dev->isoc_ctl.nfields = -1;
503         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
504                 urb = dev->isoc_ctl.urb[i];
505                 if (urb) {
506                         usb_kill_urb(urb);
507                         usb_unlink_urb(urb);
508                         if (dev->isoc_ctl.transfer_buffer[i]) {
509                                 usb_buffer_free(dev->udev,
510                                                 urb->transfer_buffer_length,
511                                                 dev->isoc_ctl.transfer_buffer[i],
512                                                 urb->transfer_dma);
513                         }
514                         usb_free_urb(urb);
515                         dev->isoc_ctl.urb[i] = NULL;
516                 }
517                 dev->isoc_ctl.transfer_buffer[i] = NULL;
518         }
519
520         kfree(dev->isoc_ctl.urb);
521         kfree(dev->isoc_ctl.transfer_buffer);
522
523         dev->isoc_ctl.urb = NULL;
524         dev->isoc_ctl.transfer_buffer = NULL;
525         dev->isoc_ctl.num_bufs = 0;
526
527         em28xx_capture_start(dev, 0);
528 }
529 EXPORT_SYMBOL_GPL(em28xx_uninit_isoc);
530
531 /*
532  * Allocate URBs and start IRQ
533  */
534 int em28xx_init_isoc(struct em28xx *dev, int max_packets,
535                      int num_bufs, int max_pkt_size,
536                      int (*isoc_copy) (struct em28xx *dev, struct urb *urb),
537                      int cap_type)
538 {
539         struct em28xx_dmaqueue *dma_q = &dev->vidq;
540         int i;
541         int sb_size, pipe;
542         struct urb *urb;
543         int j, k;
544         int rc;
545
546         em28xx_isocdbg("em28xx: called em28xx_prepare_isoc\n");
547
548         /* De-allocates all pending stuff */
549         em28xx_uninit_isoc(dev);
550
551         dev->isoc_ctl.isoc_copy = isoc_copy;
552         dev->isoc_ctl.num_bufs = num_bufs;
553
554         dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
555         if (!dev->isoc_ctl.urb) {
556                 em28xx_errdev("cannot alloc memory for usb buffers\n");
557                 return -ENOMEM;
558         }
559
560         dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
561                                               GFP_KERNEL);
562         if (!dev->isoc_ctl.urb) {
563                 em28xx_errdev("cannot allocate memory for usbtransfer\n");
564                 kfree(dev->isoc_ctl.urb);
565                 return -ENOMEM;
566         }
567
568         dev->isoc_ctl.max_pkt_size = max_pkt_size;
569         dev->isoc_ctl.buf = NULL;
570
571         sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
572
573         /* allocate urbs and transfer buffers */
574         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
575                 urb = usb_alloc_urb(max_packets, GFP_KERNEL);
576                 if (!urb) {
577                         em28xx_err("cannot alloc isoc_ctl.urb %i\n", i);
578                         em28xx_uninit_isoc(dev);
579                         return -ENOMEM;
580                 }
581                 dev->isoc_ctl.urb[i] = urb;
582
583                 dev->isoc_ctl.transfer_buffer[i] = usb_buffer_alloc(dev->udev,
584                         sb_size, GFP_KERNEL, &urb->transfer_dma);
585                 if (!dev->isoc_ctl.transfer_buffer[i]) {
586                         em28xx_err("unable to allocate %i bytes for transfer"
587                                         " buffer %i%s\n",
588                                         sb_size, i,
589                                         in_interrupt()?" while in int":"");
590                         em28xx_uninit_isoc(dev);
591                         return -ENOMEM;
592                 }
593                 memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
594
595                 /* FIXME: this is a hack - should be
596                         'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK'
597                         should also be using 'desc.bInterval'
598                  */
599                 pipe = usb_rcvisocpipe(dev->udev, cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84);
600                 usb_fill_int_urb(urb, dev->udev, pipe,
601                                  dev->isoc_ctl.transfer_buffer[i], sb_size,
602                                  em28xx_irq_callback, dma_q, 1);
603
604                 urb->number_of_packets = max_packets;
605                 urb->transfer_flags = URB_ISO_ASAP;
606
607                 k = 0;
608                 for (j = 0; j < max_packets; j++) {
609                         urb->iso_frame_desc[j].offset = k;
610                         urb->iso_frame_desc[j].length =
611                                                 dev->isoc_ctl.max_pkt_size;
612                         k += dev->isoc_ctl.max_pkt_size;
613                 }
614         }
615
616         init_waitqueue_head(&dma_q->wq);
617
618         em28xx_capture_start(dev, cap_type);
619
620         /* submit urbs and enables IRQ */
621         for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
622                 rc = usb_submit_urb(dev->isoc_ctl.urb[i], GFP_ATOMIC);
623                 if (rc) {
624                         em28xx_err("submit of urb %i failed (error=%i)\n", i,
625                                    rc);
626                         em28xx_uninit_isoc(dev);
627                         return rc;
628                 }
629         }
630
631         return 0;
632 }
633 EXPORT_SYMBOL_GPL(em28xx_init_isoc);