blob: 50a6c8425827f89ee8c73b193ce57c4eeeda8fb4 [file] [log] [blame]
Thomas Gleixnerfd9871f2019-05-19 15:51:54 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002/*
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03003 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03004 *
Jean-François Moineb813b0c2011-08-10 05:54:34 -03005 * Copyright (C) 2009-2011 Jean-François Moine <http://moinejf.free.fr>
Jean-Francois Moine5b34e3e2009-11-02 10:00:48 -03006 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03007 */
8
Joe Perches133a9fe2011-08-21 19:56:57 -03009#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030011#define MODULE_NAME "sonixj"
12
Hans de Goede9712a8b2010-01-31 12:54:29 -030013#include <linux/input.h>
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030014#include "gspca.h"
15#include "jpeg.h"
16
Jean-François Moine27c6f9e2010-04-02 06:59:13 -030017MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030018MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
19MODULE_LICENSE("GPL");
20
21/* specific webcam descriptor */
22struct sd {
23 struct gspca_dev gspca_dev; /* !! must be the first item */
24
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -030025 atomic_t avg_lum;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -030026 struct v4l2_ctrl *brightness;
27 struct v4l2_ctrl *contrast;
28 struct v4l2_ctrl *saturation;
29 struct { /* red/blue balance control cluster */
30 struct v4l2_ctrl *red_bal;
31 struct v4l2_ctrl *blue_bal;
32 };
33 struct { /* hflip/vflip control cluster */
34 struct v4l2_ctrl *vflip;
35 struct v4l2_ctrl *hflip;
36 };
37 struct v4l2_ctrl *gamma;
38 struct v4l2_ctrl *illum;
39 struct v4l2_ctrl *sharpness;
40 struct v4l2_ctrl *freq;
Jean-Francois Moine98819182009-01-19 07:37:33 -030041 u32 exposure;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030042
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -030043 struct work_struct work;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -030044
45 u32 pktsz; /* (used by pkt_scan) */
46 u16 npkt;
Hans Petter Selasky67e27c742011-05-23 08:09:18 -030047 s8 nchg;
Jean-François Moinea4a30762011-02-10 07:15:24 -030048 s8 short_mark;
49
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030050 u8 quality; /* image quality */
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -030051#define QUALITY_MIN 25
52#define QUALITY_MAX 90
53#define QUALITY_DEF 70
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030054
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -030055 u8 reg01;
56 u8 reg17;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030057 u8 reg18;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -030058 u8 flags;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030059
Jean-Francois Moine98819182009-01-19 07:37:33 -030060 s8 ag_cnt;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030061#define AG_CNT_START 13
62
Jean-Francois Moine98819182009-01-19 07:37:33 -030063 u8 bridge;
Hans de Goede3647fea2008-07-15 05:36:30 -030064#define BRIDGE_SN9C102P 0
65#define BRIDGE_SN9C105 1
66#define BRIDGE_SN9C110 2
67#define BRIDGE_SN9C120 3
Jean-Francois Moine98819182009-01-19 07:37:33 -030068 u8 sensor; /* Type of image sensor chip */
Jean-François Moine11ce8842010-07-26 06:39:40 -030069 u8 i2c_addr;
70
71 u8 jpeg_hdr[JPEG_HDR_SZ];
72};
73enum sensors {
Jean-François Moine9c33afc2010-03-17 15:25:32 -030074 SENSOR_ADCM1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030075 SENSOR_GC0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030076 SENSOR_HV7131R,
77 SENSOR_MI0360,
Jean-François Moinea067db82010-10-01 07:51:24 -030078 SENSOR_MI0360B,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030079 SENSOR_MO4000,
80 SENSOR_MT9V111,
81 SENSOR_OM6802,
82 SENSOR_OV7630,
83 SENSOR_OV7648,
84 SENSOR_OV7660,
85 SENSOR_PO1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -030086 SENSOR_PO2030N,
Jean-François Moine03ed2a12010-04-25 14:45:43 -030087 SENSOR_SOI768,
Jean-François Moine9c33afc2010-03-17 15:25:32 -030088 SENSOR_SP80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030089};
90
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -030091static void qual_upd(struct work_struct *work);
92
Jean-Francois Moineb2272a42010-12-14 16:16:16 -030093/* device flags */
Jean-François Moine3afef852011-01-13 06:39:11 -030094#define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */
95#define F_ILLUM 0x02 /* presence of illuminator */
Jean-Francois Moineb2272a42010-12-14 16:16:16 -030096
Jean-Francois Moine4fd350ee2010-12-14 16:16:58 -030097/* sn9c1xx definitions */
98/* register 0x01 */
99#define S_PWR_DN 0x01 /* sensor power down */
100#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
101#define V_TX_EN 0x04 /* video transfer enable */
102#define LED 0x08 /* output to pin LED */
103#define SCL_SEL_OD 0x20 /* open-drain mode */
104#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
105/* register 0x17 */
106#define MCK_SIZE_MASK 0x1f /* sensor master clock */
107#define SEN_CLK_EN 0x20 /* enable sensor clock */
108#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
109
Jean-Francois Moine646775732009-12-20 12:31:28 -0300110static const struct v4l2_pix_format cif_mode[] = {
111 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
112 .bytesperline = 352,
113 .sizeimage = 352 * 288 * 4 / 8 + 590,
114 .colorspace = V4L2_COLORSPACE_JPEG,
115 .priv = 0},
116};
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300117static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300118 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
119 .bytesperline = 160,
Jean-Francois Moine5d052942008-09-03 16:48:09 -0300120 .sizeimage = 160 * 120 * 4 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300121 .colorspace = V4L2_COLORSPACE_JPEG,
122 .priv = 2},
123 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
124 .bytesperline = 320,
125 .sizeimage = 320 * 240 * 3 / 8 + 590,
126 .colorspace = V4L2_COLORSPACE_JPEG,
127 .priv = 1},
128 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
129 .bytesperline = 640,
Hans de Goedea5d1cc32009-06-18 06:03:20 -0300130 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
131 .sizeimage = 640 * 480 * 3 / 4 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300132 .colorspace = V4L2_COLORSPACE_JPEG,
133 .priv = 0},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300134};
135
Jean-Francois Moine646775732009-12-20 12:31:28 -0300136static const u8 sn_adcm1700[0x1c] = {
137/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300138 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine646775732009-12-20 12:31:28 -0300139/* reg8 reg9 rega regb regc regd rege regf */
140 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
142 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
143/* reg18 reg19 reg1a reg1b */
144 0x06, 0x00, 0x00, 0x00
145};
146
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300147static const u8 sn_gc0307[0x1c] = {
148/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
149 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
150/* reg8 reg9 rega regb regc regd rege regf */
151 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
153 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
154/* reg18 reg19 reg1a reg1b */
155 0x06, 0x00, 0x00, 0x00
156};
157
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300158static const u8 sn_hv7131[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300159/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine19697b52010-07-14 06:33:51 -0300160 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300161/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300162 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300163/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
164 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300165/* reg18 reg19 reg1a reg1b */
166 0x0a, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300167};
168
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300169static const u8 sn_mi0360[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300170/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine20c957b2011-02-10 13:18:58 -0300171 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300172/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300173 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300174/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
175 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300176/* reg18 reg19 reg1a reg1b */
177 0x06, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300178};
179
Jean-François Moinea067db82010-10-01 07:51:24 -0300180static const u8 sn_mi0360b[0x1c] = {
181/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
182 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
183/* reg8 reg9 rega regb regc regd rege regf */
184 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
186 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
187/* reg18 reg19 reg1a reg1b */
188 0x06, 0x00, 0x00, 0x00
189};
190
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300191static const u8 sn_mo4000[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300192/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300193 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300194/* reg8 reg9 rega regb regc regd rege regf */
195 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
197 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300198/* reg18 reg19 reg1a reg1b */
199 0x08, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300200};
201
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300202static const u8 sn_mt9v111[0x1c] = {
203/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
204 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
205/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300206 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300207/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
208 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
209/* reg18 reg19 reg1a reg1b */
210 0x06, 0x00, 0x00, 0x00
211};
212
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300213static const u8 sn_om6802[0x1c] = {
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300214/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Amauri Magagna46b4f2a2009-10-17 07:21:29 -0300215 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300216/* reg8 reg9 rega regb regc regd rege regf */
217 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
218/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
219 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300220/* reg18 reg19 reg1a reg1b */
221 0x05, 0x00, 0x00, 0x00
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300222};
223
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300224static const u8 sn_ov7630[0x1c] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300225/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-François Moine0a85c742010-04-25 14:33:31 -0300226 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300227/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300228 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300229/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
230 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300231/* reg18 reg19 reg1a reg1b */
232 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300233};
234
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300235static const u8 sn_ov7648[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300236/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300237 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300238/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300239 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300240/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300241 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300242/* reg18 reg19 reg1a reg1b */
243 0x0b, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300244};
245
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300246static const u8 sn_ov7660[0x1c] = {
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300247/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300248 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300249/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -0300250 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -0300251/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
252 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300253/* reg18 reg19 reg1a reg1b */
254 0x07, 0x00, 0x00, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300255};
256
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300257static const u8 sn_po1030[0x1c] = {
258/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
259 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
260/* reg8 reg9 rega regb regc regd rege regf */
261 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
263 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
264/* reg18 reg19 reg1a reg1b */
265 0x07, 0x00, 0x00, 0x00
266};
267
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300268static const u8 sn_po2030n[0x1c] = {
269/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
270 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
271/* reg8 reg9 rega regb regc regd rege regf */
272 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
274 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
275/* reg18 reg19 reg1a reg1b */
276 0x07, 0x00, 0x00, 0x00
277};
278
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300279static const u8 sn_soi768[0x1c] = {
280/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
281 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
282/* reg8 reg9 rega regb regc regd rege regf */
283 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
285 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
286/* reg18 reg19 reg1a reg1b */
287 0x07, 0x00, 0x00, 0x00
288};
289
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300290static const u8 sn_sp80708[0x1c] = {
291/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
292 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
293/* reg8 reg9 rega regb regc regd rege regf */
Jean-Francois Moine98941e42009-11-02 09:56:59 -0300294 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -0300295/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
296 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
297/* reg18 reg19 reg1a reg1b */
298 0x07, 0x00, 0x00, 0x00
299};
300
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300301/* sequence specific to the sensors - !! index = SENSOR_xxx */
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300302static const u8 *sn_tb[] = {
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300303[SENSOR_ADCM1700] = sn_adcm1700,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300304[SENSOR_GC0307] = sn_gc0307,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300305[SENSOR_HV7131R] = sn_hv7131,
306[SENSOR_MI0360] = sn_mi0360,
Jean-François Moinea067db82010-10-01 07:51:24 -0300307[SENSOR_MI0360B] = sn_mi0360b,
Jean-François Moine9c33afc2010-03-17 15:25:32 -0300308[SENSOR_MO4000] = sn_mo4000,
309[SENSOR_MT9V111] = sn_mt9v111,
310[SENSOR_OM6802] = sn_om6802,
311[SENSOR_OV7630] = sn_ov7630,
312[SENSOR_OV7648] = sn_ov7648,
313[SENSOR_OV7660] = sn_ov7660,
314[SENSOR_PO1030] = sn_po1030,
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300315[SENSOR_PO2030N] = sn_po2030n,
Jean-François Moine03ed2a12010-04-25 14:45:43 -0300316[SENSOR_SOI768] = sn_soi768,
317[SENSOR_SP80708] = sn_sp80708,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300318};
319
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300320/* default gamma table */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300321static const u8 gamma_def[17] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300322 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
323 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
324};
Jean-Francois Moine646775732009-12-20 12:31:28 -0300325/* gamma for sensor ADCM1700 */
326static const u8 gamma_spec_0[17] = {
327 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
328 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
329};
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300330/* gamma for sensors HV7131R and MT9V111 */
331static const u8 gamma_spec_1[17] = {
332 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
333 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
334};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300335/* gamma for sensor GC0307 */
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300336static const u8 gamma_spec_2[17] = {
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300337 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
338 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
339};
340/* gamma for sensor SP80708 */
341static const u8 gamma_spec_3[17] = {
Jean-Francois Moineb083b922009-02-01 14:20:07 -0300342 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
343 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
344};
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -0300345
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300346/* color matrix and offsets */
Jean-Francois Moine98819182009-01-19 07:37:33 -0300347static const u8 reg84[] = {
Jean-Francois Moine803f9cc2008-10-04 14:17:02 -0300348 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
349 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
350 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
351 0x00, 0x00, 0x00 /* YUV offsets */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300352};
Németh Mártonccbc5df2010-10-18 07:00:48 -0300353
354#define DELAY 0xdd
355
Jean-Francois Moine646775732009-12-20 12:31:28 -0300356static const u8 adcm1700_sensor_init[][8] = {
357 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300358 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300359 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300360 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300361 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300362 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
363 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
364 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
365 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
366 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300367 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300368 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300369 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300370 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
371 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
372 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
373 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
374 {}
375};
376static const u8 adcm1700_sensor_param1[][8] = {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300377 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300378 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
379
380 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
381 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
382 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
383 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300384 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
Jean-Francois Moine646775732009-12-20 12:31:28 -0300385
Jean-Francois Moine878b35a2009-12-30 04:53:07 -0300386 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
387 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
388 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
389 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
Jean-Francois Moine646775732009-12-20 12:31:28 -0300390 {}
391};
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300392static const u8 gc0307_sensor_init[][8] = {
393 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
394 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
395 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
396 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
397 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
398 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
399 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
400 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
401 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
402 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
403 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
404 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
405 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
406 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
407 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
408 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
409 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
410 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
411 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
412 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300413 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300414 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
415 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
416 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
417 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
418 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
419 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
420 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
421 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
422 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
423 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
424 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
425 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
426 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
427 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
428 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
429 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
430 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
431 {}
432};
433static const u8 gc0307_sensor_param1[][8] = {
434 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
435 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
436 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
437 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
438/*param3*/
439 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
440 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300441 {}
442};
443
Jean-Francois Moine98819182009-01-19 07:37:33 -0300444static const u8 hv7131r_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300445 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
446 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
447 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
448/* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
449 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
450 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
451/* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300452
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300453 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
454 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
455 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
456 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
457 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
458 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
459 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
460 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300461
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300462 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
463 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -0300464 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300465 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
466 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300467
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300468 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
469 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
470 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
471 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
472 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine23a98272009-11-02 09:10:25 -0300473 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
474 /* set sensor clock */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300475 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300476};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300477static const u8 mi0360_sensor_init[][8] = {
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300478 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
Jean-Francois Moine98819182009-01-19 07:37:33 -0300479 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300480 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300481 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
482 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
483 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
484 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
485 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
486 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
487 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
488 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
489 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
490 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
491 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
492 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
493 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
494 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
495 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
496 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
497 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
498 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
499 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
Jean-François Moineb813b0c2011-08-10 05:54:34 -0300500 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300501 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
502 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
503 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
504 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
505 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
506 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
507 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
508 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
509 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
510 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300511
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300512 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
513 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
514 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
515 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
516 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300517
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300518 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
519 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
520 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
521 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300522
Jean-Francois Moine8c2ba442009-01-13 05:55:40 -0300523 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
524 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
525/* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
526/* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
527 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
528 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300529 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300530};
Jean-François Moinea067db82010-10-01 07:51:24 -0300531static const u8 mi0360b_sensor_init[][8] = {
532 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
533 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300534 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300535 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300536 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
Jean-François Moinea067db82010-10-01 07:51:24 -0300537 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
538 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
539 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
540 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
541 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
542 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
543 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
544 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
545 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
546 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
547 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
548 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
549 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
550 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
551 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
552 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
553 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
554 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
555 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
556 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
557 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
558 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
559 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
560 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
561 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
562 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
563 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
564 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
565 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
566 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
567
568 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
569 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
570 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
571 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
572 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
573 {}
574};
575static const u8 mi0360b_sensor_param1[][8] = {
576 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
577 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
578 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
579 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
580
581 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
582 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
583 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
584 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
585 {}
586};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300587static const u8 mo4000_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300588 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
589 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
590 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
591 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
592 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
593 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
594 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
595 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
596 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
598 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
599 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
600 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
601 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
602 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
603 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
604 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
605 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
606 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
607 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300608 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300609};
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300610static const u8 mt9v111_sensor_init[][8] = {
611 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300612 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300613 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
614 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
615 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
616 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
617 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
618 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
619 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
620 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
621 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
622 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
623 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
624 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
625 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
626 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
627 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
628 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300629 {}
630};
631static const u8 mt9v111_sensor_param1[][8] = {
Jean-François Moine80463222011-02-10 07:44:59 -0300632 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xad, 0x10}, /* G1 and B gains */
633 {0xd1, 0x5c, 0x2d, 0x00, 0xad, 0x00, 0x33, 0x10}, /* R and G2 gains */
634 {0xb1, 0x5c, 0x06, 0x00, 0x40, 0x00, 0x00, 0x10}, /* vert blanking */
635 {0xb1, 0x5c, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10}, /* horiz blanking */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -0300636 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
637 {}
638};
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300639static const u8 om6802_init0[2][8] = {
640/*fixme: variable*/
641 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
643};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300644static const u8 om6802_sensor_init[][8] = {
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300645 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
646 /* factory mode */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300647 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300648 /* output raw RGB */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300649 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300650/* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
651 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300652 /* auto-exposure speed (0) / white balance mode (auto RGB) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300653/* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
654 * set color mode */
655/* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
656 * max AGC value in AE */
657/* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
658 * preset AGC */
659/* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
660 * preset brightness */
661/* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
662 * preset contrast */
663/* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
664 * preset gamma */
665 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -0300666 /* luminance mode (0x4f -> AutoExpo on) */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300667 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
668 /* preset shutter */
669/* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
670 * auto frame rate */
671/* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300672 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
673 {}
674};
675static const u8 om6802_sensor_param1[][8] = {
676 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
677 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
678 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
679 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moined2d16e92008-09-03 16:47:23 -0300680 {}
681};
Jean-Francois Moine98819182009-01-19 07:37:33 -0300682static const u8 ov7630_sensor_init[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300683 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
684 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300685 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300686 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
687 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300688 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300689 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300690/* win: i2c_r from 00 to 80 */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300691 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
692 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
Hans de Goedecc7b5b52009-06-18 05:14:42 -0300693/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
694 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
695 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300696 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
697 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
698 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
699 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
700 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
701 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
702 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
703 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
704 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
705 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
706 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
708 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
709 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
710 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
711 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
712 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
713 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
714 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
715 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
716 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
717 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
718 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinebdd2b932010-04-25 14:23:39 -0300719 {}
720};
721static const u8 ov7630_sensor_param1[][8] = {
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300722 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
723 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
724/*fixme: + 0x12, 0x04*/
Jean-Francois Moine6c862742008-09-08 04:57:26 -0300725/* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
726 * set by setvflip */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300727 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
728 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300730/* */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300731/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
732/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -0300733/* */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300734 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine91de65a2008-09-03 17:12:18 -0300735/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -0300736 {}
737};
Jean-Francois Moine62703302008-11-11 08:42:56 -0300738
Jean-Francois Moine98819182009-01-19 07:37:33 -0300739static const u8 ov7648_sensor_init[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300740 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300742 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300743 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
745 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
746 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
747 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
748 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
749 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
750 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
751 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
752 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
753 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
754 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
755 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
756 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
757 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
758 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
759 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
760 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
761 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
762
763 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
764/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
765/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
Hans de Goede37c6dbe2009-06-18 07:35:36 -0300766/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300767 {}
768};
769static const u8 ov7648_sensor_param1[][8] = {
Jean-Francois Moine62703302008-11-11 08:42:56 -0300770/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
Jean-Francois Moine2797ba22009-02-05 15:12:24 -0300771/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
772 * set by setvflip */
Jean-Francois Moine62703302008-11-11 08:42:56 -0300773 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
774 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
775/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
776/* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
777/* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
778/*...*/
779 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
780/* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
781/* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
782/* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
783/* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
784/* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
785
786 {}
787};
788
Jean-Francois Moine98819182009-01-19 07:37:33 -0300789static const u8 ov7660_sensor_init[][8] = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300790 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300791 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300792 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300793 /* Outformat = rawRGB */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300794 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -0300795 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300796 /* GAIN BLUE RED VREF */
797 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
798 /* COM 1 BAVE GEAVE AECHH */
799 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
800 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300801 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300802 /* AECH CLKRC COM7 COM8 */
803 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
804 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
805 /* HSTART HSTOP VSTRT VSTOP */
806 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
807 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
808 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
809 /* BOS GBOS GROS ROS (BGGR offset) */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300810/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
811 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300812 /* AEW AEB VPT BBIAS */
813 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
814 /* GbBIAS RSVD EXHCH EXHCL */
815 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
816 /* RBIAS ADVFL ASDVFH YAVE */
817 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
818 /* HSYST HSYEN HREF */
819 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
820 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
821 /* ADC ACOM OFON TSLB */
822 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
823 /* COM11 COM12 COM13 COM14 */
824 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
825 /* EDGE COM15 COM16 COM17 */
826 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
827 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
828 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
829 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
830 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
831 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
832 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
833 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
834 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
835 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
836 /* LCC1 LCC2 LCC3 LCC4 */
837 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300838 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300839 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300840 /* band gap reference [0:3] DBLV */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300841 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
842 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
843 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
844 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
845 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
846 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
847 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
848 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
849 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300850 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300851/* not in all ms-win traces*/
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -0300852 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300853 {}
854};
855static const u8 ov7660_sensor_param1[][8] = {
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300856 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300857 /* bits[3..0]reserved */
858 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
860 /* VREF vertical frame ctrl */
861 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300862 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
863 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
864 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
865 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
866/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300867/****** (some exchanges in the win trace) ******/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300868/*fixme:param2*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300869 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300870 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
871 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
872 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
873/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300874/****** (some exchanges in the win trace) ******/
Jean-Francois Moine738608a2008-07-28 06:41:51 -0300875/******!! startsensor KO if changed !!****/
Jean-Francois Moine3fccb772009-11-02 09:54:04 -0300876/*fixme: param3*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300877 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
878 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
879 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
880 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300881 {}
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300882};
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300883
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300884static const u8 po1030_sensor_init[][8] = {
885/* the sensor registers are described in m5602/m5602_po1030.h */
886 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -0300887 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -0300888 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
889 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
890 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
891 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
892 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
893 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
894 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
895 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
896 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
897 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
898 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
899 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
900 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
901 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
902 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
903 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
904 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
905 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
906 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
907 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
908 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
909 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
910 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
911 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
912 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
913 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
914
915 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
916 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
917 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
918 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
919 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
920 {}
921};
922static const u8 po1030_sensor_param1[][8] = {
923/* from ms-win traces - these values change with auto gain/expo/wb.. */
924 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
925 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
926/* mean values */
927 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
928 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
929 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
930
931 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
932 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
933 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
934/* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
935 {}
936};
937
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300938static const u8 po2030n_sensor_init[][8] = {
939 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
940 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300941 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300942 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
943 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300944 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300945 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
946 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
947 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
948 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
949 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
950 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
951 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
952 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
953 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
954 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
955 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
956 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
957 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
958 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
959 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
960 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
961 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
962 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
963 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
964 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
965 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
966 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
967 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
968 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
969 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
970 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
971 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
972 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
973 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
974 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
975 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
976 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
977 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
978 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
979 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
980 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
981 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
982 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
983 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
984 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
985 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
986 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
987 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
988 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
989 {}
990};
991static const u8 po2030n_sensor_param1[][8] = {
992 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
Németh Mártonccbc5df2010-10-18 07:00:48 -0300993 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300994 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
995 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
Jean-François Moine41f09322011-11-30 06:20:07 -0300996 {0xd1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x40, 0x10}, /* RGBG gains */
Jean-François Moinead98c0f2010-03-18 05:15:30 -0300997/*param2*/
998 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
999 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1000 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1001 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1002 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001003 {}
1004};
1005
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001006static const u8 soi768_sensor_init[][8] = {
1007 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
Németh Mártonccbc5df2010-10-18 07:00:48 -03001008 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001009 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1010 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1011 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1012 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1013 {}
1014};
1015static const u8 soi768_sensor_param1[][8] = {
1016 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1017 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1018 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1019 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1020 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1021/* */
1022/* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1023/* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1024 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1025/* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1026 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1027/* the next sequence should be used for auto gain */
1028 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1029 /* global gain ? : 07 - change with 0x15 at the end */
1030 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1031 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
Jean-François Moine2458df42011-08-10 05:47:34 -03001032 {0xb1, 0x21, 0x2d, 0x63, 0x03, 0x00, 0x00, 0x10},
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001033 /* exposure ? : 0200 - change with 0x1e at the end */
1034 {}
1035};
1036
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001037static const u8 sp80708_sensor_init[][8] = {
1038 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1039 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1040 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1041 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1042 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1043 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1044 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1045 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1046 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1047 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1048 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1049 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1050 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1051 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1052 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1053 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1054 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1055 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1056 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1057 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1058 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1059 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1060 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1061 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1062 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1063 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1064 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1065 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1066 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1067 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1068 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1069 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1070 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1071 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1072 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1073 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1074 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1075 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1076 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1077 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1078 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1079 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1080 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1081 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1082 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1083 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1084 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1085 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1086 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1087 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1088 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1089 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1090 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1091 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1092 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1093 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1094 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1095 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1096 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1097 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1098 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1099 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1100 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1101 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1102 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1103 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1104 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1105 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1106 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1107 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1108 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03001109 {}
1110};
1111static const u8 sp80708_sensor_param1[][8] = {
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001112 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1113 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1114 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1115 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1116 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1117 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1118 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1119 {}
1120};
1121
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001122static const u8 (*sensor_init[])[8] = {
1123[SENSOR_ADCM1700] = adcm1700_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001124[SENSOR_GC0307] = gc0307_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001125[SENSOR_HV7131R] = hv7131r_sensor_init,
1126[SENSOR_MI0360] = mi0360_sensor_init,
Jean-François Moinea067db82010-10-01 07:51:24 -03001127[SENSOR_MI0360B] = mi0360b_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001128[SENSOR_MO4000] = mo4000_sensor_init,
1129[SENSOR_MT9V111] = mt9v111_sensor_init,
1130[SENSOR_OM6802] = om6802_sensor_init,
1131[SENSOR_OV7630] = ov7630_sensor_init,
1132[SENSOR_OV7648] = ov7648_sensor_init,
1133[SENSOR_OV7660] = ov7660_sensor_init,
1134[SENSOR_PO1030] = po1030_sensor_init,
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001135[SENSOR_PO2030N] = po2030n_sensor_init,
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001136[SENSOR_SOI768] = soi768_sensor_init,
Jean-François Moine9c33afc2010-03-17 15:25:32 -03001137[SENSOR_SP80708] = sp80708_sensor_init,
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001138};
1139
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001140/* read <len> bytes to gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001141static void reg_r(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001142 u16 value, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001143{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001144 int ret;
1145
1146 if (gspca_dev->usb_err < 0)
1147 return;
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001148 if (len > USB_BUF_SZ) {
Joe Perches52173c5f2017-09-22 14:33:35 -04001149 gspca_err(gspca_dev, "reg_r: buffer overflow\n");
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001150 return;
1151 }
Theodore Kilgorec93396e2013-02-04 13:17:55 -03001152
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001153 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001154 usb_rcvctrlpipe(gspca_dev->dev, 0),
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001155 0,
1156 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1157 value, 0,
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001158 gspca_dev->usb_buf, len,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001159 500);
Joe Perches37d5efb2017-09-22 15:20:33 -04001160 gspca_dbg(gspca_dev, D_USBI, "reg_r [%02x] -> %02x\n",
1161 value, gspca_dev->usb_buf[0]);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001162 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -03001163 pr_err("reg_r err %d\n", ret);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001164 gspca_dev->usb_err = ret;
1165 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001166}
1167
Jean-Francois Moine60017612008-07-18 08:46:19 -03001168static void reg_w1(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001169 u16 value,
1170 u8 data)
Jean-Francois Moine60017612008-07-18 08:46:19 -03001171{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001172 int ret;
1173
1174 if (gspca_dev->usb_err < 0)
1175 return;
Joe Perches37d5efb2017-09-22 15:20:33 -04001176 gspca_dbg(gspca_dev, D_USBO, "reg_w1 [%04x] = %02x\n", value, data);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001177 gspca_dev->usb_buf[0] = data;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001178 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001179 usb_sndctrlpipe(gspca_dev->dev, 0),
1180 0x08,
1181 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1182 value,
1183 0,
1184 gspca_dev->usb_buf, 1,
1185 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001186 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -03001187 pr_err("reg_w1 err %d\n", ret);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001188 gspca_dev->usb_err = ret;
1189 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03001190}
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001191static void reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001192 u16 value,
1193 const u8 *buffer,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001194 int len)
1195{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001196 int ret;
1197
1198 if (gspca_dev->usb_err < 0)
1199 return;
Joe Perches37d5efb2017-09-22 15:20:33 -04001200 gspca_dbg(gspca_dev, D_USBO, "reg_w [%04x] = %02x %02x ..\n",
1201 value, buffer[0], buffer[1]);
Theodore Kilgorec93396e2013-02-04 13:17:55 -03001202
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001203 if (len > USB_BUF_SZ) {
Joe Perches52173c5f2017-09-22 14:33:35 -04001204 gspca_err(gspca_dev, "reg_w: buffer overflow\n");
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001205 return;
Jean-Francois Moinebf7f0b92008-07-03 11:09:12 -03001206 }
Theodore Kilgorec93396e2013-02-04 13:17:55 -03001207
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001208 memcpy(gspca_dev->usb_buf, buffer, len);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001209 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine8295d992008-09-03 17:12:19 -03001210 usb_sndctrlpipe(gspca_dev->dev, 0),
1211 0x08,
1212 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1213 value, 0,
1214 gspca_dev->usb_buf, len,
1215 500);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001216 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -03001217 pr_err("reg_w err %d\n", ret);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001218 gspca_dev->usb_err = ret;
1219 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001220}
1221
Jean-Francois Moine60017612008-07-18 08:46:19 -03001222/* I2C write 1 byte */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001223static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001224{
1225 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001226 int ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001227
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001228 if (gspca_dev->usb_err < 0)
1229 return;
Joe Perches37d5efb2017-09-22 15:20:33 -04001230 gspca_dbg(gspca_dev, D_USBO, "i2c_w1 [%02x] = %02x\n", reg, val);
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001231 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001232 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001233 case SENSOR_OM6802:
1234 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001235 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1236 break;
1237 default: /* i2c command = a1 (400 kHz) */
1238 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1239 break;
1240 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001241 gspca_dev->usb_buf[1] = sd->i2c_addr;
Jean-Francois Moine60017612008-07-18 08:46:19 -03001242 gspca_dev->usb_buf[2] = reg;
1243 gspca_dev->usb_buf[3] = val;
1244 gspca_dev->usb_buf[4] = 0;
1245 gspca_dev->usb_buf[5] = 0;
1246 gspca_dev->usb_buf[6] = 0;
1247 gspca_dev->usb_buf[7] = 0x10;
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001248 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001249 usb_sndctrlpipe(gspca_dev->dev, 0),
1250 0x08,
1251 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1252 0x08, /* value = i2c */
1253 0,
1254 gspca_dev->usb_buf, 8,
1255 500);
Hans de Goede2bffebc2012-12-21 11:17:42 -03001256 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001257 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -03001258 pr_err("i2c_w1 err %d\n", ret);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001259 gspca_dev->usb_err = ret;
1260 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001261}
1262
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001263/* I2C write 8 bytes */
1264static void i2c_w8(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001265 const u8 *buffer)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001266{
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001267 int ret;
1268
1269 if (gspca_dev->usb_err < 0)
1270 return;
Joe Perches37d5efb2017-09-22 15:20:33 -04001271 gspca_dbg(gspca_dev, D_USBO, "i2c_w8 [%02x] = %02x ..\n",
1272 buffer[2], buffer[3]);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001273 memcpy(gspca_dev->usb_buf, buffer, 8);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001274 ret = usb_control_msg(gspca_dev->dev,
Jean-Francois Moine60017612008-07-18 08:46:19 -03001275 usb_sndctrlpipe(gspca_dev->dev, 0),
1276 0x08,
1277 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1278 0x08, 0, /* value, index */
1279 gspca_dev->usb_buf, 8,
1280 500);
Jean-Francois Moine8d768e12008-09-21 03:28:55 -03001281 msleep(2);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001282 if (ret < 0) {
Joe Perches133a9fe2011-08-21 19:56:57 -03001283 pr_err("i2c_w8 err %d\n", ret);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001284 gspca_dev->usb_err = ret;
1285 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001286}
1287
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001288/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1289static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001290{
1291 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001292 u8 mode[8];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001293
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001294 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001295 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001296 case SENSOR_OM6802:
1297 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
Jean-Francois Moinea7826362009-11-02 09:21:06 -03001298 mode[0] = 0x80 | 0x10;
1299 break;
1300 default: /* i2c command = 91 (400 kHz) */
1301 mode[0] = 0x81 | 0x10;
1302 break;
1303 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001304 mode[1] = sd->i2c_addr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001305 mode[2] = reg;
1306 mode[3] = 0;
1307 mode[4] = 0;
1308 mode[5] = 0;
1309 mode[6] = 0;
1310 mode[7] = 0x10;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001311 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001312 msleep(2);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001313 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001314 mode[2] = 0;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001315 i2c_w8(gspca_dev, mode);
Jean-Francois Moine60017612008-07-18 08:46:19 -03001316 msleep(2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001317 reg_r(gspca_dev, 0x0a, 5);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001318}
1319
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001320static void i2c_w_seq(struct gspca_dev *gspca_dev,
1321 const u8 (*data)[8])
1322{
1323 while ((*data)[0] != 0) {
Németh Mártonccbc5df2010-10-18 07:00:48 -03001324 if ((*data)[0] != DELAY)
Jean-Francois Moine23a98272009-11-02 09:10:25 -03001325 i2c_w8(gspca_dev, *data);
1326 else
1327 msleep((*data)[1]);
1328 data++;
1329 }
1330}
1331
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001332/* check the ID of the hv7131 sensor */
1333/* this sequence is needed because it activates the sensor */
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001334static void hv7131r_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001335{
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001336 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001337 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001338 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001339 msleep(10);
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001340 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1341 if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001342 && gspca_dev->usb_buf[1] == 0x09
Jean-François Moinea79cc7b2010-10-29 08:10:37 -03001343 && gspca_dev->usb_buf[2] == 0x01) {
Joe Perches37d5efb2017-09-22 15:20:33 -04001344 gspca_dbg(gspca_dev, D_PROBE, "Sensor HV7131R found\n");
Jean-Francois Moine7fb101a2009-10-22 06:27:14 -03001345 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001346 }
Joe Perches133a9fe2011-08-21 19:56:57 -03001347 pr_warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x\n",
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001348 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1349 gspca_dev->usb_buf[2]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001350}
1351
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001352static void mi0360_probe(struct gspca_dev *gspca_dev)
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001353{
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001354 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001355 int i, j;
Jean-Francois Moine92e8c912009-02-02 16:25:38 -03001356 u16 val = 0;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001357 static const u8 probe_tb[][4][8] = {
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001358 { /* mi0360 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001359 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1360 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1361 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1362 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1363 },
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001364 { /* mt9v111 */
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001365 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1366 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1367 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1368 {}
1369 },
1370 };
1371
1372 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1373 reg_w1(gspca_dev, 0x17, 0x62);
1374 reg_w1(gspca_dev, 0x01, 0x08);
1375 for (j = 0; j < 3; j++)
1376 i2c_w8(gspca_dev, probe_tb[i][j]);
1377 msleep(2);
1378 reg_r(gspca_dev, 0x0a, 5);
1379 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1380 if (probe_tb[i][3][0] != 0)
1381 i2c_w8(gspca_dev, probe_tb[i][3]);
1382 reg_w1(gspca_dev, 0x01, 0x29);
1383 reg_w1(gspca_dev, 0x17, 0x42);
1384 if (val != 0xffff)
1385 break;
1386 }
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001387 if (gspca_dev->usb_err < 0)
1388 return;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001389 switch (val) {
Jean-François Moinea067db82010-10-01 07:51:24 -03001390 case 0x8221:
Joe Perches37d5efb2017-09-22 15:20:33 -04001391 gspca_dbg(gspca_dev, D_PROBE, "Sensor mi0360b\n");
Jean-François Moinea067db82010-10-01 07:51:24 -03001392 sd->sensor = SENSOR_MI0360B;
1393 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001394 case 0x823a:
Joe Perches37d5efb2017-09-22 15:20:33 -04001395 gspca_dbg(gspca_dev, D_PROBE, "Sensor mt9v111\n");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001396 sd->sensor = SENSOR_MT9V111;
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001397 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001398 case 0x8243:
Joe Perches37d5efb2017-09-22 15:20:33 -04001399 gspca_dbg(gspca_dev, D_PROBE, "Sensor mi0360\n");
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001400 break;
1401 default:
Joe Perches37d5efb2017-09-22 15:20:33 -04001402 gspca_dbg(gspca_dev, D_PROBE, "Unknown sensor %04x - forced to mi0360\n",
1403 val);
Jean-Francois Moine65c52592009-02-01 14:26:51 -03001404 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001405 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001406}
1407
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001408static void ov7630_probe(struct gspca_dev *gspca_dev)
1409{
1410 struct sd *sd = (struct sd *) gspca_dev;
1411 u16 val;
1412
1413 /* check ov76xx */
1414 reg_w1(gspca_dev, 0x17, 0x62);
1415 reg_w1(gspca_dev, 0x01, 0x08);
1416 sd->i2c_addr = 0x21;
1417 i2c_r(gspca_dev, 0x0a, 2);
1418 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1419 reg_w1(gspca_dev, 0x01, 0x29);
1420 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001421 if (gspca_dev->usb_err < 0)
1422 return;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001423 if (val == 0x7628) { /* soi768 */
1424 sd->sensor = SENSOR_SOI768;
1425/*fixme: only valid for 0c45:613e?*/
1426 gspca_dev->cam.input_flags =
1427 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
Joe Perches37d5efb2017-09-22 15:20:33 -04001428 gspca_dbg(gspca_dev, D_PROBE, "Sensor soi768\n");
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001429 return;
1430 }
Joe Perches37d5efb2017-09-22 15:20:33 -04001431 gspca_dbg(gspca_dev, D_PROBE, "Sensor ov%04x\n", val);
Jean-François Moine03ed2a12010-04-25 14:45:43 -03001432}
1433
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001434static void ov7648_probe(struct gspca_dev *gspca_dev)
1435{
1436 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001437 u16 val;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001438
1439 /* check ov76xx */
1440 reg_w1(gspca_dev, 0x17, 0x62);
1441 reg_w1(gspca_dev, 0x01, 0x08);
1442 sd->i2c_addr = 0x21;
1443 i2c_r(gspca_dev, 0x0a, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001444 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001445 reg_w1(gspca_dev, 0x01, 0x29);
1446 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001447 if ((val & 0xff00) == 0x7600) { /* ov76xx */
Joe Perches37d5efb2017-09-22 15:20:33 -04001448 gspca_dbg(gspca_dev, D_PROBE, "Sensor ov%04x\n", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001449 return;
1450 }
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001451
1452 /* check po1030 */
1453 reg_w1(gspca_dev, 0x17, 0x62);
1454 reg_w1(gspca_dev, 0x01, 0x08);
1455 sd->i2c_addr = 0x6e;
1456 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001457 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1458 reg_w1(gspca_dev, 0x01, 0x29);
1459 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001460 if (gspca_dev->usb_err < 0)
1461 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001462 if (val == 0x1030) { /* po1030 */
Joe Perches37d5efb2017-09-22 15:20:33 -04001463 gspca_dbg(gspca_dev, D_PROBE, "Sensor po1030\n");
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001464 sd->sensor = SENSOR_PO1030;
1465 return;
1466 }
Joe Perches133a9fe2011-08-21 19:56:57 -03001467 pr_err("Unknown sensor %04x\n", val);
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03001468}
1469
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001470/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1471static void po2030n_probe(struct gspca_dev *gspca_dev)
1472{
1473 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001474 u16 val;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001475
1476 /* check gc0307 */
1477 reg_w1(gspca_dev, 0x17, 0x62);
1478 reg_w1(gspca_dev, 0x01, 0x08);
1479 reg_w1(gspca_dev, 0x02, 0x22);
1480 sd->i2c_addr = 0x21;
1481 i2c_r(gspca_dev, 0x00, 1);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001482 val = gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001483 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1484 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001485 if (val == 0x99) { /* gc0307 (?) */
Joe Perches37d5efb2017-09-22 15:20:33 -04001486 gspca_dbg(gspca_dev, D_PROBE, "Sensor gc0307\n");
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001487 sd->sensor = SENSOR_GC0307;
1488 return;
1489 }
1490
1491 /* check po2030n */
1492 reg_w1(gspca_dev, 0x17, 0x62);
1493 reg_w1(gspca_dev, 0x01, 0x0a);
1494 sd->i2c_addr = 0x6e;
1495 i2c_r(gspca_dev, 0x00, 2);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001496 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001497 reg_w1(gspca_dev, 0x01, 0x29);
1498 reg_w1(gspca_dev, 0x17, 0x42);
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001499 if (gspca_dev->usb_err < 0)
1500 return;
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001501 if (val == 0x2030) {
Joe Perches37d5efb2017-09-22 15:20:33 -04001502 gspca_dbg(gspca_dev, D_PROBE, "Sensor po2030n\n");
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001503/* sd->sensor = SENSOR_PO2030N; */
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001504 } else {
Joe Perches133a9fe2011-08-21 19:56:57 -03001505 pr_err("Unknown sensor ID %04x\n", val);
Jean-François Moinee3302ca2010-04-25 14:41:51 -03001506 }
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001507}
1508
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001509/* this function is called at probe time */
1510static int sd_config(struct gspca_dev *gspca_dev,
1511 const struct usb_device_id *id)
1512{
1513 struct sd *sd = (struct sd *) gspca_dev;
1514 struct cam *cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001515
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001516 sd->bridge = id->driver_info >> 16;
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03001517 sd->sensor = id->driver_info >> 8;
1518 sd->flags = id->driver_info;
Jean-Francois Moineeac8f5f2010-01-12 07:12:43 -03001519
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001520 cam = &gspca_dev->cam;
Jean-Francois Moine646775732009-12-20 12:31:28 -03001521 if (sd->sensor == SENSOR_ADCM1700) {
1522 cam->cam_mode = cif_mode;
1523 cam->nmodes = ARRAY_SIZE(cif_mode);
1524 } else {
1525 cam->cam_mode = vga_mode;
1526 cam->nmodes = ARRAY_SIZE(vga_mode);
1527 }
Jean-Francois Moine49cb6b02009-04-25 13:29:01 -03001528 cam->npkt = 24; /* 24 packets per ISOC message */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03001529
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001530 sd->ag_cnt = -1;
Jean-Francois Moine77ac0ba2009-03-02 06:40:52 -03001531 sd->quality = QUALITY_DEF;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001532
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03001533 INIT_WORK(&sd->work, qual_upd);
1534
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001535 return 0;
1536}
1537
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03001538/* this function is called at probe and resume time */
1539static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001540{
1541 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001542 const u8 *sn9c1xx;
Jean-François Moinee6a92a72011-02-10 07:52:58 -03001543 u8 regGpio[] = { 0x29, 0x70 }; /* no audio */
Jean-Francois Moine98819182009-01-19 07:37:33 -03001544 u8 regF1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001545
Hans de Goede3647fea2008-07-15 05:36:30 -03001546 /* setup a selector by bridge */
Jean-Francois Moine60017612008-07-18 08:46:19 -03001547 reg_w1(gspca_dev, 0xf1, 0x01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001548 reg_r(gspca_dev, 0x00, 1);
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03001549 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03001550 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001551 regF1 = gspca_dev->usb_buf[0];
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001552 if (gspca_dev->usb_err < 0)
1553 return gspca_dev->usb_err;
Joe Perches37d5efb2017-09-22 15:20:33 -04001554 gspca_dbg(gspca_dev, D_PROBE, "Sonix chip id: %02x\n", regF1);
Jean-François Moinee6a92a72011-02-10 07:52:58 -03001555 if (gspca_dev->audio)
1556 regGpio[1] |= 0x04; /* with audio */
Hans de Goede3647fea2008-07-15 05:36:30 -03001557 switch (sd->bridge) {
1558 case BRIDGE_SN9C102P:
Hans de Goede3647fea2008-07-15 05:36:30 -03001559 case BRIDGE_SN9C105:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001560 if (regF1 != 0x11)
1561 return -ENODEV;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001562 break;
1563 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03001564/* case BRIDGE_SN9C110: */
Hans de Goedee530a5e2011-01-06 15:23:55 -03001565/* case BRIDGE_SN9C120: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001566 if (regF1 != 0x12)
1567 return -ENODEV;
Hans de Goedee530a5e2011-01-06 15:23:55 -03001568 }
1569
1570 switch (sd->sensor) {
1571 case SENSOR_MI0360:
1572 mi0360_probe(gspca_dev);
1573 break;
1574 case SENSOR_OV7630:
1575 ov7630_probe(gspca_dev);
1576 break;
1577 case SENSOR_OV7648:
1578 ov7648_probe(gspca_dev);
1579 break;
1580 case SENSOR_PO2030N:
1581 po2030n_probe(gspca_dev);
1582 break;
1583 }
1584
1585 switch (sd->bridge) {
1586 case BRIDGE_SN9C102P:
1587 reg_w1(gspca_dev, 0x02, regGpio[1]);
1588 break;
Jean-François Moine336d23e2011-02-10 08:00:40 -03001589 default:
Hans de Goedee530a5e2011-01-06 15:23:55 -03001590 reg_w(gspca_dev, 0x01, regGpio, 2);
1591 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001592 }
1593
Hans de Goede9712a8b2010-01-31 12:54:29 -03001594 /* Note we do not disable the sensor clock here (power saving mode),
1595 as that also disables the button on the cam. */
1596 reg_w1(gspca_dev, 0xf1, 0x00);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001597
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001598 /* set the i2c address */
1599 sn9c1xx = sn_tb[sd->sensor];
1600 sd->i2c_addr = sn9c1xx[9];
1601
Jean-François Moine4bf8b672010-09-25 06:12:44 -03001602 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001603}
1604
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001605static int sd_s_ctrl(struct v4l2_ctrl *ctrl);
1606
1607static const struct v4l2_ctrl_ops sd_ctrl_ops = {
1608 .s_ctrl = sd_s_ctrl,
1609};
1610
1611/* this function is called at probe time */
1612static int sd_init_controls(struct gspca_dev *gspca_dev)
1613{
1614 struct sd *sd = (struct sd *) gspca_dev;
1615 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
1616
1617 gspca_dev->vdev.ctrl_handler = hdl;
1618 v4l2_ctrl_handler_init(hdl, 14);
1619
1620 sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1621 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
1622#define CONTRAST_MAX 127
1623 sd->contrast = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1624 V4L2_CID_CONTRAST, 0, CONTRAST_MAX, 1, 20);
1625#define COLORS_DEF 25
1626 sd->saturation = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1627 V4L2_CID_SATURATION, 0, 40, 1, COLORS_DEF);
1628 sd->red_bal = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1629 V4L2_CID_RED_BALANCE, 24, 40, 1, 32);
1630 sd->blue_bal = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1631 V4L2_CID_BLUE_BALANCE, 24, 40, 1, 32);
1632#define GAMMA_DEF 20
1633 sd->gamma = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1634 V4L2_CID_GAMMA, 0, 40, 1, GAMMA_DEF);
1635
1636 if (sd->sensor == SENSOR_OM6802)
1637 sd->sharpness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1638 V4L2_CID_SHARPNESS, 0, 255, 1, 16);
1639 else
1640 sd->sharpness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1641 V4L2_CID_SHARPNESS, 0, 255, 1, 90);
1642
1643 if (sd->flags & F_ILLUM)
1644 sd->illum = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1645 V4L2_CID_ILLUMINATORS_1, 0, 1, 1, 0);
1646
1647 if (sd->sensor == SENSOR_PO2030N) {
1648 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1649 V4L2_CID_EXPOSURE, 500, 1500, 1, 1024);
1650 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1651 V4L2_CID_GAIN, 4, 49, 1, 15);
1652 sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1653 V4L2_CID_HFLIP, 0, 1, 1, 0);
1654 }
1655
1656 if (sd->sensor != SENSOR_ADCM1700 && sd->sensor != SENSOR_OV7660 &&
1657 sd->sensor != SENSOR_PO1030 && sd->sensor != SENSOR_SOI768 &&
1658 sd->sensor != SENSOR_SP80708)
1659 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1660 V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
1661
1662 if (sd->sensor == SENSOR_HV7131R || sd->sensor == SENSOR_OV7630 ||
1663 sd->sensor == SENSOR_OV7648 || sd->sensor == SENSOR_PO2030N)
1664 sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops,
1665 V4L2_CID_VFLIP, 0, 1, 1, 0);
1666
1667 if (sd->sensor == SENSOR_OV7630 || sd->sensor == SENSOR_OV7648 ||
1668 sd->sensor == SENSOR_OV7660)
1669 sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops,
1670 V4L2_CID_POWER_LINE_FREQUENCY,
1671 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0,
1672 V4L2_CID_POWER_LINE_FREQUENCY_50HZ);
1673
1674 if (hdl->error) {
1675 pr_err("Could not initialize controls\n");
1676 return hdl->error;
1677 }
1678
1679 v4l2_ctrl_cluster(2, &sd->red_bal);
1680 if (sd->sensor == SENSOR_PO2030N) {
1681 v4l2_ctrl_cluster(2, &sd->vflip);
1682 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false);
1683 }
1684
1685 return 0;
1686}
1687
Jean-François Moinea7705c02012-02-27 06:57:04 -03001688static u32 expo_adjust(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03001689 u32 expo)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001690{
1691 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001692
1693 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001694 case SENSOR_GC0307: {
1695 int a, b;
1696
1697 /* expo = 0..255 -> a = 19..43 */
1698 a = 19 + expo * 25 / 256;
1699 i2c_w1(gspca_dev, 0x68, a);
1700 a -= 12;
1701 b = a * a * 4; /* heuristic */
1702 i2c_w1(gspca_dev, 0x03, b >> 8);
1703 i2c_w1(gspca_dev, 0x04, b);
1704 break;
1705 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001706 case SENSOR_HV7131R: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001707 u8 Expodoit[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001708 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001709
1710 Expodoit[3] = expo >> 16;
1711 Expodoit[4] = expo >> 8;
1712 Expodoit[5] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001713 i2c_w8(gspca_dev, Expodoit);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001714 break;
1715 }
Jean-François Moinea067db82010-10-01 07:51:24 -03001716 case SENSOR_MI0360:
1717 case SENSOR_MI0360B: {
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001718 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001719 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001720 static const u8 doit[] = /* update sensor */
1721 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1722 static const u8 sensorgo[] = /* sensor on */
1723 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001724
1725 if (expo > 0x0635)
1726 expo = 0x0635;
1727 else if (expo < 0x0001)
1728 expo = 0x0001;
1729 expoMi[3] = expo >> 8;
1730 expoMi[4] = expo;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001731 i2c_w8(gspca_dev, expoMi);
1732 i2c_w8(gspca_dev, doit);
1733 i2c_w8(gspca_dev, sensorgo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001734 break;
1735 }
1736 case SENSOR_MO4000: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001737 u8 expoMof[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001738 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001739 u8 expoMo10[] =
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001740 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03001741 static const u8 gainMo[] =
1742 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001743
1744 if (expo > 0x1fff)
1745 expo = 0x1fff;
1746 else if (expo < 0x0001)
1747 expo = 0x0001;
1748 expoMof[3] = (expo & 0x03fc) >> 2;
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001749 i2c_w8(gspca_dev, expoMof);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001750 expoMo10[3] = ((expo & 0x1c00) >> 10)
1751 | ((expo & 0x0003) << 4);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03001752 i2c_w8(gspca_dev, expoMo10);
1753 i2c_w8(gspca_dev, gainMo);
Joe Perches37d5efb2017-09-22 15:20:33 -04001754 gspca_dbg(gspca_dev, D_FRAM, "set exposure %d\n",
1755 ((expoMo10[3] & 0x07) << 10)
1756 | (expoMof[3] << 2)
1757 | ((expoMo10[3] & 0x30) >> 4));
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001758 break;
1759 }
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001760 case SENSOR_MT9V111: {
1761 u8 expo_c1[] =
1762 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1763
Jean-François Moine22203672011-02-10 07:49:32 -03001764 if (expo > 0x0390)
1765 expo = 0x0390;
1766 else if (expo < 0x0060)
1767 expo = 0x0060;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03001768 expo_c1[3] = expo >> 8;
1769 expo_c1[4] = expo;
1770 i2c_w8(gspca_dev, expo_c1);
1771 break;
1772 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001773 case SENSOR_OM6802: {
Jean-Francois Moine98819182009-01-19 07:37:33 -03001774 u8 gainOm[] =
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001775 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001776 /* preset AGC - works when AutoExpo = off */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001777
1778 if (expo > 0x03ff)
1779 expo = 0x03ff;
Mauro Carvalho Chehab51364122015-04-29 15:05:28 -03001780 if (expo < 0x0001)
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001781 expo = 0x0001;
1782 gainOm[3] = expo >> 2;
1783 i2c_w8(gspca_dev, gainOm);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001784 reg_w1(gspca_dev, 0x96, expo >> 5);
Joe Perches37d5efb2017-09-22 15:20:33 -04001785 gspca_dbg(gspca_dev, D_FRAM, "set exposure %d\n", gainOm[3]);
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001786 break;
1787 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001788 }
1789 return expo;
1790}
1791
1792static void setbrightness(struct gspca_dev *gspca_dev)
1793{
1794 struct sd *sd = (struct sd *) gspca_dev;
1795 unsigned int expo;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001796 int brightness = sd->brightness->val;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001797 u8 k2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001798
Jean-François Moine72b667e2010-10-02 04:35:25 -03001799 k2 = (brightness - 0x80) >> 2;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001800 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001801 case SENSOR_ADCM1700:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03001802 if (k2 > 0x1f)
1803 k2 = 0; /* only positive Y offset */
1804 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001805 case SENSOR_HV7131R:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001806 expo = brightness << 12;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001807 if (expo > 0x002dc6c0)
1808 expo = 0x002dc6c0;
1809 else if (expo < 0x02a0)
1810 expo = 0x02a0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001811 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001812 break;
1813 case SENSOR_MI0360:
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001814 case SENSOR_MO4000:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001815 expo = brightness << 4;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001816 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001817 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03001818 case SENSOR_MI0360B:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001819 expo = brightness << 2;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001820 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-François Moinea067db82010-10-01 07:51:24 -03001821 break;
Jean-François Moinec26b12d2010-04-02 07:08:39 -03001822 case SENSOR_GC0307:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001823 expo = brightness;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001824 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001825 return; /* don't set the Y offset */
Jean-François Moine22203672011-02-10 07:49:32 -03001826 case SENSOR_MT9V111:
1827 expo = brightness << 2;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001828 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-François Moine22203672011-02-10 07:49:32 -03001829 return; /* don't set the Y offset */
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03001830 case SENSOR_OM6802:
Jean-François Moine72b667e2010-10-02 04:35:25 -03001831 expo = brightness << 2;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001832 sd->exposure = expo_adjust(gspca_dev, expo);
Jean-François Moineb813b0c2011-08-10 05:54:34 -03001833 return; /* Y offset already set */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001834 }
1835
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001836 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001837}
1838
1839static void setcontrast(struct gspca_dev *gspca_dev)
1840{
1841 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001842 u8 k2;
1843 u8 contrast[6];
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001844
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001845 k2 = sd->contrast->val * 37 / (CONTRAST_MAX + 1)
Jean-François Moineabe8cee2011-08-10 05:13:45 -03001846 + 37; /* 37..73 */
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001847 contrast[0] = (k2 + 1) / 2; /* red */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001848 contrast[1] = 0;
Jean-Francois Moine91bd3412008-11-23 14:47:50 -03001849 contrast[2] = k2; /* green */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001850 contrast[3] = 0;
Jean-François Moineabe8cee2011-08-10 05:13:45 -03001851 contrast[4] = k2 / 5; /* blue */
Jean-Francois Moine577cbf42008-12-05 06:18:37 -03001852 contrast[5] = 0;
1853 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001854}
1855
1856static void setcolors(struct gspca_dev *gspca_dev)
1857{
1858 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001859 int i, v, colors;
Jean-François Moinea067db82010-10-01 07:51:24 -03001860 const s16 *uv;
Jean-Francois Moine98819182009-01-19 07:37:33 -03001861 u8 reg8a[12]; /* U & V gains */
Jean-François Moinea067db82010-10-01 07:51:24 -03001862 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001863 -24, -38, 64, /* UR UG UB */
1864 62, -51, -9 /* VR VG VB */
1865 };
Jean-François Moinea067db82010-10-01 07:51:24 -03001866 static const s16 uv_mi0360b[6] = {
1867 -20, -38, 64, /* UR UG UB */
1868 60, -51, -9 /* VR VG VB */
1869 };
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03001870
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001871 colors = sd->saturation->val;
Jean-François Moinea067db82010-10-01 07:51:24 -03001872 if (sd->sensor == SENSOR_MI0360B)
1873 uv = uv_mi0360b;
1874 else
1875 uv = uv_com;
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001876 for (i = 0; i < 6; i++) {
Jean-François Moine72b667e2010-10-02 04:35:25 -03001877 v = uv[i] * colors / COLORS_DEF;
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001878 reg8a[i * 2] = v;
1879 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
Jean-Francois Moined55b83d2008-09-03 16:48:01 -03001880 }
Jean-Francois Moinebd088832008-12-02 06:58:57 -03001881 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03001882}
1883
1884static void setredblue(struct gspca_dev *gspca_dev)
1885{
1886 struct sd *sd = (struct sd *) gspca_dev;
1887
Jean-François Moine41f09322011-11-30 06:20:07 -03001888 if (sd->sensor == SENSOR_PO2030N) {
1889 u8 rg1b[] = /* red green1 blue (no g2) */
1890 {0xc1, 0x6e, 0x16, 0x00, 0x40, 0x00, 0x00, 0x10};
1891
1892 /* 0x40 = normal value = gain x 1 */
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001893 rg1b[3] = sd->red_bal->val * 2;
1894 rg1b[5] = sd->blue_bal->val * 2;
Jean-François Moine41f09322011-11-30 06:20:07 -03001895 i2c_w8(gspca_dev, rg1b);
1896 return;
1897 }
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001898 reg_w1(gspca_dev, 0x05, sd->red_bal->val);
Jean-Francois Moine9c5f70f2008-09-03 16:48:04 -03001899/* reg_w1(gspca_dev, 0x07, 32); */
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001900 reg_w1(gspca_dev, 0x06, sd->blue_bal->val);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001901}
1902
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001903static void setgamma(struct gspca_dev *gspca_dev)
1904{
1905 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moine72b667e2010-10-02 04:35:25 -03001906 int i, val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001907 u8 gamma[17];
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001908 const u8 *gamma_base;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001909 static const u8 delta[17] = {
1910 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1911 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1912 };
1913
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001914 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03001915 case SENSOR_ADCM1700:
1916 gamma_base = gamma_spec_0;
1917 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001918 case SENSOR_HV7131R:
Jean-François Moinea067db82010-10-01 07:51:24 -03001919 case SENSOR_MI0360B:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001920 case SENSOR_MT9V111:
1921 gamma_base = gamma_spec_1;
1922 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001923 case SENSOR_GC0307:
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001924 gamma_base = gamma_spec_2;
1925 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03001926 case SENSOR_SP80708:
1927 gamma_base = gamma_spec_3;
1928 break;
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001929 default:
1930 gamma_base = gamma_def;
1931 break;
1932 }
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03001933
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001934 val = sd->gamma->val;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001935 for (i = 0; i < sizeof gamma; i++)
Jean-Francois Moineb083b922009-02-01 14:20:07 -03001936 gamma[i] = gamma_base[i]
Jean-François Moine72b667e2010-10-02 04:35:25 -03001937 + delta[i] * (val - GAMMA_DEF) / 32;
Jean-Francois Moine592f4eb2009-01-15 08:01:32 -03001938 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1939}
1940
Jean-François Moinea7705c02012-02-27 06:57:04 -03001941static void setexposure(struct gspca_dev *gspca_dev)
1942{
1943 struct sd *sd = (struct sd *) gspca_dev;
1944
1945 if (sd->sensor == SENSOR_PO2030N) {
1946 u8 rexpo[] = /* 1a: expo H, 1b: expo M */
1947 {0xa1, 0x6e, 0x1a, 0x00, 0x40, 0x00, 0x00, 0x10};
1948
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001949 rexpo[3] = gspca_dev->exposure->val >> 8;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001950 i2c_w8(gspca_dev, rexpo);
1951 msleep(6);
1952 rexpo[2] = 0x1b;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001953 rexpo[3] = gspca_dev->exposure->val;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001954 i2c_w8(gspca_dev, rexpo);
1955 }
1956}
1957
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001958static void setautogain(struct gspca_dev *gspca_dev)
1959{
1960 struct sd *sd = (struct sd *) gspca_dev;
1961
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001962 switch (sd->sensor) {
1963 case SENSOR_OV7630:
1964 case SENSOR_OV7648: {
1965 u8 comb;
1966
1967 if (sd->sensor == SENSOR_OV7630)
1968 comb = 0xc0;
1969 else
1970 comb = 0xa0;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001971 if (gspca_dev->autogain->val)
Hans de Goede1fec747c2009-06-18 06:05:07 -03001972 comb |= 0x03;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001973 i2c_w1(&sd->gspca_dev, 0x13, comb);
1974 return;
1975 }
1976 }
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001977 if (gspca_dev->autogain->val)
Jean-Francois Moinef50ba1b2008-09-03 17:12:14 -03001978 sd->ag_cnt = AG_CNT_START;
1979 else
1980 sd->ag_cnt = -1;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03001981}
1982
Jean-François Moinea7705c02012-02-27 06:57:04 -03001983static void setgain(struct gspca_dev *gspca_dev)
1984{
1985 struct sd *sd = (struct sd *) gspca_dev;
1986
1987 if (sd->sensor == SENSOR_PO2030N) {
1988 u8 rgain[] = /* 15: gain */
1989 {0xa1, 0x6e, 0x15, 0x00, 0x40, 0x00, 0x00, 0x15};
1990
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03001991 rgain[3] = gspca_dev->gain->val;
Jean-François Moinea7705c02012-02-27 06:57:04 -03001992 i2c_w8(gspca_dev, rgain);
1993 }
1994}
1995
Németh Márton76ad3b62010-10-19 03:33:47 -03001996static void sethvflip(struct gspca_dev *gspca_dev)
Jean-Francois Moine6c862742008-09-08 04:57:26 -03001997{
Jean-François Moine72b667e2010-10-02 04:35:25 -03001998 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03001999 u8 comn;
2000
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002001 switch (sd->sensor) {
2002 case SENSOR_HV7131R:
2003 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002004 if (sd->vflip->val)
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002005 comn |= 0x01;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002006 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002007 break;
2008 case SENSOR_OV7630:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002009 comn = 0x02;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002010 if (!sd->vflip->val)
Hans de Goedef8009522009-06-18 14:29:20 -03002011 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002012 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002013 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002014 case SENSOR_OV7648:
Jean-Francois Moine2797ba22009-02-05 15:12:24 -03002015 comn = 0x06;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002016 if (sd->vflip->val)
Hans de Goedef8009522009-06-18 14:29:20 -03002017 comn |= 0x80;
Jean-François Moine72b667e2010-10-02 04:35:25 -03002018 i2c_w1(gspca_dev, 0x75, comn);
Jean-François Moinef6b22e52010-02-18 04:12:06 -03002019 break;
Németh Márton76ad3b62010-10-19 03:33:47 -03002020 case SENSOR_PO2030N:
2021 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2022 * (reset value: 0x0A)
2023 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2024 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2025 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2026 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2027 * bit3-0: X
2028 */
2029 comn = 0x0a;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002030 if (sd->hflip->val)
Németh Márton76ad3b62010-10-19 03:33:47 -03002031 comn |= 0x80;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002032 if (sd->vflip->val)
Németh Márton76ad3b62010-10-19 03:33:47 -03002033 comn |= 0x40;
2034 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2035 break;
Hans de Goedef8009522009-06-18 14:29:20 -03002036 }
Jean-Francois Moine6c862742008-09-08 04:57:26 -03002037}
2038
Jean-François Moine72b667e2010-10-02 04:35:25 -03002039static void setsharpness(struct gspca_dev *gspca_dev)
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002040{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002041 struct sd *sd = (struct sd *) gspca_dev;
2042
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002043 reg_w1(gspca_dev, 0x99, sd->sharpness->val);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002044}
2045
Jean-François Moine3afef852011-01-13 06:39:11 -03002046static void setillum(struct gspca_dev *gspca_dev)
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002047{
Jean-François Moine72b667e2010-10-02 04:35:25 -03002048 struct sd *sd = (struct sd *) gspca_dev;
2049
Jean-François Moinea63d6012011-01-13 07:56:00 -03002050 switch (sd->sensor) {
2051 case SENSOR_ADCM1700:
2052 reg_w1(gspca_dev, 0x02, /* gpio */
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002053 sd->illum->val ? 0x64 : 0x60);
Jean-François Moinea63d6012011-01-13 07:56:00 -03002054 break;
2055 case SENSOR_MT9V111:
Jean-François Moine5c956062011-02-10 08:03:24 -03002056 reg_w1(gspca_dev, 0x02,
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002057 sd->illum->val ? 0x77 : 0x74);
Jean-François Moine5c956062011-02-10 08:03:24 -03002058/* should have been: */
2059/* 0x55 : 0x54); * 370i */
2060/* 0x66 : 0x64); * Clip */
Jean-François Moinea63d6012011-01-13 07:56:00 -03002061 break;
2062 }
Jean-Francois Moine0cae8962008-10-17 07:48:24 -03002063}
2064
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002065static void setfreq(struct gspca_dev *gspca_dev)
2066{
2067 struct sd *sd = (struct sd *) gspca_dev;
2068
2069 if (sd->sensor == SENSOR_OV7660) {
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002070 u8 com8;
2071
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002072 com8 = 0xdf; /* auto gain/wb/expo */
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002073 switch (sd->freq->val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002074 case 0: /* Banding filter disabled */
Jean-Francois Moine47f7f6f2009-08-25 06:14:54 -03002075 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002076 break;
2077 case 1: /* 50 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002078 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002079 i2c_w1(gspca_dev, 0x3b, 0x0a);
2080 break;
2081 case 2: /* 60 hz */
Jean-Francois Moined8f400e2009-07-08 06:33:44 -03002082 i2c_w1(gspca_dev, 0x13, com8);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002083 i2c_w1(gspca_dev, 0x3b, 0x02);
2084 break;
2085 }
2086 } else {
2087 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2088
2089 /* Get reg2a / reg2d base values */
2090 switch (sd->sensor) {
2091 case SENSOR_OV7630:
2092 reg2a = 0x08;
2093 reg2d = 0x01;
2094 break;
2095 case SENSOR_OV7648:
2096 reg2a = 0x11;
2097 reg2d = 0x81;
2098 break;
2099 }
2100
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002101 switch (sd->freq->val) {
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002102 case 0: /* Banding filter disabled */
2103 break;
2104 case 1: /* 50 hz (filter on and framerate adj) */
2105 reg2a |= 0x80;
2106 reg2b = 0xac;
2107 reg2d |= 0x04;
2108 break;
2109 case 2: /* 60 hz (filter on, no framerate adj) */
2110 reg2a |= 0x80;
2111 reg2d |= 0x04;
2112 break;
2113 }
2114 i2c_w1(gspca_dev, 0x2a, reg2a);
2115 i2c_w1(gspca_dev, 0x2b, reg2b);
2116 i2c_w1(gspca_dev, 0x2d, reg2d);
2117 }
2118}
2119
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002120static void setjpegqual(struct gspca_dev *gspca_dev)
2121{
2122 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002123
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002124 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002125#if USB_BUF_SZ < 64
2126#error "No room enough in usb_buf for quantization table"
2127#endif
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002128 memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002129 usb_control_msg(gspca_dev->dev,
2130 usb_sndctrlpipe(gspca_dev->dev, 0),
2131 0x08,
2132 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2133 0x0100, 0,
2134 gspca_dev->usb_buf, 64,
2135 500);
Jean-François Moinedccdccc2011-02-10 07:30:03 -03002136 memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64);
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002137 usb_control_msg(gspca_dev->dev,
2138 usb_sndctrlpipe(gspca_dev->dev, 0),
2139 0x08,
2140 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2141 0x0140, 0,
2142 gspca_dev->usb_buf, 64,
2143 500);
2144
2145 sd->reg18 ^= 0x40;
2146 reg_w1(gspca_dev, 0x18, sd->reg18);
2147}
2148
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002149/* JPEG quality update */
2150/* This function is executed from a work queue. */
2151static void qual_upd(struct work_struct *work)
2152{
2153 struct sd *sd = container_of(work, struct sd, work);
2154 struct gspca_dev *gspca_dev = &sd->gspca_dev;
2155
Hans de Goede844db452012-09-09 07:30:02 -03002156 /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002157 mutex_lock(&gspca_dev->usb_lock);
Joe Perches37d5efb2017-09-22 15:20:33 -04002158 gspca_dbg(gspca_dev, D_STREAM, "qual_upd %d%%\n", sd->quality);
Hans de Goede844db452012-09-09 07:30:02 -03002159 gspca_dev->usb_err = 0;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002160 setjpegqual(gspca_dev);
2161 mutex_unlock(&gspca_dev->usb_lock);
2162}
2163
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002164/* -- start the camera -- */
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -03002165static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002166{
2167 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002168 int i;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002169 u8 reg01, reg17;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002170 u8 reg0102[2];
Jean-Francois Moine98819182009-01-19 07:37:33 -03002171 const u8 *sn9c1xx;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002172 const u8 (*init)[8];
Jean-Francois Moine4f67f3a2010-12-14 16:15:00 -03002173 const u8 *reg9a;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002174 int mode;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002175 static const u8 reg9a_def[] =
2176 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2177 static const u8 reg9a_spec[] =
2178 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2179 static const u8 regd4[] = {0x60, 0x00, 0x00};
Jean-Francois Moine98819182009-01-19 07:37:33 -03002180 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2181 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
Jean-Francois Moine646775732009-12-20 12:31:28 -03002182 static const u8 CA_adcm1700[] =
2183 { 0x14, 0xec, 0x0a, 0xf6 };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002184 static const u8 CA_po2030n[] =
2185 { 0x1e, 0xe2, 0x14, 0xec };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002186 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002187 static const u8 CE_gc0307[] =
2188 { 0x32, 0xce, 0x2d, 0xd3 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002189 static const u8 CE_ov76xx[] =
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002190 { 0x32, 0xdd, 0x32, 0xdd };
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002191 static const u8 CE_po2030n[] =
2192 { 0x14, 0xe7, 0x1e, 0xdd };
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002193
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002194 /* create the JPEG header */
Ondrej Zary1966bc22013-08-30 17:54:23 -03002195 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
2196 gspca_dev->pixfmt.width,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002197 0x21); /* JPEG 422 */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002198
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002199 /* initialize the bridge */
2200 sn9c1xx = sn_tb[sd->sensor];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002201
2202 /* sensor clock already enabled in sd_init */
2203 /* reg_w1(gspca_dev, 0xf1, 0x00); */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002204 reg01 = sn9c1xx[1];
Jean-François Moine3afef852011-01-13 06:39:11 -03002205 if (sd->flags & F_PDN_INV)
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002206 reg01 ^= S_PDN_INV; /* power down inverted */
2207 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002208
2209 /* configure gpio */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002210 reg0102[0] = reg01;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002211 reg0102[1] = sn9c1xx[2];
2212 if (gspca_dev->audio)
2213 reg0102[1] |= 0x04; /* keep the audio connection */
2214 reg_w(gspca_dev, 0x01, reg0102, 2);
2215 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2216 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2217 switch (sd->sensor) {
2218 case SENSOR_GC0307:
2219 case SENSOR_OV7660:
2220 case SENSOR_PO1030:
2221 case SENSOR_PO2030N:
2222 case SENSOR_SOI768:
2223 case SENSOR_SP80708:
2224 reg9a = reg9a_spec;
2225 break;
2226 default:
2227 reg9a = reg9a_def;
2228 break;
2229 }
2230 reg_w(gspca_dev, 0x9a, reg9a, 6);
2231
2232 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2233
2234 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2235
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002236 reg17 = sn9c1xx[0x17];
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002237 switch (sd->sensor) {
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002238 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002239 msleep(50); /*fixme: is it useful? */
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002240 break;
2241 case SENSOR_OM6802:
2242 msleep(10);
2243 reg_w1(gspca_dev, 0x02, 0x73);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002244 reg17 |= SEN_CLK_EN;
2245 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002246 reg_w1(gspca_dev, 0x01, 0x22);
2247 msleep(100);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002248 reg01 = SCL_SEL_OD | S_PDN_INV;
Luiz Ramosd1520c52011-07-14 23:08:39 -03002249 reg17 &= ~MCK_SIZE_MASK;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002250 reg17 |= 0x04; /* clock / 4 */
2251 break;
2252 }
2253 reg01 |= SYS_SEL_48M;
2254 reg_w1(gspca_dev, 0x01, reg01);
2255 reg17 |= SEN_CLK_EN;
2256 reg_w1(gspca_dev, 0x17, reg17);
2257 reg01 &= ~S_PWR_DN; /* sensor power on */
2258 reg_w1(gspca_dev, 0x01, reg01);
Jean-François Moineb4b01072011-11-30 05:58:20 -03002259 reg01 &= ~SCL_SEL_OD; /* remove open-drain mode */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002260 reg_w1(gspca_dev, 0x01, reg01);
2261
2262 switch (sd->sensor) {
2263 case SENSOR_HV7131R:
2264 hv7131r_probe(gspca_dev); /*fixme: is it useful? */
2265 break;
2266 case SENSOR_OM6802:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002267 msleep(10);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002268 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002269 i2c_w8(gspca_dev, om6802_init0[0]);
2270 i2c_w8(gspca_dev, om6802_init0[1]);
2271 msleep(15);
2272 reg_w1(gspca_dev, 0x02, 0x71);
2273 msleep(150);
2274 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002275 case SENSOR_SP80708:
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002276 msleep(100);
2277 reg_w1(gspca_dev, 0x02, 0x62);
2278 break;
Jean-Francois Moine5e68f402010-12-14 16:14:10 -03002279 }
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002280
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002281 /* initialize the sensor */
2282 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2283
Jean-Francois Moine60017612008-07-18 08:46:19 -03002284 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2285 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2286 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2287 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2288 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002289 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002290 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2291 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002292 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002293 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2294 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002295 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002296 reg_w1(gspca_dev, 0xc6, 0x00);
2297 reg_w1(gspca_dev, 0xc7, 0x00);
Jean-Francois Moine646775732009-12-20 12:31:28 -03002298 if (sd->sensor == SENSOR_ADCM1700) {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002299 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2300 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002301 } else {
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002302 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2303 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
Jean-Francois Moine646775732009-12-20 12:31:28 -03002304 }
Jean-Francois Moine60017612008-07-18 08:46:19 -03002305 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002306 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002307 case SENSOR_OM6802:
2308/* case SENSOR_OV7648: * fixme: sometimes */
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002309 break;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002310 default:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002311 reg17 |= DEF_EN;
Jean-Francois Moine568788a2008-07-15 11:46:06 -03002312 break;
2313 }
Jean-Francois Moine8f47a3c2008-07-29 14:14:04 -03002314 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002315
2316 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2317 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2318 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
Jean-Francois Moine60017612008-07-18 08:46:19 -03002319 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
Jean-Francois Moineb083b922009-02-01 14:20:07 -03002320
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002321 setgamma(gspca_dev);
2322
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002323/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
Jean-Francois Moine05b809c2008-09-03 16:47:59 -03002324 for (i = 0; i < 8; i++)
2325 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002326 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002327 case SENSOR_ADCM1700:
Jean-Francois Moinec8b9b2c2009-04-26 14:46:12 -03002328 case SENSOR_OV7660:
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002329 case SENSOR_SP80708:
2330 reg_w1(gspca_dev, 0x9a, 0x05);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002331 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002332 case SENSOR_GC0307:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002333 case SENSOR_MT9V111:
Jean-François Moinea067db82010-10-01 07:51:24 -03002334 case SENSOR_MI0360B:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002335 reg_w1(gspca_dev, 0x9a, 0x07);
2336 break;
Jean-François Moine0a85c742010-04-25 14:33:31 -03002337 case SENSOR_OV7630:
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002338 case SENSOR_OV7648:
2339 reg_w1(gspca_dev, 0x9a, 0x0a);
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002340 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002341 case SENSOR_PO2030N:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002342 case SENSOR_SOI768:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002343 reg_w1(gspca_dev, 0x9a, 0x06);
2344 break;
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002345 default:
Jean-Francois Moine60017612008-07-18 08:46:19 -03002346 reg_w1(gspca_dev, 0x9a, 0x08);
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002347 break;
2348 }
Jean-François Moine72b667e2010-10-02 04:35:25 -03002349 setsharpness(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002350
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002351 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
Jean-Francois Moine878b35a2009-12-30 04:53:07 -03002352 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2353 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2354 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
Jean-Francois Moine23a98272009-11-02 09:10:25 -03002355
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002356 init = NULL;
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002357 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002358 reg01 |= SYS_SEL_48M | V_TX_EN;
2359 reg17 &= ~MCK_SIZE_MASK;
2360 reg17 |= 0x02; /* clock / 2 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002361 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002362 case SENSOR_ADCM1700:
2363 init = adcm1700_sensor_param1;
Jean-Francois Moine646775732009-12-20 12:31:28 -03002364 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002365 case SENSOR_GC0307:
2366 init = gc0307_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002367 break;
2368 case SENSOR_HV7131R:
2369 case SENSOR_MI0360:
Jean-François Moineb813b0c2011-08-10 05:54:34 -03002370 if (!mode)
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002371 reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */
2372 reg17 &= ~MCK_SIZE_MASK;
2373 reg17 |= 0x01; /* clock / 1 */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002374 break;
Jean-François Moinea067db82010-10-01 07:51:24 -03002375 case SENSOR_MI0360B:
2376 init = mi0360b_sensor_param1;
Jean-François Moinea067db82010-10-01 07:51:24 -03002377 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002378 case SENSOR_MO4000:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002379 if (mode) { /* if 320x240 */
2380 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2381 reg17 &= ~MCK_SIZE_MASK;
2382 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002383 }
2384 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002385 case SENSOR_MT9V111:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002386 init = mt9v111_sensor_param1;
Jean-Francois Moine0fbe0572009-01-30 12:14:02 -03002387 break;
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002388 case SENSOR_OM6802:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002389 init = om6802_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002390 if (!mode) { /* if 640x480 */
2391 reg17 &= ~MCK_SIZE_MASK;
Jean-François Moineaa777a82010-12-28 07:39:13 -03002392 reg17 |= 0x04; /* clock / 4 */
Jean-François Moine822f6e22011-08-09 15:13:50 -03002393 } else {
2394 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2395 reg17 &= ~MCK_SIZE_MASK;
2396 reg17 |= 0x02; /* clock / 2 */
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002397 }
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002398 break;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002399 case SENSOR_OV7630:
Jean-François Moinebdd2b932010-04-25 14:23:39 -03002400 init = ov7630_sensor_param1;
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002401 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002402 case SENSOR_OV7648:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002403 init = ov7648_sensor_param1;
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002404 reg17 &= ~MCK_SIZE_MASK;
2405 reg17 |= 0x01; /* clock / 1 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002406 break;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002407 case SENSOR_OV7660:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002408 init = ov7660_sensor_param1;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002409 break;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002410 case SENSOR_PO1030:
2411 init = po1030_sensor_param1;
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002412 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002413 case SENSOR_PO2030N:
2414 init = po2030n_sensor_param1;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002415 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002416 case SENSOR_SOI768:
2417 init = soi768_sensor_param1;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002418 break;
Jean-François Moine0303a902010-10-21 04:05:15 -03002419 case SENSOR_SP80708:
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002420 init = sp80708_sensor_param1;
Jean-Francois Moine5e31dc82009-02-01 13:59:42 -03002421 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002422 }
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002423
2424 /* more sensor initialization - param1 */
2425 if (init != NULL) {
2426 i2c_w_seq(gspca_dev, init);
2427/* init = NULL; */
2428 }
2429
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002430 reg_w(gspca_dev, 0xc0, C0, 6);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002431 switch (sd->sensor) {
2432 case SENSOR_ADCM1700:
2433 case SENSOR_GC0307:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002434 case SENSOR_SOI768:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002435 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002436 break;
2437 case SENSOR_PO2030N:
2438 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2439 break;
2440 default:
Jean-Francois Moine646775732009-12-20 12:31:28 -03002441 reg_w(gspca_dev, 0xca, CA, 4);
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002442 break;
2443 }
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002444 switch (sd->sensor) {
Jean-Francois Moine646775732009-12-20 12:31:28 -03002445 case SENSOR_ADCM1700:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002446 case SENSOR_OV7630:
2447 case SENSOR_OV7648:
Jean-Francois Moine674cbc62008-10-02 08:06:59 -03002448 case SENSOR_OV7660:
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002449 case SENSOR_SOI768:
Jean-Francois Moine6ab0b172008-09-03 16:47:34 -03002450 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002451 break;
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002452 case SENSOR_GC0307:
2453 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2454 break;
2455 case SENSOR_PO2030N:
2456 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2457 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002458 default:
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002459 reg_w(gspca_dev, 0xce, CE, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002460 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2461 break;
2462 }
2463
2464 /* here change size mode 0 -> VGA; 1 -> CIF */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -03002465 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2466 reg_w1(gspca_dev, 0x18, sd->reg18);
2467 setjpegqual(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002468
Jean-Francois Moine60017612008-07-18 08:46:19 -03002469 reg_w1(gspca_dev, 0x17, reg17);
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002470 reg_w1(gspca_dev, 0x01, reg01);
2471 sd->reg01 = reg01;
2472 sd->reg17 = reg17;
Jean-Francois Moine3fccb772009-11-02 09:54:04 -03002473
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002474 sd->pktsz = sd->npkt = 0;
2475 sd->nchg = sd->short_mark = 0;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002476
Jean-François Moine4bf8b672010-09-25 06:12:44 -03002477 return gspca_dev->usb_err;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002478}
2479
2480static void sd_stopN(struct gspca_dev *gspca_dev)
2481{
2482 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002483 static const u8 stophv7131[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002484 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002485 static const u8 stopmi0360[] =
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002486 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine98819182009-01-19 07:37:33 -03002487 static const u8 stopov7648[] =
Jean-Francois Moine62703302008-11-11 08:42:56 -03002488 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002489 static const u8 stopsoi768[] =
2490 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002491 u8 reg01;
2492 u8 reg17;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002493
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002494 reg01 = sd->reg01;
2495 reg17 = sd->reg17 & ~SEN_CLK_EN;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002496 switch (sd->sensor) {
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002497 case SENSOR_ADCM1700:
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002498 case SENSOR_GC0307:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002499 case SENSOR_PO2030N:
2500 case SENSOR_SP80708:
2501 reg01 |= LED;
2502 reg_w1(gspca_dev, 0x01, reg01);
2503 reg01 &= ~(LED | V_TX_EN);
2504 reg_w1(gspca_dev, 0x01, reg01);
2505/* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002506 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002507 case SENSOR_HV7131R:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002508 reg01 &= ~V_TX_EN;
2509 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002510 i2c_w8(gspca_dev, stophv7131);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002511 break;
2512 case SENSOR_MI0360:
Jean-François Moinea067db82010-10-01 07:51:24 -03002513 case SENSOR_MI0360B:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002514 reg01 &= ~V_TX_EN;
2515 reg_w1(gspca_dev, 0x01, reg01);
2516/* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */
Jean-Francois Moine739570b2008-07-14 09:38:29 -03002517 i2c_w8(gspca_dev, stopmi0360);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002518 break;
Jean-Francois Moine3ef2c5b2009-01-29 04:59:45 -03002519 case SENSOR_MT9V111:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002520 case SENSOR_OM6802:
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002521 case SENSOR_PO1030:
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002522 reg01 &= ~V_TX_EN;
2523 reg_w1(gspca_dev, 0x01, reg01);
2524 break;
2525 case SENSOR_OV7630:
2526 case SENSOR_OV7648:
2527 reg01 &= ~V_TX_EN;
2528 reg_w1(gspca_dev, 0x01, reg01);
2529 i2c_w8(gspca_dev, stopov7648);
2530 break;
2531 case SENSOR_OV7660:
2532 reg01 &= ~V_TX_EN;
2533 reg_w1(gspca_dev, 0x01, reg01);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002534 break;
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002535 case SENSOR_SOI768:
2536 i2c_w8(gspca_dev, stopsoi768);
Jean-François Moine03ed2a12010-04-25 14:45:43 -03002537 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002538 }
Jean-Francois Moine0e4d4132010-12-14 16:17:40 -03002539
2540 reg01 |= SCL_SEL_OD;
2541 reg_w1(gspca_dev, 0x01, reg01);
2542 reg01 |= S_PWR_DN; /* sensor power down */
2543 reg_w1(gspca_dev, 0x01, reg01);
2544 reg_w1(gspca_dev, 0x17, reg17);
2545 reg01 &= ~SYS_SEL_48M; /* clock 24MHz */
2546 reg_w1(gspca_dev, 0x01, reg01);
2547 reg01 |= LED;
2548 reg_w1(gspca_dev, 0x01, reg01);
Hans de Goede9712a8b2010-01-31 12:54:29 -03002549 /* Don't disable sensor clock as that disables the button on the cam */
2550 /* reg_w1(gspca_dev, 0xf1, 0x01); */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002551}
2552
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002553/* called on streamoff with alt==0 and on disconnect */
2554/* the usb_lock is held at entry - restore on exit */
2555static void sd_stop0(struct gspca_dev *gspca_dev)
2556{
2557 struct sd *sd = (struct sd *) gspca_dev;
2558
Bhaktipriya Shridharc994be42016-07-16 05:50:28 -03002559 mutex_unlock(&gspca_dev->usb_lock);
2560 flush_work(&sd->work);
2561 mutex_lock(&gspca_dev->usb_lock);
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002562}
2563
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002564static void do_autogain(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002565{
2566 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002567 int delta;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002568 int expotimes;
Jean-Francois Moine98819182009-01-19 07:37:33 -03002569 u8 luma_mean = 130;
2570 u8 luma_delta = 20;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002571
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002572 /* Thanks S., without your advice, autobright should not work :) */
2573 if (sd->ag_cnt < 0)
2574 return;
2575 if (--sd->ag_cnt >= 0)
2576 return;
2577 sd->ag_cnt = AG_CNT_START;
2578
2579 delta = atomic_read(&sd->avg_lum);
Joe Perches37d5efb2017-09-22 15:20:33 -04002580 gspca_dbg(gspca_dev, D_FRAM, "mean lum %d\n", delta);
Jean-François Moinea7705c02012-02-27 06:57:04 -03002581
2582 if (sd->sensor == SENSOR_PO2030N) {
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002583 gspca_expo_autogain(gspca_dev, delta, luma_mean, luma_delta,
Jean-François Moinea7705c02012-02-27 06:57:04 -03002584 15, 1024);
2585 return;
2586 }
2587
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002588 if (delta < luma_mean - luma_delta ||
2589 delta > luma_mean + luma_delta) {
2590 switch (sd->sensor) {
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002591 case SENSOR_GC0307:
2592 expotimes = sd->exposure;
2593 expotimes += (luma_mean - delta) >> 6;
2594 if (expotimes < 0)
2595 expotimes = 0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03002596 sd->exposure = expo_adjust(gspca_dev,
Jean-François Moinec26b12d2010-04-02 07:08:39 -03002597 (unsigned int) expotimes);
2598 break;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002599 case SENSOR_HV7131R:
2600 expotimes = sd->exposure >> 8;
2601 expotimes += (luma_mean - delta) >> 4;
2602 if (expotimes < 0)
2603 expotimes = 0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03002604 sd->exposure = expo_adjust(gspca_dev,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002605 (unsigned int) (expotimes << 8));
2606 break;
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002607 case SENSOR_OM6802:
Jean-François Moine22203672011-02-10 07:49:32 -03002608 case SENSOR_MT9V111:
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002609 expotimes = sd->exposure;
2610 expotimes += (luma_mean - delta) >> 2;
2611 if (expotimes < 0)
2612 expotimes = 0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03002613 sd->exposure = expo_adjust(gspca_dev,
Amauri Magagna46b4f2a2009-10-17 07:21:29 -03002614 (unsigned int) expotimes);
2615 setredblue(gspca_dev);
2616 break;
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002617 default:
2618/* case SENSOR_MO4000: */
2619/* case SENSOR_MI0360: */
Jean-François Moinea067db82010-10-01 07:51:24 -03002620/* case SENSOR_MI0360B: */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002621 expotimes = sd->exposure;
2622 expotimes += (luma_mean - delta) >> 6;
2623 if (expotimes < 0)
2624 expotimes = 0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03002625 sd->exposure = expo_adjust(gspca_dev,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002626 (unsigned int) expotimes);
Jean-Francois Moine403123d2008-11-26 04:46:15 -03002627 setredblue(gspca_dev);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002628 break;
2629 }
2630 }
2631}
2632
Jean-François Moine0f77f402011-02-10 07:01:30 -03002633/* set the average luminosity from an isoc marker */
2634static void set_lum(struct sd *sd,
2635 u8 *data)
2636{
2637 int avg_lum;
2638
2639 /* w0 w1 w2
2640 * w3 w4 w5
2641 * w6 w7 w8
2642 */
2643 avg_lum = (data[27] << 8) + data[28] /* w3 */
2644
2645 + (data[31] << 8) + data[32] /* w5 */
2646
2647 + (data[23] << 8) + data[24] /* w1 */
2648
2649 + (data[35] << 8) + data[36] /* w7 */
2650
2651 + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */
2652 avg_lum >>= 10;
2653 atomic_set(&sd->avg_lum, avg_lum);
2654}
2655
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002656/* scan the URB packets */
2657/* This function is run at interrupt level. */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002658static void sd_pkt_scan(struct gspca_dev *gspca_dev,
Jean-Francois Moine98819182009-01-19 07:37:33 -03002659 u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002660 int len) /* iso packet length */
2661{
2662 struct sd *sd = (struct sd *) gspca_dev;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002663 int i, new_qual;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002664
Jean-François Moinea4a30762011-02-10 07:15:24 -03002665 /*
2666 * A frame ends on the marker
2667 * ff ff 00 c4 c4 96 ..
2668 * which is 62 bytes long and is followed by various information
2669 * including statuses and luminosity.
2670 *
Mauro Carvalho Chehab3e4d8f42019-02-18 14:29:03 -05002671 * A marker may be split on two packets.
Jean-François Moinea4a30762011-02-10 07:15:24 -03002672 *
2673 * The 6th byte of a marker contains the bits:
2674 * 0x08: USB full
2675 * 0xc0: frame sequence
2676 * When the bit 'USB full' is set, the frame must be discarded;
2677 * this is also the case when the 2 bytes before the marker are
2678 * not the JPEG end of frame ('ff d9').
2679 */
2680
Jean-François Moine788ab1b2012-05-02 04:05:18 -03002681 /* count the packets and their size */
2682 sd->npkt++;
2683 sd->pktsz += len;
2684
Jean-François Moinea4a30762011-02-10 07:15:24 -03002685/*fixme: assumption about the following code:
2686 * - there can be only one marker in a packet
2687 */
2688
2689 /* skip the remaining bytes of a short marker */
2690 i = sd->short_mark;
2691 if (i != 0) {
2692 sd->short_mark = 0;
2693 if (i < 0 /* if 'ff' at end of previous packet */
2694 && data[0] == 0xff
2695 && data[1] == 0x00)
2696 goto marker_found;
2697 if (data[0] == 0xff && data[1] == 0xff) {
2698 i = 0;
2699 goto marker_found;
2700 }
2701 len -= i;
2702 if (len <= 0)
2703 return;
2704 data += i;
2705 }
2706
2707 /* search backwards if there is a marker in the packet */
2708 for (i = len - 1; --i >= 0; ) {
2709 if (data[i] != 0xff) {
2710 i--;
2711 continue;
2712 }
2713 if (data[i + 1] == 0xff) {
2714
2715 /* (there may be 'ff ff' inside a marker) */
2716 if (i + 2 >= len || data[i + 2] == 0x00)
2717 goto marker_found;
2718 }
2719 }
2720
2721 /* no marker found */
2722 /* add the JPEG header if first fragment */
2723 if (data[len - 1] == 0xff)
2724 sd->short_mark = -1;
2725 if (gspca_dev->last_packet_type == LAST_PACKET)
Jean-François Moinea95bd642010-10-01 07:54:30 -03002726 gspca_frame_add(gspca_dev, FIRST_PACKET,
2727 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-François Moinea95bd642010-10-01 07:54:30 -03002728 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
Jean-François Moinea4a30762011-02-10 07:15:24 -03002729 return;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002730
Jean-François Moinea4a30762011-02-10 07:15:24 -03002731 /* marker found */
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002732 /* if some error, discard the frame and decrease the quality */
Jean-François Moinea4a30762011-02-10 07:15:24 -03002733marker_found:
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002734 new_qual = 0;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002735 if (i > 2) {
2736 if (data[i - 2] != 0xff || data[i - 1] != 0xd9) {
2737 gspca_dev->last_packet_type = DISCARD_PACKET;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002738 new_qual = -3;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002739 }
2740 } else if (i + 6 < len) {
2741 if (data[i + 6] & 0x08) {
2742 gspca_dev->last_packet_type = DISCARD_PACKET;
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002743 new_qual = -5;
Jean-François Moinea4a30762011-02-10 07:15:24 -03002744 }
2745 }
Jean-François Moinea95bd642010-10-01 07:54:30 -03002746
Jean-François Moinea4a30762011-02-10 07:15:24 -03002747 gspca_frame_add(gspca_dev, LAST_PACKET, data, i);
2748
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002749 /* compute the filling rate and a new JPEG quality */
2750 if (new_qual == 0) {
2751 int r;
2752
2753 r = (sd->pktsz * 100) /
2754 (sd->npkt *
2755 gspca_dev->urb[0]->iso_frame_desc[0].length);
2756 if (r >= 85)
2757 new_qual = -3;
2758 else if (r < 75)
2759 new_qual = 2;
2760 }
2761 if (new_qual != 0) {
2762 sd->nchg += new_qual;
2763 if (sd->nchg < -6 || sd->nchg >= 12) {
2764 sd->nchg = 0;
2765 new_qual += sd->quality;
2766 if (new_qual < QUALITY_MIN)
2767 new_qual = QUALITY_MIN;
2768 else if (new_qual > QUALITY_MAX)
2769 new_qual = QUALITY_MAX;
2770 if (new_qual != sd->quality) {
2771 sd->quality = new_qual;
Bhaktipriya Shridharc994be42016-07-16 05:50:28 -03002772 schedule_work(&sd->work);
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002773 }
2774 }
2775 } else {
2776 sd->nchg = 0;
2777 }
2778 sd->pktsz = sd->npkt = 0;
2779
Jean-François Moinea4a30762011-02-10 07:15:24 -03002780 /* if the marker is smaller than 62 bytes,
2781 * memorize the number of bytes to skip in the next packet */
2782 if (i + 62 > len) { /* no more usable data */
2783 sd->short_mark = i + 62 - len;
2784 return;
2785 }
Jean-François Moine0f77f402011-02-10 07:01:30 -03002786 if (sd->ag_cnt >= 0)
Jean-François Moinea4a30762011-02-10 07:15:24 -03002787 set_lum(sd, data + i);
2788
2789 /* if more data, start a new frame */
2790 i += 62;
2791 if (i < len) {
2792 data += i;
2793 len -= i;
2794 gspca_frame_add(gspca_dev, FIRST_PACKET,
2795 sd->jpeg_hdr, JPEG_HDR_SZ);
2796 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2797 }
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002798}
2799
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002800static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
Jean-François Moinea7705c02012-02-27 06:57:04 -03002801{
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002802 struct gspca_dev *gspca_dev =
2803 container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
Jean-François Moinea7705c02012-02-27 06:57:04 -03002804
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002805 gspca_dev->usb_err = 0;
Jean-François Moinea7705c02012-02-27 06:57:04 -03002806
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002807 if (!gspca_dev->streaming)
2808 return 0;
2809
2810 switch (ctrl->id) {
2811 case V4L2_CID_BRIGHTNESS:
2812 setbrightness(gspca_dev);
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002813 break;
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002814 case V4L2_CID_CONTRAST:
2815 setcontrast(gspca_dev);
2816 break;
2817 case V4L2_CID_SATURATION:
2818 setcolors(gspca_dev);
2819 break;
2820 case V4L2_CID_RED_BALANCE:
2821 setredblue(gspca_dev);
2822 break;
2823 case V4L2_CID_GAMMA:
2824 setgamma(gspca_dev);
2825 break;
2826 case V4L2_CID_AUTOGAIN:
2827 setautogain(gspca_dev);
2828 setexposure(gspca_dev);
2829 setgain(gspca_dev);
2830 break;
2831 case V4L2_CID_VFLIP:
2832 sethvflip(gspca_dev);
2833 break;
2834 case V4L2_CID_SHARPNESS:
2835 setsharpness(gspca_dev);
2836 break;
2837 case V4L2_CID_ILLUMINATORS_1:
2838 setillum(gspca_dev);
2839 break;
2840 case V4L2_CID_POWER_LINE_FREQUENCY:
2841 setfreq(gspca_dev);
2842 break;
2843 default:
2844 return -EINVAL;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002845 }
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002846 return gspca_dev->usb_err;
Hans de Goede37c6dbe2009-06-18 07:35:36 -03002847}
2848
Peter Senna Tschudinf11ef422013-01-24 19:29:08 -03002849#if IS_ENABLED(CONFIG_INPUT)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002850static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2851 u8 *data, /* interrupt packet data */
2852 int len) /* interrupt packet length */
2853{
2854 int ret = -EINVAL;
2855
2856 if (len == 1 && data[0] == 1) {
2857 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2858 input_sync(gspca_dev->input_dev);
2859 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2860 input_sync(gspca_dev->input_dev);
2861 ret = 0;
2862 }
2863
2864 return ret;
2865}
2866#endif
2867
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002868/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -03002869static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002870 .name = MODULE_NAME,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002871 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -03002872 .init = sd_init,
Hans Verkuilc1f07ab2013-02-11 06:31:12 -03002873 .init_controls = sd_init_controls,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002874 .start = sd_start,
2875 .stopN = sd_stopN,
Jean-François Moineb96cfc33e2011-02-10 07:38:58 -03002876 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002877 .pkt_scan = sd_pkt_scan,
Jean-Francois Moinecebf3b62008-08-03 07:52:53 -03002878 .dq_callback = do_autogain,
Peter Senna Tschudinf11ef422013-01-24 19:29:08 -03002879#if IS_ENABLED(CONFIG_INPUT)
Hans de Goede9712a8b2010-01-31 12:54:29 -03002880 .int_pkt_scan = sd_int_pkt_scan,
2881#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002882};
2883
2884/* -- module initialisation -- */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002885#define BS(bridge, sensor) \
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -03002886 .driver_info = (BRIDGE_ ## bridge << 16) \
Jean-Francois Moinec6c14332010-12-14 16:15:37 -03002887 | (SENSOR_ ## sensor << 8)
2888#define BSF(bridge, sensor, flags) \
2889 .driver_info = (BRIDGE_ ## bridge << 16) \
2890 | (SENSOR_ ## sensor << 8) \
2891 | (flags)
Jean-François Moine95c967c2011-01-13 05:20:29 -03002892static const struct usb_device_id device_table[] = {
Jean-Francois Moinef9798ef2012-05-28 14:05:25 -03002893 {USB_DEVICE(0x0458, 0x7025), BSF(SN9C120, MI0360B, F_PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002894 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
Jean-François Moine3afef852011-01-13 06:39:11 -03002895 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)},
2896 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002897 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2898 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2899 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2900 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2901 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2902/* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2903 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2904/* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2905/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2906 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2907/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
Jean-François Moine3afef852011-01-13 06:39:11 -03002908 {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002909 /* or MT9V111 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002910/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2911/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2912/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
Warren Bosworth Fockec4f95d82010-05-07 15:40:04 -03002913 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002914 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2915/* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2916/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
Jean-François Moine68046752010-05-07 15:35:08 -03002917/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002918 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002919 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2920 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002921 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
Jean-François Moine860e7f42010-09-13 06:40:17 -03002922 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002923/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2924 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2925 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2926 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2927 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2928/* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2929/* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2930/* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2931 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
Jean-Francois Moined2d16e92008-09-03 16:47:23 -03002932/*bw600.inf:*/
Jean-Francois Moineb8c8a5b2009-11-23 06:46:35 -03002933 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
Alexander Goncharov2a3b5012010-09-13 06:58:16 -03002934 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002935 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2936 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2937/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002938 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
Jean-François Moinea067db82010-10-01 07:51:24 -03002939 /* or MT9V111 / MI0360B */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002940/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2941 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2942 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002943 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002944 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2945 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
Jean-François Moinead98c0f2010-03-18 05:15:30 -03002946 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
Jean-François Moine68046752010-05-07 15:35:08 -03002947 /* or GC0305 / GC0307 */
Jean-Francois Moined5aa3852009-11-07 06:10:08 -03002948 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2949 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
Jean-François Moinea63d6012011-01-13 07:56:00 -03002950 {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)},
Hans de Goedee48d38f2011-01-06 16:21:57 -03002951/* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002952 {}
2953};
2954MODULE_DEVICE_TABLE(usb, device_table);
2955
2956/* -- device connect -- */
2957static int sd_probe(struct usb_interface *intf,
2958 const struct usb_device_id *id)
2959{
2960 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2961 THIS_MODULE);
2962}
2963
2964static struct usb_driver sd_driver = {
2965 .name = MODULE_NAME,
2966 .id_table = device_table,
2967 .probe = sd_probe,
2968 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002969#ifdef CONFIG_PM
2970 .suspend = gspca_suspend,
2971 .resume = gspca_resume,
Hans de Goede8bb58962012-06-30 06:44:47 -03002972 .reset_resume = gspca_resume,
Jean-Francois Moine6a709742008-09-03 16:48:10 -03002973#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03002974};
2975
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -08002976module_usb_driver(sd_driver);