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