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