X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fvideo%2Fcpia_pp.c;fp=drivers%2Fmedia%2Fvideo%2Fcpia_pp.c;h=74cff626e044375a467000ae57a64846af4d7e58;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=41f4b8d17559d085eab1f3c6a3bf0f278eb71264;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c index 41f4b8d17..74cff626e 100644 --- a/drivers/media/video/cpia_pp.c +++ b/drivers/media/video/cpia_pp.c @@ -23,8 +23,9 @@ */ /* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ -/* #define _CPIA_DEBUG_ 1 */ +/* #define _CPIA_DEBUG_ 1 */ +#include #include #include @@ -44,7 +45,7 @@ static int cpia_pp_open(void *privdata); static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata), - void *cbdata); + void *cbdata); static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data); static int cpia_pp_streamStart(void *privdata); static int cpia_pp_streamStop(void *privdata); @@ -92,7 +93,7 @@ struct pp_cam_entry { int stream_irq; }; -static struct cpia_camera_ops cpia_pp_ops = +static struct cpia_camera_ops cpia_pp_ops = { cpia_pp_open, cpia_pp_registerCallback, @@ -122,7 +123,7 @@ static void cpia_parport_disable_irq( struct parport *port ) { } /* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility - * Link Flag during negotiation */ + * Link Flag during negotiation */ #define UPLOAD_FLAG 0x08 #define NIBBLE_TRANSFER 0x01 #define ECP_TRANSFER 0x03 @@ -138,17 +139,17 @@ static void cpia_parport_disable_irq( struct parport *port ) { /* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ /* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ -static size_t cpia_read_nibble (struct parport *port, - void *buffer, size_t len, +static size_t cpia_read_nibble (struct parport *port, + void *buffer, size_t len, int flags) { - /* adapted verbatim, with one change, from + /* adapted verbatim, with one change, from parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ unsigned char *buf = buffer; int i; unsigned char byte = 0; - + len *= 2; /* in nibbles */ for (i=0; i < len; i++) { unsigned char nibble; @@ -157,12 +158,12 @@ static size_t cpia_read_nibble (struct parport *port, * after every second nibble to signal that more * data is available. (the total number of Bytes that * should be sent is known; if too few are received, an error - * will be recorded after a timeout). + * will be recorded after a timeout). * This is incompatible with parport_ieee1284_read_nibble(), * which expects to find nFault LO after every second nibble. */ - /* Solution: modify cpia_read_nibble to only check for + /* Solution: modify cpia_read_nibble to only check for * nDataAvail before the first nibble is sent. */ @@ -215,7 +216,7 @@ static size_t cpia_read_nibble (struct parport *port, /* Second nibble */ byte |= nibble << 4; *buf++ = byte; - } else + } else byte = nibble; } @@ -237,18 +238,18 @@ static size_t cpia_read_nibble (struct parport *port, } /* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) - * (See CPiA Data sheet p. 31) - * - * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a - * nonstandard variant of nibble mode which allows the same (mediocre) - * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable + * (See CPiA Data sheet p. 31) + * + * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a + * nonstandard variant of nibble mode which allows the same (mediocre) + * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable * parallel ports, but works also for non-TRISTATE-capable ports. * (Standard nibble mode only send 4 bits per cycle) * */ -static size_t cpia_read_nibble_stream(struct parport *port, - void *buffer, size_t len, +static size_t cpia_read_nibble_stream(struct parport *port, + void *buffer, size_t len, int flags) { int i; @@ -259,7 +260,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, unsigned char nibble[2], byte = 0; int j; - /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ + /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ if (endseen > 3 ) break; @@ -267,7 +268,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, parport_frob_control (port, PARPORT_CONTROL_AUTOFD, PARPORT_CONTROL_AUTOFD); - + /* Event 9: nAck goes low. */ port->ieee1284.phase = IEEE1284_PH_REV_DATA; if (parport_wait_peripheral (port, @@ -281,7 +282,7 @@ static size_t cpia_read_nibble_stream(struct parport *port, /* Read lower nibble */ nibble[0] = parport_read_status (port) >>3; - + /* Event 10: Set nAutoFd high. */ parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); @@ -294,10 +295,10 @@ static size_t cpia_read_nibble_stream(struct parport *port, port->name); break; } - + /* Read upper nibble */ nibble[1] = parport_read_status (port) >>3; - + /* reassemble the byte */ for (j = 0; j < 2 ; j++ ) { nibble[j] &= ~8; @@ -334,8 +335,8 @@ static void EndTransferMode(struct pp_cam_entry *cam) static int ForwardSetup(struct pp_cam_entry *cam) { int retry; - - /* The CPiA uses ECP protocol for Downloads from the Host to the camera. + + /* The CPiA uses ECP protocol for Downloads from the Host to the camera. * This will be software-emulated if ECP hardware is not present */ @@ -374,9 +375,9 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility) upload_mode = mode; if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; - /* the usual camera maximum response time is 10ms, but after + /* the usual camera maximum response time is 10ms, but after * receiving some commands, it needs up to 40ms. */ - + for(retry = 0; retry < 4; ++retry) { if(!parport_negotiate(cam->port, mode)) { break; @@ -438,10 +439,10 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size) /* support for CPiA variant nibble reads */ if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { - if(cpia_read_nibble(cam->port, packet, size, 0) != size) - retval = -EIO; + if(cpia_read_nibble(cam->port, packet, size, 0) != size) + retval = -EIO; } else { - if(parport_read(cam->port, packet, size) != size) + if(parport_read(cam->port, packet, size) != size) retval = -EIO; } EndTransferMode(cam); @@ -541,18 +542,18 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock) block_size = PARPORT_CHUNK_SIZE; while( !cam->image_complete ) { cond_resched(); - + new_bytes = cpia_pp_read(cam->port, buffer, block_size ); if( new_bytes <= 0 ) { break; } i=-1; while(++iopen_count == 0) { if (parport_claim(cam->pdev)) { DBG("failed to claim the port\n"); @@ -644,12 +645,12 @@ static int cpia_pp_open(void *privdata) parport_write_control(cam->port, PARPORT_CONTROL_SELECT); udelay(50); parport_write_control(cam->port, - PARPORT_CONTROL_SELECT - | PARPORT_CONTROL_INIT); + PARPORT_CONTROL_SELECT + | PARPORT_CONTROL_INIT); } - + ++cam->open_count; - + return 0; } @@ -662,7 +663,7 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo { struct pp_cam_entry *cam = privdata; int retval = 0; - + if(cam->port->irq != PARPORT_IRQ_NONE) { INIT_WORK(&cam->cb_task, cb, cbdata); } else { @@ -706,9 +707,9 @@ static int cpia_pp_register(struct parport *port) LOG("failed to allocate camera structure\n"); return -ENOMEM; } - + pdev = parport_register_device(port, "cpia_pp", NULL, NULL, - NULL, 0, cam); + NULL, 0, cam); if (!pdev) { LOG("failed to parport_register_device\n"); @@ -752,19 +753,19 @@ static void cpia_pp_detach (struct parport *port) } cpia = NULL; } - spin_unlock( &cam_list_lock_pp ); + spin_unlock( &cam_list_lock_pp ); if (!cpia) { DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); return; } - - cam = (struct pp_cam_entry *) cpia->lowlevel_data; + + cam = (struct pp_cam_entry *) cpia->lowlevel_data; cpia_unregister_camera(cpia); - if(cam->open_count > 0) + if(cam->open_count > 0) cpia_pp_close(cam); parport_unregister_device(cam->pdev); - cpia->lowlevel_data = NULL; + cpia->lowlevel_data = NULL; kfree(cam); } @@ -802,16 +803,16 @@ static struct parport_driver cpia_pp_driver = { .detach = cpia_pp_detach, }; -static int cpia_pp_init(void) +int cpia_pp_init(void) { - printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, + printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER); if(parport_nr[0] == PPCPIA_PARPORT_OFF) { printk(" disabled\n"); return 0; } - + spin_lock_init( &cam_list_lock_pp ); if (parport_register_driver (&cpia_pp_driver)) { @@ -859,8 +860,6 @@ void cleanup_module(void) static int __init cpia_pp_setup(char *str) { - int err; - if (!strncmp(str, "parport", 7)) { int n = simple_strtoul(str + 7, NULL, 10); if (parport_ptr < PARPORT_MAX) { @@ -874,11 +873,7 @@ static int __init cpia_pp_setup(char *str) parport_nr[parport_ptr++] = PPCPIA_PARPORT_NONE; } - err=cpia_pp_init(); - if (err) - return err; - - return 1; + return 0; } __setup("cpia_pp=", cpia_pp_setup);