diff options
Diffstat (limited to 'drivers/media/video/cpia_pp.c')
-rw-r--r-- | drivers/media/video/cpia_pp.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c index 74cff626e044..3021f21aae36 100644 --- a/drivers/media/video/cpia_pp.c +++ b/drivers/media/video/cpia_pp.c | |||
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ | 25 | /* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ |
26 | /* #define _CPIA_DEBUG_ 1 */ | 26 | /* #define _CPIA_DEBUG_ 1 */ |
27 | 27 | ||
28 | #include <linux/config.h> | 28 | #include <linux/config.h> |
29 | 29 | ||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | static int cpia_pp_open(void *privdata); | 46 | static int cpia_pp_open(void *privdata); |
47 | static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata), | 47 | static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata), |
48 | void *cbdata); | 48 | void *cbdata); |
49 | static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data); | 49 | static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data); |
50 | static int cpia_pp_streamStart(void *privdata); | 50 | static int cpia_pp_streamStart(void *privdata); |
51 | static int cpia_pp_streamStop(void *privdata); | 51 | static int cpia_pp_streamStop(void *privdata); |
@@ -93,7 +93,7 @@ struct pp_cam_entry { | |||
93 | int stream_irq; | 93 | int stream_irq; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | static struct cpia_camera_ops cpia_pp_ops = | 96 | static struct cpia_camera_ops cpia_pp_ops = |
97 | { | 97 | { |
98 | cpia_pp_open, | 98 | cpia_pp_open, |
99 | cpia_pp_registerCallback, | 99 | cpia_pp_registerCallback, |
@@ -123,7 +123,7 @@ static void cpia_parport_disable_irq( struct parport *port ) { | |||
123 | } | 123 | } |
124 | 124 | ||
125 | /* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility | 125 | /* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility |
126 | * Link Flag during negotiation */ | 126 | * Link Flag during negotiation */ |
127 | #define UPLOAD_FLAG 0x08 | 127 | #define UPLOAD_FLAG 0x08 |
128 | #define NIBBLE_TRANSFER 0x01 | 128 | #define NIBBLE_TRANSFER 0x01 |
129 | #define ECP_TRANSFER 0x03 | 129 | #define ECP_TRANSFER 0x03 |
@@ -139,17 +139,17 @@ static void cpia_parport_disable_irq( struct parport *port ) { | |||
139 | /* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ | 139 | /* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ |
140 | /* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ | 140 | /* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ |
141 | 141 | ||
142 | static size_t cpia_read_nibble (struct parport *port, | 142 | static size_t cpia_read_nibble (struct parport *port, |
143 | void *buffer, size_t len, | 143 | void *buffer, size_t len, |
144 | int flags) | 144 | int flags) |
145 | { | 145 | { |
146 | /* adapted verbatim, with one change, from | 146 | /* adapted verbatim, with one change, from |
147 | parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ | 147 | parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ |
148 | 148 | ||
149 | unsigned char *buf = buffer; | 149 | unsigned char *buf = buffer; |
150 | int i; | 150 | int i; |
151 | unsigned char byte = 0; | 151 | unsigned char byte = 0; |
152 | 152 | ||
153 | len *= 2; /* in nibbles */ | 153 | len *= 2; /* in nibbles */ |
154 | for (i=0; i < len; i++) { | 154 | for (i=0; i < len; i++) { |
155 | unsigned char nibble; | 155 | unsigned char nibble; |
@@ -158,12 +158,12 @@ static size_t cpia_read_nibble (struct parport *port, | |||
158 | * after every second nibble to signal that more | 158 | * after every second nibble to signal that more |
159 | * data is available. (the total number of Bytes that | 159 | * data is available. (the total number of Bytes that |
160 | * should be sent is known; if too few are received, an error | 160 | * should be sent is known; if too few are received, an error |
161 | * will be recorded after a timeout). | 161 | * will be recorded after a timeout). |
162 | * This is incompatible with parport_ieee1284_read_nibble(), | 162 | * This is incompatible with parport_ieee1284_read_nibble(), |
163 | * which expects to find nFault LO after every second nibble. | 163 | * which expects to find nFault LO after every second nibble. |
164 | */ | 164 | */ |
165 | 165 | ||
166 | /* Solution: modify cpia_read_nibble to only check for | 166 | /* Solution: modify cpia_read_nibble to only check for |
167 | * nDataAvail before the first nibble is sent. | 167 | * nDataAvail before the first nibble is sent. |
168 | */ | 168 | */ |
169 | 169 | ||
@@ -216,7 +216,7 @@ static size_t cpia_read_nibble (struct parport *port, | |||
216 | /* Second nibble */ | 216 | /* Second nibble */ |
217 | byte |= nibble << 4; | 217 | byte |= nibble << 4; |
218 | *buf++ = byte; | 218 | *buf++ = byte; |
219 | } else | 219 | } else |
220 | byte = nibble; | 220 | byte = nibble; |
221 | } | 221 | } |
222 | 222 | ||
@@ -238,18 +238,18 @@ static size_t cpia_read_nibble (struct parport *port, | |||
238 | } | 238 | } |
239 | 239 | ||
240 | /* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) | 240 | /* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) |
241 | * (See CPiA Data sheet p. 31) | 241 | * (See CPiA Data sheet p. 31) |
242 | * | 242 | * |
243 | * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a | 243 | * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a |
244 | * nonstandard variant of nibble mode which allows the same (mediocre) | 244 | * nonstandard variant of nibble mode which allows the same (mediocre) |
245 | * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable | 245 | * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable |
246 | * parallel ports, but works also for non-TRISTATE-capable ports. | 246 | * parallel ports, but works also for non-TRISTATE-capable ports. |
247 | * (Standard nibble mode only send 4 bits per cycle) | 247 | * (Standard nibble mode only send 4 bits per cycle) |
248 | * | 248 | * |
249 | */ | 249 | */ |
250 | 250 | ||
251 | static size_t cpia_read_nibble_stream(struct parport *port, | 251 | static size_t cpia_read_nibble_stream(struct parport *port, |
252 | void *buffer, size_t len, | 252 | void *buffer, size_t len, |
253 | int flags) | 253 | int flags) |
254 | { | 254 | { |
255 | int i; | 255 | int i; |
@@ -260,7 +260,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, | |||
260 | unsigned char nibble[2], byte = 0; | 260 | unsigned char nibble[2], byte = 0; |
261 | int j; | 261 | int j; |
262 | 262 | ||
263 | /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ | 263 | /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ |
264 | if (endseen > 3 ) | 264 | if (endseen > 3 ) |
265 | break; | 265 | break; |
266 | 266 | ||
@@ -268,7 +268,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, | |||
268 | parport_frob_control (port, | 268 | parport_frob_control (port, |
269 | PARPORT_CONTROL_AUTOFD, | 269 | PARPORT_CONTROL_AUTOFD, |
270 | PARPORT_CONTROL_AUTOFD); | 270 | PARPORT_CONTROL_AUTOFD); |
271 | 271 | ||
272 | /* Event 9: nAck goes low. */ | 272 | /* Event 9: nAck goes low. */ |
273 | port->ieee1284.phase = IEEE1284_PH_REV_DATA; | 273 | port->ieee1284.phase = IEEE1284_PH_REV_DATA; |
274 | if (parport_wait_peripheral (port, | 274 | if (parport_wait_peripheral (port, |
@@ -282,7 +282,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, | |||
282 | 282 | ||
283 | /* Read lower nibble */ | 283 | /* Read lower nibble */ |
284 | nibble[0] = parport_read_status (port) >>3; | 284 | nibble[0] = parport_read_status (port) >>3; |
285 | 285 | ||
286 | /* Event 10: Set nAutoFd high. */ | 286 | /* Event 10: Set nAutoFd high. */ |
287 | parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); | 287 | parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); |
288 | 288 | ||
@@ -295,10 +295,10 @@ static size_t cpia_read_nibble_stream(struct parport *port, | |||
295 | port->name); | 295 | port->name); |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | 298 | ||
299 | /* Read upper nibble */ | 299 | /* Read upper nibble */ |
300 | nibble[1] = parport_read_status (port) >>3; | 300 | nibble[1] = parport_read_status (port) >>3; |
301 | 301 | ||
302 | /* reassemble the byte */ | 302 | /* reassemble the byte */ |
303 | for (j = 0; j < 2 ; j++ ) { | 303 | for (j = 0; j < 2 ; j++ ) { |
304 | nibble[j] &= ~8; | 304 | nibble[j] &= ~8; |
@@ -335,8 +335,8 @@ static void EndTransferMode(struct pp_cam_entry *cam) | |||
335 | static int ForwardSetup(struct pp_cam_entry *cam) | 335 | static int ForwardSetup(struct pp_cam_entry *cam) |
336 | { | 336 | { |
337 | int retry; | 337 | int retry; |
338 | 338 | ||
339 | /* The CPiA uses ECP protocol for Downloads from the Host to the camera. | 339 | /* The CPiA uses ECP protocol for Downloads from the Host to the camera. |
340 | * This will be software-emulated if ECP hardware is not present | 340 | * This will be software-emulated if ECP hardware is not present |
341 | */ | 341 | */ |
342 | 342 | ||
@@ -375,9 +375,9 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility) | |||
375 | upload_mode = mode; | 375 | upload_mode = mode; |
376 | if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; | 376 | if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; |
377 | 377 | ||
378 | /* the usual camera maximum response time is 10ms, but after | 378 | /* the usual camera maximum response time is 10ms, but after |
379 | * receiving some commands, it needs up to 40ms. */ | 379 | * receiving some commands, it needs up to 40ms. */ |
380 | 380 | ||
381 | for(retry = 0; retry < 4; ++retry) { | 381 | for(retry = 0; retry < 4; ++retry) { |
382 | if(!parport_negotiate(cam->port, mode)) { | 382 | if(!parport_negotiate(cam->port, mode)) { |
383 | break; | 383 | break; |
@@ -439,10 +439,10 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size) | |||
439 | 439 | ||
440 | /* support for CPiA variant nibble reads */ | 440 | /* support for CPiA variant nibble reads */ |
441 | if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { | 441 | if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { |
442 | if(cpia_read_nibble(cam->port, packet, size, 0) != size) | 442 | if(cpia_read_nibble(cam->port, packet, size, 0) != size) |
443 | retval = -EIO; | 443 | retval = -EIO; |
444 | } else { | 444 | } else { |
445 | if(parport_read(cam->port, packet, size) != size) | 445 | if(parport_read(cam->port, packet, size) != size) |
446 | retval = -EIO; | 446 | retval = -EIO; |
447 | } | 447 | } |
448 | EndTransferMode(cam); | 448 | EndTransferMode(cam); |
@@ -542,18 +542,18 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock) | |||
542 | block_size = PARPORT_CHUNK_SIZE; | 542 | block_size = PARPORT_CHUNK_SIZE; |
543 | while( !cam->image_complete ) { | 543 | while( !cam->image_complete ) { |
544 | cond_resched(); | 544 | cond_resched(); |
545 | 545 | ||
546 | new_bytes = cpia_pp_read(cam->port, buffer, block_size ); | 546 | new_bytes = cpia_pp_read(cam->port, buffer, block_size ); |
547 | if( new_bytes <= 0 ) { | 547 | if( new_bytes <= 0 ) { |
548 | break; | 548 | break; |
549 | } | 549 | } |
550 | i=-1; | 550 | i=-1; |
551 | while(++i<new_bytes && endseen<4) { | 551 | while(++i<new_bytes && endseen<4) { |
552 | if(*buffer==EOI) { | 552 | if(*buffer==EOI) { |
553 | endseen++; | 553 | endseen++; |
554 | } else { | 554 | } else { |
555 | endseen=0; | 555 | endseen=0; |
556 | } | 556 | } |
557 | buffer++; | 557 | buffer++; |
558 | } | 558 | } |
559 | read_bytes += i; | 559 | read_bytes += i; |
@@ -601,7 +601,7 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data) | |||
601 | } | 601 | } |
602 | if((err = ReadPacket(cam, buffer, 8)) < 0) { | 602 | if((err = ReadPacket(cam, buffer, 8)) < 0) { |
603 | DBG("Error reading command result\n"); | 603 | DBG("Error reading command result\n"); |
604 | return err; | 604 | return err; |
605 | } | 605 | } |
606 | memcpy(data, buffer, databytes); | 606 | memcpy(data, buffer, databytes); |
607 | } else if(command[0] == DATA_OUT) { | 607 | } else if(command[0] == DATA_OUT) { |
@@ -631,10 +631,10 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data) | |||
631 | static int cpia_pp_open(void *privdata) | 631 | static int cpia_pp_open(void *privdata) |
632 | { | 632 | { |
633 | struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata; | 633 | struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata; |
634 | 634 | ||
635 | if (cam == NULL) | 635 | if (cam == NULL) |
636 | return -EINVAL; | 636 | return -EINVAL; |
637 | 637 | ||
638 | if(cam->open_count == 0) { | 638 | if(cam->open_count == 0) { |
639 | if (parport_claim(cam->pdev)) { | 639 | if (parport_claim(cam->pdev)) { |
640 | DBG("failed to claim the port\n"); | 640 | DBG("failed to claim the port\n"); |
@@ -645,12 +645,12 @@ static int cpia_pp_open(void *privdata) | |||
645 | parport_write_control(cam->port, PARPORT_CONTROL_SELECT); | 645 | parport_write_control(cam->port, PARPORT_CONTROL_SELECT); |
646 | udelay(50); | 646 | udelay(50); |
647 | parport_write_control(cam->port, | 647 | parport_write_control(cam->port, |
648 | PARPORT_CONTROL_SELECT | 648 | PARPORT_CONTROL_SELECT |
649 | | PARPORT_CONTROL_INIT); | 649 | | PARPORT_CONTROL_INIT); |
650 | } | 650 | } |
651 | 651 | ||
652 | ++cam->open_count; | 652 | ++cam->open_count; |
653 | 653 | ||
654 | return 0; | 654 | return 0; |
655 | } | 655 | } |
656 | 656 | ||
@@ -663,7 +663,7 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo | |||
663 | { | 663 | { |
664 | struct pp_cam_entry *cam = privdata; | 664 | struct pp_cam_entry *cam = privdata; |
665 | int retval = 0; | 665 | int retval = 0; |
666 | 666 | ||
667 | if(cam->port->irq != PARPORT_IRQ_NONE) { | 667 | if(cam->port->irq != PARPORT_IRQ_NONE) { |
668 | INIT_WORK(&cam->cb_task, cb, cbdata); | 668 | INIT_WORK(&cam->cb_task, cb, cbdata); |
669 | } else { | 669 | } else { |
@@ -707,9 +707,9 @@ static int cpia_pp_register(struct parport *port) | |||
707 | LOG("failed to allocate camera structure\n"); | 707 | LOG("failed to allocate camera structure\n"); |
708 | return -ENOMEM; | 708 | return -ENOMEM; |
709 | } | 709 | } |
710 | 710 | ||
711 | pdev = parport_register_device(port, "cpia_pp", NULL, NULL, | 711 | pdev = parport_register_device(port, "cpia_pp", NULL, NULL, |
712 | NULL, 0, cam); | 712 | NULL, 0, cam); |
713 | 713 | ||
714 | if (!pdev) { | 714 | if (!pdev) { |
715 | LOG("failed to parport_register_device\n"); | 715 | LOG("failed to parport_register_device\n"); |
@@ -753,19 +753,19 @@ static void cpia_pp_detach (struct parport *port) | |||
753 | } | 753 | } |
754 | cpia = NULL; | 754 | cpia = NULL; |
755 | } | 755 | } |
756 | spin_unlock( &cam_list_lock_pp ); | 756 | spin_unlock( &cam_list_lock_pp ); |
757 | 757 | ||
758 | if (!cpia) { | 758 | if (!cpia) { |
759 | DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); | 759 | DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); |
760 | return; | 760 | return; |
761 | } | 761 | } |
762 | 762 | ||
763 | cam = (struct pp_cam_entry *) cpia->lowlevel_data; | 763 | cam = (struct pp_cam_entry *) cpia->lowlevel_data; |
764 | cpia_unregister_camera(cpia); | 764 | cpia_unregister_camera(cpia); |
765 | if(cam->open_count > 0) | 765 | if(cam->open_count > 0) |
766 | cpia_pp_close(cam); | 766 | cpia_pp_close(cam); |
767 | parport_unregister_device(cam->pdev); | 767 | parport_unregister_device(cam->pdev); |
768 | cpia->lowlevel_data = NULL; | 768 | cpia->lowlevel_data = NULL; |
769 | kfree(cam); | 769 | kfree(cam); |
770 | } | 770 | } |
771 | 771 | ||
@@ -805,14 +805,14 @@ static struct parport_driver cpia_pp_driver = { | |||
805 | 805 | ||
806 | int cpia_pp_init(void) | 806 | int cpia_pp_init(void) |
807 | { | 807 | { |
808 | printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, | 808 | printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, |
809 | CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER); | 809 | CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER); |
810 | 810 | ||
811 | if(parport_nr[0] == PPCPIA_PARPORT_OFF) { | 811 | if(parport_nr[0] == PPCPIA_PARPORT_OFF) { |
812 | printk(" disabled\n"); | 812 | printk(" disabled\n"); |
813 | return 0; | 813 | return 0; |
814 | } | 814 | } |
815 | 815 | ||
816 | spin_lock_init( &cam_list_lock_pp ); | 816 | spin_lock_init( &cam_list_lock_pp ); |
817 | 817 | ||
818 | if (parport_register_driver (&cpia_pp_driver)) { | 818 | if (parport_register_driver (&cpia_pp_driver)) { |