aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cpia_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cpia_usb.c')
-rw-r--r--drivers/media/video/cpia_usb.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 03275c37c5d3..9c49a4b00116 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -22,7 +22,7 @@
22 */ 22 */
23 23
24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ 24/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
25/* #define _CPIA_DEBUG_ 1 */ 25/* #define _CPIA_DEBUG_ 1 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -85,7 +85,7 @@ struct usb_cpia {
85 85
86static int cpia_usb_open(void *privdata); 86static int cpia_usb_open(void *privdata);
87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata), 87static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata),
88 void *cbdata); 88 void *cbdata);
89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data); 89static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data);
90static int cpia_usb_streamStart(void *privdata); 90static int cpia_usb_streamStart(void *privdata);
91static int cpia_usb_streamStop(void *privdata); 91static int cpia_usb_streamStop(void *privdata);
@@ -127,7 +127,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
127 ucpia->workbuff->status = FRAME_READING; 127 ucpia->workbuff->status = FRAME_READING;
128 ucpia->workbuff->length = 0; 128 ucpia->workbuff->length = 0;
129 } 129 }
130 130
131 for (i = 0; i < urb->number_of_packets; i++) { 131 for (i = 0; i < urb->number_of_packets; i++) {
132 int n = urb->iso_frame_desc[i].actual_length; 132 int n = urb->iso_frame_desc[i].actual_length;
133 int st = urb->iso_frame_desc[i].status; 133 int st = urb->iso_frame_desc[i].status;
@@ -141,9 +141,9 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n); 141 printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n);
142 return; 142 return;
143 } 143 }
144 144
145 if (n) { 145 if (n) {
146 if ((ucpia->workbuff->length > 0) || 146 if ((ucpia->workbuff->length > 0) ||
147 (0x19 == cdata[0] && 0x68 == cdata[1])) { 147 (0x19 == cdata[0] && 0x68 == cdata[1])) {
148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n); 148 memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n);
149 ucpia->workbuff->length += n; 149 ucpia->workbuff->length += n;
@@ -160,7 +160,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
160 ucpia->workbuff = ucpia->workbuff->next; 160 ucpia->workbuff = ucpia->workbuff->next;
161 ucpia->workbuff->status = FRAME_EMPTY; 161 ucpia->workbuff->status = FRAME_EMPTY;
162 ucpia->workbuff->length = 0; 162 ucpia->workbuff->length = 0;
163 163
164 if (waitqueue_active(&ucpia->wq_stream)) 164 if (waitqueue_active(&ucpia->wq_stream))
165 wake_up_interruptible(&ucpia->wq_stream); 165 wake_up_interruptible(&ucpia->wq_stream);
166 } 166 }
@@ -178,7 +178,7 @@ static int cpia_usb_open(void *privdata)
178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata; 178 struct usb_cpia *ucpia = (struct usb_cpia *) privdata;
179 struct urb *urb; 179 struct urb *urb;
180 int ret, retval = 0, fx, err; 180 int ret, retval = 0, fx, err;
181 181
182 if (!ucpia) 182 if (!ucpia)
183 return -EINVAL; 183 return -EINVAL;
184 184
@@ -191,7 +191,7 @@ static int cpia_usb_open(void *privdata)
191 retval = -EINVAL; 191 retval = -EINVAL;
192 goto error_0; 192 goto error_0;
193 } 193 }
194 194
195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3); 195 ret = usb_set_interface(ucpia->dev, ucpia->iface, 3);
196 if (ret < 0) { 196 if (ret < 0) {
197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret); 197 printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret);
@@ -286,7 +286,7 @@ error_1:
286error_0: 286error_0:
287 kfree (ucpia->sbuf[0].data); 287 kfree (ucpia->sbuf[0].data);
288 ucpia->sbuf[0].data = NULL; 288 ucpia->sbuf[0].data = NULL;
289 289
290 return retval; 290 return retval;
291} 291}
292 292
@@ -307,7 +307,7 @@ static int WritePacket(struct usb_device *udev, const u8 *packet, u8 *buf, size_
307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 307 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
308 packet[1] + (packet[0] << 8), 308 packet[1] + (packet[0] << 8),
309 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 309 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
310 packet[2] + (packet[3] << 8), 310 packet[2] + (packet[3] << 8),
311 packet[4] + (packet[5] << 8), buf, size, 1000); 311 packet[4] + (packet[5] << 8), buf, size, 1000);
312} 312}
313 313
@@ -324,7 +324,7 @@ static int ReadPacket(struct usb_device *udev, u8 *packet, u8 *buf, size_t size)
324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 324 return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
325 packet[1] + (packet[0] << 8), 325 packet[1] + (packet[0] << 8),
326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 326 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
327 packet[2] + (packet[3] << 8), 327 packet[2] + (packet[3] << 8),
328 packet[4] + (packet[5] << 8), buf, size, 1000); 328 packet[4] + (packet[5] << 8), buf, size, 1000);
329} 329}
330 330
@@ -393,7 +393,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
393 393
394 if (!ucpia || !ucpia->present) 394 if (!ucpia || !ucpia->present)
395 return -1; 395 return -1;
396 396
397 if (ucpia->curbuff->status != FRAME_READY) 397 if (ucpia->curbuff->status != FRAME_READY)
398 interruptible_sleep_on(&ucpia->wq_stream); 398 interruptible_sleep_on(&ucpia->wq_stream);
399 else 399 else
@@ -403,7 +403,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
403 403
404 if (!mybuff) 404 if (!mybuff)
405 return -1; 405 return -1;
406 406
407 if (mybuff->status != FRAME_READY || mybuff->length < 4) { 407 if (mybuff->status != FRAME_READY || mybuff->length < 4) {
408 DBG("Something went wrong!\n"); 408 DBG("Something went wrong!\n");
409 return -1; 409 return -1;
@@ -411,7 +411,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
411 411
412 memcpy(frame, mybuff->data, mybuff->length); 412 memcpy(frame, mybuff->data, mybuff->length);
413 mybuff->status = FRAME_EMPTY; 413 mybuff->status = FRAME_EMPTY;
414 414
415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */ 415/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */
416/* mybuff->length, frame[0], frame[1], */ 416/* mybuff->length, frame[0], frame[1], */
417/* frame[mybuff->length-4], frame[mybuff->length-3], */ 417/* frame[mybuff->length-4], frame[mybuff->length-3], */
@@ -447,7 +447,7 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
447 447
448 kfree(ucpia->sbuf[1].data); 448 kfree(ucpia->sbuf[1].data);
449 ucpia->sbuf[1].data = NULL; 449 ucpia->sbuf[1].data = NULL;
450 450
451 if (ucpia->sbuf[0].urb) { 451 if (ucpia->sbuf[0].urb) {
452 usb_kill_urb(ucpia->sbuf[0].urb); 452 usb_kill_urb(ucpia->sbuf[0].urb);
453 usb_free_urb(ucpia->sbuf[0].urb); 453 usb_free_urb(ucpia->sbuf[0].urb);
@@ -490,7 +490,7 @@ static int cpia_probe(struct usb_interface *intf,
490 struct usb_cpia *ucpia; 490 struct usb_cpia *ucpia;
491 struct cam_data *cam; 491 struct cam_data *cam;
492 int ret; 492 int ret;
493 493
494 /* A multi-config CPiA camera? */ 494 /* A multi-config CPiA camera? */
495 if (udev->descriptor.bNumConfigurations != 1) 495 if (udev->descriptor.bNumConfigurations != 1)
496 return -ENODEV; 496 return -ENODEV;
@@ -539,7 +539,7 @@ static int cpia_probe(struct usb_interface *intf,
539 539
540 /* Before register_camera, important */ 540 /* Before register_camera, important */
541 ucpia->present = 1; 541 ucpia->present = 1;
542 542
543 cam = cpia_register_camera(&cpia_usb_ops, ucpia); 543 cam = cpia_register_camera(&cpia_usb_ops, ucpia);
544 if (!cam) { 544 if (!cam) {
545 LOG("failed to cpia_register_camera\n"); 545 LOG("failed to cpia_register_camera\n");
@@ -591,7 +591,7 @@ static void cpia_disconnect(struct usb_interface *intf)
591 struct cam_data *cam = usb_get_intfdata(intf); 591 struct cam_data *cam = usb_get_intfdata(intf);
592 struct usb_cpia *ucpia; 592 struct usb_cpia *ucpia;
593 struct usb_device *udev; 593 struct usb_device *udev;
594 594
595 usb_set_intfdata(intf, NULL); 595 usb_set_intfdata(intf, NULL);
596 if (!cam) 596 if (!cam)
597 return; 597 return;
@@ -600,7 +600,7 @@ static void cpia_disconnect(struct usb_interface *intf)
600 spin_lock( &cam_list_lock_usb ); 600 spin_lock( &cam_list_lock_usb );
601 list_del(&cam->cam_data_list); 601 list_del(&cam->cam_data_list);
602 spin_unlock( &cam_list_lock_usb ); 602 spin_unlock( &cam_list_lock_usb );
603 603
604 ucpia->present = 0; 604 ucpia->present = 0;
605 605
606 cpia_unregister_camera(cam); 606 cpia_unregister_camera(cam);
@@ -631,7 +631,7 @@ static void cpia_disconnect(struct usb_interface *intf)
631 631
632static int __init usb_cpia_init(void) 632static int __init usb_cpia_init(void)
633{ 633{
634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, 634 printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER); 635 CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER);
636 636
637 spin_lock_init(&cam_list_lock_usb); 637 spin_lock_init(&cam_list_lock_usb);