Hi everyone.

I have here a patch against usbvideo (as found on the linux-usb cvs 
repository) for webcamgo.

I would like someone having a Webcam Go camera to test this patch and see if 
it generates any data when making a 
cat /dev/video0 > /tmp/videodata

I have not implemented the routines needed to split the video into images 
yet, therefore the data is pretty useless right now, but the biggest problems 
I have had so far is to actually make the camera stream data on the iso pipe.

All feedback is welcome, on the list or directly to me.

Index: Makefile
===================================================================
RCS file: /var/cvsroot/usb/usbvideo/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile    2001/05/03 23:54:33     1.1.1.1
+++ Makefile    2001/05/04 00:10:18     1.2
@@ -42,9 +42,9 @@
 endif
 endif
 
-OBJECTS = ibmcam.o ultracam.o usbvideo.o
+OBJECTS = ibmcam.o ultracam.o webcamgo.o usbvideo.o 
 
-all : ibmdrv.o ultradrv.o
+all : ibmdrv.o ultradrv.o webcamgodrv.o
 
 ibmdrv.o : ibmcam.o usbvideo.o
        $(LD) -r -o $@ $+
@@ -52,6 +52,9 @@
 ultradrv.o : ultracam.o usbvideo.o
        $(LD) -r -o $@ $+
 
+webcamgodrv.o : webcamgo.o usbvideo.o
+       $(LD) -r -o $@ $+
+
 %.o : %.c usbvideo.h
        @echo "--- Compiling $< ---"
        @$(CC) $(CFLAGS) -c -o $@ $<
@@ -59,14 +62,16 @@
 full: clean all
 
 clean:
-       rm -f $(OBJECTS) ibmdrv.o ultradrv.o
+       rm -f $(OBJECTS) ibmdrv.o ultradrv.o webcamgodrv.o
 
 install:
        @install -v -D -o root -g root ibmdrv.o $(MODDIR)
        @install -v -D -o root -g root ultradrv.o $(MODDIR)
+       @install -v -D -o root -g root webcamgodrv.o $(MODDIR)
        depmod -a
 
 uninstall:
        rm -f $(MODDIR)/ibmdrv.o
        rm -f $(MODDIR)/ultradrv.o
+       rm -f $(MODDIR)/webcamgodrv.o
        depmod -a
Index: webcamgo.c
===================================================================
RCS file: webcamgo.c
diff -N webcamgo.c
--- /dev/null   Wed Mar 21 22:55:49 2001
+++ /tmp/cvsxAGn5c      Fri May  4 02:28:29 2001
@@ -0,0 +1,1416 @@
+/* $Id: webcamgo.c,v 1.2 2001/05/04 00:20:50 stni Exp $
+ *
+ * USB Video Blaster Webcam Go Camera driver
+ *
+ * Supports Creative Labs Videoblaster Webcam Go Camera.
+ *
+ * This driver is based on earlier work of:
+ *
+ * (C) Copyright 1999 Johannes Erdfelt
+ * (C) Copyright 1999 Randy Dunlap
+ * + others
+ *
+ * Author: Stefan Nilsen <[EMAIL PROTECTED]>
+ *
+ * The driver is still *very* experimental and only the published specs
+ * by Winbond concerning the USB Camera Chip is facts used when making
+ * this driver. Nothing is known of the actual camera chip used in this
+ * camera.
+ */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/wrapper.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include "usbvideo.h"
+
+#define        WEBCAMGO_VENDOR_ID      0x1046 /* Winbond */
+#define        WEBCAMGO_PRODUCT_ID     0x9967
+
+#define MAX_CAMERAS            4       /* How many devices we allow to connect */
+
+#define JPEG_COMPRESSED        1
+#define PLANAR 1
+// #define YUV420 1
+
+/*
+ * This structure lives in uvd_t->user field.
+ */
+typedef struct {
+       int initialized;        /* Had we already sent init sequence? */
+       int camera_model;       /* What type of camera we got? */
+  int has_hdr;
+       unsigned char controlBuffer[6]; /* To read control transfers into */
+} webcamgo_t;
+#define        WEBCAMGO_T(uvd) ((webcamgo_t *)((uvd)->user_data))
+
+usbvideo_t *cams = NULL;
+
+static int debug = 0;
+
+static int flags = /* 0; */ FLAGS_NO_DECODING; /* FLAGS_DISPLAY_HINTS | 
FLAGS_OVERLAY_STATS; */
+
+static const int min_canvasWidth  = 8;
+static const int min_canvasHeight = 4;
+
+//static int lighting = 1; /* Medium */
+
+#define SHARPNESS_MIN  0
+#define SHARPNESS_MAX  6
+//static int sharpness = 4; /* Low noise, good details */
+
+#define FRAMERATE_MIN  0
+#define FRAMERATE_MAX  6
+static int framerate = -1;
+
+static int webcamgo_resetPipe(uvd_t *uvd);
+
+/*
+ * Here we define several initialization variables. They may
+ * be used to automatically set color, hue, brightness and
+ * contrast to desired values. This is particularly useful in
+ * case of webcams (which have no controls and no on-screen
+ * output) and also when a client V4L software is used that
+ * does not have some of those controls. In any case it's
+ * good to have startup values as options.
+ *
+ * These values are all in [0..255] range. This simplifies
+ * operation. Note that actual values of V4L variables may
+ * be scaled up (as much as << 8). User can see that only
+ * on overlay output, however, or through a V4L client.
+ */
+static int init_brightness = 128;
+static int init_contrast = 192;
+static int init_color = 128;
+static int init_hue = 128;
+static int hue_correction = 128;
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug level: 0-9 (default=0)");
+MODULE_PARM(flags, "i");
+MODULE_PARM_DESC(flags,
+               "Bitfield: 0=VIDIOCSYNC, "
+               "1=B/W, "
+               "2=show hints, "
+               "3=show stats, "
+               "4=test pattern, "
+               "5=separate frames, "
+               "6=clean frames");
+MODULE_PARM(framerate, "i");
+MODULE_PARM_DESC(framerate, "Framerate setting: 0=slowest, 6=fastest 
(default=2)");
+MODULE_PARM(lighting, "i");
+MODULE_PARM_DESC(lighting, "Photosensitivity: 0=bright, 1=medium (default), 
2=low light");
+MODULE_PARM(sharpness, "i");
+MODULE_PARM_DESC(sharpness, "Model1 noise reduction: 0=smooth, 6=sharp 
(default=4)");
+
+MODULE_PARM(init_brightness, "i");
+MODULE_PARM_DESC(init_brightness, "Brightness preconfiguration: 0-255 
(default=128)");
+MODULE_PARM(init_contrast, "i");
+MODULE_PARM_DESC(init_contrast, "Contrast preconfiguration: 0-255 
(default=192)");
+MODULE_PARM(init_color, "i");
+MODULE_PARM_DESC(init_color, "Color preconfiguration: 0-255 (default=128)");
+MODULE_PARM(init_hue, "i");
+MODULE_PARM_DESC(init_hue, "Hue preconfiguration: 0-255 (default=128)");
+MODULE_PARM(hue_correction, "i");
+MODULE_PARM_DESC(hue_correction, "YUV colorspace regulation: 0-255 
(default=128)");
+
+MODULE_AUTHOR ("Stefan Nilsen");
+MODULE_DESCRIPTION ("Creative Video Blaster USB Webcam Go Driver for Linux 
(c) 2001");
+
+/*
+ * webcamgo_ProcessIsocData()
+ *
+ * Generic routine to parse the ring queue data. It employs either
+ * webcamgo_find_header() or webcamgo_parse_lines() to do most
+ * of work.
+ *
+ */
+void webcamgo_ProcessIsocData(uvd_t *uvd, usbvideo_frame_t *frame)
+{
+       int n;
+
+       assert(uvd != NULL);
+       assert(frame != NULL);
+
+#if 1
+       info("in webcamgo_ProcessIsocData");
+       err("in webcamgo_ProcessIsocData");
+#endif
+
+       /* Try to move data from queue into frame buffer */
+       n = RingQueue_GetLength(&uvd->dp);
+       if (n > 0) {
+               int m;
+               /* See how much spare we have left */
+               m = uvd->max_frame_size - frame->seqRead_Length;
+               if (n > m)
+                       n = m;
+               /* Now move that much data into frame buffer */
+               RingQueue_Dequeue(
+                       &uvd->dp,
+                       frame->data + frame->seqRead_Length,
+                       m);
+               frame->seqRead_Length += m;
+       }
+       /* See if we filled the frame */
+       if (frame->seqRead_Length >= uvd->max_frame_size) {
+               frame->frameState = FrameState_Done;
+               uvd->curframe = -1;
+               uvd->stats.frame_num++;
+       }
+}
+
+/*
+ * webcamgo_veio()
+ *
+ * History:
+ * 1/27/00  Added check for dev == NULL; this happens if camera is unplugged.
+ */
+static int webcamgo_veio(
+       uvd_t *uvd,
+       unsigned char req,
+       unsigned short value,
+       unsigned short index,
+       int is_out)
+{
+       static const char proc[] = "webcamgo_veio";
+       webcamgo_t *webcamgo;
+       int i;
+
+       if (!CAMERA_IS_OPERATIONAL(uvd))
+               return 0;
+       webcamgo = WEBCAMGO_T(uvd);
+       if (webcamgo == NULL) {
+               err("webcamgo_veio: webcamgo == NULL");
+               return 0;
+       }
+       if (!is_out) {
+               i = usb_control_msg(
+                       uvd->dev,
+                       usb_rcvctrlpipe(uvd->dev, 0),
+                       req,
+                       USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+                       value,
+                       index,
+                       webcamgo->controlBuffer,
+                       2,
+                       HZ);
+#if 1
+               info("USB => %02x%02x "
+                       "(req=$%02x val=$%04x ind=$%04x)",
+                       webcamgo->controlBuffer[0],
+                       webcamgo->controlBuffer[1],
+                       req, value, index);
+#endif
+       } else {
+               i = usb_control_msg(
+                       uvd->dev,
+                       usb_sndctrlpipe(uvd->dev, 0),
+                       req,
+                       USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+                       value,
+                       index,
+                       NULL,
+                       0,
+                       HZ);
+       }
+       if (i < 0) {
+               err("%s: ERROR=%d. Camera stopped; Reconnect or reload driver.",
+                   proc, i);
+               uvd->last_error = i;
+       }
+       return i;
+}
+
+/*
+ * webcamgo_veio_buff()
+ * as above but uses data in 6 byte buffer
+ *
+ * History:
+ * 1/27/00  Added check for dev == NULL; this happens if camera is unplugged.
+ */
+static int webcamgo_veio_buff(
+       uvd_t *uvd,
+       unsigned char req,
+       unsigned short value,
+       unsigned short index,
+       int is_out)
+{
+       static const char proc[] = "webcamgo_veio";
+       webcamgo_t *webcamgo;
+       int i;
+
+       if (!CAMERA_IS_OPERATIONAL(uvd))
+               return 0;
+       webcamgo = WEBCAMGO_T(uvd);
+       if (webcamgo == NULL) {
+               err("webcamgo_veio: webcamgo == NULL");
+               return 0;
+       }
+       if (!is_out) {
+               i = usb_control_msg(
+                       uvd->dev,
+                       usb_rcvctrlpipe(uvd->dev, 0),
+                       req,
+                       USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+                       value,
+                       index,
+                       webcamgo->controlBuffer,
+                       sizeof(webcamgo->controlBuffer),
+                       HZ);
+#if 1
+               info("USB => %02x%02x "
+                       "(req=$%02x val=$%04x ind=$%04x)",
+                       webcamgo->controlBuffer[0],
+                       webcamgo->controlBuffer[1],
+                       req, value, index);
+#endif
+       } else {
+#if 1
+               info("USB => %02x %02x %02x %02x %02x %02x "
+                       "(req=$%02x val=$%04x ind=$%04x)",
+                       webcamgo->controlBuffer[0],
+                       webcamgo->controlBuffer[1],
+                       webcamgo->controlBuffer[2],
+                       webcamgo->controlBuffer[3],
+                       webcamgo->controlBuffer[4],
+                       webcamgo->controlBuffer[5],
+                       req, value, index);
+#endif
+               i = usb_control_msg(
+                       uvd->dev,
+                       usb_sndctrlpipe(uvd->dev, 0),
+                       req,
+                       USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+                       value,
+                       index,
+                       webcamgo->controlBuffer,
+                       6,
+                       HZ);
+       }
+       if (i < 0) {
+               err("%s: ERROR=%d. Camera stopped; Reconnect or reload driver.",
+                   proc, i);
+               uvd->last_error = i;
+       }
+       return i;
+}
+
+/*
+ * webcamgo_calculate_fps()
+ */
+static int webcamgo_calculate_fps(uvd_t *uvd)
+{
+       return 3 + framerate*4 + framerate/2;
+}
+
+/*
+ * webcamgo_adjust_contrast()
+ */
+static void webcamgo_adjust_contrast(uvd_t *uvd)
+{
+}
+
+/*
+ * webcamgo_change_lighting_conditions()
+ */
+static void webcamgo_change_lighting_conditions(uvd_t *uvd)
+{
+}
+
+/*
+ * webcamgo_set_sharpness()
+ *
+ * Cameras model 1 have internal smoothing feature. It is controlled by 
value in
+ * range [0..6], where 0 is most smooth and 6 is most sharp (raw image, I 
guess).
+ * Recommended value is 4. Cameras model 2 do not have this feature at all.
+ */
+static void webcamgo_set_sharpness(uvd_t *uvd)
+{
+}
+
+/*
+ * webcamgo_set_brightness()
+ *
+ * This procedure changes brightness of the picture.
+ */
+static void webcamgo_set_brightness(uvd_t *uvd)
+{
+}
+
+static void webcamgo_set_hue(uvd_t *uvd)
+{
+}
+
+/*
+ * webcamgo_adjust_picture()
+ *
+ * This procedure gets called from V4L interface to update picture settings.
+ * Here we change brightness and contrast.
+ */
+static void webcamgo_adjust_picture(uvd_t *uvd)
+{
+       webcamgo_adjust_contrast(uvd);
+       webcamgo_set_brightness(uvd);
+       webcamgo_set_hue(uvd);
+}
+
+/*
+ * webcamgo_video_stop()
+ *
+ * This code tells camera to stop streaming. The interface remains
+ * configured and bandwidth - claimed.
+ */
+static void webcamgo_video_stop(uvd_t *uvd)
+{
+}
+
+/*
+ * webcamgo_reinit_iso()
+ *
+ * This procedure sends couple of commands to the camera and then
+ * resets the video pipe. This sequence was observed to reinit the
+ * camera or, at least, to initiate ISO data stream.
+ */
+static void webcamgo_reinit_iso(uvd_t *uvd, int do_stop)
+{
+}
+
+static void webcamgo_video_start(uvd_t *uvd)
+{
+       webcamgo_change_lighting_conditions(uvd);
+       webcamgo_set_sharpness(uvd);
+       webcamgo_reinit_iso(uvd, 0);
+}
+
+static int webcamgo_resetPipe(uvd_t *uvd)
+{
+       usb_clear_halt(uvd->dev, uvd->video_endp);
+       return 0;
+}
+
+static int webcamgo_alternateSetting(uvd_t *uvd, int setting)
+{
+       static const char proc[] = "webcamgo_alternateSetting";
+       int i;
+       i = usb_set_interface(uvd->dev, uvd->iface, setting);
+       if (i < 0) {
+               err("%s: usb_set_interface error", proc);
+               uvd->last_error = i;
+               return -EBUSY;
+       }
+       return 0;
+}
+
+/*
+ * Return negative code on failure, 0 on success.
+ */
+static int webcamgo_setup_on_open(uvd_t *uvd)
+{
+       int setup_ok = 0; /* Success by default */
+       webcamgo_t *webcamgo;
+       int i;
+       /* Send init sequence only once, it's large! */
+       if (!WEBCAMGO_T(uvd)->initialized) {
+
+               webcamgo = WEBCAMGO_T(uvd);
+               uvd->flags = uvd->flags | FLAGS_NO_DECODING;            
+
+               webcamgo_alternateSetting(uvd, 0x00); /* Maybe don't need this */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0); /* Read the control reg. 
+Dont 
know why... 
+                                                                                      
+                                                                                      
+                           Result should be 0xff00 if camera was unpowered 
before */
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1); /* Power On, Disable 
+Suspend */      
        
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0); /* Read the control reg. 
+Dont 
know why... Result 0x0300 */
+               webcamgo_veio(uvd, 0x00, 0x0310, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x8000, 0x16, 1);
+               webcamgo_veio(uvd, 0x00, 0xff00, 0x00, 1); /* Power Off, Enable 
+Suspend */
+               webcamgo_veio(uvd, 0x00, 0x0300, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x16, 1);
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1); /* Power On, Disable 
+Suspend */
+               webcamgo_veio(uvd, 0x00, 0x0310, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0300, 0x01, 1);
+               /* Now the camera led should lite up, and a beep is heard */
+
+               webcamgo->controlBuffer[0] = 0xff;
+               webcamgo->controlBuffer[1] = 0xff;
+               webcamgo->controlBuffer[2] = 0xff;
+               webcamgo->controlBuffer[3] = 0xff;
+               webcamgo->controlBuffer[4] = 0xff;
+               webcamgo->controlBuffer[5] = 0xff;
+               webcamgo_veio_buff(uvd, 0x00, 0xffff, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0023, 0x01, 1); /* Start FSB (400KHz bit 
frequency) */
+               
+               /* Read index 0x0000. Result should be 0xbf10 */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0); /* Read the control reg. 
+Dont 
know why... */
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1);
+
+               webcamgo_veio(uvd, 0x00, 0x1000, 0x20, 1); /* Capture Y Frame Buffer 0 
Start Address [15:0] */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x21, 1); /* Capture Y Frame Buffer 0 
Start Address [20:16] */
+               webcamgo_veio(uvd, 0x00, 0x0010, 0x39, 1); /* JPEG Clock Enable */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x16, 1); /* Video Capture Init(?) */
+               webcamgo_veio(uvd, 0x00, 0x0a05, 0x3c, 1); /* USB FIFO Enable and 
Threshold Register */
+
+               /* Read index 0x0000. Result should be 0xbf10 */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0); /* Read the control reg. 
+Dont 
know why... */
+
+               webcamgo_veio(uvd, 0x00, 0xbf12, 0x00, 1); /* Toggle bit 1. Makes FIFO 
Reset */
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1); /* See above */
+
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3e, 1); /* ISO Transfer Size 
+[20:16] */
+               webcamgo_veio(uvd, 0x00, 0x0010, 0x3d, 1); /* ISO Transfer Size [15:0] 
+*/
+
+               webcamgo_veio(uvd, 0x00, 0x0a05, 0x3c, 1); /* USB FIFO Enable and 
Threshold Register */
+
+               webcamgo_alternateSetting(uvd, 0x0e); 
+
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x5d2f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               webcamgo->controlBuffer[0] = 0x74;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0xd2;
+               webcamgo->controlBuffer[3] = 0x21;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               webcamgo->controlBuffer[0] = 0xff;
+               webcamgo->controlBuffer[1] = 0xff;
+               webcamgo->controlBuffer[2] = 0xff;
+               webcamgo->controlBuffer[3] = 0xff;
+               webcamgo->controlBuffer[4] = 0xff;
+               webcamgo->controlBuffer[5] = 0xff;
+               webcamgo_veio_buff(uvd, 0x00, 0xaaaa, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               webcamgo_resetPipe(uvd);
+
+               /* Get current frame number
+                        Add some frames (16?)  to that number and submit two ISO urbs 
+                        with 0x20 frames, and 0x00bf frame size
+                        Store/show the result in the message log
+                        I dont know the reason for getting this data. 
+               */
+
+               /* TODO: abort_pipe */
+               webcamgo_resetPipe(uvd); /* Should be abort instead. Do this after we 
+have 
recieved the two urb's */
+
+               webcamgo_alternateSetting(uvd, 0x00); 
+
+               /* Clear USB Isochronous transfer size high[20:16] (bits 4-0, 15-5 is 
reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3e, 1);
+               /* Clear USB Isochronous transfer size low[15:0] */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3d, 1);
+               /* USB FIFO Enable and Threshold Register. Clear */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3c, 1);
+               /* Capture Y Frame Buffer 0 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x20, 1);
+               /* JPEG Clock Enable */
+               webcamgo_veio(uvd, 0x00, 0x0010, 0x39, 1);
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x16, 1); /* Video Capture Init */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0); /* Check data in serial bus 
control reg. Why??? */
+               /* assert(wtmp == 0x032f); */
+               webcamgo_veio(uvd, 0x00, 0x032f, 0x01, 1); /* Write the value back. 
+Why??? 
*/
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0); /* Read the control reg. 
+Dont 
know why... */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0); /* Read the control reg. 
+Dont 
know why... */
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1); /* Write the value back. 
+Why??? 
*/
+
+               /* ------------ Loop 1  ------------------- */  
+#ifdef JPEG_COMPRESSED 
+               webcamgo_veio(uvd, 0x00, 0x0010, 0x39, 1); /* JPEG Clock Enable */
+#endif
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x74;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0xd2;
+               webcamgo->controlBuffer[3] = 0x21;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x821d, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x74;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x821d, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20; /* URB 66 */
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0xd2;
+               webcamgo->controlBuffer[3] = 0x21;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x821d, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20; /* URB 69 */
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0xd2;
+               webcamgo->controlBuffer[3] = 0x75;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x875d, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               /* ... */
+
+               /* URB 278-281 Setting cropping window */
+               webcamgo_veio(uvd, 0x00, 0x00b4, 0x10, 1); /* Crop Window Start X */
+               webcamgo_veio(uvd, 0x00, 0x0334, 0x12, 1); /* Crop Window End X */
+               webcamgo_veio(uvd, 0x00, 0x0024, 0x11, 1); /* Crop Window Start Y */
+               webcamgo_veio(uvd, 0x00, 0x0204, 0x13, 1); /* Crop Window End Y */
+
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x21;
+               webcamgo->controlBuffer[1] = 0x1d;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0xd208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x21;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0xd208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               /* ... */
+
+               /* URB 292-293 Setting cropping window */
+               webcamgo_veio(uvd, 0x00, 0x0160, 0x10, 1); /* Crop Window Start X */
+               webcamgo_veio(uvd, 0x00, 0x03e0, 0x12, 1); /* Crop Window End X */
+
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x74;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0xd2;
+               webcamgo->controlBuffer[3] = 0x75;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x20;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               /* ... */
+
+               /* URB 309-340 Setting JPEG Luminance Quantization Table */
+               webcamgo_veio(uvd, 0x00, 0x0506, 0x40, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0705, 0x41, 1); 
+               webcamgo_veio(uvd, 0x00, 0x110a, 0x42, 1); 
+               webcamgo_veio(uvd, 0x00, 0x1916, 0x43, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0505, 0x44, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0806, 0x45, 1); 
+               webcamgo_veio(uvd, 0x00, 0x190b, 0x46, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0506, 0x47, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0506, 0x48, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0506, 0x49, 1); 
+               /* ... */
+               webcamgo_veio(uvd, 0x00, 0x0506, 0x5f, 1); 
+
+               /* URB 341-373 Setting JPEG Chrominance Quantization Table */
+               webcamgo_veio(uvd, 0x00, 0x0808, 0x60, 1); 
+               webcamgo_veio(uvd, 0x00, 0x140a, 0x61, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x62, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x63, 1); 
+               webcamgo_veio(uvd, 0x00, 0x0908, 0x64, 1); 
+               webcamgo_veio(uvd, 0x00, 0x1c11, 0x65, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x66, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x67, 1); 
+               webcamgo_veio(uvd, 0x00, 0x110a, 0x68, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a18, 0x69, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x6a, 1); 
+               webcamgo_veio(uvd, 0x00, 0x2a2a, 0x6b, 1); 
+               webcamgo_veio(uvd, 0x00, 0x1c14, 0x6c, 1); 
+               for (i=0x6d; i<=0x7f; ++i) {
+                       webcamgo_veio(uvd, 0x00, 0x2a2a, i, 1); 
+               }
+
+               /* URB 374-397 Send data down FSB */
+               webcamgo->controlBuffer[0] = 0x87;
+               webcamgo->controlBuffer[1] = 0x20;
+               webcamgo->controlBuffer[2] = 0x08;
+               webcamgo->controlBuffer[3] = 0xd2;
+               webcamgo->controlBuffer[4] = 0x21;
+               webcamgo->controlBuffer[5] = 0x1d;
+               webcamgo_veio_buff(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x75;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x20;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0x00;
+               webcamgo_veio_buff(uvd, 0x00, 0xd208, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+               webcamgo->controlBuffer[0] = 0x75;
+               webcamgo->controlBuffer[1] = 0x08;
+               webcamgo->controlBuffer[2] = 0x82;
+               webcamgo->controlBuffer[3] = 0x74;
+               webcamgo->controlBuffer[4] = 0x1d;
+               webcamgo->controlBuffer[5] = 0xfe;
+               webcamgo_veio_buff(uvd, 0x00, 0xd748, 0x06, 1); /* Program data to be 
+sent 
on fast serial bus (FSB) */
+
+               /* ... */
+
+               webcamgo_veio(uvd, 0x00, 0x4a5d, 0x03, 1); /* URB 398  Set DRAM 
+Timings */
+
+               webcamgo_veio(uvd, 0x00, 0x0140, 0x14, 1); /* Captured Video Width 
+(320 
pix) */
+               webcamgo_veio(uvd, 0x00, 0x00f0, 0x15, 1); /* Captured Video Height 
+(240 
pix) */                 
+               webcamgo_veio(uvd, 0x00, 0x10ab, 0x16, 1); /* YUV4:2:0 Planar mode. 
+Enable 
1-2-1 filter. 
+                                                                                      
+                                                                                      
+                           Clamp Video data to CCIR-601. Double buffer.  */           
+     
+               webcamgo_veio(uvd, 0x00, 0x1000, 0x20, 1); /* Capture Y Frame Buffer 0 
Start Address Low Register */
+               
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x21, 1); /* Capture Y Frame Buffer 0 
Start Address 
+                                                                                      
+                                                                                      
+                           High Register[20:16] (bits 4-0, 15-5 is reserved) */
+               /* Capture Y Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0x0100, 0x22, 1);
+
+               /* Capture Y Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x23, 1);      
+
+               /* Capture U Frame Buffer 0 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xa600, 0x24, 1);
+
+               /* Capture U Frame Buffer 0 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x25, 1);
+               
+               /* Capture U Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0x9700, 0x26, 1);      
+
+               /* Capture U Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x27, 1);
+
+               /* Capture V Frame Buffer 0 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xcb80, 0x28, 1);      
+
+               /* Capture V Frame Buffer 0 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x29, 1);
+
+               /* Capture V Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xbc80, 0x2a, 1);      
+
+               /* Capture V Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x2b, 1);
+
+               /* Capture Y Frame Buffer Stride */
+               webcamgo_veio(uvd, 0x00, 0x00a0, 0x2c, 1);      
+
+               /* Capture UV Frame Buffer Stride */
+               webcamgo_veio(uvd, 0x00, 0x0050, 0x2d, 1);
+
+               /* JPEG Maximum Width (320 pix) */
+               webcamgo_veio(uvd, 0x00, 0x0140, 0x30, 1);
+
+               /* JPEG Maximum Height (240 pix) */
+               webcamgo_veio(uvd, 0x00, 0x00f0, 0x31, 1);
+
+               /* JPEG Compressed bitstream buffer 0 low address */
+               webcamgo_veio(uvd, 0x00, 0xe200, 0x32, 1);
+
+               /* JPEG Compressed bitstream buffer 0 high address */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x33, 1);
+
+               /* JPEG Compressed bitstream buffer 1 low address */
+               webcamgo_veio(uvd, 0x00, 0xc300, 0x34, 1);
+
+               /* JPEG Compressed bitstream buffer 1 high address */
+               webcamgo_veio(uvd, 0x00, 0x0002, 0x35, 1);
+
+               /* JPEG Restart interval (0 = disable) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x36, 1);
+
+               /* JPEG VLE FIFO Threshold */
+               webcamgo_veio(uvd, 0x00, 0x0804, 0x37, 1);
+               
+               /* JPEG Vertical Upscaling Control (Disable) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x38, 1);
+
+#ifdef JPEG_COMPRESSED 
+               /* JPEG Enable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0013, 0x39, 1);     /* URB 285 */
+#else
+               /* JPEG Disable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0011, 0x39, 1);     /* URB 285 */
+#endif
+
+               /* USB FIFO Enable and Threshold Register. Clear */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3c, 1);
+
+               /* Set USB Isochronous transfer size low[15:0] . 57600 byte */
+               webcamgo_veio(uvd, 0x00, 0xe100, 0x3d, 1);
+       
+               /* Set USB Isochronous transfer size high[20:16] (bits 4-0, 15-5 is 
reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3e, 1);
+
+               /* Start the fast serial bus. Data in reg 6-9 above is sent with 
+400KHz 
bit frequency (2.5 us bit time) */
+               webcamgo_veio(uvd, 0x00, 0x0023, 0x01, 1);
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d21, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0874, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x7482, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x001d, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d75, 0x09, 1); /* Rev bytes? */
+
+               /* Stop the fast serial bus. Data in reg 6-9 above is sent with 400KHz 
+bit 
frequency (2.5 us bit time) */
+               do { /* Wait for 0x030f */
+                       webcamgo_veio(uvd, 0x00, 0x0002, 0x01, 1);
+                       webcamgo_veio(uvd, 0x00, 0x0003, 0x01, 1);
+
+                       webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0);
+                       webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0);
+               } while ( (webcamgo->controlBuffer[0] != 0x0f) || 
(webcamgo->controlBuffer[1] != 0x03) );
+               webcamgo_veio(uvd, 0x00, 0x0002, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0003, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0023, 0x01, 1);
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d21, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0874, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x7482, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x001d, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0820, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x2082, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xfe1d, 0x09, 1); /* Rev bytes? */
+
+               /* Select Interface 0, altsetting 0x07 */
+               webcamgo_alternateSetting(uvd, 0x03); 
+
+               /* JPEG Vertical Upscaling Control (Disable) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x38, 1);
+
+#ifdef JPEG_COMPRESSED 
+               /* JPEG Enable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0013, 0x39, 1);     /* URB 285 */
+#else
+               /* JPEG Disable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0011, 0x39, 1);     /* URB 285 */
+#endif
+               
+               /* YUV4:2:0 Planar mode. Enable 1-2-1 filter. Clamp Video data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90ab, 0x16, 1);
+               
+               /* USB FIFO Enable and Threshold Register. Enable iso pipe*/
+               webcamgo_veio(uvd, 0x00, 0x8a05, 0x3c, 1);
+               
+               /* Read the control reg. Dont know why... */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x16, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x39, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+
+#if 0
+
+               /* USB FIFO Enable and Threshold Register. Disable iso pipe*/
+               webcamgo_veio(uvd, 0x00, 0x0a05, 0x3c, 1);
+
+               /* JPEG Enable Encoder. Disable */
+               webcamgo_veio(uvd, 0x00, 0x0011, 0x39, 1);
+
+               /* YUV4:2:0 Planar mode. Enable 1-2-1 filter. Clamp Video data to 
CCIR-601. Double buffer. Video is now disabled */
+               webcamgo_veio(uvd, 0x00, 0x10ab, 0x16, 1);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+
+               /* Reset JPEG Encoder and USB FIFO */
+               webcamgo_veio(uvd, 0x00, 0xbf16, 0x00, 1);
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1);
+
+               /* Select Interface 0, altsetting 0x00 */
+               webcamgo_alternateSetting(uvd, 0x00); 
+
+               /* Check data in serial bus control reg. Why??? */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0);
+               /* Write the value back. Why??? */
+               webcamgo_veio(uvd, 0x00, 0x032f, 0x01, 1);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+               webcamgo_veio(uvd, 0x00, 0xbf10, 0x00, 1);  /* URB 202 (In my logs) */
+
+       /* -------------- Loop 2 ------------- */
+#ifdef JPEG_COMPRESSED 
+               webcamgo_veio(uvd, 0x00, 0x0010, 0x39, 1); /* JPEG Clock Enable */
+#endif
+               webcamgo_veio(uvd, 0x00, 0x4a5d, 0x03, 1); /* Set DRAM Timings */
+
+               webcamgo_veio(uvd, 0x00, 0x0140, 0x14, 1); /* Captured Video Width 
+(320 
pix) */
+               webcamgo_veio(uvd, 0x00, 0x00f0, 0x15, 1); /* Captured Video Height 
+(240 
pix) */                 
+#ifdef PLANAR
+#      ifdef YUV420
+               /* YUV4:2:0 Planar mode. Enable 1-2-1 filter. Clamp Video data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90ab, 0x16, 1);
+#      else // defined(YUV422) && defined(PLANAR)
+       /* YUV4:2:2 Planar mode. Enable 1-2-1 filter. Clamp Video data to CCIR-601. 
Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90aa, 0x16, 1);
+#      endif   
+#else // if defined(YUV420) && defined(PACKED)
+#      ifdef YUV420
+               /* No JPEG. YUV4:2:0 Packed mode. Enable 1-2-1 filter. Clamp Video 
+data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90a9, 0x16, 1);
+#      else // if defined(YUV422) && defined(PACKED)
+               /* No JPEG. YUV4:2:2 Packed mode. Enable 1-2-1 filter. Clamp Video 
+data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90a8, 0x16, 1);
+#      endif   
+#endif
+               webcamgo_veio(uvd, 0x00, 0x10ab, 0x16, 1); /* YUV4:2:0 Planar mode. 
+Enable 
1-2-1 filter. 
+                                                                                      
+                                                                                      
+                           Clamp Video data to CCIR-601. Double buffer.  */           
+     
+               webcamgo_veio(uvd, 0x00, 0x1000, 0x20, 1); /* Capture Y Frame Buffer 0 
Start Address Low Register */
+               
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x21, 1); /* Capture Y Frame Buffer 0 
Start Address 
+                                                                                      
+                                                                                      
+                           High Register[20:16] (bits 4-0, 15-5 is reserved) */
+               /* Capture Y Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0x0100, 0x22, 1);
+
+               /* Capture Y Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x23, 1);      
+
+               /* Capture U Frame Buffer 0 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xa600, 0x24, 1);
+
+               /* Capture U Frame Buffer 0 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x25, 1);
+               
+               /* Capture U Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0x9700, 0x26, 1);      
+
+               /* Capture U Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x27, 1);
+
+               /* Capture V Frame Buffer 0 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xcb80, 0x28, 1);      
+
+               /* Capture V Frame Buffer 0 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x29, 1);
+
+               /* Capture V Frame Buffer 1 Start Address Low Register */
+               webcamgo_veio(uvd, 0x00, 0xbc80, 0x2a, 1);      
+
+               /* Capture V Frame Buffer 1 Start Address High Register[20:16] (bits 
+4-0, 
15-5 is reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x2b, 1);
+
+               /* Capture Y Frame Buffer Stride */
+               webcamgo_veio(uvd, 0x00, 0x00a0, 0x2c, 1);      
+
+               /* Capture UV Frame Buffer Stride */
+               webcamgo_veio(uvd, 0x00, 0x0050, 0x2d, 1);
+
+               /* JPEG Maximum Width (320 pix) */
+               webcamgo_veio(uvd, 0x00, 0x0140, 0x30, 1);
+
+               /* JPEG Maximum Height (240 pix) */
+               webcamgo_veio(uvd, 0x00, 0x00f0, 0x31, 1);
+
+               /* JPEG Compressed bitstream buffer 0 low address */
+               webcamgo_veio(uvd, 0x00, 0xe200, 0x32, 1);
+
+               /* JPEG Compressed bitstream buffer 0 high address */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x33, 1);
+
+               /* JPEG Compressed bitstream buffer 1 low address */
+               webcamgo_veio(uvd, 0x00, 0xc300, 0x34, 1);
+
+               /* JPEG Compressed bitstream buffer 1 high address */
+               webcamgo_veio(uvd, 0x00, 0x0002, 0x35, 1);
+
+               /* JPEG Restart interval (0 = disable) */
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x36, 1);
+
+               /* JPEG VLE FIFO Threshold */
+               webcamgo_veio(uvd, 0x00, 0x0804, 0x37, 1);
+               
+               /* JPEG Vertical Upscaling Control (Disable) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x38, 1);
+
+#ifdef JPEG_COMPRESSED 
+               /* JPEG Enable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0013, 0x39, 1);     /* URB 285 */
+#else
+               /* JPEG Disable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0011, 0x39, 1);     /* URB 285 */
+#endif
+
+               /* USB FIFO Enable and Threshold Register. Clear */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3c, 1);
+
+               /* Set USB Isochronous transfer size low[15:0] . 57600 byte */
+               webcamgo_veio(uvd, 0x00, 0xe100, 0x3d, 1);
+       
+               /* Set USB Isochronous transfer size high[20:16] (bits 4-0, 15-5 is 
reserved) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x3e, 1);
+
+               /* Start the fast serial bus. Data in reg 6-9 above is sent with 
+400KHz 
bit frequency (2.5 us bit time) */
+               webcamgo_veio(uvd, 0x00, 0x0023, 0x01, 1);
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d21, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0874, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x7482, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x001d, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d75, 0x09, 1); /* Rev bytes? */
+
+#if 1 // My dumb testing
+               webcamgo_alternateSetting(uvd, 0x07); 
+               /* USB FIFO Enable and Threshold Register. Enable iso pipe*/
+               webcamgo_veio(uvd, 0x00, 0x8a05, 0x3c, 1);
+#endif
+
+               /* Stop the fast serial bus. Data in reg 6-9 above is sent with 400KHz 
+bit 
frequency (2.5 us bit time) */
+               do { /* Wait for 0x030f */
+                       webcamgo_veio(uvd, 0x00, 0x0002, 0x01, 1);
+                       webcamgo_veio(uvd, 0x00, 0x0003, 0x01, 1);
+
+                       webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0);
+                       webcamgo_veio(uvd, 0x01, 0x0000, 0x01, 0);
+               } while ( (webcamgo->controlBuffer[0] != 0x0f) || 
(webcamgo->controlBuffer[1] != 0x03) );
+               webcamgo_veio(uvd, 0x00, 0x0002, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0001, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0003, 0x01, 1);
+               webcamgo_veio(uvd, 0x00, 0x0023, 0x01, 1);
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x482f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x1d21, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0874, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x7482, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x001d, 0x09, 1); /* Rev bytes? */
+
+               /* Program new data on the fast serial bus (FSB). SDATA and SCLK data 
interleaved... */
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0820, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x2082, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0xfe1d, 0x09, 1); /* Rev bytes? */
+
+#if 1 // My dumb testing
+               /* No JPEG. YUV4:2:0 Packed mode. Enable 1-2-1 filter. Clamp Video 
+data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x5d2f, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x2087, 0x07, 1); /* Maybe need to use 0x8720 
here? */
+               webcamgo_veio(uvd, 0x00, 0xd208, 0x08, 1); /* 0x08d2 */
+               webcamgo_veio(uvd, 0x00, 0x1d21, 0x09, 1); /* 0x211d */
+
+               webcamgo_veio(uvd, 0x00, 0x8208, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0x0874, 0x07, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x21d2, 0x08, 1); /* Rev bytes? */
+               webcamgo_veio(uvd, 0x00, 0x001d, 0x09, 1); /* Rev bytes? */
+
+               webcamgo_veio(uvd, 0x00, 0xaaaa, 0x06, 1); /* Program data to be sent 
+on 
fast serial bus (FSB) */
+               webcamgo_veio(uvd, 0x00, 0xffff, 0x07, 1);
+               webcamgo_veio(uvd, 0x00, 0xffff, 0x08, 1);
+               webcamgo_veio(uvd, 0x00, 0xffff, 0x09, 1);
+
+               webcamgo_resetPipe(uvd);
+#endif
+
+
+#if 1
+               /* Select Interface 0, altsetting 0x07 */
+               webcamgo_alternateSetting(uvd, 0x07); 
+#endif
+
+               /* JPEG Vertical Upscaling Control (Disable) */
+               webcamgo_veio(uvd, 0x00, 0x0000, 0x38, 1);
+
+#ifdef JPEG_COMPRESSED 
+               /* JPEG Enable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0013, 0x39, 1);     /* URB 285 */
+#else
+               /* JPEG Disable Encoder */
+               webcamgo_veio(uvd, 0x00, 0x0011, 0x39, 1);     /* URB 285 */
+#endif
+       
+#ifdef PLANAR
+#      ifdef YUV420
+               /* YUV4:2:0 Planar mode. Enable 1-2-1 filter. Clamp Video data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90ab, 0x16, 1);
+#      else // defined(YUV422) && defined(PLANAR)
+       /* YUV4:2:2 Planar mode. Enable 1-2-1 filter. Clamp Video data to CCIR-601. 
Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90aa, 0x16, 1);
+#      endif   
+#else // if defined(YUV420) && defined(PACKED)
+#      ifdef YUV420
+               /* No JPEG. YUV4:2:0 Packed mode. Enable 1-2-1 filter. Clamp Video 
+data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90a9, 0x16, 1);
+#      else // if defined(YUV422) && defined(PACKED)
+               /* No JPEG. YUV4:2:2 Packed mode. Enable 1-2-1 filter. Clamp Video 
+data to 
CCIR-601. Double buffer. Video is now enabled */
+               webcamgo_veio(uvd, 0x00, 0x90a8, 0x16, 1);
+#      endif   
+#endif
+       
+               /* USB FIFO Enable and Threshold Register. Enable iso pipe*/
+               webcamgo_veio(uvd, 0x00, 0x8a05, 0x3c, 1);
+
+               /* Read the control reg. Dont know why... */
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x16, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x39, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x00, 0);
+
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+               webcamgo_veio(uvd, 0x01, 0x0000, 0x02, 0);
+#endif
+               WEBCAMGO_T(uvd)->initialized = (setup_ok != 0);
+       }
+       return setup_ok;
+}
+
+static void webcamgo_configure_video(uvd_t *uvd)
+{
+       if (uvd == NULL)
+               return;
+
+       RESTRICT_TO_RANGE(init_brightness, 0, 255);
+       RESTRICT_TO_RANGE(init_contrast, 0, 255);
+       RESTRICT_TO_RANGE(init_color, 0, 255);
+       RESTRICT_TO_RANGE(init_hue, 0, 255);
+       RESTRICT_TO_RANGE(hue_correction, 0, 255);
+
+       memset(&uvd->vpic, 0, sizeof(uvd->vpic));
+       memset(&uvd->vpic_old, 0x55, sizeof(uvd->vpic_old));
+
+       uvd->vpic.colour = init_color << 8;
+       uvd->vpic.hue = init_hue << 8;
+       uvd->vpic.brightness = init_brightness << 8;
+       uvd->vpic.contrast = init_contrast << 8;
+       uvd->vpic.whiteness = 105 << 8; /* This one isn't used */
+       uvd->vpic.depth = 24;
+       uvd->vpic.palette = VIDEO_PALETTE_RGB24;
+
+       memset(&uvd->vcap, 0, sizeof(uvd->vcap));
+       strcpy(uvd->vcap.name, "IBM Ultra Camera");
+       uvd->vcap.type = VID_TYPE_CAPTURE;
+       uvd->vcap.channels = 1;
+       uvd->vcap.audios = 0;
+       uvd->vcap.maxwidth = VIDEOSIZE_X(uvd->canvas);
+       uvd->vcap.maxheight = VIDEOSIZE_Y(uvd->canvas);
+       uvd->vcap.minwidth = min_canvasWidth;
+       uvd->vcap.minheight = min_canvasHeight;
+
+       memset(&uvd->vchan, 0, sizeof(uvd->vchan));
+       uvd->vchan.flags = 0;
+       uvd->vchan.tuners = 0;
+       uvd->vchan.channel = 0;
+       uvd->vchan.type = VIDEO_TYPE_CAMERA;
+       strcpy(uvd->vchan.name, "Camera");
+}
+
+/*
+ * webcamgo_probe()
+ *
+ * This procedure queries device descriptor and accepts the interface
+ * if it looks like our camera.
+ */
+static void *webcamgo_probe(struct usb_device *dev, unsigned int ifnum
+#if USES_NEW_STYLE_PROBE
+       ,const struct usb_device_id *devid
+#endif
+       )
+{
+       uvd_t *uvd = NULL;
+       int i, nas;
+       int actInterface=-1, inactInterface=-1, maxPS=0;
+       unsigned char video_ep = 0;
+
+       if (debug >= 1)
+               info("webcamgo_probe(%p,%u.)", dev, ifnum);
+
+       /* We don't handle multi-config cameras */
+       if (dev->descriptor.bNumConfigurations != 1)
+               return NULL;
+
+       /* Is it a Video Blaster Webcam Go camera? */
+       if ((dev->descriptor.idVendor != WEBCAMGO_VENDOR_ID) ||
+           (dev->descriptor.idProduct != WEBCAMGO_PRODUCT_ID))
+               return NULL;
+
+       info("Video Blaster Webcam Go camera found (rev. 0x%04x)", 
dev->descriptor.bcdDevice);
+
+       /* Validate found interface: must have one ISO endpoint */
+       nas = dev->actconfig->interface[ifnum].num_altsetting;
+       if (debug > 0)
+               info("Number of alternate settings=%d.", nas);
+       if (nas < 8) {
+               err("Too few alternate settings for this camera!");
+               return NULL;
+       }
+       /* Validate all alternate settings */
+       for (i=0; i < nas; i++) {
+               const struct usb_interface_descriptor *interface;
+               const struct usb_endpoint_descriptor *endpoint;
+
+               interface = &dev->actconfig->interface[ifnum].altsetting[i];
+               if (interface->bNumEndpoints != 1) {
+                       err("Interface %d. has %u. endpoints!",
+                           ifnum, (unsigned)(interface->bNumEndpoints));
+                       return NULL;
+               }
+               endpoint = &interface->endpoint[0];
+               if (video_ep == 0)
+                       video_ep = endpoint->bEndpointAddress;
+               else if (video_ep != endpoint->bEndpointAddress) {
+                       err("Alternate settings have different endpoint addresses!");
+                       return NULL;
+               }
+               if ((endpoint->bmAttributes & 0x03) != 0x01) {
+                       err("Interface %d. has non-ISO endpoint!", ifnum);
+                       return NULL;
+               }
+               if ((endpoint->bEndpointAddress & 0x80) == 0) {
+                       err("Interface %d. has ISO OUT endpoint!", ifnum);
+                       return NULL;
+               }
+               if (endpoint->wMaxPacketSize == 0) {
+                       if (inactInterface < 0)
+                               inactInterface = i;
+                       else {
+                               err("More than one inactive alt. setting!");
+                               return NULL;
+                       }
+               } else {
+                       if (actInterface < 0) {
+                               actInterface = i;
+                               maxPS = endpoint->wMaxPacketSize;
+                               if (debug > 0)
+                                       info("Active setting=%d. maxPS=%d.", i, maxPS);
+                       } else {
+                               /* Got another active alt. setting */
+                               if (maxPS < endpoint->wMaxPacketSize) {
+                                       /* This one is better! */
+                                       actInterface = i;
+                                       maxPS = endpoint->wMaxPacketSize;
+                                       if (debug > 0) {
+                                               info("Even better ctive setting=%d. 
+maxPS=%d.",
+                                                    i, maxPS);
+                                       }
+                               }
+                       }
+               }
+       }
+       if ((maxPS <= 0) || (actInterface < 0) || (inactInterface < 0)) {
+               err("Failed to recognize the camera!");
+               return NULL;
+       }
+
+       /* Code below may sleep, need to lock module while we are here */
+       MOD_INC_USE_COUNT;
+       uvd = usbvideo_AllocateDevice(cams);
+       if (uvd != NULL) {
+               /* Here uvd is a fully allocated uvd_t object */
+               uvd->flags = flags;
+               uvd->debug = debug;
+               uvd->dev = dev;
+               uvd->iface = ifnum;
+               uvd->ifaceAltInactive = inactInterface;
+               uvd->ifaceAltActive = actInterface;
+               uvd->video_endp = video_ep;
+               uvd->iso_packet_len = maxPS;
+               uvd->paletteBits = 1L << VIDEO_PALETTE_RGB24;
+               uvd->defaultPalette = VIDEO_PALETTE_RGB24;
+               uvd->canvas = VIDEOSIZE(320, 240);      /* FIXME */
+               uvd->videosize = uvd->canvas; /* webcamgo_size_to_videosize(size);*/
+
+               /* Initialize webcamgo-specific data */
+               assert(WEBCAMGO_T(uvd) != NULL);
+               WEBCAMGO_T(uvd)->camera_model = 0; /* Not used yet */
+               WEBCAMGO_T(uvd)->initialized = 0;
+
+               webcamgo_configure_video(uvd);
+
+               i = usbvideo_RegisterVideoDevice(uvd);
+               if (i != 0) {
+                       err("usbvideo_RegisterVideoDevice() failed.");
+                       uvd = NULL;
+               }
+       }
+       MOD_DEC_USE_COUNT;
+       return uvd;
+}
+
+/*
+ * webcamgo_init()
+ *
+ * This code is run to initialize the driver.
+ */
+static int __init webcamgo_init(void)
+{
+       usbvideo_cb_t cbTbl;
+       memset(&cbTbl, 0, sizeof(cbTbl));
+       cbTbl.probe = webcamgo_probe;
+       cbTbl.setupOnOpen = webcamgo_setup_on_open;
+       cbTbl.videoStart = webcamgo_video_start;
+       cbTbl.videoStop = webcamgo_video_stop;
+       cbTbl.processData = webcamgo_ProcessIsocData;
+       cbTbl.postProcess = usbvideo_DeinterlaceFrame;
+       cbTbl.adjustPicture = webcamgo_adjust_picture;
+       cbTbl.getFPS = webcamgo_calculate_fps;
+       return usbvideo_register(
+               &cams,
+               MAX_CAMERAS,
+               sizeof(webcamgo_t),
+               "webcamgo",
+               &cbTbl,
+               THIS_MODULE);
+}
+
+static void __exit webcamgo_cleanup(void)
+{
+       usbvideo_Deregister(&cams);
+}
+
+#if USES_NEW_STYLE_PROBE
+
+static __devinitdata struct usb_device_id id_table[] = {
+       { USB_DEVICE(WEBCAMGO_VENDOR_ID, WEBCAMGO_PRODUCT_ID) },
+       { }  /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+#endif /* USES_NEW_STYLE_PROBE */
+
+module_init(webcamgo_init);
+module_exit(webcamgo_cleanup);

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to