Commit 70f7a7d6 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] update cpia to match 2.4

parent 16fa5fe8
This diff is collapsed.
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
*/ */
#define CPIA_MAJ_VER 0 #define CPIA_MAJ_VER 0
#define CPIA_MIN_VER 7 #define CPIA_MIN_VER 8
#define CPIA_PATCH_VER 4 #define CPIA_PATCH_VER 1
#define CPIA_PP_MAJ_VER 0 #define CPIA_PP_MAJ_VER 0
#define CPIA_PP_MIN_VER 7 #define CPIA_PP_MIN_VER 8
#define CPIA_PP_PATCH_VER 4 #define CPIA_PP_PATCH_VER 1
#define CPIA_MAX_FRAME_SIZE_UNALIGNED (352 * 288 * 4) /* CIF at RGB32 */ #define CPIA_MAX_FRAME_SIZE_UNALIGNED (352 * 288 * 4) /* CIF at RGB32 */
#define CPIA_MAX_FRAME_SIZE ((CPIA_MAX_FRAME_SIZE_UNALIGNED + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) /* align above to PAGE_SIZE */ #define CPIA_MAX_FRAME_SIZE ((CPIA_MAX_FRAME_SIZE_UNALIGNED + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) /* align above to PAGE_SIZE */
...@@ -204,6 +204,13 @@ struct cam_params { ...@@ -204,6 +204,13 @@ struct cam_params {
u8 subSample; u8 subSample;
u8 yuvOrder; u8 yuvOrder;
} format; } format;
struct { /* Intel QX3 specific data */
u8 qx3_detected; /* a QX3 is present */
u8 toplight; /* top light lit , R/W */
u8 bottomlight; /* bottom light lit, R/W */
u8 button; /* snapshot button pressed (R/O) */
u8 cradled; /* microscope is in cradle (R/O) */
} qx3;
struct { struct {
u8 colStart; /* skip first 8*colStart pixels */ u8 colStart; /* skip first 8*colStart pixels */
u8 colEnd; /* finish at 8*colEnd pixels */ u8 colEnd; /* finish at 8*colEnd pixels */
...@@ -393,29 +400,6 @@ void cpia_unregister_camera(struct cam_data *cam); ...@@ -393,29 +400,6 @@ void cpia_unregister_camera(struct cam_data *cam);
(p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\ (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\
(p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0); (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
#define ADD_TO_LIST(l, drv) \
{\
lock_kernel();\
(drv)->next = l;\
(drv)->previous = &(l);\
(l) = drv;\
unlock_kernel();\
} while(0)
#define REMOVE_FROM_LIST(drv) \
{\
if ((drv)->previous != NULL) {\
lock_kernel();\
if ((drv)->next != NULL)\
(drv)->next->previous = (drv)->previous;\
*((drv)->previous) = (drv)->next;\
(drv)->previous = NULL;\
(drv)->next = NULL;\
unlock_kernel();\
}\
} while (0)
static inline void cpia_add_to_list(struct cam_data* l, struct cam_data* drv) static inline void cpia_add_to_list(struct cam_data* l, struct cam_data* drv)
{ {
drv->next = l; drv->next = l;
...@@ -423,7 +407,6 @@ static inline void cpia_add_to_list(struct cam_data* l, struct cam_data* drv) ...@@ -423,7 +407,6 @@ static inline void cpia_add_to_list(struct cam_data* l, struct cam_data* drv)
l = drv; l = drv;
} }
static inline void cpia_remove_from_list(struct cam_data* drv) static inline void cpia_remove_from_list(struct cam_data* drv)
{ {
if (drv->previous != NULL) { if (drv->previous != NULL) {
...@@ -435,7 +418,6 @@ static inline void cpia_remove_from_list(struct cam_data* drv) ...@@ -435,7 +418,6 @@ static inline void cpia_remove_from_list(struct cam_data* drv)
} }
} }
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* cpia_h */ #endif /* cpia_h */
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Supports CPiA based parallel port Video Camera's. * Supports CPiA based parallel port Video Camera's.
* *
* (C) Copyright 1999 Bas Huisman <bhuism@cs.utwente.nl> * (C) Copyright 1999 Bas Huisman <bhuism@cs.utwente.nl>
* (C) Copyright 1999-2000 Scott J. Bertin <sbertin@mindspring.com>, * (C) Copyright 1999-2000 Scott J. Bertin <sbertin@securenym.net>,
* (C) Copyright 1999-2000 Peter Pregler <Peter_Pregler@email.com> * (C) Copyright 1999-2000 Peter Pregler <Peter_Pregler@email.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -341,17 +341,6 @@ static int cpia_pp_streamStop(void *privdata) ...@@ -341,17 +341,6 @@ static int cpia_pp_streamStop(void *privdata)
return 0; return 0;
} }
static int cpia_pp_read(struct parport *port, u8 *buffer, int len)
{
int bytes_read, new_bytes;
for(bytes_read=0; bytes_read<len; bytes_read += new_bytes) {
new_bytes = parport_read(port, buffer+bytes_read,
len-bytes_read);
if(new_bytes < 0) break;
}
return bytes_read;
}
/**************************************************************************** /****************************************************************************
* *
* cpia_pp_streamRead * cpia_pp_streamRead
...@@ -361,7 +350,7 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock) ...@@ -361,7 +350,7 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
{ {
struct pp_cam_entry *cam = privdata; struct pp_cam_entry *cam = privdata;
int read_bytes = 0; int read_bytes = 0;
int i, endseen, block_size, new_bytes; int i, endseen;
if(cam == NULL) { if(cam == NULL) {
DBG("Internal driver error: cam is NULL\n"); DBG("Internal driver error: cam is NULL\n");
...@@ -390,34 +379,24 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock) ...@@ -390,34 +379,24 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
return -EIO; return -EIO;
} }
} }
endseen = 0; read_bytes = parport_read(cam->port, buffer, CPIA_MAX_IMAGE_SIZE );
block_size = PARPORT_CHUNK_SIZE;
while( !cam->image_complete ) {
cond_resched();
new_bytes = cpia_pp_read(cam->port, buffer, block_size ); EndTransferMode(cam);
if( new_bytes <= 0 ) { DBG("read %d bytes\n", read_bytes);
break; if( read_bytes<0) return -EIO;
} endseen = 0;
i=-1; for( i=0; i<read_bytes && endseen<4; i++ ) {
while(++i<new_bytes && endseen<4) { if( *buffer==EOI ) {
if(*buffer==EOI) {
endseen++; endseen++;
} else { } else {
endseen=0; endseen=0;
} }
buffer++; buffer++;
} }
read_bytes += i; if( endseen>3 ) {
if( endseen==4 ) {
cam->image_complete=1; cam->image_complete=1;
break; DBG("endseen at %d bytes\n", i);
}
if( CPIA_MAX_IMAGE_SIZE-read_bytes <= PARPORT_CHUNK_SIZE ) {
block_size=CPIA_MAX_IMAGE_SIZE-read_bytes;
} }
}
EndTransferMode(cam);
return cam->image_complete ? read_bytes : -EIO; return cam->image_complete ? read_bytes : -EIO;
} }
...@@ -716,15 +695,6 @@ void cleanup_module(void) ...@@ -716,15 +695,6 @@ void cleanup_module(void)
static int __init cpia_pp_setup(char *str) static int __init cpia_pp_setup(char *str)
{ {
#if 0
/* Is this only a 2.2ism? -jerdfelt */
if (!str) {
if (ints[0] == 0 || ints[1] == 0) {
/* disable driver on "cpia_pp=" or "cpia_pp=0" */
parport_nr[0] = PPCPIA_PARPORT_OFF;
}
} else
#endif
if (!strncmp(str, "parport", 7)) { if (!strncmp(str, "parport", 7)) {
int n = simple_strtoul(str + 7, NULL, 10); int n = simple_strtoul(str + 7, NULL, 10);
if (parport_ptr < PARPORT_MAX) { if (parport_ptr < PARPORT_MAX) {
......
...@@ -273,14 +273,16 @@ static int cpia_usb_open(void *privdata) ...@@ -273,14 +273,16 @@ static int cpia_usb_open(void *privdata)
error_urb1: /* free urb 1 */ error_urb1: /* free urb 1 */
usb_free_urb(ucpia->sbuf[1].urb); usb_free_urb(ucpia->sbuf[1].urb);
ucpia->sbuf[1].urb = NULL;
error_urb0: /* free urb 0 */ error_urb0: /* free urb 0 */
usb_free_urb(ucpia->sbuf[0].urb); usb_free_urb(ucpia->sbuf[0].urb);
ucpia->sbuf[0].urb = NULL;
error_1: error_1:
kfree (ucpia->sbuf[1].data); kfree (ucpia->sbuf[1].data);
ucpia->sbuf[1].data = NULL;
error_0: error_0:
kfree (ucpia->sbuf[0].data); kfree (ucpia->sbuf[0].data);
ucpia->sbuf[0].data = NULL;
return retval; return retval;
} }
...@@ -636,8 +638,10 @@ static void cpia_disconnect(struct usb_interface *intf) ...@@ -636,8 +638,10 @@ static void cpia_disconnect(struct usb_interface *intf)
ucpia->buffers[0] = NULL; ucpia->buffers[0] = NULL;
} }
if (!ucpia->open) if (!ucpia->open) {
kfree(ucpia); kfree(ucpia);
cam->lowlevel_data = NULL;
}
} }
static int __init usb_cpia_init(void) static int __init usb_cpia_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment