blob: 72f830a6572cc26b1df4978cbcfd7d33a8c3533c [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,
Jean-François Moinea067db82010-10-01 07:51:24 -030078 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030079 SENSOR_MO4000,
80 SENSOR_MT9V111,
81 SENSOR_OM6802,
82 SENSOR_OV7630,
83 SENSOR_OV7648,
84 SENSOR_OV7660,
85 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030086 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030087 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030088 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030089};
90
91/* V4L2 controls supported by the driver */
92static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
93static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
94static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
95static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
96static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030098static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
100static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
101static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300102static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
103static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300104static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
105static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300106static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
107static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300108static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
109static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300110static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
111static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300112static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
113static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300114
Marton Nemeth7e64dc42009-12-30 09:12:41 -0300115static const struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300116#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300117 {
118 {
119 .id = V4L2_CID_BRIGHTNESS,
120 .type = V4L2_CTRL_TYPE_INTEGER,
121 .name = "Brightness",
122 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300123#define BRIGHTNESS_MAX 0xffff
124 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300125 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300126#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300127 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300128 },
129 .set = sd_setbrightness,
130 .get = sd_getbrightness,
131 },
Hans de Goede97643982009-06-18 05:08:11 -0300132#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300133 {
134 {
135 .id = V4L2_CID_CONTRAST,
136 .type = V4L2_CTRL_TYPE_INTEGER,
137 .name = "Contrast",
138 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300139#define CONTRAST_MAX 127
140 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300141 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300142#define CONTRAST_DEF 63
143 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300144 },
145 .set = sd_setcontrast,
146 .get = sd_getcontrast,
147 },
Hans de Goede97643982009-06-18 05:08:11 -0300148#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300149 {
150 {
151 .id = V4L2_CID_SATURATION,
152 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300153 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300154 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300155 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300156 .step = 1,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300157#define COLOR_DEF 25
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300158 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300159 },
160 .set = sd_setcolors,
161 .get = sd_getcolors,
162 },
Hans de Goede97643982009-06-18 05:08:11 -0300163#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300164 {
165 {
166 .id = V4L2_CID_BLUE_BALANCE,
167 .type = V4L2_CTRL_TYPE_INTEGER,
168 .name = "Blue Balance",
169 .minimum = 24,
170 .maximum = 40,
171 .step = 1,
172#define BLUE_BALANCE_DEF 32
173 .default_value = BLUE_BALANCE_DEF,
174 },
175 .set = sd_setblue_balance,
176 .get = sd_getblue_balance,
177 },
Hans de Goede97643982009-06-18 05:08:11 -0300178#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300179 {
180 {
181 .id = V4L2_CID_RED_BALANCE,
182 .type = V4L2_CTRL_TYPE_INTEGER,
183 .name = "Red Balance",
184 .minimum = 24,
185 .maximum = 40,
186 .step = 1,
187#define RED_BALANCE_DEF 32
188 .default_value = RED_BALANCE_DEF,
189 },
190 .set = sd_setred_balance,
191 .get = sd_getred_balance,
192 },
Hans de Goede97643982009-06-18 05:08:11 -0300193#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300194 {
195 {
196 .id = V4L2_CID_GAMMA,
197 .type = V4L2_CTRL_TYPE_INTEGER,
198 .name = "Gamma",
199 .minimum = 0,
200 .maximum = 40,
201 .step = 1,
202#define GAMMA_DEF 20
203 .default_value = GAMMA_DEF,
204 },
205 .set = sd_setgamma,
206 .get = sd_getgamma,
207 },
Hans de Goede97643982009-06-18 05:08:11 -0300208#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300209 {
210 {
211 .id = V4L2_CID_AUTOGAIN,
212 .type = V4L2_CTRL_TYPE_BOOLEAN,
213 .name = "Auto Gain",
214 .minimum = 0,
215 .maximum = 1,
216 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300217#define AUTOGAIN_DEF 1
218 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300219 },
220 .set = sd_setautogain,
221 .get = sd_getautogain,
222 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300223/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300224#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300225 {
226 {
227 .id = V4L2_CID_VFLIP,
228 .type = V4L2_CTRL_TYPE_BOOLEAN,
229 .name = "Vflip",
230 .minimum = 0,
231 .maximum = 1,
232 .step = 1,
Hans de Goedef8009522009-06-18 14:29:20 -0300233#define VFLIP_DEF 0
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300234 .default_value = VFLIP_DEF,
235 },
236 .set = sd_setvflip,
237 .get = sd_getvflip,
238 },
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300239#define SHARPNESS_IDX 8
240 {
241 {
242 .id = V4L2_CID_SHARPNESS,
243 .type = V4L2_CTRL_TYPE_INTEGER,
244 .name = "Sharpness",
245 .minimum = 0,
246 .maximum = 255,
247 .step = 1,
248#define SHARPNESS_DEF 90
249 .default_value = SHARPNESS_DEF,
250 },
251 .set = sd_setsharpness,
252 .get = sd_getsharpness,
253 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300254/* mt9v111 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300255#define INFRARED_IDX 9
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300256 {
257 {
258 .id = V4L2_CID_INFRARED,
259 .type = V4L2_CTRL_TYPE_BOOLEAN,
260 .name = "Infrared",
261 .minimum = 0,
262 .maximum = 1,
263 .step = 1,
264#define INFRARED_DEF 0
265 .default_value = INFRARED_DEF,
266 },
267 .set = sd_setinfrared,
268 .get = sd_getinfrared,
269 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300270/* ov7630/ov7648/ov7660 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300271#define FREQ_IDX 10
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300272 {
273 {
274 .id = V4L2_CID_POWER_LINE_FREQUENCY,
275 .type = V4L2_CTRL_TYPE_MENU,
276 .name = "Light frequency filter",
277 .minimum = 0,
278 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
279 .step = 1,
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300280#define FREQ_DEF 1
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300281 .default_value = FREQ_DEF,
282 },
283 .set = sd_setfreq,
284 .get = sd_getfreq,
285 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300286};
287
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300288/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300289static const __u32 ctrl_dis[] = {
290[SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) |
291 (1 << INFRARED_IDX) |
292 (1 << VFLIP_IDX) |
293 (1 << FREQ_IDX),
294
Jean-François Moinec26b12d2010-04-02 07:08:39 -0300295[SENSOR_GC0307] = (1 << INFRARED_IDX) |
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300296 (1 << VFLIP_IDX) |
297 (1 << FREQ_IDX),
298
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300299[SENSOR_HV7131R] = (1 << INFRARED_IDX) |
300 (1 << FREQ_IDX),
301
302[SENSOR_MI0360] = (1 << INFRARED_IDX) |
303 (1 << VFLIP_IDX) |
304 (1 << FREQ_IDX),
305
Jean-François Moinea067db82010-10-01 07:51:24 -0300306[SENSOR_MI0360B] = (1 << INFRARED_IDX) |
307 (1 << VFLIP_IDX) |
308 (1 << FREQ_IDX),
309
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300310[SENSOR_MO4000] = (1 << INFRARED_IDX) |
311 (1 << VFLIP_IDX) |
312 (1 << FREQ_IDX),
313
314[SENSOR_MT9V111] = (1 << VFLIP_IDX) |
315 (1 << FREQ_IDX),
316
317[SENSOR_OM6802] = (1 << INFRARED_IDX) |
318 (1 << VFLIP_IDX) |
319 (1 << FREQ_IDX),
320
321[SENSOR_OV7630] = (1 << INFRARED_IDX),
322
323[SENSOR_OV7648] = (1 << INFRARED_IDX),
324
325[SENSOR_OV7660] = (1 << AUTOGAIN_IDX) |
326 (1 << INFRARED_IDX) |
327 (1 << VFLIP_IDX),
328
329[SENSOR_PO1030] = (1 << AUTOGAIN_IDX) |
330 (1 << INFRARED_IDX) |
331 (1 << VFLIP_IDX) |
332 (1 << FREQ_IDX),
333
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300334[SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) |
335 (1 << INFRARED_IDX) |
336 (1 << VFLIP_IDX) |
337 (1 << FREQ_IDX),
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300338[SENSOR_SOI768] = (1 << AUTOGAIN_IDX) |
339 (1 << INFRARED_IDX) |
340 (1 << VFLIP_IDX) |
341 (1 << FREQ_IDX),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300342
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300343[SENSOR_SP80708] = (1 << AUTOGAIN_IDX) |
344 (1 << INFRARED_IDX) |
345 (1 << VFLIP_IDX) |
346 (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300347};
348
Jean-Francois Moine646775732009-12-20 12:31:28 -0300349static const struct v4l2_pix_format cif_mode[] = {
350 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
351 .bytesperline = 352,
352 .sizeimage = 352 * 288 * 4 / 8 + 590,
353 .colorspace = V4L2_COLORSPACE_JPEG,
354 .priv = 0},
355};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300356static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300357 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
358 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300359 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300360 .colorspace = V4L2_COLORSPACE_JPEG,
361 .priv = 2},
362 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
363 .bytesperline = 320,
364 .sizeimage = 320 * 240 * 3 / 8 + 590,
365 .colorspace = V4L2_COLORSPACE_JPEG,
366 .priv = 1},
367 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
368 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300369 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
370 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300371 .colorspace = V4L2_COLORSPACE_JPEG,
372 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300373};
374
Jean-Francois Moine646775732009-12-20 12:31:28 -0300375static const u8 sn_adcm1700[0x1c] = {
376/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300377 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine646775732009-12-20 12:31:28 -0300378/* reg8 reg9 rega regb regc regd rege regf */
379 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
381 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
382/* reg18 reg19 reg1a reg1b */
383 0x06, 0x00, 0x00, 0x00
384};
385
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300386static const u8 sn_gc0307[0x1c] = {
387/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
388 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
389/* reg8 reg9 rega regb regc regd rege regf */
390 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
391/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
392 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
393/* reg18 reg19 reg1a reg1b */
394 0x06, 0x00, 0x00, 0x00
395};
396
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300397static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300398/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300399 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300400/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300401 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300402/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
403 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300404/* reg18 reg19 reg1a reg1b */
405 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300406};
407
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300408static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300409/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300410 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300411/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300412 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300413/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
414 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300415/* reg18 reg19 reg1a reg1b */
416 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300417};
418
Jean-François Moinea067db82010-10-01 07:51:24 -0300419static const u8 sn_mi0360b[0x1c] = {
420/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
421 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
422/* reg8 reg9 rega regb regc regd rege regf */
423 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
424/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
425 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
426/* reg18 reg19 reg1a reg1b */
427 0x06, 0x00, 0x00, 0x00
428};
429
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300430static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300431/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300432 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300433/* reg8 reg9 rega regb regc regd rege regf */
434 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
435/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
436 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300437/* reg18 reg19 reg1a reg1b */
438 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300439};
440
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300441static const u8 sn_mt9v111[0x1c] = {
442/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
443 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
444/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300445 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300446/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
447 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
448/* reg18 reg19 reg1a reg1b */
449 0x06, 0x00, 0x00, 0x00
450};
451
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300452static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300453/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300454 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300455/* reg8 reg9 rega regb regc regd rege regf */
456 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
458 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300459/* reg18 reg19 reg1a reg1b */
460 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300461};
462
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300463static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300464/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300465 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300466/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300467 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300468/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
469 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300470/* reg18 reg19 reg1a reg1b */
471 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300472};
473
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300474static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300475/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300476 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300477/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300478 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300479/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300480 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300481/* reg18 reg19 reg1a reg1b */
482 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300483};
484
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300485static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300486/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300487 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300488/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300489 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300490/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
491 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300492/* reg18 reg19 reg1a reg1b */
493 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300494};
495
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300496static const u8 sn_po1030[0x1c] = {
497/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
498 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
499/* reg8 reg9 rega regb regc regd rege regf */
500 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
501/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
502 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
503/* reg18 reg19 reg1a reg1b */
504 0x07, 0x00, 0x00, 0x00
505};
506
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300507static const u8 sn_po2030n[0x1c] = {
508/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
509 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
510/* reg8 reg9 rega regb regc regd rege regf */
511 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
513 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
514/* reg18 reg19 reg1a reg1b */
515 0x07, 0x00, 0x00, 0x00
516};
517
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300518static const u8 sn_soi768[0x1c] = {
519/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
520 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
521/* reg8 reg9 rega regb regc regd rege regf */
522 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
524 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
525/* reg18 reg19 reg1a reg1b */
526 0x07, 0x00, 0x00, 0x00
527};
528
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300529static const u8 sn_sp80708[0x1c] = {
530/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
531 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
532/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300533 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300534/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
535 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
536/* reg18 reg19 reg1a reg1b */
537 0x07, 0x00, 0x00, 0x00
538};
539
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300540/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300541static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300542[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300543[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300544[SENSOR_HV7131R] = sn_hv7131,
545[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300546[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300547[SENSOR_MO4000] = sn_mo4000,
548[SENSOR_MT9V111] = sn_mt9v111,
549[SENSOR_OM6802] = sn_om6802,
550[SENSOR_OV7630] = sn_ov7630,
551[SENSOR_OV7648] = sn_ov7648,
552[SENSOR_OV7660] = sn_ov7660,
553[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300554[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300555[SENSOR_SOI768] = sn_soi768,
556[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300557};
558
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300559/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300560static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300561 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
562 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
563};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300564/* gamma for sensor ADCM1700 */
565static const u8 gamma_spec_0[17] = {
566 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
567 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
568};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300569/* gamma for sensors HV7131R and MT9V111 */
570static const u8 gamma_spec_1[17] = {
571 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
572 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
573};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300574/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300575static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300576 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
577 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
578};
579/* gamma for sensor SP80708 */
580static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300581 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
582 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
583};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300584
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300585/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300586static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300587 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
588 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
589 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
590 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300591};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300592static const u8 adcm1700_sensor_init[][8] = {
593 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300594 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300595 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
596 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
598 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
599 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
600 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
601 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
602 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
603 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
604 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
605 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
606 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
609 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
610 {}
611};
612static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300613 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300614 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
615
616 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
617 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
619 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300620 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300621
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300622 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
623 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
625 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300626 {}
627};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300628static const u8 gc0307_sensor_init[][8] = {
629 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
649 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
650 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
666 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
667 {}
668};
669static const u8 gc0307_sensor_param1[][8] = {
670 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
671 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
672 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
673 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
674/*param3*/
675 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
676 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300677 {}
678};
679
Jean-Francois Moine98819182009-01-19 07:37:33 -0300680static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300681 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
682 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
683 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
684/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
685 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
687/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300688
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300689 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
691 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
692 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
693 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
694 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
695 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
696 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300697
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300698 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
699 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300700 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300701 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
702 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300703
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300704 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
705 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
706 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
707 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300709 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
710 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300711 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300712};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300713static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300714 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300715 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300716 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300717 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
718 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
719 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
720 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
722 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
724 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
726 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
727 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
730 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300736 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300737 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
739 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
741 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
743 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
746 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300747
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300748 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
749 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
750 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
752 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300753
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300754 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
755 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
756 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
757 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300758
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300759 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
760 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
761/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
762/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
763 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
764 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300765 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300766};
Jean-François Moinea067db82010-10-01 07:51:24 -0300767static const u8 mi0360b_sensor_init[][8] = {
768 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
769 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
770 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
771 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
773 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
774 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
775 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
792 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
793 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
795 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
797 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
798 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
799 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
801 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
802 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
803
804 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
808 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
809 {}
810};
811static const u8 mi0360b_sensor_param1[][8] = {
812 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
813 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
814 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
815 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
816
817 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
818 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
819 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
820 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
821 {}
822};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300823static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300824 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300844 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300845};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300846static const u8 mt9v111_sensor_init[][8] = {
847 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300848 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300849 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
850 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
851 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
852 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300853 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
854 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
855 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
856 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300857 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300858 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
859 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
860 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
861 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
862 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300863 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300864 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300865 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
866 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
867 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
868 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
869 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
870 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
871 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
872 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
873 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
874 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300875 {}
876};
877static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300878 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
879 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300880 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300881 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
882 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
883 /*******/
884 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
885 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
886 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
887 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
888 {}
889};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300890static const u8 om6802_init0[2][8] = {
891/*fixme: variable*/
892 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
893 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
894};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300895static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300896 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
897 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300898 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300899 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300900 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300901/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
902 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300903 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300904/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
905 * set color mode */
906/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
907 * max AGC value in AE */
908/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
909 * preset AGC */
910/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
911 * preset brightness */
912/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
913 * preset contrast */
914/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
915 * preset gamma */
916 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300917 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300918 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
919 /* preset shutter */
920/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
921 * auto frame rate */
922/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300923 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
924 {}
925};
926static const u8 om6802_sensor_param1[][8] = {
927 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
928 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
929 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
930 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300931 {}
932};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300933static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300934 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
935 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300936 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300937 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
938 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300939 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300940 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300941/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300942 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
943 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300944/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
945 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
946 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300947 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
948 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
949 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
950 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
951 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
952 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
953 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
954 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
955 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
956 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
957 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
958 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
959 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
960 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
961 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
962 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
963 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
964 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
965 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
966 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
967 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
968 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
969 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300970 {}
971};
972static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300973 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
974 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
975/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300976/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
977 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300978 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
979 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
980 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300981/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300982/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
983/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300984/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300985 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300986/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300987 {}
988};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300989
Jean-Francois Moine98819182009-01-19 07:37:33 -0300990static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300991 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
992 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300993 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300994 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
995 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
996 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
997 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
998 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
999 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
1000 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1001 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1002 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1003 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1004 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1005 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1006 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1007 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1008 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1009 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1010 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1011 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1012 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1013
1014 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1015/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1016/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001017/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001018 {}
1019};
1020static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001021/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001022/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1023 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001024 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1025 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1026/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1027/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1028/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1029/*...*/
1030 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1031/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1032/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1033/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1034/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1035/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1036
1037 {}
1038};
1039
Jean-Francois Moine98819182009-01-19 07:37:33 -03001040static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001041 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001042 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001043 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001044 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001045 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001046 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001047 /* GAIN BLUE RED VREF */
1048 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1049 /* COM 1 BAVE GEAVE AECHH */
1050 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1051 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001052 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001053 /* AECH CLKRC COM7 COM8 */
1054 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1055 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1056 /* HSTART HSTOP VSTRT VSTOP */
1057 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1058 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1059 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1060 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001061/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1062 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001063 /* AEW AEB VPT BBIAS */
1064 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1065 /* GbBIAS RSVD EXHCH EXHCL */
1066 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1067 /* RBIAS ADVFL ASDVFH YAVE */
1068 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1069 /* HSYST HSYEN HREF */
1070 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1071 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1072 /* ADC ACOM OFON TSLB */
1073 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1074 /* COM11 COM12 COM13 COM14 */
1075 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1076 /* EDGE COM15 COM16 COM17 */
1077 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1078 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1079 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1080 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1081 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1082 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1083 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1084 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1085 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1086 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1087 /* LCC1 LCC2 LCC3 LCC4 */
1088 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001089 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001090 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001091 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001092 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1093 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1094 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1095 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1096 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1097 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1098 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1099 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1100 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001101 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001102/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001103 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001104 {}
1105};
1106static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001107 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001108 /* bits[3..0]reserved */
1109 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1110 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1111 /* VREF vertical frame ctrl */
1112 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001113 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1114 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1115 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1116 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1117/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001118/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001119/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001120 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001121 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1122 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1123 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1124/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001125/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001126/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001127/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001128 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1129 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1130 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001132 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001133};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001134
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001135static const u8 po1030_sensor_init[][8] = {
1136/* the sensor registers are described in m5602/m5602_po1030.h */
1137 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1138 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1139 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1141 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1142 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1143 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1144 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1145 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1146 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1148 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1149 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1150 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1151 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1152 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1153 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1154 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1155 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1156 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1157 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1158 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1159 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1160 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1161 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1162 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1163 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1165
1166 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1167 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1169 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1170 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1171 {}
1172};
1173static const u8 po1030_sensor_param1[][8] = {
1174/* from ms-win traces - these values change with auto gain/expo/wb.. */
1175 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1176 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1177/* mean values */
1178 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1179 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1180 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1181
1182 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1183 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1184 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1185/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1186 {}
1187};
1188
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001189static const u8 po2030n_sensor_init[][8] = {
1190 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1191 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1192 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1193 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1194 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1195 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1196 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1199 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1202 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1203 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1204 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1207 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1208 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1209 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1216 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1217 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1226 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1230 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1231 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1234 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1235 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1236 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1237 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1239 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1240 {}
1241};
1242static const u8 po2030n_sensor_param1[][8] = {
1243 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1244 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1245 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1246 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1247 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1248/*param2*/
1249 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1253 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1254 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1255 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1256/*after start*/
1257 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1258 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1259 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1260 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1261 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1262 {}
1263};
1264
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001265static const u8 soi768_sensor_init[][8] = {
1266 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1267 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1268 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1271 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1272 {}
1273};
1274static const u8 soi768_sensor_param1[][8] = {
1275 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1279 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1280/* */
1281/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1282/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1283 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1284/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1285 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1286/* the next sequence should be used for auto gain */
1287 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1288 /* global gain ? : 07 - change with 0x15 at the end */
1289 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1290 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1291 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1292 /* exposure ? : 0200 - change with 0x1e at the end */
1293 {}
1294};
1295
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001296static const u8 sp80708_sensor_init[][8] = {
1297 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001368 {}
1369};
1370static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001371 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1374 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1375 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1376 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1377 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1378 {}
1379};
1380
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001381static const u8 (*sensor_init[])[8] = {
1382[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001383[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001384[SENSOR_HV7131R] = hv7131r_sensor_init,
1385[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001386[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001387[SENSOR_MO4000] = mo4000_sensor_init,
1388[SENSOR_MT9V111] = mt9v111_sensor_init,
1389[SENSOR_OM6802] = om6802_sensor_init,
1390[SENSOR_OV7630] = ov7630_sensor_init,
1391[SENSOR_OV7648] = ov7648_sensor_init,
1392[SENSOR_OV7660] = ov7660_sensor_init,
1393[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001394[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001395[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001396[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001397};
1398
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001399/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001400static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001401 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001402{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001403 int ret;
1404
1405 if (gspca_dev->usb_err < 0)
1406 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001407#ifdef GSPCA_DEBUG
1408 if (len > USB_BUF_SZ) {
1409 err("reg_r: buffer overflow");
1410 return;
1411 }
1412#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001413 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001414 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001415 0,
1416 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1417 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001418 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001419 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001420 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001421 if (ret < 0) {
1422 err("reg_r err %d", ret);
1423 gspca_dev->usb_err = ret;
1424 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001425}
1426
Jean-Francois Moine60017612008-07-18 08:46:19 -03001427static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001428 u16 value,
1429 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001430{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001431 int ret;
1432
1433 if (gspca_dev->usb_err < 0)
1434 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001435 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001436 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001437 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001438 usb_sndctrlpipe(gspca_dev->dev, 0),
1439 0x08,
1440 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1441 value,
1442 0,
1443 gspca_dev->usb_buf, 1,
1444 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001445 if (ret < 0) {
1446 err("reg_w1 err %d", ret);
1447 gspca_dev->usb_err = ret;
1448 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001449}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001450static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001451 u16 value,
1452 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001453 int len)
1454{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001455 int ret;
1456
1457 if (gspca_dev->usb_err < 0)
1458 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001459 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001460 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001461#ifdef GSPCA_DEBUG
1462 if (len > USB_BUF_SZ) {
1463 err("reg_w: buffer overflow");
1464 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001465 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001466#endif
1467 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001468 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001469 usb_sndctrlpipe(gspca_dev->dev, 0),
1470 0x08,
1471 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1472 value, 0,
1473 gspca_dev->usb_buf, len,
1474 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001475 if (ret < 0) {
1476 err("reg_w err %d", ret);
1477 gspca_dev->usb_err = ret;
1478 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001479}
1480
Jean-Francois Moine60017612008-07-18 08:46:19 -03001481/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001482static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001483{
1484 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001485 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001486
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001487 if (gspca_dev->usb_err < 0)
1488 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001489 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001490 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001491 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001492 case SENSOR_OM6802:
1493 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001494 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1495 break;
1496 default: /* i2c command = a1 (400 kHz) */
1497 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1498 break;
1499 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001500 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001501 gspca_dev->usb_buf[2] = reg;
1502 gspca_dev->usb_buf[3] = val;
1503 gspca_dev->usb_buf[4] = 0;
1504 gspca_dev->usb_buf[5] = 0;
1505 gspca_dev->usb_buf[6] = 0;
1506 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001507 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001508 usb_sndctrlpipe(gspca_dev->dev, 0),
1509 0x08,
1510 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1511 0x08, /* value = i2c */
1512 0,
1513 gspca_dev->usb_buf, 8,
1514 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001515 if (ret < 0) {
1516 err("i2c_w1 err %d", ret);
1517 gspca_dev->usb_err = ret;
1518 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001519}
1520
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001521/* I2C write 8 bytes */
1522static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001523 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001524{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001525 int ret;
1526
1527 if (gspca_dev->usb_err < 0)
1528 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001529 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1530 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001531 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001532 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001533 usb_sndctrlpipe(gspca_dev->dev, 0),
1534 0x08,
1535 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1536 0x08, 0, /* value, index */
1537 gspca_dev->usb_buf, 8,
1538 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001539 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001540 if (ret < 0) {
1541 err("i2c_w8 err %d", ret);
1542 gspca_dev->usb_err = ret;
1543 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001544}
1545
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001546/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1547static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001548{
1549 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001550 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001551
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001552 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001553 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001554 case SENSOR_OM6802:
1555 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001556 mode[0] = 0x80 | 0x10;
1557 break;
1558 default: /* i2c command = 91 (400 kHz) */
1559 mode[0] = 0x81 | 0x10;
1560 break;
1561 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001562 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001563 mode[2] = reg;
1564 mode[3] = 0;
1565 mode[4] = 0;
1566 mode[5] = 0;
1567 mode[6] = 0;
1568 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001569 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001570 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001571 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001572 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001573 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001574 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001575 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001576}
1577
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001578static void i2c_w_seq(struct gspca_dev *gspca_dev,
1579 const u8 (*data)[8])
1580{
1581 while ((*data)[0] != 0) {
1582 if ((*data)[0] != 0xdd)
1583 i2c_w8(gspca_dev, *data);
1584 else
1585 msleep((*data)[1]);
1586 data++;
1587 }
1588}
1589
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001590static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001591{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001592 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001593 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001594 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001595 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001596 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001597 if (gspca_dev->usb_buf[0] == 0x02
1598 && gspca_dev->usb_buf[1] == 0x09
1599 && gspca_dev->usb_buf[2] == 0x01
1600 && gspca_dev->usb_buf[3] == 0x00
1601 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001602 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1603 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001604 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001605 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001606 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1607 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001608}
1609
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001610static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001611{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001612 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001613 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001614 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001615 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001616 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001617 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1618 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1619 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1620 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1621 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001622 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001623 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1624 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1625 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1626 {}
1627 },
1628 };
1629
1630 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1631 reg_w1(gspca_dev, 0x17, 0x62);
1632 reg_w1(gspca_dev, 0x01, 0x08);
1633 for (j = 0; j < 3; j++)
1634 i2c_w8(gspca_dev, probe_tb[i][j]);
1635 msleep(2);
1636 reg_r(gspca_dev, 0x0a, 5);
1637 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1638 if (probe_tb[i][3][0] != 0)
1639 i2c_w8(gspca_dev, probe_tb[i][3]);
1640 reg_w1(gspca_dev, 0x01, 0x29);
1641 reg_w1(gspca_dev, 0x17, 0x42);
1642 if (val != 0xffff)
1643 break;
1644 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001645 if (gspca_dev->usb_err < 0)
1646 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001647 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001648 case 0x8221:
1649 PDEBUG(D_PROBE, "Sensor mi0360b");
1650 sd->sensor = SENSOR_MI0360B;
1651 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001652 case 0x823a:
1653 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001654 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001655 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001656 case 0x8243:
1657 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001658 break;
1659 default:
1660 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1661 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001662 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001663}
1664
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001665static void ov7630_probe(struct gspca_dev *gspca_dev)
1666{
1667 struct sd *sd = (struct sd *) gspca_dev;
1668 u16 val;
1669
1670 /* check ov76xx */
1671 reg_w1(gspca_dev, 0x17, 0x62);
1672 reg_w1(gspca_dev, 0x01, 0x08);
1673 sd->i2c_addr = 0x21;
1674 i2c_r(gspca_dev, 0x0a, 2);
1675 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1676 reg_w1(gspca_dev, 0x01, 0x29);
1677 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001678 if (gspca_dev->usb_err < 0)
1679 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001680 if (val == 0x7628) { /* soi768 */
1681 sd->sensor = SENSOR_SOI768;
1682/*fixme: only valid for 0c45:613e?*/
1683 gspca_dev->cam.input_flags =
1684 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1685 PDEBUG(D_PROBE, "Sensor soi768");
1686 return;
1687 }
1688 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1689}
1690
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001691static void ov7648_probe(struct gspca_dev *gspca_dev)
1692{
1693 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001694 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001695
1696 /* check ov76xx */
1697 reg_w1(gspca_dev, 0x17, 0x62);
1698 reg_w1(gspca_dev, 0x01, 0x08);
1699 sd->i2c_addr = 0x21;
1700 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001701 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001702 reg_w1(gspca_dev, 0x01, 0x29);
1703 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001704 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1705 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1706 return;
1707 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001708
1709 /* check po1030 */
1710 reg_w1(gspca_dev, 0x17, 0x62);
1711 reg_w1(gspca_dev, 0x01, 0x08);
1712 sd->i2c_addr = 0x6e;
1713 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001714 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1715 reg_w1(gspca_dev, 0x01, 0x29);
1716 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001717 if (gspca_dev->usb_err < 0)
1718 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001719 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001720 PDEBUG(D_PROBE, "Sensor po1030");
1721 sd->sensor = SENSOR_PO1030;
1722 return;
1723 }
1724
Jean-François Moine0b656322010-09-13 05:19:58 -03001725 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001726}
1727
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001728/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1729static void po2030n_probe(struct gspca_dev *gspca_dev)
1730{
1731 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001732 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001733
1734 /* check gc0307 */
1735 reg_w1(gspca_dev, 0x17, 0x62);
1736 reg_w1(gspca_dev, 0x01, 0x08);
1737 reg_w1(gspca_dev, 0x02, 0x22);
1738 sd->i2c_addr = 0x21;
1739 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001740 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001741 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1742 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001743 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001744 PDEBUG(D_PROBE, "Sensor gc0307");
1745 sd->sensor = SENSOR_GC0307;
1746 return;
1747 }
1748
1749 /* check po2030n */
1750 reg_w1(gspca_dev, 0x17, 0x62);
1751 reg_w1(gspca_dev, 0x01, 0x0a);
1752 sd->i2c_addr = 0x6e;
1753 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001754 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001755 reg_w1(gspca_dev, 0x01, 0x29);
1756 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001757 if (gspca_dev->usb_err < 0)
1758 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001759 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001760 PDEBUG(D_PROBE, "Sensor po2030n");
1761/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001762 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001763 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001764 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001765}
1766
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001767static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001768 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001769{
1770 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine19697b52010-07-14 06:33:51 -03001771 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03001772 const u8 *reg9a;
1773 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001774 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1775 static const u8 reg9a_spec[] =
1776 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001777 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001778
Hans de Goede9712a8b2010-01-31 12:54:29 -03001779 /* sensor clock already enabled in sd_init */
1780 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001781 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001782
1783 /* configure gpio */
Jean-François Moine19697b52010-07-14 06:33:51 -03001784 reg0102[0] = sn9c1xx[1];
1785 reg0102[1] = sn9c1xx[2];
1786 if (gspca_dev->audio)
1787 reg0102[1] |= 0x04; /* keep the audio connection */
1788 reg_w(gspca_dev, 0x01, reg0102, 2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001789 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001790 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001791 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001792 case SENSOR_GC0307:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001793 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001794 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001795 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001796 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001797 case SENSOR_SP80708:
1798 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001799 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001800 default:
1801 reg9a = reg9a_def;
1802 break;
1803 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001804 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001805
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001806 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001807
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001808 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001809
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001810 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001811 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001812 reg_w1(gspca_dev, 0x01, 0x43);
Jean-Francois Moine646775732009-12-20 12:31:28 -03001813 reg_w1(gspca_dev, 0x17, 0x62);
1814 reg_w1(gspca_dev, 0x01, 0x42);
1815 reg_w1(gspca_dev, 0x01, 0x42);
1816 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001817 case SENSOR_GC0307:
1818 msleep(50);
1819 reg_w1(gspca_dev, 0x01, 0x61);
1820 reg_w1(gspca_dev, 0x17, 0x22);
1821 reg_w1(gspca_dev, 0x01, 0x60);
1822 reg_w1(gspca_dev, 0x01, 0x40);
1823 msleep(50);
1824 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03001825 case SENSOR_MI0360B:
1826 reg_w1(gspca_dev, 0x01, 0x61);
1827 reg_w1(gspca_dev, 0x17, 0x60);
1828 reg_w1(gspca_dev, 0x01, 0x60);
1829 reg_w1(gspca_dev, 0x01, 0x40);
1830 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001831 case SENSOR_MT9V111:
1832 reg_w1(gspca_dev, 0x01, 0x61);
1833 reg_w1(gspca_dev, 0x17, 0x61);
1834 reg_w1(gspca_dev, 0x01, 0x60);
1835 reg_w1(gspca_dev, 0x01, 0x40);
1836 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001837 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001838 msleep(10);
1839 reg_w1(gspca_dev, 0x02, 0x73);
1840 reg_w1(gspca_dev, 0x17, 0x60);
1841 reg_w1(gspca_dev, 0x01, 0x22);
1842 msleep(100);
1843 reg_w1(gspca_dev, 0x01, 0x62);
1844 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001845 reg_w1(gspca_dev, 0x17, 0x64);
1846 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001847 msleep(10);
1848 reg_w1(gspca_dev, 0x01, 0x42);
1849 i2c_w8(gspca_dev, om6802_init0[0]);
1850 i2c_w8(gspca_dev, om6802_init0[1]);
1851 msleep(15);
1852 reg_w1(gspca_dev, 0x02, 0x71);
1853 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001854 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001855 case SENSOR_OV7630:
1856 reg_w1(gspca_dev, 0x01, 0x61);
1857 reg_w1(gspca_dev, 0x17, 0xe2);
1858 reg_w1(gspca_dev, 0x01, 0x60);
1859 reg_w1(gspca_dev, 0x01, 0x40);
1860 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001861 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001862 reg_w1(gspca_dev, 0x01, 0x63);
1863 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001864 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001865 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001866 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001867 case SENSOR_PO1030:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001868 case SENSOR_SOI768:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001869 reg_w1(gspca_dev, 0x01, 0x61);
1870 reg_w1(gspca_dev, 0x17, 0x20);
1871 reg_w1(gspca_dev, 0x01, 0x60);
1872 reg_w1(gspca_dev, 0x01, 0x40);
1873 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001874 case SENSOR_PO2030N:
Jean-François Moine19697b52010-07-14 06:33:51 -03001875 case SENSOR_OV7660:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001876 reg_w1(gspca_dev, 0x01, 0x63);
1877 reg_w1(gspca_dev, 0x17, 0x20);
1878 reg_w1(gspca_dev, 0x01, 0x62);
1879 reg_w1(gspca_dev, 0x01, 0x42);
1880 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001881 case SENSOR_SP80708:
1882 reg_w1(gspca_dev, 0x01, 0x63);
1883 reg_w1(gspca_dev, 0x17, 0x20);
1884 reg_w1(gspca_dev, 0x01, 0x62);
1885 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001886 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001887 reg_w1(gspca_dev, 0x02, 0x62);
1888 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001889 default:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001890/* case SENSOR_HV7131R: */
1891/* case SENSOR_MI0360: */
1892/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001893 reg_w1(gspca_dev, 0x01, 0x43);
1894 reg_w1(gspca_dev, 0x17, 0x61);
1895 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001896 if (sd->sensor == SENSOR_HV7131R
1897 && sd->bridge == BRIDGE_SN9C102P)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001898 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001899 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001900 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001901}
1902
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001903/* this function is called at probe time */
1904static int sd_config(struct gspca_dev *gspca_dev,
1905 const struct usb_device_id *id)
1906{
1907 struct sd *sd = (struct sd *) gspca_dev;
1908 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001909
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001910 sd->bridge = id->driver_info >> 16;
1911 sd->sensor = id->driver_info;
1912
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001913 cam = &gspca_dev->cam;
Jean-Francois Moine646775732009-12-20 12:31:28 -03001914 if (sd->sensor == SENSOR_ADCM1700) {
1915 cam->cam_mode = cif_mode;
1916 cam->nmodes = ARRAY_SIZE(cif_mode);
1917 } else {
1918 cam->cam_mode = vga_mode;
1919 cam->nmodes = ARRAY_SIZE(vga_mode);
1920 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001921 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001922
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001923 sd->brightness = BRIGHTNESS_DEF;
1924 sd->contrast = CONTRAST_DEF;
1925 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001926 sd->blue = BLUE_BALANCE_DEF;
1927 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001928 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001929 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001930 sd->ag_cnt = -1;
Hans de Goedef8009522009-06-18 14:29:20 -03001931 sd->vflip = VFLIP_DEF;
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001932 switch (sd->sensor) {
1933 case SENSOR_OM6802:
1934 sd->sharpness = 0x10;
1935 break;
1936 default:
1937 sd->sharpness = SHARPNESS_DEF;
1938 break;
1939 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001940 sd->infrared = INFRARED_DEF;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001941 sd->freq = FREQ_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001942 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001943 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001944
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001945 return 0;
1946}
1947
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001948/* this function is called at probe and resume time */
1949static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001950{
1951 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001952 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001953 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001954 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001955
Hans de Goede3647fea2008-07-15 05:36:30 -03001956 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001957 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001958 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001959 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1960 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001961 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001962 if (gspca_dev->usb_err < 0)
1963 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001964 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001965 switch (sd->bridge) {
1966 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001967 if (regF1 != 0x11)
1968 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001969 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001970 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001971 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001972 if (regF1 != 0x11)
1973 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001974 if (sd->sensor == SENSOR_MI0360)
1975 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001976 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001977 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001978 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001979 if (regF1 != 0x12)
1980 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001981 switch (sd->sensor) {
1982 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001983 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001984 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001985 case SENSOR_OV7630:
1986 ov7630_probe(gspca_dev);
1987 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001988 case SENSOR_OV7648:
1989 ov7648_probe(gspca_dev);
1990 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001991 case SENSOR_PO2030N:
1992 po2030n_probe(gspca_dev);
1993 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001994 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001995 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001996 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001997 break;
1998 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001999/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03002000/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002001 if (regF1 != 0x12)
2002 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002003 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002004 break;
2005 }
2006
Hans de Goede9712a8b2010-01-31 12:54:29 -03002007 /* Note we do not disable the sensor clock here (power saving mode),
2008 as that also disables the button on the cam. */
2009 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002010
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002011 /* set the i2c address */
2012 sn9c1xx = sn_tb[sd->sensor];
2013 sd->i2c_addr = sn9c1xx[9];
2014
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002015 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
2016
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002017 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002018}
2019
Jean-Francois Moine98819182009-01-19 07:37:33 -03002020static u32 setexposure(struct gspca_dev *gspca_dev,
2021 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002022{
2023 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002024
2025 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002026 case SENSOR_GC0307: {
2027 int a, b;
2028
2029 /* expo = 0..255 -> a = 19..43 */
2030 a = 19 + expo * 25 / 256;
2031 i2c_w1(gspca_dev, 0x68, a);
2032 a -= 12;
2033 b = a * a * 4; /* heuristic */
2034 i2c_w1(gspca_dev, 0x03, b >> 8);
2035 i2c_w1(gspca_dev, 0x04, b);
2036 break;
2037 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002038 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002039 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002040 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002041
2042 Expodoit[3] = expo >> 16;
2043 Expodoit[4] = expo >> 8;
2044 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002045 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002046 break;
2047 }
Jean-François Moinea067db82010-10-01 07:51:24 -03002048 case SENSOR_MI0360:
2049 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002050 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002051 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002052 static const u8 doit[] = /* update sensor */
2053 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
2054 static const u8 sensorgo[] = /* sensor on */
2055 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002056
2057 if (expo > 0x0635)
2058 expo = 0x0635;
2059 else if (expo < 0x0001)
2060 expo = 0x0001;
2061 expoMi[3] = expo >> 8;
2062 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002063 i2c_w8(gspca_dev, expoMi);
2064 i2c_w8(gspca_dev, doit);
2065 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002066 break;
2067 }
2068 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002069 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002070 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002071 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002072 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002073 static const u8 gainMo[] =
2074 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002075
2076 if (expo > 0x1fff)
2077 expo = 0x1fff;
2078 else if (expo < 0x0001)
2079 expo = 0x0001;
2080 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002081 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002082 expoMo10[3] = ((expo & 0x1c00) >> 10)
2083 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002084 i2c_w8(gspca_dev, expoMo10);
2085 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002086 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002087 ((expoMo10[3] & 0x07) << 10)
2088 | (expoMof[3] << 2)
2089 | ((expoMo10[3] & 0x30) >> 4));
2090 break;
2091 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002092 case SENSOR_MT9V111: {
2093 u8 expo_c1[] =
2094 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2095
2096 if (expo > 0x0280)
2097 expo = 0x0280;
2098 else if (expo < 0x0040)
2099 expo = 0x0040;
2100 expo_c1[3] = expo >> 8;
2101 expo_c1[4] = expo;
2102 i2c_w8(gspca_dev, expo_c1);
2103 break;
2104 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002105 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002106 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002107 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002108 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002109
2110 if (expo > 0x03ff)
2111 expo = 0x03ff;
2112 if (expo < 0x0001)
2113 expo = 0x0001;
2114 gainOm[3] = expo >> 2;
2115 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002116 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002117 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002118 break;
2119 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002120 }
2121 return expo;
2122}
2123
2124static void setbrightness(struct gspca_dev *gspca_dev)
2125{
2126 struct sd *sd = (struct sd *) gspca_dev;
2127 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002128 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002129
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03002130 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002131 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002132 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002133 if (k2 > 0x1f)
2134 k2 = 0; /* only positive Y offset */
2135 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002136 case SENSOR_HV7131R:
2137 expo = sd->brightness << 4;
2138 if (expo > 0x002dc6c0)
2139 expo = 0x002dc6c0;
2140 else if (expo < 0x02a0)
2141 expo = 0x02a0;
2142 sd->exposure = setexposure(gspca_dev, expo);
2143 break;
2144 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002145 case SENSOR_MO4000:
2146 expo = sd->brightness >> 4;
2147 sd->exposure = setexposure(gspca_dev, expo);
2148 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002149 case SENSOR_MI0360B:
2150 expo = sd->brightness >> 6;
2151 sd->exposure = setexposure(gspca_dev, expo);
2152 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002153 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002154 case SENSOR_MT9V111:
2155 expo = sd->brightness >> 8;
2156 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002157 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002158 case SENSOR_OM6802:
2159 expo = sd->brightness >> 6;
2160 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03002161 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002162 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002163 }
2164
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002165 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002166}
2167
2168static void setcontrast(struct gspca_dev *gspca_dev)
2169{
2170 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002171 u8 k2;
2172 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002173
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002174 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
2175 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002176 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002177 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002178 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002179 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002180 contrast[5] = 0;
2181 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002182}
2183
2184static void setcolors(struct gspca_dev *gspca_dev)
2185{
2186 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002187 int i, v;
Jean-François Moinea067db82010-10-01 07:51:24 -03002188 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002189 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002190 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002191 -24, -38, 64, /* UR UG UB */
2192 62, -51, -9 /* VR VG VB */
2193 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002194 static const s16 uv_mi0360b[6] = {
2195 -20, -38, 64, /* UR UG UB */
2196 60, -51, -9 /* VR VG VB */
2197 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002198
Jean-François Moinea067db82010-10-01 07:51:24 -03002199 if (sd->sensor == SENSOR_MI0360B)
2200 uv = uv_mi0360b;
2201 else
2202 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002203 for (i = 0; i < 6; i++) {
2204 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002205 reg8a[i * 2] = v;
2206 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002207 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002208 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002209}
2210
2211static void setredblue(struct gspca_dev *gspca_dev)
2212{
2213 struct sd *sd = (struct sd *) gspca_dev;
2214
2215 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002216/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002217 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002218}
2219
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002220static void setgamma(struct gspca_dev *gspca_dev)
2221{
2222 struct sd *sd = (struct sd *) gspca_dev;
2223 int i;
2224 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002225 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002226 static const u8 delta[17] = {
2227 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2228 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2229 };
2230
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002231 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002232 case SENSOR_ADCM1700:
2233 gamma_base = gamma_spec_0;
2234 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002235 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002236 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002237 case SENSOR_MT9V111:
2238 gamma_base = gamma_spec_1;
2239 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002240 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002241 gamma_base = gamma_spec_2;
2242 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002243 case SENSOR_SP80708:
2244 gamma_base = gamma_spec_3;
2245 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002246 default:
2247 gamma_base = gamma_def;
2248 break;
2249 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002250
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002251 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002252 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002253 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
2254 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2255}
2256
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002257static void setautogain(struct gspca_dev *gspca_dev)
2258{
2259 struct sd *sd = (struct sd *) gspca_dev;
2260
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002261 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
2262 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002263 switch (sd->sensor) {
2264 case SENSOR_OV7630:
2265 case SENSOR_OV7648: {
2266 u8 comb;
2267
2268 if (sd->sensor == SENSOR_OV7630)
2269 comb = 0xc0;
2270 else
2271 comb = 0xa0;
2272 if (sd->autogain)
Hans de Goede1fec747c2009-06-18 06:05:07 -03002273 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002274 i2c_w1(&sd->gspca_dev, 0x13, comb);
2275 return;
2276 }
2277 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002278 if (sd->autogain)
2279 sd->ag_cnt = AG_CNT_START;
2280 else
2281 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002282}
2283
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002284/* hv7131r/ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002285static void setvflip(struct sd *sd)
2286{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002287 u8 comn;
2288
Jean-Francois Moine0939e262009-11-02 09:58:49 -03002289 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2290 return;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002291 switch (sd->sensor) {
2292 case SENSOR_HV7131R:
2293 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2294 if (sd->vflip)
2295 comn |= 0x01;
2296 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
2297 break;
2298 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002299 comn = 0x02;
Hans de Goedef8009522009-06-18 14:29:20 -03002300 if (!sd->vflip)
2301 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002302 i2c_w1(&sd->gspca_dev, 0x75, comn);
2303 break;
2304 default:
2305/* case SENSOR_OV7648: */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002306 comn = 0x06;
Hans de Goedef8009522009-06-18 14:29:20 -03002307 if (sd->vflip)
2308 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002309 i2c_w1(&sd->gspca_dev, 0x75, comn);
2310 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002311 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002312}
2313
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002314static void setsharpness(struct sd *sd)
2315{
2316 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
2317}
2318
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002319static void setinfrared(struct sd *sd)
2320{
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002321 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
2322 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002323/*fixme: different sequence for StarCam Clip and StarCam 370i */
2324/* Clip */
2325 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
2326 sd->infrared ? 0x66 : 0x64);
2327}
2328
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002329static void setfreq(struct gspca_dev *gspca_dev)
2330{
2331 struct sd *sd = (struct sd *) gspca_dev;
2332
Jean-Francois Moine27954932009-07-08 05:21:50 -03002333 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
2334 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002335 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002336 u8 com8;
2337
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002338 com8 = 0xdf; /* auto gain/wb/expo */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002339 switch (sd->freq) {
2340 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002341 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002342 break;
2343 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002344 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002345 i2c_w1(gspca_dev, 0x3b, 0x0a);
2346 break;
2347 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002348 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002349 i2c_w1(gspca_dev, 0x3b, 0x02);
2350 break;
2351 }
2352 } else {
2353 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2354
2355 /* Get reg2a / reg2d base values */
2356 switch (sd->sensor) {
2357 case SENSOR_OV7630:
2358 reg2a = 0x08;
2359 reg2d = 0x01;
2360 break;
2361 case SENSOR_OV7648:
2362 reg2a = 0x11;
2363 reg2d = 0x81;
2364 break;
2365 }
2366
2367 switch (sd->freq) {
2368 case 0: /* Banding filter disabled */
2369 break;
2370 case 1: /* 50 hz (filter on and framerate adj) */
2371 reg2a |= 0x80;
2372 reg2b = 0xac;
2373 reg2d |= 0x04;
2374 break;
2375 case 2: /* 60 hz (filter on, no framerate adj) */
2376 reg2a |= 0x80;
2377 reg2d |= 0x04;
2378 break;
2379 }
2380 i2c_w1(gspca_dev, 0x2a, reg2a);
2381 i2c_w1(gspca_dev, 0x2b, reg2b);
2382 i2c_w1(gspca_dev, 0x2d, reg2d);
2383 }
2384}
2385
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002386static void setjpegqual(struct gspca_dev *gspca_dev)
2387{
2388 struct sd *sd = (struct sd *) gspca_dev;
2389 int i, sc;
2390
2391 if (sd->jpegqual < 50)
2392 sc = 5000 / sd->jpegqual;
2393 else
2394 sc = 200 - sd->jpegqual * 2;
2395#if USB_BUF_SZ < 64
2396#error "No room enough in usb_buf for quantization table"
2397#endif
2398 for (i = 0; i < 64; i++)
2399 gspca_dev->usb_buf[i] =
2400 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2401 usb_control_msg(gspca_dev->dev,
2402 usb_sndctrlpipe(gspca_dev->dev, 0),
2403 0x08,
2404 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2405 0x0100, 0,
2406 gspca_dev->usb_buf, 64,
2407 500);
2408 for (i = 0; i < 64; i++)
2409 gspca_dev->usb_buf[i] =
2410 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2411 usb_control_msg(gspca_dev->dev,
2412 usb_sndctrlpipe(gspca_dev->dev, 0),
2413 0x08,
2414 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2415 0x0140, 0,
2416 gspca_dev->usb_buf, 64,
2417 500);
2418
2419 sd->reg18 ^= 0x40;
2420 reg_w1(gspca_dev, 0x18, sd->reg18);
2421}
2422
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002423/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002424static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002425{
2426 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002427 int i;
Jean-François Moine19697b52010-07-14 06:33:51 -03002428 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002429 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002430 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002431 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002432 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2433 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine646775732009-12-20 12:31:28 -03002434 static const u8 CA_adcm1700[] =
2435 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002436 static const u8 CA_po2030n[] =
2437 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002438 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002439 static const u8 CE_gc0307[] =
2440 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002441 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002442 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002443 static const u8 CE_po2030n[] =
2444 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002445
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002446 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002447 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2448 0x21); /* JPEG 422 */
2449 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2450
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002451 /* initialize the bridge */
2452 sn9c1xx = sn_tb[sd->sensor];
2453 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002454
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002455 /* initialize the sensor */
2456 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2457
Jean-Francois Moine60017612008-07-18 08:46:19 -03002458 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2459 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2460 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2461 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2462 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002463 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002464 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2465 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002466 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002467 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2468 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002469 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002470 reg_w1(gspca_dev, 0xc6, 0x00);
2471 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002472 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002473 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2474 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002475 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002476 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2477 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002478 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002479 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002480 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002481 case SENSOR_GC0307:
2482 reg17 = 0xa2;
2483 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002484 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002485 case SENSOR_MI0360B:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002486 reg17 = 0xe0;
2487 break;
Jean-Francois Moine646775732009-12-20 12:31:28 -03002488 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002489 case SENSOR_OV7630:
2490 reg17 = 0xe2;
2491 break;
2492 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002493 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002494 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002495 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002496 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002497 reg17 = 0xa0;
2498 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002499 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002500 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002501 reg17 = 0xa0;
2502 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002503 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002504 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002505 break;
2506 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002507 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002508
2509 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2510 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2511 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002512 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002513
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002514 setgamma(gspca_dev);
2515
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002516/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002517 for (i = 0; i < 8; i++)
2518 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002519 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002520 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002521 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002522 case SENSOR_SP80708:
2523 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002524 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002525 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002526 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002527 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002528 reg_w1(gspca_dev, 0x9a, 0x07);
2529 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002530 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002531 case SENSOR_OV7648:
2532 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002533 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002534 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002535 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002536 reg_w1(gspca_dev, 0x9a, 0x06);
2537 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002538 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002539 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002540 break;
2541 }
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002542 setsharpness(sd);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002543
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002544 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002545 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2546 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2547 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002548
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002549 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002550 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002551 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002552 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002553 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002554 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2555 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002556 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002557 case SENSOR_ADCM1700:
2558 init = adcm1700_sensor_param1;
2559 reg1 = 0x46;
2560 reg17 = 0xe2;
2561 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002562 case SENSOR_GC0307:
2563 init = gc0307_sensor_param1;
2564 reg17 = 0xa2;
2565 reg1 = 0x44;
2566 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002567 case SENSOR_MI0360B:
2568 init = mi0360b_sensor_param1;
2569 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2570 reg17 = 0xe2;
2571 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002572 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002573 if (mode) {
2574/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2575 reg1 = 0x06; /* clk 24Mz */
2576 } else {
2577 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002578/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002579 }
2580 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002581 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002582 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002583 if (mode) {
2584 reg1 = 0x04; /* 320 clk 48Mhz */
2585 } else {
2586/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002587 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002588 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002589 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002590 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002591 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002592 reg17 = 0x64; /* 640 MCKSIZE */
2593 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002594 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002595 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002596 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002597 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002598 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002599 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002600 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002601 reg17 = 0x21;
2602/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002603 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002604 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002605 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002606 if (sd->bridge == BRIDGE_SN9C120) {
2607 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002608 reg17 = 0xa2;
2609 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002610 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002611 } else {
2612 reg17 = 0x22;
2613 reg1 = 0x06; /* 24 Mhz, video trf eneble
2614 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002615 }
2616 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002617 case SENSOR_PO1030:
2618 init = po1030_sensor_param1;
2619 reg17 = 0xa2;
2620 reg1 = 0x44;
2621 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002622 case SENSOR_PO2030N:
2623 init = po2030n_sensor_param1;
2624 reg1 = 0x46;
2625 reg17 = 0xa2;
2626 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002627 case SENSOR_SOI768:
2628 init = soi768_sensor_param1;
2629 reg1 = 0x44;
2630 reg17 = 0xa2;
2631 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002632 default:
2633/* case SENSOR_SP80708: */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002634 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002635 if (mode) {
2636/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002637 } else {
2638 reg1 = 0x46; /* 640 clk 48Mz */
2639 reg17 = 0xa2;
2640 }
2641 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002642 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002643
2644 /* more sensor initialization - param1 */
2645 if (init != NULL) {
2646 i2c_w_seq(gspca_dev, init);
2647/* init = NULL; */
2648 }
2649
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002650 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002651 switch (sd->sensor) {
2652 case SENSOR_ADCM1700:
2653 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002654 case SENSOR_SOI768:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002655 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002656 break;
2657 case SENSOR_PO2030N:
2658 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2659 break;
2660 default:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002661 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002662 break;
2663 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002664 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002665 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002666 case SENSOR_OV7630:
2667 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002668 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002669 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002670 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002671 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002672 case SENSOR_GC0307:
2673 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2674 break;
2675 case SENSOR_PO2030N:
2676 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2677 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002678 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002679 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002680 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2681 break;
2682 }
2683
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002684
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002685 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002686 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2687 reg_w1(gspca_dev, 0x18, sd->reg18);
2688 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002689
Jean-Francois Moine60017612008-07-18 08:46:19 -03002690 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002691 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002692
Jean-François Moine1e5eb112010-02-18 14:56:33 -03002693 setvflip(sd);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002694 setbrightness(gspca_dev);
2695 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002696 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002697 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002698 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002699 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002700}
2701
2702static void sd_stopN(struct gspca_dev *gspca_dev)
2703{
2704 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002705 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002706 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002707 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002708 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002709 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002710 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002711 static const u8 stopsoi768[] =
2712 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002713 u8 data;
2714 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002715
2716 data = 0x0b;
2717 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002718 case SENSOR_GC0307:
2719 data = 0x29;
2720 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002721 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002722 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002723 data = 0x2b;
2724 break;
2725 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002726 case SENSOR_MI0360B:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002727 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002728 data = 0x29;
2729 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002730 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002731 i2c_w8(gspca_dev, stopov7648);
2732 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002733 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002734 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002735 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002736 data = 0x29;
2737 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002738 case SENSOR_SOI768:
2739 i2c_w8(gspca_dev, stopsoi768);
2740 data = 0x29;
2741 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002742 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002743 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002744 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2745 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2746 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2747 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002748 /* Don't disable sensor clock as that disables the button on the cam */
2749 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002750}
2751
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002752static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002753{
2754 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002755 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002756 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002757 u8 luma_mean = 130;
2758 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002759
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002760 /* Thanks S., without your advice, autobright should not work :) */
2761 if (sd->ag_cnt < 0)
2762 return;
2763 if (--sd->ag_cnt >= 0)
2764 return;
2765 sd->ag_cnt = AG_CNT_START;
2766
2767 delta = atomic_read(&sd->avg_lum);
2768 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002769 if (delta < luma_mean - luma_delta ||
2770 delta > luma_mean + luma_delta) {
2771 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002772 case SENSOR_GC0307:
2773 expotimes = sd->exposure;
2774 expotimes += (luma_mean - delta) >> 6;
2775 if (expotimes < 0)
2776 expotimes = 0;
2777 sd->exposure = setexposure(gspca_dev,
2778 (unsigned int) expotimes);
2779 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002780 case SENSOR_HV7131R:
2781 expotimes = sd->exposure >> 8;
2782 expotimes += (luma_mean - delta) >> 4;
2783 if (expotimes < 0)
2784 expotimes = 0;
2785 sd->exposure = setexposure(gspca_dev,
2786 (unsigned int) (expotimes << 8));
2787 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002788 case SENSOR_OM6802:
2789 expotimes = sd->exposure;
2790 expotimes += (luma_mean - delta) >> 2;
2791 if (expotimes < 0)
2792 expotimes = 0;
2793 sd->exposure = setexposure(gspca_dev,
2794 (unsigned int) expotimes);
2795 setredblue(gspca_dev);
2796 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002797 default:
2798/* case SENSOR_MO4000: */
2799/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002800/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002801/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002802 expotimes = sd->exposure;
2803 expotimes += (luma_mean - delta) >> 6;
2804 if (expotimes < 0)
2805 expotimes = 0;
2806 sd->exposure = setexposure(gspca_dev,
2807 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002808 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002809 break;
2810 }
2811 }
2812}
2813
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002814/* scan the URB packets */
2815/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002816static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002817 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002818 int len) /* iso packet length */
2819{
2820 struct sd *sd = (struct sd *) gspca_dev;
2821 int sof, avg_lum;
2822
Jean-François Moinea95bd642010-10-01 07:54:30 -03002823 /* the image ends on a 64 bytes block starting with
2824 * ff d9 ff ff 00 c4 c4 96
2825 * and followed by various information including luminosity */
2826 /* this block may be splitted between two packets */
2827 /* a new image always starts in a new packet */
2828 switch (gspca_dev->last_packet_type) {
2829 case DISCARD_PACKET: /* restart image building */
2830 sof = len - 64;
2831 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2832 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2833 return;
2834 case LAST_PACKET: /* put the JPEG 422 header */
2835 gspca_frame_add(gspca_dev, FIRST_PACKET,
2836 sd->jpeg_hdr, JPEG_HDR_SZ);
2837 break;
2838 }
2839 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002840
Jean-François Moinea95bd642010-10-01 07:54:30 -03002841 data = gspca_dev->image;
2842 if (data == NULL)
2843 return;
2844 sof = gspca_dev->image_len - 64;
2845 if (data[sof] != 0xff
2846 || data[sof + 1] != 0xd9)
2847 return;
2848
2849 /* end of image found - remove the trailing data */
2850 gspca_dev->image_len = sof + 2;
2851 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2852 if (sd->ag_cnt < 0)
2853 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002854/* w1 w2 w3 */
2855/* w4 w5 w6 */
2856/* w7 w8 */
2857/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002858 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002859/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002860 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002861/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002862 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002863/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002864 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002865/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002866 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2867 avg_lum >>= 4;
2868 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002869}
2870
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002871static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2872{
2873 struct sd *sd = (struct sd *) gspca_dev;
2874
2875 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002876 if (gspca_dev->streaming)
2877 setbrightness(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002878 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002879}
2880
2881static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2882{
2883 struct sd *sd = (struct sd *) gspca_dev;
2884
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002885 *val = sd->brightness;
2886 return 0;
2887}
2888
2889static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2890{
2891 struct sd *sd = (struct sd *) gspca_dev;
2892
2893 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002894 if (gspca_dev->streaming)
2895 setcontrast(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002896 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002897}
2898
2899static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2900{
2901 struct sd *sd = (struct sd *) gspca_dev;
2902
2903 *val = sd->contrast;
2904 return 0;
2905}
2906
2907static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2908{
2909 struct sd *sd = (struct sd *) gspca_dev;
2910
2911 sd->colors = val;
2912 if (gspca_dev->streaming)
2913 setcolors(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002914 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002915}
2916
2917static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2918{
2919 struct sd *sd = (struct sd *) gspca_dev;
2920
2921 *val = sd->colors;
2922 return 0;
2923}
2924
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002925static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2926{
2927 struct sd *sd = (struct sd *) gspca_dev;
2928
2929 sd->blue = val;
2930 if (gspca_dev->streaming)
2931 setredblue(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002932 return gspca_dev->usb_err;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002933}
2934
2935static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2936{
2937 struct sd *sd = (struct sd *) gspca_dev;
2938
2939 *val = sd->blue;
2940 return 0;
2941}
2942
2943static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2944{
2945 struct sd *sd = (struct sd *) gspca_dev;
2946
2947 sd->red = val;
2948 if (gspca_dev->streaming)
2949 setredblue(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002950 return gspca_dev->usb_err;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002951}
2952
2953static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2954{
2955 struct sd *sd = (struct sd *) gspca_dev;
2956
2957 *val = sd->red;
2958 return 0;
2959}
2960
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002961static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2962{
2963 struct sd *sd = (struct sd *) gspca_dev;
2964
2965 sd->gamma = val;
2966 if (gspca_dev->streaming)
2967 setgamma(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002968 return gspca_dev->usb_err;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002969}
2970
2971static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2972{
2973 struct sd *sd = (struct sd *) gspca_dev;
2974
2975 *val = sd->gamma;
2976 return 0;
2977}
2978
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002979static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2980{
2981 struct sd *sd = (struct sd *) gspca_dev;
2982
2983 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002984 if (gspca_dev->streaming)
2985 setautogain(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002986 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002987}
2988
2989static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2990{
2991 struct sd *sd = (struct sd *) gspca_dev;
2992
2993 *val = sd->autogain;
2994 return 0;
2995}
2996
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002997static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2998{
2999 struct sd *sd = (struct sd *) gspca_dev;
3000
3001 sd->sharpness = val;
3002 if (gspca_dev->streaming)
3003 setsharpness(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03003004 return gspca_dev->usb_err;
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03003005}
3006
3007static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
3008{
3009 struct sd *sd = (struct sd *) gspca_dev;
3010
3011 *val = sd->sharpness;
3012 return 0;
3013}
3014
Jean-Francois Moine6c862742008-09-08 04:57:26 -03003015static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
3016{
3017 struct sd *sd = (struct sd *) gspca_dev;
3018
3019 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03003020 if (gspca_dev->streaming)
3021 setvflip(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03003022 return gspca_dev->usb_err;
Jean-Francois Moine6c862742008-09-08 04:57:26 -03003023}
3024
3025static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
3026{
3027 struct sd *sd = (struct sd *) gspca_dev;
3028
3029 *val = sd->vflip;
3030 return 0;
3031}
3032
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03003033static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
3034{
3035 struct sd *sd = (struct sd *) gspca_dev;
3036
3037 sd->infrared = val;
3038 if (gspca_dev->streaming)
3039 setinfrared(sd);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03003040 return gspca_dev->usb_err;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03003041}
3042
3043static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
3044{
3045 struct sd *sd = (struct sd *) gspca_dev;
3046
3047 *val = sd->infrared;
3048 return 0;
3049}
3050
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003051static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
3052{
3053 struct sd *sd = (struct sd *) gspca_dev;
3054
3055 sd->freq = val;
3056 if (gspca_dev->streaming)
3057 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03003058 return gspca_dev->usb_err;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003059}
3060
3061static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
3062{
3063 struct sd *sd = (struct sd *) gspca_dev;
3064
3065 *val = sd->freq;
3066 return 0;
3067}
3068
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03003069static int sd_set_jcomp(struct gspca_dev *gspca_dev,
3070 struct v4l2_jpegcompression *jcomp)
3071{
3072 struct sd *sd = (struct sd *) gspca_dev;
3073
3074 if (jcomp->quality < QUALITY_MIN)
3075 sd->quality = QUALITY_MIN;
3076 else if (jcomp->quality > QUALITY_MAX)
3077 sd->quality = QUALITY_MAX;
3078 else
3079 sd->quality = jcomp->quality;
3080 if (gspca_dev->streaming)
3081 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
3082 return 0;
3083}
3084
3085static int sd_get_jcomp(struct gspca_dev *gspca_dev,
3086 struct v4l2_jpegcompression *jcomp)
3087{
3088 struct sd *sd = (struct sd *) gspca_dev;
3089
3090 memset(jcomp, 0, sizeof *jcomp);
3091 jcomp->quality = sd->quality;
3092 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
3093 | V4L2_JPEG_MARKER_DQT;
3094 return 0;
3095}
3096
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003097static int sd_querymenu(struct gspca_dev *gspca_dev,
3098 struct v4l2_querymenu *menu)
3099{
3100 switch (menu->id) {
3101 case V4L2_CID_POWER_LINE_FREQUENCY:
3102 switch (menu->index) {
3103 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
3104 strcpy((char *) menu->name, "NoFliker");
3105 return 0;
3106 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
3107 strcpy((char *) menu->name, "50 Hz");
3108 return 0;
3109 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
3110 strcpy((char *) menu->name, "60 Hz");
3111 return 0;
3112 }
3113 break;
3114 }
3115 return -EINVAL;
3116}
3117
Jean-François Moine28566432010-10-01 07:33:26 -03003118#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03003119static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
3120 u8 *data, /* interrupt packet data */
3121 int len) /* interrupt packet length */
3122{
3123 int ret = -EINVAL;
3124
3125 if (len == 1 && data[0] == 1) {
3126 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
3127 input_sync(gspca_dev->input_dev);
3128 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
3129 input_sync(gspca_dev->input_dev);
3130 ret = 0;
3131 }
3132
3133 return ret;
3134}
3135#endif
3136
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003137/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03003138static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003139 .name = MODULE_NAME,
3140 .ctrls = sd_ctrls,
3141 .nctrls = ARRAY_SIZE(sd_ctrls),
3142 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03003143 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003144 .start = sd_start,
3145 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003146 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03003147 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03003148 .get_jcomp = sd_get_jcomp,
3149 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003150 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03003151#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03003152 .int_pkt_scan = sd_int_pkt_scan,
3153#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003154};
3155
3156/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003157#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03003158 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003159 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03003160static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03003161#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003162 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
3163 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03003164#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003165 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
3166 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
3167 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
3168 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
3169 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
3170 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
3171 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
3172/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
3173 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
3174/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
3175/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
3176 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3177/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3178 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003179 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003180/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3181/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3182/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03003183 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003184 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
3185/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
3186/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03003187/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003188 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003189#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003190 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3191 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003192#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003193 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03003194 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003195/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3196 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3197 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3198 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3199 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3200/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3201/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3202/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3203 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003204/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003205 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003206 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003207 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3208 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3209/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03003210#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003211 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003212 /* or MT9V111 / MI0360B */
Hans de Goede222a07f2008-09-03 17:12:20 -03003213#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003214/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3215 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3216 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003217#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003218 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03003219#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003220 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3221 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003222 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003223 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003224 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3225 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine646775732009-12-20 12:31:28 -03003226 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003227 {}
3228};
3229MODULE_DEVICE_TABLE(usb, device_table);
3230
3231/* -- device connect -- */
3232static int sd_probe(struct usb_interface *intf,
3233 const struct usb_device_id *id)
3234{
3235 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3236 THIS_MODULE);
3237}
3238
3239static struct usb_driver sd_driver = {
3240 .name = MODULE_NAME,
3241 .id_table = device_table,
3242 .probe = sd_probe,
3243 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003244#ifdef CONFIG_PM
3245 .suspend = gspca_suspend,
3246 .resume = gspca_resume,
3247#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003248};
3249
3250/* -- module insert / remove -- */
3251static int __init sd_mod_init(void)
3252{
Jean-François Moine54826432010-09-13 04:53:03 -03003253 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003254}
3255static void __exit sd_mod_exit(void)
3256{
3257 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003258}
3259
3260module_init(sd_mod_init);
3261module_exit(sd_mod_exit);