blob: aaa68ddb1fb456a73a92366d669686442170e63c [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-Francois Moine5b34e3e2009-11-02 10:00:48 -03004 * Copyright (C) 2009 Jean-Francois Moine <http://moinejf.free.fr>
5 * 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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090025#include <linux/slab.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030026#include "gspca.h"
27#include "jpeg.h"
28
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030029#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
30
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030031MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
33MODULE_LICENSE("GPL");
34
35/* specific webcam descriptor */
36struct sd {
37 struct gspca_dev gspca_dev; /* !! must be the first item */
38
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030039 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030040 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030041
Jean-Francois Moine98819182009-01-19 07:37:33 -030042 u16 brightness;
43 u8 contrast;
44 u8 colors;
45 u8 autogain;
46 u8 blue;
47 u8 red;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030048 u8 gamma;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -030049 u8 vflip; /* ov7630/ov7648 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -030050 u8 sharpness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -030051 u8 infrared; /* mt9v111 only */
Hans de Goede37c6dbe2009-06-18 07:35:36 -030052 u8 freq; /* ov76xx only */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030053 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030054#define QUALITY_MIN 60
55#define QUALITY_MAX 95
56#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030057 u8 jpegqual; /* webcam quality */
58
59 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030060
Jean-Francois Moine98819182009-01-19 07:37:33 -030061 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030062#define AG_CNT_START 13
63
Jean-Francois Moine98819182009-01-19 07:37:33 -030064 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030065#define BRIDGE_SN9C102P 0
66#define BRIDGE_SN9C105 1
67#define BRIDGE_SN9C110 2
68#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030069 u8 sensor; /* Type of image sensor chip */
Jean-François Moine9c33afc2010-03-17 15:25:32 -030070enum {
71 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030072 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030073 SENSOR_HV7131R,
74 SENSOR_MI0360,
75 SENSOR_MO4000,
76 SENSOR_MT9V111,
77 SENSOR_OM6802,
78 SENSOR_OV7630,
79 SENSOR_OV7648,
80 SENSOR_OV7660,
81 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030082 SENSOR_PO2030N,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030083 SENSOR_SP80708,
84} sensors;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -030085 u8 i2c_addr;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030086
87 u8 *jpeg_hdr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030088};
89
90/* V4L2 controls supported by the driver */
91static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
93static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
95static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030097static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
99static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
100static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300101static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
102static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300103static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
104static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300105static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
106static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300107static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
108static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300109static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
110static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300111static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
112static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300113
Marton Nemeth7e64dc42009-12-30 09:12:41 -0300114static const struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300115#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300116 {
117 {
118 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness",
121 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300122#define BRIGHTNESS_MAX 0xffff
123 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300124 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300125#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300126 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300127 },
128 .set = sd_setbrightness,
129 .get = sd_getbrightness,
130 },
Hans de Goede97643982009-06-18 05:08:11 -0300131#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 {
133 {
134 .id = V4L2_CID_CONTRAST,
135 .type = V4L2_CTRL_TYPE_INTEGER,
136 .name = "Contrast",
137 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300138#define CONTRAST_MAX 127
139 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300141#define CONTRAST_DEF 63
142 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300143 },
144 .set = sd_setcontrast,
145 .get = sd_getcontrast,
146 },
Hans de Goede97643982009-06-18 05:08:11 -0300147#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 {
149 {
150 .id = V4L2_CID_SATURATION,
151 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300152 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300154 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300155 .step = 1,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300156#define COLOR_DEF 25
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300157 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300158 },
159 .set = sd_setcolors,
160 .get = sd_getcolors,
161 },
Hans de Goede97643982009-06-18 05:08:11 -0300162#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300163 {
164 {
165 .id = V4L2_CID_BLUE_BALANCE,
166 .type = V4L2_CTRL_TYPE_INTEGER,
167 .name = "Blue Balance",
168 .minimum = 24,
169 .maximum = 40,
170 .step = 1,
171#define BLUE_BALANCE_DEF 32
172 .default_value = BLUE_BALANCE_DEF,
173 },
174 .set = sd_setblue_balance,
175 .get = sd_getblue_balance,
176 },
Hans de Goede97643982009-06-18 05:08:11 -0300177#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300178 {
179 {
180 .id = V4L2_CID_RED_BALANCE,
181 .type = V4L2_CTRL_TYPE_INTEGER,
182 .name = "Red Balance",
183 .minimum = 24,
184 .maximum = 40,
185 .step = 1,
186#define RED_BALANCE_DEF 32
187 .default_value = RED_BALANCE_DEF,
188 },
189 .set = sd_setred_balance,
190 .get = sd_getred_balance,
191 },
Hans de Goede97643982009-06-18 05:08:11 -0300192#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300193 {
194 {
195 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER,
197 .name = "Gamma",
198 .minimum = 0,
199 .maximum = 40,
200 .step = 1,
201#define GAMMA_DEF 20
202 .default_value = GAMMA_DEF,
203 },
204 .set = sd_setgamma,
205 .get = sd_getgamma,
206 },
Hans de Goede97643982009-06-18 05:08:11 -0300207#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300208 {
209 {
210 .id = V4L2_CID_AUTOGAIN,
211 .type = V4L2_CTRL_TYPE_BOOLEAN,
212 .name = "Auto Gain",
213 .minimum = 0,
214 .maximum = 1,
215 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300216#define AUTOGAIN_DEF 1
217 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300218 },
219 .set = sd_setautogain,
220 .get = sd_getautogain,
221 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300222/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300223#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300224 {
225 {
226 .id = V4L2_CID_VFLIP,
227 .type = V4L2_CTRL_TYPE_BOOLEAN,
228 .name = "Vflip",
229 .minimum = 0,
230 .maximum = 1,
231 .step = 1,
Hans de Goedef8009522009-06-18 14:29:20 -0300232#define VFLIP_DEF 0
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300233 .default_value = VFLIP_DEF,
234 },
235 .set = sd_setvflip,
236 .get = sd_getvflip,
237 },
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300238#define SHARPNESS_IDX 8
239 {
240 {
241 .id = V4L2_CID_SHARPNESS,
242 .type = V4L2_CTRL_TYPE_INTEGER,
243 .name = "Sharpness",
244 .minimum = 0,
245 .maximum = 255,
246 .step = 1,
247#define SHARPNESS_DEF 90
248 .default_value = SHARPNESS_DEF,
249 },
250 .set = sd_setsharpness,
251 .get = sd_getsharpness,
252 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300253/* mt9v111 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300254#define INFRARED_IDX 9
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300255 {
256 {
257 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN,
259 .name = "Infrared",
260 .minimum = 0,
261 .maximum = 1,
262 .step = 1,
263#define INFRARED_DEF 0
264 .default_value = INFRARED_DEF,
265 },
266 .set = sd_setinfrared,
267 .get = sd_getinfrared,
268 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300269/* ov7630/ov7648/ov7660 only */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300270#define FREQ_IDX 10
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300271 {
272 {
273 .id = V4L2_CID_POWER_LINE_FREQUENCY,
274 .type = V4L2_CTRL_TYPE_MENU,
275 .name = "Light frequency filter",
276 .minimum = 0,
277 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
278 .step = 1,
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300279#define FREQ_DEF 1
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300280 .default_value = FREQ_DEF,
281 },
282 .set = sd_setfreq,
283 .get = sd_getfreq,
284 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300285};
286
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300287/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300288static const __u32 ctrl_dis[] = {
289[SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) |
290 (1 << INFRARED_IDX) |
291 (1 << VFLIP_IDX) |
292 (1 << FREQ_IDX),
293
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300294[SENSOR_GC0307] = (1 << AUTOGAIN_IDX) |
295 (1 << INFRARED_IDX) |
296 (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
306[SENSOR_MO4000] = (1 << INFRARED_IDX) |
307 (1 << VFLIP_IDX) |
308 (1 << FREQ_IDX),
309
310[SENSOR_MT9V111] = (1 << VFLIP_IDX) |
311 (1 << FREQ_IDX),
312
313[SENSOR_OM6802] = (1 << INFRARED_IDX) |
314 (1 << VFLIP_IDX) |
315 (1 << FREQ_IDX),
316
317[SENSOR_OV7630] = (1 << INFRARED_IDX),
318
319[SENSOR_OV7648] = (1 << INFRARED_IDX),
320
321[SENSOR_OV7660] = (1 << AUTOGAIN_IDX) |
322 (1 << INFRARED_IDX) |
323 (1 << VFLIP_IDX),
324
325[SENSOR_PO1030] = (1 << AUTOGAIN_IDX) |
326 (1 << INFRARED_IDX) |
327 (1 << VFLIP_IDX) |
328 (1 << FREQ_IDX),
329
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300330[SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) |
331 (1 << INFRARED_IDX) |
332 (1 << VFLIP_IDX) |
333 (1 << FREQ_IDX),
334
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300335[SENSOR_SP80708] = (1 << AUTOGAIN_IDX) |
336 (1 << INFRARED_IDX) |
337 (1 << VFLIP_IDX) |
338 (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300339};
340
Jean-Francois Moine646775732009-12-20 12:31:28 -0300341static const struct v4l2_pix_format cif_mode[] = {
342 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
343 .bytesperline = 352,
344 .sizeimage = 352 * 288 * 4 / 8 + 590,
345 .colorspace = V4L2_COLORSPACE_JPEG,
346 .priv = 0},
347};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300348static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300349 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
350 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300351 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300352 .colorspace = V4L2_COLORSPACE_JPEG,
353 .priv = 2},
354 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
355 .bytesperline = 320,
356 .sizeimage = 320 * 240 * 3 / 8 + 590,
357 .colorspace = V4L2_COLORSPACE_JPEG,
358 .priv = 1},
359 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
360 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300361 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
362 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300363 .colorspace = V4L2_COLORSPACE_JPEG,
364 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300365};
366
Jean-Francois Moine646775732009-12-20 12:31:28 -0300367static const u8 sn_adcm1700[0x1c] = {
368/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300369 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine646775732009-12-20 12:31:28 -0300370/* reg8 reg9 rega regb regc regd rege regf */
371 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
373 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
374/* reg18 reg19 reg1a reg1b */
375 0x06, 0x00, 0x00, 0x00
376};
377
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300378static const u8 sn_gc0307[0x1c] = {
379/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
380 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
381/* reg8 reg9 rega regb regc regd rege regf */
382 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
384 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
385/* reg18 reg19 reg1a reg1b */
386 0x06, 0x00, 0x00, 0x00
387};
388
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300389static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300390/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
391 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
392/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300393 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300394/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
395 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300396/* reg18 reg19 reg1a reg1b */
397 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300398};
399
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300400static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300401/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
402 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
403/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300404 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300405/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
406 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300407/* reg18 reg19 reg1a reg1b */
408 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300409};
410
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300411static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300412/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300413 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300414/* reg8 reg9 rega regb regc regd rege regf */
415 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
417 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300418/* reg18 reg19 reg1a reg1b */
419 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300420};
421
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300422static const u8 sn_mt9v111[0x1c] = {
423/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
424 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
425/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300426 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300427/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
428 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
429/* reg18 reg19 reg1a reg1b */
430 0x06, 0x00, 0x00, 0x00
431};
432
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300433static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300434/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300435 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300436/* reg8 reg9 rega regb regc regd rege regf */
437 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
438/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
439 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300440/* reg18 reg19 reg1a reg1b */
441 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300442};
443
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300444static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300445/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
446 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
447/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300448 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300449/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
450 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300451/* reg18 reg19 reg1a reg1b */
452 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300453};
454
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300455static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300456/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300457 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300458/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300459 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300460/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300461 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300462/* reg18 reg19 reg1a reg1b */
463 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300464};
465
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300466static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300467/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300468 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300469/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300470 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300471/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
472 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300473/* reg18 reg19 reg1a reg1b */
474 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300475};
476
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300477static const u8 sn_po1030[0x1c] = {
478/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
479 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
480/* reg8 reg9 rega regb regc regd rege regf */
481 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
482/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
483 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
484/* reg18 reg19 reg1a reg1b */
485 0x07, 0x00, 0x00, 0x00
486};
487
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300488static const u8 sn_po2030n[0x1c] = {
489/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
490 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
491/* reg8 reg9 rega regb regc regd rege regf */
492 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
494 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
495/* reg18 reg19 reg1a reg1b */
496 0x07, 0x00, 0x00, 0x00
497};
498
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300499static const u8 sn_sp80708[0x1c] = {
500/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
501 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
502/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300503 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300504/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
505 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
506/* reg18 reg19 reg1a reg1b */
507 0x07, 0x00, 0x00, 0x00
508};
509
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300510/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300511static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300512[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300513[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300514[SENSOR_HV7131R] = sn_hv7131,
515[SENSOR_MI0360] = sn_mi0360,
516[SENSOR_MO4000] = sn_mo4000,
517[SENSOR_MT9V111] = sn_mt9v111,
518[SENSOR_OM6802] = sn_om6802,
519[SENSOR_OV7630] = sn_ov7630,
520[SENSOR_OV7648] = sn_ov7648,
521[SENSOR_OV7660] = sn_ov7660,
522[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300523[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300524[SENSOR_SP80708] = sn_sp80708
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300525};
526
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300527/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300528static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300529 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
530 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
531};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300532/* gamma for sensor ADCM1700 */
533static const u8 gamma_spec_0[17] = {
534 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
535 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
536};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300537/* gamma for sensors HV7131R and MT9V111 */
538static const u8 gamma_spec_1[17] = {
539 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
540 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
541};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300542/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300543static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300544 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
545 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
546};
547/* gamma for sensor SP80708 */
548static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300549 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
550 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
551};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300552
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300553/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300554static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300555 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
556 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
557 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
558 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300559};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300560static const u8 adcm1700_sensor_init[][8] = {
561 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300562 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300563 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
564 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
565 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
566 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
567 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
568 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
569 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
570 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
571 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
572 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
573 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
574 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
575 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
576 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
577 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
578 {}
579};
580static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300581 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300582 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
583
584 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
585 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
586 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
587 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300588 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300589
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300590 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
591 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
592 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
593 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300594 {}
595};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300596static const u8 gc0307_sensor_init[][8] = {
597 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
598 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
599 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
601 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
602 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
603 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
604 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
605 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
606 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
608 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
609 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
610 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
611 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
612 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
613 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
617 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
618 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
619 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
635 {}
636};
637static const u8 gc0307_sensor_param1[][8] = {
638 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
639 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
640 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
641 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
642/*param3*/
643 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
645
646 {0xa0, 0x21, 0x68, 0x22, 0x00, 0x00, 0x00, 0x10},
647 {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
648 {0xa0, 0x21, 0x03, 0x07, 0x00, 0x00, 0x00, 0x10},
649 {0xdd, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
650 {0xa0, 0x21, 0x04, 0x91, 0x00, 0x00, 0x00, 0x10},
651 {}
652};
653
Jean-Francois Moine98819182009-01-19 07:37:33 -0300654static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300655 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
656 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
657 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
658/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
659 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
660 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
661/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300662
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300663 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
664 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
665 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
666 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
667 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
668 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
669 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
670 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300671
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300672 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
673 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300674 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300675 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
676 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300677
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300678 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
679 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
680 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
681 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
682 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300683 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
684 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300685 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300686};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300687static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300688 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300689 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300690 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300691 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
692 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
693 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
694 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
695 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
696 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
698 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
699 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
700 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
701 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
702 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
703 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
704 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
705 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
706 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
707 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
709 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300710 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300711 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
712 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
713 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
714 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
715 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
716 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
717 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
718 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
719 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
720 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300721
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300722 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
723 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
724 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
726 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300727
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300728 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
729 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
730 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
731 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300732
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300733 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
734 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
735/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
736/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
737 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
738 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300739 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300740};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300741static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300742 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
743 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
746 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
747 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
748 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
749 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
750 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
751 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
753 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
754 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
755 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
756 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
757 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
758 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
759 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
760 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
761 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300762 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300763};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300764static const u8 mt9v111_sensor_init[][8] = {
765 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300766 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300767 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
768 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
769 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
770 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300771 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
772 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
773 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
774 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300775 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300776 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
777 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
778 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
779 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
780 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300781 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300782 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300783 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
784 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
785 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
786 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
787 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
788 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
789 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
790 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
791 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
792 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300793 {}
794};
795static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300796 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300798 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300799 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
800 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
801 /*******/
802 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
803 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
804 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
805 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
806 {}
807};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300808static const u8 om6802_init0[2][8] = {
809/*fixme: variable*/
810 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
811 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
812};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300813static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300814 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
815 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300816 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300817 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300818 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300819/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
820 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300821 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300822/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
823 * set color mode */
824/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
825 * max AGC value in AE */
826/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
827 * preset AGC */
828/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
829 * preset brightness */
830/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
831 * preset contrast */
832/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
833 * preset gamma */
834 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300835 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300836 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
837 /* preset shutter */
838/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
839 * auto frame rate */
840/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300841 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
842 {}
843};
844static const u8 om6802_sensor_param1[][8] = {
845 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
846 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
847 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
848 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300849 {}
850};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300851static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300852 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300854 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300855 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300857 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300858 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300859/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300860 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
861 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300862/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
863 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
864 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300865 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
866 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
867 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
868 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
869 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
870 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
871 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
872 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
873 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
874 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
875 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
876 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
877 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
878 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
879 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
880 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
881 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
882 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
883 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
884 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
885 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
886 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
887 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
888/* */
889 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
890 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
891/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300892/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
893 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300894 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
895 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
896 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300897/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300898/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
899/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300900/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300901 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300902/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300903 {}
904};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300905
Jean-Francois Moine98819182009-01-19 07:37:33 -0300906static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300907 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
908 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300909 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300910 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
911 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
912 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
913 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
914 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
915 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
916 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
917 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
918 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
919 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
920 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
921 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
922 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
923 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
924 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
925 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
926 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
927 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
928 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
929
930 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
931/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
932/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300933/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300934 {}
935};
936static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300937/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300938/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
939 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300940 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
941 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
942/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
943/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
944/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
945/*...*/
946 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
947/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
948/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
949/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
950/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
951/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
952
953 {}
954};
955
Jean-Francois Moine98819182009-01-19 07:37:33 -0300956static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300957 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300958 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300959 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300960 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300961 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -0300962 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300963 /* GAIN BLUE RED VREF */
964 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
965 /* COM 1 BAVE GEAVE AECHH */
966 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
967 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300968 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300969 /* AECH CLKRC COM7 COM8 */
970 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
971 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
972 /* HSTART HSTOP VSTRT VSTOP */
973 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
974 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
975 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
976 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300977/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
978 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300979 /* AEW AEB VPT BBIAS */
980 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
981 /* GbBIAS RSVD EXHCH EXHCL */
982 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
983 /* RBIAS ADVFL ASDVFH YAVE */
984 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
985 /* HSYST HSYEN HREF */
986 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
987 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
988 /* ADC ACOM OFON TSLB */
989 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
990 /* COM11 COM12 COM13 COM14 */
991 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
992 /* EDGE COM15 COM16 COM17 */
993 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
994 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
995 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
996 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
997 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
998 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
999 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1000 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1001 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1002 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1003 /* LCC1 LCC2 LCC3 LCC4 */
1004 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001005 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001006 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001007 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001008 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1009 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1010 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1011 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1012 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1013 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1014 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1015 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1016 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001017 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001018/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001019 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001020 {}
1021};
1022static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001023 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001024 /* bits[3..0]reserved */
1025 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1026 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1027 /* VREF vertical frame ctrl */
1028 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001029 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1030 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1031 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1032 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1033/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001034/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001035/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001036 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001037 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1038 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1039 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1040/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001041/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001042/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001043/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001044 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1045 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1046 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1047 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001048 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001049};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001050
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001051static const u8 po1030_sensor_init[][8] = {
1052/* the sensor registers are described in m5602/m5602_po1030.h */
1053 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1054 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1055 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1056 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1057 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1058 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1059 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1060 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1061 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1062 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1063 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1064 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1065 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1066 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1067 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1068 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1069 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1070 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1071 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1072 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1073 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1074 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1075 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1076 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1077 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1078 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1079 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1080 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1081
1082 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1083 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1084 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1085 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1086 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1087 {}
1088};
1089static const u8 po1030_sensor_param1[][8] = {
1090/* from ms-win traces - these values change with auto gain/expo/wb.. */
1091 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1092 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1093/* mean values */
1094 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1095 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1096 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1097
1098 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1099 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1100 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1101/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1102 {}
1103};
1104
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001105static const u8 po2030n_sensor_init[][8] = {
1106 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1107 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1108 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1109 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1110 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1111 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1112 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1113 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1114 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1115 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1116 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1117 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1118 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1119 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1120 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1121 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1122 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1123 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1124 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1125 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1126 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1127 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1128 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1129 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1130 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1132 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1133 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1134 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1135 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1136 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1137 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1138 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1139 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1141 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1142 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1143 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1144 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1145 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1146 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1147 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1148 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1149 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1150 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1151 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1152 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1153 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1154 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1155 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1156 {}
1157};
1158static const u8 po2030n_sensor_param1[][8] = {
1159 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1160 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1161 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1162 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1163 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1164/*param2*/
1165 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1166 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1167 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1168 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1169 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1170 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1171 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1172/*after start*/
1173 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1174 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1175 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1176 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1177 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1178 {}
1179};
1180
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001181static const u8 sp80708_sensor_init[][8] = {
1182 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1183 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1184 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1185 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1186 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1187 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1188 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1189 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1190 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1191 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1192 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1193 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1194 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1195 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1199 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1201 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1202 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1203 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1204 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1205 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1206 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1207 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1208 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1210 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1211 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1212 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1213 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1214 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1215 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1216 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1217 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1218 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1219 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1220 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1221 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1222 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1223 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1224 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1225 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1226 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1227 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1228 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1229 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1230 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1231 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1232 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1233 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1234 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1235 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1236 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1237 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1238 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1239 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1240 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1242 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1243 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1244 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1245 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1246 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1247 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1248 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1249 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001253 {}
1254};
1255static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001256 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1257 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1258 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1259 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1260 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1262 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1263 {}
1264};
1265
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001266static const u8 (*sensor_init[])[8] = {
1267[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001268[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001269[SENSOR_HV7131R] = hv7131r_sensor_init,
1270[SENSOR_MI0360] = mi0360_sensor_init,
1271[SENSOR_MO4000] = mo4000_sensor_init,
1272[SENSOR_MT9V111] = mt9v111_sensor_init,
1273[SENSOR_OM6802] = om6802_sensor_init,
1274[SENSOR_OV7630] = ov7630_sensor_init,
1275[SENSOR_OV7648] = ov7648_sensor_init,
1276[SENSOR_OV7660] = ov7660_sensor_init,
1277[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001278[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001279[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001280};
1281
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001282/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001283static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001284 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001285{
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001286#ifdef GSPCA_DEBUG
1287 if (len > USB_BUF_SZ) {
1288 err("reg_r: buffer overflow");
1289 return;
1290 }
1291#endif
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001292 usb_control_msg(gspca_dev->dev,
1293 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001294 0,
1295 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1296 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001297 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001298 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001299 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001300}
1301
Jean-Francois Moine60017612008-07-18 08:46:19 -03001302static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001303 u16 value,
1304 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001305{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001306 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001307 gspca_dev->usb_buf[0] = data;
1308 usb_control_msg(gspca_dev->dev,
1309 usb_sndctrlpipe(gspca_dev->dev, 0),
1310 0x08,
1311 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1312 value,
1313 0,
1314 gspca_dev->usb_buf, 1,
1315 500);
1316}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001317static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001318 u16 value,
1319 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001320 int len)
1321{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001322 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001323 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001324#ifdef GSPCA_DEBUG
1325 if (len > USB_BUF_SZ) {
1326 err("reg_w: buffer overflow");
1327 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001328 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001329#endif
1330 memcpy(gspca_dev->usb_buf, buffer, len);
1331 usb_control_msg(gspca_dev->dev,
1332 usb_sndctrlpipe(gspca_dev->dev, 0),
1333 0x08,
1334 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1335 value, 0,
1336 gspca_dev->usb_buf, len,
1337 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001338}
1339
Jean-Francois Moine60017612008-07-18 08:46:19 -03001340/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001341static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001342{
1343 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001344
Jean-Francois Moine60017612008-07-18 08:46:19 -03001345 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001346 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001347 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001348 case SENSOR_OM6802:
1349 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001350 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1351 break;
1352 default: /* i2c command = a1 (400 kHz) */
1353 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1354 break;
1355 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001356 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001357 gspca_dev->usb_buf[2] = reg;
1358 gspca_dev->usb_buf[3] = val;
1359 gspca_dev->usb_buf[4] = 0;
1360 gspca_dev->usb_buf[5] = 0;
1361 gspca_dev->usb_buf[6] = 0;
1362 gspca_dev->usb_buf[7] = 0x10;
1363 usb_control_msg(gspca_dev->dev,
1364 usb_sndctrlpipe(gspca_dev->dev, 0),
1365 0x08,
1366 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1367 0x08, /* value = i2c */
1368 0,
1369 gspca_dev->usb_buf, 8,
1370 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001371}
1372
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001373/* I2C write 8 bytes */
1374static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001375 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001376{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001377 memcpy(gspca_dev->usb_buf, buffer, 8);
1378 usb_control_msg(gspca_dev->dev,
1379 usb_sndctrlpipe(gspca_dev->dev, 0),
1380 0x08,
1381 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1382 0x08, 0, /* value, index */
1383 gspca_dev->usb_buf, 8,
1384 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001385 msleep(2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001386}
1387
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001388/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1389static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001390{
1391 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001392 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001393
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001394 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001395 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001396 case SENSOR_OM6802:
1397 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001398 mode[0] = 0x80 | 0x10;
1399 break;
1400 default: /* i2c command = 91 (400 kHz) */
1401 mode[0] = 0x81 | 0x10;
1402 break;
1403 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001404 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001405 mode[2] = reg;
1406 mode[3] = 0;
1407 mode[4] = 0;
1408 mode[5] = 0;
1409 mode[6] = 0;
1410 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001411 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001412 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001413 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001414 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001415 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001416 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001417 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001418}
1419
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001420static void i2c_w_seq(struct gspca_dev *gspca_dev,
1421 const u8 (*data)[8])
1422{
1423 while ((*data)[0] != 0) {
1424 if ((*data)[0] != 0xdd)
1425 i2c_w8(gspca_dev, *data);
1426 else
1427 msleep((*data)[1]);
1428 data++;
1429 }
1430}
1431
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001432static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001433{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001434 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001435 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001436 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001437 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001438 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001439 if (gspca_dev->usb_buf[0] == 0x02
1440 && gspca_dev->usb_buf[1] == 0x09
1441 && gspca_dev->usb_buf[2] == 0x01
1442 && gspca_dev->usb_buf[3] == 0x00
1443 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001444 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1445 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001446 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001447 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001448 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1449 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001450}
1451
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001452static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001453{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001454 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001455 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001456 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001457 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001458 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001459 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1460 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1461 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1462 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1463 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001464 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001465 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1466 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1467 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1468 {}
1469 },
1470 };
1471
1472 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1473 reg_w1(gspca_dev, 0x17, 0x62);
1474 reg_w1(gspca_dev, 0x01, 0x08);
1475 for (j = 0; j < 3; j++)
1476 i2c_w8(gspca_dev, probe_tb[i][j]);
1477 msleep(2);
1478 reg_r(gspca_dev, 0x0a, 5);
1479 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1480 if (probe_tb[i][3][0] != 0)
1481 i2c_w8(gspca_dev, probe_tb[i][3]);
1482 reg_w1(gspca_dev, 0x01, 0x29);
1483 reg_w1(gspca_dev, 0x17, 0x42);
1484 if (val != 0xffff)
1485 break;
1486 }
1487 switch (val) {
1488 case 0x823a:
1489 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001490 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001491 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001492 case 0x8243:
1493 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001494 break;
1495 default:
1496 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1497 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001498 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001499}
1500
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001501static void ov7648_probe(struct gspca_dev *gspca_dev)
1502{
1503 struct sd *sd = (struct sd *) gspca_dev;
1504
1505 /* check ov76xx */
1506 reg_w1(gspca_dev, 0x17, 0x62);
1507 reg_w1(gspca_dev, 0x01, 0x08);
1508 sd->i2c_addr = 0x21;
1509 i2c_r(gspca_dev, 0x0a, 2);
1510 if (gspca_dev->usb_buf[3] == 0x76) { /* ov76xx */
1511 PDEBUG(D_PROBE, "Sensor ov%02x%02x",
1512 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1513 return;
1514 }
1515
1516 /* reset */
1517 reg_w1(gspca_dev, 0x01, 0x29);
1518 reg_w1(gspca_dev, 0x17, 0x42);
1519
1520 /* check po1030 */
1521 reg_w1(gspca_dev, 0x17, 0x62);
1522 reg_w1(gspca_dev, 0x01, 0x08);
1523 sd->i2c_addr = 0x6e;
1524 i2c_r(gspca_dev, 0x00, 2);
1525 if (gspca_dev->usb_buf[3] == 0x10 /* po1030 */
1526 && gspca_dev->usb_buf[4] == 0x30) {
1527 PDEBUG(D_PROBE, "Sensor po1030");
1528 sd->sensor = SENSOR_PO1030;
1529 return;
1530 }
1531
1532 PDEBUG(D_PROBE, "Unknown sensor %02x%02x",
1533 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1534}
1535
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001536/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1537static void po2030n_probe(struct gspca_dev *gspca_dev)
1538{
1539 struct sd *sd = (struct sd *) gspca_dev;
1540
1541 /* check gc0307 */
1542 reg_w1(gspca_dev, 0x17, 0x62);
1543 reg_w1(gspca_dev, 0x01, 0x08);
1544 reg_w1(gspca_dev, 0x02, 0x22);
1545 sd->i2c_addr = 0x21;
1546 i2c_r(gspca_dev, 0x00, 1);
1547
1548 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1549 reg_w1(gspca_dev, 0x17, 0x42);
1550
1551 if (gspca_dev->usb_buf[4] == 0x99) { /* gc0307 (?) */
1552 PDEBUG(D_PROBE, "Sensor gc0307");
1553 sd->sensor = SENSOR_GC0307;
1554 return;
1555 }
1556
1557 /* check po2030n */
1558 reg_w1(gspca_dev, 0x17, 0x62);
1559 reg_w1(gspca_dev, 0x01, 0x0a);
1560 sd->i2c_addr = 0x6e;
1561 i2c_r(gspca_dev, 0x00, 2);
1562
1563 reg_w1(gspca_dev, 0x01, 0x29);
1564 reg_w1(gspca_dev, 0x17, 0x42);
1565
1566 if (gspca_dev->usb_buf[3] == 0x20
1567 && gspca_dev->usb_buf[4] == 0x30)
1568 PDEBUG(D_PROBE, "Sensor po2030n");
1569/* sd->sensor = SENSOR_PO2030N; */
1570 else
1571 PDEBUG(D_PROBE, "Unknown sensor ID %02x%02x",
1572 gspca_dev->usb_buf[3],
1573 gspca_dev->usb_buf[4]);
1574}
1575
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001576static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001577 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001578{
1579 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001580 const u8 *reg9a;
1581 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001582 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1583 static const u8 reg9a_spec[] =
1584 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001585 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001586
Hans de Goede9712a8b2010-01-31 12:54:29 -03001587 /* sensor clock already enabled in sd_init */
1588 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001589 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001590
1591 /* configure gpio */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001592 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1593 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001594 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001595 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001596 case SENSOR_GC0307:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001597 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001598 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001599 case SENSOR_PO2030N:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001600 case SENSOR_SP80708:
1601 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001602 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001603 default:
1604 reg9a = reg9a_def;
1605 break;
1606 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001607 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001608
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001609 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001610
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001611 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001612
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001613 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001614 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001615 reg_w1(gspca_dev, 0x01, 0x43);
Jean-Francois Moine646775732009-12-20 12:31:28 -03001616 reg_w1(gspca_dev, 0x17, 0x62);
1617 reg_w1(gspca_dev, 0x01, 0x42);
1618 reg_w1(gspca_dev, 0x01, 0x42);
1619 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001620 case SENSOR_GC0307:
1621 msleep(50);
1622 reg_w1(gspca_dev, 0x01, 0x61);
1623 reg_w1(gspca_dev, 0x17, 0x22);
1624 reg_w1(gspca_dev, 0x01, 0x60);
1625 reg_w1(gspca_dev, 0x01, 0x40);
1626 msleep(50);
1627 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001628 case SENSOR_MT9V111:
1629 reg_w1(gspca_dev, 0x01, 0x61);
1630 reg_w1(gspca_dev, 0x17, 0x61);
1631 reg_w1(gspca_dev, 0x01, 0x60);
1632 reg_w1(gspca_dev, 0x01, 0x40);
1633 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001634 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001635 msleep(10);
1636 reg_w1(gspca_dev, 0x02, 0x73);
1637 reg_w1(gspca_dev, 0x17, 0x60);
1638 reg_w1(gspca_dev, 0x01, 0x22);
1639 msleep(100);
1640 reg_w1(gspca_dev, 0x01, 0x62);
1641 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001642 reg_w1(gspca_dev, 0x17, 0x64);
1643 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001644 msleep(10);
1645 reg_w1(gspca_dev, 0x01, 0x42);
1646 i2c_w8(gspca_dev, om6802_init0[0]);
1647 i2c_w8(gspca_dev, om6802_init0[1]);
1648 msleep(15);
1649 reg_w1(gspca_dev, 0x02, 0x71);
1650 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001651 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001652 case SENSOR_OV7630:
1653 reg_w1(gspca_dev, 0x01, 0x61);
1654 reg_w1(gspca_dev, 0x17, 0xe2);
1655 reg_w1(gspca_dev, 0x01, 0x60);
1656 reg_w1(gspca_dev, 0x01, 0x40);
1657 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001658 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001659 reg_w1(gspca_dev, 0x01, 0x63);
1660 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001661 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001662 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001663 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001664 case SENSOR_PO1030:
1665 reg_w1(gspca_dev, 0x01, 0x61);
1666 reg_w1(gspca_dev, 0x17, 0x20);
1667 reg_w1(gspca_dev, 0x01, 0x60);
1668 reg_w1(gspca_dev, 0x01, 0x40);
1669 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001670 case SENSOR_PO2030N:
1671 reg_w1(gspca_dev, 0x01, 0x63);
1672 reg_w1(gspca_dev, 0x17, 0x20);
1673 reg_w1(gspca_dev, 0x01, 0x62);
1674 reg_w1(gspca_dev, 0x01, 0x42);
1675 break;
Jean-Francois Moine91de65a2008-09-03 17:12:18 -03001676 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001677 /* fall thru */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001678 case SENSOR_SP80708:
1679 reg_w1(gspca_dev, 0x01, 0x63);
1680 reg_w1(gspca_dev, 0x17, 0x20);
1681 reg_w1(gspca_dev, 0x01, 0x62);
1682 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001683 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001684 reg_w1(gspca_dev, 0x02, 0x62);
1685 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001686 default:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001687/* case SENSOR_HV7131R: */
1688/* case SENSOR_MI0360: */
1689/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001690 reg_w1(gspca_dev, 0x01, 0x43);
1691 reg_w1(gspca_dev, 0x17, 0x61);
1692 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001693 if (sd->sensor == SENSOR_HV7131R
1694 && sd->bridge == BRIDGE_SN9C102P)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001695 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001696 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001697 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001698}
1699
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001700/* this function is called at probe time */
1701static int sd_config(struct gspca_dev *gspca_dev,
1702 const struct usb_device_id *id)
1703{
1704 struct sd *sd = (struct sd *) gspca_dev;
1705 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001706
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001707 sd->bridge = id->driver_info >> 16;
1708 sd->sensor = id->driver_info;
1709
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001710 cam = &gspca_dev->cam;
Jean-Francois Moine646775732009-12-20 12:31:28 -03001711 if (sd->sensor == SENSOR_ADCM1700) {
1712 cam->cam_mode = cif_mode;
1713 cam->nmodes = ARRAY_SIZE(cif_mode);
1714 } else {
1715 cam->cam_mode = vga_mode;
1716 cam->nmodes = ARRAY_SIZE(vga_mode);
1717 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001718 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001719
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001720 sd->brightness = BRIGHTNESS_DEF;
1721 sd->contrast = CONTRAST_DEF;
1722 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001723 sd->blue = BLUE_BALANCE_DEF;
1724 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001725 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001726 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001727 sd->ag_cnt = -1;
Hans de Goedef8009522009-06-18 14:29:20 -03001728 sd->vflip = VFLIP_DEF;
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001729 switch (sd->sensor) {
1730 case SENSOR_OM6802:
1731 sd->sharpness = 0x10;
1732 break;
1733 default:
1734 sd->sharpness = SHARPNESS_DEF;
1735 break;
1736 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001737 sd->infrared = INFRARED_DEF;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001738 sd->freq = FREQ_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001739 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001740 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001741
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001742 return 0;
1743}
1744
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001745/* this function is called at probe and resume time */
1746static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001747{
1748 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001749 const u8 *sn9c1xx;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001750 u8 regGpio[] = { 0x29, 0x74 };
1751 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001752
Hans de Goede3647fea2008-07-15 05:36:30 -03001753 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001754 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001755 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001756 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1757 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001758 regF1 = gspca_dev->usb_buf[0];
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001759 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001760 switch (sd->bridge) {
1761 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001762 if (regF1 != 0x11)
1763 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001764 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001765 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001766 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001767 if (regF1 != 0x11)
1768 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001769 if (sd->sensor == SENSOR_MI0360)
1770 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001771 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001772 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001773 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001774 if (regF1 != 0x12)
1775 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001776 switch (sd->sensor) {
1777 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001778 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001779 break;
1780 case SENSOR_OV7648:
1781 ov7648_probe(gspca_dev);
1782 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001783 case SENSOR_PO2030N:
1784 po2030n_probe(gspca_dev);
1785 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001786 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001787 regGpio[1] = 0x70;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001788 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001789 break;
1790 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001791/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001792/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001793 if (regF1 != 0x12)
1794 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001795 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001796 break;
1797 }
1798
Hans de Goede9712a8b2010-01-31 12:54:29 -03001799 /* Note we do not disable the sensor clock here (power saving mode),
1800 as that also disables the button on the cam. */
1801 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001802
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001803 /* set the i2c address */
1804 sn9c1xx = sn_tb[sd->sensor];
1805 sd->i2c_addr = sn9c1xx[9];
1806
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001807 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1808
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001809 return 0;
1810}
1811
Jean-Francois Moine98819182009-01-19 07:37:33 -03001812static u32 setexposure(struct gspca_dev *gspca_dev,
1813 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001814{
1815 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001816
1817 switch (sd->sensor) {
1818 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001819 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001820 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001821
1822 Expodoit[3] = expo >> 16;
1823 Expodoit[4] = expo >> 8;
1824 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001825 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001826 break;
1827 }
1828 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001829 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001830 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001831 static const u8 doit[] = /* update sensor */
1832 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1833 static const u8 sensorgo[] = /* sensor on */
1834 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001835
1836 if (expo > 0x0635)
1837 expo = 0x0635;
1838 else if (expo < 0x0001)
1839 expo = 0x0001;
1840 expoMi[3] = expo >> 8;
1841 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001842 i2c_w8(gspca_dev, expoMi);
1843 i2c_w8(gspca_dev, doit);
1844 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001845 break;
1846 }
1847 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001848 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001849 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001850 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001851 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001852 static const u8 gainMo[] =
1853 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001854
1855 if (expo > 0x1fff)
1856 expo = 0x1fff;
1857 else if (expo < 0x0001)
1858 expo = 0x0001;
1859 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001860 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861 expoMo10[3] = ((expo & 0x1c00) >> 10)
1862 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001863 i2c_w8(gspca_dev, expoMo10);
1864 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001865 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001866 ((expoMo10[3] & 0x07) << 10)
1867 | (expoMof[3] << 2)
1868 | ((expoMo10[3] & 0x30) >> 4));
1869 break;
1870 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001871 case SENSOR_MT9V111: {
1872 u8 expo_c1[] =
1873 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1874
1875 if (expo > 0x0280)
1876 expo = 0x0280;
1877 else if (expo < 0x0040)
1878 expo = 0x0040;
1879 expo_c1[3] = expo >> 8;
1880 expo_c1[4] = expo;
1881 i2c_w8(gspca_dev, expo_c1);
1882 break;
1883 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001884 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001885 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001886 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001887 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001888
1889 if (expo > 0x03ff)
1890 expo = 0x03ff;
1891 if (expo < 0x0001)
1892 expo = 0x0001;
1893 gainOm[3] = expo >> 2;
1894 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001895 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001896 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001897 break;
1898 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001899 }
1900 return expo;
1901}
1902
1903static void setbrightness(struct gspca_dev *gspca_dev)
1904{
1905 struct sd *sd = (struct sd *) gspca_dev;
1906 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001907 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001908
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001909 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001910 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001911 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001912 if (k2 > 0x1f)
1913 k2 = 0; /* only positive Y offset */
1914 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001915 case SENSOR_HV7131R:
1916 expo = sd->brightness << 4;
1917 if (expo > 0x002dc6c0)
1918 expo = 0x002dc6c0;
1919 else if (expo < 0x02a0)
1920 expo = 0x02a0;
1921 sd->exposure = setexposure(gspca_dev, expo);
1922 break;
1923 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001924 case SENSOR_MO4000:
1925 expo = sd->brightness >> 4;
1926 sd->exposure = setexposure(gspca_dev, expo);
1927 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001928 case SENSOR_MT9V111:
1929 expo = sd->brightness >> 8;
1930 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001931 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001932 case SENSOR_OM6802:
1933 expo = sd->brightness >> 6;
1934 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001935 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001936 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001937 }
1938
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001939 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001940}
1941
1942static void setcontrast(struct gspca_dev *gspca_dev)
1943{
1944 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001945 u8 k2;
1946 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001947
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001948 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1949 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001950 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001951 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001952 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001953 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001954 contrast[5] = 0;
1955 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001956}
1957
1958static void setcolors(struct gspca_dev *gspca_dev)
1959{
1960 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001961 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001962 u8 reg8a[12]; /* U & V gains */
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001963 static const s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001964 -24, -38, 64, /* UR UG UB */
1965 62, -51, -9 /* VR VG VB */
1966 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001967
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001968 for (i = 0; i < 6; i++) {
1969 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001970 reg8a[i * 2] = v;
1971 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001972 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001973 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001974}
1975
1976static void setredblue(struct gspca_dev *gspca_dev)
1977{
1978 struct sd *sd = (struct sd *) gspca_dev;
1979
1980 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001981/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001982 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001983}
1984
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001985static void setgamma(struct gspca_dev *gspca_dev)
1986{
1987 struct sd *sd = (struct sd *) gspca_dev;
1988 int i;
1989 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001990 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001991 static const u8 delta[17] = {
1992 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1993 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1994 };
1995
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001996 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001997 case SENSOR_ADCM1700:
1998 gamma_base = gamma_spec_0;
1999 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002000 case SENSOR_HV7131R:
2001 case SENSOR_MT9V111:
2002 gamma_base = gamma_spec_1;
2003 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002004 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002005 gamma_base = gamma_spec_2;
2006 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002007 case SENSOR_SP80708:
2008 gamma_base = gamma_spec_3;
2009 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002010 default:
2011 gamma_base = gamma_def;
2012 break;
2013 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002014
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002015 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002016 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002017 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
2018 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2019}
2020
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002021static void setautogain(struct gspca_dev *gspca_dev)
2022{
2023 struct sd *sd = (struct sd *) gspca_dev;
2024
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002025 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
2026 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002027 switch (sd->sensor) {
2028 case SENSOR_OV7630:
2029 case SENSOR_OV7648: {
2030 u8 comb;
2031
2032 if (sd->sensor == SENSOR_OV7630)
2033 comb = 0xc0;
2034 else
2035 comb = 0xa0;
2036 if (sd->autogain)
Hans de Goede1fec747c2009-06-18 06:05:07 -03002037 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002038 i2c_w1(&sd->gspca_dev, 0x13, comb);
2039 return;
2040 }
2041 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002042 if (sd->autogain)
2043 sd->ag_cnt = AG_CNT_START;
2044 else
2045 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002046}
2047
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002048/* hv7131r/ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002049static void setvflip(struct sd *sd)
2050{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002051 u8 comn;
2052
Jean-Francois Moine0939e262009-11-02 09:58:49 -03002053 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2054 return;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002055 switch (sd->sensor) {
2056 case SENSOR_HV7131R:
2057 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2058 if (sd->vflip)
2059 comn |= 0x01;
2060 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
2061 break;
2062 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002063 comn = 0x02;
Hans de Goedef8009522009-06-18 14:29:20 -03002064 if (!sd->vflip)
2065 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002066 i2c_w1(&sd->gspca_dev, 0x75, comn);
2067 break;
2068 default:
2069/* case SENSOR_OV7648: */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002070 comn = 0x06;
Hans de Goedef8009522009-06-18 14:29:20 -03002071 if (sd->vflip)
2072 comn |= 0x80;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002073 i2c_w1(&sd->gspca_dev, 0x75, comn);
2074 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002075 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002076}
2077
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002078static void setsharpness(struct sd *sd)
2079{
2080 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
2081}
2082
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002083static void setinfrared(struct sd *sd)
2084{
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002085 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
2086 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002087/*fixme: different sequence for StarCam Clip and StarCam 370i */
2088/* Clip */
2089 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
2090 sd->infrared ? 0x66 : 0x64);
2091}
2092
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002093static void setfreq(struct gspca_dev *gspca_dev)
2094{
2095 struct sd *sd = (struct sd *) gspca_dev;
2096
Jean-Francois Moine27954932009-07-08 05:21:50 -03002097 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
2098 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002099 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002100 u8 com8;
2101
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002102 com8 = 0xdf; /* auto gain/wb/expo */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002103 switch (sd->freq) {
2104 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002105 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002106 break;
2107 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002108 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002109 i2c_w1(gspca_dev, 0x3b, 0x0a);
2110 break;
2111 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002112 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002113 i2c_w1(gspca_dev, 0x3b, 0x02);
2114 break;
2115 }
2116 } else {
2117 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2118
2119 /* Get reg2a / reg2d base values */
2120 switch (sd->sensor) {
2121 case SENSOR_OV7630:
2122 reg2a = 0x08;
2123 reg2d = 0x01;
2124 break;
2125 case SENSOR_OV7648:
2126 reg2a = 0x11;
2127 reg2d = 0x81;
2128 break;
2129 }
2130
2131 switch (sd->freq) {
2132 case 0: /* Banding filter disabled */
2133 break;
2134 case 1: /* 50 hz (filter on and framerate adj) */
2135 reg2a |= 0x80;
2136 reg2b = 0xac;
2137 reg2d |= 0x04;
2138 break;
2139 case 2: /* 60 hz (filter on, no framerate adj) */
2140 reg2a |= 0x80;
2141 reg2d |= 0x04;
2142 break;
2143 }
2144 i2c_w1(gspca_dev, 0x2a, reg2a);
2145 i2c_w1(gspca_dev, 0x2b, reg2b);
2146 i2c_w1(gspca_dev, 0x2d, reg2d);
2147 }
2148}
2149
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002150static void setjpegqual(struct gspca_dev *gspca_dev)
2151{
2152 struct sd *sd = (struct sd *) gspca_dev;
2153 int i, sc;
2154
2155 if (sd->jpegqual < 50)
2156 sc = 5000 / sd->jpegqual;
2157 else
2158 sc = 200 - sd->jpegqual * 2;
2159#if USB_BUF_SZ < 64
2160#error "No room enough in usb_buf for quantization table"
2161#endif
2162 for (i = 0; i < 64; i++)
2163 gspca_dev->usb_buf[i] =
2164 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2165 usb_control_msg(gspca_dev->dev,
2166 usb_sndctrlpipe(gspca_dev->dev, 0),
2167 0x08,
2168 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2169 0x0100, 0,
2170 gspca_dev->usb_buf, 64,
2171 500);
2172 for (i = 0; i < 64; i++)
2173 gspca_dev->usb_buf[i] =
2174 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2175 usb_control_msg(gspca_dev->dev,
2176 usb_sndctrlpipe(gspca_dev->dev, 0),
2177 0x08,
2178 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2179 0x0140, 0,
2180 gspca_dev->usb_buf, 64,
2181 500);
2182
2183 sd->reg18 ^= 0x40;
2184 reg_w1(gspca_dev, 0x18, sd->reg18);
2185}
2186
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002187/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002188static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002189{
2190 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002191 int i;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002192 u8 reg1, reg2, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002193 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002194 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002195 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002196 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2197 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine646775732009-12-20 12:31:28 -03002198 static const u8 CA_adcm1700[] =
2199 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002200 static const u8 CA_po2030n[] =
2201 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002202 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002203 static const u8 CE_gc0307[] =
2204 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002205 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002206 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002207 static const u8 CE_po2030n[] =
2208 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002209
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002210 /* create the JPEG header */
2211 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
Julia Lawall3eb02372009-07-19 07:09:32 -03002212 if (!sd->jpeg_hdr)
2213 return -ENOMEM;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002214 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2215 0x21); /* JPEG 422 */
2216 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2217
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002218 /* initialize the bridge */
2219 sn9c1xx = sn_tb[sd->sensor];
2220 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002221
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002222 /* initialize the sensor */
2223 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2224
2225 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002226 case SENSOR_ADCM1700:
2227 reg2 = 0x60;
2228 break;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002229 case SENSOR_OM6802:
2230 reg2 = 0x71;
2231 break;
2232 case SENSOR_SP80708:
2233 reg2 = 0x62;
2234 break;
2235 default:
2236 reg2 = 0x40;
2237 break;
2238 }
2239 reg_w1(gspca_dev, 0x02, reg2);
2240 reg_w1(gspca_dev, 0x02, reg2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002241
Jean-Francois Moine60017612008-07-18 08:46:19 -03002242 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2243 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2244 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2245 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2246 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002247 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002248 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2249 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002250 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002251 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2252 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002253 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002254 reg_w1(gspca_dev, 0xc6, 0x00);
2255 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002256 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002257 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2258 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002259 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002260 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2261 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002262 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002263 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002264 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002265 case SENSOR_GC0307:
2266 reg17 = 0xa2;
2267 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002268 case SENSOR_MT9V111:
2269 reg17 = 0xe0;
2270 break;
Jean-Francois Moine646775732009-12-20 12:31:28 -03002271 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002272 case SENSOR_OV7630:
2273 reg17 = 0xe2;
2274 break;
2275 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002276 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002277 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002278 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002279 reg17 = 0xa0;
2280 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002281 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002282 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002283 reg17 = 0xa0;
2284 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002285 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002286 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002287 break;
2288 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002289 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002290
2291 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2292 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2293 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002294 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002295
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002296 setgamma(gspca_dev);
2297
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002298/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002299 for (i = 0; i < 8; i++)
2300 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002301 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002302 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002303 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002304 case SENSOR_SP80708:
2305 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002306 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002307 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002308 case SENSOR_MT9V111:
2309 reg_w1(gspca_dev, 0x9a, 0x07);
2310 break;
2311 case SENSOR_OV7648:
2312 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002313 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002314 case SENSOR_PO2030N:
2315 reg_w1(gspca_dev, 0x9a, 0x06);
2316 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002317 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002318 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002319 break;
2320 }
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002321 setsharpness(sd);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002322
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002323 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002324 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2325 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2326 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002327
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002328 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002329 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002330 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002331 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002332 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002333 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2334 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002335 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002336 case SENSOR_ADCM1700:
2337 init = adcm1700_sensor_param1;
2338 reg1 = 0x46;
2339 reg17 = 0xe2;
2340 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002341 case SENSOR_GC0307:
2342 init = gc0307_sensor_param1;
2343 reg17 = 0xa2;
2344 reg1 = 0x44;
2345 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002346 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002347 if (mode) {
2348/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2349 reg1 = 0x06; /* clk 24Mz */
2350 } else {
2351 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002352/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002353 }
2354 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002355 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002356 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002357 if (mode) {
2358 reg1 = 0x04; /* 320 clk 48Mhz */
2359 } else {
2360/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002361 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002362 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002363 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002364 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002365 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002366 reg17 = 0x64; /* 640 MCKSIZE */
2367 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002368 case SENSOR_OV7630:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002369 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002370 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002371 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002372 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002373 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002374 reg17 = 0x21;
2375/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002376 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002377 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002378 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002379 if (sd->bridge == BRIDGE_SN9C120) {
2380 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002381 reg17 = 0xa2;
2382 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002383 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002384 } else {
2385 reg17 = 0x22;
2386 reg1 = 0x06; /* 24 Mhz, video trf eneble
2387 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002388 }
2389 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002390 case SENSOR_PO1030:
2391 init = po1030_sensor_param1;
2392 reg17 = 0xa2;
2393 reg1 = 0x44;
2394 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002395 case SENSOR_PO2030N:
2396 init = po2030n_sensor_param1;
2397 reg1 = 0x46;
2398 reg17 = 0xa2;
2399 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002400 default:
2401/* case SENSOR_SP80708: */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002402 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002403 if (mode) {
2404/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002405 } else {
2406 reg1 = 0x46; /* 640 clk 48Mz */
2407 reg17 = 0xa2;
2408 }
2409 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002410 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002411
2412 /* more sensor initialization - param1 */
2413 if (init != NULL) {
2414 i2c_w_seq(gspca_dev, init);
2415/* init = NULL; */
2416 }
2417
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002418 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002419 switch (sd->sensor) {
2420 case SENSOR_ADCM1700:
2421 case SENSOR_GC0307:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002422 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002423 break;
2424 case SENSOR_PO2030N:
2425 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2426 break;
2427 default:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002428 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002429 break;
2430 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002431 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002432 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002433 case SENSOR_OV7630:
2434 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002435 case SENSOR_OV7660:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002436 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002437 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002438 case SENSOR_GC0307:
2439 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2440 break;
2441 case SENSOR_PO2030N:
2442 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2443 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002444 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002445 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002446 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2447 break;
2448 }
2449
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002450
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002451 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002452 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2453 reg_w1(gspca_dev, 0x18, sd->reg18);
2454 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002455
Jean-Francois Moine60017612008-07-18 08:46:19 -03002456 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002457 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002458
Jean-François Moine1e5eb112010-02-18 14:56:33 -03002459 setvflip(sd);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002460 setbrightness(gspca_dev);
2461 setcontrast(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002462 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002463 setfreq(gspca_dev);
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002464 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002465}
2466
2467static void sd_stopN(struct gspca_dev *gspca_dev)
2468{
2469 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002470 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002471 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002472 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002473 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002474 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002475 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002476 u8 data;
2477 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002478
2479 data = 0x0b;
2480 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002481 case SENSOR_GC0307:
2482 data = 0x29;
2483 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002484 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002485 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002486 data = 0x2b;
2487 break;
2488 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002489 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002490 data = 0x29;
2491 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002492 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002493 i2c_w8(gspca_dev, stopov7648);
2494 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002495 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002496 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002497 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002498 data = 0x29;
2499 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002500 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002501 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002502 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2503 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2504 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2505 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002506 /* Don't disable sensor clock as that disables the button on the cam */
2507 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002508}
2509
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002510static void sd_stop0(struct gspca_dev *gspca_dev)
2511{
2512 struct sd *sd = (struct sd *) gspca_dev;
2513
2514 kfree(sd->jpeg_hdr);
2515}
2516
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002517static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002518{
2519 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002520 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002521 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002522 u8 luma_mean = 130;
2523 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002524
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002525 /* Thanks S., without your advice, autobright should not work :) */
2526 if (sd->ag_cnt < 0)
2527 return;
2528 if (--sd->ag_cnt >= 0)
2529 return;
2530 sd->ag_cnt = AG_CNT_START;
2531
2532 delta = atomic_read(&sd->avg_lum);
2533 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002534 if (delta < luma_mean - luma_delta ||
2535 delta > luma_mean + luma_delta) {
2536 switch (sd->sensor) {
2537 case SENSOR_HV7131R:
2538 expotimes = sd->exposure >> 8;
2539 expotimes += (luma_mean - delta) >> 4;
2540 if (expotimes < 0)
2541 expotimes = 0;
2542 sd->exposure = setexposure(gspca_dev,
2543 (unsigned int) (expotimes << 8));
2544 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002545 case SENSOR_OM6802:
2546 expotimes = sd->exposure;
2547 expotimes += (luma_mean - delta) >> 2;
2548 if (expotimes < 0)
2549 expotimes = 0;
2550 sd->exposure = setexposure(gspca_dev,
2551 (unsigned int) expotimes);
2552 setredblue(gspca_dev);
2553 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002554 default:
2555/* case SENSOR_MO4000: */
2556/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002557/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002558 expotimes = sd->exposure;
2559 expotimes += (luma_mean - delta) >> 6;
2560 if (expotimes < 0)
2561 expotimes = 0;
2562 sd->exposure = setexposure(gspca_dev,
2563 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002564 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002565 break;
2566 }
2567 }
2568}
2569
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002570/* scan the URB packets */
2571/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002572static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002573 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002574 int len) /* iso packet length */
2575{
2576 struct sd *sd = (struct sd *) gspca_dev;
2577 int sof, avg_lum;
2578
2579 sof = len - 64;
2580 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2581
2582 /* end of frame */
2583 gspca_frame_add(gspca_dev, LAST_PACKET,
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002584 data, sof + 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002585 if (sd->ag_cnt < 0)
2586 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002587/* w1 w2 w3 */
2588/* w4 w5 w6 */
2589/* w7 w8 */
2590/* w4 */
2591 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2592/* w6 */
2593 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2594/* w2 */
2595 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2596/* w8 */
2597 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2598/* w5 */
2599 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2600 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002601 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002602 return;
2603 }
2604 if (gspca_dev->last_packet_type == LAST_PACKET) {
2605
2606 /* put the JPEG 422 header */
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002607 gspca_frame_add(gspca_dev, FIRST_PACKET,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002608 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002609 }
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002610 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002611}
2612
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002613static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2614{
2615 struct sd *sd = (struct sd *) gspca_dev;
2616
2617 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002618 if (gspca_dev->streaming)
2619 setbrightness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002620 return 0;
2621}
2622
2623static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2624{
2625 struct sd *sd = (struct sd *) gspca_dev;
2626
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002627 *val = sd->brightness;
2628 return 0;
2629}
2630
2631static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2632{
2633 struct sd *sd = (struct sd *) gspca_dev;
2634
2635 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002636 if (gspca_dev->streaming)
2637 setcontrast(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002638 return 0;
2639}
2640
2641static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2642{
2643 struct sd *sd = (struct sd *) gspca_dev;
2644
2645 *val = sd->contrast;
2646 return 0;
2647}
2648
2649static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2650{
2651 struct sd *sd = (struct sd *) gspca_dev;
2652
2653 sd->colors = val;
2654 if (gspca_dev->streaming)
2655 setcolors(gspca_dev);
2656 return 0;
2657}
2658
2659static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2660{
2661 struct sd *sd = (struct sd *) gspca_dev;
2662
2663 *val = sd->colors;
2664 return 0;
2665}
2666
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002667static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2668{
2669 struct sd *sd = (struct sd *) gspca_dev;
2670
2671 sd->blue = val;
2672 if (gspca_dev->streaming)
2673 setredblue(gspca_dev);
2674 return 0;
2675}
2676
2677static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2678{
2679 struct sd *sd = (struct sd *) gspca_dev;
2680
2681 *val = sd->blue;
2682 return 0;
2683}
2684
2685static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2686{
2687 struct sd *sd = (struct sd *) gspca_dev;
2688
2689 sd->red = val;
2690 if (gspca_dev->streaming)
2691 setredblue(gspca_dev);
2692 return 0;
2693}
2694
2695static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2696{
2697 struct sd *sd = (struct sd *) gspca_dev;
2698
2699 *val = sd->red;
2700 return 0;
2701}
2702
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002703static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2704{
2705 struct sd *sd = (struct sd *) gspca_dev;
2706
2707 sd->gamma = val;
2708 if (gspca_dev->streaming)
2709 setgamma(gspca_dev);
2710 return 0;
2711}
2712
2713static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2714{
2715 struct sd *sd = (struct sd *) gspca_dev;
2716
2717 *val = sd->gamma;
2718 return 0;
2719}
2720
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002721static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2722{
2723 struct sd *sd = (struct sd *) gspca_dev;
2724
2725 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002726 if (gspca_dev->streaming)
2727 setautogain(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002728 return 0;
2729}
2730
2731static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2732{
2733 struct sd *sd = (struct sd *) gspca_dev;
2734
2735 *val = sd->autogain;
2736 return 0;
2737}
2738
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002739static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2740{
2741 struct sd *sd = (struct sd *) gspca_dev;
2742
2743 sd->sharpness = val;
2744 if (gspca_dev->streaming)
2745 setsharpness(sd);
2746 return 0;
2747}
2748
2749static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2750{
2751 struct sd *sd = (struct sd *) gspca_dev;
2752
2753 *val = sd->sharpness;
2754 return 0;
2755}
2756
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002757static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2758{
2759 struct sd *sd = (struct sd *) gspca_dev;
2760
2761 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002762 if (gspca_dev->streaming)
2763 setvflip(sd);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002764 return 0;
2765}
2766
2767static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2768{
2769 struct sd *sd = (struct sd *) gspca_dev;
2770
2771 *val = sd->vflip;
2772 return 0;
2773}
2774
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002775static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2776{
2777 struct sd *sd = (struct sd *) gspca_dev;
2778
2779 sd->infrared = val;
2780 if (gspca_dev->streaming)
2781 setinfrared(sd);
2782 return 0;
2783}
2784
2785static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2786{
2787 struct sd *sd = (struct sd *) gspca_dev;
2788
2789 *val = sd->infrared;
2790 return 0;
2791}
2792
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002793static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2794{
2795 struct sd *sd = (struct sd *) gspca_dev;
2796
2797 sd->freq = val;
2798 if (gspca_dev->streaming)
2799 setfreq(gspca_dev);
2800 return 0;
2801}
2802
2803static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2804{
2805 struct sd *sd = (struct sd *) gspca_dev;
2806
2807 *val = sd->freq;
2808 return 0;
2809}
2810
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002811static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2812 struct v4l2_jpegcompression *jcomp)
2813{
2814 struct sd *sd = (struct sd *) gspca_dev;
2815
2816 if (jcomp->quality < QUALITY_MIN)
2817 sd->quality = QUALITY_MIN;
2818 else if (jcomp->quality > QUALITY_MAX)
2819 sd->quality = QUALITY_MAX;
2820 else
2821 sd->quality = jcomp->quality;
2822 if (gspca_dev->streaming)
2823 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2824 return 0;
2825}
2826
2827static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2828 struct v4l2_jpegcompression *jcomp)
2829{
2830 struct sd *sd = (struct sd *) gspca_dev;
2831
2832 memset(jcomp, 0, sizeof *jcomp);
2833 jcomp->quality = sd->quality;
2834 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2835 | V4L2_JPEG_MARKER_DQT;
2836 return 0;
2837}
2838
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002839static int sd_querymenu(struct gspca_dev *gspca_dev,
2840 struct v4l2_querymenu *menu)
2841{
2842 switch (menu->id) {
2843 case V4L2_CID_POWER_LINE_FREQUENCY:
2844 switch (menu->index) {
2845 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2846 strcpy((char *) menu->name, "NoFliker");
2847 return 0;
2848 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2849 strcpy((char *) menu->name, "50 Hz");
2850 return 0;
2851 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2852 strcpy((char *) menu->name, "60 Hz");
2853 return 0;
2854 }
2855 break;
2856 }
2857 return -EINVAL;
2858}
2859
Hans de Goede9712a8b2010-01-31 12:54:29 -03002860#ifdef CONFIG_INPUT
2861static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2862 u8 *data, /* interrupt packet data */
2863 int len) /* interrupt packet length */
2864{
2865 int ret = -EINVAL;
2866
2867 if (len == 1 && data[0] == 1) {
2868 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2869 input_sync(gspca_dev->input_dev);
2870 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2871 input_sync(gspca_dev->input_dev);
2872 ret = 0;
2873 }
2874
2875 return ret;
2876}
2877#endif
2878
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002879/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002880static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002881 .name = MODULE_NAME,
2882 .ctrls = sd_ctrls,
2883 .nctrls = ARRAY_SIZE(sd_ctrls),
2884 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002885 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002886 .start = sd_start,
2887 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002888 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002889 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002890 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002891 .get_jcomp = sd_get_jcomp,
2892 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002893 .querymenu = sd_querymenu,
Hans de Goede9712a8b2010-01-31 12:54:29 -03002894#ifdef CONFIG_INPUT
2895 .int_pkt_scan = sd_int_pkt_scan,
2896#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002897};
2898
2899/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002900#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002901 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002902 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002903static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002904#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002905 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2906 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002907#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002908 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2909 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2910 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2911 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2912 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2913 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2914 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2915/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2916 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2917/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2918/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2919 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2920/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2921 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2922/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2923/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2924/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
2925 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2926/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2927/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
2928 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002929#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002930 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2931 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002932#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002933 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
2934/* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, P1030xC)}, */
2935/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2936 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2937 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2938 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2939 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2940/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2941/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2942/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2943 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002944/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002945 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002946 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2947 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2948/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03002949#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002950 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002951#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002952/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2953 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2954 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002955#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002956 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002957#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002958 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2959 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002960 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002961 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2962 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine646775732009-12-20 12:31:28 -03002963 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002964 {}
2965};
2966MODULE_DEVICE_TABLE(usb, device_table);
2967
2968/* -- device connect -- */
2969static int sd_probe(struct usb_interface *intf,
2970 const struct usb_device_id *id)
2971{
2972 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2973 THIS_MODULE);
2974}
2975
2976static struct usb_driver sd_driver = {
2977 .name = MODULE_NAME,
2978 .id_table = device_table,
2979 .probe = sd_probe,
2980 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002981#ifdef CONFIG_PM
2982 .suspend = gspca_suspend,
2983 .resume = gspca_resume,
2984#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002985};
2986
2987/* -- module insert / remove -- */
2988static int __init sd_mod_init(void)
2989{
Alexey Klimovf69e9522009-01-01 13:02:07 -03002990 int ret;
2991 ret = usb_register(&sd_driver);
2992 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -03002993 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -03002994 info("registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002995 return 0;
2996}
2997static void __exit sd_mod_exit(void)
2998{
2999 usb_deregister(&sd_driver);
3000 info("deregistered");
3001}
3002
3003module_init(sd_mod_init);
3004module_exit(sd_mod_exit);