blob: 184bb924f4560deb81bd2f38095f43b664b99f6f [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
2 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) library
3 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
4 *
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
6 *
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
24#include "gspca.h"
25#include "jpeg.h"
26
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030027#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
28
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030029MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
31MODULE_LICENSE("GPL");
32
33/* specific webcam descriptor */
34struct sd {
35 struct gspca_dev gspca_dev; /* !! must be the first item */
36
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030037 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030038 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030039
Jean-Francois Moine98819182009-01-19 07:37:33 -030040 u16 brightness;
41 u8 contrast;
42 u8 colors;
43 u8 autogain;
44 u8 blue;
45 u8 red;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030046 u8 gamma;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -030047 u8 vflip; /* ov7630/ov7648 only */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -030048 u8 infrared; /* mt9v111 only */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030049 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030050#define QUALITY_MIN 60
51#define QUALITY_MAX 95
52#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030053 u8 jpegqual; /* webcam quality */
54
55 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030056
Jean-Francois Moine98819182009-01-19 07:37:33 -030057 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030058#define AG_CNT_START 13
59
Jean-Francois Moine98819182009-01-19 07:37:33 -030060 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030061#define BRIDGE_SN9C102P 0
62#define BRIDGE_SN9C105 1
63#define BRIDGE_SN9C110 2
64#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030065 u8 sensor; /* Type of image sensor chip */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030066#define SENSOR_HV7131R 0
67#define SENSOR_MI0360 1
68#define SENSOR_MO4000 2
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -030069#define SENSOR_MT9V111 3
70#define SENSOR_OM6802 4
71#define SENSOR_OV7630 5
72#define SENSOR_OV7648 6
73#define SENSOR_OV7660 7
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -030074#define SENSOR_SP80708 8
Jean-Francois Moine98819182009-01-19 07:37:33 -030075 u8 i2c_base;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030076
77 u8 *jpeg_hdr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030078};
79
80/* V4L2 controls supported by the driver */
81static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
82static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
83static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
84static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
85static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
86static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030087static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
88static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
89static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
90static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030091static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030093static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -030095static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030097static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030099
100static struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300101#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300102 {
103 {
104 .id = V4L2_CID_BRIGHTNESS,
105 .type = V4L2_CTRL_TYPE_INTEGER,
106 .name = "Brightness",
107 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300108#define BRIGHTNESS_MAX 0xffff
109 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300110 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300111#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300112 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300113 },
114 .set = sd_setbrightness,
115 .get = sd_getbrightness,
116 },
Hans de Goede97643982009-06-18 05:08:11 -0300117#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300118 {
119 {
120 .id = V4L2_CID_CONTRAST,
121 .type = V4L2_CTRL_TYPE_INTEGER,
122 .name = "Contrast",
123 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300124#define CONTRAST_MAX 127
125 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300126 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300127#define CONTRAST_DEF 63
128 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300129 },
130 .set = sd_setcontrast,
131 .get = sd_getcontrast,
132 },
Hans de Goede97643982009-06-18 05:08:11 -0300133#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300134 {
135 {
136 .id = V4L2_CID_SATURATION,
137 .type = V4L2_CTRL_TYPE_INTEGER,
138 .name = "Color",
139 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300140 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300141 .step = 1,
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -0300142#define COLOR_DEF 32
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300143 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300144 },
145 .set = sd_setcolors,
146 .get = sd_getcolors,
147 },
Hans de Goede97643982009-06-18 05:08:11 -0300148#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300149 {
150 {
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,
157#define BLUE_BALANCE_DEF 32
158 .default_value = BLUE_BALANCE_DEF,
159 },
160 .set = sd_setblue_balance,
161 .get = sd_getblue_balance,
162 },
Hans de Goede97643982009-06-18 05:08:11 -0300163#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300164 {
165 {
166 .id = V4L2_CID_RED_BALANCE,
167 .type = V4L2_CTRL_TYPE_INTEGER,
168 .name = "Red Balance",
169 .minimum = 24,
170 .maximum = 40,
171 .step = 1,
172#define RED_BALANCE_DEF 32
173 .default_value = RED_BALANCE_DEF,
174 },
175 .set = sd_setred_balance,
176 .get = sd_getred_balance,
177 },
Hans de Goede97643982009-06-18 05:08:11 -0300178#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300179 {
180 {
181 .id = V4L2_CID_GAMMA,
182 .type = V4L2_CTRL_TYPE_INTEGER,
183 .name = "Gamma",
184 .minimum = 0,
185 .maximum = 40,
186 .step = 1,
187#define GAMMA_DEF 20
188 .default_value = GAMMA_DEF,
189 },
190 .set = sd_setgamma,
191 .get = sd_getgamma,
192 },
Hans de Goede97643982009-06-18 05:08:11 -0300193#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300194 {
195 {
196 .id = V4L2_CID_AUTOGAIN,
197 .type = V4L2_CTRL_TYPE_BOOLEAN,
198 .name = "Auto Gain",
199 .minimum = 0,
200 .maximum = 1,
201 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300202#define AUTOGAIN_DEF 1
203 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300204 },
205 .set = sd_setautogain,
206 .get = sd_getautogain,
207 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300208/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300209#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300210 {
211 {
212 .id = V4L2_CID_VFLIP,
213 .type = V4L2_CTRL_TYPE_BOOLEAN,
214 .name = "Vflip",
215 .minimum = 0,
216 .maximum = 1,
217 .step = 1,
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300218#define VFLIP_DEF 0 /* vflip def = 1 for ov7630 */
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300219 .default_value = VFLIP_DEF,
220 },
221 .set = sd_setvflip,
222 .get = sd_getvflip,
223 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300224/* mt9v111 only */
Hans de Goede97643982009-06-18 05:08:11 -0300225#define INFRARED_IDX 8
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300226 {
227 {
228 .id = V4L2_CID_INFRARED,
229 .type = V4L2_CTRL_TYPE_BOOLEAN,
230 .name = "Infrared",
231 .minimum = 0,
232 .maximum = 1,
233 .step = 1,
234#define INFRARED_DEF 0
235 .default_value = INFRARED_DEF,
236 },
237 .set = sd_setinfrared,
238 .get = sd_getinfrared,
239 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300240};
241
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300242/* table of the disabled controls */
243static __u32 ctrl_dis[] = {
244 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
245 /* SENSOR_HV7131R 0 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300246 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300247 /* SENSOR_MI0360 1 */
248 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
249 /* SENSOR_MO4000 2 */
Jean-Francois Moinec33c02e2009-02-05 15:04:33 -0300250 (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300251 /* SENSOR_MT9V111 3 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300252 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300253 /* SENSOR_OM6802 4 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300254 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300255 /* SENSOR_OV7630 5 */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300256 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300257 /* SENSOR_OV7648 6 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300258 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300259 /* SENSOR_OV7660 7 */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300260 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
261 /* SENSOR_SP80708 8 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300262};
263
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300264static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300265 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
266 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300267 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300268 .colorspace = V4L2_COLORSPACE_JPEG,
269 .priv = 2},
270 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
271 .bytesperline = 320,
272 .sizeimage = 320 * 240 * 3 / 8 + 590,
273 .colorspace = V4L2_COLORSPACE_JPEG,
274 .priv = 1},
275 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
276 .bytesperline = 640,
277 .sizeimage = 640 * 480 * 3 / 8 + 590,
278 .colorspace = V4L2_COLORSPACE_JPEG,
279 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300280};
281
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300282/*Data from sn9c102p+hv7131r */
283static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300284/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
285 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
286/* reg8 reg9 rega regb regc regd rege regf */
287 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
288/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
289 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300290/* reg18 reg19 reg1a reg1b */
291 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300292};
293
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300294static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300295/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
296 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
297/* reg8 reg9 rega regb regc regd rege regf */
298 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
299/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
300 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300301/* reg18 reg19 reg1a reg1b */
302 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300303};
304
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300305static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300306/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300307 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300308/* reg8 reg9 rega regb regc regd rege regf */
309 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
311 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300312/* reg18 reg19 reg1a reg1b */
313 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300314};
315
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300316static const u8 sn_mt9v111[0x1c] = {
317/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
318 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
319/* reg8 reg9 rega regb regc regd rege regf */
320 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
321/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
322 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
323/* reg18 reg19 reg1a reg1b */
324 0x06, 0x00, 0x00, 0x00
325};
326
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300327static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300328/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
329 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
330/* reg8 reg9 rega regb regc regd rege regf */
331 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
332/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
333 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300334/* reg18 reg19 reg1a reg1b */
335 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300336};
337
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300338static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300339/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
340 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
341/* reg8 reg9 rega regb regc regd rege regf */
342 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
343/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
344 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300345/* reg18 reg19 reg1a reg1b */
346 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300347};
348
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300349static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300350/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300351 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300352/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300353 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300354/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300355 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300356/* reg18 reg19 reg1a reg1b */
357 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300358};
359
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300360static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300361/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300362 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300363/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300364 0x81, 0x21, 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, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300367/* reg18 reg19 reg1a reg1b */
368 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300369};
370
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300371static const u8 sn_sp80708[0x1c] = {
372/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
373 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
374/* reg8 reg9 rega regb regc regd rege regf */
375 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
376/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
377 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
378/* reg18 reg19 reg1a reg1b */
379 0x07, 0x00, 0x00, 0x00
380};
381
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300382/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300383static const u8 *sn_tb[] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300384 sn_hv7131,
385 sn_mi0360,
386 sn_mo4000,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300387 sn_mt9v111,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300388 sn_om6802,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300389 sn_ov7630,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300390 sn_ov7648,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300391 sn_ov7660,
392 sn_sp80708
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300393};
394
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300395/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300396static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300397 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
398 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
399};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300400/* gamma for sensors HV7131R and MT9V111 */
401static const u8 gamma_spec_1[17] = {
402 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
403 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
404};
405/* gamma for sensor SP80708 */
406static const u8 gamma_spec_2[17] = {
407 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
408 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
409};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300410
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300411/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300412static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300413 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
414 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
415 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
416 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300417};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300418static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300419 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
420 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
421 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
422/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
423 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
424 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
425/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300426
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300427 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
428 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
429 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
430 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
431 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
432 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
433 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
434 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300435
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300436 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
437 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
438 {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
439 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
440 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300441
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300442 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
443 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
444 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
445 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
446 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300447 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300448};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300449static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300450 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300451 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300452 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300453 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
454 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
455 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
456 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
457 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
458 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
459 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
460 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
461 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
462 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
463 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
464 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
465 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
466 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
467 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
468 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
469 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
470 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
471 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300472 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300473 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
474 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
475 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
476 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
477 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
478 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
479 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
480 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
482 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300483
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300484 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
485 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
486 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
487 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
488 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300489
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300490 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
491 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
492 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
493 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300494
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300495 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
496 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
497/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
498/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
499 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
500 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300501 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300502};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300503static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300504 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
505 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
506 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
507 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
508 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
509 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
510 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
511 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
512 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
513 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
514 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
515 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
516 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
517 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
518 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
519 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
520 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
521 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
522 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
523 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300524 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300525};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300526static const u8 mt9v111_sensor_init[][8] = {
527 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
528 /* delay 20 ms */
529 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
530 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
531 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
532 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300533 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
534 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
535 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
536 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300537 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300538 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
539 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
540 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
541 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
542 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300543 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300544 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300545 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
546 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
547 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
548 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
549 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
550 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
551 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
552 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
553 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
554 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
555 /*******/
556 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
557 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300558 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300559 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
560 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
561 /*******/
562 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
563 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
564 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
565 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
566 {}
567};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300568static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300569 {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
570 {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
571 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
572 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
573/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
574 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
575 /* white balance & auto-exposure */
576/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
577 * set color mode */
578/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
579 * max AGC value in AE */
580/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
581 * preset AGC */
582/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
583 * preset brightness */
584/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
585 * preset contrast */
586/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
587 * preset gamma */
588 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
589 /* luminance mode (0x4f = AE) */
590 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
591 /* preset shutter */
592/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
593 * auto frame rate */
594/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
595
596/* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
597/* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
598/* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
599/* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
600 {}
601};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300602static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300603 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
604 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
605/* win: delay 20ms */
606 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
607 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
608/* win: delay 20ms */
609 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300610/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300611 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
612 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300613/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
614 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
615 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300616 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
617 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
618 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
619 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
620 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
621 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
622 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
623 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
624 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
625 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
626 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
627 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
628 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
629 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
630 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
631 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
632 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
633 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
634 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
635 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
636 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
637 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
638 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
639/* */
640 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
641 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
642/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300643/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
644 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300645 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
646 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300648/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300649 {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10},
650 {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300651/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300652 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300653/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300654 {}
655};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300656
Jean-Francois Moine98819182009-01-19 07:37:33 -0300657static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300658 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
659 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
660 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
661 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
662 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
663 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
664 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
665 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
666 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
667 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
668 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
669 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
670 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
671 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
672 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
673 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
674 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
675 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
676 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
677 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
678 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
679
680 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
681/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
682/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
683 {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10},
684/*...*/
685/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300686/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
687 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300688 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
689 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
690/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
691/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
692/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
693/*...*/
694 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
695/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
696/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
697/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
698/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
699/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
700
701 {}
702};
703
Jean-Francois Moine98819182009-01-19 07:37:33 -0300704static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300705 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine60017612008-07-18 08:46:19 -0300706/* (delay 20ms) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300707 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300708 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300709 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300710 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300711 /* GAIN BLUE RED VREF */
712 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
713 /* COM 1 BAVE GEAVE AECHH */
714 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
715 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300716 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300717 /* AECH CLKRC COM7 COM8 */
718 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
719 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
720 /* HSTART HSTOP VSTRT VSTOP */
721 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
722 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
723 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
724 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300725/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
726 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300727 /* AEW AEB VPT BBIAS */
728 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
729 /* GbBIAS RSVD EXHCH EXHCL */
730 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
731 /* RBIAS ADVFL ASDVFH YAVE */
732 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
733 /* HSYST HSYEN HREF */
734 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
735 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
736 /* ADC ACOM OFON TSLB */
737 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
738 /* COM11 COM12 COM13 COM14 */
739 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
740 /* EDGE COM15 COM16 COM17 */
741 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
742 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
743 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
744 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
745 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
746 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
747 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
748 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
749 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
750 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
751 /* LCC1 LCC2 LCC3 LCC4 */
752 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300753 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300754 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300755 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300756 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
757 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
758 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
759 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
760 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
761 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
762 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
763 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
764 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300765 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300766 {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300767/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300768 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300769 /* bits[3..0]reserved */
770 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
771 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
772 /* VREF vertical frame ctrl */
773 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300774 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
775 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
776 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
777 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
778/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300779/****** (some exchanges in the win trace) ******/
780 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300781 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
782 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
783 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
784/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300785/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300786/******!! startsensor KO if changed !!****/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300787 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
788 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
789 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300791 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300792};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300793
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300794static const u8 sp80708_sensor_init[][8] = {
795 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
796 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
797 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
798 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
799 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
800 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
801 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
802 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
803 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
804 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
805 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
806 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
807 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
809 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
810 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
811 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
812 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
813 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
814 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
815 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
816 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
817 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
818 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
819 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
820 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
860 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
866 /********/
867 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
869 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
870 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
871 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
872 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
873 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
874 {}
875};
876
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300877/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300878static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300879 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300880{
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300881#ifdef GSPCA_DEBUG
882 if (len > USB_BUF_SZ) {
883 err("reg_r: buffer overflow");
884 return;
885 }
886#endif
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300887 usb_control_msg(gspca_dev->dev,
888 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300889 0,
890 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
891 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300892 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300893 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300894 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300895}
896
Jean-Francois Moine60017612008-07-18 08:46:19 -0300897static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300898 u16 value,
899 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -0300900{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300901 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300902 gspca_dev->usb_buf[0] = data;
903 usb_control_msg(gspca_dev->dev,
904 usb_sndctrlpipe(gspca_dev->dev, 0),
905 0x08,
906 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
907 value,
908 0,
909 gspca_dev->usb_buf, 1,
910 500);
911}
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300912static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300913 u16 value,
914 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300915 int len)
916{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300917 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -0300918 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300919#ifdef GSPCA_DEBUG
920 if (len > USB_BUF_SZ) {
921 err("reg_w: buffer overflow");
922 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300923 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300924#endif
925 memcpy(gspca_dev->usb_buf, buffer, len);
926 usb_control_msg(gspca_dev->dev,
927 usb_sndctrlpipe(gspca_dev->dev, 0),
928 0x08,
929 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
930 value, 0,
931 gspca_dev->usb_buf, len,
932 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300933}
934
Jean-Francois Moine60017612008-07-18 08:46:19 -0300935/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300936static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300937{
938 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300939
Jean-Francois Moine60017612008-07-18 08:46:19 -0300940 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
941 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
942 gspca_dev->usb_buf[1] = sd->i2c_base;
943 gspca_dev->usb_buf[2] = reg;
944 gspca_dev->usb_buf[3] = val;
945 gspca_dev->usb_buf[4] = 0;
946 gspca_dev->usb_buf[5] = 0;
947 gspca_dev->usb_buf[6] = 0;
948 gspca_dev->usb_buf[7] = 0x10;
949 usb_control_msg(gspca_dev->dev,
950 usb_sndctrlpipe(gspca_dev->dev, 0),
951 0x08,
952 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
953 0x08, /* value = i2c */
954 0,
955 gspca_dev->usb_buf, 8,
956 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300957}
958
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300959/* I2C write 8 bytes */
960static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300961 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300962{
Jean-Francois Moine60017612008-07-18 08:46:19 -0300963 memcpy(gspca_dev->usb_buf, buffer, 8);
964 usb_control_msg(gspca_dev->dev,
965 usb_sndctrlpipe(gspca_dev->dev, 0),
966 0x08,
967 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
968 0x08, 0, /* value, index */
969 gspca_dev->usb_buf, 8,
970 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -0300971 msleep(2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300972}
973
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300974/* read 5 bytes in gspca_dev->usb_buf */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300975static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300976{
977 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -0300978 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300979
Hans de Goede3647fea2008-07-15 05:36:30 -0300980 mode[0] = 0x81 | 0x10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300981 mode[1] = sd->i2c_base;
982 mode[2] = reg;
983 mode[3] = 0;
984 mode[4] = 0;
985 mode[5] = 0;
986 mode[6] = 0;
987 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300988 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300989 msleep(2);
Hans de Goede3647fea2008-07-15 05:36:30 -0300990 mode[0] = 0x81 | (5 << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300991 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300992 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300993 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300994 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300995}
996
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300997static int hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300998{
Jean-Francois Moine60017612008-07-18 08:46:19 -0300999 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001000 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001001 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001002 msleep(10);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001003 i2c_r5(gspca_dev, 0); /* read sensor id */
1004 if (gspca_dev->usb_buf[0] == 0x02
1005 && gspca_dev->usb_buf[1] == 0x09
1006 && gspca_dev->usb_buf[2] == 0x01
1007 && gspca_dev->usb_buf[3] == 0x00
1008 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001009 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001010 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001011 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001012 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001013 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1014 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001015 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
1016 return -ENODEV;
1017}
1018
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001019static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001020{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001021 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001022 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001023 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001024 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001025 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001026 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1027 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1028 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1029 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1030 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001031 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001032 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1033 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1034 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1035 {}
1036 },
1037 };
1038
1039 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1040 reg_w1(gspca_dev, 0x17, 0x62);
1041 reg_w1(gspca_dev, 0x01, 0x08);
1042 for (j = 0; j < 3; j++)
1043 i2c_w8(gspca_dev, probe_tb[i][j]);
1044 msleep(2);
1045 reg_r(gspca_dev, 0x0a, 5);
1046 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1047 if (probe_tb[i][3][0] != 0)
1048 i2c_w8(gspca_dev, probe_tb[i][3]);
1049 reg_w1(gspca_dev, 0x01, 0x29);
1050 reg_w1(gspca_dev, 0x17, 0x42);
1051 if (val != 0xffff)
1052 break;
1053 }
1054 switch (val) {
1055 case 0x823a:
1056 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001057 sd->sensor = SENSOR_MT9V111;
1058 sd->i2c_base = 0x5c;
1059 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001060 case 0x8243:
1061 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001062 break;
1063 default:
1064 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1065 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001066 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001067}
1068
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001069static int configure_gpio(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001070 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001071{
1072 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001073 const u8 *reg9a;
1074 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001075 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1076 static const u8 reg9a_spec[] =
1077 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001078 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001079
Jean-Francois Moine60017612008-07-18 08:46:19 -03001080 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001081 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001082
1083 /* configure gpio */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001084 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1085 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001086 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001087 switch (sd->sensor) {
1088 case SENSOR_OV7660:
1089 case SENSOR_SP80708:
1090 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001091 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001092 default:
1093 reg9a = reg9a_def;
1094 break;
1095 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001096 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001097
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001098 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001099
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001100 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001101
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001102 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001103 case SENSOR_MT9V111:
1104 reg_w1(gspca_dev, 0x01, 0x61);
1105 reg_w1(gspca_dev, 0x17, 0x61);
1106 reg_w1(gspca_dev, 0x01, 0x60);
1107 reg_w1(gspca_dev, 0x01, 0x40);
1108 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001109 case SENSOR_OM6802:
Jean-Francois Moine4f30f6c2008-09-03 16:48:05 -03001110 reg_w1(gspca_dev, 0x02, 0x71);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001111 reg_w1(gspca_dev, 0x01, 0x42);
1112 reg_w1(gspca_dev, 0x17, 0x64);
1113 reg_w1(gspca_dev, 0x01, 0x42);
1114 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001115 case SENSOR_OV7630:
1116 reg_w1(gspca_dev, 0x01, 0x61);
1117 reg_w1(gspca_dev, 0x17, 0xe2);
1118 reg_w1(gspca_dev, 0x01, 0x60);
1119 reg_w1(gspca_dev, 0x01, 0x40);
1120 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001121 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001122 reg_w1(gspca_dev, 0x01, 0x63);
1123 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001124 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001125 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001126 break;
Jean-Francois Moine91de65a2008-09-03 17:12:18 -03001127 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001128 reg_w1(gspca_dev, 0x01, 0x61);
1129 reg_w1(gspca_dev, 0x17, 0x20);
1130 reg_w1(gspca_dev, 0x01, 0x60);
1131 reg_w1(gspca_dev, 0x01, 0x40);
1132 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001133 case SENSOR_SP80708:
1134 reg_w1(gspca_dev, 0x01, 0x63);
1135 reg_w1(gspca_dev, 0x17, 0x20);
1136 reg_w1(gspca_dev, 0x01, 0x62);
1137 reg_w1(gspca_dev, 0x01, 0x42);
1138 mdelay(100);
1139 reg_w1(gspca_dev, 0x02, 0x62);
1140 break;
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001141/* case SENSOR_HV7131R: */
1142/* case SENSOR_MI0360: */
1143/* case SENSOR_MO4000: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001144 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001145 reg_w1(gspca_dev, 0x01, 0x43);
1146 reg_w1(gspca_dev, 0x17, 0x61);
1147 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001148 if (sd->sensor == SENSOR_HV7131R) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001149 if (hv7131r_probe(gspca_dev) < 0)
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001150 return -ENODEV;
1151 }
1152 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001153 }
1154 return 0;
1155}
1156
1157static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
1158{
1159 int i = 0;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001160 static const u8 SetSensorClk[] = /* 0x08 Mclk */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001161 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
1162
1163 while (hv7131r_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001164 i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001165 i++;
1166 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001167 i2c_w8(gspca_dev, SetSensorClk);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001168}
1169
1170static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
1171{
1172 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001173
1174 while (mi0360_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001175 i2c_w8(gspca_dev, mi0360_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001176 i++;
1177 }
1178}
1179
1180static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
1181{
1182 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001183
1184 while (mo4000_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001185 i2c_w8(gspca_dev, mo4000_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001186 i++;
1187 }
1188}
1189
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001190static void mt9v111_InitSensor(struct gspca_dev *gspca_dev)
1191{
1192 int i = 0;
1193
1194 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1195 i++;
1196 msleep(20);
1197 while (mt9v111_sensor_init[i][0]) {
1198 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1199 i++;
1200 }
1201}
1202
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001203static void om6802_InitSensor(struct gspca_dev *gspca_dev)
1204{
1205 int i = 0;
1206
1207 while (om6802_sensor_init[i][0]) {
1208 i2c_w8(gspca_dev, om6802_sensor_init[i]);
1209 i++;
1210 }
1211}
1212
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001213static void ov7630_InitSensor(struct gspca_dev *gspca_dev)
1214{
1215 int i = 0;
1216
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001217 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */
1218 i++;
1219 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001220 i++;
1221 msleep(20);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001222 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1223 i++;
1224 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */
1225 i++;
1226 msleep(20);
1227 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1228 i++;
1229/*jfm:win i2c_r from 00 to 80*/
1230
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001231 while (ov7630_sensor_init[i][0]) {
1232 i2c_w8(gspca_dev, ov7630_sensor_init[i]);
1233 i++;
1234 }
1235}
1236
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001237static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
1238{
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001239 int i = 0;
1240
Jean-Francois Moine62703302008-11-11 08:42:56 -03001241 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
1242 i++;
1243/* win: dble reset */
1244 i2c_w8(gspca_dev, ov7648_sensor_init[i]); /* reset */
1245 i++;
1246 msleep(20);
1247/* win: i2c reg read 00..7f */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001248 while (ov7648_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001249 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001250 i++;
1251 }
1252}
1253
1254static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
1255{
1256 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001257
Jean-Francois Moine60017612008-07-18 08:46:19 -03001258 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
1259 i++;
1260 msleep(20);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001261 while (ov7660_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001262 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001263 i++;
1264 }
1265}
1266
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001267static void sp80708_InitSensor(struct gspca_dev *gspca_dev)
1268{
1269 int i = 0;
1270
1271 i2c_w8(gspca_dev, sp80708_sensor_init[i]); /* reset SCCB */
1272 i++;
1273 msleep(20);
1274 while (sp80708_sensor_init[i][0]) {
1275 i2c_w8(gspca_dev, sp80708_sensor_init[i]);
1276 i++;
1277 }
1278}
1279
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001280/* this function is called at probe time */
1281static int sd_config(struct gspca_dev *gspca_dev,
1282 const struct usb_device_id *id)
1283{
1284 struct sd *sd = (struct sd *) gspca_dev;
1285 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001286
1287 cam = &gspca_dev->cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001288 cam->cam_mode = vga_mode;
1289 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001290 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001291
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03001292 sd->bridge = id->driver_info >> 16;
1293 sd->sensor = id->driver_info >> 8;
1294 sd->i2c_base = id->driver_info;
1295
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001296 sd->brightness = BRIGHTNESS_DEF;
1297 sd->contrast = CONTRAST_DEF;
1298 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001299 sd->blue = BLUE_BALANCE_DEF;
1300 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001301 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001302 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001303 sd->ag_cnt = -1;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001304 if (sd->sensor != SENSOR_OV7630)
1305 sd->vflip = 0;
1306 else
1307 sd->vflip = 1;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001308 sd->infrared = INFRARED_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001309 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001310 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001311
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001312 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001313 return 0;
1314}
1315
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001316/* this function is called at probe and resume time */
1317static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001318{
1319 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001320 u8 regGpio[] = { 0x29, 0x74 };
1321 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001322
Hans de Goede3647fea2008-07-15 05:36:30 -03001323 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001324 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001325 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001326 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1327 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001328 regF1 = gspca_dev->usb_buf[0];
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001329 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001330 switch (sd->bridge) {
1331 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001332 if (regF1 != 0x11)
1333 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001334 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001335 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001336 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001337 if (regF1 != 0x11)
1338 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001339 if (sd->sensor == SENSOR_MI0360)
1340 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001341 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001342 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001343 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001344 if (regF1 != 0x12)
1345 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001346 if (sd->sensor == SENSOR_MI0360)
1347 mi0360_probe(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001348 regGpio[1] = 0x70;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001349 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001350 break;
1351 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001352/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001353/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001354 if (regF1 != 0x12)
1355 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001356 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001357 break;
1358 }
1359
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001360 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001361
1362 return 0;
1363}
1364
Jean-Francois Moine98819182009-01-19 07:37:33 -03001365static u32 setexposure(struct gspca_dev *gspca_dev,
1366 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001367{
1368 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001369
1370 switch (sd->sensor) {
1371 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001372 u8 Expodoit[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001373 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1374
1375 Expodoit[3] = expo >> 16;
1376 Expodoit[4] = expo >> 8;
1377 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001378 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001379 break;
1380 }
1381 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001382 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001383 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001384 static const u8 doit[] = /* update sensor */
1385 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1386 static const u8 sensorgo[] = /* sensor on */
1387 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001388
1389 if (expo > 0x0635)
1390 expo = 0x0635;
1391 else if (expo < 0x0001)
1392 expo = 0x0001;
1393 expoMi[3] = expo >> 8;
1394 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001395 i2c_w8(gspca_dev, expoMi);
1396 i2c_w8(gspca_dev, doit);
1397 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001398 break;
1399 }
1400 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001401 u8 expoMof[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001402 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001403 u8 expoMo10[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001404 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001405 static const u8 gainMo[] =
1406 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001407
1408 if (expo > 0x1fff)
1409 expo = 0x1fff;
1410 else if (expo < 0x0001)
1411 expo = 0x0001;
1412 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001413 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001414 expoMo10[3] = ((expo & 0x1c00) >> 10)
1415 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001416 i2c_w8(gspca_dev, expoMo10);
1417 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001418 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001419 ((expoMo10[3] & 0x07) << 10)
1420 | (expoMof[3] << 2)
1421 | ((expoMo10[3] & 0x30) >> 4));
1422 break;
1423 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001424 case SENSOR_MT9V111: {
1425 u8 expo_c1[] =
1426 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1427
1428 if (expo > 0x0280)
1429 expo = 0x0280;
1430 else if (expo < 0x0040)
1431 expo = 0x0040;
1432 expo_c1[3] = expo >> 8;
1433 expo_c1[4] = expo;
1434 i2c_w8(gspca_dev, expo_c1);
1435 break;
1436 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001437 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001438 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001439 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1440
1441 if (expo > 0x03ff)
1442 expo = 0x03ff;
1443 if (expo < 0x0001)
1444 expo = 0x0001;
1445 gainOm[3] = expo >> 2;
1446 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001447 reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001448 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001449 break;
1450 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001451 }
1452 return expo;
1453}
1454
1455static void setbrightness(struct gspca_dev *gspca_dev)
1456{
1457 struct sd *sd = (struct sd *) gspca_dev;
1458 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001459 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001460
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001461 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001462 switch (sd->sensor) {
1463 case SENSOR_HV7131R:
1464 expo = sd->brightness << 4;
1465 if (expo > 0x002dc6c0)
1466 expo = 0x002dc6c0;
1467 else if (expo < 0x02a0)
1468 expo = 0x02a0;
1469 sd->exposure = setexposure(gspca_dev, expo);
1470 break;
1471 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001472 case SENSOR_MO4000:
1473 expo = sd->brightness >> 4;
1474 sd->exposure = setexposure(gspca_dev, expo);
1475 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001476 case SENSOR_MT9V111:
1477 expo = sd->brightness >> 8;
1478 sd->exposure = setexposure(gspca_dev, expo);
1479 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001480 case SENSOR_OM6802:
1481 expo = sd->brightness >> 6;
1482 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001483 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001484 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001485 }
1486
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001487 if (sd->sensor != SENSOR_MT9V111)
1488 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001489}
1490
1491static void setcontrast(struct gspca_dev *gspca_dev)
1492{
1493 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001494 u8 k2;
1495 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001496
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001497 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1498 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001499 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001500 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001501 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001502 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001503 contrast[5] = 0;
1504 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001505}
1506
1507static void setcolors(struct gspca_dev *gspca_dev)
1508{
1509 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001510 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001511 u8 reg8a[12]; /* U & V gains */
1512 static s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001513 -24, -38, 64, /* UR UG UB */
1514 62, -51, -9 /* VR VG VB */
1515 };
1516 for (i = 0; i < 6; i++) {
1517 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001518 reg8a[i * 2] = v;
1519 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001520 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001521 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001522}
1523
1524static void setredblue(struct gspca_dev *gspca_dev)
1525{
1526 struct sd *sd = (struct sd *) gspca_dev;
1527
1528 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001529/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001530 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001531}
1532
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001533static void setgamma(struct gspca_dev *gspca_dev)
1534{
1535 struct sd *sd = (struct sd *) gspca_dev;
1536 int i;
1537 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001538 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001539 static const u8 delta[17] = {
1540 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1541 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1542 };
1543
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001544 switch (sd->sensor) {
1545 case SENSOR_HV7131R:
1546 case SENSOR_MT9V111:
1547 gamma_base = gamma_spec_1;
1548 break;
1549 case SENSOR_SP80708:
1550 gamma_base = gamma_spec_2;
1551 break;
1552 default:
1553 gamma_base = gamma_def;
1554 break;
1555 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001556
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001557 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001558 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001559 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1560 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1561}
1562
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001563static void setautogain(struct gspca_dev *gspca_dev)
1564{
1565 struct sd *sd = (struct sd *) gspca_dev;
1566
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001567 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
1568 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001569 switch (sd->sensor) {
1570 case SENSOR_OV7630:
1571 case SENSOR_OV7648: {
1572 u8 comb;
1573
1574 if (sd->sensor == SENSOR_OV7630)
1575 comb = 0xc0;
1576 else
1577 comb = 0xa0;
1578 if (sd->autogain)
1579 comb |= 0x02;
1580 i2c_w1(&sd->gspca_dev, 0x13, comb);
1581 return;
1582 }
1583 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001584 if (sd->autogain)
1585 sd->ag_cnt = AG_CNT_START;
1586 else
1587 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001588}
1589
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001590/* ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001591static void setvflip(struct sd *sd)
1592{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001593 u8 comn;
1594
1595 if (sd->sensor == SENSOR_OV7630)
1596 comn = 0x02;
1597 else
1598 comn = 0x06;
1599 if (sd->vflip)
1600 comn |= 0x80;
1601 i2c_w1(&sd->gspca_dev, 0x75, comn);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001602}
1603
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001604static void setinfrared(struct sd *sd)
1605{
1606/*fixme: different sequence for StarCam Clip and StarCam 370i */
1607/* Clip */
1608 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
1609 sd->infrared ? 0x66 : 0x64);
1610}
1611
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001612static void setjpegqual(struct gspca_dev *gspca_dev)
1613{
1614 struct sd *sd = (struct sd *) gspca_dev;
1615 int i, sc;
1616
1617 if (sd->jpegqual < 50)
1618 sc = 5000 / sd->jpegqual;
1619 else
1620 sc = 200 - sd->jpegqual * 2;
1621#if USB_BUF_SZ < 64
1622#error "No room enough in usb_buf for quantization table"
1623#endif
1624 for (i = 0; i < 64; i++)
1625 gspca_dev->usb_buf[i] =
1626 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1627 usb_control_msg(gspca_dev->dev,
1628 usb_sndctrlpipe(gspca_dev->dev, 0),
1629 0x08,
1630 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1631 0x0100, 0,
1632 gspca_dev->usb_buf, 64,
1633 500);
1634 for (i = 0; i < 64; i++)
1635 gspca_dev->usb_buf[i] =
1636 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1637 usb_control_msg(gspca_dev->dev,
1638 usb_sndctrlpipe(gspca_dev->dev, 0),
1639 0x08,
1640 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1641 0x0140, 0,
1642 gspca_dev->usb_buf, 64,
1643 500);
1644
1645 sd->reg18 ^= 0x40;
1646 reg_w1(gspca_dev, 0x18, sd->reg18);
1647}
1648
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001649/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001650static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001651{
1652 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001653 int i;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001654 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001655 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001656 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001657 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1658 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1659 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1660 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001661 { 0x32, 0xdd, 0x32, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001662
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001663 /* create the JPEG header */
1664 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
1665 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1666 0x21); /* JPEG 422 */
1667 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1668
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001669 sn9c1xx = sn_tb[(int) sd->sensor];
1670 configure_gpio(gspca_dev, sn9c1xx);
1671
Jean-Francois Moine60017612008-07-18 08:46:19 -03001672 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1673 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1674 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1675 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1676 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1677 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1678 reg_w1(gspca_dev, 0xd3, 0x50);
1679 reg_w1(gspca_dev, 0xc6, 0x00);
1680 reg_w1(gspca_dev, 0xc7, 0x00);
1681 reg_w1(gspca_dev, 0xc8, 0x50);
1682 reg_w1(gspca_dev, 0xc9, 0x3c);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001683 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001684 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001685 case SENSOR_MT9V111:
1686 reg17 = 0xe0;
1687 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001688 case SENSOR_OV7630:
1689 reg17 = 0xe2;
1690 break;
1691 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001692 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001693 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001694 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001695 reg17 = 0xa0;
1696 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001697 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001698 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001699 break;
1700 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001701 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001702/* set reg1 was here */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001703 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1704 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1705 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001706 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001707
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001708 setgamma(gspca_dev);
1709
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001710 for (i = 0; i < 8; i++)
1711 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001712 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001713 case SENSOR_MT9V111:
1714 reg_w1(gspca_dev, 0x9a, 0x07);
1715 reg_w1(gspca_dev, 0x99, 0x59);
1716 break;
Jean-Francois Moine62703302008-11-11 08:42:56 -03001717 case SENSOR_OV7648:
1718 reg_w1(gspca_dev, 0x9a, 0x0a);
1719 reg_w1(gspca_dev, 0x99, 0x60);
1720 break;
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001721 case SENSOR_OV7660:
1722 reg_w1(gspca_dev, 0x9a, 0x05);
1723 if (sd->bridge == BRIDGE_SN9C105)
1724 reg_w1(gspca_dev, 0x99, 0xff);
1725 else
1726 reg_w1(gspca_dev, 0x99, 0x5b);
1727 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001728 case SENSOR_SP80708:
1729 reg_w1(gspca_dev, 0x9a, 0x05);
1730 reg_w1(gspca_dev, 0x99, 0x59);
1731 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001732 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001733 reg_w1(gspca_dev, 0x9a, 0x08);
1734 reg_w1(gspca_dev, 0x99, 0x59);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001735 break;
1736 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001737
Jean-Francois Moinec2446b32008-07-05 11:49:20 -03001738 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001739 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001740 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001741 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001742 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1743 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001744 switch (sd->sensor) {
1745 case SENSOR_HV7131R:
1746 hv7131R_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001747 break;
1748 case SENSOR_MI0360:
1749 mi0360_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001750 break;
1751 case SENSOR_MO4000:
1752 mo4000_InitSensor(gspca_dev);
1753 if (mode) {
1754/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1755 reg1 = 0x06; /* clk 24Mz */
1756 } else {
1757 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001758/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001759 }
1760 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001761 case SENSOR_MT9V111:
1762 mt9v111_InitSensor(gspca_dev);
1763 if (mode) {
1764 reg1 = 0x04; /* 320 clk 48Mhz */
1765 } else {
1766/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03001767 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001768 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03001769 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001770 case SENSOR_OM6802:
1771 om6802_InitSensor(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001772 reg17 = 0x64; /* 640 MCKSIZE */
1773 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001774 case SENSOR_OV7630:
1775 ov7630_InitSensor(gspca_dev);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001776 setvflip(sd);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001777 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03001778 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001779 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001780 case SENSOR_OV7648:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001781 ov7648_InitSensor(gspca_dev);
Jean-Francois Moine62703302008-11-11 08:42:56 -03001782 reg17 = 0x21;
1783/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001784 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001785 case SENSOR_OV7660:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001786 ov7660_InitSensor(gspca_dev);
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001787 if (sd->bridge == BRIDGE_SN9C120) {
1788 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001789 reg17 = 0xa2;
1790 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001791 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001792 } else {
1793 reg17 = 0x22;
1794 reg1 = 0x06; /* 24 Mhz, video trf eneble
1795 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001796 }
1797 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001798 default:
1799/* case SENSOR_SP80708: */
1800 sp80708_InitSensor(gspca_dev);
1801 if (mode) {
1802/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001803 } else {
1804 reg1 = 0x46; /* 640 clk 48Mz */
1805 reg17 = 0xa2;
1806 }
1807 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001808 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001809 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001810 reg_w(gspca_dev, 0xca, CA, 4);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001811 switch (sd->sensor) {
1812 case SENSOR_OV7630:
1813 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001814 case SENSOR_OV7660:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001815 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001816 break;
1817 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001818 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001819 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1820 break;
1821 }
1822
1823 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001824 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
1825 reg_w1(gspca_dev, 0x18, sd->reg18);
1826 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001827
Jean-Francois Moine60017612008-07-18 08:46:19 -03001828 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001829 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001830 switch (sd->sensor) {
Jean-Francois Moine79a90982008-10-05 04:21:24 -03001831 case SENSOR_OV7630:
1832 setvflip(sd);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001833 break;
1834 }
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001835 setbrightness(gspca_dev);
1836 setcontrast(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001837 setautogain(gspca_dev);
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001838 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001839}
1840
1841static void sd_stopN(struct gspca_dev *gspca_dev)
1842{
1843 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001844 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001845 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001846 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001847 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001848 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03001849 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001850 u8 data;
1851 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001852
1853 data = 0x0b;
1854 switch (sd->sensor) {
1855 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001856 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001857 data = 0x2b;
1858 break;
1859 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001860 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861 data = 0x29;
1862 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001863 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001864 i2c_w8(gspca_dev, stopov7648);
1865 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001866 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001867 case SENSOR_OV7630:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001868 data = 0x29;
1869 break;
1870 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001871/* case SENSOR_MO4000: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001872/* case SENSOR_OV7660: */
1873 break;
1874 }
1875 sn9c1xx = sn_tb[(int) sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03001876 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1877 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1878 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1879 reg_w1(gspca_dev, 0x01, data);
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001880 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001881}
1882
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001883static void sd_stop0(struct gspca_dev *gspca_dev)
1884{
1885 struct sd *sd = (struct sd *) gspca_dev;
1886
1887 kfree(sd->jpeg_hdr);
1888}
1889
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001890static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001891{
1892 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001893 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001894 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001895 u8 luma_mean = 130;
1896 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001897
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001898 /* Thanks S., without your advice, autobright should not work :) */
1899 if (sd->ag_cnt < 0)
1900 return;
1901 if (--sd->ag_cnt >= 0)
1902 return;
1903 sd->ag_cnt = AG_CNT_START;
1904
1905 delta = atomic_read(&sd->avg_lum);
1906 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001907 if (delta < luma_mean - luma_delta ||
1908 delta > luma_mean + luma_delta) {
1909 switch (sd->sensor) {
1910 case SENSOR_HV7131R:
1911 expotimes = sd->exposure >> 8;
1912 expotimes += (luma_mean - delta) >> 4;
1913 if (expotimes < 0)
1914 expotimes = 0;
1915 sd->exposure = setexposure(gspca_dev,
1916 (unsigned int) (expotimes << 8));
1917 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001918 default:
1919/* case SENSOR_MO4000: */
1920/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001921/* case SENSOR_MT9V111: */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001922/* case SENSOR_OM6802: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001923 expotimes = sd->exposure;
1924 expotimes += (luma_mean - delta) >> 6;
1925 if (expotimes < 0)
1926 expotimes = 0;
1927 sd->exposure = setexposure(gspca_dev,
1928 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001929 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001930 break;
1931 }
1932 }
1933}
1934
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001935/* scan the URB packets */
1936/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001937static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1938 struct gspca_frame *frame, /* target */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001939 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001940 int len) /* iso packet length */
1941{
1942 struct sd *sd = (struct sd *) gspca_dev;
1943 int sof, avg_lum;
1944
1945 sof = len - 64;
1946 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
1947
1948 /* end of frame */
1949 gspca_frame_add(gspca_dev, LAST_PACKET,
1950 frame, data, sof + 2);
1951 if (sd->ag_cnt < 0)
1952 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001953/* w1 w2 w3 */
1954/* w4 w5 w6 */
1955/* w7 w8 */
1956/* w4 */
1957 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
1958/* w6 */
1959 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
1960/* w2 */
1961 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
1962/* w8 */
1963 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
1964/* w5 */
1965 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
1966 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001967 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001968 return;
1969 }
1970 if (gspca_dev->last_packet_type == LAST_PACKET) {
1971
1972 /* put the JPEG 422 header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001973 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1974 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001975 }
1976 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1977}
1978
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001979static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1980{
1981 struct sd *sd = (struct sd *) gspca_dev;
1982
1983 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001984 if (gspca_dev->streaming)
1985 setbrightness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001986 return 0;
1987}
1988
1989static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1990{
1991 struct sd *sd = (struct sd *) gspca_dev;
1992
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001993 *val = sd->brightness;
1994 return 0;
1995}
1996
1997static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1998{
1999 struct sd *sd = (struct sd *) gspca_dev;
2000
2001 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002002 if (gspca_dev->streaming)
2003 setcontrast(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002004 return 0;
2005}
2006
2007static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2008{
2009 struct sd *sd = (struct sd *) gspca_dev;
2010
2011 *val = sd->contrast;
2012 return 0;
2013}
2014
2015static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2016{
2017 struct sd *sd = (struct sd *) gspca_dev;
2018
2019 sd->colors = val;
2020 if (gspca_dev->streaming)
2021 setcolors(gspca_dev);
2022 return 0;
2023}
2024
2025static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2026{
2027 struct sd *sd = (struct sd *) gspca_dev;
2028
2029 *val = sd->colors;
2030 return 0;
2031}
2032
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002033static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2034{
2035 struct sd *sd = (struct sd *) gspca_dev;
2036
2037 sd->blue = val;
2038 if (gspca_dev->streaming)
2039 setredblue(gspca_dev);
2040 return 0;
2041}
2042
2043static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2044{
2045 struct sd *sd = (struct sd *) gspca_dev;
2046
2047 *val = sd->blue;
2048 return 0;
2049}
2050
2051static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2052{
2053 struct sd *sd = (struct sd *) gspca_dev;
2054
2055 sd->red = val;
2056 if (gspca_dev->streaming)
2057 setredblue(gspca_dev);
2058 return 0;
2059}
2060
2061static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2062{
2063 struct sd *sd = (struct sd *) gspca_dev;
2064
2065 *val = sd->red;
2066 return 0;
2067}
2068
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002069static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2070{
2071 struct sd *sd = (struct sd *) gspca_dev;
2072
2073 sd->gamma = val;
2074 if (gspca_dev->streaming)
2075 setgamma(gspca_dev);
2076 return 0;
2077}
2078
2079static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2080{
2081 struct sd *sd = (struct sd *) gspca_dev;
2082
2083 *val = sd->gamma;
2084 return 0;
2085}
2086
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002087static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2088{
2089 struct sd *sd = (struct sd *) gspca_dev;
2090
2091 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002092 if (gspca_dev->streaming)
2093 setautogain(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002094 return 0;
2095}
2096
2097static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2098{
2099 struct sd *sd = (struct sd *) gspca_dev;
2100
2101 *val = sd->autogain;
2102 return 0;
2103}
2104
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002105static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2106{
2107 struct sd *sd = (struct sd *) gspca_dev;
2108
2109 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002110 if (gspca_dev->streaming)
2111 setvflip(sd);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002112 return 0;
2113}
2114
2115static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2116{
2117 struct sd *sd = (struct sd *) gspca_dev;
2118
2119 *val = sd->vflip;
2120 return 0;
2121}
2122
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002123static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2124{
2125 struct sd *sd = (struct sd *) gspca_dev;
2126
2127 sd->infrared = val;
2128 if (gspca_dev->streaming)
2129 setinfrared(sd);
2130 return 0;
2131}
2132
2133static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2134{
2135 struct sd *sd = (struct sd *) gspca_dev;
2136
2137 *val = sd->infrared;
2138 return 0;
2139}
2140
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002141static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2142 struct v4l2_jpegcompression *jcomp)
2143{
2144 struct sd *sd = (struct sd *) gspca_dev;
2145
2146 if (jcomp->quality < QUALITY_MIN)
2147 sd->quality = QUALITY_MIN;
2148 else if (jcomp->quality > QUALITY_MAX)
2149 sd->quality = QUALITY_MAX;
2150 else
2151 sd->quality = jcomp->quality;
2152 if (gspca_dev->streaming)
2153 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2154 return 0;
2155}
2156
2157static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2158 struct v4l2_jpegcompression *jcomp)
2159{
2160 struct sd *sd = (struct sd *) gspca_dev;
2161
2162 memset(jcomp, 0, sizeof *jcomp);
2163 jcomp->quality = sd->quality;
2164 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2165 | V4L2_JPEG_MARKER_DQT;
2166 return 0;
2167}
2168
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002169/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002170static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002171 .name = MODULE_NAME,
2172 .ctrls = sd_ctrls,
2173 .nctrls = ARRAY_SIZE(sd_ctrls),
2174 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002175 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002176 .start = sd_start,
2177 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002178 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002179 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002180 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002181 .get_jcomp = sd_get_jcomp,
2182 .set_jcomp = sd_set_jcomp,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002183};
2184
2185/* -- module initialisation -- */
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002186#define BSI(bridge, sensor, i2c_addr) \
2187 .driver_info = (BRIDGE_ ## bridge << 16) \
2188 | (SENSOR_ ## sensor << 8) \
2189 | (i2c_addr)
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002190static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002191#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002192 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
Jean-Francois Moine7b537392008-09-07 11:56:49 -03002193 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002194#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002195 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
2196 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
2197 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine7e21fda2008-11-10 04:45:51 -03002198 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002199 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine3319dc92008-12-01 14:44:02 -03002200 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
Jani Monosesf8eaaf42009-05-07 03:32:27 -03002201 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002202 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
2203/* bw600.inf:
2204 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
2205/* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
2206/* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
2207 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
2208/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
Jean-Francois Moine661ab252009-01-29 16:03:19 -03002209 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002210/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
2211/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2212 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
2213/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2214/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
2215 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
2216 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002217#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2218 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2219#endif
Jean-Francois Moineceec80e2009-05-09 06:21:35 -03002220 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002221/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
Jean-Francois Moineceec80e2009-05-09 06:21:35 -03002222 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
2223 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
2224 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
2225 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002226/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2227/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002228 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
2229/*bw600.inf:*/
Jean-Francois Moine62703302008-11-11 08:42:56 -03002230 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002231 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002232 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002233/* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03002234#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002235 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002236#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002237 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
Jean-Francois Moine821ced22008-11-11 07:10:11 -03002238 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002239#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002240 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002241#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002242 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
Hans de Goedecc7b5b52009-06-18 05:14:42 -03002243 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)},
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002244 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002245 {}
2246};
2247MODULE_DEVICE_TABLE(usb, device_table);
2248
2249/* -- device connect -- */
2250static int sd_probe(struct usb_interface *intf,
2251 const struct usb_device_id *id)
2252{
2253 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2254 THIS_MODULE);
2255}
2256
2257static struct usb_driver sd_driver = {
2258 .name = MODULE_NAME,
2259 .id_table = device_table,
2260 .probe = sd_probe,
2261 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002262#ifdef CONFIG_PM
2263 .suspend = gspca_suspend,
2264 .resume = gspca_resume,
2265#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002266};
2267
2268/* -- module insert / remove -- */
2269static int __init sd_mod_init(void)
2270{
Alexey Klimovf69e9522009-01-01 13:02:07 -03002271 int ret;
2272 ret = usb_register(&sd_driver);
2273 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -03002274 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -03002275 info("registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002276 return 0;
2277}
2278static void __exit sd_mod_exit(void)
2279{
2280 usb_deregister(&sd_driver);
2281 info("deregistered");
2282}
2283
2284module_init(sd_mod_init);
2285module_exit(sd_mod_exit);