blob: 0bd36a00dd2a02f9db58c149b9c0418ce2ebf40d [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03002 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003 *
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03004 * Copyright (C) 2009 Jean-Francois Moine <http://moinejf.free.fr>
5 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "sonixj"
23
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 Moineb8c8a5b2009-11-23 06:46:35 -030075#define SENSOR_PO1030 8
76#define SENSOR_SP80708 9
Jean-Francois Moined5aa3852009-11-07 06:10:08 -030077 u8 i2c_addr;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030078
79 u8 *jpeg_hdr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030080};
81
82/* V4L2 controls supported by the driver */
83static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
84static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
85static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
86static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
87static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
88static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine403123d2008-11-26 04:46:15 -030089static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
90static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
91static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -030093static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030095static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6c862742008-09-08 04:57:26 -030097static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030099static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
100static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300101static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
102static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300103
104static struct ctrl sd_ctrls[] = {
Hans de Goede97643982009-06-18 05:08:11 -0300105#define BRIGHTNESS_IDX 0
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300106 {
107 {
108 .id = V4L2_CID_BRIGHTNESS,
109 .type = V4L2_CTRL_TYPE_INTEGER,
110 .name = "Brightness",
111 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300112#define BRIGHTNESS_MAX 0xffff
113 .maximum = BRIGHTNESS_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300114 .step = 1,
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -0300115#define BRIGHTNESS_DEF 0x8000
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300116 .default_value = BRIGHTNESS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300117 },
118 .set = sd_setbrightness,
119 .get = sd_getbrightness,
120 },
Hans de Goede97643982009-06-18 05:08:11 -0300121#define CONTRAST_IDX 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300122 {
123 {
124 .id = V4L2_CID_CONTRAST,
125 .type = V4L2_CTRL_TYPE_INTEGER,
126 .name = "Contrast",
127 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300128#define CONTRAST_MAX 127
129 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300130 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300131#define CONTRAST_DEF 63
132 .default_value = CONTRAST_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300133 },
134 .set = sd_setcontrast,
135 .get = sd_getcontrast,
136 },
Hans de Goede97643982009-06-18 05:08:11 -0300137#define COLOR_IDX 2
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300138 {
139 {
140 .id = V4L2_CID_SATURATION,
141 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300142 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300143 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300144 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300145 .step = 1,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300146#define COLOR_DEF 25
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300147 .default_value = COLOR_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 },
149 .set = sd_setcolors,
150 .get = sd_getcolors,
151 },
Hans de Goede97643982009-06-18 05:08:11 -0300152#define BLUE_BALANCE_IDX 3
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300153 {
154 {
155 .id = V4L2_CID_BLUE_BALANCE,
156 .type = V4L2_CTRL_TYPE_INTEGER,
157 .name = "Blue Balance",
158 .minimum = 24,
159 .maximum = 40,
160 .step = 1,
161#define BLUE_BALANCE_DEF 32
162 .default_value = BLUE_BALANCE_DEF,
163 },
164 .set = sd_setblue_balance,
165 .get = sd_getblue_balance,
166 },
Hans de Goede97643982009-06-18 05:08:11 -0300167#define RED_BALANCE_IDX 4
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300168 {
169 {
170 .id = V4L2_CID_RED_BALANCE,
171 .type = V4L2_CTRL_TYPE_INTEGER,
172 .name = "Red Balance",
173 .minimum = 24,
174 .maximum = 40,
175 .step = 1,
176#define RED_BALANCE_DEF 32
177 .default_value = RED_BALANCE_DEF,
178 },
179 .set = sd_setred_balance,
180 .get = sd_getred_balance,
181 },
Hans de Goede97643982009-06-18 05:08:11 -0300182#define GAMMA_IDX 5
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300183 {
184 {
185 .id = V4L2_CID_GAMMA,
186 .type = V4L2_CTRL_TYPE_INTEGER,
187 .name = "Gamma",
188 .minimum = 0,
189 .maximum = 40,
190 .step = 1,
191#define GAMMA_DEF 20
192 .default_value = GAMMA_DEF,
193 },
194 .set = sd_setgamma,
195 .get = sd_getgamma,
196 },
Hans de Goede97643982009-06-18 05:08:11 -0300197#define AUTOGAIN_IDX 6
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300198 {
199 {
200 .id = V4L2_CID_AUTOGAIN,
201 .type = V4L2_CTRL_TYPE_BOOLEAN,
202 .name = "Auto Gain",
203 .minimum = 0,
204 .maximum = 1,
205 .step = 1,
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300206#define AUTOGAIN_DEF 1
207 .default_value = AUTOGAIN_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300208 },
209 .set = sd_setautogain,
210 .get = sd_getautogain,
211 },
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300212/* ov7630/ov7648 only */
Hans de Goede97643982009-06-18 05:08:11 -0300213#define VFLIP_IDX 7
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300214 {
215 {
216 .id = V4L2_CID_VFLIP,
217 .type = V4L2_CTRL_TYPE_BOOLEAN,
218 .name = "Vflip",
219 .minimum = 0,
220 .maximum = 1,
221 .step = 1,
Hans de Goedef8009522009-06-18 14:29:20 -0300222#define VFLIP_DEF 0
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300223 .default_value = VFLIP_DEF,
224 },
225 .set = sd_setvflip,
226 .get = sd_getvflip,
227 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300228/* mt9v111 only */
Hans de Goede97643982009-06-18 05:08:11 -0300229#define INFRARED_IDX 8
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300230 {
231 {
232 .id = V4L2_CID_INFRARED,
233 .type = V4L2_CTRL_TYPE_BOOLEAN,
234 .name = "Infrared",
235 .minimum = 0,
236 .maximum = 1,
237 .step = 1,
238#define INFRARED_DEF 0
239 .default_value = INFRARED_DEF,
240 },
241 .set = sd_setinfrared,
242 .get = sd_getinfrared,
243 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300244/* ov7630/ov7648/ov7660 only */
245#define FREQ_IDX 9
246 {
247 {
248 .id = V4L2_CID_POWER_LINE_FREQUENCY,
249 .type = V4L2_CTRL_TYPE_MENU,
250 .name = "Light frequency filter",
251 .minimum = 0,
252 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
253 .step = 1,
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300254#define FREQ_DEF 1
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300255 .default_value = FREQ_DEF,
256 },
257 .set = sd_setfreq,
258 .get = sd_getfreq,
259 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300260};
261
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300262/* table of the disabled controls */
263static __u32 ctrl_dis[] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300264 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300265 /* SENSOR_HV7131R 0 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300266 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300267 /* SENSOR_MI0360 1 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300268 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300269 /* SENSOR_MO4000 2 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300270 (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300271 /* SENSOR_MT9V111 3 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300272 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300273 /* SENSOR_OM6802 4 */
Hans de Goede1fec7472009-06-18 06:05:07 -0300274 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300275 /* SENSOR_OV7630 5 */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300276 (1 << INFRARED_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300277 /* SENSOR_OV7648 6 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300278 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300279 /* SENSOR_OV7660 7 */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300280 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300281 (1 << FREQ_IDX), /* SENSOR_PO1030 8 */
282 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
283 (1 << FREQ_IDX), /* SENSOR_SP80708 9 */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300284};
285
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300286static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300287 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
288 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300289 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300290 .colorspace = V4L2_COLORSPACE_JPEG,
291 .priv = 2},
292 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
293 .bytesperline = 320,
294 .sizeimage = 320 * 240 * 3 / 8 + 590,
295 .colorspace = V4L2_COLORSPACE_JPEG,
296 .priv = 1},
297 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
298 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300299 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
300 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300301 .colorspace = V4L2_COLORSPACE_JPEG,
302 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300303};
304
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300305/*Data from sn9c102p+hv7131r */
306static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300307/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
308 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
309/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300310 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300311/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
312 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300313/* reg18 reg19 reg1a reg1b */
314 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300315};
316
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300317static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300318/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
319 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
320/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300321 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300322/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
323 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300324/* reg18 reg19 reg1a reg1b */
325 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300326};
327
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300328static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300329/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300330 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300331/* reg8 reg9 rega regb regc regd rege regf */
332 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
333/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
334 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300335/* reg18 reg19 reg1a reg1b */
336 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300337};
338
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300339static const u8 sn_mt9v111[0x1c] = {
340/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
341 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
342/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300343 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300344/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
345 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
346/* reg18 reg19 reg1a reg1b */
347 0x06, 0x00, 0x00, 0x00
348};
349
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300350static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300351/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300352 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300353/* reg8 reg9 rega regb regc regd rege regf */
354 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
356 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300357/* reg18 reg19 reg1a reg1b */
358 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300359};
360
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300361static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300362/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
363 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
364/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300365 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300366/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
367 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300368/* reg18 reg19 reg1a reg1b */
369 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300370};
371
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300372static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300373/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300374 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300375/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300376 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300377/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300378 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300379/* reg18 reg19 reg1a reg1b */
380 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300381};
382
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300383static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300384/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -0300385 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300386/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -0300387 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300388/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
389 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300390/* reg18 reg19 reg1a reg1b */
391 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300392};
393
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300394static const u8 sn_po1030[0x1c] = {
395/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
396 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
397/* reg8 reg9 rega regb regc regd rege regf */
398 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
400 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
401/* reg18 reg19 reg1a reg1b */
402 0x07, 0x00, 0x00, 0x00
403};
404
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300405static const u8 sn_sp80708[0x1c] = {
406/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
407 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
408/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300409 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300410/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
411 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
412/* reg18 reg19 reg1a reg1b */
413 0x07, 0x00, 0x00, 0x00
414};
415
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300416/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300417static const u8 *sn_tb[] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300418 sn_hv7131,
419 sn_mi0360,
420 sn_mo4000,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300421 sn_mt9v111,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300422 sn_om6802,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300423 sn_ov7630,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300424 sn_ov7648,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300425 sn_ov7660,
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300426 sn_po1030,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300427 sn_sp80708
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300428};
429
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300430/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300431static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300432 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
433 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
434};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300435/* gamma for sensors HV7131R and MT9V111 */
436static const u8 gamma_spec_1[17] = {
437 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
438 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
439};
440/* gamma for sensor SP80708 */
441static const u8 gamma_spec_2[17] = {
442 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
443 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
444};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300445
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300446/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300447static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300448 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
449 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
450 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
451 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300452};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300453static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300454 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
455 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
456 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
457/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
458 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
459 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
460/* {0x91, 0x11, 0x18, 0x00, 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, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
464 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
465 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
466 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
467 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
468 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
469 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300470
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300471 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
472 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300473 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300474 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
475 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300476
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300477 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
478 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
479 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
480 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300482 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
483 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300484 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300485};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300486static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300487 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300488 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300489 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300490 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
491 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
492 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
493 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
494 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
495 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
496 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
497 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
498 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
499 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
500 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
502 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
503 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
504 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
505 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
506 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
507 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
508 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300509 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300510 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
511 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
512 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
513 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
514 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
515 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
516 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
517 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
518 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
519 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300520
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300521 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
522 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
523 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
524 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
525 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300526
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300527 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
528 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
529 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
530 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300531
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300532 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
533 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
534/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
535/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
536 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
537 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300538 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300539};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300540static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300541 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
542 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
543 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
544 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
545 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
546 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
547 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
548 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
549 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
550 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
551 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
552 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
553 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
554 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
555 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
556 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
557 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
558 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
559 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
560 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300561 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300562};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300563static const u8 mt9v111_sensor_init[][8] = {
564 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300565 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300566 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
567 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
568 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
569 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300570 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
571 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
572 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
573 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300574 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300575 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
576 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
577 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
578 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
579 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300580 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300581 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300582 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
583 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
584 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
585 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
586 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
587 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
588 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
589 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
590 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
591 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300592 {}
593};
594static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300595 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
596 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300597 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300598 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
599 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
600 /*******/
601 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
602 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
603 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
604 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
605 {}
606};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300607static const u8 om6802_init0[2][8] = {
608/*fixme: variable*/
609 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
610 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
611};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300612static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300613 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
614 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300615 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300616 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300617 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300618/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
619 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300620 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300621/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
622 * set color mode */
623/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
624 * max AGC value in AE */
625/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
626 * preset AGC */
627/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
628 * preset brightness */
629/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
630 * preset contrast */
631/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
632 * preset gamma */
633 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300634 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300635 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
636 /* preset shutter */
637/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
638 * auto frame rate */
639/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300640 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
641 {}
642};
643static const u8 om6802_sensor_param1[][8] = {
644 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300648 {}
649};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300650static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300651 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
652 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300653 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300654 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
655 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300656 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300657 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300658/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300659 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
660 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300661/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
662 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
663 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300664 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
665 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
666 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
667 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
668 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
669 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
670 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
671 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
672 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
673 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
674 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
675 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
676 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
677 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
678 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
679 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
680 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
681 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
682 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
683 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
684 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
685 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
686 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
687/* */
688 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
689 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
690/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300691/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
692 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300693 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
694 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
695 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300696/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300697/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
698/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300699/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300700 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300701/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300702 {}
703};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300704
Jean-Francois Moine98819182009-01-19 07:37:33 -0300705static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300706 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300708 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300709 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
710 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
711 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
712 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
713 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
714 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
715 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
716 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
717 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
718 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
719 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
720 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
721 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
722 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
723 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
724 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
725 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
726 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
727 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
728
729 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
730/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
731/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300732/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300733 {}
734};
735static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300736/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300737/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
738 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300739 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
740 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
741/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
742/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
743/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
744/*...*/
745 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
746/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
747/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
748/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
749/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
750/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
751
752 {}
753};
754
Jean-Francois Moine98819182009-01-19 07:37:33 -0300755static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300756 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300757 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300758 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300759 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300760 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -0300761 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300762 /* GAIN BLUE RED VREF */
763 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
764 /* COM 1 BAVE GEAVE AECHH */
765 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
766 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300767 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300768 /* AECH CLKRC COM7 COM8 */
769 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
770 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
771 /* HSTART HSTOP VSTRT VSTOP */
772 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
773 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
774 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
775 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300776/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
777 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300778 /* AEW AEB VPT BBIAS */
779 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
780 /* GbBIAS RSVD EXHCH EXHCL */
781 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
782 /* RBIAS ADVFL ASDVFH YAVE */
783 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
784 /* HSYST HSYEN HREF */
785 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
786 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
787 /* ADC ACOM OFON TSLB */
788 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
789 /* COM11 COM12 COM13 COM14 */
790 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
791 /* EDGE COM15 COM16 COM17 */
792 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
793 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
794 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
795 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
796 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
797 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
798 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
799 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
800 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
801 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
802 /* LCC1 LCC2 LCC3 LCC4 */
803 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300804 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300805 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300806 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300807 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
808 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
809 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
810 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
811 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
812 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
813 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
814 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
815 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300816 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300817/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300818 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300819 {}
820};
821static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300822 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300823 /* bits[3..0]reserved */
824 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
826 /* VREF vertical frame ctrl */
827 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300828 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
829 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
830 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
831 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
832/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300833/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300834/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300835 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300836 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
837 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
838 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
839/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300840/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300841/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300842/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300843 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300847 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300848};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300849
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300850static const u8 po1030_sensor_init[][8] = {
851/* the sensor registers are described in m5602/m5602_po1030.h */
852 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
853 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
854 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
856 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
857 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
858 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
859 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
860 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
861 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
862 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
863 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
864 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
865 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
866 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
867 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
868 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
869 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
870 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
871 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
872 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
873 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
874 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
875 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
876 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
877 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
878 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
879 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
880
881 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
882 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
883 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
884 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
885 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
886 {}
887};
888static const u8 po1030_sensor_param1[][8] = {
889/* from ms-win traces - these values change with auto gain/expo/wb.. */
890 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
891 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
892/* mean values */
893 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
894 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
895 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
896
897 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
898 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
899 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
900/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
901 {}
902};
903
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300904static const u8 sp80708_sensor_init[][8] = {
905 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
906 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
907 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
908 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
909 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
910 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
911 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
912 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
913 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
914 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
915 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
916 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
917 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
918 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
920 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
921 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
922 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
923 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
924 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
925 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
926 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
927 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
928 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
929 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
930 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
931 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
932 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
933 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
934 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
935 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
936 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
937 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
938 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
939 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
940 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
941 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
942 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
943 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
944 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
945 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
946 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
947 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
948 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
949 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
950 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
951 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
952 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
953 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
954 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
955 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
956 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
957 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
958 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
959 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
960 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
961 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
962 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
963 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
964 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
965 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
966 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
967 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
968 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
969 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
970 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
971 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
972 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
973 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
974 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
975 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300976 {}
977};
978static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300979 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
980 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
981 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
982 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
983 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
984 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
985 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
986 {}
987};
988
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300989static const u8 (*sensor_init[10])[8] = {
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300990 hv7131r_sensor_init, /* HV7131R 0 */
991 mi0360_sensor_init, /* MI0360 1 */
992 mo4000_sensor_init, /* MO4000 2 */
993 mt9v111_sensor_init, /* MT9V111 3 */
994 om6802_sensor_init, /* OM6802 4 */
995 ov7630_sensor_init, /* OV7630 5 */
996 ov7648_sensor_init, /* OV7648 6 */
997 ov7660_sensor_init, /* OV7660 7 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300998 po1030_sensor_init, /* PO1030 8 */
999 sp80708_sensor_init, /* SP80708 9 */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001000};
1001
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001002/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001003static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001004 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001005{
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001006#ifdef GSPCA_DEBUG
1007 if (len > USB_BUF_SZ) {
1008 err("reg_r: buffer overflow");
1009 return;
1010 }
1011#endif
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001012 usb_control_msg(gspca_dev->dev,
1013 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001014 0,
1015 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1016 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001017 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001018 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001019 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001020}
1021
Jean-Francois Moine60017612008-07-18 08:46:19 -03001022static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001023 u16 value,
1024 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001025{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001026 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001027 gspca_dev->usb_buf[0] = data;
1028 usb_control_msg(gspca_dev->dev,
1029 usb_sndctrlpipe(gspca_dev->dev, 0),
1030 0x08,
1031 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1032 value,
1033 0,
1034 gspca_dev->usb_buf, 1,
1035 500);
1036}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001037static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001038 u16 value,
1039 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001040 int len)
1041{
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001042 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001043 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001044#ifdef GSPCA_DEBUG
1045 if (len > USB_BUF_SZ) {
1046 err("reg_w: buffer overflow");
1047 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001048 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001049#endif
1050 memcpy(gspca_dev->usb_buf, buffer, len);
1051 usb_control_msg(gspca_dev->dev,
1052 usb_sndctrlpipe(gspca_dev->dev, 0),
1053 0x08,
1054 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1055 value, 0,
1056 gspca_dev->usb_buf, len,
1057 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001058}
1059
Jean-Francois Moine60017612008-07-18 08:46:19 -03001060/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001061static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001062{
1063 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001064
Jean-Francois Moine60017612008-07-18 08:46:19 -03001065 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001066 switch (sd->sensor) {
1067 case SENSOR_OM6802: /* i2c command = a0 (100 kHz) */
1068 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1069 break;
1070 default: /* i2c command = a1 (400 kHz) */
1071 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1072 break;
1073 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001074 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001075 gspca_dev->usb_buf[2] = reg;
1076 gspca_dev->usb_buf[3] = val;
1077 gspca_dev->usb_buf[4] = 0;
1078 gspca_dev->usb_buf[5] = 0;
1079 gspca_dev->usb_buf[6] = 0;
1080 gspca_dev->usb_buf[7] = 0x10;
1081 usb_control_msg(gspca_dev->dev,
1082 usb_sndctrlpipe(gspca_dev->dev, 0),
1083 0x08,
1084 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1085 0x08, /* value = i2c */
1086 0,
1087 gspca_dev->usb_buf, 8,
1088 500);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001089}
1090
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001091/* I2C write 8 bytes */
1092static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001093 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001094{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001095 memcpy(gspca_dev->usb_buf, buffer, 8);
1096 usb_control_msg(gspca_dev->dev,
1097 usb_sndctrlpipe(gspca_dev->dev, 0),
1098 0x08,
1099 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1100 0x08, 0, /* value, index */
1101 gspca_dev->usb_buf, 8,
1102 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001103 msleep(2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001104}
1105
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001106/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1107static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001108{
1109 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001110 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001111
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001112 switch (sd->sensor) {
1113 case SENSOR_OM6802: /* i2c command = 90 (100 kHz) */
1114 mode[0] = 0x80 | 0x10;
1115 break;
1116 default: /* i2c command = 91 (400 kHz) */
1117 mode[0] = 0x81 | 0x10;
1118 break;
1119 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001120 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001121 mode[2] = reg;
1122 mode[3] = 0;
1123 mode[4] = 0;
1124 mode[5] = 0;
1125 mode[6] = 0;
1126 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001127 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001128 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001129 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001130 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001131 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001132 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001133 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001134}
1135
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001136static void i2c_w_seq(struct gspca_dev *gspca_dev,
1137 const u8 (*data)[8])
1138{
1139 while ((*data)[0] != 0) {
1140 if ((*data)[0] != 0xdd)
1141 i2c_w8(gspca_dev, *data);
1142 else
1143 msleep((*data)[1]);
1144 data++;
1145 }
1146}
1147
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001148static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001149{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001150 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001151 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001152 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001153 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001154 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001155 if (gspca_dev->usb_buf[0] == 0x02
1156 && gspca_dev->usb_buf[1] == 0x09
1157 && gspca_dev->usb_buf[2] == 0x01
1158 && gspca_dev->usb_buf[3] == 0x00
1159 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001160 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1161 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001162 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001163 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001164 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1165 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001166}
1167
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001168static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001169{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001170 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001171 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001172 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001173 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001174 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001175 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1176 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1177 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1178 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1179 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001180 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001181 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1182 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1183 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1184 {}
1185 },
1186 };
1187
1188 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1189 reg_w1(gspca_dev, 0x17, 0x62);
1190 reg_w1(gspca_dev, 0x01, 0x08);
1191 for (j = 0; j < 3; j++)
1192 i2c_w8(gspca_dev, probe_tb[i][j]);
1193 msleep(2);
1194 reg_r(gspca_dev, 0x0a, 5);
1195 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1196 if (probe_tb[i][3][0] != 0)
1197 i2c_w8(gspca_dev, probe_tb[i][3]);
1198 reg_w1(gspca_dev, 0x01, 0x29);
1199 reg_w1(gspca_dev, 0x17, 0x42);
1200 if (val != 0xffff)
1201 break;
1202 }
1203 switch (val) {
1204 case 0x823a:
1205 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001206 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001207 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001208 case 0x8243:
1209 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001210 break;
1211 default:
1212 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1213 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001214 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001215}
1216
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001217static void ov7648_probe(struct gspca_dev *gspca_dev)
1218{
1219 struct sd *sd = (struct sd *) gspca_dev;
1220
1221 /* check ov76xx */
1222 reg_w1(gspca_dev, 0x17, 0x62);
1223 reg_w1(gspca_dev, 0x01, 0x08);
1224 sd->i2c_addr = 0x21;
1225 i2c_r(gspca_dev, 0x0a, 2);
1226 if (gspca_dev->usb_buf[3] == 0x76) { /* ov76xx */
1227 PDEBUG(D_PROBE, "Sensor ov%02x%02x",
1228 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1229 return;
1230 }
1231
1232 /* reset */
1233 reg_w1(gspca_dev, 0x01, 0x29);
1234 reg_w1(gspca_dev, 0x17, 0x42);
1235
1236 /* check po1030 */
1237 reg_w1(gspca_dev, 0x17, 0x62);
1238 reg_w1(gspca_dev, 0x01, 0x08);
1239 sd->i2c_addr = 0x6e;
1240 i2c_r(gspca_dev, 0x00, 2);
1241 if (gspca_dev->usb_buf[3] == 0x10 /* po1030 */
1242 && gspca_dev->usb_buf[4] == 0x30) {
1243 PDEBUG(D_PROBE, "Sensor po1030");
1244 sd->sensor = SENSOR_PO1030;
1245 return;
1246 }
1247
1248 PDEBUG(D_PROBE, "Unknown sensor %02x%02x",
1249 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1250}
1251
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001252static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001253 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001254{
1255 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001256 const u8 *reg9a;
1257 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001258 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1259 static const u8 reg9a_spec[] =
1260 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001261 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001262
Jean-Francois Moine60017612008-07-18 08:46:19 -03001263 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001264 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001265
1266 /* configure gpio */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001267 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1268 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001269 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001270 switch (sd->sensor) {
1271 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001272 case SENSOR_PO1030:
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001273 case SENSOR_SP80708:
1274 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001275 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001276 default:
1277 reg9a = reg9a_def;
1278 break;
1279 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001280 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001281
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001282 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001283
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001284 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001285
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001286 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001287 case SENSOR_MT9V111:
1288 reg_w1(gspca_dev, 0x01, 0x61);
1289 reg_w1(gspca_dev, 0x17, 0x61);
1290 reg_w1(gspca_dev, 0x01, 0x60);
1291 reg_w1(gspca_dev, 0x01, 0x40);
1292 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001293 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001294 msleep(10);
1295 reg_w1(gspca_dev, 0x02, 0x73);
1296 reg_w1(gspca_dev, 0x17, 0x60);
1297 reg_w1(gspca_dev, 0x01, 0x22);
1298 msleep(100);
1299 reg_w1(gspca_dev, 0x01, 0x62);
1300 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001301 reg_w1(gspca_dev, 0x17, 0x64);
1302 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001303 msleep(10);
1304 reg_w1(gspca_dev, 0x01, 0x42);
1305 i2c_w8(gspca_dev, om6802_init0[0]);
1306 i2c_w8(gspca_dev, om6802_init0[1]);
1307 msleep(15);
1308 reg_w1(gspca_dev, 0x02, 0x71);
1309 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001310 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001311 case SENSOR_OV7630:
1312 reg_w1(gspca_dev, 0x01, 0x61);
1313 reg_w1(gspca_dev, 0x17, 0xe2);
1314 reg_w1(gspca_dev, 0x01, 0x60);
1315 reg_w1(gspca_dev, 0x01, 0x40);
1316 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001317 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001318 reg_w1(gspca_dev, 0x01, 0x63);
1319 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001320 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001321 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001322 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001323 case SENSOR_PO1030:
1324 reg_w1(gspca_dev, 0x01, 0x61);
1325 reg_w1(gspca_dev, 0x17, 0x20);
1326 reg_w1(gspca_dev, 0x01, 0x60);
1327 reg_w1(gspca_dev, 0x01, 0x40);
1328 break;
Jean-Francois Moine91de65a2008-09-03 17:12:18 -03001329 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001330 /* fall thru */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001331 case SENSOR_SP80708:
1332 reg_w1(gspca_dev, 0x01, 0x63);
1333 reg_w1(gspca_dev, 0x17, 0x20);
1334 reg_w1(gspca_dev, 0x01, 0x62);
1335 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001336 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001337 reg_w1(gspca_dev, 0x02, 0x62);
1338 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001339 default:
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001340/* case SENSOR_HV7131R: */
1341/* case SENSOR_MI0360: */
1342/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001343 reg_w1(gspca_dev, 0x01, 0x43);
1344 reg_w1(gspca_dev, 0x17, 0x61);
1345 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001346 if (sd->sensor == SENSOR_HV7131R
1347 && sd->bridge == BRIDGE_SN9C102P)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001348 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001349 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001350 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001351}
1352
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001353/* this function is called at probe time */
1354static int sd_config(struct gspca_dev *gspca_dev,
1355 const struct usb_device_id *id)
1356{
1357 struct sd *sd = (struct sd *) gspca_dev;
1358 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001359
1360 cam = &gspca_dev->cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001361 cam->cam_mode = vga_mode;
1362 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001363 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001364
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03001365 sd->bridge = id->driver_info >> 16;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001366 sd->sensor = id->driver_info;
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03001367
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001368 sd->brightness = BRIGHTNESS_DEF;
1369 sd->contrast = CONTRAST_DEF;
1370 sd->colors = COLOR_DEF;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001371 sd->blue = BLUE_BALANCE_DEF;
1372 sd->red = RED_BALANCE_DEF;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001373 sd->gamma = GAMMA_DEF;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001374 sd->autogain = AUTOGAIN_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001375 sd->ag_cnt = -1;
Hans de Goedef8009522009-06-18 14:29:20 -03001376 sd->vflip = VFLIP_DEF;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001377 sd->infrared = INFRARED_DEF;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001378 sd->freq = FREQ_DEF;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001379 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001380 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001381
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001382 return 0;
1383}
1384
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001385/* this function is called at probe and resume time */
1386static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001387{
1388 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001389 const u8 *sn9c1xx;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001390 u8 regGpio[] = { 0x29, 0x74 };
1391 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001392
Hans de Goede3647fea2008-07-15 05:36:30 -03001393 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001394 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001395 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001396 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1397 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001398 regF1 = gspca_dev->usb_buf[0];
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001399 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001400 switch (sd->bridge) {
1401 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001402 if (regF1 != 0x11)
1403 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001404 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001405 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001406 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001407 if (regF1 != 0x11)
1408 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001409 if (sd->sensor == SENSOR_MI0360)
1410 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001411 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001412 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001413 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001414 if (regF1 != 0x12)
1415 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001416 switch (sd->sensor) {
1417 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001418 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001419 break;
1420 case SENSOR_OV7648:
1421 ov7648_probe(gspca_dev);
1422 break;
1423 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001424 regGpio[1] = 0x70;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001425 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001426 break;
1427 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001428/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001429/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001430 if (regF1 != 0x12)
1431 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001432 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001433 break;
1434 }
1435
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03001436 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001437
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001438 /* set the i2c address */
1439 sn9c1xx = sn_tb[sd->sensor];
1440 sd->i2c_addr = sn9c1xx[9];
1441
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001442 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1443
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001444 return 0;
1445}
1446
Jean-Francois Moine98819182009-01-19 07:37:33 -03001447static u32 setexposure(struct gspca_dev *gspca_dev,
1448 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001449{
1450 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001451
1452 switch (sd->sensor) {
1453 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001454 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001455 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001456
1457 Expodoit[3] = expo >> 16;
1458 Expodoit[4] = expo >> 8;
1459 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001460 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001461 break;
1462 }
1463 case SENSOR_MI0360: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001464 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001465 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001466 static const u8 doit[] = /* update sensor */
1467 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1468 static const u8 sensorgo[] = /* sensor on */
1469 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001470
1471 if (expo > 0x0635)
1472 expo = 0x0635;
1473 else if (expo < 0x0001)
1474 expo = 0x0001;
1475 expoMi[3] = expo >> 8;
1476 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001477 i2c_w8(gspca_dev, expoMi);
1478 i2c_w8(gspca_dev, doit);
1479 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001480 break;
1481 }
1482 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001483 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001484 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001485 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001486 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001487 static const u8 gainMo[] =
1488 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001489
1490 if (expo > 0x1fff)
1491 expo = 0x1fff;
1492 else if (expo < 0x0001)
1493 expo = 0x0001;
1494 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001495 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001496 expoMo10[3] = ((expo & 0x1c00) >> 10)
1497 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001498 i2c_w8(gspca_dev, expoMo10);
1499 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001500 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001501 ((expoMo10[3] & 0x07) << 10)
1502 | (expoMof[3] << 2)
1503 | ((expoMo10[3] & 0x30) >> 4));
1504 break;
1505 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001506 case SENSOR_MT9V111: {
1507 u8 expo_c1[] =
1508 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1509
1510 if (expo > 0x0280)
1511 expo = 0x0280;
1512 else if (expo < 0x0040)
1513 expo = 0x0040;
1514 expo_c1[3] = expo >> 8;
1515 expo_c1[4] = expo;
1516 i2c_w8(gspca_dev, expo_c1);
1517 break;
1518 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001519 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001520 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001521 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001522 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001523
1524 if (expo > 0x03ff)
1525 expo = 0x03ff;
1526 if (expo < 0x0001)
1527 expo = 0x0001;
1528 gainOm[3] = expo >> 2;
1529 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001530 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001531 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001532 break;
1533 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001534 }
1535 return expo;
1536}
1537
1538static void setbrightness(struct gspca_dev *gspca_dev)
1539{
1540 struct sd *sd = (struct sd *) gspca_dev;
1541 unsigned int expo;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001542 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001543
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001544 k2 = ((int) sd->brightness - 0x8000) >> 10;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001545 switch (sd->sensor) {
1546 case SENSOR_HV7131R:
1547 expo = sd->brightness << 4;
1548 if (expo > 0x002dc6c0)
1549 expo = 0x002dc6c0;
1550 else if (expo < 0x02a0)
1551 expo = 0x02a0;
1552 sd->exposure = setexposure(gspca_dev, expo);
1553 break;
1554 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001555 case SENSOR_MO4000:
1556 expo = sd->brightness >> 4;
1557 sd->exposure = setexposure(gspca_dev, expo);
1558 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001559 case SENSOR_MT9V111:
1560 expo = sd->brightness >> 8;
1561 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001562 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001563 case SENSOR_OM6802:
1564 expo = sd->brightness >> 6;
1565 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moineb1b056a2008-11-25 04:47:09 -03001566 k2 = sd->brightness >> 11;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001567 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001568 }
1569
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001570 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001571}
1572
1573static void setcontrast(struct gspca_dev *gspca_dev)
1574{
1575 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001576 u8 k2;
1577 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001578
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001579 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1580 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001581 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001582 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001583 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001584 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001585 contrast[5] = 0;
1586 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001587}
1588
1589static void setcolors(struct gspca_dev *gspca_dev)
1590{
1591 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001592 int i, v;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001593 u8 reg8a[12]; /* U & V gains */
1594 static s16 uv[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001595 -24, -38, 64, /* UR UG UB */
1596 62, -51, -9 /* VR VG VB */
1597 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001598
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001599 for (i = 0; i < 6; i++) {
1600 v = uv[i] * sd->colors / COLOR_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001601 reg8a[i * 2] = v;
1602 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001603 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001604 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001605}
1606
1607static void setredblue(struct gspca_dev *gspca_dev)
1608{
1609 struct sd *sd = (struct sd *) gspca_dev;
1610
1611 reg_w1(gspca_dev, 0x05, sd->red);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001612/* reg_w1(gspca_dev, 0x07, 32); */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001613 reg_w1(gspca_dev, 0x06, sd->blue);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001614}
1615
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001616static void setgamma(struct gspca_dev *gspca_dev)
1617{
1618 struct sd *sd = (struct sd *) gspca_dev;
1619 int i;
1620 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001621 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001622 static const u8 delta[17] = {
1623 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1624 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1625 };
1626
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001627 switch (sd->sensor) {
1628 case SENSOR_HV7131R:
1629 case SENSOR_MT9V111:
1630 gamma_base = gamma_spec_1;
1631 break;
1632 case SENSOR_SP80708:
1633 gamma_base = gamma_spec_2;
1634 break;
1635 default:
1636 gamma_base = gamma_def;
1637 break;
1638 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001639
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001640 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001641 gamma[i] = gamma_base[i]
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001642 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1643 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1644}
1645
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001646static void setautogain(struct gspca_dev *gspca_dev)
1647{
1648 struct sd *sd = (struct sd *) gspca_dev;
1649
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001650 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
1651 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001652 switch (sd->sensor) {
1653 case SENSOR_OV7630:
1654 case SENSOR_OV7648: {
1655 u8 comb;
1656
1657 if (sd->sensor == SENSOR_OV7630)
1658 comb = 0xc0;
1659 else
1660 comb = 0xa0;
1661 if (sd->autogain)
Hans de Goede1fec7472009-06-18 06:05:07 -03001662 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001663 i2c_w1(&sd->gspca_dev, 0x13, comb);
1664 return;
1665 }
1666 }
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001667 if (sd->autogain)
1668 sd->ag_cnt = AG_CNT_START;
1669 else
1670 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001671}
1672
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001673/* ov7630/ov7648 only */
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001674static void setvflip(struct sd *sd)
1675{
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001676 u8 comn;
1677
Jean-Francois Moine0939e262009-11-02 09:58:49 -03001678 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
1679 return;
Hans de Goedef8009522009-06-18 14:29:20 -03001680 if (sd->sensor == SENSOR_OV7630) {
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001681 comn = 0x02;
Hans de Goedef8009522009-06-18 14:29:20 -03001682 if (!sd->vflip)
1683 comn |= 0x80;
1684 } else {
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001685 comn = 0x06;
Hans de Goedef8009522009-06-18 14:29:20 -03001686 if (sd->vflip)
1687 comn |= 0x80;
1688 }
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001689 i2c_w1(&sd->gspca_dev, 0x75, comn);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001690}
1691
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001692static void setinfrared(struct sd *sd)
1693{
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001694 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
1695 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03001696/*fixme: different sequence for StarCam Clip and StarCam 370i */
1697/* Clip */
1698 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
1699 sd->infrared ? 0x66 : 0x64);
1700}
1701
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001702static void setfreq(struct gspca_dev *gspca_dev)
1703{
1704 struct sd *sd = (struct sd *) gspca_dev;
1705
Jean-Francois Moine27954932009-07-08 05:21:50 -03001706 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
1707 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001708 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001709 u8 com8;
1710
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001711 com8 = 0xdf; /* auto gain/wb/expo */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001712 switch (sd->freq) {
1713 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001714 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001715 break;
1716 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001717 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001718 i2c_w1(gspca_dev, 0x3b, 0x0a);
1719 break;
1720 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001721 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001722 i2c_w1(gspca_dev, 0x3b, 0x02);
1723 break;
1724 }
1725 } else {
1726 u8 reg2a = 0, reg2b = 0, reg2d = 0;
1727
1728 /* Get reg2a / reg2d base values */
1729 switch (sd->sensor) {
1730 case SENSOR_OV7630:
1731 reg2a = 0x08;
1732 reg2d = 0x01;
1733 break;
1734 case SENSOR_OV7648:
1735 reg2a = 0x11;
1736 reg2d = 0x81;
1737 break;
1738 }
1739
1740 switch (sd->freq) {
1741 case 0: /* Banding filter disabled */
1742 break;
1743 case 1: /* 50 hz (filter on and framerate adj) */
1744 reg2a |= 0x80;
1745 reg2b = 0xac;
1746 reg2d |= 0x04;
1747 break;
1748 case 2: /* 60 hz (filter on, no framerate adj) */
1749 reg2a |= 0x80;
1750 reg2d |= 0x04;
1751 break;
1752 }
1753 i2c_w1(gspca_dev, 0x2a, reg2a);
1754 i2c_w1(gspca_dev, 0x2b, reg2b);
1755 i2c_w1(gspca_dev, 0x2d, reg2d);
1756 }
1757}
1758
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001759static void setjpegqual(struct gspca_dev *gspca_dev)
1760{
1761 struct sd *sd = (struct sd *) gspca_dev;
1762 int i, sc;
1763
1764 if (sd->jpegqual < 50)
1765 sc = 5000 / sd->jpegqual;
1766 else
1767 sc = 200 - sd->jpegqual * 2;
1768#if USB_BUF_SZ < 64
1769#error "No room enough in usb_buf for quantization table"
1770#endif
1771 for (i = 0; i < 64; i++)
1772 gspca_dev->usb_buf[i] =
1773 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1774 usb_control_msg(gspca_dev->dev,
1775 usb_sndctrlpipe(gspca_dev->dev, 0),
1776 0x08,
1777 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1778 0x0100, 0,
1779 gspca_dev->usb_buf, 64,
1780 500);
1781 for (i = 0; i < 64; i++)
1782 gspca_dev->usb_buf[i] =
1783 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1784 usb_control_msg(gspca_dev->dev,
1785 usb_sndctrlpipe(gspca_dev->dev, 0),
1786 0x08,
1787 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1788 0x0140, 0,
1789 gspca_dev->usb_buf, 64,
1790 500);
1791
1792 sd->reg18 ^= 0x40;
1793 reg_w1(gspca_dev, 0x18, sd->reg18);
1794}
1795
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001796/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03001797static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001798{
1799 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001800 int i;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001801 u8 reg1, reg2, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001802 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001803 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001804 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001805 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1806 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1807 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1808 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001809 { 0x32, 0xdd, 0x32, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001810
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001811 /* create the JPEG header */
1812 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
Julia Lawall3eb02372009-07-19 07:09:32 -03001813 if (!sd->jpeg_hdr)
1814 return -ENOMEM;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001815 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1816 0x21); /* JPEG 422 */
1817 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1818
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001819 /* initialize the bridge */
1820 sn9c1xx = sn_tb[sd->sensor];
1821 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001822
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001823 /* initialize the sensor */
1824 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
1825
1826 switch (sd->sensor) {
1827 case SENSOR_OM6802:
1828 reg2 = 0x71;
1829 break;
1830 case SENSOR_SP80708:
1831 reg2 = 0x62;
1832 break;
1833 default:
1834 reg2 = 0x40;
1835 break;
1836 }
1837 reg_w1(gspca_dev, 0x02, reg2);
1838 reg_w1(gspca_dev, 0x02, reg2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001839
Jean-Francois Moine60017612008-07-18 08:46:19 -03001840 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1841 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1842 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1843 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1844 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1845 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1846 reg_w1(gspca_dev, 0xd3, 0x50);
1847 reg_w1(gspca_dev, 0xc6, 0x00);
1848 reg_w1(gspca_dev, 0xc7, 0x00);
1849 reg_w1(gspca_dev, 0xc8, 0x50);
1850 reg_w1(gspca_dev, 0xc9, 0x3c);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001851 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001852 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001853 case SENSOR_MT9V111:
1854 reg17 = 0xe0;
1855 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001856 case SENSOR_OV7630:
1857 reg17 = 0xe2;
1858 break;
1859 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001860 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001861 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001862 case SENSOR_OV7660:
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001863 reg17 = 0xa0;
1864 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001865 case SENSOR_PO1030:
1866 reg17 = 0xa0;
1867 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001868 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001869 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03001870 break;
1871 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001872 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001873/* set reg1 was here */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001874 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1875 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1876 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001877 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001878
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001879 setgamma(gspca_dev);
1880
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001881 for (i = 0; i < 8; i++)
1882 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001883 switch (sd->sensor) {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001884 case SENSOR_MT9V111:
1885 reg_w1(gspca_dev, 0x9a, 0x07);
1886 reg_w1(gspca_dev, 0x99, 0x59);
1887 break;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001888 case SENSOR_OM6802:
1889 reg_w1(gspca_dev, 0x9a, 0x08);
1890 reg_w1(gspca_dev, 0x99, 0x10);
1891 break;
Jean-Francois Moine62703302008-11-11 08:42:56 -03001892 case SENSOR_OV7648:
1893 reg_w1(gspca_dev, 0x9a, 0x0a);
1894 reg_w1(gspca_dev, 0x99, 0x60);
1895 break;
Jean-Francois Moinec8b9b2ca2009-04-26 14:46:12 -03001896 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001897 case SENSOR_SP80708:
1898 reg_w1(gspca_dev, 0x9a, 0x05);
1899 reg_w1(gspca_dev, 0x99, 0x59);
1900 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001901 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001902 reg_w1(gspca_dev, 0x9a, 0x08);
1903 reg_w1(gspca_dev, 0x99, 0x59);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001904 break;
1905 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001906
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001907 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1908 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1909 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1910 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001911
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001912 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001913 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001914 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001915 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001916 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001917 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1918 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001919 switch (sd->sensor) {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001920 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001921 if (mode) {
1922/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1923 reg1 = 0x06; /* clk 24Mz */
1924 } else {
1925 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001926/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001927 }
1928 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001929 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001930 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001931 if (mode) {
1932 reg1 = 0x04; /* 320 clk 48Mhz */
1933 } else {
1934/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03001935 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001936 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03001937 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001938 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001939 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001940 reg17 = 0x64; /* 640 MCKSIZE */
1941 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001942 case SENSOR_OV7630:
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001943 setvflip(sd);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001944 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03001945 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001946 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001947 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001948 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03001949 reg17 = 0x21;
1950/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001951 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001952 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001953 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001954 if (sd->bridge == BRIDGE_SN9C120) {
1955 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001956 reg17 = 0xa2;
1957 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03001958 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03001959 } else {
1960 reg17 = 0x22;
1961 reg1 = 0x06; /* 24 Mhz, video trf eneble
1962 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001963 }
1964 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001965 case SENSOR_PO1030:
1966 init = po1030_sensor_param1;
1967 reg17 = 0xa2;
1968 reg1 = 0x44;
1969 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001970 default:
1971/* case SENSOR_SP80708: */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001972 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001973 if (mode) {
1974/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001975 } else {
1976 reg1 = 0x46; /* 640 clk 48Mz */
1977 reg17 = 0xa2;
1978 }
1979 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001980 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001981
1982 /* more sensor initialization - param1 */
1983 if (init != NULL) {
1984 i2c_w_seq(gspca_dev, init);
1985/* init = NULL; */
1986 }
1987
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001988 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001989 reg_w(gspca_dev, 0xca, CA, 4);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001990 switch (sd->sensor) {
1991 case SENSOR_OV7630:
1992 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001993 case SENSOR_OV7660:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03001994 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001995 break;
1996 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001997 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001998 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1999 break;
2000 }
2001
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002002
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002003 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002004 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2005 reg_w1(gspca_dev, 0x18, sd->reg18);
2006 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002007
Jean-Francois Moine60017612008-07-18 08:46:19 -03002008 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002009 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002010
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002011 switch (sd->sensor) {
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002012 case SENSOR_OV7630:
2013 setvflip(sd);
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002014 break;
2015 }
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002016 setbrightness(gspca_dev);
2017 setcontrast(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002018 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002019 setfreq(gspca_dev);
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002020 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002021}
2022
2023static void sd_stopN(struct gspca_dev *gspca_dev)
2024{
2025 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002026 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002027 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002028 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002029 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002030 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002031 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002032 u8 data;
2033 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002034
2035 data = 0x0b;
2036 switch (sd->sensor) {
2037 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002038 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002039 data = 0x2b;
2040 break;
2041 case SENSOR_MI0360:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002042 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002043 data = 0x29;
2044 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002045 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002046 i2c_w8(gspca_dev, stopov7648);
2047 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002048 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002049 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002050 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002051 data = 0x29;
2052 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002053 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002054 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002055 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2056 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2057 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2058 reg_w1(gspca_dev, 0x01, data);
Jean-Francois Moine759aa3c2008-09-03 16:48:03 -03002059 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002060}
2061
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002062static void sd_stop0(struct gspca_dev *gspca_dev)
2063{
2064 struct sd *sd = (struct sd *) gspca_dev;
2065
2066 kfree(sd->jpeg_hdr);
2067}
2068
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002069static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002070{
2071 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002072 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002073 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002074 u8 luma_mean = 130;
2075 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002076
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002077 /* Thanks S., without your advice, autobright should not work :) */
2078 if (sd->ag_cnt < 0)
2079 return;
2080 if (--sd->ag_cnt >= 0)
2081 return;
2082 sd->ag_cnt = AG_CNT_START;
2083
2084 delta = atomic_read(&sd->avg_lum);
2085 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002086 if (delta < luma_mean - luma_delta ||
2087 delta > luma_mean + luma_delta) {
2088 switch (sd->sensor) {
2089 case SENSOR_HV7131R:
2090 expotimes = sd->exposure >> 8;
2091 expotimes += (luma_mean - delta) >> 4;
2092 if (expotimes < 0)
2093 expotimes = 0;
2094 sd->exposure = setexposure(gspca_dev,
2095 (unsigned int) (expotimes << 8));
2096 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002097 case SENSOR_OM6802:
2098 expotimes = sd->exposure;
2099 expotimes += (luma_mean - delta) >> 2;
2100 if (expotimes < 0)
2101 expotimes = 0;
2102 sd->exposure = setexposure(gspca_dev,
2103 (unsigned int) expotimes);
2104 setredblue(gspca_dev);
2105 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002106 default:
2107/* case SENSOR_MO4000: */
2108/* case SENSOR_MI0360: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002109/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002110 expotimes = sd->exposure;
2111 expotimes += (luma_mean - delta) >> 6;
2112 if (expotimes < 0)
2113 expotimes = 0;
2114 sd->exposure = setexposure(gspca_dev,
2115 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002116 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002117 break;
2118 }
2119 }
2120}
2121
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002122/* scan the URB packets */
2123/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002124static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002125 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002126 int len) /* iso packet length */
2127{
2128 struct sd *sd = (struct sd *) gspca_dev;
2129 int sof, avg_lum;
2130
2131 sof = len - 64;
2132 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2133
2134 /* end of frame */
2135 gspca_frame_add(gspca_dev, LAST_PACKET,
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002136 data, sof + 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002137 if (sd->ag_cnt < 0)
2138 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002139/* w1 w2 w3 */
2140/* w4 w5 w6 */
2141/* w7 w8 */
2142/* w4 */
2143 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2144/* w6 */
2145 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2146/* w2 */
2147 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2148/* w8 */
2149 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2150/* w5 */
2151 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2152 avg_lum >>= 4;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002153 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002154 return;
2155 }
2156 if (gspca_dev->last_packet_type == LAST_PACKET) {
2157
2158 /* put the JPEG 422 header */
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002159 gspca_frame_add(gspca_dev, FIRST_PACKET,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002160 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002161 }
Jean-Francois Moine76dd2722009-11-13 09:21:03 -03002162 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002163}
2164
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002165static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2166{
2167 struct sd *sd = (struct sd *) gspca_dev;
2168
2169 sd->brightness = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002170 if (gspca_dev->streaming)
2171 setbrightness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002172 return 0;
2173}
2174
2175static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2176{
2177 struct sd *sd = (struct sd *) gspca_dev;
2178
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002179 *val = sd->brightness;
2180 return 0;
2181}
2182
2183static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2184{
2185 struct sd *sd = (struct sd *) gspca_dev;
2186
2187 sd->contrast = val;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002188 if (gspca_dev->streaming)
2189 setcontrast(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002190 return 0;
2191}
2192
2193static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2194{
2195 struct sd *sd = (struct sd *) gspca_dev;
2196
2197 *val = sd->contrast;
2198 return 0;
2199}
2200
2201static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2202{
2203 struct sd *sd = (struct sd *) gspca_dev;
2204
2205 sd->colors = val;
2206 if (gspca_dev->streaming)
2207 setcolors(gspca_dev);
2208 return 0;
2209}
2210
2211static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2212{
2213 struct sd *sd = (struct sd *) gspca_dev;
2214
2215 *val = sd->colors;
2216 return 0;
2217}
2218
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002219static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2220{
2221 struct sd *sd = (struct sd *) gspca_dev;
2222
2223 sd->blue = val;
2224 if (gspca_dev->streaming)
2225 setredblue(gspca_dev);
2226 return 0;
2227}
2228
2229static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2230{
2231 struct sd *sd = (struct sd *) gspca_dev;
2232
2233 *val = sd->blue;
2234 return 0;
2235}
2236
2237static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2238{
2239 struct sd *sd = (struct sd *) gspca_dev;
2240
2241 sd->red = val;
2242 if (gspca_dev->streaming)
2243 setredblue(gspca_dev);
2244 return 0;
2245}
2246
2247static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2248{
2249 struct sd *sd = (struct sd *) gspca_dev;
2250
2251 *val = sd->red;
2252 return 0;
2253}
2254
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002255static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2256{
2257 struct sd *sd = (struct sd *) gspca_dev;
2258
2259 sd->gamma = val;
2260 if (gspca_dev->streaming)
2261 setgamma(gspca_dev);
2262 return 0;
2263}
2264
2265static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2266{
2267 struct sd *sd = (struct sd *) gspca_dev;
2268
2269 *val = sd->gamma;
2270 return 0;
2271}
2272
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002273static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2274{
2275 struct sd *sd = (struct sd *) gspca_dev;
2276
2277 sd->autogain = val;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002278 if (gspca_dev->streaming)
2279 setautogain(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002280 return 0;
2281}
2282
2283static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2284{
2285 struct sd *sd = (struct sd *) gspca_dev;
2286
2287 *val = sd->autogain;
2288 return 0;
2289}
2290
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002291static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2292{
2293 struct sd *sd = (struct sd *) gspca_dev;
2294
2295 sd->vflip = val;
Jean-Francois Moine79a90982008-10-05 04:21:24 -03002296 if (gspca_dev->streaming)
2297 setvflip(sd);
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002298 return 0;
2299}
2300
2301static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2302{
2303 struct sd *sd = (struct sd *) gspca_dev;
2304
2305 *val = sd->vflip;
2306 return 0;
2307}
2308
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002309static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2310{
2311 struct sd *sd = (struct sd *) gspca_dev;
2312
2313 sd->infrared = val;
2314 if (gspca_dev->streaming)
2315 setinfrared(sd);
2316 return 0;
2317}
2318
2319static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2320{
2321 struct sd *sd = (struct sd *) gspca_dev;
2322
2323 *val = sd->infrared;
2324 return 0;
2325}
2326
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002327static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2328{
2329 struct sd *sd = (struct sd *) gspca_dev;
2330
2331 sd->freq = val;
2332 if (gspca_dev->streaming)
2333 setfreq(gspca_dev);
2334 return 0;
2335}
2336
2337static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2338{
2339 struct sd *sd = (struct sd *) gspca_dev;
2340
2341 *val = sd->freq;
2342 return 0;
2343}
2344
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002345static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2346 struct v4l2_jpegcompression *jcomp)
2347{
2348 struct sd *sd = (struct sd *) gspca_dev;
2349
2350 if (jcomp->quality < QUALITY_MIN)
2351 sd->quality = QUALITY_MIN;
2352 else if (jcomp->quality > QUALITY_MAX)
2353 sd->quality = QUALITY_MAX;
2354 else
2355 sd->quality = jcomp->quality;
2356 if (gspca_dev->streaming)
2357 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2358 return 0;
2359}
2360
2361static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2362 struct v4l2_jpegcompression *jcomp)
2363{
2364 struct sd *sd = (struct sd *) gspca_dev;
2365
2366 memset(jcomp, 0, sizeof *jcomp);
2367 jcomp->quality = sd->quality;
2368 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2369 | V4L2_JPEG_MARKER_DQT;
2370 return 0;
2371}
2372
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002373static int sd_querymenu(struct gspca_dev *gspca_dev,
2374 struct v4l2_querymenu *menu)
2375{
2376 switch (menu->id) {
2377 case V4L2_CID_POWER_LINE_FREQUENCY:
2378 switch (menu->index) {
2379 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2380 strcpy((char *) menu->name, "NoFliker");
2381 return 0;
2382 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2383 strcpy((char *) menu->name, "50 Hz");
2384 return 0;
2385 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2386 strcpy((char *) menu->name, "60 Hz");
2387 return 0;
2388 }
2389 break;
2390 }
2391 return -EINVAL;
2392}
2393
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002394/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002395static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002396 .name = MODULE_NAME,
2397 .ctrls = sd_ctrls,
2398 .nctrls = ARRAY_SIZE(sd_ctrls),
2399 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002400 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002401 .start = sd_start,
2402 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002403 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002404 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002405 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002406 .get_jcomp = sd_get_jcomp,
2407 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002408 .querymenu = sd_querymenu,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002409};
2410
2411/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002412#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002413 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002414 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002415static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002416#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002417 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2418 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002419#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002420 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2421 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2422 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2423 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2424 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2425 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2426 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2427/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2428 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2429/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2430/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2431 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2432/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2433 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2434/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2435/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2436/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
2437 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2438/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2439/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
2440 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002441#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002442 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2443 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002444#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002445 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
2446/* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, P1030xC)}, */
2447/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2448 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2449 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2450 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2451 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2452/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2453/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2454/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2455 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002456/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002457 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002458 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2459 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2460/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Hans de Goede222a07f2008-09-03 17:12:20 -03002461#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002462 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002463#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002464/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2465 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2466 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03002467#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002468 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03002469#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002470 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2471 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
2472/* {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, *sn9c120b*/
2473 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2474 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002475 {}
2476};
2477MODULE_DEVICE_TABLE(usb, device_table);
2478
2479/* -- device connect -- */
2480static int sd_probe(struct usb_interface *intf,
2481 const struct usb_device_id *id)
2482{
2483 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2484 THIS_MODULE);
2485}
2486
2487static struct usb_driver sd_driver = {
2488 .name = MODULE_NAME,
2489 .id_table = device_table,
2490 .probe = sd_probe,
2491 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002492#ifdef CONFIG_PM
2493 .suspend = gspca_suspend,
2494 .resume = gspca_resume,
2495#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002496};
2497
2498/* -- module insert / remove -- */
2499static int __init sd_mod_init(void)
2500{
Alexey Klimovf69e9522009-01-01 13:02:07 -03002501 int ret;
2502 ret = usb_register(&sd_driver);
2503 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -03002504 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -03002505 info("registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002506 return 0;
2507}
2508static void __exit sd_mod_exit(void)
2509{
2510 usb_deregister(&sd_driver);
2511 info("deregistered");
2512}
2513
2514module_init(sd_mod_init);
2515module_exit(sd_mod_exit);