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