Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen...
[linux-2.6] / 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         unsigned char autogain;
36         unsigned char lightfreq;
37
38         char qindex;
39         char bridge;
40 #define BRIDGE_VC0321 0
41 #define BRIDGE_VC0323 1
42         char sensor;
43 #define SENSOR_HV7131R 0
44 #define SENSOR_MI1320 1
45 #define SENSOR_MI1310_SOC 2
46 #define SENSOR_OV7660 3
47 #define SENSOR_OV7670 4
48 #define SENSOR_PO3130NC 5
49 };
50
51 /* V4L2 controls supported by the driver */
52 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
53 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
54 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
55 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
56
57 static struct ctrl sd_ctrls[] = {
58         {
59             {
60                 .id      = V4L2_CID_AUTOGAIN,
61                 .type    = V4L2_CTRL_TYPE_BOOLEAN,
62                 .name    = "Auto Gain",
63                 .minimum = 0,
64                 .maximum = 1,
65                 .step    = 1,
66 #define AUTOGAIN_DEF 1
67                 .default_value = AUTOGAIN_DEF,
68             },
69             .set = sd_setautogain,
70             .get = sd_getautogain,
71         },
72 #define LIGHTFREQ_IDX 1
73         {
74             {
75                 .id      = V4L2_CID_POWER_LINE_FREQUENCY,
76                 .type    = V4L2_CTRL_TYPE_MENU,
77                 .name    = "Light frequency filter",
78                 .minimum = 0,
79                 .maximum = 2,   /* 0: No, 1: 50Hz, 2:60Hz */
80                 .step    = 1,
81 #define FREQ_DEF 1
82                 .default_value = FREQ_DEF,
83                 .default_value = 1,
84             },
85             .set = sd_setfreq,
86             .get = sd_getfreq,
87         },
88 };
89
90 static struct v4l2_pix_format vc0321_mode[] = {
91         {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
92                 .bytesperline = 320,
93                 .sizeimage = 320 * 240 * 2,
94                 .colorspace = V4L2_COLORSPACE_SRGB,
95                 .priv = 1},
96         {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE,
97                 .bytesperline = 640,
98                 .sizeimage = 640 * 480 * 2,
99                 .colorspace = V4L2_COLORSPACE_SRGB,
100                 .priv = 0},
101 };
102 static struct v4l2_pix_format vc0323_mode[] = {
103         {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
104                 .bytesperline = 320,
105                 .sizeimage = 320 * 240 * 3 / 8 + 590,
106                 .colorspace = V4L2_COLORSPACE_JPEG,
107                 .priv = 1},
108         {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
109                 .bytesperline = 640,
110                 .sizeimage = 640 * 480 * 3 / 8 + 590,
111                 .colorspace = V4L2_COLORSPACE_JPEG,
112                 .priv = 0},
113 };
114
115 static const __u8 mi1310_socinitVGA_JPG[][4] = {
116         {0xb0, 0x03, 0x19, 0xcc},
117         {0xb0, 0x04, 0x02, 0xcc},
118         {0xb3, 0x00, 0x64, 0xcc},
119         {0xb3, 0x00, 0x65, 0xcc},
120         {0xb3, 0x05, 0x00, 0xcc},
121         {0xb3, 0x06, 0x00, 0xcc},
122         {0xb3, 0x08, 0x01, 0xcc},
123         {0xb3, 0x09, 0x0c, 0xcc},
124         {0xb3, 0x34, 0x02, 0xcc},
125         {0xb3, 0x35, 0xdd, 0xcc},
126         {0xb3, 0x02, 0x00, 0xcc},
127         {0xb3, 0x03, 0x0a, 0xcc},
128         {0xb3, 0x04, 0x05, 0xcc},
129         {0xb3, 0x20, 0x00, 0xcc},
130         {0xb3, 0x21, 0x00, 0xcc},
131         {0xb3, 0x22, 0x03, 0xcc},
132         {0xb3, 0x23, 0xc0, 0xcc},
133         {0xb3, 0x14, 0x00, 0xcc},
134         {0xb3, 0x15, 0x00, 0xcc},
135         {0xb3, 0x16, 0x04, 0xcc},
136         {0xb3, 0x17, 0xff, 0xcc},
137         {0xb3, 0x00, 0x65, 0xcc},
138         {0xb8, 0x00, 0x00, 0xcc},
139         {0xbc, 0x00, 0xd0, 0xcc},
140         {0xbc, 0x01, 0x01, 0xcc},
141         {0xf0, 0x00, 0x02, 0xbb},
142         {0xc8, 0x9f, 0x0b, 0xbb},
143         {0x5b, 0x00, 0x01, 0xbb},
144         {0x2f, 0xde, 0x20, 0xbb},
145         {0xf0, 0x00, 0x00, 0xbb},
146         {0x20, 0x03, 0x02, 0xbb},
147         {0xf0, 0x00, 0x01, 0xbb},
148         {0x05, 0x00, 0x07, 0xbb},
149         {0x34, 0x00, 0x00, 0xbb},
150         {0x35, 0xff, 0x00, 0xbb},
151         {0xdc, 0x07, 0x02, 0xbb},
152         {0xdd, 0x3c, 0x18, 0xbb},
153         {0xde, 0x92, 0x6d, 0xbb},
154         {0xdf, 0xcd, 0xb1, 0xbb},
155         {0xe0, 0xff, 0xe7, 0xbb},
156         {0x06, 0xf0, 0x0d, 0xbb},
157         {0x06, 0x70, 0x0e, 0xbb},
158         {0x4c, 0x00, 0x01, 0xbb},
159         {0x4d, 0x00, 0x01, 0xbb},
160         {0xf0, 0x00, 0x02, 0xbb},
161         {0x2e, 0x0c, 0x55, 0xbb},
162         {0x21, 0xb6, 0x6e, 0xbb},
163         {0x36, 0x30, 0x10, 0xbb},
164         {0x37, 0x00, 0xc1, 0xbb},
165         {0xf0, 0x00, 0x00, 0xbb},
166         {0x07, 0x00, 0x84, 0xbb},
167         {0x08, 0x02, 0x4a, 0xbb},
168         {0x05, 0x01, 0x10, 0xbb},
169         {0x06, 0x00, 0x39, 0xbb},
170         {0xf0, 0x00, 0x02, 0xbb},
171         {0x58, 0x02, 0x67, 0xbb},
172         {0x57, 0x02, 0x00, 0xbb},
173         {0x5a, 0x02, 0x67, 0xbb},
174         {0x59, 0x02, 0x00, 0xbb},
175         {0x5c, 0x12, 0x0d, 0xbb},
176         {0x5d, 0x16, 0x11, 0xbb},
177         {0x39, 0x06, 0x18, 0xbb},
178         {0x3a, 0x06, 0x18, 0xbb},
179         {0x3b, 0x06, 0x18, 0xbb},
180         {0x3c, 0x06, 0x18, 0xbb},
181         {0x64, 0x7b, 0x5b, 0xbb},
182         {0xf0, 0x00, 0x02, 0xbb},
183         {0x36, 0x30, 0x10, 0xbb},
184         {0x37, 0x00, 0xc0, 0xbb},
185         {0xbc, 0x0e, 0x00, 0xcc},
186         {0xbc, 0x0f, 0x05, 0xcc},
187         {0xbc, 0x10, 0xc0, 0xcc},
188         {0xbc, 0x11, 0x03, 0xcc},
189         {0xb6, 0x00, 0x00, 0xcc},
190         {0xb6, 0x03, 0x02, 0xcc},
191         {0xb6, 0x02, 0x80, 0xcc},
192         {0xb6, 0x05, 0x01, 0xcc},
193         {0xb6, 0x04, 0xe0, 0xcc},
194         {0xb6, 0x12, 0xf8, 0xcc},
195         {0xb6, 0x13, 0x25, 0xcc},
196         {0xb6, 0x18, 0x02, 0xcc},
197         {0xb6, 0x17, 0x58, 0xcc},
198         {0xb6, 0x16, 0x00, 0xcc},
199         {0xb6, 0x22, 0x12, 0xcc},
200         {0xb6, 0x23, 0x0b, 0xcc},
201         {0xbf, 0xc0, 0x39, 0xcc},
202         {0xbf, 0xc1, 0x04, 0xcc},
203         {0xbf, 0xcc, 0x00, 0xcc},
204         {0xbc, 0x02, 0x18, 0xcc},
205         {0xbc, 0x03, 0x50, 0xcc},
206         {0xbc, 0x04, 0x18, 0xcc},
207         {0xbc, 0x05, 0x00, 0xcc},
208         {0xbc, 0x06, 0x00, 0xcc},
209         {0xbc, 0x08, 0x30, 0xcc},
210         {0xbc, 0x09, 0x40, 0xcc},
211         {0xbc, 0x0a, 0x10, 0xcc},
212         {0xbc, 0x0b, 0x00, 0xcc},
213         {0xbc, 0x0c, 0x00, 0xcc},
214         {0xb3, 0x5c, 0x01, 0xcc},
215         {0xf0, 0x00, 0x01, 0xbb},
216         {0x80, 0x00, 0x03, 0xbb},
217         {0x81, 0xc7, 0x14, 0xbb},
218         {0x82, 0xeb, 0xe8, 0xbb},
219         {0x83, 0xfe, 0xf4, 0xbb},
220         {0x84, 0xcd, 0x10, 0xbb},
221         {0x85, 0xf3, 0xee, 0xbb},
222         {0x86, 0xff, 0xf1, 0xbb},
223         {0x87, 0xcd, 0x10, 0xbb},
224         {0x88, 0xf3, 0xee, 0xbb},
225         {0x89, 0x01, 0xf1, 0xbb},
226         {0x8a, 0xe5, 0x17, 0xbb},
227         {0x8b, 0xe8, 0xe2, 0xbb},
228         {0x8c, 0xf7, 0xed, 0xbb},
229         {0x8d, 0x00, 0xff, 0xbb},
230         {0x8e, 0xec, 0x10, 0xbb},
231         {0x8f, 0xf0, 0xed, 0xbb},
232         {0x90, 0xf9, 0xf2, 0xbb},
233         {0x91, 0x00, 0x00, 0xbb},
234         {0x92, 0xe9, 0x0d, 0xbb},
235         {0x93, 0xf4, 0xf2, 0xbb},
236         {0x94, 0xfb, 0xf5, 0xbb},
237         {0x95, 0x00, 0xff, 0xbb},
238         {0xb6, 0x0f, 0x08, 0xbb},
239         {0xb7, 0x3d, 0x16, 0xbb},
240         {0xb8, 0x0c, 0x04, 0xbb},
241         {0xb9, 0x1c, 0x07, 0xbb},
242         {0xba, 0x0a, 0x03, 0xbb},
243         {0xbb, 0x1b, 0x09, 0xbb},
244         {0xbc, 0x17, 0x0d, 0xbb},
245         {0xbd, 0x23, 0x1d, 0xbb},
246         {0xbe, 0x00, 0x28, 0xbb},
247         {0xbf, 0x11, 0x09, 0xbb},
248         {0xc0, 0x16, 0x15, 0xbb},
249         {0xc1, 0x00, 0x1b, 0xbb},
250         {0xc2, 0x0e, 0x07, 0xbb},
251         {0xc3, 0x14, 0x10, 0xbb},
252         {0xc4, 0x00, 0x17, 0xbb},
253         {0x06, 0x74, 0x8e, 0xbb},
254         {0xf0, 0x00, 0x01, 0xbb},
255         {0x06, 0xf4, 0x8e, 0xbb},
256         {0x00, 0x00, 0x50, 0xdd},
257         {0x06, 0x74, 0x8e, 0xbb},
258         {0xf0, 0x00, 0x02, 0xbb},
259         {0x24, 0x50, 0x20, 0xbb},
260         {0xf0, 0x00, 0x02, 0xbb},
261         {0x34, 0x0c, 0x50, 0xbb},
262         {0xb3, 0x01, 0x41, 0xcc},
263         {0xf0, 0x00, 0x00, 0xbb},
264         {0x03, 0x03, 0xc0, 0xbb},
265         {},
266 };
267 static const __u8 mi1310_socinitQVGA_JPG[][4] = {
268         {0xb0, 0x03, 0x19, 0xcc},       {0xb0, 0x04, 0x02, 0xcc},
269         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
270         {0xb3, 0x05, 0x00, 0xcc},       {0xb3, 0x06, 0x00, 0xcc},
271         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
272         {0xb3, 0x34, 0x02, 0xcc},       {0xb3, 0x35, 0xdd, 0xcc},
273         {0xb3, 0x02, 0x00, 0xcc},       {0xb3, 0x03, 0x0a, 0xcc},
274         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
275         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x03, 0xcc},
276         {0xb3, 0x23, 0xc0, 0xcc},       {0xb3, 0x14, 0x00, 0xcc},
277         {0xb3, 0x15, 0x00, 0xcc},       {0xb3, 0x16, 0x04, 0xcc},
278         {0xb3, 0x17, 0xff, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
279         {0xb8, 0x00, 0x00, 0xcc},       {0xbc, 0x00, 0xf0, 0xcc},
280         {0xbc, 0x01, 0x01, 0xcc},       {0xf0, 0x00, 0x02, 0xbb},
281         {0xc8, 0x9f, 0x0b, 0xbb},       {0x5b, 0x00, 0x01, 0xbb},
282         {0x2f, 0xde, 0x20, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
283         {0x20, 0x03, 0x02, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
284         {0x05, 0x00, 0x07, 0xbb},       {0x34, 0x00, 0x00, 0xbb},
285         {0x35, 0xff, 0x00, 0xbb},       {0xdc, 0x07, 0x02, 0xbb},
286         {0xdd, 0x3c, 0x18, 0xbb},       {0xde, 0x92, 0x6d, 0xbb},
287         {0xdf, 0xcd, 0xb1, 0xbb},       {0xe0, 0xff, 0xe7, 0xbb},
288         {0x06, 0xf0, 0x0d, 0xbb},       {0x06, 0x70, 0x0e, 0xbb},
289         {0x4c, 0x00, 0x01, 0xbb},       {0x4d, 0x00, 0x01, 0xbb},
290         {0xf0, 0x00, 0x02, 0xbb},       {0x2e, 0x0c, 0x55, 0xbb},
291         {0x21, 0xb6, 0x6e, 0xbb},       {0x36, 0x30, 0x10, 0xbb},
292         {0x37, 0x00, 0xc1, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
293         {0x07, 0x00, 0x84, 0xbb},       {0x08, 0x02, 0x4a, 0xbb},
294         {0x05, 0x01, 0x10, 0xbb},       {0x06, 0x00, 0x39, 0xbb},
295         {0xf0, 0x00, 0x02, 0xbb},       {0x58, 0x02, 0x67, 0xbb},
296         {0x57, 0x02, 0x00, 0xbb},       {0x5a, 0x02, 0x67, 0xbb},
297         {0x59, 0x02, 0x00, 0xbb},       {0x5c, 0x12, 0x0d, 0xbb},
298         {0x5d, 0x16, 0x11, 0xbb},       {0x39, 0x06, 0x18, 0xbb},
299         {0x3a, 0x06, 0x18, 0xbb},       {0x3b, 0x06, 0x18, 0xbb},
300         {0x3c, 0x06, 0x18, 0xbb},       {0x64, 0x7b, 0x5b, 0xbb},
301         {0xf0, 0x00, 0x02, 0xbb},       {0x36, 0x30, 0x10, 0xbb},
302         {0x37, 0x00, 0xc0, 0xbb},       {0xbc, 0x0e, 0x00, 0xcc},
303         {0xbc, 0x0f, 0x05, 0xcc},       {0xbc, 0x10, 0xc0, 0xcc},
304         {0xbc, 0x11, 0x03, 0xcc},       {0xb6, 0x00, 0x00, 0xcc},
305         {0xb6, 0x03, 0x01, 0xcc},       {0xb6, 0x02, 0x40, 0xcc},
306         {0xb6, 0x05, 0x00, 0xcc},       {0xb6, 0x04, 0xf0, 0xcc},
307         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x25, 0xcc},
308         {0xb6, 0x18, 0x00, 0xcc},       {0xb6, 0x17, 0x96, 0xcc},
309         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
310         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
311         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
312         {0xb3, 0x5c, 0x01, 0xcc},       {0xf0, 0x00, 0x01, 0xbb},
313         {0x80, 0x00, 0x03, 0xbb},       {0x81, 0xc7, 0x14, 0xbb},
314         {0x82, 0xeb, 0xe8, 0xbb},       {0x83, 0xfe, 0xf4, 0xbb},
315         {0x84, 0xcd, 0x10, 0xbb},       {0x85, 0xf3, 0xee, 0xbb},
316         {0x86, 0xff, 0xf1, 0xbb},       {0x87, 0xcd, 0x10, 0xbb},
317         {0x88, 0xf3, 0xee, 0xbb},       {0x89, 0x01, 0xf1, 0xbb},
318         {0x8a, 0xe5, 0x17, 0xbb},       {0x8b, 0xe8, 0xe2, 0xbb},
319         {0x8c, 0xf7, 0xed, 0xbb},       {0x8d, 0x00, 0xff, 0xbb},
320         {0x8e, 0xec, 0x10, 0xbb},       {0x8f, 0xf0, 0xed, 0xbb},
321         {0x90, 0xf9, 0xf2, 0xbb},       {0x91, 0x00, 0x00, 0xbb},
322         {0x92, 0xe9, 0x0d, 0xbb},       {0x93, 0xf4, 0xf2, 0xbb},
323         {0x94, 0xfb, 0xf5, 0xbb},       {0x95, 0x00, 0xff, 0xbb},
324         {0xb6, 0x0f, 0x08, 0xbb},       {0xb7, 0x3d, 0x16, 0xbb},
325         {0xb8, 0x0c, 0x04, 0xbb},       {0xb9, 0x1c, 0x07, 0xbb},
326         {0xba, 0x0a, 0x03, 0xbb},       {0xbb, 0x1b, 0x09, 0xbb},
327         {0xbc, 0x17, 0x0d, 0xbb},       {0xbd, 0x23, 0x1d, 0xbb},
328         {0xbe, 0x00, 0x28, 0xbb},       {0xbf, 0x11, 0x09, 0xbb},
329         {0xc0, 0x16, 0x15, 0xbb},       {0xc1, 0x00, 0x1b, 0xbb},
330         {0xc2, 0x0e, 0x07, 0xbb},       {0xc3, 0x14, 0x10, 0xbb},
331         {0xc4, 0x00, 0x17, 0xbb},       {0x06, 0x74, 0x8e, 0xbb},
332         {0xf0, 0x00, 0x01, 0xbb},       {0x06, 0xf4, 0x8e, 0xbb},
333         {0x00, 0x00, 0x50, 0xdd},       {0x06, 0x74, 0x8e, 0xbb},
334         {0xf0, 0x00, 0x02, 0xbb},       {0x24, 0x50, 0x20, 0xbb},
335         {0xf0, 0x00, 0x02, 0xbb},       {0x34, 0x0c, 0x50, 0xbb},
336         {0xb3, 0x01, 0x41, 0xcc},       {0xf0, 0x00, 0x00, 0xbb},
337         {0x03, 0x03, 0xc0, 0xbb},
338         {},
339 };
340
341 static const __u8 mi1320_gamma[17] = {
342         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
343         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
344 };
345 static const __u8 mi1320_matrix[9] = {
346         0x54, 0xda, 0x06, 0xf1, 0x50, 0xf4, 0xf7, 0xea, 0x52
347 };
348 static const __u8 mi1320_initVGA_data[][4] = {
349         {0xb3, 0x01, 0x01, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
350         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
351         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
352         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
353         {0xb0, 0x16, 0x03, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
354         {0xb3, 0x06, 0x00, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
355         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x34, 0x02, 0xcc},
356         {0xb3, 0x35, 0xc8, 0xcc},       {0xb3, 0x02, 0x00, 0xcc},
357         {0xb3, 0x03, 0x0a, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
358         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
359         {0xb3, 0x22, 0x03, 0xcc},       {0xb3, 0x23, 0xc0, 0xcc},
360         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
361         {0xb3, 0x16, 0x04, 0xcc},       {0xb3, 0x17, 0xff, 0xcc},
362         {0xb3, 0x00, 0x67, 0xcc},       {0xbc, 0x00, 0xd0, 0xcc},
363         {0xbc, 0x01, 0x01, 0xcc},       {0xf0, 0x00, 0x00, 0xbb},
364         {0x0d, 0x00, 0x09, 0xbb},       {0x00, 0x01, 0x00, 0xdd},
365         {0x0d, 0x00, 0x08, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
366         {0xa1, 0x05, 0x00, 0xbb},       {0xa4, 0x03, 0xc0, 0xbb},
367         {0xf0, 0x00, 0x02, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
368         {0xc8, 0x9f, 0x0b, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
369         {0xf0, 0x00, 0x00, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
370         {0x20, 0x01, 0x00, 0xbb},       {0x00, 0x00, 0x10, 0xdd},
371         {0xf0, 0x00, 0x01, 0xbb},       {0x9d, 0x3c, 0xa0, 0xbb},
372         {0x47, 0x30, 0x30, 0xbb},       {0xf0, 0x00, 0x00, 0xbb},
373         {0x0a, 0x80, 0x11, 0xbb},       {0x35, 0x00, 0x22, 0xbb},
374         {0xf0, 0x00, 0x02, 0xbb},       {0x9d, 0xc5, 0x05, 0xbb},
375         {0xdc, 0x0f, 0xfc, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
376         {0x06, 0x74, 0x0e, 0xbb},       {0x80, 0x00, 0x06, 0xbb},
377         {0x81, 0x04, 0x00, 0xbb},       {0x82, 0x01, 0x02, 0xbb},
378         {0x83, 0x03, 0x02, 0xbb},       {0x84, 0x05, 0x00, 0xbb},
379         {0x85, 0x01, 0x00, 0xbb},       {0x86, 0x03, 0x02, 0xbb},
380         {0x87, 0x05, 0x00, 0xbb},       {0x88, 0x01, 0x00, 0xbb},
381         {0x89, 0x02, 0x02, 0xbb},       {0x8a, 0xfd, 0x04, 0xbb},
382         {0x8b, 0xfc, 0xfd, 0xbb},       {0x8c, 0xff, 0xfd, 0xbb},
383         {0x8d, 0x00, 0x00, 0xbb},       {0x8e, 0xfe, 0x05, 0xbb},
384         {0x8f, 0xfc, 0xfd, 0xbb},       {0x90, 0xfe, 0xfd, 0xbb},
385         {0x91, 0x00, 0x00, 0xbb},       {0x92, 0xfe, 0x03, 0xbb},
386         {0x93, 0xfd, 0xfe, 0xbb},       {0x94, 0xff, 0xfd, 0xbb},
387         {0x95, 0x00, 0x00, 0xbb},       {0xb6, 0x07, 0x05, 0xbb},
388         {0xb7, 0x13, 0x06, 0xbb},       {0xb8, 0x08, 0x06, 0xbb},
389         {0xb9, 0x14, 0x08, 0xbb},       {0xba, 0x06, 0x05, 0xbb},
390         {0xbb, 0x13, 0x06, 0xbb},       {0xbc, 0x03, 0x01, 0xbb},
391         {0xbd, 0x03, 0x04, 0xbb},       {0xbe, 0x00, 0x02, 0xbb},
392         {0xbf, 0x03, 0x01, 0xbb},       {0xc0, 0x02, 0x04, 0xbb},
393         {0xc1, 0x00, 0x04, 0xbb},       {0xc2, 0x02, 0x01, 0xbb},
394         {0xc3, 0x01, 0x03, 0xbb},       {0xc4, 0x00, 0x04, 0xbb},
395         {0xf0, 0x00, 0x00, 0xbb},       {0x05, 0x01, 0x13, 0xbb},
396         {0x06, 0x00, 0x11, 0xbb},       {0x07, 0x00, 0x85, 0xbb},
397         {0x08, 0x00, 0x27, 0xbb},       {0x20, 0x01, 0x03, 0xbb},
398         {0x21, 0x80, 0x00, 0xbb},       {0x22, 0x0d, 0x0f, 0xbb},
399         {0x24, 0x80, 0x00, 0xbb},       {0x59, 0x00, 0xff, 0xbb},
400         {0xf0, 0x00, 0x02, 0xbb},       {0x39, 0x03, 0x0d, 0xbb},
401         {0x3a, 0x06, 0x1b, 0xbb},       {0x3b, 0x00, 0x95, 0xbb},
402         {0x3c, 0x04, 0xdb, 0xbb},       {0x57, 0x02, 0x00, 0xbb},
403         {0x58, 0x02, 0x66, 0xbb},       {0x59, 0x00, 0xff, 0xbb},
404         {0x5a, 0x01, 0x33, 0xbb},       {0x5c, 0x12, 0x0d, 0xbb},
405         {0x5d, 0x16, 0x11, 0xbb},       {0x64, 0x5e, 0x1c, 0xbb},
406         {0xf0, 0x00, 0x02, 0xbb},       {0x2f, 0xd1, 0x00, 0xbb},
407         {0x5b, 0x00, 0x01, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
408         {0x36, 0x68, 0x10, 0xbb},       {0x00, 0x00, 0x30, 0xdd},
409         {0x37, 0x82, 0x00, 0xbb},       {0xbc, 0x0e, 0x00, 0xcc},
410         {0xbc, 0x0f, 0x05, 0xcc},       {0xbc, 0x10, 0xc0, 0xcc},
411         {0xbc, 0x11, 0x03, 0xcc},       {0xb6, 0x00, 0x00, 0xcc},
412         {0xb6, 0x03, 0x05, 0xcc},       {0xb6, 0x02, 0x00, 0xcc},
413         {0xb6, 0x05, 0x04, 0xcc},       {0xb6, 0x04, 0x00, 0xcc},
414         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x29, 0xcc},
415         {0xb6, 0x18, 0x0a, 0xcc},       {0xb6, 0x17, 0x00, 0xcc},
416         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
417         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x26, 0xcc},
418         {0xbf, 0xc1, 0x02, 0xcc},       {0xbf, 0xcc, 0x04, 0xcc},
419         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
420         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
421         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
422         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
423         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
424         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
425         {}
426 };
427 static const __u8 mi1320_initQVGA_data[][4] = {
428         {0xb3, 0x01, 0x01, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
429         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
430         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x33, 0xdd},
431         {0xb3, 0x00, 0x64, 0xcc},       {0xb3, 0x00, 0x65, 0xcc},
432         {0xb0, 0x16, 0x03, 0xcc},       {0xb3, 0x05, 0x01, 0xcc},
433         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
434         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x34, 0x02, 0xcc},
435         {0xb3, 0x35, 0xc8, 0xcc},       {0xb3, 0x02, 0x00, 0xcc},
436         {0xb3, 0x03, 0x0a, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
437         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
438         {0xb3, 0x22, 0x01, 0xcc},       {0xb3, 0x23, 0xe0, 0xcc},
439         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
440         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
441         {0xb3, 0x00, 0x65, 0xcc},       {0xb8, 0x00, 0x00, 0xcc},
442         {0xbc, 0x00, 0xd0, 0xcc},       {0xbc, 0x01, 0x01, 0xcc},
443         {0xf0, 0x00, 0x00, 0xbb},       {0x0d, 0x00, 0x09, 0xbb},
444         {0x00, 0x01, 0x00, 0xdd},       {0x0d, 0x00, 0x08, 0xbb},
445         {0xf0, 0x00, 0x00, 0xbb},       {0x02, 0x00, 0x64, 0xbb},
446         {0x05, 0x01, 0x78, 0xbb},       {0x06, 0x00, 0x11, 0xbb},
447         {0x07, 0x01, 0x42, 0xbb},       {0x08, 0x00, 0x11, 0xbb},
448         {0x20, 0x01, 0x00, 0xbb},       {0x21, 0x80, 0x00, 0xbb},
449         {0x22, 0x0d, 0x0f, 0xbb},       {0x24, 0x80, 0x00, 0xbb},
450         {0x59, 0x00, 0xff, 0xbb},       {0xf0, 0x00, 0x01, 0xbb},
451         {0x9d, 0x3c, 0xa0, 0xbb},       {0x47, 0x30, 0x30, 0xbb},
452         {0xf0, 0x00, 0x00, 0xbb},       {0x0a, 0x80, 0x11, 0xbb},
453         {0x35, 0x00, 0x22, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
454         {0x9d, 0xc5, 0x05, 0xbb},       {0xdc, 0x0f, 0xfc, 0xbb},
455         {0xf0, 0x00, 0x01, 0xbb},       {0x06, 0x74, 0x0e, 0xbb},
456         {0x80, 0x00, 0x06, 0xbb},       {0x81, 0x04, 0x00, 0xbb},
457         {0x82, 0x01, 0x02, 0xbb},       {0x83, 0x03, 0x02, 0xbb},
458         {0x84, 0x05, 0x00, 0xbb},       {0x85, 0x01, 0x00, 0xbb},
459         {0x86, 0x03, 0x02, 0xbb},       {0x87, 0x05, 0x00, 0xbb},
460         {0x88, 0x01, 0x00, 0xbb},       {0x89, 0x02, 0x02, 0xbb},
461         {0x8a, 0xfd, 0x04, 0xbb},       {0x8b, 0xfc, 0xfd, 0xbb},
462         {0x8c, 0xff, 0xfd, 0xbb},       {0x8d, 0x00, 0x00, 0xbb},
463         {0x8e, 0xfe, 0x05, 0xbb},       {0x8f, 0xfc, 0xfd, 0xbb},
464         {0x90, 0xfe, 0xfd, 0xbb},       {0x91, 0x00, 0x00, 0xbb},
465         {0x92, 0xfe, 0x03, 0xbb},       {0x93, 0xfd, 0xfe, 0xbb},
466         {0x94, 0xff, 0xfd, 0xbb},       {0x95, 0x00, 0x00, 0xbb},
467         {0xb6, 0x07, 0x05, 0xbb},       {0xb7, 0x13, 0x06, 0xbb},
468         {0xb8, 0x08, 0x06, 0xbb},       {0xb9, 0x14, 0x08, 0xbb},
469         {0xba, 0x06, 0x05, 0xbb},       {0xbb, 0x13, 0x06, 0xbb},
470         {0xbc, 0x03, 0x01, 0xbb},       {0xbd, 0x03, 0x04, 0xbb},
471         {0xbe, 0x00, 0x02, 0xbb},       {0xbf, 0x03, 0x01, 0xbb},
472         {0xc0, 0x02, 0x04, 0xbb},       {0xc1, 0x00, 0x04, 0xbb},
473         {0xc2, 0x02, 0x01, 0xbb},       {0xc3, 0x01, 0x03, 0xbb},
474         {0xc4, 0x00, 0x04, 0xbb},       {0xf0, 0x00, 0x02, 0xbb},
475         {0xc8, 0x00, 0x00, 0xbb},       {0x2e, 0x00, 0x00, 0xbb},
476         {0x2e, 0x0c, 0x5b, 0xbb},       {0x2f, 0xd1, 0x00, 0xbb},
477         {0x39, 0x03, 0xca, 0xbb},       {0x3a, 0x06, 0x80, 0xbb},
478         {0x3b, 0x01, 0x52, 0xbb},       {0x3c, 0x05, 0x40, 0xbb},
479         {0x57, 0x01, 0x9c, 0xbb},       {0x58, 0x01, 0xee, 0xbb},
480         {0x59, 0x00, 0xf0, 0xbb},       {0x5a, 0x01, 0x20, 0xbb},
481         {0x5c, 0x1d, 0x17, 0xbb},       {0x5d, 0x22, 0x1c, 0xbb},
482         {0x64, 0x1e, 0x1c, 0xbb},       {0x5b, 0x00, 0x01, 0xbb},
483         {0xf0, 0x00, 0x02, 0xbb},       {0x36, 0x68, 0x10, 0xbb},
484         {0x00, 0x00, 0x30, 0xdd},       {0x37, 0x81, 0x00, 0xbb},
485         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
486         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
487         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
488         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
489         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
490         {0xbf, 0xc0, 0x26, 0xcc},       {0xbf, 0xc1, 0x02, 0xcc},
491         {0xbf, 0xcc, 0x04, 0xcc},       {0xb3, 0x5c, 0x01, 0xcc},
492         {0xb3, 0x01, 0x41, 0xcc},
493         {}
494 };
495
496 static const __u8 po3130_gamma[17] = {
497         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
498         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
499 };
500 static const __u8 po3130_matrix[9] = {
501         0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
502 };
503
504 static const __u8 po3130_initVGA_data[][4] = {
505         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
506         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
507         {0xb3, 0x00, 0x04, 0xcc},       {0xb3, 0x00, 0x24, 0xcc},
508         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
509         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
510         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x03, 0x1a, 0xcc},
511         {0xb3, 0x04, 0x15, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
512         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
513         {0xb3, 0x23, 0xe8, 0xcc},       {0xb8, 0x08, 0xe8, 0xcc},
514         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
515         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
516         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0xf6, 0xcc},
517         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0x71, 0xcc},
518         {0xb8, 0x00, 0x21, 0xcc},       {0xb8, 0x27, 0x20, 0xcc},
519         {0xb8, 0x01, 0x79, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
520         {0xb8, 0x2c, 0x50, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
521         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
522         {0xb8, 0x30, 0x50, 0xcc},       {0xb8, 0x31, 0xf8, 0xcc},
523         {0xb8, 0x32, 0xf8, 0xcc},       {0xb8, 0x33, 0xf8, 0xcc},
524         {0xb8, 0x34, 0x50, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
525         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
526         {0x00, 0x1e, 0xc6, 0xaa},       {0x00, 0x20, 0x44, 0xaa},
527         {0x00, 0xad, 0x02, 0xaa},       {0x00, 0xae, 0x2c, 0xaa},
528         {0x00, 0x12, 0x08, 0xaa},       {0x00, 0x17, 0x41, 0xaa},
529         {0x00, 0x19, 0x41, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
530         {0x00, 0x21, 0x00, 0xaa},       {0x00, 0x36, 0xc0, 0xaa},
531         {0x00, 0x37, 0xc8, 0xaa},       {0x00, 0x3b, 0x36, 0xaa},
532         {0x00, 0x4b, 0xfe, 0xaa},       {0x00, 0x51, 0x1c, 0xaa},
533         {0x00, 0x52, 0x01, 0xaa},       {0x00, 0x55, 0x0a, 0xaa},
534         {0x00, 0x59, 0x02, 0xaa},       {0x00, 0x5a, 0x04, 0xaa},
535         {0x00, 0x5c, 0x10, 0xaa},       {0x00, 0x5d, 0x10, 0xaa},
536         {0x00, 0x5e, 0x10, 0xaa},       {0x00, 0x5f, 0x10, 0xaa},
537         {0x00, 0x61, 0x00, 0xaa},       {0x00, 0x62, 0x18, 0xaa},
538         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x70, 0x68, 0xaa},
539         {0x00, 0x80, 0x71, 0xaa},       {0x00, 0x81, 0x08, 0xaa},
540         {0x00, 0x82, 0x00, 0xaa},       {0x00, 0x83, 0x55, 0xaa},
541         {0x00, 0x84, 0x06, 0xaa},       {0x00, 0x85, 0x06, 0xaa},
542         {0x00, 0x86, 0x13, 0xaa},       {0x00, 0x87, 0x18, 0xaa},
543         {0x00, 0xaa, 0x3f, 0xaa},       {0x00, 0xab, 0x44, 0xaa},
544         {0x00, 0xb0, 0x68, 0xaa},       {0x00, 0xb5, 0x10, 0xaa},
545         {0x00, 0xb8, 0x20, 0xaa},       {0x00, 0xb9, 0xa0, 0xaa},
546         {0x00, 0xbc, 0x04, 0xaa},       {0x00, 0x8b, 0x40, 0xaa},
547         {0x00, 0x8c, 0x91, 0xaa},       {0x00, 0x8d, 0x8f, 0xaa},
548         {0x00, 0x8e, 0x91, 0xaa},       {0x00, 0x8f, 0x43, 0xaa},
549         {0x00, 0x90, 0x92, 0xaa},       {0x00, 0x91, 0x89, 0xaa},
550         {0x00, 0x92, 0x9d, 0xaa},       {0x00, 0x93, 0x46, 0xaa},
551         {0x00, 0xd6, 0x22, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
552         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
553         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
554         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
555         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
556         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
557         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0xd6, 0x62, 0xaa},
558         {0x00, 0x73, 0x00, 0xaa},       {0x00, 0x74, 0x10, 0xaa},
559         {0x00, 0x75, 0x20, 0xaa},       {0x00, 0x76, 0x2b, 0xaa},
560         {0x00, 0x77, 0x36, 0xaa},       {0x00, 0x78, 0x49, 0xaa},
561         {0x00, 0x79, 0x5a, 0xaa},       {0x00, 0x7a, 0x7f, 0xaa},
562         {0x00, 0x7b, 0x9b, 0xaa},       {0x00, 0x7c, 0xba, 0xaa},
563         {0x00, 0x7d, 0xd4, 0xaa},       {0x00, 0x7e, 0xea, 0xaa},
564         {0x00, 0xd6, 0xa2, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
565         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
566         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
567         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
568         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
569         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
570         {0x00, 0x7e, 0xea, 0xaa},
571         {0x00, 0x4c, 0x07, 0xaa},
572         {0x00, 0x4b, 0xe0, 0xaa},       {0x00, 0x4e, 0x77, 0xaa},
573         {0x00, 0x59, 0x02, 0xaa},       {0x00, 0x4d, 0x0a, 0xaa},
574 /*      {0x00, 0xd1, 0x00, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
575         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc}, */
576         {0x00, 0xd1, 0x3c, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
577         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
578         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
579         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
580         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
581         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
582         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
583         {0xb9, 0x08, 0x3c, 0xcc},       {0x00, 0x05, 0x00, 0xaa},
584         {0xb3, 0x5c, 0x00, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
585         {}
586 };
587 static const __u8 po3130_rundata[][4] = {
588         {0x00, 0x47, 0x45, 0xaa},       {0x00, 0x48, 0x9b, 0xaa},
589         {0x00, 0x49, 0x3a, 0xaa},       {0x00, 0x4a, 0x01, 0xaa},
590         {0x00, 0x44, 0x40, 0xaa},
591 /*      {0x00, 0xd5, 0x7c, 0xaa}, */
592         {0x00, 0xad, 0x04, 0xaa},       {0x00, 0xae, 0x00, 0xaa},
593         {0x00, 0xb0, 0x78, 0xaa},       {0x00, 0x98, 0x02, 0xaa},
594         {0x00, 0x94, 0x25, 0xaa},       {0x00, 0x95, 0x25, 0xaa},
595         {0x00, 0x59, 0x68, 0xaa},       {0x00, 0x44, 0x20, 0xaa},
596         {0x00, 0x17, 0x50, 0xaa},       {0x00, 0x19, 0x50, 0xaa},
597         {0x00, 0xd1, 0x3c, 0xaa},       {0x00, 0xd1, 0x3c, 0xaa},
598         {0x00, 0x1e, 0x06, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
599         {}
600 };
601
602 static const __u8 po3130_initQVGA_data[][4] = {
603         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
604         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x09, 0xcc},
605         {0xb3, 0x00, 0x04, 0xcc},       {0xb3, 0x00, 0x24, 0xcc},
606         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
607         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
608         {0xb3, 0x06, 0x01, 0xcc},       {0xb3, 0x03, 0x1a, 0xcc},
609         {0xb3, 0x04, 0x15, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
610         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
611         {0xb3, 0x23, 0xe0, 0xcc},       {0xb8, 0x08, 0xe0, 0xcc},
612         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
613         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
614         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0xf6, 0xcc},
615         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
616         {0xb8, 0x00, 0x21, 0xcc},       {0xb8, 0x27, 0x20, 0xcc},
617         {0xb8, 0x01, 0x79, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
618         {0xb8, 0x2c, 0x50, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
619         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
620         {0xb8, 0x30, 0x50, 0xcc},       {0xb8, 0x31, 0xf8, 0xcc},
621         {0xb8, 0x32, 0xf8, 0xcc},       {0xb8, 0x33, 0xf8, 0xcc},
622         {0xb8, 0x34, 0x50, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
623         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
624         {0x00, 0x1e, 0xc6, 0xaa},       {0x00, 0x20, 0x44, 0xaa},
625         {0x00, 0xad, 0x02, 0xaa},       {0x00, 0xae, 0x2c, 0xaa},
626         {0x00, 0x12, 0x08, 0xaa},       {0x00, 0x17, 0x41, 0xaa},
627         {0x00, 0x19, 0x41, 0xaa},       {0x00, 0x1e, 0x06, 0xaa},
628         {0x00, 0x21, 0x00, 0xaa},       {0x00, 0x36, 0xc0, 0xaa},
629         {0x00, 0x37, 0xc8, 0xaa},       {0x00, 0x3b, 0x36, 0xaa},
630         {0x00, 0x4b, 0xfe, 0xaa},       {0x00, 0x51, 0x1c, 0xaa},
631         {0x00, 0x52, 0x01, 0xaa},       {0x00, 0x55, 0x0a, 0xaa},
632         {0x00, 0x59, 0x6f, 0xaa},       {0x00, 0x5a, 0x04, 0xaa},
633         {0x00, 0x5c, 0x10, 0xaa},       {0x00, 0x5d, 0x10, 0xaa},
634         {0x00, 0x5e, 0x10, 0xaa},       {0x00, 0x5f, 0x10, 0xaa},
635         {0x00, 0x61, 0x00, 0xaa},       {0x00, 0x62, 0x18, 0xaa},
636         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x70, 0x68, 0xaa},
637         {0x00, 0x80, 0x71, 0xaa},       {0x00, 0x81, 0x08, 0xaa},
638         {0x00, 0x82, 0x00, 0xaa},       {0x00, 0x83, 0x55, 0xaa},
639         {0x00, 0x84, 0x06, 0xaa},       {0x00, 0x85, 0x06, 0xaa},
640         {0x00, 0x86, 0x13, 0xaa},       {0x00, 0x87, 0x18, 0xaa},
641         {0x00, 0xaa, 0x3f, 0xaa},       {0x00, 0xab, 0x44, 0xaa},
642         {0x00, 0xb0, 0x68, 0xaa},       {0x00, 0xb5, 0x10, 0xaa},
643         {0x00, 0xb8, 0x20, 0xaa},       {0x00, 0xb9, 0xa0, 0xaa},
644         {0x00, 0xbc, 0x04, 0xaa},       {0x00, 0x8b, 0x40, 0xaa},
645         {0x00, 0x8c, 0x91, 0xaa},       {0x00, 0x8d, 0x8f, 0xaa},
646         {0x00, 0x8e, 0x91, 0xaa},       {0x00, 0x8f, 0x43, 0xaa},
647         {0x00, 0x90, 0x92, 0xaa},       {0x00, 0x91, 0x89, 0xaa},
648         {0x00, 0x92, 0x9d, 0xaa},       {0x00, 0x93, 0x46, 0xaa},
649         {0x00, 0xd6, 0x22, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
650         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
651         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
652         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
653         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
654         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
655         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0xd6, 0x62, 0xaa},
656         {0x00, 0x73, 0x00, 0xaa},       {0x00, 0x74, 0x10, 0xaa},
657         {0x00, 0x75, 0x20, 0xaa},       {0x00, 0x76, 0x2b, 0xaa},
658         {0x00, 0x77, 0x36, 0xaa},       {0x00, 0x78, 0x49, 0xaa},
659         {0x00, 0x79, 0x5a, 0xaa},       {0x00, 0x7a, 0x7f, 0xaa},
660         {0x00, 0x7b, 0x9b, 0xaa},       {0x00, 0x7c, 0xba, 0xaa},
661         {0x00, 0x7d, 0xd4, 0xaa},       {0x00, 0x7e, 0xea, 0xaa},
662         {0x00, 0xd6, 0xa2, 0xaa},       {0x00, 0x73, 0x00, 0xaa},
663         {0x00, 0x74, 0x10, 0xaa},       {0x00, 0x75, 0x20, 0xaa},
664         {0x00, 0x76, 0x2b, 0xaa},       {0x00, 0x77, 0x36, 0xaa},
665         {0x00, 0x78, 0x49, 0xaa},       {0x00, 0x79, 0x5a, 0xaa},
666         {0x00, 0x7a, 0x7f, 0xaa},       {0x00, 0x7b, 0x9b, 0xaa},
667         {0x00, 0x7c, 0xba, 0xaa},       {0x00, 0x7d, 0xd4, 0xaa},
668         {0x00, 0x7e, 0xea, 0xaa},       {0x00, 0x4c, 0x07, 0xaa},
669         {0x00, 0x4b, 0xe0, 0xaa},       {0x00, 0x4e, 0x77, 0xaa},
670         {0x00, 0x59, 0x66, 0xaa},       {0x00, 0x4d, 0x0a, 0xaa},
671         {0x00, 0xd1, 0x00, 0xaa},       {0x00, 0x20, 0xc4, 0xaa},
672         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
673         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
674         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
675         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
676         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
677         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
678         {0xb9, 0x08, 0x3c, 0xcc},       {0xbc, 0x02, 0x18, 0xcc},
679         {0xbc, 0x03, 0x50, 0xcc},       {0xbc, 0x04, 0x18, 0xcc},
680         {0xbc, 0x05, 0x00, 0xcc},       {0xbc, 0x06, 0x00, 0xcc},
681         {0xbc, 0x08, 0x30, 0xcc},       {0xbc, 0x09, 0x40, 0xcc},
682         {0xbc, 0x0a, 0x10, 0xcc},       {0xbc, 0x0b, 0x00, 0xcc},
683         {0xbc, 0x0c, 0x00, 0xcc},       {0x00, 0x05, 0x00, 0xaa},
684         {0xb3, 0x5c, 0x00, 0xcc},       {0xb3, 0x01, 0x41, 0xcc},
685         {}
686 };
687
688 static const __u8 hv7131r_gamma[17] = {
689 /*      0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
690  *      0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff */
691         0x04, 0x1a, 0x36, 0x55, 0x6f, 0x87, 0x9d, 0xb0, 0xc1,
692         0xcf, 0xda, 0xe4, 0xec, 0xf3, 0xf8, 0xfd, 0xff
693 };
694 static const __u8 hv7131r_matrix[9] = {
695         0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
696 };
697 static const __u8 hv7131r_initVGA_data[][4] = {
698         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
699         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
700         {0xb3, 0x00, 0x24, 0xcc},
701         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
702         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
703         {0xb3, 0x06, 0x01, 0xcc},
704         {0xb3, 0x01, 0x45, 0xcc},       {0xb3, 0x03, 0x0b, 0xcc},
705         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
706         {0xb3, 0x21, 0x00, 0xcc},
707         {0xb3, 0x22, 0x01, 0xcc},       {0xb3, 0x23, 0xe0, 0xcc},
708         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
709         {0xb3, 0x16, 0x02, 0xcc},
710         {0xb3, 0x17, 0x7f, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
711         {0xb3, 0x35, 0x91, 0xcc},       {0xb3, 0x00, 0x27, 0xcc},
712         {0xbc, 0x00, 0x73, 0xcc},
713         {0xb8, 0x00, 0x23, 0xcc},       {0x00, 0x01, 0x0c, 0xaa},
714         {0x00, 0x14, 0x01, 0xaa},       {0x00, 0x15, 0xe6, 0xaa},
715         {0x00, 0x16, 0x02, 0xaa},
716         {0x00, 0x17, 0x86, 0xaa},       {0x00, 0x23, 0x00, 0xaa},
717         {0x00, 0x25, 0x09, 0xaa},       {0x00, 0x26, 0x27, 0xaa},
718         {0x00, 0x27, 0xc0, 0xaa},
719         {0xb8, 0x2c, 0x60, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
720         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
721         {0xb8, 0x30, 0x50, 0xcc},
722         {0xb8, 0x31, 0xf8, 0xcc},       {0xb8, 0x32, 0xf8, 0xcc},
723         {0xb8, 0x33, 0xf8, 0xcc},       {0xb8, 0x34, 0x65, 0xcc},
724         {0xb8, 0x35, 0x00, 0xcc},
725         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
726         {0xb8, 0x27, 0x20, 0xcc},       {0xb8, 0x01, 0x7d, 0xcc},
727         {0xb8, 0x81, 0x09, 0xcc},
728         {0xb3, 0x01, 0x41, 0xcc},       {0xb8, 0xfe, 0x00, 0xcc},
729         {0xb8, 0xff, 0x28, 0xcc},       {0xb9, 0x00, 0x28, 0xcc},
730         {0xb9, 0x01, 0x28, 0xcc},
731         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
732         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
733         {0xb9, 0x06, 0x3c, 0xcc},
734         {0xb9, 0x07, 0x3c, 0xcc},       {0xb9, 0x08, 0x3c, 0xcc},
735         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
736         {0x00, 0x30, 0x18, 0xaa},
737         {}
738 };
739
740 static const __u8 hv7131r_initQVGA_data[][4] = {
741         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
742         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
743         {0xb3, 0x00, 0x24, 0xcc},
744         {0xb3, 0x00, 0x25, 0xcc},       {0xb3, 0x08, 0x01, 0xcc},
745         {0xb3, 0x09, 0x0c, 0xcc},       {0xb3, 0x05, 0x00, 0xcc},
746         {0xb3, 0x06, 0x01, 0xcc},
747         {0xb3, 0x03, 0x0b, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
748         {0xb3, 0x20, 0x00, 0xcc},       {0xb3, 0x21, 0x00, 0xcc},
749         {0xb3, 0x22, 0x01, 0xcc},
750         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x14, 0x00, 0xcc},
751         {0xb3, 0x15, 0x00, 0xcc},       {0xb3, 0x16, 0x02, 0xcc},
752         {0xb3, 0x17, 0x7f, 0xcc},
753         {0xb3, 0x34, 0x01, 0xcc},       {0xb3, 0x35, 0x91, 0xcc},
754         {0xb3, 0x00, 0x27, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
755         {0xb8, 0x00, 0x21, 0xcc},
756         {0x00, 0x01, 0x0c, 0xaa},       {0x00, 0x14, 0x01, 0xaa},
757         {0x00, 0x15, 0xe6, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
758         {0x00, 0x17, 0x86, 0xaa},
759         {0x00, 0x23, 0x00, 0xaa},       {0x00, 0x25, 0x01, 0xaa},
760         {0x00, 0x26, 0xd4, 0xaa},       {0x00, 0x27, 0xc0, 0xaa},
761         {0xbc, 0x02, 0x08, 0xcc},
762         {0xbc, 0x03, 0x70, 0xcc},       {0xbc, 0x04, 0x08, 0xcc},
763         {0xbc, 0x05, 0x00, 0xcc},       {0xbc, 0x06, 0x00, 0xcc},
764         {0xbc, 0x08, 0x3c, 0xcc},
765         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x04, 0xcc},
766         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
767         {0xb8, 0xfe, 0x02, 0xcc},
768         {0xb8, 0xff, 0x07, 0xcc},       {0xb9, 0x00, 0x14, 0xcc},
769         {0xb9, 0x01, 0x14, 0xcc},       {0xb9, 0x02, 0x14, 0xcc},
770         {0xb9, 0x03, 0x00, 0xcc},
771         {0xb9, 0x04, 0x02, 0xcc},       {0xb9, 0x05, 0x05, 0xcc},
772         {0xb9, 0x06, 0x0f, 0xcc},       {0xb9, 0x07, 0x0f, 0xcc},
773         {0xb9, 0x08, 0x0f, 0xcc},
774         {0xb8, 0x2c, 0x60, 0xcc},       {0xb8, 0x2d, 0xf8, 0xcc},
775         {0xb8, 0x2e, 0xf8, 0xcc},       {0xb8, 0x2f, 0xf8, 0xcc},
776         {0xb8, 0x30, 0x50, 0xcc},
777         {0xb8, 0x31, 0xf8, 0xcc},       {0xb8, 0x32, 0xf8, 0xcc},
778         {0xb8, 0x33, 0xf8, 0xcc},
779         {0xb8, 0x34, 0x65, 0xcc},       {0xb8, 0x35, 0x00, 0xcc},
780         {0xb8, 0x36, 0x00, 0xcc},       {0xb8, 0x37, 0x00, 0xcc},
781         {0xb8, 0x27, 0x20, 0xcc},
782         {0xb8, 0x01, 0x7d, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
783         {0xb3, 0x01, 0x41, 0xcc},       {0xb8, 0xfe, 0x00, 0xcc},
784         {0xb8, 0xff, 0x28, 0xcc},
785         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
786         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
787         {0xb9, 0x04, 0x00, 0xcc},
788         {0xb9, 0x05, 0x3c, 0xcc},       {0xb9, 0x06, 0x3c, 0xcc},
789         {0xb9, 0x07, 0x3c, 0xcc},       {0xb9, 0x08, 0x3c, 0xcc},
790         {0xb8, 0x8e, 0x00, 0xcc},
791         {0xb8, 0x8f, 0xff, 0xcc},       {0x00, 0x30, 0x18, 0xaa},
792         {}
793 };
794
795 static const __u8 ov7660_gamma[17] = {
796         0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
797         0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
798 };
799 static const __u8 ov7660_matrix[9] = {
800         0x5a, 0xf0, 0xf6, 0xf3, 0x57, 0xf6, 0xf3, 0xef, 0x62
801 };
802 static const __u8 ov7660_initVGA_data[][4] = {
803         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
804         {0x00, 0x00, 0x50, 0xdd},
805         {0xb0, 0x03, 0x01, 0xcc},
806         {0xb3, 0x00, 0x21, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
807         {0xb3, 0x05, 0x01, 0xcc},
808         {0xb3, 0x06, 0x03, 0xcc},
809         {0xb3, 0x03, 0x1f, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
810         {0xb3, 0x05, 0x00, 0xcc},
811         {0xb3, 0x06, 0x01, 0xcc},
812         {0xb3, 0x15, 0x00, 0xcc},/* 0xb315  <-0 href startl */
813         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
814         {0xb3, 0x21, 0x00, 0xcc},
815         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x1d, 0x01, 0xcc},
816         {0xb3, 0x1f, 0x02, 0xcc},
817         {0xb3, 0x34, 0x01, 0xcc},
818         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
819         {0xb8, 0x00, 0x33, 0xcc}, /* 13 */
820         {0xb8, 0x01, 0x7d, 0xcc},
821         {0xbc, 0x00, 0x73, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
822         {0xb8, 0x27, 0x20, 0xcc},
823         {0xb8, 0x8f, 0x50, 0xcc},
824         {0x00, 0x01, 0x80, 0xaa},       {0x00, 0x02, 0x80, 0xaa},
825         {0x00, 0x12, 0x80, 0xaa},
826         {0x00, 0x12, 0x05, 0xaa},
827         {0x00, 0x1e, 0x01, 0xaa},
828         {0x00, 0x3d, 0x40, 0xaa}, /* 0x3d <-40 gamma 01 */
829         {0x00, 0x41, 0x00, 0xaa}, /* edge 00 */
830         {0x00, 0x0d, 0x48, 0xaa},       {0x00, 0x0e, 0x04, 0xaa},
831         {0x00, 0x13, 0xa7, 0xaa},
832         {0x00, 0x40, 0xc1, 0xaa},       {0x00, 0x35, 0x00, 0xaa},
833         {0x00, 0x36, 0x00, 0xaa},
834         {0x00, 0x3c, 0x68, 0xaa},       {0x00, 0x1b, 0x05, 0xaa},
835         {0x00, 0x39, 0x43, 0xaa},
836         {0x00, 0x8d, 0xcf, 0xaa},
837         {0x00, 0x8b, 0xcc, 0xaa},       {0x00, 0x8c, 0xcc, 0xaa},
838         {0x00, 0x0f, 0x62, 0xaa},
839         {0x00, 0x35, 0x84, 0xaa},
840         {0x00, 0x3b, 0x08, 0xaa}, /* 0 * Nightframe 1/4 + 50Hz -> 0xC8 */
841         {0x00, 0x3a, 0x00, 0xaa}, /* mx change yuyv format 00, 04, 01; 08, 0c*/
842         {0x00, 0x14, 0x2a, 0xaa}, /* agc ampli */
843         {0x00, 0x9e, 0x40, 0xaa},       {0xb8, 0x8f, 0x50, 0xcc},
844         {0x00, 0x01, 0x80, 0xaa},
845         {0x00, 0x02, 0x80, 0xaa},
846         {0xb8, 0xfe, 0x00, 0xcc},       {0xb8, 0xff, 0x28, 0xcc},
847         {0xb9, 0x00, 0x28, 0xcc},
848         {0xb9, 0x01, 0x28, 0xcc},       {0xb9, 0x02, 0x28, 0xcc},
849         {0xb9, 0x03, 0x00, 0xcc},
850         {0xb9, 0x04, 0x00, 0xcc},
851         {0xb9, 0x05, 0x3c, 0xcc},       {0xb9, 0x06, 0x3c, 0xcc},
852         {0xb9, 0x07, 0x3c, 0xcc},
853         {0xb9, 0x08, 0x3c, 0xcc},
854
855         {0xb8, 0x8e, 0x00, 0xcc},       {0xb8, 0x8f, 0xff, 0xcc},
856
857         {0x00, 0x29, 0x3c, 0xaa},       {0xb3, 0x01, 0x45, 0xcc},
858         {}
859 };
860 static const __u8 ov7660_initQVGA_data[][4] = {
861         {0xb0, 0x4d, 0x00, 0xcc},       {0xb3, 0x01, 0x01, 0xcc},
862         {0x00, 0x00, 0x50, 0xdd},       {0xb0, 0x03, 0x01, 0xcc},
863         {0xb3, 0x00, 0x21, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
864         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x03, 0xcc},
865         {0xb3, 0x03, 0x1f, 0xcc},       {0xb3, 0x04, 0x05, 0xcc},
866         {0xb3, 0x05, 0x00, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
867         {0xb3, 0x15, 0x00, 0xcc},/* 0xb315  <-0 href startl */
868         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
869         {0xb3, 0x21, 0x00, 0xcc},
870         {0xb3, 0x23, 0xe0, 0xcc},       {0xb3, 0x1d, 0x01, 0xcc},
871         {0xb3, 0x1f, 0x02, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
872         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x00, 0x26, 0xcc},
873         {0xb8, 0x00, 0x33, 0xcc}, /* 13 */
874         {0xb8, 0x01, 0x7d, 0xcc},
875 /* sizer */
876         {0xbc, 0x00, 0xd3, 0xcc},
877         {0xb8, 0x81, 0x09, 0xcc},       {0xb8, 0x81, 0x09, 0xcc},
878         {0xb8, 0x27, 0x20, 0xcc},       {0xb8, 0x8f, 0x50, 0xcc},
879         {0x00, 0x01, 0x80, 0xaa},       {0x00, 0x02, 0x80, 0xaa},
880         {0x00, 0x12, 0x80, 0xaa},       {0x00, 0x12, 0x05, 0xaa},
881         {0x00, 0x1e, 0x01, 0xaa},
882         {0x00, 0x3d, 0x40, 0xaa}, /* 0x3d <-40 gamma 01 */
883         {0x00, 0x41, 0x00, 0xaa}, /* edge 00 */
884         {0x00, 0x0d, 0x48, 0xaa},       {0x00, 0x0e, 0x04, 0xaa},
885         {0x00, 0x13, 0xa7, 0xaa},
886         {0x00, 0x40, 0xc1, 0xaa},       {0x00, 0x35, 0x00, 0xaa},
887         {0x00, 0x36, 0x00, 0xaa},
888         {0x00, 0x3c, 0x68, 0xaa},       {0x00, 0x1b, 0x05, 0xaa},
889         {0x00, 0x39, 0x43, 0xaa},       {0x00, 0x8d, 0xcf, 0xaa},
890         {0x00, 0x8b, 0xcc, 0xaa},       {0x00, 0x8c, 0xcc, 0xaa},
891         {0x00, 0x0f, 0x62, 0xaa},       {0x00, 0x35, 0x84, 0xaa},
892         {0x00, 0x3b, 0x08, 0xaa}, /* 0  * Nightframe 1/4 + 50Hz -> 0xC8 */
893         {0x00, 0x3a, 0x00, 0xaa}, /* mx change yuyv format 00, 04, 01; 08, 0c*/
894         {0x00, 0x14, 0x2a, 0xaa}, /* agc ampli */
895         {0x00, 0x9e, 0x40, 0xaa},       {0xb8, 0x8f, 0x50, 0xcc},
896         {0x00, 0x01, 0x80, 0xaa},
897         {0x00, 0x02, 0x80, 0xaa},
898 /* sizer filters */
899         {0xbc, 0x02, 0x08, 0xcc},
900         {0xbc, 0x03, 0x70, 0xcc},
901         {0xb8, 0x35, 0x00, 0xcc},
902         {0xb8, 0x36, 0x00, 0xcc},
903         {0xb8, 0x37, 0x00, 0xcc},
904         {0xbc, 0x04, 0x08, 0xcc},
905         {0xbc, 0x05, 0x00, 0xcc},
906         {0xbc, 0x06, 0x00, 0xcc},
907         {0xbc, 0x08, 0x3c, 0xcc},
908         {0xbc, 0x09, 0x40, 0xcc},
909         {0xbc, 0x0a, 0x04, 0xcc},
910         {0xbc, 0x0b, 0x00, 0xcc},
911         {0xbc, 0x0c, 0x00, 0xcc},
912 /* */
913         {0xb8, 0xfe, 0x00, 0xcc},
914         {0xb8, 0xff, 0x28, 0xcc},
915 /* */
916         {0xb9, 0x00, 0x28, 0xcc},       {0xb9, 0x01, 0x28, 0xcc},
917         {0xb9, 0x02, 0x28, 0xcc},       {0xb9, 0x03, 0x00, 0xcc},
918         {0xb9, 0x04, 0x00, 0xcc},       {0xb9, 0x05, 0x3c, 0xcc},
919         {0xb9, 0x06, 0x3c, 0xcc},       {0xb9, 0x07, 0x3c, 0xcc},
920         {0xb9, 0x08, 0x3c, 0xcc},
921 /* */
922         {0xb8, 0x8e, 0x00, 0xcc},
923         {0xb8, 0x8f, 0xff, 0xcc}, /* ff */
924         {0x00, 0x29, 0x3c, 0xaa},
925         {0xb3, 0x01, 0x45, 0xcc}, /* 45 */
926         {}
927 };
928
929 static const __u8 ov7660_50HZ[][4] = {
930         {0x00, 0x3b, 0x08, 0xaa},
931         {0x00, 0x9d, 0x40, 0xaa},
932         {0x00, 0x13, 0xa7, 0xaa},
933         {}
934 };
935
936 static const __u8 ov7660_60HZ[][4] = {
937         {0x00, 0x3b, 0x00, 0xaa},
938         {0x00, 0x9e, 0x40, 0xaa},
939         {0x00, 0x13, 0xa7, 0xaa},
940         {}
941 };
942
943 static const __u8 ov7660_NoFliker[][4] = {
944         {0x00, 0x13, 0x87, 0xaa},
945         {}
946 };
947
948 static const __u8 ov7670_initVGA_JPG[][4] = {
949         {0xb3, 0x01, 0x05, 0xcc},
950         {0x00, 0x00, 0x30, 0xdd},       {0xb0, 0x03, 0x19, 0xcc},
951         {0x00, 0x00, 0x10, 0xdd},
952         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
953         {0xb3, 0x00, 0x66, 0xcc},       {0xb3, 0x00, 0x67, 0xcc},
954         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
955         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
956         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
957         {0xb3, 0x02, 0x02, 0xcc},       {0xb3, 0x03, 0x1f, 0xcc},
958         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
959         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
960         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
961         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
962         {0xb3, 0x23, 0xe0, 0xcc},       {0xbc, 0x00, 0x41, 0xcc},
963         {0xbc, 0x01, 0x01, 0xcc},       {0x00, 0x12, 0x80, 0xaa},
964         {0x00, 0x00, 0x20, 0xdd},       {0x00, 0x12, 0x00, 0xaa},
965         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x6b, 0x0a, 0xaa},
966         {0x00, 0x3a, 0x04, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
967         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x7a, 0x29, 0xaa},
968         {0x00, 0x7b, 0x0e, 0xaa},       {0x00, 0x7c, 0x1a, 0xaa},
969         {0x00, 0x7d, 0x31, 0xaa},       {0x00, 0x7e, 0x53, 0xaa},
970         {0x00, 0x7f, 0x60, 0xaa},       {0x00, 0x80, 0x6b, 0xaa},
971         {0x00, 0x81, 0x73, 0xaa},       {0x00, 0x82, 0x7b, 0xaa},
972         {0x00, 0x83, 0x82, 0xaa},       {0x00, 0x84, 0x89, 0xaa},
973         {0x00, 0x85, 0x96, 0xaa},       {0x00, 0x86, 0xa1, 0xaa},
974         {0x00, 0x87, 0xb7, 0xaa},       {0x00, 0x88, 0xcc, 0xaa},
975         {0x00, 0x89, 0xe1, 0xaa},       {0x00, 0x13, 0xe0, 0xaa},
976         {0x00, 0x00, 0x00, 0xaa},       {0x00, 0x10, 0x00, 0xaa},
977         {0x00, 0x0d, 0x40, 0xaa},       {0x00, 0x14, 0x28, 0xaa},
978         {0x00, 0xa5, 0x05, 0xaa},       {0x00, 0xab, 0x07, 0xaa},
979         {0x00, 0x24, 0x95, 0xaa},       {0x00, 0x25, 0x33, 0xaa},
980         {0x00, 0x26, 0xe3, 0xaa},       {0x00, 0x9f, 0x88, 0xaa},
981         {0x00, 0xa0, 0x78, 0xaa},       {0x00, 0x55, 0x90, 0xaa},
982         {0x00, 0xa1, 0x03, 0xaa},       {0x00, 0xa6, 0xe0, 0xaa},
983         {0x00, 0xa7, 0xd8, 0xaa},       {0x00, 0xa8, 0xf0, 0xaa},
984         {0x00, 0xa9, 0x90, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
985         {0x00, 0x13, 0xe5, 0xaa},       {0x00, 0x0e, 0x61, 0xaa},
986         {0x00, 0x0f, 0x4b, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
987         {0x00, 0x1e, 0x07, 0xaa},       {0x00, 0x21, 0x02, 0xaa},
988         {0x00, 0x22, 0x91, 0xaa},       {0x00, 0x29, 0x07, 0xaa},
989         {0x00, 0x33, 0x0b, 0xaa},       {0x00, 0x35, 0x0b, 0xaa},
990         {0x00, 0x37, 0x1d, 0xaa},       {0x00, 0x38, 0x71, 0xaa},
991         {0x00, 0x39, 0x2a, 0xaa},       {0x00, 0x3c, 0x78, 0xaa},
992         {0x00, 0x4d, 0x40, 0xaa},       {0x00, 0x4e, 0x20, 0xaa},
993         {0x00, 0x74, 0x19, 0xaa},       {0x00, 0x8d, 0x4f, 0xaa},
994         {0x00, 0x8e, 0x00, 0xaa},       {0x00, 0x8f, 0x00, 0xaa},
995         {0x00, 0x90, 0x00, 0xaa},       {0x00, 0x91, 0x00, 0xaa},
996         {0x00, 0x96, 0x00, 0xaa},       {0x00, 0x9a, 0x80, 0xaa},
997         {0x00, 0xb0, 0x84, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
998         {0x00, 0xb2, 0x0e, 0xaa},       {0x00, 0xb3, 0x82, 0xaa},
999         {0x00, 0xb8, 0x0a, 0xaa},       {0x00, 0x43, 0x14, 0xaa},
1000         {0x00, 0x44, 0xf0, 0xaa},       {0x00, 0x45, 0x45, 0xaa},
1001         {0x00, 0x46, 0x63, 0xaa},       {0x00, 0x47, 0x2d, 0xaa},
1002         {0x00, 0x48, 0x46, 0xaa},       {0x00, 0x59, 0x88, 0xaa},
1003         {0x00, 0x5a, 0xa0, 0xaa},       {0x00, 0x5b, 0xc6, 0xaa},
1004         {0x00, 0x5c, 0x7d, 0xaa},       {0x00, 0x5d, 0x5f, 0xaa},
1005         {0x00, 0x5e, 0x19, 0xaa},       {0x00, 0x6c, 0x0a, 0xaa},
1006         {0x00, 0x6d, 0x55, 0xaa},       {0x00, 0x6e, 0x11, 0xaa},
1007         {0x00, 0x6f, 0x9e, 0xaa},       {0x00, 0x69, 0x00, 0xaa},
1008         {0x00, 0x6a, 0x40, 0xaa},       {0x00, 0x01, 0x40, 0xaa},
1009         {0x00, 0x02, 0x40, 0xaa},       {0x00, 0x13, 0xe7, 0xaa},
1010         {0x00, 0x5f, 0xf0, 0xaa},       {0x00, 0x60, 0xf0, 0xaa},
1011         {0x00, 0x61, 0xf0, 0xaa},       {0x00, 0x27, 0xa0, 0xaa},
1012         {0x00, 0x28, 0x80, 0xaa},       {0x00, 0x2c, 0x90, 0xaa},
1013         {0x00, 0x4f, 0x66, 0xaa},       {0x00, 0x50, 0x66, 0xaa},
1014         {0x00, 0x51, 0x00, 0xaa},       {0x00, 0x52, 0x22, 0xaa},
1015         {0x00, 0x53, 0x5e, 0xaa},       {0x00, 0x54, 0x80, 0xaa},
1016         {0x00, 0x58, 0x9e, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1017         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x85, 0xaa},
1018         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1019         {0x00, 0x77, 0x0a, 0xaa},       {0x00, 0x3d, 0x88, 0xaa},
1020         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1021         {0x00, 0x41, 0x38, 0xaa},       {0x00, 0x62, 0x30, 0xaa},
1022         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1023         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x0b, 0xaa},
1024         {0x00, 0x65, 0x00, 0xaa},       {0x00, 0x66, 0x05, 0xaa},
1025         {0x00, 0x56, 0x50, 0xaa},       {0x00, 0x34, 0x11, 0xaa},
1026         {0x00, 0xa4, 0x88, 0xaa},       {0x00, 0x96, 0x00, 0xaa},
1027         {0x00, 0x97, 0x30, 0xaa},       {0x00, 0x98, 0x20, 0xaa},
1028         {0x00, 0x99, 0x30, 0xaa},       {0x00, 0x9a, 0x84, 0xaa},
1029         {0x00, 0x9b, 0x29, 0xaa},       {0x00, 0x9c, 0x03, 0xaa},
1030         {0x00, 0x78, 0x04, 0xaa},       {0x00, 0x79, 0x01, 0xaa},
1031         {0x00, 0xc8, 0xf0, 0xaa},       {0x00, 0x79, 0x0f, 0xaa},
1032         {0x00, 0xc8, 0x00, 0xaa},       {0x00, 0x79, 0x10, 0xaa},
1033         {0x00, 0xc8, 0x7e, 0xaa},       {0x00, 0x79, 0x0a, 0xaa},
1034         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x0b, 0xaa},
1035         {0x00, 0xc8, 0x01, 0xaa},       {0x00, 0x79, 0x0c, 0xaa},
1036         {0x00, 0xc8, 0x0f, 0xaa},       {0x00, 0x79, 0x0d, 0xaa},
1037         {0x00, 0xc8, 0x20, 0xaa},       {0x00, 0x79, 0x09, 0xaa},
1038         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x02, 0xaa},
1039         {0x00, 0xc8, 0xc0, 0xaa},       {0x00, 0x79, 0x03, 0xaa},
1040         {0x00, 0xc8, 0x40, 0xaa},       {0x00, 0x79, 0x05, 0xaa},
1041         {0x00, 0xc8, 0x30, 0xaa},       {0x00, 0x79, 0x26, 0xaa},
1042         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x3a, 0x04, 0xaa},
1043         {0x00, 0x12, 0x00, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1044         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x17, 0x14, 0xaa},
1045         {0x00, 0x18, 0x02, 0xaa},       {0x00, 0x32, 0x92, 0xaa},
1046         {0x00, 0x19, 0x02, 0xaa},       {0x00, 0x1a, 0x7a, 0xaa},
1047         {0x00, 0x03, 0x0a, 0xaa},       {0x00, 0x0c, 0x00, 0xaa},
1048         {0x00, 0x3e, 0x00, 0xaa},       {0x00, 0x70, 0x3a, 0xaa},
1049         {0x00, 0x71, 0x35, 0xaa},       {0x00, 0x72, 0x11, 0xaa},
1050         {0x00, 0x73, 0xf0, 0xaa},       {0x00, 0xa2, 0x02, 0xaa},
1051         {0x00, 0xb1, 0x00, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1052         {0x00, 0x1e, 0x37, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
1053         {0x00, 0x24, 0x80, 0xaa},       {0x00, 0x25, 0x74, 0xaa},
1054         {0x00, 0x26, 0xd3, 0xaa},       {0x00, 0x0d, 0x00, 0xaa},
1055         {0x00, 0x14, 0x18, 0xaa},       {0x00, 0x9d, 0x99, 0xaa},
1056         {0x00, 0x9e, 0x7f, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1057         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x06, 0xaa},
1058         {0x00, 0x66, 0x05, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1059         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x07, 0xaa},
1060         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1061         {0x00, 0x77, 0x00, 0xaa},       {0x00, 0x3d, 0xc2, 0xaa},
1062         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1063         {0x00, 0x41, 0x38, 0xaa},       {0xb6, 0x00, 0x00, 0xcc},
1064         {0xb6, 0x03, 0x02, 0xcc},       {0xb6, 0x02, 0x80, 0xcc},
1065         {0xb6, 0x05, 0x01, 0xcc},       {0xb6, 0x04, 0xe0, 0xcc},
1066         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x13, 0xcc},
1067         {0xb6, 0x18, 0x02, 0xcc},       {0xb6, 0x17, 0x58, 0xcc},
1068         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
1069         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
1070         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
1071         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x45, 0xcc},
1072         {0x00, 0x77, 0x05, 0xaa},
1073         {},
1074 };
1075
1076 static const __u8 ov7670_initQVGA_JPG[][4] = {
1077         {0xb3, 0x01, 0x05, 0xcc},       {0x00, 0x00, 0x30, 0xdd},
1078         {0xb0, 0x03, 0x19, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
1079         {0xb0, 0x04, 0x02, 0xcc},       {0x00, 0x00, 0x10, 0xdd},
1080         {0xb3, 0x00, 0x66, 0xcc},       {0xb3, 0x00, 0x67, 0xcc},
1081         {0xb3, 0x35, 0xa1, 0xcc},       {0xb3, 0x34, 0x01, 0xcc},
1082         {0xb3, 0x05, 0x01, 0xcc},       {0xb3, 0x06, 0x01, 0xcc},
1083         {0xb3, 0x08, 0x01, 0xcc},       {0xb3, 0x09, 0x0c, 0xcc},
1084         {0xb3, 0x02, 0x02, 0xcc},       {0xb3, 0x03, 0x1f, 0xcc},
1085         {0xb3, 0x14, 0x00, 0xcc},       {0xb3, 0x15, 0x00, 0xcc},
1086         {0xb3, 0x16, 0x02, 0xcc},       {0xb3, 0x17, 0x7f, 0xcc},
1087         {0xb3, 0x04, 0x05, 0xcc},       {0xb3, 0x20, 0x00, 0xcc},
1088         {0xb3, 0x21, 0x00, 0xcc},       {0xb3, 0x22, 0x01, 0xcc},
1089         {0xb3, 0x23, 0xe0, 0xcc},       {0xbc, 0x00, 0xd1, 0xcc},
1090         {0xbc, 0x01, 0x01, 0xcc},       {0x00, 0x12, 0x80, 0xaa},
1091         {0x00, 0x00, 0x20, 0xdd},       {0x00, 0x12, 0x00, 0xaa},
1092         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x6b, 0x0a, 0xaa},
1093         {0x00, 0x3a, 0x04, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1094         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x7a, 0x29, 0xaa},
1095         {0x00, 0x7b, 0x0e, 0xaa},       {0x00, 0x7c, 0x1a, 0xaa},
1096         {0x00, 0x7d, 0x31, 0xaa},       {0x00, 0x7e, 0x53, 0xaa},
1097         {0x00, 0x7f, 0x60, 0xaa},       {0x00, 0x80, 0x6b, 0xaa},
1098         {0x00, 0x81, 0x73, 0xaa},       {0x00, 0x82, 0x7b, 0xaa},
1099         {0x00, 0x83, 0x82, 0xaa},       {0x00, 0x84, 0x89, 0xaa},
1100         {0x00, 0x85, 0x96, 0xaa},       {0x00, 0x86, 0xa1, 0xaa},
1101         {0x00, 0x87, 0xb7, 0xaa},       {0x00, 0x88, 0xcc, 0xaa},
1102         {0x00, 0x89, 0xe1, 0xaa},       {0x00, 0x13, 0xe0, 0xaa},
1103         {0x00, 0x00, 0x00, 0xaa},       {0x00, 0x10, 0x00, 0xaa},
1104         {0x00, 0x0d, 0x40, 0xaa},       {0x00, 0x14, 0x28, 0xaa},
1105         {0x00, 0xa5, 0x05, 0xaa},       {0x00, 0xab, 0x07, 0xaa},
1106         {0x00, 0x24, 0x95, 0xaa},       {0x00, 0x25, 0x33, 0xaa},
1107         {0x00, 0x26, 0xe3, 0xaa},       {0x00, 0x9f, 0x88, 0xaa},
1108         {0x00, 0xa0, 0x78, 0xaa},       {0x00, 0x55, 0x90, 0xaa},
1109         {0x00, 0xa1, 0x03, 0xaa},       {0x00, 0xa6, 0xe0, 0xaa},
1110         {0x00, 0xa7, 0xd8, 0xaa},       {0x00, 0xa8, 0xf0, 0xaa},
1111         {0x00, 0xa9, 0x90, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
1112         {0x00, 0x13, 0xe5, 0xaa},       {0x00, 0x0e, 0x61, 0xaa},
1113         {0x00, 0x0f, 0x4b, 0xaa},       {0x00, 0x16, 0x02, 0xaa},
1114         {0x00, 0x1e, 0x07, 0xaa},       {0x00, 0x21, 0x02, 0xaa},
1115         {0x00, 0x22, 0x91, 0xaa},       {0x00, 0x29, 0x07, 0xaa},
1116         {0x00, 0x33, 0x0b, 0xaa},       {0x00, 0x35, 0x0b, 0xaa},
1117         {0x00, 0x37, 0x1d, 0xaa},       {0x00, 0x38, 0x71, 0xaa},
1118         {0x00, 0x39, 0x2a, 0xaa},       {0x00, 0x3c, 0x78, 0xaa},
1119         {0x00, 0x4d, 0x40, 0xaa},       {0x00, 0x4e, 0x20, 0xaa},
1120         {0x00, 0x74, 0x19, 0xaa},       {0x00, 0x8d, 0x4f, 0xaa},
1121         {0x00, 0x8e, 0x00, 0xaa},       {0x00, 0x8f, 0x00, 0xaa},
1122         {0x00, 0x90, 0x00, 0xaa},       {0x00, 0x91, 0x00, 0xaa},
1123         {0x00, 0x96, 0x00, 0xaa},       {0x00, 0x9a, 0x80, 0xaa},
1124         {0x00, 0xb0, 0x84, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1125         {0x00, 0xb2, 0x0e, 0xaa},       {0x00, 0xb3, 0x82, 0xaa},
1126         {0x00, 0xb8, 0x0a, 0xaa},       {0x00, 0x43, 0x14, 0xaa},
1127         {0x00, 0x44, 0xf0, 0xaa},       {0x00, 0x45, 0x45, 0xaa},
1128         {0x00, 0x46, 0x63, 0xaa},       {0x00, 0x47, 0x2d, 0xaa},
1129         {0x00, 0x48, 0x46, 0xaa},       {0x00, 0x59, 0x88, 0xaa},
1130         {0x00, 0x5a, 0xa0, 0xaa},       {0x00, 0x5b, 0xc6, 0xaa},
1131         {0x00, 0x5c, 0x7d, 0xaa},       {0x00, 0x5d, 0x5f, 0xaa},
1132         {0x00, 0x5e, 0x19, 0xaa},       {0x00, 0x6c, 0x0a, 0xaa},
1133         {0x00, 0x6d, 0x55, 0xaa},       {0x00, 0x6e, 0x11, 0xaa},
1134         {0x00, 0x6f, 0x9e, 0xaa},       {0x00, 0x69, 0x00, 0xaa},
1135         {0x00, 0x6a, 0x40, 0xaa},       {0x00, 0x01, 0x40, 0xaa},
1136         {0x00, 0x02, 0x40, 0xaa},       {0x00, 0x13, 0xe7, 0xaa},
1137         {0x00, 0x5f, 0xf0, 0xaa},       {0x00, 0x60, 0xf0, 0xaa},
1138         {0x00, 0x61, 0xf0, 0xaa},       {0x00, 0x27, 0xa0, 0xaa},
1139         {0x00, 0x28, 0x80, 0xaa},       {0x00, 0x2c, 0x90, 0xaa},
1140         {0x00, 0x4f, 0x66, 0xaa},       {0x00, 0x50, 0x66, 0xaa},
1141         {0x00, 0x51, 0x00, 0xaa},       {0x00, 0x52, 0x22, 0xaa},
1142         {0x00, 0x53, 0x5e, 0xaa},       {0x00, 0x54, 0x80, 0xaa},
1143         {0x00, 0x58, 0x9e, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1144         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x85, 0xaa},
1145         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1146         {0x00, 0x77, 0x0a, 0xaa},       {0x00, 0x3d, 0x88, 0xaa},
1147         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1148         {0x00, 0x41, 0x38, 0xaa},       {0x00, 0x62, 0x30, 0xaa},
1149         {0x00, 0x63, 0x30, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1150         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x0b, 0xaa},
1151         {0x00, 0x65, 0x00, 0xaa},       {0x00, 0x66, 0x05, 0xaa},
1152         {0x00, 0x56, 0x50, 0xaa},       {0x00, 0x34, 0x11, 0xaa},
1153         {0x00, 0xa4, 0x88, 0xaa},       {0x00, 0x96, 0x00, 0xaa},
1154         {0x00, 0x97, 0x30, 0xaa},       {0x00, 0x98, 0x20, 0xaa},
1155         {0x00, 0x99, 0x30, 0xaa},       {0x00, 0x9a, 0x84, 0xaa},
1156         {0x00, 0x9b, 0x29, 0xaa},       {0x00, 0x9c, 0x03, 0xaa},
1157         {0x00, 0x78, 0x04, 0xaa},       {0x00, 0x79, 0x01, 0xaa},
1158         {0x00, 0xc8, 0xf0, 0xaa},       {0x00, 0x79, 0x0f, 0xaa},
1159         {0x00, 0xc8, 0x00, 0xaa},       {0x00, 0x79, 0x10, 0xaa},
1160         {0x00, 0xc8, 0x7e, 0xaa},       {0x00, 0x79, 0x0a, 0xaa},
1161         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x0b, 0xaa},
1162         {0x00, 0xc8, 0x01, 0xaa},       {0x00, 0x79, 0x0c, 0xaa},
1163         {0x00, 0xc8, 0x0f, 0xaa},       {0x00, 0x79, 0x0d, 0xaa},
1164         {0x00, 0xc8, 0x20, 0xaa},       {0x00, 0x79, 0x09, 0xaa},
1165         {0x00, 0xc8, 0x80, 0xaa},       {0x00, 0x79, 0x02, 0xaa},
1166         {0x00, 0xc8, 0xc0, 0xaa},       {0x00, 0x79, 0x03, 0xaa},
1167         {0x00, 0xc8, 0x40, 0xaa},       {0x00, 0x79, 0x05, 0xaa},
1168         {0x00, 0xc8, 0x30, 0xaa},       {0x00, 0x79, 0x26, 0xaa},
1169         {0x00, 0x11, 0x40, 0xaa},       {0x00, 0x3a, 0x04, 0xaa},
1170         {0x00, 0x12, 0x00, 0xaa},       {0x00, 0x40, 0xc0, 0xaa},
1171         {0x00, 0x8c, 0x00, 0xaa},       {0x00, 0x17, 0x14, 0xaa},
1172         {0x00, 0x18, 0x02, 0xaa},       {0x00, 0x32, 0x92, 0xaa},
1173         {0x00, 0x19, 0x02, 0xaa},       {0x00, 0x1a, 0x7a, 0xaa},
1174         {0x00, 0x03, 0x0a, 0xaa},       {0x00, 0x0c, 0x00, 0xaa},
1175         {0x00, 0x3e, 0x00, 0xaa},       {0x00, 0x70, 0x3a, 0xaa},
1176         {0x00, 0x71, 0x35, 0xaa},       {0x00, 0x72, 0x11, 0xaa},
1177         {0x00, 0x73, 0xf0, 0xaa},       {0x00, 0xa2, 0x02, 0xaa},
1178         {0x00, 0xb1, 0x00, 0xaa},       {0x00, 0xb1, 0x0c, 0xaa},
1179         {0x00, 0x1e, 0x37, 0xaa},       {0x00, 0xaa, 0x14, 0xaa},
1180         {0x00, 0x24, 0x80, 0xaa},       {0x00, 0x25, 0x74, 0xaa},
1181         {0x00, 0x26, 0xd3, 0xaa},       {0x00, 0x0d, 0x00, 0xaa},
1182         {0x00, 0x14, 0x18, 0xaa},       {0x00, 0x9d, 0x99, 0xaa},
1183         {0x00, 0x9e, 0x7f, 0xaa},       {0x00, 0x64, 0x08, 0xaa},
1184         {0x00, 0x94, 0x07, 0xaa},       {0x00, 0x95, 0x06, 0xaa},
1185         {0x00, 0x66, 0x05, 0xaa},       {0x00, 0x41, 0x08, 0xaa},
1186         {0x00, 0x3f, 0x00, 0xaa},       {0x00, 0x75, 0x07, 0xaa},
1187         {0x00, 0x76, 0xe1, 0xaa},       {0x00, 0x4c, 0x00, 0xaa},
1188         {0x00, 0x77, 0x00, 0xaa},       {0x00, 0x3d, 0xc2, 0xaa},
1189         {0x00, 0x4b, 0x09, 0xaa},       {0x00, 0xc9, 0x60, 0xaa},
1190         {0x00, 0x41, 0x38, 0xaa},       {0xb6, 0x00, 0x00, 0xcc},
1191         {0xb6, 0x03, 0x01, 0xcc},       {0xb6, 0x02, 0x40, 0xcc},
1192         {0xb6, 0x05, 0x00, 0xcc},       {0xb6, 0x04, 0xf0, 0xcc},
1193         {0xb6, 0x12, 0xf8, 0xcc},       {0xb6, 0x13, 0x21, 0xcc},
1194         {0xb6, 0x18, 0x00, 0xcc},       {0xb6, 0x17, 0x96, 0xcc},
1195         {0xb6, 0x16, 0x00, 0xcc},       {0xb6, 0x22, 0x12, 0xcc},
1196         {0xb6, 0x23, 0x0b, 0xcc},       {0xbf, 0xc0, 0x39, 0xcc},
1197         {0xbf, 0xc1, 0x04, 0xcc},       {0xbf, 0xcc, 0x00, 0xcc},
1198         {0xbc, 0x02, 0x18, 0xcc},       {0xbc, 0x03, 0x50, 0xcc},
1199         {0xbc, 0x04, 0x18, 0xcc},       {0xbc, 0x05, 0x00, 0xcc},
1200         {0xbc, 0x06, 0x00, 0xcc},       {0xbc, 0x08, 0x30, 0xcc},
1201         {0xbc, 0x09, 0x40, 0xcc},       {0xbc, 0x0a, 0x10, 0xcc},
1202         {0xbc, 0x0b, 0x00, 0xcc},       {0xbc, 0x0c, 0x00, 0xcc},
1203         {0xb3, 0x5c, 0x01, 0xcc},       {0xb3, 0x01, 0x45, 0xcc},
1204         {0x00, 0x77, 0x05, 0xaa },
1205         {},
1206 };
1207
1208 struct sensor_info {
1209         int sensorId;
1210         __u8 I2cAdd;
1211         __u8 IdAdd;
1212         __u16 VpId;
1213         __u8 m1;
1214         __u8 m2;
1215         __u8 op;
1216         };
1217
1218 static const struct sensor_info sensor_info_data[] = {
1219 /*      sensorId,         I2cAdd,       IdAdd,  VpId,  m1,    m2,  op */
1220         {SENSOR_HV7131R,    0x80 | 0x11, 0x00, 0x0209, 0x24, 0x25, 0x01},
1221         {SENSOR_OV7660,     0x80 | 0x21, 0x0a, 0x7660, 0x26, 0x26, 0x05},
1222         {SENSOR_PO3130NC,   0x80 | 0x76, 0x00, 0x3130, 0x24, 0x25, 0x01},
1223         {SENSOR_MI1320,     0x80 | 0xc8, 0x00, 0x148c, 0x64, 0x65, 0x01},
1224         {SENSOR_OV7670,     0x80 | 0x21, 0x0a, 0x7673, 0x66, 0x67, 0x05},
1225         {SENSOR_MI1310_SOC, 0x80 | 0x5d, 0x00, 0x143a, 0x24, 0x25, 0x01},
1226 };
1227
1228 /* read 'len' bytes in gspca_dev->usb_buf */
1229 static void reg_r(struct gspca_dev *gspca_dev,
1230                   __u16 req,
1231                   __u16 index,
1232                   __u16 len)
1233 {
1234         usb_control_msg(gspca_dev->dev,
1235                         usb_rcvctrlpipe(gspca_dev->dev, 0),
1236                         req,
1237                         USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1238                         1,                      /* value */
1239                         index, gspca_dev->usb_buf, len,
1240                         500);
1241 }
1242
1243 static void reg_w(struct usb_device *dev,
1244                             __u16 req,
1245                             __u16 value,
1246                             __u16 index)
1247 {
1248         usb_control_msg(dev,
1249                         usb_sndctrlpipe(dev, 0),
1250                         req,
1251                         USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1252                         value, index, NULL, 0,
1253                         500);
1254 }
1255
1256 static void read_sensor_register(struct gspca_dev *gspca_dev,
1257                                 __u16 address, __u16 *value)
1258 {
1259         struct usb_device *dev = gspca_dev->dev;
1260         __u8 ldata, mdata, hdata;
1261         int retry = 50;
1262
1263         *value = 0;
1264
1265         reg_r(gspca_dev, 0xa1, 0xb33f, 1);
1266         /*PDEBUG(D_PROBE, " I2c Bus Busy Wait  0x%02X ", tmpvalue); */
1267         if (!(gspca_dev->usb_buf[0] & 0x02)) {
1268                 PDEBUG(D_ERR, "I2c Bus Busy Wait %d",
1269                         gspca_dev->usb_buf[0] & 0x02);
1270                 return;
1271         }
1272         reg_w(dev, 0xa0, address, 0xb33a);
1273         reg_w(dev, 0xa0, 0x02, 0xb339);
1274
1275         reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1276         while (retry-- && gspca_dev->usb_buf[0]) {
1277                 reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1278 /*              PDEBUG(D_PROBE, "Read again 0xb33b %d", tmpvalue); */
1279                 msleep(1);
1280         }
1281         reg_r(gspca_dev, 0xa1, 0xb33e, 1);
1282         hdata = gspca_dev->usb_buf[0];
1283         reg_r(gspca_dev, 0xa1, 0xb33d, 1);
1284         mdata = gspca_dev->usb_buf[0];
1285         reg_r(gspca_dev, 0xa1, 0xb33c, 1);
1286         ldata = gspca_dev->usb_buf[0];
1287         PDEBUG(D_PROBE, "Read Sensor h (0x%02X) m (0x%02X) l (0x%02X)",
1288                 hdata, mdata, ldata);
1289         reg_r(gspca_dev, 0xa1, 0xb334, 1);
1290         if (gspca_dev->usb_buf[0] == 0x02)
1291                 *value = (ldata << 8) + mdata;
1292         else
1293                 *value = ldata;
1294 }
1295
1296 static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
1297 {
1298         struct usb_device *dev = gspca_dev->dev;
1299         int i;
1300         __u16 value;
1301         const struct sensor_info *ptsensor_info;
1302
1303         reg_r(gspca_dev, 0xa1, 0xbfcf, 1);
1304         PDEBUG(D_PROBE, "check sensor header %d", gspca_dev->usb_buf[0]);
1305         for (i = 0; i < ARRAY_SIZE(sensor_info_data); i++) {
1306                 ptsensor_info = &sensor_info_data[i];
1307                 reg_w(dev, 0xa0, 0x02, 0xb334);
1308                 reg_w(dev, 0xa0, ptsensor_info->m1, 0xb300);
1309                 reg_w(dev, 0xa0, ptsensor_info->m2, 0xb300);
1310                 reg_w(dev, 0xa0, 0x01, 0xb308);
1311                 reg_w(dev, 0xa0, 0x0c, 0xb309);
1312                 reg_w(dev, 0xa0, ptsensor_info->I2cAdd, 0xb335);
1313 /*              PDEBUG(D_PROBE,
1314                         "check sensor VC032X -> %d Add -> ox%02X!",
1315                         i, ptsensor_info->I2cAdd); */
1316                 reg_w(dev, 0xa0, ptsensor_info->op, 0xb301);
1317                 read_sensor_register(gspca_dev, ptsensor_info->IdAdd, &value);
1318                 if (value == ptsensor_info->VpId) {
1319 /*                      PDEBUG(D_PROBE, "find sensor VC032X -> ox%04X!",
1320                                 ptsensor_info->VpId); */
1321                         return ptsensor_info->sensorId;
1322                 }
1323         }
1324         return -1;
1325 }
1326
1327 static __u8 i2c_write(struct gspca_dev *gspca_dev,
1328                         __u8 reg, const __u8 *val, __u8 size)
1329 {
1330         struct usb_device *dev = gspca_dev->dev;
1331
1332         if (size > 3 || size < 1)
1333                 return -EINVAL;
1334         reg_r(gspca_dev, 0xa1, 0xb33f, 1);
1335         reg_w(dev, 0xa0, size, 0xb334);
1336         reg_w(dev, 0xa0, reg, 0xb33a);
1337         switch (size) {
1338         case 1:
1339                 reg_w(dev, 0xa0, val[0], 0xb336);
1340                 break;
1341         case 2:
1342                 reg_w(dev, 0xa0, val[0], 0xb336);
1343                 reg_w(dev, 0xa0, val[1], 0xb337);
1344                 break;
1345         case 3:
1346                 reg_w(dev, 0xa0, val[0], 0xb336);
1347                 reg_w(dev, 0xa0, val[1], 0xb337);
1348                 reg_w(dev, 0xa0, val[2], 0xb338);
1349                 break;
1350         default:
1351                 reg_w(dev, 0xa0, 0x01, 0xb334);
1352                 return -EINVAL;
1353         }
1354         reg_w(dev, 0xa0, 0x01, 0xb339);
1355         reg_r(gspca_dev, 0xa1, 0xb33b, 1);
1356         return gspca_dev->usb_buf[0] == 0;
1357 }
1358
1359 static void put_tab_to_reg(struct gspca_dev *gspca_dev,
1360                         const __u8 *tab, __u8 tabsize, __u16 addr)
1361 {
1362         int j;
1363         __u16 ad = addr;
1364
1365         for (j = 0; j < tabsize; j++)
1366                 reg_w(gspca_dev->dev, 0xa0, tab[j], ad++);
1367 }
1368
1369 static void usb_exchange(struct gspca_dev *gspca_dev,
1370                         const __u8 data[][4])
1371 {
1372         struct usb_device *dev = gspca_dev->dev;
1373         int i = 0;
1374
1375         for (;;) {
1376                 switch (data[i][3]) {
1377                 default:
1378                         return;
1379                 case 0xcc:                      /* normal write */
1380                         reg_w(dev, 0xa0, data[i][2],
1381                                         ((data[i][0])<<8) | data[i][1]);
1382                         break;
1383                 case 0xaa:                      /* i2c op */
1384                         i2c_write(gspca_dev, data[i][1], &data[i][2], 1);
1385                         break;
1386                 case 0xbb:                      /* i2c op */
1387                         i2c_write(gspca_dev, data[i][0], &data[i][1], 2);
1388                         break;
1389                 case 0xdd:
1390                         msleep(data[i][2] + 10);
1391                         break;
1392                 }
1393                 i++;
1394         }
1395         /*not reached*/
1396 }
1397
1398 /*
1399  "GammaT"=hex:04,17,31,4f,6a,83,99,ad,bf,ce,da,e5,ee,f5,fb,ff,ff
1400  "MatrixT"=hex:60,f9,e5,e7,50,05,f3,e6,66
1401  */
1402
1403 static void vc0321_reset(struct gspca_dev *gspca_dev)
1404 {
1405         reg_w(gspca_dev->dev, 0xa0, 0x00, 0xb04d);
1406         reg_w(gspca_dev->dev, 0xa0, 0x01, 0xb301);
1407         msleep(100);
1408         reg_w(gspca_dev->dev, 0xa0, 0x01, 0xb003);
1409         msleep(100);
1410 }
1411
1412 /* this function is called at probe time */
1413 static int sd_config(struct gspca_dev *gspca_dev,
1414                         const struct usb_device_id *id)
1415 {
1416         struct sd *sd = (struct sd *) gspca_dev;
1417         struct usb_device *dev = gspca_dev->dev;
1418         struct cam *cam;
1419         int sensor;
1420
1421         cam = &gspca_dev->cam;
1422         cam->epaddr = 0x02;
1423         sd->bridge = id->driver_info;
1424         if (sd->bridge == BRIDGE_VC0321) {
1425                 cam->cam_mode = vc0321_mode;
1426                 cam->nmodes = ARRAY_SIZE(vc0321_mode);
1427         } else {
1428                 cam->cam_mode = vc0323_mode;
1429                 cam->nmodes = ARRAY_SIZE(vc0323_mode);
1430         }
1431
1432         vc0321_reset(gspca_dev);
1433         sensor = vc032x_probe_sensor(gspca_dev);
1434         switch (sensor) {
1435         case -1:
1436                 PDEBUG(D_PROBE, "Unknown sensor...");
1437                 return -EINVAL;
1438         case SENSOR_HV7131R:
1439                 PDEBUG(D_PROBE, "Find Sensor HV7131R");
1440                 sd->sensor = SENSOR_HV7131R;
1441                 break;
1442         case SENSOR_MI1310_SOC:
1443                 PDEBUG(D_PROBE, "Find Sensor MI1310_SOC");
1444                 sd->sensor = SENSOR_MI1310_SOC;
1445                 break;
1446         case SENSOR_MI1320:
1447                 PDEBUG(D_PROBE, "Find Sensor MI1320");
1448                 sd->sensor = SENSOR_MI1320;
1449                 break;
1450         case SENSOR_OV7660:
1451                 PDEBUG(D_PROBE, "Find Sensor OV7660");
1452                 sd->sensor = SENSOR_OV7660;
1453                 break;
1454         case SENSOR_OV7670:
1455                 PDEBUG(D_PROBE, "Find Sensor OV7670");
1456                 sd->sensor = SENSOR_OV7670;
1457                 break;
1458         case SENSOR_PO3130NC:
1459                 PDEBUG(D_PROBE, "Find Sensor PO3130NC");
1460                 sd->sensor = SENSOR_PO3130NC;
1461                 break;
1462         }
1463
1464         sd->qindex = 7;
1465         sd->autogain = AUTOGAIN_DEF;
1466         sd->lightfreq = FREQ_DEF;
1467         if (sd->sensor != SENSOR_OV7670)
1468                 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX);
1469
1470         if (sd->bridge == BRIDGE_VC0321) {
1471                 reg_r(gspca_dev, 0x8a, 0, 3);
1472                 reg_w(dev, 0x87, 0x00, 0x0f0f);
1473
1474                 reg_r(gspca_dev, 0x8b, 0, 3);
1475                 reg_w(dev, 0x88, 0x00, 0x0202);
1476         }
1477         return 0;
1478 }
1479
1480 /* this function is called at probe and time */
1481 static int sd_init(struct gspca_dev *gspca_dev)
1482 {
1483         return 0;
1484 }
1485
1486 static void setquality(struct gspca_dev *gspca_dev)
1487 {
1488 }
1489
1490 static void setautogain(struct gspca_dev *gspca_dev)
1491 {
1492 }
1493
1494 static void setlightfreq(struct gspca_dev *gspca_dev)
1495 {
1496         struct sd *sd = (struct sd *) gspca_dev;
1497         static const __u8 (*ov7660_freq_tb[3])[4] =
1498                 {ov7660_NoFliker, ov7660_50HZ, ov7660_60HZ};
1499
1500         if (sd->sensor != SENSOR_OV7660)
1501                 return;
1502         usb_exchange(gspca_dev, ov7660_freq_tb[sd->lightfreq]);
1503 }
1504
1505 static void sd_start(struct gspca_dev *gspca_dev)
1506 {
1507         struct sd *sd = (struct sd *) gspca_dev;
1508         const __u8 *GammaT = NULL;
1509         const __u8 *MatrixT = NULL;
1510         int mode;
1511
1512         /* Assume start use the good resolution from gspca_dev->mode */
1513         if (sd->bridge == BRIDGE_VC0321) {
1514                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfec);
1515                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfed);
1516                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfee);
1517                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfef);
1518         }
1519
1520         mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1521         switch (sd->sensor) {
1522         case SENSOR_HV7131R:
1523                 GammaT = hv7131r_gamma;
1524                 MatrixT = hv7131r_matrix;
1525                 if (mode) {
1526                         /* 320x240 */
1527                         usb_exchange(gspca_dev, hv7131r_initQVGA_data);
1528                 } else {
1529                         /* 640x480 */
1530                         usb_exchange(gspca_dev, hv7131r_initVGA_data);
1531                 }
1532                 break;
1533         case SENSOR_OV7660:
1534                 GammaT = ov7660_gamma;
1535                 MatrixT = ov7660_matrix;
1536                 if (mode) {
1537                         /* 320x240 */
1538                         usb_exchange(gspca_dev, ov7660_initQVGA_data);
1539                 } else {
1540                         /* 640x480 */
1541                         usb_exchange(gspca_dev, ov7660_initVGA_data);
1542                 }
1543                 break;
1544         case SENSOR_OV7670:
1545                 /*GammaT = ov7660_gamma; */
1546                 /*MatrixT = ov7660_matrix; */
1547                 if (mode) {
1548                         /* 320x240 */
1549                         usb_exchange(gspca_dev, ov7670_initQVGA_JPG);
1550                 } else {
1551                         /* 640x480 */
1552                         usb_exchange(gspca_dev, ov7670_initVGA_JPG);
1553                 }
1554                 break;
1555         case SENSOR_MI1310_SOC:
1556                 if (mode) {
1557                         /* 320x240 */
1558                         usb_exchange(gspca_dev, mi1310_socinitQVGA_JPG);
1559                 } else {
1560                         /* 640x480 */
1561                         usb_exchange(gspca_dev, mi1310_socinitVGA_JPG);
1562                 }
1563                 break;
1564         case SENSOR_MI1320:
1565                 GammaT = mi1320_gamma;
1566                 MatrixT = mi1320_matrix;
1567                 if (mode) {
1568                         /* 320x240 */
1569                         usb_exchange(gspca_dev, mi1320_initQVGA_data);
1570                 } else {
1571                         /* 640x480 */
1572                         usb_exchange(gspca_dev, mi1320_initVGA_data);
1573                 }
1574                 break;
1575         case SENSOR_PO3130NC:
1576                 GammaT = po3130_gamma;
1577                 MatrixT = po3130_matrix;
1578                 if (mode) {
1579                         /* 320x240 */
1580                         usb_exchange(gspca_dev, po3130_initQVGA_data);
1581                 } else {
1582                         /* 640x480 */
1583                         usb_exchange(gspca_dev, po3130_initVGA_data);
1584                 }
1585                 usb_exchange(gspca_dev, po3130_rundata);
1586                 break;
1587         default:
1588                 PDEBUG(D_PROBE, "Damned !! no sensor found Bye");
1589                 return;
1590         }
1591         if (GammaT && MatrixT) {
1592                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb84a);
1593                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb85b);
1594                 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb86c);
1595                 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c);
1596
1597                 /* Seem SHARPNESS */
1598                 /*
1599                 reg_w(gspca_dev->dev, 0xa0, 0x80, 0xb80a);
1600                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb80b);
1601                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb80e);
1602                 */
1603                 /* all 0x40 ??? do nothing
1604                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb822);
1605                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb823);
1606                 reg_w(gspca_dev->dev, 0xa0, 0x40, 0xb824);
1607                 */
1608                 /* Only works for HV7131R ??
1609                 reg_r (gspca_dev, 0xa1, 0xb881, 1);
1610                 reg_w(gspca_dev->dev, 0xa0, 0xfe01, 0xb881);
1611                 reg_w(gspca_dev->dev, 0xa0, 0x79, 0xb801);
1612                 */
1613                 /* only hv7131r et ov7660
1614                 reg_w(gspca_dev->dev, 0xa0, 0x20, 0xb827);
1615                 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xb826); * ISP_GAIN 80
1616                 reg_w(gspca_dev->dev, 0xa0, 0x23, 0xb800); * ISP CTRL_BAS
1617                 */
1618                 /* set the led on 0x0892 0x0896 */
1619                 reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff);
1620                 msleep(100);
1621                 setquality(gspca_dev);
1622                 setautogain(gspca_dev);
1623                 setlightfreq(gspca_dev);
1624         }
1625 }
1626
1627 static void sd_stopN(struct gspca_dev *gspca_dev)
1628 {
1629         struct usb_device *dev = gspca_dev->dev;
1630
1631         reg_w(dev, 0x89, 0xffff, 0xffff);
1632         reg_w(dev, 0xa0, 0x01, 0xb301);
1633         reg_w(dev, 0xa0, 0x09, 0xb003);
1634 }
1635
1636 static void sd_stop0(struct gspca_dev *gspca_dev)
1637 {
1638         struct usb_device *dev = gspca_dev->dev;
1639
1640         reg_w(dev, 0x89, 0xffff, 0xffff);
1641 }
1642
1643 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1644                         struct gspca_frame *frame,      /* target */
1645                         __u8 *data,                     /* isoc packet */
1646                         int len)                        /* iso pkt length */
1647 {
1648         struct sd *sd = (struct sd *) gspca_dev;
1649
1650         if (data[0] == 0xff && data[1] == 0xd8) {
1651                 PDEBUG(D_PACK,
1652                         "vc032x header packet found len %d", len);
1653                 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
1654                                                 data, 0);
1655                 if (sd->bridge == BRIDGE_VC0321) {
1656 #define VCHDRSZ 46
1657                         data += VCHDRSZ;
1658                         len -= VCHDRSZ;
1659 #undef VCHDRSZ
1660                 }
1661                 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1662                                 data, len);
1663                 return;
1664         }
1665         gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1666 }
1667
1668 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
1669 {
1670         struct sd *sd = (struct sd *) gspca_dev;
1671
1672         sd->autogain = val;
1673         if (gspca_dev->streaming)
1674                 setautogain(gspca_dev);
1675         return 0;
1676 }
1677
1678 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
1679 {
1680         struct sd *sd = (struct sd *) gspca_dev;
1681
1682         *val = sd->autogain;
1683         return 0;
1684 }
1685
1686 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
1687 {
1688         struct sd *sd = (struct sd *) gspca_dev;
1689
1690         sd->lightfreq = val;
1691         if (gspca_dev->streaming)
1692                 setlightfreq(gspca_dev);
1693         return 0;
1694 }
1695
1696 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
1697 {
1698         struct sd *sd = (struct sd *) gspca_dev;
1699
1700         *val = sd->lightfreq;
1701         return 0;
1702 }
1703
1704 static int sd_querymenu(struct gspca_dev *gspca_dev,
1705                         struct v4l2_querymenu *menu)
1706 {
1707         switch (menu->id) {
1708         case V4L2_CID_POWER_LINE_FREQUENCY:
1709                 switch (menu->index) {
1710                 case 0:         /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
1711                         strcpy((char *) menu->name, "NoFliker");
1712                         return 0;
1713                 case 1:         /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
1714                         strcpy((char *) menu->name, "50 Hz");
1715                         return 0;
1716                 case 2:         /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
1717                         strcpy((char *) menu->name, "60 Hz");
1718                         return 0;
1719                 }
1720                 break;
1721         }
1722         return -EINVAL;
1723 }
1724
1725 /* sub-driver description */
1726 static const struct sd_desc sd_desc = {
1727         .name = MODULE_NAME,
1728         .ctrls = sd_ctrls,
1729         .nctrls = ARRAY_SIZE(sd_ctrls),
1730         .config = sd_config,
1731         .init = sd_init,
1732         .start = sd_start,
1733         .stopN = sd_stopN,
1734         .stop0 = sd_stop0,
1735         .pkt_scan = sd_pkt_scan,
1736         .querymenu = sd_querymenu,
1737 };
1738
1739 /* -- module initialisation -- */
1740 static const __devinitdata struct usb_device_id device_table[] = {
1741         {USB_DEVICE(0x046d, 0x0892), .driver_info = BRIDGE_VC0321},
1742         {USB_DEVICE(0x046d, 0x0896), .driver_info = BRIDGE_VC0321},
1743         {USB_DEVICE(0x0ac8, 0x0321), .driver_info = BRIDGE_VC0321},
1744         {USB_DEVICE(0x0ac8, 0x0323), .driver_info = BRIDGE_VC0323},
1745         {USB_DEVICE(0x0ac8, 0x0328), .driver_info = BRIDGE_VC0321},
1746         {USB_DEVICE(0x0ac8, 0xc001), .driver_info = BRIDGE_VC0321},
1747         {USB_DEVICE(0x0ac8, 0xc002), .driver_info = BRIDGE_VC0321},
1748         {USB_DEVICE(0x17ef, 0x4802), .driver_info = BRIDGE_VC0323},
1749         {}
1750 };
1751 MODULE_DEVICE_TABLE(usb, device_table);
1752
1753 /* -- device connect -- */
1754 static int sd_probe(struct usb_interface *intf,
1755                         const struct usb_device_id *id)
1756 {
1757         return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
1758                                 THIS_MODULE);
1759 }
1760
1761 static struct usb_driver sd_driver = {
1762         .name = MODULE_NAME,
1763         .id_table = device_table,
1764         .probe = sd_probe,
1765         .disconnect = gspca_disconnect,
1766 #ifdef CONFIG_PM
1767         .suspend = gspca_suspend,
1768         .resume = gspca_resume,
1769 #endif
1770 };
1771
1772 /* -- module insert / remove -- */
1773 static int __init sd_mod_init(void)
1774 {
1775         if (usb_register(&sd_driver) < 0)
1776                 return -1;
1777         PDEBUG(D_PROBE, "registered");
1778         return 0;
1779 }
1780 static void __exit sd_mod_exit(void)
1781 {
1782         usb_deregister(&sd_driver);
1783         PDEBUG(D_PROBE, "deregistered");
1784 }
1785
1786 module_init(sd_mod_init);
1787 module_exit(sd_mod_exit);