aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-core.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 77f64900717..a742a57d397 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -77,12 +77,12 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78 0x0000, reg, buf, len, HZ); 78 0x0000, reg, buf, len, HZ);
79 79
80 if (reg_debug){ 80 if (reg_debug) {
81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); 81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret);
82 for (byte = 0; byte < len; byte++) { 82 for (byte = 0; byte < len; byte++)
83 printk(" %02x", (unsigned char)buf[byte]); 83 printk(KERN_INFO " %02x", (unsigned char)buf[byte]);
84 } 84
85 printk("\n"); 85 printk(KERN_INFO "\n");
86 } 86 }
87 87
88 return ret; 88 return ret;
@@ -143,8 +143,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
143 if (reg_debug) { 143 if (reg_debug) {
144 int i; 144 int i;
145 for (i = 0; i < len; ++i) 145 for (i = 0; i < len; ++i)
146 printk (" %02x", (unsigned char)buf[i]); 146 printk(KERN_INFO " %02x", (unsigned char)buf[i]);
147 printk ("\n"); 147 printk(KERN_INFO "\n");
148 } 148 }
149 149
150 if (!bufs) 150 if (!bufs)
@@ -173,8 +173,12 @@ static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
173{ 173{
174 int oldval; 174 int oldval;
175 u8 newval; 175 u8 newval;
176 if ((oldval = em28xx_read_reg(dev, reg)) < 0) 176
177 oldval = em28xx_read_reg(dev, reg);
178
179 if (oldval < 0)
177 return oldval; 180 return oldval;
181
178 newval = (((u8) oldval) & ~bitmask) | (val & bitmask); 182 newval = (((u8) oldval) & ~bitmask) | (val & bitmask);
179 return em28xx_write_regs(dev, reg, &newval, 1); 183 return em28xx_write_regs(dev, reg, &newval, 1);
180} 184}
@@ -187,20 +191,26 @@ static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
187{ 191{
188 int ret, i; 192 int ret, i;
189 u8 addr = reg & 0x7f; 193 u8 addr = reg & 0x7f;
190 if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) 194
195 ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2);
196 if (ret < 0)
191 return ret; 197 return ret;
192 if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) 198
199 ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1);
200 if (ret < 0)
193 return ret; 201 return ret;
194 202
195 /* Wait up to 50 ms for AC97 command to complete */ 203 /* Wait up to 50 ms for AC97 command to complete */
196 for (i = 0; i < 10; i++) { 204 for (i = 0; i < 10; i++) {
197 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) 205 ret = em28xx_read_reg(dev, AC97BUSY_REG);
206 if (ret < 0)
198 return ret; 207 return ret;
208
199 if (!(ret & 0x01)) 209 if (!(ret & 0x01))
200 return 0; 210 return 0;
201 msleep(5); 211 msleep(5);
202 } 212 }
203 em28xx_warn ("AC97 command still being executed: not handled properly!\n"); 213 em28xx_warn("AC97 command still being executed: not handled properly!\n");
204 return 0; 214 return 0;
205} 215}
206 216
@@ -338,11 +348,11 @@ int em28xx_capture_start(struct em28xx *dev, int start)
338 rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); 348 rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
339 349
340 if (dev->mode == EM28XX_ANALOG_MODE) 350 if (dev->mode == EM28XX_ANALOG_MODE)
341 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x67", 1); 351 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x67", 1);
342 else 352 else
343 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x37", 1); 353 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x37", 1);
344 354
345 msleep (6); 355 msleep(6);
346 356
347 return rc; 357 return rc;
348} 358}
@@ -357,7 +367,8 @@ int em28xx_outfmt_set_yuv422(struct em28xx *dev)
357static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, 367static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
358 u8 ymin, u8 ymax) 368 u8 ymin, u8 ymax)
359{ 369{
360 em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax); 370 em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n",
371 xmin, ymin, xmax, ymax);
361 372
362 em28xx_write_regs(dev, XMIN_REG, &xmin, 1); 373 em28xx_write_regs(dev, XMIN_REG, &xmin, 1);
363 em28xx_write_regs(dev, XMAX_REG, &xmax, 1); 374 em28xx_write_regs(dev, XMAX_REG, &xmax, 1);
@@ -372,7 +383,8 @@ static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
372 u8 cheight = height; 383 u8 cheight = height;
373 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); 384 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
374 385
375 em28xx_coredbg("em28xx Area Set: (%d,%d)\n", (width | (overflow & 2) << 7), 386 em28xx_coredbg("em28xx Area Set: (%d,%d)\n",
387 (width | (overflow & 2) << 7),
376 (height | (overflow & 1) << 8)); 388 (height | (overflow & 1) << 8));
377 389
378 em28xx_write_regs(dev, HSTART_REG, &hstart, 1); 390 em28xx_write_regs(dev, HSTART_REG, &hstart, 1);
@@ -386,7 +398,7 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
386{ 398{
387 u8 mode; 399 u8 mode;
388 /* the em2800 scaler only supports scaling down to 50% */ 400 /* the em2800 scaler only supports scaling down to 50% */
389 if(dev->is_em2800) 401 if (dev->is_em2800)
390 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00); 402 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
391 else { 403 else {
392 u8 buf[2]; 404 u8 buf[2];
@@ -396,7 +408,8 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
396 buf[0] = v; 408 buf[0] = v;
397 buf[1] = v >> 8; 409 buf[1] = v >> 8;
398 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2); 410 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2);
399 /* it seems that both H and V scalers must be active to work correctly */ 411 /* it seems that both H and V scalers must be active
412 to work correctly */
400 mode = (h || v)? 0x30: 0x00; 413 mode = (h || v)? 0x30: 0x00;
401 } 414 }
402 return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30); 415 return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30);
@@ -449,7 +462,7 @@ int em28xx_set_alternate(struct em28xx *dev)
449 dev->alt, dev->max_pkt_size); 462 dev->alt, dev->max_pkt_size);
450 errCode = usb_set_interface(dev->udev, 0, dev->alt); 463 errCode = usb_set_interface(dev->udev, 0, dev->alt);
451 if (errCode < 0) { 464 if (errCode < 0) {
452 em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", 465 em28xx_errdev("cannot change alternate number to %d (error=%i)\n",
453 dev->alt, errCode); 466 dev->alt, errCode);
454 return errCode; 467 return errCode;
455 } 468 }
@@ -507,9 +520,9 @@ void em28xx_uninit_isoc(struct em28xx *dev)
507 usb_unlink_urb(urb); 520 usb_unlink_urb(urb);
508 if (dev->isoc_ctl.transfer_buffer[i]) { 521 if (dev->isoc_ctl.transfer_buffer[i]) {
509 usb_buffer_free(dev->udev, 522 usb_buffer_free(dev->udev,
510 urb->transfer_buffer_length, 523 urb->transfer_buffer_length,
511 dev->isoc_ctl.transfer_buffer[i], 524 dev->isoc_ctl.transfer_buffer[i],
512 urb->transfer_dma); 525 urb->transfer_dma);
513 } 526 }
514 usb_free_urb(urb); 527 usb_free_urb(urb);
515 dev->isoc_ctl.urb[i] = NULL; 528 dev->isoc_ctl.urb[i] = NULL;
@@ -596,7 +609,9 @@ int em28xx_init_isoc(struct em28xx *dev, int max_packets,
596 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK' 609 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK'
597 should also be using 'desc.bInterval' 610 should also be using 'desc.bInterval'
598 */ 611 */
599 pipe = usb_rcvisocpipe(dev->udev, cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84); 612 pipe = usb_rcvisocpipe(dev->udev,
613 cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84);
614
600 usb_fill_int_urb(urb, dev->udev, pipe, 615 usb_fill_int_urb(urb, dev->udev, pipe,
601 dev->isoc_ctl.transfer_buffer[i], sb_size, 616 dev->isoc_ctl.transfer_buffer[i], sb_size,
602 em28xx_irq_callback, dma_q, 1); 617 em28xx_irq_callback, dma_q, 1);