blob: d6332ab80669218cdfa1d5b0fdd3a61874be9fc5 [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 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -030049 u8 freq; /* ov76xx only */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030050 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030051#define QUALITY_MIN 60
52#define QUALITY_MAX 95
53#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030054 u8 jpegqual; /* webcam quality */
55
56 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030057
Jean-Francois Moine98819182009-01-19 07:37:33 -030058 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030059#define AG_CNT_START 13
60
Jean-Francois Moine98819182009-01-19 07:37:33 -030061 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030062#define BRIDGE_SN9C102P 0
63#define BRIDGE_SN9C105 1
64#define BRIDGE_SN9C110 2
65#define BRIDGE_SN9C120 3
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);
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300100static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
101static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300102
103static struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300104#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300105 {
106 {
107 .id = V4L2_CID_BRIGHTNESS,
108 .type = V4L2_CTRL_TYPE_INTEGER,
109 .name = "Brightness",
110 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300111#define BRIGHTNESS_MAX 0xffff
112 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300113 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300114#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300115 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300116 },
117 .set = sd_setbrightness,
118 .get = sd_getbrightness,
119 },
Hans de Goede97643982009-06-18 05:08:11 -0300120#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300121 {
122 {
123 .id = V4L2_CID_CONTRAST,
124 .type = V4L2_CTRL_TYPE_INTEGER,
125 .name = "Contrast",
126 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300127#define CONTRAST_MAX 127
128 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300129 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300130#define CONTRAST_DEF 63
131 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 },
133 .set = sd_setcontrast,
134 .get = sd_getcontrast,
135 },
Hans de Goede97643982009-06-18 05:08:11 -0300136#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300137 {
138 {
139 .id = V4L2_CID_SATURATION,
140 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300141 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300143 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300144 .step = 1,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300145#define COLOR_DEF 25
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300146 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300147 },
148 .set = sd_setcolors,
149 .get = sd_getcolors,
150 },
Hans de Goede97643982009-06-18 05:08:11 -0300151#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300152 {
153 {
154 .id = V4L2_CID_BLUE_BALANCE,
155 .type = V4L2_CTRL_TYPE_INTEGER,
156 .name = "Blue Balance",
157 .minimum = 24,
158 .maximum = 40,
159 .step = 1,
160#define BLUE_BALANCE_DEF 32
161 .default_value = BLUE_BALANCE_DEF,
162 },
163 .set = sd_setblue_balance,
164 .get = sd_getblue_balance,
165 },
Hans de Goede97643982009-06-18 05:08:11 -0300166#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300167 {
168 {
169 .id = V4L2_CID_RED_BALANCE,
170 .type = V4L2_CTRL_TYPE_INTEGER,
171 .name = "Red Balance",
172 .minimum = 24,
173 .maximum = 40,
174 .step = 1,
175#define RED_BALANCE_DEF 32
176 .default_value = RED_BALANCE_DEF,
177 },
178 .set = sd_setred_balance,
179 .get = sd_getred_balance,
180 },
Hans de Goede97643982009-06-18 05:08:11 -0300181#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300182 {
183 {
184 .id = V4L2_CID_GAMMA,
185 .type = V4L2_CTRL_TYPE_INTEGER,
186 .name = "Gamma",
187 .minimum = 0,
188 .maximum = 40,
189 .step = 1,
190#define GAMMA_DEF 20
191 .default_value = GAMMA_DEF,
192 },
193 .set = sd_setgamma,
194 .get = sd_getgamma,
195 },
Hans de Goede97643982009-06-18 05:08:11 -0300196#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300197 {
198 {
199 .id = V4L2_CID_AUTOGAIN,
200 .type = V4L2_CTRL_TYPE_BOOLEAN,
201 .name = "Auto Gain",
202 .minimum = 0,
203 .maximum = 1,
204 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300205#define AUTOGAIN_DEF 1
206 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300207 },
208 .set = sd_setautogain,
209 .get = sd_getautogain,
210 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300211/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300212#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300213 {
214 {
215 .id = V4L2_CID_VFLIP,
216 .type = V4L2_CTRL_TYPE_BOOLEAN,
217 .name = "Vflip",
218 .minimum = 0,
219 .maximum = 1,
220 .step = 1,
Hans de Goedef8009522009-06-18 14:29:20 -0300221#define VFLIP_DEF 0
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300222 .default_value = VFLIP_DEF,
223 },
224 .set = sd_setvflip,
225 .get = sd_getvflip,
226 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300227/* mt9v111 only */
Hans de Goede97643982009-06-18 05:08:11 -0300228#define INFRARED_IDX 8
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300229 {
230 {
231 .id = V4L2_CID_INFRARED,
232 .type = V4L2_CTRL_TYPE_BOOLEAN,
233 .name = "Infrared",
234 .minimum = 0,
235 .maximum = 1,
236 .step = 1,
237#define INFRARED_DEF 0
238 .default_value = INFRARED_DEF,
239 },
240 .set = sd_setinfrared,
241 .get = sd_getinfrared,
242 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300243/* ov7630/ov7648/ov7660 only */
244#define FREQ_IDX 9
245 {
246 {
247 .id = V4L2_CID_POWER_LINE_FREQUENCY,
248 .type = V4L2_CTRL_TYPE_MENU,
249 .name = "Light frequency filter",
250 .minimum = 0,
251 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
252 .step = 1,
253#define FREQ_DEF 2
254 .default_value = FREQ_DEF,
255 },
256 .set = sd_setfreq,
257 .get = sd_getfreq,
258 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300259};
260
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300261/* table of the disabled controls */
262static __u32 ctrl_dis[] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300263 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300264 /* SENSOR_HV7131R 0 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300265 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300266 /* SENSOR_MI0360 1 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300267 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300268 /* SENSOR_MO4000 2 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300269 (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300270 /* SENSOR_MT9V111 3 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300271 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300272 /* SENSOR_OM6802 4 */
Hans de Goede1fec7472009-06-18 06:05:07 -0300273 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300274 /* SENSOR_OV7630 5 */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300275 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300276 /* SENSOR_OV7648 6 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300277 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300278 /* SENSOR_OV7660 7 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300279 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
280 (1 << FREQ_IDX), /* SENSOR_SP80708 8 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300281};
282
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300283static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300284 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
285 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300286 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300287 .colorspace = V4L2_COLORSPACE_JPEG,
288 .priv = 2},
289 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
290 .bytesperline = 320,
291 .sizeimage = 320 * 240 * 3 / 8 + 590,
292 .colorspace = V4L2_COLORSPACE_JPEG,
293 .priv = 1},
294 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
295 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300296 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
297 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300298 .colorspace = V4L2_COLORSPACE_JPEG,
299 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300300};
301
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300302/*Data from sn9c102p+hv7131r */
303static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300304/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
305 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
306/* reg8 reg9 rega regb regc regd rege regf */
307 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
308/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
309 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300310/* reg18 reg19 reg1a reg1b */
311 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300312};
313
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300314static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300315/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
316 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
317/* reg8 reg9 rega regb regc regd rege regf */
318 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
319/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
320 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300321/* reg18 reg19 reg1a reg1b */
322 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300323};
324
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300325static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300326/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300327 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300328/* reg8 reg9 rega regb regc regd rege regf */
329 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
331 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300332/* reg18 reg19 reg1a reg1b */
333 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300334};
335
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300336static const u8 sn_mt9v111[0x1c] = {
337/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
338 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
339/* reg8 reg9 rega regb regc regd rege regf */
340 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
341/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
342 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
343/* reg18 reg19 reg1a reg1b */
344 0x06, 0x00, 0x00, 0x00
345};
346
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300347static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300348/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
349 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
350/* reg8 reg9 rega regb regc regd rege regf */
351 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
353 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300354/* reg18 reg19 reg1a reg1b */
355 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300356};
357
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300358static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300359/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
360 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
361/* reg8 reg9 rega regb regc regd rege regf */
362 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
363/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
364 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300365/* reg18 reg19 reg1a reg1b */
366 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300367};
368
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300369static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300370/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300371 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300372/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300373 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300374/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300375 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300376/* reg18 reg19 reg1a reg1b */
377 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300378};
379
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300380static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300381/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -0300382 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300383/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -0300384 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300385/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
386 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300387/* reg18 reg19 reg1a reg1b */
388 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300389};
390
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300391static const u8 sn_sp80708[0x1c] = {
392/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
393 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
394/* reg8 reg9 rega regb regc regd rege regf */
395 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
396/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
397 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
398/* reg18 reg19 reg1a reg1b */
399 0x07, 0x00, 0x00, 0x00
400};
401
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300402/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300403static const u8 *sn_tb[] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300404 sn_hv7131,
405 sn_mi0360,
406 sn_mo4000,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300407 sn_mt9v111,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300408 sn_om6802,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300409 sn_ov7630,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300410 sn_ov7648,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300411 sn_ov7660,
412 sn_sp80708
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300413};
414
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300415/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300416static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300417 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
418 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
419};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300420/* gamma for sensors HV7131R and MT9V111 */
421static const u8 gamma_spec_1[17] = {
422 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
423 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
424};
425/* gamma for sensor SP80708 */
426static const u8 gamma_spec_2[17] = {
427 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
428 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
429};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300430
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300431/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300432static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300433 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
434 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
435 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
436 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300437};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300438static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300439 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
440 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
441 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
442/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
443 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
444 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
445/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300446
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300447 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
448 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
449 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
450 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
451 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
452 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
453 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
454 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300455
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300456 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
457 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
458 {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
459 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
460 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300461
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300462 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
463 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
464 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
465 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
466 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300467 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300468};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300469static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300470 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300471 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300472 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300473 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
474 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
475 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
476 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
477 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
478 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
479 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
480 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
482 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
483 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
484 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
485 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
486 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
487 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
488 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
489 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
490 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
491 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300492 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300493 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
494 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
495 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
496 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
497 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
498 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
499 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
500 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
502 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300503
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300504 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
505 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
506 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
507 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
508 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300509
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300510 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
511 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
512 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
513 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300514
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300515 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
516 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
517/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
518/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
519 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
520 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300521 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300522};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300523static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300524 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
525 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
526 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
527 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
528 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
529 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
530 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
531 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
532 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
533 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
534 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
535 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
536 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
537 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
538 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
539 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
540 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
541 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
542 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
543 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300544 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300545};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300546static const u8 mt9v111_sensor_init[][8] = {
547 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
548 /* delay 20 ms */
549 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
550 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
551 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
552 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300553 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
554 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
555 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
556 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300557 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300558 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
559 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
560 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
561 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
562 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300563 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300564 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300565 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
566 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
567 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
568 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
569 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
570 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
571 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
572 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
573 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
574 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
575 /*******/
576 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
577 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300578 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300579 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
580 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
581 /*******/
582 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
583 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
584 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
585 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
586 {}
587};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300588static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300589 {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
590 {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
591 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
592 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
593/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
594 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
595 /* white balance & auto-exposure */
596/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
597 * set color mode */
598/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
599 * max AGC value in AE */
600/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
601 * preset AGC */
602/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
603 * preset brightness */
604/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
605 * preset contrast */
606/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
607 * preset gamma */
608 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
609 /* luminance mode (0x4f = AE) */
610 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
611 /* preset shutter */
612/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
613 * auto frame rate */
614/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
615
616/* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
617/* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
618/* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
619/* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
620 {}
621};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300622static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300623 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
624 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
625/* win: delay 20ms */
626 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
627 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
628/* win: delay 20ms */
629 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300630/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300631 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
632 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300633/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
634 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
635 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300636 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
637 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
638 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
639 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
640 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
641 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
642 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
643 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
644 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
645 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
646 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
648 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
650 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
651 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
652 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
653 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
654 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
655 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
656 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
657 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
658 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
659/* */
660 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
661 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
662/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300663/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
664 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300665 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
666 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
667 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300668/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300669/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
670/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300671/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300672 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300673/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300674 {}
675};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300676
Jean-Francois Moine98819182009-01-19 07:37:33 -0300677static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300678 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
679 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
680 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
681 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
682 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
683 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
684 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
685 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
687 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
688 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
689 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
690 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
691 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
692 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
693 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
694 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
695 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
696 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
697 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
698 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
699
700 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
701/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
702/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300703/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300704/*...*/
705/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300706/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
707 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300708 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
709 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
710/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
711/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
712/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
713/*...*/
714 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
715/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
716/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
717/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
718/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
719/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
720
721 {}
722};
723
Jean-Francois Moine98819182009-01-19 07:37:33 -0300724static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300725 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine60017612008-07-18 08:46:19 -0300726/* (delay 20ms) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300727 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300728 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300729 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300730 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300731 /* GAIN BLUE RED VREF */
732 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
733 /* COM 1 BAVE GEAVE AECHH */
734 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
735 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300736 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300737 /* AECH CLKRC COM7 COM8 */
738 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
739 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
740 /* HSTART HSTOP VSTRT VSTOP */
741 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
742 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
743 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
744 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300745/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
746 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300747 /* AEW AEB VPT BBIAS */
748 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
749 /* GbBIAS RSVD EXHCH EXHCL */
750 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
751 /* RBIAS ADVFL ASDVFH YAVE */
752 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
753 /* HSYST HSYEN HREF */
754 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
755 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
756 /* ADC ACOM OFON TSLB */
757 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
758 /* COM11 COM12 COM13 COM14 */
759 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
760 /* EDGE COM15 COM16 COM17 */
761 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
762 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
763 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
764 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
765 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
766 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
767 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
768 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
769 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
770 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
771 /* LCC1 LCC2 LCC3 LCC4 */
772 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300773 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300774 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300775 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300776 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
777 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
778 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
779 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
780 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
781 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
782 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
783 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
784 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300785 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -0300786 {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300787/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300788 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300789 /* bits[3..0]reserved */
790 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
791 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
792 /* VREF vertical frame ctrl */
793 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300794 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
795 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
796 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
797 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
798/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300799/****** (some exchanges in the win trace) ******/
800 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300801 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
802 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
803 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
804/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300805/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300806/******!! startsensor KO if changed !!****/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300807 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
809 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
810 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300811 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300812};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300813
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300814static const u8 sp80708_sensor_init[][8] = {
815 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
816 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
817 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
818 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
819 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
820 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
860 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
866 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
867 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
869 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
870 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
871 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
872 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
873 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
874 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
875 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
876 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
877 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
878 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
879 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
880 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
881 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
882 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
884 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
885 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
886 /********/
887 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
888 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
889 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
890 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
891 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
892 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
893 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
894 {}
895};
896
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300897/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300898static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300899 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300900{
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300901#ifdef GSPCA_DEBUG
902 if (len > USB_BUF_SZ) {
903 err("reg_r: buffer overflow");
904 return;
905 }
906#endif
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300907 usb_control_msg(gspca_dev->dev,
908 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300909 0,
910 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
911 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300912 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300913 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300914 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300915}
916
Jean-Francois Moine60017612008-07-18 08:46:19 -0300917static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300918 u16 value,
919 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -0300920{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300921 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -0300922 gspca_dev->usb_buf[0] = data;
923 usb_control_msg(gspca_dev->dev,
924 usb_sndctrlpipe(gspca_dev->dev, 0),
925 0x08,
926 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
927 value,
928 0,
929 gspca_dev->usb_buf, 1,
930 500);
931}
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300932static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300933 u16 value,
934 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300935 int len)
936{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300937 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -0300938 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300939#ifdef GSPCA_DEBUG
940 if (len > USB_BUF_SZ) {
941 err("reg_w: buffer overflow");
942 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -0300943 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -0300944#endif
945 memcpy(gspca_dev->usb_buf, buffer, len);
946 usb_control_msg(gspca_dev->dev,
947 usb_sndctrlpipe(gspca_dev->dev, 0),
948 0x08,
949 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
950 value, 0,
951 gspca_dev->usb_buf, len,
952 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300953}
954
Jean-Francois Moine60017612008-07-18 08:46:19 -0300955/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300956static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300957{
958 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300959
Jean-Francois Moine60017612008-07-18 08:46:19 -0300960 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
961 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
962 gspca_dev->usb_buf[1] = sd->i2c_base;
963 gspca_dev->usb_buf[2] = reg;
964 gspca_dev->usb_buf[3] = val;
965 gspca_dev->usb_buf[4] = 0;
966 gspca_dev->usb_buf[5] = 0;
967 gspca_dev->usb_buf[6] = 0;
968 gspca_dev->usb_buf[7] = 0x10;
969 usb_control_msg(gspca_dev->dev,
970 usb_sndctrlpipe(gspca_dev->dev, 0),
971 0x08,
972 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
973 0x08, /* value = i2c */
974 0,
975 gspca_dev->usb_buf, 8,
976 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300977}
978
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300979/* I2C write 8 bytes */
980static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -0300981 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300982{
Jean-Francois Moine60017612008-07-18 08:46:19 -0300983 memcpy(gspca_dev->usb_buf, buffer, 8);
984 usb_control_msg(gspca_dev->dev,
985 usb_sndctrlpipe(gspca_dev->dev, 0),
986 0x08,
987 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
988 0x08, 0, /* value, index */
989 gspca_dev->usb_buf, 8,
990 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -0300991 msleep(2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300992}
993
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300994/* read 5 bytes in gspca_dev->usb_buf */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300995static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300996{
997 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -0300998 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300999
Hans de Goede3647fea2008-07-15 05:36:30 -03001000 mode[0] = 0x81 | 0x10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001001 mode[1] = sd->i2c_base;
1002 mode[2] = reg;
1003 mode[3] = 0;
1004 mode[4] = 0;
1005 mode[5] = 0;
1006 mode[6] = 0;
1007 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001008 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001009 msleep(2);
Hans de Goede3647fea2008-07-15 05:36:30 -03001010 mode[0] = 0x81 | (5 << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001011 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001012 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001013 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001014 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001015}
1016
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001017static int hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001018{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001019 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001020 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001021 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001022 msleep(10);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001023 i2c_r5(gspca_dev, 0); /* read sensor id */
1024 if (gspca_dev->usb_buf[0] == 0x02
1025 && gspca_dev->usb_buf[1] == 0x09
1026 && gspca_dev->usb_buf[2] == 0x01
1027 && gspca_dev->usb_buf[3] == 0x00
1028 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001029 PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001030 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001031 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001032 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001033 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1034 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001035 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
1036 return -ENODEV;
1037}
1038
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001039static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001040{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001041 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001042 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001043 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001044 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001045 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001046 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1047 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1048 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1049 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1050 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001051 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001052 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1053 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1054 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1055 {}
1056 },
1057 };
1058
1059 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1060 reg_w1(gspca_dev, 0x17, 0x62);
1061 reg_w1(gspca_dev, 0x01, 0x08);
1062 for (j = 0; j < 3; j++)
1063 i2c_w8(gspca_dev, probe_tb[i][j]);
1064 msleep(2);
1065 reg_r(gspca_dev, 0x0a, 5);
1066 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1067 if (probe_tb[i][3][0] != 0)
1068 i2c_w8(gspca_dev, probe_tb[i][3]);
1069 reg_w1(gspca_dev, 0x01, 0x29);
1070 reg_w1(gspca_dev, 0x17, 0x42);
1071 if (val != 0xffff)
1072 break;
1073 }
1074 switch (val) {
1075 case 0x823a:
1076 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001077 sd->sensor = SENSOR_MT9V111;
1078 sd->i2c_base = 0x5c;
1079 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001080 case 0x8243:
1081 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001082 break;
1083 default:
1084 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1085 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001086 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001087}
1088
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001089static int configure_gpio(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001090 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001091{
1092 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001093 const u8 *reg9a;
1094 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001095 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1096 static const u8 reg9a_spec[] =
1097 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001098 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001099
Jean-Francois Moine60017612008-07-18 08:46:19 -03001100 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001101 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001102
1103 /* configure gpio */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001104 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1105 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001106 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001107 switch (sd->sensor) {
1108 case SENSOR_OV7660:
1109 case SENSOR_SP80708:
1110 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001111 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001112 default:
1113 reg9a = reg9a_def;
1114 break;
1115 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001116 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001117
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001118 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001119
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001120 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001121
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001122 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001123 case SENSOR_MT9V111:
1124 reg_w1(gspca_dev, 0x01, 0x61);
1125 reg_w1(gspca_dev, 0x17, 0x61);
1126 reg_w1(gspca_dev, 0x01, 0x60);
1127 reg_w1(gspca_dev, 0x01, 0x40);
1128 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001129 case SENSOR_OM6802:
Jean-Francois Moine4f30f6c2008-09-03 16:48:05 -03001130 reg_w1(gspca_dev, 0x02, 0x71);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001131 reg_w1(gspca_dev, 0x01, 0x42);
1132 reg_w1(gspca_dev, 0x17, 0x64);
1133 reg_w1(gspca_dev, 0x01, 0x42);
1134 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001135 case SENSOR_OV7630:
1136 reg_w1(gspca_dev, 0x01, 0x61);
1137 reg_w1(gspca_dev, 0x17, 0xe2);
1138 reg_w1(gspca_dev, 0x01, 0x60);
1139 reg_w1(gspca_dev, 0x01, 0x40);
1140 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001141 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001142 reg_w1(gspca_dev, 0x01, 0x63);
1143 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001144 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001145 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001146 break;
Jean-Francois Moine91de65a2008-09-03 17:12:18 -03001147 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001148 reg_w1(gspca_dev, 0x01, 0x61);
1149 reg_w1(gspca_dev, 0x17, 0x20);
1150 reg_w1(gspca_dev, 0x01, 0x60);
1151 reg_w1(gspca_dev, 0x01, 0x40);
1152 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001153 case SENSOR_SP80708:
1154 reg_w1(gspca_dev, 0x01, 0x63);
1155 reg_w1(gspca_dev, 0x17, 0x20);
1156 reg_w1(gspca_dev, 0x01, 0x62);
1157 reg_w1(gspca_dev, 0x01, 0x42);
1158 mdelay(100);
1159 reg_w1(gspca_dev, 0x02, 0x62);
1160 break;
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001161/* case SENSOR_HV7131R: */
1162/* case SENSOR_MI0360: */
1163/* case SENSOR_MO4000: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001164 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001165 reg_w1(gspca_dev, 0x01, 0x43);
1166 reg_w1(gspca_dev, 0x17, 0x61);
1167 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001168 if (sd->sensor == SENSOR_HV7131R) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001169 if (hv7131r_probe(gspca_dev) < 0)
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001170 return -ENODEV;
1171 }
1172 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001173 }
1174 return 0;
1175}
1176
1177static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
1178{
1179 int i = 0;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001180 static const u8 SetSensorClk[] = /* 0x08 Mclk */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001181 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
1182
1183 while (hv7131r_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001184 i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001185 i++;
1186 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001187 i2c_w8(gspca_dev, SetSensorClk);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001188}
1189
1190static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
1191{
1192 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001193
1194 while (mi0360_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001195 i2c_w8(gspca_dev, mi0360_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001196 i++;
1197 }
1198}
1199
1200static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
1201{
1202 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001203
1204 while (mo4000_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001205 i2c_w8(gspca_dev, mo4000_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001206 i++;
1207 }
1208}
1209
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001210static void mt9v111_InitSensor(struct gspca_dev *gspca_dev)
1211{
1212 int i = 0;
1213
1214 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1215 i++;
1216 msleep(20);
1217 while (mt9v111_sensor_init[i][0]) {
1218 i2c_w8(gspca_dev, mt9v111_sensor_init[i]);
1219 i++;
1220 }
1221}
1222
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001223static void om6802_InitSensor(struct gspca_dev *gspca_dev)
1224{
1225 int i = 0;
1226
1227 while (om6802_sensor_init[i][0]) {
1228 i2c_w8(gspca_dev, om6802_sensor_init[i]);
1229 i++;
1230 }
1231}
1232
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001233static void ov7630_InitSensor(struct gspca_dev *gspca_dev)
1234{
1235 int i = 0;
1236
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001237 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */
1238 i++;
1239 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001240 i++;
1241 msleep(20);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001242 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1243 i++;
1244 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */
1245 i++;
1246 msleep(20);
1247 i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */
1248 i++;
1249/*jfm:win i2c_r from 00 to 80*/
1250
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001251 while (ov7630_sensor_init[i][0]) {
1252 i2c_w8(gspca_dev, ov7630_sensor_init[i]);
1253 i++;
1254 }
1255}
1256
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001257static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
1258{
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001259 int i = 0;
1260
Jean-Francois Moine62703302008-11-11 08:42:56 -03001261 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
1262 i++;
1263/* win: dble reset */
1264 i2c_w8(gspca_dev, ov7648_sensor_init[i]); /* reset */
1265 i++;
1266 msleep(20);
1267/* win: i2c reg read 00..7f */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001268 while (ov7648_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001269 i2c_w8(gspca_dev, ov7648_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001270 i++;
1271 }
1272}
1273
1274static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
1275{
1276 int i = 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001277
Jean-Francois Moine60017612008-07-18 08:46:19 -03001278 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
1279 i++;
1280 msleep(20);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001281 while (ov7660_sensor_init[i][0]) {
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001282 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001283 i++;
1284 }
1285}
1286
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001287static void sp80708_InitSensor(struct gspca_dev *gspca_dev)
1288{
1289 int i = 0;
1290
1291 i2c_w8(gspca_dev, sp80708_sensor_init[i]); /* reset SCCB */
1292 i++;
1293 msleep(20);
1294 while (sp80708_sensor_init[i][0]) {
1295 i2c_w8(gspca_dev, sp80708_sensor_init[i]);
1296 i++;
1297 }
1298}
1299
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001300/* this function is called at probe time */
1301static int sd_config(struct gspca_dev *gspca_dev,
1302 const struct usb_device_id *id)
1303{
1304 struct sd *sd = (struct sd *) gspca_dev;
1305 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001306
1307 cam = &gspca_dev->cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001308 cam->cam_mode = vga_mode;
1309 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001310 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001311
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03001312 sd->bridge = id->driver_info >> 16;
1313 sd->sensor = id->driver_info >> 8;
1314 sd->i2c_base = id->driver_info;
1315
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001316 sd->brightness = BRIGHTNESS_DEF;
1317 sd->contrast = CONTRAST_DEF;
1318 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001319 sd->blue = BLUE_BALANCE_DEF;
1320 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001321 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001322 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001323 sd->ag_cnt = -1;
Hans de Goedef8009522009-06-18 14:29:20 -03001324 sd->vflip = VFLIP_DEF;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001325 sd->infrared = INFRARED_DEF;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001326 sd->freq = FREQ_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001327 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001328 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001329
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001330 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001331 return 0;
1332}
1333
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001334/* this function is called at probe and resume time */
1335static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001336{
1337 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001338 u8 regGpio[] = { 0x29, 0x74 };
1339 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001340
Hans de Goede3647fea2008-07-15 05:36:30 -03001341 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001342 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001343 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001344 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1345 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001346 regF1 = gspca_dev->usb_buf[0];
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001347 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001348 switch (sd->bridge) {
1349 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001350 if (regF1 != 0x11)
1351 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001352 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001353 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001354 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001355 if (regF1 != 0x11)
1356 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001357 if (sd->sensor == SENSOR_MI0360)
1358 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001359 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001360 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001361 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001362 if (regF1 != 0x12)
1363 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001364 if (sd->sensor == SENSOR_MI0360)
1365 mi0360_probe(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001366 regGpio[1] = 0x70;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001367 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001368 break;
1369 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001370/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001371/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001372 if (regF1 != 0x12)
1373 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001374 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001375 break;
1376 }
1377
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001378 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001379
1380 return 0;
1381}
1382
Jean-Francois Moine98819182009-01-19 07:37:33 -03001383static u32 setexposure(struct gspca_dev *gspca_dev,
1384 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001385{
1386 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001387
1388 switch (sd->sensor) {
1389 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001390 u8 Expodoit[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001391 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1392
1393 Expodoit[3] = expo >> 16;
1394 Expodoit[4] = expo >> 8;
1395 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001396 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001397 break;
1398 }
1399 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001400 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001401 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001402 static const u8 doit[] = /* update sensor */
1403 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1404 static const u8 sensorgo[] = /* sensor on */
1405 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001406
1407 if (expo > 0x0635)
1408 expo = 0x0635;
1409 else if (expo < 0x0001)
1410 expo = 0x0001;
1411 expoMi[3] = expo >> 8;
1412 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001413 i2c_w8(gspca_dev, expoMi);
1414 i2c_w8(gspca_dev, doit);
1415 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001416 break;
1417 }
1418 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001419 u8 expoMof[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001420 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001421 u8 expoMo10[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001422 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001423 static const u8 gainMo[] =
1424 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001425
1426 if (expo > 0x1fff)
1427 expo = 0x1fff;
1428 else if (expo < 0x0001)
1429 expo = 0x0001;
1430 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001431 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001432 expoMo10[3] = ((expo & 0x1c00) >> 10)
1433 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001434 i2c_w8(gspca_dev, expoMo10);
1435 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001436 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001437 ((expoMo10[3] & 0x07) << 10)
1438 | (expoMof[3] << 2)
1439 | ((expoMo10[3] & 0x30) >> 4));
1440 break;
1441 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001442 case SENSOR_MT9V111: {
1443 u8 expo_c1[] =
1444 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1445
1446 if (expo > 0x0280)
1447 expo = 0x0280;
1448 else if (expo < 0x0040)
1449 expo = 0x0040;
1450 expo_c1[3] = expo >> 8;
1451 expo_c1[4] = expo;
1452 i2c_w8(gspca_dev, expo_c1);
1453 break;
1454 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001455 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001456 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001457 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1458
1459 if (expo > 0x03ff)
1460 expo = 0x03ff;
1461 if (expo < 0x0001)
1462 expo = 0x0001;
1463 gainOm[3] = expo >> 2;
1464 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001465 reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001466 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001467 break;
1468 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001469 }
1470 return expo;
1471}
1472
1473static void setbrightness(struct gspca_dev *gspca_dev)
1474{
1475 struct sd *sd = (struct sd *) gspca_dev;
1476 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001477 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001478
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001479 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001480 switch (sd->sensor) {
1481 case SENSOR_HV7131R:
1482 expo = sd->brightness << 4;
1483 if (expo > 0x002dc6c0)
1484 expo = 0x002dc6c0;
1485 else if (expo < 0x02a0)
1486 expo = 0x02a0;
1487 sd->exposure = setexposure(gspca_dev, expo);
1488 break;
1489 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001490 case SENSOR_MO4000:
1491 expo = sd->brightness >> 4;
1492 sd->exposure = setexposure(gspca_dev, expo);
1493 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001494 case SENSOR_MT9V111:
1495 expo = sd->brightness >> 8;
1496 sd->exposure = setexposure(gspca_dev, expo);
1497 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001498 case SENSOR_OM6802:
1499 expo = sd->brightness >> 6;
1500 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001501 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001502 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001503 }
1504
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001505 if (sd->sensor != SENSOR_MT9V111)
1506 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001507}
1508
1509static void setcontrast(struct gspca_dev *gspca_dev)
1510{
1511 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001512 u8 k2;
1513 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001514
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001515 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1516 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001517 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001518 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001519 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001520 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001521 contrast[5] = 0;
1522 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001523}
1524
1525static void setcolors(struct gspca_dev *gspca_dev)
1526{
1527 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001528 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001529 u8 reg8a[12]; /* U & V gains */
1530 static s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001531 -24, -38, 64, /* UR UG UB */
1532 62, -51, -9 /* VR VG VB */
1533 };
1534 for (i = 0; i < 6; i++) {
1535 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001536 reg8a[i * 2] = v;
1537 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001538 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001539 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001540}
1541
1542static void setredblue(struct gspca_dev *gspca_dev)
1543{
1544 struct sd *sd = (struct sd *) gspca_dev;
1545
1546 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001547/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001548 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001549}
1550
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001551static void setgamma(struct gspca_dev *gspca_dev)
1552{
1553 struct sd *sd = (struct sd *) gspca_dev;
1554 int i;
1555 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001556 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001557 static const u8 delta[17] = {
1558 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1559 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1560 };
1561
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001562 switch (sd->sensor) {
1563 case SENSOR_HV7131R:
1564 case SENSOR_MT9V111:
1565 gamma_base = gamma_spec_1;
1566 break;
1567 case SENSOR_SP80708:
1568 gamma_base = gamma_spec_2;
1569 break;
1570 default:
1571 gamma_base = gamma_def;
1572 break;
1573 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001574
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001575 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001576 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001577 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1578 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1579}
1580
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001581static void setautogain(struct gspca_dev *gspca_dev)
1582{
1583 struct sd *sd = (struct sd *) gspca_dev;
1584
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001585 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
1586 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001587 switch (sd->sensor) {
1588 case SENSOR_OV7630:
1589 case SENSOR_OV7648: {
1590 u8 comb;
1591
1592 if (sd->sensor == SENSOR_OV7630)
1593 comb = 0xc0;
1594 else
1595 comb = 0xa0;
1596 if (sd->autogain)
Hans de Goede1fec7472009-06-18 06:05:07 -03001597 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001598 i2c_w1(&sd->gspca_dev, 0x13, comb);
1599 return;
1600 }
1601 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001602 if (sd->autogain)
1603 sd->ag_cnt = AG_CNT_START;
1604 else
1605 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001606}
1607
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001608/* ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001609static void setvflip(struct sd *sd)
1610{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001611 u8 comn;
1612
Hans de Goedef8009522009-06-18 14:29:20 -03001613 if (sd->sensor == SENSOR_OV7630) {
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001614 comn = 0x02;
Hans de Goedef8009522009-06-18 14:29:20 -03001615 if (!sd->vflip)
1616 comn |= 0x80;
1617 } else {
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001618 comn = 0x06;
Hans de Goedef8009522009-06-18 14:29:20 -03001619 if (sd->vflip)
1620 comn |= 0x80;
1621 }
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001622 i2c_w1(&sd->gspca_dev, 0x75, comn);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001623}
1624
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001625static void setinfrared(struct sd *sd)
1626{
1627/*fixme: different sequence for StarCam Clip and StarCam 370i */
1628/* Clip */
1629 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
1630 sd->infrared ? 0x66 : 0x64);
1631}
1632
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001633static void setfreq(struct gspca_dev *gspca_dev)
1634{
1635 struct sd *sd = (struct sd *) gspca_dev;
1636
Jean-Francois Moine27954932009-07-08 05:21:50 -03001637 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
1638 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001639 if (sd->sensor == SENSOR_OV7660) {
1640 switch (sd->freq) {
1641 case 0: /* Banding filter disabled */
1642 i2c_w1(gspca_dev, 0x13, 0xdf);
1643 break;
1644 case 1: /* 50 hz */
1645 i2c_w1(gspca_dev, 0x13, 0xff);
1646 i2c_w1(gspca_dev, 0x3b, 0x0a);
1647 break;
1648 case 2: /* 60 hz */
1649 i2c_w1(gspca_dev, 0x13, 0xff);
1650 i2c_w1(gspca_dev, 0x3b, 0x02);
1651 break;
1652 }
1653 } else {
1654 u8 reg2a = 0, reg2b = 0, reg2d = 0;
1655
1656 /* Get reg2a / reg2d base values */
1657 switch (sd->sensor) {
1658 case SENSOR_OV7630:
1659 reg2a = 0x08;
1660 reg2d = 0x01;
1661 break;
1662 case SENSOR_OV7648:
1663 reg2a = 0x11;
1664 reg2d = 0x81;
1665 break;
1666 }
1667
1668 switch (sd->freq) {
1669 case 0: /* Banding filter disabled */
1670 break;
1671 case 1: /* 50 hz (filter on and framerate adj) */
1672 reg2a |= 0x80;
1673 reg2b = 0xac;
1674 reg2d |= 0x04;
1675 break;
1676 case 2: /* 60 hz (filter on, no framerate adj) */
1677 reg2a |= 0x80;
1678 reg2d |= 0x04;
1679 break;
1680 }
1681 i2c_w1(gspca_dev, 0x2a, reg2a);
1682 i2c_w1(gspca_dev, 0x2b, reg2b);
1683 i2c_w1(gspca_dev, 0x2d, reg2d);
1684 }
1685}
1686
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001687static void setjpegqual(struct gspca_dev *gspca_dev)
1688{
1689 struct sd *sd = (struct sd *) gspca_dev;
1690 int i, sc;
1691
1692 if (sd->jpegqual < 50)
1693 sc = 5000 / sd->jpegqual;
1694 else
1695 sc = 200 - sd->jpegqual * 2;
1696#if USB_BUF_SZ < 64
1697#error "No room enough in usb_buf for quantization table"
1698#endif
1699 for (i = 0; i < 64; i++)
1700 gspca_dev->usb_buf[i] =
1701 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1702 usb_control_msg(gspca_dev->dev,
1703 usb_sndctrlpipe(gspca_dev->dev, 0),
1704 0x08,
1705 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1706 0x0100, 0,
1707 gspca_dev->usb_buf, 64,
1708 500);
1709 for (i = 0; i < 64; i++)
1710 gspca_dev->usb_buf[i] =
1711 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1712 usb_control_msg(gspca_dev->dev,
1713 usb_sndctrlpipe(gspca_dev->dev, 0),
1714 0x08,
1715 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1716 0x0140, 0,
1717 gspca_dev->usb_buf, 64,
1718 500);
1719
1720 sd->reg18 ^= 0x40;
1721 reg_w1(gspca_dev, 0x18, sd->reg18);
1722}
1723
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001724/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001725static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001726{
1727 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001728 int i;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001729 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001730 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001731 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001732 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1733 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1734 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1735 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001736 { 0x32, 0xdd, 0x32, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001737
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001738 /* create the JPEG header */
1739 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
Julia Lawall3eb02372009-07-19 07:09:32 -03001740 if (!sd->jpeg_hdr)
1741 return -ENOMEM;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001742 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1743 0x21); /* JPEG 422 */
1744 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1745
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001746 sn9c1xx = sn_tb[(int) sd->sensor];
1747 configure_gpio(gspca_dev, sn9c1xx);
1748
Jean-Francois Moine60017612008-07-18 08:46:19 -03001749 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1750 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1751 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1752 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1753 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1754 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1755 reg_w1(gspca_dev, 0xd3, 0x50);
1756 reg_w1(gspca_dev, 0xc6, 0x00);
1757 reg_w1(gspca_dev, 0xc7, 0x00);
1758 reg_w1(gspca_dev, 0xc8, 0x50);
1759 reg_w1(gspca_dev, 0xc9, 0x3c);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001760 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001761 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001762 case SENSOR_MT9V111:
1763 reg17 = 0xe0;
1764 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001765 case SENSOR_OV7630:
1766 reg17 = 0xe2;
1767 break;
1768 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001769 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001770 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001771 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001772 reg17 = 0xa0;
1773 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001774 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001775 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001776 break;
1777 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001778 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001779/* set reg1 was here */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001780 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1781 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1782 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001783 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001784
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001785 setgamma(gspca_dev);
1786
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001787 for (i = 0; i < 8; i++)
1788 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001789 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001790 case SENSOR_MT9V111:
1791 reg_w1(gspca_dev, 0x9a, 0x07);
1792 reg_w1(gspca_dev, 0x99, 0x59);
1793 break;
Jean-Francois Moine62703302008-11-11 08:42:56 -03001794 case SENSOR_OV7648:
1795 reg_w1(gspca_dev, 0x9a, 0x0a);
1796 reg_w1(gspca_dev, 0x99, 0x60);
1797 break;
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001798 case SENSOR_OV7660:
1799 reg_w1(gspca_dev, 0x9a, 0x05);
1800 if (sd->bridge == BRIDGE_SN9C105)
1801 reg_w1(gspca_dev, 0x99, 0xff);
1802 else
1803 reg_w1(gspca_dev, 0x99, 0x5b);
1804 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001805 case SENSOR_SP80708:
1806 reg_w1(gspca_dev, 0x9a, 0x05);
1807 reg_w1(gspca_dev, 0x99, 0x59);
1808 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001809 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001810 reg_w1(gspca_dev, 0x9a, 0x08);
1811 reg_w1(gspca_dev, 0x99, 0x59);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001812 break;
1813 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001814
Jean-Francois Moinec2446b32008-07-05 11:49:20 -03001815 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001816 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001817 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001818 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001819 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1820 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001821 switch (sd->sensor) {
1822 case SENSOR_HV7131R:
1823 hv7131R_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001824 break;
1825 case SENSOR_MI0360:
1826 mi0360_InitSensor(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001827 break;
1828 case SENSOR_MO4000:
1829 mo4000_InitSensor(gspca_dev);
1830 if (mode) {
1831/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1832 reg1 = 0x06; /* clk 24Mz */
1833 } else {
1834 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001835/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001836 }
1837 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001838 case SENSOR_MT9V111:
1839 mt9v111_InitSensor(gspca_dev);
1840 if (mode) {
1841 reg1 = 0x04; /* 320 clk 48Mhz */
1842 } else {
1843/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03001844 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001845 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03001846 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001847 case SENSOR_OM6802:
1848 om6802_InitSensor(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001849 reg17 = 0x64; /* 640 MCKSIZE */
1850 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001851 case SENSOR_OV7630:
1852 ov7630_InitSensor(gspca_dev);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001853 setvflip(sd);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001854 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03001855 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001856 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001857 case SENSOR_OV7648:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001858 ov7648_InitSensor(gspca_dev);
Jean-Francois Moine62703302008-11-11 08:42:56 -03001859 reg17 = 0x21;
1860/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001862 case SENSOR_OV7660:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001863 ov7660_InitSensor(gspca_dev);
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001864 if (sd->bridge == BRIDGE_SN9C120) {
1865 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001866 reg17 = 0xa2;
1867 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001868 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001869 } else {
1870 reg17 = 0x22;
1871 reg1 = 0x06; /* 24 Mhz, video trf eneble
1872 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001873 }
1874 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001875 default:
1876/* case SENSOR_SP80708: */
1877 sp80708_InitSensor(gspca_dev);
1878 if (mode) {
1879/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001880 } else {
1881 reg1 = 0x46; /* 640 clk 48Mz */
1882 reg17 = 0xa2;
1883 }
1884 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001885 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001886 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001887 reg_w(gspca_dev, 0xca, CA, 4);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001888 switch (sd->sensor) {
1889 case SENSOR_OV7630:
1890 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001891 case SENSOR_OV7660:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001892 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001893 break;
1894 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001895 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001896 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1897 break;
1898 }
1899
1900 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001901 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
1902 reg_w1(gspca_dev, 0x18, sd->reg18);
1903 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001904
Jean-Francois Moine60017612008-07-18 08:46:19 -03001905 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001906 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001907 switch (sd->sensor) {
Jean-Francois Moine79a90982008-10-05 04:21:24 -03001908 case SENSOR_OV7630:
1909 setvflip(sd);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001910 break;
1911 }
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001912 setbrightness(gspca_dev);
1913 setcontrast(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001914 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001915 setfreq(gspca_dev);
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001916 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001917}
1918
1919static void sd_stopN(struct gspca_dev *gspca_dev)
1920{
1921 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001922 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001923 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001924 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001925 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001926 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03001927 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001928 u8 data;
1929 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001930
1931 data = 0x0b;
1932 switch (sd->sensor) {
1933 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001934 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001935 data = 0x2b;
1936 break;
1937 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001938 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001939 data = 0x29;
1940 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001941 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001942 i2c_w8(gspca_dev, stopov7648);
1943 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001944 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001945 case SENSOR_OV7630:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001946 data = 0x29;
1947 break;
1948 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001949/* case SENSOR_MO4000: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001950/* case SENSOR_OV7660: */
1951 break;
1952 }
1953 sn9c1xx = sn_tb[(int) sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03001954 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1955 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1956 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1957 reg_w1(gspca_dev, 0x01, data);
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001958 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001959}
1960
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001961static void sd_stop0(struct gspca_dev *gspca_dev)
1962{
1963 struct sd *sd = (struct sd *) gspca_dev;
1964
1965 kfree(sd->jpeg_hdr);
1966}
1967
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001968static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001969{
1970 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001971 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001972 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001973 u8 luma_mean = 130;
1974 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001975
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001976 /* Thanks S., without your advice, autobright should not work :) */
1977 if (sd->ag_cnt < 0)
1978 return;
1979 if (--sd->ag_cnt >= 0)
1980 return;
1981 sd->ag_cnt = AG_CNT_START;
1982
1983 delta = atomic_read(&sd->avg_lum);
1984 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001985 if (delta < luma_mean - luma_delta ||
1986 delta > luma_mean + luma_delta) {
1987 switch (sd->sensor) {
1988 case SENSOR_HV7131R:
1989 expotimes = sd->exposure >> 8;
1990 expotimes += (luma_mean - delta) >> 4;
1991 if (expotimes < 0)
1992 expotimes = 0;
1993 sd->exposure = setexposure(gspca_dev,
1994 (unsigned int) (expotimes << 8));
1995 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001996 default:
1997/* case SENSOR_MO4000: */
1998/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001999/* case SENSOR_MT9V111: */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002000/* case SENSOR_OM6802: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002001 expotimes = sd->exposure;
2002 expotimes += (luma_mean - delta) >> 6;
2003 if (expotimes < 0)
2004 expotimes = 0;
2005 sd->exposure = setexposure(gspca_dev,
2006 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002007 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002008 break;
2009 }
2010 }
2011}
2012
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002013/* scan the URB packets */
2014/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002015static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2016 struct gspca_frame *frame, /* target */
Jean-Francois Moine98819182009-01-19 07:37:33 -03002017 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002018 int len) /* iso packet length */
2019{
2020 struct sd *sd = (struct sd *) gspca_dev;
2021 int sof, avg_lum;
2022
2023 sof = len - 64;
2024 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2025
2026 /* end of frame */
2027 gspca_frame_add(gspca_dev, LAST_PACKET,
2028 frame, data, sof + 2);
2029 if (sd->ag_cnt < 0)
2030 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002031/* w1 w2 w3 */
2032/* w4 w5 w6 */
2033/* w7 w8 */
2034/* w4 */
2035 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2036/* w6 */
2037 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2038/* w2 */
2039 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2040/* w8 */
2041 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2042/* w5 */
2043 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2044 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002045 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002046 return;
2047 }
2048 if (gspca_dev->last_packet_type == LAST_PACKET) {
2049
2050 /* put the JPEG 422 header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002051 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
2052 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002053 }
2054 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
2055}
2056
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002057static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2058{
2059 struct sd *sd = (struct sd *) gspca_dev;
2060
2061 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002062 if (gspca_dev->streaming)
2063 setbrightness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002064 return 0;
2065}
2066
2067static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2068{
2069 struct sd *sd = (struct sd *) gspca_dev;
2070
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002071 *val = sd->brightness;
2072 return 0;
2073}
2074
2075static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2076{
2077 struct sd *sd = (struct sd *) gspca_dev;
2078
2079 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002080 if (gspca_dev->streaming)
2081 setcontrast(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002082 return 0;
2083}
2084
2085static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2086{
2087 struct sd *sd = (struct sd *) gspca_dev;
2088
2089 *val = sd->contrast;
2090 return 0;
2091}
2092
2093static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2094{
2095 struct sd *sd = (struct sd *) gspca_dev;
2096
2097 sd->colors = val;
2098 if (gspca_dev->streaming)
2099 setcolors(gspca_dev);
2100 return 0;
2101}
2102
2103static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2104{
2105 struct sd *sd = (struct sd *) gspca_dev;
2106
2107 *val = sd->colors;
2108 return 0;
2109}
2110
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002111static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2112{
2113 struct sd *sd = (struct sd *) gspca_dev;
2114
2115 sd->blue = val;
2116 if (gspca_dev->streaming)
2117 setredblue(gspca_dev);
2118 return 0;
2119}
2120
2121static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2122{
2123 struct sd *sd = (struct sd *) gspca_dev;
2124
2125 *val = sd->blue;
2126 return 0;
2127}
2128
2129static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2130{
2131 struct sd *sd = (struct sd *) gspca_dev;
2132
2133 sd->red = val;
2134 if (gspca_dev->streaming)
2135 setredblue(gspca_dev);
2136 return 0;
2137}
2138
2139static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2140{
2141 struct sd *sd = (struct sd *) gspca_dev;
2142
2143 *val = sd->red;
2144 return 0;
2145}
2146
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002147static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2148{
2149 struct sd *sd = (struct sd *) gspca_dev;
2150
2151 sd->gamma = val;
2152 if (gspca_dev->streaming)
2153 setgamma(gspca_dev);
2154 return 0;
2155}
2156
2157static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2158{
2159 struct sd *sd = (struct sd *) gspca_dev;
2160
2161 *val = sd->gamma;
2162 return 0;
2163}
2164
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002165static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2166{
2167 struct sd *sd = (struct sd *) gspca_dev;
2168
2169 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002170 if (gspca_dev->streaming)
2171 setautogain(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002172 return 0;
2173}
2174
2175static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2176{
2177 struct sd *sd = (struct sd *) gspca_dev;
2178
2179 *val = sd->autogain;
2180 return 0;
2181}
2182
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002183static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2184{
2185 struct sd *sd = (struct sd *) gspca_dev;
2186
2187 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002188 if (gspca_dev->streaming)
2189 setvflip(sd);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002190 return 0;
2191}
2192
2193static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2194{
2195 struct sd *sd = (struct sd *) gspca_dev;
2196
2197 *val = sd->vflip;
2198 return 0;
2199}
2200
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002201static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2202{
2203 struct sd *sd = (struct sd *) gspca_dev;
2204
2205 sd->infrared = val;
2206 if (gspca_dev->streaming)
2207 setinfrared(sd);
2208 return 0;
2209}
2210
2211static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2212{
2213 struct sd *sd = (struct sd *) gspca_dev;
2214
2215 *val = sd->infrared;
2216 return 0;
2217}
2218
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002219static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2220{
2221 struct sd *sd = (struct sd *) gspca_dev;
2222
2223 sd->freq = val;
2224 if (gspca_dev->streaming)
2225 setfreq(gspca_dev);
2226 return 0;
2227}
2228
2229static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2230{
2231 struct sd *sd = (struct sd *) gspca_dev;
2232
2233 *val = sd->freq;
2234 return 0;
2235}
2236
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002237static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2238 struct v4l2_jpegcompression *jcomp)
2239{
2240 struct sd *sd = (struct sd *) gspca_dev;
2241
2242 if (jcomp->quality < QUALITY_MIN)
2243 sd->quality = QUALITY_MIN;
2244 else if (jcomp->quality > QUALITY_MAX)
2245 sd->quality = QUALITY_MAX;
2246 else
2247 sd->quality = jcomp->quality;
2248 if (gspca_dev->streaming)
2249 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2250 return 0;
2251}
2252
2253static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2254 struct v4l2_jpegcompression *jcomp)
2255{
2256 struct sd *sd = (struct sd *) gspca_dev;
2257
2258 memset(jcomp, 0, sizeof *jcomp);
2259 jcomp->quality = sd->quality;
2260 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2261 | V4L2_JPEG_MARKER_DQT;
2262 return 0;
2263}
2264
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002265static int sd_querymenu(struct gspca_dev *gspca_dev,
2266 struct v4l2_querymenu *menu)
2267{
2268 switch (menu->id) {
2269 case V4L2_CID_POWER_LINE_FREQUENCY:
2270 switch (menu->index) {
2271 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2272 strcpy((char *) menu->name, "NoFliker");
2273 return 0;
2274 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2275 strcpy((char *) menu->name, "50 Hz");
2276 return 0;
2277 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2278 strcpy((char *) menu->name, "60 Hz");
2279 return 0;
2280 }
2281 break;
2282 }
2283 return -EINVAL;
2284}
2285
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002286/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002287static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002288 .name = MODULE_NAME,
2289 .ctrls = sd_ctrls,
2290 .nctrls = ARRAY_SIZE(sd_ctrls),
2291 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002292 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002293 .start = sd_start,
2294 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002295 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002296 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002297 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002298 .get_jcomp = sd_get_jcomp,
2299 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002300 .querymenu = sd_querymenu,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002301};
2302
2303/* -- module initialisation -- */
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002304#define BSI(bridge, sensor, i2c_addr) \
2305 .driver_info = (BRIDGE_ ## bridge << 16) \
2306 | (SENSOR_ ## sensor << 8) \
2307 | (i2c_addr)
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002308static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002309#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002310 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
Jean-Francois Moine7b537392008-09-07 11:56:49 -03002311 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002312#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002313 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
2314 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
2315 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine7e21fda2008-11-10 04:45:51 -03002316 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002317 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine3319dc92008-12-01 14:44:02 -03002318 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
Jani Monosesf8eaaf4f2009-05-07 03:32:27 -03002319 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002320 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
2321/* bw600.inf:
2322 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
2323/* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
2324/* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
2325 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
2326/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
Jean-Francois Moine661ab252009-01-29 16:03:19 -03002327 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002328/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
2329/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2330 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
2331/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2332/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
2333 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
2334 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002335#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2336 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2337#endif
Jean-Francois Moineceec80e2009-05-09 06:21:35 -03002338 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002339/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
Jean-Francois Moineceec80e2009-05-09 06:21:35 -03002340 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
2341 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
2342 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
2343 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002344/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2345/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002346 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
2347/*bw600.inf:*/
Jean-Francois Moine62703302008-11-11 08:42:56 -03002348 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002349 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002350 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)},
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002351/* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03002352#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002353 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002354#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002355 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
Jean-Francois Moine821ced22008-11-11 07:10:11 -03002356 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002357#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002358 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002359#endif
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002360 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
Hans de Goedecc7b5b52009-06-18 05:14:42 -03002361 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)},
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002362 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002363 {}
2364};
2365MODULE_DEVICE_TABLE(usb, device_table);
2366
2367/* -- device connect -- */
2368static int sd_probe(struct usb_interface *intf,
2369 const struct usb_device_id *id)
2370{
2371 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2372 THIS_MODULE);
2373}
2374
2375static struct usb_driver sd_driver = {
2376 .name = MODULE_NAME,
2377 .id_table = device_table,
2378 .probe = sd_probe,
2379 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002380#ifdef CONFIG_PM
2381 .suspend = gspca_suspend,
2382 .resume = gspca_resume,
2383#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002384};
2385
2386/* -- module insert / remove -- */
2387static int __init sd_mod_init(void)
2388{
Alexey Klimovf69e9522009-01-01 13:02:07 -03002389 int ret;
2390 ret = usb_register(&sd_driver);
2391 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -03002392 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -03002393 info("registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002394 return 0;
2395}
2396static void __exit sd_mod_exit(void)
2397{
2398 usb_deregister(&sd_driver);
2399 info("deregistered");
2400}
2401
2402module_init(sd_mod_init);
2403module_exit(sd_mod_exit);