blob: 21f0330885dd843067c280d750c15f9f3e329e2c [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-François Moine27c6f9e2010-04-02 06:59:13 -030028MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030029MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
30MODULE_LICENSE("GPL");
31
Jean-François Moine3afef852011-01-13 06:39:11 -030032static int starcam;
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,
Jean-François Moine3afef852011-01-13 06:39:11 -030046 ILLUM,
Jean-François Moine72b667e2010-10-02 04:35:25 -030047 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-François Moinea4a30762011-02-10 07:15:24 -030060 s8 short_mark;
61
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030062 u8 quality; /* image quality */
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -030063#define QUALITY_MIN 60
64#define QUALITY_MAX 95
65#define QUALITY_DEF 80
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030066 u8 jpegqual; /* webcam quality */
67
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -030068 u8 reg01;
69 u8 reg17;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030070 u8 reg18;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -030071 u8 flags;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030072
Jean-Francois Moine98819182009-01-19 07:37:33 -030073 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030074#define AG_CNT_START 13
75
Jean-Francois Moine98819182009-01-19 07:37:33 -030076 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030077#define BRIDGE_SN9C102P 0
78#define BRIDGE_SN9C105 1
79#define BRIDGE_SN9C110 2
80#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030081 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030082 u8 i2c_addr;
83
84 u8 jpeg_hdr[JPEG_HDR_SZ];
85};
86enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030087 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030088 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030089 SENSOR_HV7131R,
90 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030091 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030092 SENSOR_MO4000,
93 SENSOR_MT9V111,
94 SENSOR_OM6802,
95 SENSOR_OV7630,
96 SENSOR_OV7648,
97 SENSOR_OV7660,
98 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030099 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300100 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300101 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300102};
103
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300104/* device flags */
Jean-François Moine3afef852011-01-13 06:39:11 -0300105#define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */
106#define F_ILLUM 0x02 /* presence of illuminator */
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300107
Jean-Francois Moine4fd350e2010-12-14 16:16:58 -0300108/* sn9c1xx definitions */
109/* register 0x01 */
110#define S_PWR_DN 0x01 /* sensor power down */
111#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
112#define V_TX_EN 0x04 /* video transfer enable */
113#define LED 0x08 /* output to pin LED */
114#define SCL_SEL_OD 0x20 /* open-drain mode */
115#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
116/* register 0x17 */
117#define MCK_SIZE_MASK 0x1f /* sensor master clock */
118#define SEN_CLK_EN 0x20 /* enable sensor clock */
119#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
120
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300121/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300122static void setbrightness(struct gspca_dev *gspca_dev);
123static void setcontrast(struct gspca_dev *gspca_dev);
124static void setcolors(struct gspca_dev *gspca_dev);
125static void setredblue(struct gspca_dev *gspca_dev);
126static void setgamma(struct gspca_dev *gspca_dev);
127static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300128static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300129static void setsharpness(struct gspca_dev *gspca_dev);
Jean-François Moine3afef852011-01-13 06:39:11 -0300130static void setillum(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300131static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300132
Jean-François Moine72b667e2010-10-02 04:35:25 -0300133static const struct ctrl sd_ctrls[NCTRLS] = {
134[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300135 {
136 .id = V4L2_CID_BRIGHTNESS,
137 .type = V4L2_CTRL_TYPE_INTEGER,
138 .name = "Brightness",
139 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300140 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300141 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300142 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300143 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300144 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300145 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300146[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300147 {
148 .id = V4L2_CID_CONTRAST,
149 .type = V4L2_CTRL_TYPE_INTEGER,
150 .name = "Contrast",
151 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300152#define CONTRAST_MAX 127
153 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300154 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300155 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300156 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300157 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300158 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300159[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300160 {
161 .id = V4L2_CID_SATURATION,
162 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300163 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300164 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300165 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300166 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300167#define COLORS_DEF 25
168 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300169 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300170 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300171 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300172[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300173 {
174 .id = V4L2_CID_BLUE_BALANCE,
175 .type = V4L2_CTRL_TYPE_INTEGER,
176 .name = "Blue Balance",
177 .minimum = 24,
178 .maximum = 40,
179 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300180 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300181 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300182 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300183 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300184[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300185 {
186 .id = V4L2_CID_RED_BALANCE,
187 .type = V4L2_CTRL_TYPE_INTEGER,
188 .name = "Red Balance",
189 .minimum = 24,
190 .maximum = 40,
191 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300192 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300193 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300194 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300195 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300196[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300197 {
198 .id = V4L2_CID_GAMMA,
199 .type = V4L2_CTRL_TYPE_INTEGER,
200 .name = "Gamma",
201 .minimum = 0,
202 .maximum = 40,
203 .step = 1,
204#define GAMMA_DEF 20
205 .default_value = GAMMA_DEF,
206 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300207 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300208 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300209[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300210 {
211 .id = V4L2_CID_AUTOGAIN,
212 .type = V4L2_CTRL_TYPE_BOOLEAN,
213 .name = "Auto Gain",
214 .minimum = 0,
215 .maximum = 1,
216 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300217 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300218 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300219 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300220 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300221[HFLIP] = {
222 {
223 .id = V4L2_CID_HFLIP,
224 .type = V4L2_CTRL_TYPE_BOOLEAN,
225 .name = "Mirror",
226 .minimum = 0,
227 .maximum = 1,
228 .step = 1,
229 .default_value = 0,
230 },
231 .set_control = sethvflip
232 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300233[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300234 {
235 .id = V4L2_CID_VFLIP,
236 .type = V4L2_CTRL_TYPE_BOOLEAN,
237 .name = "Vflip",
238 .minimum = 0,
239 .maximum = 1,
240 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300241 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300242 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300243 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300244 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300245[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300246 {
247 .id = V4L2_CID_SHARPNESS,
248 .type = V4L2_CTRL_TYPE_INTEGER,
249 .name = "Sharpness",
250 .minimum = 0,
251 .maximum = 255,
252 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300253 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300254 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300255 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300256 },
Jean-François Moine3afef852011-01-13 06:39:11 -0300257[ILLUM] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300258 {
Jean-François Moine3afef852011-01-13 06:39:11 -0300259 .id = V4L2_CID_ILLUMINATORS_1,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300260 .type = V4L2_CTRL_TYPE_BOOLEAN,
Jean-François Moine3afef852011-01-13 06:39:11 -0300261 .name = "Illuminator / infrared",
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300262 .minimum = 0,
263 .maximum = 1,
264 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300265 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300266 },
Jean-François Moine3afef852011-01-13 06:39:11 -0300267 .set_control = setillum
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300268 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300269/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300270[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300271 {
272 .id = V4L2_CID_POWER_LINE_FREQUENCY,
273 .type = V4L2_CTRL_TYPE_MENU,
274 .name = "Light frequency filter",
275 .minimum = 0,
276 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
277 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300278 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300279 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300280 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300281 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300282};
283
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300284/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300285static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300286[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300287 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300288 (1 << VFLIP) |
289 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300290
Jean-François Moine3afef852011-01-13 06:39:11 -0300291[SENSOR_GC0307] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300292 (1 << VFLIP) |
293 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300294
Jean-François Moine3afef852011-01-13 06:39:11 -0300295[SENSOR_HV7131R] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300296 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300297
Jean-François Moine3afef852011-01-13 06:39:11 -0300298[SENSOR_MI0360] = (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 Moine3afef852011-01-13 06:39:11 -0300302[SENSOR_MI0360B] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300303 (1 << VFLIP) |
304 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300305
Jean-François Moine3afef852011-01-13 06:39:11 -0300306[SENSOR_MO4000] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300307 (1 << VFLIP) |
308 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300309
Németh Márton76ad3b62010-10-19 03:33:47 -0300310[SENSOR_MT9V111] = (1 << HFLIP) |
311 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300312 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300313
Jean-François Moine3afef852011-01-13 06:39:11 -0300314[SENSOR_OM6802] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300315 (1 << VFLIP) |
316 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300317
Jean-François Moine3afef852011-01-13 06:39:11 -0300318[SENSOR_OV7630] = (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300319
Jean-François Moine3afef852011-01-13 06:39:11 -0300320[SENSOR_OV7648] = (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300321
Jean-François Moine72b667e2010-10-02 04:35:25 -0300322[SENSOR_OV7660] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300323 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300324 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300325
Jean-François Moine72b667e2010-10-02 04:35:25 -0300326[SENSOR_PO1030] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300327 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300328 (1 << VFLIP) |
329 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300330
Jean-François Moine72b667e2010-10-02 04:35:25 -0300331[SENSOR_PO2030N] = (1 << AUTOGAIN) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300332 (1 << FREQ),
Jean-François Moine780e3122010-10-19 04:29:10 -0300333
Jean-François Moine72b667e2010-10-02 04:35:25 -0300334[SENSOR_SOI768] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300335 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300336 (1 << VFLIP) |
337 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300338
Jean-François Moine72b667e2010-10-02 04:35:25 -0300339[SENSOR_SP80708] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300340 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300341 (1 << VFLIP) |
342 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300343};
344
Jean-Francois Moine64677572009-12-20 12:31:28 -0300345static const struct v4l2_pix_format cif_mode[] = {
346 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
347 .bytesperline = 352,
348 .sizeimage = 352 * 288 * 4 / 8 + 590,
349 .colorspace = V4L2_COLORSPACE_JPEG,
350 .priv = 0},
351};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300352static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300353 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
354 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300355 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300356 .colorspace = V4L2_COLORSPACE_JPEG,
357 .priv = 2},
358 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
359 .bytesperline = 320,
360 .sizeimage = 320 * 240 * 3 / 8 + 590,
361 .colorspace = V4L2_COLORSPACE_JPEG,
362 .priv = 1},
363 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
364 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300365 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
366 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300367 .colorspace = V4L2_COLORSPACE_JPEG,
368 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300369};
370
Jean-Francois Moine64677572009-12-20 12:31:28 -0300371static const u8 sn_adcm1700[0x1c] = {
372/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300373 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine64677572009-12-20 12:31:28 -0300374/* reg8 reg9 rega regb regc regd rege regf */
375 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
377 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
378/* reg18 reg19 reg1a reg1b */
379 0x06, 0x00, 0x00, 0x00
380};
381
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300382static const u8 sn_gc0307[0x1c] = {
383/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
384 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
385/* reg8 reg9 rega regb regc regd rege regf */
386 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
388 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
389/* reg18 reg19 reg1a reg1b */
390 0x06, 0x00, 0x00, 0x00
391};
392
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300393static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300394/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300395 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300396/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300397 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300398/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
399 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300400/* reg18 reg19 reg1a reg1b */
401 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300402};
403
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300404static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300405/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300406 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300407/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300408 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300409/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
410 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300411/* reg18 reg19 reg1a reg1b */
412 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300413};
414
Jean-François Moinea067db82010-10-01 07:51:24 -0300415static const u8 sn_mi0360b[0x1c] = {
416/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
417 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
418/* reg8 reg9 rega regb regc regd rege regf */
419 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
421 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
422/* reg18 reg19 reg1a reg1b */
423 0x06, 0x00, 0x00, 0x00
424};
425
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300426static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300427/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300428 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300429/* reg8 reg9 rega regb regc regd rege regf */
430 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
431/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
432 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300433/* reg18 reg19 reg1a reg1b */
434 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300435};
436
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300437static const u8 sn_mt9v111[0x1c] = {
438/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
439 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
440/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300441 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300442/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
443 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
444/* reg18 reg19 reg1a reg1b */
445 0x06, 0x00, 0x00, 0x00
446};
447
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300448static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300449/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300450 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300451/* reg8 reg9 rega regb regc regd rege regf */
452 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
454 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300455/* reg18 reg19 reg1a reg1b */
456 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300457};
458
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300459static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300460/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300461 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300462/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300463 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300464/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
465 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300466/* reg18 reg19 reg1a reg1b */
467 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300468};
469
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300470static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300471/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300472 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300473/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300474 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300475/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300476 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300477/* reg18 reg19 reg1a reg1b */
478 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300479};
480
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300481static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300482/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300483 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300484/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300485 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300486/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
487 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300488/* reg18 reg19 reg1a reg1b */
489 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300490};
491
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300492static const u8 sn_po1030[0x1c] = {
493/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
494 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
495/* reg8 reg9 rega regb regc regd rege regf */
496 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
498 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
499/* reg18 reg19 reg1a reg1b */
500 0x07, 0x00, 0x00, 0x00
501};
502
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300503static const u8 sn_po2030n[0x1c] = {
504/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
505 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
506/* reg8 reg9 rega regb regc regd rege regf */
507 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
509 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
510/* reg18 reg19 reg1a reg1b */
511 0x07, 0x00, 0x00, 0x00
512};
513
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300514static const u8 sn_soi768[0x1c] = {
515/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
516 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
517/* reg8 reg9 rega regb regc regd rege regf */
518 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
520 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
521/* reg18 reg19 reg1a reg1b */
522 0x07, 0x00, 0x00, 0x00
523};
524
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300525static const u8 sn_sp80708[0x1c] = {
526/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
527 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
528/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300529 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300530/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
531 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
532/* reg18 reg19 reg1a reg1b */
533 0x07, 0x00, 0x00, 0x00
534};
535
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300536/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300537static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300538[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300539[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300540[SENSOR_HV7131R] = sn_hv7131,
541[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300542[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300543[SENSOR_MO4000] = sn_mo4000,
544[SENSOR_MT9V111] = sn_mt9v111,
545[SENSOR_OM6802] = sn_om6802,
546[SENSOR_OV7630] = sn_ov7630,
547[SENSOR_OV7648] = sn_ov7648,
548[SENSOR_OV7660] = sn_ov7660,
549[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300550[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300551[SENSOR_SOI768] = sn_soi768,
552[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300553};
554
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300555/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300556static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300557 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
558 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
559};
Jean-Francois Moine64677572009-12-20 12:31:28 -0300560/* gamma for sensor ADCM1700 */
561static const u8 gamma_spec_0[17] = {
562 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
563 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
564};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300565/* gamma for sensors HV7131R and MT9V111 */
566static const u8 gamma_spec_1[17] = {
567 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
568 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
569};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300570/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300571static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300572 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
573 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
574};
575/* gamma for sensor SP80708 */
576static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300577 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
578 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
579};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300580
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300581/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300582static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300583 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
584 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
585 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
586 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300587};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300588
589#define DELAY 0xdd
590
Jean-Francois Moine64677572009-12-20 12:31:28 -0300591static const u8 adcm1700_sensor_init[][8] = {
592 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300593 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300594 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300595 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300596 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300597 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
598 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
599 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
600 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
601 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300602 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300603 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300604 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300605 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
606 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
607 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
609 {}
610};
611static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300612 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300613 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
614
615 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
616 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
617 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
618 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300619 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine64677572009-12-20 12:31:28 -0300620
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300621 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
622 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
624 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine64677572009-12-20 12:31:28 -0300625 {}
626};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300627static const u8 gc0307_sensor_init[][8] = {
628 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300648 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300649 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
666 {}
667};
668static const u8 gc0307_sensor_param1[][8] = {
669 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
670 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
671 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
672 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
673/*param3*/
674 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
675 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300676 {}
677};
678
Jean-Francois Moine98819182009-01-19 07:37:33 -0300679static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300680 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
681 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
682 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
683/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
684 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
685 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
686/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300687
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300688 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
689 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
690 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
691 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
692 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
693 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
694 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
695 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300696
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300697 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
698 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300699 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300700 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
701 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300702
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300703 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
704 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
705 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
706 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300708 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
709 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300710 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300711};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300712static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300713 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300714 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300715 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300716 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
717 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
718 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
719 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
720 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
722 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
724 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
726 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
727 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
730 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300735 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300736 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
737 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
738 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
739 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
740 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
742 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
743 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
745 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300746
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300747 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
748 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
749 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
750 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
751 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300752
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300753 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
754 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
755 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
756 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300757
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300758 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
759 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
760/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
761/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
762 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
763 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300764 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300765};
Jean-François Moinea067db82010-10-01 07:51:24 -0300766static const u8 mi0360b_sensor_init[][8] = {
767 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300769 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300770 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300771 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300772 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
773 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
774 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
775 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
776 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
791 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
792 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
794 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
795 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
796 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
797 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
798 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
799 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
801 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
802
803 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
804 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
806 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
807 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
808 {}
809};
810static const u8 mi0360b_sensor_param1[][8] = {
811 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
812 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
813 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
814 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
815
816 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
817 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
818 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
819 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
820 {}
821};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300822static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300823 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300843 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300844};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300845static const u8 mt9v111_sensor_init[][8] = {
846 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300847 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300848 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
849 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
850 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
851 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300852 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
853 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
854 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
855 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300856 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300857 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
858 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
859 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
860 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
861 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300862 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300863 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300864 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
865 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
866 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
867 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
868 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
869 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
870 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
871 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
872 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
873 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300874 {}
875};
876static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300877 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
878 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300879 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300880 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
881 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
882 /*******/
883 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
884 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
885 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
886 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
887 {}
888};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300889static const u8 om6802_init0[2][8] = {
890/*fixme: variable*/
891 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
892 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
893};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300894static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300895 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
896 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300897 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300898 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300899 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300900/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
901 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300902 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300903/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
904 * set color mode */
905/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
906 * max AGC value in AE */
907/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
908 * preset AGC */
909/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
910 * preset brightness */
911/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
912 * preset contrast */
913/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
914 * preset gamma */
915 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300916 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300917 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
918 /* preset shutter */
919/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
920 * auto frame rate */
921/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300922 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
923 {}
924};
925static const u8 om6802_sensor_param1[][8] = {
926 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
927 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
928 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
929 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300930 {}
931};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300932static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300933 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
934 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300935 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300936 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
937 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300938 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300939 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300940/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300941 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
942 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300943/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
944 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
945 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300946 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
947 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
948 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
949 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
950 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
951 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
952 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
953 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
954 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
955 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
956 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
957 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
958 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
959 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
960 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
961 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
962 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
963 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
964 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
965 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
966 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
967 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
968 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300969 {}
970};
971static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300972 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
973 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
974/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300975/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
976 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300977 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
978 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
979 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300980/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300981/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
982/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300983/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300984 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300985/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300986 {}
987};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300988
Jean-Francois Moine98819182009-01-19 07:37:33 -0300989static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300990 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
991 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300992 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300993 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
994 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
995 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
996 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
997 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
998 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
999 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1000 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1001 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1002 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1003 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1004 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1005 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1006 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1007 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1008 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1009 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1010 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1011 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1012
1013 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1014/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1015/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001016/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001017 {}
1018};
1019static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001020/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001021/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1022 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001023 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1024 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1025/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1026/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1027/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1028/*...*/
1029 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1030/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1031/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1032/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1033/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1034/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1035
1036 {}
1037};
1038
Jean-Francois Moine98819182009-01-19 07:37:33 -03001039static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001040 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001041 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001042 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001043 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001044 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001045 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001046 /* GAIN BLUE RED VREF */
1047 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1048 /* COM 1 BAVE GEAVE AECHH */
1049 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1050 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001051 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001052 /* AECH CLKRC COM7 COM8 */
1053 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1054 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1055 /* HSTART HSTOP VSTRT VSTOP */
1056 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1057 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1058 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1059 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001060/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1061 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001062 /* AEW AEB VPT BBIAS */
1063 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1064 /* GbBIAS RSVD EXHCH EXHCL */
1065 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1066 /* RBIAS ADVFL ASDVFH YAVE */
1067 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1068 /* HSYST HSYEN HREF */
1069 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1070 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1071 /* ADC ACOM OFON TSLB */
1072 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1073 /* COM11 COM12 COM13 COM14 */
1074 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1075 /* EDGE COM15 COM16 COM17 */
1076 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1077 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1078 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1079 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1080 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1081 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1082 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1083 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1084 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1085 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1086 /* LCC1 LCC2 LCC3 LCC4 */
1087 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001088 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001089 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001090 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001091 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1092 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1093 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1094 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1095 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1096 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1097 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1098 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1099 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001100 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001101/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001102 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001103 {}
1104};
1105static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001106 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001107 /* bits[3..0]reserved */
1108 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1109 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1110 /* VREF vertical frame ctrl */
1111 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001112 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1113 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1114 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1115 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1116/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001117/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001118/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001119 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001120 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1121 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1122 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1123/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001124/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001125/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001126/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001127 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1128 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1129 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1130 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001131 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001132};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001133
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001134static const u8 po1030_sensor_init[][8] = {
1135/* the sensor registers are described in m5602/m5602_po1030.h */
1136 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001137 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001138 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1139 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1141 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1142 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1143 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1144 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1145 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1146 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1148 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1149 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1150 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1151 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1152 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1153 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1154 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1155 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1156 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1157 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1158 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1159 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1160 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1161 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1162 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1163 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1164
1165 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1166 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1167 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1169 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1170 {}
1171};
1172static const u8 po1030_sensor_param1[][8] = {
1173/* from ms-win traces - these values change with auto gain/expo/wb.. */
1174 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1175 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1176/* mean values */
1177 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1178 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1179 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1180
1181 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1182 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1183 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1184/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1185 {}
1186};
1187
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001188static const u8 po2030n_sensor_init[][8] = {
1189 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1190 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001191 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001192 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1193 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001194 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001195 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1199 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1200 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1201 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1202 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1203 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1204 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1207 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1208 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1209 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1215 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1216 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1226 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1229 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1230 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1231 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1233 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1234 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1235 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1236 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1237 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1238 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1239 {}
1240};
1241static const u8 po2030n_sensor_param1[][8] = {
1242 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001243 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001244 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1245 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1246 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1247/*param2*/
1248 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1249 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1253 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1254 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1255/*after start*/
1256 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001257 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001258 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001259 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001260 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1261 {}
1262};
1263
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001264static const u8 soi768_sensor_init[][8] = {
1265 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001266 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001267 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1268 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1271 {}
1272};
1273static const u8 soi768_sensor_param1[][8] = {
1274 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1275 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1278 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1279/* */
1280/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1281/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1282 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1283/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1284 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1285/* the next sequence should be used for auto gain */
1286 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1287 /* global gain ? : 07 - change with 0x15 at the end */
1288 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1289 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1290 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1291 /* exposure ? : 0200 - change with 0x1e at the end */
1292 {}
1293};
1294
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001295static const u8 sp80708_sensor_init[][8] = {
1296 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1297 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001367 {}
1368};
1369static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001370 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1371 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1374 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1375 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1376 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1377 {}
1378};
1379
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001380static const u8 (*sensor_init[])[8] = {
1381[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001382[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001383[SENSOR_HV7131R] = hv7131r_sensor_init,
1384[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001385[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001386[SENSOR_MO4000] = mo4000_sensor_init,
1387[SENSOR_MT9V111] = mt9v111_sensor_init,
1388[SENSOR_OM6802] = om6802_sensor_init,
1389[SENSOR_OV7630] = ov7630_sensor_init,
1390[SENSOR_OV7648] = ov7648_sensor_init,
1391[SENSOR_OV7660] = ov7660_sensor_init,
1392[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001393[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001394[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001395[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001396};
1397
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001398/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001399static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001400 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001401{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001402 int ret;
1403
1404 if (gspca_dev->usb_err < 0)
1405 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001406#ifdef GSPCA_DEBUG
1407 if (len > USB_BUF_SZ) {
1408 err("reg_r: buffer overflow");
1409 return;
1410 }
1411#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001412 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001413 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001414 0,
1415 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1416 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001417 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001418 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001419 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001420 if (ret < 0) {
1421 err("reg_r err %d", ret);
1422 gspca_dev->usb_err = ret;
1423 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001424}
1425
Jean-Francois Moine60017612008-07-18 08:46:19 -03001426static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001427 u16 value,
1428 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001429{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001430 int ret;
1431
1432 if (gspca_dev->usb_err < 0)
1433 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001434 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001435 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001436 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001437 usb_sndctrlpipe(gspca_dev->dev, 0),
1438 0x08,
1439 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1440 value,
1441 0,
1442 gspca_dev->usb_buf, 1,
1443 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001444 if (ret < 0) {
1445 err("reg_w1 err %d", ret);
1446 gspca_dev->usb_err = ret;
1447 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001448}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001449static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001450 u16 value,
1451 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001452 int len)
1453{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001454 int ret;
1455
1456 if (gspca_dev->usb_err < 0)
1457 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001458 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001459 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001460#ifdef GSPCA_DEBUG
1461 if (len > USB_BUF_SZ) {
1462 err("reg_w: buffer overflow");
1463 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001464 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001465#endif
1466 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001467 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001468 usb_sndctrlpipe(gspca_dev->dev, 0),
1469 0x08,
1470 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1471 value, 0,
1472 gspca_dev->usb_buf, len,
1473 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001474 if (ret < 0) {
1475 err("reg_w err %d", ret);
1476 gspca_dev->usb_err = ret;
1477 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001478}
1479
Jean-Francois Moine60017612008-07-18 08:46:19 -03001480/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001481static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001482{
1483 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001484 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001485
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001486 if (gspca_dev->usb_err < 0)
1487 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001488 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001489 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001490 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001491 case SENSOR_OM6802:
1492 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001493 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1494 break;
1495 default: /* i2c command = a1 (400 kHz) */
1496 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1497 break;
1498 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001499 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001500 gspca_dev->usb_buf[2] = reg;
1501 gspca_dev->usb_buf[3] = val;
1502 gspca_dev->usb_buf[4] = 0;
1503 gspca_dev->usb_buf[5] = 0;
1504 gspca_dev->usb_buf[6] = 0;
1505 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001506 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001507 usb_sndctrlpipe(gspca_dev->dev, 0),
1508 0x08,
1509 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1510 0x08, /* value = i2c */
1511 0,
1512 gspca_dev->usb_buf, 8,
1513 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001514 if (ret < 0) {
1515 err("i2c_w1 err %d", ret);
1516 gspca_dev->usb_err = ret;
1517 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001518}
1519
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001520/* I2C write 8 bytes */
1521static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001522 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001523{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001524 int ret;
1525
1526 if (gspca_dev->usb_err < 0)
1527 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001528 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1529 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001530 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001531 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001532 usb_sndctrlpipe(gspca_dev->dev, 0),
1533 0x08,
1534 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1535 0x08, 0, /* value, index */
1536 gspca_dev->usb_buf, 8,
1537 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001538 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001539 if (ret < 0) {
1540 err("i2c_w8 err %d", ret);
1541 gspca_dev->usb_err = ret;
1542 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001543}
1544
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001545/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1546static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001547{
1548 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001549 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001550
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001551 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001552 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001553 case SENSOR_OM6802:
1554 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001555 mode[0] = 0x80 | 0x10;
1556 break;
1557 default: /* i2c command = 91 (400 kHz) */
1558 mode[0] = 0x81 | 0x10;
1559 break;
1560 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001561 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001562 mode[2] = reg;
1563 mode[3] = 0;
1564 mode[4] = 0;
1565 mode[5] = 0;
1566 mode[6] = 0;
1567 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001568 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001569 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001570 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001571 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001572 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001573 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001574 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001575}
1576
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001577static void i2c_w_seq(struct gspca_dev *gspca_dev,
1578 const u8 (*data)[8])
1579{
1580 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001581 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001582 i2c_w8(gspca_dev, *data);
1583 else
1584 msleep((*data)[1]);
1585 data++;
1586 }
1587}
1588
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001589/* check the ID of the hv7131 sensor */
1590/* this sequence is needed because it activates the sensor */
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001591static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001592{
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001593 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001594 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001595 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001596 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001597 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1598 if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001599 && gspca_dev->usb_buf[1] == 0x09
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001600 && gspca_dev->usb_buf[2] == 0x01) {
1601 PDEBUG(D_PROBE, "Sensor HV7131R found");
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001602 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001603 }
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001604 warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001605 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1606 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001607}
1608
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001609static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001610{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001611 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001612 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001613 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001614 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001615 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001616 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1617 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1618 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1619 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1620 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001621 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001622 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1623 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1624 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1625 {}
1626 },
1627 };
1628
1629 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1630 reg_w1(gspca_dev, 0x17, 0x62);
1631 reg_w1(gspca_dev, 0x01, 0x08);
1632 for (j = 0; j < 3; j++)
1633 i2c_w8(gspca_dev, probe_tb[i][j]);
1634 msleep(2);
1635 reg_r(gspca_dev, 0x0a, 5);
1636 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1637 if (probe_tb[i][3][0] != 0)
1638 i2c_w8(gspca_dev, probe_tb[i][3]);
1639 reg_w1(gspca_dev, 0x01, 0x29);
1640 reg_w1(gspca_dev, 0x17, 0x42);
1641 if (val != 0xffff)
1642 break;
1643 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001644 if (gspca_dev->usb_err < 0)
1645 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001646 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001647 case 0x8221:
1648 PDEBUG(D_PROBE, "Sensor mi0360b");
1649 sd->sensor = SENSOR_MI0360B;
1650 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001651 case 0x823a:
1652 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001653 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001654 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001655 case 0x8243:
1656 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001657 break;
1658 default:
1659 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1660 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001661 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001662}
1663
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001664static void ov7630_probe(struct gspca_dev *gspca_dev)
1665{
1666 struct sd *sd = (struct sd *) gspca_dev;
1667 u16 val;
1668
1669 /* check ov76xx */
1670 reg_w1(gspca_dev, 0x17, 0x62);
1671 reg_w1(gspca_dev, 0x01, 0x08);
1672 sd->i2c_addr = 0x21;
1673 i2c_r(gspca_dev, 0x0a, 2);
1674 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1675 reg_w1(gspca_dev, 0x01, 0x29);
1676 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001677 if (gspca_dev->usb_err < 0)
1678 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001679 if (val == 0x7628) { /* soi768 */
1680 sd->sensor = SENSOR_SOI768;
1681/*fixme: only valid for 0c45:613e?*/
1682 gspca_dev->cam.input_flags =
1683 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1684 PDEBUG(D_PROBE, "Sensor soi768");
1685 return;
1686 }
1687 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1688}
1689
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001690static void ov7648_probe(struct gspca_dev *gspca_dev)
1691{
1692 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001693 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001694
1695 /* check ov76xx */
1696 reg_w1(gspca_dev, 0x17, 0x62);
1697 reg_w1(gspca_dev, 0x01, 0x08);
1698 sd->i2c_addr = 0x21;
1699 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001700 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001701 reg_w1(gspca_dev, 0x01, 0x29);
1702 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001703 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1704 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1705 return;
1706 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001707
1708 /* check po1030 */
1709 reg_w1(gspca_dev, 0x17, 0x62);
1710 reg_w1(gspca_dev, 0x01, 0x08);
1711 sd->i2c_addr = 0x6e;
1712 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001713 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1714 reg_w1(gspca_dev, 0x01, 0x29);
1715 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001716 if (gspca_dev->usb_err < 0)
1717 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001718 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001719 PDEBUG(D_PROBE, "Sensor po1030");
1720 sd->sensor = SENSOR_PO1030;
1721 return;
1722 }
Jean-François Moine0b656322010-09-13 05:19:58 -03001723 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001724}
1725
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001726/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1727static void po2030n_probe(struct gspca_dev *gspca_dev)
1728{
1729 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001730 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001731
1732 /* check gc0307 */
1733 reg_w1(gspca_dev, 0x17, 0x62);
1734 reg_w1(gspca_dev, 0x01, 0x08);
1735 reg_w1(gspca_dev, 0x02, 0x22);
1736 sd->i2c_addr = 0x21;
1737 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001738 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001739 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1740 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001741 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001742 PDEBUG(D_PROBE, "Sensor gc0307");
1743 sd->sensor = SENSOR_GC0307;
1744 return;
1745 }
1746
1747 /* check po2030n */
1748 reg_w1(gspca_dev, 0x17, 0x62);
1749 reg_w1(gspca_dev, 0x01, 0x0a);
1750 sd->i2c_addr = 0x6e;
1751 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001752 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001753 reg_w1(gspca_dev, 0x01, 0x29);
1754 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001755 if (gspca_dev->usb_err < 0)
1756 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001757 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001758 PDEBUG(D_PROBE, "Sensor po2030n");
1759/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001760 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001761 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001762 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001763}
1764
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001765/* this function is called at probe time */
1766static int sd_config(struct gspca_dev *gspca_dev,
1767 const struct usb_device_id *id)
1768{
1769 struct sd *sd = (struct sd *) gspca_dev;
1770 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001771
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001772 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001773 sd->sensor = id->driver_info >> 8;
1774 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001775
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001776 cam = &gspca_dev->cam;
Jean-Francois Moine64677572009-12-20 12:31:28 -03001777 if (sd->sensor == SENSOR_ADCM1700) {
1778 cam->cam_mode = cif_mode;
1779 cam->nmodes = ARRAY_SIZE(cif_mode);
1780 } else {
1781 cam->cam_mode = vga_mode;
1782 cam->nmodes = ARRAY_SIZE(vga_mode);
1783 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001784 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001785 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001786
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001787 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001788 sd->quality = QUALITY_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03001789 sd->jpegqual = 80;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001790
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001791 return 0;
1792}
1793
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001794/* this function is called at probe and resume time */
1795static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001796{
1797 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001798 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001799 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001800 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001801
Hans de Goede3647fea2008-07-15 05:36:30 -03001802 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001803 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001804 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001805 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001806 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001807 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001808 if (gspca_dev->usb_err < 0)
1809 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001810 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001811 switch (sd->bridge) {
1812 case BRIDGE_SN9C102P:
Hans de Goede3647fea2008-07-15 05:36:30 -03001813 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001814 if (regF1 != 0x11)
1815 return -ENODEV;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001816 break;
1817 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001818/* case BRIDGE_SN9C110: */
Hans de Goedee530a5e2011-01-06 15:23:55 -03001819/* case BRIDGE_SN9C120: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001820 if (regF1 != 0x12)
1821 return -ENODEV;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001822 }
1823
1824 switch (sd->sensor) {
1825 case SENSOR_MI0360:
1826 mi0360_probe(gspca_dev);
1827 break;
1828 case SENSOR_OV7630:
1829 ov7630_probe(gspca_dev);
1830 break;
1831 case SENSOR_OV7648:
1832 ov7648_probe(gspca_dev);
1833 break;
1834 case SENSOR_PO2030N:
1835 po2030n_probe(gspca_dev);
1836 break;
1837 }
1838
1839 switch (sd->bridge) {
1840 case BRIDGE_SN9C102P:
1841 reg_w1(gspca_dev, 0x02, regGpio[1]);
1842 break;
1843 case BRIDGE_SN9C105:
1844 reg_w(gspca_dev, 0x01, regGpio, 2);
1845 break;
1846 case BRIDGE_SN9C110:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001847 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001848 break;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001849 case BRIDGE_SN9C120:
1850 regGpio[1] = 0x70; /* no audio */
1851 reg_w(gspca_dev, 0x01, regGpio, 2);
1852 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001853 }
1854
Jean-François Moine72b667e2010-10-02 04:35:25 -03001855 if (sd->sensor == SENSOR_OM6802)
1856 sd->ctrls[SHARPNESS].def = 0x10;
1857
Hans de Goede9712a8b2010-01-31 12:54:29 -03001858 /* Note we do not disable the sensor clock here (power saving mode),
1859 as that also disables the button on the cam. */
1860 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001862 /* set the i2c address */
1863 sn9c1xx = sn_tb[sd->sensor];
1864 sd->i2c_addr = sn9c1xx[9];
1865
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001866 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
Jean-François Moine3afef852011-01-13 06:39:11 -03001867 if (!(sd->flags & F_ILLUM))
1868 gspca_dev->ctrl_dis |= (1 << ILLUM);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001869
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001870 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001871}
1872
Jean-Francois Moine98819182009-01-19 07:37:33 -03001873static u32 setexposure(struct gspca_dev *gspca_dev,
1874 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001875{
1876 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001877
1878 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001879 case SENSOR_GC0307: {
1880 int a, b;
1881
1882 /* expo = 0..255 -> a = 19..43 */
1883 a = 19 + expo * 25 / 256;
1884 i2c_w1(gspca_dev, 0x68, a);
1885 a -= 12;
1886 b = a * a * 4; /* heuristic */
1887 i2c_w1(gspca_dev, 0x03, b >> 8);
1888 i2c_w1(gspca_dev, 0x04, b);
1889 break;
1890 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001891 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001892 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001893 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001894
1895 Expodoit[3] = expo >> 16;
1896 Expodoit[4] = expo >> 8;
1897 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001898 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001899 break;
1900 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001901 case SENSOR_MI0360:
1902 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001903 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001904 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001905 static const u8 doit[] = /* update sensor */
1906 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1907 static const u8 sensorgo[] = /* sensor on */
1908 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001909
1910 if (expo > 0x0635)
1911 expo = 0x0635;
1912 else if (expo < 0x0001)
1913 expo = 0x0001;
1914 expoMi[3] = expo >> 8;
1915 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001916 i2c_w8(gspca_dev, expoMi);
1917 i2c_w8(gspca_dev, doit);
1918 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001919 break;
1920 }
1921 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001922 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001923 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001924 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001925 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001926 static const u8 gainMo[] =
1927 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001928
1929 if (expo > 0x1fff)
1930 expo = 0x1fff;
1931 else if (expo < 0x0001)
1932 expo = 0x0001;
1933 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001934 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001935 expoMo10[3] = ((expo & 0x1c00) >> 10)
1936 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001937 i2c_w8(gspca_dev, expoMo10);
1938 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001939 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001940 ((expoMo10[3] & 0x07) << 10)
1941 | (expoMof[3] << 2)
1942 | ((expoMo10[3] & 0x30) >> 4));
1943 break;
1944 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001945 case SENSOR_MT9V111: {
1946 u8 expo_c1[] =
1947 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1948
1949 if (expo > 0x0280)
1950 expo = 0x0280;
1951 else if (expo < 0x0040)
1952 expo = 0x0040;
1953 expo_c1[3] = expo >> 8;
1954 expo_c1[4] = expo;
1955 i2c_w8(gspca_dev, expo_c1);
1956 break;
1957 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001958 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001959 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001960 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001961 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001962
1963 if (expo > 0x03ff)
1964 expo = 0x03ff;
1965 if (expo < 0x0001)
1966 expo = 0x0001;
1967 gainOm[3] = expo >> 2;
1968 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001969 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001970 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001971 break;
1972 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001973 }
1974 return expo;
1975}
1976
1977static void setbrightness(struct gspca_dev *gspca_dev)
1978{
1979 struct sd *sd = (struct sd *) gspca_dev;
1980 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001981 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001982 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001983
Jean-François Moine72b667e2010-10-02 04:35:25 -03001984 brightness = sd->ctrls[BRIGHTNESS].val;
1985 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001986 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03001987 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001988 if (k2 > 0x1f)
1989 k2 = 0; /* only positive Y offset */
1990 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001991 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001992 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001993 if (expo > 0x002dc6c0)
1994 expo = 0x002dc6c0;
1995 else if (expo < 0x02a0)
1996 expo = 0x02a0;
1997 sd->exposure = setexposure(gspca_dev, expo);
1998 break;
1999 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002000 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002001 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002002 sd->exposure = setexposure(gspca_dev, expo);
2003 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002004 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002005 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002006 sd->exposure = setexposure(gspca_dev, expo);
2007 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002008 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002009 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002010 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002011 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002012 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002013 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002014 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002015 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002016 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002017 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002018 }
2019
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002020 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002021}
2022
2023static void setcontrast(struct gspca_dev *gspca_dev)
2024{
2025 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002026 u8 k2;
2027 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002028
Jean-François Moine72b667e2010-10-02 04:35:25 -03002029 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2030 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002031 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002032 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002033 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002034 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002035 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002036 contrast[5] = 0;
2037 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002038}
2039
2040static void setcolors(struct gspca_dev *gspca_dev)
2041{
2042 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002043 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002044 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002045 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002046 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002047 -24, -38, 64, /* UR UG UB */
2048 62, -51, -9 /* VR VG VB */
2049 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002050 static const s16 uv_mi0360b[6] = {
2051 -20, -38, 64, /* UR UG UB */
2052 60, -51, -9 /* VR VG VB */
2053 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002054
Jean-François Moine72b667e2010-10-02 04:35:25 -03002055 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002056 if (sd->sensor == SENSOR_MI0360B)
2057 uv = uv_mi0360b;
2058 else
2059 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002060 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002061 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002062 reg8a[i * 2] = v;
2063 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002064 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002065 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002066}
2067
2068static void setredblue(struct gspca_dev *gspca_dev)
2069{
2070 struct sd *sd = (struct sd *) gspca_dev;
2071
Jean-François Moine72b667e2010-10-02 04:35:25 -03002072 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002073/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002074 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002075}
2076
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002077static void setgamma(struct gspca_dev *gspca_dev)
2078{
2079 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002080 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002081 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002082 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002083 static const u8 delta[17] = {
2084 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2085 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2086 };
2087
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002088 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002089 case SENSOR_ADCM1700:
2090 gamma_base = gamma_spec_0;
2091 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002092 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002093 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002094 case SENSOR_MT9V111:
2095 gamma_base = gamma_spec_1;
2096 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002097 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002098 gamma_base = gamma_spec_2;
2099 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002100 case SENSOR_SP80708:
2101 gamma_base = gamma_spec_3;
2102 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002103 default:
2104 gamma_base = gamma_def;
2105 break;
2106 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002107
Jean-François Moine72b667e2010-10-02 04:35:25 -03002108 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002109 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002110 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002111 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002112 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2113}
2114
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002115static void setautogain(struct gspca_dev *gspca_dev)
2116{
2117 struct sd *sd = (struct sd *) gspca_dev;
2118
Jean-François Moine72b667e2010-10-02 04:35:25 -03002119 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002120 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002121 switch (sd->sensor) {
2122 case SENSOR_OV7630:
2123 case SENSOR_OV7648: {
2124 u8 comb;
2125
2126 if (sd->sensor == SENSOR_OV7630)
2127 comb = 0xc0;
2128 else
2129 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002130 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec7472009-06-18 06:05:07 -03002131 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002132 i2c_w1(&sd->gspca_dev, 0x13, comb);
2133 return;
2134 }
2135 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002136 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002137 sd->ag_cnt = AG_CNT_START;
2138 else
2139 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002140}
2141
Németh Márton76ad3b62010-10-19 03:33:47 -03002142static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002143{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002144 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002145 u8 comn;
2146
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002147 switch (sd->sensor) {
2148 case SENSOR_HV7131R:
2149 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002150 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002151 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002152 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002153 break;
2154 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002155 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002156 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002157 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002158 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002159 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002160 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002161 comn = 0x06;
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_PO2030N:
2167 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2168 * (reset value: 0x0A)
2169 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2170 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2171 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2172 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2173 * bit3-0: X
2174 */
2175 comn = 0x0a;
2176 if (sd->ctrls[HFLIP].val)
2177 comn |= 0x80;
2178 if (sd->ctrls[VFLIP].val)
2179 comn |= 0x40;
2180 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2181 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002182 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002183}
2184
Jean-François Moine72b667e2010-10-02 04:35:25 -03002185static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002186{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002187 struct sd *sd = (struct sd *) gspca_dev;
2188
2189 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002190}
2191
Jean-François Moine3afef852011-01-13 06:39:11 -03002192static void setillum(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002193{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002194 struct sd *sd = (struct sd *) gspca_dev;
2195
Jean-François Moine3afef852011-01-13 06:39:11 -03002196 if (gspca_dev->ctrl_dis & (1 << ILLUM))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002197 return;
Jean-François Moinea63d6012011-01-13 07:56:00 -03002198 switch (sd->sensor) {
2199 case SENSOR_ADCM1700:
2200 reg_w1(gspca_dev, 0x02, /* gpio */
2201 sd->ctrls[ILLUM].val ? 0x64 : 0x60);
2202 break;
2203 case SENSOR_MT9V111:
2204 if (starcam)
2205 reg_w1(gspca_dev, 0x02,
2206 sd->ctrls[ILLUM].val ?
2207 0x55 : 0x54); /* 370i */
2208 else
2209 reg_w1(gspca_dev, 0x02,
2210 sd->ctrls[ILLUM].val ?
2211 0x66 : 0x64); /* Clip */
2212 break;
2213 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002214}
2215
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002216static void setfreq(struct gspca_dev *gspca_dev)
2217{
2218 struct sd *sd = (struct sd *) gspca_dev;
2219
Jean-François Moine72b667e2010-10-02 04:35:25 -03002220 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002221 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002222 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002223 u8 com8;
2224
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002225 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002226 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002227 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002228 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002229 break;
2230 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002231 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002232 i2c_w1(gspca_dev, 0x3b, 0x0a);
2233 break;
2234 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002235 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002236 i2c_w1(gspca_dev, 0x3b, 0x02);
2237 break;
2238 }
2239 } else {
2240 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2241
2242 /* Get reg2a / reg2d base values */
2243 switch (sd->sensor) {
2244 case SENSOR_OV7630:
2245 reg2a = 0x08;
2246 reg2d = 0x01;
2247 break;
2248 case SENSOR_OV7648:
2249 reg2a = 0x11;
2250 reg2d = 0x81;
2251 break;
2252 }
2253
Jean-François Moine72b667e2010-10-02 04:35:25 -03002254 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002255 case 0: /* Banding filter disabled */
2256 break;
2257 case 1: /* 50 hz (filter on and framerate adj) */
2258 reg2a |= 0x80;
2259 reg2b = 0xac;
2260 reg2d |= 0x04;
2261 break;
2262 case 2: /* 60 hz (filter on, no framerate adj) */
2263 reg2a |= 0x80;
2264 reg2d |= 0x04;
2265 break;
2266 }
2267 i2c_w1(gspca_dev, 0x2a, reg2a);
2268 i2c_w1(gspca_dev, 0x2b, reg2b);
2269 i2c_w1(gspca_dev, 0x2d, reg2d);
2270 }
2271}
2272
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002273static void setjpegqual(struct gspca_dev *gspca_dev)
2274{
2275 struct sd *sd = (struct sd *) gspca_dev;
2276 int i, sc;
2277
2278 if (sd->jpegqual < 50)
2279 sc = 5000 / sd->jpegqual;
2280 else
2281 sc = 200 - sd->jpegqual * 2;
2282#if USB_BUF_SZ < 64
2283#error "No room enough in usb_buf for quantization table"
2284#endif
2285 for (i = 0; i < 64; i++)
2286 gspca_dev->usb_buf[i] =
2287 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2288 usb_control_msg(gspca_dev->dev,
2289 usb_sndctrlpipe(gspca_dev->dev, 0),
2290 0x08,
2291 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2292 0x0100, 0,
2293 gspca_dev->usb_buf, 64,
2294 500);
2295 for (i = 0; i < 64; i++)
2296 gspca_dev->usb_buf[i] =
2297 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2298 usb_control_msg(gspca_dev->dev,
2299 usb_sndctrlpipe(gspca_dev->dev, 0),
2300 0x08,
2301 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2302 0x0140, 0,
2303 gspca_dev->usb_buf, 64,
2304 500);
2305
2306 sd->reg18 ^= 0x40;
2307 reg_w1(gspca_dev, 0x18, sd->reg18);
2308}
2309
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002310/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002311static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002312{
2313 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002314 int i;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002315 u8 reg01, reg17;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002316 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03002317 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002318 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002319 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002320 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002321 static const u8 reg9a_def[] =
2322 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2323 static const u8 reg9a_spec[] =
2324 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2325 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002326 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2327 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine64677572009-12-20 12:31:28 -03002328 static const u8 CA_adcm1700[] =
2329 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002330 static const u8 CA_po2030n[] =
2331 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002332 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002333 static const u8 CE_gc0307[] =
2334 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002335 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002336 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002337 static const u8 CE_po2030n[] =
2338 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002339
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002340 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002341 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2342 0x21); /* JPEG 422 */
2343 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2344
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002345 /* initialize the bridge */
2346 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002347
2348 /* sensor clock already enabled in sd_init */
2349 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002350 reg01 = sn9c1xx[1];
Jean-François Moine3afef852011-01-13 06:39:11 -03002351 if (sd->flags & F_PDN_INV)
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002352 reg01 ^= S_PDN_INV; /* power down inverted */
2353 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002354
2355 /* configure gpio */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002356 reg0102[0] = reg01;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002357 reg0102[1] = sn9c1xx[2];
2358 if (gspca_dev->audio)
2359 reg0102[1] |= 0x04; /* keep the audio connection */
2360 reg_w(gspca_dev, 0x01, reg0102, 2);
2361 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2362 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2363 switch (sd->sensor) {
2364 case SENSOR_GC0307:
2365 case SENSOR_OV7660:
2366 case SENSOR_PO1030:
2367 case SENSOR_PO2030N:
2368 case SENSOR_SOI768:
2369 case SENSOR_SP80708:
2370 reg9a = reg9a_spec;
2371 break;
2372 default:
2373 reg9a = reg9a_def;
2374 break;
2375 }
2376 reg_w(gspca_dev, 0x9a, reg9a, 6);
2377
2378 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2379
2380 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2381
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002382 reg17 = sn9c1xx[0x17];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002383 switch (sd->sensor) {
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002384 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002385 msleep(50); /*fixme: is it useful? */
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002386 break;
2387 case SENSOR_OM6802:
2388 msleep(10);
2389 reg_w1(gspca_dev, 0x02, 0x73);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002390 reg17 |= SEN_CLK_EN;
2391 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002392 reg_w1(gspca_dev, 0x01, 0x22);
2393 msleep(100);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002394 reg01 = SCL_SEL_OD | S_PDN_INV;
2395 reg17 &= MCK_SIZE_MASK;
2396 reg17 |= 0x04; /* clock / 4 */
2397 break;
2398 }
2399 reg01 |= SYS_SEL_48M;
2400 reg_w1(gspca_dev, 0x01, reg01);
2401 reg17 |= SEN_CLK_EN;
2402 reg_w1(gspca_dev, 0x17, reg17);
2403 reg01 &= ~S_PWR_DN; /* sensor power on */
2404 reg_w1(gspca_dev, 0x01, reg01);
2405 reg01 &= ~SYS_SEL_48M;
2406 reg_w1(gspca_dev, 0x01, reg01);
2407
2408 switch (sd->sensor) {
2409 case SENSOR_HV7131R:
2410 hv7131r_probe(gspca_dev); /*fixme: is it useful? */
2411 break;
2412 case SENSOR_OM6802:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002413 msleep(10);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002414 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002415 i2c_w8(gspca_dev, om6802_init0[0]);
2416 i2c_w8(gspca_dev, om6802_init0[1]);
2417 msleep(15);
2418 reg_w1(gspca_dev, 0x02, 0x71);
2419 msleep(150);
2420 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002421 case SENSOR_SP80708:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002422 msleep(100);
2423 reg_w1(gspca_dev, 0x02, 0x62);
2424 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002425 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002426
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002427 /* initialize the sensor */
2428 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2429
Jean-Francois Moine60017612008-07-18 08:46:19 -03002430 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2431 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2432 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2433 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2434 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002435 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002436 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2437 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002438 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002439 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2440 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002441 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002442 reg_w1(gspca_dev, 0xc6, 0x00);
2443 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine64677572009-12-20 12:31:28 -03002444 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002445 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2446 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002447 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002448 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2449 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine64677572009-12-20 12:31:28 -03002450 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002451 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002452 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002453 case SENSOR_OM6802:
2454/* case SENSOR_OV7648: * fixme: sometimes */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002455 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002456 default:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002457 reg17 |= DEF_EN;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002458 break;
2459 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002460 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002461
2462 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2463 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2464 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002465 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002466
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002467 setgamma(gspca_dev);
2468
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002469/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002470 for (i = 0; i < 8; i++)
2471 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002472 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002473 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002474 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002475 case SENSOR_SP80708:
2476 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002477 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002478 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002479 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002480 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002481 reg_w1(gspca_dev, 0x9a, 0x07);
2482 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002483 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002484 case SENSOR_OV7648:
2485 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002486 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002487 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002488 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002489 reg_w1(gspca_dev, 0x9a, 0x06);
2490 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002491 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002492 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002493 break;
2494 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002495 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002496
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002497 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002498 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2499 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2500 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002501
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002502 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002503 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002504 reg01 |= SYS_SEL_48M | V_TX_EN;
2505 reg17 &= ~MCK_SIZE_MASK;
2506 reg17 |= 0x02; /* clock / 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002507 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002508 case SENSOR_ADCM1700:
2509 init = adcm1700_sensor_param1;
Jean-Francois Moine64677572009-12-20 12:31:28 -03002510 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002511 case SENSOR_GC0307:
2512 init = gc0307_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002513 break;
2514 case SENSOR_HV7131R:
2515 case SENSOR_MI0360:
2516 if (mode)
2517 reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */
2518 else
2519 reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */
2520 reg17 &= ~MCK_SIZE_MASK;
2521 reg17 |= 0x01; /* clock / 1 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002522 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002523 case SENSOR_MI0360B:
2524 init = mi0360b_sensor_param1;
Jean-François Moinea067db82010-10-01 07:51:24 -03002525 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002526 case SENSOR_MO4000:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002527 if (mode) { /* if 320x240 */
2528 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2529 reg17 &= ~MCK_SIZE_MASK;
2530 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002531 }
2532 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002533 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002534 init = mt9v111_sensor_param1;
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002535 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002536 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002537 init = om6802_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002538 if (!mode) { /* if 640x480 */
2539 reg17 &= ~MCK_SIZE_MASK;
Jean-François Moineaa777a82010-12-28 07:39:13 -03002540 reg17 |= 0x04; /* clock / 4 */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002541 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002542 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002543 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002544 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002545 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002546 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002547 init = ov7648_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002548 reg17 &= ~MCK_SIZE_MASK;
2549 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002550 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002551 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002552 init = ov7660_sensor_param1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002553 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002554 case SENSOR_PO1030:
2555 init = po1030_sensor_param1;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002556 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002557 case SENSOR_PO2030N:
2558 init = po2030n_sensor_param1;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002559 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002560 case SENSOR_SOI768:
2561 init = soi768_sensor_param1;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002562 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002563 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002564 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002565 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002566 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002567
2568 /* more sensor initialization - param1 */
2569 if (init != NULL) {
2570 i2c_w_seq(gspca_dev, init);
2571/* init = NULL; */
2572 }
2573
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002574 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002575 switch (sd->sensor) {
2576 case SENSOR_ADCM1700:
2577 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002578 case SENSOR_SOI768:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002579 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002580 break;
2581 case SENSOR_PO2030N:
2582 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2583 break;
2584 default:
Jean-Francois Moine64677572009-12-20 12:31:28 -03002585 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002586 break;
2587 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002588 switch (sd->sensor) {
Jean-Francois Moine64677572009-12-20 12:31:28 -03002589 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002590 case SENSOR_OV7630:
2591 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002592 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002593 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002594 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002595 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002596 case SENSOR_GC0307:
2597 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2598 break;
2599 case SENSOR_PO2030N:
2600 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2601 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002602 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002603 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002604 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2605 break;
2606 }
2607
2608 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002609 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2610 reg_w1(gspca_dev, 0x18, sd->reg18);
2611 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002612
Jean-Francois Moine60017612008-07-18 08:46:19 -03002613 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002614 reg_w1(gspca_dev, 0x01, reg01);
2615 sd->reg01 = reg01;
2616 sd->reg17 = reg17;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002617
Németh Márton76ad3b62010-10-19 03:33:47 -03002618 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002619 setbrightness(gspca_dev);
2620 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002621 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002622 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002623 setfreq(gspca_dev);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002624 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002625}
2626
2627static void sd_stopN(struct gspca_dev *gspca_dev)
2628{
2629 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002630 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002631 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002632 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002633 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002634 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002635 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002636 static const u8 stopsoi768[] =
2637 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002638 u8 reg01;
2639 u8 reg17;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002640
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002641 reg01 = sd->reg01;
2642 reg17 = sd->reg17 & ~SEN_CLK_EN;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002643 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002644 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002645 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002646 case SENSOR_PO2030N:
2647 case SENSOR_SP80708:
2648 reg01 |= LED;
2649 reg_w1(gspca_dev, 0x01, reg01);
2650 reg01 &= ~(LED | V_TX_EN);
2651 reg_w1(gspca_dev, 0x01, reg01);
2652/* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002653 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002654 case SENSOR_HV7131R:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002655 reg01 &= ~V_TX_EN;
2656 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002657 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002658 break;
2659 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002660 case SENSOR_MI0360B:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002661 reg01 &= ~V_TX_EN;
2662 reg_w1(gspca_dev, 0x01, reg01);
2663/* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002664 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002665 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002666 case SENSOR_MT9V111:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002667 case SENSOR_OM6802:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002668 case SENSOR_PO1030:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002669 reg01 &= ~V_TX_EN;
2670 reg_w1(gspca_dev, 0x01, reg01);
2671 break;
2672 case SENSOR_OV7630:
2673 case SENSOR_OV7648:
2674 reg01 &= ~V_TX_EN;
2675 reg_w1(gspca_dev, 0x01, reg01);
2676 i2c_w8(gspca_dev, stopov7648);
2677 break;
2678 case SENSOR_OV7660:
2679 reg01 &= ~V_TX_EN;
2680 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002681 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002682 case SENSOR_SOI768:
2683 i2c_w8(gspca_dev, stopsoi768);
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002684 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002685 }
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002686
2687 reg01 |= SCL_SEL_OD;
2688 reg_w1(gspca_dev, 0x01, reg01);
2689 reg01 |= S_PWR_DN; /* sensor power down */
2690 reg_w1(gspca_dev, 0x01, reg01);
2691 reg_w1(gspca_dev, 0x17, reg17);
2692 reg01 &= ~SYS_SEL_48M; /* clock 24MHz */
2693 reg_w1(gspca_dev, 0x01, reg01);
2694 reg01 |= LED;
2695 reg_w1(gspca_dev, 0x01, reg01);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002696 /* Don't disable sensor clock as that disables the button on the cam */
2697 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002698}
2699
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002700static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002701{
2702 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002703 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002704 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002705 u8 luma_mean = 130;
2706 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002707
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002708 /* Thanks S., without your advice, autobright should not work :) */
2709 if (sd->ag_cnt < 0)
2710 return;
2711 if (--sd->ag_cnt >= 0)
2712 return;
2713 sd->ag_cnt = AG_CNT_START;
2714
2715 delta = atomic_read(&sd->avg_lum);
2716 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002717 if (delta < luma_mean - luma_delta ||
2718 delta > luma_mean + luma_delta) {
2719 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002720 case SENSOR_GC0307:
2721 expotimes = sd->exposure;
2722 expotimes += (luma_mean - delta) >> 6;
2723 if (expotimes < 0)
2724 expotimes = 0;
2725 sd->exposure = setexposure(gspca_dev,
2726 (unsigned int) expotimes);
2727 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002728 case SENSOR_HV7131R:
2729 expotimes = sd->exposure >> 8;
2730 expotimes += (luma_mean - delta) >> 4;
2731 if (expotimes < 0)
2732 expotimes = 0;
2733 sd->exposure = setexposure(gspca_dev,
2734 (unsigned int) (expotimes << 8));
2735 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002736 case SENSOR_OM6802:
2737 expotimes = sd->exposure;
2738 expotimes += (luma_mean - delta) >> 2;
2739 if (expotimes < 0)
2740 expotimes = 0;
2741 sd->exposure = setexposure(gspca_dev,
2742 (unsigned int) expotimes);
2743 setredblue(gspca_dev);
2744 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002745 default:
2746/* case SENSOR_MO4000: */
2747/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002748/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002749/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002750 expotimes = sd->exposure;
2751 expotimes += (luma_mean - delta) >> 6;
2752 if (expotimes < 0)
2753 expotimes = 0;
2754 sd->exposure = setexposure(gspca_dev,
2755 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002756 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002757 break;
2758 }
2759 }
2760}
2761
Jean-François Moine0f77f402011-02-10 07:01:30 -03002762/* set the average luminosity from an isoc marker */
2763static void set_lum(struct sd *sd,
2764 u8 *data)
2765{
2766 int avg_lum;
2767
2768 /* w0 w1 w2
2769 * w3 w4 w5
2770 * w6 w7 w8
2771 */
2772 avg_lum = (data[27] << 8) + data[28] /* w3 */
2773
2774 + (data[31] << 8) + data[32] /* w5 */
2775
2776 + (data[23] << 8) + data[24] /* w1 */
2777
2778 + (data[35] << 8) + data[36] /* w7 */
2779
2780 + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */
2781 avg_lum >>= 10;
2782 atomic_set(&sd->avg_lum, avg_lum);
2783}
2784
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002785/* scan the URB packets */
2786/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002787static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002788 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002789 int len) /* iso packet length */
2790{
2791 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002792 int i;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002793
Jean-François Moinea4a30762011-02-10 07:15:24 -03002794 /*
2795 * A frame ends on the marker
2796 * ff ff 00 c4 c4 96 ..
2797 * which is 62 bytes long and is followed by various information
2798 * including statuses and luminosity.
2799 *
2800 * A marker may be splitted on two packets.
2801 *
2802 * The 6th byte of a marker contains the bits:
2803 * 0x08: USB full
2804 * 0xc0: frame sequence
2805 * When the bit 'USB full' is set, the frame must be discarded;
2806 * this is also the case when the 2 bytes before the marker are
2807 * not the JPEG end of frame ('ff d9').
2808 */
2809
2810/*fixme: assumption about the following code:
2811 * - there can be only one marker in a packet
2812 */
2813
2814 /* skip the remaining bytes of a short marker */
2815 i = sd->short_mark;
2816 if (i != 0) {
2817 sd->short_mark = 0;
2818 if (i < 0 /* if 'ff' at end of previous packet */
2819 && data[0] == 0xff
2820 && data[1] == 0x00)
2821 goto marker_found;
2822 if (data[0] == 0xff && data[1] == 0xff) {
2823 i = 0;
2824 goto marker_found;
2825 }
2826 len -= i;
2827 if (len <= 0)
2828 return;
2829 data += i;
2830 }
2831
2832 /* search backwards if there is a marker in the packet */
2833 for (i = len - 1; --i >= 0; ) {
2834 if (data[i] != 0xff) {
2835 i--;
2836 continue;
2837 }
2838 if (data[i + 1] == 0xff) {
2839
2840 /* (there may be 'ff ff' inside a marker) */
2841 if (i + 2 >= len || data[i + 2] == 0x00)
2842 goto marker_found;
2843 }
2844 }
2845
2846 /* no marker found */
2847 /* add the JPEG header if first fragment */
2848 if (data[len - 1] == 0xff)
2849 sd->short_mark = -1;
2850 if (gspca_dev->last_packet_type == LAST_PACKET)
Jean-François Moinea95bd642010-10-01 07:54:30 -03002851 gspca_frame_add(gspca_dev, FIRST_PACKET,
2852 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-François Moinea95bd642010-10-01 07:54:30 -03002853 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-François Moinea4a30762011-02-10 07:15:24 -03002854 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002855
Jean-François Moinea4a30762011-02-10 07:15:24 -03002856 /* marker found */
2857 /* if some error, discard the frame */
2858marker_found:
2859 if (i > 2) {
2860 if (data[i - 2] != 0xff || data[i - 1] != 0xd9) {
2861 gspca_dev->last_packet_type = DISCARD_PACKET;
2862 }
2863 } else if (i + 6 < len) {
2864 if (data[i + 6] & 0x08) {
2865 gspca_dev->last_packet_type = DISCARD_PACKET;
2866 }
2867 }
Jean-François Moinea95bd642010-10-01 07:54:30 -03002868
Jean-François Moinea4a30762011-02-10 07:15:24 -03002869 gspca_frame_add(gspca_dev, LAST_PACKET, data, i);
2870
2871 /* if the marker is smaller than 62 bytes,
2872 * memorize the number of bytes to skip in the next packet */
2873 if (i + 62 > len) { /* no more usable data */
2874 sd->short_mark = i + 62 - len;
2875 return;
2876 }
2877
Jean-François Moine0f77f402011-02-10 07:01:30 -03002878 if (sd->ag_cnt >= 0)
Jean-François Moinea4a30762011-02-10 07:15:24 -03002879 set_lum(sd, data + i);
2880
2881 /* if more data, start a new frame */
2882 i += 62;
2883 if (i < len) {
2884 data += i;
2885 len -= i;
2886 gspca_frame_add(gspca_dev, FIRST_PACKET,
2887 sd->jpeg_hdr, JPEG_HDR_SZ);
2888 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2889 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002890}
2891
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002892static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2893 struct v4l2_jpegcompression *jcomp)
2894{
2895 struct sd *sd = (struct sd *) gspca_dev;
2896
2897 if (jcomp->quality < QUALITY_MIN)
2898 sd->quality = QUALITY_MIN;
2899 else if (jcomp->quality > QUALITY_MAX)
2900 sd->quality = QUALITY_MAX;
2901 else
2902 sd->quality = jcomp->quality;
2903 if (gspca_dev->streaming)
2904 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2905 return 0;
2906}
2907
2908static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2909 struct v4l2_jpegcompression *jcomp)
2910{
2911 struct sd *sd = (struct sd *) gspca_dev;
2912
2913 memset(jcomp, 0, sizeof *jcomp);
2914 jcomp->quality = sd->quality;
2915 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2916 | V4L2_JPEG_MARKER_DQT;
2917 return 0;
2918}
2919
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002920static int sd_querymenu(struct gspca_dev *gspca_dev,
2921 struct v4l2_querymenu *menu)
2922{
2923 switch (menu->id) {
2924 case V4L2_CID_POWER_LINE_FREQUENCY:
2925 switch (menu->index) {
2926 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2927 strcpy((char *) menu->name, "NoFliker");
2928 return 0;
2929 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2930 strcpy((char *) menu->name, "50 Hz");
2931 return 0;
2932 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2933 strcpy((char *) menu->name, "60 Hz");
2934 return 0;
2935 }
2936 break;
2937 }
2938 return -EINVAL;
2939}
2940
Jean-François Moine28566432010-10-01 07:33:26 -03002941#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002942static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2943 u8 *data, /* interrupt packet data */
2944 int len) /* interrupt packet length */
2945{
2946 int ret = -EINVAL;
2947
2948 if (len == 1 && data[0] == 1) {
2949 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2950 input_sync(gspca_dev->input_dev);
2951 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2952 input_sync(gspca_dev->input_dev);
2953 ret = 0;
2954 }
2955
2956 return ret;
2957}
2958#endif
2959
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002960/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002961static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002962 .name = MODULE_NAME,
2963 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03002964 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002965 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002966 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002967 .start = sd_start,
2968 .stopN = sd_stopN,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002969 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002970 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002971 .get_jcomp = sd_get_jcomp,
2972 .set_jcomp = sd_set_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002973 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03002974#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002975 .int_pkt_scan = sd_int_pkt_scan,
2976#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002977};
2978
2979/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002980#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002981 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03002982 | (SENSOR_ ## sensor << 8)
2983#define BSF(bridge, sensor, flags) \
2984 .driver_info = (BRIDGE_ ## bridge << 16) \
2985 | (SENSOR_ ## sensor << 8) \
2986 | (flags)
Jean-François Moine95c967c2011-01-13 05:20:29 -03002987static const struct usb_device_id device_table[] = {
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002988 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2989 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-François Moine3afef852011-01-13 06:39:11 -03002990 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)},
2991 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002992 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2993 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2994 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2995 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2996 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2997/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2998 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2999/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
3000/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
3001 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3002/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
Jean-François Moine3afef852011-01-13 06:39:11 -03003003 {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003004 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003005/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3006/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3007/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03003008 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003009 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
3010/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
3011/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03003012/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003013 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003014 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3015 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003016 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03003017 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003018/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3019 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3020 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3021 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3022 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3023/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3024/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3025/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3026 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003027/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003028 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003029 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003030 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3031 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3032/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003033 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003034 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003035/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3036 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3037 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003038 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003039 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3040 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003041 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003042 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003043 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3044 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-François Moinea63d6012011-01-13 07:56:00 -03003045 {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)},
Hans de Goedee48d38f2011-01-06 16:21:57 -03003046/* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003047 {}
3048};
3049MODULE_DEVICE_TABLE(usb, device_table);
3050
3051/* -- device connect -- */
3052static int sd_probe(struct usb_interface *intf,
3053 const struct usb_device_id *id)
3054{
3055 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3056 THIS_MODULE);
3057}
3058
3059static struct usb_driver sd_driver = {
3060 .name = MODULE_NAME,
3061 .id_table = device_table,
3062 .probe = sd_probe,
3063 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003064#ifdef CONFIG_PM
3065 .suspend = gspca_suspend,
3066 .resume = gspca_resume,
3067#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003068};
3069
3070/* -- module insert / remove -- */
3071static int __init sd_mod_init(void)
3072{
Jean-François Moine54826432010-09-13 04:53:03 -03003073 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003074}
3075static void __exit sd_mod_exit(void)
3076{
3077 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003078}
3079
3080module_init(sd_mod_init);
3081module_exit(sd_mod_exit);
Jean-François Moine3afef852011-01-13 06:39:11 -03003082
3083module_param(starcam, int, 0644);
3084MODULE_PARM_DESC(starcam,
3085 "StarCam model. 0: Clip, 1: 370i");