ChangeSet 1.893.2.14, 2002/12/24 11:56:06-08:00, spse@secret.org.uk

[PATCH] 2.4.20 usbvideo cleanups 3/4

This is a backport of some usbvideo cleanups from 2.5:

typedef struct { .. } RingQueue_t -> struct RingQueue
typedef struct { .. } usbvideo_sbuf_t -> struct usbvideo_sbuf
typedef struct { .. } usbvideo_frame_t -> struct usbvideo_frame
typedef struct { .. } usbvideo_statistics_t -> struct usbvideo_statistics
typedef struct { .. } usbvideo_cb_t -> struct usbvideo_cb


diff -Nru a/drivers/usb/ibmcam.c b/drivers/usb/ibmcam.c
--- a/drivers/usb/ibmcam.c	Mon Jan  6 11:30:56 2003
+++ b/drivers/usb/ibmcam.c	Mon Jan  6 11:30:56 2003
@@ -251,7 +251,7 @@
  */
 static ParseState_t ibmcam_find_header(struct uvd *uvd) /* FIXME: Add frame here */
 {
-	usbvideo_frame_t *frame;
+	struct usbvideo_frame *frame;
 	ibmcam_t *icam;
 
 	if ((uvd->curframe) < 0 || (uvd->curframe >= USBVIDEO_NUMFRAMES)) {
@@ -399,7 +399,7 @@
  */
 static ParseState_t ibmcam_parse_lines(
 	struct uvd *uvd,
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	long *pcopylen)
 {
 	unsigned char *f;
@@ -664,7 +664,7 @@
  */
 static ParseState_t ibmcam_model2_320x240_parse_lines(
 	struct uvd *uvd,
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	long *pcopylen)
 {
 	unsigned char *f, *la, *lb;
@@ -818,7 +818,7 @@
 
 static ParseState_t ibmcam_model3_parse_lines(
 	struct uvd *uvd,
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	long *pcopylen)
 {
 	unsigned char *data;
@@ -963,7 +963,7 @@
  */
 static ParseState_t ibmcam_model4_128x96_parse_lines(
 	struct uvd *uvd,
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	long *pcopylen)
 {
 	const unsigned char *data_rv, *data_gv, *data_bv;
@@ -1049,7 +1049,7 @@
  * History:
  * 1/21/00  Created.
  */
-void ibmcam_ProcessIsocData(struct uvd *uvd, usbvideo_frame_t *frame)
+void ibmcam_ProcessIsocData(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	ParseState_t newstate;
 	long copylen = 0;
@@ -3910,7 +3910,7 @@
  */
 static int __init ibmcam_init(void)
 {
-	usbvideo_cb_t cbTbl;
+	struct usbvideo_cb cbTbl;
 	memset(&cbTbl, 0, sizeof(cbTbl));
 	cbTbl.probe = ibmcam_probe;
 	cbTbl.setupOnOpen = ibmcam_setup_on_open;
diff -Nru a/drivers/usb/ultracam.c b/drivers/usb/ultracam.c
--- a/drivers/usb/ultracam.c	Mon Jan  6 11:30:56 2003
+++ b/drivers/usb/ultracam.c	Mon Jan  6 11:30:56 2003
@@ -103,7 +103,7 @@
  * 02-Nov-2000 First (mostly dummy) version.
  * 06-Nov-2000 Rewrote to dump all data into frame.
  */
-void ultracam_ProcessIsocData(struct uvd *uvd, usbvideo_frame_t *frame)
+void ultracam_ProcessIsocData(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	int n;
 
@@ -666,7 +666,7 @@
  */
 static int __init ultracam_init(void)
 {
-	usbvideo_cb_t cbTbl;
+	struct usbvideo_cb cbTbl;
 	memset(&cbTbl, 0, sizeof(cbTbl));
 	cbTbl.probe = ultracam_probe;
 	cbTbl.setupOnOpen = ultracam_setup_on_open;
diff -Nru a/drivers/usb/usbvideo.c b/drivers/usb/usbvideo.c
--- a/drivers/usb/usbvideo.c	Mon Jan  6 11:30:56 2003
+++ b/drivers/usb/usbvideo.c	Mon Jan  6 11:30:56 2003
@@ -109,13 +109,13 @@
 	vfree(mem);
 }
 
-void RingQueue_Initialize(RingQueue_t *rq)
+void RingQueue_Initialize(struct RingQueue *rq)
 {
 	assert(rq != NULL);
 	init_waitqueue_head(&rq->wqh);
 }
 
-void RingQueue_Allocate(RingQueue_t *rq, int rqLen)
+void RingQueue_Allocate(struct RingQueue *rq, int rqLen)
 {
 	assert(rq != NULL);
 	assert(rqLen > 0);
@@ -124,14 +124,14 @@
 	assert(rq->queue != NULL);
 }
 
-int RingQueue_IsAllocated(const RingQueue_t *rq)
+int RingQueue_IsAllocated(const struct RingQueue *rq)
 {
 	if (rq == NULL)
 		return 0;
 	return (rq->queue != NULL) && (rq->length > 0);
 }
 
-void RingQueue_Free(RingQueue_t *rq)
+void RingQueue_Free(struct RingQueue *rq)
 {
 	assert(rq != NULL);
 	if (RingQueue_IsAllocated(rq)) {
@@ -141,7 +141,7 @@
 	}
 }
 
-int RingQueue_Dequeue(RingQueue_t *rq, unsigned char *dst, int len)
+int RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len)
 {
 	int i;
 	assert(rq != NULL);
@@ -153,7 +153,7 @@
 	return len;
 }
 
-int RingQueue_Enqueue(RingQueue_t *rq, const unsigned char *cdata, int n)
+int RingQueue_Enqueue(struct RingQueue *rq, const unsigned char *cdata, int n)
 {
 	int enqueued = 0;
 
@@ -183,7 +183,7 @@
 	return enqueued;
 }
 
-int RingQueue_GetLength(const RingQueue_t *rq)
+int RingQueue_GetLength(const struct RingQueue *rq)
 {
 	int ri, wi;
 
@@ -199,13 +199,13 @@
 		return wi + (rq->length - ri);
 }
 
-void RingQueue_InterruptibleSleepOn(RingQueue_t *rq)
+void RingQueue_InterruptibleSleepOn(struct RingQueue *rq)
 {
 	assert(rq != NULL);
 	interruptible_sleep_on(&rq->wqh);
 }
 
-void RingQueue_WakeUpInterruptible(RingQueue_t *rq)
+void RingQueue_WakeUpInterruptible(struct RingQueue *rq)
 {
 	assert(rq != NULL);
 	if (waitqueue_active(&rq->wqh))
@@ -240,7 +240,7 @@
  * History:
  * 01-Feb-2000 Created.
  */
-void usbvideo_OverlayChar(struct uvd *uvd, usbvideo_frame_t *frame,
+void usbvideo_OverlayChar(struct uvd *uvd, struct usbvideo_frame *frame,
 			  int x, int y, int ch)
 {
 	static const unsigned short digits[16] = {
@@ -295,7 +295,7 @@
  * History:
  * 01-Feb-2000 Created.
  */
-void usbvideo_OverlayString(struct uvd *uvd, usbvideo_frame_t *frame,
+void usbvideo_OverlayString(struct uvd *uvd, struct usbvideo_frame *frame,
 			    int x, int y, const char *str)
 {
 	while (*str) {
@@ -313,7 +313,7 @@
  * History:
  * 01-Feb-2000 Created.
  */
-void usbvideo_OverlayStats(struct uvd *uvd, usbvideo_frame_t *frame)
+void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	const int y_diff = 8;
 	char tmp[16];
@@ -492,7 +492,7 @@
  * purposes.
  */
 void usbvideo_DrawLine(
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	int x1, int y1,
 	int x2, int y2,
 	unsigned char cr, unsigned char cg, unsigned char cb)
@@ -564,7 +564,7 @@
  */
 void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode)
 {
-	usbvideo_frame_t *frame;
+	struct usbvideo_frame *frame;
 	int num_cell = 0;
 	int scan_length = 0;
 	static int num_pass = 0;
@@ -711,7 +711,7 @@
 	const int num_cams,
 	const int num_extra,
 	const char *driverName,
-	const usbvideo_cb_t *cbTbl,
+	const struct usbvideo_cb *cbTbl,
 	struct module *md )
 {
 	usbvideo_t *cams;
@@ -1577,7 +1577,7 @@
 {
 	struct uvd *uvd = (struct uvd *) dev;
 	int frmx = -1;
-	usbvideo_frame_t *frame;
+	struct usbvideo_frame *frame;
 
 	if (!CAMERA_IS_OPERATIONAL(uvd) || (buf == NULL))
 		return -EFAULT;
@@ -1934,7 +1934,7 @@
  */
 int usbvideo_NewFrame(struct uvd *uvd, int framenum)
 {
-	usbvideo_frame_t *frame;
+	struct usbvideo_frame *frame;
 	int n;
 
 	if (uvd->debug > 1)
@@ -2007,7 +2007,7 @@
  * FLAGS_NO_DECODING set. Therefore, any regular build of any driver
  * based on usbvideo can use this feature at any time.
  */
-void usbvideo_CollectRawData(struct uvd *uvd, usbvideo_frame_t *frame)
+void usbvideo_CollectRawData(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	int n;
 
@@ -2039,7 +2039,7 @@
 
 int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
 {
-	usbvideo_frame_t *frame = &uvd->frame[frameNum];
+	struct usbvideo_frame *frame = &uvd->frame[frameNum];
 
 	if (uvd->debug >= 2)
 		info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum);
@@ -2169,7 +2169,7 @@
  * line above then we just copy next line. Similarly, if we need to
  * create a last line then preceding line is used.
  */
-void usbvideo_DeinterlaceFrame(struct uvd *uvd, usbvideo_frame_t *frame)
+void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	if ((uvd == NULL) || (frame == NULL))
 		return;
@@ -2237,7 +2237,7 @@
  * History:
  * 09-Feb-2001  Created.
  */
-void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, usbvideo_frame_t *frame)
+void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, struct usbvideo_frame *frame)
 {
 	int i, j, v4l_linesize;
 	signed long adj;
diff -Nru a/drivers/usb/usbvideo.h b/drivers/usb/usbvideo.h
--- a/drivers/usb/usbvideo.h	Mon Jan  6 11:30:56 2003
+++ b/drivers/usb/usbvideo.h	Mon Jan  6 11:30:56 2003
@@ -117,13 +117,13 @@
 #define	RING_QUEUE_DEQUEUE_BYTES(rq,n) RING_QUEUE_ADVANCE_INDEX(rq,ri,n)
 #define	RING_QUEUE_PEEK(rq,ofs) ((rq)->queue[((ofs) + (rq)->ri) % (rq)->length])
 
-typedef struct {
+struct RingQueue {
 	unsigned char *queue;	/* Data from the Isoc data pump */
 	int length;		/* How many bytes allocated for the queue */
 	int wi;			/* That's where we write */
 	int ri;			/* Read from here until you hit write index */
 	wait_queue_head_t wqh;	/* Processes waiting */
-} RingQueue_t;
+};
 
 typedef enum {
 	ScanState_Scanning,	/* Scanning for header */
@@ -157,18 +157,16 @@
 	Deinterlace_FillEvenLines
 } Deinterlace_t;
 
-struct usb_device;
-
 #define USBVIDEO_NUMFRAMES	2	/* How many frames we work with */
 #define USBVIDEO_NUMSBUF	2	/* How many URBs linked in a ring */
 
 /* This structure represents one Isoc request - URB and buffer */
-typedef struct {
+struct usbvideo_sbuf {
 	char *data;
 	struct urb *urb;
-} usbvideo_sbuf_t;
+};
 
-typedef struct {
+struct usbvideo_frame {
 	char *data;		/* Frame buffer */
 	unsigned long header;	/* Significant bits from the header */
 
@@ -187,10 +185,10 @@
 	long seqRead_Index;	/* Amount of data that has been already read */
 
 	void *user;		/* Additional data that user may need */
-} usbvideo_frame_t;
+};
 
 /* Statistics that can be overlaid on screen */
-typedef struct {
+struct usbvideo_statistics {
         unsigned long frame_num;	/* Sequential number of the frame */
         unsigned long urb_count;        /* How many URBs we received so far */
         unsigned long urb_length;       /* Length of last URB */
@@ -198,7 +196,7 @@
         unsigned long header_count;     /* How many frame headers we found */
 	unsigned long iso_skip_count;	/* How many empty ISO packets received */
 	unsigned long iso_err_count;	/* How many bad ISO packets received */
-} usbvideo_statistics_t;
+};
 
 struct s_usbvideo_t;
 
@@ -235,16 +233,16 @@
 	int curframe;
 	int iso_packet_len;	/* Videomode-dependent, saves bus bandwidth */
 
-	RingQueue_t dp;		/* Isoc data pump */
-	usbvideo_frame_t frame[USBVIDEO_NUMFRAMES];
-	usbvideo_sbuf_t sbuf[USBVIDEO_NUMSBUF];
+	struct RingQueue dp;	/* Isoc data pump */
+	struct usbvideo_frame frame[USBVIDEO_NUMFRAMES];
+	struct usbvideo_sbuf sbuf[USBVIDEO_NUMSBUF];
 
 	volatile int remove_pending;	/* If set then about to exit */
 
 	struct video_picture vpic, vpic_old;	/* Picture settings */
 	struct video_capability vcap;		/* Video capabilities */
 	struct video_channel vchan;	/* May be used for tuner support */
-	usbvideo_statistics_t stats;
+	struct usbvideo_statistics stats;
 	struct proc_dir_entry *procfs_vEntry;	/* /proc/video/MYDRIVER/video2 */
 	char videoName[32];		/* Holds name like "video7" */
 };
@@ -254,29 +252,29 @@
  * services are registered. All of these default to NULL, except those
  * that default to usbvideo-provided methods.
  */
-typedef struct {
+struct usbvideo_cb {
 	void *(*probe)(struct usb_device *, unsigned int,const struct usb_device_id *);
 	void (*userFree)(struct uvd *);
 	void (*disconnect)(struct usb_device *, void *);
 	int (*setupOnOpen)(struct uvd *);
 	void (*videoStart)(struct uvd *);
 	void (*videoStop)(struct uvd *);
-	void (*processData)(struct uvd *, usbvideo_frame_t *);
-	void (*postProcess)(struct uvd *, usbvideo_frame_t *);
+	void (*processData)(struct uvd *, struct usbvideo_frame *);
+	void (*postProcess)(struct uvd *, struct usbvideo_frame *);
 	void (*adjustPicture)(struct uvd *);
 	int (*getFPS)(struct uvd *);
-	int (*overlayHook)(struct uvd *, usbvideo_frame_t *);
+	int (*overlayHook)(struct uvd *, struct usbvideo_frame *);
 	int (*getFrame)(struct uvd *, int);
 	int (*procfs_read)(char *page,char **start,off_t off,int count,int *eof,void *data);
 	int (*procfs_write)(struct file *file,const char *buffer,unsigned long count,void *data);
-} usbvideo_cb_t;
+};
 
 struct s_usbvideo_t {
 	int num_cameras;		/* As allocated */
 	struct usb_driver usbdrv;	/* Interface to the USB stack */
 	char drvName[80];		/* Driver name */
 	struct semaphore lock;		/* Mutex protecting camera structures */
-	usbvideo_cb_t cb;		/* Table of callbacks (virtual methods) */
+	struct usbvideo_cb cb;		/* Table of callbacks (virtual methods) */
 	struct video_device vdt;	/* Video device template */
 	struct uvd *cam;			/* Array of camera structures */
 	int uses_procfs;		/* Non-zero if we create /proc entries */
@@ -302,26 +300,26 @@
 #define	VALID_CALLBACK(uvd,cbName) ((((uvd) != NULL) && \
 		((uvd)->handle != NULL)) ? GET_CALLBACK(uvd,cbName) : NULL)
 
-void RingQueue_Initialize(RingQueue_t *rq);
-void RingQueue_Allocate(RingQueue_t *rq, int rqLen);
-int  RingQueue_IsAllocated(const RingQueue_t *rq);
-void RingQueue_Free(RingQueue_t *rq);
-int  RingQueue_Dequeue(RingQueue_t *rq, unsigned char *dst, int len);
-int  RingQueue_Enqueue(RingQueue_t *rq, const unsigned char *cdata, int n);
-int  RingQueue_GetLength(const RingQueue_t *rq);
-void RingQueue_InterruptibleSleepOn(RingQueue_t *rq);
-void RingQueue_WakeUpInterruptible(RingQueue_t *rq);
+void RingQueue_Initialize(struct RingQueue *rq);
+void RingQueue_Allocate(struct RingQueue *rq, int rqLen);
+int  RingQueue_IsAllocated(const struct RingQueue *rq);
+void RingQueue_Free(struct RingQueue *rq);
+int  RingQueue_Dequeue(struct RingQueue *rq, unsigned char *dst, int len);
+int  RingQueue_Enqueue(struct RingQueue *rq, const unsigned char *cdata, int n);
+int  RingQueue_GetLength(const struct RingQueue *rq);
+void RingQueue_InterruptibleSleepOn(struct RingQueue *rq);
+void RingQueue_WakeUpInterruptible(struct RingQueue *rq);
 
-void usbvideo_CollectRawData(struct uvd *uvd, usbvideo_frame_t *frame);
+void usbvideo_CollectRawData(struct uvd *uvd, struct usbvideo_frame *frame);
 void usbvideo_DrawLine(
-	usbvideo_frame_t *frame,
+	struct usbvideo_frame *frame,
 	int x1, int y1,
 	int x2, int y2,
 	unsigned char cr, unsigned char cg, unsigned char cb);
 void usbvideo_HexDump(const unsigned char *data, int len);
-void usbvideo_OverlayChar(struct uvd *uvd, usbvideo_frame_t *frame, int x, int y, int ch);
-void usbvideo_OverlayString(struct uvd *uvd, usbvideo_frame_t *frame, int x, int y, const char *str);
-void usbvideo_OverlayStats(struct uvd *uvd, usbvideo_frame_t *frame);
+void usbvideo_OverlayChar(struct uvd *uvd, struct usbvideo_frame *frame, int x, int y, int ch);
+void usbvideo_OverlayString(struct uvd *uvd, struct usbvideo_frame *frame, int x, int y, const char *str);
+void usbvideo_OverlayStats(struct uvd *uvd, struct usbvideo_frame *frame);
 void usbvideo_ReportStatistics(const struct uvd *uvd);
 void usbvideo_SayAndWait(const char *what);
 void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode);
@@ -338,7 +336,7 @@
 	const int num_cams,
 	const int num_extra,
 	const char *driverName,
-	const usbvideo_cb_t *cbTable,
+	const struct usbvideo_cb *cbTable,
 	struct module *md);
 struct uvd *usbvideo_AllocateDevice(usbvideo_t *cams);
 int usbvideo_RegisterVideoDevice(struct uvd *uvd);
@@ -360,8 +358,8 @@
 int usbvideo_NewFrame(struct uvd *uvd, int framenum);
 int usbvideo_StartDataPump(struct uvd *uvd);
 void usbvideo_StopDataPump(struct uvd *uvd);
-void usbvideo_DeinterlaceFrame(struct uvd *uvd, usbvideo_frame_t *frame);
-void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, usbvideo_frame_t *frame);
+void usbvideo_DeinterlaceFrame(struct uvd *uvd, struct usbvideo_frame *frame);
+void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, struct usbvideo_frame *frame);
 
 /*
  * This code performs bounds checking - use it when working with
@@ -377,7 +375,7 @@
  * VIDEOSIZE_X(fr->request), total VIDEOSIZE_Y(frame->request) lines.
  */
 static inline void RGB24_PUTPIXEL(
-	usbvideo_frame_t *fr,
+	struct usbvideo_frame *fr,
 	int ix, int iy,
 	unsigned char vr,
 	unsigned char vg,
