include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / media / video / gspca / zc3xx.c
index d217c04..7d7814c 100644 (file)
@@ -1,9 +1,8 @@
 /*
- *     Z-Star/Vimicro zc301/zc302p/vc30x library
- *     Copyright (C) 2004 2005 2006 Michel Xhaard
- *             mxhaard@magic.fr
+ * Z-Star/Vimicro zc301/zc302p/vc30x library
  *
- * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
+ * Copyright (C) 2009-2010 Jean-Francois Moine <http://moinejf.free.fr>
+ * Copyright (C) 2004 2005 2006 Michel Xhaard mxhaard@magic.fr
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #define MODULE_NAME "zc3xx"
 
+#include <linux/input.h>
+#include <linux/slab.h>
 #include "gspca.h"
 #include "jpeg.h"
 
-MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, "
+MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>, "
                "Serge A. Suchkov <Serge.A.S@tochka.ru>");
 MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver");
 MODULE_LICENSE("GPL");
@@ -39,18 +40,18 @@ static int force_sensor = -1;
 struct sd {
        struct gspca_dev gspca_dev;     /* !! must be the first item */
 
-       __u8 brightness;
-       __u8 contrast;
-       __u8 gamma;
-       __u8 autogain;
-       __u8 lightfreq;
-       __u8 sharpness;
+       u8 brightness;
+       u8 contrast;
+       u8 gamma;
+       u8 autogain;
+       u8 lightfreq;
+       u8 sharpness;
        u8 quality;                     /* image quality */
 #define QUALITY_MIN 40
 #define QUALITY_MAX 60
 #define QUALITY_DEF 50
 
-       signed char sensor;             /* Type of image sensor chip */
+       u8 sensor;              /* Type of image sensor chip */
 /* !! values used in different tables */
 #define SENSOR_ADCM2700 0
 #define SENSOR_CS2102 1
@@ -92,9 +93,8 @@ static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
 static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
 static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
 
-static struct ctrl sd_ctrls[] = {
+static const struct ctrl sd_ctrls[] = {
 #define BRIGHTNESS_IDX 0
-#define SD_BRIGHTNESS 0
        {
            {
                .id      = V4L2_CID_BRIGHTNESS,
@@ -103,12 +103,12 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 255,
                .step    = 1,
-               .default_value = 128,
+#define BRIGHTNESS_DEF 128
+               .default_value = BRIGHTNESS_DEF,
            },
            .set = sd_setbrightness,
            .get = sd_getbrightness,
        },
-#define SD_CONTRAST 1
        {
            {
                .id      = V4L2_CID_CONTRAST,
@@ -117,12 +117,12 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 255,
                .step    = 1,
-               .default_value = 128,
+#define CONTRAST_DEF 128
+               .default_value = CONTRAST_DEF,
            },
            .set = sd_setcontrast,
            .get = sd_getcontrast,
        },
-#define SD_GAMMA 2
        {
            {
                .id      = V4L2_CID_GAMMA,
@@ -136,7 +136,6 @@ static struct ctrl sd_ctrls[] = {
            .set = sd_setgamma,
            .get = sd_getgamma,
        },
-#define SD_AUTOGAIN 3
        {
            {
                .id      = V4L2_CID_AUTOGAIN,
@@ -145,13 +144,13 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 1,
                .step    = 1,
-               .default_value = 1,
+#define AUTOGAIN_DEF 1
+               .default_value = AUTOGAIN_DEF,
            },
            .set = sd_setautogain,
            .get = sd_getautogain,
        },
 #define LIGHTFREQ_IDX 4
-#define SD_FREQ 4
        {
            {
                .id      = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -160,12 +159,12 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 2,   /* 0: 0, 1: 50Hz, 2:60Hz */
                .step    = 1,
-               .default_value = 1,
+#define FREQ_DEF 0
+               .default_value = FREQ_DEF,
            },
            .set = sd_setfreq,
            .get = sd_getfreq,
        },
-#define SD_SHARPNESS 5
        {
            {
                .id      = V4L2_CID_SHARPNESS,
@@ -174,7 +173,8 @@ static struct ctrl sd_ctrls[] = {
                .minimum = 0,
                .maximum = 3,
                .step    = 1,
-               .default_value = 2,
+#define SHARPNESS_DEF 2
+               .default_value = SHARPNESS_DEF,
            },
            .set = sd_setsharpness,
            .get = sd_getsharpness,
@@ -194,6 +194,19 @@ static const struct v4l2_pix_format vga_mode[] = {
                .priv = 0},
 };
 
+static const struct v4l2_pix_format broken_vga_mode[] = {
+       {320, 232, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+               .bytesperline = 320,
+               .sizeimage = 320 * 232 * 4 / 8 + 590,
+               .colorspace = V4L2_COLORSPACE_JPEG,
+               .priv = 1},
+       {640, 472, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+               .bytesperline = 640,
+               .sizeimage = 640 * 472 * 3 / 8 + 590,
+               .colorspace = V4L2_COLORSPACE_JPEG,
+               .priv = 0},
+};
+
 static const struct v4l2_pix_format sif_mode[] = {
        {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
                .bytesperline = 176,
@@ -209,9 +222,9 @@ static const struct v4l2_pix_format sif_mode[] = {
 
 /* usb exchanges */
 struct usb_action {
-       __u8    req;
-       __u8    val;
-       __u16   idx;
+       u8      req;
+       u8      val;
+       u16     idx;
 };
 
 static const struct usb_action adcm2700_Initial[] = {
@@ -421,7 +434,7 @@ static const struct usb_action adcm2700_NoFliker[] = {
        {0xaa, 0xfe, 0x0010},                           /* 00,fe,10,aa */
        {}
 };
-static const struct usb_action cs2102_Initial[] = {    /* 320x240 */
+static const struct usb_action cs2102_InitialScale[] = {       /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -473,7 +486,7 @@ static const struct usb_action cs2102_Initial[] = { /* 320x240 */
        {}
 };
 
-static const struct usb_action cs2102_InitialScale[] = {       /* 640x480 */
+static const struct usb_action cs2102_Initial[] = {    /* 640x480 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -524,7 +537,7 @@ static const struct usb_action cs2102_InitialScale[] = {    /* 640x480 */
        {0xa0, 0x00, 0x01ad},
        {}
 };
-static const struct usb_action cs2102_50HZ[] = {
+static const struct usb_action cs2102_50HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0001},
        {0xaa, 0x24, 0x005f},
@@ -546,7 +559,7 @@ static const struct usb_action cs2102_50HZ[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3},
        {}
 };
-static const struct usb_action cs2102_50HZScale[] = {
+static const struct usb_action cs2102_50HZ[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0000},
        {0xaa, 0x24, 0x00af},
@@ -568,7 +581,7 @@ static const struct usb_action cs2102_50HZScale[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3},
        {}
 };
-static const struct usb_action cs2102_60HZ[] = {
+static const struct usb_action cs2102_60HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0001},
        {0xaa, 0x24, 0x0055},
@@ -590,7 +603,7 @@ static const struct usb_action cs2102_60HZ[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3},
        {}
 };
-static const struct usb_action cs2102_60HZScale[] = {
+static const struct usb_action cs2102_60HZ[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0000},
        {0xaa, 0x24, 0x00aa},
@@ -612,7 +625,7 @@ static const struct usb_action cs2102_60HZScale[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3},
        {}
 };
-static const struct usb_action cs2102_NoFliker[] = {
+static const struct usb_action cs2102_NoFlikerScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0001},
        {0xaa, 0x24, 0x005f},
@@ -634,7 +647,7 @@ static const struct usb_action cs2102_NoFliker[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3},
        {}
 };
-static const struct usb_action cs2102_NoFlikerScale[] = {
+static const struct usb_action cs2102_NoFliker[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
        {0xaa, 0x23, 0x0000},
        {0xaa, 0x24, 0x00af},
@@ -658,7 +671,7 @@ static const struct usb_action cs2102_NoFlikerScale[] = {
 };
 
 /* CS2102_KOCOM */
-static const struct usb_action cs2102K_Initial[] = {
+static const struct usb_action cs2102K_InitialScale[] = {
        {0xa0, 0x11, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
        {0xa0, 0x08, ZC3XX_R010_CMOSSENSORSELECT},
@@ -917,7 +930,7 @@ static const struct usb_action cs2102K_Initial[] = {
        {}
 };
 
-static const struct usb_action cs2102K_InitialScale[] = {
+static const struct usb_action cs2102K_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
@@ -1495,7 +1508,7 @@ static const struct usb_action gc0305_NoFliker[] = {
        {}
 };
 
-static const struct usb_action hdcs2020xb_Initial[] = {
+static const struct usb_action hdcs2020b_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x11, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},  /* qtable 0x05 */
@@ -1627,7 +1640,7 @@ static const struct usb_action hdcs2020xb_Initial[] = {
        {0xa0, 0x40, ZC3XX_R118_BGAIN},
        {}
 };
-static const struct usb_action hdcs2020xb_InitialScale[] = {
+static const struct usb_action hdcs2020b_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
@@ -1819,7 +1832,7 @@ static const struct usb_action hdcs2020b_NoFliker[] = {
        {}
 };
 
-static const struct usb_action hv7131bxx_Initial[] = {         /* 320x240 */
+static const struct usb_action hv7131b_InitialScale[] = {      /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -1866,7 +1879,7 @@ static const struct usb_action hv7131bxx_Initial[] = {            /* 320x240 */
        {}
 };
 
-static const struct usb_action hv7131bxx_InitialScale[] = {    /* 640x480*/
+static const struct usb_action hv7131b_Initial[] = {   /* 640x480*/
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x00, ZC3XX_R010_CMOSSENSORSELECT},
@@ -2063,7 +2076,7 @@ static const struct usb_action hv7131b_NoFlikerScale[] = { /* 320x240 */
        {}
 };
 
-static const struct usb_action hv7131cxx_Initial[] = {
+static const struct usb_action hv7131r_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT},
@@ -2157,7 +2170,7 @@ static const struct usb_action hv7131cxx_Initial[] = {
        {}
 };
 
-static const struct usb_action hv7131cxx_InitialScale[] = {
+static const struct usb_action hv7131r_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
 
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},   /* diff */
@@ -2259,7 +2272,7 @@ static const struct usb_action hv7131cxx_InitialScale[] = {
        {}
 };
 
-static const struct usb_action icm105axx_Initial[] = {
+static const struct usb_action icm105a_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
@@ -2436,7 +2449,7 @@ static const struct usb_action icm105axx_Initial[] = {
        {}
 };
 
-static const struct usb_action icm105axx_InitialScale[] = {
+static const struct usb_action icm105a_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
@@ -2615,7 +2628,7 @@ static const struct usb_action icm105axx_InitialScale[] = {
        {0xa0, 0x40, ZC3XX_R118_BGAIN},
        {}
 };
-static const struct usb_action icm105a_50HZ[] = {
+static const struct usb_action icm105a_50HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x0020}, /* 00,0c,20,aa */
@@ -2646,7 +2659,7 @@ static const struct usb_action icm105a_50HZ[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, /* 00,20,ff,cc */
        {}
 };
-static const struct usb_action icm105a_50HZScale[] = {
+static const struct usb_action icm105a_50HZ[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x008c}, /* 00,0c,8c,aa */
@@ -2679,7 +2692,7 @@ static const struct usb_action icm105a_50HZScale[] = {
        {0xa0, 0xc0, ZC3XX_R1A8_DIGITALGAIN}, /* 01,a8,c0,cc */
        {}
 };
-static const struct usb_action icm105a_60HZ[] = {
+static const struct usb_action icm105a_60HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x0004}, /* 00,0c,04,aa */
@@ -2710,7 +2723,7 @@ static const struct usb_action icm105a_60HZ[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, /* 00,20,ff,cc */
        {}
 };
-static const struct usb_action icm105a_60HZScale[] = {
+static const struct usb_action icm105a_60HZ[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x0008}, /* 00,0c,08,aa */
@@ -2743,7 +2756,7 @@ static const struct usb_action icm105a_60HZScale[] = {
        {0xa0, 0xc0, ZC3XX_R1A8_DIGITALGAIN}, /* 01,a8,c0,cc */
        {}
 };
-static const struct usb_action icm105a_NoFliker[] = {
+static const struct usb_action icm105a_NoFlikerScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x0004}, /* 00,0c,04,aa */
@@ -2774,7 +2787,7 @@ static const struct usb_action icm105a_NoFliker[] = {
        {0xa0, 0xff, ZC3XX_R020_HSYNC_3}, /* 00,20,ff,cc */
        {}
 };
-static const struct usb_action icm105a_NoFlikerScale[] = {
+static const struct usb_action icm105a_NoFliker[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
        {0xaa, 0x0d, 0x0003}, /* 00,0d,03,aa */
        {0xaa, 0x0c, 0x0004}, /* 00,0c,04,aa */
@@ -2808,7 +2821,7 @@ static const struct usb_action icm105a_NoFlikerScale[] = {
        {}
 };
 
-static const struct usb_action MC501CB_InitialScale[] = {
+static const struct usb_action mc501cb_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT}, /* 00,02,00,cc */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */
@@ -2928,7 +2941,7 @@ static const struct usb_action MC501CB_InitialScale[] = {
        {}
 };
 
-static const struct usb_action MC501CB_Initial[] = {    /* 320x240 */
+static const struct usb_action mc501cb_InitialScale[] = {       /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */
@@ -3047,7 +3060,7 @@ static const struct usb_action MC501CB_Initial[] = {       /* 320x240 */
        {}
 };
 
-static const struct usb_action MC501CB_50HZ[] = {
+static const struct usb_action mc501cb_50HZScale[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x001d}, /* 00,36,1D,aa */
@@ -3064,7 +3077,7 @@ static const struct usb_action MC501CB_50HZ[] = {
        {}
 };
 
-static const struct usb_action MC501CB_50HZScale[] = {
+static const struct usb_action mc501cb_50HZ[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x003a}, /* 00,36,3A,aa */
@@ -3081,7 +3094,7 @@ static const struct usb_action MC501CB_50HZScale[] = {
        {}
 };
 
-static const struct usb_action MC501CB_60HZ[] = {
+static const struct usb_action mc501cb_60HZScale[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */
@@ -3098,7 +3111,7 @@ static const struct usb_action MC501CB_60HZ[] = {
        {}
 };
 
-static const struct usb_action MC501CB_60HZScale[] = {
+static const struct usb_action mc501cb_60HZ[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */
@@ -3115,7 +3128,7 @@ static const struct usb_action MC501CB_60HZScale[] = {
        {}
 };
 
-static const struct usb_action MC501CB_NoFliker[] = {
+static const struct usb_action mc501cb_NoFlikerScale[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */
@@ -3132,7 +3145,7 @@ static const struct usb_action MC501CB_NoFliker[] = {
        {}
 };
 
-static const struct usb_action MC501CB_NoFlikerScale[] = {
+static const struct usb_action mc501cb_NoFliker[] = {
        {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */
        {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */
        {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */
@@ -3144,8 +3157,8 @@ static const struct usb_action MC501CB_NoFlikerScale[] = {
        {}
 };
 
-/* from zs211.inf - HKR,%OV7620%,Initial - 640x480 */
-static const struct usb_action OV7620_mode0[] = {
+/* from zs211.inf */
+static const struct usb_action ov7620_Initial[] = {    /* 640x480 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT}, /* 00,02,40,cc */
        {0xa0, 0x00, ZC3XX_R008_CLOCKSETTING}, /* 00,08,00,cc */
@@ -3214,9 +3227,7 @@ static const struct usb_action OV7620_mode0[] = {
        {0xa0, 0x50, ZC3XX_R1A8_DIGITALGAIN}, /* 01,a8,50,cc */
        {}
 };
-
-/* from zs211.inf - HKR,%OV7620%,InitialScale - 320x240 */
-static const struct usb_action OV7620_mode1[] = {
+static const struct usb_action ov7620_InitialScale[] = {       /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x50, ZC3XX_R002_CLOCKSELECT},   /* 00,02,50,cc */
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},  /* 00,08,00,cc */
@@ -3287,9 +3298,7 @@ static const struct usb_action OV7620_mode1[] = {
        {0xa0, 0x50, ZC3XX_R1A8_DIGITALGAIN},   /* 01,a8,50,cc */
        {}
 };
-
-/* from zs211.inf - HKR,%OV7620%\AE,50HZ */
-static const struct usb_action OV7620_50HZ[] = {
+static const struct usb_action ov7620_50HZ[] = {
        {0xaa, 0x13, 0x00a3},   /* 00,13,a3,aa */
        {0xdd, 0x00, 0x0100},   /* 00,01,00,dd */
        {0xaa, 0x2b, 0x0096},   /* 00,2b,96,aa */
@@ -3307,9 +3316,7 @@ static const struct usb_action OV7620_50HZ[] = {
                                                         if mode0 (640x480) */
        {}
 };
-
-/* from zs211.inf - HKR,%OV7620%\AE,60HZ */
-static const struct usb_action OV7620_60HZ[] = {
+static const struct usb_action ov7620_60HZ[] = {
        {0xaa, 0x13, 0x00a3},                   /* 00,13,a3,aa */
                                                /* (bug in zs211.inf) */
        {0xdd, 0x00, 0x0100},                   /* 00,01,00,dd */
@@ -3331,9 +3338,7 @@ static const struct usb_action OV7620_60HZ[] = {
        {0xa1, 0x01, 0x0037},           */
        {}
 };
-
-/* from zs211.inf - HKR,%OV7620%\AE,NoFliker */
-static const struct usb_action OV7620_NoFliker[] = {
+static const struct usb_action ov7620_NoFliker[] = {
        {0xaa, 0x13, 0x00a3},                   /* 00,13,a3,aa */
                                                /* (bug in zs211.inf) */
        {0xdd, 0x00, 0x0100},                   /* 00,01,00,dd */
@@ -3354,7 +3359,7 @@ static const struct usb_action OV7620_NoFliker[] = {
        {}
 };
 
-static const struct usb_action ov7630c_Initial[] = {
+static const struct usb_action ov7630c_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
@@ -3511,7 +3516,7 @@ static const struct usb_action ov7630c_Initial[] = {
        {}
 };
 
-static const struct usb_action ov7630c_InitialScale[] = {
+static const struct usb_action ov7630c_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
@@ -3682,7 +3687,7 @@ static const struct usb_action pas106b_Initial_com[] = {
        {}
 };
 
-static const struct usb_action pas106b_Initial[] = {   /* 176x144 */
+static const struct usb_action pas106b_InitialScale[] = {      /* 176x144 */
 /* JPEG control */
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
 /* Sream and Sensor specific */
@@ -3800,7 +3805,7 @@ static const struct usb_action pas106b_Initial[] = {      /* 176x144 */
        {}
 };
 
-static const struct usb_action pas106b_InitialScale[] = {      /* 352x288 */
+static const struct usb_action pas106b_Initial[] = {   /* 352x288 */
 /* JPEG control */
        {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
 /* Sream and Sensor specific */
@@ -3972,10 +3977,10 @@ static const struct usb_action pas106b_NoFliker[] = {
        {}
 };
 
-/* from usbvm31b.inf */
+/* from lvWIMv.inf 046d:08a2/:08aa 2007/06/03 */
 static const struct usb_action pas202b_Initial[] = {   /* 640x480 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},         /* 00,00,01,cc */
-       {0xa0, 0x00, ZC3XX_R008_CLOCKSETTING},          /* 00,08,00,cc */
+       {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
        {0xa0, 0x0e, ZC3XX_R010_CMOSSENSORSELECT},      /* 00,10,0e,cc */
        {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},           /* 00,02,00,cc */
        {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH},        /* 00,03,02,cc */
@@ -4000,7 +4005,7 @@ static const struct usb_action pas202b_Initial[] = {      /* 640x480 */
        {0xaa, 0x09, 0x0006},                           /* 00,09,06,aa */
        {0xaa, 0x0a, 0x0001},                           /* 00,0a,01,aa */
        {0xaa, 0x0b, 0x0001},                           /* 00,0b,01,aa */
-       {0xaa, 0x0c, 0x0008},                           /* 00,0c,08,aa */
+       {0xaa, 0x0c, 0x0006},
        {0xaa, 0x0d, 0x0000},                           /* 00,0d,00,aa */
        {0xaa, 0x10, 0x0000},                           /* 00,10,00,aa */
        {0xaa, 0x12, 0x0005},                           /* 00,12,05,aa */
@@ -4019,13 +4024,13 @@ static const struct usb_action pas202b_Initial[] = {    /* 640x480 */
 };
 static const struct usb_action pas202b_InitialScale[] = {      /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},         /* 00,00,01,cc */
-       {0xa0, 0x00, ZC3XX_R008_CLOCKSETTING},          /* 00,08,00,cc */
+       {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
        {0xa0, 0x0e, ZC3XX_R010_CMOSSENSORSELECT},      /* 00,10,0e,cc */
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT},           /* 00,02,10,cc */
        {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH},        /* 00,03,02,cc */
        {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW},         /* 00,04,80,cc */
        {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},       /* 00,05,01,cc */
-       {0xa0, 0xd0, ZC3XX_R006_FRAMEHEIGHTLOW},        /* 00,06,d0,cc */
+       {0xa0, 0xe0, ZC3XX_R006_FRAMEHEIGHTLOW},
        {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},       /* 00,01,01,cc */
        {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC},      /* 00,12,03,cc */
        {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},      /* 00,12,01,cc */
@@ -4035,7 +4040,7 @@ static const struct usb_action pas202b_InitialScale[] = { /* 320x240 */
        {0xa0, 0x08, ZC3XX_R11A_FIRSTYLOW},             /* 01,1a,08,cc */
        {0xa0, 0x02, ZC3XX_R11C_FIRSTXLOW},             /* 01,1c,02,cc */
        {0xa0, 0x01, ZC3XX_R09B_WINHEIGHTHIGH},         /* 00,9b,01,cc */
-       {0xa0, 0xd8, ZC3XX_R09C_WINHEIGHTLOW},          /* 00,9c,d8,cc */
+       {0xa0, 0xe8, ZC3XX_R09C_WINHEIGHTLOW},
        {0xa0, 0x02, ZC3XX_R09D_WINWIDTHHIGH},          /* 00,9d,02,cc */
        {0xa0, 0x88, ZC3XX_R09E_WINWIDTHLOW},           /* 00,9e,88,cc */
        {0xaa, 0x02, 0x0002},                           /* 00,02,02,aa */
@@ -4044,7 +4049,7 @@ static const struct usb_action pas202b_InitialScale[] = { /* 320x240 */
        {0xaa, 0x09, 0x0006},                           /* 00,09,06,aa */
        {0xaa, 0x0a, 0x0001},                           /* 00,0a,01,aa */
        {0xaa, 0x0b, 0x0001},                           /* 00,0b,01,aa */
-       {0xaa, 0x0c, 0x0008},                           /* 00,0c,08,aa */
+       {0xaa, 0x0c, 0x0006},
        {0xaa, 0x0d, 0x0000},                           /* 00,0d,00,aa */
        {0xaa, 0x10, 0x0000},                           /* 00,10,00,aa */
        {0xaa, 0x12, 0x0005},                           /* 00,12,05,aa */
@@ -4059,6 +4064,8 @@ static const struct usb_action pas202b_InitialScale[] = { /* 320x240 */
        {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},        /* 02,50,08,cc */
        {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},          /* 03,01,08,cc */
        {0xa0, 0x70, ZC3XX_R18D_YTARGET},               /* 01,8d,70,cc */
+       {0xa0, 0xff, ZC3XX_R097_WINYSTARTHIGH},
+       {0xa0, 0xfe, ZC3XX_R098_WINYSTARTLOW},
        {}
 };
 static const struct usb_action pas202b_50HZ[] = {
@@ -4066,22 +4073,22 @@ static const struct usb_action pas202b_50HZ[] = {
        {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID},            /* 00,87,20,cc */
        {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW},            /* 00,88,21,cc */
        {0xaa, 0x20, 0x0002},                           /* 00,20,02,aa */
-       {0xaa, 0x21, 0x0068},                           /* 00,21,68,aa */
+       {0xaa, 0x21, 0x001b},
        {0xaa, 0x03, 0x0044},                           /* 00,03,44,aa */
-       {0xaa, 0x04, 0x0009},                           /* 00,04,09,aa */
-       {0xaa, 0x05, 0x0028},                           /* 00,05,28,aa */
+       {0xaa, 0x04, 0x0008},
+       {0xaa, 0x05, 0x001b},
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
-       {0xa0, 0x14, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,14,cc */
+       {0xa0, 0x1c, ZC3XX_R1A9_DIGITALLIMITDIFF},
        {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,24,cc */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x07, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,07,cc */
-       {0xa0, 0xd2, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,d2,cc */
+       {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x1b, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
        {0xa0, 0x4d, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,4d,cc */
-       {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
-       {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
+       {0xa0, 0x0e, ZC3XX_R18C_AEFREEZE},
+       {0xa0, 0x1b, ZC3XX_R18F_AEUNFREEZE},
        {0xa0, 0x44, ZC3XX_R01D_HSYNC_0},               /* 00,1d,44,cc */
        {0xa0, 0x6f, ZC3XX_R01E_HSYNC_1},               /* 00,1e,6f,cc */
        {0xa0, 0xad, ZC3XX_R01F_HSYNC_2},               /* 00,1f,ad,cc */
@@ -4094,23 +4101,23 @@ static const struct usb_action pas202b_50HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},         /* 00,19,00,cc */
        {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID},            /* 00,87,20,cc */
        {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW},            /* 00,88,21,cc */
-       {0xaa, 0x20, 0x0002},                           /* 00,20,02,aa */
-       {0xaa, 0x21, 0x006c},                           /* 00,21,6c,aa */
+       {0xaa, 0x20, 0x0004},
+       {0xaa, 0x21, 0x003d},
        {0xaa, 0x03, 0x0041},                           /* 00,03,41,aa */
-       {0xaa, 0x04, 0x0009},                           /* 00,04,09,aa */
-       {0xaa, 0x05, 0x002c},                           /* 00,05,2c,aa */
+       {0xaa, 0x04, 0x0010},
+       {0xaa, 0x05, 0x003d},
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
-       {0xa0, 0x14, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,14,cc */
+       {0xa0, 0x1c, ZC3XX_R1A9_DIGITALLIMITDIFF},
        {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,24,cc */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x0f, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,0f,cc */
-       {0xa0, 0xbe, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,be,cc */
+       {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x3d, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
        {0xa0, 0x9b, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,9b,cc */
-       {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
-       {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
+       {0xa0, 0x0e, ZC3XX_R18C_AEFREEZE},
+       {0xa0, 0x1b, ZC3XX_R18F_AEUNFREEZE},
        {0xa0, 0x41, ZC3XX_R01D_HSYNC_0},               /* 00,1d,41,cc */
        {0xa0, 0x6f, ZC3XX_R01E_HSYNC_1},               /* 00,1e,6f,cc */
        {0xa0, 0xad, ZC3XX_R01F_HSYNC_2},               /* 00,1f,ad,cc */
@@ -4130,16 +4137,16 @@ static const struct usb_action pas202b_60HZ[] = {
        {0xaa, 0x05, 0x0000},                           /* 00,05,00,aa */
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
-       {0xa0, 0x14, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,14,cc */
+       {0xa0, 0x1c, ZC3XX_R1A9_DIGITALLIMITDIFF},
        {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,24,cc */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x07, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,07,cc */
-       {0xa0, 0xc0, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,c0,cc */
+       {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x00, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
        {0xa0, 0x40, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,40,cc */
-       {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
-       {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
+       {0xa0, 0x0e, ZC3XX_R18C_AEFREEZE},
+       {0xa0, 0x1b, ZC3XX_R18F_AEUNFREEZE},
        {0xa0, 0x45, ZC3XX_R01D_HSYNC_0},               /* 00,1d,45,cc */
        {0xa0, 0x8e, ZC3XX_R01E_HSYNC_1},               /* 00,1e,8e,cc */
        {0xa0, 0xc1, ZC3XX_R01F_HSYNC_2},               /* 00,1f,c1,cc */
@@ -4152,23 +4159,23 @@ static const struct usb_action pas202b_60HZScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},         /* 00,19,00,cc */
        {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID},            /* 00,87,20,cc */
        {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW},            /* 00,88,21,cc */
-       {0xaa, 0x20, 0x0002},                           /* 00,20,02,aa */
-       {0xaa, 0x21, 0x0004},                           /* 00,21,04,aa */
+       {0xaa, 0x20, 0x0004},
+       {0xaa, 0x21, 0x0008},
        {0xaa, 0x03, 0x0042},                           /* 00,03,42,aa */
-       {0xaa, 0x04, 0x0008},                           /* 00,04,08,aa */
-       {0xaa, 0x05, 0x0004},                           /* 00,05,04,aa */
+       {0xaa, 0x04, 0x0010},
+       {0xaa, 0x05, 0x0008},
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
-       {0xa0, 0x14, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,14,cc */
+       {0xa0, 0x1c, ZC3XX_R1A9_DIGITALLIMITDIFF},
        {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,24,cc */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x0f, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,0f,cc */
-       {0xa0, 0x9f, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,9f,cc */
+       {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x08, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
        {0xa0, 0x81, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,81,cc */
-       {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
-       {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
+       {0xa0, 0x0e, ZC3XX_R18C_AEFREEZE},
+       {0xa0, 0x1b, ZC3XX_R18F_AEUNFREEZE},
        {0xa0, 0x42, ZC3XX_R01D_HSYNC_0},               /* 00,1d,42,cc */
        {0xa0, 0x6f, ZC3XX_R01E_HSYNC_1},               /* 00,1e,6f,cc */
        {0xa0, 0xaf, ZC3XX_R01F_HSYNC_2},               /* 00,1f,af,cc */
@@ -4182,22 +4189,22 @@ static const struct usb_action pas202b_NoFliker[] = {
        {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID},            /* 00,87,20,cc */
        {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW},            /* 00,88,21,cc */
        {0xaa, 0x20, 0x0002},                           /* 00,20,02,aa */
-       {0xaa, 0x21, 0x0020},                           /* 00,21,20,aa */
+       {0xaa, 0x21, 0x0006},
        {0xaa, 0x03, 0x0040},                           /* 00,03,40,aa */
        {0xaa, 0x04, 0x0008},                           /* 00,04,08,aa */
-       {0xaa, 0x05, 0x0020},                           /* 00,05,20,aa */
+       {0xaa, 0x05, 0x0006},
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x07, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,07,cc */
-       {0xa0, 0xf0, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,f0,cc */
+       {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x06, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
-       {0xa0, 0x02, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,02,cc */
+       {0xa0, 0x01, ZC3XX_R197_ANTIFLICKERLOW},
        {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
        {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
        {0xa0, 0x00, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,00,cc */
-       {0xa0, 0x00, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,00,cc */
+       {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},
        {0xa0, 0x40, ZC3XX_R01D_HSYNC_0},               /* 00,1d,40,cc */
        {0xa0, 0x60, ZC3XX_R01E_HSYNC_1},               /* 00,1e,60,cc */
        {0xa0, 0x90, ZC3XX_R01F_HSYNC_2},               /* 00,1f,90,cc */
@@ -4210,23 +4217,23 @@ static const struct usb_action pas202b_NoFlikerScale[] = {
        {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},         /* 00,19,00,cc */
        {0xa0, 0x20, ZC3XX_R087_EXPTIMEMID},            /* 00,87,20,cc */
        {0xa0, 0x21, ZC3XX_R088_EXPTIMELOW},            /* 00,88,21,cc */
-       {0xaa, 0x20, 0x0002},                           /* 00,20,02,aa */
-       {0xaa, 0x21, 0x0010},                           /* 00,21,10,aa */
+       {0xaa, 0x20, 0x0004},
+       {0xaa, 0x21, 0x000c},
        {0xaa, 0x03, 0x0040},                           /* 00,03,40,aa */
-       {0xaa, 0x04, 0x0008},                           /* 00,04,08,aa */
-       {0xaa, 0x05, 0x0010},                           /* 00,05,10,aa */
+       {0xaa, 0x04, 0x0010},
+       {0xaa, 0x05, 0x000c},
        {0xaa, 0x0e, 0x0001},                           /* 00,0e,01,aa */
        {0xaa, 0x0f, 0x0000},                           /* 00,0f,00,aa */
        {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},     /* 01,90,00,cc */
-       {0xa0, 0x0f, ZC3XX_R191_EXPOSURELIMITMID},      /* 01,91,0f,cc */
-       {0xa0, 0xf0, ZC3XX_R192_EXPOSURELIMITLOW},      /* 01,92,f0,cc */
+       {0xa0, 0x04, ZC3XX_R191_EXPOSURELIMITMID},
+       {0xa0, 0x0c, ZC3XX_R192_EXPOSURELIMITLOW},
        {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},       /* 01,95,00,cc */
        {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},        /* 01,96,00,cc */
        {0xa0, 0x02, ZC3XX_R197_ANTIFLICKERLOW},        /* 01,97,02,cc */
        {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},              /* 01,8c,10,cc */
        {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},            /* 01,8f,20,cc */
        {0xa0, 0x00, ZC3XX_R1A9_DIGITALLIMITDIFF},      /* 01,a9,00,cc */
-       {0xa0, 0x00, ZC3XX_R1AA_DIGITALGAINSTEP},       /* 01,aa,00,cc */
+       {0xa0, 0x24, ZC3XX_R1AA_DIGITALGAINSTEP},
        {0xa0, 0x40, ZC3XX_R01D_HSYNC_0},               /* 00,1d,40,cc */
        {0xa0, 0x60, ZC3XX_R01E_HSYNC_1},               /* 00,1e,60,cc */
        {0xa0, 0x90, ZC3XX_R01F_HSYNC_2},               /* 00,1f,90,cc */
@@ -4713,8 +4720,8 @@ static const struct usb_action pb0330_NoFlikerScale[] = {
        {}
 };
 
-/* from oem9.inf - HKR,%PO2030%,Initial - 640x480 - (close to CS2102) */
-static const struct usb_action PO2030_mode0[] = {
+/* from oem9.inf */
+static const struct usb_action po2030_Initial[] = {    /* 640x480 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x04, ZC3XX_R002_CLOCKSELECT},   /* 00,02,04,cc */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */
@@ -4790,8 +4797,8 @@ static const struct usb_action PO2030_mode0[] = {
        {}
 };
 
-/* from oem9.inf - HKR,%PO2030%,InitialScale - 320x240 */
-static const struct usb_action PO2030_mode1[] = {
+/* from oem9.inf */
+static const struct usb_action po2030_InitialScale[] = {       /* 320x240 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
        {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */
@@ -4867,7 +4874,7 @@ static const struct usb_action PO2030_mode1[] = {
        {}
 };
 
-static const struct usb_action PO2030_50HZ[] = {
+static const struct usb_action po2030_50HZ[] = {
        {0xaa, 0x8d, 0x0008}, /* 00,8d,08,aa */
        {0xaa, 0x1a, 0x0001}, /* 00,1a,01,aa */
        {0xaa, 0x1b, 0x000a}, /* 00,1b,0a,aa */
@@ -4889,7 +4896,7 @@ static const struct usb_action PO2030_50HZ[] = {
        {}
 };
 
-static const struct usb_action PO2030_60HZ[] = {
+static const struct usb_action po2030_60HZ[] = {
        {0xaa, 0x8d, 0x0008}, /* 00,8d,08,aa */
        {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa */
        {0xaa, 0x1b, 0x00de}, /* 00,1b,de,aa */
@@ -4912,7 +4919,7 @@ static const struct usb_action PO2030_60HZ[] = {
        {}
 };
 
-static const struct usb_action PO2030_NoFliker[] = {
+static const struct usb_action po2030_NoFliker[] = {
        {0xa0, 0x02, ZC3XX_R180_AUTOCORRECTENABLE}, /* 01,80,02,cc */
        {0xaa, 0x8d, 0x000d}, /* 00,8d,0d,aa */
        {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa */
@@ -4924,7 +4931,7 @@ static const struct usb_action PO2030_NoFliker[] = {
 };
 
 /* TEST */
-static const struct usb_action tas5130CK_Initial[] = {
+static const struct usb_action tas5130cK_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x01, 0x003b},
        {0xa0, 0x0e, 0x003a},
@@ -5127,7 +5134,7 @@ static const struct usb_action tas5130CK_Initial[] = {
        {}
 };
 
-static const struct usb_action tas5130CK_InitialScale[] = {
+static const struct usb_action tas5130cK_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x01, 0x003b},
        {0xa0, 0x0e, 0x003a},
@@ -5560,7 +5567,7 @@ static const struct usb_action tas5130cxx_NoFlikerScale[] = {
        {}
 };
 
-static const struct usb_action tas5130c_vf0250_Initial[] = {
+static const struct usb_action tas5130c_vf0250_InitialScale[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},         /* 00,00,01,cc, */
        {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING},          /* 00,08,02,cc, */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT},      /* 00,10,01,cc, */
@@ -5627,7 +5634,7 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
        {}
 };
 
-static const struct usb_action tas5130c_vf0250_InitialScale[] = {
+static const struct usb_action tas5130c_vf0250_Initial[] = {
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},         /* 00,00,01,cc, */
        {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING},          /* 00,08,02,cc, */
        {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT},      /* 00,10,01,cc, */
@@ -5692,8 +5699,7 @@ static const struct usb_action tas5130c_vf0250_InitialScale[] = {
        {0xa0, 0x65, ZC3XX_R118_BGAIN},         /* 01,18,65,cc */
        {}
 };
-/* "50HZ" light frequency banding filter */
-static const struct usb_action tas5130c_vf0250_50HZ[] = {
+static const struct usb_action tas5130c_vf0250_50HZScale[] = {
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0001},           /* 00,83,01,aa */
        {0xaa, 0x84, 0x00aa},           /* 00,84,aa,aa */
@@ -5717,8 +5723,7 @@ static const struct usb_action tas5130c_vf0250_50HZ[] = {
        {}
 };
 
-/* "50HZScale" light frequency banding filter */
-static const struct usb_action tas5130c_vf0250_50HZScale[] = {
+static const struct usb_action tas5130c_vf0250_50HZ[] = {
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0003},           /* 00,83,03,aa */
        {0xaa, 0x84, 0x0054},           /* 00,84,54,aa */
@@ -5742,8 +5747,7 @@ static const struct usb_action tas5130c_vf0250_50HZScale[] = {
        {}
 };
 
-/* "60HZ" light frequency banding filter */
-static const struct usb_action tas5130c_vf0250_60HZ[] = {
+static const struct usb_action tas5130c_vf0250_60HZScale[] = {
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0001},           /* 00,83,01,aa */
        {0xaa, 0x84, 0x0062},           /* 00,84,62,aa */
@@ -5767,8 +5771,7 @@ static const struct usb_action tas5130c_vf0250_60HZ[] = {
        {}
 };
 
-/* "60HZScale" light frequency banding ilter */
-static const struct usb_action tas5130c_vf0250_60HZScale[] = {
+static const struct usb_action tas5130c_vf0250_60HZ[] = {
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0002},           /* 00,83,02,aa */
        {0xaa, 0x84, 0x00c4},           /* 00,84,c4,aa */
@@ -5792,8 +5795,7 @@ static const struct usb_action tas5130c_vf0250_60HZScale[] = {
        {}
 };
 
-/* "NoFliker" light frequency banding flter */
-static const struct usb_action tas5130c_vf0250_NoFliker[] = {
+static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
        {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE},         /* 01,00,0c,cc, */
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0000},           /* 00,83,00,aa */
@@ -5815,8 +5817,7 @@ static const struct usb_action tas5130c_vf0250_NoFliker[] = {
        {}
 };
 
-/* "NoFlikerScale" light frequency banding filter */
-static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
+static const struct usb_action tas5130c_vf0250_NoFliker[] = {
        {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE},         /* 01,00,0c,cc, */
        {0xaa, 0x82, 0x0000},           /* 00,82,00,aa */
        {0xaa, 0x83, 0x0000},           /* 00,83,00,aa */
@@ -5839,7 +5840,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
 };
 
 static u8 reg_r_i(struct gspca_dev *gspca_dev,
-               __u16 index)
+               u16 index)
 {
        usb_control_msg(gspca_dev->dev,
                        usb_rcvctrlpipe(gspca_dev->dev, 0),
@@ -5852,7 +5853,7 @@ static u8 reg_r_i(struct gspca_dev *gspca_dev,
 }
 
 static u8 reg_r(struct gspca_dev *gspca_dev,
-               __u16 index)
+               u16 index)
 {
        u8 ret;
 
@@ -5862,8 +5863,8 @@ static u8 reg_r(struct gspca_dev *gspca_dev,
 }
 
 static void reg_w_i(struct usb_device *dev,
-                       __u8 value,
-                       __u16 index)
+                       u8 value,
+                       u16 index)
 {
        usb_control_msg(dev,
                        usb_sndctrlpipe(dev, 0),
@@ -5874,18 +5875,18 @@ static void reg_w_i(struct usb_device *dev,
 }
 
 static void reg_w(struct usb_device *dev,
-                       __u8 value,
-                       __u16 index)
+                       u8 value,
+                       u16 index)
 {
        PDEBUG(D_USBO, "reg w [%04x] = %02x", index, value);
        reg_w_i(dev, value, index);
 }
 
-static __u16 i2c_read(struct gspca_dev *gspca_dev,
-                       __u8 reg)
+static u16 i2c_read(struct gspca_dev *gspca_dev,
+                       u8 reg)
 {
-       __u8 retbyte;
-       __u16 retval;
+       u8 retbyte;
+       u16 retval;
 
        reg_w_i(gspca_dev->dev, reg, 0x0092);
        reg_w_i(gspca_dev->dev, 0x02, 0x0090);          /* <- read command */
@@ -5900,12 +5901,12 @@ static __u16 i2c_read(struct gspca_dev *gspca_dev,
        return retval;
 }
 
-static __u8 i2c_write(struct gspca_dev *gspca_dev,
-                       __u8 reg,
-                       __u8 valL,
-                       __u8 valH)
+static u8 i2c_write(struct gspca_dev *gspca_dev,
+                       u8 reg,
+                       u8 valL,
+                       u8 valH)
 {
-       __u8 retbyte;
+       u8 retbyte;
 
        reg_w_i(gspca_dev->dev, reg, 0x92);
        reg_w_i(gspca_dev->dev, valL, 0x93);
@@ -5957,24 +5958,24 @@ static void setmatrix(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        int i;
-       const __u8 *matrix;
+       const u8 *matrix;
        static const u8 adcm2700_matrix[9] =
 /*             {0x66, 0xed, 0xed, 0xed, 0x66, 0xed, 0xed, 0xed, 0x66}; */
 /*ms-win*/
                {0x74, 0xed, 0xed, 0xed, 0x74, 0xed, 0xed, 0xed, 0x74};
-       static const __u8 gc0305_matrix[9] =
+       static const u8 gc0305_matrix[9] =
                {0x50, 0xf8, 0xf8, 0xf8, 0x50, 0xf8, 0xf8, 0xf8, 0x50};
-       static const __u8 ov7620_matrix[9] =
+       static const u8 ov7620_matrix[9] =
                {0x58, 0xf4, 0xf4, 0xf4, 0x58, 0xf4, 0xf4, 0xf4, 0x58};
-       static const __u8 pas202b_matrix[9] =
+       static const u8 pas202b_matrix[9] =
                {0x4c, 0xf5, 0xff, 0xf9, 0x51, 0xf5, 0xfb, 0xed, 0x5f};
-       static const __u8 po2030_matrix[9] =
+       static const u8 po2030_matrix[9] =
                {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60};
        static const u8 tas5130c_matrix[9] =
                {0x68, 0xec, 0xec, 0xec, 0x68, 0xec, 0xec, 0xec, 0x68};
-       static const __u8 vf0250_matrix[9] =
+       static const u8 vf0250_matrix[9] =
                {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b};
-       static const __u8 *matrix_tb[SENSOR_MAX] = {
+       static const u8 *matrix_tb[SENSOR_MAX] = {
                adcm2700_matrix, /* SENSOR_ADCM2700 0 */
                ov7620_matrix,  /* SENSOR_CS2102 1 */
                NULL,           /* SENSOR_CS2102K 2 */
@@ -6006,11 +6007,12 @@ static void setmatrix(struct gspca_dev *gspca_dev)
 static void setbrightness(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       __u8 brightness;
+       u8 brightness;
 
        switch (sd->sensor) {
        case SENSOR_GC0305:
        case SENSOR_OV7620:
+       case SENSOR_PAS202B:
        case SENSOR_PO2030:
                return;
        }
@@ -6034,7 +6036,7 @@ static void setsharpness(struct gspca_dev *gspca_dev)
        struct sd *sd = (struct sd *) gspca_dev;
        struct usb_device *dev = gspca_dev->dev;
        int sharpness;
-       static const __u8 sharpness_tb[][2] = {
+       static const u8 sharpness_tb[][2] = {
                {0x02, 0x03},
                {0x04, 0x07},
                {0x08, 0x0f},
@@ -6053,7 +6055,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        struct usb_device *dev = gspca_dev->dev;
-       const __u8 *Tgamma;
+       const u8 *Tgamma;
        int g, i, k, adj, gp;
        u8 gr[16];
        static const u8 delta_tb[16] =          /* delta for contrast */
@@ -6108,13 +6110,14 @@ static void setquality(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        struct usb_device *dev = gspca_dev->dev;
-       __u8 frxt;
+       u8 frxt;
 
        switch (sd->sensor) {
        case SENSOR_ADCM2700:
        case SENSOR_GC0305:
        case SENSOR_HV7131B:
        case SENSOR_OV7620:
+       case SENSOR_PAS202B:
        case SENSOR_PO2030:
                return;
        }
@@ -6168,9 +6171,9 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
                 hdcs2020b_50HZ, hdcs2020b_50HZ,
                 hdcs2020b_60HZ, hdcs2020b_60HZ},
 /* SENSOR_HV7131B 5 */
-               {hv7131b_NoFlikerScale, hv7131b_NoFliker,
-                hv7131b_50HZScale, hv7131b_50HZ,
-                hv7131b_60HZScale, hv7131b_60HZ},
+               {hv7131b_NoFliker, hv7131b_NoFlikerScale,
+                hv7131b_50HZ, hv7131b_50HZScale,
+                hv7131b_60HZ, hv7131b_60HZScale},
 /* SENSOR_HV7131C 6 */
                {NULL, NULL,
                 NULL, NULL,
@@ -6180,17 +6183,17 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
                 icm105a_50HZ, icm105a_50HZScale,
                 icm105a_60HZ, icm105a_60HZScale},
 /* SENSOR_MC501CB 8 */
-               {MC501CB_NoFliker, MC501CB_NoFlikerScale,
-                MC501CB_50HZ, MC501CB_50HZScale,
-                MC501CB_60HZ, MC501CB_60HZScale},
+               {mc501cb_NoFliker, mc501cb_NoFlikerScale,
+                mc501cb_50HZ, mc501cb_50HZScale,
+                mc501cb_60HZ, mc501cb_60HZScale},
 /* SENSOR_MI0360SOC 9 */
-               {mi360soc_AENoFlikerScale, mi360soc_AENoFliker,
-                mi360soc_AE50HZScale, mi360soc_AE50HZ,
-                mi360soc_AE60HZScale, mi360soc_AE60HZ},
+               {mi360soc_AENoFliker, mi360soc_AENoFlikerScale,
+                mi360soc_AE50HZ, mi360soc_AE50HZScale,
+                mi360soc_AE60HZ, mi360soc_AE60HZScale},
 /* SENSOR_OV7620 10 */
-               {OV7620_NoFliker, OV7620_NoFliker,
-                OV7620_50HZ, OV7620_50HZ,
-                OV7620_60HZ, OV7620_60HZ},
+               {ov7620_NoFliker, ov7620_NoFliker,
+                ov7620_50HZ, ov7620_50HZ,
+                ov7620_60HZ, ov7620_60HZ},
 /* SENSOR_OV7630C 11 */
                {NULL, NULL,
                 NULL, NULL,
@@ -6208,17 +6211,17 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
                 pb0330_50HZScale, pb0330_50HZ,
                 pb0330_60HZScale, pb0330_60HZ},
 /* SENSOR_PO2030 15 */
-               {PO2030_NoFliker, PO2030_NoFliker,
-                PO2030_50HZ, PO2030_50HZ,
-                PO2030_60HZ, PO2030_60HZ},
+               {po2030_NoFliker, po2030_NoFliker,
+                po2030_50HZ, po2030_50HZ,
+                po2030_60HZ, po2030_60HZ},
 /* SENSOR_TAS5130CK 16 */
-               {tas5130cxx_NoFlikerScale, tas5130cxx_NoFliker,
-                tas5130cxx_50HZScale, tas5130cxx_50HZ,
-                tas5130cxx_60HZScale, tas5130cxx_60HZ},
+               {tas5130cxx_NoFliker, tas5130cxx_NoFlikerScale,
+                tas5130cxx_50HZ, tas5130cxx_50HZScale,
+                tas5130cxx_60HZ, tas5130cxx_60HZScale},
 /* SENSOR_TAS5130CXX 17 */
-               {tas5130cxx_NoFlikerScale, tas5130cxx_NoFliker,
-                tas5130cxx_50HZScale, tas5130cxx_50HZ,
-                tas5130cxx_60HZScale, tas5130cxx_60HZ},
+               {tas5130cxx_NoFliker, tas5130cxx_NoFlikerScale,
+                tas5130cxx_50HZ, tas5130cxx_50HZScale,
+                tas5130cxx_60HZ, tas5130cxx_60HZScale},
 /* SENSOR_TAS5130C_VF0250 18 */
                {tas5130c_vf0250_NoFliker, tas5130c_vf0250_NoFlikerScale,
                 tas5130c_vf0250_50HZ, tas5130c_vf0250_50HZScale,
@@ -6227,9 +6230,9 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
 
        i = sd->lightfreq * 2;
        mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
-       if (!mode)
-               i++;                    /* 640x480 */
-       zc3_freq = freq_tb[(int) sd->sensor][i];
+       if (mode)
+               i++;                    /* 320x240 */
+       zc3_freq = freq_tb[sd->sensor][i];
        if (zc3_freq != NULL) {
                usb_exchange(gspca_dev, zc3_freq);
                switch (sd->sensor) {
@@ -6247,6 +6250,9 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
                                        reg_w(gspca_dev->dev, 0x44, 0x0002);
                        }
                        break;
+               case SENSOR_PAS202B:
+                       reg_w(gspca_dev->dev, 0x00, 0x01a7);
+                       break;
                }
        }
        return 0;
@@ -6255,7 +6261,7 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
 static void setautogain(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       __u8 autoval;
+       u8 autoval;
 
        if (sd->autogain)
                autoval = 0x42;
@@ -6283,6 +6289,12 @@ static void send_unknown(struct usb_device *dev, int sensor)
                reg_w(dev, 0x02, 0x003b);
                reg_w(dev, 0x00, 0x0038);
                break;
+       case SENSOR_PAS202B:
+               reg_w(dev, 0x03, 0x003b);
+               reg_w(dev, 0x0c, 0x003a);
+               reg_w(dev, 0x0b, 0x0039);
+               reg_w(dev, 0x0b, 0x0038);
+               break;
        }
 }
 
@@ -6299,7 +6311,7 @@ static void start_2wr_probe(struct usb_device *dev, int sensor)
 
 static int sif_probe(struct gspca_dev *gspca_dev)
 {
-       __u16 checkword;
+       u16 checkword;
 
        start_2wr_probe(gspca_dev->dev, 0x0f);          /* PAS106 */
        reg_w(gspca_dev->dev, 0x08, 0x008d);
@@ -6342,6 +6354,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
        }
 
        start_2wr_probe(dev, 0x08);             /* HDCS2020 */
+       i2c_write(gspca_dev, 0x1c, 0x00, 0x00);
        i2c_write(gspca_dev, 0x15, 0xaa, 0x00);
        retword = i2c_read(gspca_dev, 0x15);
        if (retword != 0)
@@ -6370,8 +6383,10 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
        i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
        msleep(50);
        retword = i2c_read(gspca_dev, 0x03);
-       if (retword != 0)
+       if (retword != 0) {
+               send_unknown(dev, SENSOR_PAS202B);
                return 0x0e;                    /* PAS202BCB */
+       }
 
        start_2wr_probe(dev, 0x02);             /* TAS5130C */
        i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
@@ -6407,8 +6422,8 @@ ov_check:
 }
 
 struct sensor_by_chipset_revision {
-       __u16 revision;
-       __u8 internal_sensor_id;
+       u16 revision;
+       u8 internal_sensor_id;
 };
 static const struct sensor_by_chipset_revision chipset_revision_sensor[] = {
        {0xc000, 0x12},         /* TAS5130C */
@@ -6425,7 +6440,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
        struct sd *sd = (struct sd *) gspca_dev;
        struct usb_device *dev = gspca_dev->dev;
        int i;
-       __u8 retbyte;
+       u8 retbyte;
        u16 retword;
 
 /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
@@ -6573,8 +6588,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
        struct sd *sd = (struct sd *) gspca_dev;
        struct cam *cam;
        int sensor;
-       int vga = 1;            /* 1: vga, 0: sif */
-       static const __u8 gamma[SENSOR_MAX] = {
+       static const u8 gamma[SENSOR_MAX] = {
                4,      /* SENSOR_ADCM2700 0 */
                4,      /* SENSOR_CS2102 1 */
                5,      /* SENSOR_CS2102K 2 */
@@ -6595,9 +6609,30 @@ static int sd_config(struct gspca_dev *gspca_dev,
                3,      /* SENSOR_TAS5130CXX 17 */
                3,      /* SENSOR_TAS5130C_VF0250 18 */
        };
+       static const u8 mode_tb[SENSOR_MAX] = {
+               2,      /* SENSOR_ADCM2700 0 */
+               1,      /* SENSOR_CS2102 1 */
+               1,      /* SENSOR_CS2102K 2 */
+               1,      /* SENSOR_GC0305 3 */
+               1,      /* SENSOR_HDCS2020b 4 */
+               1,      /* SENSOR_HV7131B 5 */
+               1,      /* SENSOR_HV7131C 6 */
+               1,      /* SENSOR_ICM105A 7 */
+               2,      /* SENSOR_MC501CB 8 */
+               1,      /* SENSOR_MI0360SOC 9 */
+               2,      /* SENSOR_OV7620 10 */
+               1,      /* SENSOR_OV7630C 11 */
+               0,      /* SENSOR_PAS106 12 */
+               1,      /* SENSOR_PAS202B 13 */
+               1,      /* SENSOR_PB0330 14 */
+               1,      /* SENSOR_PO2030 15 */
+               1,      /* SENSOR_TAS5130CK 16 */
+               1,      /* SENSOR_TAS5130CXX 17 */
+               1,      /* SENSOR_TAS5130C_VF0250 18 */
+       };
 
        /* define some sensors from the vendor/product */
-       sd->sharpness = 2;
+       sd->sharpness = SHARPNESS_DEF;
        sd->sensor = id->driver_info;
        sensor = zcxx_probeSensor(gspca_dev);
        if (sensor >= 0)
@@ -6663,12 +6698,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
                case 0x0e:
                        PDEBUG(D_PROBE, "Find Sensor PAS202B");
                        sd->sensor = SENSOR_PAS202B;
-                       sd->sharpness = 1;
+/*                     sd->sharpness = 1; */
                        break;
                case 0x0f:
                        PDEBUG(D_PROBE, "Find Sensor PAS106");
                        sd->sensor = SENSOR_PAS106;
-                       vga = 0;                /* SIF */
                        break;
                case 0x10:
                case 0x12:
@@ -6734,31 +6768,38 @@ static int sd_config(struct gspca_dev *gspca_dev,
        if (sensor < 0x20) {
                if (sensor == -1 || sensor == 0x10 || sensor == 0x12)
                        reg_w(gspca_dev->dev, 0x02, 0x0010);
-               else
-                       reg_w(gspca_dev->dev, sensor & 0x0f, 0x0010);
                reg_r(gspca_dev, 0x0010);
        }
 
        cam = &gspca_dev->cam;
 /*fixme:test*/
        gspca_dev->nbalt--;
-       if (vga) {
-               cam->cam_mode = vga_mode;
-               cam->nmodes = ARRAY_SIZE(vga_mode);
-       } else {
+       switch (mode_tb[sd->sensor]) {
+       case 0:
                cam->cam_mode = sif_mode;
                cam->nmodes = ARRAY_SIZE(sif_mode);
+               break;
+       case 1:
+               cam->cam_mode = vga_mode;
+               cam->nmodes = ARRAY_SIZE(vga_mode);
+               break;
+       default:
+/*     case 2: */
+               cam->cam_mode = broken_vga_mode;
+               cam->nmodes = ARRAY_SIZE(broken_vga_mode);
+               break;
        }
-       sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
-       sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
-       sd->gamma = gamma[(int) sd->sensor];
-       sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value;
-       sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value;
+       sd->brightness = BRIGHTNESS_DEF;
+       sd->contrast = CONTRAST_DEF;
+       sd->gamma = gamma[sd->sensor];
+       sd->autogain = AUTOGAIN_DEF;
+       sd->lightfreq = FREQ_DEF;
        sd->quality = QUALITY_DEF;
 
        switch (sd->sensor) {
        case SENSOR_GC0305:
        case SENSOR_OV7620:
+       case SENSOR_PAS202B:
        case SENSOR_PO2030:
                gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX);
                break;
@@ -6769,14 +6810,13 @@ static int sd_config(struct gspca_dev *gspca_dev,
                break;
        }
 
-       /* switch the led off */
-       reg_w(gspca_dev->dev, 0x01, 0x0000);
        return 0;
 }
 
 /* this function is called at probe and resume time */
 static int sd_init(struct gspca_dev *gspca_dev)
 {
+       /* switch off the led */
        reg_w(gspca_dev->dev, 0x01, 0x0000);
        return 0;
 }
@@ -6785,28 +6825,27 @@ static int sd_start(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        struct usb_device *dev = gspca_dev->dev;
-       const struct usb_action *zc3_init;
        int mode;
        static const struct usb_action *init_tb[SENSOR_MAX][2] = {
                {adcm2700_Initial, adcm2700_InitialScale},      /* 0 */
-               {cs2102_InitialScale, cs2102_Initial},          /* 1 */
-               {cs2102K_InitialScale, cs2102K_Initial},        /* 2 */
+               {cs2102_Initial, cs2102_InitialScale},          /* 1 */
+               {cs2102K_Initial, cs2102K_InitialScale},        /* 2 */
                {gc0305_Initial, gc0305_InitialScale},          /* 3 */
-               {hdcs2020xb_InitialScale, hdcs2020xb_Initial},  /* 4 */
-               {hv7131bxx_InitialScale, hv7131bxx_Initial},    /* 5 */
-               {hv7131cxx_InitialScale, hv7131cxx_Initial},    /* 6 */
-               {icm105axx_InitialScale, icm105axx_Initial},    /* 7 */
-               {MC501CB_InitialScale, MC501CB_Initial},        /* 8 */
+               {hdcs2020b_Initial, hdcs2020b_InitialScale},    /* 4 */
+               {hv7131b_Initial, hv7131b_InitialScale},        /* 5 */
+               {hv7131r_Initial, hv7131r_InitialScale},        /* 6 */
+               {icm105a_Initial, icm105a_InitialScale},        /* 7 */
+               {mc501cb_Initial, mc501cb_InitialScale},        /* 8 */
                {mi0360soc_Initial, mi0360soc_InitialScale},    /* 9 */
-               {OV7620_mode0, OV7620_mode1},                   /* 10 */
-               {ov7630c_InitialScale, ov7630c_Initial},        /* 11 */
-               {pas106b_InitialScale, pas106b_Initial},        /* 12 */
+               {ov7620_Initial, ov7620_InitialScale},          /* 10 */
+               {ov7630c_Initial, ov7630c_InitialScale},        /* 11 */
+               {pas106b_Initial, pas106b_InitialScale},        /* 12 */
                {pas202b_Initial, pas202b_InitialScale},        /* 13 */
                {pb0330_Initial, pb0330_InitialScale},          /* 14 */
-               {PO2030_mode0, PO2030_mode1},                   /* 15 */
-               {tas5130CK_InitialScale, tas5130CK_Initial},    /* 16 */
+               {po2030_Initial, po2030_InitialScale},          /* 15 */
+               {tas5130cK_Initial, tas5130cK_InitialScale},    /* 16 */
                {tas5130cxx_Initial, tas5130cxx_InitialScale},  /* 17 */
-               {tas5130c_vf0250_InitialScale, tas5130c_vf0250_Initial},
+               {tas5130c_vf0250_Initial, tas5130c_vf0250_InitialScale},
                                                                /* 18 */
        };
 
@@ -6818,8 +6857,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                        0x21);          /* JPEG 422 */
        jpeg_set_qual(sd->jpeg_hdr, sd->quality);
 
-       mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
-       zc3_init = init_tb[(int) sd->sensor][mode];
+       mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
        switch (sd->sensor) {
        case SENSOR_HV7131C:
                zcxx_probeSensor(gspca_dev);
@@ -6828,7 +6866,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                usb_exchange(gspca_dev, pas106b_Initial_com);
                break;
        }
-       usb_exchange(gspca_dev, zc3_init);
+       usb_exchange(gspca_dev, init_tb[sd->sensor][mode]);
 
        switch (sd->sensor) {
        case SENSOR_ADCM2700:
@@ -6847,6 +6885,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
                reg_w(dev, 0x02, 0x003b);
                reg_w(dev, 0x00, 0x0038);
                break;
+       case SENSOR_PAS202B:
+               reg_w(dev, 0x03, 0x003b);
+               reg_w(dev, 0x0c, 0x003a);
+               reg_w(dev, 0x0b, 0x0039);
+               break;
        }
 
        setmatrix(gspca_dev);
@@ -6925,13 +6968,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
        switch (sd->sensor) {
        case SENSOR_PO2030:
                msleep(50);
-               reg_r(gspca_dev, 0x0008);
-               reg_r(gspca_dev, 0x0007);
-               /*fall thru*/
-       case SENSOR_PAS202B:
                reg_w(dev, 0x00, 0x0007);       /* (from win traces) */
                reg_w(dev, 0x02, ZC3XX_R008_CLOCKSETTING);
                break;
+       case SENSOR_PAS202B:
+               reg_w(dev, 0x32, 0x0007);       /* (from win traces) */
+               reg_w(dev, 0x02, ZC3XX_R008_CLOCKSETTING);
+               break;
        }
        return 0;
 }
@@ -7129,6 +7172,22 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
        return 0;
 }
 
+#ifdef CONFIG_INPUT
+static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
+                       u8 *data,               /* interrupt packet data */
+                       int len)                /* interrput packet length */
+{
+       if (len == 8 && data[4] == 1) {
+               input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
+               input_sync(gspca_dev->input_dev);
+               input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
+               input_sync(gspca_dev->input_dev);
+       }
+
+       return 0;
+}
+#endif
+
 static const struct sd_desc sd_desc = {
        .name = MODULE_NAME,
        .ctrls = sd_ctrls,
@@ -7141,6 +7200,9 @@ static const struct sd_desc sd_desc = {
        .querymenu = sd_querymenu,
        .get_jcomp = sd_get_jcomp,
        .set_jcomp = sd_set_jcomp,
+#ifdef CONFIG_INPUT
+       .int_pkt_scan = sd_int_pkt_scan,
+#endif
 };
 
 static const __devinitdata struct usb_device_id device_table[] = {