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