blob: 2bfb8df9168b9155d4874ba5b5e7959b78cd24a1 [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 Moineb96cfc33e2011-02-10 07:38:58 -030060 struct work_struct work;
61 struct workqueue_struct *work_thread;
62
63 u32 pktsz; /* (used by pkt_scan) */
64 u16 npkt;
65 u8 nchg;
Jean-François Moinea4a30762011-02-10 07:15:24 -030066 s8 short_mark;
67
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030068 u8 quality; /* image quality */
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -030069#define QUALITY_MIN 25
70#define QUALITY_MAX 90
71#define QUALITY_DEF 70
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030072
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -030073 u8 reg01;
74 u8 reg17;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030075 u8 reg18;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -030076 u8 flags;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030077
Jean-Francois Moine98819182009-01-19 07:37:33 -030078 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030079#define AG_CNT_START 13
80
Jean-Francois Moine98819182009-01-19 07:37:33 -030081 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030082#define BRIDGE_SN9C102P 0
83#define BRIDGE_SN9C105 1
84#define BRIDGE_SN9C110 2
85#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030086 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030087 u8 i2c_addr;
88
89 u8 jpeg_hdr[JPEG_HDR_SZ];
90};
91enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030092 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030093 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030094 SENSOR_HV7131R,
95 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030096 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030097 SENSOR_MO4000,
98 SENSOR_MT9V111,
99 SENSOR_OM6802,
100 SENSOR_OV7630,
101 SENSOR_OV7648,
102 SENSOR_OV7660,
103 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300104 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300105 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300106 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300107};
108
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -0300109static void qual_upd(struct work_struct *work);
110
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300111/* device flags */
Jean-François Moine3afef852011-01-13 06:39:11 -0300112#define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */
113#define F_ILLUM 0x02 /* presence of illuminator */
Jean-Francois Moineb2272a42010-12-14 16:16:16 -0300114
Jean-Francois Moine4fd350ee2010-12-14 16:16:58 -0300115/* sn9c1xx definitions */
116/* register 0x01 */
117#define S_PWR_DN 0x01 /* sensor power down */
118#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
119#define V_TX_EN 0x04 /* video transfer enable */
120#define LED 0x08 /* output to pin LED */
121#define SCL_SEL_OD 0x20 /* open-drain mode */
122#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
123/* register 0x17 */
124#define MCK_SIZE_MASK 0x1f /* sensor master clock */
125#define SEN_CLK_EN 0x20 /* enable sensor clock */
126#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
127
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300128/* V4L2 controls supported by the driver */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300129static void setbrightness(struct gspca_dev *gspca_dev);
130static void setcontrast(struct gspca_dev *gspca_dev);
131static void setcolors(struct gspca_dev *gspca_dev);
132static void setredblue(struct gspca_dev *gspca_dev);
133static void setgamma(struct gspca_dev *gspca_dev);
134static void setautogain(struct gspca_dev *gspca_dev);
Németh Márton76ad3b62010-10-19 03:33:47 -0300135static void sethvflip(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300136static void setsharpness(struct gspca_dev *gspca_dev);
Jean-François Moine3afef852011-01-13 06:39:11 -0300137static void setillum(struct gspca_dev *gspca_dev);
Jean-François Moine72b667e2010-10-02 04:35:25 -0300138static void setfreq(struct gspca_dev *gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300139
Jean-François Moine72b667e2010-10-02 04:35:25 -0300140static const struct ctrl sd_ctrls[NCTRLS] = {
141[BRIGHTNESS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142 {
143 .id = V4L2_CID_BRIGHTNESS,
144 .type = V4L2_CTRL_TYPE_INTEGER,
145 .name = "Brightness",
146 .minimum = 0,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300147 .maximum = 0xff,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300148 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300149 .default_value = 0x80,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300150 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300151 .set_control = setbrightness
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300152 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300153[CONTRAST] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300154 {
155 .id = V4L2_CID_CONTRAST,
156 .type = V4L2_CTRL_TYPE_INTEGER,
157 .name = "Contrast",
158 .minimum = 0,
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300159#define CONTRAST_MAX 127
160 .maximum = CONTRAST_MAX,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300161 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300162 .default_value = 63,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300163 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300164 .set_control = setcontrast
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300165 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300166[COLORS] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300167 {
168 .id = V4L2_CID_SATURATION,
169 .type = V4L2_CTRL_TYPE_INTEGER,
Hans de Goede3fb4a572009-06-18 14:31:36 -0300170 .name = "Saturation",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300171 .minimum = 0,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300172 .maximum = 40,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300173 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300174#define COLORS_DEF 25
175 .default_value = COLORS_DEF,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300176 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300177 .set_control = setcolors
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300178 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300179[BLUE] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300180 {
181 .id = V4L2_CID_BLUE_BALANCE,
182 .type = V4L2_CTRL_TYPE_INTEGER,
183 .name = "Blue Balance",
184 .minimum = 24,
185 .maximum = 40,
186 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300187 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300188 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300189 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300190 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300191[RED] = {
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300192 {
193 .id = V4L2_CID_RED_BALANCE,
194 .type = V4L2_CTRL_TYPE_INTEGER,
195 .name = "Red Balance",
196 .minimum = 24,
197 .maximum = 40,
198 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300199 .default_value = 32,
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300200 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300201 .set_control = setredblue
Jean-Francois Moine403123d2008-11-26 04:46:15 -0300202 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300203[GAMMA] = {
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300204 {
205 .id = V4L2_CID_GAMMA,
206 .type = V4L2_CTRL_TYPE_INTEGER,
207 .name = "Gamma",
208 .minimum = 0,
209 .maximum = 40,
210 .step = 1,
211#define GAMMA_DEF 20
212 .default_value = GAMMA_DEF,
213 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300214 .set_control = setgamma
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300215 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300216[AUTOGAIN] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300217 {
218 .id = V4L2_CID_AUTOGAIN,
219 .type = V4L2_CTRL_TYPE_BOOLEAN,
220 .name = "Auto Gain",
221 .minimum = 0,
222 .maximum = 1,
223 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300224 .default_value = 1
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300225 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300226 .set_control = setautogain
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300227 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300228[HFLIP] = {
229 {
230 .id = V4L2_CID_HFLIP,
231 .type = V4L2_CTRL_TYPE_BOOLEAN,
232 .name = "Mirror",
233 .minimum = 0,
234 .maximum = 1,
235 .step = 1,
236 .default_value = 0,
237 },
238 .set_control = sethvflip
239 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300240[VFLIP] = {
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300241 {
242 .id = V4L2_CID_VFLIP,
243 .type = V4L2_CTRL_TYPE_BOOLEAN,
244 .name = "Vflip",
245 .minimum = 0,
246 .maximum = 1,
247 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300248 .default_value = 0,
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300249 },
Németh Márton76ad3b62010-10-19 03:33:47 -0300250 .set_control = sethvflip
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300251 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300252[SHARPNESS] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300253 {
254 .id = V4L2_CID_SHARPNESS,
255 .type = V4L2_CTRL_TYPE_INTEGER,
256 .name = "Sharpness",
257 .minimum = 0,
258 .maximum = 255,
259 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300260 .default_value = 90,
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300261 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300262 .set_control = setsharpness
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300263 },
Jean-François Moine3afef852011-01-13 06:39:11 -0300264[ILLUM] = {
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300265 {
Jean-François Moine3afef852011-01-13 06:39:11 -0300266 .id = V4L2_CID_ILLUMINATORS_1,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300267 .type = V4L2_CTRL_TYPE_BOOLEAN,
Jean-François Moine3afef852011-01-13 06:39:11 -0300268 .name = "Illuminator / infrared",
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300269 .minimum = 0,
270 .maximum = 1,
271 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300272 .default_value = 0,
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300273 },
Jean-François Moine3afef852011-01-13 06:39:11 -0300274 .set_control = setillum
Jean-Francois Moine0cae8962008-10-17 07:48:24 -0300275 },
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300276/* ov7630/ov7648/ov7660 only */
Jean-François Moine72b667e2010-10-02 04:35:25 -0300277[FREQ] = {
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300278 {
279 .id = V4L2_CID_POWER_LINE_FREQUENCY,
280 .type = V4L2_CTRL_TYPE_MENU,
281 .name = "Light frequency filter",
282 .minimum = 0,
283 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
284 .step = 1,
Jean-François Moine72b667e2010-10-02 04:35:25 -0300285 .default_value = 1,
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300286 },
Jean-François Moine72b667e2010-10-02 04:35:25 -0300287 .set_control = setfreq
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300288 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300289};
290
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300291/* table of the disabled controls */
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300292static const __u32 ctrl_dis[] = {
Jean-François Moine72b667e2010-10-02 04:35:25 -0300293[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300294 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300295 (1 << VFLIP) |
296 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300297
Jean-François Moine3afef852011-01-13 06:39:11 -0300298[SENSOR_GC0307] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300299 (1 << VFLIP) |
300 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300301
Jean-François Moine3afef852011-01-13 06:39:11 -0300302[SENSOR_HV7131R] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300303 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300304
Jean-François Moine3afef852011-01-13 06:39:11 -0300305[SENSOR_MI0360] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300306 (1 << VFLIP) |
307 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300308
Jean-François Moine3afef852011-01-13 06:39:11 -0300309[SENSOR_MI0360B] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300310 (1 << VFLIP) |
311 (1 << FREQ),
Jean-François Moinea067db82010-10-01 07:51:24 -0300312
Jean-François Moine3afef852011-01-13 06:39:11 -0300313[SENSOR_MO4000] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300314 (1 << VFLIP) |
315 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300316
Németh Márton76ad3b62010-10-19 03:33:47 -0300317[SENSOR_MT9V111] = (1 << HFLIP) |
318 (1 << VFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300319 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300320
Jean-François Moine3afef852011-01-13 06:39:11 -0300321[SENSOR_OM6802] = (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300322 (1 << VFLIP) |
323 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300324
Jean-François Moine3afef852011-01-13 06:39:11 -0300325[SENSOR_OV7630] = (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300326
Jean-François Moine3afef852011-01-13 06:39:11 -0300327[SENSOR_OV7648] = (1 << HFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300328
Jean-François Moine72b667e2010-10-02 04:35:25 -0300329[SENSOR_OV7660] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300330 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300331 (1 << VFLIP),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300332
Jean-François Moine72b667e2010-10-02 04:35:25 -0300333[SENSOR_PO1030] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300334 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300335 (1 << VFLIP) |
336 (1 << FREQ),
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300337
Jean-François Moine72b667e2010-10-02 04:35:25 -0300338[SENSOR_PO2030N] = (1 << AUTOGAIN) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300339 (1 << FREQ),
Jean-François Moine780e3122010-10-19 04:29:10 -0300340
Jean-François Moine72b667e2010-10-02 04:35:25 -0300341[SENSOR_SOI768] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300342 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300343 (1 << VFLIP) |
344 (1 << FREQ),
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300345
Jean-François Moine72b667e2010-10-02 04:35:25 -0300346[SENSOR_SP80708] = (1 << AUTOGAIN) |
Németh Márton76ad3b62010-10-19 03:33:47 -0300347 (1 << HFLIP) |
Jean-François Moine72b667e2010-10-02 04:35:25 -0300348 (1 << VFLIP) |
349 (1 << FREQ),
Jean-Francois Moine577cbf42008-12-05 06:18:37 -0300350};
351
Jean-Francois Moine646775732009-12-20 12:31:28 -0300352static const struct v4l2_pix_format cif_mode[] = {
353 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
354 .bytesperline = 352,
355 .sizeimage = 352 * 288 * 4 / 8 + 590,
356 .colorspace = V4L2_COLORSPACE_JPEG,
357 .priv = 0},
358};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300359static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300360 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
361 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300362 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300363 .colorspace = V4L2_COLORSPACE_JPEG,
364 .priv = 2},
365 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
366 .bytesperline = 320,
367 .sizeimage = 320 * 240 * 3 / 8 + 590,
368 .colorspace = V4L2_COLORSPACE_JPEG,
369 .priv = 1},
370 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
371 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300372 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
373 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300374 .colorspace = V4L2_COLORSPACE_JPEG,
375 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300376};
377
Jean-Francois Moine646775732009-12-20 12:31:28 -0300378static const u8 sn_adcm1700[0x1c] = {
379/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300380 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine646775732009-12-20 12:31:28 -0300381/* reg8 reg9 rega regb regc regd rege regf */
382 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
384 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
385/* reg18 reg19 reg1a reg1b */
386 0x06, 0x00, 0x00, 0x00
387};
388
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300389static const u8 sn_gc0307[0x1c] = {
390/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
391 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
392/* reg8 reg9 rega regb regc regd rege regf */
393 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
394/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
395 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
396/* reg18 reg19 reg1a reg1b */
397 0x06, 0x00, 0x00, 0x00
398};
399
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300400static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300401/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300402 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300403/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300404 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300405/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
406 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300407/* reg18 reg19 reg1a reg1b */
408 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300409};
410
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300411static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300412/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300413 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300414/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300415 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300416/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
417 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300418/* reg18 reg19 reg1a reg1b */
419 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300420};
421
Jean-François Moinea067db82010-10-01 07:51:24 -0300422static const u8 sn_mi0360b[0x1c] = {
423/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
424 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
425/* reg8 reg9 rega regb regc regd rege regf */
426 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
427/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
428 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
429/* reg18 reg19 reg1a reg1b */
430 0x06, 0x00, 0x00, 0x00
431};
432
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300433static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300434/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300435 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300436/* reg8 reg9 rega regb regc regd rege regf */
437 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
438/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
439 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300440/* reg18 reg19 reg1a reg1b */
441 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300442};
443
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300444static const u8 sn_mt9v111[0x1c] = {
445/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
446 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
447/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300448 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300449/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
450 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
451/* reg18 reg19 reg1a reg1b */
452 0x06, 0x00, 0x00, 0x00
453};
454
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300455static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300456/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300457 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300458/* reg8 reg9 rega regb regc regd rege regf */
459 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
461 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300462/* reg18 reg19 reg1a reg1b */
463 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300464};
465
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300466static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300467/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300468 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300469/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300470 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300471/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
472 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300473/* reg18 reg19 reg1a reg1b */
474 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300475};
476
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300477static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300478/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300479 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300480/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300481 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300482/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300483 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300484/* reg18 reg19 reg1a reg1b */
485 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300486};
487
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300488static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300489/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300490 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300491/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300492 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300493/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
494 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300495/* reg18 reg19 reg1a reg1b */
496 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300497};
498
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300499static const u8 sn_po1030[0x1c] = {
500/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
501 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
502/* reg8 reg9 rega regb regc regd rege regf */
503 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
505 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
506/* reg18 reg19 reg1a reg1b */
507 0x07, 0x00, 0x00, 0x00
508};
509
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300510static const u8 sn_po2030n[0x1c] = {
511/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
512 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
513/* reg8 reg9 rega regb regc regd rege regf */
514 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
515/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
516 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
517/* reg18 reg19 reg1a reg1b */
518 0x07, 0x00, 0x00, 0x00
519};
520
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300521static const u8 sn_soi768[0x1c] = {
522/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
523 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
524/* reg8 reg9 rega regb regc regd rege regf */
525 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
526/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
527 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
528/* reg18 reg19 reg1a reg1b */
529 0x07, 0x00, 0x00, 0x00
530};
531
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300532static const u8 sn_sp80708[0x1c] = {
533/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
534 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
535/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300536 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300537/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
538 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
539/* reg18 reg19 reg1a reg1b */
540 0x07, 0x00, 0x00, 0x00
541};
542
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300543/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300544static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300545[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300546[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300547[SENSOR_HV7131R] = sn_hv7131,
548[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300549[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300550[SENSOR_MO4000] = sn_mo4000,
551[SENSOR_MT9V111] = sn_mt9v111,
552[SENSOR_OM6802] = sn_om6802,
553[SENSOR_OV7630] = sn_ov7630,
554[SENSOR_OV7648] = sn_ov7648,
555[SENSOR_OV7660] = sn_ov7660,
556[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300557[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300558[SENSOR_SOI768] = sn_soi768,
559[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300560};
561
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300562/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300563static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300564 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
565 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
566};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300567/* gamma for sensor ADCM1700 */
568static const u8 gamma_spec_0[17] = {
569 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
570 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
571};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300572/* gamma for sensors HV7131R and MT9V111 */
573static const u8 gamma_spec_1[17] = {
574 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
575 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
576};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300577/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300578static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300579 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
580 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
581};
582/* gamma for sensor SP80708 */
583static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300584 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
585 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
586};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300587
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300588/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300589static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300590 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
591 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
592 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
593 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300594};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300595
596#define DELAY 0xdd
597
Jean-Francois Moine646775732009-12-20 12:31:28 -0300598static const u8 adcm1700_sensor_init[][8] = {
599 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300600 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300601 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300602 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300603 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300604 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
605 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
606 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
607 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300609 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300610 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300611 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300612 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
613 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
614 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
615 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
616 {}
617};
618static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300619 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300620 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
621
622 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
623 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
625 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300626 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300627
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300628 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
629 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
631 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300632 {}
633};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300634static const u8 gc0307_sensor_init[][8] = {
635 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
649 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
650 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300655 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300656 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
666 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
667 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
668 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
669 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
670 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
671 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
672 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
673 {}
674};
675static const u8 gc0307_sensor_param1[][8] = {
676 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
677 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
678 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
679 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
680/*param3*/
681 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
682 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300683 {}
684};
685
Jean-Francois Moine98819182009-01-19 07:37:33 -0300686static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300687 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
688 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
689 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
690/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
691 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
692 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
693/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300694
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300695 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
696 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
697 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
698 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
699 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
700 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
701 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
702 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300703
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300704 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
705 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300706 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300707 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300709
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300710 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
711 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
712 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
713 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
714 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300715 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
716 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300717 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300718};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300719static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300720 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300721 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300722 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300723 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
724 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
725 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
726 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
727 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
730 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
736 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
737 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
739 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300742 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300743 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
745 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
746 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
747 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
748 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
749 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
750 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
752 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300753
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300754 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
755 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
756 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
757 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
758 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300759
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300760 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
761 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
762 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
763 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300764
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300765 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
766 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
767/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
768/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
769 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
770 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300771 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300772};
Jean-François Moinea067db82010-10-01 07:51:24 -0300773static const u8 mi0360b_sensor_init[][8] = {
774 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
775 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300776 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300777 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300778 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300779 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
780 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
781 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
795 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
798 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
799 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
801 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
802 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
803 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
804 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
805 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
806 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
808 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
809
810 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
811 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
812 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
813 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
814 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
815 {}
816};
817static const u8 mi0360b_sensor_param1[][8] = {
818 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
819 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
820 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
821 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
822
823 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
824 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
825 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
826 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
827 {}
828};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300829static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300830 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300850 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300851};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300852static const u8 mt9v111_sensor_init[][8] = {
853 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300854 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300855 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
856 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
857 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
858 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300859 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
860 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
861 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
862 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300863 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300864 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
865 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
866 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
867 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
868 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300869 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300870 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300871 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
872 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
873 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
874 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
875 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
876 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
877 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
878 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
879 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
880 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300881 {}
882};
883static const u8 mt9v111_sensor_param1[][8] = {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300884 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
885 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine2687a2f2009-02-01 14:48:55 -0300886 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300887 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
888 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
889 /*******/
890 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
891 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
892 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
893 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
894 {}
895};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300896static const u8 om6802_init0[2][8] = {
897/*fixme: variable*/
898 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
899 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
900};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300901static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300902 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
903 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300904 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300905 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300906 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300907/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
908 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300909 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300910/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
911 * set color mode */
912/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
913 * max AGC value in AE */
914/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
915 * preset AGC */
916/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
917 * preset brightness */
918/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
919 * preset contrast */
920/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
921 * preset gamma */
922 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300923 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300924 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
925 /* preset shutter */
926/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
927 * auto frame rate */
928/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300929 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
930 {}
931};
932static const u8 om6802_sensor_param1[][8] = {
933 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
934 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
935 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
936 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300937 {}
938};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300939static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300940 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
941 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300942 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300943 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
944 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300945 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300946 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300947/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300948 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
949 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300950/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
951 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
952 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300953 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
954 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
955 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
956 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
957 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
958 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
959 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
960 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
961 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
962 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
963 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
964 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
965 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
966 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
967 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
968 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
969 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
970 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
971 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
972 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
973 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
974 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
975 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300976 {}
977};
978static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300979 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
980 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
981/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300982/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
983 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300984 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
985 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
986 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300987/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300988/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
989/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300990/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300991 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300992/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300993 {}
994};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300995
Jean-Francois Moine98819182009-01-19 07:37:33 -0300996static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300997 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
998 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300999 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001000 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1001 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
1002 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
1003 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
1004 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
1005 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
1006 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1007 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1008 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1009 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1010 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1011 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1012 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1013 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1014 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1015 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1016 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1017 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1018 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1019
1020 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1021/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1022/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -03001023/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001024 {}
1025};
1026static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -03001027/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001028/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1029 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -03001030 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1031 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1032/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1033/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1034/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1035/*...*/
1036 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1037/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1038/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1039/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1040/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1041/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1042
1043 {}
1044};
1045
Jean-Francois Moine98819182009-01-19 07:37:33 -03001046static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001047 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001048 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001049 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001050 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001051 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03001052 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001053 /* GAIN BLUE RED VREF */
1054 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1055 /* COM 1 BAVE GEAVE AECHH */
1056 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1057 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001058 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001059 /* AECH CLKRC COM7 COM8 */
1060 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1061 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1062 /* HSTART HSTOP VSTRT VSTOP */
1063 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1064 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1065 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1066 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001067/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1068 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001069 /* AEW AEB VPT BBIAS */
1070 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1071 /* GbBIAS RSVD EXHCH EXHCL */
1072 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1073 /* RBIAS ADVFL ASDVFH YAVE */
1074 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1075 /* HSYST HSYEN HREF */
1076 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1077 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1078 /* ADC ACOM OFON TSLB */
1079 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1080 /* COM11 COM12 COM13 COM14 */
1081 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1082 /* EDGE COM15 COM16 COM17 */
1083 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1084 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1085 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1086 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1087 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1088 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1089 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1090 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1091 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1092 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1093 /* LCC1 LCC2 LCC3 LCC4 */
1094 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001095 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001096 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001097 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001098 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1099 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1100 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1101 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1102 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1103 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1104 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1105 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1106 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001107 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001108/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03001109 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001110 {}
1111};
1112static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001113 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001114 /* bits[3..0]reserved */
1115 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1116 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1117 /* VREF vertical frame ctrl */
1118 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001119 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1120 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1121 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1122 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1123/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001124/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001125/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001126 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001127 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1128 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1129 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1130/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001131/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -03001132/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001133/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001134 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1135 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1136 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1137 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001138 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001139};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001140
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001141static const u8 po1030_sensor_init[][8] = {
1142/* the sensor registers are described in m5602/m5602_po1030.h */
1143 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001144 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001145 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1146 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1148 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1149 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1150 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1151 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1152 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1153 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1154 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1155 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1156 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1157 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1158 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1159 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1160 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1161 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1162 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1163 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1164 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1165 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1166 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1167 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1168 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1169 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1170 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1171
1172 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1173 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1175 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1176 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1177 {}
1178};
1179static const u8 po1030_sensor_param1[][8] = {
1180/* from ms-win traces - these values change with auto gain/expo/wb.. */
1181 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1182 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1183/* mean values */
1184 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1185 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1186 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1187
1188 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1189 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1190 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1191/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1192 {}
1193};
1194
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001195static const u8 po2030n_sensor_init[][8] = {
1196 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001198 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001199 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001201 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001202 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1203 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1204 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1205 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1206 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1207 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1208 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1209 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1210 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1216 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1217 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1222 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1223 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1226 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1230 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1231 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1234 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1235 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1236 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1237 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1239 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1240 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1241 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1242 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1243 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1244 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1245 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1246 {}
1247};
1248static const u8 po2030n_sensor_param1[][8] = {
1249 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001250 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001251 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1253 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1254/*param2*/
1255 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1256 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1257 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1258 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1259 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1260 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1261 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1262/*after start*/
1263 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001264 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001265 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -03001266 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001267 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1268 {}
1269};
1270
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001271static const u8 soi768_sensor_init[][8] = {
1272 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001273 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001274 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1275 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1278 {}
1279};
1280static const u8 soi768_sensor_param1[][8] = {
1281 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1282 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1283 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1284 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1285 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1286/* */
1287/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1288/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1289 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1290/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1291 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1292/* the next sequence should be used for auto gain */
1293 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1294 /* global gain ? : 07 - change with 0x15 at the end */
1295 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1296 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1297 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1298 /* exposure ? : 0200 - change with 0x1e at the end */
1299 {}
1300};
1301
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001302static const u8 sp80708_sensor_init[][8] = {
1303 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1368 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1369 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1370 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1371 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001374 {}
1375};
1376static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001377 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1378 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1379 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1380 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1381 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1382 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1383 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1384 {}
1385};
1386
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001387static const u8 (*sensor_init[])[8] = {
1388[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001389[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001390[SENSOR_HV7131R] = hv7131r_sensor_init,
1391[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001392[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001393[SENSOR_MO4000] = mo4000_sensor_init,
1394[SENSOR_MT9V111] = mt9v111_sensor_init,
1395[SENSOR_OM6802] = om6802_sensor_init,
1396[SENSOR_OV7630] = ov7630_sensor_init,
1397[SENSOR_OV7648] = ov7648_sensor_init,
1398[SENSOR_OV7660] = ov7660_sensor_init,
1399[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001400[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001401[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001402[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001403};
1404
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001405/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001406static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001407 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001408{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001409 int ret;
1410
1411 if (gspca_dev->usb_err < 0)
1412 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001413#ifdef GSPCA_DEBUG
1414 if (len > USB_BUF_SZ) {
1415 err("reg_r: buffer overflow");
1416 return;
1417 }
1418#endif
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001419 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001420 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001421 0,
1422 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1423 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001424 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001425 500);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001426 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001427 if (ret < 0) {
1428 err("reg_r err %d", ret);
1429 gspca_dev->usb_err = ret;
1430 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001431}
1432
Jean-Francois Moine60017612008-07-18 08:46:19 -03001433static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001434 u16 value,
1435 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001436{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001437 int ret;
1438
1439 if (gspca_dev->usb_err < 0)
1440 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001441 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001442 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001443 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001444 usb_sndctrlpipe(gspca_dev->dev, 0),
1445 0x08,
1446 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1447 value,
1448 0,
1449 gspca_dev->usb_buf, 1,
1450 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001451 if (ret < 0) {
1452 err("reg_w1 err %d", ret);
1453 gspca_dev->usb_err = ret;
1454 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001455}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001456static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001457 u16 value,
1458 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001459 int len)
1460{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001461 int ret;
1462
1463 if (gspca_dev->usb_err < 0)
1464 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001465 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
Jean-Francois Moine60017612008-07-18 08:46:19 -03001466 value, buffer[0], buffer[1]);
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001467#ifdef GSPCA_DEBUG
1468 if (len > USB_BUF_SZ) {
1469 err("reg_w: buffer overflow");
1470 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001471 }
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001472#endif
1473 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001474 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001475 usb_sndctrlpipe(gspca_dev->dev, 0),
1476 0x08,
1477 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1478 value, 0,
1479 gspca_dev->usb_buf, len,
1480 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001481 if (ret < 0) {
1482 err("reg_w err %d", ret);
1483 gspca_dev->usb_err = ret;
1484 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001485}
1486
Jean-Francois Moine60017612008-07-18 08:46:19 -03001487/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001488static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001489{
1490 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001491 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001492
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001493 if (gspca_dev->usb_err < 0)
1494 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001495 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001496 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001497 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001498 case SENSOR_OM6802:
1499 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001500 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1501 break;
1502 default: /* i2c command = a1 (400 kHz) */
1503 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1504 break;
1505 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001506 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001507 gspca_dev->usb_buf[2] = reg;
1508 gspca_dev->usb_buf[3] = val;
1509 gspca_dev->usb_buf[4] = 0;
1510 gspca_dev->usb_buf[5] = 0;
1511 gspca_dev->usb_buf[6] = 0;
1512 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001513 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001514 usb_sndctrlpipe(gspca_dev->dev, 0),
1515 0x08,
1516 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1517 0x08, /* value = i2c */
1518 0,
1519 gspca_dev->usb_buf, 8,
1520 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001521 if (ret < 0) {
1522 err("i2c_w1 err %d", ret);
1523 gspca_dev->usb_err = ret;
1524 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001525}
1526
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001527/* I2C write 8 bytes */
1528static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001529 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001530{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001531 int ret;
1532
1533 if (gspca_dev->usb_err < 0)
1534 return;
Jean-François Moinecfd23c82010-04-25 14:27:39 -03001535 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1536 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001537 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001538 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001539 usb_sndctrlpipe(gspca_dev->dev, 0),
1540 0x08,
1541 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1542 0x08, 0, /* value, index */
1543 gspca_dev->usb_buf, 8,
1544 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001545 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001546 if (ret < 0) {
1547 err("i2c_w8 err %d", ret);
1548 gspca_dev->usb_err = ret;
1549 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001550}
1551
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001552/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1553static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001554{
1555 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001556 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001557
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001558 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001559 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001560 case SENSOR_OM6802:
1561 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001562 mode[0] = 0x80 | 0x10;
1563 break;
1564 default: /* i2c command = 91 (400 kHz) */
1565 mode[0] = 0x81 | 0x10;
1566 break;
1567 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001568 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001569 mode[2] = reg;
1570 mode[3] = 0;
1571 mode[4] = 0;
1572 mode[5] = 0;
1573 mode[6] = 0;
1574 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001575 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001576 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001577 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001578 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001579 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001580 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001581 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001582}
1583
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001584static void i2c_w_seq(struct gspca_dev *gspca_dev,
1585 const u8 (*data)[8])
1586{
1587 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001588 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001589 i2c_w8(gspca_dev, *data);
1590 else
1591 msleep((*data)[1]);
1592 data++;
1593 }
1594}
1595
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001596/* check the ID of the hv7131 sensor */
1597/* this sequence is needed because it activates the sensor */
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001598static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001599{
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001600 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001601 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001602 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001603 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001604 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1605 if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001606 && gspca_dev->usb_buf[1] == 0x09
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001607 && gspca_dev->usb_buf[2] == 0x01) {
1608 PDEBUG(D_PROBE, "Sensor HV7131R found");
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001609 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001610 }
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001611 warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001612 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1613 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001614}
1615
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001616static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001617{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001618 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001619 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001620 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001621 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001622 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001623 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1624 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1625 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1626 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1627 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001628 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001629 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1630 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1631 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1632 {}
1633 },
1634 };
1635
1636 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1637 reg_w1(gspca_dev, 0x17, 0x62);
1638 reg_w1(gspca_dev, 0x01, 0x08);
1639 for (j = 0; j < 3; j++)
1640 i2c_w8(gspca_dev, probe_tb[i][j]);
1641 msleep(2);
1642 reg_r(gspca_dev, 0x0a, 5);
1643 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1644 if (probe_tb[i][3][0] != 0)
1645 i2c_w8(gspca_dev, probe_tb[i][3]);
1646 reg_w1(gspca_dev, 0x01, 0x29);
1647 reg_w1(gspca_dev, 0x17, 0x42);
1648 if (val != 0xffff)
1649 break;
1650 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001651 if (gspca_dev->usb_err < 0)
1652 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001653 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001654 case 0x8221:
1655 PDEBUG(D_PROBE, "Sensor mi0360b");
1656 sd->sensor = SENSOR_MI0360B;
1657 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001658 case 0x823a:
1659 PDEBUG(D_PROBE, "Sensor mt9v111");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001660 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001661 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001662 case 0x8243:
1663 PDEBUG(D_PROBE, "Sensor mi0360");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001664 break;
1665 default:
1666 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1667 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001668 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001669}
1670
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001671static void ov7630_probe(struct gspca_dev *gspca_dev)
1672{
1673 struct sd *sd = (struct sd *) gspca_dev;
1674 u16 val;
1675
1676 /* check ov76xx */
1677 reg_w1(gspca_dev, 0x17, 0x62);
1678 reg_w1(gspca_dev, 0x01, 0x08);
1679 sd->i2c_addr = 0x21;
1680 i2c_r(gspca_dev, 0x0a, 2);
1681 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1682 reg_w1(gspca_dev, 0x01, 0x29);
1683 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001684 if (gspca_dev->usb_err < 0)
1685 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001686 if (val == 0x7628) { /* soi768 */
1687 sd->sensor = SENSOR_SOI768;
1688/*fixme: only valid for 0c45:613e?*/
1689 gspca_dev->cam.input_flags =
1690 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1691 PDEBUG(D_PROBE, "Sensor soi768");
1692 return;
1693 }
1694 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1695}
1696
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001697static void ov7648_probe(struct gspca_dev *gspca_dev)
1698{
1699 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001700 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001701
1702 /* check ov76xx */
1703 reg_w1(gspca_dev, 0x17, 0x62);
1704 reg_w1(gspca_dev, 0x01, 0x08);
1705 sd->i2c_addr = 0x21;
1706 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001707 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001708 reg_w1(gspca_dev, 0x01, 0x29);
1709 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001710 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1711 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1712 return;
1713 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001714
1715 /* check po1030 */
1716 reg_w1(gspca_dev, 0x17, 0x62);
1717 reg_w1(gspca_dev, 0x01, 0x08);
1718 sd->i2c_addr = 0x6e;
1719 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001720 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1721 reg_w1(gspca_dev, 0x01, 0x29);
1722 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001723 if (gspca_dev->usb_err < 0)
1724 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001725 if (val == 0x1030) { /* po1030 */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001726 PDEBUG(D_PROBE, "Sensor po1030");
1727 sd->sensor = SENSOR_PO1030;
1728 return;
1729 }
Jean-François Moine0b656322010-09-13 05:19:58 -03001730 err("Unknown sensor %04x", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001731}
1732
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001733/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1734static void po2030n_probe(struct gspca_dev *gspca_dev)
1735{
1736 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001737 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001738
1739 /* check gc0307 */
1740 reg_w1(gspca_dev, 0x17, 0x62);
1741 reg_w1(gspca_dev, 0x01, 0x08);
1742 reg_w1(gspca_dev, 0x02, 0x22);
1743 sd->i2c_addr = 0x21;
1744 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001745 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001746 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1747 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001748 if (val == 0x99) { /* gc0307 (?) */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001749 PDEBUG(D_PROBE, "Sensor gc0307");
1750 sd->sensor = SENSOR_GC0307;
1751 return;
1752 }
1753
1754 /* check po2030n */
1755 reg_w1(gspca_dev, 0x17, 0x62);
1756 reg_w1(gspca_dev, 0x01, 0x0a);
1757 sd->i2c_addr = 0x6e;
1758 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001759 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001760 reg_w1(gspca_dev, 0x01, 0x29);
1761 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001762 if (gspca_dev->usb_err < 0)
1763 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001764 if (val == 0x2030) {
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001765 PDEBUG(D_PROBE, "Sensor po2030n");
1766/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001767 } else {
Jean-François Moine0b656322010-09-13 05:19:58 -03001768 err("Unknown sensor ID %04x", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001769 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001770}
1771
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001772/* this function is called at probe time */
1773static int sd_config(struct gspca_dev *gspca_dev,
1774 const struct usb_device_id *id)
1775{
1776 struct sd *sd = (struct sd *) gspca_dev;
1777 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001778
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001779 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001780 sd->sensor = id->driver_info >> 8;
1781 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001782
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001783 cam = &gspca_dev->cam;
Jean-Francois Moine646775732009-12-20 12:31:28 -03001784 if (sd->sensor == SENSOR_ADCM1700) {
1785 cam->cam_mode = cif_mode;
1786 cam->nmodes = ARRAY_SIZE(cif_mode);
1787 } else {
1788 cam->cam_mode = vga_mode;
1789 cam->nmodes = ARRAY_SIZE(vga_mode);
1790 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001791 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-François Moine72b667e2010-10-02 04:35:25 -03001792 cam->ctrls = sd->ctrls;
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001793
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001794 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001795 sd->quality = QUALITY_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001796
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03001797 INIT_WORK(&sd->work, qual_upd);
1798
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001799 return 0;
1800}
1801
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001802/* this function is called at probe and resume time */
1803static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001804{
1805 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001806 const u8 *sn9c1xx;
Jean-François Moine19697b52010-07-14 06:33:51 -03001807 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001808 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001809
Hans de Goede3647fea2008-07-15 05:36:30 -03001810 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001811 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001812 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001813 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001814 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001815 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001816 if (gspca_dev->usb_err < 0)
1817 return gspca_dev->usb_err;
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001818 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
Hans de Goede3647fea2008-07-15 05:36:30 -03001819 switch (sd->bridge) {
1820 case BRIDGE_SN9C102P:
Hans de Goede3647fea2008-07-15 05:36:30 -03001821 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001822 if (regF1 != 0x11)
1823 return -ENODEV;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001824 break;
1825 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001826/* case BRIDGE_SN9C110: */
Hans de Goedee530a5e2011-01-06 15:23:55 -03001827/* case BRIDGE_SN9C120: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001828 if (regF1 != 0x12)
1829 return -ENODEV;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001830 }
1831
1832 switch (sd->sensor) {
1833 case SENSOR_MI0360:
1834 mi0360_probe(gspca_dev);
1835 break;
1836 case SENSOR_OV7630:
1837 ov7630_probe(gspca_dev);
1838 break;
1839 case SENSOR_OV7648:
1840 ov7648_probe(gspca_dev);
1841 break;
1842 case SENSOR_PO2030N:
1843 po2030n_probe(gspca_dev);
1844 break;
1845 }
1846
1847 switch (sd->bridge) {
1848 case BRIDGE_SN9C102P:
1849 reg_w1(gspca_dev, 0x02, regGpio[1]);
1850 break;
1851 case BRIDGE_SN9C105:
1852 reg_w(gspca_dev, 0x01, regGpio, 2);
1853 break;
1854 case BRIDGE_SN9C110:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001855 reg_w1(gspca_dev, 0x02, 0x62);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001856 break;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001857 case BRIDGE_SN9C120:
1858 regGpio[1] = 0x70; /* no audio */
1859 reg_w(gspca_dev, 0x01, regGpio, 2);
1860 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001861 }
1862
Jean-François Moine72b667e2010-10-02 04:35:25 -03001863 if (sd->sensor == SENSOR_OM6802)
1864 sd->ctrls[SHARPNESS].def = 0x10;
1865
Hans de Goede9712a8b2010-01-31 12:54:29 -03001866 /* Note we do not disable the sensor clock here (power saving mode),
1867 as that also disables the button on the cam. */
1868 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001869
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001870 /* set the i2c address */
1871 sn9c1xx = sn_tb[sd->sensor];
1872 sd->i2c_addr = sn9c1xx[9];
1873
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001874 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
Jean-François Moine3afef852011-01-13 06:39:11 -03001875 if (!(sd->flags & F_ILLUM))
1876 gspca_dev->ctrl_dis |= (1 << ILLUM);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001877
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001878 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001879}
1880
Jean-Francois Moine98819182009-01-19 07:37:33 -03001881static u32 setexposure(struct gspca_dev *gspca_dev,
1882 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001883{
1884 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001885
1886 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001887 case SENSOR_GC0307: {
1888 int a, b;
1889
1890 /* expo = 0..255 -> a = 19..43 */
1891 a = 19 + expo * 25 / 256;
1892 i2c_w1(gspca_dev, 0x68, a);
1893 a -= 12;
1894 b = a * a * 4; /* heuristic */
1895 i2c_w1(gspca_dev, 0x03, b >> 8);
1896 i2c_w1(gspca_dev, 0x04, b);
1897 break;
1898 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001899 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001900 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001901 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001902
1903 Expodoit[3] = expo >> 16;
1904 Expodoit[4] = expo >> 8;
1905 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001906 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001907 break;
1908 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001909 case SENSOR_MI0360:
1910 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001911 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001912 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001913 static const u8 doit[] = /* update sensor */
1914 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1915 static const u8 sensorgo[] = /* sensor on */
1916 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001917
1918 if (expo > 0x0635)
1919 expo = 0x0635;
1920 else if (expo < 0x0001)
1921 expo = 0x0001;
1922 expoMi[3] = expo >> 8;
1923 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001924 i2c_w8(gspca_dev, expoMi);
1925 i2c_w8(gspca_dev, doit);
1926 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001927 break;
1928 }
1929 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001930 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001931 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001932 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001933 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001934 static const u8 gainMo[] =
1935 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001936
1937 if (expo > 0x1fff)
1938 expo = 0x1fff;
1939 else if (expo < 0x0001)
1940 expo = 0x0001;
1941 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001942 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001943 expoMo10[3] = ((expo & 0x1c00) >> 10)
1944 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001945 i2c_w8(gspca_dev, expoMo10);
1946 i2c_w8(gspca_dev, gainMo);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001947 PDEBUG(D_FRAM, "set exposure %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001948 ((expoMo10[3] & 0x07) << 10)
1949 | (expoMof[3] << 2)
1950 | ((expoMo10[3] & 0x30) >> 4));
1951 break;
1952 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001953 case SENSOR_MT9V111: {
1954 u8 expo_c1[] =
1955 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1956
1957 if (expo > 0x0280)
1958 expo = 0x0280;
1959 else if (expo < 0x0040)
1960 expo = 0x0040;
1961 expo_c1[3] = expo >> 8;
1962 expo_c1[4] = expo;
1963 i2c_w8(gspca_dev, expo_c1);
1964 break;
1965 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001966 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001967 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001968 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001969 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001970
1971 if (expo > 0x03ff)
1972 expo = 0x03ff;
1973 if (expo < 0x0001)
1974 expo = 0x0001;
1975 gainOm[3] = expo >> 2;
1976 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001977 reg_w1(gspca_dev, 0x96, expo >> 5);
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001978 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001979 break;
1980 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001981 }
1982 return expo;
1983}
1984
1985static void setbrightness(struct gspca_dev *gspca_dev)
1986{
1987 struct sd *sd = (struct sd *) gspca_dev;
1988 unsigned int expo;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001989 int brightness;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001990 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001991
Jean-François Moine72b667e2010-10-02 04:35:25 -03001992 brightness = sd->ctrls[BRIGHTNESS].val;
1993 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001994 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001995 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001996 if (k2 > 0x1f)
1997 k2 = 0; /* only positive Y offset */
1998 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001999 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002000 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002001 if (expo > 0x002dc6c0)
2002 expo = 0x002dc6c0;
2003 else if (expo < 0x02a0)
2004 expo = 0x02a0;
2005 sd->exposure = setexposure(gspca_dev, expo);
2006 break;
2007 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002008 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002009 expo = brightness << 4;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002010 sd->exposure = setexposure(gspca_dev, expo);
2011 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002012 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002013 expo = brightness << 2;
Jean-François Moinea067db82010-10-01 07:51:24 -03002014 sd->exposure = setexposure(gspca_dev, expo);
2015 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002016 case SENSOR_GC0307:
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002017 case SENSOR_MT9V111:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002018 expo = brightness;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002019 sd->exposure = setexposure(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002020 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002021 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03002022 expo = brightness << 2;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002023 sd->exposure = setexposure(gspca_dev, expo);
Jean-François Moine72b667e2010-10-02 04:35:25 -03002024 k2 = brightness >> 3;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002025 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002026 }
2027
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002028 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002029}
2030
2031static void setcontrast(struct gspca_dev *gspca_dev)
2032{
2033 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002034 u8 k2;
2035 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002036
Jean-François Moine72b667e2010-10-02 04:35:25 -03002037 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2038 + 0x10; /* 10..40 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002039 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002040 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002041 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002042 contrast[3] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002043 contrast[4] = (k2 + 1) / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03002044 contrast[5] = 0;
2045 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002046}
2047
2048static void setcolors(struct gspca_dev *gspca_dev)
2049{
2050 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002051 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03002052 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002053 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03002054 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002055 -24, -38, 64, /* UR UG UB */
2056 62, -51, -9 /* VR VG VB */
2057 };
Jean-François Moinea067db82010-10-01 07:51:24 -03002058 static const s16 uv_mi0360b[6] = {
2059 -20, -38, 64, /* UR UG UB */
2060 60, -51, -9 /* VR VG VB */
2061 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002062
Jean-François Moine72b667e2010-10-02 04:35:25 -03002063 colors = sd->ctrls[COLORS].val;
Jean-François Moinea067db82010-10-01 07:51:24 -03002064 if (sd->sensor == SENSOR_MI0360B)
2065 uv = uv_mi0360b;
2066 else
2067 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002068 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03002069 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002070 reg8a[i * 2] = v;
2071 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03002072 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03002073 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002074}
2075
2076static void setredblue(struct gspca_dev *gspca_dev)
2077{
2078 struct sd *sd = (struct sd *) gspca_dev;
2079
Jean-François Moine72b667e2010-10-02 04:35:25 -03002080 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03002081/* reg_w1(gspca_dev, 0x07, 32); */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002082 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002083}
2084
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002085static void setgamma(struct gspca_dev *gspca_dev)
2086{
2087 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002088 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002089 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002090 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002091 static const u8 delta[17] = {
2092 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2093 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2094 };
2095
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002096 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002097 case SENSOR_ADCM1700:
2098 gamma_base = gamma_spec_0;
2099 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002100 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03002101 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002102 case SENSOR_MT9V111:
2103 gamma_base = gamma_spec_1;
2104 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002105 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002106 gamma_base = gamma_spec_2;
2107 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002108 case SENSOR_SP80708:
2109 gamma_base = gamma_spec_3;
2110 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002111 default:
2112 gamma_base = gamma_def;
2113 break;
2114 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002115
Jean-François Moine72b667e2010-10-02 04:35:25 -03002116 val = sd->ctrls[GAMMA].val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002117 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002118 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03002119 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03002120 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2121}
2122
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002123static void setautogain(struct gspca_dev *gspca_dev)
2124{
2125 struct sd *sd = (struct sd *) gspca_dev;
2126
Jean-François Moine72b667e2010-10-02 04:35:25 -03002127 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002128 return;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002129 switch (sd->sensor) {
2130 case SENSOR_OV7630:
2131 case SENSOR_OV7648: {
2132 u8 comb;
2133
2134 if (sd->sensor == SENSOR_OV7630)
2135 comb = 0xc0;
2136 else
2137 comb = 0xa0;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002138 if (sd->ctrls[AUTOGAIN].val)
Hans de Goede1fec747c2009-06-18 06:05:07 -03002139 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002140 i2c_w1(&sd->gspca_dev, 0x13, comb);
2141 return;
2142 }
2143 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002144 if (sd->ctrls[AUTOGAIN].val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03002145 sd->ag_cnt = AG_CNT_START;
2146 else
2147 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002148}
2149
Németh Márton76ad3b62010-10-19 03:33:47 -03002150static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002151{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002152 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002153 u8 comn;
2154
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002155 switch (sd->sensor) {
2156 case SENSOR_HV7131R:
2157 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002158 if (sd->ctrls[VFLIP].val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002159 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002160 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002161 break;
2162 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002163 comn = 0x02;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002164 if (!sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002165 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002166 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002167 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002168 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002169 comn = 0x06;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002170 if (sd->ctrls[VFLIP].val)
Hans de Goedef8009522009-06-18 14:29:20 -03002171 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002172 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002173 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002174 case SENSOR_PO2030N:
2175 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2176 * (reset value: 0x0A)
2177 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2178 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2179 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2180 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2181 * bit3-0: X
2182 */
2183 comn = 0x0a;
2184 if (sd->ctrls[HFLIP].val)
2185 comn |= 0x80;
2186 if (sd->ctrls[VFLIP].val)
2187 comn |= 0x40;
2188 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2189 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002190 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002191}
2192
Jean-François Moine72b667e2010-10-02 04:35:25 -03002193static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002194{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002195 struct sd *sd = (struct sd *) gspca_dev;
2196
2197 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002198}
2199
Jean-François Moine3afef852011-01-13 06:39:11 -03002200static void setillum(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002201{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002202 struct sd *sd = (struct sd *) gspca_dev;
2203
Jean-François Moine3afef852011-01-13 06:39:11 -03002204 if (gspca_dev->ctrl_dis & (1 << ILLUM))
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002205 return;
Jean-François Moinea63d6012011-01-13 07:56:00 -03002206 switch (sd->sensor) {
2207 case SENSOR_ADCM1700:
2208 reg_w1(gspca_dev, 0x02, /* gpio */
2209 sd->ctrls[ILLUM].val ? 0x64 : 0x60);
2210 break;
2211 case SENSOR_MT9V111:
2212 if (starcam)
2213 reg_w1(gspca_dev, 0x02,
2214 sd->ctrls[ILLUM].val ?
2215 0x55 : 0x54); /* 370i */
2216 else
2217 reg_w1(gspca_dev, 0x02,
2218 sd->ctrls[ILLUM].val ?
2219 0x66 : 0x64); /* Clip */
2220 break;
2221 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002222}
2223
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002224static void setfreq(struct gspca_dev *gspca_dev)
2225{
2226 struct sd *sd = (struct sd *) gspca_dev;
2227
Jean-François Moine72b667e2010-10-02 04:35:25 -03002228 if (gspca_dev->ctrl_dis & (1 << FREQ))
Jean-Francois Moine27954932009-07-08 05:21:50 -03002229 return;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002230 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002231 u8 com8;
2232
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002233 com8 = 0xdf; /* auto gain/wb/expo */
Jean-François Moine72b667e2010-10-02 04:35:25 -03002234 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002235 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002236 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002237 break;
2238 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002239 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002240 i2c_w1(gspca_dev, 0x3b, 0x0a);
2241 break;
2242 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002243 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002244 i2c_w1(gspca_dev, 0x3b, 0x02);
2245 break;
2246 }
2247 } else {
2248 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2249
2250 /* Get reg2a / reg2d base values */
2251 switch (sd->sensor) {
2252 case SENSOR_OV7630:
2253 reg2a = 0x08;
2254 reg2d = 0x01;
2255 break;
2256 case SENSOR_OV7648:
2257 reg2a = 0x11;
2258 reg2d = 0x81;
2259 break;
2260 }
2261
Jean-François Moine72b667e2010-10-02 04:35:25 -03002262 switch (sd->ctrls[FREQ].val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002263 case 0: /* Banding filter disabled */
2264 break;
2265 case 1: /* 50 hz (filter on and framerate adj) */
2266 reg2a |= 0x80;
2267 reg2b = 0xac;
2268 reg2d |= 0x04;
2269 break;
2270 case 2: /* 60 hz (filter on, no framerate adj) */
2271 reg2a |= 0x80;
2272 reg2d |= 0x04;
2273 break;
2274 }
2275 i2c_w1(gspca_dev, 0x2a, reg2a);
2276 i2c_w1(gspca_dev, 0x2b, reg2b);
2277 i2c_w1(gspca_dev, 0x2d, reg2d);
2278 }
2279}
2280
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002281static void setjpegqual(struct gspca_dev *gspca_dev)
2282{
2283 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002284
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002285 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002286#if USB_BUF_SZ < 64
2287#error "No room enough in usb_buf for quantization table"
2288#endif
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002289 memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002290 usb_control_msg(gspca_dev->dev,
2291 usb_sndctrlpipe(gspca_dev->dev, 0),
2292 0x08,
2293 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2294 0x0100, 0,
2295 gspca_dev->usb_buf, 64,
2296 500);
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002297 memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002298 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-François Moineb96cfc33e2011-02-10 07:38:58 -03002310/* JPEG quality update */
2311/* This function is executed from a work queue. */
2312static void qual_upd(struct work_struct *work)
2313{
2314 struct sd *sd = container_of(work, struct sd, work);
2315 struct gspca_dev *gspca_dev = &sd->gspca_dev;
2316
2317 mutex_lock(&gspca_dev->usb_lock);
2318 PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality);
2319 setjpegqual(gspca_dev);
2320 mutex_unlock(&gspca_dev->usb_lock);
2321}
2322
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002323/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002324static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002325{
2326 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002327 int i;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002328 u8 reg01, reg17;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002329 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03002330 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002331 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002332 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002333 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002334 static const u8 reg9a_def[] =
2335 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2336 static const u8 reg9a_spec[] =
2337 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2338 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002339 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2340 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine646775732009-12-20 12:31:28 -03002341 static const u8 CA_adcm1700[] =
2342 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002343 static const u8 CA_po2030n[] =
2344 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002345 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002346 static const u8 CE_gc0307[] =
2347 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002348 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002349 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002350 static const u8 CE_po2030n[] =
2351 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002352
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002353 /* create the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002354 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2355 0x21); /* JPEG 422 */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002356
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002357 /* initialize the bridge */
2358 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002359
2360 /* sensor clock already enabled in sd_init */
2361 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002362 reg01 = sn9c1xx[1];
Jean-François Moine3afef852011-01-13 06:39:11 -03002363 if (sd->flags & F_PDN_INV)
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002364 reg01 ^= S_PDN_INV; /* power down inverted */
2365 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002366
2367 /* configure gpio */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002368 reg0102[0] = reg01;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002369 reg0102[1] = sn9c1xx[2];
2370 if (gspca_dev->audio)
2371 reg0102[1] |= 0x04; /* keep the audio connection */
2372 reg_w(gspca_dev, 0x01, reg0102, 2);
2373 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2374 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2375 switch (sd->sensor) {
2376 case SENSOR_GC0307:
2377 case SENSOR_OV7660:
2378 case SENSOR_PO1030:
2379 case SENSOR_PO2030N:
2380 case SENSOR_SOI768:
2381 case SENSOR_SP80708:
2382 reg9a = reg9a_spec;
2383 break;
2384 default:
2385 reg9a = reg9a_def;
2386 break;
2387 }
2388 reg_w(gspca_dev, 0x9a, reg9a, 6);
2389
2390 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2391
2392 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2393
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002394 reg17 = sn9c1xx[0x17];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002395 switch (sd->sensor) {
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002396 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002397 msleep(50); /*fixme: is it useful? */
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002398 break;
2399 case SENSOR_OM6802:
2400 msleep(10);
2401 reg_w1(gspca_dev, 0x02, 0x73);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002402 reg17 |= SEN_CLK_EN;
2403 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002404 reg_w1(gspca_dev, 0x01, 0x22);
2405 msleep(100);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002406 reg01 = SCL_SEL_OD | S_PDN_INV;
2407 reg17 &= MCK_SIZE_MASK;
2408 reg17 |= 0x04; /* clock / 4 */
2409 break;
2410 }
2411 reg01 |= SYS_SEL_48M;
2412 reg_w1(gspca_dev, 0x01, reg01);
2413 reg17 |= SEN_CLK_EN;
2414 reg_w1(gspca_dev, 0x17, reg17);
2415 reg01 &= ~S_PWR_DN; /* sensor power on */
2416 reg_w1(gspca_dev, 0x01, reg01);
2417 reg01 &= ~SYS_SEL_48M;
2418 reg_w1(gspca_dev, 0x01, reg01);
2419
2420 switch (sd->sensor) {
2421 case SENSOR_HV7131R:
2422 hv7131r_probe(gspca_dev); /*fixme: is it useful? */
2423 break;
2424 case SENSOR_OM6802:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002425 msleep(10);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002426 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002427 i2c_w8(gspca_dev, om6802_init0[0]);
2428 i2c_w8(gspca_dev, om6802_init0[1]);
2429 msleep(15);
2430 reg_w1(gspca_dev, 0x02, 0x71);
2431 msleep(150);
2432 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002433 case SENSOR_SP80708:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002434 msleep(100);
2435 reg_w1(gspca_dev, 0x02, 0x62);
2436 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002437 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002438
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002439 /* initialize the sensor */
2440 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2441
Jean-Francois Moine60017612008-07-18 08:46:19 -03002442 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2443 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2444 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2445 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2446 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002447 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002448 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2449 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002450 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002451 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2452 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002453 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002454 reg_w1(gspca_dev, 0xc6, 0x00);
2455 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002456 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002457 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2458 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002459 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002460 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2461 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002462 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002463 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002464 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002465 case SENSOR_OM6802:
2466/* case SENSOR_OV7648: * fixme: sometimes */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002467 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002468 default:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002469 reg17 |= DEF_EN;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002470 break;
2471 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002472 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002473
2474 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2475 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2476 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002477 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002478
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002479 setgamma(gspca_dev);
2480
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002481/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002482 for (i = 0; i < 8; i++)
2483 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002484 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002485 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002486 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002487 case SENSOR_SP80708:
2488 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002489 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002490 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002491 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002492 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002493 reg_w1(gspca_dev, 0x9a, 0x07);
2494 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002495 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002496 case SENSOR_OV7648:
2497 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002498 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002499 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002500 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002501 reg_w1(gspca_dev, 0x9a, 0x06);
2502 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002503 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002504 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002505 break;
2506 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002507 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002508
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002509 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002510 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2511 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2512 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002513
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002514 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002515 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002516 reg01 |= SYS_SEL_48M | V_TX_EN;
2517 reg17 &= ~MCK_SIZE_MASK;
2518 reg17 |= 0x02; /* clock / 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002519 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002520 case SENSOR_ADCM1700:
2521 init = adcm1700_sensor_param1;
Jean-Francois Moine646775732009-12-20 12:31:28 -03002522 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002523 case SENSOR_GC0307:
2524 init = gc0307_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002525 break;
2526 case SENSOR_HV7131R:
2527 case SENSOR_MI0360:
2528 if (mode)
2529 reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */
2530 else
2531 reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */
2532 reg17 &= ~MCK_SIZE_MASK;
2533 reg17 |= 0x01; /* clock / 1 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002534 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002535 case SENSOR_MI0360B:
2536 init = mi0360b_sensor_param1;
Jean-François Moinea067db82010-10-01 07:51:24 -03002537 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002538 case SENSOR_MO4000:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002539 if (mode) { /* if 320x240 */
2540 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2541 reg17 &= ~MCK_SIZE_MASK;
2542 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002543 }
2544 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002545 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002546 init = mt9v111_sensor_param1;
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002547 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002548 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002549 init = om6802_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002550 if (!mode) { /* if 640x480 */
2551 reg17 &= ~MCK_SIZE_MASK;
Jean-François Moineaa777a82010-12-28 07:39:13 -03002552 reg17 |= 0x04; /* clock / 4 */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002553 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002554 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002555 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002556 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002557 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002558 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002559 init = ov7648_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002560 reg17 &= ~MCK_SIZE_MASK;
2561 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002562 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002563 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002564 init = ov7660_sensor_param1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002565 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002566 case SENSOR_PO1030:
2567 init = po1030_sensor_param1;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002568 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002569 case SENSOR_PO2030N:
2570 init = po2030n_sensor_param1;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002571 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002572 case SENSOR_SOI768:
2573 init = soi768_sensor_param1;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002574 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002575 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002576 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002577 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002578 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002579
2580 /* more sensor initialization - param1 */
2581 if (init != NULL) {
2582 i2c_w_seq(gspca_dev, init);
2583/* init = NULL; */
2584 }
2585
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002586 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002587 switch (sd->sensor) {
2588 case SENSOR_ADCM1700:
2589 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002590 case SENSOR_SOI768:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002591 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002592 break;
2593 case SENSOR_PO2030N:
2594 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2595 break;
2596 default:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002597 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002598 break;
2599 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002600 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002601 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002602 case SENSOR_OV7630:
2603 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002604 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002605 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002606 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002607 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002608 case SENSOR_GC0307:
2609 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2610 break;
2611 case SENSOR_PO2030N:
2612 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2613 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002614 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002615 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002616 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2617 break;
2618 }
2619
2620 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002621 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2622 reg_w1(gspca_dev, 0x18, sd->reg18);
2623 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002624
Jean-Francois Moine60017612008-07-18 08:46:19 -03002625 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002626 reg_w1(gspca_dev, 0x01, reg01);
2627 sd->reg01 = reg01;
2628 sd->reg17 = reg17;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002629
Németh Márton76ad3b62010-10-19 03:33:47 -03002630 sethvflip(gspca_dev);
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03002631 setbrightness(gspca_dev);
2632 setcontrast(gspca_dev);
Jean-François Moinefff2f702010-04-25 14:31:05 -03002633 setcolors(gspca_dev);
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002634 setautogain(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002635 setfreq(gspca_dev);
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002636
2637 sd->pktsz = sd->npkt = 0;
2638 sd->nchg = sd->short_mark = 0;
2639 sd->work_thread = create_singlethread_workqueue(MODULE_NAME);
2640
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002641 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002642}
2643
2644static void sd_stopN(struct gspca_dev *gspca_dev)
2645{
2646 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002647 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002648 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002649 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002650 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002651 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002652 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002653 static const u8 stopsoi768[] =
2654 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002655 u8 reg01;
2656 u8 reg17;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002657
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002658 reg01 = sd->reg01;
2659 reg17 = sd->reg17 & ~SEN_CLK_EN;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002660 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002661 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002662 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002663 case SENSOR_PO2030N:
2664 case SENSOR_SP80708:
2665 reg01 |= LED;
2666 reg_w1(gspca_dev, 0x01, reg01);
2667 reg01 &= ~(LED | V_TX_EN);
2668 reg_w1(gspca_dev, 0x01, reg01);
2669/* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002670 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002671 case SENSOR_HV7131R:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002672 reg01 &= ~V_TX_EN;
2673 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002674 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002675 break;
2676 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002677 case SENSOR_MI0360B:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002678 reg01 &= ~V_TX_EN;
2679 reg_w1(gspca_dev, 0x01, reg01);
2680/* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002681 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002682 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002683 case SENSOR_MT9V111:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002684 case SENSOR_OM6802:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002685 case SENSOR_PO1030:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002686 reg01 &= ~V_TX_EN;
2687 reg_w1(gspca_dev, 0x01, reg01);
2688 break;
2689 case SENSOR_OV7630:
2690 case SENSOR_OV7648:
2691 reg01 &= ~V_TX_EN;
2692 reg_w1(gspca_dev, 0x01, reg01);
2693 i2c_w8(gspca_dev, stopov7648);
2694 break;
2695 case SENSOR_OV7660:
2696 reg01 &= ~V_TX_EN;
2697 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002698 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002699 case SENSOR_SOI768:
2700 i2c_w8(gspca_dev, stopsoi768);
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002701 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002702 }
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002703
2704 reg01 |= SCL_SEL_OD;
2705 reg_w1(gspca_dev, 0x01, reg01);
2706 reg01 |= S_PWR_DN; /* sensor power down */
2707 reg_w1(gspca_dev, 0x01, reg01);
2708 reg_w1(gspca_dev, 0x17, reg17);
2709 reg01 &= ~SYS_SEL_48M; /* clock 24MHz */
2710 reg_w1(gspca_dev, 0x01, reg01);
2711 reg01 |= LED;
2712 reg_w1(gspca_dev, 0x01, reg01);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002713 /* Don't disable sensor clock as that disables the button on the cam */
2714 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002715}
2716
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002717/* called on streamoff with alt==0 and on disconnect */
2718/* the usb_lock is held at entry - restore on exit */
2719static void sd_stop0(struct gspca_dev *gspca_dev)
2720{
2721 struct sd *sd = (struct sd *) gspca_dev;
2722
2723 if (sd->work_thread != NULL) {
2724 mutex_unlock(&gspca_dev->usb_lock);
2725 destroy_workqueue(sd->work_thread);
2726 mutex_lock(&gspca_dev->usb_lock);
2727 sd->work_thread = NULL;
2728 }
2729}
2730
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002731static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002732{
2733 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002734 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002735 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002736 u8 luma_mean = 130;
2737 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002738
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002739 /* Thanks S., without your advice, autobright should not work :) */
2740 if (sd->ag_cnt < 0)
2741 return;
2742 if (--sd->ag_cnt >= 0)
2743 return;
2744 sd->ag_cnt = AG_CNT_START;
2745
2746 delta = atomic_read(&sd->avg_lum);
2747 PDEBUG(D_FRAM, "mean lum %d", delta);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002748 if (delta < luma_mean - luma_delta ||
2749 delta > luma_mean + luma_delta) {
2750 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002751 case SENSOR_GC0307:
2752 expotimes = sd->exposure;
2753 expotimes += (luma_mean - delta) >> 6;
2754 if (expotimes < 0)
2755 expotimes = 0;
2756 sd->exposure = setexposure(gspca_dev,
2757 (unsigned int) expotimes);
2758 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002759 case SENSOR_HV7131R:
2760 expotimes = sd->exposure >> 8;
2761 expotimes += (luma_mean - delta) >> 4;
2762 if (expotimes < 0)
2763 expotimes = 0;
2764 sd->exposure = setexposure(gspca_dev,
2765 (unsigned int) (expotimes << 8));
2766 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002767 case SENSOR_OM6802:
2768 expotimes = sd->exposure;
2769 expotimes += (luma_mean - delta) >> 2;
2770 if (expotimes < 0)
2771 expotimes = 0;
2772 sd->exposure = setexposure(gspca_dev,
2773 (unsigned int) expotimes);
2774 setredblue(gspca_dev);
2775 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002776 default:
2777/* case SENSOR_MO4000: */
2778/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002779/* case SENSOR_MI0360B: */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002780/* case SENSOR_MT9V111: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002781 expotimes = sd->exposure;
2782 expotimes += (luma_mean - delta) >> 6;
2783 if (expotimes < 0)
2784 expotimes = 0;
2785 sd->exposure = setexposure(gspca_dev,
2786 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002787 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002788 break;
2789 }
2790 }
2791}
2792
Jean-François Moine0f77f402011-02-10 07:01:30 -03002793/* set the average luminosity from an isoc marker */
2794static void set_lum(struct sd *sd,
2795 u8 *data)
2796{
2797 int avg_lum;
2798
2799 /* w0 w1 w2
2800 * w3 w4 w5
2801 * w6 w7 w8
2802 */
2803 avg_lum = (data[27] << 8) + data[28] /* w3 */
2804
2805 + (data[31] << 8) + data[32] /* w5 */
2806
2807 + (data[23] << 8) + data[24] /* w1 */
2808
2809 + (data[35] << 8) + data[36] /* w7 */
2810
2811 + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */
2812 avg_lum >>= 10;
2813 atomic_set(&sd->avg_lum, avg_lum);
2814}
2815
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002816/* scan the URB packets */
2817/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002818static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002819 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002820 int len) /* iso packet length */
2821{
2822 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002823 int i, new_qual;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002824
Jean-François Moinea4a30762011-02-10 07:15:24 -03002825 /*
2826 * A frame ends on the marker
2827 * ff ff 00 c4 c4 96 ..
2828 * which is 62 bytes long and is followed by various information
2829 * including statuses and luminosity.
2830 *
2831 * A marker may be splitted on two packets.
2832 *
2833 * The 6th byte of a marker contains the bits:
2834 * 0x08: USB full
2835 * 0xc0: frame sequence
2836 * When the bit 'USB full' is set, the frame must be discarded;
2837 * this is also the case when the 2 bytes before the marker are
2838 * not the JPEG end of frame ('ff d9').
2839 */
2840
2841/*fixme: assumption about the following code:
2842 * - there can be only one marker in a packet
2843 */
2844
2845 /* skip the remaining bytes of a short marker */
2846 i = sd->short_mark;
2847 if (i != 0) {
2848 sd->short_mark = 0;
2849 if (i < 0 /* if 'ff' at end of previous packet */
2850 && data[0] == 0xff
2851 && data[1] == 0x00)
2852 goto marker_found;
2853 if (data[0] == 0xff && data[1] == 0xff) {
2854 i = 0;
2855 goto marker_found;
2856 }
2857 len -= i;
2858 if (len <= 0)
2859 return;
2860 data += i;
2861 }
2862
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002863 /* count the packets and their size */
2864 sd->npkt++;
2865 sd->pktsz += len;
2866
Jean-François Moinea4a30762011-02-10 07:15:24 -03002867 /* search backwards if there is a marker in the packet */
2868 for (i = len - 1; --i >= 0; ) {
2869 if (data[i] != 0xff) {
2870 i--;
2871 continue;
2872 }
2873 if (data[i + 1] == 0xff) {
2874
2875 /* (there may be 'ff ff' inside a marker) */
2876 if (i + 2 >= len || data[i + 2] == 0x00)
2877 goto marker_found;
2878 }
2879 }
2880
2881 /* no marker found */
2882 /* add the JPEG header if first fragment */
2883 if (data[len - 1] == 0xff)
2884 sd->short_mark = -1;
2885 if (gspca_dev->last_packet_type == LAST_PACKET)
Jean-François Moinea95bd642010-10-01 07:54:30 -03002886 gspca_frame_add(gspca_dev, FIRST_PACKET,
2887 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-François Moinea95bd642010-10-01 07:54:30 -03002888 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-François Moinea4a30762011-02-10 07:15:24 -03002889 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002890
Jean-François Moinea4a30762011-02-10 07:15:24 -03002891 /* marker found */
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002892 /* if some error, discard the frame and decrease the quality */
Jean-François Moinea4a30762011-02-10 07:15:24 -03002893marker_found:
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002894 new_qual = 0;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002895 if (i > 2) {
2896 if (data[i - 2] != 0xff || data[i - 1] != 0xd9) {
2897 gspca_dev->last_packet_type = DISCARD_PACKET;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002898 new_qual = -3;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002899 }
2900 } else if (i + 6 < len) {
2901 if (data[i + 6] & 0x08) {
2902 gspca_dev->last_packet_type = DISCARD_PACKET;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002903 new_qual = -5;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002904 }
2905 }
Jean-François Moinea95bd642010-10-01 07:54:30 -03002906
Jean-François Moinea4a30762011-02-10 07:15:24 -03002907 gspca_frame_add(gspca_dev, LAST_PACKET, data, i);
2908
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002909 /* compute the filling rate and a new JPEG quality */
2910 if (new_qual == 0) {
2911 int r;
2912
2913 r = (sd->pktsz * 100) /
2914 (sd->npkt *
2915 gspca_dev->urb[0]->iso_frame_desc[0].length);
2916 if (r >= 85)
2917 new_qual = -3;
2918 else if (r < 75)
2919 new_qual = 2;
2920 }
2921 if (new_qual != 0) {
2922 sd->nchg += new_qual;
2923 if (sd->nchg < -6 || sd->nchg >= 12) {
2924 sd->nchg = 0;
2925 new_qual += sd->quality;
2926 if (new_qual < QUALITY_MIN)
2927 new_qual = QUALITY_MIN;
2928 else if (new_qual > QUALITY_MAX)
2929 new_qual = QUALITY_MAX;
2930 if (new_qual != sd->quality) {
2931 sd->quality = new_qual;
2932 queue_work(sd->work_thread, &sd->work);
2933 }
2934 }
2935 } else {
2936 sd->nchg = 0;
2937 }
2938 sd->pktsz = sd->npkt = 0;
2939
Jean-François Moinea4a30762011-02-10 07:15:24 -03002940 /* if the marker is smaller than 62 bytes,
2941 * memorize the number of bytes to skip in the next packet */
2942 if (i + 62 > len) { /* no more usable data */
2943 sd->short_mark = i + 62 - len;
2944 return;
2945 }
Jean-François Moine0f77f402011-02-10 07:01:30 -03002946 if (sd->ag_cnt >= 0)
Jean-François Moinea4a30762011-02-10 07:15:24 -03002947 set_lum(sd, data + i);
2948
2949 /* if more data, start a new frame */
2950 i += 62;
2951 if (i < len) {
2952 data += i;
2953 len -= i;
2954 gspca_frame_add(gspca_dev, FIRST_PACKET,
2955 sd->jpeg_hdr, JPEG_HDR_SZ);
2956 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2957 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002958}
2959
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03002960static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2961 struct v4l2_jpegcompression *jcomp)
2962{
2963 struct sd *sd = (struct sd *) gspca_dev;
2964
2965 memset(jcomp, 0, sizeof *jcomp);
2966 jcomp->quality = sd->quality;
2967 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2968 | V4L2_JPEG_MARKER_DQT;
2969 return 0;
2970}
2971
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002972static int sd_querymenu(struct gspca_dev *gspca_dev,
2973 struct v4l2_querymenu *menu)
2974{
2975 switch (menu->id) {
2976 case V4L2_CID_POWER_LINE_FREQUENCY:
2977 switch (menu->index) {
2978 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2979 strcpy((char *) menu->name, "NoFliker");
2980 return 0;
2981 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2982 strcpy((char *) menu->name, "50 Hz");
2983 return 0;
2984 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2985 strcpy((char *) menu->name, "60 Hz");
2986 return 0;
2987 }
2988 break;
2989 }
2990 return -EINVAL;
2991}
2992
Jean-François Moine28566432010-10-01 07:33:26 -03002993#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002994static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2995 u8 *data, /* interrupt packet data */
2996 int len) /* interrupt packet length */
2997{
2998 int ret = -EINVAL;
2999
3000 if (len == 1 && data[0] == 1) {
3001 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
3002 input_sync(gspca_dev->input_dev);
3003 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
3004 input_sync(gspca_dev->input_dev);
3005 ret = 0;
3006 }
3007
3008 return ret;
3009}
3010#endif
3011
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003012/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03003013static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003014 .name = MODULE_NAME,
3015 .ctrls = sd_ctrls,
Jean-François Moine72b667e2010-10-02 04:35:25 -03003016 .nctrls = NCTRLS,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003017 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03003018 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003019 .start = sd_start,
3020 .stopN = sd_stopN,
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03003021 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003022 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03003023 .dq_callback = do_autogain,
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03003024 .get_jcomp = sd_get_jcomp,
Hans de Goede37c6dbe2009-06-18 07:35:36 -03003025 .querymenu = sd_querymenu,
Jean-François Moine28566432010-10-01 07:33:26 -03003026#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
Hans de Goede9712a8b2010-01-31 12:54:29 -03003027 .int_pkt_scan = sd_int_pkt_scan,
3028#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003029};
3030
3031/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003032#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03003033 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03003034 | (SENSOR_ ## sensor << 8)
3035#define BSF(bridge, sensor, flags) \
3036 .driver_info = (BRIDGE_ ## bridge << 16) \
3037 | (SENSOR_ ## sensor << 8) \
3038 | (flags)
Jean-François Moine95c967c2011-01-13 05:20:29 -03003039static const struct usb_device_id device_table[] = {
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003040 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
3041 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-François Moine3afef852011-01-13 06:39:11 -03003042 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)},
3043 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003044 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
3045 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
3046 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
3047 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
3048 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
3049/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
3050 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
3051/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
3052/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
3053 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3054/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
Jean-François Moine3afef852011-01-13 06:39:11 -03003055 {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003056 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003057/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3058/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3059/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03003060 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003061 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
3062/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
3063/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03003064/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003065 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003066 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3067 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003068 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03003069 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003070/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3071 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3072 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3073 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3074 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3075/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3076/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3077/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3078 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03003079/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03003080 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03003081 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003082 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3083 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3084/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003085 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03003086 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003087/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3088 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3089 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003090 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003091 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3092 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03003093 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03003094 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03003095 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3096 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-François Moinea63d6012011-01-13 07:56:00 -03003097 {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)},
Hans de Goedee48d38f2011-01-06 16:21:57 -03003098/* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003099 {}
3100};
3101MODULE_DEVICE_TABLE(usb, device_table);
3102
3103/* -- device connect -- */
3104static int sd_probe(struct usb_interface *intf,
3105 const struct usb_device_id *id)
3106{
3107 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3108 THIS_MODULE);
3109}
3110
3111static struct usb_driver sd_driver = {
3112 .name = MODULE_NAME,
3113 .id_table = device_table,
3114 .probe = sd_probe,
3115 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03003116#ifdef CONFIG_PM
3117 .suspend = gspca_suspend,
3118 .resume = gspca_resume,
3119#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003120};
3121
3122/* -- module insert / remove -- */
3123static int __init sd_mod_init(void)
3124{
Jean-François Moine54826432010-09-13 04:53:03 -03003125 return usb_register(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003126}
3127static void __exit sd_mod_exit(void)
3128{
3129 usb_deregister(&sd_driver);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03003130}
3131
3132module_init(sd_mod_init);
3133module_exit(sd_mod_exit);
Jean-François Moine3afef852011-01-13 06:39:11 -03003134
3135module_param(starcam, int, 0644);
3136MODULE_PARM_DESC(starcam,
3137 "StarCam model. 0: Clip, 1: 370i");