blob: e58ac891b208c2ef742832f5c893aab5d2b793f9 [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
65#define BRIDGE_SN9C325 4
Jean-Francois Moine98819182009-01-19 07:37:33 -030066 u8 sensor; /* Type of image sensor chip */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030067#define SENSOR_HV7131R 0
68#define SENSOR_MI0360 1
69#define SENSOR_MO4000 2
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -030070#define SENSOR_MT9V111 3
71#define SENSOR_OM6802 4
72#define SENSOR_OV7630 5
73#define SENSOR_OV7648 6
74#define SENSOR_OV7660 7
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -030075#define SENSOR_SP80708 8
Jean-Francois Moine98819182009-01-19 07:37:33 -030076 u8 i2c_base;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030077
78 u8 *jpeg_hdr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030079};
80
81/* V4L2 controls supported by the driver */
82static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
83static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
84static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
85static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
86static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
87static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030088static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
89static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
90static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
91static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030092static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
93static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030094static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
95static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -030096static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030098static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300100
101static struct ctrl sd_ctrls[] = {
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 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300117 {
118 {
119 .id = V4L2_CID_CONTRAST,
120 .type = V4L2_CTRL_TYPE_INTEGER,
121 .name = "Contrast",
122 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300123#define CONTRAST_MAX 127
124 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300125 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300126#define CONTRAST_DEF 63
127 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300128 },
129 .set = sd_setcontrast,
130 .get = sd_getcontrast,
131 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 {
133 {
134 .id = V4L2_CID_SATURATION,
135 .type = V4L2_CTRL_TYPE_INTEGER,
136 .name = "Color",
137 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300138 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300139 .step = 1,
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -0300140#define COLOR_DEF 32
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300141 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 },
143 .set = sd_setcolors,
144 .get = sd_getcolors,
145 },
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300146 {
147 {
148 .id = V4L2_CID_BLUE_BALANCE,
149 .type = V4L2_CTRL_TYPE_INTEGER,
150 .name = "Blue Balance",
151 .minimum = 24,
152 .maximum = 40,
153 .step = 1,
154#define BLUE_BALANCE_DEF 32
155 .default_value = BLUE_BALANCE_DEF,
156 },
157 .set = sd_setblue_balance,
158 .get = sd_getblue_balance,
159 },
160 {
161 {
162 .id = V4L2_CID_RED_BALANCE,
163 .type = V4L2_CTRL_TYPE_INTEGER,
164 .name = "Red Balance",
165 .minimum = 24,
166 .maximum = 40,
167 .step = 1,
168#define RED_BALANCE_DEF 32
169 .default_value = RED_BALANCE_DEF,
170 },
171 .set = sd_setred_balance,
172 .get = sd_getred_balance,
173 },
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300174 {
175 {
176 .id = V4L2_CID_GAMMA,
177 .type = V4L2_CTRL_TYPE_INTEGER,
178 .name = "Gamma",
179 .minimum = 0,
180 .maximum = 40,
181 .step = 1,
182#define GAMMA_DEF 20
183 .default_value = GAMMA_DEF,
184 },
185 .set = sd_setgamma,
186 .get = sd_getgamma,
187 },
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300188#define AUTOGAIN_IDX 5
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300189 {
190 {
191 .id = V4L2_CID_AUTOGAIN,
192 .type = V4L2_CTRL_TYPE_BOOLEAN,
193 .name = "Auto Gain",
194 .minimum = 0,
195 .maximum = 1,
196 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300197#define AUTOGAIN_DEF 1
198 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300199 },
200 .set = sd_setautogain,
201 .get = sd_getautogain,
202 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300203/* ov7630/ov7648 only */
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300204#define VFLIP_IDX 6
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300205 {
206 {
207 .id = V4L2_CID_VFLIP,
208 .type = V4L2_CTRL_TYPE_BOOLEAN,
209 .name = "Vflip",
210 .minimum = 0,
211 .maximum = 1,
212 .step = 1,
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300213#define VFLIP_DEF 0 /* vflip def = 1 for ov7630 */
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300214 .default_value = VFLIP_DEF,
215 },
216 .set = sd_setvflip,
217 .get = sd_getvflip,
218 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300219/* mt9v111 only */
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300220#define INFRARED_IDX 7
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300221 {
222 {
223 .id = V4L2_CID_INFRARED,
224 .type = V4L2_CTRL_TYPE_BOOLEAN,
225 .name = "Infrared",
226 .minimum = 0,
227 .maximum = 1,
228 .step = 1,
229#define INFRARED_DEF 0
230 .default_value = INFRARED_DEF,
231 },
232 .set = sd_setinfrared,
233 .get = sd_getinfrared,
234 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300235};
236
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300237/* table of the disabled controls */
238static __u32 ctrl_dis[] = {
239 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
240 /* SENSOR_HV7131R 0 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300241 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300242 /* SENSOR_MI0360 1 */
243 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
244 /* SENSOR_MO4000 2 */
Jean-Francois Moinec33c02e2009-02-05 15:04:33 -0300245 (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300246 /* SENSOR_MT9V111 3 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300247 (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300248 /* SENSOR_OM6802 4 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300249 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300250 /* SENSOR_OV7630 5 */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300251 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300252 /* SENSOR_OV7648 6 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300253 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300254 /* SENSOR_OV7660 7 */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300255 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
256 /* SENSOR_SP80708 8 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300257};
258
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300259static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300260 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
261 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300262 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300263 .colorspace = V4L2_COLORSPACE_JPEG,
264 .priv = 2},
265 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
266 .bytesperline = 320,
267 .sizeimage = 320 * 240 * 3 / 8 + 590,
268 .colorspace = V4L2_COLORSPACE_JPEG,
269 .priv = 1},
270 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
271 .bytesperline = 640,
272 .sizeimage = 640 * 480 * 3 / 8 + 590,
273 .colorspace = V4L2_COLORSPACE_JPEG,
274 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300275};
276
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300277/*Data from sn9c102p+hv7131r */
278static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300279/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
280 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
281/* reg8 reg9 rega regb regc regd rege regf */
282 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
283/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
284 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300285/* reg18 reg19 reg1a reg1b */
286 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300287};
288
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300289static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300290/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
291 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
292/* reg8 reg9 rega regb regc regd rege regf */
293 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
294/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
295 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300296/* reg18 reg19 reg1a reg1b */
297 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300298};
299
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300300static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300301/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300302 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300303/* reg8 reg9 rega regb regc regd rege regf */
304 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
306 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300307/* reg18 reg19 reg1a reg1b */
308 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300309};
310
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300311static const u8 sn_mt9v111[0x1c] = {
312/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
313 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
314/* reg8 reg9 rega regb regc regd rege regf */
315 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
316/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
317 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
318/* reg18 reg19 reg1a reg1b */
319 0x06, 0x00, 0x00, 0x00
320};
321
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300322static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300323/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
324 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
325/* reg8 reg9 rega regb regc regd rege regf */
326 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
327/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
328 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300329/* reg18 reg19 reg1a reg1b */
330 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300331};
332
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300333static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300334/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
335 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
336/* reg8 reg9 rega regb regc regd rege regf */
337 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
338/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
339 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300340/* reg18 reg19 reg1a reg1b */
341 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300342};
343
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300344static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300345/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300346 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300347/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300348 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300349/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300350 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300351/* reg18 reg19 reg1a reg1b */
352 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300353};
354
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300355static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300356/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
357 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
358/* reg8 reg9 rega regb regc regd rege regf */
359 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
360/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
361 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300362/* reg18 reg19 reg1a reg1b */
363 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300364};
365
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300366static const u8 sn_sp80708[0x1c] = {
367/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
368 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
369/* reg8 reg9 rega regb regc regd rege regf */
370 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
371/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
372 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
373/* reg18 reg19 reg1a reg1b */
374 0x07, 0x00, 0x00, 0x00
375};
376
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300377/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300378static const u8 *sn_tb[] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300379 sn_hv7131,
380 sn_mi0360,
381 sn_mo4000,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300382 sn_mt9v111,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300383 sn_om6802,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300384 sn_ov7630,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300385 sn_ov7648,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300386 sn_ov7660,
387 sn_sp80708
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300388};
389
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300390/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300391static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300392 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
393 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
394};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300395/* gamma for sensors HV7131R and MT9V111 */
396static const u8 gamma_spec_1[17] = {
397 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
398 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
399};
400/* gamma for sensor SP80708 */
401static const u8 gamma_spec_2[17] = {
402 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
403 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
404};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300405
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300406/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300407static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300408 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
409 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
410 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
411 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300412};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300413static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300414 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
415 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
416 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
417/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
418 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
419 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
420/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300421
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300422 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
423 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
424 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
425 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
426 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
427 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
428 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
429 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300430
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300431 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
432 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
433 {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
434 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
435 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300436
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300437 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
438 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
439 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
440 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
441 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300442 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300443};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300444static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300445 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300446 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300447 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300448 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
449 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
450 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
451 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
452 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
453 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
454 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
455 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
456 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
457 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
458 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
459 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
460 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
461 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
462 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
463 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
464 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
465 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
466 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300467 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300468 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
469 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
470 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
471 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
472 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
473 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
474 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
475 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
476 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
477 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300478
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300479 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
480 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
481 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
482 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
483 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300484
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300485 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
486 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
487 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
488 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300489
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300490 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
491 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
492/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
493/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
494 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
495 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300496 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300497};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300498static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300499 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
500 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
502 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
503 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
504 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
505 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
506 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
507 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
508 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
509 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
510 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
511 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
512 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
513 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
514 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
515 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
516 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
517 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
518 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300519 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300520};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300521static const u8 mt9v111_sensor_init[][8] = {
522 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
523 /* delay 20 ms */
524 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
525 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
526 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
527 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300528 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
529 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
530 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
531 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300532 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300533 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
534 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
535 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
536 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
537 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300538 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300539 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300540 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
541 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
542 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
543 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
544 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
545 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
546 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
547 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
548 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
549 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
550 /*******/
551 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
552 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300553 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300554 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
555 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
556 /*******/
557 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
558 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
559 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
560 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
561 {}
562};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300563static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300564 {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
565 {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
566 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
567 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
568/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
569 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
570 /* white balance & auto-exposure */
571/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
572 * set color mode */
573/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
574 * max AGC value in AE */
575/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
576 * preset AGC */
577/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
578 * preset brightness */
579/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
580 * preset contrast */
581/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
582 * preset gamma */
583 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
584 /* luminance mode (0x4f = AE) */
585 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
586 /* preset shutter */
587/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
588 * auto frame rate */
589/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
590
591/* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
592/* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
593/* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
594/* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
595 {}
596};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300597static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300598 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
599 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
600/* win: delay 20ms */
601 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
602 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
603/* win: delay 20ms */
604 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300605/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300606 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
607 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
608 {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10},
609 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
610 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
611 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
612 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
613 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
614 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
615 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
616 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
617 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
618 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
619 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
620 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
621 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
622 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
623 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
624 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
625 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
626 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
627 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
628 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
629 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
630 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
631 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
632/* */
633 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
634 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
635/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300636/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
637 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300638 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
639 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
640 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300641/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300642 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
643 {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10},
644 {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300645/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300646 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300647/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300648 {}
649};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300650
Jean-Francois Moine98819182009-01-19 07:37:33 -0300651static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300652 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
653 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
654 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
655 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
656 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
657 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
658 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
659 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
660 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
661 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
662 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
663 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
664 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
665 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
666 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
667 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
668 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
669 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
670 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
671 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
672 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
673
674 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
675/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
676/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
677 {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10},
678/*...*/
679/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300680/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
681 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300682 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
683 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
684/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
685/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
686/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
687/*...*/
688 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
689/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
690/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
691/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
692/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
693/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
694
695 {}
696};
697
Jean-Francois Moine98819182009-01-19 07:37:33 -0300698static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300699 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine60017612008-07-18 08:46:19 -0300700/* (delay 20ms) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300701 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300702 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300703 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300704 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300705 /* GAIN BLUE RED VREF */
706 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
707 /* COM 1 BAVE GEAVE AECHH */
708 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
709 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300710 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300711 /* AECH CLKRC COM7 COM8 */
712 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
713 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
714 /* HSTART HSTOP VSTRT VSTOP */
715 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
716 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
717 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
718 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300719/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
720 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300721 /* AEW AEB VPT BBIAS */
722 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
723 /* GbBIAS RSVD EXHCH EXHCL */
724 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
725 /* RBIAS ADVFL ASDVFH YAVE */
726 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
727 /* HSYST HSYEN HREF */
728 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
729 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
730 /* ADC ACOM OFON TSLB */
731 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
732 /* COM11 COM12 COM13 COM14 */
733 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
734 /* EDGE COM15 COM16 COM17 */
735 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
736 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
737 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
738 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
739 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
740 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
741 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
742 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
743 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
744 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
745 /* LCC1 LCC2 LCC3 LCC4 */
746 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300747 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300748 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300749 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300750 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
751 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
752 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
753 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
754 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
755 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
756 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
757 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
758 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300759 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300760/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300761 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300762 /* bits[3..0]reserved */
763 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
764 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
765 /* VREF vertical frame ctrl */
766 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300767 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
768 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
769 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
770 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
771/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300772/****** (some exchanges in the win trace) ******/
773 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300774 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
775 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
776 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
777/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300778/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300779/******!! startsensor KO if changed !!****/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300780 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
781 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
782 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300784 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300785};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300786
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300787static const u8 sp80708_sensor_init[][8] = {
788 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
789 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
790 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
792 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
793 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
794 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
795 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
796 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
797 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
798 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
799 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
800 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
801 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
802 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
803 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
804 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
805 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
806 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
807 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
809 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
810 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
811 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
812 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
813 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
814 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
815 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
816 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
817 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
818 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
819 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
820 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
859 /********/
860 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
866 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
867 {}
868};
869
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300870/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300871static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300872 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300873{
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300874#ifdef GSPCA_DEBUG
875 if (len > USB_BUF_SZ) {
876 err("reg_r: buffer overflow");
877 return;
878 }
879#endif
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300880 usb_control_msg(gspca_dev->dev,
881 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300882 0,
883 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
884 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300885 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300886 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300887 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300888}
889
Jean-Francois Moine60017612008-07-18 08:46:19 -0300890static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300891 u16 value,
892 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -0300893{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300894 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300895 gspca_dev->usb_buf[0] = data;
896 usb_control_msg(gspca_dev->dev,
897 usb_sndctrlpipe(gspca_dev->dev, 0),
898 0x08,
899 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
900 value,
901 0,
902 gspca_dev->usb_buf, 1,
903 500);
904}
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300905static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300906 u16 value,
907 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300908 int len)
909{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300910 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -0300911 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300912#ifdef GSPCA_DEBUG
913 if (len > USB_BUF_SZ) {
914 err("reg_w: buffer overflow");
915 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300916 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300917#endif
918 memcpy(gspca_dev->usb_buf, buffer, len);
919 usb_control_msg(gspca_dev->dev,
920 usb_sndctrlpipe(gspca_dev->dev, 0),
921 0x08,
922 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
923 value, 0,
924 gspca_dev->usb_buf, len,
925 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300926}
927
Jean-Francois Moine60017612008-07-18 08:46:19 -0300928/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300929static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300930{
931 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300932
Jean-Francois Moine60017612008-07-18 08:46:19 -0300933 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
934 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
935 gspca_dev->usb_buf[1] = sd->i2c_base;
936 gspca_dev->usb_buf[2] = reg;
937 gspca_dev->usb_buf[3] = val;
938 gspca_dev->usb_buf[4] = 0;
939 gspca_dev->usb_buf[5] = 0;
940 gspca_dev->usb_buf[6] = 0;
941 gspca_dev->usb_buf[7] = 0x10;
942 usb_control_msg(gspca_dev->dev,
943 usb_sndctrlpipe(gspca_dev->dev, 0),
944 0x08,
945 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
946 0x08, /* value = i2c */
947 0,
948 gspca_dev->usb_buf, 8,
949 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300950}
951
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300952/* I2C write 8 bytes */
953static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300954 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300955{
Jean-Francois Moine60017612008-07-18 08:46:19 -0300956 memcpy(gspca_dev->usb_buf, buffer, 8);
957 usb_control_msg(gspca_dev->dev,
958 usb_sndctrlpipe(gspca_dev->dev, 0),
959 0x08,
960 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
961 0x08, 0, /* value, index */
962 gspca_dev->usb_buf, 8,
963 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -0300964 msleep(2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300965}
966
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300967/* read 5 bytes in gspca_dev->usb_buf */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300968static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300969{
970 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -0300971 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300972
Hans de Goede3647fea2008-07-15 05:36:30 -0300973 mode[0] = 0x81 | 0x10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300974 mode[1] = sd->i2c_base;
975 mode[2] = reg;
976 mode[3] = 0;
977 mode[4] = 0;
978 mode[5] = 0;
979 mode[6] = 0;
980 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300981 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300982 msleep(2);
Hans de Goede3647fea2008-07-15 05:36:30 -0300983 mode[0] = 0x81 | (5 << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300984 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300985 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300986 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300987 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300988}
989
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300990static int hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300991{
Jean-Francois Moine60017612008-07-18 08:46:19 -0300992 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300993 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300994 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300995 msleep(10);
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300996 i2c_r5(gspca_dev, 0); /* read sensor id */
997 if (gspca_dev->usb_buf[0] == 0x02
998 && gspca_dev->usb_buf[1] == 0x09
999 && gspca_dev->usb_buf[2] == 0x01
1000 && gspca_dev->usb_buf[3] == 0x00
1001 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001002 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001003 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001004 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001005 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001006 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1007 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001008 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
1009 return -ENODEV;
1010}
1011
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001012static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001013{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001014 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001015 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001016 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001017 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001018 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001019 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1020 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1021 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1022 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1023 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001024 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001025 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1026 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1027 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1028 {}
1029 },
1030 };
1031
1032 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1033 reg_w1(gspca_dev, 0x17, 0x62);
1034 reg_w1(gspca_dev, 0x01, 0x08);
1035 for (j = 0; j < 3; j++)
1036 i2c_w8(gspca_dev, probe_tb[i][j]);
1037 msleep(2);
1038 reg_r(gspca_dev, 0x0a, 5);
1039 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1040 if (probe_tb[i][3][0] != 0)
1041 i2c_w8(gspca_dev, probe_tb[i][3]);
1042 reg_w1(gspca_dev, 0x01, 0x29);
1043 reg_w1(gspca_dev, 0x17, 0x42);
1044 if (val != 0xffff)
1045 break;
1046 }
1047 switch (val) {
1048 case 0x823a:
1049 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001050 sd->sensor = SENSOR_MT9V111;
1051 sd->i2c_base = 0x5c;
1052 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001053 case 0x8243:
1054 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001055 break;
1056 default:
1057 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1058 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001059 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001060}
1061
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001062static int configure_gpio(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001063 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001064{
1065 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001066 const u8 *reg9a;
1067 static const u8 reg9a_def[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001068 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001069 static const u8 reg9a_sn9c325[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001070 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001071 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001072
Jean-Francois Moine60017612008-07-18 08:46:19 -03001073 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001074 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001075
1076 /* configure gpio */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001077 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1078 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001079 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
Hans de Goede3647fea2008-07-15 05:36:30 -03001080 switch (sd->bridge) {
1081 case BRIDGE_SN9C325:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001082 reg9a = reg9a_sn9c325;
1083 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001084 default:
1085 reg9a = reg9a_def;
1086 break;
1087 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001088 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001089
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001090 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001091
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001092 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001093
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001094 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001095 case SENSOR_MT9V111:
1096 reg_w1(gspca_dev, 0x01, 0x61);
1097 reg_w1(gspca_dev, 0x17, 0x61);
1098 reg_w1(gspca_dev, 0x01, 0x60);
1099 reg_w1(gspca_dev, 0x01, 0x40);
1100 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001101 case SENSOR_OM6802:
Jean-Francois Moine4f30f6c2008-09-03 16:48:05 -03001102 reg_w1(gspca_dev, 0x02, 0x71);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001103 reg_w1(gspca_dev, 0x01, 0x42);
1104 reg_w1(gspca_dev, 0x17, 0x64);
1105 reg_w1(gspca_dev, 0x01, 0x42);
1106 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001107/*jfm: from win trace */
1108 case SENSOR_OV7630:
1109 reg_w1(gspca_dev, 0x01, 0x61);
1110 reg_w1(gspca_dev, 0x17, 0xe2);
1111 reg_w1(gspca_dev, 0x01, 0x60);
1112 reg_w1(gspca_dev, 0x01, 0x40);
1113 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001114 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001115 reg_w1(gspca_dev, 0x01, 0x63);
1116 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001117 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001118 break;
Jean-Francois Moine91de65a2008-09-03 17:12:18 -03001119/*jfm: from win trace */
1120 case SENSOR_OV7660:
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001121 if (sd->bridge == BRIDGE_SN9C120) {
1122 reg_w1(gspca_dev, 0x01, 0x61);
1123 reg_w1(gspca_dev, 0x17, 0x20);
1124 reg_w1(gspca_dev, 0x01, 0x60);
1125 reg_w1(gspca_dev, 0x01, 0x40);
1126 break;
1127 }
1128 /* fall thru */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001129 case SENSOR_SP80708:
1130 reg_w1(gspca_dev, 0x01, 0x63);
1131 reg_w1(gspca_dev, 0x17, 0x20);
1132 reg_w1(gspca_dev, 0x01, 0x62);
1133 reg_w1(gspca_dev, 0x01, 0x42);
1134 mdelay(100);
1135 reg_w1(gspca_dev, 0x02, 0x62);
1136 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001137 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001138 reg_w1(gspca_dev, 0x01, 0x43);
1139 reg_w1(gspca_dev, 0x17, 0x61);
1140 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001141 if (sd->sensor == SENSOR_HV7131R) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001142 if (hv7131r_probe(gspca_dev) < 0)
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001143 return -ENODEV;
1144 }
1145 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001146 }
1147 return 0;
1148}
1149
1150static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
1151{
1152 int i = 0;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001153 static const u8 SetSensorClk[] = /* 0x08 Mclk */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001154 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
1155
1156 while (hv7131r_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001157 i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001158 i++;
1159 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001160 i2c_w8(gspca_dev, SetSensorClk);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001161}
1162
1163static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
1164{
1165 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001166
1167 while (mi0360_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001168 i2c_w8(gspca_dev, mi0360_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001169 i++;
1170 }
1171}
1172
1173static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
1174{
1175 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001176
1177 while (mo4000_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001178 i2c_w8(gspca_dev, mo4000_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001179 i++;
1180 }
1181}
1182
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001183static void mt9v111_InitSensor(struct gspca_dev *gspca_dev)
1184{
1185 int i = 0;
1186
1187 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1188 i++;
1189 msleep(20);
1190 while (mt9v111_sensor_init[i][0]) {
1191 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1192 i++;
1193 }
1194}
1195
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001196static void om6802_InitSensor(struct gspca_dev *gspca_dev)
1197{
1198 int i = 0;
1199
1200 while (om6802_sensor_init[i][0]) {
1201 i2c_w8(gspca_dev, om6802_sensor_init[i]);
1202 i++;
1203 }
1204}
1205
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001206static void ov7630_InitSensor(struct gspca_dev *gspca_dev)
1207{
1208 int i = 0;
1209
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001210 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */
1211 i++;
1212 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001213 i++;
1214 msleep(20);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001215 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1216 i++;
1217 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */
1218 i++;
1219 msleep(20);
1220 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1221 i++;
1222/*jfm:win i2c_r from 00 to 80*/
1223
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001224 while (ov7630_sensor_init[i][0]) {
1225 i2c_w8(gspca_dev, ov7630_sensor_init[i]);
1226 i++;
1227 }
1228}
1229
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001230static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
1231{
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001232 int i = 0;
1233
Jean-Francois Moine62703302008-11-11 08:42:56 -03001234 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
1235 i++;
1236/* win: dble reset */
1237 i2c_w8(gspca_dev, ov7648_sensor_init[i]); /* reset */
1238 i++;
1239 msleep(20);
1240/* win: i2c reg read 00..7f */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001241 while (ov7648_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001242 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001243 i++;
1244 }
1245}
1246
1247static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
1248{
1249 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001250
Jean-Francois Moine60017612008-07-18 08:46:19 -03001251 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
1252 i++;
1253 msleep(20);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001254 while (ov7660_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001255 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001256 i++;
1257 }
1258}
1259
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001260static void sp80708_InitSensor(struct gspca_dev *gspca_dev)
1261{
1262 int i = 0;
1263
1264 i2c_w8(gspca_dev, sp80708_sensor_init[i]); /* reset SCCB */
1265 i++;
1266 msleep(20);
1267 while (sp80708_sensor_init[i][0]) {
1268 i2c_w8(gspca_dev, sp80708_sensor_init[i]);
1269 i++;
1270 }
1271}
1272
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001273/* this function is called at probe time */
1274static int sd_config(struct gspca_dev *gspca_dev,
1275 const struct usb_device_id *id)
1276{
1277 struct sd *sd = (struct sd *) gspca_dev;
1278 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001279
1280 cam = &gspca_dev->cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001281 cam->cam_mode = vga_mode;
1282 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001283 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001284
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03001285 sd->bridge = id->driver_info >> 16;
1286 sd->sensor = id->driver_info >> 8;
1287 sd->i2c_base = id->driver_info;
1288
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001289 sd->brightness = BRIGHTNESS_DEF;
1290 sd->contrast = CONTRAST_DEF;
1291 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001292 sd->blue = BLUE_BALANCE_DEF;
1293 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001294 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001295 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001296 sd->ag_cnt = -1;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001297 if (sd->sensor != SENSOR_OV7630)
1298 sd->vflip = 0;
1299 else
1300 sd->vflip = 1;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001301 sd->infrared = INFRARED_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001302 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001303 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001304
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001305 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001306 return 0;
1307}
1308
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001309/* this function is called at probe and resume time */
1310static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001311{
1312 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001313 u8 regGpio[] = { 0x29, 0x74 };
1314 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001315
Hans de Goede3647fea2008-07-15 05:36:30 -03001316 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001317 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001318 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001319 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1320 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001321 regF1 = gspca_dev->usb_buf[0];
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001322 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001323 switch (sd->bridge) {
1324 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001325 if (regF1 != 0x11)
1326 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001327 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001328 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001329 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001330 if (regF1 != 0x11)
1331 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001332 if (sd->sensor == SENSOR_MI0360)
1333 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001334 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001335 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001336 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001337 if (regF1 != 0x12)
1338 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001339 if (sd->sensor == SENSOR_MI0360)
1340 mi0360_probe(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001341 regGpio[1] = 0x70;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001342 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001343 break;
1344 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001345/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001346/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001347 if (regF1 != 0x12)
1348 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001349 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001350 break;
1351 }
1352
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001353 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001354
1355 return 0;
1356}
1357
Jean-Francois Moine98819182009-01-19 07:37:33 -03001358static u32 setexposure(struct gspca_dev *gspca_dev,
1359 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001360{
1361 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001362
1363 switch (sd->sensor) {
1364 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001365 u8 Expodoit[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001366 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1367
1368 Expodoit[3] = expo >> 16;
1369 Expodoit[4] = expo >> 8;
1370 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001371 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001372 break;
1373 }
1374 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001375 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001376 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001377 static const u8 doit[] = /* update sensor */
1378 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1379 static const u8 sensorgo[] = /* sensor on */
1380 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001381
1382 if (expo > 0x0635)
1383 expo = 0x0635;
1384 else if (expo < 0x0001)
1385 expo = 0x0001;
1386 expoMi[3] = expo >> 8;
1387 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001388 i2c_w8(gspca_dev, expoMi);
1389 i2c_w8(gspca_dev, doit);
1390 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001391 break;
1392 }
1393 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001394 u8 expoMof[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001395 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001396 u8 expoMo10[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001397 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001398 static const u8 gainMo[] =
1399 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001400
1401 if (expo > 0x1fff)
1402 expo = 0x1fff;
1403 else if (expo < 0x0001)
1404 expo = 0x0001;
1405 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001406 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001407 expoMo10[3] = ((expo & 0x1c00) >> 10)
1408 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001409 i2c_w8(gspca_dev, expoMo10);
1410 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001411 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001412 ((expoMo10[3] & 0x07) << 10)
1413 | (expoMof[3] << 2)
1414 | ((expoMo10[3] & 0x30) >> 4));
1415 break;
1416 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001417 case SENSOR_MT9V111: {
1418 u8 expo_c1[] =
1419 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1420
1421 if (expo > 0x0280)
1422 expo = 0x0280;
1423 else if (expo < 0x0040)
1424 expo = 0x0040;
1425 expo_c1[3] = expo >> 8;
1426 expo_c1[4] = expo;
1427 i2c_w8(gspca_dev, expo_c1);
1428 break;
1429 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001430 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001431 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001432 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1433
1434 if (expo > 0x03ff)
1435 expo = 0x03ff;
1436 if (expo < 0x0001)
1437 expo = 0x0001;
1438 gainOm[3] = expo >> 2;
1439 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001440 reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001441 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001442 break;
1443 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001444 }
1445 return expo;
1446}
1447
1448static void setbrightness(struct gspca_dev *gspca_dev)
1449{
1450 struct sd *sd = (struct sd *) gspca_dev;
1451 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001452 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001453
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001454 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001455 switch (sd->sensor) {
1456 case SENSOR_HV7131R:
1457 expo = sd->brightness << 4;
1458 if (expo > 0x002dc6c0)
1459 expo = 0x002dc6c0;
1460 else if (expo < 0x02a0)
1461 expo = 0x02a0;
1462 sd->exposure = setexposure(gspca_dev, expo);
1463 break;
1464 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001465 case SENSOR_MO4000:
1466 expo = sd->brightness >> 4;
1467 sd->exposure = setexposure(gspca_dev, expo);
1468 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001469 case SENSOR_MT9V111:
1470 expo = sd->brightness >> 8;
1471 sd->exposure = setexposure(gspca_dev, expo);
1472 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001473 case SENSOR_OM6802:
1474 expo = sd->brightness >> 6;
1475 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001476 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001477 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001478 }
1479
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001480 if (sd->sensor != SENSOR_MT9V111)
1481 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001482}
1483
1484static void setcontrast(struct gspca_dev *gspca_dev)
1485{
1486 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001487 u8 k2;
1488 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001489
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001490 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1491 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001492 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001493 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001494 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001495 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001496 contrast[5] = 0;
1497 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001498}
1499
1500static void setcolors(struct gspca_dev *gspca_dev)
1501{
1502 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001503 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001504 u8 reg8a[12]; /* U & V gains */
1505 static s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001506 -24, -38, 64, /* UR UG UB */
1507 62, -51, -9 /* VR VG VB */
1508 };
1509 for (i = 0; i < 6; i++) {
1510 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001511 reg8a[i * 2] = v;
1512 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001513 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001514 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001515}
1516
1517static void setredblue(struct gspca_dev *gspca_dev)
1518{
1519 struct sd *sd = (struct sd *) gspca_dev;
1520
1521 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001522/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001523 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001524}
1525
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001526static void setgamma(struct gspca_dev *gspca_dev)
1527{
1528 struct sd *sd = (struct sd *) gspca_dev;
1529 int i;
1530 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001531 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001532 static const u8 delta[17] = {
1533 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1534 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1535 };
1536
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001537 switch (sd->sensor) {
1538 case SENSOR_HV7131R:
1539 case SENSOR_MT9V111:
1540 gamma_base = gamma_spec_1;
1541 break;
1542 case SENSOR_SP80708:
1543 gamma_base = gamma_spec_2;
1544 break;
1545 default:
1546 gamma_base = gamma_def;
1547 break;
1548 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001549
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001550 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001551 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001552 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1553 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1554}
1555
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001556static void setautogain(struct gspca_dev *gspca_dev)
1557{
1558 struct sd *sd = (struct sd *) gspca_dev;
1559
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001560 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
1561 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001562 switch (sd->sensor) {
1563 case SENSOR_OV7630:
1564 case SENSOR_OV7648: {
1565 u8 comb;
1566
1567 if (sd->sensor == SENSOR_OV7630)
1568 comb = 0xc0;
1569 else
1570 comb = 0xa0;
1571 if (sd->autogain)
1572 comb |= 0x02;
1573 i2c_w1(&sd->gspca_dev, 0x13, comb);
1574 return;
1575 }
1576 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001577 if (sd->autogain)
1578 sd->ag_cnt = AG_CNT_START;
1579 else
1580 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001581}
1582
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001583/* ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001584static void setvflip(struct sd *sd)
1585{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001586 u8 comn;
1587
1588 if (sd->sensor == SENSOR_OV7630)
1589 comn = 0x02;
1590 else
1591 comn = 0x06;
1592 if (sd->vflip)
1593 comn |= 0x80;
1594 i2c_w1(&sd->gspca_dev, 0x75, comn);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001595}
1596
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001597static void setinfrared(struct sd *sd)
1598{
1599/*fixme: different sequence for StarCam Clip and StarCam 370i */
1600/* Clip */
1601 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
1602 sd->infrared ? 0x66 : 0x64);
1603}
1604
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001605static void setjpegqual(struct gspca_dev *gspca_dev)
1606{
1607 struct sd *sd = (struct sd *) gspca_dev;
1608 int i, sc;
1609
1610 if (sd->jpegqual < 50)
1611 sc = 5000 / sd->jpegqual;
1612 else
1613 sc = 200 - sd->jpegqual * 2;
1614#if USB_BUF_SZ < 64
1615#error "No room enough in usb_buf for quantization table"
1616#endif
1617 for (i = 0; i < 64; i++)
1618 gspca_dev->usb_buf[i] =
1619 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1620 usb_control_msg(gspca_dev->dev,
1621 usb_sndctrlpipe(gspca_dev->dev, 0),
1622 0x08,
1623 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1624 0x0100, 0,
1625 gspca_dev->usb_buf, 64,
1626 500);
1627 for (i = 0; i < 64; i++)
1628 gspca_dev->usb_buf[i] =
1629 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1630 usb_control_msg(gspca_dev->dev,
1631 usb_sndctrlpipe(gspca_dev->dev, 0),
1632 0x08,
1633 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1634 0x0140, 0,
1635 gspca_dev->usb_buf, 64,
1636 500);
1637
1638 sd->reg18 ^= 0x40;
1639 reg_w1(gspca_dev, 0x18, sd->reg18);
1640}
1641
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001642/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001643static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001644{
1645 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001646 int i;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001647 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001648 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001649 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001650 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1651 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1652 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1653 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001654 { 0x32, 0xdd, 0x32, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001655
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001656 /* create the JPEG header */
1657 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
1658 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1659 0x21); /* JPEG 422 */
1660 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1661
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001662 sn9c1xx = sn_tb[(int) sd->sensor];
1663 configure_gpio(gspca_dev, sn9c1xx);
1664
Jean-Francois Moine60017612008-07-18 08:46:19 -03001665 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1666 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1667 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1668 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1669 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1670 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1671 reg_w1(gspca_dev, 0xd3, 0x50);
1672 reg_w1(gspca_dev, 0xc6, 0x00);
1673 reg_w1(gspca_dev, 0xc7, 0x00);
1674 reg_w1(gspca_dev, 0xc8, 0x50);
1675 reg_w1(gspca_dev, 0xc9, 0x3c);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001676 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001677 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001678 case SENSOR_MT9V111:
1679 reg17 = 0xe0;
1680 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001681 case SENSOR_OV7630:
1682 reg17 = 0xe2;
1683 break;
1684 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001685 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001686 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001687/*jfm: from win trace */
1688 case SENSOR_OV7660:
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001689 if (sd->bridge == BRIDGE_SN9C120) {
1690 reg17 = 0xa0;
1691 break;
1692 }
1693 /* fall thru */
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001694 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001695 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001696 break;
1697 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001698 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001699/* set reg1 was here */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001700 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1701 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1702 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001703 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001704
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001705 setgamma(gspca_dev);
1706
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001707 for (i = 0; i < 8; i++)
1708 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001709 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001710 case SENSOR_MT9V111:
1711 reg_w1(gspca_dev, 0x9a, 0x07);
1712 reg_w1(gspca_dev, 0x99, 0x59);
1713 break;
Jean-Francois Moine62703302008-11-11 08:42:56 -03001714 case SENSOR_OV7648:
1715 reg_w1(gspca_dev, 0x9a, 0x0a);
1716 reg_w1(gspca_dev, 0x99, 0x60);
1717 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001718 case SENSOR_SP80708:
1719 reg_w1(gspca_dev, 0x9a, 0x05);
1720 reg_w1(gspca_dev, 0x99, 0x59);
1721 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001722 case SENSOR_OV7660:
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001723 if (sd->bridge == BRIDGE_SN9C120) {
1724 reg_w1(gspca_dev, 0x9a, 0x05);
1725 break;
1726 }
1727 /* fall thru */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001728 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001729 reg_w1(gspca_dev, 0x9a, 0x08);
1730 reg_w1(gspca_dev, 0x99, 0x59);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001731 break;
1732 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001733
Jean-Francois Moinec2446b32008-07-05 11:49:20 -03001734 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001735 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001736 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001737 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001738 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1739 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001740 switch (sd->sensor) {
1741 case SENSOR_HV7131R:
1742 hv7131R_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001743 break;
1744 case SENSOR_MI0360:
1745 mi0360_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001746 break;
1747 case SENSOR_MO4000:
1748 mo4000_InitSensor(gspca_dev);
1749 if (mode) {
1750/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1751 reg1 = 0x06; /* clk 24Mz */
1752 } else {
1753 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001754/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001755 }
1756 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001757 case SENSOR_MT9V111:
1758 mt9v111_InitSensor(gspca_dev);
1759 if (mode) {
1760 reg1 = 0x04; /* 320 clk 48Mhz */
1761 } else {
1762/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03001763 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001764 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03001765 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001766 case SENSOR_OM6802:
1767 om6802_InitSensor(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001768 reg17 = 0x64; /* 640 MCKSIZE */
1769 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001770 case SENSOR_OV7630:
1771 ov7630_InitSensor(gspca_dev);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001772 setvflip(sd);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001773 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03001774 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001775 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001776 case SENSOR_OV7648:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001777 ov7648_InitSensor(gspca_dev);
Jean-Francois Moine62703302008-11-11 08:42:56 -03001778 reg17 = 0x21;
1779/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001780 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001781 case SENSOR_OV7660:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001782 ov7660_InitSensor(gspca_dev);
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001783 if (sd->bridge == BRIDGE_SN9C120) {
1784 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001785 reg17 = 0xa2;
1786 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001787 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001788 } else {
1789 reg17 = 0x22;
1790 reg1 = 0x06; /* 24 Mhz, video trf eneble
1791 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001792 }
1793 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001794 default:
1795/* case SENSOR_SP80708: */
1796 sp80708_InitSensor(gspca_dev);
1797 if (mode) {
1798/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001799 } else {
1800 reg1 = 0x46; /* 640 clk 48Mz */
1801 reg17 = 0xa2;
1802 }
1803 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001804 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001805 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001806 reg_w(gspca_dev, 0xca, CA, 4);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001807 switch (sd->sensor) {
1808 case SENSOR_OV7630:
1809 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001810 case SENSOR_OV7660:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001811 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001812 break;
1813 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001814 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001815 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1816 break;
1817 }
1818
1819 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001820 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
1821 reg_w1(gspca_dev, 0x18, sd->reg18);
1822 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001823
Jean-Francois Moine60017612008-07-18 08:46:19 -03001824 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001825 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001826 switch (sd->sensor) {
Jean-Francois Moine79a90982008-10-05 04:21:24 -03001827 case SENSOR_OV7630:
1828 setvflip(sd);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001829 break;
1830 }
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001831 setbrightness(gspca_dev);
1832 setcontrast(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001833 setautogain(gspca_dev);
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001834 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001835}
1836
1837static void sd_stopN(struct gspca_dev *gspca_dev)
1838{
1839 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001840 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001841 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001842 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001843 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001844 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03001845 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001846 u8 data;
1847 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001848
1849 data = 0x0b;
1850 switch (sd->sensor) {
1851 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001852 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001853 data = 0x2b;
1854 break;
1855 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001856 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001857 data = 0x29;
1858 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001859 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001860 i2c_w8(gspca_dev, stopov7648);
1861 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001862 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001863 case SENSOR_OV7630:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001864 data = 0x29;
1865 break;
1866 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001867/* case SENSOR_MO4000: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001868/* case SENSOR_OV7660: */
1869 break;
1870 }
1871 sn9c1xx = sn_tb[(int) sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03001872 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1873 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1874 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1875 reg_w1(gspca_dev, 0x01, data);
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001876 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001877}
1878
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001879static void sd_stop0(struct gspca_dev *gspca_dev)
1880{
1881 struct sd *sd = (struct sd *) gspca_dev;
1882
1883 kfree(sd->jpeg_hdr);
1884}
1885
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001886static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001887{
1888 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001889 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001890 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001891 u8 luma_mean = 130;
1892 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001893
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001894 /* Thanks S., without your advice, autobright should not work :) */
1895 if (sd->ag_cnt < 0)
1896 return;
1897 if (--sd->ag_cnt >= 0)
1898 return;
1899 sd->ag_cnt = AG_CNT_START;
1900
1901 delta = atomic_read(&sd->avg_lum);
1902 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001903 if (delta < luma_mean - luma_delta ||
1904 delta > luma_mean + luma_delta) {
1905 switch (sd->sensor) {
1906 case SENSOR_HV7131R:
1907 expotimes = sd->exposure >> 8;
1908 expotimes += (luma_mean - delta) >> 4;
1909 if (expotimes < 0)
1910 expotimes = 0;
1911 sd->exposure = setexposure(gspca_dev,
1912 (unsigned int) (expotimes << 8));
1913 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001914 default:
1915/* case SENSOR_MO4000: */
1916/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001917/* case SENSOR_MT9V111: */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001918/* case SENSOR_OM6802: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001919 expotimes = sd->exposure;
1920 expotimes += (luma_mean - delta) >> 6;
1921 if (expotimes < 0)
1922 expotimes = 0;
1923 sd->exposure = setexposure(gspca_dev,
1924 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001925 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001926 break;
1927 }
1928 }
1929}
1930
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001931/* scan the URB packets */
1932/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001933static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1934 struct gspca_frame *frame, /* target */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001935 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001936 int len) /* iso packet length */
1937{
1938 struct sd *sd = (struct sd *) gspca_dev;
1939 int sof, avg_lum;
1940
1941 sof = len - 64;
1942 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
1943
1944 /* end of frame */
1945 gspca_frame_add(gspca_dev, LAST_PACKET,
1946 frame, data, sof + 2);
1947 if (sd->ag_cnt < 0)
1948 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001949/* w1 w2 w3 */
1950/* w4 w5 w6 */
1951/* w7 w8 */
1952/* w4 */
1953 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
1954/* w6 */
1955 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
1956/* w2 */
1957 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
1958/* w8 */
1959 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
1960/* w5 */
1961 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
1962 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001963 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001964 return;
1965 }
1966 if (gspca_dev->last_packet_type == LAST_PACKET) {
1967
1968 /* put the JPEG 422 header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001969 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1970 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001971 }
1972 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1973}
1974
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001975static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1976{
1977 struct sd *sd = (struct sd *) gspca_dev;
1978
1979 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001980 if (gspca_dev->streaming)
1981 setbrightness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001982 return 0;
1983}
1984
1985static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1986{
1987 struct sd *sd = (struct sd *) gspca_dev;
1988
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001989 *val = sd->brightness;
1990 return 0;
1991}
1992
1993static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1994{
1995 struct sd *sd = (struct sd *) gspca_dev;
1996
1997 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001998 if (gspca_dev->streaming)
1999 setcontrast(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002000 return 0;
2001}
2002
2003static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2004{
2005 struct sd *sd = (struct sd *) gspca_dev;
2006
2007 *val = sd->contrast;
2008 return 0;
2009}
2010
2011static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2012{
2013 struct sd *sd = (struct sd *) gspca_dev;
2014
2015 sd->colors = val;
2016 if (gspca_dev->streaming)
2017 setcolors(gspca_dev);
2018 return 0;
2019}
2020
2021static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2022{
2023 struct sd *sd = (struct sd *) gspca_dev;
2024
2025 *val = sd->colors;
2026 return 0;
2027}
2028
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002029static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2030{
2031 struct sd *sd = (struct sd *) gspca_dev;
2032
2033 sd->blue = val;
2034 if (gspca_dev->streaming)
2035 setredblue(gspca_dev);
2036 return 0;
2037}
2038
2039static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2040{
2041 struct sd *sd = (struct sd *) gspca_dev;
2042
2043 *val = sd->blue;
2044 return 0;
2045}
2046
2047static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2048{
2049 struct sd *sd = (struct sd *) gspca_dev;
2050
2051 sd->red = val;
2052 if (gspca_dev->streaming)
2053 setredblue(gspca_dev);
2054 return 0;
2055}
2056
2057static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2058{
2059 struct sd *sd = (struct sd *) gspca_dev;
2060
2061 *val = sd->red;
2062 return 0;
2063}
2064
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002065static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2066{
2067 struct sd *sd = (struct sd *) gspca_dev;
2068
2069 sd->gamma = val;
2070 if (gspca_dev->streaming)
2071 setgamma(gspca_dev);
2072 return 0;
2073}
2074
2075static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2076{
2077 struct sd *sd = (struct sd *) gspca_dev;
2078
2079 *val = sd->gamma;
2080 return 0;
2081}
2082
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002083static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2084{
2085 struct sd *sd = (struct sd *) gspca_dev;
2086
2087 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002088 if (gspca_dev->streaming)
2089 setautogain(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002090 return 0;
2091}
2092
2093static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2094{
2095 struct sd *sd = (struct sd *) gspca_dev;
2096
2097 *val = sd->autogain;
2098 return 0;
2099}
2100
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002101static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2102{
2103 struct sd *sd = (struct sd *) gspca_dev;
2104
2105 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002106 if (gspca_dev->streaming)
2107 setvflip(sd);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002108 return 0;
2109}
2110
2111static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2112{
2113 struct sd *sd = (struct sd *) gspca_dev;
2114
2115 *val = sd->vflip;
2116 return 0;
2117}
2118
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002119static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2120{
2121 struct sd *sd = (struct sd *) gspca_dev;
2122
2123 sd->infrared = val;
2124 if (gspca_dev->streaming)
2125 setinfrared(sd);
2126 return 0;
2127}
2128
2129static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2130{
2131 struct sd *sd = (struct sd *) gspca_dev;
2132
2133 *val = sd->infrared;
2134 return 0;
2135}
2136
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002137static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2138 struct v4l2_jpegcompression *jcomp)
2139{
2140 struct sd *sd = (struct sd *) gspca_dev;
2141
2142 if (jcomp->quality < QUALITY_MIN)
2143 sd->quality = QUALITY_MIN;
2144 else if (jcomp->quality > QUALITY_MAX)
2145 sd->quality = QUALITY_MAX;
2146 else
2147 sd->quality = jcomp->quality;
2148 if (gspca_dev->streaming)
2149 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2150 return 0;
2151}
2152
2153static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2154 struct v4l2_jpegcompression *jcomp)
2155{
2156 struct sd *sd = (struct sd *) gspca_dev;
2157
2158 memset(jcomp, 0, sizeof *jcomp);
2159 jcomp->quality = sd->quality;
2160 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2161 | V4L2_JPEG_MARKER_DQT;
2162 return 0;
2163}
2164
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002165/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002166static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002167 .name = MODULE_NAME,
2168 .ctrls = sd_ctrls,
2169 .nctrls = ARRAY_SIZE(sd_ctrls),
2170 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002171 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002172 .start = sd_start,
2173 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002174 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002175 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002176 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002177 .get_jcomp = sd_get_jcomp,
2178 .set_jcomp = sd_set_jcomp,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002179};
2180
2181/* -- module initialisation -- */
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002182#define BSI(bridge, sensor, i2c_addr) \
2183 .driver_info = (BRIDGE_ ## bridge << 16) \
2184 | (SENSOR_ ## sensor << 8) \
2185 | (i2c_addr)
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002186static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002187#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002188 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
Jean-Francois Moine7b537392008-09-07 11:56:49 -03002189 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002190#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002191 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
2192 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
2193 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine7e21fda2008-11-10 04:45:51 -03002194 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002195 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine3319dc92008-12-01 14:44:02 -03002196 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002197 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
2198/* bw600.inf:
2199 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
2200/* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
2201/* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
2202 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
2203/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
Jean-Francois Moine661ab252009-01-29 16:03:19 -03002204 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002205/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
2206/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2207 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
2208/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2209/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
2210 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
2211 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002212#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2213 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2214#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002215/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
2216/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2217/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002218 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
2219/*bw600.inf:*/
Jean-Francois Moine62703302008-11-11 08:42:56 -03002220 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002221 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002222 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002223/* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03002224#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002225 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002226#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002227 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
Jean-Francois Moine821ced22008-11-11 07:10:11 -03002228 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002229#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002230 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002231#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002232 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
2233/* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002234 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002235 {}
2236};
2237MODULE_DEVICE_TABLE(usb, device_table);
2238
2239/* -- device connect -- */
2240static int sd_probe(struct usb_interface *intf,
2241 const struct usb_device_id *id)
2242{
2243 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2244 THIS_MODULE);
2245}
2246
2247static struct usb_driver sd_driver = {
2248 .name = MODULE_NAME,
2249 .id_table = device_table,
2250 .probe = sd_probe,
2251 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002252#ifdef CONFIG_PM
2253 .suspend = gspca_suspend,
2254 .resume = gspca_resume,
2255#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002256};
2257
2258/* -- module insert / remove -- */
2259static int __init sd_mod_init(void)
2260{
Alexey Klimovf69e9522009-01-01 13:02:07 -03002261 int ret;
2262 ret = usb_register(&sd_driver);
2263 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -03002264 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -03002265 info("registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002266 return 0;
2267}
2268static void __exit sd_mod_exit(void)
2269{
2270 usb_deregister(&sd_driver);
2271 info("deregistered");
2272}
2273
2274module_init(sd_mod_init);
2275module_exit(sd_mod_exit);