blob: f5dab675c96c038183d3dfe2d71b34eefd9ee036 [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03002 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003 *
Jean-François Moine27c6f9e2010-04-02 06:59:13 -03004 * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr>
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03005 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "sonixj"
23
Hans de Goede9712a8b2010-01-31 12:54:29 -030024#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030025#include "gspca.h"
26#include "jpeg.h"
27
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030028#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29
Jean-François Moine27c6f9e2010-04-02 06:59:13 -030030MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030031MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL");
33
Jean-François Moine72b667e2010-10-02 04:35:25 -030034/* controls */
35enum e_ctrl {
36 BRIGHTNESS,
37 CONTRAST,
38 COLORS,
39 BLUE,
40 RED,
41 GAMMA,
42 AUTOGAIN,
Németh Márton76ad3b62010-10-19 03:33:47 -030043 HFLIP,
Jean-François Moine72b667e2010-10-02 04:35:25 -030044 VFLIP,
45 SHARPNESS,
46 INFRARED,
47 FREQ,
48 NCTRLS /* number of controls */
49};
50
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030051/* specific webcam descriptor */
52struct sd {
53 struct gspca_dev gspca_dev; /* !! must be the first item */
54
Jean-François Moine72b667e2010-10-02 04:35:25 -030055 struct gspca_ctrl ctrls[NCTRLS];
56
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030057 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030058 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030059
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030060 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030061#define QUALITY_MIN 60
62#define QUALITY_MAX 95
63#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030064 u8 jpegqual; /* webcam quality */
65
66 u8 reg18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030067
Jean-Francois Moine98819182009-01-19 07:37:33 -030068 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030069#define AG_CNT_START 13
70
Jean-Francois Moine98819182009-01-19 07:37:33 -030071 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030072#define BRIDGE_SN9C102P 0
73#define BRIDGE_SN9C105 1
74#define BRIDGE_SN9C110 2
75#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030076 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030077 u8 i2c_addr;
78
79 u8 jpeg_hdr[JPEG_HDR_SZ];
80};
81enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030082 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030083 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030084 SENSOR_HV7131R,
85 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030086 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030087 SENSOR_MO4000,
88 SENSOR_MT9V111,
89 SENSOR_OM6802,
90 SENSOR_OV7630,
91 SENSOR_OV7648,
92 SENSOR_OV7660,
93 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030094 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030095 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030096 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030097};
98
99/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300100static void setbrightness(struct gspca_dev *gspca_dev);
101static void setcontrast(struct gspca_dev *gspca_dev);
102static void setcolors(struct gspca_dev *gspca_dev);
103static void setredblue(struct gspca_dev *gspca_dev);
104static void setgamma(struct gspca_dev *gspca_dev);
105static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300106static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300107static void setsharpness(struct gspca_dev *gspca_dev);
108static void setinfrared(struct gspca_dev *gspca_dev);
109static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300110
Jean-François Moine72b667e2010-10-02 04:35:25 -0300111static const struct ctrl sd_ctrls[NCTRLS] = {
112[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300113 {
114 .id = V4L2_CID_BRIGHTNESS,
115 .type = V4L2_CTRL_TYPE_INTEGER,
116 .name = "Brightness",
117 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300118 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300119 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300120 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300121 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300122 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300123 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300124[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300125 {
126 .id = V4L2_CID_CONTRAST,
127 .type = V4L2_CTRL_TYPE_INTEGER,
128 .name = "Contrast",
129 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300130#define CONTRAST_MAX 127
131 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300133 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300134 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300135 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300136 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300137[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300138 {
139 .id = V4L2_CID_SATURATION,
140 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300141 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300143 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300144 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300145#define COLORS_DEF 25
146 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300147 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300148 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300149 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300150[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300151 {
152 .id = V4L2_CID_BLUE_BALANCE,
153 .type = V4L2_CTRL_TYPE_INTEGER,
154 .name = "Blue Balance",
155 .minimum = 24,
156 .maximum = 40,
157 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300158 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300159 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300160 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300161 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300162[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300163 {
164 .id = V4L2_CID_RED_BALANCE,
165 .type = V4L2_CTRL_TYPE_INTEGER,
166 .name = "Red Balance",
167 .minimum = 24,
168 .maximum = 40,
169 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300170 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300171 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300172 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300173 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300174[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300175 {
176 .id = V4L2_CID_GAMMA,
177 .type = V4L2_CTRL_TYPE_INTEGER,
178 .name = "Gamma",
179 .minimum = 0,
180 .maximum = 40,
181 .step = 1,
182#define GAMMA_DEF 20
183 .default_value = GAMMA_DEF,
184 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300185 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300186 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300187[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300188 {
189 .id = V4L2_CID_AUTOGAIN,
190 .type = V4L2_CTRL_TYPE_BOOLEAN,
191 .name = "Auto Gain",
192 .minimum = 0,
193 .maximum = 1,
194 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300195 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300196 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300197 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300198 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300199[HFLIP] = {
200 {
201 .id = V4L2_CID_HFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
203 .name = "Mirror",
204 .minimum = 0,
205 .maximum = 1,
206 .step = 1,
207 .default_value = 0,
208 },
209 .set_control = sethvflip
210 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300211[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300212 {
213 .id = V4L2_CID_VFLIP,
214 .type = V4L2_CTRL_TYPE_BOOLEAN,
215 .name = "Vflip",
216 .minimum = 0,
217 .maximum = 1,
218 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300219 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300220 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300221 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300222 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300223[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300224 {
225 .id = V4L2_CID_SHARPNESS,
226 .type = V4L2_CTRL_TYPE_INTEGER,
227 .name = "Sharpness",
228 .minimum = 0,
229 .maximum = 255,
230 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300231 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300232 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300233 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300234 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300235/* mt9v111 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300236[INFRARED] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300237 {
238 .id = V4L2_CID_INFRARED,
239 .type = V4L2_CTRL_TYPE_BOOLEAN,
240 .name = "Infrared",
241 .minimum = 0,
242 .maximum = 1,
243 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300244 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300245 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300246 .set_control = setinfrared
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300247 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300248/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300249[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300250 {
251 .id = V4L2_CID_POWER_LINE_FREQUENCY,
252 .type = V4L2_CTRL_TYPE_MENU,
253 .name = "Light frequency filter",
254 .minimum = 0,
255 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
256 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300257 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300258 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300259 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300260 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300261};
262
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300263/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300264static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300265[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
266 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300267 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300268 (1 << VFLIP) |
269 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300270
Jean-François Moine72b667e2010-10-02 04:35:25 -0300271[SENSOR_GC0307] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300272 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300273 (1 << VFLIP) |
274 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300275
Jean-François Moine72b667e2010-10-02 04:35:25 -0300276[SENSOR_HV7131R] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300277 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300278 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300279
Jean-François Moine72b667e2010-10-02 04:35:25 -0300280[SENSOR_MI0360] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300281 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300282 (1 << VFLIP) |
283 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300284
Jean-François Moine72b667e2010-10-02 04:35:25 -0300285[SENSOR_MI0360B] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300286 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300287 (1 << VFLIP) |
288 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300289
Jean-François Moine72b667e2010-10-02 04:35:25 -0300290[SENSOR_MO4000] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300291 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300292 (1 << VFLIP) |
293 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300294
Németh Márton76ad3b62010-10-19 03:33:47 -0300295[SENSOR_MT9V111] = (1 << HFLIP) |
296 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300297 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300298
Jean-François Moine72b667e2010-10-02 04:35:25 -0300299[SENSOR_OM6802] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300300 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300301 (1 << VFLIP) |
302 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300303
Németh Márton76ad3b62010-10-19 03:33:47 -0300304[SENSOR_OV7630] = (1 << INFRARED) |
305 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300306
Németh Márton76ad3b62010-10-19 03:33:47 -0300307[SENSOR_OV7648] = (1 << INFRARED) |
308 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300309
Jean-François Moine72b667e2010-10-02 04:35:25 -0300310[SENSOR_OV7660] = (1 << AUTOGAIN) |
311 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300312 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300313 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300314
Jean-François Moine72b667e2010-10-02 04:35:25 -0300315[SENSOR_PO1030] = (1 << AUTOGAIN) |
316 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300317 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300318 (1 << VFLIP) |
319 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300320
Jean-François Moine72b667e2010-10-02 04:35:25 -0300321[SENSOR_PO2030N] = (1 << AUTOGAIN) |
322 (1 << INFRARED) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300323 (1 << FREQ),
324[SENSOR_SOI768] = (1 << AUTOGAIN) |
325 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300326 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300327 (1 << VFLIP) |
328 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300329
Jean-François Moine72b667e2010-10-02 04:35:25 -0300330[SENSOR_SP80708] = (1 << AUTOGAIN) |
331 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300332 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300333 (1 << VFLIP) |
334 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300335};
336
Jean-Francois Moine64677572009-12-20 12:31:28 -0300337static const struct v4l2_pix_format cif_mode[] = {
338 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
339 .bytesperline = 352,
340 .sizeimage = 352 * 288 * 4 / 8 + 590,
341 .colorspace = V4L2_COLORSPACE_JPEG,
342 .priv = 0},
343};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300344static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300345 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
346 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300347 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300348 .colorspace = V4L2_COLORSPACE_JPEG,
349 .priv = 2},
350 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
351 .bytesperline = 320,
352 .sizeimage = 320 * 240 * 3 / 8 + 590,
353 .colorspace = V4L2_COLORSPACE_JPEG,
354 .priv = 1},
355 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
356 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300357 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
358 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300359 .colorspace = V4L2_COLORSPACE_JPEG,
360 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300361};
362
Jean-Francois Moine64677572009-12-20 12:31:28 -0300363static const u8 sn_adcm1700[0x1c] = {
364/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300365 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300366/* reg8 reg9 rega regb regc regd rege regf */
367 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
368/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
369 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
370/* reg18 reg19 reg1a reg1b */
371 0x06, 0x00, 0x00, 0x00
372};
373
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300374static const u8 sn_gc0307[0x1c] = {
375/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
376 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
377/* reg8 reg9 rega regb regc regd rege regf */
378 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
379/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
380 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
381/* reg18 reg19 reg1a reg1b */
382 0x06, 0x00, 0x00, 0x00
383};
384
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300385static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300386/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300387 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300388/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300389 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300390/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
391 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300392/* reg18 reg19 reg1a reg1b */
393 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300394};
395
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300396static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300397/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300398 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300399/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300400 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300401/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
402 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300403/* reg18 reg19 reg1a reg1b */
404 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300405};
406
Jean-François Moinea067db82010-10-01 07:51:24 -0300407static const u8 sn_mi0360b[0x1c] = {
408/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
409 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
410/* reg8 reg9 rega regb regc regd rege regf */
411 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
412/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
413 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
414/* reg18 reg19 reg1a reg1b */
415 0x06, 0x00, 0x00, 0x00
416};
417
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300418static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300419/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300420 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300421/* reg8 reg9 rega regb regc regd rege regf */
422 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
423/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
424 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300425/* reg18 reg19 reg1a reg1b */
426 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300427};
428
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300429static const u8 sn_mt9v111[0x1c] = {
430/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
431 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
432/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300433 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300434/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
435 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
436/* reg18 reg19 reg1a reg1b */
437 0x06, 0x00, 0x00, 0x00
438};
439
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300440static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300441/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300442 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300443/* reg8 reg9 rega regb regc regd rege regf */
444 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
446 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300447/* reg18 reg19 reg1a reg1b */
448 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300449};
450
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300451static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300452/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300453 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300454/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300455 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300456/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
457 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300458/* reg18 reg19 reg1a reg1b */
459 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300460};
461
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300462static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300463/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300464 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300465/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300466 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300467/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300468 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300469/* reg18 reg19 reg1a reg1b */
470 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300471};
472
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300473static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300474/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300475 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300476/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300477 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300478/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
479 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300480/* reg18 reg19 reg1a reg1b */
481 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300482};
483
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300484static const u8 sn_po1030[0x1c] = {
485/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
486 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
487/* reg8 reg9 rega regb regc regd rege regf */
488 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
489/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
490 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
491/* reg18 reg19 reg1a reg1b */
492 0x07, 0x00, 0x00, 0x00
493};
494
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300495static const u8 sn_po2030n[0x1c] = {
496/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
497 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
498/* reg8 reg9 rega regb regc regd rege regf */
499 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
500/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
501 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
502/* reg18 reg19 reg1a reg1b */
503 0x07, 0x00, 0x00, 0x00
504};
505
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300506static const u8 sn_soi768[0x1c] = {
507/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
508 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
509/* reg8 reg9 rega regb regc regd rege regf */
510 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
511/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
512 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
513/* reg18 reg19 reg1a reg1b */
514 0x07, 0x00, 0x00, 0x00
515};
516
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300517static const u8 sn_sp80708[0x1c] = {
518/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
519 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
520/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300521 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300522/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
523 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
524/* reg18 reg19 reg1a reg1b */
525 0x07, 0x00, 0x00, 0x00
526};
527
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300528/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300529static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300530[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300531[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300532[SENSOR_HV7131R] = sn_hv7131,
533[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300534[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300535[SENSOR_MO4000] = sn_mo4000,
536[SENSOR_MT9V111] = sn_mt9v111,
537[SENSOR_OM6802] = sn_om6802,
538[SENSOR_OV7630] = sn_ov7630,
539[SENSOR_OV7648] = sn_ov7648,
540[SENSOR_OV7660] = sn_ov7660,
541[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300542[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300543[SENSOR_SOI768] = sn_soi768,
544[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300545};
546
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300547/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300548static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300549 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
550 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
551};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300552/* gamma for sensor ADCM1700 */
553static const u8 gamma_spec_0[17] = {
554 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
555 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
556};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300557/* gamma for sensors HV7131R and MT9V111 */
558static const u8 gamma_spec_1[17] = {
559 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
560 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
561};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300562/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300563static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300564 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
565 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
566};
567/* gamma for sensor SP80708 */
568static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300569 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
570 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
571};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300572
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300573/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300574static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300575 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
576 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
577 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
578 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300579};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300580
581#define DELAY 0xdd
582
Jean-Francois Moine64677572009-12-20 12:31:28 -0300583static const u8 adcm1700_sensor_init[][8] = {
584 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300585 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300586 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300587 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300588 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300589 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
590 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
591 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
592 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
593 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300594 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300595 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300596 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300597 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
598 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
599 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
600 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
601 {}
602};
603static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300604 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300605 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
606
607 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
609 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
610 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300611 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300612
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300613 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
614 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
616 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300617 {}
618};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300619static const u8 gc0307_sensor_init[][8] = {
620 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300640 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300641 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
658 {}
659};
660static const u8 gc0307_sensor_param1[][8] = {
661 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
662 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
663 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
664 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
665/*param3*/
666 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
667 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300668 {}
669};
670
Jean-Francois Moine98819182009-01-19 07:37:33 -0300671static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300672 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
673 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
674 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
675/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
676 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
677 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
678/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300679
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300680 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
681 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
682 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
683 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
684 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
685 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
686 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
687 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300688
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300689 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300691 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300692 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300694
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300695 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
696 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
698 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
699 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300700 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
701 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300702 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300703};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300704static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300705 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300706 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300707 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300708 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
709 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
710 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
711 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
712 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
713 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
714 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
715 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
716 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
717 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
718 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
719 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
720 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
722 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
724 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
726 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300727 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300728 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
730 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
731 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
732 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
734 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
736 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
737 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300738
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300739 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
740 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
741 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
743 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300744
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300745 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
746 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
747 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
748 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300749
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300750 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
751 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
752/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
753/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
754 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
755 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300756 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300757};
Jean-François Moinea067db82010-10-01 07:51:24 -0300758static const u8 mi0360b_sensor_init[][8] = {
759 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
760 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300761 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300762 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300763 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300764 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
765 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
766 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
767 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
768 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
769 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
770 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
771 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
773 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
774 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
775 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
783 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
784 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
786 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
787 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
788 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
790 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
793 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
794
795 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
796 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
797 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
798 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
799 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
800 {}
801};
802static const u8 mi0360b_sensor_param1[][8] = {
803 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
804 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
807
808 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
809 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
810 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
811 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
812 {}
813};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300814static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300815 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
816 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
817 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
818 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
819 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
820 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300835 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300836};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300837static const u8 mt9v111_sensor_init[][8] = {
838 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300839 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300840 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
841 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
842 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
843 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300844 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
845 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
846 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
847 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300848 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300849 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
850 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
851 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
852 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
853 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300854 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300855 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300856 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
857 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
858 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
859 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
860 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
861 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
862 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
863 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
864 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
865 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300866 {}
867};
868static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300869 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
870 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300871 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300872 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
873 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
874 /*******/
875 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
876 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
877 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
878 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
879 {}
880};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300881static const u8 om6802_init0[2][8] = {
882/*fixme: variable*/
883 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
884 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
885};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300886static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300887 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
888 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300889 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300890 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300891 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300892/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
893 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300894 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300895/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
896 * set color mode */
897/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
898 * max AGC value in AE */
899/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
900 * preset AGC */
901/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
902 * preset brightness */
903/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
904 * preset contrast */
905/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
906 * preset gamma */
907 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300908 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300909 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
910 /* preset shutter */
911/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
912 * auto frame rate */
913/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300914 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
915 {}
916};
917static const u8 om6802_sensor_param1[][8] = {
918 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
919 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
920 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
921 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300922 {}
923};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300924static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300925 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
926 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300927 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300928 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
929 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300930 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300931 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300932/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300933 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
934 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300935/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
936 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
937 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300938 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
939 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
940 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
941 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
942 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
943 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
944 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
945 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
946 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
947 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
948 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
949 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
950 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
951 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
952 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
953 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
954 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
955 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
956 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
957 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
958 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
959 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
960 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300961 {}
962};
963static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300964 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
965 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
966/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300967/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
968 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300969 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
970 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
971 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300972/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300973/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
974/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300975/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300976 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300977/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300978 {}
979};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300980
Jean-Francois Moine98819182009-01-19 07:37:33 -0300981static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300982 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
983 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300984 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300985 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
986 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
987 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
988 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
989 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
990 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
991 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
992 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
993 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
994 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
995 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
996 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
997 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
998 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
999 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1000 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1001 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1002 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1003 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1004
1005 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1006/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1007/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001008/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001009 {}
1010};
1011static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001012/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001013/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1014 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001015 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1016 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1017/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1018/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1019/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1020/*...*/
1021 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1022/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1023/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1024/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1025/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1026/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1027
1028 {}
1029};
1030
Jean-Francois Moine98819182009-01-19 07:37:33 -03001031static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001032 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001033 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001034 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001035 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001036 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001037 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001038 /* GAIN BLUE RED VREF */
1039 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1040 /* COM 1 BAVE GEAVE AECHH */
1041 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1042 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001043 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001044 /* AECH CLKRC COM7 COM8 */
1045 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1046 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1047 /* HSTART HSTOP VSTRT VSTOP */
1048 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1049 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1050 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1051 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001052/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1053 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001054 /* AEW AEB VPT BBIAS */
1055 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1056 /* GbBIAS RSVD EXHCH EXHCL */
1057 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1058 /* RBIAS ADVFL ASDVFH YAVE */
1059 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1060 /* HSYST HSYEN HREF */
1061 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1062 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1063 /* ADC ACOM OFON TSLB */
1064 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1065 /* COM11 COM12 COM13 COM14 */
1066 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1067 /* EDGE COM15 COM16 COM17 */
1068 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1069 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1070 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1071 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1072 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1073 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1074 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1075 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1076 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1077 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1078 /* LCC1 LCC2 LCC3 LCC4 */
1079 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001080 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001081 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001082 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001083 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1084 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1085 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1086 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1087 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1088 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1089 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1090 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1091 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001092 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001093/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001094 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001095 {}
1096};
1097static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001098 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001099 /* bits[3..0]reserved */
1100 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1101 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1102 /* VREF vertical frame ctrl */
1103 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001104 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1105 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1106 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1107 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1108/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001109/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001110/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001111 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001112 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1113 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1114 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1115/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001116/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001117/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001118/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001119 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1120 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1121 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1122 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001123 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001124};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001125
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001126static const u8 po1030_sensor_init[][8] = {
1127/* the sensor registers are described in m5602/m5602_po1030.h */
1128 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001129 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001130 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1132 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1133 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1134 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1135 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1136 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1137 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1138 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1139 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1140 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1141 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1142 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1143 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1144 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1145 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1146 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1148 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1149 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1150 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1151 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1152 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1153 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1154 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1155 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1156
1157 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1158 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1159 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1160 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1161 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1162 {}
1163};
1164static const u8 po1030_sensor_param1[][8] = {
1165/* from ms-win traces - these values change with auto gain/expo/wb.. */
1166 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1167 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1168/* mean values */
1169 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1170 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1171 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1172
1173 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1174 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1175 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1176/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1177 {}
1178};
1179
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001180static const u8 po2030n_sensor_init[][8] = {
1181 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1182 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001183 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001184 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1185 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001186 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001187 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1188 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1189 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1190 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1191 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1192 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1193 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1194 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1195 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1197 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1198 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1199 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1200 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1202 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1203 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1204 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1207 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1208 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1209 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1216 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1221 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1222 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1225 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1226 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1227 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1230 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1231 {}
1232};
1233static const u8 po2030n_sensor_param1[][8] = {
1234 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001235 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001236 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1237 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1239/*param2*/
1240 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1242 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1243 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1244 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1245 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1246 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1247/*after start*/
1248 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001249 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001250 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001251 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001252 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1253 {}
1254};
1255
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001256static const u8 soi768_sensor_init[][8] = {
1257 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001258 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001259 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1260 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1263 {}
1264};
1265static const u8 soi768_sensor_param1[][8] = {
1266 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1267 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1268 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1270 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1271/* */
1272/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1273/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1274 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1275/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1276 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1277/* the next sequence should be used for auto gain */
1278 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1279 /* global gain ? : 07 - change with 0x15 at the end */
1280 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1281 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1282 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1283 /* exposure ? : 0200 - change with 0x1e at the end */
1284 {}
1285};
1286
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001287static const u8 sp80708_sensor_init[][8] = {
1288 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1289 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1290 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1291 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1292 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1293 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1294 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1295 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1296 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1297 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001359 {}
1360};
1361static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001362 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1368 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1369 {}
1370};
1371
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001372static const u8 (*sensor_init[])[8] = {
1373[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001374[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001375[SENSOR_HV7131R] = hv7131r_sensor_init,
1376[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001377[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001378[SENSOR_MO4000] = mo4000_sensor_init,
1379[SENSOR_MT9V111] = mt9v111_sensor_init,
1380[SENSOR_OM6802] = om6802_sensor_init,
1381[SENSOR_OV7630] = ov7630_sensor_init,
1382[SENSOR_OV7648] = ov7648_sensor_init,
1383[SENSOR_OV7660] = ov7660_sensor_init,
1384[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001385[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001386[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001387[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001388};
1389
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001390/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001391static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001392 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001393{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001394 int ret;
1395
1396 if (gspca_dev->usb_err < 0)
1397 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001398#ifdef GSPCA_DEBUG
1399 if (len > USB_BUF_SZ) {
1400 err("reg_r: buffer overflow");
1401 return;
1402 }
1403#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001404 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001405 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001406 0,
1407 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1408 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001409 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001410 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001411 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001412 if (ret < 0) {
1413 err("reg_r err %d", ret);
1414 gspca_dev->usb_err = ret;
1415 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001416}
1417
Jean-Francois Moine60017612008-07-18 08:46:19 -03001418static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001419 u16 value,
1420 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001421{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001422 int ret;
1423
1424 if (gspca_dev->usb_err < 0)
1425 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001426 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001427 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001428 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001429 usb_sndctrlpipe(gspca_dev->dev, 0),
1430 0x08,
1431 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1432 value,
1433 0,
1434 gspca_dev->usb_buf, 1,
1435 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001436 if (ret < 0) {
1437 err("reg_w1 err %d", ret);
1438 gspca_dev->usb_err = ret;
1439 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001440}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001441static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001442 u16 value,
1443 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001444 int len)
1445{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001446 int ret;
1447
1448 if (gspca_dev->usb_err < 0)
1449 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001450 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001451 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001452#ifdef GSPCA_DEBUG
1453 if (len > USB_BUF_SZ) {
1454 err("reg_w: buffer overflow");
1455 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001456 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001457#endif
1458 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001459 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001460 usb_sndctrlpipe(gspca_dev->dev, 0),
1461 0x08,
1462 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1463 value, 0,
1464 gspca_dev->usb_buf, len,
1465 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001466 if (ret < 0) {
1467 err("reg_w err %d", ret);
1468 gspca_dev->usb_err = ret;
1469 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001470}
1471
Jean-Francois Moine60017612008-07-18 08:46:19 -03001472/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001473static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001474{
1475 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001476 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001477
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001478 if (gspca_dev->usb_err < 0)
1479 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001480 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001481 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001482 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001483 case SENSOR_OM6802:
1484 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001485 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1486 break;
1487 default: /* i2c command = a1 (400 kHz) */
1488 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1489 break;
1490 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001491 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001492 gspca_dev->usb_buf[2] = reg;
1493 gspca_dev->usb_buf[3] = val;
1494 gspca_dev->usb_buf[4] = 0;
1495 gspca_dev->usb_buf[5] = 0;
1496 gspca_dev->usb_buf[6] = 0;
1497 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001498 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001499 usb_sndctrlpipe(gspca_dev->dev, 0),
1500 0x08,
1501 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1502 0x08, /* value = i2c */
1503 0,
1504 gspca_dev->usb_buf, 8,
1505 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001506 if (ret < 0) {
1507 err("i2c_w1 err %d", ret);
1508 gspca_dev->usb_err = ret;
1509 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001510}
1511
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001512/* I2C write 8 bytes */
1513static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001514 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001515{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001516 int ret;
1517
1518 if (gspca_dev->usb_err < 0)
1519 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001520 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1521 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001522 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001523 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001524 usb_sndctrlpipe(gspca_dev->dev, 0),
1525 0x08,
1526 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1527 0x08, 0, /* value, index */
1528 gspca_dev->usb_buf, 8,
1529 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001530 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001531 if (ret < 0) {
1532 err("i2c_w8 err %d", ret);
1533 gspca_dev->usb_err = ret;
1534 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001535}
1536
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001537/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1538static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001539{
1540 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001541 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001542
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001543 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001544 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001545 case SENSOR_OM6802:
1546 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001547 mode[0] = 0x80 | 0x10;
1548 break;
1549 default: /* i2c command = 91 (400 kHz) */
1550 mode[0] = 0x81 | 0x10;
1551 break;
1552 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001553 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001554 mode[2] = reg;
1555 mode[3] = 0;
1556 mode[4] = 0;
1557 mode[5] = 0;
1558 mode[6] = 0;
1559 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001560 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001561 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001562 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001563 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001564 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001565 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001566 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001567}
1568
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001569static void i2c_w_seq(struct gspca_dev *gspca_dev,
1570 const u8 (*data)[8])
1571{
1572 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001573 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001574 i2c_w8(gspca_dev, *data);
1575 else
1576 msleep((*data)[1]);
1577 data++;
1578 }
1579}
1580
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001581static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001582{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001583 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001584 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001585 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001586 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001587 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001588 if (gspca_dev->usb_buf[0] == 0x02
1589 && gspca_dev->usb_buf[1] == 0x09
1590 && gspca_dev->usb_buf[2] == 0x01
1591 && gspca_dev->usb_buf[3] == 0x00
1592 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001593 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1594 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001595 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001596 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001597 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1598 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001599}
1600
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001601static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001602{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001603 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001604 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001605 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001606 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001607 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001608 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1609 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1610 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1611 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1612 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001613 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001614 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1615 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1616 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1617 {}
1618 },
1619 };
1620
1621 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1622 reg_w1(gspca_dev, 0x17, 0x62);
1623 reg_w1(gspca_dev, 0x01, 0x08);
1624 for (j = 0; j < 3; j++)
1625 i2c_w8(gspca_dev, probe_tb[i][j]);
1626 msleep(2);
1627 reg_r(gspca_dev, 0x0a, 5);
1628 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1629 if (probe_tb[i][3][0] != 0)
1630 i2c_w8(gspca_dev, probe_tb[i][3]);
1631 reg_w1(gspca_dev, 0x01, 0x29);
1632 reg_w1(gspca_dev, 0x17, 0x42);
1633 if (val != 0xffff)
1634 break;
1635 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001636 if (gspca_dev->usb_err < 0)
1637 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001638 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001639 case 0x8221:
1640 PDEBUG(D_PROBE, "Sensor mi0360b");
1641 sd->sensor = SENSOR_MI0360B;
1642 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001643 case 0x823a:
1644 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001645 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001646 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001647 case 0x8243:
1648 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001649 break;
1650 default:
1651 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1652 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001653 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001654}
1655
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001656static void ov7630_probe(struct gspca_dev *gspca_dev)
1657{
1658 struct sd *sd = (struct sd *) gspca_dev;
1659 u16 val;
1660
1661 /* check ov76xx */
1662 reg_w1(gspca_dev, 0x17, 0x62);
1663 reg_w1(gspca_dev, 0x01, 0x08);
1664 sd->i2c_addr = 0x21;
1665 i2c_r(gspca_dev, 0x0a, 2);
1666 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1667 reg_w1(gspca_dev, 0x01, 0x29);
1668 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001669 if (gspca_dev->usb_err < 0)
1670 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001671 if (val == 0x7628) { /* soi768 */
1672 sd->sensor = SENSOR_SOI768;
1673/*fixme: only valid for 0c45:613e?*/
1674 gspca_dev->cam.input_flags =
1675 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1676 PDEBUG(D_PROBE, "Sensor soi768");
1677 return;
1678 }
1679 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1680}
1681
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001682static void ov7648_probe(struct gspca_dev *gspca_dev)
1683{
1684 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001685 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001686
1687 /* check ov76xx */
1688 reg_w1(gspca_dev, 0x17, 0x62);
1689 reg_w1(gspca_dev, 0x01, 0x08);
1690 sd->i2c_addr = 0x21;
1691 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001692 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001693 reg_w1(gspca_dev, 0x01, 0x29);
1694 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001695 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1696 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1697 return;
1698 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001699
1700 /* check po1030 */
1701 reg_w1(gspca_dev, 0x17, 0x62);
1702 reg_w1(gspca_dev, 0x01, 0x08);
1703 sd->i2c_addr = 0x6e;
1704 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001705 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1706 reg_w1(gspca_dev, 0x01, 0x29);
1707 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001708 if (gspca_dev->usb_err < 0)
1709 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001710 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001711 PDEBUG(D_PROBE, "Sensor po1030");
1712 sd->sensor = SENSOR_PO1030;
1713 return;
1714 }
1715
Jean-François Moine0b656322010-09-13 05:19:58 -03001716 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001717}
1718
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001719/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1720static void po2030n_probe(struct gspca_dev *gspca_dev)
1721{
1722 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001723 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001724
1725 /* check gc0307 */
1726 reg_w1(gspca_dev, 0x17, 0x62);
1727 reg_w1(gspca_dev, 0x01, 0x08);
1728 reg_w1(gspca_dev, 0x02, 0x22);
1729 sd->i2c_addr = 0x21;
1730 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001731 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001732 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1733 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001734 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001735 PDEBUG(D_PROBE, "Sensor gc0307");
1736 sd->sensor = SENSOR_GC0307;
1737 return;
1738 }
1739
1740 /* check po2030n */
1741 reg_w1(gspca_dev, 0x17, 0x62);
1742 reg_w1(gspca_dev, 0x01, 0x0a);
1743 sd->i2c_addr = 0x6e;
1744 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001745 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001746 reg_w1(gspca_dev, 0x01, 0x29);
1747 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001748 if (gspca_dev->usb_err < 0)
1749 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001750 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001751 PDEBUG(D_PROBE, "Sensor po2030n");
1752/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001753 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001754 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001755 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001756}
1757
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001758static void bridge_init(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001759 const u8 *sn9c1xx)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001760{
1761 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine19697b52010-07-14 06:33:51 -03001762 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03001763 const u8 *reg9a;
1764 static const u8 reg9a_def[] =
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001765 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1766 static const u8 reg9a_spec[] =
1767 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
Jean-Francois Moine98819182009-01-19 07:37:33 -03001768 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001769
Hans de Goede9712a8b2010-01-31 12:54:29 -03001770 /* sensor clock already enabled in sd_init */
1771 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001772 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001773
1774 /* configure gpio */
Jean-François Moine19697b52010-07-14 06:33:51 -03001775 reg0102[0] = sn9c1xx[1];
1776 reg0102[1] = sn9c1xx[2];
1777 if (gspca_dev->audio)
1778 reg0102[1] |= 0x04; /* keep the audio connection */
1779 reg_w(gspca_dev, 0x01, reg0102, 2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001780 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001781 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001782 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001783 case SENSOR_GC0307:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001784 case SENSOR_OV7660:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001785 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001786 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001787 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001788 case SENSOR_SP80708:
1789 reg9a = reg9a_spec;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001790 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001791 default:
1792 reg9a = reg9a_def;
1793 break;
1794 }
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001795 reg_w(gspca_dev, 0x9a, reg9a, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001796
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001797 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001798
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001799 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001800
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001801 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001802 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001803 reg_w1(gspca_dev, 0x01, 0x43);
Jean-Francois Moine64677572009-12-20 12:31:28 -03001804 reg_w1(gspca_dev, 0x17, 0x62);
1805 reg_w1(gspca_dev, 0x01, 0x42);
1806 reg_w1(gspca_dev, 0x01, 0x42);
1807 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001808 case SENSOR_GC0307:
1809 msleep(50);
1810 reg_w1(gspca_dev, 0x01, 0x61);
1811 reg_w1(gspca_dev, 0x17, 0x22);
1812 reg_w1(gspca_dev, 0x01, 0x60);
1813 reg_w1(gspca_dev, 0x01, 0x40);
1814 msleep(50);
1815 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03001816 case SENSOR_MI0360B:
1817 reg_w1(gspca_dev, 0x01, 0x61);
1818 reg_w1(gspca_dev, 0x17, 0x60);
1819 reg_w1(gspca_dev, 0x01, 0x60);
1820 reg_w1(gspca_dev, 0x01, 0x40);
1821 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001822 case SENSOR_MT9V111:
1823 reg_w1(gspca_dev, 0x01, 0x61);
1824 reg_w1(gspca_dev, 0x17, 0x61);
1825 reg_w1(gspca_dev, 0x01, 0x60);
1826 reg_w1(gspca_dev, 0x01, 0x40);
1827 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001828 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001829 msleep(10);
1830 reg_w1(gspca_dev, 0x02, 0x73);
1831 reg_w1(gspca_dev, 0x17, 0x60);
1832 reg_w1(gspca_dev, 0x01, 0x22);
1833 msleep(100);
1834 reg_w1(gspca_dev, 0x01, 0x62);
1835 reg_w1(gspca_dev, 0x17, 0x64);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001836 reg_w1(gspca_dev, 0x17, 0x64);
1837 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001838 msleep(10);
1839 reg_w1(gspca_dev, 0x01, 0x42);
1840 i2c_w8(gspca_dev, om6802_init0[0]);
1841 i2c_w8(gspca_dev, om6802_init0[1]);
1842 msleep(15);
1843 reg_w1(gspca_dev, 0x02, 0x71);
1844 msleep(150);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001845 break;
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03001846 case SENSOR_OV7630:
1847 reg_w1(gspca_dev, 0x01, 0x61);
1848 reg_w1(gspca_dev, 0x17, 0xe2);
1849 reg_w1(gspca_dev, 0x01, 0x60);
1850 reg_w1(gspca_dev, 0x01, 0x40);
1851 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001852 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03001853 reg_w1(gspca_dev, 0x01, 0x63);
1854 reg_w1(gspca_dev, 0x17, 0x20);
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001855 reg_w1(gspca_dev, 0x01, 0x62);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001856 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001857 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001858 case SENSOR_PO1030:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001859 case SENSOR_SOI768:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001860 reg_w1(gspca_dev, 0x01, 0x61);
1861 reg_w1(gspca_dev, 0x17, 0x20);
1862 reg_w1(gspca_dev, 0x01, 0x60);
1863 reg_w1(gspca_dev, 0x01, 0x40);
1864 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001865 case SENSOR_PO2030N:
Jean-François Moine19697b52010-07-14 06:33:51 -03001866 case SENSOR_OV7660:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001867 reg_w1(gspca_dev, 0x01, 0x63);
1868 reg_w1(gspca_dev, 0x17, 0x20);
1869 reg_w1(gspca_dev, 0x01, 0x62);
1870 reg_w1(gspca_dev, 0x01, 0x42);
1871 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001872 case SENSOR_SP80708:
1873 reg_w1(gspca_dev, 0x01, 0x63);
1874 reg_w1(gspca_dev, 0x17, 0x20);
1875 reg_w1(gspca_dev, 0x01, 0x62);
1876 reg_w1(gspca_dev, 0x01, 0x42);
Jean-Francois Moine1f78a972009-08-29 07:11:58 -03001877 msleep(100);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001878 reg_w1(gspca_dev, 0x02, 0x62);
1879 break;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001880 default:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03001881/* case SENSOR_HV7131R: */
1882/* case SENSOR_MI0360: */
1883/* case SENSOR_MO4000: */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001884 reg_w1(gspca_dev, 0x01, 0x43);
1885 reg_w1(gspca_dev, 0x17, 0x61);
1886 reg_w1(gspca_dev, 0x01, 0x42);
Jean-François Moine75f05ba2010-10-21 04:09:34 -03001887 if (sd->sensor == SENSOR_HV7131R)
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001888 hv7131r_probe(gspca_dev);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001889 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001890 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001891}
1892
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001893/* this function is called at probe time */
1894static int sd_config(struct gspca_dev *gspca_dev,
1895 const struct usb_device_id *id)
1896{
1897 struct sd *sd = (struct sd *) gspca_dev;
1898 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001899
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001900 sd->bridge = id->driver_info >> 16;
1901 sd->sensor = id->driver_info;
1902
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001903 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001904 if (sd->sensor == SENSOR_ADCM1700) {
1905 cam->cam_mode = cif_mode;
1906 cam->nmodes = ARRAY_SIZE(cif_mode);
1907 } else {
1908 cam->cam_mode = vga_mode;
1909 cam->nmodes = ARRAY_SIZE(vga_mode);
1910 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001911 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001912 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001913
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001914 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001915 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001916 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001917
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001918 return 0;
1919}
1920
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001921/* this function is called at probe and resume time */
1922static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001923{
1924 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001925 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001926 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001927 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001928
Hans de Goede3647fea2008-07-15 05:36:30 -03001929 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001930 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001931 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001932 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1933 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001934 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001935 if (gspca_dev->usb_err < 0)
1936 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001937 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001938 switch (sd->bridge) {
1939 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001940 if (regF1 != 0x11)
1941 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001942 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001943 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001944 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001945 if (regF1 != 0x11)
1946 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001947 if (sd->sensor == SENSOR_MI0360)
1948 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001949 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001950 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001951 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001952 if (regF1 != 0x12)
1953 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001954 switch (sd->sensor) {
1955 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001956 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001957 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001958 case SENSOR_OV7630:
1959 ov7630_probe(gspca_dev);
1960 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001961 case SENSOR_OV7648:
1962 ov7648_probe(gspca_dev);
1963 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001964 case SENSOR_PO2030N:
1965 po2030n_probe(gspca_dev);
1966 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001967 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001968 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001969 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001970 break;
1971 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001972/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001973/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001974 if (regF1 != 0x12)
1975 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001976 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001977 break;
1978 }
1979
Jean-François Moine72b667e2010-10-02 04:35:25 -03001980 if (sd->sensor == SENSOR_OM6802)
1981 sd->ctrls[SHARPNESS].def = 0x10;
1982
Hans de Goede9712a8b2010-01-31 12:54:29 -03001983 /* Note we do not disable the sensor clock here (power saving mode),
1984 as that also disables the button on the cam. */
1985 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001986
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001987 /* set the i2c address */
1988 sn9c1xx = sn_tb[sd->sensor];
1989 sd->i2c_addr = sn9c1xx[9];
1990
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001991 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1992
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001993 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001994}
1995
Jean-Francois Moine98819182009-01-19 07:37:33 -03001996static u32 setexposure(struct gspca_dev *gspca_dev,
1997 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001998{
1999 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002000
2001 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002002 case SENSOR_GC0307: {
2003 int a, b;
2004
2005 /* expo = 0..255 -> a = 19..43 */
2006 a = 19 + expo * 25 / 256;
2007 i2c_w1(gspca_dev, 0x68, a);
2008 a -= 12;
2009 b = a * a * 4; /* heuristic */
2010 i2c_w1(gspca_dev, 0x03, b >> 8);
2011 i2c_w1(gspca_dev, 0x04, b);
2012 break;
2013 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002014 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002015 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002016 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002017
2018 Expodoit[3] = expo >> 16;
2019 Expodoit[4] = expo >> 8;
2020 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002021 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002022 break;
2023 }
Jean-François Moinea067db82010-10-01 07:51:24 -03002024 case SENSOR_MI0360:
2025 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002026 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002027 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002028 static const u8 doit[] = /* update sensor */
2029 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
2030 static const u8 sensorgo[] = /* sensor on */
2031 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002032
2033 if (expo > 0x0635)
2034 expo = 0x0635;
2035 else if (expo < 0x0001)
2036 expo = 0x0001;
2037 expoMi[3] = expo >> 8;
2038 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002039 i2c_w8(gspca_dev, expoMi);
2040 i2c_w8(gspca_dev, doit);
2041 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002042 break;
2043 }
2044 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002045 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002046 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002047 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002048 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002049 static const u8 gainMo[] =
2050 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002051
2052 if (expo > 0x1fff)
2053 expo = 0x1fff;
2054 else if (expo < 0x0001)
2055 expo = 0x0001;
2056 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002057 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002058 expoMo10[3] = ((expo & 0x1c00) >> 10)
2059 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002060 i2c_w8(gspca_dev, expoMo10);
2061 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002062 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002063 ((expoMo10[3] & 0x07) << 10)
2064 | (expoMof[3] << 2)
2065 | ((expoMo10[3] & 0x30) >> 4));
2066 break;
2067 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002068 case SENSOR_MT9V111: {
2069 u8 expo_c1[] =
2070 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2071
2072 if (expo > 0x0280)
2073 expo = 0x0280;
2074 else if (expo < 0x0040)
2075 expo = 0x0040;
2076 expo_c1[3] = expo >> 8;
2077 expo_c1[4] = expo;
2078 i2c_w8(gspca_dev, expo_c1);
2079 break;
2080 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002081 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03002082 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002083 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002084 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002085
2086 if (expo > 0x03ff)
2087 expo = 0x03ff;
2088 if (expo < 0x0001)
2089 expo = 0x0001;
2090 gainOm[3] = expo >> 2;
2091 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002092 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002093 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002094 break;
2095 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002096 }
2097 return expo;
2098}
2099
2100static void setbrightness(struct gspca_dev *gspca_dev)
2101{
2102 struct sd *sd = (struct sd *) gspca_dev;
2103 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002104 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002105 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002106
Jean-François Moine72b667e2010-10-02 04:35:25 -03002107 brightness = sd->ctrls[BRIGHTNESS].val;
2108 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002109 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002110 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002111 if (k2 > 0x1f)
2112 k2 = 0; /* only positive Y offset */
2113 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002114 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002115 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002116 if (expo > 0x002dc6c0)
2117 expo = 0x002dc6c0;
2118 else if (expo < 0x02a0)
2119 expo = 0x02a0;
2120 sd->exposure = setexposure(gspca_dev, expo);
2121 break;
2122 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002123 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002124 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002125 sd->exposure = setexposure(gspca_dev, expo);
2126 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002127 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002128 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002129 sd->exposure = setexposure(gspca_dev, expo);
2130 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002131 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002132 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002133 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002134 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002135 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002136 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002137 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002138 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002139 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002140 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002141 }
2142
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002143 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002144}
2145
2146static void setcontrast(struct gspca_dev *gspca_dev)
2147{
2148 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002149 u8 k2;
2150 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002151
Jean-François Moine72b667e2010-10-02 04:35:25 -03002152 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2153 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002154 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002155 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002156 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002157 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002158 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002159 contrast[5] = 0;
2160 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002161}
2162
2163static void setcolors(struct gspca_dev *gspca_dev)
2164{
2165 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002166 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002167 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002168 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002169 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002170 -24, -38, 64, /* UR UG UB */
2171 62, -51, -9 /* VR VG VB */
2172 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002173 static const s16 uv_mi0360b[6] = {
2174 -20, -38, 64, /* UR UG UB */
2175 60, -51, -9 /* VR VG VB */
2176 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002177
Jean-François Moine72b667e2010-10-02 04:35:25 -03002178 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002179 if (sd->sensor == SENSOR_MI0360B)
2180 uv = uv_mi0360b;
2181 else
2182 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002183 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002184 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002185 reg8a[i * 2] = v;
2186 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002187 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002188 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002189}
2190
2191static void setredblue(struct gspca_dev *gspca_dev)
2192{
2193 struct sd *sd = (struct sd *) gspca_dev;
2194
Jean-François Moine72b667e2010-10-02 04:35:25 -03002195 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002196/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002197 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002198}
2199
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002200static void setgamma(struct gspca_dev *gspca_dev)
2201{
2202 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002203 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002204 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002205 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002206 static const u8 delta[17] = {
2207 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2208 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2209 };
2210
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002211 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002212 case SENSOR_ADCM1700:
2213 gamma_base = gamma_spec_0;
2214 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002215 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002216 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002217 case SENSOR_MT9V111:
2218 gamma_base = gamma_spec_1;
2219 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002220 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002221 gamma_base = gamma_spec_2;
2222 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002223 case SENSOR_SP80708:
2224 gamma_base = gamma_spec_3;
2225 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002226 default:
2227 gamma_base = gamma_def;
2228 break;
2229 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002230
Jean-François Moine72b667e2010-10-02 04:35:25 -03002231 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002232 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002233 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002234 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002235 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2236}
2237
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002238static void setautogain(struct gspca_dev *gspca_dev)
2239{
2240 struct sd *sd = (struct sd *) gspca_dev;
2241
Jean-François Moine72b667e2010-10-02 04:35:25 -03002242 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002243 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002244 switch (sd->sensor) {
2245 case SENSOR_OV7630:
2246 case SENSOR_OV7648: {
2247 u8 comb;
2248
2249 if (sd->sensor == SENSOR_OV7630)
2250 comb = 0xc0;
2251 else
2252 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002253 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec7472009-06-18 06:05:07 -03002254 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002255 i2c_w1(&sd->gspca_dev, 0x13, comb);
2256 return;
2257 }
2258 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002259 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002260 sd->ag_cnt = AG_CNT_START;
2261 else
2262 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002263}
2264
Németh Márton76ad3b62010-10-19 03:33:47 -03002265static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002266{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002267 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002268 u8 comn;
2269
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002270 switch (sd->sensor) {
2271 case SENSOR_HV7131R:
2272 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002273 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002274 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002275 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002276 break;
2277 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002278 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002279 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002280 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002281 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002282 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002283 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002284 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002285 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002286 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002287 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002288 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002289 case SENSOR_PO2030N:
2290 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2291 * (reset value: 0x0A)
2292 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2293 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2294 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2295 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2296 * bit3-0: X
2297 */
2298 comn = 0x0a;
2299 if (sd->ctrls[HFLIP].val)
2300 comn |= 0x80;
2301 if (sd->ctrls[VFLIP].val)
2302 comn |= 0x40;
2303 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2304 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002305 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002306}
2307
Jean-François Moine72b667e2010-10-02 04:35:25 -03002308static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002309{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002310 struct sd *sd = (struct sd *) gspca_dev;
2311
2312 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002313}
2314
Jean-François Moine72b667e2010-10-02 04:35:25 -03002315static void setinfrared(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002316{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002317 struct sd *sd = (struct sd *) gspca_dev;
2318
2319 if (gspca_dev->ctrl_dis & (1 << INFRARED))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002320 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002321/*fixme: different sequence for StarCam Clip and StarCam 370i */
2322/* Clip */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002323 i2c_w1(gspca_dev, 0x02, /* gpio */
2324 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002325}
2326
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002327static void setfreq(struct gspca_dev *gspca_dev)
2328{
2329 struct sd *sd = (struct sd *) gspca_dev;
2330
Jean-François Moine72b667e2010-10-02 04:35:25 -03002331 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002332 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002333 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002334 u8 com8;
2335
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002336 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002337 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002338 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002339 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002340 break;
2341 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002342 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002343 i2c_w1(gspca_dev, 0x3b, 0x0a);
2344 break;
2345 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002346 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002347 i2c_w1(gspca_dev, 0x3b, 0x02);
2348 break;
2349 }
2350 } else {
2351 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2352
2353 /* Get reg2a / reg2d base values */
2354 switch (sd->sensor) {
2355 case SENSOR_OV7630:
2356 reg2a = 0x08;
2357 reg2d = 0x01;
2358 break;
2359 case SENSOR_OV7648:
2360 reg2a = 0x11;
2361 reg2d = 0x81;
2362 break;
2363 }
2364
Jean-François Moine72b667e2010-10-02 04:35:25 -03002365 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002366 case 0: /* Banding filter disabled */
2367 break;
2368 case 1: /* 50 hz (filter on and framerate adj) */
2369 reg2a |= 0x80;
2370 reg2b = 0xac;
2371 reg2d |= 0x04;
2372 break;
2373 case 2: /* 60 hz (filter on, no framerate adj) */
2374 reg2a |= 0x80;
2375 reg2d |= 0x04;
2376 break;
2377 }
2378 i2c_w1(gspca_dev, 0x2a, reg2a);
2379 i2c_w1(gspca_dev, 0x2b, reg2b);
2380 i2c_w1(gspca_dev, 0x2d, reg2d);
2381 }
2382}
2383
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002384static void setjpegqual(struct gspca_dev *gspca_dev)
2385{
2386 struct sd *sd = (struct sd *) gspca_dev;
2387 int i, sc;
2388
2389 if (sd->jpegqual < 50)
2390 sc = 5000 / sd->jpegqual;
2391 else
2392 sc = 200 - sd->jpegqual * 2;
2393#if USB_BUF_SZ < 64
2394#error "No room enough in usb_buf for quantization table"
2395#endif
2396 for (i = 0; i < 64; i++)
2397 gspca_dev->usb_buf[i] =
2398 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2399 usb_control_msg(gspca_dev->dev,
2400 usb_sndctrlpipe(gspca_dev->dev, 0),
2401 0x08,
2402 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2403 0x0100, 0,
2404 gspca_dev->usb_buf, 64,
2405 500);
2406 for (i = 0; i < 64; i++)
2407 gspca_dev->usb_buf[i] =
2408 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2409 usb_control_msg(gspca_dev->dev,
2410 usb_sndctrlpipe(gspca_dev->dev, 0),
2411 0x08,
2412 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2413 0x0140, 0,
2414 gspca_dev->usb_buf, 64,
2415 500);
2416
2417 sd->reg18 ^= 0x40;
2418 reg_w1(gspca_dev, 0x18, sd->reg18);
2419}
2420
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002421/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002422static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002423{
2424 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002425 int i;
Jean-François Moine19697b52010-07-14 06:33:51 -03002426 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002427 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002428 const u8 (*init)[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002429 int mode;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002430 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2431 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002432 static const u8 CA_adcm1700[] =
2433 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002434 static const u8 CA_po2030n[] =
2435 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002436 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002437 static const u8 CE_gc0307[] =
2438 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002439 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002440 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002441 static const u8 CE_po2030n[] =
2442 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002443
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002444 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002445 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2446 0x21); /* JPEG 422 */
2447 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2448
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002449 /* initialize the bridge */
2450 sn9c1xx = sn_tb[sd->sensor];
2451 bridge_init(gspca_dev, sn9c1xx);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002452
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002453 /* initialize the sensor */
2454 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2455
Jean-Francois Moine60017612008-07-18 08:46:19 -03002456 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2457 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2458 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2459 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2460 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002461 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002462 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2463 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002464 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002465 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2466 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002467 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002468 reg_w1(gspca_dev, 0xc6, 0x00);
2469 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002470 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002471 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2472 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002473 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002474 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2475 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002476 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002477 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002478 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002479 case SENSOR_GC0307:
2480 reg17 = 0xa2;
2481 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002482 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002483 case SENSOR_MI0360B:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002484 reg17 = 0xe0;
2485 break;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002486 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002487 case SENSOR_OV7630:
2488 reg17 = 0xe2;
2489 break;
2490 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002491 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002492 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002493 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002494 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002495 reg17 = 0xa0;
2496 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002497 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002498 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002499 reg17 = 0xa0;
2500 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002501 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002502 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002503 break;
2504 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002505 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002506
2507 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2508 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2509 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002510 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002511
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002512 setgamma(gspca_dev);
2513
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002514/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002515 for (i = 0; i < 8; i++)
2516 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002517 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002518 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002519 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002520 case SENSOR_SP80708:
2521 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002522 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002523 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002524 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002525 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002526 reg_w1(gspca_dev, 0x9a, 0x07);
2527 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002528 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002529 case SENSOR_OV7648:
2530 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002531 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002532 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002533 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002534 reg_w1(gspca_dev, 0x9a, 0x06);
2535 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002536 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002537 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002538 break;
2539 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002540 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002541
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002542 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002543 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2544 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2545 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002546
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002547 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002548 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002549 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002550 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002551 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002552 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2553 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002554 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002555 case SENSOR_ADCM1700:
2556 init = adcm1700_sensor_param1;
2557 reg1 = 0x46;
2558 reg17 = 0xe2;
2559 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002560 case SENSOR_GC0307:
2561 init = gc0307_sensor_param1;
2562 reg17 = 0xa2;
2563 reg1 = 0x44;
2564 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002565 case SENSOR_MI0360B:
2566 init = mi0360b_sensor_param1;
2567 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2568 reg17 = 0xe2;
2569 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002570 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002571 if (mode) {
2572/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2573 reg1 = 0x06; /* clk 24Mz */
2574 } else {
2575 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002576/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002577 }
2578 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002579 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002580 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002581 if (mode) {
2582 reg1 = 0x04; /* 320 clk 48Mhz */
2583 } else {
2584/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002585 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002586 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002587 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002588 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002589 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002590 reg17 = 0x64; /* 640 MCKSIZE */
2591 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002592 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002593 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002594 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002595 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002596 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002597 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002598 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002599 reg17 = 0x21;
2600/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002601 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002602 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002603 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002604 if (sd->bridge == BRIDGE_SN9C120) {
2605 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002606 reg17 = 0xa2;
2607 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002608 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002609 } else {
2610 reg17 = 0x22;
2611 reg1 = 0x06; /* 24 Mhz, video trf eneble
2612 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002613 }
2614 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002615 case SENSOR_PO1030:
2616 init = po1030_sensor_param1;
2617 reg17 = 0xa2;
2618 reg1 = 0x44;
2619 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002620 case SENSOR_PO2030N:
2621 init = po2030n_sensor_param1;
2622 reg1 = 0x46;
2623 reg17 = 0xa2;
2624 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002625 case SENSOR_SOI768:
2626 init = soi768_sensor_param1;
2627 reg1 = 0x44;
2628 reg17 = 0xa2;
2629 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002630 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002631 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002632 if (mode) {
2633/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002634 } else {
2635 reg1 = 0x46; /* 640 clk 48Mz */
2636 reg17 = 0xa2;
2637 }
2638 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002639 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002640
2641 /* more sensor initialization - param1 */
2642 if (init != NULL) {
2643 i2c_w_seq(gspca_dev, init);
2644/* init = NULL; */
2645 }
2646
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002647 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002648 switch (sd->sensor) {
2649 case SENSOR_ADCM1700:
2650 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002651 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002652 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002653 break;
2654 case SENSOR_PO2030N:
2655 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2656 break;
2657 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002658 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002659 break;
2660 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002661 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002662 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002663 case SENSOR_OV7630:
2664 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002665 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002666 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002667 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002668 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002669 case SENSOR_GC0307:
2670 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2671 break;
2672 case SENSOR_PO2030N:
2673 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2674 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002675 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002676 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002677 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2678 break;
2679 }
2680
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002681
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002682 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002683 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2684 reg_w1(gspca_dev, 0x18, sd->reg18);
2685 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002686
Jean-Francois Moine60017612008-07-18 08:46:19 -03002687 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002688 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002689
Németh Márton76ad3b62010-10-19 03:33:47 -03002690 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002691 setbrightness(gspca_dev);
2692 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002693 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002694 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002695 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002696 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002697}
2698
2699static void sd_stopN(struct gspca_dev *gspca_dev)
2700{
2701 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002702 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002703 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002704 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002705 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002706 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002707 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002708 static const u8 stopsoi768[] =
2709 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002710 u8 data;
2711 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002712
2713 data = 0x0b;
2714 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002715 case SENSOR_GC0307:
2716 data = 0x29;
2717 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002718 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002719 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002720 data = 0x2b;
2721 break;
2722 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002723 case SENSOR_MI0360B:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002724 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002725 data = 0x29;
2726 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002727 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002728 i2c_w8(gspca_dev, stopov7648);
2729 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002730 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002731 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002732 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002733 data = 0x29;
2734 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002735 case SENSOR_SOI768:
2736 i2c_w8(gspca_dev, stopsoi768);
2737 data = 0x29;
2738 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002739 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002740 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002741 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2742 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2743 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2744 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002745 /* Don't disable sensor clock as that disables the button on the cam */
2746 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002747}
2748
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002749static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002750{
2751 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002752 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002753 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002754 u8 luma_mean = 130;
2755 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002756
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002757 /* Thanks S., without your advice, autobright should not work :) */
2758 if (sd->ag_cnt < 0)
2759 return;
2760 if (--sd->ag_cnt >= 0)
2761 return;
2762 sd->ag_cnt = AG_CNT_START;
2763
2764 delta = atomic_read(&sd->avg_lum);
2765 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002766 if (delta < luma_mean - luma_delta ||
2767 delta > luma_mean + luma_delta) {
2768 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002769 case SENSOR_GC0307:
2770 expotimes = sd->exposure;
2771 expotimes += (luma_mean - delta) >> 6;
2772 if (expotimes < 0)
2773 expotimes = 0;
2774 sd->exposure = setexposure(gspca_dev,
2775 (unsigned int) expotimes);
2776 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002777 case SENSOR_HV7131R:
2778 expotimes = sd->exposure >> 8;
2779 expotimes += (luma_mean - delta) >> 4;
2780 if (expotimes < 0)
2781 expotimes = 0;
2782 sd->exposure = setexposure(gspca_dev,
2783 (unsigned int) (expotimes << 8));
2784 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002785 case SENSOR_OM6802:
2786 expotimes = sd->exposure;
2787 expotimes += (luma_mean - delta) >> 2;
2788 if (expotimes < 0)
2789 expotimes = 0;
2790 sd->exposure = setexposure(gspca_dev,
2791 (unsigned int) expotimes);
2792 setredblue(gspca_dev);
2793 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002794 default:
2795/* case SENSOR_MO4000: */
2796/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002797/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002798/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002799 expotimes = sd->exposure;
2800 expotimes += (luma_mean - delta) >> 6;
2801 if (expotimes < 0)
2802 expotimes = 0;
2803 sd->exposure = setexposure(gspca_dev,
2804 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002805 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002806 break;
2807 }
2808 }
2809}
2810
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002811/* scan the URB packets */
2812/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002813static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002814 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002815 int len) /* iso packet length */
2816{
2817 struct sd *sd = (struct sd *) gspca_dev;
2818 int sof, avg_lum;
2819
Jean-François Moinea95bd642010-10-01 07:54:30 -03002820 /* the image ends on a 64 bytes block starting with
2821 * ff d9 ff ff 00 c4 c4 96
2822 * and followed by various information including luminosity */
2823 /* this block may be splitted between two packets */
2824 /* a new image always starts in a new packet */
2825 switch (gspca_dev->last_packet_type) {
2826 case DISCARD_PACKET: /* restart image building */
2827 sof = len - 64;
2828 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2829 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2830 return;
2831 case LAST_PACKET: /* put the JPEG 422 header */
2832 gspca_frame_add(gspca_dev, FIRST_PACKET,
2833 sd->jpeg_hdr, JPEG_HDR_SZ);
2834 break;
2835 }
2836 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002837
Jean-François Moinea95bd642010-10-01 07:54:30 -03002838 data = gspca_dev->image;
2839 if (data == NULL)
2840 return;
2841 sof = gspca_dev->image_len - 64;
2842 if (data[sof] != 0xff
2843 || data[sof + 1] != 0xd9)
2844 return;
2845
2846 /* end of image found - remove the trailing data */
2847 gspca_dev->image_len = sof + 2;
2848 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2849 if (sd->ag_cnt < 0)
2850 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002851/* w1 w2 w3 */
2852/* w4 w5 w6 */
2853/* w7 w8 */
2854/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002855 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002856/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002857 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002858/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002859 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002860/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002861 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002862/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002863 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2864 avg_lum >>= 4;
2865 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002866}
2867
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002868static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2869 struct v4l2_jpegcompression *jcomp)
2870{
2871 struct sd *sd = (struct sd *) gspca_dev;
2872
2873 if (jcomp->quality < QUALITY_MIN)
2874 sd->quality = QUALITY_MIN;
2875 else if (jcomp->quality > QUALITY_MAX)
2876 sd->quality = QUALITY_MAX;
2877 else
2878 sd->quality = jcomp->quality;
2879 if (gspca_dev->streaming)
2880 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2881 return 0;
2882}
2883
2884static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2885 struct v4l2_jpegcompression *jcomp)
2886{
2887 struct sd *sd = (struct sd *) gspca_dev;
2888
2889 memset(jcomp, 0, sizeof *jcomp);
2890 jcomp->quality = sd->quality;
2891 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2892 | V4L2_JPEG_MARKER_DQT;
2893 return 0;
2894}
2895
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002896static int sd_querymenu(struct gspca_dev *gspca_dev,
2897 struct v4l2_querymenu *menu)
2898{
2899 switch (menu->id) {
2900 case V4L2_CID_POWER_LINE_FREQUENCY:
2901 switch (menu->index) {
2902 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2903 strcpy((char *) menu->name, "NoFliker");
2904 return 0;
2905 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2906 strcpy((char *) menu->name, "50 Hz");
2907 return 0;
2908 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2909 strcpy((char *) menu->name, "60 Hz");
2910 return 0;
2911 }
2912 break;
2913 }
2914 return -EINVAL;
2915}
2916
Jean-François Moine28566432010-10-01 07:33:26 -03002917#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002918static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2919 u8 *data, /* interrupt packet data */
2920 int len) /* interrupt packet length */
2921{
2922 int ret = -EINVAL;
2923
2924 if (len == 1 && data[0] == 1) {
2925 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2926 input_sync(gspca_dev->input_dev);
2927 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2928 input_sync(gspca_dev->input_dev);
2929 ret = 0;
2930 }
2931
2932 return ret;
2933}
2934#endif
2935
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002936/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002937static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002938 .name = MODULE_NAME,
2939 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002940 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002941 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002942 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002943 .start = sd_start,
2944 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002945 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002946 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002947 .get_jcomp = sd_get_jcomp,
2948 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002949 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002950#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002951 .int_pkt_scan = sd_int_pkt_scan,
2952#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002953};
2954
2955/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002956#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002957 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002958 | SENSOR_ ## sensor
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002959static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002960#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002961 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2962 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002963#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002964 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2965 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2966 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2967 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2968 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2969 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2970 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2971/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2972 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2973/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2974/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2975 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2976/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2977 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002978 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002979/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2980/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2981/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002982 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002983 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2984/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2985/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03002986/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002987 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002988#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002989 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2990 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002991#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002992 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03002993 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002994/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2995 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2996 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2997 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2998 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2999/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3000/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3001/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3002 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003003/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003004 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003005 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003006 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3007 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3008/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003009 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003010 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003011/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3012 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3013 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003014#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003015 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03003016#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003017 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3018 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003019 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003020 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003021 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3022 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine64677572009-12-20 12:31:28 -03003023 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003024 {}
3025};
3026MODULE_DEVICE_TABLE(usb, device_table);
3027
3028/* -- device connect -- */
3029static int sd_probe(struct usb_interface *intf,
3030 const struct usb_device_id *id)
3031{
3032 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3033 THIS_MODULE);
3034}
3035
3036static struct usb_driver sd_driver = {
3037 .name = MODULE_NAME,
3038 .id_table = device_table,
3039 .probe = sd_probe,
3040 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003041#ifdef CONFIG_PM
3042 .suspend = gspca_suspend,
3043 .resume = gspca_resume,
3044#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003045};
3046
3047/* -- module insert / remove -- */
3048static int __init sd_mod_init(void)
3049{
Jean-François Moine54826432010-09-13 04:53:03 -03003050 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003051}
3052static void __exit sd_mod_exit(void)
3053{
3054 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003055}
3056
3057module_init(sd_mod_init);
3058module_exit(sd_mod_exit);