PageRenderTime 128ms CodeModel.GetById 13ms app.highlight 93ms RepoModel.GetById 0ms app.codeStats 1ms

/drivers/media/video/gspca/spca501.c

https://bitbucket.org/ndreys/linux-sunxi
C | 2200 lines | 1988 code | 94 blank | 118 comment | 21 complexity | a030ff87c3d8c02f9019a5fc03a8403f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
   1/*
   2 * SPCA501 chip based cameras initialization data
   3 *
   4 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License as published by
   8 * the Free Software Foundation; either version 2 of the License, or
   9 * any later version.
  10 *
  11 * This program is distributed in the hope that it will be useful,
  12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 * GNU General Public License for more details.
  15 *
  16 * You should have received a copy of the GNU General Public License
  17 * along with this program; if not, write to the Free Software
  18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19 *
  20 */
  21
  22#define MODULE_NAME "spca501"
  23
  24#include "gspca.h"
  25
  26MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
  27MODULE_DESCRIPTION("GSPCA/SPCA501 USB Camera Driver");
  28MODULE_LICENSE("GPL");
  29
  30/* specific webcam descriptor */
  31struct sd {
  32	struct gspca_dev gspca_dev;	/* !! must be the first item */
  33
  34	unsigned short contrast;
  35	__u8 brightness;
  36	__u8 colors;
  37	__u8 blue_balance;
  38	__u8 red_balance;
  39
  40	char subtype;
  41#define Arowana300KCMOSCamera 0
  42#define IntelCreateAndShare 1
  43#define KodakDVC325 2
  44#define MystFromOriUnknownCamera 3
  45#define SmileIntlCamera 4
  46#define ThreeComHomeConnectLite 5
  47#define ViewQuestM318B 6
  48};
  49
  50/* V4L2 controls supported by the driver */
  51static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
  52static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
  53static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
  54static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
  55static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
  56static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
  57static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
  58static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
  59static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
  60static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
  61
  62static const struct ctrl sd_ctrls[] = {
  63#define MY_BRIGHTNESS 0
  64	{
  65	    {
  66		.id      = V4L2_CID_BRIGHTNESS,
  67		.type    = V4L2_CTRL_TYPE_INTEGER,
  68		.name    = "Brightness",
  69		.minimum = 0,
  70		.maximum = 127,
  71		.step    = 1,
  72		.default_value = 0,
  73	    },
  74	    .set = sd_setbrightness,
  75	    .get = sd_getbrightness,
  76	},
  77#define MY_CONTRAST 1
  78	{
  79	    {
  80		.id      = V4L2_CID_CONTRAST,
  81		.type    = V4L2_CTRL_TYPE_INTEGER,
  82		.name    = "Contrast",
  83		.minimum = 0,
  84		.maximum = 64725,
  85		.step    = 1,
  86		.default_value = 64725,
  87	    },
  88	    .set = sd_setcontrast,
  89	    .get = sd_getcontrast,
  90	},
  91#define MY_COLOR 2
  92	{
  93	    {
  94		.id      = V4L2_CID_SATURATION,
  95		.type    = V4L2_CTRL_TYPE_INTEGER,
  96		.name    = "Color",
  97		.minimum = 0,
  98		.maximum = 63,
  99		.step    = 1,
 100		.default_value = 20,
 101	    },
 102	    .set = sd_setcolors,
 103	    .get = sd_getcolors,
 104	},
 105#define MY_BLUE_BALANCE 3
 106	{
 107	    {
 108		.id      = V4L2_CID_BLUE_BALANCE,
 109		.type    = V4L2_CTRL_TYPE_INTEGER,
 110		.name    = "Blue Balance",
 111		.minimum = 0,
 112		.maximum = 127,
 113		.step    = 1,
 114		.default_value = 0,
 115	    },
 116	    .set = sd_setblue_balance,
 117	    .get = sd_getblue_balance,
 118	},
 119#define MY_RED_BALANCE 4
 120	{
 121	    {
 122		.id      = V4L2_CID_RED_BALANCE,
 123		.type    = V4L2_CTRL_TYPE_INTEGER,
 124		.name    = "Red Balance",
 125		.minimum = 0,
 126		.maximum = 127,
 127		.step    = 1,
 128		.default_value = 0,
 129	    },
 130	    .set = sd_setred_balance,
 131	    .get = sd_getred_balance,
 132	},
 133};
 134
 135static const struct v4l2_pix_format vga_mode[] = {
 136	{160, 120, V4L2_PIX_FMT_SPCA501, V4L2_FIELD_NONE,
 137		.bytesperline = 160,
 138		.sizeimage = 160 * 120 * 3 / 2,
 139		.colorspace = V4L2_COLORSPACE_SRGB,
 140		.priv = 2},
 141	{320, 240, V4L2_PIX_FMT_SPCA501, V4L2_FIELD_NONE,
 142		.bytesperline = 320,
 143		.sizeimage = 320 * 240 * 3 / 2,
 144		.colorspace = V4L2_COLORSPACE_SRGB,
 145		.priv = 1},
 146	{640, 480, V4L2_PIX_FMT_SPCA501, V4L2_FIELD_NONE,
 147		.bytesperline = 640,
 148		.sizeimage = 640 * 480 * 3 / 2,
 149		.colorspace = V4L2_COLORSPACE_SRGB,
 150		.priv = 0},
 151};
 152
 153#define SPCA50X_REG_USB 0x2	/* spca505 501 */
 154/*
 155 * Data to initialize a SPCA501. From a capture file provided by Bill Roehl
 156 * With SPCA501 chip description
 157 */
 158#define CCDSP_SET		/* set CCDSP parameters */
 159#define TG_SET			/* set time generator set */
 160#undef DSPWIN_SET		/* set DSP windows parameters */
 161#undef ALTER_GAMA	/* Set alternate set to YUV transform coeffs. */
 162#define SPCA501_SNAPBIT 0x80
 163#define SPCA501_SNAPCTRL 0x10
 164/* Frame packet header offsets for the spca501 */
 165#define SPCA501_OFFSET_GPIO   1
 166#define SPCA501_OFFSET_TYPE   2
 167#define SPCA501_OFFSET_TURN3A 3
 168#define SPCA501_OFFSET_FRAMSEQ 4
 169#define SPCA501_OFFSET_COMPRESS 5
 170#define SPCA501_OFFSET_QUANT 6
 171#define SPCA501_OFFSET_QUANT2 7
 172#define SPCA501_OFFSET_DATA 8
 173
 174#define SPCA501_PROP_COMP_ENABLE(d) ((d) & 1)
 175#define SPCA501_PROP_SNAP(d) ((d) & 0x40)
 176#define SPCA501_PROP_SNAP_CTRL(d) ((d) & 0x10)
 177#define SPCA501_PROP_COMP_THRESH(d) (((d) & 0x0e) >> 1)
 178#define SPCA501_PROP_COMP_QUANT(d) (((d) & 0x70) >> 4)
 179
 180/* SPCA501 CCDSP control */
 181#define SPCA501_REG_CCDSP 0x01
 182/* SPCA501 control/status registers */
 183#define SPCA501_REG_CTLRL 0x02
 184
 185/* registers for color correction and YUV transformation */
 186#define SPCA501_A11 0x08
 187#define SPCA501_A12 0x09
 188#define SPCA501_A13 0x0A
 189#define SPCA501_A21 0x0B
 190#define SPCA501_A22 0x0C
 191#define SPCA501_A23 0x0D
 192#define SPCA501_A31 0x0E
 193#define SPCA501_A32 0x0F
 194#define SPCA501_A33 0x10
 195
 196/* Data for video camera initialization before capturing */
 197static const __u16 spca501_open_data[][3] = {
 198	/* bmRequest,value,index */
 199
 200	{0x2, 0x50, 0x00},	/* C/S enable soft reset */
 201	{0x2, 0x40, 0x00},	/* C/S disable soft reset */
 202	{0x2, 0x02, 0x05},	/* C/S general purpose I/O data */
 203	{0x2, 0x03, 0x05},	/* C/S general purpose I/O data */
 204
 205#ifdef CCDSP_SET
 206	{0x1, 0x38, 0x01},	/* CCDSP options */
 207	{0x1, 0x05, 0x02}, /* CCDSP Optical black level for user settings */
 208	{0x1, 0xC0, 0x03},	/* CCDSP Optical black settings */
 209
 210	{0x1, 0x67, 0x07},
 211	{0x1, 0x63, 0x3f},	/* CCDSP CCD gamma enable */
 212	{0x1, 0x03, 0x56},	/* Add gamma correction */
 213
 214	{0x1, 0xFF, 0x15},	/* CCDSP High luminance for white balance */
 215	{0x1, 0x01, 0x16},	/* CCDSP Low luminance for white balance */
 216
 217/* Color correction and RGB-to-YUV transformation coefficients changing */
 218#ifdef ALTER_GAMA
 219	{0x0, 0x00, 0x08},	/* A11 */
 220	{0x0, 0x00, 0x09},	/* A12 */
 221	{0x0, 0x90, 0x0A},	/* A13 */
 222	{0x0, 0x12, 0x0B},	/* A21 */
 223	{0x0, 0x00, 0x0C},	/* A22 */
 224	{0x0, 0x00, 0x0D},	/* A23 */
 225	{0x0, 0x00, 0x0E},	/* A31 */
 226	{0x0, 0x02, 0x0F},	/* A32 */
 227	{0x0, 0x00, 0x10},	/* A33 */
 228#else
 229	{0x1, 0x2a, 0x08},	/* A11 0x31 */
 230	{0x1, 0xf8, 0x09},	/* A12 f8 */
 231	{0x1, 0xf8, 0x0A},	/* A13 f8 */
 232	{0x1, 0xf8, 0x0B},	/* A21 f8 */
 233	{0x1, 0x14, 0x0C},	/* A22 0x14 */
 234	{0x1, 0xf8, 0x0D},	/* A23 f8 */
 235	{0x1, 0xf8, 0x0E},	/* A31 f8 */
 236	{0x1, 0xf8, 0x0F},	/* A32 f8 */
 237	{0x1, 0x20, 0x10},	/* A33 0x20 */
 238#endif
 239	{0x1, 0x00, 0x11},	/* R offset */
 240	{0x1, 0x00, 0x12},	/* G offset */
 241	{0x1, 0x00, 0x13},	/* B offset */
 242	{0x1, 0x00, 0x14},	/* GB offset */
 243
 244#endif
 245
 246#ifdef TG_SET
 247	/* Time generator manipulations */
 248	{0x0, 0xfc, 0x0},	/* Set up high bits of shutter speed */
 249	{0x0, 0x01, 0x1},	/* Set up low bits of shutter speed */
 250
 251	{0x0, 0xe4, 0x04},	/* DCLK*2 clock phase adjustment */
 252	{0x0, 0x08, 0x05},	/* ADCK phase adjustment, inv. ext. VB */
 253	{0x0, 0x03, 0x06},	/* FR phase adjustment */
 254	{0x0, 0x01, 0x07},	/* FCDS phase adjustment */
 255	{0x0, 0x39, 0x08},	/* FS phase adjustment */
 256	{0x0, 0x88, 0x0a},	/* FH1 phase and delay adjustment */
 257	{0x0, 0x03, 0x0f},	/* pixel identification */
 258	{0x0, 0x00, 0x11},	/* clock source selection (default) */
 259
 260	/*VERY strange manipulations with
 261	 * select DMCLP or OBPX to be ADCLP output (0x0C)
 262	 * OPB always toggle or not (0x0D) but they allow
 263	 * us to set up brightness
 264	 */
 265	{0x0, 0x01, 0x0c},
 266	{0x0, 0xe0, 0x0d},
 267	/* Done */
 268#endif
 269
 270#ifdef DSPWIN_SET
 271	{0x1, 0xa0, 0x01},	/* Setting image processing parameters */
 272	{0x1, 0x1c, 0x17},	/* Changing Windows positions X1 */
 273	{0x1, 0xe2, 0x19},	/* X2 */
 274	{0x1, 0x1c, 0x1b},	/* X3 */
 275	{0x1, 0xe2, 0x1d},	/* X4 */
 276	{0x1, 0x5f, 0x1f},	/* X5 */
 277	{0x1, 0x32, 0x20},	/* Y5 */
 278	{0x1, 0x01, 0x10},	/* Changing A33 */
 279#endif
 280
 281	{0x2, 0x204a, 0x07},/* Setting video compression & resolution 160x120 */
 282	{0x2, 0x94, 0x06},	/* Setting video no compression */
 283	{}
 284};
 285
 286/*
 287   The SPCAxxx docs from Sunplus document these values
 288   in tables, one table per register number.  In the data
 289   below, dmRequest is the register number, index is the Addr,
 290   and value is a combination of Bit values.
 291   Bit  Value (hex)
 292   0    01
 293   1    02
 294   2    04
 295   3    08
 296   4    10
 297   5    20
 298   6    40
 299   7    80
 300 */
 301
 302/* Data for chip initialization (set default values) */
 303static const __u16 spca501_init_data[][3] = {
 304	/* Set all the values to powerup defaults */
 305	/* bmRequest,value,index */
 306	{0x0, 0xAA, 0x00},
 307	{0x0, 0x02, 0x01},
 308	{0x0, 0x01, 0x02},
 309	{0x0, 0x02, 0x03},
 310	{0x0, 0xCE, 0x04},
 311	{0x0, 0x00, 0x05},
 312	{0x0, 0x00, 0x06},
 313	{0x0, 0x00, 0x07},
 314	{0x0, 0x00, 0x08},
 315	{0x0, 0x00, 0x09},
 316	{0x0, 0x90, 0x0A},
 317	{0x0, 0x12, 0x0B},
 318	{0x0, 0x00, 0x0C},
 319	{0x0, 0x00, 0x0D},
 320	{0x0, 0x00, 0x0E},
 321	{0x0, 0x02, 0x0F},
 322	{0x0, 0x00, 0x10},
 323	{0x0, 0x00, 0x11},
 324	{0x0, 0x00, 0x12},
 325	{0x0, 0x00, 0x13},
 326	{0x0, 0x00, 0x14},
 327	{0x0, 0x00, 0x15},
 328	{0x0, 0x00, 0x16},
 329	{0x0, 0x00, 0x17},
 330	{0x0, 0x00, 0x18},
 331	{0x0, 0x00, 0x19},
 332	{0x0, 0x00, 0x1A},
 333	{0x0, 0x00, 0x1B},
 334	{0x0, 0x00, 0x1C},
 335	{0x0, 0x00, 0x1D},
 336	{0x0, 0x00, 0x1E},
 337	{0x0, 0x00, 0x1F},
 338	{0x0, 0x00, 0x20},
 339	{0x0, 0x00, 0x21},
 340	{0x0, 0x00, 0x22},
 341	{0x0, 0x00, 0x23},
 342	{0x0, 0x00, 0x24},
 343	{0x0, 0x00, 0x25},
 344	{0x0, 0x00, 0x26},
 345	{0x0, 0x00, 0x27},
 346	{0x0, 0x00, 0x28},
 347	{0x0, 0x00, 0x29},
 348	{0x0, 0x00, 0x2A},
 349	{0x0, 0x00, 0x2B},
 350	{0x0, 0x00, 0x2C},
 351	{0x0, 0x00, 0x2D},
 352	{0x0, 0x00, 0x2E},
 353	{0x0, 0x00, 0x2F},
 354	{0x0, 0x00, 0x30},
 355	{0x0, 0x00, 0x31},
 356	{0x0, 0x00, 0x32},
 357	{0x0, 0x00, 0x33},
 358	{0x0, 0x00, 0x34},
 359	{0x0, 0x00, 0x35},
 360	{0x0, 0x00, 0x36},
 361	{0x0, 0x00, 0x37},
 362	{0x0, 0x00, 0x38},
 363	{0x0, 0x00, 0x39},
 364	{0x0, 0x00, 0x3A},
 365	{0x0, 0x00, 0x3B},
 366	{0x0, 0x00, 0x3C},
 367	{0x0, 0x00, 0x3D},
 368	{0x0, 0x00, 0x3E},
 369	{0x0, 0x00, 0x3F},
 370	{0x0, 0x00, 0x40},
 371	{0x0, 0x00, 0x41},
 372	{0x0, 0x00, 0x42},
 373	{0x0, 0x00, 0x43},
 374	{0x0, 0x00, 0x44},
 375	{0x0, 0x00, 0x45},
 376	{0x0, 0x00, 0x46},
 377	{0x0, 0x00, 0x47},
 378	{0x0, 0x00, 0x48},
 379	{0x0, 0x00, 0x49},
 380	{0x0, 0x00, 0x4A},
 381	{0x0, 0x00, 0x4B},
 382	{0x0, 0x00, 0x4C},
 383	{0x0, 0x00, 0x4D},
 384	{0x0, 0x00, 0x4E},
 385	{0x0, 0x00, 0x4F},
 386	{0x0, 0x00, 0x50},
 387	{0x0, 0x00, 0x51},
 388	{0x0, 0x00, 0x52},
 389	{0x0, 0x00, 0x53},
 390	{0x0, 0x00, 0x54},
 391	{0x0, 0x00, 0x55},
 392	{0x0, 0x00, 0x56},
 393	{0x0, 0x00, 0x57},
 394	{0x0, 0x00, 0x58},
 395	{0x0, 0x00, 0x59},
 396	{0x0, 0x00, 0x5A},
 397	{0x0, 0x00, 0x5B},
 398	{0x0, 0x00, 0x5C},
 399	{0x0, 0x00, 0x5D},
 400	{0x0, 0x00, 0x5E},
 401	{0x0, 0x00, 0x5F},
 402	{0x0, 0x00, 0x60},
 403	{0x0, 0x00, 0x61},
 404	{0x0, 0x00, 0x62},
 405	{0x0, 0x00, 0x63},
 406	{0x0, 0x00, 0x64},
 407	{0x0, 0x00, 0x65},
 408	{0x0, 0x00, 0x66},
 409	{0x0, 0x00, 0x67},
 410	{0x0, 0x00, 0x68},
 411	{0x0, 0x00, 0x69},
 412	{0x0, 0x00, 0x6A},
 413	{0x0, 0x00, 0x6B},
 414	{0x0, 0x00, 0x6C},
 415	{0x0, 0x00, 0x6D},
 416	{0x0, 0x00, 0x6E},
 417	{0x0, 0x00, 0x6F},
 418	{0x0, 0x00, 0x70},
 419	{0x0, 0x00, 0x71},
 420	{0x0, 0x00, 0x72},
 421	{0x0, 0x00, 0x73},
 422	{0x0, 0x00, 0x74},
 423	{0x0, 0x00, 0x75},
 424	{0x0, 0x00, 0x76},
 425	{0x0, 0x00, 0x77},
 426	{0x0, 0x00, 0x78},
 427	{0x0, 0x00, 0x79},
 428	{0x0, 0x00, 0x7A},
 429	{0x0, 0x00, 0x7B},
 430	{0x0, 0x00, 0x7C},
 431	{0x0, 0x00, 0x7D},
 432	{0x0, 0x00, 0x7E},
 433	{0x0, 0x00, 0x7F},
 434	{0x0, 0x00, 0x80},
 435	{0x0, 0x00, 0x81},
 436	{0x0, 0x00, 0x82},
 437	{0x0, 0x00, 0x83},
 438	{0x0, 0x00, 0x84},
 439	{0x0, 0x00, 0x85},
 440	{0x0, 0x00, 0x86},
 441	{0x0, 0x00, 0x87},
 442	{0x0, 0x00, 0x88},
 443	{0x0, 0x00, 0x89},
 444	{0x0, 0x00, 0x8A},
 445	{0x0, 0x00, 0x8B},
 446	{0x0, 0x00, 0x8C},
 447	{0x0, 0x00, 0x8D},
 448	{0x0, 0x00, 0x8E},
 449	{0x0, 0x00, 0x8F},
 450	{0x0, 0x00, 0x90},
 451	{0x0, 0x00, 0x91},
 452	{0x0, 0x00, 0x92},
 453	{0x0, 0x00, 0x93},
 454	{0x0, 0x00, 0x94},
 455	{0x0, 0x00, 0x95},
 456	{0x0, 0x00, 0x96},
 457	{0x0, 0x00, 0x97},
 458	{0x0, 0x00, 0x98},
 459	{0x0, 0x00, 0x99},
 460	{0x0, 0x00, 0x9A},
 461	{0x0, 0x00, 0x9B},
 462	{0x0, 0x00, 0x9C},
 463	{0x0, 0x00, 0x9D},
 464	{0x0, 0x00, 0x9E},
 465	{0x0, 0x00, 0x9F},
 466	{0x0, 0x00, 0xA0},
 467	{0x0, 0x00, 0xA1},
 468	{0x0, 0x00, 0xA2},
 469	{0x0, 0x00, 0xA3},
 470	{0x0, 0x00, 0xA4},
 471	{0x0, 0x00, 0xA5},
 472	{0x0, 0x00, 0xA6},
 473	{0x0, 0x00, 0xA7},
 474	{0x0, 0x00, 0xA8},
 475	{0x0, 0x00, 0xA9},
 476	{0x0, 0x00, 0xAA},
 477	{0x0, 0x00, 0xAB},
 478	{0x0, 0x00, 0xAC},
 479	{0x0, 0x00, 0xAD},
 480	{0x0, 0x00, 0xAE},
 481	{0x0, 0x00, 0xAF},
 482	{0x0, 0x00, 0xB0},
 483	{0x0, 0x00, 0xB1},
 484	{0x0, 0x00, 0xB2},
 485	{0x0, 0x00, 0xB3},
 486	{0x0, 0x00, 0xB4},
 487	{0x0, 0x00, 0xB5},
 488	{0x0, 0x00, 0xB6},
 489	{0x0, 0x00, 0xB7},
 490	{0x0, 0x00, 0xB8},
 491	{0x0, 0x00, 0xB9},
 492	{0x0, 0x00, 0xBA},
 493	{0x0, 0x00, 0xBB},
 494	{0x0, 0x00, 0xBC},
 495	{0x0, 0x00, 0xBD},
 496	{0x0, 0x00, 0xBE},
 497	{0x0, 0x00, 0xBF},
 498	{0x0, 0x00, 0xC0},
 499	{0x0, 0x00, 0xC1},
 500	{0x0, 0x00, 0xC2},
 501	{0x0, 0x00, 0xC3},
 502	{0x0, 0x00, 0xC4},
 503	{0x0, 0x00, 0xC5},
 504	{0x0, 0x00, 0xC6},
 505	{0x0, 0x00, 0xC7},
 506	{0x0, 0x00, 0xC8},
 507	{0x0, 0x00, 0xC9},
 508	{0x0, 0x00, 0xCA},
 509	{0x0, 0x00, 0xCB},
 510	{0x0, 0x00, 0xCC},
 511	{0x1, 0xF4, 0x00},
 512	{0x1, 0x38, 0x01},
 513	{0x1, 0x40, 0x02},
 514	{0x1, 0x0A, 0x03},
 515	{0x1, 0x40, 0x04},
 516	{0x1, 0x40, 0x05},
 517	{0x1, 0x40, 0x06},
 518	{0x1, 0x67, 0x07},
 519	{0x1, 0x31, 0x08},
 520	{0x1, 0x00, 0x09},
 521	{0x1, 0x00, 0x0A},
 522	{0x1, 0x00, 0x0B},
 523	{0x1, 0x14, 0x0C},
 524	{0x1, 0x00, 0x0D},
 525	{0x1, 0x00, 0x0E},
 526	{0x1, 0x00, 0x0F},
 527	{0x1, 0x1E, 0x10},
 528	{0x1, 0x00, 0x11},
 529	{0x1, 0x00, 0x12},
 530	{0x1, 0x00, 0x13},
 531	{0x1, 0x00, 0x14},
 532	{0x1, 0xFF, 0x15},
 533	{0x1, 0x01, 0x16},
 534	{0x1, 0x32, 0x17},
 535	{0x1, 0x23, 0x18},
 536	{0x1, 0xCE, 0x19},
 537	{0x1, 0x23, 0x1A},
 538	{0x1, 0x32, 0x1B},
 539	{0x1, 0x8D, 0x1C},
 540	{0x1, 0xCE, 0x1D},
 541	{0x1, 0x8D, 0x1E},
 542	{0x1, 0x00, 0x1F},
 543	{0x1, 0x00, 0x20},
 544	{0x1, 0xFF, 0x3E},
 545	{0x1, 0x02, 0x3F},
 546	{0x1, 0x00, 0x40},
 547	{0x1, 0x00, 0x41},
 548	{0x1, 0x00, 0x42},
 549	{0x1, 0x00, 0x43},
 550	{0x1, 0x00, 0x44},
 551	{0x1, 0x00, 0x45},
 552	{0x1, 0x00, 0x46},
 553	{0x1, 0x00, 0x47},
 554	{0x1, 0x00, 0x48},
 555	{0x1, 0x00, 0x49},
 556	{0x1, 0x00, 0x4A},
 557	{0x1, 0x00, 0x4B},
 558	{0x1, 0x00, 0x4C},
 559	{0x1, 0x00, 0x4D},
 560	{0x1, 0x00, 0x4E},
 561	{0x1, 0x00, 0x4F},
 562	{0x1, 0x00, 0x50},
 563	{0x1, 0x00, 0x51},
 564	{0x1, 0x00, 0x52},
 565	{0x1, 0x00, 0x53},
 566	{0x1, 0x00, 0x54},
 567	{0x1, 0x00, 0x55},
 568	{0x1, 0x00, 0x56},
 569	{0x1, 0x00, 0x57},
 570	{0x1, 0x00, 0x58},
 571	{0x1, 0x00, 0x59},
 572	{0x1, 0x00, 0x5A},
 573	{0x2, 0x03, 0x00},
 574	{0x2, 0x00, 0x01},
 575	{0x2, 0x00, 0x05},
 576	{0x2, 0x00, 0x06},
 577	{0x2, 0x00, 0x07},
 578	{0x2, 0x00, 0x10},
 579	{0x2, 0x00, 0x11},
 580	/* Strange - looks like the 501 driver doesn't do anything
 581	 * at insert time except read the EEPROM
 582	 */
 583	{}
 584};
 585
 586/* Data for video camera init before capture.
 587 * Capture and decoding by Colin Peart.
 588 * This is is for the 3com HomeConnect Lite which is spca501a based.
 589 */
 590static const __u16 spca501_3com_open_data[][3] = {
 591	/* bmRequest,value,index */
 592	{0x2, 0x0050, 0x0000},	/* C/S Enable TG soft reset, timing mode=010 */
 593	{0x2, 0x0043, 0x0000},	/* C/S Disable TG soft reset, timing mode=010 */
 594	{0x2, 0x0002, 0x0005},	/* C/S GPIO */
 595	{0x2, 0x0003, 0x0005},	/* C/S GPIO */
 596
 597#ifdef CCDSP_SET
 598	{0x1, 0x0020, 0x0001},	/* CCDSP Options */
 599
 600	{0x1, 0x0020, 0x0002},	/* CCDSP Black Level */
 601	{0x1, 0x006e, 0x0007},	/* CCDSP Gamma options */
 602	{0x1, 0x0090, 0x0015},	/* CCDSP Luminance Low */
 603	{0x1, 0x00ff, 0x0016},	/* CCDSP Luminance High */
 604	{0x1, 0x0003, 0x003F},	/* CCDSP Gamma correction toggle */
 605
 606#ifdef ALTER_GAMMA
 607	{0x1, 0x0010, 0x0008},	/* CCDSP YUV A11 */
 608	{0x1, 0x0000, 0x0009},	/* CCDSP YUV A12 */
 609	{0x1, 0x0000, 0x000a},	/* CCDSP YUV A13 */
 610	{0x1, 0x0000, 0x000b},	/* CCDSP YUV A21 */
 611	{0x1, 0x0010, 0x000c},	/* CCDSP YUV A22 */
 612	{0x1, 0x0000, 0x000d},	/* CCDSP YUV A23 */
 613	{0x1, 0x0000, 0x000e},	/* CCDSP YUV A31 */
 614	{0x1, 0x0000, 0x000f},	/* CCDSP YUV A32 */
 615	{0x1, 0x0010, 0x0010},	/* CCDSP YUV A33 */
 616	{0x1, 0x0000, 0x0011},	/* CCDSP R Offset */
 617	{0x1, 0x0000, 0x0012},	/* CCDSP G Offset */
 618	{0x1, 0x0001, 0x0013},	/* CCDSP B Offset */
 619	{0x1, 0x0001, 0x0014},	/* CCDSP BG Offset */
 620	{0x1, 0x003f, 0x00C1},	/* CCDSP Gamma Correction Enable */
 621#endif
 622#endif
 623
 624#ifdef TG_SET
 625	{0x0, 0x00fc, 0x0000},	/* TG Shutter Speed High Bits */
 626	{0x0, 0x0000, 0x0001},	/* TG Shutter Speed Low Bits */
 627	{0x0, 0x00e4, 0x0004},	/* TG DCLK*2 Adjust */
 628	{0x0, 0x0008, 0x0005},	/* TG ADCK Adjust */
 629	{0x0, 0x0003, 0x0006},	/* TG FR Phase Adjust */
 630	{0x0, 0x0001, 0x0007},	/* TG FCDS Phase Adjust */
 631	{0x0, 0x0039, 0x0008},	/* TG FS Phase Adjust */
 632	{0x0, 0x0088, 0x000a},	/* TG MH1 */
 633	{0x0, 0x0003, 0x000f},	/* TG Pixel ID */
 634
 635	/* Like below, unexplained toglleing */
 636	{0x0, 0x0080, 0x000c},
 637	{0x0, 0x0000, 0x000d},
 638	{0x0, 0x0080, 0x000c},
 639	{0x0, 0x0004, 0x000d},
 640	{0x0, 0x0000, 0x000c},
 641	{0x0, 0x0000, 0x000d},
 642	{0x0, 0x0040, 0x000c},
 643	{0x0, 0x0017, 0x000d},
 644	{0x0, 0x00c0, 0x000c},
 645	{0x0, 0x0000, 0x000d},
 646	{0x0, 0x0080, 0x000c},
 647	{0x0, 0x0006, 0x000d},
 648	{0x0, 0x0080, 0x000c},
 649	{0x0, 0x0004, 0x000d},
 650	{0x0, 0x0002, 0x0003},
 651#endif
 652
 653#ifdef DSPWIN_SET
 654	{0x1, 0x001c, 0x0017},	/* CCDSP W1 Start X */
 655	{0x1, 0x00e2, 0x0019},	/* CCDSP W2 Start X */
 656	{0x1, 0x001c, 0x001b},	/* CCDSP W3 Start X */
 657	{0x1, 0x00e2, 0x001d},	/* CCDSP W4 Start X */
 658	{0x1, 0x00aa, 0x001f},	/* CCDSP W5 Start X */
 659	{0x1, 0x0070, 0x0020},	/* CCDSP W5 Start Y */
 660#endif
 661	{0x0, 0x0001, 0x0010},	/* TG Start Clock */
 662
 663/*	{0x2, 0x006a, 0x0001},	 * C/S Enable ISOSYNCH Packet Engine */
 664	{0x2, 0x0068, 0x0001},	/* C/S Diable ISOSYNCH Packet Engine */
 665	{0x2, 0x0000, 0x0005},
 666	{0x2, 0x0043, 0x0000},	/* C/S Set Timing Mode, Disable TG soft reset */
 667	{0x2, 0x0043, 0x0000},	/* C/S Set Timing Mode, Disable TG soft reset */
 668	{0x2, 0x0002, 0x0005},	/* C/S GPIO */
 669	{0x2, 0x0003, 0x0005},	/* C/S GPIO */
 670
 671	{0x2, 0x006a, 0x0001},	/* C/S Enable ISOSYNCH Packet Engine */
 672	{}
 673};
 674
 675/*
 676 * Data used to initialize a SPCA501C with HV7131B sensor.
 677 * From a capture file taken with USBSnoop v 1.5
 678 * I have a "SPCA501C pc camera chipset" manual by sunplus, but some
 679 * of the value meanings are obscure or simply "reserved".
 680 * to do list:
 681 * 1) Understand what every value means
 682 * 2) Understand why some values seem to appear more than once
 683 * 3) Write a small comment for each line of the following arrays.
 684 */
 685static const __u16 spca501c_arowana_open_data[][3] = {
 686	/* bmRequest,value,index */
 687	{0x02, 0x0007, 0x0005},
 688	{0x02, 0xa048, 0x0000},
 689	{0x05, 0x0022, 0x0004},
 690	{0x01, 0x0006, 0x0011},
 691	{0x01, 0x00ff, 0x0012},
 692	{0x01, 0x0014, 0x0013},
 693	{0x01, 0x0000, 0x0014},
 694	{0x01, 0x0042, 0x0051},
 695	{0x01, 0x0040, 0x0052},
 696	{0x01, 0x0051, 0x0053},
 697	{0x01, 0x0040, 0x0054},
 698	{0x01, 0x0000, 0x0055},
 699	{0x00, 0x0025, 0x0000},
 700	{0x00, 0x0026, 0x0000},
 701	{0x00, 0x0001, 0x0000},
 702	{0x00, 0x0027, 0x0000},
 703	{0x00, 0x008a, 0x0000},
 704	{}
 705};
 706
 707static const __u16 spca501c_arowana_init_data[][3] = {
 708	/* bmRequest,value,index */
 709	{0x02, 0x0007, 0x0005},
 710	{0x02, 0xa048, 0x0000},
 711	{0x05, 0x0022, 0x0004},
 712	{0x01, 0x0006, 0x0011},
 713	{0x01, 0x00ff, 0x0012},
 714	{0x01, 0x0014, 0x0013},
 715	{0x01, 0x0000, 0x0014},
 716	{0x01, 0x0042, 0x0051},
 717	{0x01, 0x0040, 0x0052},
 718	{0x01, 0x0051, 0x0053},
 719	{0x01, 0x0040, 0x0054},
 720	{0x01, 0x0000, 0x0055},
 721	{0x00, 0x0025, 0x0000},
 722	{0x00, 0x0026, 0x0000},
 723	{0x00, 0x0001, 0x0000},
 724	{0x00, 0x0027, 0x0000},
 725	{0x00, 0x008a, 0x0000},
 726	{0x02, 0x0000, 0x0005},
 727	{0x02, 0x0007, 0x0005},
 728	{0x02, 0x2000, 0x0000},
 729	{0x05, 0x0022, 0x0004},
 730	{0x05, 0x0015, 0x0001},
 731	{0x05, 0x00ea, 0x0000},
 732	{0x05, 0x0021, 0x0001},
 733	{0x05, 0x00d2, 0x0000},
 734	{0x05, 0x0023, 0x0001},
 735	{0x05, 0x0003, 0x0000},
 736	{0x05, 0x0030, 0x0001},
 737	{0x05, 0x002b, 0x0000},
 738	{0x05, 0x0031, 0x0001},
 739	{0x05, 0x0023, 0x0000},
 740	{0x05, 0x0032, 0x0001},
 741	{0x05, 0x0023, 0x0000},
 742	{0x05, 0x0033, 0x0001},
 743	{0x05, 0x0023, 0x0000},
 744	{0x05, 0x0034, 0x0001},
 745	{0x05, 0x0002, 0x0000},
 746	{0x05, 0x0050, 0x0001},
 747	{0x05, 0x0000, 0x0000},
 748	{0x05, 0x0051, 0x0001},
 749	{0x05, 0x0000, 0x0000},
 750	{0x05, 0x0052, 0x0001},
 751	{0x05, 0x0000, 0x0000},
 752	{0x05, 0x0054, 0x0001},
 753	{0x05, 0x0001, 0x0000},
 754	{0x00, 0x0000, 0x0001},
 755	{0x00, 0x0000, 0x0002},
 756	{0x00, 0x000c, 0x0003},
 757	{0x00, 0x0000, 0x0004},
 758	{0x00, 0x0090, 0x0005},
 759	{0x00, 0x0000, 0x0006},
 760	{0x00, 0x0040, 0x0007},
 761	{0x00, 0x00c0, 0x0008},
 762	{0x00, 0x004a, 0x0009},
 763	{0x00, 0x0000, 0x000a},
 764	{0x00, 0x0000, 0x000b},
 765	{0x00, 0x0001, 0x000c},
 766	{0x00, 0x0001, 0x000d},
 767	{0x00, 0x0000, 0x000e},
 768	{0x00, 0x0002, 0x000f},
 769	{0x00, 0x0001, 0x0010},
 770	{0x00, 0x0000, 0x0011},
 771	{0x00, 0x0000, 0x0012},
 772	{0x00, 0x0002, 0x0020},
 773	{0x00, 0x0080, 0x0021},
 774	{0x00, 0x0001, 0x0022},
 775	{0x00, 0x00e0, 0x0023},
 776	{0x00, 0x0000, 0x0024},
 777	{0x00, 0x00d5, 0x0025},
 778	{0x00, 0x0000, 0x0026},
 779	{0x00, 0x000b, 0x0027},
 780	{0x00, 0x0000, 0x0046},
 781	{0x00, 0x0000, 0x0047},
 782	{0x00, 0x0000, 0x0048},
 783	{0x00, 0x0000, 0x0049},
 784	{0x00, 0x0008, 0x004a},
 785	{0xff, 0x0000, 0x00d0},
 786	{0xff, 0x00d8, 0x00d1},
 787	{0xff, 0x0000, 0x00d4},
 788	{0xff, 0x0000, 0x00d5},
 789	{0x01, 0x00a6, 0x0000},
 790	{0x01, 0x0028, 0x0001},
 791	{0x01, 0x0000, 0x0002},
 792	{0x01, 0x000a, 0x0003},
 793	{0x01, 0x0040, 0x0004},
 794	{0x01, 0x0066, 0x0007},
 795	{0x01, 0x0011, 0x0008},
 796	{0x01, 0x0032, 0x0009},
 797	{0x01, 0x00fd, 0x000a},
 798	{0x01, 0x0038, 0x000b},
 799	{0x01, 0x00d1, 0x000c},
 800	{0x01, 0x00f7, 0x000d},
 801	{0x01, 0x00ed, 0x000e},
 802	{0x01, 0x00d8, 0x000f},
 803	{0x01, 0x0038, 0x0010},
 804	{0x01, 0x00ff, 0x0015},
 805	{0x01, 0x0001, 0x0016},
 806	{0x01, 0x0032, 0x0017},
 807	{0x01, 0x0023, 0x0018},
 808	{0x01, 0x00ce, 0x0019},
 809	{0x01, 0x0023, 0x001a},
 810	{0x01, 0x0032, 0x001b},
 811	{0x01, 0x008d, 0x001c},
 812	{0x01, 0x00ce, 0x001d},
 813	{0x01, 0x008d, 0x001e},
 814	{0x01, 0x0000, 0x001f},
 815	{0x01, 0x0000, 0x0020},
 816	{0x01, 0x00ff, 0x003e},
 817	{0x01, 0x0003, 0x003f},
 818	{0x01, 0x0000, 0x0040},
 819	{0x01, 0x0035, 0x0041},
 820	{0x01, 0x0053, 0x0042},
 821	{0x01, 0x0069, 0x0043},
 822	{0x01, 0x007c, 0x0044},
 823	{0x01, 0x008c, 0x0045},
 824	{0x01, 0x009a, 0x0046},
 825	{0x01, 0x00a8, 0x0047},
 826	{0x01, 0x00b4, 0x0048},
 827	{0x01, 0x00bf, 0x0049},
 828	{0x01, 0x00ca, 0x004a},
 829	{0x01, 0x00d4, 0x004b},
 830	{0x01, 0x00dd, 0x004c},
 831	{0x01, 0x00e7, 0x004d},
 832	{0x01, 0x00ef, 0x004e},
 833	{0x01, 0x00f8, 0x004f},
 834	{0x01, 0x00ff, 0x0050},
 835	{0x01, 0x0001, 0x0056},
 836	{0x01, 0x0060, 0x0057},
 837	{0x01, 0x0040, 0x0058},
 838	{0x01, 0x0011, 0x0059},
 839	{0x01, 0x0001, 0x005a},
 840	{0x02, 0x0007, 0x0005},
 841	{0x02, 0xa048, 0x0000},
 842	{0x02, 0x0007, 0x0005},
 843	{0x02, 0x0015, 0x0006},
 844	{0x02, 0x100a, 0x0007},
 845	{0x02, 0xa048, 0x0000},
 846	{0x02, 0xc002, 0x0001},
 847	{0x02, 0x000f, 0x0005},
 848	{0x02, 0xa048, 0x0000},
 849	{0x05, 0x0022, 0x0004},
 850	{0x05, 0x0025, 0x0001},
 851	{0x05, 0x0000, 0x0000},
 852	{0x05, 0x0026, 0x0001},
 853	{0x05, 0x0001, 0x0000},
 854	{0x05, 0x0027, 0x0001},
 855	{0x05, 0x0000, 0x0000},
 856	{0x05, 0x0001, 0x0001},
 857	{0x05, 0x0000, 0x0000},
 858	{0x05, 0x0021, 0x0001},
 859	{0x05, 0x00d2, 0x0000},
 860	{0x05, 0x0020, 0x0001},
 861	{0x05, 0x0000, 0x0000},
 862	{0x00, 0x0090, 0x0005},
 863	{0x01, 0x00a6, 0x0000},
 864	{0x02, 0x0007, 0x0005},
 865	{0x02, 0x2000, 0x0000},
 866	{0x05, 0x0022, 0x0004},
 867	{0x05, 0x0015, 0x0001},
 868	{0x05, 0x00ea, 0x0000},
 869	{0x05, 0x0021, 0x0001},
 870	{0x05, 0x00d2, 0x0000},
 871	{0x05, 0x0023, 0x0001},
 872	{0x05, 0x0003, 0x0000},
 873	{0x05, 0x0030, 0x0001},
 874	{0x05, 0x002b, 0x0000},
 875	{0x05, 0x0031, 0x0001},
 876	{0x05, 0x0023, 0x0000},
 877	{0x05, 0x0032, 0x0001},
 878	{0x05, 0x0023, 0x0000},
 879	{0x05, 0x0033, 0x0001},
 880	{0x05, 0x0023, 0x0000},
 881	{0x05, 0x0034, 0x0001},
 882	{0x05, 0x0002, 0x0000},
 883	{0x05, 0x0050, 0x0001},
 884	{0x05, 0x0000, 0x0000},
 885	{0x05, 0x0051, 0x0001},
 886	{0x05, 0x0000, 0x0000},
 887	{0x05, 0x0052, 0x0001},
 888	{0x05, 0x0000, 0x0000},
 889	{0x05, 0x0054, 0x0001},
 890	{0x05, 0x0001, 0x0000},
 891	{0x00, 0x0000, 0x0001},
 892	{0x00, 0x0000, 0x0002},
 893	{0x00, 0x000c, 0x0003},
 894	{0x00, 0x0000, 0x0004},
 895	{0x00, 0x0090, 0x0005},
 896	{0x00, 0x0000, 0x0006},
 897	{0x00, 0x0040, 0x0007},
 898	{0x00, 0x00c0, 0x0008},
 899	{0x00, 0x004a, 0x0009},
 900	{0x00, 0x0000, 0x000a},
 901	{0x00, 0x0000, 0x000b},
 902	{0x00, 0x0001, 0x000c},
 903	{0x00, 0x0001, 0x000d},
 904	{0x00, 0x0000, 0x000e},
 905	{0x00, 0x0002, 0x000f},
 906	{0x00, 0x0001, 0x0010},
 907	{0x00, 0x0000, 0x0011},
 908	{0x00, 0x0000, 0x0012},
 909	{0x00, 0x0002, 0x0020},
 910	{0x00, 0x0080, 0x0021},
 911	{0x00, 0x0001, 0x0022},
 912	{0x00, 0x00e0, 0x0023},
 913	{0x00, 0x0000, 0x0024},
 914	{0x00, 0x00d5, 0x0025},
 915	{0x00, 0x0000, 0x0026},
 916	{0x00, 0x000b, 0x0027},
 917	{0x00, 0x0000, 0x0046},
 918	{0x00, 0x0000, 0x0047},
 919	{0x00, 0x0000, 0x0048},
 920	{0x00, 0x0000, 0x0049},
 921	{0x00, 0x0008, 0x004a},
 922	{0xff, 0x0000, 0x00d0},
 923	{0xff, 0x00d8, 0x00d1},
 924	{0xff, 0x0000, 0x00d4},
 925	{0xff, 0x0000, 0x00d5},
 926	{0x01, 0x00a6, 0x0000},
 927	{0x01, 0x0028, 0x0001},
 928	{0x01, 0x0000, 0x0002},
 929	{0x01, 0x000a, 0x0003},
 930	{0x01, 0x0040, 0x0004},
 931	{0x01, 0x0066, 0x0007},
 932	{0x01, 0x0011, 0x0008},
 933	{0x01, 0x0032, 0x0009},
 934	{0x01, 0x00fd, 0x000a},
 935	{0x01, 0x0038, 0x000b},
 936	{0x01, 0x00d1, 0x000c},
 937	{0x01, 0x00f7, 0x000d},
 938	{0x01, 0x00ed, 0x000e},
 939	{0x01, 0x00d8, 0x000f},
 940	{0x01, 0x0038, 0x0010},
 941	{0x01, 0x00ff, 0x0015},
 942	{0x01, 0x0001, 0x0016},
 943	{0x01, 0x0032, 0x0017},
 944	{0x01, 0x0023, 0x0018},
 945	{0x01, 0x00ce, 0x0019},
 946	{0x01, 0x0023, 0x001a},
 947	{0x01, 0x0032, 0x001b},
 948	{0x01, 0x008d, 0x001c},
 949	{0x01, 0x00ce, 0x001d},
 950	{0x01, 0x008d, 0x001e},
 951	{0x01, 0x0000, 0x001f},
 952	{0x01, 0x0000, 0x0020},
 953	{0x01, 0x00ff, 0x003e},
 954	{0x01, 0x0003, 0x003f},
 955	{0x01, 0x0000, 0x0040},
 956	{0x01, 0x0035, 0x0041},
 957	{0x01, 0x0053, 0x0042},
 958	{0x01, 0x0069, 0x0043},
 959	{0x01, 0x007c, 0x0044},
 960	{0x01, 0x008c, 0x0045},
 961	{0x01, 0x009a, 0x0046},
 962	{0x01, 0x00a8, 0x0047},
 963	{0x01, 0x00b4, 0x0048},
 964	{0x01, 0x00bf, 0x0049},
 965	{0x01, 0x00ca, 0x004a},
 966	{0x01, 0x00d4, 0x004b},
 967	{0x01, 0x00dd, 0x004c},
 968	{0x01, 0x00e7, 0x004d},
 969	{0x01, 0x00ef, 0x004e},
 970	{0x01, 0x00f8, 0x004f},
 971	{0x01, 0x00ff, 0x0050},
 972	{0x01, 0x0001, 0x0056},
 973	{0x01, 0x0060, 0x0057},
 974	{0x01, 0x0040, 0x0058},
 975	{0x01, 0x0011, 0x0059},
 976	{0x01, 0x0001, 0x005a},
 977	{0x02, 0x0007, 0x0005},
 978	{0x02, 0xa048, 0x0000},
 979	{0x02, 0x0007, 0x0005},
 980	{0x02, 0x0015, 0x0006},
 981	{0x02, 0x100a, 0x0007},
 982	{0x02, 0xa048, 0x0000},
 983	{0x02, 0xc002, 0x0001},
 984	{0x02, 0x000f, 0x0005},
 985	{0x02, 0xa048, 0x0000},
 986	{0x05, 0x0022, 0x0004},
 987	{0x05, 0x0025, 0x0001},
 988	{0x05, 0x0000, 0x0000},
 989	{0x05, 0x0026, 0x0001},
 990	{0x05, 0x0001, 0x0000},
 991	{0x05, 0x0027, 0x0001},
 992	{0x05, 0x0000, 0x0000},
 993	{0x05, 0x0001, 0x0001},
 994	{0x05, 0x0000, 0x0000},
 995	{0x05, 0x0021, 0x0001},
 996	{0x05, 0x00d2, 0x0000},
 997	{0x05, 0x0020, 0x0001},
 998	{0x05, 0x0000, 0x0000},
 999	{0x00, 0x0090, 0x0005},
1000	{0x01, 0x00a6, 0x0000},
1001	{0x01, 0x0003, 0x003f},
1002	{0x01, 0x0001, 0x0056},
1003	{0x01, 0x0011, 0x0008},
1004	{0x01, 0x0032, 0x0009},
1005	{0x01, 0xfffd, 0x000a},
1006	{0x01, 0x0023, 0x000b},
1007	{0x01, 0xffea, 0x000c},
1008	{0x01, 0xfff4, 0x000d},
1009	{0x01, 0xfffc, 0x000e},
1010	{0x01, 0xffe3, 0x000f},
1011	{0x01, 0x001f, 0x0010},
1012	{0x01, 0x00a8, 0x0001},
1013	{0x01, 0x0067, 0x0007},
1014	{0x01, 0x0032, 0x0017},
1015	{0x01, 0x0023, 0x0018},
1016	{0x01, 0x00ce, 0x0019},
1017	{0x01, 0x0023, 0x001a},
1018	{0x01, 0x0032, 0x001b},
1019	{0x01, 0x008d, 0x001c},
1020	{0x01, 0x00ce, 0x001d},
1021	{0x01, 0x008d, 0x001e},
1022	{0x01, 0x00c8, 0x0015},
1023	{0x01, 0x0032, 0x0016},
1024	{0x01, 0x0000, 0x0011},
1025	{0x01, 0x0000, 0x0012},
1026	{0x01, 0x0000, 0x0013},
1027	{0x01, 0x000a, 0x0003},
1028	{0x02, 0xc002, 0x0001},
1029	{0x02, 0x0007, 0x0005},
1030	{0x02, 0xc000, 0x0001},
1031	{0x02, 0x0000, 0x0005},
1032	{0x02, 0x0007, 0x0005},
1033	{0x02, 0x2000, 0x0000},
1034	{0x05, 0x0022, 0x0004},
1035	{0x05, 0x0015, 0x0001},
1036	{0x05, 0x00ea, 0x0000},
1037	{0x05, 0x0021, 0x0001},
1038	{0x05, 0x00d2, 0x0000},
1039	{0x05, 0x0023, 0x0001},
1040	{0x05, 0x0003, 0x0000},
1041	{0x05, 0x0030, 0x0001},
1042	{0x05, 0x002b, 0x0000},
1043	{0x05, 0x0031, 0x0001},
1044	{0x05, 0x0023, 0x0000},
1045	{0x05, 0x0032, 0x0001},
1046	{0x05, 0x0023, 0x0000},
1047	{0x05, 0x0033, 0x0001},
1048	{0x05, 0x0023, 0x0000},
1049	{0x05, 0x0034, 0x0001},
1050	{0x05, 0x0002, 0x0000},
1051	{0x05, 0x0050, 0x0001},
1052	{0x05, 0x0000, 0x0000},
1053	{0x05, 0x0051, 0x0001},
1054	{0x05, 0x0000, 0x0000},
1055	{0x05, 0x0052, 0x0001},
1056	{0x05, 0x0000, 0x0000},
1057	{0x05, 0x0054, 0x0001},
1058	{0x05, 0x0001, 0x0000},
1059	{0x00, 0x0000, 0x0001},
1060	{0x00, 0x0000, 0x0002},
1061	{0x00, 0x000c, 0x0003},
1062	{0x00, 0x0000, 0x0004},
1063	{0x00, 0x0090, 0x0005},
1064	{0x00, 0x0000, 0x0006},
1065	{0x00, 0x0040, 0x0007},
1066	{0x00, 0x00c0, 0x0008},
1067	{0x00, 0x004a, 0x0009},
1068	{0x00, 0x0000, 0x000a},
1069	{0x00, 0x0000, 0x000b},
1070	{0x00, 0x0001, 0x000c},
1071	{0x00, 0x0001, 0x000d},
1072	{0x00, 0x0000, 0x000e},
1073	{0x00, 0x0002, 0x000f},
1074	{0x00, 0x0001, 0x0010},
1075	{0x00, 0x0000, 0x0011},
1076	{0x00, 0x0000, 0x0012},
1077	{0x00, 0x0002, 0x0020},
1078	{0x00, 0x0080, 0x0021},
1079	{0x00, 0x0001, 0x0022},
1080	{0x00, 0x00e0, 0x0023},
1081	{0x00, 0x0000, 0x0024},
1082	{0x00, 0x00d5, 0x0025},
1083	{0x00, 0x0000, 0x0026},
1084	{0x00, 0x000b, 0x0027},
1085	{0x00, 0x0000, 0x0046},
1086	{0x00, 0x0000, 0x0047},
1087	{0x00, 0x0000, 0x0048},
1088	{0x00, 0x0000, 0x0049},
1089	{0x00, 0x0008, 0x004a},
1090	{0xff, 0x0000, 0x00d0},
1091	{0xff, 0x00d8, 0x00d1},
1092	{0xff, 0x0000, 0x00d4},
1093	{0xff, 0x0000, 0x00d5},
1094	{0x01, 0x00a6, 0x0000},
1095	{0x01, 0x0028, 0x0001},
1096	{0x01, 0x0000, 0x0002},
1097	{0x01, 0x000a, 0x0003},
1098	{0x01, 0x0040, 0x0004},
1099	{0x01, 0x0066, 0x0007},
1100	{0x01, 0x0011, 0x0008},
1101	{0x01, 0x0032, 0x0009},
1102	{0x01, 0x00fd, 0x000a},
1103	{0x01, 0x0038, 0x000b},
1104	{0x01, 0x00d1, 0x000c},
1105	{0x01, 0x00f7, 0x000d},
1106	{0x01, 0x00ed, 0x000e},
1107	{0x01, 0x00d8, 0x000f},
1108	{0x01, 0x0038, 0x0010},
1109	{0x01, 0x00ff, 0x0015},
1110	{0x01, 0x0001, 0x0016},
1111	{0x01, 0x0032, 0x0017},
1112	{0x01, 0x0023, 0x0018},
1113	{0x01, 0x00ce, 0x0019},
1114	{0x01, 0x0023, 0x001a},
1115	{0x01, 0x0032, 0x001b},
1116	{0x01, 0x008d, 0x001c},
1117	{0x01, 0x00ce, 0x001d},
1118	{0x01, 0x008d, 0x001e},
1119	{0x01, 0x0000, 0x001f},
1120	{0x01, 0x0000, 0x0020},
1121	{0x01, 0x00ff, 0x003e},
1122	{0x01, 0x0003, 0x003f},
1123	{0x01, 0x0000, 0x0040},
1124	{0x01, 0x0035, 0x0041},
1125	{0x01, 0x0053, 0x0042},
1126	{0x01, 0x0069, 0x0043},
1127	{0x01, 0x007c, 0x0044},
1128	{0x01, 0x008c, 0x0045},
1129	{0x01, 0x009a, 0x0046},
1130	{0x01, 0x00a8, 0x0047},
1131	{0x01, 0x00b4, 0x0048},
1132	{0x01, 0x00bf, 0x0049},
1133	{0x01, 0x00ca, 0x004a},
1134	{0x01, 0x00d4, 0x004b},
1135	{0x01, 0x00dd, 0x004c},
1136	{0x01, 0x00e7, 0x004d},
1137	{0x01, 0x00ef, 0x004e},
1138	{0x01, 0x00f8, 0x004f},
1139	{0x01, 0x00ff, 0x0050},
1140	{0x01, 0x0001, 0x0056},
1141	{0x01, 0x0060, 0x0057},
1142	{0x01, 0x0040, 0x0058},
1143	{0x01, 0x0011, 0x0059},
1144	{0x01, 0x0001, 0x005a},
1145	{0x02, 0x0007, 0x0005},
1146	{0x02, 0xa048, 0x0000},
1147	{0x02, 0x0007, 0x0005},
1148	{0x02, 0x0015, 0x0006},
1149	{0x02, 0x100a, 0x0007},
1150	{0x02, 0xa048, 0x0000},
1151	{0x02, 0xc002, 0x0001},
1152	{0x02, 0x000f, 0x0005},
1153	{0x02, 0xa048, 0x0000},
1154	{0x05, 0x0022, 0x0004},
1155	{0x05, 0x0025, 0x0001},
1156	{0x05, 0x0000, 0x0000},
1157	{0x05, 0x0026, 0x0001},
1158	{0x05, 0x0001, 0x0000},
1159	{0x05, 0x0027, 0x0001},
1160	{0x05, 0x0000, 0x0000},
1161	{0x05, 0x0001, 0x0001},
1162	{0x05, 0x0000, 0x0000},
1163	{0x05, 0x0021, 0x0001},
1164	{0x05, 0x00d2, 0x0000},
1165	{0x05, 0x0020, 0x0001},
1166	{0x05, 0x0000, 0x0000},
1167	{0x00, 0x0090, 0x0005},
1168	{0x01, 0x00a6, 0x0000},
1169	{0x02, 0x0007, 0x0005},
1170	{0x02, 0x2000, 0x0000},
1171	{0x05, 0x0022, 0x0004},
1172	{0x05, 0x0015, 0x0001},
1173	{0x05, 0x00ea, 0x0000},
1174	{0x05, 0x0021, 0x0001},
1175	{0x05, 0x00d2, 0x0000},
1176	{0x05, 0x0023, 0x0001},
1177	{0x05, 0x0003, 0x0000},
1178	{0x05, 0x0030, 0x0001},
1179	{0x05, 0x002b, 0x0000},
1180	{0x05, 0x0031, 0x0001},
1181	{0x05, 0x0023, 0x0000},
1182	{0x05, 0x0032, 0x0001},
1183	{0x05, 0x0023, 0x0000},
1184	{0x05, 0x0033, 0x0001},
1185	{0x05, 0x0023, 0x0000},
1186	{0x05, 0x0034, 0x0001},
1187	{0x05, 0x0002, 0x0000},
1188	{0x05, 0x0050, 0x0001},
1189	{0x05, 0x0000, 0x0000},
1190	{0x05, 0x0051, 0x0001},
1191	{0x05, 0x0000, 0x0000},
1192	{0x05, 0x0052, 0x0001},
1193	{0x05, 0x0000, 0x0000},
1194	{0x05, 0x0054, 0x0001},
1195	{0x05, 0x0001, 0x0000},
1196	{0x00, 0x0000, 0x0001},
1197	{0x00, 0x0000, 0x0002},
1198	{0x00, 0x000c, 0x0003},
1199	{0x00, 0x0000, 0x0004},
1200	{0x00, 0x0090, 0x0005},
1201	{0x00, 0x0000, 0x0006},
1202	{0x00, 0x0040, 0x0007},
1203	{0x00, 0x00c0, 0x0008},
1204	{0x00, 0x004a, 0x0009},
1205	{0x00, 0x0000, 0x000a},
1206	{0x00, 0x0000, 0x000b},
1207	{0x00, 0x0001, 0x000c},
1208	{0x00, 0x0001, 0x000d},
1209	{0x00, 0x0000, 0x000e},
1210	{0x00, 0x0002, 0x000f},
1211	{0x00, 0x0001, 0x0010},
1212	{0x00, 0x0000, 0x0011},
1213	{0x00, 0x0000, 0x0012},
1214	{0x00, 0x0002, 0x0020},
1215	{0x00, 0x0080, 0x0021},
1216	{0x00, 0x0001, 0x0022},
1217	{0x00, 0x00e0, 0x0023},
1218	{0x00, 0x0000, 0x0024},
1219	{0x00, 0x00d5, 0x0025},
1220	{0x00, 0x0000, 0x0026},
1221	{0x00, 0x000b, 0x0027},
1222	{0x00, 0x0000, 0x0046},
1223	{0x00, 0x0000, 0x0047},
1224	{0x00, 0x0000, 0x0048},
1225	{0x00, 0x0000, 0x0049},
1226	{0x00, 0x0008, 0x004a},
1227	{0xff, 0x0000, 0x00d0},
1228	{0xff, 0x00d8, 0x00d1},
1229	{0xff, 0x0000, 0x00d4},
1230	{0xff, 0x0000, 0x00d5},
1231	{0x01, 0x00a6, 0x0000},
1232	{0x01, 0x0028, 0x0001},
1233	{0x01, 0x0000, 0x0002},
1234	{0x01, 0x000a, 0x0003},
1235	{0x01, 0x0040, 0x0004},
1236	{0x01, 0x0066, 0x0007},
1237	{0x01, 0x0011, 0x0008},
1238	{0x01, 0x0032, 0x0009},
1239	{0x01, 0x00fd, 0x000a},
1240	{0x01, 0x0038, 0x000b},
1241	{0x01, 0x00d1, 0x000c},
1242	{0x01, 0x00f7, 0x000d},
1243	{0x01, 0x00ed, 0x000e},
1244	{0x01, 0x00d8, 0x000f},
1245	{0x01, 0x0038, 0x0010},
1246	{0x01, 0x00ff, 0x0015},
1247	{0x01, 0x0001, 0x0016},
1248	{0x01, 0x0032, 0x0017},
1249	{0x01, 0x0023, 0x0018},
1250	{0x01, 0x00ce, 0x0019},
1251	{0x01, 0x0023, 0x001a},
1252	{0x01, 0x0032, 0x001b},
1253	{0x01, 0x008d, 0x001c},
1254	{0x01, 0x00ce, 0x001d},
1255	{0x01, 0x008d, 0x001e},
1256	{0x01, 0x0000, 0x001f},
1257	{0x01, 0x0000, 0x0020},
1258	{0x01, 0x00ff, 0x003e},
1259	{0x01, 0x0003, 0x003f},
1260	{0x01, 0x0000, 0x0040},
1261	{0x01, 0x0035, 0x0041},
1262	{0x01, 0x0053, 0x0042},
1263	{0x01, 0x0069, 0x0043},
1264	{0x01, 0x007c, 0x0044},
1265	{0x01, 0x008c, 0x0045},
1266	{0x01, 0x009a, 0x0046},
1267	{0x01, 0x00a8, 0x0047},
1268	{0x01, 0x00b4, 0x0048},
1269	{0x01, 0x00bf, 0x0049},
1270	{0x01, 0x00ca, 0x004a},
1271	{0x01, 0x00d4, 0x004b},
1272	{0x01, 0x00dd, 0x004c},
1273	{0x01, 0x00e7, 0x004d},
1274	{0x01, 0x00ef, 0x004e},
1275	{0x01, 0x00f8, 0x004f},
1276	{0x01, 0x00ff, 0x0050},
1277	{0x01, 0x0001, 0x0056},
1278	{0x01, 0x0060, 0x0057},
1279	{0x01, 0x0040, 0x0058},
1280	{0x01, 0x0011, 0x0059},
1281	{0x01, 0x0001, 0x005a},
1282	{0x02, 0x0007, 0x0005},
1283	{0x02, 0xa048, 0x0000},
1284	{0x02, 0x0007, 0x0005},
1285	{0x02, 0x0015, 0x0006},
1286	{0x02, 0x100a, 0x0007},
1287	{0x02, 0xa048, 0x0000},
1288	{0x02, 0xc002, 0x0001},
1289	{0x02, 0x000f, 0x0005},
1290	{0x02, 0xa048, 0x0000},
1291	{0x05, 0x0022, 0x0004},
1292	{0x05, 0x0025, 0x0001},
1293	{0x05, 0x0000, 0x0000},
1294	{0x05, 0x0026, 0x0001},
1295	{0x05, 0x0001, 0x0000},
1296	{0x05, 0x0027, 0x0001},
1297	{0x05, 0x0000, 0x0000},
1298	{0x05, 0x0001, 0x0001},
1299	{0x05, 0x0000, 0x0000},
1300	{0x05, 0x0021, 0x0001},
1301	{0x05, 0x00d2, 0x0000},
1302	{0x05, 0x0020, 0x0001},
1303	{0x05, 0x0000, 0x0000},
1304	{0x00, 0x0090, 0x0005},
1305	{0x01, 0x00a6, 0x0000},
1306	{0x05, 0x0026, 0x0001},
1307	{0x05, 0x0001, 0x0000},
1308	{0x05, 0x0027, 0x0001},
1309	{0x05, 0x000f, 0x0000},
1310	{0x01, 0x0003, 0x003f},
1311	{0x01, 0x0001, 0x0056},
1312	{0x01, 0x0011, 0x0008},
1313	{0x01, 0x0032, 0x0009},
1314	{0x01, 0xfffd, 0x000a},
1315	{0x01, 0x0023, 0x000b},
1316	{0x01, 0xffea, 0x000c},
1317	{0x01, 0xfff4, 0x000d},
1318	{0x01, 0xfffc, 0x000e},
1319	{0x01, 0xffe3, 0x000f},
1320	{0x01, 0x001f, 0x0010},
1321	{0x01, 0x00a8, 0x0001},
1322	{0x01, 0x0067, 0x0007},
1323	{0x01, 0x0042, 0x0051},
1324	{0x01, 0x0051, 0x0053},
1325	{0x01, 0x000a, 0x0003},
1326	{0x02, 0xc002, 0x0001},
1327	{0x02, 0x0007, 0x0005},
1328	{0x02, 0xc000, 0x0001},
1329	{0x02, 0x0000, 0x0005},
1330	{0x02, 0x0007, 0x0005},
1331	{0x02, 0x2000, 0x0000},
1332	{0x05, 0x0022, 0x0004},
1333	{0x05, 0x0015, 0x0001},
1334	{0x05, 0x00ea, 0x0000},
1335	{0x05, 0x0021, 0x0001},
1336	{0x05, 0x00d2, 0x0000},
1337	{0x05, 0x0023, 0x0001},
1338	{0x05, 0x0003, 0x0000},
1339	{0x05, 0x0030, 0x0001},
1340	{0x05, 0x002b, 0x0000},
1341	{0x05, 0x0031, 0x0001},
1342	{0x05, 0x0023, 0x0000},
1343	{0x05, 0x0032, 0x0001},
1344	{0x05, 0x0023, 0x0000},
1345	{0x05, 0x0033, 0x0001},
1346	{0x05, 0x0023, 0x0000},
1347	{0x05, 0x0034, 0x0001},
1348	{0x05, 0x0002, 0x0000},
1349	{0x05, 0x0050, 0x0001},
1350	{0x05, 0x0000, 0x0000},
1351	{0x05, 0x0051, 0x0001},
1352	{0x05, 0x0000, 0x0000},
1353	{0x05, 0x0052, 0x0001},
1354	{0x05, 0x0000, 0x0000},
1355	{0x05, 0x0054, 0x0001},
1356	{0x05, 0x0001, 0x0000},
1357	{0x00, 0x0000, 0x0001},
1358	{0x00, 0x0000, 0x0002},
1359	{0x00, 0x000c, 0x0003},
1360	{0x00, 0x0000, 0x0004},
1361	{0x00, 0x0090, 0x0005},
1362	{0x00, 0x0000, 0x0006},
1363	{0x00, 0x0040, 0x0007},
1364	{0x00, 0x00c0, 0x0008},
1365	{0x00, 0x004a, 0x0009},
1366	{0x00, 0x0000, 0x000a},
1367	{0x00, 0x0000, 0x000b},
1368	{0x00, 0x0001, 0x000c},
1369	{0x00, 0x0001, 0x000d},
1370	{0x00, 0x0000, 0x000e},
1371	{0x00, 0x0002, 0x000f},
1372	{0x00, 0x0001, 0x0010},
1373	{0x00, 0x0000, 0x0011},
1374	{0x00, 0x0000, 0x0012},
1375	{0x00, 0x0002, 0x0020},
1376	{0x00, 0x0080, 0x0021},
1377	{0x00, 0x0001, 0x0022},
1378	{0x00, 0x00e0, 0x0023},
1379	{0x00, 0x0000, 0x0024},
1380	{0x00, 0x00d5, 0x0025},
1381	{0x00, 0x0000, 0x0026},
1382	{0x00, 0x000b, 0x0027},
1383	{0x00, 0x0000, 0x0046},
1384	{0x00, 0x0000, 0x0047},
1385	{0x00, 0x0000, 0x0048},
1386	{0x00, 0x0000, 0x0049},
1387	{0x00, 0x0008, 0x004a},
1388	{0xff, 0x0000, 0x00d0},
1389	{0xff, 0x00d8, 0x00d1},
1390	{0xff, 0x0000, 0x00d4},
1391	{0xff, 0x0000, 0x00d5},
1392	{0x01, 0x00a6, 0x0000},
1393	{0x01, 0x0028, 0x0001},
1394	{0x01, 0x0000, 0x0002},
1395	{0x01, 0x000a, 0x0003},
1396	{0x01, 0x0040, 0x0004},
1397	{0x01, 0x0066, 0x0007},
1398	{0x01, 0x0011, 0x0008},
1399	{0x01, 0x0032, 0x0009},
1400	{0x01, 0x00fd, 0x000a},
1401	{0x01, 0x0038, 0x000b},
1402	{0x01, 0x00d1, 0x000c},
1403	{0x01, 0x00f7, 0x000d},
1404	{0x01, 0x00ed, 0x000e},
1405	{0x01, 0x00d8, 0x000f},
1406	{0x01, 0x0038, 0x0010},
1407	{0x01, 0x00ff, 0x0015},
1408	{0x01, 0x0001, 0x0016},
1409	{0x01, 0x0032, 0x0017},
1410	{0x01, 0x0023, 0x0018},
1411	{0x01, 0x00ce, 0x0019},
1412	{0x01, 0x0023, 0x001a},
1413	{0x01, 0x0032, 0x001b},
1414	{0x01, 0x008d, 0x001c},
1415	{0x01, 0x00ce, 0x001d},
1416	{0x01, 0x008d, 0x001e},
1417	{0x01, 0x0000, 0x001f},
1418	{0x01, 0x0000, 0x0020},
1419	{0x01, 0x00ff, 0x003e},
1420	{0x01, 0x0003, 0x003f},
1421	{0x01, 0x0000, 0x0040},
1422	{0x01, 0x0035, 0x0041},
1423	{0x01, 0x0053, 0x0042},
1424	{0x01, 0x0069, 0x0043},
1425	{0x01, 0x007c, 0x0044},
1426	{0x01, 0x008c, 0x0045},
1427	{0x01, 0x009a, 0x0046},
1428	{0x01, 0x00a8, 0x0047},
1429	{0x01, 0x00b4, 0x0048},
1430	{0x01, 0x00bf, 0x0049},
1431	{0x01, 0x00ca, 0x004a},
1432	{0x01, 0x00d4, 0x004b},
1433	{0x01, 0x00dd, 0x004c},
1434	{0x01, 0x00e7, 0x004d},
1435	{0x01, 0x00ef, 0x004e},
1436	{0x01, 0x00f8, 0x004f},
1437	{0x01, 0x00ff, 0x0050},
1438	{0x01, 0x0001, 0x0056},
1439	{0x01, 0x0060, 0x0057},
1440	{0x01, 0x0040, 0x0058},
1441	{0x01, 0x0011, 0x0059},
1442	{0x01, 0x0001, 0x005a},
1443	{0x02, 0x0007, 0x0005},
1444	{0x02, 0xa048, 0x0000},
1445	{0x02, 0x0007, 0x0005},
1446	{0x02, 0x0015, 0x0006},
1447	{0x02, 0x100a, 0x0007},
1448	{0x02, 0xa048, 0x0000},
1449	{0x02, 0xc002, 0x0001},
1450	{0x02, 0x000f, 0x0005},
1451	{0x02, 0xa048, 0x0000},
1452	{0x05, 0x0022, 0x0004},
1453	{0x05, 0x0025, 0x0001},
1454	{0x05, 0x0000, 0x0000},
1455	{0x05, 0x0026, 0x0001},
1456	{0x05, 0x0001, 0x0000},
1457	{0x05, 0x0027, 0x0001},
1458	{0x05, 0x0000, 0x0000},
1459	{0x05, 0x0001, 0x0001},
1460	{0x05, 0x0000, 0x0000},
1461	{0x05, 0x0021, 0x0001},
1462	{0x05, 0x00d2, 0x0000},
1463	{0x05, 0x0020, 0x0001},
1464	{0x05, 0x0000, 0x0000},
1465	{0x00, 0x0090, 0x0005},
1466	{0x01, 0x00a6, 0x0000},
1467	{0x02, 0x0007, 0x0005},
1468	{0x02, 0x2000, 0x0000},
1469	{0x05, 0x0022, 0x0004},
1470	{0x05, 0x0015, 0x0001},
1471	{0x05, 0x00ea, 0x0000},
1472	{0x05, 0x0021, 0x0001},
1473	{0x05, 0x00d2, 0x0000},
1474	{0x05, 0x0023, 0x0001},
1475	{0x05, 0x0003, 0x0000},
1476	{0x05, 0x0030, 0x0001},
1477	{0x05, 0x002b, 0x0000},
1478	{0x05, 0x0031, 0x0001},
1479	{0x05, 0x0023, 0x0000},
1480	{0x05, 0x0032, 0x0001},
1481	{0x05, 0x0023, 0x0000},
1482	{0x05, 0x0033, 0x0001},
1483	{0x05, 0x0023, 0x0000},
1484	{0x05, 0x0034, 0x0001},
1485	{0x05, 0x0002, 0x0000},
1486	{0x05, 0x0050, 0x0001},
1487	{0x05, 0x0000, 0x0000},
1488	{0x05, 0x0051, 0x0001},
1489	{0x05, 0x0000, 0x0000},
1490	{0x05, 0x0052, 0x0001},
1491	{0x05, 0x0000, 0x0000},
1492	{0x05, 0x0054, 0x0001},
1493	{0x05, 0x0001, 0x0000},
1494	{0x00, 0x0000, 0x0001},
1495	{0x00, 0x0000, 0x0002},
1496	{0x00, 0x000c, 0x0003},
1497	{0x00, 0x0000, 0x0004},
1498	{0x00, 0x0090, 0x0005},
1499	{0x00, 0x0000, 0x0006},
1500	{0x00, 0x0040, 0x0007},
1501	{0x00, 0x00c0, 0x0008},
1502	{0x00, 0x004a, 0x0009},
1503	{0x00, 0x0000, 0x000a},
1504	{0x00, 0x0000, 0x000b},
1505	{0x00, 0x0001, 0x000c},
1506	{0x00, 0x0001, 0x000d},
1507	{0x00, 0x0000, 0x000e},
1508	{0x00, 0x0002, 0x000f},
1509	{0x00, 0x0001, 0x0010},
1510	{0x00, 0x0000, 0x0011},
1511	{0x00, 0x0000, 0x0012},
1512	{0x00, 0x0002, 0x0020},
1513	{0x00, 0x0080, 0x0021},
1514	{0x00, 0x0001, 0x0022},
1515	{0x00, 0x00e0, 0x0023},
1516	{0x00, 0x0000, 0x0024},
1517	{0x00, 0x00d5, 0x0025},
1518	{0x00, 0x0000, 0x0026},
1519	{0x00, 0x000b, 0x0027},
1520	{0x00, 0x0000, 0x0046},
1521	{0x00, 0x0000, 0x0047},
1522	{0x00, 0x0000, 0x0048},
1523	{0x00, 0x0000, 0x0049},
1524	{0x00, 0x0008, 0x004a},
1525	{0xff, 0x0000, 0x00d0},
1526	{0xff, 0x00d8, 0x00d1},
1527	{0xff, 0x0000, 0x00d4},
1528	{0xff, 0x0000, 0x00d5},
1529	{0x01, 0x00a6, 0x0000},
1530	{0x01, 0x0028, 0x0001},
1531	{0x01, 0x0000, 0x0002},
1532	{0x01, 0x000a, 0x0003},
1533	{0x01, 0x0040, 0x0004},
1534	{0x01, 0x0066, 0x0007},
1535	{0x01, 0x0011, 0x0008},
1536	{0x01, 0x0032, 0x0009},
1537	{0x01, 0x00fd, 0x000a},
1538	{0x01, 0x0038, 0x000b},
1539	{0x01, 0x00d1, 0x000c},
1540	{0x01, 0x00f7, 0x000d},
1541	{0x01, 0x00ed, 0x000e},
1542	{0x01, 0x00d8, 0x000f},
1543	{0x01, 0x0038, 0x0010},
1544	{0x01, 0x00ff, 0x0015},
1545	{0x01, 0x0001, 0x0016},
1546	{0x01, 0x0032, 0x0017},
1547	{0x01, 0x0023, 0x0018},
1548	{0x01, 0x00ce, 0x0019},
1549	{0x01, 0x0023, 0x001a},
1550	{0x01, 0x0032, 0x001b},
1551	{0x01, 0x008d, 0x001c},
1552	{0x01, 0x00ce, 0x001d},
1553	{0x01, 0x008d, 0x001e},
1554	{0x01, 0x0000, 0x001f},
1555	{0x01, 0x0000, 0x0020},
1556	{0x01, 0x00ff, 0x003e},
1557	{0x01, 0x0003, 0x003f},
1558	{0x01, 0x0000, 0x0040},
1559	{0x01, 0x0035, 0x0041},
1560	{0x01, 0x0053, 0x0042},
1561	{0x01, 0x0069, 0x0043},
1562	{0x01, 0x007c, 0x0044},
1563	{0x01, 0x008c, 0x0045},
1564	{0x01, 0x009a, 0x0046},
1565	{0x01, 0x00a8, 0x0047},
1566	{0x01, 0x00b4, 0x0048},
1567	{0x01, 0x00bf, 0x0049},
1568	{0x01, 0x00ca, 0x004a},
1569	{0x01, 0x00d4, 0x004b},
1570	{0x01, 0x00dd, 0x004c},
1571	{0x01, 0x00e7, 0x004d},
1572	{0x01, 0x00ef, 0x004e},
1573	{0x01, 0x00f8, 0x004f},
1574	{0x01, 0x00ff, 0x0050},
1575	{0x01, 0x0001, 0x0056},
1576	{0x01, 0x0060, 0x0057},
1577	{0x01, 0x0040, 0x0058},
1578	{0x01, 0x0011, 0x0059},
1579	{0x01, 0x0001, 0x005a},
1580	{0x02, 0x0007, 0x0005},
1581	{0x02, 0xa048, 0x0000},
1582	{0x02, 0x0007, 0x0005},
1583	{0x02, 0x0015, 0x0006},
1584	{0x02, 0x100a, 0x0007},
1585	{0x02, 0xa048, 0x0000},
1586	{0x02, 0xc002, 0x0001},
1587	{0x02, 0x000f, 0x0005},
1588	{0x02, 0xa048, 0x0000},
1589	{0x05, 0x0022, 0x0004},
1590	{0x05, 0x0025, 0x0001},
1591	{0x05, 0x0000, 0x0000},
1592	{0x05, 0x0026, 0x0001},
1593	{0x05, 0x0001, 0x0000},
1594	{0x05, 0x0027, 0x0001},
1595	{0x05, 0x0000, 0x0000},
1596	{0x05, 0x0001, 0x0001},
1597	{0x05, 0x0000, 0x0000},
1598	{0x05, 0x0021, 0x0001},
1599	{0x05, 0x00d2, 0x0000},
1600	{0x05, 0x0020, 0x0001},
1601	{0x05, 0x0000, 0x0000},
1602	{0x00, 0x0090, 0x0005},
1603	{0x01, 0x00a6, 0x0000},
1604	{0x05, 0x0026, 0x0001},
1605	{0x05, 0x0001, 0x0000},
1606	{0x05, 0x0027, 0x0001},
1607	{0x05, 0x001e, 0x0000},
1608	{0x01, 0x0003, 0x003f},
1609	{0x01, 0x0001, 0x0056},
1610	{0x01, 0x0011, 0x0008},
1611	{0x01, 0x0032, 0x0009},
1612	{0x01, 0xfffd, 0x000a},
1613	{0x01, 0x0023, 0x000b},
1614	{0x01, 0xffea, 0x000c},
1615	{0x01, 0xfff4, 0x000d},
1616	{0x01, 0xfffc, 0x000e},
1617	{0x01, 0xffe3, 0x000f},
1618	{0x01, 0x001f, 0x0010},
1619	{0x01, 0x00a8, 0x0001},
1620	{0x01, 0x0067, 0x0007},
1621	{0x01, 0x0042, 0x0051},
1622	{0x01, 0x0051, 0x0053},
1623	{0x01, 0x000a, 0x0003},
1624	{0x02, 0xc002, 0x0001},
1625	{0x02, 0x0007, 0x0005},
1626	{0x01, 0x0042, 0x0051},
1627	{0x01, 0x0051, 0x0053},
1628	{0x05, 0x0026, 0x0001},
1629	{0x05, 0x0001, 0x0000},
1630	{0x05, 0x0027, 0x0001},
1631	{0x05, 0x002d, 0x0000},
1632	{0x01, 0x0003, 0x003f},
1633	{0x01, 0x0001, 0x0056},
1634	{0x02, 0xc000, 0x0001},
1635	{0x02, 0x0000, 0x0005},
1636	{}
1637};
1638
1639/* Unknown camera from Ori Usbid 0x0000:0x0000 */
1640/* Based on snoops from Ori Cohen */
1641static const __u16 spca501c_mysterious_open_data[][3] = {
1642	{0x02, 0x000f, 0x0005},
1643	{0x02, 0xa048, 0x0000},
1644	{0x05, 0x0022, 0x0004},
1645/* DSP Registers */
1646	{0x01, 0x0016, 0x0011},	/* RGB offset */
1647	{0x01, 0x0000, 0x0012},
1648	{0x01, 0x0006, 0x0013},
1649	{0x01, 0x0078, 0x0051},
1650	{0x01, 0x0040, 0x0052},
1651	{0x01, 0x0046, 0x0053},
1652	{0x01, 0x0040, 0x0054},
1653	{0x00, 0x0025, 0x0000},
1654/*	{0x00, 0x0000, 0x0000 }, */
1655/* Part 2 */
1656/* TG Registers */
1657	{0x00, 0x0026, 0x0000},
1658	{0x00, 0x0001, 0x0000},
1659	{0x00, 0x0027, 0x0000},
1660	{0x00, 0x008a, 0x0000},
1661	{0x02, 0x0007, 0x0005},
1662	{0x02, 0x2000, 0x0000},
1663	{0x05, 0x0022, 0x0004},
1664	{0x05, 0x0015, 0x0001},
1665	{0x05, 0x00ea, 0x0000},
1666	{0x05, 0x0021, 0x0001},
1667	{0x05, 0x00d2, 0x0000},
1668	{0x05, 0x0023, 0x0001},
1669	{0x05, 0x0003, 0x0000},
1670	{0x05, 0x0030, 0x0001},
1671	{0x05, 0x002b, 0x0000},
1672	{0x05, 0x0031, 0x0001},
1673	{0x05, 0x0023, 0x0000},
1674	{0x05, 0x0032, 0x0001},
1675	{0x05, 0x0023, 0x0000},
1676	{0x05, 0x0033, 0x0001},
1677	{0x05, 0x0023, 0x0000},
1678	{0x05, 0x0034, 0x0001},
1679	{0x05, 0x0002, 0x0000},
1680	{0x05, 0x0050, 0x0001},
1681	{0x05, 0x0000, 0x0000},
1682	{0x05, 0x0051, 0x0001},
1683	{0x05, 0x0000, 0x0000},
1684	{0x05, 0x0052, 0x0001},
1685	{0x05, 0x0000, 0x0000},
1686	{0x05, 0x0054, 0x0001},
1687	{0x05, 0x0001, 0x0000},
1688	{}
1689};
1690
1691/* Based on snoops from Ori Cohen */
1692static const __u16 spca501c_mysterious_init_data[][3] = {
1693/* Part 3 */
1694/* TG registers */
1695/*	{0x00, 0x0000, 0x0000}, */
1696	{0x00, 0x0000, 0x0001},
1697	{0x00, 0x0000, 0x0002},
1698	{0x00, 0x0006, 0x0003},
1699	{0x00, 0x0000, 0x0004},
1700	{0x00, 0x0090, 0x0005},
1701	{0x00, 0x0000, 0x0006},
1702	{0x00, 0x0040, 0x0007},
1703	{0x00, 0x00c0, 0x0008},
1704	{0x00, 0x004a, 0x0009},
1705	{0x00, 0x0000, 0x000a},
1706	{0x00, 0x0000, 0x000b},
1707	{0x00, 0x0001, 0x000c},
1708	{0x00, 0x0001, 0x000d},
1709	{0x00, 0x0000, 0x000e},
1710	{0x00, 0x0002, 0x000f},
1711	{0x00, 0x0001, 0x0010},
1712	{0x00, 0x0000, 0x0011},
1713	{0x00, 0x0001, 0x0012},
1714	{0x00, 0x0002, 0x0020},
1715	{0x00, 0x0080, 0x0021},	/* 640 */
1716	{0x00, 0x0001, 0x0022},
1717	{0x00, 0x00e0, 0x0023},	/* 480 */
1718	{0x00, 0x0000, 0x0024},	/* Offset H hight */
1719	{0x00, 0x00d3, 0x0025},	/* low */
1720	{0x00, 0x0000, 0x0026},	/* Offset V */
1721	{0x00, 0x000d, 0x0027},	/* low */
1722	{0x00, 0x0000, 0x0046},
1723	{0x00, 0x0000, 0x0047},
1724	{0x00, 0x0000, 0x0048},
1725	{0x00, 0x0000, 0x0049},
1726	{0x00, 0x0008, 0x004a},
1727/* DSP Registers	*/
1728	{0x01, 0x00a6, 0x0000},
1729	{0x01, 0x0028, 0x0001},
1730	{0x01, 0x0000, 0x0002},
1731	{0x01, 0x000a, 0x0003},	/* Level Calc bit7 ->1 Auto */
1732	{0x01, 0x0040, 0x0004},
1733	{0x01, 0x0066, 0x0007},
1734	{0x01, 0x000f, 0x0008},	/* A11 Color correction coeff */
1735	{0x01, 0x002d, 0x0009},	/* A12 */
1736	{0x01, 0x0005, 0x000a},	/* A13 */
1737	{0x01, 0x0023, 0x000b},	/* A21 */
1738	{0x01, 0x00e0, 0x000c},	/* A22 */
1739	{0x01, 0x00fd, 0x000d},	/* A23 */
1740	{0x01, 0x00f4, 0x000e},	/* A31 */
1741	{0x01, 0x00e4, 0x000f},	/* A32 */
1742	{0x01, 0x0028, 0x0010},	/* A33 */
1743	{0x01, 0x00ff, 0x0015},	/* Reserved */
1744	{0x01, 0x0001, 0x0016},	/* Reserved */
1745	{0x01, 0x0032, 0x0017},	/* Win1 Start begin */
1746	{0x01, 0x0023, 0x0018},
1747	{0x01, 0x00ce, 0x0019},
1748	{0x01, 0x0023, 0x001a},
1749	{0x01, 0x0032, 0x001b},
1750	{0x01, 0x008d, 0x001c},
1751	{0x01, 0x00ce, 0x001d},
1752	{0x01, 0x008d, 0x001e},
1753	{0x01, 0x0000, 0x001f},
1754	{0x01, 0x0000, 0x0020},	/* Win1 Start end */
1755	{0x01, 0x00ff, 0x003e},	/* Reserved begin */
1756	{0x01, 0x0002, 0x003f},
1757	{0x01, 0x0000, 0x0040},
1758	{0x01, 0x0035, 0x0041},
1759	{0x01, 0x0053, 0x0042},
1760	{0x01, 0x0069, 0x0043},
1761	{0x01, 0x007c, 0x0044},
1762	{0x01, 0x008c, 0x0045},
1763	{0x01, 0x009a, 0x0046},
1764	{0x01, 0x00a8, 0x0047},
1765	{0x01, 0x00b4, 0x0048},
1766	{0x01, 0x00bf, 0x0049},
1767	{0x01, 0x00ca, 0x004a},
1768	{0x01, 0x00d4, 0x004b},
1769	{0x01, 0x00dd, 0x004c},
1770	{0x01, 0x00e7, 0x004d},
1771	{0x01, 0x00ef, 0x004e},
1772	{0x01, 0x00f8, 0x004f},
1773	{0x01, 0x00ff, 0x0050},
1774	{0x01, 0x0003, 0x0056},	/* Reserved end */
1775	{0x01, 0x0060, 0x0057},	/* Edge Gain */
1776	{0x01, 0x0040, 0x0058},
1777	{0x01, 0x0011, 0x0059},	/* Edge Bandwidth */
1778	{0x01, 0x0001, 0x005a},
1779	{0x02, 0x0007, 0x0005},
1780	{0x02, 0xa048, 0x0000},
1781	{0x02, 0x0007, 0x0005},
1782	{0x02, 0x0015, 0x0006},
1783	{0x02, 0x200a, 0x0007},
1784	{0x02, 0xa048, 0x0000},
1785	{0x02, 0xc000, 0x0001},
1786	{0x02, 0x000f, 0x0005},
1787	{0x02, 0xa048, 0x0000},
1788	{0x05, 0x0022, 0x0004},
1789	{0x05, 0x0025, 0x0001},
1790	{0x05, 0x0000, 0x0000},
1791/* Part 4 */
1792	{0x05, 0x0026, 0x0001},
1793	{0x05, 0x0001, 0x0000},
1794	{0x05, 0x0027, 0x0001},
1795	{0x05, 0x0000, 0x0000},
1796	{0x05, 0x0001, 0x0001},
1797	{0x05, 0x0000, 0x0000},
1798	{0x05, 0x0021, 0x0001},
1799	{0x05, 0x00d2, 0x0000},
1800	{0x05, 0x0020, 0x0001},
1801	{0x05, 0x0000, 0x0000},
1802	{0x00, 0x0090, 0x0005},
1803	{0x01, 0x00a6, 0x0000},
1804	{0x02, 0x0000, 0x0005},
1805	{0x05, 0x0026, 0x0001},
1806	{0x05, 0x0001, 0x0000},
1807	{0x05, 0x0027, 0x0001},
1808	{0x05, 0x004e, 0x0000},
1809/* Part 5 */
1810	{0x01, 0x0003, 0x003f},
1811	{0x01, 0x0001, 0x0056},
1812	{0x01, 0x000f, 0x0008},
1813	{0x01, 0x002d, 0x0009},
1814	{0x01, 0x0005, 0x000a},
1815	{0x01, 0x0023, 0x000b},
1816	{0x01, 0xffe0, 0x000c},
1817	{0x01, 0xfffd, 0x000d},
1818	{0x01, 0xfff4, 0x000e},
1819	{0x01, 0xffe4, 0x000f},
1820	{0x01, 0x0028, 0x0010},
1821	{0x01, 0x00a8, 0x0001},
1822	{0x01, 0x0066, 0x0007},
1823	{0x01, 0x0032, 0x0017},
1824	{0x01, 0x0023, 0x0018},
1825	{0x01, 0x00ce, 0x0019},
1826	{0x01, 0x0023, 0x001a},
1827	{0x01, 0x0032, 0x001b},
1828	{0x01, 0x008d, 0x001c},
1829	{0x01, 0x00ce, 0x001d},
1830	{0x01, 0x008d, 0x001e},
1831	{0x01, 0x00c8, 0x0015},	/* c8 Poids fort Luma */
1832	{0x01, 0x0032, 0x0016},	/* 32 */
1833	{0x01, 0x0016, 0x0011},	/* R 00 */
1834	{0x01, 0x0016, 0x0012},	/* G 00 */
1835	{0x01, 0x0016, 0x0013},	/* B 00 */
1836	{0x01, 0x000a, 0x0003},
1837	{0x02, 0xc002, 0x0001},
1838	{0x02, 0x0007, 0x0005},
1839	{}
1840};
1841
1842static int reg_write(struct usb_device *dev,
1843		     __u16 req, __u16 index, __u16 value)
1844{
1845	int ret;
1846
1847	ret = usb_control_msg(dev,
1848			usb_sndctrlpipe(dev, 0),
1849			req,
1850			USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1851			value, index, NULL, 0, 500);
1852	PDEBUG(D_USBO, "reg write: 0x%02x 0x%02x 0x%02x",
1853		req, index, value);
1854	if (ret < 0)
1855		err("reg write: error %d", ret);
1856	return ret;
1857}
1858
1859
1860static int write_vector(struct gspca_dev *gspca_dev,
1861			const __u16 data[][3])
1862{
1863	struct usb_device *dev = gspca_dev->dev;
1864	int ret, i = 0;
1865
1866	while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
1867		ret = reg_write(dev, data[i][0], data[i][2], data[i][1]);
1868		if (ret < 0) {
1869			PDEBUG(D_ERR,
1870				"Reg write failed for 0x%02x,0x%02x,0x%02x",
1871				data[i][0], data[i][1], data[i][2]);
1872			return ret;
1873		}
1874		i++;
1875	}
1876	return 0;
1877}
1878
1879static void setbrightness(struct gspca_dev *gspca_dev)
1880{
1881	struct sd *sd = (struct sd *) gspca_dev;
1882
1883	reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x12, sd->brightness);
1884}
1885
1886static void setcontrast(struct gspca_dev *gspca_dev)
1887{
1888	struct sd *sd = (struct sd *) gspca_dev;
1889
1890	reg_write(gspca_dev->dev, 0x00, 0x00,
1891				  (sd->contrast >> 8) & 0xff);
1892	reg_write(gspca_dev->dev, 0x00, 0x01,
1893				  sd->contrast & 0xff);
1894}
1895
1896static void setcolors(struct gspca_dev *gspca_dev)
1897{
1898	struct sd *sd = (struct sd *) gspca_dev;
1899
1900	reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x0c, sd->colors);
1901}
1902
1903static void setblue_balance(struct gspca_dev *gspca_dev)
1904{
1905	struct sd *sd = (struct sd *) gspca_dev;
1906
1907	reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, sd->blue_balance);
1908}
1909
1910static void setred_balance(struct gspca_dev *gspca_dev)
1911{
1912	struct sd *sd = (struct sd *) gspca_dev;
1913
1914	reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, sd->red_balance);
1915}
1916
1917/* this function is called at probe time */
1918static int sd_config(struct gspca_dev *gspca_dev,
1919			const struct usb_device_id *id)
1920{
1921	struct sd *sd = (struct sd *) gspca_dev;
1922	struct cam *cam;
1923
1924	cam = &gspca_dev->cam;
1925	cam->cam_mode = vga_mode;
1926	cam->nmodes = ARRAY_SIZE(vga_mode);
1927	sd->subtype = id->driver_info;
1928	sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value;
1929	sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value;
1930	sd->colors = sd_ctrls[MY_COLOR].qctrl.default_value;
1931
1932	return 0;
1933}
1934
1935/* this function is called at probe and resume time */
1936static int sd_init(struct gspca_dev *gspca_dev)
1937{
1938	struct sd *sd = (struct sd *) gspca_dev;
1939
1940	switch (sd->subtype) {
1941	case Arowana300KCMOSCamera:
1942	case SmileIntlCamera:
1943		/* Arowana 300k CMOS Camera data */
1944		if (write_vector(gspca_dev, spca501c_arowana_init_data))
1945			goto error;
1946		break;
1947	case MystFromOriUnknownCamera:
1948		/* Unknown Ori CMOS Camera data */
1949		if (write_vector(gspca_dev, spca501c_mysterious_open_data))
1950			goto error;
1951		break;
1952	default:
1953		/* generic spca501 init data */
1954		if (write_vector(gspca_dev, spca501_init_data))
1955			goto error;
1956		break;
1957	}
1958	PDEBUG(D_STREAM, "Initializing SPCA501 finished");
1959	return 0;
1960error:
1961	return -EINVAL;
1962}
1963
1964static int sd_start(struct gspca_dev *gspca_dev)
1965{
1966	struct sd *sd = (struct sd *) gspca_dev;
1967	struct usb_device *dev = gspca_dev->dev;
1968	int mode;
1969
1970	switch (sd->subtype) {
1971	case ThreeComHomeConnectLite:
1972		/* Special handling for 3com data */
1973		write_vector(gspca_dev, spca501_3com_open_data);
1974		break;
1975	case Arowana300KCMOSCamera:
1976	case SmileIntlCamera:
1977		/* Arowana 300k CMOS Camera data */
1978		write_vector(gspca_dev, spca501c_arowana_open_data);
1979		break;
1980	case MystFromOriUnknownCamera:
1981		/* Unknown CMOS Camera data */
1982		write_vector(gspca_dev, spca501c_mysterious_init_data);
1983		break;
1984	default:
1985		/* Generic 501 open data */
1986		write_vector(gspca_dev, spca501_open_data);
1987	}
1988
1989	/* memorize the wanted pixel format */
1990	mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1991
1992	/* Enable ISO packet machine CTRL reg=2,
1993	 * index=1 bitmask=0x2 (bit ordinal 1) */
1994	reg_write(dev, SPCA50X_REG_USB, 0x6, 0x94);
1995	switch (mode) {
1996	case 0: /* 640x480 */
1997		reg_write(dev, SPCA50X_REG_USB, 0x07, 0x004a);
1998		break;
1999	case 1: /* 320x240 */
2000		reg_write(dev, SPCA50X_REG_USB, 0x07, 0x104a);
2001		break;
2002	default:
2003/*	case 2:  * 160x120 */
2004		reg_write(dev, SPCA50X_REG_USB, 0x07, 0x204a);
2005		break;
2006	}
2007	reg_write(dev, SPCA501_REG_CTLRL, 0x01, 0x02);
2008
2009	/* HDG atleast the Intel CreateAndShare needs to have one of its
2010	 * brightness / contrast / color set otherwise it assumes what seems
2011	 * max contrast. Note that strange enough setting any of these is
2012	 * enough to fix the max contrast problem, to be sure we set all 3 */
2013	setbrightness(gspca_dev);
2014	setcontrast(gspca_dev);
2015	setcolors(gspca_dev);
2016	return 0;
2017}
2018
2019static void sd_stopN(struct gspca_dev *gspca_dev)
2020{
2021	/* Disable ISO packet
2022	 * machine CTRL reg=2, index=1 bitmask=0x0 (bit ordinal 1) */
2023	reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00);
2024}
2025
2026/* called on streamoff with alt 0 and on disconnect */
2027static void sd_stop0(struct gspca_dev *gspca_dev)
2028{
2029	if (!gspca_dev->present)
2030		return;
2031	reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00);
2032}
2033
2034static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2035			u8 *data,			/* isoc packet */
2036			int len)			/* iso packet length */
2037{
2038	switch (data[0]) {
2039	case 0:				/* start of frame */
2040		gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2041		data += SPCA501_OFFSET_DATA;
2042		len -= SPCA501_OFFSET_DATA;
2043		gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
2044		return;
2045	case 0xff:			/* drop */
2046/*		gspca_dev->last_packet_type = DISCARD_PACKET; */
2047		return;
2048	}
2049	data++;
2050	len--;
2051	gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2052}
2053
2054static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2055{
2056	struct sd *sd = (struct sd *) gspca_dev;
2057
2058	sd->brightness = val;
2059	if (gspca_dev->streaming)
2060		setbrightness(gspca_dev);
2061	return 0;
2062}
2063
2064static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2065{
2066	struct sd *sd = (struct sd *) gspca_dev;
2067
2068	*val = sd->brightness;
2069	return 0;
2070}
2071
2072static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2073{
2074	struct sd *sd = (struct sd *) gspca_dev;
2075
2076	sd->contrast = val;
2077	if (gspca_dev->streaming)
2078		setcontrast(gspca_dev);
2079	return 0;
2080}
2081
2082static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2083{
2084	struct sd *sd = (struct sd *) gspca_dev;
2085
2086	*val = sd->contrast;
2087	return 0;
2088}
2089
2090static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2091{
2092	struct sd *sd = (struct sd *) gspca_dev;
2093
2094	sd->colors = val;
2095	if (gspca_dev->streaming)
2096		setcolors(gspca_dev);
2097	return 0;
2098}
2099
2100static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2101{
2102	struct sd *sd = (struct sd *) gspca_dev;
2103
2104	*val = sd->colors;
2105	return 0;
2106}
2107
2108static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2109{
2110	struct sd *sd = (struct sd *) gspca_dev;
2111
2112	sd->blue_balance = val;
2113	if (gspca_dev->streaming)
2114		setblue_balance(gspca_dev);
2115	return 0;
2116}
2117
2118static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2119{
2120	struct sd *sd = (struct sd *) gspca_dev;
2121
2122	*val = sd->blue_balance;
2123	return 0;
2124}
2125
2126static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2127{
2128	struct sd *sd = (struct sd *) gspca_dev;
2129
2130	sd->red_balance = val;
2131	if (gspca_dev->streaming)
2132		setred_balance(gspca_dev);
2133	return 0;
2134}
2135
2136static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2137{
2138	struct sd *sd = (struct sd *) gspca_dev;
2139
2140	*val = sd->red_balance;
2141	return 0;
2142}
2143
2144/* sub-driver description */
2145static const struct sd_desc sd_desc = {
2146	.name = MODULE_NAME,
2147	.ctrls = sd_ctrls,
2148	.nctrls = ARRAY_SIZE(sd_ctrls),
2149	.config = sd_config,
2150	.init = sd_init,
2151	.start = sd_start,
2152	.stopN = sd_stopN,
2153	.stop0 = sd_stop0,
2154	.pkt_scan = sd_pkt_scan,
2155};
2156
2157/* -- module initialisation -- */
2158static const struct usb_device_id device_table[] = {
2159	{USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325},
2160	{USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera},
2161	{USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite},
2162	{USB_DEVICE(0x0733, 0x0401), .driver_info = IntelCreateAndShare},
2163	{USB_DEVICE(0x0733, 0x0402), .driver_info = ViewQuestM318B},
2164	{USB_DEVICE(0x1776, 0x501c), .driver_info = Arowana300KCMOSCamera},
2165	{USB_DEVICE(0x0000, 0x0000), .driver_info = MystFromOriUnknownCamera},
2166	{}
2167};
2168MODULE_DEVICE_TABLE(usb, device_table);
2169
2170/* -- device connect -- */
2171static int sd_probe(struct usb_interface *intf,
2172			const struct usb_device_id *id)
2173{
2174	return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2175				THIS_MODULE);
2176}
2177
2178static struct usb_driver sd_driver = {
2179	.name = MODULE_NAME,
2180	.id_table = device_table,
2181	.probe = sd_probe,
2182	.disconnect = gspca_disconnect,
2183#ifdef CONFIG_PM
2184	.suspend = gspca_suspend,
2185	.resume = gspca_resume,
2186#endif
2187};
2188
2189/* -- module insert / remove -- */
2190static int __init sd_mod_init(void)
2191{
2192	return usb_register(&sd_driver);
2193}
2194static void __exit sd_mod_exit(void)
2195{
2196	usb_deregister(&sd_driver);
2197}
2198
2199module_init(sd_mod_init);
2200module_exit(sd_mod_exit);