blob: c0573c405a11bf978d10591e3e08a361e35bab65 [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03002 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003 *
Jean-François Moine27c6f9e2010-04-02 06:59:13 -03004 * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr>
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03005 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "sonixj"
23
Hans de Goede9712a8b2010-01-31 12:54:29 -030024#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030025#include "gspca.h"
26#include "jpeg.h"
27
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030028#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29
Jean-François Moine27c6f9e2010-04-02 06:59:13 -030030MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030031MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL");
33
Jean-François Moine72b667e2010-10-02 04:35:25 -030034/* controls */
35enum e_ctrl {
36 BRIGHTNESS,
37 CONTRAST,
38 COLORS,
39 BLUE,
40 RED,
41 GAMMA,
42 AUTOGAIN,
43 VFLIP,
44 SHARPNESS,
45 INFRARED,
46 FREQ,
47 NCTRLS /* number of controls */
48};
49
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030050/* specific webcam descriptor */
51struct sd {
52 struct gspca_dev gspca_dev; /* !! must be the first item */
53
Jean-François Moine72b667e2010-10-02 04:35:25 -030054 struct gspca_ctrl ctrls[NCTRLS];
55
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030056 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030057 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030058
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030059 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030060#define QUALITY_MIN 60
61#define QUALITY_MAX 95
62#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030063 u8 jpegqual; /* webcam quality */
64
65 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030066
Jean-Francois Moine98819182009-01-19 07:37:33 -030067 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030068#define AG_CNT_START 13
69
Jean-Francois Moine98819182009-01-19 07:37:33 -030070 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030071#define BRIDGE_SN9C102P 0
72#define BRIDGE_SN9C105 1
73#define BRIDGE_SN9C110 2
74#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030075 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030076 u8 i2c_addr;
77
78 u8 jpeg_hdr[JPEG_HDR_SZ];
79};
80enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030081 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030082 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030083 SENSOR_HV7131R,
84 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030085 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030086 SENSOR_MO4000,
87 SENSOR_MT9V111,
88 SENSOR_OM6802,
89 SENSOR_OV7630,
90 SENSOR_OV7648,
91 SENSOR_OV7660,
92 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030093 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030094 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030095 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030096};
97
98/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -030099static void setbrightness(struct gspca_dev *gspca_dev);
100static void setcontrast(struct gspca_dev *gspca_dev);
101static void setcolors(struct gspca_dev *gspca_dev);
102static void setredblue(struct gspca_dev *gspca_dev);
103static void setgamma(struct gspca_dev *gspca_dev);
104static void setautogain(struct gspca_dev *gspca_dev);
105static void setvflip(struct gspca_dev *gspca_dev);
106static void setsharpness(struct gspca_dev *gspca_dev);
107static void setinfrared(struct gspca_dev *gspca_dev);
108static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300109
Jean-François Moine72b667e2010-10-02 04:35:25 -0300110static const struct ctrl sd_ctrls[NCTRLS] = {
111[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300112 {
113 .id = V4L2_CID_BRIGHTNESS,
114 .type = V4L2_CTRL_TYPE_INTEGER,
115 .name = "Brightness",
116 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300117 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300118 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300119 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300120 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300121 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300122 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300123[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300124 {
125 .id = V4L2_CID_CONTRAST,
126 .type = V4L2_CTRL_TYPE_INTEGER,
127 .name = "Contrast",
128 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300129#define CONTRAST_MAX 127
130 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300131 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300132 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300133 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300134 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300135 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300136[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300137 {
138 .id = V4L2_CID_SATURATION,
139 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300140 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300141 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300142 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300143 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300144#define COLORS_DEF 25
145 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300146 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300147 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300149[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300150 {
151 .id = V4L2_CID_BLUE_BALANCE,
152 .type = V4L2_CTRL_TYPE_INTEGER,
153 .name = "Blue Balance",
154 .minimum = 24,
155 .maximum = 40,
156 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300157 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300158 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300159 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300160 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300161[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300162 {
163 .id = V4L2_CID_RED_BALANCE,
164 .type = V4L2_CTRL_TYPE_INTEGER,
165 .name = "Red Balance",
166 .minimum = 24,
167 .maximum = 40,
168 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300169 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300170 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300171 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300172 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300173[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300174 {
175 .id = V4L2_CID_GAMMA,
176 .type = V4L2_CTRL_TYPE_INTEGER,
177 .name = "Gamma",
178 .minimum = 0,
179 .maximum = 40,
180 .step = 1,
181#define GAMMA_DEF 20
182 .default_value = GAMMA_DEF,
183 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300184 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300185 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300186[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300187 {
188 .id = V4L2_CID_AUTOGAIN,
189 .type = V4L2_CTRL_TYPE_BOOLEAN,
190 .name = "Auto Gain",
191 .minimum = 0,
192 .maximum = 1,
193 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300194 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300195 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300196 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300197 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300198/* ov7630/ov7648 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300199[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300200 {
201 .id = V4L2_CID_VFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
203 .name = "Vflip",
204 .minimum = 0,
205 .maximum = 1,
206 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300207 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300208 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300209 .set_control = setvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300210 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300211[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300212 {
213 .id = V4L2_CID_SHARPNESS,
214 .type = V4L2_CTRL_TYPE_INTEGER,
215 .name = "Sharpness",
216 .minimum = 0,
217 .maximum = 255,
218 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300219 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300220 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300221 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300222 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300223/* mt9v111 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300224[INFRARED] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300225 {
226 .id = V4L2_CID_INFRARED,
227 .type = V4L2_CTRL_TYPE_BOOLEAN,
228 .name = "Infrared",
229 .minimum = 0,
230 .maximum = 1,
231 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300232 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300233 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300234 .set_control = setinfrared
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300235 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300236/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300237[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300238 {
239 .id = V4L2_CID_POWER_LINE_FREQUENCY,
240 .type = V4L2_CTRL_TYPE_MENU,
241 .name = "Light frequency filter",
242 .minimum = 0,
243 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
244 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300245 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300246 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300247 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300248 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300249};
250
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300251/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300252static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300253[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
254 (1 << INFRARED) |
255 (1 << VFLIP) |
256 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300257
Jean-François Moine72b667e2010-10-02 04:35:25 -0300258[SENSOR_GC0307] = (1 << INFRARED) |
259 (1 << VFLIP) |
260 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300261
Jean-François Moine72b667e2010-10-02 04:35:25 -0300262[SENSOR_HV7131R] = (1 << INFRARED) |
263 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300264
Jean-François Moine72b667e2010-10-02 04:35:25 -0300265[SENSOR_MI0360] = (1 << INFRARED) |
266 (1 << VFLIP) |
267 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300268
Jean-François Moine72b667e2010-10-02 04:35:25 -0300269[SENSOR_MI0360B] = (1 << INFRARED) |
270 (1 << VFLIP) |
271 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300272
Jean-François Moine72b667e2010-10-02 04:35:25 -0300273[SENSOR_MO4000] = (1 << INFRARED) |
274 (1 << VFLIP) |
275 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300276
Jean-François Moine72b667e2010-10-02 04:35:25 -0300277[SENSOR_MT9V111] = (1 << VFLIP) |
278 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300279
Jean-François Moine72b667e2010-10-02 04:35:25 -0300280[SENSOR_OM6802] = (1 << INFRARED) |
281 (1 << VFLIP) |
282 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300283
Jean-François Moine72b667e2010-10-02 04:35:25 -0300284[SENSOR_OV7630] = (1 << INFRARED),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300285
Jean-François Moine72b667e2010-10-02 04:35:25 -0300286[SENSOR_OV7648] = (1 << INFRARED),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300287
Jean-François Moine72b667e2010-10-02 04:35:25 -0300288[SENSOR_OV7660] = (1 << AUTOGAIN) |
289 (1 << INFRARED) |
290 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300291
Jean-François Moine72b667e2010-10-02 04:35:25 -0300292[SENSOR_PO1030] = (1 << AUTOGAIN) |
293 (1 << INFRARED) |
294 (1 << VFLIP) |
295 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300296
Jean-François Moine72b667e2010-10-02 04:35:25 -0300297[SENSOR_PO2030N] = (1 << AUTOGAIN) |
298 (1 << INFRARED) |
299 (1 << VFLIP) |
300 (1 << FREQ),
301[SENSOR_SOI768] = (1 << AUTOGAIN) |
302 (1 << INFRARED) |
303 (1 << VFLIP) |
304 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300305
Jean-François Moine72b667e2010-10-02 04:35:25 -0300306[SENSOR_SP80708] = (1 << AUTOGAIN) |
307 (1 << INFRARED) |
308 (1 << VFLIP) |
309 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300310};
311
Jean-Francois Moine64677572009-12-20 12:31:28 -0300312static const struct v4l2_pix_format cif_mode[] = {
313 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
314 .bytesperline = 352,
315 .sizeimage = 352 * 288 * 4 / 8 + 590,
316 .colorspace = V4L2_COLORSPACE_JPEG,
317 .priv = 0},
318};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300319static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300320 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
321 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300322 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300323 .colorspace = V4L2_COLORSPACE_JPEG,
324 .priv = 2},
325 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
326 .bytesperline = 320,
327 .sizeimage = 320 * 240 * 3 / 8 + 590,
328 .colorspace = V4L2_COLORSPACE_JPEG,
329 .priv = 1},
330 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
331 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300332 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
333 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300334 .colorspace = V4L2_COLORSPACE_JPEG,
335 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300336};
337
Jean-Francois Moine64677572009-12-20 12:31:28 -0300338static const u8 sn_adcm1700[0x1c] = {
339/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300340 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300341/* reg8 reg9 rega regb regc regd rege regf */
342 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
344 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
345/* reg18 reg19 reg1a reg1b */
346 0x06, 0x00, 0x00, 0x00
347};
348
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300349static const u8 sn_gc0307[0x1c] = {
350/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
351 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
352/* reg8 reg9 rega regb regc regd rege regf */
353 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
355 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
356/* reg18 reg19 reg1a reg1b */
357 0x06, 0x00, 0x00, 0x00
358};
359
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300360static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300361/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300362 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300363/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300364 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300365/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
366 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300367/* reg18 reg19 reg1a reg1b */
368 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300369};
370
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300371static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300372/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300373 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300374/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300375 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300376/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
377 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300378/* reg18 reg19 reg1a reg1b */
379 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300380};
381
Jean-François Moinea067db82010-10-01 07:51:24 -0300382static const u8 sn_mi0360b[0x1c] = {
383/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
384 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
385/* reg8 reg9 rega regb regc regd rege regf */
386 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
388 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
389/* reg18 reg19 reg1a reg1b */
390 0x06, 0x00, 0x00, 0x00
391};
392
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300393static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300394/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300395 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300396/* reg8 reg9 rega regb regc regd rege regf */
397 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
398/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
399 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300400/* reg18 reg19 reg1a reg1b */
401 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300402};
403
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300404static const u8 sn_mt9v111[0x1c] = {
405/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
406 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
407/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300408 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300409/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
410 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
411/* reg18 reg19 reg1a reg1b */
412 0x06, 0x00, 0x00, 0x00
413};
414
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300415static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300416/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300417 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300418/* reg8 reg9 rega regb regc regd rege regf */
419 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
421 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300422/* reg18 reg19 reg1a reg1b */
423 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300424};
425
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300426static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300427/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300428 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300429/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300430 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300431/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
432 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300433/* reg18 reg19 reg1a reg1b */
434 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300435};
436
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300437static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300438/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300439 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300440/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300441 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300442/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300443 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300444/* reg18 reg19 reg1a reg1b */
445 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300446};
447
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300448static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300449/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300450 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300451/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300452 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300453/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
454 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300455/* reg18 reg19 reg1a reg1b */
456 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300457};
458
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300459static const u8 sn_po1030[0x1c] = {
460/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
461 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
462/* reg8 reg9 rega regb regc regd rege regf */
463 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
465 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
466/* reg18 reg19 reg1a reg1b */
467 0x07, 0x00, 0x00, 0x00
468};
469
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300470static const u8 sn_po2030n[0x1c] = {
471/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
472 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
473/* reg8 reg9 rega regb regc regd rege regf */
474 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
476 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
477/* reg18 reg19 reg1a reg1b */
478 0x07, 0x00, 0x00, 0x00
479};
480
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300481static const u8 sn_soi768[0x1c] = {
482/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
483 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
484/* reg8 reg9 rega regb regc regd rege regf */
485 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
487 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
488/* reg18 reg19 reg1a reg1b */
489 0x07, 0x00, 0x00, 0x00
490};
491
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300492static const u8 sn_sp80708[0x1c] = {
493/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
494 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
495/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300496 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300497/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
498 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
499/* reg18 reg19 reg1a reg1b */
500 0x07, 0x00, 0x00, 0x00
501};
502
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300503/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300504static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300505[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300506[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300507[SENSOR_HV7131R] = sn_hv7131,
508[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300509[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300510[SENSOR_MO4000] = sn_mo4000,
511[SENSOR_MT9V111] = sn_mt9v111,
512[SENSOR_OM6802] = sn_om6802,
513[SENSOR_OV7630] = sn_ov7630,
514[SENSOR_OV7648] = sn_ov7648,
515[SENSOR_OV7660] = sn_ov7660,
516[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300517[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300518[SENSOR_SOI768] = sn_soi768,
519[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300520};
521
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300522/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300523static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300524 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
525 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
526};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300527/* gamma for sensor ADCM1700 */
528static const u8 gamma_spec_0[17] = {
529 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
530 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
531};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300532/* gamma for sensors HV7131R and MT9V111 */
533static const u8 gamma_spec_1[17] = {
534 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
535 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
536};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300537/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300538static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300539 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
540 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
541};
542/* gamma for sensor SP80708 */
543static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300544 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
545 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
546};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300547
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300548/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300549static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300550 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
551 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
552 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
553 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300554};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300555static const u8 adcm1700_sensor_init[][8] = {
556 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300557 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300558 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
559 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
560 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
561 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
562 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
563 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
564 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
565 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
566 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
567 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
568 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
569 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
570 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
571 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
572 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
573 {}
574};
575static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300576 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300577 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
578
579 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
580 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
581 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
582 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300583 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300584
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300585 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
586 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
587 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
588 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300589 {}
590};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300591static const u8 gc0307_sensor_init[][8] = {
592 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
593 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
594 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
595 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
596 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
598 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
599 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
601 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
602 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
603 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
604 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
605 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
606 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
608 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
609 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
610 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
611 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
612 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
613 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
617 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
619 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
630 {}
631};
632static const u8 gc0307_sensor_param1[][8] = {
633 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
634 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
635 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
636 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
637/*param3*/
638 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300640 {}
641};
642
Jean-Francois Moine98819182009-01-19 07:37:33 -0300643static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300644 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
645 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
646 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
647/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
648 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
650/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300651
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300652 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
653 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
654 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
655 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
656 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
657 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
658 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
659 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300660
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300661 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
662 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300663 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300664 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
665 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300666
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300667 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
668 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
669 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
670 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
671 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300672 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
673 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300674 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300675};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300676static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300677 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300678 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300679 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300680 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
681 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
682 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
683 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
684 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
685 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
687 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
688 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
689 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
690 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
691 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
692 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
694 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
695 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
696 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
698 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300699 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300700 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
701 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
702 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
703 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
704 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
705 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
706 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
709 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300710
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300711 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
712 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
713 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
714 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
715 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300716
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300717 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
718 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
719 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
720 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300721
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300722 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
723 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
724/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
725/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
726 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
727 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300728 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300729};
Jean-François Moinea067db82010-10-01 07:51:24 -0300730static const u8 mi0360b_sensor_init[][8] = {
731 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
732 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
733 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
734 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
736 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
737 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
738 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
739 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
743 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
746 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
747 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
748 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
749 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
750 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
752 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
753 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
754 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
755 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
756 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
757 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
758 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
759 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
760 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
761 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
762 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
763 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
764 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
765 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
766
767 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
769 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
770 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
771 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
772 {}
773};
774static const u8 mi0360b_sensor_param1[][8] = {
775 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
777 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
778 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
779
780 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
781 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
782 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
783 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
784 {}
785};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300786static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300787 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
788 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
793 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
794 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
795 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
798 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
799 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
800 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
801 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
802 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
803 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
804 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
805 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
806 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300807 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300808};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300809static const u8 mt9v111_sensor_init[][8] = {
810 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300811 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300812 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
813 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
814 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
815 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300816 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
817 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
818 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
819 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300820 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300821 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
822 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
823 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
824 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
825 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300826 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300827 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300828 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
829 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
830 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
831 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
832 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
833 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
834 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
835 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
836 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
837 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300838 {}
839};
840static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300841 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
842 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300843 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300844 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
845 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
846 /*******/
847 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
848 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
849 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
850 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
851 {}
852};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300853static const u8 om6802_init0[2][8] = {
854/*fixme: variable*/
855 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
856 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
857};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300858static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300859 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
860 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300861 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300862 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300863 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300864/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
865 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300866 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300867/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
868 * set color mode */
869/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
870 * max AGC value in AE */
871/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
872 * preset AGC */
873/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
874 * preset brightness */
875/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
876 * preset contrast */
877/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
878 * preset gamma */
879 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300880 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300881 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
882 /* preset shutter */
883/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
884 * auto frame rate */
885/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300886 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
887 {}
888};
889static const u8 om6802_sensor_param1[][8] = {
890 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
891 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
892 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
893 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300894 {}
895};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300896static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300897 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
898 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300899 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300900 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300902 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300903 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300904/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300905 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
906 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300907/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
908 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
909 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300910 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
911 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
912 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
913 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
914 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
915 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
916 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
917 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
918 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
920 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
921 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
922 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
923 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
924 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
925 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
926 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
927 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
928 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
929 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
930 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
931 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
932 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300933 {}
934};
935static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300936 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
937 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
938/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300939/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
940 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300941 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
942 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
943 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300944/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300945/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
946/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300947/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300948 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300949/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300950 {}
951};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300952
Jean-Francois Moine98819182009-01-19 07:37:33 -0300953static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300954 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
955 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300956 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300957 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
958 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
959 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
960 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
961 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
962 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
963 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
964 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
965 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
966 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
967 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
968 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
969 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
970 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
971 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
972 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
973 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
974 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
975 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
976
977 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
978/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
979/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300980/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300981 {}
982};
983static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300984/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300985/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
986 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300987 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
988 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
989/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
990/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
991/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
992/*...*/
993 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
994/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
995/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
996/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
997/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
998/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
999
1000 {}
1001};
1002
Jean-Francois Moine98819182009-01-19 07:37:33 -03001003static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001004 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001005 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001006 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001007 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001008 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001009 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001010 /* GAIN BLUE RED VREF */
1011 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1012 /* COM 1 BAVE GEAVE AECHH */
1013 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1014 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001015 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001016 /* AECH CLKRC COM7 COM8 */
1017 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1018 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1019 /* HSTART HSTOP VSTRT VSTOP */
1020 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1021 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1022 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1023 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001024/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1025 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001026 /* AEW AEB VPT BBIAS */
1027 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1028 /* GbBIAS RSVD EXHCH EXHCL */
1029 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1030 /* RBIAS ADVFL ASDVFH YAVE */
1031 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1032 /* HSYST HSYEN HREF */
1033 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1034 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1035 /* ADC ACOM OFON TSLB */
1036 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1037 /* COM11 COM12 COM13 COM14 */
1038 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1039 /* EDGE COM15 COM16 COM17 */
1040 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1041 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1042 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1043 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1044 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1045 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1046 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1047 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1048 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1049 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1050 /* LCC1 LCC2 LCC3 LCC4 */
1051 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001052 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001053 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001054 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001055 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1056 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1057 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1058 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1059 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1060 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1061 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1062 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1063 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001064 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001065/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001066 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001067 {}
1068};
1069static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001070 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001071 /* bits[3..0]reserved */
1072 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1073 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1074 /* VREF vertical frame ctrl */
1075 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001076 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1077 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1078 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1079 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1080/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001081/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001082/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001083 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001084 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1085 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1086 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1087/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001088/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001089/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001090/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001091 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1092 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1093 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1094 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001095 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001096};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001097
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001098static const u8 po1030_sensor_init[][8] = {
1099/* the sensor registers are described in m5602/m5602_po1030.h */
1100 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1101 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1102 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1103 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1104 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1105 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1106 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1107 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1108 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1109 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1110 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1111 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1112 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1113 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1114 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1115 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1116 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1117 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1118 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1119 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1120 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1121 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1122 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1123 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1124 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1125 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1126 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1127 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1128
1129 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1130 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1132 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1133 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1134 {}
1135};
1136static const u8 po1030_sensor_param1[][8] = {
1137/* from ms-win traces - these values change with auto gain/expo/wb.. */
1138 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1139 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1140/* mean values */
1141 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1142 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1143 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1144
1145 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1146 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1147 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1148/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1149 {}
1150};
1151
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001152static const u8 po2030n_sensor_init[][8] = {
1153 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1154 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1155 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1156 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1157 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1158 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1159 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1160 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1161 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1162 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1163 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1165 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1166 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1167 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1169 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1170 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1171 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1172 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1173 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1175 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1176 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1177 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1178 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1179 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1180 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1181 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1182 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1183 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1184 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1185 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1186 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1187 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1188 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1189 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1190 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1191 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1192 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1193 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1194 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1195 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1197 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1198 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1199 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1200 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1202 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1203 {}
1204};
1205static const u8 po2030n_sensor_param1[][8] = {
1206 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1207 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1208 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1211/*param2*/
1212 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1214 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1215 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1216 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1217 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1218 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1219/*after start*/
1220 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1221 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1222 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1223 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1224 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1225 {}
1226};
1227
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001228static const u8 soi768_sensor_init[][8] = {
1229 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1230 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1231 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1233 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1234 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1235 {}
1236};
1237static const u8 soi768_sensor_param1[][8] = {
1238 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1239 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1240 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1242 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1243/* */
1244/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1245/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1246 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1247/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1248 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1249/* the next sequence should be used for auto gain */
1250 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1251 /* global gain ? : 07 - change with 0x15 at the end */
1252 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1253 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1254 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1255 /* exposure ? : 0200 - change with 0x1e at the end */
1256 {}
1257};
1258
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001259static const u8 sp80708_sensor_init[][8] = {
1260 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1263 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1264 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1265 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1266 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1267 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1268 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1271 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1272 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1273 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1274 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1275 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1279 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1280 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1281 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1282 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1283 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1284 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1285 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1286 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1287 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1288 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1289 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1290 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1291 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1292 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1293 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1294 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1295 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1296 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1297 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001331 {}
1332};
1333static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001334 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1340 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1341 {}
1342};
1343
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001344static const u8 (*sensor_init[])[8] = {
1345[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001346[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001347[SENSOR_HV7131R] = hv7131r_sensor_init,
1348[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001349[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001350[SENSOR_MO4000] = mo4000_sensor_init,
1351[SENSOR_MT9V111] = mt9v111_sensor_init,
1352[SENSOR_OM6802] = om6802_sensor_init,
1353[SENSOR_OV7630] = ov7630_sensor_init,
1354[SENSOR_OV7648] = ov7648_sensor_init,
1355[SENSOR_OV7660] = ov7660_sensor_init,
1356[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001357[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001358[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001359[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001360};
1361
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001362/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001363static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001364 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001365{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001366 int ret;
1367
1368 if (gspca_dev->usb_err < 0)
1369 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001370#ifdef GSPCA_DEBUG
1371 if (len > USB_BUF_SZ) {
1372 err("reg_r: buffer overflow");
1373 return;
1374 }
1375#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001376 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001377 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001378 0,
1379 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1380 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001381 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001382 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001383 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001384 if (ret < 0) {
1385 err("reg_r err %d", ret);
1386 gspca_dev->usb_err = ret;
1387 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001388}
1389
Jean-Francois Moine60017612008-07-18 08:46:19 -03001390static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001391 u16 value,
1392 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001393{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001394 int ret;
1395
1396 if (gspca_dev->usb_err < 0)
1397 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001398 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001399 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001400 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001401 usb_sndctrlpipe(gspca_dev->dev, 0),
1402 0x08,
1403 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1404 value,
1405 0,
1406 gspca_dev->usb_buf, 1,
1407 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001408 if (ret < 0) {
1409 err("reg_w1 err %d", ret);
1410 gspca_dev->usb_err = ret;
1411 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001412}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001413static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001414 u16 value,
1415 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001416 int len)
1417{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001418 int ret;
1419
1420 if (gspca_dev->usb_err < 0)
1421 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001422 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001423 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001424#ifdef GSPCA_DEBUG
1425 if (len > USB_BUF_SZ) {
1426 err("reg_w: buffer overflow");
1427 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001428 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001429#endif
1430 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001431 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001432 usb_sndctrlpipe(gspca_dev->dev, 0),
1433 0x08,
1434 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1435 value, 0,
1436 gspca_dev->usb_buf, len,
1437 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001438 if (ret < 0) {
1439 err("reg_w err %d", ret);
1440 gspca_dev->usb_err = ret;
1441 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001442}
1443
Jean-Francois Moine60017612008-07-18 08:46:19 -03001444/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001445static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001446{
1447 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001448 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001449
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001450 if (gspca_dev->usb_err < 0)
1451 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001452 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001453 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001454 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001455 case SENSOR_OM6802:
1456 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001457 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1458 break;
1459 default: /* i2c command = a1 (400 kHz) */
1460 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1461 break;
1462 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001463 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001464 gspca_dev->usb_buf[2] = reg;
1465 gspca_dev->usb_buf[3] = val;
1466 gspca_dev->usb_buf[4] = 0;
1467 gspca_dev->usb_buf[5] = 0;
1468 gspca_dev->usb_buf[6] = 0;
1469 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001470 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001471 usb_sndctrlpipe(gspca_dev->dev, 0),
1472 0x08,
1473 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1474 0x08, /* value = i2c */
1475 0,
1476 gspca_dev->usb_buf, 8,
1477 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001478 if (ret < 0) {
1479 err("i2c_w1 err %d", ret);
1480 gspca_dev->usb_err = ret;
1481 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001482}
1483
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001484/* I2C write 8 bytes */
1485static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001486 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001487{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001488 int ret;
1489
1490 if (gspca_dev->usb_err < 0)
1491 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001492 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1493 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001494 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001495 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001496 usb_sndctrlpipe(gspca_dev->dev, 0),
1497 0x08,
1498 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1499 0x08, 0, /* value, index */
1500 gspca_dev->usb_buf, 8,
1501 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001502 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001503 if (ret < 0) {
1504 err("i2c_w8 err %d", ret);
1505 gspca_dev->usb_err = ret;
1506 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001507}
1508
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001509/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1510static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001511{
1512 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001513 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001514
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001515 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001516 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001517 case SENSOR_OM6802:
1518 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001519 mode[0] = 0x80 | 0x10;
1520 break;
1521 default: /* i2c command = 91 (400 kHz) */
1522 mode[0] = 0x81 | 0x10;
1523 break;
1524 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001525 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001526 mode[2] = reg;
1527 mode[3] = 0;
1528 mode[4] = 0;
1529 mode[5] = 0;
1530 mode[6] = 0;
1531 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001532 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001533 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001534 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001535 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001536 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001537 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001538 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001539}
1540
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001541static void i2c_w_seq(struct gspca_dev *gspca_dev,
1542 const u8 (*data)[8])
1543{
1544 while ((*data)[0] != 0) {
1545 if ((*data)[0] != 0xdd)
1546 i2c_w8(gspca_dev, *data);
1547 else
1548 msleep((*data)[1]);
1549 data++;
1550 }
1551}
1552
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001553static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001554{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001555 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001556 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001557 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001558 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001559 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001560 if (gspca_dev->usb_buf[0] == 0x02
1561 && gspca_dev->usb_buf[1] == 0x09
1562 && gspca_dev->usb_buf[2] == 0x01
1563 && gspca_dev->usb_buf[3] == 0x00
1564 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001565 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1566 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001567 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001568 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001569 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1570 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001571}
1572
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001573static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001574{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001575 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001576 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001577 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001578 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001579 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001580 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1581 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1582 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1583 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1584 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001585 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001586 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1587 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1588 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1589 {}
1590 },
1591 };
1592
1593 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1594 reg_w1(gspca_dev, 0x17, 0x62);
1595 reg_w1(gspca_dev, 0x01, 0x08);
1596 for (j = 0; j < 3; j++)
1597 i2c_w8(gspca_dev, probe_tb[i][j]);
1598 msleep(2);
1599 reg_r(gspca_dev, 0x0a, 5);
1600 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1601 if (probe_tb[i][3][0] != 0)
1602 i2c_w8(gspca_dev, probe_tb[i][3]);
1603 reg_w1(gspca_dev, 0x01, 0x29);
1604 reg_w1(gspca_dev, 0x17, 0x42);
1605 if (val != 0xffff)
1606 break;
1607 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001608 if (gspca_dev->usb_err < 0)
1609 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001610 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001611 case 0x8221:
1612 PDEBUG(D_PROBE, "Sensor mi0360b");
1613 sd->sensor = SENSOR_MI0360B;
1614 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001615 case 0x823a:
1616 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001617 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001618 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001619 case 0x8243:
1620 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001621 break;
1622 default:
1623 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1624 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001625 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001626}
1627
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001628static void ov7630_probe(struct gspca_dev *gspca_dev)
1629{
1630 struct sd *sd = (struct sd *) gspca_dev;
1631 u16 val;
1632
1633 /* check ov76xx */
1634 reg_w1(gspca_dev, 0x17, 0x62);
1635 reg_w1(gspca_dev, 0x01, 0x08);
1636 sd->i2c_addr = 0x21;
1637 i2c_r(gspca_dev, 0x0a, 2);
1638 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1639 reg_w1(gspca_dev, 0x01, 0x29);
1640 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001641 if (gspca_dev->usb_err < 0)
1642 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001643 if (val == 0x7628) { /* soi768 */
1644 sd->sensor = SENSOR_SOI768;
1645/*fixme: only valid for 0c45:613e?*/
1646 gspca_dev->cam.input_flags =
1647 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1648 PDEBUG(D_PROBE, "Sensor soi768");
1649 return;
1650 }
1651 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1652}
1653
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001654static void ov7648_probe(struct gspca_dev *gspca_dev)
1655{
1656 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001657 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001658
1659 /* check ov76xx */
1660 reg_w1(gspca_dev, 0x17, 0x62);
1661 reg_w1(gspca_dev, 0x01, 0x08);
1662 sd->i2c_addr = 0x21;
1663 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001664 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001665 reg_w1(gspca_dev, 0x01, 0x29);
1666 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001667 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1668 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1669 return;
1670 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001671
1672 /* check po1030 */
1673 reg_w1(gspca_dev, 0x17, 0x62);
1674 reg_w1(gspca_dev, 0x01, 0x08);
1675 sd->i2c_addr = 0x6e;
1676 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001677 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1678 reg_w1(gspca_dev, 0x01, 0x29);
1679 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001680 if (gspca_dev->usb_err < 0)
1681 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001682 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001683 PDEBUG(D_PROBE, "Sensor po1030");
1684 sd->sensor = SENSOR_PO1030;
1685 return;
1686 }
1687
Jean-François Moine0b656322010-09-13 05:19:58 -03001688 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001689}
1690
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001691/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1692static void po2030n_probe(struct gspca_dev *gspca_dev)
1693{
1694 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001695 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001696
1697 /* check gc0307 */
1698 reg_w1(gspca_dev, 0x17, 0x62);
1699 reg_w1(gspca_dev, 0x01, 0x08);
1700 reg_w1(gspca_dev, 0x02, 0x22);
1701 sd->i2c_addr = 0x21;
1702 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001703 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001704 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1705 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001706 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001707 PDEBUG(D_PROBE, "Sensor gc0307");
1708 sd->sensor = SENSOR_GC0307;
1709 return;
1710 }
1711
1712 /* check po2030n */
1713 reg_w1(gspca_dev, 0x17, 0x62);
1714 reg_w1(gspca_dev, 0x01, 0x0a);
1715 sd->i2c_addr = 0x6e;
1716 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001717 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001718 reg_w1(gspca_dev, 0x01, 0x29);
1719 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001720 if (gspca_dev->usb_err < 0)
1721 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001722 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001723 PDEBUG(D_PROBE, "Sensor po2030n");
1724/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001725 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001726 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001727 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001728}
1729
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001730static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001731 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001732{
1733 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine19697b52010-07-14 06:33:51 -03001734 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03001735 const u8 *reg9a;
1736 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001737 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1738 static const u8 reg9a_spec[] =
1739 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001740 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001741
Hans de Goede9712a8b2010-01-31 12:54:29 -03001742 /* sensor clock already enabled in sd_init */
1743 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001744 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001745
1746 /* configure gpio */
Jean-François Moine19697b52010-07-14 06:33:51 -03001747 reg0102[0] = sn9c1xx[1];
1748 reg0102[1] = sn9c1xx[2];
1749 if (gspca_dev->audio)
1750 reg0102[1] |= 0x04; /* keep the audio connection */
1751 reg_w(gspca_dev, 0x01, reg0102, 2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001752 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001753 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001754 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001755 case SENSOR_GC0307:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001756 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001757 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001758 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001759 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001760 case SENSOR_SP80708:
1761 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001762 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001763 default:
1764 reg9a = reg9a_def;
1765 break;
1766 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001767 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001768
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001769 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001770
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001771 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001772
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001773 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001774 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001775 reg_w1(gspca_dev, 0x01, 0x43);
Jean-Francois Moine64677572009-12-20 12:31:28 -03001776 reg_w1(gspca_dev, 0x17, 0x62);
1777 reg_w1(gspca_dev, 0x01, 0x42);
1778 reg_w1(gspca_dev, 0x01, 0x42);
1779 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001780 case SENSOR_GC0307:
1781 msleep(50);
1782 reg_w1(gspca_dev, 0x01, 0x61);
1783 reg_w1(gspca_dev, 0x17, 0x22);
1784 reg_w1(gspca_dev, 0x01, 0x60);
1785 reg_w1(gspca_dev, 0x01, 0x40);
1786 msleep(50);
1787 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03001788 case SENSOR_MI0360B:
1789 reg_w1(gspca_dev, 0x01, 0x61);
1790 reg_w1(gspca_dev, 0x17, 0x60);
1791 reg_w1(gspca_dev, 0x01, 0x60);
1792 reg_w1(gspca_dev, 0x01, 0x40);
1793 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001794 case SENSOR_MT9V111:
1795 reg_w1(gspca_dev, 0x01, 0x61);
1796 reg_w1(gspca_dev, 0x17, 0x61);
1797 reg_w1(gspca_dev, 0x01, 0x60);
1798 reg_w1(gspca_dev, 0x01, 0x40);
1799 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001800 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001801 msleep(10);
1802 reg_w1(gspca_dev, 0x02, 0x73);
1803 reg_w1(gspca_dev, 0x17, 0x60);
1804 reg_w1(gspca_dev, 0x01, 0x22);
1805 msleep(100);
1806 reg_w1(gspca_dev, 0x01, 0x62);
1807 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001808 reg_w1(gspca_dev, 0x17, 0x64);
1809 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001810 msleep(10);
1811 reg_w1(gspca_dev, 0x01, 0x42);
1812 i2c_w8(gspca_dev, om6802_init0[0]);
1813 i2c_w8(gspca_dev, om6802_init0[1]);
1814 msleep(15);
1815 reg_w1(gspca_dev, 0x02, 0x71);
1816 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001817 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001818 case SENSOR_OV7630:
1819 reg_w1(gspca_dev, 0x01, 0x61);
1820 reg_w1(gspca_dev, 0x17, 0xe2);
1821 reg_w1(gspca_dev, 0x01, 0x60);
1822 reg_w1(gspca_dev, 0x01, 0x40);
1823 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001824 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001825 reg_w1(gspca_dev, 0x01, 0x63);
1826 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001827 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001828 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001829 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001830 case SENSOR_PO1030:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001831 case SENSOR_SOI768:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001832 reg_w1(gspca_dev, 0x01, 0x61);
1833 reg_w1(gspca_dev, 0x17, 0x20);
1834 reg_w1(gspca_dev, 0x01, 0x60);
1835 reg_w1(gspca_dev, 0x01, 0x40);
1836 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001837 case SENSOR_PO2030N:
Jean-François Moine19697b52010-07-14 06:33:51 -03001838 case SENSOR_OV7660:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001839 reg_w1(gspca_dev, 0x01, 0x63);
1840 reg_w1(gspca_dev, 0x17, 0x20);
1841 reg_w1(gspca_dev, 0x01, 0x62);
1842 reg_w1(gspca_dev, 0x01, 0x42);
1843 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001844 case SENSOR_SP80708:
1845 reg_w1(gspca_dev, 0x01, 0x63);
1846 reg_w1(gspca_dev, 0x17, 0x20);
1847 reg_w1(gspca_dev, 0x01, 0x62);
1848 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001849 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001850 reg_w1(gspca_dev, 0x02, 0x62);
1851 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001852 default:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001853/* case SENSOR_HV7131R: */
1854/* case SENSOR_MI0360: */
1855/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001856 reg_w1(gspca_dev, 0x01, 0x43);
1857 reg_w1(gspca_dev, 0x17, 0x61);
1858 reg_w1(gspca_dev, 0x01, 0x42);
Jean-François Moine75f05ba2010-10-21 04:09:34 -03001859 if (sd->sensor == SENSOR_HV7131R)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001860 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001861 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001862 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001863}
1864
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001865/* this function is called at probe time */
1866static int sd_config(struct gspca_dev *gspca_dev,
1867 const struct usb_device_id *id)
1868{
1869 struct sd *sd = (struct sd *) gspca_dev;
1870 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001871
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001872 sd->bridge = id->driver_info >> 16;
1873 sd->sensor = id->driver_info;
1874
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001875 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001876 if (sd->sensor == SENSOR_ADCM1700) {
1877 cam->cam_mode = cif_mode;
1878 cam->nmodes = ARRAY_SIZE(cif_mode);
1879 } else {
1880 cam->cam_mode = vga_mode;
1881 cam->nmodes = ARRAY_SIZE(vga_mode);
1882 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001883 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001884 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001885
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001886 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001887 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001888 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001889
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001890 return 0;
1891}
1892
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001893/* this function is called at probe and resume time */
1894static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001895{
1896 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001897 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001898 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001899 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001900
Hans de Goede3647fea2008-07-15 05:36:30 -03001901 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001902 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001903 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001904 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1905 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001906 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001907 if (gspca_dev->usb_err < 0)
1908 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001909 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001910 switch (sd->bridge) {
1911 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001912 if (regF1 != 0x11)
1913 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001914 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001915 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001916 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001917 if (regF1 != 0x11)
1918 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001919 if (sd->sensor == SENSOR_MI0360)
1920 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001921 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001922 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001923 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001924 if (regF1 != 0x12)
1925 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001926 switch (sd->sensor) {
1927 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001928 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001929 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001930 case SENSOR_OV7630:
1931 ov7630_probe(gspca_dev);
1932 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001933 case SENSOR_OV7648:
1934 ov7648_probe(gspca_dev);
1935 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001936 case SENSOR_PO2030N:
1937 po2030n_probe(gspca_dev);
1938 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001939 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001940 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001941 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001942 break;
1943 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001944/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001945/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001946 if (regF1 != 0x12)
1947 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001948 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001949 break;
1950 }
1951
Jean-François Moine72b667e2010-10-02 04:35:25 -03001952 if (sd->sensor == SENSOR_OM6802)
1953 sd->ctrls[SHARPNESS].def = 0x10;
1954
Hans de Goede9712a8b2010-01-31 12:54:29 -03001955 /* Note we do not disable the sensor clock here (power saving mode),
1956 as that also disables the button on the cam. */
1957 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001958
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001959 /* set the i2c address */
1960 sn9c1xx = sn_tb[sd->sensor];
1961 sd->i2c_addr = sn9c1xx[9];
1962
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001963 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1964
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001965 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001966}
1967
Jean-Francois Moine98819182009-01-19 07:37:33 -03001968static u32 setexposure(struct gspca_dev *gspca_dev,
1969 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001970{
1971 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001972
1973 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001974 case SENSOR_GC0307: {
1975 int a, b;
1976
1977 /* expo = 0..255 -> a = 19..43 */
1978 a = 19 + expo * 25 / 256;
1979 i2c_w1(gspca_dev, 0x68, a);
1980 a -= 12;
1981 b = a * a * 4; /* heuristic */
1982 i2c_w1(gspca_dev, 0x03, b >> 8);
1983 i2c_w1(gspca_dev, 0x04, b);
1984 break;
1985 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001986 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001987 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001988 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001989
1990 Expodoit[3] = expo >> 16;
1991 Expodoit[4] = expo >> 8;
1992 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001993 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001994 break;
1995 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001996 case SENSOR_MI0360:
1997 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001998 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001999 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002000 static const u8 doit[] = /* update sensor */
2001 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
2002 static const u8 sensorgo[] = /* sensor on */
2003 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002004
2005 if (expo > 0x0635)
2006 expo = 0x0635;
2007 else if (expo < 0x0001)
2008 expo = 0x0001;
2009 expoMi[3] = expo >> 8;
2010 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002011 i2c_w8(gspca_dev, expoMi);
2012 i2c_w8(gspca_dev, doit);
2013 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002014 break;
2015 }
2016 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002017 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002018 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002019 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002020 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002021 static const u8 gainMo[] =
2022 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002023
2024 if (expo > 0x1fff)
2025 expo = 0x1fff;
2026 else if (expo < 0x0001)
2027 expo = 0x0001;
2028 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002029 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002030 expoMo10[3] = ((expo & 0x1c00) >> 10)
2031 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002032 i2c_w8(gspca_dev, expoMo10);
2033 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002034 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002035 ((expoMo10[3] & 0x07) << 10)
2036 | (expoMof[3] << 2)
2037 | ((expoMo10[3] & 0x30) >> 4));
2038 break;
2039 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002040 case SENSOR_MT9V111: {
2041 u8 expo_c1[] =
2042 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2043
2044 if (expo > 0x0280)
2045 expo = 0x0280;
2046 else if (expo < 0x0040)
2047 expo = 0x0040;
2048 expo_c1[3] = expo >> 8;
2049 expo_c1[4] = expo;
2050 i2c_w8(gspca_dev, expo_c1);
2051 break;
2052 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002053 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002054 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002055 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002056 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002057
2058 if (expo > 0x03ff)
2059 expo = 0x03ff;
2060 if (expo < 0x0001)
2061 expo = 0x0001;
2062 gainOm[3] = expo >> 2;
2063 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002064 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002065 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002066 break;
2067 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002068 }
2069 return expo;
2070}
2071
2072static void setbrightness(struct gspca_dev *gspca_dev)
2073{
2074 struct sd *sd = (struct sd *) gspca_dev;
2075 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002076 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002077 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002078
Jean-François Moine72b667e2010-10-02 04:35:25 -03002079 brightness = sd->ctrls[BRIGHTNESS].val;
2080 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002081 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002082 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002083 if (k2 > 0x1f)
2084 k2 = 0; /* only positive Y offset */
2085 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002086 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002087 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002088 if (expo > 0x002dc6c0)
2089 expo = 0x002dc6c0;
2090 else if (expo < 0x02a0)
2091 expo = 0x02a0;
2092 sd->exposure = setexposure(gspca_dev, expo);
2093 break;
2094 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002095 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002096 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002097 sd->exposure = setexposure(gspca_dev, expo);
2098 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002099 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002100 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002101 sd->exposure = setexposure(gspca_dev, expo);
2102 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002103 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002104 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002105 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002106 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002107 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002108 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002109 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002110 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002111 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002112 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002113 }
2114
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002115 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002116}
2117
2118static void setcontrast(struct gspca_dev *gspca_dev)
2119{
2120 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002121 u8 k2;
2122 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002123
Jean-François Moine72b667e2010-10-02 04:35:25 -03002124 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2125 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002126 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002127 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002128 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002129 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002130 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002131 contrast[5] = 0;
2132 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002133}
2134
2135static void setcolors(struct gspca_dev *gspca_dev)
2136{
2137 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002138 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002139 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002140 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002141 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002142 -24, -38, 64, /* UR UG UB */
2143 62, -51, -9 /* VR VG VB */
2144 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002145 static const s16 uv_mi0360b[6] = {
2146 -20, -38, 64, /* UR UG UB */
2147 60, -51, -9 /* VR VG VB */
2148 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002149
Jean-François Moine72b667e2010-10-02 04:35:25 -03002150 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002151 if (sd->sensor == SENSOR_MI0360B)
2152 uv = uv_mi0360b;
2153 else
2154 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002155 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002156 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002157 reg8a[i * 2] = v;
2158 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002159 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002160 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002161}
2162
2163static void setredblue(struct gspca_dev *gspca_dev)
2164{
2165 struct sd *sd = (struct sd *) gspca_dev;
2166
Jean-François Moine72b667e2010-10-02 04:35:25 -03002167 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002168/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002169 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002170}
2171
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002172static void setgamma(struct gspca_dev *gspca_dev)
2173{
2174 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002175 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002176 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002177 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002178 static const u8 delta[17] = {
2179 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2180 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2181 };
2182
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002183 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002184 case SENSOR_ADCM1700:
2185 gamma_base = gamma_spec_0;
2186 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002187 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002188 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002189 case SENSOR_MT9V111:
2190 gamma_base = gamma_spec_1;
2191 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002192 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002193 gamma_base = gamma_spec_2;
2194 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002195 case SENSOR_SP80708:
2196 gamma_base = gamma_spec_3;
2197 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002198 default:
2199 gamma_base = gamma_def;
2200 break;
2201 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002202
Jean-François Moine72b667e2010-10-02 04:35:25 -03002203 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002204 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002205 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002206 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002207 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2208}
2209
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002210static void setautogain(struct gspca_dev *gspca_dev)
2211{
2212 struct sd *sd = (struct sd *) gspca_dev;
2213
Jean-François Moine72b667e2010-10-02 04:35:25 -03002214 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002215 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002216 switch (sd->sensor) {
2217 case SENSOR_OV7630:
2218 case SENSOR_OV7648: {
2219 u8 comb;
2220
2221 if (sd->sensor == SENSOR_OV7630)
2222 comb = 0xc0;
2223 else
2224 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002225 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec7472009-06-18 06:05:07 -03002226 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002227 i2c_w1(&sd->gspca_dev, 0x13, comb);
2228 return;
2229 }
2230 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002231 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002232 sd->ag_cnt = AG_CNT_START;
2233 else
2234 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002235}
2236
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002237/* hv7131r/ov7630/ov7648 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002238static void setvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002239{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002240 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002241 u8 comn;
2242
Jean-François Moine72b667e2010-10-02 04:35:25 -03002243 if (gspca_dev->ctrl_dis & (1 << VFLIP))
Jean-Francois Moine0939e262009-11-02 09:58:49 -03002244 return;
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002245 switch (sd->sensor) {
2246 case SENSOR_HV7131R:
2247 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002248 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002249 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002250 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002251 break;
2252 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002253 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002254 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002255 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002256 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002257 break;
2258 default:
2259/* case SENSOR_OV7648: */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002260 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002261 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002262 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002263 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002264 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002265 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002266}
2267
Jean-François Moine72b667e2010-10-02 04:35:25 -03002268static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002269{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002270 struct sd *sd = (struct sd *) gspca_dev;
2271
2272 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002273}
2274
Jean-François Moine72b667e2010-10-02 04:35:25 -03002275static void setinfrared(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002276{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002277 struct sd *sd = (struct sd *) gspca_dev;
2278
2279 if (gspca_dev->ctrl_dis & (1 << INFRARED))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002280 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002281/*fixme: different sequence for StarCam Clip and StarCam 370i */
2282/* Clip */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002283 i2c_w1(gspca_dev, 0x02, /* gpio */
2284 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002285}
2286
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002287static void setfreq(struct gspca_dev *gspca_dev)
2288{
2289 struct sd *sd = (struct sd *) gspca_dev;
2290
Jean-François Moine72b667e2010-10-02 04:35:25 -03002291 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002292 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002293 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002294 u8 com8;
2295
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002296 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002297 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002298 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002299 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002300 break;
2301 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002302 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002303 i2c_w1(gspca_dev, 0x3b, 0x0a);
2304 break;
2305 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002306 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002307 i2c_w1(gspca_dev, 0x3b, 0x02);
2308 break;
2309 }
2310 } else {
2311 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2312
2313 /* Get reg2a / reg2d base values */
2314 switch (sd->sensor) {
2315 case SENSOR_OV7630:
2316 reg2a = 0x08;
2317 reg2d = 0x01;
2318 break;
2319 case SENSOR_OV7648:
2320 reg2a = 0x11;
2321 reg2d = 0x81;
2322 break;
2323 }
2324
Jean-François Moine72b667e2010-10-02 04:35:25 -03002325 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002326 case 0: /* Banding filter disabled */
2327 break;
2328 case 1: /* 50 hz (filter on and framerate adj) */
2329 reg2a |= 0x80;
2330 reg2b = 0xac;
2331 reg2d |= 0x04;
2332 break;
2333 case 2: /* 60 hz (filter on, no framerate adj) */
2334 reg2a |= 0x80;
2335 reg2d |= 0x04;
2336 break;
2337 }
2338 i2c_w1(gspca_dev, 0x2a, reg2a);
2339 i2c_w1(gspca_dev, 0x2b, reg2b);
2340 i2c_w1(gspca_dev, 0x2d, reg2d);
2341 }
2342}
2343
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002344static void setjpegqual(struct gspca_dev *gspca_dev)
2345{
2346 struct sd *sd = (struct sd *) gspca_dev;
2347 int i, sc;
2348
2349 if (sd->jpegqual < 50)
2350 sc = 5000 / sd->jpegqual;
2351 else
2352 sc = 200 - sd->jpegqual * 2;
2353#if USB_BUF_SZ < 64
2354#error "No room enough in usb_buf for quantization table"
2355#endif
2356 for (i = 0; i < 64; i++)
2357 gspca_dev->usb_buf[i] =
2358 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2359 usb_control_msg(gspca_dev->dev,
2360 usb_sndctrlpipe(gspca_dev->dev, 0),
2361 0x08,
2362 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2363 0x0100, 0,
2364 gspca_dev->usb_buf, 64,
2365 500);
2366 for (i = 0; i < 64; i++)
2367 gspca_dev->usb_buf[i] =
2368 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2369 usb_control_msg(gspca_dev->dev,
2370 usb_sndctrlpipe(gspca_dev->dev, 0),
2371 0x08,
2372 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2373 0x0140, 0,
2374 gspca_dev->usb_buf, 64,
2375 500);
2376
2377 sd->reg18 ^= 0x40;
2378 reg_w1(gspca_dev, 0x18, sd->reg18);
2379}
2380
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002381/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002382static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002383{
2384 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002385 int i;
Jean-François Moine19697b52010-07-14 06:33:51 -03002386 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002387 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002388 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002389 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002390 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2391 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002392 static const u8 CA_adcm1700[] =
2393 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002394 static const u8 CA_po2030n[] =
2395 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002396 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002397 static const u8 CE_gc0307[] =
2398 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002399 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002400 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002401 static const u8 CE_po2030n[] =
2402 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002403
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002404 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002405 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2406 0x21); /* JPEG 422 */
2407 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2408
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002409 /* initialize the bridge */
2410 sn9c1xx = sn_tb[sd->sensor];
2411 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002412
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002413 /* initialize the sensor */
2414 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2415
Jean-Francois Moine60017612008-07-18 08:46:19 -03002416 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2417 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2418 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2419 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2420 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002421 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002422 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2423 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002424 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002425 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2426 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002427 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002428 reg_w1(gspca_dev, 0xc6, 0x00);
2429 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002430 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002431 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2432 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002433 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002434 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2435 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002436 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002437 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002438 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002439 case SENSOR_GC0307:
2440 reg17 = 0xa2;
2441 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002442 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002443 case SENSOR_MI0360B:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002444 reg17 = 0xe0;
2445 break;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002446 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002447 case SENSOR_OV7630:
2448 reg17 = 0xe2;
2449 break;
2450 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002451 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002452 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002453 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002454 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002455 reg17 = 0xa0;
2456 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002457 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002458 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002459 reg17 = 0xa0;
2460 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002461 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002462 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002463 break;
2464 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002465 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002466
2467 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2468 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2469 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002470 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002471
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002472 setgamma(gspca_dev);
2473
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002474/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002475 for (i = 0; i < 8; i++)
2476 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002477 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002478 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002479 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002480 case SENSOR_SP80708:
2481 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002482 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002483 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002484 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002485 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002486 reg_w1(gspca_dev, 0x9a, 0x07);
2487 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002488 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002489 case SENSOR_OV7648:
2490 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002491 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002492 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002493 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002494 reg_w1(gspca_dev, 0x9a, 0x06);
2495 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002496 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002497 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002498 break;
2499 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002500 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002501
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002502 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002503 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2504 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2505 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002506
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002507 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002508 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002509 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002510 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002511 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002512 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2513 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002514 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002515 case SENSOR_ADCM1700:
2516 init = adcm1700_sensor_param1;
2517 reg1 = 0x46;
2518 reg17 = 0xe2;
2519 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002520 case SENSOR_GC0307:
2521 init = gc0307_sensor_param1;
2522 reg17 = 0xa2;
2523 reg1 = 0x44;
2524 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002525 case SENSOR_MI0360B:
2526 init = mi0360b_sensor_param1;
2527 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2528 reg17 = 0xe2;
2529 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002530 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002531 if (mode) {
2532/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2533 reg1 = 0x06; /* clk 24Mz */
2534 } else {
2535 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002536/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002537 }
2538 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002539 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002540 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002541 if (mode) {
2542 reg1 = 0x04; /* 320 clk 48Mhz */
2543 } else {
2544/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002545 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002546 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002547 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002548 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002549 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002550 reg17 = 0x64; /* 640 MCKSIZE */
2551 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002552 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002553 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002554 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002555 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002556 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002557 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002558 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002559 reg17 = 0x21;
2560/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002561 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002562 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002563 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002564 if (sd->bridge == BRIDGE_SN9C120) {
2565 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002566 reg17 = 0xa2;
2567 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002568 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002569 } else {
2570 reg17 = 0x22;
2571 reg1 = 0x06; /* 24 Mhz, video trf eneble
2572 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002573 }
2574 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002575 case SENSOR_PO1030:
2576 init = po1030_sensor_param1;
2577 reg17 = 0xa2;
2578 reg1 = 0x44;
2579 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002580 case SENSOR_PO2030N:
2581 init = po2030n_sensor_param1;
2582 reg1 = 0x46;
2583 reg17 = 0xa2;
2584 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002585 case SENSOR_SOI768:
2586 init = soi768_sensor_param1;
2587 reg1 = 0x44;
2588 reg17 = 0xa2;
2589 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002590 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002591 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002592 if (mode) {
2593/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002594 } else {
2595 reg1 = 0x46; /* 640 clk 48Mz */
2596 reg17 = 0xa2;
2597 }
2598 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002599 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002600
2601 /* more sensor initialization - param1 */
2602 if (init != NULL) {
2603 i2c_w_seq(gspca_dev, init);
2604/* init = NULL; */
2605 }
2606
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002607 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002608 switch (sd->sensor) {
2609 case SENSOR_ADCM1700:
2610 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002611 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002612 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002613 break;
2614 case SENSOR_PO2030N:
2615 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2616 break;
2617 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002618 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002619 break;
2620 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002621 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002622 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002623 case SENSOR_OV7630:
2624 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002625 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002626 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002627 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002628 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002629 case SENSOR_GC0307:
2630 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2631 break;
2632 case SENSOR_PO2030N:
2633 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2634 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002635 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002636 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002637 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2638 break;
2639 }
2640
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002641
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002642 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002643 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2644 reg_w1(gspca_dev, 0x18, sd->reg18);
2645 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002646
Jean-Francois Moine60017612008-07-18 08:46:19 -03002647 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002648 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002649
Jean-François Moine72b667e2010-10-02 04:35:25 -03002650 setvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002651 setbrightness(gspca_dev);
2652 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002653 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002654 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002655 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002656 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002657}
2658
2659static void sd_stopN(struct gspca_dev *gspca_dev)
2660{
2661 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002662 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002663 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002664 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002665 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002666 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002667 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002668 static const u8 stopsoi768[] =
2669 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002670 u8 data;
2671 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002672
2673 data = 0x0b;
2674 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002675 case SENSOR_GC0307:
2676 data = 0x29;
2677 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002678 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002679 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002680 data = 0x2b;
2681 break;
2682 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002683 case SENSOR_MI0360B:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002684 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002685 data = 0x29;
2686 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002687 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002688 i2c_w8(gspca_dev, stopov7648);
2689 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002690 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002691 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002692 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002693 data = 0x29;
2694 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002695 case SENSOR_SOI768:
2696 i2c_w8(gspca_dev, stopsoi768);
2697 data = 0x29;
2698 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002699 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002700 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002701 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2702 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2703 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2704 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002705 /* Don't disable sensor clock as that disables the button on the cam */
2706 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002707}
2708
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002709static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002710{
2711 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002712 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002713 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002714 u8 luma_mean = 130;
2715 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002716
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002717 /* Thanks S., without your advice, autobright should not work :) */
2718 if (sd->ag_cnt < 0)
2719 return;
2720 if (--sd->ag_cnt >= 0)
2721 return;
2722 sd->ag_cnt = AG_CNT_START;
2723
2724 delta = atomic_read(&sd->avg_lum);
2725 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002726 if (delta < luma_mean - luma_delta ||
2727 delta > luma_mean + luma_delta) {
2728 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002729 case SENSOR_GC0307:
2730 expotimes = sd->exposure;
2731 expotimes += (luma_mean - delta) >> 6;
2732 if (expotimes < 0)
2733 expotimes = 0;
2734 sd->exposure = setexposure(gspca_dev,
2735 (unsigned int) expotimes);
2736 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002737 case SENSOR_HV7131R:
2738 expotimes = sd->exposure >> 8;
2739 expotimes += (luma_mean - delta) >> 4;
2740 if (expotimes < 0)
2741 expotimes = 0;
2742 sd->exposure = setexposure(gspca_dev,
2743 (unsigned int) (expotimes << 8));
2744 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002745 case SENSOR_OM6802:
2746 expotimes = sd->exposure;
2747 expotimes += (luma_mean - delta) >> 2;
2748 if (expotimes < 0)
2749 expotimes = 0;
2750 sd->exposure = setexposure(gspca_dev,
2751 (unsigned int) expotimes);
2752 setredblue(gspca_dev);
2753 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002754 default:
2755/* case SENSOR_MO4000: */
2756/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002757/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002758/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002759 expotimes = sd->exposure;
2760 expotimes += (luma_mean - delta) >> 6;
2761 if (expotimes < 0)
2762 expotimes = 0;
2763 sd->exposure = setexposure(gspca_dev,
2764 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002765 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002766 break;
2767 }
2768 }
2769}
2770
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002771/* scan the URB packets */
2772/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002773static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002774 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002775 int len) /* iso packet length */
2776{
2777 struct sd *sd = (struct sd *) gspca_dev;
2778 int sof, avg_lum;
2779
Jean-François Moinea95bd642010-10-01 07:54:30 -03002780 /* the image ends on a 64 bytes block starting with
2781 * ff d9 ff ff 00 c4 c4 96
2782 * and followed by various information including luminosity */
2783 /* this block may be splitted between two packets */
2784 /* a new image always starts in a new packet */
2785 switch (gspca_dev->last_packet_type) {
2786 case DISCARD_PACKET: /* restart image building */
2787 sof = len - 64;
2788 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2789 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2790 return;
2791 case LAST_PACKET: /* put the JPEG 422 header */
2792 gspca_frame_add(gspca_dev, FIRST_PACKET,
2793 sd->jpeg_hdr, JPEG_HDR_SZ);
2794 break;
2795 }
2796 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002797
Jean-François Moinea95bd642010-10-01 07:54:30 -03002798 data = gspca_dev->image;
2799 if (data == NULL)
2800 return;
2801 sof = gspca_dev->image_len - 64;
2802 if (data[sof] != 0xff
2803 || data[sof + 1] != 0xd9)
2804 return;
2805
2806 /* end of image found - remove the trailing data */
2807 gspca_dev->image_len = sof + 2;
2808 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2809 if (sd->ag_cnt < 0)
2810 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002811/* w1 w2 w3 */
2812/* w4 w5 w6 */
2813/* w7 w8 */
2814/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002815 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002816/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002817 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002818/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002819 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002820/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002821 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002822/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002823 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2824 avg_lum >>= 4;
2825 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002826}
2827
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002828static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2829 struct v4l2_jpegcompression *jcomp)
2830{
2831 struct sd *sd = (struct sd *) gspca_dev;
2832
2833 if (jcomp->quality < QUALITY_MIN)
2834 sd->quality = QUALITY_MIN;
2835 else if (jcomp->quality > QUALITY_MAX)
2836 sd->quality = QUALITY_MAX;
2837 else
2838 sd->quality = jcomp->quality;
2839 if (gspca_dev->streaming)
2840 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2841 return 0;
2842}
2843
2844static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2845 struct v4l2_jpegcompression *jcomp)
2846{
2847 struct sd *sd = (struct sd *) gspca_dev;
2848
2849 memset(jcomp, 0, sizeof *jcomp);
2850 jcomp->quality = sd->quality;
2851 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2852 | V4L2_JPEG_MARKER_DQT;
2853 return 0;
2854}
2855
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002856static int sd_querymenu(struct gspca_dev *gspca_dev,
2857 struct v4l2_querymenu *menu)
2858{
2859 switch (menu->id) {
2860 case V4L2_CID_POWER_LINE_FREQUENCY:
2861 switch (menu->index) {
2862 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2863 strcpy((char *) menu->name, "NoFliker");
2864 return 0;
2865 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2866 strcpy((char *) menu->name, "50 Hz");
2867 return 0;
2868 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2869 strcpy((char *) menu->name, "60 Hz");
2870 return 0;
2871 }
2872 break;
2873 }
2874 return -EINVAL;
2875}
2876
Jean-François Moine28566432010-10-01 07:33:26 -03002877#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002878static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2879 u8 *data, /* interrupt packet data */
2880 int len) /* interrupt packet length */
2881{
2882 int ret = -EINVAL;
2883
2884 if (len == 1 && data[0] == 1) {
2885 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2886 input_sync(gspca_dev->input_dev);
2887 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2888 input_sync(gspca_dev->input_dev);
2889 ret = 0;
2890 }
2891
2892 return ret;
2893}
2894#endif
2895
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002896/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002897static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002898 .name = MODULE_NAME,
2899 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002900 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002901 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002902 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002903 .start = sd_start,
2904 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002905 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002906 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002907 .get_jcomp = sd_get_jcomp,
2908 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002909 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002910#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002911 .int_pkt_scan = sd_int_pkt_scan,
2912#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002913};
2914
2915/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002916#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002917 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002918 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002919static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002920#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002921 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2922 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002923#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002924 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2925 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2926 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2927 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2928 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2929 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2930 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2931/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2932 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2933/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2934/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2935 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2936/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2937 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002938 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002939/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2940/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2941/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002942 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002943 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2944/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2945/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03002946/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002947 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002948#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002949 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2950 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002951#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002952 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03002953 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002954/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2955 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2956 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2957 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2958 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2959/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2960/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2961/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2962 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002963/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002964 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03002965 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002966 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2967 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2968/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002969 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002970 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002971/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2972 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2973 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002974#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002975 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002976#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002977 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2978 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002979 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03002980 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002981 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2982 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine64677572009-12-20 12:31:28 -03002983 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002984 {}
2985};
2986MODULE_DEVICE_TABLE(usb, device_table);
2987
2988/* -- device connect -- */
2989static int sd_probe(struct usb_interface *intf,
2990 const struct usb_device_id *id)
2991{
2992 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2993 THIS_MODULE);
2994}
2995
2996static struct usb_driver sd_driver = {
2997 .name = MODULE_NAME,
2998 .id_table = device_table,
2999 .probe = sd_probe,
3000 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003001#ifdef CONFIG_PM
3002 .suspend = gspca_suspend,
3003 .resume = gspca_resume,
3004#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003005};
3006
3007/* -- module insert / remove -- */
3008static int __init sd_mod_init(void)
3009{
Jean-François Moine54826432010-09-13 04:53:03 -03003010 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003011}
3012static void __exit sd_mod_exit(void)
3013{
3014 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003015}
3016
3017module_init(sd_mod_init);
3018module_exit(sd_mod_exit);