blob: 583c3410a2c28992df8858b4a03685fc04b5934e [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03002 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003 *
Jean-François Moine27c6f9e2010-04-02 06:59:13 -03004 * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr>
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03005 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "sonixj"
23
Hans de Goede9712a8b2010-01-31 12:54:29 -030024#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030025#include "gspca.h"
26#include "jpeg.h"
27
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030028#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29
Jean-François Moine27c6f9e2010-04-02 06:59:13 -030030MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030031MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL");
33
34/* specific webcam descriptor */
35struct sd {
36 struct gspca_dev gspca_dev; /* !! must be the first item */
37
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030038 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030039 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030040
Jean-Francois Moine98819182009-01-19 07:37:33 -030041 u16 brightness;
42 u8 contrast;
43 u8 colors;
44 u8 autogain;
45 u8 blue;
46 u8 red;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030047 u8 gamma;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -030048 u8 vflip; /* ov7630/ov7648 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -030049 u8 sharpness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -030050 u8 infrared; /* mt9v111 only */
Hans de Goede37c6dbe2009-06-18 07:35:36 -030051 u8 freq; /* ov76xx only */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030052 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030053#define QUALITY_MIN 60
54#define QUALITY_MAX 95
55#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030056 u8 jpegqual; /* webcam quality */
57
58 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030059
Jean-Francois Moine98819182009-01-19 07:37:33 -030060 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030061#define AG_CNT_START 13
62
Jean-Francois Moine98819182009-01-19 07:37:33 -030063 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030064#define BRIDGE_SN9C102P 0
65#define BRIDGE_SN9C105 1
66#define BRIDGE_SN9C110 2
67#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030068 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030069 u8 i2c_addr;
70
71 u8 jpeg_hdr[JPEG_HDR_SZ];
72};
73enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030074 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030075 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030076 SENSOR_HV7131R,
77 SENSOR_MI0360,
78 SENSOR_MO4000,
79 SENSOR_MT9V111,
80 SENSOR_OM6802,
81 SENSOR_OV7630,
82 SENSOR_OV7648,
83 SENSOR_OV7660,
84 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030085 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030086 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030087 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030088};
89
90/* V4L2 controls supported by the driver */
91static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
93static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
95static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030097static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
99static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
100static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300101static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
102static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300103static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
104static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300105static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
106static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300107static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
108static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300109static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
110static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300111static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
112static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300113
Marton Nemeth7e64dc42009-12-30 09:12:41 -0300114static const struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300115#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300116 {
117 {
118 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness",
121 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300122#define BRIGHTNESS_MAX 0xffff
123 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300124 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300125#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300126 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300127 },
128 .set = sd_setbrightness,
129 .get = sd_getbrightness,
130 },
Hans de Goede97643982009-06-18 05:08:11 -0300131#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 {
133 {
134 .id = V4L2_CID_CONTRAST,
135 .type = V4L2_CTRL_TYPE_INTEGER,
136 .name = "Contrast",
137 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300138#define CONTRAST_MAX 127
139 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300141#define CONTRAST_DEF 63
142 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300143 },
144 .set = sd_setcontrast,
145 .get = sd_getcontrast,
146 },
Hans de Goede97643982009-06-18 05:08:11 -0300147#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 {
149 {
150 .id = V4L2_CID_SATURATION,
151 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300152 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300154 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300155 .step = 1,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300156#define COLOR_DEF 25
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300157 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300158 },
159 .set = sd_setcolors,
160 .get = sd_getcolors,
161 },
Hans de Goede97643982009-06-18 05:08:11 -0300162#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300163 {
164 {
165 .id = V4L2_CID_BLUE_BALANCE,
166 .type = V4L2_CTRL_TYPE_INTEGER,
167 .name = "Blue Balance",
168 .minimum = 24,
169 .maximum = 40,
170 .step = 1,
171#define BLUE_BALANCE_DEF 32
172 .default_value = BLUE_BALANCE_DEF,
173 },
174 .set = sd_setblue_balance,
175 .get = sd_getblue_balance,
176 },
Hans de Goede97643982009-06-18 05:08:11 -0300177#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300178 {
179 {
180 .id = V4L2_CID_RED_BALANCE,
181 .type = V4L2_CTRL_TYPE_INTEGER,
182 .name = "Red Balance",
183 .minimum = 24,
184 .maximum = 40,
185 .step = 1,
186#define RED_BALANCE_DEF 32
187 .default_value = RED_BALANCE_DEF,
188 },
189 .set = sd_setred_balance,
190 .get = sd_getred_balance,
191 },
Hans de Goede97643982009-06-18 05:08:11 -0300192#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300193 {
194 {
195 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER,
197 .name = "Gamma",
198 .minimum = 0,
199 .maximum = 40,
200 .step = 1,
201#define GAMMA_DEF 20
202 .default_value = GAMMA_DEF,
203 },
204 .set = sd_setgamma,
205 .get = sd_getgamma,
206 },
Hans de Goede97643982009-06-18 05:08:11 -0300207#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300208 {
209 {
210 .id = V4L2_CID_AUTOGAIN,
211 .type = V4L2_CTRL_TYPE_BOOLEAN,
212 .name = "Auto Gain",
213 .minimum = 0,
214 .maximum = 1,
215 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300216#define AUTOGAIN_DEF 1
217 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300218 },
219 .set = sd_setautogain,
220 .get = sd_getautogain,
221 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300222/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300223#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300224 {
225 {
226 .id = V4L2_CID_VFLIP,
227 .type = V4L2_CTRL_TYPE_BOOLEAN,
228 .name = "Vflip",
229 .minimum = 0,
230 .maximum = 1,
231 .step = 1,
Hans de Goedef8009522009-06-18 14:29:20 -0300232#define VFLIP_DEF 0
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300233 .default_value = VFLIP_DEF,
234 },
235 .set = sd_setvflip,
236 .get = sd_getvflip,
237 },
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300238#define SHARPNESS_IDX 8
239 {
240 {
241 .id = V4L2_CID_SHARPNESS,
242 .type = V4L2_CTRL_TYPE_INTEGER,
243 .name = "Sharpness",
244 .minimum = 0,
245 .maximum = 255,
246 .step = 1,
247#define SHARPNESS_DEF 90
248 .default_value = SHARPNESS_DEF,
249 },
250 .set = sd_setsharpness,
251 .get = sd_getsharpness,
252 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300253/* mt9v111 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300254#define INFRARED_IDX 9
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300255 {
256 {
257 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN,
259 .name = "Infrared",
260 .minimum = 0,
261 .maximum = 1,
262 .step = 1,
263#define INFRARED_DEF 0
264 .default_value = INFRARED_DEF,
265 },
266 .set = sd_setinfrared,
267 .get = sd_getinfrared,
268 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300269/* ov7630/ov7648/ov7660 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300270#define FREQ_IDX 10
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300271 {
272 {
273 .id = V4L2_CID_POWER_LINE_FREQUENCY,
274 .type = V4L2_CTRL_TYPE_MENU,
275 .name = "Light frequency filter",
276 .minimum = 0,
277 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
278 .step = 1,
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300279#define FREQ_DEF 1
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300280 .default_value = FREQ_DEF,
281 },
282 .set = sd_setfreq,
283 .get = sd_getfreq,
284 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300285};
286
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300287/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300288static const __u32 ctrl_dis[] = {
289[SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) |
290 (1 << INFRARED_IDX) |
291 (1 << VFLIP_IDX) |
292 (1 << FREQ_IDX),
293
Jean-François Moinec26b12d2010-04-02 07:08:39 -0300294[SENSOR_GC0307] = (1 << INFRARED_IDX) |
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300295 (1 << VFLIP_IDX) |
296 (1 << FREQ_IDX),
297
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300298[SENSOR_HV7131R] = (1 << INFRARED_IDX) |
299 (1 << FREQ_IDX),
300
301[SENSOR_MI0360] = (1 << INFRARED_IDX) |
302 (1 << VFLIP_IDX) |
303 (1 << FREQ_IDX),
304
305[SENSOR_MO4000] = (1 << INFRARED_IDX) |
306 (1 << VFLIP_IDX) |
307 (1 << FREQ_IDX),
308
309[SENSOR_MT9V111] = (1 << VFLIP_IDX) |
310 (1 << FREQ_IDX),
311
312[SENSOR_OM6802] = (1 << INFRARED_IDX) |
313 (1 << VFLIP_IDX) |
314 (1 << FREQ_IDX),
315
316[SENSOR_OV7630] = (1 << INFRARED_IDX),
317
318[SENSOR_OV7648] = (1 << INFRARED_IDX),
319
320[SENSOR_OV7660] = (1 << AUTOGAIN_IDX) |
321 (1 << INFRARED_IDX) |
322 (1 << VFLIP_IDX),
323
324[SENSOR_PO1030] = (1 << AUTOGAIN_IDX) |
325 (1 << INFRARED_IDX) |
326 (1 << VFLIP_IDX) |
327 (1 << FREQ_IDX),
328
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300329[SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) |
330 (1 << INFRARED_IDX) |
331 (1 << VFLIP_IDX) |
332 (1 << FREQ_IDX),
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300333[SENSOR_SOI768] = (1 << AUTOGAIN_IDX) |
334 (1 << INFRARED_IDX) |
335 (1 << VFLIP_IDX) |
336 (1 << FREQ_IDX),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300337
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300338[SENSOR_SP80708] = (1 << AUTOGAIN_IDX) |
339 (1 << INFRARED_IDX) |
340 (1 << VFLIP_IDX) |
341 (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300342};
343
Jean-Francois Moine64677572009-12-20 12:31:28 -0300344static const struct v4l2_pix_format cif_mode[] = {
345 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
346 .bytesperline = 352,
347 .sizeimage = 352 * 288 * 4 / 8 + 590,
348 .colorspace = V4L2_COLORSPACE_JPEG,
349 .priv = 0},
350};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300351static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300352 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
353 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300354 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300355 .colorspace = V4L2_COLORSPACE_JPEG,
356 .priv = 2},
357 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
358 .bytesperline = 320,
359 .sizeimage = 320 * 240 * 3 / 8 + 590,
360 .colorspace = V4L2_COLORSPACE_JPEG,
361 .priv = 1},
362 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
363 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300364 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
365 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300366 .colorspace = V4L2_COLORSPACE_JPEG,
367 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300368};
369
Jean-Francois Moine64677572009-12-20 12:31:28 -0300370static const u8 sn_adcm1700[0x1c] = {
371/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300372 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300373/* reg8 reg9 rega regb regc regd rege regf */
374 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
375/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
376 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
377/* reg18 reg19 reg1a reg1b */
378 0x06, 0x00, 0x00, 0x00
379};
380
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300381static const u8 sn_gc0307[0x1c] = {
382/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
383 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
384/* reg8 reg9 rega regb regc regd rege regf */
385 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
387 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
388/* reg18 reg19 reg1a reg1b */
389 0x06, 0x00, 0x00, 0x00
390};
391
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300392static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300393/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300394 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300395/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300396 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300397/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
398 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300399/* reg18 reg19 reg1a reg1b */
400 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300401};
402
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300403static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300404/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300405 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300406/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300407 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300408/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
409 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300410/* reg18 reg19 reg1a reg1b */
411 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300412};
413
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300414static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300415/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300416 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300417/* reg8 reg9 rega regb regc regd rege regf */
418 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
420 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300421/* reg18 reg19 reg1a reg1b */
422 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300423};
424
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300425static const u8 sn_mt9v111[0x1c] = {
426/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
427 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
428/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300429 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300430/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
431 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
432/* reg18 reg19 reg1a reg1b */
433 0x06, 0x00, 0x00, 0x00
434};
435
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300436static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300437/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300438 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300439/* reg8 reg9 rega regb regc regd rege regf */
440 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
442 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300443/* reg18 reg19 reg1a reg1b */
444 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300445};
446
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300447static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300448/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300449 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300450/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300451 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300452/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
453 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300454/* reg18 reg19 reg1a reg1b */
455 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300456};
457
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300458static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300459/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300460 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300461/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300462 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300463/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300464 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300465/* reg18 reg19 reg1a reg1b */
466 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300467};
468
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300469static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300470/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300471 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300472/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300473 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300474/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
475 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300476/* reg18 reg19 reg1a reg1b */
477 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300478};
479
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300480static const u8 sn_po1030[0x1c] = {
481/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
482 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
483/* reg8 reg9 rega regb regc regd rege regf */
484 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
485/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
486 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
487/* reg18 reg19 reg1a reg1b */
488 0x07, 0x00, 0x00, 0x00
489};
490
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300491static const u8 sn_po2030n[0x1c] = {
492/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
493 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
494/* reg8 reg9 rega regb regc regd rege regf */
495 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
496/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
497 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
498/* reg18 reg19 reg1a reg1b */
499 0x07, 0x00, 0x00, 0x00
500};
501
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300502static const u8 sn_soi768[0x1c] = {
503/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
504 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
505/* reg8 reg9 rega regb regc regd rege regf */
506 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
507/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
508 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
509/* reg18 reg19 reg1a reg1b */
510 0x07, 0x00, 0x00, 0x00
511};
512
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300513static const u8 sn_sp80708[0x1c] = {
514/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
515 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
516/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300517 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300518/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
519 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
520/* reg18 reg19 reg1a reg1b */
521 0x07, 0x00, 0x00, 0x00
522};
523
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300524/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300525static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300526[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300527[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300528[SENSOR_HV7131R] = sn_hv7131,
529[SENSOR_MI0360] = sn_mi0360,
530[SENSOR_MO4000] = sn_mo4000,
531[SENSOR_MT9V111] = sn_mt9v111,
532[SENSOR_OM6802] = sn_om6802,
533[SENSOR_OV7630] = sn_ov7630,
534[SENSOR_OV7648] = sn_ov7648,
535[SENSOR_OV7660] = sn_ov7660,
536[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300537[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300538[SENSOR_SOI768] = sn_soi768,
539[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300540};
541
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300542/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300543static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300544 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
545 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
546};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300547/* gamma for sensor ADCM1700 */
548static const u8 gamma_spec_0[17] = {
549 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
550 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
551};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300552/* gamma for sensors HV7131R and MT9V111 */
553static const u8 gamma_spec_1[17] = {
554 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
555 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
556};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300557/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300558static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300559 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
560 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
561};
562/* gamma for sensor SP80708 */
563static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300564 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
565 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
566};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300567
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300568/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300569static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300570 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
571 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
572 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
573 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300574};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300575static const u8 adcm1700_sensor_init[][8] = {
576 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300577 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300578 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
579 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
580 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
581 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
582 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
583 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
584 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
585 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
586 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
587 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
588 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
589 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
590 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
591 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
592 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
593 {}
594};
595static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300596 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300597 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
598
599 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
600 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
601 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
602 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300603 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300604
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300605 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
606 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300609 {}
610};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300611static const u8 gc0307_sensor_init[][8] = {
612 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
613 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
617 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
619 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
632 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
633 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
650 {}
651};
652static const u8 gc0307_sensor_param1[][8] = {
653 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
654 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
655 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
656 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
657/*param3*/
658 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300660 {}
661};
662
Jean-Francois Moine98819182009-01-19 07:37:33 -0300663static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300664 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
665 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
666 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
667/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
668 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
669 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
670/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300671
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300672 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
673 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
674 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
675 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
676 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
677 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
678 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
679 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300680
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300681 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
682 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300683 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300684 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
685 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300686
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300687 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
688 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
689 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
691 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300692 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
693 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300694 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300695};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300696static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300697 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300698 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300699 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300700 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
701 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
702 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
703 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
704 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
705 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
706 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
709 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
710 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
711 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
712 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
713 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
714 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
715 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
716 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
717 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
718 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300719 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300720 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
722 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
724 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
726 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
727 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
729 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300730
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300731 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
732 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
733 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
735 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300736
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300737 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
738 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
739 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
740 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300741
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300742 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
743 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
744/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
745/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
746 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
747 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300748 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300749};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300750static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300751 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
753 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
754 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
755 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
756 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
757 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
758 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
759 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
760 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
761 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
762 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
763 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
764 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
765 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
766 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
767 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
768 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
769 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
770 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300771 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300772};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300773static const u8 mt9v111_sensor_init[][8] = {
774 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300775 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300776 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
778 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
779 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300780 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
781 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
782 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
783 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300784 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300785 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
786 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
787 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
788 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
789 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300790 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300791 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300792 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
793 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
794 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
795 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
796 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
797 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
798 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
799 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
800 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
801 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300802 {}
803};
804static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300805 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
806 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300807 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300808 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
809 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
810 /*******/
811 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
812 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
813 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
814 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
815 {}
816};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300817static const u8 om6802_init0[2][8] = {
818/*fixme: variable*/
819 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
820 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
821};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300822static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300823 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
824 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300825 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300826 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300827 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300828/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
829 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300830 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300831/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
832 * set color mode */
833/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
834 * max AGC value in AE */
835/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
836 * preset AGC */
837/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
838 * preset brightness */
839/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
840 * preset contrast */
841/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
842 * preset gamma */
843 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300844 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300845 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
846 /* preset shutter */
847/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
848 * auto frame rate */
849/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300850 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
851 {}
852};
853static const u8 om6802_sensor_param1[][8] = {
854 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
855 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
856 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
857 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300858 {}
859};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300860static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300861 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300863 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300864 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300866 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300867 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300868/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300869 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
870 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300871/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
872 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
873 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300874 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
875 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
876 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
877 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
878 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
879 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
880 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
881 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
882 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
884 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
885 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
886 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
887 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
888 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
889 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
890 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
891 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
892 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
893 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
894 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
895 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
896 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300897 {}
898};
899static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300900 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
902/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300903/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
904 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300905 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
906 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
907 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300908/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300909/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
910/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300911/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300912 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300913/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300914 {}
915};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300916
Jean-Francois Moine98819182009-01-19 07:37:33 -0300917static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300918 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300920 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300921 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
922 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
923 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
924 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
925 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
926 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
927 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
928 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
929 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
930 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
931 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
932 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
933 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
934 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
935 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
936 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
937 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
938 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
939 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
940
941 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
942/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
943/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300944/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300945 {}
946};
947static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300948/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300949/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
950 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300951 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
952 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
953/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
954/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
955/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
956/*...*/
957 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
958/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
959/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
960/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
961/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
962/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
963
964 {}
965};
966
Jean-Francois Moine98819182009-01-19 07:37:33 -0300967static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300968 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300969 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300970 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300971 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300972 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -0300973 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300974 /* GAIN BLUE RED VREF */
975 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
976 /* COM 1 BAVE GEAVE AECHH */
977 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
978 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300979 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300980 /* AECH CLKRC COM7 COM8 */
981 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
982 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
983 /* HSTART HSTOP VSTRT VSTOP */
984 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
985 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
986 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
987 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300988/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
989 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300990 /* AEW AEB VPT BBIAS */
991 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
992 /* GbBIAS RSVD EXHCH EXHCL */
993 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
994 /* RBIAS ADVFL ASDVFH YAVE */
995 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
996 /* HSYST HSYEN HREF */
997 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
998 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
999 /* ADC ACOM OFON TSLB */
1000 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1001 /* COM11 COM12 COM13 COM14 */
1002 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1003 /* EDGE COM15 COM16 COM17 */
1004 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1005 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1006 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1007 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1008 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1009 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1010 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1011 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1012 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1013 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1014 /* LCC1 LCC2 LCC3 LCC4 */
1015 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001016 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001017 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001018 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001019 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1020 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1021 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1022 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1023 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1024 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1025 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1026 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1027 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001028 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001029/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001030 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001031 {}
1032};
1033static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001034 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001035 /* bits[3..0]reserved */
1036 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1037 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1038 /* VREF vertical frame ctrl */
1039 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001040 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1041 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1042 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1043 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1044/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001045/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001046/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001047 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001048 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1049 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1050 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1051/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001052/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001053/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001054/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001055 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1056 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1057 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1058 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001059 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001060};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001061
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001062static const u8 po1030_sensor_init[][8] = {
1063/* the sensor registers are described in m5602/m5602_po1030.h */
1064 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1065 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1066 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1067 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1068 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1069 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1070 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1071 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1072 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1073 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1074 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1075 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1076 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1077 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1078 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1079 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1080 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1081 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1082 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1083 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1084 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1085 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1086 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1087 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1088 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1089 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1090 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1091 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1092
1093 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1094 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1095 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1096 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1097 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1098 {}
1099};
1100static const u8 po1030_sensor_param1[][8] = {
1101/* from ms-win traces - these values change with auto gain/expo/wb.. */
1102 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1103 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1104/* mean values */
1105 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1106 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1107 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1108
1109 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1110 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1111 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1112/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1113 {}
1114};
1115
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001116static const u8 po2030n_sensor_init[][8] = {
1117 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1118 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1119 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1120 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1121 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1122 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1123 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1124 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1125 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1126 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1127 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1128 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1129 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1130 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1131 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1132 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1133 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1134 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1135 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1136 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1137 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1138 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1139 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1141 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1142 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1143 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1144 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1145 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1146 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1148 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1149 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1150 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1151 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1152 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1153 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1154 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1155 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1156 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1157 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1158 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1159 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1160 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1161 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1162 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1163 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1165 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1166 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1167 {}
1168};
1169static const u8 po2030n_sensor_param1[][8] = {
1170 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1171 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1172 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1173 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1175/*param2*/
1176 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1177 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1178 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1179 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1180 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1181 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1182 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1183/*after start*/
1184 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1185 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1186 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1187 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1188 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1189 {}
1190};
1191
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001192static const u8 soi768_sensor_init[][8] = {
1193 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1194 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1195 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1199 {}
1200};
1201static const u8 soi768_sensor_param1[][8] = {
1202 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1203 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1204 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1207/* */
1208/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1209/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1210 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1211/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1212 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1213/* the next sequence should be used for auto gain */
1214 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1215 /* global gain ? : 07 - change with 0x15 at the end */
1216 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1217 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1218 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1219 /* exposure ? : 0200 - change with 0x1e at the end */
1220 {}
1221};
1222
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001223static const u8 sp80708_sensor_init[][8] = {
1224 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1225 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1226 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1228 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1229 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1230 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1231 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1232 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1233 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1234 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1235 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1236 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1237 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1238 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1239 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1240 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1242 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1243 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1244 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1245 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1246 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1247 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1248 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1249 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1253 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1254 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1255 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1256 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1257 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1258 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1259 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1260 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1263 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1264 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1265 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1266 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1267 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1268 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1271 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1272 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1273 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1274 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1275 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1279 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1280 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1281 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1282 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1283 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1284 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1285 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1286 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1287 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1288 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1289 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1290 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1291 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1292 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1293 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1294 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001295 {}
1296};
1297static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001298 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1304 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1305 {}
1306};
1307
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001308static const u8 (*sensor_init[])[8] = {
1309[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001310[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001311[SENSOR_HV7131R] = hv7131r_sensor_init,
1312[SENSOR_MI0360] = mi0360_sensor_init,
1313[SENSOR_MO4000] = mo4000_sensor_init,
1314[SENSOR_MT9V111] = mt9v111_sensor_init,
1315[SENSOR_OM6802] = om6802_sensor_init,
1316[SENSOR_OV7630] = ov7630_sensor_init,
1317[SENSOR_OV7648] = ov7648_sensor_init,
1318[SENSOR_OV7660] = ov7660_sensor_init,
1319[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001320[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001321[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001322[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001323};
1324
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001325/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001326static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001327 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001328{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001329 int ret;
1330
1331 if (gspca_dev->usb_err < 0)
1332 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001333#ifdef GSPCA_DEBUG
1334 if (len > USB_BUF_SZ) {
1335 err("reg_r: buffer overflow");
1336 return;
1337 }
1338#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001339 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001340 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001341 0,
1342 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1343 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001344 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001345 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001346 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001347 if (ret < 0) {
1348 err("reg_r err %d", ret);
1349 gspca_dev->usb_err = ret;
1350 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001351}
1352
Jean-Francois Moine60017612008-07-18 08:46:19 -03001353static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001354 u16 value,
1355 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001356{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001357 int ret;
1358
1359 if (gspca_dev->usb_err < 0)
1360 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001361 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001362 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001363 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001364 usb_sndctrlpipe(gspca_dev->dev, 0),
1365 0x08,
1366 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1367 value,
1368 0,
1369 gspca_dev->usb_buf, 1,
1370 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001371 if (ret < 0) {
1372 err("reg_w1 err %d", ret);
1373 gspca_dev->usb_err = ret;
1374 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001375}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001376static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001377 u16 value,
1378 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001379 int len)
1380{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001381 int ret;
1382
1383 if (gspca_dev->usb_err < 0)
1384 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001385 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001386 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001387#ifdef GSPCA_DEBUG
1388 if (len > USB_BUF_SZ) {
1389 err("reg_w: buffer overflow");
1390 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001391 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001392#endif
1393 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001394 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001395 usb_sndctrlpipe(gspca_dev->dev, 0),
1396 0x08,
1397 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1398 value, 0,
1399 gspca_dev->usb_buf, len,
1400 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001401 if (ret < 0) {
1402 err("reg_w err %d", ret);
1403 gspca_dev->usb_err = ret;
1404 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001405}
1406
Jean-Francois Moine60017612008-07-18 08:46:19 -03001407/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001408static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001409{
1410 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001411 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001412
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001413 if (gspca_dev->usb_err < 0)
1414 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001415 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001416 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001417 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001418 case SENSOR_OM6802:
1419 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001420 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1421 break;
1422 default: /* i2c command = a1 (400 kHz) */
1423 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1424 break;
1425 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001426 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001427 gspca_dev->usb_buf[2] = reg;
1428 gspca_dev->usb_buf[3] = val;
1429 gspca_dev->usb_buf[4] = 0;
1430 gspca_dev->usb_buf[5] = 0;
1431 gspca_dev->usb_buf[6] = 0;
1432 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001433 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001434 usb_sndctrlpipe(gspca_dev->dev, 0),
1435 0x08,
1436 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1437 0x08, /* value = i2c */
1438 0,
1439 gspca_dev->usb_buf, 8,
1440 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001441 if (ret < 0) {
1442 err("i2c_w1 err %d", ret);
1443 gspca_dev->usb_err = ret;
1444 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001445}
1446
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001447/* I2C write 8 bytes */
1448static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001449 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001450{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001451 int ret;
1452
1453 if (gspca_dev->usb_err < 0)
1454 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001455 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1456 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001457 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001458 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001459 usb_sndctrlpipe(gspca_dev->dev, 0),
1460 0x08,
1461 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1462 0x08, 0, /* value, index */
1463 gspca_dev->usb_buf, 8,
1464 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001465 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001466 if (ret < 0) {
1467 err("i2c_w8 err %d", ret);
1468 gspca_dev->usb_err = ret;
1469 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001470}
1471
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001472/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1473static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001474{
1475 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001476 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001477
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001478 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001479 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001480 case SENSOR_OM6802:
1481 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001482 mode[0] = 0x80 | 0x10;
1483 break;
1484 default: /* i2c command = 91 (400 kHz) */
1485 mode[0] = 0x81 | 0x10;
1486 break;
1487 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001488 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001489 mode[2] = reg;
1490 mode[3] = 0;
1491 mode[4] = 0;
1492 mode[5] = 0;
1493 mode[6] = 0;
1494 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001495 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001496 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001497 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001498 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001499 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001500 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001501 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001502}
1503
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001504static void i2c_w_seq(struct gspca_dev *gspca_dev,
1505 const u8 (*data)[8])
1506{
1507 while ((*data)[0] != 0) {
1508 if ((*data)[0] != 0xdd)
1509 i2c_w8(gspca_dev, *data);
1510 else
1511 msleep((*data)[1]);
1512 data++;
1513 }
1514}
1515
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001516static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001517{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001518 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001519 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001520 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001521 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001522 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001523 if (gspca_dev->usb_buf[0] == 0x02
1524 && gspca_dev->usb_buf[1] == 0x09
1525 && gspca_dev->usb_buf[2] == 0x01
1526 && gspca_dev->usb_buf[3] == 0x00
1527 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001528 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1529 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001530 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001531 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001532 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1533 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001534}
1535
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001536static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001537{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001538 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001539 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001540 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001541 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001542 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001543 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1544 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1545 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1546 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1547 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001548 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001549 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1550 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1551 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1552 {}
1553 },
1554 };
1555
1556 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1557 reg_w1(gspca_dev, 0x17, 0x62);
1558 reg_w1(gspca_dev, 0x01, 0x08);
1559 for (j = 0; j < 3; j++)
1560 i2c_w8(gspca_dev, probe_tb[i][j]);
1561 msleep(2);
1562 reg_r(gspca_dev, 0x0a, 5);
1563 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1564 if (probe_tb[i][3][0] != 0)
1565 i2c_w8(gspca_dev, probe_tb[i][3]);
1566 reg_w1(gspca_dev, 0x01, 0x29);
1567 reg_w1(gspca_dev, 0x17, 0x42);
1568 if (val != 0xffff)
1569 break;
1570 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001571 if (gspca_dev->usb_err < 0)
1572 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001573 switch (val) {
1574 case 0x823a:
1575 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001576 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001577 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001578 case 0x8243:
1579 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001580 break;
1581 default:
1582 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1583 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001584 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001585}
1586
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001587static void ov7630_probe(struct gspca_dev *gspca_dev)
1588{
1589 struct sd *sd = (struct sd *) gspca_dev;
1590 u16 val;
1591
1592 /* check ov76xx */
1593 reg_w1(gspca_dev, 0x17, 0x62);
1594 reg_w1(gspca_dev, 0x01, 0x08);
1595 sd->i2c_addr = 0x21;
1596 i2c_r(gspca_dev, 0x0a, 2);
1597 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1598 reg_w1(gspca_dev, 0x01, 0x29);
1599 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001600 if (gspca_dev->usb_err < 0)
1601 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001602 if (val == 0x7628) { /* soi768 */
1603 sd->sensor = SENSOR_SOI768;
1604/*fixme: only valid for 0c45:613e?*/
1605 gspca_dev->cam.input_flags =
1606 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1607 PDEBUG(D_PROBE, "Sensor soi768");
1608 return;
1609 }
1610 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1611}
1612
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001613static void ov7648_probe(struct gspca_dev *gspca_dev)
1614{
1615 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001616 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001617
1618 /* check ov76xx */
1619 reg_w1(gspca_dev, 0x17, 0x62);
1620 reg_w1(gspca_dev, 0x01, 0x08);
1621 sd->i2c_addr = 0x21;
1622 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001623 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001624 reg_w1(gspca_dev, 0x01, 0x29);
1625 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001626 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1627 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1628 return;
1629 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001630
1631 /* check po1030 */
1632 reg_w1(gspca_dev, 0x17, 0x62);
1633 reg_w1(gspca_dev, 0x01, 0x08);
1634 sd->i2c_addr = 0x6e;
1635 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001636 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1637 reg_w1(gspca_dev, 0x01, 0x29);
1638 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001639 if (gspca_dev->usb_err < 0)
1640 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001641 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001642 PDEBUG(D_PROBE, "Sensor po1030");
1643 sd->sensor = SENSOR_PO1030;
1644 return;
1645 }
1646
Jean-François Moine0b656322010-09-13 05:19:58 -03001647 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001648}
1649
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001650/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1651static void po2030n_probe(struct gspca_dev *gspca_dev)
1652{
1653 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001654 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001655
1656 /* check gc0307 */
1657 reg_w1(gspca_dev, 0x17, 0x62);
1658 reg_w1(gspca_dev, 0x01, 0x08);
1659 reg_w1(gspca_dev, 0x02, 0x22);
1660 sd->i2c_addr = 0x21;
1661 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001662 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001663 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1664 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001665 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001666 PDEBUG(D_PROBE, "Sensor gc0307");
1667 sd->sensor = SENSOR_GC0307;
1668 return;
1669 }
1670
1671 /* check po2030n */
1672 reg_w1(gspca_dev, 0x17, 0x62);
1673 reg_w1(gspca_dev, 0x01, 0x0a);
1674 sd->i2c_addr = 0x6e;
1675 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001676 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001677 reg_w1(gspca_dev, 0x01, 0x29);
1678 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001679 if (gspca_dev->usb_err < 0)
1680 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001681 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001682 PDEBUG(D_PROBE, "Sensor po2030n");
1683/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001684 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001685 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001686 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001687}
1688
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001689static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001690 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001691{
1692 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine19697b52010-07-14 06:33:51 -03001693 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03001694 const u8 *reg9a;
1695 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001696 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1697 static const u8 reg9a_spec[] =
1698 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001699 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001700
Hans de Goede9712a8b2010-01-31 12:54:29 -03001701 /* sensor clock already enabled in sd_init */
1702 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001703 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001704
1705 /* configure gpio */
Jean-François Moine19697b52010-07-14 06:33:51 -03001706 reg0102[0] = sn9c1xx[1];
1707 reg0102[1] = sn9c1xx[2];
1708 if (gspca_dev->audio)
1709 reg0102[1] |= 0x04; /* keep the audio connection */
1710 reg_w(gspca_dev, 0x01, reg0102, 2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001711 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001712 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001713 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001714 case SENSOR_GC0307:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001715 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001716 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001717 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001718 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001719 case SENSOR_SP80708:
1720 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001721 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001722 default:
1723 reg9a = reg9a_def;
1724 break;
1725 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001726 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001727
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001728 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001729
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001730 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001731
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001732 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001733 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001734 reg_w1(gspca_dev, 0x01, 0x43);
Jean-Francois Moine64677572009-12-20 12:31:28 -03001735 reg_w1(gspca_dev, 0x17, 0x62);
1736 reg_w1(gspca_dev, 0x01, 0x42);
1737 reg_w1(gspca_dev, 0x01, 0x42);
1738 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001739 case SENSOR_GC0307:
1740 msleep(50);
1741 reg_w1(gspca_dev, 0x01, 0x61);
1742 reg_w1(gspca_dev, 0x17, 0x22);
1743 reg_w1(gspca_dev, 0x01, 0x60);
1744 reg_w1(gspca_dev, 0x01, 0x40);
1745 msleep(50);
1746 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001747 case SENSOR_MT9V111:
1748 reg_w1(gspca_dev, 0x01, 0x61);
1749 reg_w1(gspca_dev, 0x17, 0x61);
1750 reg_w1(gspca_dev, 0x01, 0x60);
1751 reg_w1(gspca_dev, 0x01, 0x40);
1752 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001753 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001754 msleep(10);
1755 reg_w1(gspca_dev, 0x02, 0x73);
1756 reg_w1(gspca_dev, 0x17, 0x60);
1757 reg_w1(gspca_dev, 0x01, 0x22);
1758 msleep(100);
1759 reg_w1(gspca_dev, 0x01, 0x62);
1760 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001761 reg_w1(gspca_dev, 0x17, 0x64);
1762 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001763 msleep(10);
1764 reg_w1(gspca_dev, 0x01, 0x42);
1765 i2c_w8(gspca_dev, om6802_init0[0]);
1766 i2c_w8(gspca_dev, om6802_init0[1]);
1767 msleep(15);
1768 reg_w1(gspca_dev, 0x02, 0x71);
1769 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001770 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001771 case SENSOR_OV7630:
1772 reg_w1(gspca_dev, 0x01, 0x61);
1773 reg_w1(gspca_dev, 0x17, 0xe2);
1774 reg_w1(gspca_dev, 0x01, 0x60);
1775 reg_w1(gspca_dev, 0x01, 0x40);
1776 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001777 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001778 reg_w1(gspca_dev, 0x01, 0x63);
1779 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001780 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001781 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001782 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001783 case SENSOR_PO1030:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001784 case SENSOR_SOI768:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001785 reg_w1(gspca_dev, 0x01, 0x61);
1786 reg_w1(gspca_dev, 0x17, 0x20);
1787 reg_w1(gspca_dev, 0x01, 0x60);
1788 reg_w1(gspca_dev, 0x01, 0x40);
1789 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001790 case SENSOR_PO2030N:
Jean-François Moine19697b52010-07-14 06:33:51 -03001791 case SENSOR_OV7660:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001792 reg_w1(gspca_dev, 0x01, 0x63);
1793 reg_w1(gspca_dev, 0x17, 0x20);
1794 reg_w1(gspca_dev, 0x01, 0x62);
1795 reg_w1(gspca_dev, 0x01, 0x42);
1796 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001797 case SENSOR_SP80708:
1798 reg_w1(gspca_dev, 0x01, 0x63);
1799 reg_w1(gspca_dev, 0x17, 0x20);
1800 reg_w1(gspca_dev, 0x01, 0x62);
1801 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001802 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001803 reg_w1(gspca_dev, 0x02, 0x62);
1804 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001805 default:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001806/* case SENSOR_HV7131R: */
1807/* case SENSOR_MI0360: */
1808/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001809 reg_w1(gspca_dev, 0x01, 0x43);
1810 reg_w1(gspca_dev, 0x17, 0x61);
1811 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001812 if (sd->sensor == SENSOR_HV7131R
1813 && sd->bridge == BRIDGE_SN9C102P)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001814 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001815 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001816 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001817}
1818
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001819/* this function is called at probe time */
1820static int sd_config(struct gspca_dev *gspca_dev,
1821 const struct usb_device_id *id)
1822{
1823 struct sd *sd = (struct sd *) gspca_dev;
1824 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001825
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001826 sd->bridge = id->driver_info >> 16;
1827 sd->sensor = id->driver_info;
1828
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001829 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001830 if (sd->sensor == SENSOR_ADCM1700) {
1831 cam->cam_mode = cif_mode;
1832 cam->nmodes = ARRAY_SIZE(cif_mode);
1833 } else {
1834 cam->cam_mode = vga_mode;
1835 cam->nmodes = ARRAY_SIZE(vga_mode);
1836 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001837 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001838
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001839 sd->brightness = BRIGHTNESS_DEF;
1840 sd->contrast = CONTRAST_DEF;
1841 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001842 sd->blue = BLUE_BALANCE_DEF;
1843 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001844 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001845 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001846 sd->ag_cnt = -1;
Hans de Goedef8009522009-06-18 14:29:20 -03001847 sd->vflip = VFLIP_DEF;
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001848 switch (sd->sensor) {
1849 case SENSOR_OM6802:
1850 sd->sharpness = 0x10;
1851 break;
1852 default:
1853 sd->sharpness = SHARPNESS_DEF;
1854 break;
1855 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001856 sd->infrared = INFRARED_DEF;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001857 sd->freq = FREQ_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001858 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001859 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001860
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861 return 0;
1862}
1863
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001864/* this function is called at probe and resume time */
1865static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001866{
1867 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001868 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001869 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001870 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001871
Hans de Goede3647fea2008-07-15 05:36:30 -03001872 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001873 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001874 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001875 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1876 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001877 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001878 if (gspca_dev->usb_err < 0)
1879 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001880 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001881 switch (sd->bridge) {
1882 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001883 if (regF1 != 0x11)
1884 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001885 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001886 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001887 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001888 if (regF1 != 0x11)
1889 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001890 if (sd->sensor == SENSOR_MI0360)
1891 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001892 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001893 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001894 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001895 if (regF1 != 0x12)
1896 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001897 switch (sd->sensor) {
1898 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001899 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001900 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001901 case SENSOR_OV7630:
1902 ov7630_probe(gspca_dev);
1903 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001904 case SENSOR_OV7648:
1905 ov7648_probe(gspca_dev);
1906 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001907 case SENSOR_PO2030N:
1908 po2030n_probe(gspca_dev);
1909 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001910 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001911 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001912 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001913 break;
1914 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001915/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001916/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001917 if (regF1 != 0x12)
1918 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001919 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001920 break;
1921 }
1922
Hans de Goede9712a8b2010-01-31 12:54:29 -03001923 /* Note we do not disable the sensor clock here (power saving mode),
1924 as that also disables the button on the cam. */
1925 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001926
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001927 /* set the i2c address */
1928 sn9c1xx = sn_tb[sd->sensor];
1929 sd->i2c_addr = sn9c1xx[9];
1930
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001931 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1932
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001933 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001934}
1935
Jean-Francois Moine98819182009-01-19 07:37:33 -03001936static u32 setexposure(struct gspca_dev *gspca_dev,
1937 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001938{
1939 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001940
1941 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001942 case SENSOR_GC0307: {
1943 int a, b;
1944
1945 /* expo = 0..255 -> a = 19..43 */
1946 a = 19 + expo * 25 / 256;
1947 i2c_w1(gspca_dev, 0x68, a);
1948 a -= 12;
1949 b = a * a * 4; /* heuristic */
1950 i2c_w1(gspca_dev, 0x03, b >> 8);
1951 i2c_w1(gspca_dev, 0x04, b);
1952 break;
1953 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001954 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001955 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001956 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001957
1958 Expodoit[3] = expo >> 16;
1959 Expodoit[4] = expo >> 8;
1960 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001961 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001962 break;
1963 }
1964 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001965 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001966 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001967 static const u8 doit[] = /* update sensor */
1968 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1969 static const u8 sensorgo[] = /* sensor on */
1970 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001971
1972 if (expo > 0x0635)
1973 expo = 0x0635;
1974 else if (expo < 0x0001)
1975 expo = 0x0001;
1976 expoMi[3] = expo >> 8;
1977 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001978 i2c_w8(gspca_dev, expoMi);
1979 i2c_w8(gspca_dev, doit);
1980 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001981 break;
1982 }
1983 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001984 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001985 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001986 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001987 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001988 static const u8 gainMo[] =
1989 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001990
1991 if (expo > 0x1fff)
1992 expo = 0x1fff;
1993 else if (expo < 0x0001)
1994 expo = 0x0001;
1995 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001996 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001997 expoMo10[3] = ((expo & 0x1c00) >> 10)
1998 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001999 i2c_w8(gspca_dev, expoMo10);
2000 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002001 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002002 ((expoMo10[3] & 0x07) << 10)
2003 | (expoMof[3] << 2)
2004 | ((expoMo10[3] & 0x30) >> 4));
2005 break;
2006 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002007 case SENSOR_MT9V111: {
2008 u8 expo_c1[] =
2009 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2010
2011 if (expo > 0x0280)
2012 expo = 0x0280;
2013 else if (expo < 0x0040)
2014 expo = 0x0040;
2015 expo_c1[3] = expo >> 8;
2016 expo_c1[4] = expo;
2017 i2c_w8(gspca_dev, expo_c1);
2018 break;
2019 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002020 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002021 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002022 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002023 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002024
2025 if (expo > 0x03ff)
2026 expo = 0x03ff;
2027 if (expo < 0x0001)
2028 expo = 0x0001;
2029 gainOm[3] = expo >> 2;
2030 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002031 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002032 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002033 break;
2034 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002035 }
2036 return expo;
2037}
2038
2039static void setbrightness(struct gspca_dev *gspca_dev)
2040{
2041 struct sd *sd = (struct sd *) gspca_dev;
2042 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002043 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002044
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03002045 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002046 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002047 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002048 if (k2 > 0x1f)
2049 k2 = 0; /* only positive Y offset */
2050 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002051 case SENSOR_HV7131R:
2052 expo = sd->brightness << 4;
2053 if (expo > 0x002dc6c0)
2054 expo = 0x002dc6c0;
2055 else if (expo < 0x02a0)
2056 expo = 0x02a0;
2057 sd->exposure = setexposure(gspca_dev, expo);
2058 break;
2059 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002060 case SENSOR_MO4000:
2061 expo = sd->brightness >> 4;
2062 sd->exposure = setexposure(gspca_dev, expo);
2063 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002064 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002065 case SENSOR_MT9V111:
2066 expo = sd->brightness >> 8;
2067 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002068 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002069 case SENSOR_OM6802:
2070 expo = sd->brightness >> 6;
2071 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03002072 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002073 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002074 }
2075
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002076 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002077}
2078
2079static void setcontrast(struct gspca_dev *gspca_dev)
2080{
2081 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002082 u8 k2;
2083 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002084
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002085 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
2086 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002087 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002088 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002089 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002090 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002091 contrast[5] = 0;
2092 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002093}
2094
2095static void setcolors(struct gspca_dev *gspca_dev)
2096{
2097 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002098 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002099 u8 reg8a[12]; /* U & V gains */
Jean-François Moine9c33afc2010-03-17 15:25:32 -03002100 static const s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002101 -24, -38, 64, /* UR UG UB */
2102 62, -51, -9 /* VR VG VB */
2103 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002104
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002105 for (i = 0; i < 6; i++) {
2106 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002107 reg8a[i * 2] = v;
2108 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002109 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002110 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002111}
2112
2113static void setredblue(struct gspca_dev *gspca_dev)
2114{
2115 struct sd *sd = (struct sd *) gspca_dev;
2116
2117 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002118/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002119 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002120}
2121
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002122static void setgamma(struct gspca_dev *gspca_dev)
2123{
2124 struct sd *sd = (struct sd *) gspca_dev;
2125 int i;
2126 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002127 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002128 static const u8 delta[17] = {
2129 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2130 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2131 };
2132
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002133 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002134 case SENSOR_ADCM1700:
2135 gamma_base = gamma_spec_0;
2136 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002137 case SENSOR_HV7131R:
2138 case SENSOR_MT9V111:
2139 gamma_base = gamma_spec_1;
2140 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002141 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002142 gamma_base = gamma_spec_2;
2143 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002144 case SENSOR_SP80708:
2145 gamma_base = gamma_spec_3;
2146 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002147 default:
2148 gamma_base = gamma_def;
2149 break;
2150 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002151
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002152 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002153 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002154 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
2155 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2156}
2157
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002158static void setautogain(struct gspca_dev *gspca_dev)
2159{
2160 struct sd *sd = (struct sd *) gspca_dev;
2161
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002162 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
2163 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002164 switch (sd->sensor) {
2165 case SENSOR_OV7630:
2166 case SENSOR_OV7648: {
2167 u8 comb;
2168
2169 if (sd->sensor == SENSOR_OV7630)
2170 comb = 0xc0;
2171 else
2172 comb = 0xa0;
2173 if (sd->autogain)
Hans de Goede1fec7472009-06-18 06:05:07 -03002174 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002175 i2c_w1(&sd->gspca_dev, 0x13, comb);
2176 return;
2177 }
2178 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002179 if (sd->autogain)
2180 sd->ag_cnt = AG_CNT_START;
2181 else
2182 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002183}
2184
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002185/* hv7131r/ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002186static void setvflip(struct sd *sd)
2187{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002188 u8 comn;
2189
Jean-Francois Moine0939e262009-11-02 09:58:49 -03002190 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2191 return;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002192 switch (sd->sensor) {
2193 case SENSOR_HV7131R:
2194 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2195 if (sd->vflip)
2196 comn |= 0x01;
2197 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
2198 break;
2199 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002200 comn = 0x02;
Hans de Goedef8009522009-06-18 14:29:20 -03002201 if (!sd->vflip)
2202 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002203 i2c_w1(&sd->gspca_dev, 0x75, comn);
2204 break;
2205 default:
2206/* case SENSOR_OV7648: */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002207 comn = 0x06;
Hans de Goedef8009522009-06-18 14:29:20 -03002208 if (sd->vflip)
2209 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002210 i2c_w1(&sd->gspca_dev, 0x75, comn);
2211 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002212 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002213}
2214
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002215static void setsharpness(struct sd *sd)
2216{
2217 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
2218}
2219
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002220static void setinfrared(struct sd *sd)
2221{
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002222 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
2223 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002224/*fixme: different sequence for StarCam Clip and StarCam 370i */
2225/* Clip */
2226 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
2227 sd->infrared ? 0x66 : 0x64);
2228}
2229
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002230static void setfreq(struct gspca_dev *gspca_dev)
2231{
2232 struct sd *sd = (struct sd *) gspca_dev;
2233
Jean-Francois Moine27954932009-07-08 05:21:50 -03002234 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
2235 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002236 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002237 u8 com8;
2238
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002239 com8 = 0xdf; /* auto gain/wb/expo */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002240 switch (sd->freq) {
2241 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002242 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002243 break;
2244 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002245 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002246 i2c_w1(gspca_dev, 0x3b, 0x0a);
2247 break;
2248 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002249 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002250 i2c_w1(gspca_dev, 0x3b, 0x02);
2251 break;
2252 }
2253 } else {
2254 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2255
2256 /* Get reg2a / reg2d base values */
2257 switch (sd->sensor) {
2258 case SENSOR_OV7630:
2259 reg2a = 0x08;
2260 reg2d = 0x01;
2261 break;
2262 case SENSOR_OV7648:
2263 reg2a = 0x11;
2264 reg2d = 0x81;
2265 break;
2266 }
2267
2268 switch (sd->freq) {
2269 case 0: /* Banding filter disabled */
2270 break;
2271 case 1: /* 50 hz (filter on and framerate adj) */
2272 reg2a |= 0x80;
2273 reg2b = 0xac;
2274 reg2d |= 0x04;
2275 break;
2276 case 2: /* 60 hz (filter on, no framerate adj) */
2277 reg2a |= 0x80;
2278 reg2d |= 0x04;
2279 break;
2280 }
2281 i2c_w1(gspca_dev, 0x2a, reg2a);
2282 i2c_w1(gspca_dev, 0x2b, reg2b);
2283 i2c_w1(gspca_dev, 0x2d, reg2d);
2284 }
2285}
2286
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002287static void setjpegqual(struct gspca_dev *gspca_dev)
2288{
2289 struct sd *sd = (struct sd *) gspca_dev;
2290 int i, sc;
2291
2292 if (sd->jpegqual < 50)
2293 sc = 5000 / sd->jpegqual;
2294 else
2295 sc = 200 - sd->jpegqual * 2;
2296#if USB_BUF_SZ < 64
2297#error "No room enough in usb_buf for quantization table"
2298#endif
2299 for (i = 0; i < 64; i++)
2300 gspca_dev->usb_buf[i] =
2301 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2302 usb_control_msg(gspca_dev->dev,
2303 usb_sndctrlpipe(gspca_dev->dev, 0),
2304 0x08,
2305 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2306 0x0100, 0,
2307 gspca_dev->usb_buf, 64,
2308 500);
2309 for (i = 0; i < 64; i++)
2310 gspca_dev->usb_buf[i] =
2311 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2312 usb_control_msg(gspca_dev->dev,
2313 usb_sndctrlpipe(gspca_dev->dev, 0),
2314 0x08,
2315 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2316 0x0140, 0,
2317 gspca_dev->usb_buf, 64,
2318 500);
2319
2320 sd->reg18 ^= 0x40;
2321 reg_w1(gspca_dev, 0x18, sd->reg18);
2322}
2323
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002324/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002325static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002326{
2327 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002328 int i;
Jean-François Moine19697b52010-07-14 06:33:51 -03002329 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002330 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002331 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002332 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002333 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2334 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002335 static const u8 CA_adcm1700[] =
2336 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002337 static const u8 CA_po2030n[] =
2338 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002339 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002340 static const u8 CE_gc0307[] =
2341 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002342 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002343 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002344 static const u8 CE_po2030n[] =
2345 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002346
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002347 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002348 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2349 0x21); /* JPEG 422 */
2350 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2351
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002352 /* initialize the bridge */
2353 sn9c1xx = sn_tb[sd->sensor];
2354 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002355
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002356 /* initialize the sensor */
2357 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2358
Jean-Francois Moine60017612008-07-18 08:46:19 -03002359 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2360 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2361 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2362 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2363 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002364 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002365 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2366 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002367 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002368 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2369 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002370 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002371 reg_w1(gspca_dev, 0xc6, 0x00);
2372 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002373 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002374 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2375 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002376 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002377 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2378 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002379 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002380 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002381 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002382 case SENSOR_GC0307:
2383 reg17 = 0xa2;
2384 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002385 case SENSOR_MT9V111:
2386 reg17 = 0xe0;
2387 break;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002388 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002389 case SENSOR_OV7630:
2390 reg17 = 0xe2;
2391 break;
2392 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002393 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002394 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002395 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002396 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002397 reg17 = 0xa0;
2398 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002399 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002400 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002401 reg17 = 0xa0;
2402 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002403 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002404 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002405 break;
2406 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002407 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002408
2409 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2410 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2411 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002412 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002413
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002414 setgamma(gspca_dev);
2415
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002416/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002417 for (i = 0; i < 8; i++)
2418 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002419 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002420 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002421 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002422 case SENSOR_SP80708:
2423 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002424 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002425 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002426 case SENSOR_MT9V111:
2427 reg_w1(gspca_dev, 0x9a, 0x07);
2428 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002429 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002430 case SENSOR_OV7648:
2431 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002432 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002433 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002434 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002435 reg_w1(gspca_dev, 0x9a, 0x06);
2436 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002437 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002438 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002439 break;
2440 }
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002441 setsharpness(sd);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002442
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002443 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002444 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2445 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2446 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002447
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002448 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002449 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002450 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002451 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002452 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002453 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2454 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002455 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002456 case SENSOR_ADCM1700:
2457 init = adcm1700_sensor_param1;
2458 reg1 = 0x46;
2459 reg17 = 0xe2;
2460 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002461 case SENSOR_GC0307:
2462 init = gc0307_sensor_param1;
2463 reg17 = 0xa2;
2464 reg1 = 0x44;
2465 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002466 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002467 if (mode) {
2468/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2469 reg1 = 0x06; /* clk 24Mz */
2470 } else {
2471 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002472/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002473 }
2474 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002475 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002476 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002477 if (mode) {
2478 reg1 = 0x04; /* 320 clk 48Mhz */
2479 } else {
2480/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002481 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002482 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002483 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002484 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002485 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002486 reg17 = 0x64; /* 640 MCKSIZE */
2487 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002488 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002489 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002490 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002491 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002492 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002493 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002494 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002495 reg17 = 0x21;
2496/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002497 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002498 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002499 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002500 if (sd->bridge == BRIDGE_SN9C120) {
2501 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002502 reg17 = 0xa2;
2503 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002504 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002505 } else {
2506 reg17 = 0x22;
2507 reg1 = 0x06; /* 24 Mhz, video trf eneble
2508 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002509 }
2510 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002511 case SENSOR_PO1030:
2512 init = po1030_sensor_param1;
2513 reg17 = 0xa2;
2514 reg1 = 0x44;
2515 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002516 case SENSOR_PO2030N:
2517 init = po2030n_sensor_param1;
2518 reg1 = 0x46;
2519 reg17 = 0xa2;
2520 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002521 case SENSOR_SOI768:
2522 init = soi768_sensor_param1;
2523 reg1 = 0x44;
2524 reg17 = 0xa2;
2525 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002526 default:
2527/* case SENSOR_SP80708: */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002528 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002529 if (mode) {
2530/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002531 } else {
2532 reg1 = 0x46; /* 640 clk 48Mz */
2533 reg17 = 0xa2;
2534 }
2535 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002536 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002537
2538 /* more sensor initialization - param1 */
2539 if (init != NULL) {
2540 i2c_w_seq(gspca_dev, init);
2541/* init = NULL; */
2542 }
2543
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002544 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002545 switch (sd->sensor) {
2546 case SENSOR_ADCM1700:
2547 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002548 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002549 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002550 break;
2551 case SENSOR_PO2030N:
2552 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2553 break;
2554 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002555 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002556 break;
2557 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002558 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002559 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002560 case SENSOR_OV7630:
2561 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002562 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002563 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002564 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002565 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002566 case SENSOR_GC0307:
2567 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2568 break;
2569 case SENSOR_PO2030N:
2570 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2571 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002572 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002573 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002574 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2575 break;
2576 }
2577
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002578
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002579 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002580 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2581 reg_w1(gspca_dev, 0x18, sd->reg18);
2582 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002583
Jean-Francois Moine60017612008-07-18 08:46:19 -03002584 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002585 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002586
Jean-François Moine1e5eb112010-02-18 14:56:33 -03002587 setvflip(sd);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002588 setbrightness(gspca_dev);
2589 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002590 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002591 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002592 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002593 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002594}
2595
2596static void sd_stopN(struct gspca_dev *gspca_dev)
2597{
2598 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002599 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002600 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002601 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002602 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002603 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002604 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002605 static const u8 stopsoi768[] =
2606 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002607 u8 data;
2608 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002609
2610 data = 0x0b;
2611 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002612 case SENSOR_GC0307:
2613 data = 0x29;
2614 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002615 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002616 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002617 data = 0x2b;
2618 break;
2619 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002620 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002621 data = 0x29;
2622 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002623 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002624 i2c_w8(gspca_dev, stopov7648);
2625 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002626 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002627 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002628 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002629 data = 0x29;
2630 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002631 case SENSOR_SOI768:
2632 i2c_w8(gspca_dev, stopsoi768);
2633 data = 0x29;
2634 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002635 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002636 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002637 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2638 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2639 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2640 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002641 /* Don't disable sensor clock as that disables the button on the cam */
2642 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002643}
2644
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002645static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002646{
2647 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002648 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002649 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002650 u8 luma_mean = 130;
2651 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002652
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002653 /* Thanks S., without your advice, autobright should not work :) */
2654 if (sd->ag_cnt < 0)
2655 return;
2656 if (--sd->ag_cnt >= 0)
2657 return;
2658 sd->ag_cnt = AG_CNT_START;
2659
2660 delta = atomic_read(&sd->avg_lum);
2661 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002662 if (delta < luma_mean - luma_delta ||
2663 delta > luma_mean + luma_delta) {
2664 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002665 case SENSOR_GC0307:
2666 expotimes = sd->exposure;
2667 expotimes += (luma_mean - delta) >> 6;
2668 if (expotimes < 0)
2669 expotimes = 0;
2670 sd->exposure = setexposure(gspca_dev,
2671 (unsigned int) expotimes);
2672 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002673 case SENSOR_HV7131R:
2674 expotimes = sd->exposure >> 8;
2675 expotimes += (luma_mean - delta) >> 4;
2676 if (expotimes < 0)
2677 expotimes = 0;
2678 sd->exposure = setexposure(gspca_dev,
2679 (unsigned int) (expotimes << 8));
2680 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002681 case SENSOR_OM6802:
2682 expotimes = sd->exposure;
2683 expotimes += (luma_mean - delta) >> 2;
2684 if (expotimes < 0)
2685 expotimes = 0;
2686 sd->exposure = setexposure(gspca_dev,
2687 (unsigned int) expotimes);
2688 setredblue(gspca_dev);
2689 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002690 default:
2691/* case SENSOR_MO4000: */
2692/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002693/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002694 expotimes = sd->exposure;
2695 expotimes += (luma_mean - delta) >> 6;
2696 if (expotimes < 0)
2697 expotimes = 0;
2698 sd->exposure = setexposure(gspca_dev,
2699 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002700 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002701 break;
2702 }
2703 }
2704}
2705
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002706/* scan the URB packets */
2707/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002708static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002709 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002710 int len) /* iso packet length */
2711{
2712 struct sd *sd = (struct sd *) gspca_dev;
2713 int sof, avg_lum;
2714
2715 sof = len - 64;
2716 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2717
2718 /* end of frame */
2719 gspca_frame_add(gspca_dev, LAST_PACKET,
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002720 data, sof + 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002721 if (sd->ag_cnt < 0)
2722 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002723/* w1 w2 w3 */
2724/* w4 w5 w6 */
2725/* w7 w8 */
2726/* w4 */
2727 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2728/* w6 */
2729 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2730/* w2 */
2731 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2732/* w8 */
2733 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2734/* w5 */
2735 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2736 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002737 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002738 return;
2739 }
2740 if (gspca_dev->last_packet_type == LAST_PACKET) {
2741
2742 /* put the JPEG 422 header */
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002743 gspca_frame_add(gspca_dev, FIRST_PACKET,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002744 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002745 }
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002746 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002747}
2748
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002749static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2750{
2751 struct sd *sd = (struct sd *) gspca_dev;
2752
2753 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002754 if (gspca_dev->streaming)
2755 setbrightness(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002756 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002757}
2758
2759static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2760{
2761 struct sd *sd = (struct sd *) gspca_dev;
2762
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002763 *val = sd->brightness;
2764 return 0;
2765}
2766
2767static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2768{
2769 struct sd *sd = (struct sd *) gspca_dev;
2770
2771 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002772 if (gspca_dev->streaming)
2773 setcontrast(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002774 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002775}
2776
2777static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2778{
2779 struct sd *sd = (struct sd *) gspca_dev;
2780
2781 *val = sd->contrast;
2782 return 0;
2783}
2784
2785static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2786{
2787 struct sd *sd = (struct sd *) gspca_dev;
2788
2789 sd->colors = val;
2790 if (gspca_dev->streaming)
2791 setcolors(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002792 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002793}
2794
2795static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2796{
2797 struct sd *sd = (struct sd *) gspca_dev;
2798
2799 *val = sd->colors;
2800 return 0;
2801}
2802
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002803static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2804{
2805 struct sd *sd = (struct sd *) gspca_dev;
2806
2807 sd->blue = val;
2808 if (gspca_dev->streaming)
2809 setredblue(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002810 return gspca_dev->usb_err;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002811}
2812
2813static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2814{
2815 struct sd *sd = (struct sd *) gspca_dev;
2816
2817 *val = sd->blue;
2818 return 0;
2819}
2820
2821static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2822{
2823 struct sd *sd = (struct sd *) gspca_dev;
2824
2825 sd->red = val;
2826 if (gspca_dev->streaming)
2827 setredblue(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002828 return gspca_dev->usb_err;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002829}
2830
2831static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2832{
2833 struct sd *sd = (struct sd *) gspca_dev;
2834
2835 *val = sd->red;
2836 return 0;
2837}
2838
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002839static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2840{
2841 struct sd *sd = (struct sd *) gspca_dev;
2842
2843 sd->gamma = val;
2844 if (gspca_dev->streaming)
2845 setgamma(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002846 return gspca_dev->usb_err;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002847}
2848
2849static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2850{
2851 struct sd *sd = (struct sd *) gspca_dev;
2852
2853 *val = sd->gamma;
2854 return 0;
2855}
2856
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002857static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2858{
2859 struct sd *sd = (struct sd *) gspca_dev;
2860
2861 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002862 if (gspca_dev->streaming)
2863 setautogain(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002864 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002865}
2866
2867static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2868{
2869 struct sd *sd = (struct sd *) gspca_dev;
2870
2871 *val = sd->autogain;
2872 return 0;
2873}
2874
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002875static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2876{
2877 struct sd *sd = (struct sd *) gspca_dev;
2878
2879 sd->sharpness = val;
2880 if (gspca_dev->streaming)
2881 setsharpness(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002882 return gspca_dev->usb_err;
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002883}
2884
2885static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2886{
2887 struct sd *sd = (struct sd *) gspca_dev;
2888
2889 *val = sd->sharpness;
2890 return 0;
2891}
2892
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002893static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2894{
2895 struct sd *sd = (struct sd *) gspca_dev;
2896
2897 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002898 if (gspca_dev->streaming)
2899 setvflip(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002900 return gspca_dev->usb_err;
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002901}
2902
2903static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2904{
2905 struct sd *sd = (struct sd *) gspca_dev;
2906
2907 *val = sd->vflip;
2908 return 0;
2909}
2910
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002911static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2912{
2913 struct sd *sd = (struct sd *) gspca_dev;
2914
2915 sd->infrared = val;
2916 if (gspca_dev->streaming)
2917 setinfrared(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002918 return gspca_dev->usb_err;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002919}
2920
2921static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2922{
2923 struct sd *sd = (struct sd *) gspca_dev;
2924
2925 *val = sd->infrared;
2926 return 0;
2927}
2928
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002929static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2930{
2931 struct sd *sd = (struct sd *) gspca_dev;
2932
2933 sd->freq = val;
2934 if (gspca_dev->streaming)
2935 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002936 return gspca_dev->usb_err;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002937}
2938
2939static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2940{
2941 struct sd *sd = (struct sd *) gspca_dev;
2942
2943 *val = sd->freq;
2944 return 0;
2945}
2946
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002947static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2948 struct v4l2_jpegcompression *jcomp)
2949{
2950 struct sd *sd = (struct sd *) gspca_dev;
2951
2952 if (jcomp->quality < QUALITY_MIN)
2953 sd->quality = QUALITY_MIN;
2954 else if (jcomp->quality > QUALITY_MAX)
2955 sd->quality = QUALITY_MAX;
2956 else
2957 sd->quality = jcomp->quality;
2958 if (gspca_dev->streaming)
2959 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2960 return 0;
2961}
2962
2963static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2964 struct v4l2_jpegcompression *jcomp)
2965{
2966 struct sd *sd = (struct sd *) gspca_dev;
2967
2968 memset(jcomp, 0, sizeof *jcomp);
2969 jcomp->quality = sd->quality;
2970 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2971 | V4L2_JPEG_MARKER_DQT;
2972 return 0;
2973}
2974
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002975static int sd_querymenu(struct gspca_dev *gspca_dev,
2976 struct v4l2_querymenu *menu)
2977{
2978 switch (menu->id) {
2979 case V4L2_CID_POWER_LINE_FREQUENCY:
2980 switch (menu->index) {
2981 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2982 strcpy((char *) menu->name, "NoFliker");
2983 return 0;
2984 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2985 strcpy((char *) menu->name, "50 Hz");
2986 return 0;
2987 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2988 strcpy((char *) menu->name, "60 Hz");
2989 return 0;
2990 }
2991 break;
2992 }
2993 return -EINVAL;
2994}
2995
Hans de Goede9712a8b2010-01-31 12:54:29 -03002996#ifdef CONFIG_INPUT
2997static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2998 u8 *data, /* interrupt packet data */
2999 int len) /* interrupt packet length */
3000{
3001 int ret = -EINVAL;
3002
3003 if (len == 1 && data[0] == 1) {
3004 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
3005 input_sync(gspca_dev->input_dev);
3006 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
3007 input_sync(gspca_dev->input_dev);
3008 ret = 0;
3009 }
3010
3011 return ret;
3012}
3013#endif
3014
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003015/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03003016static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003017 .name = MODULE_NAME,
3018 .ctrls = sd_ctrls,
3019 .nctrls = ARRAY_SIZE(sd_ctrls),
3020 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03003021 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003022 .start = sd_start,
3023 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003024 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03003025 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03003026 .get_jcomp = sd_get_jcomp,
3027 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003028 .querymenu = sd_querymenu,
Hans de Goede9712a8b2010-01-31 12:54:29 -03003029#ifdef CONFIG_INPUT
3030 .int_pkt_scan = sd_int_pkt_scan,
3031#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003032};
3033
3034/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003035#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03003036 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003037 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03003038static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03003039#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003040 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
3041 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03003042#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003043 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
3044 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
3045 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
3046 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
3047 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
3048 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
3049 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
3050/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
3051 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
3052/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
3053/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
3054 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3055/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3056 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
3057/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3058/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3059/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03003060 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003061 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
3062/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
3063/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03003064/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003065 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003066#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003067 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3068 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003069#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003070 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03003071 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003072/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3073 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3074 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3075 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3076 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3077/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3078/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3079/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3080 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003081/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003082 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003083 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003084 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3085 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3086/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03003087#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003088 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003089#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003090/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3091 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3092 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003093#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003094 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03003095#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003096 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3097 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003098 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003099 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003100 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3101 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine64677572009-12-20 12:31:28 -03003102 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003103 {}
3104};
3105MODULE_DEVICE_TABLE(usb, device_table);
3106
3107/* -- device connect -- */
3108static int sd_probe(struct usb_interface *intf,
3109 const struct usb_device_id *id)
3110{
3111 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3112 THIS_MODULE);
3113}
3114
3115static struct usb_driver sd_driver = {
3116 .name = MODULE_NAME,
3117 .id_table = device_table,
3118 .probe = sd_probe,
3119 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003120#ifdef CONFIG_PM
3121 .suspend = gspca_suspend,
3122 .resume = gspca_resume,
3123#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003124};
3125
3126/* -- module insert / remove -- */
3127static int __init sd_mod_init(void)
3128{
Jean-François Moine54826432010-09-13 04:53:03 -03003129 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003130}
3131static void __exit sd_mod_exit(void)
3132{
3133 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003134}
3135
3136module_init(sd_mod_init);
3137module_exit(sd_mod_exit);