V4L/DVB (9870): gspca - vc032x: Webcam 15b8:6002 and sensor po1200 added.
[linux-2.6.git] / drivers / media / video / gspca / vc032x.c
1 /*
2  *              Z-star vc0321 library
3  *              Copyright (C) 2006 Koninski Artur takeshi87@o2.pl
4  *              Copyright (C) 2006 Michel Xhaard
5  *
6  * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22
23 #define MODULE_NAME "vc032x"
24
25 #include "gspca.h"
26
27 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
28 MODULE_DESCRIPTION("GSPCA/VC032X USB Camera Driver");
29 MODULE_LICENSE("GPL");
30
31 /* specific webcam descriptor */
32 struct sd {
33         struct gspca_dev gspca_dev;     /* !! must be the first item */
34
35         __u8 hflip;
36         __u8 vflip;
37         __u8 lightfreq;
38
39         char qindex;
40         char bridge;
41 #define BRIDGE_VC0321 0
42 #define BRIDGE_VC0323 1
43         char sensor;
44 #define SENSOR_HV7131R 0
45 #define SENSOR_MI0360 1
46 #define SENSOR_MI1320 2
47 #define SENSOR_MI1310_SOC 3
48 #define SENSOR_OV7660 4
49 #define SENSOR_OV7670 5
50 #define SENSOR_PO1200 6
51 #define SENSOR_PO3130NC 7
52 };
53
54 /* V4L2 controls supported by the driver */
55 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
56 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
57 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
58 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
59 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
60 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
61
62 static struct ctrl sd_ctrls[] = {
63 /* next 2 controls work with ov7660 and ov7670 only */
64 #define HFLIP_IDX 0
65         {
66             {
67                 .id      = V4L2_CID_HFLIP,
68                 .type    = V4L2_CTRL_TYPE_BOOLEAN,
69                 .name    = "Mirror",
70                 .minimum = 0,
71                 .maximum = 1,
72                 .step    = 1,
73 #define HFLIP_DEF 0
74                 .default_value = HFLIP_DEF,
75             },
76             .set = sd_sethflip,
77             .get = sd_gethflip,
78         },
79 #define VFLIP_IDX 1
80         {
81             {
82                 .id      = V4L2_CID_VFLIP,
83                 .type    = V4L2_CTRL_TYPE_BOOLEAN,
84                 .name    = "Vflip",
85                 .minimum = 0,
86                 .maximum = 1,
87                 .step    = 1,
88 #define VFLIP_DEF 0
89                 .default_value = VFLIP_DEF,
90             },
91             .set = sd_setvflip,
92             .get = sd_getvflip,
93         },
94 #define LIGHTFREQ_IDX 2
95         {
96             {
97                 .id      = V4L2_CID_POWER_LINE_FREQUENCY,
98                 .type    = V4L2_CTRL_TYPE_MENU,
99                 .name    = "Light frequency filter",
100                 .minimum = 0,
101                 .maximum = 2,   /* 0: No, 1: 50Hz, 2:60Hz */
102                 .step    = 1,
103 #define FREQ_DEF 1
104                 .default_value = FREQ_DEF,
105             },
106             .set = sd_setfreq,
107             .get = sd_getfreq,
108         },
109 };
110
111 static struct v4l2_pix_format vc0321_mode[] = {
112         {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
113                 .bytesperline = 320,
114                 .sizeimage = 320 * 240 * 2,
115                 .colorspace = V4L2_COLORSPACE_SRGB,
116                 .priv = 1},
117         {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
118                 .bytesperline = 640,
119                 .sizeimage = 640 * 480 * 2,
120                 .colorspace = V4L2_COLORSPACE_SRGB,
121                 .priv = 0},
122 };
123 static struct v4l2_pix_format vc0323_mode[] = {
124         {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
125                 .bytesperline = 320,
126                 .sizeimage = 320 * 240 * 3 / 8 + 590,
127                 .colorspace = V4L2_COLORSPACE_JPEG,
128                 .priv = 1},
129         {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
130                 .bytesperline = 640,
131                 .sizeimage = 640 * 480 * 3 / 8 + 590,
132                 .colorspace = V4L2_COLORSPACE_JPEG,
133                 .priv = 0},
134 };
135
136 static struct v4l2_pix_format svga_mode[] = {
137         {800, 600, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
138                 .bytesperline = 800,
139                 .sizeimage = 800 * 600 * 1 / 4 + 590,
140                 .colorspace = V4L2_COLORSPACE_JPEG,
141                 .priv = 0},
142 };
143
144 /* OV7660/7670 registers */
145 #define OV7660_REG_MVFP 0x1e
146 #define OV7660_MVFP_MIRROR      0x20
147 #define OV7660_MVFP_VFLIP       0x10
148
149 static const __u8 mi0360_matrix[9] = {
150         0x50, 0xf8, 0xf8, 0xf5, 0x50, 0xfb, 0xff, 0xf1, 0x50
151 };
152
153 static const __u8 mi0360_initVGA_JPG[][4] = {
154         {0xb0, 0x03, 0x19, 0xcc},
155         {0xb0, 0x04, 0x02, 0xcc},
156         {0xb3, 0x00, 0x24, 0xcc},
157         {0xb3, 0x00, 0x25, 0xcc},
158         {0xb3, 0x08, 0x01, 0xcc},
159         {0xb3, 0x09, 0x0c, 0xcc},
160         {0xb3, 0x05, 0x01, 0xcc},
161         {0xb3, 0x06, 0x03, 0xcc},
162         {0xb3, 0x03, 0x0a, 0xcc},
163         {0xb3, 0x20, 0x00, 0xcc},
164         {0xb3, 0x21, 0x00, 0xcc},
165         {0xb3, 0x22, 0x01, 0xcc},
166         {0xb3, 0x23, 0xe0, 0xcc},
167         {0xb3, 0x04, 0x05, 0xcc},
168         {0xb3, 0x14, 0x00, 0xcc},
169         {0xb3, 0x15, 0x00, 0xcc},
170         {0xb3, 0x16, 0x02, 0xcc},
171         {0xb3, 0x17, 0x7f, 0xcc},
172         {0xb3, 0x35, 0xdd, 0xcc},
173         {0xb3, 0x34, 0x02, 0xcc},
174         {0xb3, 0x00, 0x25, 0xcc},
175         {0xbc, 0x00, 0x71, 0xcc},
176         {0xb8, 0x00, 0x13, 0xcc},
177         {0xb8, 0x27, 0x20, 0xcc},
178         {0xb8, 0x2c, 0x50, 0xcc},
179         {0xb8, 0x2d, 0xf8, 0xcc},
180         {0xb8, 0x2e, 0xf8, 0xcc},
181         {0xb8, 0x2f, 0xf8, 0xcc},
182         {0xb8, 0x30, 0x50, 0xcc},
183         {0xb8, 0x31, 0xf8, 0xcc},
184         {0xb8, 0x32, 0xf8, 0xcc},
185         {0xb8, 0x33, 0xf8, 0xcc},
186         {0xb8, 0x34, 0x50, 0xcc},
187         {0xb8, 0x35, 0x00, 0xcc},
188         {0xb8, 0x36, 0x00, 0xcc},
189         {0xb8, 0x37, 0x00, 0xcc},
190         {0xb8, 0x01, 0x79, 0xcc},
191         {0xb8, 0x08, 0xe0, 0xcc},
192         {0xb3, 0x01, 0x41, 0xcc},
193         {0xb8, 0x01, 0x79, 0xcc},
194         {0xb8, 0x14, 0x18, 0xcc},
195         {0xb8, 0xb2, 0x0a, 0xcc},
196         {0xb8, 0xb4, 0x0a, 0xcc},
197         {0xb8, 0xb5, 0x0a, 0xcc},
198         {0xb8, 0xfe, 0x00, 0xcc},
199         {0xb8, 0xff, 0x28, 0xcc},
200         {0xb9, 0x00, 0x28, 0xcc},
201         {0xb9, 0x01, 0x28, 0xcc},
202         {0xb9, 0x02, 0x28, 0xcc},
203         {0xb9, 0x03, 0x00, 0xcc},
204         {0xb9, 0x04, 0x00, 0xcc},
205         {0xb9, 0x05, 0x3c, 0xcc},
206         {0xb9, 0x06, 0x3c, 0xcc},
207         {0xb9, 0x07, 0x3c, 0xcc},
208         {0xb9, 0x08, 0x3c, 0xcc},
209         {0xb8, 0x8e, 0x00, 0xcc},
210         {0xb8, 0x8f, 0xff, 0xcc},
211         {0xb8, 0x81, 0x09, 0xcc},
212         {0x31, 0x00, 0x00, 0xbb},
213         {0x09, 0x01, 0xc7, 0xbb},
214         {0x34, 0x01, 0x00, 0xbb},
215         {0x2b, 0x00, 0x28, 0xbb},
216         {0x2c, 0x00, 0x30, 0xbb},
217         {0x2d, 0x00, 0x30, 0xbb},
218         {0x2e, 0x00, 0x28, 0xbb},
219         {0x62, 0x04, 0x11, 0xbb},
220         {0x03, 0x01, 0xe0, 0xbb},
221         {0x2c, 0x00, 0x2c, 0xbb},
222         {0x20, 0xd0, 0x00, 0xbb},
223         {0x01, 0x00, 0x08, 0xbb},
224         {0x06, 0x00, 0x10, 0xbb},
225         {0x05, 0x00, 0x20, 0xbb},
226         {0x20, 0x00, 0x00, 0xbb},
227         {0xb6, 0x00, 0x00, 0xcc},
228         {0xb6, 0x03, 0x02, 0xcc},
229         {0xb6, 0x02, 0x80, 0xcc},
230         {0xb6, 0x05, 0x01, 0xcc},
231         {0xb6, 0x04, 0xe0, 0xcc},
232         {0xb6, 0x12, 0x78, 0xcc},
233         {0xb6, 0x18, 0x02, 0xcc},
234         {0xb6, 0x17, 0x58, 0xcc},
235         {0xb6, 0x16, 0x00, 0xcc},
236         {0xb6, 0x22, 0x12, 0xcc},
237         {0xb6, 0x23, 0x0b, 0xcc},
238         {0xb3, 0x02, 0x02, 0xcc},
239         {0xbf, 0xc0, 0x39, 0xcc},
240         {0xbf, 0xc1, 0x04, 0xcc},
241         {0xbf, 0xcc, 0x10, 0xcc},
242         {0xb9, 0x12, 0x00, 0xcc},
243         {0xb9, 0x13, 0x0a, 0xcc},
244         {0xb9, 0x14, 0x0a, 0xcc},
245         {0xb9, 0x15, 0x0a, 0xcc},
246         {0xb9, 0x16, 0x0a, 0xcc},
247         {0xb9, 0x18, 0x00, 0xcc},
248         {0xb9, 0x19, 0x0f, 0xcc},
249         {0xb9, 0x1a, 0x0f, 0xcc},
250         {0xb9, 0x1b, 0x0f, 0xcc},
251         {0xb9, 0x1c, 0x0f, 0xcc},
252         {0xb8, 0x8e, 0x00, 0xcc},
253         {0xb8, 0x8f, 0xff, 0xcc},
254         {0xb6, 0x12, 0xf8, 0xcc},
255         {0xb8, 0x0c, 0x20, 0xcc},
256         {0xb8, 0x0d, 0x70, 0xcc},
257         {0xb6, 0x13, 0x13, 0xcc},
258         {0x35, 0x00, 0x60, 0xbb},
259         {0xb3, 0x5c, 0x01, 0xcc},
260         {}
261 };
262 static const __u8 mi0360_initQVGA_JPG[][4] = {
263         {0xb0, 0x03, 0x19, 0xcc},
264         {0xb0, 0x04, 0x02, 0xcc},
265         {0xb3, 0x00, 0x24, 0xcc},
266         {0xb3, 0x00, 0x25, 0xcc},
267         {0xb3, 0x08, 0x01, 0xcc},
268         {0xb3, 0x09, 0x0c, 0xcc},
269         {0xb3, 0x05, 0x01, 0xcc},
270         {0xb3, 0x06, 0x03, 0xcc},
271         {0xb3, 0x03, 0x0a, 0xcc},
272         {0xb3, 0x20, 0x00, 0xcc},
273         {0xb3, 0x21, 0x00, 0xcc},
274         {0xb3, 0x22, 0x01, 0xcc},
275         {0xb3, 0x23, 0xe0, 0xcc},
276         {0xb3, 0x04, 0x05, 0xcc},
277         {0xb3, 0x14, 0x00, 0xcc},
278         {0xb3, 0x15, 0x00, 0xcc},
279         {0xb3, 0x16, 0x02, 0xcc},
280         {0xb3, 0x17, 0x7f, 0xcc},
281         {0xb3, 0x35, 0xdd, 0xcc},
282         {0xb3, 0x34, 0x02, 0xcc},
283         {0xb3, 0x00, 0x25, 0xcc},
284         {0xbc, 0x00, 0xd1, 0xcc},
285         {0xb8, 0x00, 0x13, 0xcc},
286         {0xb8, 0x27, 0x20, 0xcc},
287         {0xb8, 0x2c, 0x50, 0xcc},
288         {0xb8, 0x2d, 0xf8, 0xcc},
289         {0xb8, 0x2e, 0xf8, 0xcc},
290         {0xb8, 0x2f, 0xf8, 0xcc},
291         {0xb8, 0x30, 0x50, 0xcc},
292         {0xb8, 0x31, 0xf8, 0xcc},
293         {0xb8, 0x32, 0xf8, 0xcc},
294         {0xb8, 0x33, 0xf8, 0xcc},
295         {0xb8, 0x34, 0x50, 0xcc},
296         {0xb8, 0x35, 0x00, 0xcc},
297         {0xb8, 0x36, 0x00, 0xcc},
298         {0xb8, 0x37, 0x00, 0xcc},
299         {0xb8, 0x01, 0x79, 0xcc},
300         {0xb8, 0x08, 0xe0, 0xcc},
301         {0xb3, 0x01, 0x41, 0xcc},
302         {0xb8, 0x01, 0x79, 0xcc},
303         {0xb8, 0x14, 0x18, 0xcc},
304         {0xb8, 0xb2, 0x0a, 0xcc},
305         {0xb8, 0xb4, 0x0a, 0xcc},
306         {0xb8, 0xb5, 0x0a, 0xcc},
307         {0xb8, 0xfe, 0x00, 0xcc},
308         {0xb8, 0xff, 0x28, 0xcc},
309         {0xb9, 0x00, 0x28, 0xcc},
310         {0xb9, 0x01, 0x28, 0xcc},
311         {0xb9, 0x02, 0x28, 0xcc},
312         {0xb9, 0x03, 0x00, 0xcc},
313         {0xb9, 0x04, 0x00, 0xcc},
314         {0xb9, 0x05, 0x3c, 0xcc},
315         {0xb9, 0x06, 0x3c, 0xcc},
316         {0xb9, 0x07, 0x3c, 0xcc},
317         {0xb9, 0x08, 0x3c, 0xcc},
318         {0xb8, 0x8e, 0x00, 0xcc},
319         {0xb8, 0x8f, 0xff, 0xcc},
320         {0xb8, 0x81, 0x09, 0xcc},
321         {0x31, 0x00, 0x00, 0xbb},
322         {0x09, 0x01, 0xc7, 0xbb},
323         {0x34, 0x01, 0x00, 0xbb},
324         {0x2b, 0x00, 0x28, 0xbb},
325         {0x2c, 0x00, 0x30, 0xbb},
326         {0x2d, 0x00, 0x30, 0xbb},
327         {0x2e, 0x00, 0x28, 0xbb},
328         {0x62, 0x04, 0x11, 0xbb},
329         {0x03, 0x01, 0xe0, 0xbb},
330         {0x2c, 0x00, 0x2c, 0xbb},
331         {0x20, 0xd0, 0x00, 0xbb},
332         {0x01, 0x00, 0x08, 0xbb},
333         {0x06, 0x00, 0x10, 0xbb},
334         {0x05, 0x00, 0x20, 0xbb},
335         {0x20, 0x00, 0x00, 0xbb},
336         {0xb6, 0x00, 0x00, 0xcc},
337         {0xb6, 0x03, 0x01, 0xcc},
338         {0xb6, 0x02, 0x40, 0xcc},
339         {0xb6, 0x05, 0x00, 0xcc},
340         {0xb6, 0x04, 0xf0, 0xcc},
341         {0xb6, 0x12, 0x78, 0xcc},
342         {0xb6, 0x18, 0x00, 0xcc},
343         {0xb6, 0x17, 0x96, 0xcc},
344         {0xb6, 0x16, 0x00, 0xcc},
345         {0xb6, 0x22, 0x12, 0xcc},
346         {0xb6, 0x23, 0x0b, 0xcc},
347         {0xb3, 0x02, 0x02, 0xcc},
348         {0xbf, 0xc0, 0x39, 0xcc},
349         {0xbf, 0xc1, 0x04, 0xcc},
350         {0xbf, 0xcc, 0x10, 0xcc},
351         {0xb9, 0x12, 0x00, 0xcc},
352         {0xb9, 0x13, 0x0a, 0xcc},
353         {0xb9, 0x14, 0x0a, 0xcc},
354         {0xb9, 0x15, 0x0a, 0xcc},
355         {0xb9, 0x16, 0x0a, 0xcc},
356         {0xb9, 0x18, 0x00, 0xcc},
357         {0xb9, 0x19, 0x0f, 0xcc},
358         {0xb9, 0x1a, 0x0f, 0xcc},
359         {0xb9, 0x1b, 0x0f, 0xcc},
360         {0xb9, 0x1c, 0x0f, 0xcc},
361         {0xb8, 0x8e, 0x00, 0xcc},
362         {0xb8, 0x8f, 0xff, 0xcc},
363         {0xb6, 0x12, 0xf8, 0xcc},
364         {0xb6, 0x13, 0x13, 0xcc},
365         {0xbc, 0x02, 0x18, 0xcc},
366         {0xbc, 0x03, 0x50, 0xcc},
367         {0xbc, 0x04, 0x18, 0xcc},
368         {0xbc, 0x05, 0x00, 0xcc},
369         {0xbc, 0x06, 0x00, 0xcc},
370         {0xbc, 0x08, 0x30, 0xcc},
371         {0xbc, 0x09, 0x40, 0xcc},
372         {0xbc, 0x0a, 0x10, 0xcc},
373         {0xb8, 0x0c, 0x20, 0xcc},
374         {0xb8, 0x0d, 0x70, 0xcc},
375         {0xbc, 0x0b, 0x00, 0xcc},
376         {0xbc, 0x0c, 0x00, 0xcc},
377         {0x35, 0x00, 0xef, 0xbb},
378         {0xb3, 0x5c, 0x01, 0xcc},
379         {}
380 };
381
382 static const __u8 mi1310_socinitVGA_JPG[][4] = {
383         {0xb0, 0x03, 0x19, 0xcc},
384         {0xb0, 0x04, 0x02, 0xcc},
385         {0xb3, 0x00, 0x64, 0xcc},
386         {0xb3, 0x00, 0x65, 0xcc},
387         {0xb3, 0x05, 0x00, 0xcc},
388         {0xb3, 0x06, 0x00, 0xcc},
389         {0xb3, 0x08, 0x01, 0xcc},
390         {0xb3, 0x09, 0x0c, 0xcc},
391         {0xb3, 0x34, 0x02, 0xcc},
392         {0xb3, 0x35, 0xdd, 0xcc},
393         {0xb3, 0x02, 0x00, 0xcc},
394         {0xb3, 0x03, 0x0a, 0xcc},
395         {0xb3, 0x04, 0x05, 0xcc},
396         {0xb3, 0x20, 0x00, 0xcc},
397         {0xb3, 0x21, 0x00, 0xcc},
398         {0xb3, 0x22, 0x03, 0xcc},
399         {0xb3, 0x23, 0xc0, 0xcc},
400         {0xb3, 0x14, 0x00, 0xcc},
401         {0xb3, 0x15, 0x00, 0xcc},
402         {0xb3, 0x16, 0x04, 0xcc},
403         {0xb3, 0x17, 0xff, 0xcc},
404         {0xb3, 0x00, 0x65, 0xcc},
405         {0xb8, 0x00, 0x00, 0xcc},
406         {0xbc, 0x00, 0xd0, 0xcc},
407         {0xbc, 0x01, 0x01, 0xcc},
408         {0xf0, 0x00, 0x02, 0xbb},
409         {0xc8, 0x9f, 0x0b, 0xbb},
410         {0x5b, 0x00, 0x01, 0xbb},
411         {0x2f, 0xde, 0x20, 0xbb},
412         {0xf0, 0x00, 0x00, 0xbb},
413         {0x20, 0x03, 0x02, 0xbb},
414         {0xf0, 0x00, 0x01, 0xbb},
415         {0x05, 0x00, 0x07, 0xbb},
416         {0x34, 0x00, 0x00, 0xbb},
417         {0x35, 0xff, 0x00, 0xbb},
418         {0xdc, 0x07, 0x02, 0xbb},
419         {0xdd, 0x3c, 0x18, 0xbb},
420         {0xde, 0x92, 0x6d, 0xbb},
421         {0xdf, 0xcd, 0xb1, 0xbb},
422         {0xe0, 0xff, 0xe7, 0xbb},
423         {0x06, 0xf0, 0x0d, 0xbb},
424         {0x06, 0x70, 0x0e, 0xbb},
425         {0x4c, 0x00, 0x01, 0xbb},
426         {0x4d, 0x00, 0x01, 0xbb},
427         {0xf0, 0x00, 0x02, 0xbb},
428         {0x2e, 0x0c, 0x55, 0xbb},
429         {0x21, 0xb6, 0x6e, 0xbb},
430         {0x36, 0x30, 0x10, 0xbb},
431         {0x37, 0x00, 0xc1, 0xbb},
432         {0xf0, 0x00, 0x00, 0xbb},
433         {0x07, 0x00, 0x84, 0xbb},
434         {0x08, 0x02, 0x4a, 0xbb},
435         {0x05, 0x01, 0x10, 0xbb},
436         {0x06, 0x00, 0x39, 0xbb},
437         {0xf0, 0x00, 0x02, 0xbb},
438         {0x58, 0x02, 0x67, 0xbb},
439         {0x57, 0x02, 0x00, 0xbb},
440         {0x5a, 0x02, 0x67, 0xbb},
441         {0x59, 0x02, 0x00, 0xbb},
442         {0x5c, 0x12, 0x0d, 0xbb},
443         {0x5d, 0x16, 0x11, 0xbb},
444         {0x39, 0x06, 0x18, 0xbb},
445         {0x3a, 0x06, 0x18, 0xbb},
446         {0x3b, 0x06, 0x18, 0xbb},
447         {0x3c, 0x06, 0x18, 0xbb},
448         {0x64, 0x7b, 0x5b, 0xbb},
449         {0xf0, 0x00, 0x02, 0xbb},
450         {0x36, 0x30, 0x10, 0xbb},
451         {0x37, 0x00, 0xc0, 0xbb},
452         {0xbc, 0x0e, 0x00, 0xcc},
453         {0xbc, 0x0f, 0x05, 0xcc},
454         {0xbc, 0x10, 0xc0, 0xcc},
455         {0xbc, 0x11, 0x03, 0xcc},
456         {0xb6, 0x00, 0x00, 0xcc},
457         {0xb6, 0x03, 0x02, 0xcc},
458         {0xb6, 0x02, 0x80, 0xcc},
459         {0xb6, 0x05, 0x01, 0xcc},
460         {0xb6, 0x04, 0xe0, 0xcc},
461         {0xb6, 0x12, 0xf8, 0xcc},
462         {0xb6, 0x13, 0x25, 0xcc},
463         {0xb6, 0x18, 0x02, 0xcc},
464         {0xb6, 0x17, 0x58, 0xcc},
465         {0xb6, 0x16, 0x00, 0xcc},
466         {0xb6, 0x22, 0x12, 0xcc},
467         {0xb6, 0x23, 0x0b, 0xcc},
468         {0xbf, 0xc0, 0x39, 0xcc},
469         {0xbf, 0xc1, 0x04, 0xcc},
470         {0xbf, 0xcc, 0x00, 0xcc},
471         {0xbc, 0x02, 0x18, 0xcc},
472         {0xbc, 0x03, 0x50, 0xcc},
473         {0xbc, 0x04, 0x18, 0xcc},
474         {0xbc, 0x05, 0x00, 0xcc},
475         {0xbc, 0x06, 0x00, 0xcc},
476         {0xbc, 0x08, 0x30, 0xcc},
477         {0xbc, 0x09, 0x40, 0xcc},
478         {0xbc, 0x0a, 0x10, 0xcc},
479         {0xbc, 0x0b, 0x00, 0xcc},
480         {0xbc, 0x0c, 0x00, 0xcc},
481         {0xb3, 0x5c, 0x01, 0xcc},
482         {0xf0, 0x00, 0x01, 0xbb},
483         {0x80, 0x00, 0x03, 0xbb},
484         {0x81, 0xc7, 0x14, 0xbb},
485         {0x82, 0xeb, 0xe8, 0xbb},
486         {0x83, 0xfe, 0xf4, 0xbb},
487         {0x84, 0xcd, 0x10, 0xbb},
488         {0x85, 0xf3, 0xee, 0xbb},
489         {0x86, 0xff, 0xf1, 0xbb},
490         {0x87, 0xcd, 0x10, 0xbb},
491         {0x88, 0xf3, 0xee, 0xbb},
492         {0x89, 0x01, 0xf1, 0xbb},
493         {0x8a, 0xe5, 0x17, 0xbb},
494         {0x8b, 0xe8, 0xe2, 0xbb},
495         {0x8c, 0xf7, 0xed, 0xbb},
496         {0x8d, 0x00, 0xff, 0xbb},
497         {0x8e, 0xec, 0x10, 0xbb},
498         {0x8f, 0xf0, 0xed, 0xbb},
499         {0x90, 0xf9, 0xf2, 0xbb},
500         {0x91, 0x00, 0x00, 0xbb},
501         {0x92, 0xe9, 0x0d, 0xbb},
502         {0x93, 0xf4, 0xf2, 0xbb},
503         {0x94, 0xfb, 0xf5, 0xbb},
504         {0x95, 0x00, 0xff, 0xbb},
505         {0xb6, 0x0f, 0x08, 0xbb},
506         {0xb7, 0x3d, 0x16, 0xbb},
507         {0xb8, 0x0c, 0x04, 0xbb},
508         {0xb9, 0x1c, 0x07, 0xbb},
509         {0xba, 0x0a, 0x03, 0xbb},
510         {0xbb, 0x1b, 0x09, 0xbb},
511         {0xbc, 0x17, 0x0d, 0xbb},
512         {0xbd, 0x23, 0x1d, 0xbb},
513         {0xbe, 0x00, 0x28, 0xbb},
514         {0xbf, 0x11, 0x09, 0xbb},
515         {0xc0, 0x16, 0x15, 0xbb},
516         {0xc1, 0x00, 0x1b, 0xbb},
517         {0xc2, 0x0e, 0x07, 0xbb},
518         {0xc3, 0x14, 0x10, 0xbb},
519         {0xc4, 0x00, 0x17, 0xbb},
520         {0x06, 0x74, 0x8e, 0xbb},
521         {0xf0, 0x00, 0x01, 0xbb},
522         {0x06, 0xf4, 0x8e, 0xbb},
523         {0x00, 0x00, 0x50, 0xdd},
524         {0x06, 0x74, 0x8e, 0xbb},
525         {0xf0, 0x00, 0x02, 0xbb},
526         {0x24, 0x50, 0x20, 0xbb},
527         {0xf0, 0x00, 0x02, 0xbb},
528         {0x34, 0x0c, 0x50, 0xbb},
529         {0xb3, 0x01, 0x41, 0xcc},
530         {0xf0, 0x00, 0x00, 0xbb},
531         {0x03, 0x03, 0xc0, 0xbb},
532         {},
533 };
534 static const __u8 mi1310_socinitQVGA_JPG[][4] = {
535         {0xb0, 0x03, 0x19, 0xcc},       {0xb0, 0x04, 0x02, 0xcc},
536         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
537         {0xb3, 0x05, 0x00, 0xcc},       {0xb3, 0x06, 0x00, 0xcc},
538         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
539         {0xb3, 0x34, 0x02, 0xcc},       {0xb3, 0x35, 0xdd, 0xcc},
540         {0xb3, 0x02, 0x00, 0xcc},       {0xb3, 0x03, 0x0a, 0xcc},
541         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
542         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x03, 0xcc},
543         {0xb3, 0x23, 0xc0, 0xcc},       {0xb3, 0x14, 0x00, 0xcc},
544         {0xb3, 0x15, 0x00, 0xcc},       {0xb3, 0x16, 0x04, 0xcc},
545         {0xb3, 0x17, 0xff, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
546         {0xb8, 0x00, 0x00, 0xcc},       {0xbc, 0x00, 0xf0, 0xcc},
547         {0xbc, 0x01, 0x01, 0xcc},       {0xf0, 0x00, 0x02, 0xbb},
548         {0xc8, 0x9f, 0x0b, 0xbb},       {0x5b, 0x00, 0x01, 0xbb},
549         {0x2f, 0xde, 0x20, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
550         {0x20, 0x03, 0x02, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
551         {0x05, 0x00, 0x07, 0xbb},       {0x34, 0x00, 0x00, 0xbb},
552         {0x35, 0xff, 0x00, 0xbb},       {0xdc, 0x07, 0x02, 0xbb},
553         {0xdd, 0x3c, 0x18, 0xbb},       {0xde, 0x92, 0x6d, 0xbb},
554         {0xdf, 0xcd, 0xb1, 0xbb},       {0xe0, 0xff, 0xe7, 0xbb},
555         {0x06, 0xf0, 0x0d, 0xbb},       {0x06, 0x70, 0x0e, 0xbb},
556         {0x4c, 0x00, 0x01, 0xbb},       {0x4d, 0x00, 0x01, 0xbb},
557         {0xf0, 0x00, 0x02, 0xbb},       {0x2e, 0x0c, 0x55, 0xbb},
558         {0x21, 0xb6, 0x6e, 0xbb},       {0x36, 0x30, 0x10, 0xbb},
559         {0x37, 0x00, 0xc1, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
560         {0x07, 0x00, 0x84, 0xbb},       {0x08, 0x02, 0x4a, 0xbb},
561         {0x05, 0x01, 0x10, 0xbb},       {0x06, 0x00, 0x39, 0xbb},
562         {0xf0, 0x00, 0x02, 0xbb},       {0x58, 0x02, 0x67, 0xbb},
563         {0x57, 0x02, 0x00, 0xbb},       {0x5a, 0x02, 0x67, 0xbb},
564         {0x59, 0x02, 0x00, 0xbb},       {0x5c, 0x12, 0x0d, 0xbb},
565         {0x5d, 0x16, 0x11, 0xbb},       {0x39, 0x06, 0x18, 0xbb},
566         {0x3a, 0x06, 0x18, 0xbb},       {0x3b, 0x06, 0x18, 0xbb},
567         {0x3c, 0x06, 0x18, 0xbb},       {0x64, 0x7b, 0x5b, 0xbb},
568         {0xf0, 0x00, 0x02, 0xbb},       {0x36, 0x30, 0x10, 0xbb},
569         {0x37, 0x00, 0xc0, 0xbb},       {0xbc, 0x0e, 0x00, 0xcc},
570         {0xbc, 0x0f, 0x05, 0xcc},       {0xbc, 0x10, 0xc0, 0xcc},
571         {0xbc, 0x11, 0x03, 0xcc},       {0xb6, 0x00, 0x00, 0xcc},
572         {0xb6, 0x03, 0x01, 0xcc},       {0xb6, 0x02, 0x40, 0xcc},
573         {0xb6, 0x05, 0x00, 0xcc},       {0xb6, 0x04, 0xf0, 0xcc},
574         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x25, 0xcc},
575         {0xb6, 0x18, 0x00, 0xcc},       {0xb6, 0x17, 0x96, 0xcc},
576         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
577         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
578         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
579         {0xb3, 0x5c, 0x01, 0xcc},       {0xf0, 0x00, 0x01, 0xbb},
580         {0x80, 0x00, 0x03, 0xbb},       {0x81, 0xc7, 0x14, 0xbb},
581         {0x82, 0xeb, 0xe8, 0xbb},       {0x83, 0xfe, 0xf4, 0xbb},
582         {0x84, 0xcd, 0x10, 0xbb},       {0x85, 0xf3, 0xee, 0xbb},
583         {0x86, 0xff, 0xf1, 0xbb},       {0x87, 0xcd, 0x10, 0xbb},
584         {0x88, 0xf3, 0xee, 0xbb},       {0x89, 0x01, 0xf1, 0xbb},
585         {0x8a, 0xe5, 0x17, 0xbb},       {0x8b, 0xe8, 0xe2, 0xbb},
586         {0x8c, 0xf7, 0xed, 0xbb},       {0x8d, 0x00, 0xff, 0xbb},
587         {0x8e, 0xec, 0x10, 0xbb},       {0x8f, 0xf0, 0xed, 0xbb},
588         {0x90, 0xf9, 0xf2, 0xbb},       {0x91, 0x00, 0x00, 0xbb},
589         {0x92, 0xe9, 0x0d, 0xbb},       {0x93, 0xf4, 0xf2, 0xbb},
590         {0x94, 0xfb, 0xf5, 0xbb},       {0x95, 0x00, 0xff, 0xbb},
591         {0xb6, 0x0f, 0x08, 0xbb},       {0xb7, 0x3d, 0x16, 0xbb},
592         {0xb8, 0x0c, 0x04, 0xbb},       {0xb9, 0x1c, 0x07, 0xbb},
593         {0xba, 0x0a, 0x03, 0xbb},       {0xbb, 0x1b, 0x09, 0xbb},
594         {0xbc, 0x17, 0x0d, 0xbb},       {0xbd, 0x23, 0x1d, 0xbb},
595         {0xbe, 0x00, 0x28, 0xbb},       {0xbf, 0x11, 0x09, 0xbb},
596         {0xc0, 0x16, 0x15, 0xbb},       {0xc1, 0x00, 0x1b, 0xbb},
597         {0xc2, 0x0e, 0x07, 0xbb},       {0xc3, 0x14, 0x10, 0xbb},
598         {0xc4, 0x00, 0x17, 0xbb},       {0x06, 0x74, 0x8e, 0xbb},
599         {0xf0, 0x00, 0x01, 0xbb},       {0x06, 0xf4, 0x8e, 0xbb},
600         {0x00, 0x00, 0x50, 0xdd},       {0x06, 0x74, 0x8e, 0xbb},
601         {0xf0, 0x00, 0x02, 0xbb},       {0x24, 0x50, 0x20, 0xbb},
602         {0xf0, 0x00, 0x02, 0xbb},       {0x34, 0x0c, 0x50, 0xbb},
603         {0xb3, 0x01, 0x41, 0xcc},       {0xf0, 0x00, 0x00, 0xbb},
604         {0x03, 0x03, 0xc0, 0xbb},
605         {},
606 };
607
608 static const __u8 mi1320_gamma[17] = {
609         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
610         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
611 };
612 static const __u8 mi1320_matrix[9] = {
613         0x54, 0xda, 0x06, 0xf1, 0x50, 0xf4, 0xf7, 0xea, 0x52
614 };
615 static const __u8 mi1320_initVGA_data[][4] = {
616         {0xb3, 0x01, 0x01, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
617         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
618         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
619         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
620         {0xb0, 0x16, 0x03, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
621         {0xb3, 0x06, 0x00, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
622         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x34, 0x02, 0xcc},
623         {0xb3, 0x35, 0xc8, 0xcc},       {0xb3, 0x02, 0x00, 0xcc},
624         {0xb3, 0x03, 0x0a, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
625         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
626         {0xb3, 0x22, 0x03, 0xcc},       {0xb3, 0x23, 0xc0, 0xcc},
627         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
628         {0xb3, 0x16, 0x04, 0xcc},       {0xb3, 0x17, 0xff, 0xcc},
629         {0xb3, 0x00, 0x67, 0xcc},       {0xbc, 0x00, 0xd0, 0xcc},
630         {0xbc, 0x01, 0x01, 0xcc},       {0xf0, 0x00, 0x00, 0xbb},
631         {0x0d, 0x00, 0x09, 0xbb},       {0x00, 0x01, 0x00, 0xdd},
632         {0x0d, 0x00, 0x08, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
633         {0xa1, 0x05, 0x00, 0xbb},       {0xa4, 0x03, 0xc0, 0xbb},
634         {0xf0, 0x00, 0x02, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
635         {0xc8, 0x9f, 0x0b, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
636         {0xf0, 0x00, 0x00, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
637         {0x20, 0x01, 0x00, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
638         {0xf0, 0x00, 0x01, 0xbb},       {0x9d, 0x3c, 0xa0, 0xbb},
639         {0x47, 0x30, 0x30, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
640         {0x0a, 0x80, 0x11, 0xbb},       {0x35, 0x00, 0x22, 0xbb},
641         {0xf0, 0x00, 0x02, 0xbb},       {0x9d, 0xc5, 0x05, 0xbb},
642         {0xdc, 0x0f, 0xfc, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
643         {0x06, 0x74, 0x0e, 0xbb},       {0x80, 0x00, 0x06, 0xbb},
644         {0x81, 0x04, 0x00, 0xbb},       {0x82, 0x01, 0x02, 0xbb},
645         {0x83, 0x03, 0x02, 0xbb},       {0x84, 0x05, 0x00, 0xbb},
646         {0x85, 0x01, 0x00, 0xbb},       {0x86, 0x03, 0x02, 0xbb},
647         {0x87, 0x05, 0x00, 0xbb},       {0x88, 0x01, 0x00, 0xbb},
648         {0x89, 0x02, 0x02, 0xbb},       {0x8a, 0xfd, 0x04, 0xbb},
649         {0x8b, 0xfc, 0xfd, 0xbb},       {0x8c, 0xff, 0xfd, 0xbb},
650         {0x8d, 0x00, 0x00, 0xbb},       {0x8e, 0xfe, 0x05, 0xbb},
651         {0x8f, 0xfc, 0xfd, 0xbb},       {0x90, 0xfe, 0xfd, 0xbb},
652         {0x91, 0x00, 0x00, 0xbb},       {0x92, 0xfe, 0x03, 0xbb},
653         {0x93, 0xfd, 0xfe, 0xbb},       {0x94, 0xff, 0xfd, 0xbb},
654         {0x95, 0x00, 0x00, 0xbb},       {0xb6, 0x07, 0x05, 0xbb},
655         {0xb7, 0x13, 0x06, 0xbb},       {0xb8, 0x08, 0x06, 0xbb},
656         {0xb9, 0x14, 0x08, 0xbb},       {0xba, 0x06, 0x05, 0xbb},
657         {0xbb, 0x13, 0x06, 0xbb},       {0xbc, 0x03, 0x01, 0xbb},
658         {0xbd, 0x03, 0x04, 0xbb},       {0xbe, 0x00, 0x02, 0xbb},
659         {0xbf, 0x03, 0x01, 0xbb},       {0xc0, 0x02, 0x04, 0xbb},
660         {0xc1, 0x00, 0x04, 0xbb},       {0xc2, 0x02, 0x01, 0xbb},
661         {0xc3, 0x01, 0x03, 0xbb},       {0xc4, 0x00, 0x04, 0xbb},
662         {0xf0, 0x00, 0x00, 0xbb},       {0x05, 0x01, 0x13, 0xbb},
663         {0x06, 0x00, 0x11, 0xbb},       {0x07, 0x00, 0x85, 0xbb},
664         {0x08, 0x00, 0x27, 0xbb},       {0x20, 0x01, 0x03, 0xbb},
665         {0x21, 0x80, 0x00, 0xbb},       {0x22, 0x0d, 0x0f, 0xbb},
666         {0x24, 0x80, 0x00, 0xbb},       {0x59, 0x00, 0xff, 0xbb},
667         {0xf0, 0x00, 0x02, 0xbb},       {0x39, 0x03, 0x0d, 0xbb},
668         {0x3a, 0x06, 0x1b, 0xbb},       {0x3b, 0x00, 0x95, 0xbb},
669         {0x3c, 0x04, 0xdb, 0xbb},       {0x57, 0x02, 0x00, 0xbb},
670         {0x58, 0x02, 0x66, 0xbb},       {0x59, 0x00, 0xff, 0xbb},
671         {0x5a, 0x01, 0x33, 0xbb},       {0x5c, 0x12, 0x0d, 0xbb},
672         {0x5d, 0x16, 0x11, 0xbb},       {0x64, 0x5e, 0x1c, 0xbb},
673         {0xf0, 0x00, 0x02, 0xbb},       {0x2f, 0xd1, 0x00, 0xbb},
674         {0x5b, 0x00, 0x01, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
675         {0x36, 0x68, 0x10, 0xbb},       {0x00, 0x00, 0x30, 0xdd},
676         {0x37, 0x82, 0x00, 0xbb},       {0xbc, 0x0e, 0x00, 0xcc},
677         {0xbc, 0x0f, 0x05, 0xcc},       {0xbc, 0x10, 0xc0, 0xcc},
678         {0xbc, 0x11, 0x03, 0xcc},       {0xb6, 0x00, 0x00, 0xcc},
679         {0xb6, 0x03, 0x05, 0xcc},       {0xb6, 0x02, 0x00, 0xcc},
680         {0xb6, 0x05, 0x04, 0xcc},       {0xb6, 0x04, 0x00, 0xcc},
681         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x29, 0xcc},
682         {0xb6, 0x18, 0x0a, 0xcc},       {0xb6, 0x17, 0x00, 0xcc},
683         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
684         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x26, 0xcc},
685         {0xbf, 0xc1, 0x02, 0xcc},       {0xbf, 0xcc, 0x04, 0xcc},
686         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
687         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
688         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
689         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
690         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
691         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
692         {}
693 };
694 static const __u8 mi1320_initQVGA_data[][4] = {
695         {0xb3, 0x01, 0x01, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
696         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
697         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
698         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
699         {0xb0, 0x16, 0x03, 0xcc},       {0xb3, 0x05, 0x01, 0xcc},
700         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
701         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x34, 0x02, 0xcc},
702         {0xb3, 0x35, 0xc8, 0xcc},       {0xb3, 0x02, 0x00, 0xcc},
703         {0xb3, 0x03, 0x0a, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
704         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
705         {0xb3, 0x22, 0x01, 0xcc},       {0xb3, 0x23, 0xe0, 0xcc},
706         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
707         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
708         {0xb3, 0x00, 0x65, 0xcc},       {0xb8, 0x00, 0x00, 0xcc},
709         {0xbc, 0x00, 0xd0, 0xcc},       {0xbc, 0x01, 0x01, 0xcc},
710         {0xf0, 0x00, 0x00, 0xbb},       {0x0d, 0x00, 0x09, 0xbb},
711         {0x00, 0x01, 0x00, 0xdd},       {0x0d, 0x00, 0x08, 0xbb},
712         {0xf0, 0x00, 0x00, 0xbb},       {0x02, 0x00, 0x64, 0xbb},
713         {0x05, 0x01, 0x78, 0xbb},       {0x06, 0x00, 0x11, 0xbb},
714         {0x07, 0x01, 0x42, 0xbb},       {0x08, 0x00, 0x11, 0xbb},
715         {0x20, 0x01, 0x00, 0xbb},       {0x21, 0x80, 0x00, 0xbb},
716         {0x22, 0x0d, 0x0f, 0xbb},       {0x24, 0x80, 0x00, 0xbb},
717         {0x59, 0x00, 0xff, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
718         {0x9d, 0x3c, 0xa0, 0xbb},       {0x47, 0x30, 0x30, 0xbb},
719         {0xf0, 0x00, 0x00, 0xbb},       {0x0a, 0x80, 0x11, 0xbb},
720         {0x35, 0x00, 0x22, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
721         {0x9d, 0xc5, 0x05, 0xbb},       {0xdc, 0x0f, 0xfc, 0xbb},
722         {0xf0, 0x00, 0x01, 0xbb},       {0x06, 0x74, 0x0e, 0xbb},
723         {0x80, 0x00, 0x06, 0xbb},       {0x81, 0x04, 0x00, 0xbb},
724         {0x82, 0x01, 0x02, 0xbb},       {0x83, 0x03, 0x02, 0xbb},
725         {0x84, 0x05, 0x00, 0xbb},       {0x85, 0x01, 0x00, 0xbb},
726         {0x86, 0x03, 0x02, 0xbb},       {0x87, 0x05, 0x00, 0xbb},
727         {0x88, 0x01, 0x00, 0xbb},       {0x89, 0x02, 0x02, 0xbb},
728         {0x8a, 0xfd, 0x04, 0xbb},       {0x8b, 0xfc, 0xfd, 0xbb},
729         {0x8c, 0xff, 0xfd, 0xbb},       {0x8d, 0x00, 0x00, 0xbb},
730         {0x8e, 0xfe, 0x05, 0xbb},       {0x8f, 0xfc, 0xfd, 0xbb},
731         {0x90, 0xfe, 0xfd, 0xbb},       {0x91, 0x00, 0x00, 0xbb},
732         {0x92, 0xfe, 0x03, 0xbb},       {0x93, 0xfd, 0xfe, 0xbb},
733         {0x94, 0xff, 0xfd, 0xbb},       {0x95, 0x00, 0x00, 0xbb},
734         {0xb6, 0x07, 0x05, 0xbb},       {0xb7, 0x13, 0x06, 0xbb},
735         {0xb8, 0x08, 0x06, 0xbb},       {0xb9, 0x14, 0x08, 0xbb},
736         {0xba, 0x06, 0x05, 0xbb},       {0xbb, 0x13, 0x06, 0xbb},
737         {0xbc, 0x03, 0x01, 0xbb},       {0xbd, 0x03, 0x04, 0xbb},
738         {0xbe, 0x00, 0x02, 0xbb},       {0xbf, 0x03, 0x01, 0xbb},
739         {0xc0, 0x02, 0x04, 0xbb},       {0xc1, 0x00, 0x04, 0xbb},
740         {0xc2, 0x02, 0x01, 0xbb},       {0xc3, 0x01, 0x03, 0xbb},
741         {0xc4, 0x00, 0x04, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
742         {0xc8, 0x00, 0x00, 0xbb},       {0x2e, 0x00, 0x00, 0xbb},
743         {0x2e, 0x0c, 0x5b, 0xbb},       {0x2f, 0xd1, 0x00, 0xbb},
744         {0x39, 0x03, 0xca, 0xbb},       {0x3a, 0x06, 0x80, 0xbb},
745         {0x3b, 0x01, 0x52, 0xbb},       {0x3c, 0x05, 0x40, 0xbb},
746         {0x57, 0x01, 0x9c, 0xbb},       {0x58, 0x01, 0xee, 0xbb},
747         {0x59, 0x00, 0xf0, 0xbb},       {0x5a, 0x01, 0x20, 0xbb},
748         {0x5c, 0x1d, 0x17, 0xbb},       {0x5d, 0x22, 0x1c, 0xbb},
749         {0x64, 0x1e, 0x1c, 0xbb},       {0x5b, 0x00, 0x01, 0xbb},
750         {0xf0, 0x00, 0x02, 0xbb},       {0x36, 0x68, 0x10, 0xbb},
751         {0x00, 0x00, 0x30, 0xdd},       {0x37, 0x81, 0x00, 0xbb},
752         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
753         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
754         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
755         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
756         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
757         {0xbf, 0xc0, 0x26, 0xcc},       {0xbf, 0xc1, 0x02, 0xcc},
758         {0xbf, 0xcc, 0x04, 0xcc},       {0xb3, 0x5c, 0x01, 0xcc},
759         {0xb3, 0x01, 0x41, 0xcc},
760         {}
761 };
762
763 static const __u8 po3130_gamma[17] = {
764         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
765         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
766 };
767 static const __u8 po3130_matrix[9] = {
768         0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
769 };
770
771 static const __u8 po3130_initVGA_data[][4] = {
772         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
773         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
774         {0xb3, 0x00, 0x04, 0xcc},       {0xb3, 0x00, 0x24, 0xcc},
775         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
776         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
777         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x03, 0x1a, 0xcc},
778         {0xb3, 0x04, 0x15, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
779         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
780         {0xb3, 0x23, 0xe8, 0xcc},       {0xb8, 0x08, 0xe8, 0xcc},
781         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
782         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
783         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0xf6, 0xcc},
784         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0x71, 0xcc},
785         {0xb8, 0x00, 0x21, 0xcc},       {0xb8, 0x27, 0x20, 0xcc},
786         {0xb8, 0x01, 0x79, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
787         {0xb8, 0x2c, 0x50, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
788         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
789         {0xb8, 0x30, 0x50, 0xcc},       {0xb8, 0x31, 0xf8, 0xcc},
790         {0xb8, 0x32, 0xf8, 0xcc},       {0xb8, 0x33, 0xf8, 0xcc},
791         {0xb8, 0x34, 0x50, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
792         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
793         {0x00, 0x1e, 0xc6, 0xaa},       {0x00, 0x20, 0x44, 0xaa},
794         {0x00, 0xad, 0x02, 0xaa},       {0x00, 0xae, 0x2c, 0xaa},
795         {0x00, 0x12, 0x08, 0xaa},       {0x00, 0x17, 0x41, 0xaa},
796         {0x00, 0x19, 0x41, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
797         {0x00, 0x21, 0x00, 0xaa},       {0x00, 0x36, 0xc0, 0xaa},
798         {0x00, 0x37, 0xc8, 0xaa},       {0x00, 0x3b, 0x36, 0xaa},
799         {0x00, 0x4b, 0xfe, 0xaa},       {0x00, 0x51, 0x1c, 0xaa},
800         {0x00, 0x52, 0x01, 0xaa},       {0x00, 0x55, 0x0a, 0xaa},
801         {0x00, 0x59, 0x02, 0xaa},       {0x00, 0x5a, 0x04, 0xaa},
802         {0x00, 0x5c, 0x10, 0xaa},       {0x00, 0x5d, 0x10, 0xaa},
803         {0x00, 0x5e, 0x10, 0xaa},       {0x00, 0x5f, 0x10, 0xaa},
804         {0x00, 0x61, 0x00, 0xaa},       {0x00, 0x62, 0x18, 0xaa},
805         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x70, 0x68, 0xaa},
806         {0x00, 0x80, 0x71, 0xaa},       {0x00, 0x81, 0x08, 0xaa},
807         {0x00, 0x82, 0x00, 0xaa},       {0x00, 0x83, 0x55, 0xaa},
808         {0x00, 0x84, 0x06, 0xaa},       {0x00, 0x85, 0x06, 0xaa},
809         {0x00, 0x86, 0x13, 0xaa},       {0x00, 0x87, 0x18, 0xaa},
810         {0x00, 0xaa, 0x3f, 0xaa},       {0x00, 0xab, 0x44, 0xaa},
811         {0x00, 0xb0, 0x68, 0xaa},       {0x00, 0xb5, 0x10, 0xaa},
812         {0x00, 0xb8, 0x20, 0xaa},       {0x00, 0xb9, 0xa0, 0xaa},
813         {0x00, 0xbc, 0x04, 0xaa},       {0x00, 0x8b, 0x40, 0xaa},
814         {0x00, 0x8c, 0x91, 0xaa},       {0x00, 0x8d, 0x8f, 0xaa},
815         {0x00, 0x8e, 0x91, 0xaa},       {0x00, 0x8f, 0x43, 0xaa},
816         {0x00, 0x90, 0x92, 0xaa},       {0x00, 0x91, 0x89, 0xaa},
817         {0x00, 0x92, 0x9d, 0xaa},       {0x00, 0x93, 0x46, 0xaa},
818         {0x00, 0xd6, 0x22, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
819         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
820         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
821         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
822         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
823         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
824         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0xd6, 0x62, 0xaa},
825         {0x00, 0x73, 0x00, 0xaa},       {0x00, 0x74, 0x10, 0xaa},
826         {0x00, 0x75, 0x20, 0xaa},       {0x00, 0x76, 0x2b, 0xaa},
827         {0x00, 0x77, 0x36, 0xaa},       {0x00, 0x78, 0x49, 0xaa},
828         {0x00, 0x79, 0x5a, 0xaa},       {0x00, 0x7a, 0x7f, 0xaa},
829         {0x00, 0x7b, 0x9b, 0xaa},       {0x00, 0x7c, 0xba, 0xaa},
830         {0x00, 0x7d, 0xd4, 0xaa},       {0x00, 0x7e, 0xea, 0xaa},
831         {0x00, 0xd6, 0xa2, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
832         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
833         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
834         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
835         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
836         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
837         {0x00, 0x7e, 0xea, 0xaa},
838         {0x00, 0x4c, 0x07, 0xaa},
839         {0x00, 0x4b, 0xe0, 0xaa},       {0x00, 0x4e, 0x77, 0xaa},
840         {0x00, 0x59, 0x02, 0xaa},       {0x00, 0x4d, 0x0a, 0xaa},
841 /*      {0x00, 0xd1, 0x00, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
842         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc}, */
843         {0x00, 0xd1, 0x3c, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
844         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
845         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
846         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
847         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
848         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
849         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
850         {0xb9, 0x08, 0x3c, 0xcc},       {0x00, 0x05, 0x00, 0xaa},
851         {0xb3, 0x5c, 0x00, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
852         {}
853 };
854 static const __u8 po3130_rundata[][4] = {
855         {0x00, 0x47, 0x45, 0xaa},       {0x00, 0x48, 0x9b, 0xaa},
856         {0x00, 0x49, 0x3a, 0xaa},       {0x00, 0x4a, 0x01, 0xaa},
857         {0x00, 0x44, 0x40, 0xaa},
858 /*      {0x00, 0xd5, 0x7c, 0xaa}, */
859         {0x00, 0xad, 0x04, 0xaa},       {0x00, 0xae, 0x00, 0xaa},
860         {0x00, 0xb0, 0x78, 0xaa},       {0x00, 0x98, 0x02, 0xaa},
861         {0x00, 0x94, 0x25, 0xaa},       {0x00, 0x95, 0x25, 0xaa},
862         {0x00, 0x59, 0x68, 0xaa},       {0x00, 0x44, 0x20, 0xaa},
863         {0x00, 0x17, 0x50, 0xaa},       {0x00, 0x19, 0x50, 0xaa},
864         {0x00, 0xd1, 0x3c, 0xaa},       {0x00, 0xd1, 0x3c, 0xaa},
865         {0x00, 0x1e, 0x06, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
866         {}
867 };
868
869 static const __u8 po3130_initQVGA_data[][4] = {
870         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
871         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x09, 0xcc},
872         {0xb3, 0x00, 0x04, 0xcc},       {0xb3, 0x00, 0x24, 0xcc},
873         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
874         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
875         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x03, 0x1a, 0xcc},
876         {0xb3, 0x04, 0x15, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
877         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
878         {0xb3, 0x23, 0xe0, 0xcc},       {0xb8, 0x08, 0xe0, 0xcc},
879         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
880         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
881         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0xf6, 0xcc},
882         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
883         {0xb8, 0x00, 0x21, 0xcc},       {0xb8, 0x27, 0x20, 0xcc},
884         {0xb8, 0x01, 0x79, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
885         {0xb8, 0x2c, 0x50, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
886         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
887         {0xb8, 0x30, 0x50, 0xcc},       {0xb8, 0x31, 0xf8, 0xcc},
888         {0xb8, 0x32, 0xf8, 0xcc},       {0xb8, 0x33, 0xf8, 0xcc},
889         {0xb8, 0x34, 0x50, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
890         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
891         {0x00, 0x1e, 0xc6, 0xaa},       {0x00, 0x20, 0x44, 0xaa},
892         {0x00, 0xad, 0x02, 0xaa},       {0x00, 0xae, 0x2c, 0xaa},
893         {0x00, 0x12, 0x08, 0xaa},       {0x00, 0x17, 0x41, 0xaa},
894         {0x00, 0x19, 0x41, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
895         {0x00, 0x21, 0x00, 0xaa},       {0x00, 0x36, 0xc0, 0xaa},
896         {0x00, 0x37, 0xc8, 0xaa},       {0x00, 0x3b, 0x36, 0xaa},
897         {0x00, 0x4b, 0xfe, 0xaa},       {0x00, 0x51, 0x1c, 0xaa},
898         {0x00, 0x52, 0x01, 0xaa},       {0x00, 0x55, 0x0a, 0xaa},
899         {0x00, 0x59, 0x6f, 0xaa},       {0x00, 0x5a, 0x04, 0xaa},
900         {0x00, 0x5c, 0x10, 0xaa},       {0x00, 0x5d, 0x10, 0xaa},
901         {0x00, 0x5e, 0x10, 0xaa},       {0x00, 0x5f, 0x10, 0xaa},
902         {0x00, 0x61, 0x00, 0xaa},       {0x00, 0x62, 0x18, 0xaa},
903         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x70, 0x68, 0xaa},
904         {0x00, 0x80, 0x71, 0xaa},       {0x00, 0x81, 0x08, 0xaa},
905         {0x00, 0x82, 0x00, 0xaa},       {0x00, 0x83, 0x55, 0xaa},
906         {0x00, 0x84, 0x06, 0xaa},       {0x00, 0x85, 0x06, 0xaa},
907         {0x00, 0x86, 0x13, 0xaa},       {0x00, 0x87, 0x18, 0xaa},
908         {0x00, 0xaa, 0x3f, 0xaa},       {0x00, 0xab, 0x44, 0xaa},
909         {0x00, 0xb0, 0x68, 0xaa},       {0x00, 0xb5, 0x10, 0xaa},
910         {0x00, 0xb8, 0x20, 0xaa},       {0x00, 0xb9, 0xa0, 0xaa},
911         {0x00, 0xbc, 0x04, 0xaa},       {0x00, 0x8b, 0x40, 0xaa},
912         {0x00, 0x8c, 0x91, 0xaa},       {0x00, 0x8d, 0x8f, 0xaa},
913         {0x00, 0x8e, 0x91, 0xaa},       {0x00, 0x8f, 0x43, 0xaa},
914         {0x00, 0x90, 0x92, 0xaa},       {0x00, 0x91, 0x89, 0xaa},
915         {0x00, 0x92, 0x9d, 0xaa},       {0x00, 0x93, 0x46, 0xaa},
916         {0x00, 0xd6, 0x22, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
917         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
918         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
919         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
920         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
921         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
922         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0xd6, 0x62, 0xaa},
923         {0x00, 0x73, 0x00, 0xaa},       {0x00, 0x74, 0x10, 0xaa},
924         {0x00, 0x75, 0x20, 0xaa},       {0x00, 0x76, 0x2b, 0xaa},
925         {0x00, 0x77, 0x36, 0xaa},       {0x00, 0x78, 0x49, 0xaa},
926         {0x00, 0x79, 0x5a, 0xaa},       {0x00, 0x7a, 0x7f, 0xaa},
927         {0x00, 0x7b, 0x9b, 0xaa},       {0x00, 0x7c, 0xba, 0xaa},
928         {0x00, 0x7d, 0xd4, 0xaa},       {0x00, 0x7e, 0xea, 0xaa},
929         {0x00, 0xd6, 0xa2, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
930         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
931         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
932         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
933         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
934         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
935         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0x4c, 0x07, 0xaa},
936         {0x00, 0x4b, 0xe0, 0xaa},       {0x00, 0x4e, 0x77, 0xaa},
937         {0x00, 0x59, 0x66, 0xaa},       {0x00, 0x4d, 0x0a, 0xaa},
938         {0x00, 0xd1, 0x00, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
939         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
940         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
941         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
942         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
943         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
944         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
945         {0xb9, 0x08, 0x3c, 0xcc},       {0xbc, 0x02, 0x18, 0xcc},
946         {0xbc, 0x03, 0x50, 0xcc},       {0xbc, 0x04, 0x18, 0xcc},
947         {0xbc, 0x05, 0x00, 0xcc},       {0xbc, 0x06, 0x00, 0xcc},
948         {0xbc, 0x08, 0x30, 0xcc},       {0xbc, 0x09, 0x40, 0xcc},
949         {0xbc, 0x0a, 0x10, 0xcc},       {0xbc, 0x0b, 0x00, 0xcc},
950         {0xbc, 0x0c, 0x00, 0xcc},       {0x00, 0x05, 0x00, 0xaa},
951         {0xb3, 0x5c, 0x00, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
952         {}
953 };
954
955 static const __u8 hv7131r_gamma[17] = {
956 /*      0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
957  *      0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff */
958         0x04, 0x1a, 0x36, 0x55, 0x6f, 0x87, 0x9d, 0xb0, 0xc1,
959         0xcf, 0xda, 0xe4, 0xec, 0xf3, 0xf8, 0xfd, 0xff
960 };
961 static const __u8 hv7131r_matrix[9] = {
962         0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
963 };
964 static const __u8 hv7131r_initVGA_data[][4] = {
965         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
966         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
967         {0xb3, 0x00, 0x24, 0xcc},
968         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
969         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
970         {0xb3, 0x06, 0x01, 0xcc},
971         {0xb3, 0x01, 0x45, 0xcc},       {0xb3, 0x03, 0x0b, 0xcc},
972         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
973         {0xb3, 0x21, 0x00, 0xcc},
974         {0xb3, 0x22, 0x01, 0xcc},       {0xb3, 0x23, 0xe0, 0xcc},
975         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
976         {0xb3, 0x16, 0x02, 0xcc},
977         {0xb3, 0x17, 0x7f, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
978         {0xb3, 0x35, 0x91, 0xcc},       {0xb3, 0x00, 0x27, 0xcc},
979         {0xbc, 0x00, 0x73, 0xcc},
980         {0xb8, 0x00, 0x23, 0xcc},       {0x00, 0x01, 0x0c, 0xaa},
981         {0x00, 0x14, 0x01, 0xaa},       {0x00, 0x15, 0xe6, 0xaa},
982         {0x00, 0x16, 0x02, 0xaa},
983         {0x00, 0x17, 0x86, 0xaa},       {0x00, 0x23, 0x00, 0xaa},
984         {0x00, 0x25, 0x09, 0xaa},       {0x00, 0x26, 0x27, 0xaa},
985         {0x00, 0x27, 0xc0, 0xaa},
986         {0xb8, 0x2c, 0x60, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
987         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
988         {0xb8, 0x30, 0x50, 0xcc},
989         {0xb8, 0x31, 0xf8, 0xcc},       {0xb8, 0x32, 0xf8, 0xcc},
990         {0xb8, 0x33, 0xf8, 0xcc},       {0xb8, 0x34, 0x65, 0xcc},
991         {0xb8, 0x35, 0x00, 0xcc},
992         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
993         {0xb8, 0x27, 0x20, 0xcc},       {0xb8, 0x01, 0x7d, 0xcc},
994         {0xb8, 0x81, 0x09, 0xcc},
995         {0xb3, 0x01, 0x41, 0xcc},       {0xb8, 0xfe, 0x00, 0xcc},
996         {0xb8, 0xff, 0x28, 0xcc},       {0xb9, 0x00, 0x28, 0xcc},
997         {0xb9, 0x01, 0x28, 0xcc},
998         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
999         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
1000         {0xb9, 0x06, 0x3c, 0xcc},
1001         {0xb9, 0x07, 0x3c, 0xcc},       {0xb9, 0x08, 0x3c, 0xcc},
1002         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
1003         {0x00, 0x30, 0x18, 0xaa},
1004         {}
1005 };
1006
1007 static const __u8 hv7131r_initQVGA_data[][4] = {
1008         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
1009         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
1010         {0xb3, 0x00, 0x24, 0xcc},
1011         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
1012         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
1013         {0xb3, 0x06, 0x01, 0xcc},
1014         {0xb3, 0x03, 0x0b, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
1015         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
1016         {0xb3, 0x22, 0x01, 0xcc},
1017         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x14, 0x00, 0xcc},
1018         {0xb3, 0x15, 0x00, 0xcc},       {0xb3, 0x16, 0x02, 0xcc},
1019         {0xb3, 0x17, 0x7f, 0xcc},
1020         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0x91, 0xcc},
1021         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
1022         {0xb8, 0x00, 0x21, 0xcc},
1023         {0x00, 0x01, 0x0c, 0xaa},       {0x00, 0x14, 0x01, 0xaa},
1024         {0x00, 0x15, 0xe6, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
1025         {0x00, 0x17, 0x86, 0xaa},
1026         {0x00, 0x23, 0x00, 0xaa},       {0x00, 0x25, 0x01, 0xaa},
1027         {0x00, 0x26, 0xd4, 0xaa},       {0x00, 0x27, 0xc0, 0xaa},
1028         {0xbc, 0x02, 0x08, 0xcc},
1029         {0xbc, 0x03, 0x70, 0xcc},       {0xbc, 0x04, 0x08, 0xcc},
1030         {0xbc, 0x05, 0x00, 0xcc},       {0xbc, 0x06, 0x00, 0xcc},
1031         {0xbc, 0x08, 0x3c, 0xcc},
1032         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x04, 0xcc},
1033         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
1034         {0xb8, 0xfe, 0x02, 0xcc},
1035         {0xb8, 0xff, 0x07, 0xcc},       {0xb9, 0x00, 0x14, 0xcc},
1036         {0xb9, 0x01, 0x14, 0xcc},       {0xb9, 0x02, 0x14, 0xcc},
1037         {0xb9, 0x03, 0x00, 0xcc},
1038         {0xb9, 0x04, 0x02, 0xcc},       {0xb9, 0x05, 0x05, 0xcc},
1039         {0xb9, 0x06, 0x0f, 0xcc},       {0xb9, 0x07, 0x0f, 0xcc},
1040         {0xb9, 0x08, 0x0f, 0xcc},
1041         {0xb8, 0x2c, 0x60, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
1042         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
1043         {0xb8, 0x30, 0x50, 0xcc},
1044         {0xb8, 0x31, 0xf8, 0xcc},       {0xb8, 0x32, 0xf8, 0xcc},
1045         {0xb8, 0x33, 0xf8, 0xcc},
1046         {0xb8, 0x34, 0x65, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
1047         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
1048         {0xb8, 0x27, 0x20, 0xcc},
1049         {0xb8, 0x01, 0x7d, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
1050         {0xb3, 0x01, 0x41, 0xcc},       {0xb8, 0xfe, 0x00, 0xcc},
1051         {0xb8, 0xff, 0x28, 0xcc},
1052         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
1053         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
1054         {0xb9, 0x04, 0x00, 0xcc},
1055         {0xb9, 0x05, 0x3c, 0xcc},       {0xb9, 0x06, 0x3c, 0xcc},
1056         {0xb9, 0x07, 0x3c, 0xcc},       {0xb9, 0x08, 0x3c, 0xcc},
1057         {0xb8, 0x8e, 0x00, 0xcc},
1058         {0xb8, 0x8f, 0xff, 0xcc},       {0x00, 0x30, 0x18, 0xaa},
1059         {}
1060 };
1061
1062 static const __u8 ov7660_gamma[17] = {
1063         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1064         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1065 };
1066 static const __u8 ov7660_matrix[9] = {
1067         0x5a, 0xf0, 0xf6, 0xf3, 0x57, 0xf6, 0xf3, 0xef, 0x62
1068 };
1069 static const __u8 ov7660_initVGA_data[][4] = {
1070         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
1071         {0x00, 0x00, 0x50, 0xdd},
1072         {0xb0, 0x03, 0x01, 0xcc},
1073         {0xb3, 0x00, 0x21, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
1074         {0xb3, 0x05, 0x01, 0xcc},
1075         {0xb3, 0x06, 0x03, 0xcc},
1076         {0xb3, 0x03, 0x1f, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
1077         {0xb3, 0x05, 0x00, 0xcc},
1078         {0xb3, 0x06, 0x01, 0xcc},
1079         {0xb3, 0x15, 0x00, 0xcc},/* 0xb315  <-0 href startl */
1080         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
1081         {0xb3, 0x21, 0x00, 0xcc},
1082         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x1d, 0x01, 0xcc},
1083         {0xb3, 0x1f, 0x02, 0xcc},
1084         {0xb3, 0x34, 0x01, 0xcc},
1085         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
1086         {0xb8, 0x00, 0x33, 0xcc}, /* 13 */
1087         {0xb8, 0x01, 0x7d, 0xcc},
1088         {0xbc, 0x00, 0x73, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
1089         {0xb8, 0x27, 0x20, 0xcc},
1090         {0xb8, 0x8f, 0x50, 0xcc},
1091         {0x00, 0x01, 0x80, 0xaa},       {0x00, 0x02, 0x80, 0xaa},
1092         {0x00, 0x12, 0x80, 0xaa},
1093         {0x00, 0x12, 0x05, 0xaa},
1094         {0x00, 0x1e, 0x01, 0xaa},       /* MVFP */
1095         {0x00, 0x3d, 0x40, 0xaa}, /* 0x3d <-40 gamma 01 */
1096         {0x00, 0x41, 0x00, 0xaa}, /* edge 00 */
1097         {0x00, 0x0d, 0x48, 0xaa},       {0x00, 0x0e, 0x04, 0xaa},
1098         {0x00, 0x13, 0xa7, 0xaa},
1099         {0x00, 0x40, 0xc1, 0xaa},       {0x00, 0x35, 0x00, 0xaa},
1100         {0x00, 0x36, 0x00, 0xaa},
1101         {0x00, 0x3c, 0x68, 0xaa},       {0x00, 0x1b, 0x05, 0xaa},
1102         {0x00, 0x39, 0x43, 0xaa},
1103         {0x00, 0x8d, 0xcf, 0xaa},
1104         {0x00, 0x8b, 0xcc, 0xaa},       {0x00, 0x8c, 0xcc, 0xaa},
1105         {0x00, 0x0f, 0x62, 0xaa},
1106         {0x00, 0x35, 0x84, 0xaa},
1107         {0x00, 0x3b, 0x08, 0xaa}, /* 0 * Nightframe 1/4 + 50Hz -> 0xC8 */
1108         {0x00, 0x3a, 0x00, 0xaa}, /* mx change yuyv format 00, 04, 01; 08, 0c*/
1109         {0x00, 0x14, 0x2a, 0xaa}, /* agc ampli */
1110         {0x00, 0x9e, 0x40, 0xaa},       {0xb8, 0x8f, 0x50, 0xcc},
1111         {0x00, 0x01, 0x80, 0xaa},
1112         {0x00, 0x02, 0x80, 0xaa},
1113         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
1114         {0xb9, 0x00, 0x28, 0xcc},
1115         {0xb9, 0x01, 0x28, 0xcc},       {0xb9, 0x02, 0x28, 0xcc},
1116         {0xb9, 0x03, 0x00, 0xcc},
1117         {0xb9, 0x04, 0x00, 0xcc},
1118         {0xb9, 0x05, 0x3c, 0xcc},       {0xb9, 0x06, 0x3c, 0xcc},
1119         {0xb9, 0x07, 0x3c, 0xcc},
1120         {0xb9, 0x08, 0x3c, 0xcc},
1121
1122         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
1123
1124         {0x00, 0x29, 0x3c, 0xaa},       {0xb3, 0x01, 0x45, 0xcc},
1125         {}
1126 };
1127 static const __u8 ov7660_initQVGA_data[][4] = {
1128         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
1129         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
1130         {0xb3, 0x00, 0x21, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
1131         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x03, 0xcc},
1132         {0xb3, 0x03, 0x1f, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
1133         {0xb3, 0x05, 0x00, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
1134         {0xb3, 0x15, 0x00, 0xcc},/* 0xb315  <-0 href startl */
1135         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
1136         {0xb3, 0x21, 0x00, 0xcc},
1137         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x1d, 0x01, 0xcc},
1138         {0xb3, 0x1f, 0x02, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
1139         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
1140         {0xb8, 0x00, 0x33, 0xcc}, /* 13 */
1141         {0xb8, 0x01, 0x7d, 0xcc},
1142 /* sizer */
1143         {0xbc, 0x00, 0xd3, 0xcc},
1144         {0xb8, 0x81, 0x09, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
1145         {0xb8, 0x27, 0x20, 0xcc},       {0xb8, 0x8f, 0x50, 0xcc},
1146         {0x00, 0x01, 0x80, 0xaa},       {0x00, 0x02, 0x80, 0xaa},
1147         {0x00, 0x12, 0x80, 0xaa},       {0x00, 0x12, 0x05, 0xaa},
1148         {0x00, 0x1e, 0x01, 0xaa},       /* MVFP */
1149         {0x00, 0x3d, 0x40, 0xaa}, /* 0x3d <-40 gamma 01 */
1150         {0x00, 0x41, 0x00, 0xaa}, /* edge 00 */
1151         {0x00, 0x0d, 0x48, 0xaa},       {0x00, 0x0e, 0x04, 0xaa},
1152         {0x00, 0x13, 0xa7, 0xaa},
1153         {0x00, 0x40, 0xc1, 0xaa},       {0x00, 0x35, 0x00, 0xaa},
1154         {0x00, 0x36, 0x00, 0xaa},
1155         {0x00, 0x3c, 0x68, 0xaa},       {0x00, 0x1b, 0x05, 0xaa},
1156         {0x00, 0x39, 0x43, 0xaa},       {0x00, 0x8d, 0xcf, 0xaa},
1157         {0x00, 0x8b, 0xcc, 0xaa},       {0x00, 0x8c, 0xcc, 0xaa},
1158         {0x00, 0x0f, 0x62, 0xaa},       {0x00, 0x35, 0x84, 0xaa},
1159         {0x00, 0x3b, 0x08, 0xaa}, /* 0  * Nightframe 1/4 + 50Hz -> 0xC8 */
1160         {0x00, 0x3a, 0x00, 0xaa}, /* mx change yuyv format 00, 04, 01; 08, 0c*/
1161         {0x00, 0x14, 0x2a, 0xaa}, /* agc ampli */
1162         {0x00, 0x9e, 0x40, 0xaa},       {0xb8, 0x8f, 0x50, 0xcc},
1163         {0x00, 0x01, 0x80, 0xaa},
1164         {0x00, 0x02, 0x80, 0xaa},
1165 /* sizer filters */
1166         {0xbc, 0x02, 0x08, 0xcc},
1167         {0xbc, 0x03, 0x70, 0xcc},
1168         {0xb8, 0x35, 0x00, 0xcc},
1169         {0xb8, 0x36, 0x00, 0xcc},
1170         {0xb8, 0x37, 0x00, 0xcc},
1171         {0xbc, 0x04, 0x08, 0xcc},
1172         {0xbc, 0x05, 0x00, 0xcc},
1173         {0xbc, 0x06, 0x00, 0xcc},
1174         {0xbc, 0x08, 0x3c, 0xcc},
1175         {0xbc, 0x09, 0x40, 0xcc},
1176         {0xbc, 0x0a, 0x04, 0xcc},
1177         {0xbc, 0x0b, 0x00, 0xcc},
1178         {0xbc, 0x0c, 0x00, 0xcc},
1179 /* */
1180         {0xb8, 0xfe, 0x00, 0xcc},
1181         {0xb8, 0xff, 0x28, 0xcc},
1182 /* */
1183         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
1184         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
1185         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
1186         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
1187         {0xb9, 0x08, 0x3c, 0xcc},
1188 /* */
1189         {0xb8, 0x8e, 0x00, 0xcc},
1190         {0xb8, 0x8f, 0xff, 0xcc}, /* ff */
1191         {0x00, 0x29, 0x3c, 0xaa},
1192         {0xb3, 0x01, 0x45, 0xcc}, /* 45 */
1193         {}
1194 };
1195
1196 static const __u8 ov7660_50HZ[][4] = {
1197         {0x00, 0x3b, 0x08, 0xaa},
1198         {0x00, 0x9d, 0x40, 0xaa},
1199         {0x00, 0x13, 0xa7, 0xaa},
1200         {}
1201 };
1202
1203 static const __u8 ov7660_60HZ[][4] = {
1204         {0x00, 0x3b, 0x00, 0xaa},
1205         {0x00, 0x9e, 0x40, 0xaa},
1206         {0x00, 0x13, 0xa7, 0xaa},
1207         {}
1208 };
1209
1210 static const __u8 ov7660_NoFliker[][4] = {
1211         {0x00, 0x13, 0x87, 0xaa},
1212         {}
1213 };
1214
1215 static const __u8 ov7670_initVGA_JPG[][4] = {
1216         {0xb3, 0x01, 0x05, 0xcc},
1217         {0x00, 0x00, 0x30, 0xdd},       {0xb0, 0x03, 0x19, 0xcc},
1218         {0x00, 0x00, 0x10, 0xdd},
1219         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
1220         {0xb3, 0x00, 0x66, 0xcc},       {0xb3, 0x00, 0x67, 0xcc},
1221         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
1222         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
1223         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
1224         {0xb3, 0x02, 0x02, 0xcc},       {0xb3, 0x03, 0x1f, 0xcc},
1225         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
1226         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
1227         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
1228         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
1229         {0xb3, 0x23, 0xe0, 0xcc},       {0xbc, 0x00, 0x41, 0xcc},
1230         {0xbc, 0x01, 0x01, 0xcc},       {0x00, 0x12, 0x80, 0xaa},
1231         {0x00, 0x00, 0x20, 0xdd},       {0x00, 0x12, 0x00, 0xaa},
1232         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x6b, 0x0a, 0xaa},
1233         {0x00, 0x3a, 0x04, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1234         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x7a, 0x29, 0xaa},
1235         {0x00, 0x7b, 0x0e, 0xaa},       {0x00, 0x7c, 0x1a, 0xaa},
1236         {0x00, 0x7d, 0x31, 0xaa},       {0x00, 0x7e, 0x53, 0xaa},
1237         {0x00, 0x7f, 0x60, 0xaa},       {0x00, 0x80, 0x6b, 0xaa},
1238         {0x00, 0x81, 0x73, 0xaa},       {0x00, 0x82, 0x7b, 0xaa},
1239         {0x00, 0x83, 0x82, 0xaa},       {0x00, 0x84, 0x89, 0xaa},
1240         {0x00, 0x85, 0x96, 0xaa},       {0x00, 0x86, 0xa1, 0xaa},
1241         {0x00, 0x87, 0xb7, 0xaa},       {0x00, 0x88, 0xcc, 0xaa},
1242         {0x00, 0x89, 0xe1, 0xaa},       {0x00, 0x13, 0xe0, 0xaa},
1243         {0x00, 0x00, 0x00, 0xaa},       {0x00, 0x10, 0x00, 0xaa},
1244         {0x00, 0x0d, 0x40, 0xaa},       {0x00, 0x14, 0x28, 0xaa},
1245         {0x00, 0xa5, 0x05, 0xaa},       {0x00, 0xab, 0x07, 0xaa},
1246         {0x00, 0x24, 0x95, 0xaa},       {0x00, 0x25, 0x33, 0xaa},
1247         {0x00, 0x26, 0xe3, 0xaa},       {0x00, 0x9f, 0x88, 0xaa},
1248         {0x00, 0xa0, 0x78, 0xaa},       {0x00, 0x55, 0x90, 0xaa},
1249         {0x00, 0xa1, 0x03, 0xaa},       {0x00, 0xa6, 0xe0, 0xaa},
1250         {0x00, 0xa7, 0xd8, 0xaa},       {0x00, 0xa8, 0xf0, 0xaa},
1251         {0x00, 0xa9, 0x90, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
1252         {0x00, 0x13, 0xe5, 0xaa},       {0x00, 0x0e, 0x61, 0xaa},
1253         {0x00, 0x0f, 0x4b, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
1254         {0x00, 0x1e, 0x07, 0xaa},       /* MVFP */
1255         {0x00, 0x21, 0x02, 0xaa},
1256         {0x00, 0x22, 0x91, 0xaa},       {0x00, 0x29, 0x07, 0xaa},
1257         {0x00, 0x33, 0x0b, 0xaa},       {0x00, 0x35, 0x0b, 0xaa},
1258         {0x00, 0x37, 0x1d, 0xaa},       {0x00, 0x38, 0x71, 0xaa},
1259         {0x00, 0x39, 0x2a, 0xaa},       {0x00, 0x3c, 0x78, 0xaa},
1260         {0x00, 0x4d, 0x40, 0xaa},       {0x00, 0x4e, 0x20, 0xaa},
1261         {0x00, 0x74, 0x19, 0xaa},       {0x00, 0x8d, 0x4f, 0xaa},
1262         {0x00, 0x8e, 0x00, 0xaa},       {0x00, 0x8f, 0x00, 0xaa},
1263         {0x00, 0x90, 0x00, 0xaa},       {0x00, 0x91, 0x00, 0xaa},
1264         {0x00, 0x96, 0x00, 0xaa},       {0x00, 0x9a, 0x80, 0xaa},
1265         {0x00, 0xb0, 0x84, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1266         {0x00, 0xb2, 0x0e, 0xaa},       {0x00, 0xb3, 0x82, 0xaa},
1267         {0x00, 0xb8, 0x0a, 0xaa},       {0x00, 0x43, 0x14, 0xaa},
1268         {0x00, 0x44, 0xf0, 0xaa},       {0x00, 0x45, 0x45, 0xaa},
1269         {0x00, 0x46, 0x63, 0xaa},       {0x00, 0x47, 0x2d, 0xaa},
1270         {0x00, 0x48, 0x46, 0xaa},       {0x00, 0x59, 0x88, 0xaa},
1271         {0x00, 0x5a, 0xa0, 0xaa},       {0x00, 0x5b, 0xc6, 0xaa},
1272         {0x00, 0x5c, 0x7d, 0xaa},       {0x00, 0x5d, 0x5f, 0xaa},
1273         {0x00, 0x5e, 0x19, 0xaa},       {0x00, 0x6c, 0x0a, 0xaa},
1274         {0x00, 0x6d, 0x55, 0xaa},       {0x00, 0x6e, 0x11, 0xaa},
1275         {0x00, 0x6f, 0x9e, 0xaa},       {0x00, 0x69, 0x00, 0xaa},
1276         {0x00, 0x6a, 0x40, 0xaa},       {0x00, 0x01, 0x40, 0xaa},
1277         {0x00, 0x02, 0x40, 0xaa},       {0x00, 0x13, 0xe7, 0xaa},
1278         {0x00, 0x5f, 0xf0, 0xaa},       {0x00, 0x60, 0xf0, 0xaa},
1279         {0x00, 0x61, 0xf0, 0xaa},       {0x00, 0x27, 0xa0, 0xaa},
1280         {0x00, 0x28, 0x80, 0xaa},       {0x00, 0x2c, 0x90, 0xaa},
1281         {0x00, 0x4f, 0x66, 0xaa},       {0x00, 0x50, 0x66, 0xaa},
1282         {0x00, 0x51, 0x00, 0xaa},       {0x00, 0x52, 0x22, 0xaa},
1283         {0x00, 0x53, 0x5e, 0xaa},       {0x00, 0x54, 0x80, 0xaa},
1284         {0x00, 0x58, 0x9e, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1285         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x85, 0xaa},
1286         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1287         {0x00, 0x77, 0x0a, 0xaa},       {0x00, 0x3d, 0x88, 0xaa},
1288         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1289         {0x00, 0x41, 0x38, 0xaa},       {0x00, 0x62, 0x30, 0xaa},
1290         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1291         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x0b, 0xaa},
1292         {0x00, 0x65, 0x00, 0xaa},       {0x00, 0x66, 0x05, 0xaa},
1293         {0x00, 0x56, 0x50, 0xaa},       {0x00, 0x34, 0x11, 0xaa},
1294         {0x00, 0xa4, 0x88, 0xaa},       {0x00, 0x96, 0x00, 0xaa},
1295         {0x00, 0x97, 0x30, 0xaa},       {0x00, 0x98, 0x20, 0xaa},
1296         {0x00, 0x99, 0x30, 0xaa},       {0x00, 0x9a, 0x84, 0xaa},
1297         {0x00, 0x9b, 0x29, 0xaa},       {0x00, 0x9c, 0x03, 0xaa},
1298         {0x00, 0x78, 0x04, 0xaa},       {0x00, 0x79, 0x01, 0xaa},
1299         {0x00, 0xc8, 0xf0, 0xaa},       {0x00, 0x79, 0x0f, 0xaa},
1300         {0x00, 0xc8, 0x00, 0xaa},       {0x00, 0x79, 0x10, 0xaa},
1301         {0x00, 0xc8, 0x7e, 0xaa},       {0x00, 0x79, 0x0a, 0xaa},
1302         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x0b, 0xaa},
1303         {0x00, 0xc8, 0x01, 0xaa},       {0x00, 0x79, 0x0c, 0xaa},
1304         {0x00, 0xc8, 0x0f, 0xaa},       {0x00, 0x79, 0x0d, 0xaa},
1305         {0x00, 0xc8, 0x20, 0xaa},       {0x00, 0x79, 0x09, 0xaa},
1306         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x02, 0xaa},
1307         {0x00, 0xc8, 0xc0, 0xaa},       {0x00, 0x79, 0x03, 0xaa},
1308         {0x00, 0xc8, 0x40, 0xaa},       {0x00, 0x79, 0x05, 0xaa},
1309         {0x00, 0xc8, 0x30, 0xaa},       {0x00, 0x79, 0x26, 0xaa},
1310         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x3a, 0x04, 0xaa},
1311         {0x00, 0x12, 0x00, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1312         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x17, 0x14, 0xaa},
1313         {0x00, 0x18, 0x02, 0xaa},       {0x00, 0x32, 0x92, 0xaa},
1314         {0x00, 0x19, 0x02, 0xaa},       {0x00, 0x1a, 0x7a, 0xaa},
1315         {0x00, 0x03, 0x0a, 0xaa},       {0x00, 0x0c, 0x00, 0xaa},
1316         {0x00, 0x3e, 0x00, 0xaa},       {0x00, 0x70, 0x3a, 0xaa},
1317         {0x00, 0x71, 0x35, 0xaa},       {0x00, 0x72, 0x11, 0xaa},
1318         {0x00, 0x73, 0xf0, 0xaa},       {0x00, 0xa2, 0x02, 0xaa},
1319         {0x00, 0xb1, 0x00, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1320         {0x00, 0x1e, 0x37, 0xaa},       /* MVFP */
1321         {0x00, 0xaa, 0x14, 0xaa},
1322         {0x00, 0x24, 0x80, 0xaa},       {0x00, 0x25, 0x74, 0xaa},
1323         {0x00, 0x26, 0xd3, 0xaa},       {0x00, 0x0d, 0x00, 0xaa},
1324         {0x00, 0x14, 0x18, 0xaa},       {0x00, 0x9d, 0x99, 0xaa},
1325         {0x00, 0x9e, 0x7f, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1326         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x06, 0xaa},
1327         {0x00, 0x66, 0x05, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1328         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x07, 0xaa},
1329         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1330         {0x00, 0x77, 0x00, 0xaa},       {0x00, 0x3d, 0xc2, 0xaa},
1331         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1332         {0x00, 0x41, 0x38, 0xaa},       {0xb6, 0x00, 0x00, 0xcc},
1333         {0xb6, 0x03, 0x02, 0xcc},       {0xb6, 0x02, 0x80, 0xcc},
1334         {0xb6, 0x05, 0x01, 0xcc},       {0xb6, 0x04, 0xe0, 0xcc},
1335         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x13, 0xcc},
1336         {0xb6, 0x18, 0x02, 0xcc},       {0xb6, 0x17, 0x58, 0xcc},
1337         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
1338         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
1339         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
1340         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x45, 0xcc},
1341         {0x00, 0x77, 0x05, 0xaa},
1342         {},
1343 };
1344
1345 static const __u8 ov7670_initQVGA_JPG[][4] = {
1346         {0xb3, 0x01, 0x05, 0xcc},       {0x00, 0x00, 0x30, 0xdd},
1347         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
1348         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
1349         {0xb3, 0x00, 0x66, 0xcc},       {0xb3, 0x00, 0x67, 0xcc},
1350         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
1351         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
1352         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
1353         {0xb3, 0x02, 0x02, 0xcc},       {0xb3, 0x03, 0x1f, 0xcc},
1354         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
1355         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
1356         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
1357         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
1358         {0xb3, 0x23, 0xe0, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
1359         {0xbc, 0x01, 0x01, 0xcc},       {0x00, 0x12, 0x80, 0xaa},
1360         {0x00, 0x00, 0x20, 0xdd},       {0x00, 0x12, 0x00, 0xaa},
1361         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x6b, 0x0a, 0xaa},
1362         {0x00, 0x3a, 0x04, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1363         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x7a, 0x29, 0xaa},
1364         {0x00, 0x7b, 0x0e, 0xaa},       {0x00, 0x7c, 0x1a, 0xaa},
1365         {0x00, 0x7d, 0x31, 0xaa},       {0x00, 0x7e, 0x53, 0xaa},
1366         {0x00, 0x7f, 0x60, 0xaa},       {0x00, 0x80, 0x6b, 0xaa},
1367         {0x00, 0x81, 0x73, 0xaa},       {0x00, 0x82, 0x7b, 0xaa},
1368         {0x00, 0x83, 0x82, 0xaa},       {0x00, 0x84, 0x89, 0xaa},
1369         {0x00, 0x85, 0x96, 0xaa},       {0x00, 0x86, 0xa1, 0xaa},
1370         {0x00, 0x87, 0xb7, 0xaa},       {0x00, 0x88, 0xcc, 0xaa},
1371         {0x00, 0x89, 0xe1, 0xaa},       {0x00, 0x13, 0xe0, 0xaa},
1372         {0x00, 0x00, 0x00, 0xaa},       {0x00, 0x10, 0x00, 0xaa},
1373         {0x00, 0x0d, 0x40, 0xaa},       {0x00, 0x14, 0x28, 0xaa},
1374         {0x00, 0xa5, 0x05, 0xaa},       {0x00, 0xab, 0x07, 0xaa},
1375         {0x00, 0x24, 0x95, 0xaa},       {0x00, 0x25, 0x33, 0xaa},
1376         {0x00, 0x26, 0xe3, 0xaa},       {0x00, 0x9f, 0x88, 0xaa},
1377         {0x00, 0xa0, 0x78, 0xaa},       {0x00, 0x55, 0x90, 0xaa},
1378         {0x00, 0xa1, 0x03, 0xaa},       {0x00, 0xa6, 0xe0, 0xaa},
1379         {0x00, 0xa7, 0xd8, 0xaa},       {0x00, 0xa8, 0xf0, 0xaa},
1380         {0x00, 0xa9, 0x90, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
1381         {0x00, 0x13, 0xe5, 0xaa},       {0x00, 0x0e, 0x61, 0xaa},
1382         {0x00, 0x0f, 0x4b, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
1383         {0x00, 0x1e, 0x07, 0xaa},       /* MVFP */
1384         {0x00, 0x21, 0x02, 0xaa},
1385         {0x00, 0x22, 0x91, 0xaa},       {0x00, 0x29, 0x07, 0xaa},
1386         {0x00, 0x33, 0x0b, 0xaa},       {0x00, 0x35, 0x0b, 0xaa},
1387         {0x00, 0x37, 0x1d, 0xaa},       {0x00, 0x38, 0x71, 0xaa},
1388         {0x00, 0x39, 0x2a, 0xaa},       {0x00, 0x3c, 0x78, 0xaa},
1389         {0x00, 0x4d, 0x40, 0xaa},       {0x00, 0x4e, 0x20, 0xaa},
1390         {0x00, 0x74, 0x19, 0xaa},       {0x00, 0x8d, 0x4f, 0xaa},
1391         {0x00, 0x8e, 0x00, 0xaa},       {0x00, 0x8f, 0x00, 0xaa},
1392         {0x00, 0x90, 0x00, 0xaa},       {0x00, 0x91, 0x00, 0xaa},
1393         {0x00, 0x96, 0x00, 0xaa},       {0x00, 0x9a, 0x80, 0xaa},
1394         {0x00, 0xb0, 0x84, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1395         {0x00, 0xb2, 0x0e, 0xaa},       {0x00, 0xb3, 0x82, 0xaa},
1396         {0x00, 0xb8, 0x0a, 0xaa},       {0x00, 0x43, 0x14, 0xaa},
1397         {0x00, 0x44, 0xf0, 0xaa},       {0x00, 0x45, 0x45, 0xaa},
1398         {0x00, 0x46, 0x63, 0xaa},       {0x00, 0x47, 0x2d, 0xaa},
1399         {0x00, 0x48, 0x46, 0xaa},       {0x00, 0x59, 0x88, 0xaa},
1400         {0x00, 0x5a, 0xa0, 0xaa},       {0x00, 0x5b, 0xc6, 0xaa},
1401         {0x00, 0x5c, 0x7d, 0xaa},       {0x00, 0x5d, 0x5f, 0xaa},
1402         {0x00, 0x5e, 0x19, 0xaa},       {0x00, 0x6c, 0x0a, 0xaa},
1403         {0x00, 0x6d, 0x55, 0xaa},       {0x00, 0x6e, 0x11, 0xaa},
1404         {0x00, 0x6f, 0x9e, 0xaa},       {0x00, 0x69, 0x00, 0xaa},
1405         {0x00, 0x6a, 0x40, 0xaa},       {0x00, 0x01, 0x40, 0xaa},
1406         {0x00, 0x02, 0x40, 0xaa},       {0x00, 0x13, 0xe7, 0xaa},
1407         {0x00, 0x5f, 0xf0, 0xaa},       {0x00, 0x60, 0xf0, 0xaa},
1408         {0x00, 0x61, 0xf0, 0xaa},       {0x00, 0x27, 0xa0, 0xaa},
1409         {0x00, 0x28, 0x80, 0xaa},       {0x00, 0x2c, 0x90, 0xaa},
1410         {0x00, 0x4f, 0x66, 0xaa},       {0x00, 0x50, 0x66, 0xaa},
1411         {0x00, 0x51, 0x00, 0xaa},       {0x00, 0x52, 0x22, 0xaa},
1412         {0x00, 0x53, 0x5e, 0xaa},       {0x00, 0x54, 0x80, 0xaa},
1413         {0x00, 0x58, 0x9e, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1414         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x85, 0xaa},
1415         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1416         {0x00, 0x77, 0x0a, 0xaa},       {0x00, 0x3d, 0x88, 0xaa},
1417         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1418         {0x00, 0x41, 0x38, 0xaa},       {0x00, 0x62, 0x30, 0xaa},
1419         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1420         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x0b, 0xaa},
1421         {0x00, 0x65, 0x00, 0xaa},       {0x00, 0x66, 0x05, 0xaa},
1422         {0x00, 0x56, 0x50, 0xaa},       {0x00, 0x34, 0x11, 0xaa},
1423         {0x00, 0xa4, 0x88, 0xaa},       {0x00, 0x96, 0x00, 0xaa},
1424         {0x00, 0x97, 0x30, 0xaa},       {0x00, 0x98, 0x20, 0xaa},
1425         {0x00, 0x99, 0x30, 0xaa},       {0x00, 0x9a, 0x84, 0xaa},
1426         {0x00, 0x9b, 0x29, 0xaa},       {0x00, 0x9c, 0x03, 0xaa},
1427         {0x00, 0x78, 0x04, 0xaa},       {0x00, 0x79, 0x01, 0xaa},
1428         {0x00, 0xc8, 0xf0, 0xaa},       {0x00, 0x79, 0x0f, 0xaa},
1429         {0x00, 0xc8, 0x00, 0xaa},       {0x00, 0x79, 0x10, 0xaa},
1430         {0x00, 0xc8, 0x7e, 0xaa},       {0x00, 0x79, 0x0a, 0xaa},
1431         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x0b, 0xaa},
1432         {0x00, 0xc8, 0x01, 0xaa},       {0x00, 0x79, 0x0c, 0xaa},
1433         {0x00, 0xc8, 0x0f, 0xaa},       {0x00, 0x79, 0x0d, 0xaa},
1434         {0x00, 0xc8, 0x20, 0xaa},       {0x00, 0x79, 0x09, 0xaa},
1435         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x02, 0xaa},
1436         {0x00, 0xc8, 0xc0, 0xaa},       {0x00, 0x79, 0x03, 0xaa},
1437         {0x00, 0xc8, 0x40, 0xaa},       {0x00, 0x79, 0x05, 0xaa},
1438         {0x00, 0xc8, 0x30, 0xaa},       {0x00, 0x79, 0x26, 0xaa},
1439         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x3a, 0x04, 0xaa},
1440         {0x00, 0x12, 0x00, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1441         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x17, 0x14, 0xaa},
1442         {0x00, 0x18, 0x02, 0xaa},       {0x00, 0x32, 0x92, 0xaa},
1443         {0x00, 0x19, 0x02, 0xaa},       {0x00, 0x1a, 0x7a, 0xaa},
1444         {0x00, 0x03, 0x0a, 0xaa},       {0x00, 0x0c, 0x00, 0xaa},
1445         {0x00, 0x3e, 0x00, 0xaa},       {0x00, 0x70, 0x3a, 0xaa},
1446         {0x00, 0x71, 0x35, 0xaa},       {0x00, 0x72, 0x11, 0xaa},
1447         {0x00, 0x73, 0xf0, 0xaa},       {0x00, 0xa2, 0x02, 0xaa},
1448         {0x00, 0xb1, 0x00, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1449         {0x00, 0x1e, 0x37, 0xaa},       /* MVFP */
1450         {0x00, 0xaa, 0x14, 0xaa},
1451         {0x00, 0x24, 0x80, 0xaa},       {0x00, 0x25, 0x74, 0xaa},
1452         {0x00, 0x26, 0xd3, 0xaa},       {0x00, 0x0d, 0x00, 0xaa},
1453         {0x00, 0x14, 0x18, 0xaa},       {0x00, 0x9d, 0x99, 0xaa},
1454         {0x00, 0x9e, 0x7f, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1455         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x06, 0xaa},
1456         {0x00, 0x66, 0x05, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1457         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x07, 0xaa},
1458         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1459         {0x00, 0x77, 0x00, 0xaa},       {0x00, 0x3d, 0xc2, 0xaa},
1460         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1461         {0x00, 0x41, 0x38, 0xaa},       {0xb6, 0x00, 0x00, 0xcc},
1462         {0xb6, 0x03, 0x01, 0xcc},       {0xb6, 0x02, 0x40, 0xcc},
1463         {0xb6, 0x05, 0x00, 0xcc},       {0xb6, 0x04, 0xf0, 0xcc},
1464         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x21, 0xcc},
1465         {0xb6, 0x18, 0x00, 0xcc},       {0xb6, 0x17, 0x96, 0xcc},
1466         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
1467         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
1468         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
1469         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
1470         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
1471         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
1472         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
1473         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
1474         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x45, 0xcc},
1475         {0x00, 0x77, 0x05, 0xaa },
1476         {},
1477 };
1478
1479 /* PO1200 - values from usbvm326.inf and ms-win trace */
1480 static const __u8 po1200_gamma[17] = {
1481         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1482         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1483 };
1484 static const __u8 po1200_matrix[9] = {
1485         0x60, 0xf9, 0xe5, 0xe7, 0x50, 0x05, 0xf3, 0xe6, 0x5e
1486 };
1487 static const __u8 po1200_initVGA_data[][4] = {
1488         {0xb0, 0x03, 0x19, 0xcc},       /* reset? */
1489         {0xb0, 0x03, 0x19, 0xcc},
1490 /*      {0x00, 0x00, 0x33, 0xdd}, */
1491         {0xb0, 0x04, 0x02, 0xcc},
1492         {0xb0, 0x02, 0x02, 0xcc},
1493         {0xb3, 0x5d, 0x00, 0xcc},
1494         {0xb3, 0x01, 0x01, 0xcc},
1495         {0xb3, 0x00, 0x64, 0xcc},
1496         {0xb3, 0x00, 0x65, 0xcc},
1497         {0xb3, 0x05, 0x01, 0xcc},
1498         {0xb3, 0x06, 0x01, 0xcc},
1499         {0xb3, 0x5c, 0x01, 0xcc},
1500         {0xb3, 0x08, 0x01, 0xcc},
1501         {0xb3, 0x09, 0x0c, 0xcc},
1502         {0xb3, 0x00, 0x67, 0xcc},
1503         {0xb3, 0x02, 0xb2, 0xcc},
1504         {0xb3, 0x03, 0x18, 0xcc},
1505         {0xb3, 0x04, 0x15, 0xcc},
1506         {0xb3, 0x20, 0x00, 0xcc},
1507         {0xb3, 0x21, 0x00, 0xcc},
1508         {0xb3, 0x22, 0x02, 0xcc},
1509         {0xb3, 0x23, 0x58, 0xcc},
1510         {0xb3, 0x14, 0x00, 0xcc},
1511         {0xb3, 0x15, 0x00, 0xcc},
1512         {0xb3, 0x16, 0x03, 0xcc},
1513         {0xb3, 0x17, 0x1f, 0xcc},
1514         {0xbc, 0x00, 0x71, 0xcc},
1515         {0xbc, 0x01, 0x01, 0xcc},
1516         {0xb0, 0x54, 0x13, 0xcc},
1517         {0xb3, 0x00, 0x67, 0xcc},
1518         {0xb3, 0x34, 0x01, 0xcc},
1519         {0xb3, 0x35, 0xdc, 0xcc},
1520         {0x00, 0x03, 0x00, 0xaa},
1521         {0x00, 0x12, 0x05, 0xaa},
1522         {0x00, 0x13, 0x02, 0xaa},
1523         {0x00, 0x1e, 0xc6, 0xaa},
1524         {0x00, 0x21, 0x00, 0xaa},
1525         {0x00, 0x25, 0x02, 0xaa},
1526         {0x00, 0x3c, 0x4f, 0xaa},
1527         {0x00, 0x3f, 0xe0, 0xaa},
1528         {0x00, 0x42, 0xff, 0xaa},
1529         {0x00, 0x45, 0x34, 0xaa},
1530         {0x00, 0x55, 0xfe, 0xaa},
1531         {0x00, 0x59, 0xd3, 0xaa},
1532         {0x00, 0x5e, 0x04, 0xaa},
1533         {0x00, 0x61, 0xb8, 0xaa},
1534         {0x00, 0x62, 0x02, 0xaa},
1535         {0x00, 0xa7, 0x31, 0xaa},
1536         {0x00, 0xa9, 0x66, 0xaa},
1537         {0x00, 0xb0, 0x00, 0xaa},
1538         {0x00, 0xb1, 0x00, 0xaa},
1539         {0x00, 0xb3, 0x11, 0xaa},
1540         {0x00, 0xb6, 0x26, 0xaa},
1541         {0x00, 0xb7, 0x20, 0xaa},
1542         {0x00, 0xba, 0x04, 0xaa},
1543         {0x00, 0x88, 0x42, 0xaa},
1544         {0x00, 0x89, 0x9a, 0xaa},
1545         {0x00, 0x8a, 0x88, 0xaa},
1546         {0x00, 0x8b, 0x8e, 0xaa},
1547         {0x00, 0x8c, 0x3e, 0xaa},
1548         {0x00, 0x8d, 0x90, 0xaa},
1549         {0x00, 0x8e, 0x87, 0xaa},
1550         {0x00, 0x8f, 0x96, 0xaa},
1551         {0x00, 0x90, 0x3d, 0xaa},
1552         {0x00, 0x64, 0x00, 0xaa},
1553         {0x00, 0x65, 0x10, 0xaa},
1554         {0x00, 0x66, 0x20, 0xaa},
1555         {0x00, 0x67, 0x2b, 0xaa},
1556         {0x00, 0x68, 0x36, 0xaa},
1557         {0x00, 0x69, 0x49, 0xaa},
1558         {0x00, 0x6a, 0x5a, 0xaa},
1559         {0x00, 0x6b, 0x7f, 0xaa},
1560         {0x00, 0x6c, 0x9b, 0xaa},
1561         {0x00, 0x6d, 0xba, 0xaa},
1562         {0x00, 0x6e, 0xd4, 0xaa},
1563         {0x00, 0x6f, 0xea, 0xaa},
1564         {0x00, 0x70, 0x00, 0xaa},
1565         {0x00, 0x71, 0x10, 0xaa},
1566         {0x00, 0x72, 0x20, 0xaa},
1567         {0x00, 0x73, 0x2b, 0xaa},
1568         {0x00, 0x74, 0x36, 0xaa},
1569         {0x00, 0x75, 0x49, 0xaa},
1570         {0x00, 0x76, 0x5a, 0xaa},
1571         {0x00, 0x77, 0x7f, 0xaa},
1572         {0x00, 0x78, 0x9b, 0xaa},
1573         {0x00, 0x79, 0xba, 0xaa},
1574         {0x00, 0x7a, 0xd4, 0xaa},
1575         {0x00, 0x7b, 0xea, 0xaa},
1576         {0x00, 0x7c, 0x00, 0xaa},
1577         {0x00, 0x7d, 0x10, 0xaa},
1578         {0x00, 0x7e, 0x20, 0xaa},
1579         {0x00, 0x7f, 0x2b, 0xaa},
1580         {0x00, 0x80, 0x36, 0xaa},
1581         {0x00, 0x81, 0x49, 0xaa},
1582         {0x00, 0x82, 0x5a, 0xaa},
1583         {0x00, 0x83, 0x7f, 0xaa},
1584         {0x00, 0x84, 0x9b, 0xaa},
1585         {0x00, 0x85, 0xba, 0xaa},
1586         {0x00, 0x86, 0xd4, 0xaa},
1587         {0x00, 0x87, 0xea, 0xaa},
1588         {0x00, 0x57, 0x2a, 0xaa},
1589         {0x00, 0x03, 0x01, 0xaa},
1590         {0x00, 0x04, 0x10, 0xaa},
1591         {0x00, 0x05, 0x10, 0xaa},
1592         {0x00, 0x06, 0x10, 0xaa},
1593         {0x00, 0x07, 0x10, 0xaa},
1594         {0x00, 0x08, 0x13, 0xaa},
1595         {0x00, 0x0a, 0x00, 0xaa},
1596         {0x00, 0x0b, 0x10, 0xaa},
1597         {0x00, 0x0c, 0x20, 0xaa},
1598         {0x00, 0x0d, 0x18, 0xaa},
1599         {0x00, 0x22, 0x01, 0xaa},
1600         {0x00, 0x23, 0x60, 0xaa},
1601         {0x00, 0x25, 0x08, 0xaa},
1602         {0x00, 0x26, 0x82, 0xaa},
1603         {0x00, 0x2e, 0x0f, 0xaa},
1604         {0x00, 0x2f, 0x1e, 0xaa},
1605         {0x00, 0x30, 0x2d, 0xaa},
1606         {0x00, 0x31, 0x3c, 0xaa},
1607         {0x00, 0x32, 0x4b, 0xaa},
1608         {0x00, 0x33, 0x5a, 0xaa},
1609         {0x00, 0x34, 0x69, 0xaa},
1610         {0x00, 0x35, 0x78, 0xaa},
1611         {0x00, 0x36, 0x87, 0xaa},
1612         {0x00, 0x37, 0x96, 0xaa},
1613         {0x00, 0x38, 0xa5, 0xaa},
1614         {0x00, 0x39, 0xb4, 0xaa},
1615         {0x00, 0x3a, 0xc3, 0xaa},
1616         {0x00, 0x3b, 0xd2, 0xaa},
1617         {0x00, 0x3c, 0xe1, 0xaa},
1618         {0x00, 0x3e, 0xff, 0xaa},
1619         {0x00, 0x3f, 0xff, 0xaa},
1620         {0x00, 0x40, 0xff, 0xaa},
1621         {0x00, 0x41, 0xff, 0xaa},
1622         {0x00, 0x42, 0xff, 0xaa},
1623         {0x00, 0x43, 0xff, 0xaa},
1624         {0x00, 0x03, 0x00, 0xaa},
1625         {0x00, 0x03, 0x00, 0xaa},
1626         {0x00, 0x20, 0xc4, 0xaa},
1627         {0x00, 0x13, 0x03, 0xaa},
1628         {0x00, 0x3c, 0x50, 0xaa},
1629         {0x00, 0x61, 0x6a, 0xaa},
1630         {0x00, 0x51, 0x5b, 0xaa},
1631         {0x00, 0x52, 0x91, 0xaa},
1632         {0x00, 0x53, 0x4c, 0xaa},
1633         {0x00, 0x54, 0x50, 0xaa},
1634         {0x00, 0x56, 0x02, 0xaa},
1635         {0xb6, 0x00, 0x00, 0xcc},
1636         {0xb6, 0x03, 0x03, 0xcc},
1637         {0xb6, 0x02, 0x20, 0xcc},
1638         {0xb6, 0x05, 0x02, 0xcc},
1639         {0xb6, 0x04, 0x58, 0xcc},
1640         {0xb6, 0x12, 0xf8, 0xcc},
1641         {0xb6, 0x13, 0x21, 0xcc},
1642         {0xb6, 0x18, 0x03, 0xcc},
1643         {0xb6, 0x17, 0xa9, 0xcc},
1644         {0xb6, 0x16, 0x80, 0xcc},
1645         {0xb6, 0x22, 0x12, 0xcc},
1646         {0xb6, 0x23, 0x0b, 0xcc},
1647         {0xbf, 0xc0, 0x39, 0xcc},
1648         {0xbf, 0xc1, 0x04, 0xcc},
1649         {0xbf, 0xcc, 0x00, 0xcc},
1650         {0xb8, 0x06, 0x20, 0xcc},
1651         {0xb8, 0x07, 0x03, 0xcc},
1652         {0xb8, 0x08, 0x58, 0xcc},
1653         {0xb8, 0x09, 0x02, 0xcc},
1654         {0xb3, 0x01, 0x41, 0xcc},
1655         {0x00, 0x03, 0x00, 0xaa},
1656         {0x00, 0xd9, 0x0f, 0xaa},
1657         {0x00, 0xda, 0xaa, 0xaa},
1658         {0x00, 0xd9, 0x10, 0xaa},
1659         {0x00, 0xda, 0xaa, 0xaa},
1660         {0x00, 0xd9, 0x11, 0xaa},
1661         {0x00, 0xda, 0x00, 0xaa},
1662         {0x00, 0xd9, 0x12, 0xaa},
1663         {0x00, 0xda, 0xff, 0xaa},
1664         {0x00, 0xd9, 0x13, 0xaa},
1665         {0x00, 0xda, 0xff, 0xaa},
1666         {0x00, 0xe8, 0x11, 0xaa},
1667         {0x00, 0xe9, 0x12, 0xaa},
1668         {0x00, 0xea, 0x5c, 0xaa},
1669         {0x00, 0xeb, 0xff, 0xaa},
1670         {0x00, 0xd8, 0x80, 0xaa},
1671         {0x00, 0xe6, 0x02, 0xaa},
1672         {0x00, 0xd6, 0x40, 0xaa},
1673         {0x00, 0xe3, 0x05, 0xaa},
1674         {0x00, 0xe0, 0x40, 0xaa},
1675         {0x00, 0xde, 0x03, 0xaa},
1676         {0x00, 0xdf, 0x03, 0xaa},
1677         {0x00, 0xdb, 0x02, 0xaa},
1678         {0x00, 0xdc, 0x00, 0xaa},
1679         {0x00, 0xdd, 0x03, 0xaa},
1680         {0x00, 0xe1, 0x08, 0xaa},
1681         {0x00, 0xe2, 0x01, 0xaa},
1682         {0x00, 0xd6, 0x40, 0xaa},
1683         {0x00, 0xe4, 0x40, 0xaa},
1684         {0x00, 0xa8, 0x9f, 0xaa},
1685         {0x00, 0xb4, 0x16, 0xaa},
1686         {0xb0, 0x02, 0x06, 0xcc},
1687         {0xb0, 0x18, 0x06, 0xcc},
1688         {0xb0, 0x19, 0x06, 0xcc},
1689         {0xb3, 0x5d, 0x18, 0xcc},
1690         {0xb3, 0x05, 0x00, 0xcc},
1691         {0xb3, 0x06, 0x00, 0xcc},
1692         {0x00, 0xb4, 0x0e, 0xaa},
1693         {0x00, 0xb5, 0x49, 0xaa},
1694         {0x00, 0xb6, 0x1c, 0xaa},
1695         {0x00, 0xb7, 0x96, 0xaa},
1696 /* end of usbvm326.inf - start of ms-win trace */
1697         {0xb6, 0x12, 0xf8, 0xcc},
1698         {0xb6, 0x13, 0x3d, 0xcc},
1699 /*read b306*/
1700         {0x00, 0x03, 0x00, 0xaa},
1701         {0x00, 0x1a, 0x09, 0xaa},
1702         {0x00, 0x1b, 0x8a, 0xaa},
1703 /*read b827*/
1704         {0xb8, 0x27, 0x00, 0xcc},
1705         {0xb8, 0x26, 0x60, 0xcc},
1706         {0xb8, 0x26, 0x60, 0xcc},
1707 /*gamma - to do?*/
1708         {0x00, 0x03, 0x00, 0xaa},
1709         {0x00, 0xae, 0x84, 0xaa},
1710 /*gamma again*/
1711         {0x00, 0x03, 0x00, 0xaa},
1712         {0x00, 0x96, 0xa0, 0xaa},
1713 /*matrix*/
1714         {0x00, 0x03, 0x00, 0xaa},
1715         {0x00, 0x91, 0x35, 0xaa},
1716         {0x00, 0x92, 0x22, 0xaa},
1717 /*gamma*/
1718         {0x00, 0x03, 0x00, 0xaa},
1719         {0x00, 0x95, 0x85, 0xaa},
1720 /*matrix*/
1721         {0x00, 0x03, 0x00, 0xaa},
1722         {0x00, 0x61, 0xb8, 0xaa},
1723         {0x00, 0x03, 0x00, 0xaa},
1724         {0x00, 0x4d, 0x20, 0xaa},
1725         {0xb8, 0x22, 0x40, 0xcc},
1726         {0xb8, 0x23, 0x40, 0xcc},
1727         {0xb8, 0x24, 0x40, 0xcc},
1728         {0xb8, 0x81, 0x09, 0xcc},
1729         {0x00, 0x00, 0x64, 0xdd},
1730         {0x00, 0x03, 0x01, 0xaa},
1731 /*read 46*/
1732         {0x00, 0x46, 0x3c, 0xaa},
1733         {0x00, 0x03, 0x00, 0xaa},
1734         {0x00, 0x16, 0x40, 0xaa},
1735         {0x00, 0x17, 0x40, 0xaa},
1736         {0x00, 0x18, 0x40, 0xaa},
1737         {0x00, 0x19, 0x41, 0xaa},
1738         {0x00, 0x03, 0x01, 0xaa},
1739         {0x00, 0x46, 0x3c, 0xaa},
1740         {0x00, 0x00, 0x18, 0xdd},
1741 /*read bfff*/
1742         {0x00, 0x03, 0x00, 0xaa},
1743         {0x00, 0x1e, 0x46, 0xaa},
1744         {0x00, 0xa8, 0x8f, 0xaa},
1745         {0x00, 0x03, 0x00, 0xaa},
1746         {0x00, 0xb4, 0x1c, 0xaa},
1747         {0x00, 0xb5, 0x92, 0xaa},
1748         {0x00, 0xb6, 0x39, 0xaa},
1749         {0x00, 0xb7, 0x24, 0xaa},
1750 /*write 89 0400 1415*/
1751 };
1752
1753 struct sensor_info {
1754         int sensorId;
1755         __u8 I2cAdd;
1756         __u8 IdAdd;
1757         __u16 VpId;
1758         __u8 m1;
1759         __u8 m2;
1760         __u8 op;
1761         };
1762
1763 static const struct sensor_info sensor_info_data[] = {
1764 /*      sensorId,         I2cAdd,       IdAdd,  VpId,  m1,    m2,  op */
1765         {SENSOR_HV7131R,    0x80 | 0x11, 0x00, 0x0209, 0x24, 0x25, 0x01},
1766         {SENSOR_OV7660,     0x80 | 0x21, 0x0a, 0x7660, 0x26, 0x26, 0x05},
1767         {SENSOR_PO3130NC,   0x80 | 0x76, 0x00, 0x3130, 0x24, 0x25, 0x01},
1768         {SENSOR_MI1320,     0x80 | 0xc8, 0x00, 0x148c, 0x64, 0x65, 0x01},
1769         {SENSOR_OV7670,     0x80 | 0x21, 0x0a, 0x7673, 0x66, 0x67, 0x05},
1770         {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x143a, 0x24, 0x25, 0x01},
1771 /* (tested in vc032x_probe_sensor) */
1772 /*      {SENSOR_MI0360,     0x80 | 0x5d, 0x00, 0x8243, 0x24, 0x25, 0x01}, */
1773         {SENSOR_PO1200,     0x80 | 0x5c, 0x00, 0x1200, 0x67, 0x67, 0x01},
1774 };
1775
1776 /* read 'len' bytes in gspca_dev->usb_buf */
1777 static void reg_r(struct gspca_dev *gspca_dev,
1778                   __u16 req,
1779                   __u16 index,
1780                   __u16 len)
1781 {
1782         usb_control_msg(gspca_dev->dev,
1783                         usb_rcvctrlpipe(gspca_dev->dev, 0),
1784                         req,
1785                         USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1786                         1,                      /* value */
1787                         index, gspca_dev->usb_buf, len,
1788                         500);
1789 }
1790
1791 static void reg_w(struct usb_device *dev,
1792                             __u16 req,
1793                             __u16 value,
1794                             __u16 index)
1795 {
1796         usb_control_msg(dev,
1797                         usb_sndctrlpipe(dev, 0),
1798                         req,
1799                         USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1800                         value, index, NULL, 0,
1801                         500);
1802 }
1803
1804 static void read_sensor_register(struct gspca_dev *gspca_dev,
1805                                 __u16 address, __u16 *value)
1806 {
1807         struct usb_device *dev = gspca_dev->dev;
1808         __u8 ldata, mdata, hdata;
1809         int retry = 50;
1810
1811         *value = 0;
1812
1813         reg_r(gspca_dev, 0xa1, 0xb33f, 1);
1814         /*PDEBUG(D_PROBE, " I2c Bus Busy Wait  0x%02X ", tmpvalue); */
1815         if (!(gspca_dev->usb_buf[0] & 0x02)) {
1816                 PDEBUG(D_ERR, "I2c Bus Busy Wait %d",
1817                         gspca_dev->usb_buf[0] & 0x02);
1818                 return;
1819         }
1820         reg_w(dev, 0xa0, address, 0xb33a);
1821         reg_w(dev, 0xa0, 0x02, 0xb339);
1822
1823         reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1824         while (retry-- && gspca_dev->usb_buf[0]) {
1825                 reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1826 /*              PDEBUG(D_PROBE, "Read again 0xb33b %d", tmpvalue); */
1827                 msleep(1);
1828         }
1829         reg_r(gspca_dev, 0xa1, 0xb33e, 1);
1830         ldata = gspca_dev->usb_buf[0];
1831         reg_r(gspca_dev, 0xa1, 0xb33d, 1);
1832         mdata = gspca_dev->usb_buf[0];
1833         reg_r(gspca_dev, 0xa1, 0xb33c, 1);
1834         hdata = gspca_dev->usb_buf[0];
1835         PDEBUG(D_PROBE, "Read Sensor %02x%02x %02x",
1836                 hdata, mdata, ldata);
1837         reg_r(gspca_dev, 0xa1, 0xb334, 1);
1838         if (gspca_dev->usb_buf[0] == 0x02)
1839                 *value = (hdata << 8) + mdata;
1840         else
1841                 *value = hdata;
1842 }
1843
1844 static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
1845 {
1846         struct usb_device *dev = gspca_dev->dev;
1847         int i;
1848         __u16 value;
1849         const struct sensor_info *ptsensor_info;
1850
1851         reg_r(gspca_dev, 0xa1, 0xbfcf, 1);
1852         PDEBUG(D_PROBE, "check sensor header %02x", gspca_dev->usb_buf[0]);
1853         for (i = 0; i < ARRAY_SIZE(sensor_info_data); i++) {
1854                 ptsensor_info = &sensor_info_data[i];
1855                 reg_w(dev, 0xa0, 0x02, 0xb334);
1856                 reg_w(dev, 0xa0, ptsensor_info->m1, 0xb300);
1857                 reg_w(dev, 0xa0, ptsensor_info->m2, 0xb300);
1858                 reg_w(dev, 0xa0, 0x01, 0xb308);
1859                 reg_w(dev, 0xa0, 0x0c, 0xb309);
1860                 reg_w(dev, 0xa0, ptsensor_info->I2cAdd, 0xb335);
1861                 reg_w(dev, 0xa0, ptsensor_info->op, 0xb301);
1862                 read_sensor_register(gspca_dev, ptsensor_info->IdAdd, &value);
1863                 if (value == ptsensor_info->VpId)
1864                         return ptsensor_info->sensorId;
1865
1866                 /* special case for MI0360 */
1867                 if (ptsensor_info->sensorId == SENSOR_MI1310_SOC
1868                     && value == 0x8243)
1869                         return ptsensor_info->sensorId;
1870         }
1871         return -1;
1872 }
1873
1874 static __u8 i2c_write(struct gspca_dev *gspca_dev,
1875                         __u8 reg, const __u8 *val, __u8 size)
1876 {
1877         struct usb_device *dev = gspca_dev->dev;
1878
1879         if (size > 3 || size < 1)
1880                 return -EINVAL;
1881         reg_r(gspca_dev, 0xa1, 0xb33f, 1);
1882         reg_w(dev, 0xa0, size, 0xb334);
1883         reg_w(dev, 0xa0, reg, 0xb33a);
1884         switch (size) {
1885         case 1:
1886                 reg_w(dev, 0xa0, val[0], 0xb336);
1887                 break;
1888         case 2:
1889                 reg_w(dev, 0xa0, val[0], 0xb336);
1890                 reg_w(dev, 0xa0, val[1], 0xb337);
1891                 break;
1892         case 3:
1893                 reg_w(dev, 0xa0, val[0], 0xb336);
1894                 reg_w(dev, 0xa0, val[1], 0xb337);
1895                 reg_w(dev, 0xa0, val[2], 0xb338);
1896                 break;
1897         default:
1898                 reg_w(dev, 0xa0, 0x01, 0xb334);
1899                 return -EINVAL;
1900         }
1901         reg_w(dev, 0xa0, 0x01, 0xb339);
1902         reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1903         return gspca_dev->usb_buf[0] == 0;
1904 }
1905
1906 static void put_tab_to_reg(struct gspca_dev *gspca_dev,
1907                         const __u8 *tab, __u8 tabsize, __u16 addr)
1908 {
1909         int j;
1910         __u16 ad = addr;
1911
1912         for (j = 0; j < tabsize; j++)
1913                 reg_w(gspca_dev->dev, 0xa0, tab[j], ad++);
1914 }
1915
1916 static void usb_exchange(struct gspca_dev *gspca_dev,
1917                         const __u8 data[][4])
1918 {
1919         struct usb_device *dev = gspca_dev->dev;
1920         int i = 0;
1921
1922         for (;;) {
1923                 switch (data[i][3]) {
1924                 default:
1925                         return;
1926                 case 0xcc:                      /* normal write */
1927                         reg_w(dev, 0xa0, data[i][2],
1928                                         ((data[i][0])<<8) | data[i][1]);
1929                         break;
1930                 case 0xaa:                      /* i2c op */
1931                         i2c_write(gspca_dev, data[i][1], &data[i][2], 1);
1932                         break;
1933                 case 0xbb:                      /* i2c op */
1934                         i2c_write(gspca_dev, data[i][0], &data[i][1], 2);
1935                         break;
1936                 case 0xdd:
1937                         msleep(data[i][2] + 10);
1938                         break;
1939                 }
1940                 i++;
1941         }
1942         /*not reached*/
1943 }
1944
1945 /*
1946  "GammaT"=hex:04,17,31,4f,6a,83,99,ad,bf,ce,da,e5,ee,f5,fb,ff,ff
1947  "MatrixT"=hex:60,f9,e5,e7,50,05,f3,e6,66
1948  */
1949
1950 static void vc0321_reset(struct gspca_dev *gspca_dev)
1951 {
1952         reg_w(gspca_dev->dev, 0xa0, 0x00, 0xb04d);
1953         reg_w(gspca_dev->dev, 0xa0, 0x01, 0xb301);
1954         msleep(100);
1955         reg_w(gspca_dev->dev, 0xa0, 0x01, 0xb003);
1956         msleep(100);
1957 }
1958
1959 /* this function is called at probe time */
1960 static int sd_config(struct gspca_dev *gspca_dev,
1961                         const struct usb_device_id *id)
1962 {
1963         struct sd *sd = (struct sd *) gspca_dev;
1964         struct usb_device *dev = gspca_dev->dev;
1965         struct cam *cam;
1966         int sensor;
1967
1968         cam = &gspca_dev->cam;
1969         cam->epaddr = 0x02;
1970         sd->bridge = id->driver_info;
1971
1972         vc0321_reset(gspca_dev);
1973         sensor = vc032x_probe_sensor(gspca_dev);
1974         switch (sensor) {
1975         case -1:
1976                 PDEBUG(D_PROBE, "Unknown sensor...");
1977                 return -EINVAL;
1978         case SENSOR_HV7131R:
1979                 PDEBUG(D_PROBE, "Find Sensor HV7131R");
1980                 break;
1981         case SENSOR_MI0360:
1982                 PDEBUG(D_PROBE, "Find Sensor MI0360");
1983                 sd->bridge = BRIDGE_VC0323;
1984                 break;
1985         case SENSOR_MI1310_SOC:
1986                 PDEBUG(D_PROBE, "Find Sensor MI1310_SOC");
1987                 break;
1988         case SENSOR_MI1320:
1989                 PDEBUG(D_PROBE, "Find Sensor MI1320");
1990                 break;
1991         case SENSOR_OV7660:
1992                 PDEBUG(D_PROBE, "Find Sensor OV7660");
1993                 break;
1994         case SENSOR_OV7670:
1995                 PDEBUG(D_PROBE, "Find Sensor OV7670");
1996                 break;
1997         case SENSOR_PO1200:
1998                 PDEBUG(D_PROBE, "Find Sensor PO1200");
1999                 break;
2000         case SENSOR_PO3130NC:
2001                 PDEBUG(D_PROBE, "Find Sensor PO3130NC");
2002                 break;
2003         }
2004         sd->sensor = sensor;
2005
2006         if (sd->bridge == BRIDGE_VC0321) {
2007                 cam->cam_mode = vc0321_mode;
2008                 cam->nmodes = ARRAY_SIZE(vc0321_mode);
2009         } else {
2010                 if (sensor != SENSOR_PO1200) {
2011                         cam->cam_mode = vc0323_mode;
2012                         cam->nmodes = ARRAY_SIZE(vc0323_mode);
2013                 } else {
2014                         cam->cam_mode = svga_mode;
2015                         cam->nmodes = ARRAY_SIZE(svga_mode);
2016                 }
2017         }
2018
2019         sd->qindex = 7;
2020         sd->hflip = HFLIP_DEF;
2021         sd->vflip = VFLIP_DEF;
2022         if (sd->sensor == SENSOR_OV7670) {
2023                 sd->hflip = 1;
2024                 sd->vflip = 1;
2025         }
2026         sd->lightfreq = FREQ_DEF;
2027         if (sd->sensor != SENSOR_OV7670)
2028                 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX);
2029         switch (sd->sensor) {
2030         case SENSOR_OV7660:
2031         case SENSOR_OV7670:
2032                 break;
2033         default:
2034                 gspca_dev->ctrl_dis = (1 << HFLIP_IDX)
2035                                         | (1 << VFLIP_IDX);
2036                 break;
2037         }
2038
2039         if (sd->bridge == BRIDGE_VC0321) {
2040                 reg_r(gspca_dev, 0x8a, 0, 3);
2041                 reg_w(dev, 0x87, 0x00, 0x0f0f);
2042
2043                 reg_r(gspca_dev, 0x8b, 0, 3);
2044                 reg_w(dev, 0x88, 0x00, 0x0202);
2045         }
2046         return 0;
2047 }
2048
2049 /* this function is called at probe and time */
2050 static int sd_init(struct gspca_dev *gspca_dev)
2051 {
2052         return 0;
2053 }
2054
2055 static void setquality(struct gspca_dev *gspca_dev)
2056 {
2057 }
2058
2059 /* for OV7660 and OV7670 only */
2060 static void sethvflip(struct gspca_dev *gspca_dev)
2061 {
2062         struct sd *sd = (struct sd *) gspca_dev;
2063         __u8 data;
2064
2065         switch (sd->sensor) {
2066         case SENSOR_OV7660:
2067                 data = 1;
2068                 break;
2069         case SENSOR_OV7670:
2070                 data = 7;
2071                 break;
2072         default:
2073                 return;
2074         }
2075         data |= OV7660_MVFP_MIRROR * sd->hflip
2076                 | OV7660_MVFP_VFLIP * sd->vflip;
2077         i2c_write(gspca_dev, OV7660_REG_MVFP, &data, 1);
2078 }
2079
2080 static void setlightfreq(struct gspca_dev *gspca_dev)
2081 {
2082         struct sd *sd = (struct sd *) gspca_dev;
2083         static const __u8 (*ov7660_freq_tb[3])[4] =
2084                 {ov7660_NoFliker, ov7660_50HZ, ov7660_60HZ};
2085
2086         if (sd->sensor != SENSOR_OV7660)
2087                 return;
2088         usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]);
2089 }
2090
2091 static int sd_start(struct gspca_dev *gspca_dev)
2092 {
2093         struct sd *sd = (struct sd *) gspca_dev;
2094         const __u8 *GammaT = NULL;
2095         const __u8 *MatrixT = NULL;
2096         int mode;
2097
2098         /* Assume start use the good resolution from gspca_dev->mode */
2099         if (sd->bridge == BRIDGE_VC0321) {
2100                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfec);
2101                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfed);
2102                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfee);
2103                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfef);
2104         }
2105
2106         mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
2107         switch (sd->sensor) {
2108         case SENSOR_HV7131R:
2109                 GammaT = hv7131r_gamma;
2110                 MatrixT = hv7131r_matrix;
2111                 if (mode) {
2112                         /* 320x240 */
2113                         usb_exchange(gspca_dev, hv7131r_initQVGA_data);
2114                 } else {
2115                         /* 640x480 */
2116                         usb_exchange(gspca_dev, hv7131r_initVGA_data);
2117                 }
2118                 break;
2119         case SENSOR_OV7660:
2120                 GammaT = ov7660_gamma;
2121                 MatrixT = ov7660_matrix;
2122                 if (mode) {
2123                         /* 320x240 */
2124                         usb_exchange(gspca_dev, ov7660_initQVGA_data);
2125                 } else {
2126                         /* 640x480 */
2127                         usb_exchange(gspca_dev, ov7660_initVGA_data);
2128                 }
2129                 break;
2130         case SENSOR_OV7670:
2131                 /*GammaT = ov7660_gamma; */
2132                 /*MatrixT = ov7660_matrix; */
2133                 if (mode) {
2134                         /* 320x240 */
2135                         usb_exchange(gspca_dev, ov7670_initQVGA_JPG);
2136                 } else {
2137                         /* 640x480 */
2138                         usb_exchange(gspca_dev, ov7670_initVGA_JPG);
2139                 }
2140                 break;
2141         case SENSOR_MI0360:
2142                 GammaT = mi1320_gamma;
2143                 MatrixT = mi0360_matrix;
2144                 if (mode) {
2145                         /* 320x240 */
2146                         usb_exchange(gspca_dev, mi0360_initQVGA_JPG);
2147                 } else {
2148                         /* 640x480 */
2149                         usb_exchange(gspca_dev, mi0360_initVGA_JPG);
2150                 }
2151                 break;
2152         case SENSOR_MI1310_SOC:
2153                 if (mode) {
2154                         /* 320x240 */
2155                         usb_exchange(gspca_dev, mi1310_socinitQVGA_JPG);
2156                 } else {
2157                         /* 640x480 */
2158                         usb_exchange(gspca_dev, mi1310_socinitVGA_JPG);
2159                 }
2160                 break;
2161         case SENSOR_MI1320:
2162                 GammaT = mi1320_gamma;
2163                 MatrixT = mi1320_matrix;
2164                 if (mode) {
2165                         /* 320x240 */
2166                         usb_exchange(gspca_dev, mi1320_initQVGA_data);
2167                 } else {
2168                         /* 640x480 */
2169                         usb_exchange(gspca_dev, mi1320_initVGA_data);
2170                 }
2171                 break;
2172         case SENSOR_PO3130NC:
2173                 GammaT = po3130_gamma;
2174                 MatrixT = po3130_matrix;
2175                 if (mode) {
2176                         /* 320x240 */
2177                         usb_exchange(gspca_dev, po3130_initQVGA_data);
2178                 } else {
2179                         /* 640x480 */
2180                         usb_exchange(gspca_dev, po3130_initVGA_data);
2181                 }
2182                 usb_exchange(gspca_dev, po3130_rundata);
2183                 break;
2184         case SENSOR_PO1200:
2185                 GammaT = po1200_gamma;
2186                 MatrixT = po1200_matrix;
2187                 usb_exchange(gspca_dev, po1200_initVGA_data);
2188                 break;
2189         default:
2190                 PDEBUG(D_PROBE, "Damned !! no sensor found Bye");
2191                 return -EMEDIUMTYPE;
2192         }
2193         if (GammaT && MatrixT) {
2194                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb84a);
2195                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb85b);
2196                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb86c);
2197                 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c);
2198
2199                 /* Seem SHARPNESS */
2200                 /*
2201                 reg_w(gspca_dev->dev, 0xa0, 0x80, 0xb80a);
2202                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb80b);
2203                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb80e);
2204                 */
2205                 /* all 0x40 ??? do nothing
2206                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb822);
2207                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb823);
2208                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb824);
2209                 */
2210                 /* Only works for HV7131R ??
2211                 reg_r (gspca_dev, 0xa1, 0xb881, 1);
2212                 reg_w(gspca_dev->dev, 0xa0, 0xfe01, 0xb881);
2213                 reg_w(gspca_dev->dev, 0xa0, 0x79, 0xb801);
2214                 */
2215                 /* only hv7131r et ov7660
2216                 reg_w(gspca_dev->dev, 0xa0, 0x20, 0xb827);
2217                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb826); * ISP_GAIN 80
2218                 reg_w(gspca_dev->dev, 0xa0, 0x23, 0xb800); * ISP CTRL_BAS
2219                 */
2220                 /* set the led on 0x0892 0x0896 */
2221                 if (sd->sensor != SENSOR_PO1200) {
2222                         reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff);
2223                         msleep(100);
2224                         setquality(gspca_dev);
2225                         sethvflip(gspca_dev);
2226                         setlightfreq(gspca_dev);
2227                 } else {
2228                         reg_w(gspca_dev->dev, 0x89, 0x0400, 0x1415);
2229                 }
2230         }
2231         return 0;
2232 }
2233
2234 static void sd_stopN(struct gspca_dev *gspca_dev)
2235 {
2236         struct usb_device *dev = gspca_dev->dev;
2237
2238         reg_w(dev, 0x89, 0xffff, 0xffff);
2239         reg_w(dev, 0xa0, 0x01, 0xb301);
2240         reg_w(dev, 0xa0, 0x09, 0xb003);
2241 }
2242
2243 /* called on streamoff with alt 0 and on disconnect */
2244 static void sd_stop0(struct gspca_dev *gspca_dev)
2245 {
2246         struct usb_device *dev = gspca_dev->dev;
2247
2248         if (!gspca_dev->present)
2249                 return;
2250         reg_w(dev, 0x89, 0xffff, 0xffff);
2251 }
2252
2253 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2254                         struct gspca_frame *frame,      /* target */
2255                         __u8 *data,                     /* isoc packet */
2256                         int len)                        /* iso pkt length */
2257 {
2258         struct sd *sd = (struct sd *) gspca_dev;
2259
2260         if (data[0] == 0xff && data[1] == 0xd8) {
2261                 PDEBUG(D_PACK,
2262                         "vc032x header packet found len %d", len);
2263                 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
2264                                                 data, 0);
2265                 if (sd->bridge == BRIDGE_VC0321) {
2266 #define VCHDRSZ 46
2267                         data += VCHDRSZ;
2268                         len -= VCHDRSZ;
2269 #undef VCHDRSZ
2270                 }
2271                 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
2272                                 data, len);
2273                 return;
2274         }
2275         gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
2276 }
2277
2278 static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
2279 {
2280         struct sd *sd = (struct sd *) gspca_dev;
2281
2282         sd->hflip = val;
2283         if (gspca_dev->streaming)
2284                 sethvflip(gspca_dev);
2285         return 0;
2286 }
2287
2288 static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
2289 {
2290         struct sd *sd = (struct sd *) gspca_dev;
2291
2292         *val = sd->hflip;
2293         return 0;
2294 }
2295
2296 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2297 {
2298         struct sd *sd = (struct sd *) gspca_dev;
2299
2300         sd->vflip = val;
2301         if (gspca_dev->streaming)
2302                 sethvflip(gspca_dev);
2303         return 0;
2304 }
2305
2306 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2307 {
2308         struct sd *sd = (struct sd *) gspca_dev;
2309
2310         *val = sd->vflip;
2311         return 0;
2312 }
2313
2314 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2315 {
2316         struct sd *sd = (struct sd *) gspca_dev;
2317
2318         sd->lightfreq = val;
2319         if (gspca_dev->streaming)
2320                 setlightfreq(gspca_dev);
2321         return 0;
2322 }
2323
2324 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2325 {
2326         struct sd *sd = (struct sd *) gspca_dev;
2327
2328         *val = sd->lightfreq;
2329         return 0;
2330 }
2331
2332 static int sd_querymenu(struct gspca_dev *gspca_dev,
2333                         struct v4l2_querymenu *menu)
2334 {
2335         switch (menu->id) {
2336         case V4L2_CID_POWER_LINE_FREQUENCY:
2337                 switch (menu->index) {
2338                 case 0:         /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2339                         strcpy((char *) menu->name, "NoFliker");
2340                         return 0;
2341                 case 1:         /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2342                         strcpy((char *) menu->name, "50 Hz");
2343                         return 0;
2344                 case 2:         /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2345                         strcpy((char *) menu->name, "60 Hz");
2346                         return 0;
2347                 }
2348                 break;
2349         }
2350         return -EINVAL;
2351 }
2352
2353 /* sub-driver description */
2354 static const struct sd_desc sd_desc = {
2355         .name = MODULE_NAME,
2356         .ctrls = sd_ctrls,
2357         .nctrls = ARRAY_SIZE(sd_ctrls),
2358         .config = sd_config,
2359         .init = sd_init,
2360         .start = sd_start,
2361         .stopN = sd_stopN,
2362         .stop0 = sd_stop0,
2363         .pkt_scan = sd_pkt_scan,
2364         .querymenu = sd_querymenu,
2365 };
2366
2367 /* -- module initialisation -- */
2368 static const __devinitdata struct usb_device_id device_table[] = {
2369         {USB_DEVICE(0x046d, 0x0892), .driver_info = BRIDGE_VC0321},
2370         {USB_DEVICE(0x046d, 0x0896), .driver_info = BRIDGE_VC0321},
2371         {USB_DEVICE(0x0ac8, 0x0321), .driver_info = BRIDGE_VC0321},
2372         {USB_DEVICE(0x0ac8, 0x0323), .driver_info = BRIDGE_VC0323},
2373         {USB_DEVICE(0x0ac8, 0x0328), .driver_info = BRIDGE_VC0321},
2374         {USB_DEVICE(0x0ac8, 0xc001), .driver_info = BRIDGE_VC0321},
2375         {USB_DEVICE(0x0ac8, 0xc002), .driver_info = BRIDGE_VC0321},
2376         {USB_DEVICE(0x15b8, 0x6002), .driver_info = BRIDGE_VC0323},
2377         {USB_DEVICE(0x17ef, 0x4802), .driver_info = BRIDGE_VC0323},
2378         {}
2379 };
2380 MODULE_DEVICE_TABLE(usb, device_table);
2381
2382 /* -- device connect -- */
2383 static int sd_probe(struct usb_interface *intf,
2384                         const struct usb_device_id *id)
2385 {
2386         return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2387                                 THIS_MODULE);
2388 }
2389
2390 static struct usb_driver sd_driver = {
2391         .name = MODULE_NAME,
2392         .id_table = device_table,
2393         .probe = sd_probe,
2394         .disconnect = gspca_disconnect,
2395 #ifdef CONFIG_PM
2396         .suspend = gspca_suspend,
2397         .resume = gspca_resume,
2398 #endif
2399 };
2400
2401 /* -- module insert / remove -- */
2402 static int __init sd_mod_init(void)
2403 {
2404         if (usb_register(&sd_driver) < 0)
2405                 return -1;
2406         PDEBUG(D_PROBE, "registered");
2407         return 0;
2408 }
2409 static void __exit sd_mod_exit(void)
2410 {
2411         usb_deregister(&sd_driver);
2412         PDEBUG(D_PROBE, "deregistered");
2413 }
2414
2415 module_init(sd_mod_init);
2416 module_exit(sd_mod_exit);