blob: 8ff4c89c3d82e766700a067badd6d43de6b90c47 [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 Moine4fd350e2010-12-14 16:16:58 -0300103/* sn9c1xx definitions */
104/* register 0x01 */
105#define S_PWR_DN 0x01 /* sensor power down */
106#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
107#define V_TX_EN 0x04 /* video transfer enable */
108#define LED 0x08 /* output to pin LED */
109#define SCL_SEL_OD 0x20 /* open-drain mode */
110#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
111/* register 0x17 */
112#define MCK_SIZE_MASK 0x1f /* sensor master clock */
113#define SEN_CLK_EN 0x20 /* enable sensor clock */
114#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
115
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300116/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300117static void setbrightness(struct gspca_dev *gspca_dev);
118static void setcontrast(struct gspca_dev *gspca_dev);
119static void setcolors(struct gspca_dev *gspca_dev);
120static void setredblue(struct gspca_dev *gspca_dev);
121static void setgamma(struct gspca_dev *gspca_dev);
122static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300123static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300124static void setsharpness(struct gspca_dev *gspca_dev);
125static void setinfrared(struct gspca_dev *gspca_dev);
126static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300127
Jean-François Moine72b667e2010-10-02 04:35:25 -0300128static const struct ctrl sd_ctrls[NCTRLS] = {
129[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300130 {
131 .id = V4L2_CID_BRIGHTNESS,
132 .type = V4L2_CTRL_TYPE_INTEGER,
133 .name = "Brightness",
134 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300135 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300136 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300137 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300138 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300139 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300141[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 {
143 .id = V4L2_CID_CONTRAST,
144 .type = V4L2_CTRL_TYPE_INTEGER,
145 .name = "Contrast",
146 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300147#define CONTRAST_MAX 127
148 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300149 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300150 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300151 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300152 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300154[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300155 {
156 .id = V4L2_CID_SATURATION,
157 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300158 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300159 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300160 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300161 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300162#define COLORS_DEF 25
163 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300164 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300165 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300166 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300167[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300168 {
169 .id = V4L2_CID_BLUE_BALANCE,
170 .type = V4L2_CTRL_TYPE_INTEGER,
171 .name = "Blue Balance",
172 .minimum = 24,
173 .maximum = 40,
174 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300175 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300176 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300177 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300178 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300179[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300180 {
181 .id = V4L2_CID_RED_BALANCE,
182 .type = V4L2_CTRL_TYPE_INTEGER,
183 .name = "Red Balance",
184 .minimum = 24,
185 .maximum = 40,
186 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300187 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300188 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300189 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300190 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300191[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300192 {
193 .id = V4L2_CID_GAMMA,
194 .type = V4L2_CTRL_TYPE_INTEGER,
195 .name = "Gamma",
196 .minimum = 0,
197 .maximum = 40,
198 .step = 1,
199#define GAMMA_DEF 20
200 .default_value = GAMMA_DEF,
201 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300202 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300203 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300204[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300205 {
206 .id = V4L2_CID_AUTOGAIN,
207 .type = V4L2_CTRL_TYPE_BOOLEAN,
208 .name = "Auto Gain",
209 .minimum = 0,
210 .maximum = 1,
211 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300212 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300213 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300214 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300215 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300216[HFLIP] = {
217 {
218 .id = V4L2_CID_HFLIP,
219 .type = V4L2_CTRL_TYPE_BOOLEAN,
220 .name = "Mirror",
221 .minimum = 0,
222 .maximum = 1,
223 .step = 1,
224 .default_value = 0,
225 },
226 .set_control = sethvflip
227 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300228[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300229 {
230 .id = V4L2_CID_VFLIP,
231 .type = V4L2_CTRL_TYPE_BOOLEAN,
232 .name = "Vflip",
233 .minimum = 0,
234 .maximum = 1,
235 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300236 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300237 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300238 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300239 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300240[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300241 {
242 .id = V4L2_CID_SHARPNESS,
243 .type = V4L2_CTRL_TYPE_INTEGER,
244 .name = "Sharpness",
245 .minimum = 0,
246 .maximum = 255,
247 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300248 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300249 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300250 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300251 },
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300252/* mt9v111 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300253[INFRARED] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300254 {
255 .id = V4L2_CID_INFRARED,
256 .type = V4L2_CTRL_TYPE_BOOLEAN,
257 .name = "Infrared",
258 .minimum = 0,
259 .maximum = 1,
260 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300261 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300262 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300263 .set_control = setinfrared
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300264 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300265/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300266[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300267 {
268 .id = V4L2_CID_POWER_LINE_FREQUENCY,
269 .type = V4L2_CTRL_TYPE_MENU,
270 .name = "Light frequency filter",
271 .minimum = 0,
272 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
273 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300274 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300275 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300276 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300277 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300278};
279
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300280/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300281static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300282[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
283 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300284 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300285 (1 << VFLIP) |
286 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300287
Jean-François Moine72b667e2010-10-02 04:35:25 -0300288[SENSOR_GC0307] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300289 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300290 (1 << VFLIP) |
291 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300292
Jean-François Moine72b667e2010-10-02 04:35:25 -0300293[SENSOR_HV7131R] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300294 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300295 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300296
Jean-François Moine72b667e2010-10-02 04:35:25 -0300297[SENSOR_MI0360] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300298 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300299 (1 << VFLIP) |
300 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300301
Jean-François Moine72b667e2010-10-02 04:35:25 -0300302[SENSOR_MI0360B] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300303 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300304 (1 << VFLIP) |
305 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300306
Jean-François Moine72b667e2010-10-02 04:35:25 -0300307[SENSOR_MO4000] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300308 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300309 (1 << VFLIP) |
310 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300311
Németh Márton76ad3b62010-10-19 03:33:47 -0300312[SENSOR_MT9V111] = (1 << HFLIP) |
313 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300314 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300315
Jean-François Moine72b667e2010-10-02 04:35:25 -0300316[SENSOR_OM6802] = (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300317 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300318 (1 << VFLIP) |
319 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300320
Németh Márton76ad3b62010-10-19 03:33:47 -0300321[SENSOR_OV7630] = (1 << INFRARED) |
322 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300323
Németh Márton76ad3b62010-10-19 03:33:47 -0300324[SENSOR_OV7648] = (1 << INFRARED) |
325 (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300326
Jean-François Moine72b667e2010-10-02 04:35:25 -0300327[SENSOR_OV7660] = (1 << AUTOGAIN) |
328 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300329 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300330 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300331
Jean-François Moine72b667e2010-10-02 04:35:25 -0300332[SENSOR_PO1030] = (1 << AUTOGAIN) |
333 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300334 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300335 (1 << VFLIP) |
336 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300337
Jean-François Moine72b667e2010-10-02 04:35:25 -0300338[SENSOR_PO2030N] = (1 << AUTOGAIN) |
339 (1 << INFRARED) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300340 (1 << FREQ),
Jean-François Moine780e3122010-10-19 04:29:10 -0300341
Jean-François Moine72b667e2010-10-02 04:35:25 -0300342[SENSOR_SOI768] = (1 << AUTOGAIN) |
343 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300344 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300345 (1 << VFLIP) |
346 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300347
Jean-François Moine72b667e2010-10-02 04:35:25 -0300348[SENSOR_SP80708] = (1 << AUTOGAIN) |
349 (1 << INFRARED) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300350 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300351 (1 << VFLIP) |
352 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300353};
354
Jean-Francois Moine64677572009-12-20 12:31:28 -0300355static const struct v4l2_pix_format cif_mode[] = {
356 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
357 .bytesperline = 352,
358 .sizeimage = 352 * 288 * 4 / 8 + 590,
359 .colorspace = V4L2_COLORSPACE_JPEG,
360 .priv = 0},
361};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300362static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300363 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
364 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300365 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300366 .colorspace = V4L2_COLORSPACE_JPEG,
367 .priv = 2},
368 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
369 .bytesperline = 320,
370 .sizeimage = 320 * 240 * 3 / 8 + 590,
371 .colorspace = V4L2_COLORSPACE_JPEG,
372 .priv = 1},
373 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
374 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300375 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
376 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300377 .colorspace = V4L2_COLORSPACE_JPEG,
378 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300379};
380
Jean-Francois Moine64677572009-12-20 12:31:28 -0300381static const u8 sn_adcm1700[0x1c] = {
382/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300383 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300384/* reg8 reg9 rega regb regc regd rege regf */
385 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
387 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
388/* reg18 reg19 reg1a reg1b */
389 0x06, 0x00, 0x00, 0x00
390};
391
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300392static const u8 sn_gc0307[0x1c] = {
393/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
394 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
395/* reg8 reg9 rega regb regc regd rege regf */
396 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
397/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
398 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
399/* reg18 reg19 reg1a reg1b */
400 0x06, 0x00, 0x00, 0x00
401};
402
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300403static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300404/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300405 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300406/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300407 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300408/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
409 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300410/* reg18 reg19 reg1a reg1b */
411 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300412};
413
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300414static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300415/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300416 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300417/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300418 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300419/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
420 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300421/* reg18 reg19 reg1a reg1b */
422 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300423};
424
Jean-François Moinea067db82010-10-01 07:51:24 -0300425static const u8 sn_mi0360b[0x1c] = {
426/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
427 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
428/* reg8 reg9 rega regb regc regd rege regf */
429 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
430/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
431 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
432/* reg18 reg19 reg1a reg1b */
433 0x06, 0x00, 0x00, 0x00
434};
435
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300436static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300437/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300438 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300439/* reg8 reg9 rega regb regc regd rege regf */
440 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
442 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300443/* reg18 reg19 reg1a reg1b */
444 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300445};
446
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300447static const u8 sn_mt9v111[0x1c] = {
448/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
449 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
450/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300451 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300452/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
453 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
454/* reg18 reg19 reg1a reg1b */
455 0x06, 0x00, 0x00, 0x00
456};
457
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300458static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300459/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300460 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300461/* reg8 reg9 rega regb regc regd rege regf */
462 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
463/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
464 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300465/* reg18 reg19 reg1a reg1b */
466 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300467};
468
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300469static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300470/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300471 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300472/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300473 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300474/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
475 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300476/* reg18 reg19 reg1a reg1b */
477 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300478};
479
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300480static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300481/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300482 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300483/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300484 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300485/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300486 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300487/* reg18 reg19 reg1a reg1b */
488 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300489};
490
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300491static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300492/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300493 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300494/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300495 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300496/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
497 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300498/* reg18 reg19 reg1a reg1b */
499 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300500};
501
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300502static const u8 sn_po1030[0x1c] = {
503/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
504 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
505/* reg8 reg9 rega regb regc regd rege regf */
506 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
507/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
508 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
509/* reg18 reg19 reg1a reg1b */
510 0x07, 0x00, 0x00, 0x00
511};
512
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300513static const u8 sn_po2030n[0x1c] = {
514/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
515 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
516/* reg8 reg9 rega regb regc regd rege regf */
517 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
519 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
520/* reg18 reg19 reg1a reg1b */
521 0x07, 0x00, 0x00, 0x00
522};
523
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300524static const u8 sn_soi768[0x1c] = {
525/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
526 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
527/* reg8 reg9 rega regb regc regd rege regf */
528 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
529/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
530 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
531/* reg18 reg19 reg1a reg1b */
532 0x07, 0x00, 0x00, 0x00
533};
534
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300535static const u8 sn_sp80708[0x1c] = {
536/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
537 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
538/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300539 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300540/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
541 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
542/* reg18 reg19 reg1a reg1b */
543 0x07, 0x00, 0x00, 0x00
544};
545
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300546/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300547static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300548[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300549[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300550[SENSOR_HV7131R] = sn_hv7131,
551[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300552[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300553[SENSOR_MO4000] = sn_mo4000,
554[SENSOR_MT9V111] = sn_mt9v111,
555[SENSOR_OM6802] = sn_om6802,
556[SENSOR_OV7630] = sn_ov7630,
557[SENSOR_OV7648] = sn_ov7648,
558[SENSOR_OV7660] = sn_ov7660,
559[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300560[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300561[SENSOR_SOI768] = sn_soi768,
562[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300563};
564
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300565/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300566static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300567 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
568 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
569};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300570/* gamma for sensor ADCM1700 */
571static const u8 gamma_spec_0[17] = {
572 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
573 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
574};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300575/* gamma for sensors HV7131R and MT9V111 */
576static const u8 gamma_spec_1[17] = {
577 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
578 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
579};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300580/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300581static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300582 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
583 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
584};
585/* gamma for sensor SP80708 */
586static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300587 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
588 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
589};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300590
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300591/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300592static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300593 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
594 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
595 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
596 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300597};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300598
599#define DELAY 0xdd
600
Jean-Francois Moine64677572009-12-20 12:31:28 -0300601static const u8 adcm1700_sensor_init[][8] = {
602 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300603 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300604 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300605 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300606 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300607 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
609 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
610 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
611 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300612 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300613 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300614 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300615 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
617 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
618 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
619 {}
620};
621static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300622 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300623 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
624
625 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
626 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
628 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300629 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300630
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300631 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
632 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
634 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300635 {}
636};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300637static const u8 gc0307_sensor_init[][8] = {
638 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300658 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300659 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
666 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
667 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
668 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
669 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
670 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
671 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
672 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
673 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
674 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
675 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
676 {}
677};
678static const u8 gc0307_sensor_param1[][8] = {
679 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
680 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
681 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
682 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
683/*param3*/
684 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
685 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300686 {}
687};
688
Jean-Francois Moine98819182009-01-19 07:37:33 -0300689static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300690 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
691 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
692 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
693/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
694 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
695 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
696/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300697
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300698 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
699 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
700 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
701 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
702 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
703 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
704 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
705 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300706
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300707 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
708 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300709 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300710 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
711 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300712
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300713 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
714 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
715 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
716 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
717 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300718 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
719 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300720 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300721};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300722static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300723 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300724 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300725 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300726 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
727 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
728 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
729 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
730 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
736 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
737 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
739 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
740 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
743 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300745 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300746 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
747 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
748 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
749 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
750 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
752 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
753 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
754 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
755 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300756
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300757 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
758 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
759 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
760 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
761 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300762
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300763 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
764 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
765 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
766 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300767
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300768 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
769 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
770/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
771/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
772 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
773 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300774 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300775};
Jean-François Moinea067db82010-10-01 07:51:24 -0300776static const u8 mi0360b_sensor_init[][8] = {
777 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
778 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300779 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300780 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300781 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300782 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
783 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
784 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
795 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
798 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
799 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
801 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
802 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
803 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
804 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
805 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
806 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
808 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
809 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
810 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
811 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
812
813 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
814 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
815 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
816 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
817 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
818 {}
819};
820static const u8 mi0360b_sensor_param1[][8] = {
821 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
822 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
823 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
824 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
825
826 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
827 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
828 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
829 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
830 {}
831};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300832static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300833 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300853 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300854};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300855static const u8 mt9v111_sensor_init[][8] = {
856 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300857 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300858 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
859 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
860 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
861 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300862 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
863 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
864 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
865 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300866 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300867 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
868 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
869 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
870 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
871 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300872 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300873 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300874 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
875 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
876 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
877 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
878 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
879 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
880 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
881 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
882 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
883 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300884 {}
885};
886static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300887 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
888 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300889 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300890 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
891 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
892 /*******/
893 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
894 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
895 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
896 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
897 {}
898};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300899static const u8 om6802_init0[2][8] = {
900/*fixme: variable*/
901 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
902 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
903};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300904static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300905 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
906 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300907 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300908 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300909 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300910/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
911 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300912 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300913/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
914 * set color mode */
915/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
916 * max AGC value in AE */
917/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
918 * preset AGC */
919/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
920 * preset brightness */
921/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
922 * preset contrast */
923/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
924 * preset gamma */
925 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300926 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300927 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
928 /* preset shutter */
929/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
930 * auto frame rate */
931/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300932 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
933 {}
934};
935static const u8 om6802_sensor_param1[][8] = {
936 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
937 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
938 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
939 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300940 {}
941};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300942static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300943 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
944 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300945 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300946 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
947 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300948 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300949 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300950/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300951 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
952 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300953/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
954 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
955 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300956 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
957 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
958 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
959 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
960 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
961 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
962 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
963 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
964 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
965 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
966 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
967 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
968 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
969 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
970 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
971 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
972 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
973 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
974 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
975 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
976 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
977 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
978 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300979 {}
980};
981static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300982 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
983 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
984/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300985/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
986 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300987 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
988 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
989 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300990/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300991/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
992/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300993/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300994 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300995/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300996 {}
997};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300998
Jean-Francois Moine98819182009-01-19 07:37:33 -0300999static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001000 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
1001 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001002 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001003 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1004 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
1005 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
1006 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
1007 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
1008 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
1009 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1010 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1011 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1012 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1013 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1014 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1015 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1016 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1017 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1018 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1019 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1020 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1021 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1022
1023 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1024/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1025/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001026/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001027 {}
1028};
1029static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001030/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001031/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1032 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001033 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1034 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1035/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1036/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1037/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1038/*...*/
1039 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1040/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1041/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1042/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1043/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1044/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1045
1046 {}
1047};
1048
Jean-Francois Moine98819182009-01-19 07:37:33 -03001049static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001050 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001051 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001052 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001053 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001054 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001055 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001056 /* GAIN BLUE RED VREF */
1057 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1058 /* COM 1 BAVE GEAVE AECHH */
1059 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1060 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001061 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001062 /* AECH CLKRC COM7 COM8 */
1063 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1064 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1065 /* HSTART HSTOP VSTRT VSTOP */
1066 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1067 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1068 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1069 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001070/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1071 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001072 /* AEW AEB VPT BBIAS */
1073 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1074 /* GbBIAS RSVD EXHCH EXHCL */
1075 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1076 /* RBIAS ADVFL ASDVFH YAVE */
1077 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1078 /* HSYST HSYEN HREF */
1079 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1080 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1081 /* ADC ACOM OFON TSLB */
1082 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1083 /* COM11 COM12 COM13 COM14 */
1084 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1085 /* EDGE COM15 COM16 COM17 */
1086 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1087 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1088 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1089 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1090 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1091 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1092 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1093 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1094 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1095 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1096 /* LCC1 LCC2 LCC3 LCC4 */
1097 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001098 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001099 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001100 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001101 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1102 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1103 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1104 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1105 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1106 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1107 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1108 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1109 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001110 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001111/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001112 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001113 {}
1114};
1115static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001116 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001117 /* bits[3..0]reserved */
1118 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1119 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1120 /* VREF vertical frame ctrl */
1121 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001122 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1123 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1124 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1125 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1126/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001127/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001128/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001129 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001130 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1131 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1132 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1133/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001134/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001135/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001136/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001137 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1138 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1139 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001141 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001142};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001143
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001144static const u8 po1030_sensor_init[][8] = {
1145/* the sensor registers are described in m5602/m5602_po1030.h */
1146 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001147 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001148 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1149 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1150 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1151 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1152 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1153 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1154 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1155 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1156 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1157 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1158 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1159 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1160 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1161 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1162 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1163 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1164 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1165 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1166 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1167 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1169 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1170 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1171 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1172 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1173 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1174
1175 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1176 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1177 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1178 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1179 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1180 {}
1181};
1182static const u8 po1030_sensor_param1[][8] = {
1183/* from ms-win traces - these values change with auto gain/expo/wb.. */
1184 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1185 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1186/* mean values */
1187 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1188 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1189 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1190
1191 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1192 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1193 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1194/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1195 {}
1196};
1197
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001198static const u8 po2030n_sensor_init[][8] = {
1199 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001201 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001202 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1203 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001204 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001205 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1206 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1207 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1208 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1211 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1212 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1213 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1216 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1225 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1226 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1230 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1231 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1234 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1235 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1236 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1237 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1239 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1240 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1241 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1242 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1243 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1244 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1245 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1246 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1247 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1248 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1249 {}
1250};
1251static const u8 po2030n_sensor_param1[][8] = {
1252 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001253 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001254 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1255 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1256 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1257/*param2*/
1258 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1259 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1260 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1263 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1264 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1265/*after start*/
1266 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001267 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001268 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001269 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001270 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1271 {}
1272};
1273
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001274static const u8 soi768_sensor_init[][8] = {
1275 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001276 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001277 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1279 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1280 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1281 {}
1282};
1283static const u8 soi768_sensor_param1[][8] = {
1284 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1285 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1286 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1287 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1288 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1289/* */
1290/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1291/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1292 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1293/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1294 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1295/* the next sequence should be used for auto gain */
1296 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1297 /* global gain ? : 07 - change with 0x15 at the end */
1298 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1299 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1300 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1301 /* exposure ? : 0200 - change with 0x1e at the end */
1302 {}
1303};
1304
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001305static const u8 sp80708_sensor_init[][8] = {
1306 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1368 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1369 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1370 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1371 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1374 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1375 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1376 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001377 {}
1378};
1379static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001380 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1381 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1382 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1383 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1384 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1385 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1386 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1387 {}
1388};
1389
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001390static const u8 (*sensor_init[])[8] = {
1391[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001392[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001393[SENSOR_HV7131R] = hv7131r_sensor_init,
1394[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001395[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001396[SENSOR_MO4000] = mo4000_sensor_init,
1397[SENSOR_MT9V111] = mt9v111_sensor_init,
1398[SENSOR_OM6802] = om6802_sensor_init,
1399[SENSOR_OV7630] = ov7630_sensor_init,
1400[SENSOR_OV7648] = ov7648_sensor_init,
1401[SENSOR_OV7660] = ov7660_sensor_init,
1402[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001403[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001404[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001405[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001406};
1407
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001408/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001409static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001410 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001411{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001412 int ret;
1413
1414 if (gspca_dev->usb_err < 0)
1415 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001416#ifdef GSPCA_DEBUG
1417 if (len > USB_BUF_SZ) {
1418 err("reg_r: buffer overflow");
1419 return;
1420 }
1421#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001422 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001423 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001424 0,
1425 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1426 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001427 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001428 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001429 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001430 if (ret < 0) {
1431 err("reg_r err %d", ret);
1432 gspca_dev->usb_err = ret;
1433 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001434}
1435
Jean-Francois Moine60017612008-07-18 08:46:19 -03001436static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001437 u16 value,
1438 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001439{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001440 int ret;
1441
1442 if (gspca_dev->usb_err < 0)
1443 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001444 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001445 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001446 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001447 usb_sndctrlpipe(gspca_dev->dev, 0),
1448 0x08,
1449 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1450 value,
1451 0,
1452 gspca_dev->usb_buf, 1,
1453 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001454 if (ret < 0) {
1455 err("reg_w1 err %d", ret);
1456 gspca_dev->usb_err = ret;
1457 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001458}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001459static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001460 u16 value,
1461 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001462 int len)
1463{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001464 int ret;
1465
1466 if (gspca_dev->usb_err < 0)
1467 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001468 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001469 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001470#ifdef GSPCA_DEBUG
1471 if (len > USB_BUF_SZ) {
1472 err("reg_w: buffer overflow");
1473 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001474 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001475#endif
1476 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001477 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001478 usb_sndctrlpipe(gspca_dev->dev, 0),
1479 0x08,
1480 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1481 value, 0,
1482 gspca_dev->usb_buf, len,
1483 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001484 if (ret < 0) {
1485 err("reg_w err %d", ret);
1486 gspca_dev->usb_err = ret;
1487 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001488}
1489
Jean-Francois Moine60017612008-07-18 08:46:19 -03001490/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001491static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001492{
1493 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001494 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001495
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001496 if (gspca_dev->usb_err < 0)
1497 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001498 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001499 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001500 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001501 case SENSOR_OM6802:
1502 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001503 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1504 break;
1505 default: /* i2c command = a1 (400 kHz) */
1506 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1507 break;
1508 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001509 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001510 gspca_dev->usb_buf[2] = reg;
1511 gspca_dev->usb_buf[3] = val;
1512 gspca_dev->usb_buf[4] = 0;
1513 gspca_dev->usb_buf[5] = 0;
1514 gspca_dev->usb_buf[6] = 0;
1515 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001516 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001517 usb_sndctrlpipe(gspca_dev->dev, 0),
1518 0x08,
1519 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1520 0x08, /* value = i2c */
1521 0,
1522 gspca_dev->usb_buf, 8,
1523 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001524 if (ret < 0) {
1525 err("i2c_w1 err %d", ret);
1526 gspca_dev->usb_err = ret;
1527 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001528}
1529
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001530/* I2C write 8 bytes */
1531static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001532 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001533{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001534 int ret;
1535
1536 if (gspca_dev->usb_err < 0)
1537 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001538 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1539 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001540 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001541 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001542 usb_sndctrlpipe(gspca_dev->dev, 0),
1543 0x08,
1544 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1545 0x08, 0, /* value, index */
1546 gspca_dev->usb_buf, 8,
1547 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001548 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001549 if (ret < 0) {
1550 err("i2c_w8 err %d", ret);
1551 gspca_dev->usb_err = ret;
1552 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001553}
1554
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001555/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1556static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001557{
1558 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001559 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001560
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001561 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001562 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001563 case SENSOR_OM6802:
1564 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001565 mode[0] = 0x80 | 0x10;
1566 break;
1567 default: /* i2c command = 91 (400 kHz) */
1568 mode[0] = 0x81 | 0x10;
1569 break;
1570 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001571 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001572 mode[2] = reg;
1573 mode[3] = 0;
1574 mode[4] = 0;
1575 mode[5] = 0;
1576 mode[6] = 0;
1577 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001578 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001579 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001580 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001581 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001582 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001583 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001584 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001585}
1586
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001587static void i2c_w_seq(struct gspca_dev *gspca_dev,
1588 const u8 (*data)[8])
1589{
1590 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001591 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001592 i2c_w8(gspca_dev, *data);
1593 else
1594 msleep((*data)[1]);
1595 data++;
1596 }
1597}
1598
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001599static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001600{
Jean-Francois Moine60017612008-07-18 08:46:19 -03001601 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001602 msleep(10);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001603 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001604 msleep(10);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001605 i2c_r(gspca_dev, 0, 5); /* read sensor id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001606 if (gspca_dev->usb_buf[0] == 0x02
1607 && gspca_dev->usb_buf[1] == 0x09
1608 && gspca_dev->usb_buf[2] == 0x01
1609 && gspca_dev->usb_buf[3] == 0x00
1610 && gspca_dev->usb_buf[4] == 0x00) {
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001611 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1612 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001613 }
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001614 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001615 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1616 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001617}
1618
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001619static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001620{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001621 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001622 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001623 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001624 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001625 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001626 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1627 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1628 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1629 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1630 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001631 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001632 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1633 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1634 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1635 {}
1636 },
1637 };
1638
1639 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1640 reg_w1(gspca_dev, 0x17, 0x62);
1641 reg_w1(gspca_dev, 0x01, 0x08);
1642 for (j = 0; j < 3; j++)
1643 i2c_w8(gspca_dev, probe_tb[i][j]);
1644 msleep(2);
1645 reg_r(gspca_dev, 0x0a, 5);
1646 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1647 if (probe_tb[i][3][0] != 0)
1648 i2c_w8(gspca_dev, probe_tb[i][3]);
1649 reg_w1(gspca_dev, 0x01, 0x29);
1650 reg_w1(gspca_dev, 0x17, 0x42);
1651 if (val != 0xffff)
1652 break;
1653 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001654 if (gspca_dev->usb_err < 0)
1655 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001656 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001657 case 0x8221:
1658 PDEBUG(D_PROBE, "Sensor mi0360b");
1659 sd->sensor = SENSOR_MI0360B;
1660 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001661 case 0x823a:
1662 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001663 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001664 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001665 case 0x8243:
1666 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001667 break;
1668 default:
1669 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1670 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001671 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001672}
1673
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001674static void ov7630_probe(struct gspca_dev *gspca_dev)
1675{
1676 struct sd *sd = (struct sd *) gspca_dev;
1677 u16 val;
1678
1679 /* check ov76xx */
1680 reg_w1(gspca_dev, 0x17, 0x62);
1681 reg_w1(gspca_dev, 0x01, 0x08);
1682 sd->i2c_addr = 0x21;
1683 i2c_r(gspca_dev, 0x0a, 2);
1684 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1685 reg_w1(gspca_dev, 0x01, 0x29);
1686 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001687 if (gspca_dev->usb_err < 0)
1688 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001689 if (val == 0x7628) { /* soi768 */
1690 sd->sensor = SENSOR_SOI768;
1691/*fixme: only valid for 0c45:613e?*/
1692 gspca_dev->cam.input_flags =
1693 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1694 PDEBUG(D_PROBE, "Sensor soi768");
1695 return;
1696 }
1697 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1698}
1699
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001700static void ov7648_probe(struct gspca_dev *gspca_dev)
1701{
1702 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001703 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001704
1705 /* check ov76xx */
1706 reg_w1(gspca_dev, 0x17, 0x62);
1707 reg_w1(gspca_dev, 0x01, 0x08);
1708 sd->i2c_addr = 0x21;
1709 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001710 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001711 reg_w1(gspca_dev, 0x01, 0x29);
1712 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001713 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1714 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1715 return;
1716 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001717
1718 /* check po1030 */
1719 reg_w1(gspca_dev, 0x17, 0x62);
1720 reg_w1(gspca_dev, 0x01, 0x08);
1721 sd->i2c_addr = 0x6e;
1722 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001723 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1724 reg_w1(gspca_dev, 0x01, 0x29);
1725 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001726 if (gspca_dev->usb_err < 0)
1727 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001728 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001729 PDEBUG(D_PROBE, "Sensor po1030");
1730 sd->sensor = SENSOR_PO1030;
1731 return;
1732 }
Jean-François Moine0b656322010-09-13 05:19:58 -03001733 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001734}
1735
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001736/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1737static void po2030n_probe(struct gspca_dev *gspca_dev)
1738{
1739 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001740 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001741
1742 /* check gc0307 */
1743 reg_w1(gspca_dev, 0x17, 0x62);
1744 reg_w1(gspca_dev, 0x01, 0x08);
1745 reg_w1(gspca_dev, 0x02, 0x22);
1746 sd->i2c_addr = 0x21;
1747 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001748 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001749 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1750 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001751 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001752 PDEBUG(D_PROBE, "Sensor gc0307");
1753 sd->sensor = SENSOR_GC0307;
1754 return;
1755 }
1756
1757 /* check po2030n */
1758 reg_w1(gspca_dev, 0x17, 0x62);
1759 reg_w1(gspca_dev, 0x01, 0x0a);
1760 sd->i2c_addr = 0x6e;
1761 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001762 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001763 reg_w1(gspca_dev, 0x01, 0x29);
1764 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001765 if (gspca_dev->usb_err < 0)
1766 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001767 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001768 PDEBUG(D_PROBE, "Sensor po2030n");
1769/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001770 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001771 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001772 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001773}
1774
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001775/* this function is called at probe time */
1776static int sd_config(struct gspca_dev *gspca_dev,
1777 const struct usb_device_id *id)
1778{
1779 struct sd *sd = (struct sd *) gspca_dev;
1780 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001781
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001782 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001783 sd->sensor = id->driver_info >> 8;
1784 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001785
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001786 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001787 if (sd->sensor == SENSOR_ADCM1700) {
1788 cam->cam_mode = cif_mode;
1789 cam->nmodes = ARRAY_SIZE(cif_mode);
1790 } else {
1791 cam->cam_mode = vga_mode;
1792 cam->nmodes = ARRAY_SIZE(vga_mode);
1793 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001794 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001795 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001796
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001797 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001798 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001799 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001800
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001801 return 0;
1802}
1803
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001804/* this function is called at probe and resume time */
1805static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001806{
1807 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001808 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001809 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001810 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001811
Hans de Goede3647fea2008-07-15 05:36:30 -03001812 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001813 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001814 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001815 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001816 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001817 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001818 if (gspca_dev->usb_err < 0)
1819 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001820 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001821 switch (sd->bridge) {
1822 case BRIDGE_SN9C102P:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001823 if (regF1 != 0x11)
1824 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001825 reg_w1(gspca_dev, 0x02, regGpio[1]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001826 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001827 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001828 if (regF1 != 0x11)
1829 return -ENODEV;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001830 if (sd->sensor == SENSOR_MI0360)
1831 mi0360_probe(gspca_dev);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001832 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001833 break;
Hans de Goede3647fea2008-07-15 05:36:30 -03001834 case BRIDGE_SN9C120:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001835 if (regF1 != 0x12)
1836 return -ENODEV;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001837 switch (sd->sensor) {
1838 case SENSOR_MI0360:
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001839 mi0360_probe(gspca_dev);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001840 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001841 case SENSOR_OV7630:
1842 ov7630_probe(gspca_dev);
1843 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001844 case SENSOR_OV7648:
1845 ov7648_probe(gspca_dev);
1846 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001847 case SENSOR_PO2030N:
1848 po2030n_probe(gspca_dev);
1849 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001850 }
Jean-François Moine19697b52010-07-14 06:33:51 -03001851 regGpio[1] = 0x70; /* no audio */
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03001852 reg_w(gspca_dev, 0x01, regGpio, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001853 break;
1854 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001855/* case BRIDGE_SN9C110: */
Hans de Goede3647fea2008-07-15 05:36:30 -03001856/* case BRIDGE_SN9C325: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001857 if (regF1 != 0x12)
1858 return -ENODEV;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001859 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001860 break;
1861 }
1862
Jean-François Moine72b667e2010-10-02 04:35:25 -03001863 if (sd->sensor == SENSOR_OM6802)
1864 sd->ctrls[SHARPNESS].def = 0x10;
1865
Hans de Goede9712a8b2010-01-31 12:54:29 -03001866 /* Note we do not disable the sensor clock here (power saving mode),
1867 as that also disables the button on the cam. */
1868 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001869
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001870 /* set the i2c address */
1871 sn9c1xx = sn_tb[sd->sensor];
1872 sd->i2c_addr = sn9c1xx[9];
1873
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001874 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1875
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001876 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001877}
1878
Jean-Francois Moine98819182009-01-19 07:37:33 -03001879static u32 setexposure(struct gspca_dev *gspca_dev,
1880 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001881{
1882 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001883
1884 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001885 case SENSOR_GC0307: {
1886 int a, b;
1887
1888 /* expo = 0..255 -> a = 19..43 */
1889 a = 19 + expo * 25 / 256;
1890 i2c_w1(gspca_dev, 0x68, a);
1891 a -= 12;
1892 b = a * a * 4; /* heuristic */
1893 i2c_w1(gspca_dev, 0x03, b >> 8);
1894 i2c_w1(gspca_dev, 0x04, b);
1895 break;
1896 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001897 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001898 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001899 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001900
1901 Expodoit[3] = expo >> 16;
1902 Expodoit[4] = expo >> 8;
1903 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001904 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001905 break;
1906 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001907 case SENSOR_MI0360:
1908 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001909 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001910 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001911 static const u8 doit[] = /* update sensor */
1912 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1913 static const u8 sensorgo[] = /* sensor on */
1914 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001915
1916 if (expo > 0x0635)
1917 expo = 0x0635;
1918 else if (expo < 0x0001)
1919 expo = 0x0001;
1920 expoMi[3] = expo >> 8;
1921 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001922 i2c_w8(gspca_dev, expoMi);
1923 i2c_w8(gspca_dev, doit);
1924 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001925 break;
1926 }
1927 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001928 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001929 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001930 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001931 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001932 static const u8 gainMo[] =
1933 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001934
1935 if (expo > 0x1fff)
1936 expo = 0x1fff;
1937 else if (expo < 0x0001)
1938 expo = 0x0001;
1939 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001940 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001941 expoMo10[3] = ((expo & 0x1c00) >> 10)
1942 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001943 i2c_w8(gspca_dev, expoMo10);
1944 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001945 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001946 ((expoMo10[3] & 0x07) << 10)
1947 | (expoMof[3] << 2)
1948 | ((expoMo10[3] & 0x30) >> 4));
1949 break;
1950 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001951 case SENSOR_MT9V111: {
1952 u8 expo_c1[] =
1953 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1954
1955 if (expo > 0x0280)
1956 expo = 0x0280;
1957 else if (expo < 0x0040)
1958 expo = 0x0040;
1959 expo_c1[3] = expo >> 8;
1960 expo_c1[4] = expo;
1961 i2c_w8(gspca_dev, expo_c1);
1962 break;
1963 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001964 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001965 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001966 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001967 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001968
1969 if (expo > 0x03ff)
1970 expo = 0x03ff;
1971 if (expo < 0x0001)
1972 expo = 0x0001;
1973 gainOm[3] = expo >> 2;
1974 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001975 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001976 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001977 break;
1978 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001979 }
1980 return expo;
1981}
1982
1983static void setbrightness(struct gspca_dev *gspca_dev)
1984{
1985 struct sd *sd = (struct sd *) gspca_dev;
1986 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001987 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001988 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001989
Jean-François Moine72b667e2010-10-02 04:35:25 -03001990 brightness = sd->ctrls[BRIGHTNESS].val;
1991 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001992 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001993 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001994 if (k2 > 0x1f)
1995 k2 = 0; /* only positive Y offset */
1996 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001997 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001998 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001999 if (expo > 0x002dc6c0)
2000 expo = 0x002dc6c0;
2001 else if (expo < 0x02a0)
2002 expo = 0x02a0;
2003 sd->exposure = setexposure(gspca_dev, expo);
2004 break;
2005 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002006 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002007 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002008 sd->exposure = setexposure(gspca_dev, expo);
2009 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002010 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002011 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002012 sd->exposure = setexposure(gspca_dev, expo);
2013 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002014 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002015 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002016 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002017 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002018 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002019 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002020 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002021 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002022 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002023 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002024 }
2025
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002026 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002027}
2028
2029static void setcontrast(struct gspca_dev *gspca_dev)
2030{
2031 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002032 u8 k2;
2033 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002034
Jean-François Moine72b667e2010-10-02 04:35:25 -03002035 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2036 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002037 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002038 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002039 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002040 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002041 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002042 contrast[5] = 0;
2043 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002044}
2045
2046static void setcolors(struct gspca_dev *gspca_dev)
2047{
2048 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002049 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002050 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002051 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002052 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002053 -24, -38, 64, /* UR UG UB */
2054 62, -51, -9 /* VR VG VB */
2055 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002056 static const s16 uv_mi0360b[6] = {
2057 -20, -38, 64, /* UR UG UB */
2058 60, -51, -9 /* VR VG VB */
2059 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002060
Jean-François Moine72b667e2010-10-02 04:35:25 -03002061 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002062 if (sd->sensor == SENSOR_MI0360B)
2063 uv = uv_mi0360b;
2064 else
2065 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002066 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002067 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002068 reg8a[i * 2] = v;
2069 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002070 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002071 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002072}
2073
2074static void setredblue(struct gspca_dev *gspca_dev)
2075{
2076 struct sd *sd = (struct sd *) gspca_dev;
2077
Jean-François Moine72b667e2010-10-02 04:35:25 -03002078 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002079/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002080 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002081}
2082
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002083static void setgamma(struct gspca_dev *gspca_dev)
2084{
2085 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002086 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002087 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002088 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002089 static const u8 delta[17] = {
2090 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2091 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2092 };
2093
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002094 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002095 case SENSOR_ADCM1700:
2096 gamma_base = gamma_spec_0;
2097 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002098 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002099 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002100 case SENSOR_MT9V111:
2101 gamma_base = gamma_spec_1;
2102 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002103 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002104 gamma_base = gamma_spec_2;
2105 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002106 case SENSOR_SP80708:
2107 gamma_base = gamma_spec_3;
2108 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002109 default:
2110 gamma_base = gamma_def;
2111 break;
2112 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002113
Jean-François Moine72b667e2010-10-02 04:35:25 -03002114 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002115 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002116 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002117 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002118 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2119}
2120
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002121static void setautogain(struct gspca_dev *gspca_dev)
2122{
2123 struct sd *sd = (struct sd *) gspca_dev;
2124
Jean-François Moine72b667e2010-10-02 04:35:25 -03002125 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002126 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002127 switch (sd->sensor) {
2128 case SENSOR_OV7630:
2129 case SENSOR_OV7648: {
2130 u8 comb;
2131
2132 if (sd->sensor == SENSOR_OV7630)
2133 comb = 0xc0;
2134 else
2135 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002136 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec7472009-06-18 06:05:07 -03002137 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002138 i2c_w1(&sd->gspca_dev, 0x13, comb);
2139 return;
2140 }
2141 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002142 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002143 sd->ag_cnt = AG_CNT_START;
2144 else
2145 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002146}
2147
Németh Márton76ad3b62010-10-19 03:33:47 -03002148static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002149{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002150 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002151 u8 comn;
2152
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002153 switch (sd->sensor) {
2154 case SENSOR_HV7131R:
2155 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002156 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002157 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002158 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002159 break;
2160 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002161 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002162 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002163 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002164 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002165 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002166 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002167 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002168 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002169 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002170 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002171 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002172 case SENSOR_PO2030N:
2173 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2174 * (reset value: 0x0A)
2175 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2176 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2177 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2178 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2179 * bit3-0: X
2180 */
2181 comn = 0x0a;
2182 if (sd->ctrls[HFLIP].val)
2183 comn |= 0x80;
2184 if (sd->ctrls[VFLIP].val)
2185 comn |= 0x40;
2186 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2187 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002188 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002189}
2190
Jean-François Moine72b667e2010-10-02 04:35:25 -03002191static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002192{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002193 struct sd *sd = (struct sd *) gspca_dev;
2194
2195 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002196}
2197
Jean-François Moine72b667e2010-10-02 04:35:25 -03002198static void setinfrared(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002199{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002200 struct sd *sd = (struct sd *) gspca_dev;
2201
2202 if (gspca_dev->ctrl_dis & (1 << INFRARED))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002203 return;
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002204/*fixme: different sequence for StarCam Clip and StarCam 370i */
2205/* Clip */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002206 i2c_w1(gspca_dev, 0x02, /* gpio */
2207 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002208}
2209
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002210static void setfreq(struct gspca_dev *gspca_dev)
2211{
2212 struct sd *sd = (struct sd *) gspca_dev;
2213
Jean-François Moine72b667e2010-10-02 04:35:25 -03002214 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002215 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002216 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002217 u8 com8;
2218
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002219 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002220 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002221 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002222 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002223 break;
2224 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002225 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002226 i2c_w1(gspca_dev, 0x3b, 0x0a);
2227 break;
2228 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002229 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002230 i2c_w1(gspca_dev, 0x3b, 0x02);
2231 break;
2232 }
2233 } else {
2234 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2235
2236 /* Get reg2a / reg2d base values */
2237 switch (sd->sensor) {
2238 case SENSOR_OV7630:
2239 reg2a = 0x08;
2240 reg2d = 0x01;
2241 break;
2242 case SENSOR_OV7648:
2243 reg2a = 0x11;
2244 reg2d = 0x81;
2245 break;
2246 }
2247
Jean-François Moine72b667e2010-10-02 04:35:25 -03002248 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002249 case 0: /* Banding filter disabled */
2250 break;
2251 case 1: /* 50 hz (filter on and framerate adj) */
2252 reg2a |= 0x80;
2253 reg2b = 0xac;
2254 reg2d |= 0x04;
2255 break;
2256 case 2: /* 60 hz (filter on, no framerate adj) */
2257 reg2a |= 0x80;
2258 reg2d |= 0x04;
2259 break;
2260 }
2261 i2c_w1(gspca_dev, 0x2a, reg2a);
2262 i2c_w1(gspca_dev, 0x2b, reg2b);
2263 i2c_w1(gspca_dev, 0x2d, reg2d);
2264 }
2265}
2266
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002267static void setjpegqual(struct gspca_dev *gspca_dev)
2268{
2269 struct sd *sd = (struct sd *) gspca_dev;
2270 int i, sc;
2271
2272 if (sd->jpegqual < 50)
2273 sc = 5000 / sd->jpegqual;
2274 else
2275 sc = 200 - sd->jpegqual * 2;
2276#if USB_BUF_SZ < 64
2277#error "No room enough in usb_buf for quantization table"
2278#endif
2279 for (i = 0; i < 64; i++)
2280 gspca_dev->usb_buf[i] =
2281 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2282 usb_control_msg(gspca_dev->dev,
2283 usb_sndctrlpipe(gspca_dev->dev, 0),
2284 0x08,
2285 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2286 0x0100, 0,
2287 gspca_dev->usb_buf, 64,
2288 500);
2289 for (i = 0; i < 64; i++)
2290 gspca_dev->usb_buf[i] =
2291 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2292 usb_control_msg(gspca_dev->dev,
2293 usb_sndctrlpipe(gspca_dev->dev, 0),
2294 0x08,
2295 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2296 0x0140, 0,
2297 gspca_dev->usb_buf, 64,
2298 500);
2299
2300 sd->reg18 ^= 0x40;
2301 reg_w1(gspca_dev, 0x18, sd->reg18);
2302}
2303
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002304/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002305static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002306{
2307 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002308 int i;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002309 u8 reg0102[2];
Jean-François Moine19697b52010-07-14 06:33:51 -03002310 u8 reg1, reg17;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002311 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002312 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002313 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002314 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002315 static const u8 reg9a_def[] =
2316 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2317 static const u8 reg9a_spec[] =
2318 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2319 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002320 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2321 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002322 static const u8 CA_adcm1700[] =
2323 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002324 static const u8 CA_po2030n[] =
2325 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002326 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002327 static const u8 CE_gc0307[] =
2328 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002329 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002330 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002331 static const u8 CE_po2030n[] =
2332 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002333
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002334 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002335 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2336 0x21); /* JPEG 422 */
2337 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2338
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002339 /* initialize the bridge */
2340 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002341
2342 /* sensor clock already enabled in sd_init */
2343 /* reg_w1(gspca_dev, 0xf1, 0x00); */
2344 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2345
2346 /* configure gpio */
2347 reg0102[0] = sn9c1xx[1];
2348 reg0102[1] = sn9c1xx[2];
2349 if (gspca_dev->audio)
2350 reg0102[1] |= 0x04; /* keep the audio connection */
2351 reg_w(gspca_dev, 0x01, reg0102, 2);
2352 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2353 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2354 switch (sd->sensor) {
2355 case SENSOR_GC0307:
2356 case SENSOR_OV7660:
2357 case SENSOR_PO1030:
2358 case SENSOR_PO2030N:
2359 case SENSOR_SOI768:
2360 case SENSOR_SP80708:
2361 reg9a = reg9a_spec;
2362 break;
2363 default:
2364 reg9a = reg9a_def;
2365 break;
2366 }
2367 reg_w(gspca_dev, 0x9a, reg9a, 6);
2368
2369 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2370
2371 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2372
2373 switch (sd->sensor) {
2374 case SENSOR_ADCM1700:
2375 reg_w1(gspca_dev, 0x01, 0x43);
2376 reg_w1(gspca_dev, 0x17, 0x62);
2377 reg_w1(gspca_dev, 0x01, 0x42);
2378 reg_w1(gspca_dev, 0x01, 0x42);
2379 break;
2380 case SENSOR_GC0307:
2381 msleep(50);
2382 reg_w1(gspca_dev, 0x01, 0x61);
2383 reg_w1(gspca_dev, 0x17, 0x22);
2384 reg_w1(gspca_dev, 0x01, 0x60);
2385 reg_w1(gspca_dev, 0x01, 0x40);
2386 msleep(50);
2387 break;
2388 case SENSOR_MI0360B:
2389 reg_w1(gspca_dev, 0x01, 0x61);
2390 reg_w1(gspca_dev, 0x17, 0x60);
2391 reg_w1(gspca_dev, 0x01, 0x60);
2392 reg_w1(gspca_dev, 0x01, 0x40);
2393 break;
2394 case SENSOR_MT9V111:
2395 reg_w1(gspca_dev, 0x01, 0x61);
2396 reg_w1(gspca_dev, 0x17, 0x61);
2397 reg_w1(gspca_dev, 0x01, 0x60);
2398 reg_w1(gspca_dev, 0x01, 0x40);
2399 break;
2400 case SENSOR_OM6802:
2401 msleep(10);
2402 reg_w1(gspca_dev, 0x02, 0x73);
2403 reg_w1(gspca_dev, 0x17, 0x60);
2404 reg_w1(gspca_dev, 0x01, 0x22);
2405 msleep(100);
2406 reg_w1(gspca_dev, 0x01, 0x62);
2407 reg_w1(gspca_dev, 0x17, 0x64);
2408 reg_w1(gspca_dev, 0x17, 0x64);
2409 reg_w1(gspca_dev, 0x01, 0x42);
2410 msleep(10);
2411 reg_w1(gspca_dev, 0x01, 0x42);
2412 i2c_w8(gspca_dev, om6802_init0[0]);
2413 i2c_w8(gspca_dev, om6802_init0[1]);
2414 msleep(15);
2415 reg_w1(gspca_dev, 0x02, 0x71);
2416 msleep(150);
2417 break;
2418 case SENSOR_OV7630:
2419 reg_w1(gspca_dev, 0x01, 0x61);
2420 reg_w1(gspca_dev, 0x17, 0xe2);
2421 reg_w1(gspca_dev, 0x01, 0x60);
2422 reg_w1(gspca_dev, 0x01, 0x40);
2423 break;
2424 case SENSOR_OV7648:
2425 reg_w1(gspca_dev, 0x01, 0x63);
2426 reg_w1(gspca_dev, 0x17, 0x20);
2427 reg_w1(gspca_dev, 0x01, 0x62);
2428 reg_w1(gspca_dev, 0x01, 0x42);
2429 break;
2430 case SENSOR_PO1030:
2431 case SENSOR_SOI768:
2432 reg_w1(gspca_dev, 0x01, 0x61);
2433 reg_w1(gspca_dev, 0x17, 0x20);
2434 reg_w1(gspca_dev, 0x01, 0x60);
2435 reg_w1(gspca_dev, 0x01, 0x40);
2436 break;
2437 case SENSOR_PO2030N:
2438 case SENSOR_OV7660:
2439 reg_w1(gspca_dev, 0x01, 0x63);
2440 reg_w1(gspca_dev, 0x17, 0x20);
2441 reg_w1(gspca_dev, 0x01, 0x62);
2442 reg_w1(gspca_dev, 0x01, 0x42);
2443 break;
2444 case SENSOR_SP80708:
2445 reg_w1(gspca_dev, 0x01, 0x63);
2446 reg_w1(gspca_dev, 0x17, 0x20);
2447 reg_w1(gspca_dev, 0x01, 0x62);
2448 reg_w1(gspca_dev, 0x01, 0x42);
2449 msleep(100);
2450 reg_w1(gspca_dev, 0x02, 0x62);
2451 break;
2452 default:
2453/* case SENSOR_HV7131R: */
2454/* case SENSOR_MI0360: */
2455/* case SENSOR_MO4000: */
2456 reg_w1(gspca_dev, 0x01, 0x43);
2457 reg_w1(gspca_dev, 0x17, 0x61);
2458 reg_w1(gspca_dev, 0x01, 0x42);
2459 if (sd->sensor == SENSOR_HV7131R)
2460 hv7131r_probe(gspca_dev);
2461 break;
2462 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002463
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002464 /* initialize the sensor */
2465 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2466
Jean-Francois Moine60017612008-07-18 08:46:19 -03002467 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2468 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2469 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2470 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2471 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002472 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002473 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2474 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002475 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002476 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2477 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002478 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002479 reg_w1(gspca_dev, 0xc6, 0x00);
2480 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002481 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002482 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2483 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002484 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002485 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2486 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002487 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002488 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002489 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002490 case SENSOR_GC0307:
2491 reg17 = 0xa2;
2492 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002493 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002494 case SENSOR_MI0360B:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002495 reg17 = 0xe0;
2496 break;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002497 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002498 case SENSOR_OV7630:
2499 reg17 = 0xe2;
2500 break;
2501 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002502 reg17 = 0x20;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002503 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002504 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002505 case SENSOR_SOI768:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002506 reg17 = 0xa0;
2507 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002508 case SENSOR_PO1030:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002509 case SENSOR_PO2030N:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002510 reg17 = 0xa0;
2511 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002512 default:
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002513 reg17 = 0x60;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002514 break;
2515 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002516 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002517
2518 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2519 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2520 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002521 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002522
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002523 setgamma(gspca_dev);
2524
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002525/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002526 for (i = 0; i < 8; i++)
2527 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002528 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002529 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002530 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002531 case SENSOR_SP80708:
2532 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002533 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002534 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002535 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002536 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002537 reg_w1(gspca_dev, 0x9a, 0x07);
2538 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002539 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002540 case SENSOR_OV7648:
2541 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002542 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002543 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002544 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002545 reg_w1(gspca_dev, 0x9a, 0x06);
2546 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002547 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002548 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002549 break;
2550 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002551 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002552
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002553 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002554 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2555 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2556 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002557
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002558 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002559 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine60017612008-07-18 08:46:19 -03002560 if (mode)
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002561 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002562 else
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002563 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2564 reg17 = 0x61; /* 0x:20: enable sensor clock */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002565 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002566 case SENSOR_ADCM1700:
2567 init = adcm1700_sensor_param1;
2568 reg1 = 0x46;
2569 reg17 = 0xe2;
2570 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002571 case SENSOR_GC0307:
2572 init = gc0307_sensor_param1;
2573 reg17 = 0xa2;
2574 reg1 = 0x44;
2575 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002576 case SENSOR_MI0360B:
2577 init = mi0360b_sensor_param1;
2578 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2579 reg17 = 0xe2;
2580 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002581 case SENSOR_MO4000:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002582 if (mode) {
2583/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2584 reg1 = 0x06; /* clk 24Mz */
2585 } else {
2586 reg17 = 0x22; /* 640 MCKSIZE */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002587/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002588 }
2589 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002590 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002591 init = mt9v111_sensor_param1;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002592 if (mode) {
2593 reg1 = 0x04; /* 320 clk 48Mhz */
2594 } else {
2595/* reg1 = 0x06; * 640 clk 24Mz (done) */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -03002596 reg17 = 0xc2;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002597 }
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002598 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002599 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002600 init = om6802_sensor_param1;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002601 reg17 = 0x64; /* 640 MCKSIZE */
2602 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002603 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002604 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002605 reg17 = 0xe2;
Jean-Francois Moine5b064da2008-09-03 16:48:08 -03002606 reg1 = 0x44;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002607 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002608 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002609 init = ov7648_sensor_param1;
Jean-Francois Moine62703302008-11-11 08:42:56 -03002610 reg17 = 0x21;
2611/* reg1 = 0x42; * 42 - 46? */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002612 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002613 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002614 init = ov7660_sensor_param1;
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002615 if (sd->bridge == BRIDGE_SN9C120) {
2616 if (mode) { /* 320x240 - 160x120 */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002617 reg17 = 0xa2;
2618 reg1 = 0x44; /* 48 Mhz, video trf eneble */
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002619 }
Jean-Francois Moinedaa5cb42008-12-02 15:00:57 -03002620 } else {
2621 reg17 = 0x22;
2622 reg1 = 0x06; /* 24 Mhz, video trf eneble
2623 * inverse power down */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002624 }
2625 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002626 case SENSOR_PO1030:
2627 init = po1030_sensor_param1;
2628 reg17 = 0xa2;
2629 reg1 = 0x44;
2630 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002631 case SENSOR_PO2030N:
2632 init = po2030n_sensor_param1;
2633 reg1 = 0x46;
2634 reg17 = 0xa2;
2635 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002636 case SENSOR_SOI768:
2637 init = soi768_sensor_param1;
2638 reg1 = 0x44;
2639 reg17 = 0xa2;
2640 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002641 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002642 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002643 if (mode) {
2644/*?? reg1 = 0x04; * 320 clk 48Mhz */
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002645 } else {
2646 reg1 = 0x46; /* 640 clk 48Mz */
2647 reg17 = 0xa2;
2648 }
2649 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002650 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002651
2652 /* more sensor initialization - param1 */
2653 if (init != NULL) {
2654 i2c_w_seq(gspca_dev, init);
2655/* init = NULL; */
2656 }
2657
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002658 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002659 switch (sd->sensor) {
2660 case SENSOR_ADCM1700:
2661 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002662 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002663 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002664 break;
2665 case SENSOR_PO2030N:
2666 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2667 break;
2668 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002669 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002670 break;
2671 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002672 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002673 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002674 case SENSOR_OV7630:
2675 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002676 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002677 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002678 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002679 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002680 case SENSOR_GC0307:
2681 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2682 break;
2683 case SENSOR_PO2030N:
2684 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2685 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002686 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002687 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002688 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2689 break;
2690 }
2691
2692 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002693 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2694 reg_w1(gspca_dev, 0x18, sd->reg18);
2695 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002696
Jean-Francois Moine60017612008-07-18 08:46:19 -03002697 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine1432f302008-11-21 04:34:15 -03002698 reg_w1(gspca_dev, 0x01, reg1);
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002699
Németh Márton76ad3b62010-10-19 03:33:47 -03002700 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002701 setbrightness(gspca_dev);
2702 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002703 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002704 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002705 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002706 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002707}
2708
2709static void sd_stopN(struct gspca_dev *gspca_dev)
2710{
2711 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002712 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002713 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002714 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002715 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002716 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002717 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002718 static const u8 stopsoi768[] =
2719 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002720 u8 data;
2721 const u8 *sn9c1xx;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002722
2723 data = 0x0b;
2724 switch (sd->sensor) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002725 case SENSOR_GC0307:
2726 data = 0x29;
2727 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002728 case SENSOR_HV7131R:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002729 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002730 data = 0x2b;
2731 break;
2732 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002733 case SENSOR_MI0360B:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002734 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002735 data = 0x29;
2736 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002737 case SENSOR_OV7648:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002738 i2c_w8(gspca_dev, stopov7648);
2739 /* fall thru */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002740 case SENSOR_MT9V111:
Jean-Francois Moine62703302008-11-11 08:42:56 -03002741 case SENSOR_OV7630:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002742 case SENSOR_PO1030:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002743 data = 0x29;
2744 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002745 case SENSOR_SOI768:
2746 i2c_w8(gspca_dev, stopsoi768);
2747 data = 0x29;
2748 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002749 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002750 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine60017612008-07-18 08:46:19 -03002751 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2752 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2753 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2754 reg_w1(gspca_dev, 0x01, data);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002755 /* Don't disable sensor clock as that disables the button on the cam */
2756 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002757}
2758
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002759static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002760{
2761 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002762 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002763 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002764 u8 luma_mean = 130;
2765 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002766
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002767 /* Thanks S., without your advice, autobright should not work :) */
2768 if (sd->ag_cnt < 0)
2769 return;
2770 if (--sd->ag_cnt >= 0)
2771 return;
2772 sd->ag_cnt = AG_CNT_START;
2773
2774 delta = atomic_read(&sd->avg_lum);
2775 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002776 if (delta < luma_mean - luma_delta ||
2777 delta > luma_mean + luma_delta) {
2778 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002779 case SENSOR_GC0307:
2780 expotimes = sd->exposure;
2781 expotimes += (luma_mean - delta) >> 6;
2782 if (expotimes < 0)
2783 expotimes = 0;
2784 sd->exposure = setexposure(gspca_dev,
2785 (unsigned int) expotimes);
2786 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002787 case SENSOR_HV7131R:
2788 expotimes = sd->exposure >> 8;
2789 expotimes += (luma_mean - delta) >> 4;
2790 if (expotimes < 0)
2791 expotimes = 0;
2792 sd->exposure = setexposure(gspca_dev,
2793 (unsigned int) (expotimes << 8));
2794 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002795 case SENSOR_OM6802:
2796 expotimes = sd->exposure;
2797 expotimes += (luma_mean - delta) >> 2;
2798 if (expotimes < 0)
2799 expotimes = 0;
2800 sd->exposure = setexposure(gspca_dev,
2801 (unsigned int) expotimes);
2802 setredblue(gspca_dev);
2803 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002804 default:
2805/* case SENSOR_MO4000: */
2806/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002807/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002808/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002809 expotimes = sd->exposure;
2810 expotimes += (luma_mean - delta) >> 6;
2811 if (expotimes < 0)
2812 expotimes = 0;
2813 sd->exposure = setexposure(gspca_dev,
2814 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002815 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002816 break;
2817 }
2818 }
2819}
2820
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002821/* scan the URB packets */
2822/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002823static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002824 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002825 int len) /* iso packet length */
2826{
2827 struct sd *sd = (struct sd *) gspca_dev;
2828 int sof, avg_lum;
2829
Jean-François Moinea95bd642010-10-01 07:54:30 -03002830 /* the image ends on a 64 bytes block starting with
2831 * ff d9 ff ff 00 c4 c4 96
2832 * and followed by various information including luminosity */
2833 /* this block may be splitted between two packets */
2834 /* a new image always starts in a new packet */
2835 switch (gspca_dev->last_packet_type) {
2836 case DISCARD_PACKET: /* restart image building */
2837 sof = len - 64;
2838 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2839 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2840 return;
2841 case LAST_PACKET: /* put the JPEG 422 header */
2842 gspca_frame_add(gspca_dev, FIRST_PACKET,
2843 sd->jpeg_hdr, JPEG_HDR_SZ);
2844 break;
2845 }
2846 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002847
Jean-François Moinea95bd642010-10-01 07:54:30 -03002848 data = gspca_dev->image;
2849 if (data == NULL)
2850 return;
2851 sof = gspca_dev->image_len - 64;
2852 if (data[sof] != 0xff
2853 || data[sof + 1] != 0xd9)
2854 return;
2855
2856 /* end of image found - remove the trailing data */
2857 gspca_dev->image_len = sof + 2;
2858 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2859 if (sd->ag_cnt < 0)
2860 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002861/* w1 w2 w3 */
2862/* w4 w5 w6 */
2863/* w7 w8 */
2864/* w4 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002865 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002866/* w6 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002867 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002868/* w2 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002869 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002870/* w8 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002871 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002872/* w5 */
Jean-François Moinea95bd642010-10-01 07:54:30 -03002873 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2874 avg_lum >>= 4;
2875 atomic_set(&sd->avg_lum, avg_lum);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002876}
2877
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002878static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2879 struct v4l2_jpegcompression *jcomp)
2880{
2881 struct sd *sd = (struct sd *) gspca_dev;
2882
2883 if (jcomp->quality < QUALITY_MIN)
2884 sd->quality = QUALITY_MIN;
2885 else if (jcomp->quality > QUALITY_MAX)
2886 sd->quality = QUALITY_MAX;
2887 else
2888 sd->quality = jcomp->quality;
2889 if (gspca_dev->streaming)
2890 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2891 return 0;
2892}
2893
2894static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2895 struct v4l2_jpegcompression *jcomp)
2896{
2897 struct sd *sd = (struct sd *) gspca_dev;
2898
2899 memset(jcomp, 0, sizeof *jcomp);
2900 jcomp->quality = sd->quality;
2901 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2902 | V4L2_JPEG_MARKER_DQT;
2903 return 0;
2904}
2905
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002906static int sd_querymenu(struct gspca_dev *gspca_dev,
2907 struct v4l2_querymenu *menu)
2908{
2909 switch (menu->id) {
2910 case V4L2_CID_POWER_LINE_FREQUENCY:
2911 switch (menu->index) {
2912 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2913 strcpy((char *) menu->name, "NoFliker");
2914 return 0;
2915 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2916 strcpy((char *) menu->name, "50 Hz");
2917 return 0;
2918 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2919 strcpy((char *) menu->name, "60 Hz");
2920 return 0;
2921 }
2922 break;
2923 }
2924 return -EINVAL;
2925}
2926
Jean-François Moine28566432010-10-01 07:33:26 -03002927#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002928static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2929 u8 *data, /* interrupt packet data */
2930 int len) /* interrupt packet length */
2931{
2932 int ret = -EINVAL;
2933
2934 if (len == 1 && data[0] == 1) {
2935 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2936 input_sync(gspca_dev->input_dev);
2937 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2938 input_sync(gspca_dev->input_dev);
2939 ret = 0;
2940 }
2941
2942 return ret;
2943}
2944#endif
2945
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002946/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002947static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002948 .name = MODULE_NAME,
2949 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002950 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002951 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002952 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002953 .start = sd_start,
2954 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002955 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002956 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002957 .get_jcomp = sd_get_jcomp,
2958 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002959 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002960#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002961 .int_pkt_scan = sd_int_pkt_scan,
2962#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002963};
2964
2965/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002966#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002967 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03002968 | (SENSOR_ ## sensor << 8)
2969#define BSF(bridge, sensor, flags) \
2970 .driver_info = (BRIDGE_ ## bridge << 16) \
2971 | (SENSOR_ ## sensor << 8) \
2972 | (flags)
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002973static const __devinitdata struct usb_device_id device_table[] = {
Hans de Goede222a07f2008-09-03 17:12:20 -03002974#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002975 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2976 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-Francois Moinea08d81a2008-11-22 04:53:31 -03002977#endif
Jean-Francois Moineb2272a42010-12-14 16:16:16 -03002978 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)},
2979 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002980 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2981 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2982 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2983 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2984 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2985/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2986 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2987/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2988/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2989 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2990/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2991 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002992 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002993/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2994/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2995/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002996 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002997 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2998/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2999/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03003000/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003001 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003002#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003003 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3004 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moine3c41cb72008-09-10 02:57:09 -03003005#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003006 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03003007 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003008/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3009 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3010 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3011 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3012 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3013/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3014/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3015/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3016 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003017/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003018 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003019 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003020 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3021 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3022/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003023 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003024 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003025/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3026 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3027 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Hans de Goede222a07f2008-09-03 17:12:20 -03003028#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003029 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moine8d977702009-02-19 15:34:48 -03003030#endif
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003031 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3032 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003033 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003034 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003035 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3036 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-Francois Moine64677572009-12-20 12:31:28 -03003037 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003038 {}
3039};
3040MODULE_DEVICE_TABLE(usb, device_table);
3041
3042/* -- device connect -- */
3043static int sd_probe(struct usb_interface *intf,
3044 const struct usb_device_id *id)
3045{
3046 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3047 THIS_MODULE);
3048}
3049
3050static struct usb_driver sd_driver = {
3051 .name = MODULE_NAME,
3052 .id_table = device_table,
3053 .probe = sd_probe,
3054 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003055#ifdef CONFIG_PM
3056 .suspend = gspca_suspend,
3057 .resume = gspca_resume,
3058#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003059};
3060
3061/* -- module insert / remove -- */
3062static int __init sd_mod_init(void)
3063{
Jean-François Moine54826432010-09-13 04:53:03 -03003064 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003065}
3066static void __exit sd_mod_exit(void)
3067{
3068 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003069}
3070
3071module_init(sd_mod_init);
3072module_exit(sd_mod_exit);