blob: 9c5a2aace49393efe6dc1c79be538aab16d5b9cd [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03002 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003 *
Jean-François Moine27c6f9e2010-04-02 06:59:13 -03004 * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr>
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03005 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "sonixj"
23
Hans de Goede9712a8b2010-01-31 12:54:29 -030024#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030025#include "gspca.h"
26#include "jpeg.h"
27
Jean-Francois Moine0cae8962008-10-17 07:48:24 -030028#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29
Jean-François Moine27c6f9e2010-04-02 06:59:13 -030030MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030031MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL");
33
Jean-François Moine72b667e2010-10-02 04:35:25 -030034/* controls */
35enum e_ctrl {
36 BRIGHTNESS,
37 CONTRAST,
38 COLORS,
39 BLUE,
40 RED,
41 GAMMA,
42 AUTOGAIN,
Németh Márton76ad3b62010-10-19 03:33:47 -030043 HFLIP,
Jean-François Moine72b667e2010-10-02 04:35:25 -030044 VFLIP,
45 SHARPNESS,
46 INFRARED,
47 FREQ,
48 NCTRLS /* number of controls */
49};
50
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030051/* specific webcam descriptor */
52struct sd {
53 struct gspca_dev gspca_dev; /* !! must be the first item */
54
Jean-François Moine72b667e2010-10-02 04:35:25 -030055 struct gspca_ctrl ctrls[NCTRLS];
56
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030057 atomic_t avg_lum;
Jean-Francois Moine98819182009-01-19 07:37:33 -030058 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030059
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030060 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030061#define QUALITY_MIN 60
62#define QUALITY_MAX 95
63#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030064 u8 jpegqual; /* webcam quality */
65
66 u8 reg18;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -030067 u8 flags;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030068
Jean-Francois Moine98819182009-01-19 07:37:33 -030069 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030070#define AG_CNT_START 13
71
Jean-Francois Moine98819182009-01-19 07:37:33 -030072 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030073#define BRIDGE_SN9C102P 0
74#define BRIDGE_SN9C105 1
75#define BRIDGE_SN9C110 2
76#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030077 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030078 u8 i2c_addr;
79
80 u8 jpeg_hdr[JPEG_HDR_SZ];
81};
82enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030083 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030084 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030085 SENSOR_HV7131R,
86 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030087 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030088 SENSOR_MO4000,
89 SENSOR_MT9V111,
90 SENSOR_OM6802,
91 SENSOR_OV7630,
92 SENSOR_OV7648,
93 SENSOR_OV7660,
94 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030095 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030096 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030097 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030098};
99
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300100/* device flags */
101#define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */
102
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300103/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300104static void setbrightness(struct gspca_dev *gspca_dev);
105static void setcontrast(struct gspca_dev *gspca_dev);
106static void setcolors(struct gspca_dev *gspca_dev);
107static void setredblue(struct gspca_dev *gspca_dev);
108static void setgamma(struct gspca_dev *gspca_dev);
109static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300110static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300111static void setsharpness(struct gspca_dev *gspca_dev);
112static void setinfrared(struct gspca_dev *gspca_dev);
113static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300114
Jean-François Moine72b667e2010-10-02 04:35:25 -0300115static const struct ctrl sd_ctrls[NCTRLS] = {
116[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300117 {
118 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness",
121 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300122 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300123 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300124 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300125 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300126 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300127 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300128[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300129 {
130 .id = V4L2_CID_CONTRAST,
131 .type = V4L2_CTRL_TYPE_INTEGER,
132 .name = "Contrast",
133 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300134#define CONTRAST_MAX 127
135 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300136 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300137 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300138 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300139 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300141[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 {
143 .id = V4L2_CID_SATURATION,
144 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300145 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300146 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300147 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300149#define COLORS_DEF 25
150 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300151 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300152 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300154[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300155 {
156 .id = V4L2_CID_BLUE_BALANCE,
157 .type = V4L2_CTRL_TYPE_INTEGER,
158 .name = "Blue Balance",
159 .minimum = 24,
160 .maximum = 40,
161 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300162 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300163 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300164 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300165 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300166[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300167 {
168 .id = V4L2_CID_RED_BALANCE,
169 .type = V4L2_CTRL_TYPE_INTEGER,
170 .name = "Red Balance",
171 .minimum = 24,
172 .maximum = 40,
173 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300174 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300175 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300176 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300177 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300178[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300179 {
180 .id = V4L2_CID_GAMMA,
181 .type = V4L2_CTRL_TYPE_INTEGER,
182 .name = "Gamma",
183 .minimum = 0,
184 .maximum = 40,
185 .step = 1,
186#define GAMMA_DEF 20
187 .default_value = GAMMA_DEF,
188 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300189 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300190 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300191[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300192 {
193 .id = V4L2_CID_AUTOGAIN,
194 .type = V4L2_CTRL_TYPE_BOOLEAN,
195 .name = "Auto Gain",
196 .minimum = 0,
197 .maximum = 1,
198 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300199 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300200 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300201 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300202 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300203[HFLIP] = {
204 {
205 .id = V4L2_CID_HFLIP,
206 .type = V4L2_CTRL_TYPE_BOOLEAN,
207 .name = "Mirror",
208 .minimum = 0,
209 .maximum = 1,
210 .step = 1,
211 .default_value = 0,
212 },
213 .set_control = sethvflip
214 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300215[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300216 {
217 .id = V4L2_CID_VFLIP,
218 .type = V4L2_CTRL_TYPE_BOOLEAN,
219 .name = "Vflip",
220 .minimum = 0,
221 .maximum = 1,
222 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300223 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300224 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300225 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300226 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300227[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300228 {
229 .id = V4L2_CID_SHARPNESS,
230 .type = V4L2_CTRL_TYPE_INTEGER,
231 .name = "Sharpness",
232 .minimum = 0,
233 .maximum = 255,
234 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300235 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300236 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300237 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300238 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300239/* mt9v111 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300240[INFRARED] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300241 {
242 .id = V4L2_CID_INFRARED,
243 .type = V4L2_CTRL_TYPE_BOOLEAN,
244 .name = "Infrared",
245 .minimum = 0,
246 .maximum = 1,
247 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300248 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300249 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300250 .set_control = setinfrared
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300251 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300252/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300253[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300254 {
255 .id = V4L2_CID_POWER_LINE_FREQUENCY,
256 .type = V4L2_CTRL_TYPE_MENU,
257 .name = "Light frequency filter",
258 .minimum = 0,
259 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
260 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300261 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300262 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300263 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300264 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300265};
266
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300267/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300268static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300269[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
270 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300271 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300272 (1 << VFLIP) |
273 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300274
Jean-François Moine72b667e2010-10-02 04:35:25 -0300275[SENSOR_GC0307] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300276 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300277 (1 << VFLIP) |
278 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300279
Jean-François Moine72b667e2010-10-02 04:35:25 -0300280[SENSOR_HV7131R] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300281 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300282 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300283
Jean-François Moine72b667e2010-10-02 04:35:25 -0300284[SENSOR_MI0360] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300285 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300286 (1 << VFLIP) |
287 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300288
Jean-François Moine72b667e2010-10-02 04:35:25 -0300289[SENSOR_MI0360B] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300290 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300291 (1 << VFLIP) |
292 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300293
Jean-François Moine72b667e2010-10-02 04:35:25 -0300294[SENSOR_MO4000] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300295 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300296 (1 << VFLIP) |
297 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300298
Németh Márton76ad3b62010-10-19 03:33:47 -0300299[SENSOR_MT9V111] = (1 << HFLIP) |
300 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300301 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300302
Jean-François Moine72b667e2010-10-02 04:35:25 -0300303[SENSOR_OM6802] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300304 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300305 (1 << VFLIP) |
306 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300307
Németh Márton76ad3b62010-10-19 03:33:47 -0300308[SENSOR_OV7630] = (1 << INFRARED) |
309 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300310
Németh Márton76ad3b62010-10-19 03:33:47 -0300311[SENSOR_OV7648] = (1 << INFRARED) |
312 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300313
Jean-François Moine72b667e2010-10-02 04:35:25 -0300314[SENSOR_OV7660] = (1 << AUTOGAIN) |
315 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300316 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300317 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300318
Jean-François Moine72b667e2010-10-02 04:35:25 -0300319[SENSOR_PO1030] = (1 << AUTOGAIN) |
320 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300321 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300322 (1 << VFLIP) |
323 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300324
Jean-François Moine72b667e2010-10-02 04:35:25 -0300325[SENSOR_PO2030N] = (1 << AUTOGAIN) |
326 (1 << INFRARED) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300327 (1 << FREQ),
Jean-François Moine780e3122010-10-19 04:29:10 -0300328
Jean-François Moine72b667e2010-10-02 04:35:25 -0300329[SENSOR_SOI768] = (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) |
333 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300334
Jean-François Moine72b667e2010-10-02 04:35:25 -0300335[SENSOR_SP80708] = (1 << AUTOGAIN) |
336 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300337 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300338 (1 << VFLIP) |
339 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300340};
341
Jean-Francois Moine646775732009-12-20 12:31:28 -0300342static const struct v4l2_pix_format cif_mode[] = {
343 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
344 .bytesperline = 352,
345 .sizeimage = 352 * 288 * 4 / 8 + 590,
346 .colorspace = V4L2_COLORSPACE_JPEG,
347 .priv = 0},
348};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300349static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300350 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
351 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300352 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300353 .colorspace = V4L2_COLORSPACE_JPEG,
354 .priv = 2},
355 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
356 .bytesperline = 320,
357 .sizeimage = 320 * 240 * 3 / 8 + 590,
358 .colorspace = V4L2_COLORSPACE_JPEG,
359 .priv = 1},
360 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
361 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300362 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
363 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300364 .colorspace = V4L2_COLORSPACE_JPEG,
365 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300366};
367
Jean-Francois Moine646775732009-12-20 12:31:28 -0300368static const u8 sn_adcm1700[0x1c] = {
369/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300370 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine646775732009-12-20 12:31:28 -0300371/* reg8 reg9 rega regb regc regd rege regf */
372 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
374 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
375/* reg18 reg19 reg1a reg1b */
376 0x06, 0x00, 0x00, 0x00
377};
378
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300379static const u8 sn_gc0307[0x1c] = {
380/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
381 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
382/* reg8 reg9 rega regb regc regd rege regf */
383 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
385 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
386/* reg18 reg19 reg1a reg1b */
387 0x06, 0x00, 0x00, 0x00
388};
389
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300390static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300391/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300392 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300393/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300394 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300395/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
396 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300397/* reg18 reg19 reg1a reg1b */
398 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300399};
400
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300401static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300402/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300403 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300404/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300405 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300406/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
407 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300408/* reg18 reg19 reg1a reg1b */
409 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300410};
411
Jean-François Moinea067db82010-10-01 07:51:24 -0300412static const u8 sn_mi0360b[0x1c] = {
413/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
414 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
415/* reg8 reg9 rega regb regc regd rege regf */
416 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
418 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
419/* reg18 reg19 reg1a reg1b */
420 0x06, 0x00, 0x00, 0x00
421};
422
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300423static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300424/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300425 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300426/* reg8 reg9 rega regb regc regd rege regf */
427 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
428/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
429 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300430/* reg18 reg19 reg1a reg1b */
431 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300432};
433
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300434static const u8 sn_mt9v111[0x1c] = {
435/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
436 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
437/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300438 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300439/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
440 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
441/* reg18 reg19 reg1a reg1b */
442 0x06, 0x00, 0x00, 0x00
443};
444
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300445static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300446/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300447 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300448/* reg8 reg9 rega regb regc regd rege regf */
449 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
450/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
451 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300452/* reg18 reg19 reg1a reg1b */
453 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300454};
455
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300456static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300457/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300458 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300459/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300460 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300461/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
462 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300463/* reg18 reg19 reg1a reg1b */
464 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300465};
466
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300467static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300468/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300469 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300470/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300471 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300472/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300473 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300474/* reg18 reg19 reg1a reg1b */
475 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300476};
477
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300478static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300479/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300480 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300481/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300482 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300483/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
484 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300485/* reg18 reg19 reg1a reg1b */
486 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300487};
488
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300489static const u8 sn_po1030[0x1c] = {
490/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
491 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
492/* reg8 reg9 rega regb regc regd rege regf */
493 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
494/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
495 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
496/* reg18 reg19 reg1a reg1b */
497 0x07, 0x00, 0x00, 0x00
498};
499
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300500static const u8 sn_po2030n[0x1c] = {
501/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
502 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
503/* reg8 reg9 rega regb regc regd rege regf */
504 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
505/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
506 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
507/* reg18 reg19 reg1a reg1b */
508 0x07, 0x00, 0x00, 0x00
509};
510
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300511static const u8 sn_soi768[0x1c] = {
512/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
513 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
514/* reg8 reg9 rega regb regc regd rege regf */
515 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
516/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
517 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
518/* reg18 reg19 reg1a reg1b */
519 0x07, 0x00, 0x00, 0x00
520};
521
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300522static const u8 sn_sp80708[0x1c] = {
523/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
524 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
525/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300526 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300527/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
528 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
529/* reg18 reg19 reg1a reg1b */
530 0x07, 0x00, 0x00, 0x00
531};
532
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300533/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300534static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300535[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300536[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300537[SENSOR_HV7131R] = sn_hv7131,
538[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300539[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300540[SENSOR_MO4000] = sn_mo4000,
541[SENSOR_MT9V111] = sn_mt9v111,
542[SENSOR_OM6802] = sn_om6802,
543[SENSOR_OV7630] = sn_ov7630,
544[SENSOR_OV7648] = sn_ov7648,
545[SENSOR_OV7660] = sn_ov7660,
546[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300547[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300548[SENSOR_SOI768] = sn_soi768,
549[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300550};
551
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300552/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300553static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300554 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
555 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
556};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300557/* gamma for sensor ADCM1700 */
558static const u8 gamma_spec_0[17] = {
559 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
560 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
561};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300562/* gamma for sensors HV7131R and MT9V111 */
563static const u8 gamma_spec_1[17] = {
564 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
565 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
566};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300567/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300568static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300569 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
570 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
571};
572/* gamma for sensor SP80708 */
573static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300574 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
575 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
576};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300577
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300578/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300579static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300580 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
581 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
582 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
583 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300584};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300585
586#define DELAY 0xdd
587
Jean-Francois Moine646775732009-12-20 12:31:28 -0300588static const u8 adcm1700_sensor_init[][8] = {
589 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300590 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300591 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300592 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300593 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300594 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
595 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
596 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
597 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
598 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300599 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300600 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300601 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300602 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
603 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
604 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
605 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
606 {}
607};
608static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300609 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300610 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
611
612 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
613 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
615 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300616 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300617
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300618 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
619 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
621 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300622 {}
623};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300624static const u8 gc0307_sensor_init[][8] = {
625 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300645 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300646 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
663 {}
664};
665static const u8 gc0307_sensor_param1[][8] = {
666 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
667 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
668 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
669 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
670/*param3*/
671 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
672 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300673 {}
674};
675
Jean-Francois Moine98819182009-01-19 07:37:33 -0300676static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300677 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
678 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
679 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
680/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
681 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
682 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
683/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300684
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300685 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
686 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
687 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
688 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
689 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
690 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
691 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
692 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300693
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300694 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
695 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300696 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300697 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
698 {0xa1, 0x11, 0x23, 0x09, 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, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
702 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
703 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
704 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300705 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
706 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300707 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300708};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300709static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300710 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300711 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300712 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300713 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
714 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
715 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
716 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
717 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
718 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
719 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
720 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
722 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
724 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
726 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
727 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
730 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300732 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300733 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
735 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
736 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
737 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
739 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
742 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300743
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300744 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
745 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
746 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
747 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
748 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300749
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300750 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
751 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
752 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
753 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300754
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300755 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
756 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
757/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
758/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
759 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
760 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300761 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300762};
Jean-François Moinea067db82010-10-01 07:51:24 -0300763static const u8 mi0360b_sensor_init[][8] = {
764 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
765 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300766 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300767 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300768 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300769 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
770 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
771 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
773 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
774 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
775 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
788 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
789 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
791 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
793 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
795 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
798 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
799
800 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
801 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
802 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
803 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
804 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
805 {}
806};
807static const u8 mi0360b_sensor_param1[][8] = {
808 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
809 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
810 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
811 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
812
813 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
814 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
815 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
816 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
817 {}
818};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300819static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300820 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300840 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300841};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300842static const u8 mt9v111_sensor_init[][8] = {
843 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300844 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300845 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
846 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
847 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
848 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300849 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
850 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
851 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
852 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300853 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300854 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
855 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
856 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
857 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
858 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300859 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300860 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300861 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
862 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
863 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
864 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
865 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
866 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
867 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
868 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
869 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
870 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300871 {}
872};
873static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300874 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
875 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300876 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300877 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
878 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
879 /*******/
880 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
881 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
882 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
883 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
884 {}
885};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300886static const u8 om6802_init0[2][8] = {
887/*fixme: variable*/
888 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
889 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
890};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300891static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300892 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
893 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300894 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300895 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300896 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300897/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
898 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300899 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300900/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
901 * set color mode */
902/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
903 * max AGC value in AE */
904/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
905 * preset AGC */
906/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
907 * preset brightness */
908/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
909 * preset contrast */
910/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
911 * preset gamma */
912 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300913 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300914 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
915 /* preset shutter */
916/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
917 * auto frame rate */
918/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300919 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
920 {}
921};
922static const u8 om6802_sensor_param1[][8] = {
923 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
924 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
925 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
926 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300927 {}
928};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300929static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300930 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
931 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300932 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300933 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
934 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300935 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300936 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300937/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300938 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
939 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300940/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
941 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
942 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300943 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
944 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
945 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
946 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
947 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
948 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
949 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
950 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
951 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
952 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
953 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
954 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
955 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
956 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
957 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
958 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
959 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
960 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
961 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
962 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
963 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
964 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
965 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300966 {}
967};
968static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300969 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
970 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
971/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300972/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
973 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300974 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
975 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
976 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300977/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300978/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
979/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300980/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300981 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300982/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300983 {}
984};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300985
Jean-Francois Moine98819182009-01-19 07:37:33 -0300986static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300987 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
988 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300989 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300990 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
991 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
992 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
993 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
994 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
995 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
996 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
997 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
998 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
999 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1000 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1001 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1002 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1003 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1004 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1005 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1006 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1007 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1008 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1009
1010 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1011/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1012/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001013/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001014 {}
1015};
1016static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001017/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001018/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1019 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001020 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1021 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1022/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1023/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1024/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1025/*...*/
1026 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1027/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1028/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1029/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1030/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1031/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1032
1033 {}
1034};
1035
Jean-Francois Moine98819182009-01-19 07:37:33 -03001036static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001037 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001038 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001039 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001040 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001041 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001042 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001043 /* GAIN BLUE RED VREF */
1044 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1045 /* COM 1 BAVE GEAVE AECHH */
1046 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1047 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001048 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001049 /* AECH CLKRC COM7 COM8 */
1050 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1051 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1052 /* HSTART HSTOP VSTRT VSTOP */
1053 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1054 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1055 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1056 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001057/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1058 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001059 /* AEW AEB VPT BBIAS */
1060 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1061 /* GbBIAS RSVD EXHCH EXHCL */
1062 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1063 /* RBIAS ADVFL ASDVFH YAVE */
1064 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1065 /* HSYST HSYEN HREF */
1066 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1067 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1068 /* ADC ACOM OFON TSLB */
1069 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1070 /* COM11 COM12 COM13 COM14 */
1071 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1072 /* EDGE COM15 COM16 COM17 */
1073 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1074 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1075 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1076 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1077 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1078 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1079 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1080 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1081 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1082 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1083 /* LCC1 LCC2 LCC3 LCC4 */
1084 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001085 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001086 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001087 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001088 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1089 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1090 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1091 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1092 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1093 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1094 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1095 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1096 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001097 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001098/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001099 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001100 {}
1101};
1102static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001103 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001104 /* bits[3..0]reserved */
1105 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1106 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1107 /* VREF vertical frame ctrl */
1108 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001109 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1110 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1111 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1112 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1113/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001114/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001115/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001116 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001117 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1118 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1119 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1120/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001121/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001122/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001123/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001124 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1125 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1126 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1127 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001128 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001129};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001130
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001131static const u8 po1030_sensor_init[][8] = {
1132/* the sensor registers are described in m5602/m5602_po1030.h */
1133 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001134 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001135 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1136 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1137 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1138 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1139 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1140 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1141 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1142 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1143 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1144 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1145 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1146 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1148 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1149 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1150 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1151 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1152 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1153 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1154 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1155 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1156 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1157 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1158 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1159 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1160 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1161
1162 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1163 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1165 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1166 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1167 {}
1168};
1169static const u8 po1030_sensor_param1[][8] = {
1170/* from ms-win traces - these values change with auto gain/expo/wb.. */
1171 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1172 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1173/* mean values */
1174 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1175 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1176 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1177
1178 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1179 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1180 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1181/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1182 {}
1183};
1184
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001185static const u8 po2030n_sensor_init[][8] = {
1186 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1187 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001188 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001189 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1190 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001191 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001192 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1193 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1194 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1195 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1197 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1198 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1199 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1200 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1202 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1203 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1204 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1207 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1208 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1209 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1212 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1213 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1216 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1226 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1227 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1230 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1231 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1232 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1234 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1235 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1236 {}
1237};
1238static const u8 po2030n_sensor_param1[][8] = {
1239 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001240 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001241 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1242 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1243 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1244/*param2*/
1245 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1246 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1247 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1248 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1249 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1251 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1252/*after start*/
1253 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001254 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001255 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001256 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001257 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1258 {}
1259};
1260
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001261static const u8 soi768_sensor_init[][8] = {
1262 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001263 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001264 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1265 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1266 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1267 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1268 {}
1269};
1270static const u8 soi768_sensor_param1[][8] = {
1271 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1272 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1273 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1274 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1275 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1276/* */
1277/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1278/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1279 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1280/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1281 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1282/* the next sequence should be used for auto gain */
1283 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1284 /* global gain ? : 07 - change with 0x15 at the end */
1285 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1286 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1287 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1288 /* exposure ? : 0200 - change with 0x1e at the end */
1289 {}
1290};
1291
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001292static const u8 sp80708_sensor_init[][8] = {
1293 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1294 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1295 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1296 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1297 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001364 {}
1365};
1366static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001367 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1368 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1369 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1370 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1371 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1373 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1374 {}
1375};
1376
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001377static const u8 (*sensor_init[])[8] = {
1378[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001379[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001380[SENSOR_HV7131R] = hv7131r_sensor_init,
1381[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001382[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001383[SENSOR_MO4000] = mo4000_sensor_init,
1384[SENSOR_MT9V111] = mt9v111_sensor_init,
1385[SENSOR_OM6802] = om6802_sensor_init,
1386[SENSOR_OV7630] = ov7630_sensor_init,
1387[SENSOR_OV7648] = ov7648_sensor_init,
1388[SENSOR_OV7660] = ov7660_sensor_init,
1389[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001390[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001391[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001392[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001393};
1394
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001395/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001396static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001397 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001398{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001399 int ret;
1400
1401 if (gspca_dev->usb_err < 0)
1402 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001403#ifdef GSPCA_DEBUG
1404 if (len > USB_BUF_SZ) {
1405 err("reg_r: buffer overflow");
1406 return;
1407 }
1408#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001409 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001410 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001411 0,
1412 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1413 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001414 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001415 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001416 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001417 if (ret < 0) {
1418 err("reg_r err %d", ret);
1419 gspca_dev->usb_err = ret;
1420 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001421}
1422
Jean-Francois Moine60017612008-07-18 08:46:19 -03001423static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001424 u16 value,
1425 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001426{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001427 int ret;
1428
1429 if (gspca_dev->usb_err < 0)
1430 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001431 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001432 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001433 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001434 usb_sndctrlpipe(gspca_dev->dev, 0),
1435 0x08,
1436 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1437 value,
1438 0,
1439 gspca_dev->usb_buf, 1,
1440 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001441 if (ret < 0) {
1442 err("reg_w1 err %d", ret);
1443 gspca_dev->usb_err = ret;
1444 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001445}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001446static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001447 u16 value,
1448 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001449 int len)
1450{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001451 int ret;
1452
1453 if (gspca_dev->usb_err < 0)
1454 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001455 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001456 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001457#ifdef GSPCA_DEBUG
1458 if (len > USB_BUF_SZ) {
1459 err("reg_w: buffer overflow");
1460 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001461 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001462#endif
1463 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001464 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001465 usb_sndctrlpipe(gspca_dev->dev, 0),
1466 0x08,
1467 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1468 value, 0,
1469 gspca_dev->usb_buf, len,
1470 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001471 if (ret < 0) {
1472 err("reg_w err %d", ret);
1473 gspca_dev->usb_err = ret;
1474 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001475}
1476
Jean-Francois Moine60017612008-07-18 08:46:19 -03001477/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001478static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001479{
1480 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001481 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001482
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001483 if (gspca_dev->usb_err < 0)
1484 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001485 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001486 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001487 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001488 case SENSOR_OM6802:
1489 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001490 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1491 break;
1492 default: /* i2c command = a1 (400 kHz) */
1493 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1494 break;
1495 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001496 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001497 gspca_dev->usb_buf[2] = reg;
1498 gspca_dev->usb_buf[3] = val;
1499 gspca_dev->usb_buf[4] = 0;
1500 gspca_dev->usb_buf[5] = 0;
1501 gspca_dev->usb_buf[6] = 0;
1502 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001503 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001504 usb_sndctrlpipe(gspca_dev->dev, 0),
1505 0x08,
1506 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1507 0x08, /* value = i2c */
1508 0,
1509 gspca_dev->usb_buf, 8,
1510 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001511 if (ret < 0) {
1512 err("i2c_w1 err %d", ret);
1513 gspca_dev->usb_err = ret;
1514 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001515}
1516
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001517/* I2C write 8 bytes */
1518static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001519 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001520{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001521 int ret;
1522
1523 if (gspca_dev->usb_err < 0)
1524 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001525 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1526 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001527 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001528 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001529 usb_sndctrlpipe(gspca_dev->dev, 0),
1530 0x08,
1531 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1532 0x08, 0, /* value, index */
1533 gspca_dev->usb_buf, 8,
1534 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001535 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001536 if (ret < 0) {
1537 err("i2c_w8 err %d", ret);
1538 gspca_dev->usb_err = ret;
1539 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001540}
1541
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001542/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1543static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001544{
1545 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001546 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001547
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001548 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001549 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001550 case SENSOR_OM6802:
1551 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001552 mode[0] = 0x80 | 0x10;
1553 break;
1554 default: /* i2c command = 91 (400 kHz) */
1555 mode[0] = 0x81 | 0x10;
1556 break;
1557 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001558 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001559 mode[2] = reg;
1560 mode[3] = 0;
1561 mode[4] = 0;
1562 mode[5] = 0;
1563 mode[6] = 0;
1564 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001565 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001566 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001567 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001568 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001569 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001570 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001571 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001572}
1573
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001574static void i2c_w_seq(struct gspca_dev *gspca_dev,
1575 const u8 (*data)[8])
1576{
1577 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001578 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001579 i2c_w8(gspca_dev, *data);
1580 else
1581 msleep((*data)[1]);
1582 data++;
1583 }
1584}
1585
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001586static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001587{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001588 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001589 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001590 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001591 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001592 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001593 if (gspca_dev->usb_buf[0] == 0x02
1594 && gspca_dev->usb_buf[1] == 0x09
1595 && gspca_dev->usb_buf[2] == 0x01
1596 && gspca_dev->usb_buf[3] == 0x00
1597 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001598 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1599 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001600 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001601 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001602 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1603 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001604}
1605
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001606static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001607{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001608 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001609 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001610 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001611 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001612 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001613 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1614 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1615 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1616 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1617 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001618 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001619 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1620 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1621 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1622 {}
1623 },
1624 };
1625
1626 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1627 reg_w1(gspca_dev, 0x17, 0x62);
1628 reg_w1(gspca_dev, 0x01, 0x08);
1629 for (j = 0; j < 3; j++)
1630 i2c_w8(gspca_dev, probe_tb[i][j]);
1631 msleep(2);
1632 reg_r(gspca_dev, 0x0a, 5);
1633 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1634 if (probe_tb[i][3][0] != 0)
1635 i2c_w8(gspca_dev, probe_tb[i][3]);
1636 reg_w1(gspca_dev, 0x01, 0x29);
1637 reg_w1(gspca_dev, 0x17, 0x42);
1638 if (val != 0xffff)
1639 break;
1640 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001641 if (gspca_dev->usb_err < 0)
1642 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001643 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001644 case 0x8221:
1645 PDEBUG(D_PROBE, "Sensor mi0360b");
1646 sd->sensor = SENSOR_MI0360B;
1647 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001648 case 0x823a:
1649 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001650 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001651 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001652 case 0x8243:
1653 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001654 break;
1655 default:
1656 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1657 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001658 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001659}
1660
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001661static void ov7630_probe(struct gspca_dev *gspca_dev)
1662{
1663 struct sd *sd = (struct sd *) gspca_dev;
1664 u16 val;
1665
1666 /* check ov76xx */
1667 reg_w1(gspca_dev, 0x17, 0x62);
1668 reg_w1(gspca_dev, 0x01, 0x08);
1669 sd->i2c_addr = 0x21;
1670 i2c_r(gspca_dev, 0x0a, 2);
1671 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1672 reg_w1(gspca_dev, 0x01, 0x29);
1673 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001674 if (gspca_dev->usb_err < 0)
1675 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001676 if (val == 0x7628) { /* soi768 */
1677 sd->sensor = SENSOR_SOI768;
1678/*fixme: only valid for 0c45:613e?*/
1679 gspca_dev->cam.input_flags =
1680 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1681 PDEBUG(D_PROBE, "Sensor soi768");
1682 return;
1683 }
1684 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1685}
1686
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001687static void ov7648_probe(struct gspca_dev *gspca_dev)
1688{
1689 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001690 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001691
1692 /* check ov76xx */
1693 reg_w1(gspca_dev, 0x17, 0x62);
1694 reg_w1(gspca_dev, 0x01, 0x08);
1695 sd->i2c_addr = 0x21;
1696 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001697 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001698 reg_w1(gspca_dev, 0x01, 0x29);
1699 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001700 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1701 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1702 return;
1703 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001704
1705 /* check po1030 */
1706 reg_w1(gspca_dev, 0x17, 0x62);
1707 reg_w1(gspca_dev, 0x01, 0x08);
1708 sd->i2c_addr = 0x6e;
1709 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001710 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1711 reg_w1(gspca_dev, 0x01, 0x29);
1712 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001713 if (gspca_dev->usb_err < 0)
1714 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001715 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001716 PDEBUG(D_PROBE, "Sensor po1030");
1717 sd->sensor = SENSOR_PO1030;
1718 return;
1719 }
Jean-François Moine0b656322010-09-13 05:19:58 -03001720 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001721}
1722
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001723/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1724static void po2030n_probe(struct gspca_dev *gspca_dev)
1725{
1726 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001727 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001728
1729 /* check gc0307 */
1730 reg_w1(gspca_dev, 0x17, 0x62);
1731 reg_w1(gspca_dev, 0x01, 0x08);
1732 reg_w1(gspca_dev, 0x02, 0x22);
1733 sd->i2c_addr = 0x21;
1734 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001735 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001736 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1737 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001738 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001739 PDEBUG(D_PROBE, "Sensor gc0307");
1740 sd->sensor = SENSOR_GC0307;
1741 return;
1742 }
1743
1744 /* check po2030n */
1745 reg_w1(gspca_dev, 0x17, 0x62);
1746 reg_w1(gspca_dev, 0x01, 0x0a);
1747 sd->i2c_addr = 0x6e;
1748 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001749 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001750 reg_w1(gspca_dev, 0x01, 0x29);
1751 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001752 if (gspca_dev->usb_err < 0)
1753 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001754 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001755 PDEBUG(D_PROBE, "Sensor po2030n");
1756/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001757 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001758 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001759 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001760}
1761
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001762/* this function is called at probe time */
1763static int sd_config(struct gspca_dev *gspca_dev,
1764 const struct usb_device_id *id)
1765{
1766 struct sd *sd = (struct sd *) gspca_dev;
1767 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001768
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001769 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001770 sd->sensor = id->driver_info >> 8;
1771 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001772
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001773 cam = &gspca_dev->cam;
Jean-Francois Moine646775732009-12-20 12:31:28 -03001774 if (sd->sensor == SENSOR_ADCM1700) {
1775 cam->cam_mode = cif_mode;
1776 cam->nmodes = ARRAY_SIZE(cif_mode);
1777 } else {
1778 cam->cam_mode = vga_mode;
1779 cam->nmodes = ARRAY_SIZE(vga_mode);
1780 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001781 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001782 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001783
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001784 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001785 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001786 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001787
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001788 return 0;
1789}
1790
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001791/* this function is called at probe and resume time */
1792static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001793{
1794 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001795 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001796 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001797 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001798
Hans de Goede3647fea2008-07-15 05:36:30 -03001799 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001800 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001801 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001802 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001803 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001804 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001805 if (gspca_dev->usb_err < 0)
1806 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001807 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001808 switch (sd->bridge) {
1809 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001810 if (regF1 != 0x11)
1811 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001812 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001813 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001814 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001815 if (regF1 != 0x11)
1816 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001817 if (sd->sensor == SENSOR_MI0360)
1818 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001819 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001820 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001821 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001822 if (regF1 != 0x12)
1823 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001824 switch (sd->sensor) {
1825 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001826 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001827 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001828 case SENSOR_OV7630:
1829 ov7630_probe(gspca_dev);
1830 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001831 case SENSOR_OV7648:
1832 ov7648_probe(gspca_dev);
1833 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001834 case SENSOR_PO2030N:
1835 po2030n_probe(gspca_dev);
1836 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001837 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001838 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001839 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001840 break;
1841 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001842/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001843/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001844 if (regF1 != 0x12)
1845 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001846 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001847 break;
1848 }
1849
Jean-François Moine72b667e2010-10-02 04:35:25 -03001850 if (sd->sensor == SENSOR_OM6802)
1851 sd->ctrls[SHARPNESS].def = 0x10;
1852
Hans de Goede9712a8b2010-01-31 12:54:29 -03001853 /* Note we do not disable the sensor clock here (power saving mode),
1854 as that also disables the button on the cam. */
1855 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001856
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001857 /* set the i2c address */
1858 sn9c1xx = sn_tb[sd->sensor];
1859 sd->i2c_addr = sn9c1xx[9];
1860
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001861 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1862
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001863 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001864}
1865
Jean-Francois Moine98819182009-01-19 07:37:33 -03001866static u32 setexposure(struct gspca_dev *gspca_dev,
1867 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001868{
1869 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001870
1871 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001872 case SENSOR_GC0307: {
1873 int a, b;
1874
1875 /* expo = 0..255 -> a = 19..43 */
1876 a = 19 + expo * 25 / 256;
1877 i2c_w1(gspca_dev, 0x68, a);
1878 a -= 12;
1879 b = a * a * 4; /* heuristic */
1880 i2c_w1(gspca_dev, 0x03, b >> 8);
1881 i2c_w1(gspca_dev, 0x04, b);
1882 break;
1883 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001884 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001885 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001886 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001887
1888 Expodoit[3] = expo >> 16;
1889 Expodoit[4] = expo >> 8;
1890 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001891 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001892 break;
1893 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001894 case SENSOR_MI0360:
1895 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001896 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001897 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001898 static const u8 doit[] = /* update sensor */
1899 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1900 static const u8 sensorgo[] = /* sensor on */
1901 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001902
1903 if (expo > 0x0635)
1904 expo = 0x0635;
1905 else if (expo < 0x0001)
1906 expo = 0x0001;
1907 expoMi[3] = expo >> 8;
1908 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001909 i2c_w8(gspca_dev, expoMi);
1910 i2c_w8(gspca_dev, doit);
1911 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001912 break;
1913 }
1914 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001915 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001916 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001917 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001918 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001919 static const u8 gainMo[] =
1920 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001921
1922 if (expo > 0x1fff)
1923 expo = 0x1fff;
1924 else if (expo < 0x0001)
1925 expo = 0x0001;
1926 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001927 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001928 expoMo10[3] = ((expo & 0x1c00) >> 10)
1929 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001930 i2c_w8(gspca_dev, expoMo10);
1931 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001932 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001933 ((expoMo10[3] & 0x07) << 10)
1934 | (expoMof[3] << 2)
1935 | ((expoMo10[3] & 0x30) >> 4));
1936 break;
1937 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001938 case SENSOR_MT9V111: {
1939 u8 expo_c1[] =
1940 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1941
1942 if (expo > 0x0280)
1943 expo = 0x0280;
1944 else if (expo < 0x0040)
1945 expo = 0x0040;
1946 expo_c1[3] = expo >> 8;
1947 expo_c1[4] = expo;
1948 i2c_w8(gspca_dev, expo_c1);
1949 break;
1950 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001951 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001952 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001953 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001954 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001955
1956 if (expo > 0x03ff)
1957 expo = 0x03ff;
1958 if (expo < 0x0001)
1959 expo = 0x0001;
1960 gainOm[3] = expo >> 2;
1961 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001962 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001963 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001964 break;
1965 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001966 }
1967 return expo;
1968}
1969
1970static void setbrightness(struct gspca_dev *gspca_dev)
1971{
1972 struct sd *sd = (struct sd *) gspca_dev;
1973 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001974 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001975 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001976
Jean-François Moine72b667e2010-10-02 04:35:25 -03001977 brightness = sd->ctrls[BRIGHTNESS].val;
1978 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001979 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001980 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001981 if (k2 > 0x1f)
1982 k2 = 0; /* only positive Y offset */
1983 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001984 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001985 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001986 if (expo > 0x002dc6c0)
1987 expo = 0x002dc6c0;
1988 else if (expo < 0x02a0)
1989 expo = 0x02a0;
1990 sd->exposure = setexposure(gspca_dev, expo);
1991 break;
1992 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001993 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001994 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001995 sd->exposure = setexposure(gspca_dev, expo);
1996 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03001997 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001998 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03001999 sd->exposure = setexposure(gspca_dev, expo);
2000 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002001 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002002 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002003 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002004 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002005 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002006 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002007 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002008 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002009 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002010 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002011 }
2012
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002013 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002014}
2015
2016static void setcontrast(struct gspca_dev *gspca_dev)
2017{
2018 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002019 u8 k2;
2020 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002021
Jean-François Moine72b667e2010-10-02 04:35:25 -03002022 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2023 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002024 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002025 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002026 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002027 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002028 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002029 contrast[5] = 0;
2030 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002031}
2032
2033static void setcolors(struct gspca_dev *gspca_dev)
2034{
2035 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002036 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002037 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002038 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002039 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002040 -24, -38, 64, /* UR UG UB */
2041 62, -51, -9 /* VR VG VB */
2042 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002043 static const s16 uv_mi0360b[6] = {
2044 -20, -38, 64, /* UR UG UB */
2045 60, -51, -9 /* VR VG VB */
2046 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002047
Jean-François Moine72b667e2010-10-02 04:35:25 -03002048 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002049 if (sd->sensor == SENSOR_MI0360B)
2050 uv = uv_mi0360b;
2051 else
2052 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002053 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002054 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002055 reg8a[i * 2] = v;
2056 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002057 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002058 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002059}
2060
2061static void setredblue(struct gspca_dev *gspca_dev)
2062{
2063 struct sd *sd = (struct sd *) gspca_dev;
2064
Jean-François Moine72b667e2010-10-02 04:35:25 -03002065 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002066/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002067 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002068}
2069
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002070static void setgamma(struct gspca_dev *gspca_dev)
2071{
2072 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002073 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002074 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002075 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002076 static const u8 delta[17] = {
2077 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2078 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2079 };
2080
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002081 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002082 case SENSOR_ADCM1700:
2083 gamma_base = gamma_spec_0;
2084 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002085 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002086 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002087 case SENSOR_MT9V111:
2088 gamma_base = gamma_spec_1;
2089 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002090 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002091 gamma_base = gamma_spec_2;
2092 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002093 case SENSOR_SP80708:
2094 gamma_base = gamma_spec_3;
2095 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002096 default:
2097 gamma_base = gamma_def;
2098 break;
2099 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002100
Jean-François Moine72b667e2010-10-02 04:35:25 -03002101 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002102 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002103 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002104 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002105 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2106}
2107
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002108static void setautogain(struct gspca_dev *gspca_dev)
2109{
2110 struct sd *sd = (struct sd *) gspca_dev;
2111
Jean-François Moine72b667e2010-10-02 04:35:25 -03002112 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002113 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002114 switch (sd->sensor) {
2115 case SENSOR_OV7630:
2116 case SENSOR_OV7648: {
2117 u8 comb;
2118
2119 if (sd->sensor == SENSOR_OV7630)
2120 comb = 0xc0;
2121 else
2122 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002123 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec747c2009-06-18 06:05:07 -03002124 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002125 i2c_w1(&sd->gspca_dev, 0x13, comb);
2126 return;
2127 }
2128 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002129 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002130 sd->ag_cnt = AG_CNT_START;
2131 else
2132 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002133}
2134
Németh Márton76ad3b62010-10-19 03:33:47 -03002135static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002136{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002137 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002138 u8 comn;
2139
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002140 switch (sd->sensor) {
2141 case SENSOR_HV7131R:
2142 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002143 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002144 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002145 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002146 break;
2147 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002148 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002149 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002150 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002151 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002152 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002153 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002154 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002155 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002156 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002157 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002158 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002159 case SENSOR_PO2030N:
2160 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2161 * (reset value: 0x0A)
2162 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2163 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2164 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2165 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2166 * bit3-0: X
2167 */
2168 comn = 0x0a;
2169 if (sd->ctrls[HFLIP].val)
2170 comn |= 0x80;
2171 if (sd->ctrls[VFLIP].val)
2172 comn |= 0x40;
2173 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2174 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002175 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002176}
2177
Jean-François Moine72b667e2010-10-02 04:35:25 -03002178static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002179{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002180 struct sd *sd = (struct sd *) gspca_dev;
2181
2182 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002183}
2184
Jean-François Moine72b667e2010-10-02 04:35:25 -03002185static void setinfrared(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002186{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002187 struct sd *sd = (struct sd *) gspca_dev;
2188
2189 if (gspca_dev->ctrl_dis & (1 << INFRARED))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002190 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002191/*fixme: different sequence for StarCam Clip and StarCam 370i */
2192/* Clip */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002193 i2c_w1(gspca_dev, 0x02, /* gpio */
2194 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002195}
2196
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002197static void setfreq(struct gspca_dev *gspca_dev)
2198{
2199 struct sd *sd = (struct sd *) gspca_dev;
2200
Jean-François Moine72b667e2010-10-02 04:35:25 -03002201 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002202 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002203 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002204 u8 com8;
2205
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002206 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002207 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002208 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002209 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002210 break;
2211 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002212 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002213 i2c_w1(gspca_dev, 0x3b, 0x0a);
2214 break;
2215 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002216 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002217 i2c_w1(gspca_dev, 0x3b, 0x02);
2218 break;
2219 }
2220 } else {
2221 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2222
2223 /* Get reg2a / reg2d base values */
2224 switch (sd->sensor) {
2225 case SENSOR_OV7630:
2226 reg2a = 0x08;
2227 reg2d = 0x01;
2228 break;
2229 case SENSOR_OV7648:
2230 reg2a = 0x11;
2231 reg2d = 0x81;
2232 break;
2233 }
2234
Jean-François Moine72b667e2010-10-02 04:35:25 -03002235 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002236 case 0: /* Banding filter disabled */
2237 break;
2238 case 1: /* 50 hz (filter on and framerate adj) */
2239 reg2a |= 0x80;
2240 reg2b = 0xac;
2241 reg2d |= 0x04;
2242 break;
2243 case 2: /* 60 hz (filter on, no framerate adj) */
2244 reg2a |= 0x80;
2245 reg2d |= 0x04;
2246 break;
2247 }
2248 i2c_w1(gspca_dev, 0x2a, reg2a);
2249 i2c_w1(gspca_dev, 0x2b, reg2b);
2250 i2c_w1(gspca_dev, 0x2d, reg2d);
2251 }
2252}
2253
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002254static void setjpegqual(struct gspca_dev *gspca_dev)
2255{
2256 struct sd *sd = (struct sd *) gspca_dev;
2257 int i, sc;
2258
2259 if (sd->jpegqual < 50)
2260 sc = 5000 / sd->jpegqual;
2261 else
2262 sc = 200 - sd->jpegqual * 2;
2263#if USB_BUF_SZ < 64
2264#error "No room enough in usb_buf for quantization table"
2265#endif
2266 for (i = 0; i < 64; i++)
2267 gspca_dev->usb_buf[i] =
2268 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2269 usb_control_msg(gspca_dev->dev,
2270 usb_sndctrlpipe(gspca_dev->dev, 0),
2271 0x08,
2272 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2273 0x0100, 0,
2274 gspca_dev->usb_buf, 64,
2275 500);
2276 for (i = 0; i < 64; i++)
2277 gspca_dev->usb_buf[i] =
2278 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2279 usb_control_msg(gspca_dev->dev,
2280 usb_sndctrlpipe(gspca_dev->dev, 0),
2281 0x08,
2282 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2283 0x0140, 0,
2284 gspca_dev->usb_buf, 64,
2285 500);
2286
2287 sd->reg18 ^= 0x40;
2288 reg_w1(gspca_dev, 0x18, sd->reg18);
2289}
2290
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002291/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002292static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002293{
2294 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002295 int i;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002296 u8 reg0102[2];
Jean-François Moine19697b52010-07-14 06:33:51 -03002297 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002298 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002299 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002300 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002301 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002302 static const u8 reg9a_def[] =
2303 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2304 static const u8 reg9a_spec[] =
2305 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2306 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002307 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2308 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine646775732009-12-20 12:31:28 -03002309 static const u8 CA_adcm1700[] =
2310 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002311 static const u8 CA_po2030n[] =
2312 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002313 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002314 static const u8 CE_gc0307[] =
2315 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002316 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002317 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002318 static const u8 CE_po2030n[] =
2319 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002320
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002321 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002322 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2323 0x21); /* JPEG 422 */
2324 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2325
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002326 /* initialize the bridge */
2327 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002328
2329 /* sensor clock already enabled in sd_init */
2330 /* reg_w1(gspca_dev, 0xf1, 0x00); */
2331 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2332
2333 /* configure gpio */
2334 reg0102[0] = sn9c1xx[1];
2335 reg0102[1] = sn9c1xx[2];
2336 if (gspca_dev->audio)
2337 reg0102[1] |= 0x04; /* keep the audio connection */
2338 reg_w(gspca_dev, 0x01, reg0102, 2);
2339 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2340 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2341 switch (sd->sensor) {
2342 case SENSOR_GC0307:
2343 case SENSOR_OV7660:
2344 case SENSOR_PO1030:
2345 case SENSOR_PO2030N:
2346 case SENSOR_SOI768:
2347 case SENSOR_SP80708:
2348 reg9a = reg9a_spec;
2349 break;
2350 default:
2351 reg9a = reg9a_def;
2352 break;
2353 }
2354 reg_w(gspca_dev, 0x9a, reg9a, 6);
2355
2356 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2357
2358 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2359
2360 switch (sd->sensor) {
2361 case SENSOR_ADCM1700:
2362 reg_w1(gspca_dev, 0x01, 0x43);
2363 reg_w1(gspca_dev, 0x17, 0x62);
2364 reg_w1(gspca_dev, 0x01, 0x42);
2365 reg_w1(gspca_dev, 0x01, 0x42);
2366 break;
2367 case SENSOR_GC0307:
2368 msleep(50);
2369 reg_w1(gspca_dev, 0x01, 0x61);
2370 reg_w1(gspca_dev, 0x17, 0x22);
2371 reg_w1(gspca_dev, 0x01, 0x60);
2372 reg_w1(gspca_dev, 0x01, 0x40);
2373 msleep(50);
2374 break;
2375 case SENSOR_MI0360B:
2376 reg_w1(gspca_dev, 0x01, 0x61);
2377 reg_w1(gspca_dev, 0x17, 0x60);
2378 reg_w1(gspca_dev, 0x01, 0x60);
2379 reg_w1(gspca_dev, 0x01, 0x40);
2380 break;
2381 case SENSOR_MT9V111:
2382 reg_w1(gspca_dev, 0x01, 0x61);
2383 reg_w1(gspca_dev, 0x17, 0x61);
2384 reg_w1(gspca_dev, 0x01, 0x60);
2385 reg_w1(gspca_dev, 0x01, 0x40);
2386 break;
2387 case SENSOR_OM6802:
2388 msleep(10);
2389 reg_w1(gspca_dev, 0x02, 0x73);
2390 reg_w1(gspca_dev, 0x17, 0x60);
2391 reg_w1(gspca_dev, 0x01, 0x22);
2392 msleep(100);
2393 reg_w1(gspca_dev, 0x01, 0x62);
2394 reg_w1(gspca_dev, 0x17, 0x64);
2395 reg_w1(gspca_dev, 0x17, 0x64);
2396 reg_w1(gspca_dev, 0x01, 0x42);
2397 msleep(10);
2398 reg_w1(gspca_dev, 0x01, 0x42);
2399 i2c_w8(gspca_dev, om6802_init0[0]);
2400 i2c_w8(gspca_dev, om6802_init0[1]);
2401 msleep(15);
2402 reg_w1(gspca_dev, 0x02, 0x71);
2403 msleep(150);
2404 break;
2405 case SENSOR_OV7630:
2406 reg_w1(gspca_dev, 0x01, 0x61);
2407 reg_w1(gspca_dev, 0x17, 0xe2);
2408 reg_w1(gspca_dev, 0x01, 0x60);
2409 reg_w1(gspca_dev, 0x01, 0x40);
2410 break;
2411 case SENSOR_OV7648:
2412 reg_w1(gspca_dev, 0x01, 0x63);
2413 reg_w1(gspca_dev, 0x17, 0x20);
2414 reg_w1(gspca_dev, 0x01, 0x62);
2415 reg_w1(gspca_dev, 0x01, 0x42);
2416 break;
2417 case SENSOR_PO1030:
2418 case SENSOR_SOI768:
2419 reg_w1(gspca_dev, 0x01, 0x61);
2420 reg_w1(gspca_dev, 0x17, 0x20);
2421 reg_w1(gspca_dev, 0x01, 0x60);
2422 reg_w1(gspca_dev, 0x01, 0x40);
2423 break;
2424 case SENSOR_PO2030N:
2425 case SENSOR_OV7660:
2426 reg_w1(gspca_dev, 0x01, 0x63);
2427 reg_w1(gspca_dev, 0x17, 0x20);
2428 reg_w1(gspca_dev, 0x01, 0x62);
2429 reg_w1(gspca_dev, 0x01, 0x42);
2430 break;
2431 case SENSOR_SP80708:
2432 reg_w1(gspca_dev, 0x01, 0x63);
2433 reg_w1(gspca_dev, 0x17, 0x20);
2434 reg_w1(gspca_dev, 0x01, 0x62);
2435 reg_w1(gspca_dev, 0x01, 0x42);
2436 msleep(100);
2437 reg_w1(gspca_dev, 0x02, 0x62);
2438 break;
2439 default:
2440/* case SENSOR_HV7131R: */
2441/* case SENSOR_MI0360: */
2442/* case SENSOR_MO4000: */
2443 reg_w1(gspca_dev, 0x01, 0x43);
2444 reg_w1(gspca_dev, 0x17, 0x61);
2445 reg_w1(gspca_dev, 0x01, 0x42);
2446 if (sd->sensor == SENSOR_HV7131R)
2447 hv7131r_probe(gspca_dev);
2448 break;
2449 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002450
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002451 /* initialize the sensor */
2452 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2453
Jean-Francois Moine60017612008-07-18 08:46:19 -03002454 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2455 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2456 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2457 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2458 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002459 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002460 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2461 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002462 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002463 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2464 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002465 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002466 reg_w1(gspca_dev, 0xc6, 0x00);
2467 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002468 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002469 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2470 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002471 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002472 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2473 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002474 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002475 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002476 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002477 case SENSOR_GC0307:
2478 reg17 = 0xa2;
2479 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002480 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002481 case SENSOR_MI0360B:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002482 reg17 = 0xe0;
2483 break;
Jean-Francois Moine646775732009-12-20 12:31:28 -03002484 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002485 case SENSOR_OV7630:
2486 reg17 = 0xe2;
2487 break;
2488 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002489 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002490 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002491 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002492 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002493 reg17 = 0xa0;
2494 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002495 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002496 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002497 reg17 = 0xa0;
2498 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002499 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002500 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002501 break;
2502 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002503 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002504
2505 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2506 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2507 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002508 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002509
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002510 setgamma(gspca_dev);
2511
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002512/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002513 for (i = 0; i < 8; i++)
2514 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002515 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002516 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002517 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002518 case SENSOR_SP80708:
2519 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002520 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002521 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002522 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002523 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002524 reg_w1(gspca_dev, 0x9a, 0x07);
2525 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002526 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002527 case SENSOR_OV7648:
2528 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002529 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002530 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002531 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002532 reg_w1(gspca_dev, 0x9a, 0x06);
2533 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002534 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002535 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002536 break;
2537 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002538 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002539
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002540 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002541 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2542 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2543 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002544
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002545 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002546 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002547 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002548 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002549 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002550 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2551 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002552 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002553 case SENSOR_ADCM1700:
2554 init = adcm1700_sensor_param1;
2555 reg1 = 0x46;
2556 reg17 = 0xe2;
2557 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002558 case SENSOR_GC0307:
2559 init = gc0307_sensor_param1;
2560 reg17 = 0xa2;
2561 reg1 = 0x44;
2562 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002563 case SENSOR_MI0360B:
2564 init = mi0360b_sensor_param1;
2565 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2566 reg17 = 0xe2;
2567 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002568 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002569 if (mode) {
2570/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2571 reg1 = 0x06; /* clk 24Mz */
2572 } else {
2573 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002574/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002575 }
2576 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002577 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002578 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002579 if (mode) {
2580 reg1 = 0x04; /* 320 clk 48Mhz */
2581 } else {
2582/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002583 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002584 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002585 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002586 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002587 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002588 reg17 = 0x64; /* 640 MCKSIZE */
2589 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002590 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002591 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002592 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002593 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002594 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002595 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002596 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002597 reg17 = 0x21;
2598/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002599 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002600 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002601 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002602 if (sd->bridge == BRIDGE_SN9C120) {
2603 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002604 reg17 = 0xa2;
2605 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002606 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002607 } else {
2608 reg17 = 0x22;
2609 reg1 = 0x06; /* 24 Mhz, video trf eneble
2610 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002611 }
2612 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002613 case SENSOR_PO1030:
2614 init = po1030_sensor_param1;
2615 reg17 = 0xa2;
2616 reg1 = 0x44;
2617 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002618 case SENSOR_PO2030N:
2619 init = po2030n_sensor_param1;
2620 reg1 = 0x46;
2621 reg17 = 0xa2;
2622 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002623 case SENSOR_SOI768:
2624 init = soi768_sensor_param1;
2625 reg1 = 0x44;
2626 reg17 = 0xa2;
2627 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002628 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002629 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002630 if (mode) {
2631/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002632 } else {
2633 reg1 = 0x46; /* 640 clk 48Mz */
2634 reg17 = 0xa2;
2635 }
2636 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002637 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002638
2639 /* more sensor initialization - param1 */
2640 if (init != NULL) {
2641 i2c_w_seq(gspca_dev, init);
2642/* init = NULL; */
2643 }
2644
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002645 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002646 switch (sd->sensor) {
2647 case SENSOR_ADCM1700:
2648 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002649 case SENSOR_SOI768:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002650 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002651 break;
2652 case SENSOR_PO2030N:
2653 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2654 break;
2655 default:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002656 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002657 break;
2658 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002659 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002660 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002661 case SENSOR_OV7630:
2662 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002663 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002664 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002665 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002666 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002667 case SENSOR_GC0307:
2668 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2669 break;
2670 case SENSOR_PO2030N:
2671 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2672 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002673 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002674 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002675 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2676 break;
2677 }
2678
2679 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002680 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2681 reg_w1(gspca_dev, 0x18, sd->reg18);
2682 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002683
Jean-Francois Moine60017612008-07-18 08:46:19 -03002684 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002685 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002686
Németh Márton76ad3b62010-10-19 03:33:47 -03002687 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002688 setbrightness(gspca_dev);
2689 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002690 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002691 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002692 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002693 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002694}
2695
2696static void sd_stopN(struct gspca_dev *gspca_dev)
2697{
2698 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002699 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002700 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002701 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002702 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002703 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002704 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002705 static const u8 stopsoi768[] =
2706 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002707 u8 data;
2708 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002709
2710 data = 0x0b;
2711 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002712 case SENSOR_GC0307:
2713 data = 0x29;
2714 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002715 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002716 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002717 data = 0x2b;
2718 break;
2719 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002720 case SENSOR_MI0360B:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002721 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002722 data = 0x29;
2723 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002724 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002725 i2c_w8(gspca_dev, stopov7648);
2726 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002727 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002728 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002729 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002730 data = 0x29;
2731 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002732 case SENSOR_SOI768:
2733 i2c_w8(gspca_dev, stopsoi768);
2734 data = 0x29;
2735 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002736 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002737 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002738 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2739 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2740 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2741 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002742 /* Don't disable sensor clock as that disables the button on the cam */
2743 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002744}
2745
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002746static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002747{
2748 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002749 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002750 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002751 u8 luma_mean = 130;
2752 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002753
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002754 /* Thanks S., without your advice, autobright should not work :) */
2755 if (sd->ag_cnt < 0)
2756 return;
2757 if (--sd->ag_cnt >= 0)
2758 return;
2759 sd->ag_cnt = AG_CNT_START;
2760
2761 delta = atomic_read(&sd->avg_lum);
2762 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002763 if (delta < luma_mean - luma_delta ||
2764 delta > luma_mean + luma_delta) {
2765 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002766 case SENSOR_GC0307:
2767 expotimes = sd->exposure;
2768 expotimes += (luma_mean - delta) >> 6;
2769 if (expotimes < 0)
2770 expotimes = 0;
2771 sd->exposure = setexposure(gspca_dev,
2772 (unsigned int) expotimes);
2773 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002774 case SENSOR_HV7131R:
2775 expotimes = sd->exposure >> 8;
2776 expotimes += (luma_mean - delta) >> 4;
2777 if (expotimes < 0)
2778 expotimes = 0;
2779 sd->exposure = setexposure(gspca_dev,
2780 (unsigned int) (expotimes << 8));
2781 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002782 case SENSOR_OM6802:
2783 expotimes = sd->exposure;
2784 expotimes += (luma_mean - delta) >> 2;
2785 if (expotimes < 0)
2786 expotimes = 0;
2787 sd->exposure = setexposure(gspca_dev,
2788 (unsigned int) expotimes);
2789 setredblue(gspca_dev);
2790 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002791 default:
2792/* case SENSOR_MO4000: */
2793/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002794/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002795/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002796 expotimes = sd->exposure;
2797 expotimes += (luma_mean - delta) >> 6;
2798 if (expotimes < 0)
2799 expotimes = 0;
2800 sd->exposure = setexposure(gspca_dev,
2801 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002802 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002803 break;
2804 }
2805 }
2806}
2807
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002808/* scan the URB packets */
2809/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002810static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002811 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002812 int len) /* iso packet length */
2813{
2814 struct sd *sd = (struct sd *) gspca_dev;
2815 int sof, avg_lum;
2816
Jean-François Moinea95bd642010-10-01 07:54:30 -03002817 /* the image ends on a 64 bytes block starting with
2818 * ff d9 ff ff 00 c4 c4 96
2819 * and followed by various information including luminosity */
2820 /* this block may be splitted between two packets */
2821 /* a new image always starts in a new packet */
2822 switch (gspca_dev->last_packet_type) {
2823 case DISCARD_PACKET: /* restart image building */
2824 sof = len - 64;
2825 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2826 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2827 return;
2828 case LAST_PACKET: /* put the JPEG 422 header */
2829 gspca_frame_add(gspca_dev, FIRST_PACKET,
2830 sd->jpeg_hdr, JPEG_HDR_SZ);
2831 break;
2832 }
2833 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002834
Jean-François Moinea95bd642010-10-01 07:54:30 -03002835 data = gspca_dev->image;
2836 if (data == NULL)
2837 return;
2838 sof = gspca_dev->image_len - 64;
2839 if (data[sof] != 0xff
2840 || data[sof + 1] != 0xd9)
2841 return;
2842
2843 /* end of image found - remove the trailing data */
2844 gspca_dev->image_len = sof + 2;
2845 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2846 if (sd->ag_cnt < 0)
2847 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002848/* w1 w2 w3 */
2849/* w4 w5 w6 */
2850/* w7 w8 */
2851/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002852 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002853/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002854 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002855/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002856 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002857/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002858 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002859/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002860 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2861 avg_lum >>= 4;
2862 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002863}
2864
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002865static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2866 struct v4l2_jpegcompression *jcomp)
2867{
2868 struct sd *sd = (struct sd *) gspca_dev;
2869
2870 if (jcomp->quality < QUALITY_MIN)
2871 sd->quality = QUALITY_MIN;
2872 else if (jcomp->quality > QUALITY_MAX)
2873 sd->quality = QUALITY_MAX;
2874 else
2875 sd->quality = jcomp->quality;
2876 if (gspca_dev->streaming)
2877 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2878 return 0;
2879}
2880
2881static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2882 struct v4l2_jpegcompression *jcomp)
2883{
2884 struct sd *sd = (struct sd *) gspca_dev;
2885
2886 memset(jcomp, 0, sizeof *jcomp);
2887 jcomp->quality = sd->quality;
2888 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2889 | V4L2_JPEG_MARKER_DQT;
2890 return 0;
2891}
2892
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002893static int sd_querymenu(struct gspca_dev *gspca_dev,
2894 struct v4l2_querymenu *menu)
2895{
2896 switch (menu->id) {
2897 case V4L2_CID_POWER_LINE_FREQUENCY:
2898 switch (menu->index) {
2899 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2900 strcpy((char *) menu->name, "NoFliker");
2901 return 0;
2902 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2903 strcpy((char *) menu->name, "50 Hz");
2904 return 0;
2905 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2906 strcpy((char *) menu->name, "60 Hz");
2907 return 0;
2908 }
2909 break;
2910 }
2911 return -EINVAL;
2912}
2913
Jean-François Moine28566432010-10-01 07:33:26 -03002914#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002915static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2916 u8 *data, /* interrupt packet data */
2917 int len) /* interrupt packet length */
2918{
2919 int ret = -EINVAL;
2920
2921 if (len == 1 && data[0] == 1) {
2922 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2923 input_sync(gspca_dev->input_dev);
2924 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2925 input_sync(gspca_dev->input_dev);
2926 ret = 0;
2927 }
2928
2929 return ret;
2930}
2931#endif
2932
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002933/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002934static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002935 .name = MODULE_NAME,
2936 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002937 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002938 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002939 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002940 .start = sd_start,
2941 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002942 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002943 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002944 .get_jcomp = sd_get_jcomp,
2945 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002946 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002947#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002948 .int_pkt_scan = sd_int_pkt_scan,
2949#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002950};
2951
2952/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002953#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002954 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03002955 | (SENSOR_ ## sensor << 8)
2956#define BSF(bridge, sensor, flags) \
2957 .driver_info = (BRIDGE_ ## bridge << 16) \
2958 | (SENSOR_ ## sensor << 8) \
2959 | (flags)
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002960static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002961#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002962 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2963 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002964#endif
Jean-Francois Moineb2272a42010-12-14 16:16:16 -03002965 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)},
2966 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002967 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2968 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2969 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2970 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2971 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2972/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2973 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2974/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2975/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2976 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2977/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2978 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002979 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002980/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2981/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2982/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002983 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002984 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2985/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2986/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03002987/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002988 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002989#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002990 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2991 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03002992#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002993 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03002994 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002995/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2996 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2997 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2998 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2999 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3000/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3001/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3002/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3003 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003004/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003005 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003006 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003007 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3008 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3009/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003010 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003011 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003012/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3013 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3014 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003015#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003016 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03003017#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003018 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3019 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003020 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003021 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003022 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3023 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine646775732009-12-20 12:31:28 -03003024 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003025 {}
3026};
3027MODULE_DEVICE_TABLE(usb, device_table);
3028
3029/* -- device connect -- */
3030static int sd_probe(struct usb_interface *intf,
3031 const struct usb_device_id *id)
3032{
3033 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3034 THIS_MODULE);
3035}
3036
3037static struct usb_driver sd_driver = {
3038 .name = MODULE_NAME,
3039 .id_table = device_table,
3040 .probe = sd_probe,
3041 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003042#ifdef CONFIG_PM
3043 .suspend = gspca_suspend,
3044 .resume = gspca_resume,
3045#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003046};
3047
3048/* -- module insert / remove -- */
3049static int __init sd_mod_init(void)
3050{
Jean-François Moine54826432010-09-13 04:53:03 -03003051 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003052}
3053static void __exit sd_mod_exit(void)
3054{
3055 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003056}
3057
3058module_init(sd_mod_init);
3059module_exit(sd_mod_exit);