blob: 3e41653f11c1caf7ce757c1359114b8e0a81edbf [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
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -030066 u8 reg01;
67 u8 reg17;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030068 u8 reg18;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -030069 u8 flags;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030070
Jean-Francois Moine98819182009-01-19 07:37:33 -030071 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030072#define AG_CNT_START 13
73
Jean-Francois Moine98819182009-01-19 07:37:33 -030074 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030075#define BRIDGE_SN9C102P 0
76#define BRIDGE_SN9C105 1
77#define BRIDGE_SN9C110 2
78#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030079 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030080 u8 i2c_addr;
81
82 u8 jpeg_hdr[JPEG_HDR_SZ];
83};
84enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030085 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030086 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030087 SENSOR_HV7131R,
88 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030089 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030090 SENSOR_MO4000,
91 SENSOR_MT9V111,
92 SENSOR_OM6802,
93 SENSOR_OV7630,
94 SENSOR_OV7648,
95 SENSOR_OV7660,
96 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030097 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030098 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030099 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300100};
101
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300102/* device flags */
103#define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */
104
Jean-Francois Moine4fd350e2010-12-14 16:16:58 -0300105/* sn9c1xx definitions */
106/* register 0x01 */
107#define S_PWR_DN 0x01 /* sensor power down */
108#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
109#define V_TX_EN 0x04 /* video transfer enable */
110#define LED 0x08 /* output to pin LED */
111#define SCL_SEL_OD 0x20 /* open-drain mode */
112#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
113/* register 0x17 */
114#define MCK_SIZE_MASK 0x1f /* sensor master clock */
115#define SEN_CLK_EN 0x20 /* enable sensor clock */
116#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
117
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300118/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300119static void setbrightness(struct gspca_dev *gspca_dev);
120static void setcontrast(struct gspca_dev *gspca_dev);
121static void setcolors(struct gspca_dev *gspca_dev);
122static void setredblue(struct gspca_dev *gspca_dev);
123static void setgamma(struct gspca_dev *gspca_dev);
124static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300125static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300126static void setsharpness(struct gspca_dev *gspca_dev);
127static void setinfrared(struct gspca_dev *gspca_dev);
128static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300129
Jean-François Moine72b667e2010-10-02 04:35:25 -0300130static const struct ctrl sd_ctrls[NCTRLS] = {
131[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132 {
133 .id = V4L2_CID_BRIGHTNESS,
134 .type = V4L2_CTRL_TYPE_INTEGER,
135 .name = "Brightness",
136 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300137 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300138 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300139 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300141 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300143[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300144 {
145 .id = V4L2_CID_CONTRAST,
146 .type = V4L2_CTRL_TYPE_INTEGER,
147 .name = "Contrast",
148 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300149#define CONTRAST_MAX 127
150 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300151 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300152 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300154 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300155 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300156[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300157 {
158 .id = V4L2_CID_SATURATION,
159 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300160 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300161 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300162 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300163 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300164#define COLORS_DEF 25
165 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300166 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300167 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300168 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300169[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300170 {
171 .id = V4L2_CID_BLUE_BALANCE,
172 .type = V4L2_CTRL_TYPE_INTEGER,
173 .name = "Blue Balance",
174 .minimum = 24,
175 .maximum = 40,
176 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300177 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300178 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300179 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300180 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300181[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300182 {
183 .id = V4L2_CID_RED_BALANCE,
184 .type = V4L2_CTRL_TYPE_INTEGER,
185 .name = "Red Balance",
186 .minimum = 24,
187 .maximum = 40,
188 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300189 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300190 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300191 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300192 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300193[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300194 {
195 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER,
197 .name = "Gamma",
198 .minimum = 0,
199 .maximum = 40,
200 .step = 1,
201#define GAMMA_DEF 20
202 .default_value = GAMMA_DEF,
203 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300204 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300205 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300206[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300207 {
208 .id = V4L2_CID_AUTOGAIN,
209 .type = V4L2_CTRL_TYPE_BOOLEAN,
210 .name = "Auto Gain",
211 .minimum = 0,
212 .maximum = 1,
213 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300214 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300215 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300216 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300217 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300218[HFLIP] = {
219 {
220 .id = V4L2_CID_HFLIP,
221 .type = V4L2_CTRL_TYPE_BOOLEAN,
222 .name = "Mirror",
223 .minimum = 0,
224 .maximum = 1,
225 .step = 1,
226 .default_value = 0,
227 },
228 .set_control = sethvflip
229 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300230[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300231 {
232 .id = V4L2_CID_VFLIP,
233 .type = V4L2_CTRL_TYPE_BOOLEAN,
234 .name = "Vflip",
235 .minimum = 0,
236 .maximum = 1,
237 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300238 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300239 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300240 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300241 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300242[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300243 {
244 .id = V4L2_CID_SHARPNESS,
245 .type = V4L2_CTRL_TYPE_INTEGER,
246 .name = "Sharpness",
247 .minimum = 0,
248 .maximum = 255,
249 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300250 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300251 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300252 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300253 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300254/* mt9v111 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300255[INFRARED] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300256 {
257 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN,
259 .name = "Infrared",
260 .minimum = 0,
261 .maximum = 1,
262 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300263 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300264 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300265 .set_control = setinfrared
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300266 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300267/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300268[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300269 {
270 .id = V4L2_CID_POWER_LINE_FREQUENCY,
271 .type = V4L2_CTRL_TYPE_MENU,
272 .name = "Light frequency filter",
273 .minimum = 0,
274 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
275 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300276 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300277 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300278 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300279 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300280};
281
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300282/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300283static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300284[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
285 (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 Moine9c33afc2010-03-17 15:25:32 -0300289
Jean-François Moine72b667e2010-10-02 04:35:25 -0300290[SENSOR_GC0307] = (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 Moinead98c0f2010-03-18 05:15:30 -0300294
Jean-François Moine72b667e2010-10-02 04:35:25 -0300295[SENSOR_HV7131R] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300296 (1 << HFLIP) |
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_MI0360] = (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
Jean-François Moine72b667e2010-10-02 04:35:25 -0300304[SENSOR_MI0360B] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300305 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300306 (1 << VFLIP) |
307 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300308
Jean-François Moine72b667e2010-10-02 04:35:25 -0300309[SENSOR_MO4000] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300310 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300311 (1 << VFLIP) |
312 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300313
Németh Márton76ad3b62010-10-19 03:33:47 -0300314[SENSOR_MT9V111] = (1 << HFLIP) |
315 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300316 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300317
Jean-François Moine72b667e2010-10-02 04:35:25 -0300318[SENSOR_OM6802] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300319 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300320 (1 << VFLIP) |
321 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300322
Németh Márton76ad3b62010-10-19 03:33:47 -0300323[SENSOR_OV7630] = (1 << INFRARED) |
324 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300325
Németh Márton76ad3b62010-10-19 03:33:47 -0300326[SENSOR_OV7648] = (1 << INFRARED) |
327 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300328
Jean-François Moine72b667e2010-10-02 04:35:25 -0300329[SENSOR_OV7660] = (1 << AUTOGAIN) |
330 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300331 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300332 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300333
Jean-François Moine72b667e2010-10-02 04:35:25 -0300334[SENSOR_PO1030] = (1 << AUTOGAIN) |
335 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300336 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300337 (1 << VFLIP) |
338 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300339
Jean-François Moine72b667e2010-10-02 04:35:25 -0300340[SENSOR_PO2030N] = (1 << AUTOGAIN) |
341 (1 << INFRARED) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300342 (1 << FREQ),
Jean-François Moine780e3122010-10-19 04:29:10 -0300343
Jean-François Moine72b667e2010-10-02 04:35:25 -0300344[SENSOR_SOI768] = (1 << AUTOGAIN) |
345 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300346 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300347 (1 << VFLIP) |
348 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300349
Jean-François Moine72b667e2010-10-02 04:35:25 -0300350[SENSOR_SP80708] = (1 << AUTOGAIN) |
351 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300352 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300353 (1 << VFLIP) |
354 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300355};
356
Jean-Francois Moine64677572009-12-20 12:31:28 -0300357static const struct v4l2_pix_format cif_mode[] = {
358 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
359 .bytesperline = 352,
360 .sizeimage = 352 * 288 * 4 / 8 + 590,
361 .colorspace = V4L2_COLORSPACE_JPEG,
362 .priv = 0},
363};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300364static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300365 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
366 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300367 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300368 .colorspace = V4L2_COLORSPACE_JPEG,
369 .priv = 2},
370 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
371 .bytesperline = 320,
372 .sizeimage = 320 * 240 * 3 / 8 + 590,
373 .colorspace = V4L2_COLORSPACE_JPEG,
374 .priv = 1},
375 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
376 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300377 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
378 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300379 .colorspace = V4L2_COLORSPACE_JPEG,
380 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300381};
382
Jean-Francois Moine64677572009-12-20 12:31:28 -0300383static const u8 sn_adcm1700[0x1c] = {
384/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300385 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300386/* reg8 reg9 rega regb regc regd rege regf */
387 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
388/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
389 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
390/* reg18 reg19 reg1a reg1b */
391 0x06, 0x00, 0x00, 0x00
392};
393
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300394static const u8 sn_gc0307[0x1c] = {
395/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
396 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
397/* reg8 reg9 rega regb regc regd rege regf */
398 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
400 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
401/* reg18 reg19 reg1a reg1b */
402 0x06, 0x00, 0x00, 0x00
403};
404
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300405static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300406/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300407 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300408/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300409 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300410/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
411 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300412/* reg18 reg19 reg1a reg1b */
413 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300414};
415
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300416static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300417/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300418 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300419/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300420 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300421/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
422 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300423/* reg18 reg19 reg1a reg1b */
424 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300425};
426
Jean-François Moinea067db82010-10-01 07:51:24 -0300427static const u8 sn_mi0360b[0x1c] = {
428/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
429 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
430/* reg8 reg9 rega regb regc regd rege regf */
431 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
432/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
433 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
434/* reg18 reg19 reg1a reg1b */
435 0x06, 0x00, 0x00, 0x00
436};
437
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300438static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300439/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300440 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300441/* reg8 reg9 rega regb regc regd rege regf */
442 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
444 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300445/* reg18 reg19 reg1a reg1b */
446 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300447};
448
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300449static const u8 sn_mt9v111[0x1c] = {
450/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
451 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
452/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300453 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300454/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
455 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
456/* reg18 reg19 reg1a reg1b */
457 0x06, 0x00, 0x00, 0x00
458};
459
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300460static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300461/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300462 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300463/* reg8 reg9 rega regb regc regd rege regf */
464 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
466 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300467/* reg18 reg19 reg1a reg1b */
468 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300469};
470
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300471static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300472/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300473 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300474/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300475 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300476/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
477 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300478/* reg18 reg19 reg1a reg1b */
479 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300480};
481
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300482static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300483/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300484 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300485/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300486 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300487/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300488 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300489/* reg18 reg19 reg1a reg1b */
490 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300491};
492
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300493static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300494/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300495 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300496/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300497 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300498/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
499 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300500/* reg18 reg19 reg1a reg1b */
501 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300502};
503
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300504static const u8 sn_po1030[0x1c] = {
505/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
506 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
507/* reg8 reg9 rega regb regc regd rege regf */
508 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
509/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
510 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
511/* reg18 reg19 reg1a reg1b */
512 0x07, 0x00, 0x00, 0x00
513};
514
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300515static const u8 sn_po2030n[0x1c] = {
516/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
517 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
518/* reg8 reg9 rega regb regc regd rege regf */
519 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
520/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
521 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
522/* reg18 reg19 reg1a reg1b */
523 0x07, 0x00, 0x00, 0x00
524};
525
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300526static const u8 sn_soi768[0x1c] = {
527/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
528 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
529/* reg8 reg9 rega regb regc regd rege regf */
530 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
531/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
532 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
533/* reg18 reg19 reg1a reg1b */
534 0x07, 0x00, 0x00, 0x00
535};
536
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300537static const u8 sn_sp80708[0x1c] = {
538/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
539 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
540/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300541 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300542/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
543 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
544/* reg18 reg19 reg1a reg1b */
545 0x07, 0x00, 0x00, 0x00
546};
547
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300548/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300549static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300550[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300551[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300552[SENSOR_HV7131R] = sn_hv7131,
553[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300554[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300555[SENSOR_MO4000] = sn_mo4000,
556[SENSOR_MT9V111] = sn_mt9v111,
557[SENSOR_OM6802] = sn_om6802,
558[SENSOR_OV7630] = sn_ov7630,
559[SENSOR_OV7648] = sn_ov7648,
560[SENSOR_OV7660] = sn_ov7660,
561[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300562[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300563[SENSOR_SOI768] = sn_soi768,
564[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300565};
566
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300567/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300568static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300569 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
570 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
571};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300572/* gamma for sensor ADCM1700 */
573static const u8 gamma_spec_0[17] = {
574 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
575 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
576};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300577/* gamma for sensors HV7131R and MT9V111 */
578static const u8 gamma_spec_1[17] = {
579 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
580 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
581};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300582/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300583static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300584 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
585 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
586};
587/* gamma for sensor SP80708 */
588static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300589 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
590 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
591};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300592
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300593/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300594static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300595 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
596 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
597 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
598 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300599};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300600
601#define DELAY 0xdd
602
Jean-Francois Moine64677572009-12-20 12:31:28 -0300603static const u8 adcm1700_sensor_init[][8] = {
604 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300605 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300606 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300607 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300608 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300609 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
610 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
611 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
612 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
613 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300614 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300615 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300616 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300617 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
619 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
620 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
621 {}
622};
623static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300624 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300625 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
626
627 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
628 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
630 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300631 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300632
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300633 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
634 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
636 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300637 {}
638};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300639static const u8 gc0307_sensor_init[][8] = {
640 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300660 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300661 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
666 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
667 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
668 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
669 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
670 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
671 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
672 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
673 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
674 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
675 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
676 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
677 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
678 {}
679};
680static const u8 gc0307_sensor_param1[][8] = {
681 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
682 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
683 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
684 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
685/*param3*/
686 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
687 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300688 {}
689};
690
Jean-Francois Moine98819182009-01-19 07:37:33 -0300691static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300692 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
693 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
694 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
695/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
696 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
698/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300699
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300700 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
701 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
702 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
703 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
704 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
705 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
706 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
707 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300708
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300709 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
710 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300711 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300712 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
713 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300714
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300715 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
716 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
717 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
718 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
719 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300720 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
721 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300722 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300723};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300724static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300725 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300726 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300727 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300728 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
729 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
730 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
731 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
736 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
737 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
739 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
742 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
743 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
746 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300747 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300748 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
749 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
750 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
752 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
753 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
754 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
755 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
756 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
757 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300758
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300759 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
760 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
761 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
762 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
763 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300764
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300765 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
766 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
767 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300769
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300770 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
771 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
772/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
773/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
774 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
775 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300776 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300777};
Jean-François Moinea067db82010-10-01 07:51:24 -0300778static const u8 mi0360b_sensor_init[][8] = {
779 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
780 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300781 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300782 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300783 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300784 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
785 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
786 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
795 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
798 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
799 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
801 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
802 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
803 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
804 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
805 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
806 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
808 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
809 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
810 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
811 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
812 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
813 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
814
815 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
816 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
817 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
818 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
819 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
820 {}
821};
822static const u8 mi0360b_sensor_param1[][8] = {
823 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
824 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
825 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
826 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
827
828 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
829 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
830 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
831 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
832 {}
833};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300834static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300835 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300855 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300856};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300857static const u8 mt9v111_sensor_init[][8] = {
858 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300859 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300860 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
861 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
862 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
863 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300864 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
865 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
866 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
867 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300868 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300869 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
870 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
871 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
872 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
873 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300874 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300875 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300876 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
877 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
878 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
879 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
880 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
881 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
882 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
883 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
884 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
885 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300886 {}
887};
888static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300889 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
890 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300891 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300892 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
893 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
894 /*******/
895 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
896 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
897 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
898 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
899 {}
900};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300901static const u8 om6802_init0[2][8] = {
902/*fixme: variable*/
903 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
904 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
905};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300906static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300907 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
908 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300909 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300910 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300911 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300912/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
913 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300914 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300915/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
916 * set color mode */
917/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
918 * max AGC value in AE */
919/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
920 * preset AGC */
921/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
922 * preset brightness */
923/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
924 * preset contrast */
925/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
926 * preset gamma */
927 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300928 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300929 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
930 /* preset shutter */
931/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
932 * auto frame rate */
933/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300934 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
935 {}
936};
937static const u8 om6802_sensor_param1[][8] = {
938 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
939 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
940 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
941 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300942 {}
943};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300944static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300945 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
946 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300947 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300948 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
949 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300950 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300951 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300952/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300953 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
954 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300955/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
956 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
957 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300958 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
959 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
960 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
961 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
962 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
963 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
964 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
965 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
966 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
967 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
968 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
969 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
970 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
971 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
972 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
973 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
974 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
975 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
976 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
977 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
978 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
979 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
980 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300981 {}
982};
983static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300984 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
985 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
986/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300987/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
988 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300989 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
990 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
991 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300992/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300993/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
994/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300995/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300996 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300997/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300998 {}
999};
Jean-Francois Moine62703302008-11-11 08:42:56 -03001000
Jean-Francois Moine98819182009-01-19 07:37:33 -03001001static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001002 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
1003 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001004 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001005 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1006 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
1007 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
1008 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
1009 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
1010 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
1011 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1012 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1013 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1014 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1015 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1016 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1017 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1018 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1019 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1020 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1021 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1022 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1023 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1024
1025 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1026/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1027/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001028/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001029 {}
1030};
1031static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001032/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001033/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1034 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001035 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1036 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1037/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1038/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1039/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1040/*...*/
1041 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1042/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1043/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1044/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1045/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1046/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1047
1048 {}
1049};
1050
Jean-Francois Moine98819182009-01-19 07:37:33 -03001051static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001052 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001053 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001054 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001055 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001056 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001057 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001058 /* GAIN BLUE RED VREF */
1059 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1060 /* COM 1 BAVE GEAVE AECHH */
1061 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1062 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001063 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001064 /* AECH CLKRC COM7 COM8 */
1065 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1066 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1067 /* HSTART HSTOP VSTRT VSTOP */
1068 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1069 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1070 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1071 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001072/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1073 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001074 /* AEW AEB VPT BBIAS */
1075 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1076 /* GbBIAS RSVD EXHCH EXHCL */
1077 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1078 /* RBIAS ADVFL ASDVFH YAVE */
1079 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1080 /* HSYST HSYEN HREF */
1081 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1082 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1083 /* ADC ACOM OFON TSLB */
1084 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1085 /* COM11 COM12 COM13 COM14 */
1086 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1087 /* EDGE COM15 COM16 COM17 */
1088 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1089 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1090 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1091 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1092 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1093 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1094 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1095 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1096 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1097 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1098 /* LCC1 LCC2 LCC3 LCC4 */
1099 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001100 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001101 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001102 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001103 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1104 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1105 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1106 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1107 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1108 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1109 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1110 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1111 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001112 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001113/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001114 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001115 {}
1116};
1117static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001118 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001119 /* bits[3..0]reserved */
1120 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1121 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1122 /* VREF vertical frame ctrl */
1123 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001124 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1125 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1126 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1127 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1128/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001129/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001130/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001131 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001132 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1133 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1134 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1135/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001136/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001137/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001138/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001139 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1140 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1141 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1142 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001143 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001144};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001145
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001146static const u8 po1030_sensor_init[][8] = {
1147/* the sensor registers are described in m5602/m5602_po1030.h */
1148 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001149 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001150 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1151 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1152 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1153 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1154 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1155 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1156 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1157 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1158 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1159 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1160 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1161 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1162 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1163 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1164 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1165 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1166 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1167 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1168 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1169 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1170 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1171 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1172 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1173 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1174 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1175 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1176
1177 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1178 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1179 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1180 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1181 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1182 {}
1183};
1184static const u8 po1030_sensor_param1[][8] = {
1185/* from ms-win traces - these values change with auto gain/expo/wb.. */
1186 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1187 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1188/* mean values */
1189 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1190 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1191 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1192
1193 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1194 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1195 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1196/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1197 {}
1198};
1199
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001200static const u8 po2030n_sensor_init[][8] = {
1201 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1202 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001203 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001204 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1205 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001206 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001207 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1208 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1210 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1211 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1213 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1214 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1215 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1216 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1226 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1227 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1228 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1230 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1231 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1234 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1235 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1236 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1237 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1239 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1240 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1241 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1242 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1243 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1244 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1245 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1246 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1247 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1248 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1249 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1250 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1251 {}
1252};
1253static const u8 po2030n_sensor_param1[][8] = {
1254 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001255 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001256 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1257 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1258 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1259/*param2*/
1260 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1263 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1264 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1265 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1266 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1267/*after start*/
1268 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001269 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001270 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001271 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001272 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1273 {}
1274};
1275
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001276static const u8 soi768_sensor_init[][8] = {
1277 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001278 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001279 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1280 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1281 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1282 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1283 {}
1284};
1285static const u8 soi768_sensor_param1[][8] = {
1286 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1287 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1288 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1289 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1290 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1291/* */
1292/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1293/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1294 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1295/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1296 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1297/* the next sequence should be used for auto gain */
1298 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1299 /* global gain ? : 07 - change with 0x15 at the end */
1300 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1301 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1302 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1303 /* exposure ? : 0200 - change with 0x1e at the end */
1304 {}
1305};
1306
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001307static const u8 sp80708_sensor_init[][8] = {
1308 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1368 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1369 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1370 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1371 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1374 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1375 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1376 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1377 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1378 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001379 {}
1380};
1381static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001382 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1383 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1384 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1385 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1386 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1387 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1388 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1389 {}
1390};
1391
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001392static const u8 (*sensor_init[])[8] = {
1393[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001394[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001395[SENSOR_HV7131R] = hv7131r_sensor_init,
1396[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001397[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001398[SENSOR_MO4000] = mo4000_sensor_init,
1399[SENSOR_MT9V111] = mt9v111_sensor_init,
1400[SENSOR_OM6802] = om6802_sensor_init,
1401[SENSOR_OV7630] = ov7630_sensor_init,
1402[SENSOR_OV7648] = ov7648_sensor_init,
1403[SENSOR_OV7660] = ov7660_sensor_init,
1404[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001405[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001406[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001407[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001408};
1409
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001410/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001411static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001412 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001413{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001414 int ret;
1415
1416 if (gspca_dev->usb_err < 0)
1417 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001418#ifdef GSPCA_DEBUG
1419 if (len > USB_BUF_SZ) {
1420 err("reg_r: buffer overflow");
1421 return;
1422 }
1423#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001424 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001425 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001426 0,
1427 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1428 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001429 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001430 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001431 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001432 if (ret < 0) {
1433 err("reg_r err %d", ret);
1434 gspca_dev->usb_err = ret;
1435 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001436}
1437
Jean-Francois Moine60017612008-07-18 08:46:19 -03001438static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001439 u16 value,
1440 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001441{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001442 int ret;
1443
1444 if (gspca_dev->usb_err < 0)
1445 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001446 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001447 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001448 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001449 usb_sndctrlpipe(gspca_dev->dev, 0),
1450 0x08,
1451 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1452 value,
1453 0,
1454 gspca_dev->usb_buf, 1,
1455 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001456 if (ret < 0) {
1457 err("reg_w1 err %d", ret);
1458 gspca_dev->usb_err = ret;
1459 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001460}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001461static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001462 u16 value,
1463 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001464 int len)
1465{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001466 int ret;
1467
1468 if (gspca_dev->usb_err < 0)
1469 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001470 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001471 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001472#ifdef GSPCA_DEBUG
1473 if (len > USB_BUF_SZ) {
1474 err("reg_w: buffer overflow");
1475 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001476 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001477#endif
1478 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001479 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001480 usb_sndctrlpipe(gspca_dev->dev, 0),
1481 0x08,
1482 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1483 value, 0,
1484 gspca_dev->usb_buf, len,
1485 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001486 if (ret < 0) {
1487 err("reg_w err %d", ret);
1488 gspca_dev->usb_err = ret;
1489 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001490}
1491
Jean-Francois Moine60017612008-07-18 08:46:19 -03001492/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001493static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001494{
1495 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001496 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001497
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001498 if (gspca_dev->usb_err < 0)
1499 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001500 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001501 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001502 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001503 case SENSOR_OM6802:
1504 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001505 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1506 break;
1507 default: /* i2c command = a1 (400 kHz) */
1508 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1509 break;
1510 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001511 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001512 gspca_dev->usb_buf[2] = reg;
1513 gspca_dev->usb_buf[3] = val;
1514 gspca_dev->usb_buf[4] = 0;
1515 gspca_dev->usb_buf[5] = 0;
1516 gspca_dev->usb_buf[6] = 0;
1517 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001518 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001519 usb_sndctrlpipe(gspca_dev->dev, 0),
1520 0x08,
1521 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1522 0x08, /* value = i2c */
1523 0,
1524 gspca_dev->usb_buf, 8,
1525 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001526 if (ret < 0) {
1527 err("i2c_w1 err %d", ret);
1528 gspca_dev->usb_err = ret;
1529 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001530}
1531
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001532/* I2C write 8 bytes */
1533static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001534 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001535{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001536 int ret;
1537
1538 if (gspca_dev->usb_err < 0)
1539 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001540 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1541 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001542 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001543 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001544 usb_sndctrlpipe(gspca_dev->dev, 0),
1545 0x08,
1546 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1547 0x08, 0, /* value, index */
1548 gspca_dev->usb_buf, 8,
1549 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001550 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001551 if (ret < 0) {
1552 err("i2c_w8 err %d", ret);
1553 gspca_dev->usb_err = ret;
1554 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001555}
1556
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001557/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1558static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001559{
1560 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001561 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001562
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001563 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001564 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001565 case SENSOR_OM6802:
1566 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001567 mode[0] = 0x80 | 0x10;
1568 break;
1569 default: /* i2c command = 91 (400 kHz) */
1570 mode[0] = 0x81 | 0x10;
1571 break;
1572 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001573 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001574 mode[2] = reg;
1575 mode[3] = 0;
1576 mode[4] = 0;
1577 mode[5] = 0;
1578 mode[6] = 0;
1579 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001580 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001581 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001582 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001583 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001584 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001585 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001586 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001587}
1588
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001589static void i2c_w_seq(struct gspca_dev *gspca_dev,
1590 const u8 (*data)[8])
1591{
1592 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001593 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001594 i2c_w8(gspca_dev, *data);
1595 else
1596 msleep((*data)[1]);
1597 data++;
1598 }
1599}
1600
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001601/* check the ID of the hv7131 sensor */
1602/* this sequence is needed because it activates the sensor */
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001603static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001604{
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001605 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001606 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001607 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001608 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001609 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1610 if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001611 && gspca_dev->usb_buf[1] == 0x09
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001612 && gspca_dev->usb_buf[2] == 0x01) {
1613 PDEBUG(D_PROBE, "Sensor HV7131R found");
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001614 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001615 }
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001616 warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001617 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1618 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001619}
1620
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001621static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001622{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001623 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001624 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001625 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001626 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001627 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001628 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1629 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1630 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1631 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1632 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001633 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001634 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1635 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1636 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1637 {}
1638 },
1639 };
1640
1641 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1642 reg_w1(gspca_dev, 0x17, 0x62);
1643 reg_w1(gspca_dev, 0x01, 0x08);
1644 for (j = 0; j < 3; j++)
1645 i2c_w8(gspca_dev, probe_tb[i][j]);
1646 msleep(2);
1647 reg_r(gspca_dev, 0x0a, 5);
1648 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1649 if (probe_tb[i][3][0] != 0)
1650 i2c_w8(gspca_dev, probe_tb[i][3]);
1651 reg_w1(gspca_dev, 0x01, 0x29);
1652 reg_w1(gspca_dev, 0x17, 0x42);
1653 if (val != 0xffff)
1654 break;
1655 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001656 if (gspca_dev->usb_err < 0)
1657 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001658 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001659 case 0x8221:
1660 PDEBUG(D_PROBE, "Sensor mi0360b");
1661 sd->sensor = SENSOR_MI0360B;
1662 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001663 case 0x823a:
1664 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001665 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001666 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001667 case 0x8243:
1668 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001669 break;
1670 default:
1671 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1672 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001673 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001674}
1675
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001676static void ov7630_probe(struct gspca_dev *gspca_dev)
1677{
1678 struct sd *sd = (struct sd *) gspca_dev;
1679 u16 val;
1680
1681 /* check ov76xx */
1682 reg_w1(gspca_dev, 0x17, 0x62);
1683 reg_w1(gspca_dev, 0x01, 0x08);
1684 sd->i2c_addr = 0x21;
1685 i2c_r(gspca_dev, 0x0a, 2);
1686 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1687 reg_w1(gspca_dev, 0x01, 0x29);
1688 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001689 if (gspca_dev->usb_err < 0)
1690 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001691 if (val == 0x7628) { /* soi768 */
1692 sd->sensor = SENSOR_SOI768;
1693/*fixme: only valid for 0c45:613e?*/
1694 gspca_dev->cam.input_flags =
1695 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1696 PDEBUG(D_PROBE, "Sensor soi768");
1697 return;
1698 }
1699 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1700}
1701
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001702static void ov7648_probe(struct gspca_dev *gspca_dev)
1703{
1704 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001705 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001706
1707 /* check ov76xx */
1708 reg_w1(gspca_dev, 0x17, 0x62);
1709 reg_w1(gspca_dev, 0x01, 0x08);
1710 sd->i2c_addr = 0x21;
1711 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001712 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001713 reg_w1(gspca_dev, 0x01, 0x29);
1714 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001715 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1716 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1717 return;
1718 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001719
1720 /* check po1030 */
1721 reg_w1(gspca_dev, 0x17, 0x62);
1722 reg_w1(gspca_dev, 0x01, 0x08);
1723 sd->i2c_addr = 0x6e;
1724 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001725 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1726 reg_w1(gspca_dev, 0x01, 0x29);
1727 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001728 if (gspca_dev->usb_err < 0)
1729 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001730 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001731 PDEBUG(D_PROBE, "Sensor po1030");
1732 sd->sensor = SENSOR_PO1030;
1733 return;
1734 }
Jean-François Moine0b656322010-09-13 05:19:58 -03001735 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001736}
1737
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001738/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1739static void po2030n_probe(struct gspca_dev *gspca_dev)
1740{
1741 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001742 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001743
1744 /* check gc0307 */
1745 reg_w1(gspca_dev, 0x17, 0x62);
1746 reg_w1(gspca_dev, 0x01, 0x08);
1747 reg_w1(gspca_dev, 0x02, 0x22);
1748 sd->i2c_addr = 0x21;
1749 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001750 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001751 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1752 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001753 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001754 PDEBUG(D_PROBE, "Sensor gc0307");
1755 sd->sensor = SENSOR_GC0307;
1756 return;
1757 }
1758
1759 /* check po2030n */
1760 reg_w1(gspca_dev, 0x17, 0x62);
1761 reg_w1(gspca_dev, 0x01, 0x0a);
1762 sd->i2c_addr = 0x6e;
1763 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001764 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001765 reg_w1(gspca_dev, 0x01, 0x29);
1766 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001767 if (gspca_dev->usb_err < 0)
1768 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001769 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001770 PDEBUG(D_PROBE, "Sensor po2030n");
1771/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001772 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001773 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001774 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001775}
1776
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001777/* this function is called at probe time */
1778static int sd_config(struct gspca_dev *gspca_dev,
1779 const struct usb_device_id *id)
1780{
1781 struct sd *sd = (struct sd *) gspca_dev;
1782 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001783
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001784 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001785 sd->sensor = id->driver_info >> 8;
1786 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001787
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001788 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001789 if (sd->sensor == SENSOR_ADCM1700) {
1790 cam->cam_mode = cif_mode;
1791 cam->nmodes = ARRAY_SIZE(cif_mode);
1792 } else {
1793 cam->cam_mode = vga_mode;
1794 cam->nmodes = ARRAY_SIZE(vga_mode);
1795 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001796 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001797 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001798
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001799 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001800 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001801 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001802
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001803 return 0;
1804}
1805
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001806/* this function is called at probe and resume time */
1807static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001808{
1809 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001810 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001811 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001812 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001813
Hans de Goede3647fea2008-07-15 05:36:30 -03001814 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001815 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001816 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001817 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001818 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001819 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001820 if (gspca_dev->usb_err < 0)
1821 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001822 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001823 switch (sd->bridge) {
1824 case BRIDGE_SN9C102P:
Hans de Goede3647fea2008-07-15 05:36:30 -03001825 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001826 if (regF1 != 0x11)
1827 return -ENODEV;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001828 break;
1829 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001830/* case BRIDGE_SN9C110: */
Hans de Goedee530a5e2011-01-06 15:23:55 -03001831/* case BRIDGE_SN9C120: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001832 if (regF1 != 0x12)
1833 return -ENODEV;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001834 }
1835
1836 switch (sd->sensor) {
1837 case SENSOR_MI0360:
1838 mi0360_probe(gspca_dev);
1839 break;
1840 case SENSOR_OV7630:
1841 ov7630_probe(gspca_dev);
1842 break;
1843 case SENSOR_OV7648:
1844 ov7648_probe(gspca_dev);
1845 break;
1846 case SENSOR_PO2030N:
1847 po2030n_probe(gspca_dev);
1848 break;
1849 }
1850
1851 switch (sd->bridge) {
1852 case BRIDGE_SN9C102P:
1853 reg_w1(gspca_dev, 0x02, regGpio[1]);
1854 break;
1855 case BRIDGE_SN9C105:
1856 reg_w(gspca_dev, 0x01, regGpio, 2);
1857 break;
1858 case BRIDGE_SN9C110:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001859 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001860 break;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001861 case BRIDGE_SN9C120:
1862 regGpio[1] = 0x70; /* no audio */
1863 reg_w(gspca_dev, 0x01, regGpio, 2);
1864 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001865 }
1866
Jean-François Moine72b667e2010-10-02 04:35:25 -03001867 if (sd->sensor == SENSOR_OM6802)
1868 sd->ctrls[SHARPNESS].def = 0x10;
1869
Hans de Goede9712a8b2010-01-31 12:54:29 -03001870 /* Note we do not disable the sensor clock here (power saving mode),
1871 as that also disables the button on the cam. */
1872 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001873
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001874 /* set the i2c address */
1875 sn9c1xx = sn_tb[sd->sensor];
1876 sd->i2c_addr = sn9c1xx[9];
1877
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001878 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1879
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001880 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001881}
1882
Jean-Francois Moine98819182009-01-19 07:37:33 -03001883static u32 setexposure(struct gspca_dev *gspca_dev,
1884 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001885{
1886 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001887
1888 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001889 case SENSOR_GC0307: {
1890 int a, b;
1891
1892 /* expo = 0..255 -> a = 19..43 */
1893 a = 19 + expo * 25 / 256;
1894 i2c_w1(gspca_dev, 0x68, a);
1895 a -= 12;
1896 b = a * a * 4; /* heuristic */
1897 i2c_w1(gspca_dev, 0x03, b >> 8);
1898 i2c_w1(gspca_dev, 0x04, b);
1899 break;
1900 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001901 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001902 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001903 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001904
1905 Expodoit[3] = expo >> 16;
1906 Expodoit[4] = expo >> 8;
1907 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001908 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001909 break;
1910 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001911 case SENSOR_MI0360:
1912 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001913 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001914 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001915 static const u8 doit[] = /* update sensor */
1916 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1917 static const u8 sensorgo[] = /* sensor on */
1918 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001919
1920 if (expo > 0x0635)
1921 expo = 0x0635;
1922 else if (expo < 0x0001)
1923 expo = 0x0001;
1924 expoMi[3] = expo >> 8;
1925 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001926 i2c_w8(gspca_dev, expoMi);
1927 i2c_w8(gspca_dev, doit);
1928 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001929 break;
1930 }
1931 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001932 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001933 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001934 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001935 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001936 static const u8 gainMo[] =
1937 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001938
1939 if (expo > 0x1fff)
1940 expo = 0x1fff;
1941 else if (expo < 0x0001)
1942 expo = 0x0001;
1943 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001944 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001945 expoMo10[3] = ((expo & 0x1c00) >> 10)
1946 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001947 i2c_w8(gspca_dev, expoMo10);
1948 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001949 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001950 ((expoMo10[3] & 0x07) << 10)
1951 | (expoMof[3] << 2)
1952 | ((expoMo10[3] & 0x30) >> 4));
1953 break;
1954 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001955 case SENSOR_MT9V111: {
1956 u8 expo_c1[] =
1957 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1958
1959 if (expo > 0x0280)
1960 expo = 0x0280;
1961 else if (expo < 0x0040)
1962 expo = 0x0040;
1963 expo_c1[3] = expo >> 8;
1964 expo_c1[4] = expo;
1965 i2c_w8(gspca_dev, expo_c1);
1966 break;
1967 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001968 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001969 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001970 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001971 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001972
1973 if (expo > 0x03ff)
1974 expo = 0x03ff;
1975 if (expo < 0x0001)
1976 expo = 0x0001;
1977 gainOm[3] = expo >> 2;
1978 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001979 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001980 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001981 break;
1982 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001983 }
1984 return expo;
1985}
1986
1987static void setbrightness(struct gspca_dev *gspca_dev)
1988{
1989 struct sd *sd = (struct sd *) gspca_dev;
1990 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001991 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001992 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001993
Jean-François Moine72b667e2010-10-02 04:35:25 -03001994 brightness = sd->ctrls[BRIGHTNESS].val;
1995 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001996 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001997 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001998 if (k2 > 0x1f)
1999 k2 = 0; /* only positive Y offset */
2000 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002001 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002002 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002003 if (expo > 0x002dc6c0)
2004 expo = 0x002dc6c0;
2005 else if (expo < 0x02a0)
2006 expo = 0x02a0;
2007 sd->exposure = setexposure(gspca_dev, expo);
2008 break;
2009 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002010 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002011 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002012 sd->exposure = setexposure(gspca_dev, expo);
2013 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002014 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002015 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002016 sd->exposure = setexposure(gspca_dev, expo);
2017 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002018 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002019 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002020 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002021 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002022 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002023 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002024 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002025 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002026 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002027 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002028 }
2029
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002030 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002031}
2032
2033static void setcontrast(struct gspca_dev *gspca_dev)
2034{
2035 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002036 u8 k2;
2037 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002038
Jean-François Moine72b667e2010-10-02 04:35:25 -03002039 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2040 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002041 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002042 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002043 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002044 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002045 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002046 contrast[5] = 0;
2047 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002048}
2049
2050static void setcolors(struct gspca_dev *gspca_dev)
2051{
2052 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002053 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002054 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002055 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002056 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002057 -24, -38, 64, /* UR UG UB */
2058 62, -51, -9 /* VR VG VB */
2059 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002060 static const s16 uv_mi0360b[6] = {
2061 -20, -38, 64, /* UR UG UB */
2062 60, -51, -9 /* VR VG VB */
2063 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002064
Jean-François Moine72b667e2010-10-02 04:35:25 -03002065 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002066 if (sd->sensor == SENSOR_MI0360B)
2067 uv = uv_mi0360b;
2068 else
2069 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002070 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002071 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002072 reg8a[i * 2] = v;
2073 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002074 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002075 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002076}
2077
2078static void setredblue(struct gspca_dev *gspca_dev)
2079{
2080 struct sd *sd = (struct sd *) gspca_dev;
2081
Jean-François Moine72b667e2010-10-02 04:35:25 -03002082 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002083/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002084 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002085}
2086
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002087static void setgamma(struct gspca_dev *gspca_dev)
2088{
2089 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002090 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002091 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002092 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002093 static const u8 delta[17] = {
2094 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2095 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2096 };
2097
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002098 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002099 case SENSOR_ADCM1700:
2100 gamma_base = gamma_spec_0;
2101 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002102 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002103 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002104 case SENSOR_MT9V111:
2105 gamma_base = gamma_spec_1;
2106 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002107 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002108 gamma_base = gamma_spec_2;
2109 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002110 case SENSOR_SP80708:
2111 gamma_base = gamma_spec_3;
2112 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002113 default:
2114 gamma_base = gamma_def;
2115 break;
2116 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002117
Jean-François Moine72b667e2010-10-02 04:35:25 -03002118 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002119 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002120 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002121 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002122 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2123}
2124
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002125static void setautogain(struct gspca_dev *gspca_dev)
2126{
2127 struct sd *sd = (struct sd *) gspca_dev;
2128
Jean-François Moine72b667e2010-10-02 04:35:25 -03002129 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002130 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002131 switch (sd->sensor) {
2132 case SENSOR_OV7630:
2133 case SENSOR_OV7648: {
2134 u8 comb;
2135
2136 if (sd->sensor == SENSOR_OV7630)
2137 comb = 0xc0;
2138 else
2139 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002140 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec7472009-06-18 06:05:07 -03002141 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002142 i2c_w1(&sd->gspca_dev, 0x13, comb);
2143 return;
2144 }
2145 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002146 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002147 sd->ag_cnt = AG_CNT_START;
2148 else
2149 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002150}
2151
Németh Márton76ad3b62010-10-19 03:33:47 -03002152static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002153{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002154 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002155 u8 comn;
2156
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002157 switch (sd->sensor) {
2158 case SENSOR_HV7131R:
2159 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002160 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002161 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002162 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002163 break;
2164 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002165 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002166 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002167 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002168 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002169 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002170 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002171 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002172 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002173 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002174 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002175 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002176 case SENSOR_PO2030N:
2177 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2178 * (reset value: 0x0A)
2179 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2180 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2181 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2182 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2183 * bit3-0: X
2184 */
2185 comn = 0x0a;
2186 if (sd->ctrls[HFLIP].val)
2187 comn |= 0x80;
2188 if (sd->ctrls[VFLIP].val)
2189 comn |= 0x40;
2190 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2191 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002192 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002193}
2194
Jean-François Moine72b667e2010-10-02 04:35:25 -03002195static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002196{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002197 struct sd *sd = (struct sd *) gspca_dev;
2198
2199 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002200}
2201
Jean-François Moine72b667e2010-10-02 04:35:25 -03002202static void setinfrared(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002203{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002204 struct sd *sd = (struct sd *) gspca_dev;
2205
2206 if (gspca_dev->ctrl_dis & (1 << INFRARED))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002207 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002208/*fixme: different sequence for StarCam Clip and StarCam 370i */
2209/* Clip */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002210 i2c_w1(gspca_dev, 0x02, /* gpio */
2211 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002212}
2213
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002214static void setfreq(struct gspca_dev *gspca_dev)
2215{
2216 struct sd *sd = (struct sd *) gspca_dev;
2217
Jean-François Moine72b667e2010-10-02 04:35:25 -03002218 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002219 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002220 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002221 u8 com8;
2222
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002223 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002224 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002225 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002226 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002227 break;
2228 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002229 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002230 i2c_w1(gspca_dev, 0x3b, 0x0a);
2231 break;
2232 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002233 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002234 i2c_w1(gspca_dev, 0x3b, 0x02);
2235 break;
2236 }
2237 } else {
2238 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2239
2240 /* Get reg2a / reg2d base values */
2241 switch (sd->sensor) {
2242 case SENSOR_OV7630:
2243 reg2a = 0x08;
2244 reg2d = 0x01;
2245 break;
2246 case SENSOR_OV7648:
2247 reg2a = 0x11;
2248 reg2d = 0x81;
2249 break;
2250 }
2251
Jean-François Moine72b667e2010-10-02 04:35:25 -03002252 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002253 case 0: /* Banding filter disabled */
2254 break;
2255 case 1: /* 50 hz (filter on and framerate adj) */
2256 reg2a |= 0x80;
2257 reg2b = 0xac;
2258 reg2d |= 0x04;
2259 break;
2260 case 2: /* 60 hz (filter on, no framerate adj) */
2261 reg2a |= 0x80;
2262 reg2d |= 0x04;
2263 break;
2264 }
2265 i2c_w1(gspca_dev, 0x2a, reg2a);
2266 i2c_w1(gspca_dev, 0x2b, reg2b);
2267 i2c_w1(gspca_dev, 0x2d, reg2d);
2268 }
2269}
2270
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002271static void setjpegqual(struct gspca_dev *gspca_dev)
2272{
2273 struct sd *sd = (struct sd *) gspca_dev;
2274 int i, sc;
2275
2276 if (sd->jpegqual < 50)
2277 sc = 5000 / sd->jpegqual;
2278 else
2279 sc = 200 - sd->jpegqual * 2;
2280#if USB_BUF_SZ < 64
2281#error "No room enough in usb_buf for quantization table"
2282#endif
2283 for (i = 0; i < 64; i++)
2284 gspca_dev->usb_buf[i] =
2285 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2286 usb_control_msg(gspca_dev->dev,
2287 usb_sndctrlpipe(gspca_dev->dev, 0),
2288 0x08,
2289 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2290 0x0100, 0,
2291 gspca_dev->usb_buf, 64,
2292 500);
2293 for (i = 0; i < 64; i++)
2294 gspca_dev->usb_buf[i] =
2295 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2296 usb_control_msg(gspca_dev->dev,
2297 usb_sndctrlpipe(gspca_dev->dev, 0),
2298 0x08,
2299 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2300 0x0140, 0,
2301 gspca_dev->usb_buf, 64,
2302 500);
2303
2304 sd->reg18 ^= 0x40;
2305 reg_w1(gspca_dev, 0x18, sd->reg18);
2306}
2307
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002308/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002309static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002310{
2311 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002312 int i;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002313 u8 reg01, reg17;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002314 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03002315 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002316 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002317 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002318 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002319 static const u8 reg9a_def[] =
2320 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2321 static const u8 reg9a_spec[] =
2322 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2323 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002324 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2325 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002326 static const u8 CA_adcm1700[] =
2327 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002328 static const u8 CA_po2030n[] =
2329 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002330 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002331 static const u8 CE_gc0307[] =
2332 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002333 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002334 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002335 static const u8 CE_po2030n[] =
2336 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002337
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002338 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002339 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2340 0x21); /* JPEG 422 */
2341 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2342
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002343 /* initialize the bridge */
2344 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002345
2346 /* sensor clock already enabled in sd_init */
2347 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002348 reg01 = sn9c1xx[1];
2349 if (sd->flags & PDN_INV)
2350 reg01 ^= S_PDN_INV; /* power down inverted */
2351 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002352
2353 /* configure gpio */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002354 reg0102[0] = reg01;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002355 reg0102[1] = sn9c1xx[2];
2356 if (gspca_dev->audio)
2357 reg0102[1] |= 0x04; /* keep the audio connection */
2358 reg_w(gspca_dev, 0x01, reg0102, 2);
2359 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2360 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2361 switch (sd->sensor) {
2362 case SENSOR_GC0307:
2363 case SENSOR_OV7660:
2364 case SENSOR_PO1030:
2365 case SENSOR_PO2030N:
2366 case SENSOR_SOI768:
2367 case SENSOR_SP80708:
2368 reg9a = reg9a_spec;
2369 break;
2370 default:
2371 reg9a = reg9a_def;
2372 break;
2373 }
2374 reg_w(gspca_dev, 0x9a, reg9a, 6);
2375
2376 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2377
2378 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2379
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002380 reg17 = sn9c1xx[0x17];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002381 switch (sd->sensor) {
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002382 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002383 msleep(50); /*fixme: is it useful? */
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002384 break;
2385 case SENSOR_OM6802:
2386 msleep(10);
2387 reg_w1(gspca_dev, 0x02, 0x73);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002388 reg17 |= SEN_CLK_EN;
2389 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002390 reg_w1(gspca_dev, 0x01, 0x22);
2391 msleep(100);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002392 reg01 = SCL_SEL_OD | S_PDN_INV;
2393 reg17 &= MCK_SIZE_MASK;
2394 reg17 |= 0x04; /* clock / 4 */
2395 break;
2396 }
2397 reg01 |= SYS_SEL_48M;
2398 reg_w1(gspca_dev, 0x01, reg01);
2399 reg17 |= SEN_CLK_EN;
2400 reg_w1(gspca_dev, 0x17, reg17);
2401 reg01 &= ~S_PWR_DN; /* sensor power on */
2402 reg_w1(gspca_dev, 0x01, reg01);
2403 reg01 &= ~SYS_SEL_48M;
2404 reg_w1(gspca_dev, 0x01, reg01);
2405
2406 switch (sd->sensor) {
2407 case SENSOR_HV7131R:
2408 hv7131r_probe(gspca_dev); /*fixme: is it useful? */
2409 break;
2410 case SENSOR_OM6802:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002411 msleep(10);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002412 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002413 i2c_w8(gspca_dev, om6802_init0[0]);
2414 i2c_w8(gspca_dev, om6802_init0[1]);
2415 msleep(15);
2416 reg_w1(gspca_dev, 0x02, 0x71);
2417 msleep(150);
2418 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002419 case SENSOR_SP80708:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002420 msleep(100);
2421 reg_w1(gspca_dev, 0x02, 0x62);
2422 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002423 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002424
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002425 /* initialize the sensor */
2426 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2427
Jean-Francois Moine60017612008-07-18 08:46:19 -03002428 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2429 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2430 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2431 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2432 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002433 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002434 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2435 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002436 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002437 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2438 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002439 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002440 reg_w1(gspca_dev, 0xc6, 0x00);
2441 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002442 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002443 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2444 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002445 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002446 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2447 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002448 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002449 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002450 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002451 case SENSOR_OM6802:
2452/* case SENSOR_OV7648: * fixme: sometimes */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002453 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002454 default:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002455 reg17 |= DEF_EN;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002456 break;
2457 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002458 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002459
2460 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2461 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2462 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002463 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002464
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002465 setgamma(gspca_dev);
2466
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002467/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002468 for (i = 0; i < 8; i++)
2469 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002470 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002471 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002472 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002473 case SENSOR_SP80708:
2474 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002475 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002476 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002477 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002478 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002479 reg_w1(gspca_dev, 0x9a, 0x07);
2480 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002481 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002482 case SENSOR_OV7648:
2483 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002484 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002485 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002486 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002487 reg_w1(gspca_dev, 0x9a, 0x06);
2488 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002489 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002490 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002491 break;
2492 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002493 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002494
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002495 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002496 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2497 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2498 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002499
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002500 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002501 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002502 reg01 |= SYS_SEL_48M | V_TX_EN;
2503 reg17 &= ~MCK_SIZE_MASK;
2504 reg17 |= 0x02; /* clock / 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002505 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002506 case SENSOR_ADCM1700:
2507 init = adcm1700_sensor_param1;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002508 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002509 case SENSOR_GC0307:
2510 init = gc0307_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002511 break;
2512 case SENSOR_HV7131R:
2513 case SENSOR_MI0360:
2514 if (mode)
2515 reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */
2516 else
2517 reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */
2518 reg17 &= ~MCK_SIZE_MASK;
2519 reg17 |= 0x01; /* clock / 1 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002520 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002521 case SENSOR_MI0360B:
2522 init = mi0360b_sensor_param1;
Jean-François Moinea067db82010-10-01 07:51:24 -03002523 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002524 case SENSOR_MO4000:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002525 if (mode) { /* if 320x240 */
2526 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2527 reg17 &= ~MCK_SIZE_MASK;
2528 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002529 }
2530 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002531 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002532 init = mt9v111_sensor_param1;
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002533 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002534 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002535 init = om6802_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002536 if (!mode) { /* if 640x480 */
2537 reg17 &= ~MCK_SIZE_MASK;
Jean-François Moineaa777a82010-12-28 07:39:13 -03002538 reg17 |= 0x04; /* clock / 4 */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002539 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002540 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002541 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002542 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002543 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002544 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002545 init = ov7648_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002546 reg17 &= ~MCK_SIZE_MASK;
2547 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002548 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002549 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002550 init = ov7660_sensor_param1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002551 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002552 case SENSOR_PO1030:
2553 init = po1030_sensor_param1;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002554 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002555 case SENSOR_PO2030N:
2556 init = po2030n_sensor_param1;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002557 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002558 case SENSOR_SOI768:
2559 init = soi768_sensor_param1;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002560 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002561 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002562 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002563 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002564 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002565
2566 /* more sensor initialization - param1 */
2567 if (init != NULL) {
2568 i2c_w_seq(gspca_dev, init);
2569/* init = NULL; */
2570 }
2571
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002572 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002573 switch (sd->sensor) {
2574 case SENSOR_ADCM1700:
2575 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002576 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002577 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002578 break;
2579 case SENSOR_PO2030N:
2580 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2581 break;
2582 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002583 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002584 break;
2585 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002586 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002587 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002588 case SENSOR_OV7630:
2589 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002590 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002591 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002592 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002593 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002594 case SENSOR_GC0307:
2595 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2596 break;
2597 case SENSOR_PO2030N:
2598 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2599 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002600 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002601 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002602 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2603 break;
2604 }
2605
2606 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002607 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2608 reg_w1(gspca_dev, 0x18, sd->reg18);
2609 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002610
Jean-Francois Moine60017612008-07-18 08:46:19 -03002611 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002612 reg_w1(gspca_dev, 0x01, reg01);
2613 sd->reg01 = reg01;
2614 sd->reg17 = reg17;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002615
Németh Márton76ad3b62010-10-19 03:33:47 -03002616 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002617 setbrightness(gspca_dev);
2618 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002619 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002620 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002621 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002622 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002623}
2624
2625static void sd_stopN(struct gspca_dev *gspca_dev)
2626{
2627 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002628 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002629 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002630 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002631 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002632 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002633 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002634 static const u8 stopsoi768[] =
2635 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002636 u8 reg01;
2637 u8 reg17;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002638
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002639 reg01 = sd->reg01;
2640 reg17 = sd->reg17 & ~SEN_CLK_EN;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002641 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002642 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002643 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002644 case SENSOR_PO2030N:
2645 case SENSOR_SP80708:
2646 reg01 |= LED;
2647 reg_w1(gspca_dev, 0x01, reg01);
2648 reg01 &= ~(LED | V_TX_EN);
2649 reg_w1(gspca_dev, 0x01, reg01);
2650/* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002651 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002652 case SENSOR_HV7131R:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002653 reg01 &= ~V_TX_EN;
2654 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002655 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002656 break;
2657 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002658 case SENSOR_MI0360B:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002659 reg01 &= ~V_TX_EN;
2660 reg_w1(gspca_dev, 0x01, reg01);
2661/* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002662 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002663 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002664 case SENSOR_MT9V111:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002665 case SENSOR_OM6802:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002666 case SENSOR_PO1030:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002667 reg01 &= ~V_TX_EN;
2668 reg_w1(gspca_dev, 0x01, reg01);
2669 break;
2670 case SENSOR_OV7630:
2671 case SENSOR_OV7648:
2672 reg01 &= ~V_TX_EN;
2673 reg_w1(gspca_dev, 0x01, reg01);
2674 i2c_w8(gspca_dev, stopov7648);
2675 break;
2676 case SENSOR_OV7660:
2677 reg01 &= ~V_TX_EN;
2678 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002679 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002680 case SENSOR_SOI768:
2681 i2c_w8(gspca_dev, stopsoi768);
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002682 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002683 }
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002684
2685 reg01 |= SCL_SEL_OD;
2686 reg_w1(gspca_dev, 0x01, reg01);
2687 reg01 |= S_PWR_DN; /* sensor power down */
2688 reg_w1(gspca_dev, 0x01, reg01);
2689 reg_w1(gspca_dev, 0x17, reg17);
2690 reg01 &= ~SYS_SEL_48M; /* clock 24MHz */
2691 reg_w1(gspca_dev, 0x01, reg01);
2692 reg01 |= LED;
2693 reg_w1(gspca_dev, 0x01, reg01);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002694 /* Don't disable sensor clock as that disables the button on the cam */
2695 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002696}
2697
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002698static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002699{
2700 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002701 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002702 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002703 u8 luma_mean = 130;
2704 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002705
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002706 /* Thanks S., without your advice, autobright should not work :) */
2707 if (sd->ag_cnt < 0)
2708 return;
2709 if (--sd->ag_cnt >= 0)
2710 return;
2711 sd->ag_cnt = AG_CNT_START;
2712
2713 delta = atomic_read(&sd->avg_lum);
2714 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002715 if (delta < luma_mean - luma_delta ||
2716 delta > luma_mean + luma_delta) {
2717 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002718 case SENSOR_GC0307:
2719 expotimes = sd->exposure;
2720 expotimes += (luma_mean - delta) >> 6;
2721 if (expotimes < 0)
2722 expotimes = 0;
2723 sd->exposure = setexposure(gspca_dev,
2724 (unsigned int) expotimes);
2725 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002726 case SENSOR_HV7131R:
2727 expotimes = sd->exposure >> 8;
2728 expotimes += (luma_mean - delta) >> 4;
2729 if (expotimes < 0)
2730 expotimes = 0;
2731 sd->exposure = setexposure(gspca_dev,
2732 (unsigned int) (expotimes << 8));
2733 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002734 case SENSOR_OM6802:
2735 expotimes = sd->exposure;
2736 expotimes += (luma_mean - delta) >> 2;
2737 if (expotimes < 0)
2738 expotimes = 0;
2739 sd->exposure = setexposure(gspca_dev,
2740 (unsigned int) expotimes);
2741 setredblue(gspca_dev);
2742 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002743 default:
2744/* case SENSOR_MO4000: */
2745/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002746/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002747/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002748 expotimes = sd->exposure;
2749 expotimes += (luma_mean - delta) >> 6;
2750 if (expotimes < 0)
2751 expotimes = 0;
2752 sd->exposure = setexposure(gspca_dev,
2753 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002754 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002755 break;
2756 }
2757 }
2758}
2759
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002760/* scan the URB packets */
2761/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002762static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002763 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002764 int len) /* iso packet length */
2765{
2766 struct sd *sd = (struct sd *) gspca_dev;
2767 int sof, avg_lum;
2768
Jean-François Moinea95bd642010-10-01 07:54:30 -03002769 /* the image ends on a 64 bytes block starting with
2770 * ff d9 ff ff 00 c4 c4 96
2771 * and followed by various information including luminosity */
2772 /* this block may be splitted between two packets */
2773 /* a new image always starts in a new packet */
2774 switch (gspca_dev->last_packet_type) {
2775 case DISCARD_PACKET: /* restart image building */
2776 sof = len - 64;
2777 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2778 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2779 return;
2780 case LAST_PACKET: /* put the JPEG 422 header */
2781 gspca_frame_add(gspca_dev, FIRST_PACKET,
2782 sd->jpeg_hdr, JPEG_HDR_SZ);
2783 break;
2784 }
2785 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002786
Jean-François Moinea95bd642010-10-01 07:54:30 -03002787 data = gspca_dev->image;
2788 if (data == NULL)
2789 return;
2790 sof = gspca_dev->image_len - 64;
2791 if (data[sof] != 0xff
2792 || data[sof + 1] != 0xd9)
2793 return;
2794
2795 /* end of image found - remove the trailing data */
2796 gspca_dev->image_len = sof + 2;
2797 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2798 if (sd->ag_cnt < 0)
2799 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002800/* w1 w2 w3 */
2801/* w4 w5 w6 */
2802/* w7 w8 */
2803/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002804 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002805/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002806 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002807/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002808 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002809/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002810 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002811/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002812 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2813 avg_lum >>= 4;
2814 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002815}
2816
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002817static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2818 struct v4l2_jpegcompression *jcomp)
2819{
2820 struct sd *sd = (struct sd *) gspca_dev;
2821
2822 if (jcomp->quality < QUALITY_MIN)
2823 sd->quality = QUALITY_MIN;
2824 else if (jcomp->quality > QUALITY_MAX)
2825 sd->quality = QUALITY_MAX;
2826 else
2827 sd->quality = jcomp->quality;
2828 if (gspca_dev->streaming)
2829 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2830 return 0;
2831}
2832
2833static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2834 struct v4l2_jpegcompression *jcomp)
2835{
2836 struct sd *sd = (struct sd *) gspca_dev;
2837
2838 memset(jcomp, 0, sizeof *jcomp);
2839 jcomp->quality = sd->quality;
2840 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2841 | V4L2_JPEG_MARKER_DQT;
2842 return 0;
2843}
2844
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002845static int sd_querymenu(struct gspca_dev *gspca_dev,
2846 struct v4l2_querymenu *menu)
2847{
2848 switch (menu->id) {
2849 case V4L2_CID_POWER_LINE_FREQUENCY:
2850 switch (menu->index) {
2851 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2852 strcpy((char *) menu->name, "NoFliker");
2853 return 0;
2854 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2855 strcpy((char *) menu->name, "50 Hz");
2856 return 0;
2857 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2858 strcpy((char *) menu->name, "60 Hz");
2859 return 0;
2860 }
2861 break;
2862 }
2863 return -EINVAL;
2864}
2865
Jean-François Moine28566432010-10-01 07:33:26 -03002866#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002867static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2868 u8 *data, /* interrupt packet data */
2869 int len) /* interrupt packet length */
2870{
2871 int ret = -EINVAL;
2872
2873 if (len == 1 && data[0] == 1) {
2874 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2875 input_sync(gspca_dev->input_dev);
2876 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2877 input_sync(gspca_dev->input_dev);
2878 ret = 0;
2879 }
2880
2881 return ret;
2882}
2883#endif
2884
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002885/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002886static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002887 .name = MODULE_NAME,
2888 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002889 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002890 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002891 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002892 .start = sd_start,
2893 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002894 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002895 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002896 .get_jcomp = sd_get_jcomp,
2897 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002898 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002899#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002900 .int_pkt_scan = sd_int_pkt_scan,
2901#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002902};
2903
2904/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002905#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002906 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03002907 | (SENSOR_ ## sensor << 8)
2908#define BSF(bridge, sensor, flags) \
2909 .driver_info = (BRIDGE_ ## bridge << 16) \
2910 | (SENSOR_ ## sensor << 8) \
2911 | (flags)
Jean-François Moine95c967c2011-01-13 05:20:29 -03002912static const struct usb_device_id device_table[] = {
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002913 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2914 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moineb2272a42010-12-14 16:16:16 -03002915 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)},
2916 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002917 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2918 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2919 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2920 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2921 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2922/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2923 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2924/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2925/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2926 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2927/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2928 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002929 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002930/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2931/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2932/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002933 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002934 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2935/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2936/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03002937/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002938 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002939 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2940 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002941 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03002942 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002943/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2944 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2945 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2946 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2947 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2948/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2949/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2950/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2951 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002952/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002953 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03002954 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002955 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2956 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2957/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002958 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002959 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002960/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2961 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2962 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002963 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002964 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2965 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002966 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03002967 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002968 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2969 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine64677572009-12-20 12:31:28 -03002970 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Hans de Goedee48d38f2011-01-06 16:21:57 -03002971/* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002972 {}
2973};
2974MODULE_DEVICE_TABLE(usb, device_table);
2975
2976/* -- device connect -- */
2977static int sd_probe(struct usb_interface *intf,
2978 const struct usb_device_id *id)
2979{
2980 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2981 THIS_MODULE);
2982}
2983
2984static struct usb_driver sd_driver = {
2985 .name = MODULE_NAME,
2986 .id_table = device_table,
2987 .probe = sd_probe,
2988 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002989#ifdef CONFIG_PM
2990 .suspend = gspca_suspend,
2991 .resume = gspca_resume,
2992#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002993};
2994
2995/* -- module insert / remove -- */
2996static int __init sd_mod_init(void)
2997{
Jean-François Moine54826432010-09-13 04:53:03 -03002998 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002999}
3000static void __exit sd_mod_exit(void)
3001{
3002 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003003}
3004
3005module_init(sd_mod_init);
3006module_exit(sd_mod_exit);