aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c926
1 files changed, 445 insertions, 481 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 370544361be2..330dadc00106 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -31,24 +31,32 @@ MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33 33
34/* controls */
35enum e_ctrl {
36 BRIGHTNESS,
37 CONTRAST,
38 COLORS,
39 BLUE,
40 RED,
41 GAMMA,
42 AUTOGAIN,
43 HFLIP,
44 VFLIP,
45 SHARPNESS,
46 INFRARED,
47 FREQ,
48 NCTRLS /* number of controls */
49};
50
34/* specific webcam descriptor */ 51/* specific webcam descriptor */
35struct sd { 52struct sd {
36 struct gspca_dev gspca_dev; /* !! must be the first item */ 53 struct gspca_dev gspca_dev; /* !! must be the first item */
37 54
55 struct gspca_ctrl ctrls[NCTRLS];
56
38 atomic_t avg_lum; 57 atomic_t avg_lum;
39 u32 exposure; 58 u32 exposure;
40 59
41 u16 brightness;
42 u8 contrast;
43 u8 colors;
44 u8 autogain;
45 u8 blue;
46 u8 red;
47 u8 gamma;
48 u8 vflip; /* ov7630/ov7648 only */
49 u8 sharpness;
50 u8 infrared; /* mt9v111 only */
51 u8 freq; /* ov76xx only */
52 u8 quality; /* image quality */ 60 u8 quality; /* image quality */
53#define QUALITY_MIN 60 61#define QUALITY_MIN 60
54#define QUALITY_MAX 95 62#define QUALITY_MAX 95
@@ -75,6 +83,7 @@ enum sensors {
75 SENSOR_GC0307, 83 SENSOR_GC0307,
76 SENSOR_HV7131R, 84 SENSOR_HV7131R,
77 SENSOR_MI0360, 85 SENSOR_MI0360,
86 SENSOR_MI0360B,
78 SENSOR_MO4000, 87 SENSOR_MO4000,
79 SENSOR_MT9V111, 88 SENSOR_MT9V111,
80 SENSOR_OM6802, 89 SENSOR_OM6802,
@@ -88,48 +97,31 @@ enum sensors {
88}; 97};
89 98
90/* V4L2 controls supported by the driver */ 99/* V4L2 controls supported by the driver */
91static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); 100static void setbrightness(struct gspca_dev *gspca_dev);
92static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 101static void setcontrast(struct gspca_dev *gspca_dev);
93static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); 102static void setcolors(struct gspca_dev *gspca_dev);
94static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 103static void setredblue(struct gspca_dev *gspca_dev);
95static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); 104static void setgamma(struct gspca_dev *gspca_dev);
96static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 105static void setautogain(struct gspca_dev *gspca_dev);
97static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); 106static void sethvflip(struct gspca_dev *gspca_dev);
98static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); 107static void setsharpness(struct gspca_dev *gspca_dev);
99static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); 108static void setinfrared(struct gspca_dev *gspca_dev);
100static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); 109static void setfreq(struct gspca_dev *gspca_dev);
101static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); 110
102static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); 111static const struct ctrl sd_ctrls[NCTRLS] = {
103static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 112[BRIGHTNESS] = {
104static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
105static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
106static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
107static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
108static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
109static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
110static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
111static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
112static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
113
114static const struct ctrl sd_ctrls[] = {
115#define BRIGHTNESS_IDX 0
116 {
117 { 113 {
118 .id = V4L2_CID_BRIGHTNESS, 114 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER, 115 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness", 116 .name = "Brightness",
121 .minimum = 0, 117 .minimum = 0,
122#define BRIGHTNESS_MAX 0xffff 118 .maximum = 0xff,
123 .maximum = BRIGHTNESS_MAX,
124 .step = 1, 119 .step = 1,
125#define BRIGHTNESS_DEF 0x8000 120 .default_value = 0x80,
126 .default_value = BRIGHTNESS_DEF,
127 }, 121 },
128 .set = sd_setbrightness, 122 .set_control = setbrightness
129 .get = sd_getbrightness,
130 }, 123 },
131#define CONTRAST_IDX 1 124[CONTRAST] = {
132 {
133 { 125 {
134 .id = V4L2_CID_CONTRAST, 126 .id = V4L2_CID_CONTRAST,
135 .type = V4L2_CTRL_TYPE_INTEGER, 127 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -138,14 +130,11 @@ static const struct ctrl sd_ctrls[] = {
138#define CONTRAST_MAX 127 130#define CONTRAST_MAX 127
139 .maximum = CONTRAST_MAX, 131 .maximum = CONTRAST_MAX,
140 .step = 1, 132 .step = 1,
141#define CONTRAST_DEF 63 133 .default_value = 63,
142 .default_value = CONTRAST_DEF,
143 }, 134 },
144 .set = sd_setcontrast, 135 .set_control = setcontrast
145 .get = sd_getcontrast,
146 }, 136 },
147#define COLOR_IDX 2 137[COLORS] = {
148 {
149 { 138 {
150 .id = V4L2_CID_SATURATION, 139 .id = V4L2_CID_SATURATION,
151 .type = V4L2_CTRL_TYPE_INTEGER, 140 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -153,14 +142,12 @@ static const struct ctrl sd_ctrls[] = {
153 .minimum = 0, 142 .minimum = 0,
154 .maximum = 40, 143 .maximum = 40,
155 .step = 1, 144 .step = 1,
156#define COLOR_DEF 25 145#define COLORS_DEF 25
157 .default_value = COLOR_DEF, 146 .default_value = COLORS_DEF,
158 }, 147 },
159 .set = sd_setcolors, 148 .set_control = setcolors
160 .get = sd_getcolors,
161 }, 149 },
162#define BLUE_BALANCE_IDX 3 150[BLUE] = {
163 {
164 { 151 {
165 .id = V4L2_CID_BLUE_BALANCE, 152 .id = V4L2_CID_BLUE_BALANCE,
166 .type = V4L2_CTRL_TYPE_INTEGER, 153 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -168,14 +155,11 @@ static const struct ctrl sd_ctrls[] = {
168 .minimum = 24, 155 .minimum = 24,
169 .maximum = 40, 156 .maximum = 40,
170 .step = 1, 157 .step = 1,
171#define BLUE_BALANCE_DEF 32 158 .default_value = 32,
172 .default_value = BLUE_BALANCE_DEF,
173 }, 159 },
174 .set = sd_setblue_balance, 160 .set_control = setredblue
175 .get = sd_getblue_balance,
176 }, 161 },
177#define RED_BALANCE_IDX 4 162[RED] = {
178 {
179 { 163 {
180 .id = V4L2_CID_RED_BALANCE, 164 .id = V4L2_CID_RED_BALANCE,
181 .type = V4L2_CTRL_TYPE_INTEGER, 165 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -183,14 +167,11 @@ static const struct ctrl sd_ctrls[] = {
183 .minimum = 24, 167 .minimum = 24,
184 .maximum = 40, 168 .maximum = 40,
185 .step = 1, 169 .step = 1,
186#define RED_BALANCE_DEF 32 170 .default_value = 32,
187 .default_value = RED_BALANCE_DEF,
188 }, 171 },
189 .set = sd_setred_balance, 172 .set_control = setredblue
190 .get = sd_getred_balance,
191 }, 173 },
192#define GAMMA_IDX 5 174[GAMMA] = {
193 {
194 { 175 {
195 .id = V4L2_CID_GAMMA, 176 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER, 177 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -201,11 +182,9 @@ static const struct ctrl sd_ctrls[] = {
201#define GAMMA_DEF 20 182#define GAMMA_DEF 20
202 .default_value = GAMMA_DEF, 183 .default_value = GAMMA_DEF,
203 }, 184 },
204 .set = sd_setgamma, 185 .set_control = setgamma
205 .get = sd_getgamma,
206 }, 186 },
207#define AUTOGAIN_IDX 6 187[AUTOGAIN] = {
208 {
209 { 188 {
210 .id = V4L2_CID_AUTOGAIN, 189 .id = V4L2_CID_AUTOGAIN,
211 .type = V4L2_CTRL_TYPE_BOOLEAN, 190 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -213,15 +192,23 @@ static const struct ctrl sd_ctrls[] = {
213 .minimum = 0, 192 .minimum = 0,
214 .maximum = 1, 193 .maximum = 1,
215 .step = 1, 194 .step = 1,
216#define AUTOGAIN_DEF 1 195 .default_value = 1
217 .default_value = AUTOGAIN_DEF, 196 },
197 .set_control = setautogain
198 },
199[HFLIP] = {
200 {
201 .id = V4L2_CID_HFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
203 .name = "Mirror",
204 .minimum = 0,
205 .maximum = 1,
206 .step = 1,
207 .default_value = 0,
218 }, 208 },
219 .set = sd_setautogain, 209 .set_control = sethvflip
220 .get = sd_getautogain,
221 }, 210 },
222/* ov7630/ov7648 only */ 211[VFLIP] = {
223#define VFLIP_IDX 7
224 {
225 { 212 {
226 .id = V4L2_CID_VFLIP, 213 .id = V4L2_CID_VFLIP,
227 .type = V4L2_CTRL_TYPE_BOOLEAN, 214 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -229,14 +216,11 @@ static const struct ctrl sd_ctrls[] = {
229 .minimum = 0, 216 .minimum = 0,
230 .maximum = 1, 217 .maximum = 1,
231 .step = 1, 218 .step = 1,
232#define VFLIP_DEF 0 219 .default_value = 0,
233 .default_value = VFLIP_DEF,
234 }, 220 },
235 .set = sd_setvflip, 221 .set_control = sethvflip
236 .get = sd_getvflip,
237 }, 222 },
238#define SHARPNESS_IDX 8 223[SHARPNESS] = {
239 {
240 { 224 {
241 .id = V4L2_CID_SHARPNESS, 225 .id = V4L2_CID_SHARPNESS,
242 .type = V4L2_CTRL_TYPE_INTEGER, 226 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -244,15 +228,12 @@ static const struct ctrl sd_ctrls[] = {
244 .minimum = 0, 228 .minimum = 0,
245 .maximum = 255, 229 .maximum = 255,
246 .step = 1, 230 .step = 1,
247#define SHARPNESS_DEF 90 231 .default_value = 90,
248 .default_value = SHARPNESS_DEF,
249 }, 232 },
250 .set = sd_setsharpness, 233 .set_control = setsharpness
251 .get = sd_getsharpness,
252 }, 234 },
253/* mt9v111 only */ 235/* mt9v111 only */
254#define INFRARED_IDX 9 236[INFRARED] = {
255 {
256 { 237 {
257 .id = V4L2_CID_INFRARED, 238 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN, 239 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -260,15 +241,12 @@ static const struct ctrl sd_ctrls[] = {
260 .minimum = 0, 241 .minimum = 0,
261 .maximum = 1, 242 .maximum = 1,
262 .step = 1, 243 .step = 1,
263#define INFRARED_DEF 0 244 .default_value = 0,
264 .default_value = INFRARED_DEF,
265 }, 245 },
266 .set = sd_setinfrared, 246 .set_control = setinfrared
267 .get = sd_getinfrared,
268 }, 247 },
269/* ov7630/ov7648/ov7660 only */ 248/* ov7630/ov7648/ov7660 only */
270#define FREQ_IDX 10 249[FREQ] = {
271 {
272 { 250 {
273 .id = V4L2_CID_POWER_LINE_FREQUENCY, 251 .id = V4L2_CID_POWER_LINE_FREQUENCY,
274 .type = V4L2_CTRL_TYPE_MENU, 252 .type = V4L2_CTRL_TYPE_MENU,
@@ -276,69 +254,85 @@ static const struct ctrl sd_ctrls[] = {
276 .minimum = 0, 254 .minimum = 0,
277 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ 255 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
278 .step = 1, 256 .step = 1,
279#define FREQ_DEF 1 257 .default_value = 1,
280 .default_value = FREQ_DEF,
281 }, 258 },
282 .set = sd_setfreq, 259 .set_control = setfreq
283 .get = sd_getfreq,
284 }, 260 },
285}; 261};
286 262
287/* table of the disabled controls */ 263/* table of the disabled controls */
288static const __u32 ctrl_dis[] = { 264static const __u32 ctrl_dis[] = {
289[SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) | 265[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
290 (1 << INFRARED_IDX) | 266 (1 << INFRARED) |
291 (1 << VFLIP_IDX) | 267 (1 << HFLIP) |
292 (1 << FREQ_IDX), 268 (1 << VFLIP) |
293 269 (1 << FREQ),
294[SENSOR_GC0307] = (1 << INFRARED_IDX) | 270
295 (1 << VFLIP_IDX) | 271[SENSOR_GC0307] = (1 << INFRARED) |
296 (1 << FREQ_IDX), 272 (1 << HFLIP) |
297 273 (1 << VFLIP) |
298[SENSOR_HV7131R] = (1 << INFRARED_IDX) | 274 (1 << FREQ),
299 (1 << FREQ_IDX), 275
300 276[SENSOR_HV7131R] = (1 << INFRARED) |
301[SENSOR_MI0360] = (1 << INFRARED_IDX) | 277 (1 << HFLIP) |
302 (1 << VFLIP_IDX) | 278 (1 << FREQ),
303 (1 << FREQ_IDX), 279
304 280[SENSOR_MI0360] = (1 << INFRARED) |
305[SENSOR_MO4000] = (1 << INFRARED_IDX) | 281 (1 << HFLIP) |
306 (1 << VFLIP_IDX) | 282 (1 << VFLIP) |
307 (1 << FREQ_IDX), 283 (1 << FREQ),
308 284
309[SENSOR_MT9V111] = (1 << VFLIP_IDX) | 285[SENSOR_MI0360B] = (1 << INFRARED) |
310 (1 << FREQ_IDX), 286 (1 << HFLIP) |
311 287 (1 << VFLIP) |
312[SENSOR_OM6802] = (1 << INFRARED_IDX) | 288 (1 << FREQ),
313 (1 << VFLIP_IDX) | 289
314 (1 << FREQ_IDX), 290[SENSOR_MO4000] = (1 << INFRARED) |
315 291 (1 << HFLIP) |
316[SENSOR_OV7630] = (1 << INFRARED_IDX), 292 (1 << VFLIP) |
317 293 (1 << FREQ),
318[SENSOR_OV7648] = (1 << INFRARED_IDX), 294
319 295[SENSOR_MT9V111] = (1 << HFLIP) |
320[SENSOR_OV7660] = (1 << AUTOGAIN_IDX) | 296 (1 << VFLIP) |
321 (1 << INFRARED_IDX) | 297 (1 << FREQ),
322 (1 << VFLIP_IDX), 298
323 299[SENSOR_OM6802] = (1 << INFRARED) |
324[SENSOR_PO1030] = (1 << AUTOGAIN_IDX) | 300 (1 << HFLIP) |
325 (1 << INFRARED_IDX) | 301 (1 << VFLIP) |
326 (1 << VFLIP_IDX) | 302 (1 << FREQ),
327 (1 << FREQ_IDX), 303
328 304[SENSOR_OV7630] = (1 << INFRARED) |
329[SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) | 305 (1 << HFLIP),
330 (1 << INFRARED_IDX) | 306
331 (1 << VFLIP_IDX) | 307[SENSOR_OV7648] = (1 << INFRARED) |
332 (1 << FREQ_IDX), 308 (1 << HFLIP),
333[SENSOR_SOI768] = (1 << AUTOGAIN_IDX) | 309
334 (1 << INFRARED_IDX) | 310[SENSOR_OV7660] = (1 << AUTOGAIN) |
335 (1 << VFLIP_IDX) | 311 (1 << INFRARED) |
336 (1 << FREQ_IDX), 312 (1 << HFLIP) |
337 313 (1 << VFLIP),
338[SENSOR_SP80708] = (1 << AUTOGAIN_IDX) | 314
339 (1 << INFRARED_IDX) | 315[SENSOR_PO1030] = (1 << AUTOGAIN) |
340 (1 << VFLIP_IDX) | 316 (1 << INFRARED) |
341 (1 << FREQ_IDX), 317 (1 << HFLIP) |
318 (1 << VFLIP) |
319 (1 << FREQ),
320
321[SENSOR_PO2030N] = (1 << AUTOGAIN) |
322 (1 << INFRARED) |
323 (1 << FREQ),
324
325[SENSOR_SOI768] = (1 << AUTOGAIN) |
326 (1 << INFRARED) |
327 (1 << HFLIP) |
328 (1 << VFLIP) |
329 (1 << FREQ),
330
331[SENSOR_SP80708] = (1 << AUTOGAIN) |
332 (1 << INFRARED) |
333 (1 << HFLIP) |
334 (1 << VFLIP) |
335 (1 << FREQ),
342}; 336};
343 337
344static const struct v4l2_pix_format cif_mode[] = { 338static const struct v4l2_pix_format cif_mode[] = {
@@ -411,6 +405,17 @@ static const u8 sn_mi0360[0x1c] = {
411 0x06, 0x00, 0x00, 0x00 405 0x06, 0x00, 0x00, 0x00
412}; 406};
413 407
408static const u8 sn_mi0360b[0x1c] = {
409/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
410 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
411/* reg8 reg9 rega regb regc regd rege regf */
412 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
414 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
415/* reg18 reg19 reg1a reg1b */
416 0x06, 0x00, 0x00, 0x00
417};
418
414static const u8 sn_mo4000[0x1c] = { 419static const u8 sn_mo4000[0x1c] = {
415/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 420/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
416 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, 421 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
@@ -527,6 +532,7 @@ static const u8 *sn_tb[] = {
527[SENSOR_GC0307] = sn_gc0307, 532[SENSOR_GC0307] = sn_gc0307,
528[SENSOR_HV7131R] = sn_hv7131, 533[SENSOR_HV7131R] = sn_hv7131,
529[SENSOR_MI0360] = sn_mi0360, 534[SENSOR_MI0360] = sn_mi0360,
535[SENSOR_MI0360B] = sn_mi0360b,
530[SENSOR_MO4000] = sn_mo4000, 536[SENSOR_MO4000] = sn_mo4000,
531[SENSOR_MT9V111] = sn_mt9v111, 537[SENSOR_MT9V111] = sn_mt9v111,
532[SENSOR_OM6802] = sn_om6802, 538[SENSOR_OM6802] = sn_om6802,
@@ -572,20 +578,23 @@ static const u8 reg84[] = {
572 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ 578 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
573 0x00, 0x00, 0x00 /* YUV offsets */ 579 0x00, 0x00, 0x00 /* YUV offsets */
574}; 580};
581
582#define DELAY 0xdd
583
575static const u8 adcm1700_sensor_init[][8] = { 584static const u8 adcm1700_sensor_init[][8] = {
576 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, 585 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
577 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ 586 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
578 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 587 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
579 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, 588 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
580 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 589 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
581 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, 590 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
582 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, 591 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
583 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, 592 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
584 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, 593 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
585 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, 594 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
586 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 595 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
587 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, 596 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
588 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 597 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
589 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, 598 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
590 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, 599 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
591 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, 600 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
@@ -629,7 +638,7 @@ static const u8 gc0307_sensor_init[][8] = {
629 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, 638 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, 639 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, 640 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
632 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ 641 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
633 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, 642 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, 643 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, 644 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
@@ -747,6 +756,62 @@ static const u8 mi0360_sensor_init[][8] = {
747 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ 756 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
748 {} 757 {}
749}; 758};
759static const u8 mi0360b_sensor_init[][8] = {
760 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
761 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
762 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
763 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
764 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
765 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
766 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
767 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
769 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
770 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
771 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
773 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
774 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
775 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
784 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
785 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
787 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
789 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
791 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
794 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
795
796 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
797 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
798 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
799 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
800 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
801 {}
802};
803static const u8 mi0360b_sensor_param1[][8] = {
804 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
807 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
808
809 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
810 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
811 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
812 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
813 {}
814};
750static const u8 mo4000_sensor_init[][8] = { 815static const u8 mo4000_sensor_init[][8] = {
751 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, 816 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, 817 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
@@ -772,7 +837,7 @@ static const u8 mo4000_sensor_init[][8] = {
772}; 837};
773static const u8 mt9v111_sensor_init[][8] = { 838static const u8 mt9v111_sensor_init[][8] = {
774 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ 839 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
775 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 840 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
776 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, 841 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ 842 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
778 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ 843 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
@@ -860,10 +925,10 @@ static const u8 om6802_sensor_param1[][8] = {
860static const u8 ov7630_sensor_init[][8] = { 925static const u8 ov7630_sensor_init[][8] = {
861 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, 926 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, 927 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
863 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 928 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
864 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, 929 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, 930 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
866 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 931 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
867 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, 932 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
868/* win: i2c_r from 00 to 80 */ 933/* win: i2c_r from 00 to 80 */
869 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, 934 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
@@ -917,7 +982,7 @@ static const u8 ov7630_sensor_param1[][8] = {
917static const u8 ov7648_sensor_init[][8] = { 982static const u8 ov7648_sensor_init[][8] = {
918 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, 983 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ 984 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
920 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 985 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
921 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, 986 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
922 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, 987 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
923 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, 988 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
@@ -966,7 +1031,7 @@ static const u8 ov7648_sensor_param1[][8] = {
966 1031
967static const u8 ov7660_sensor_init[][8] = { 1032static const u8 ov7660_sensor_init[][8] = {
968 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ 1033 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
969 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 1034 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
970 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 1035 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
971 /* Outformat = rawRGB */ 1036 /* Outformat = rawRGB */
972 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 1037 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
@@ -1062,7 +1127,7 @@ static const u8 ov7660_sensor_param1[][8] = {
1062static const u8 po1030_sensor_init[][8] = { 1127static const u8 po1030_sensor_init[][8] = {
1063/* the sensor registers are described in m5602/m5602_po1030.h */ 1128/* the sensor registers are described in m5602/m5602_po1030.h */
1064 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ 1129 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1065 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 1130 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1066 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, 1131 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1067 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, 1132 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1068 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, 1133 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
@@ -1116,10 +1181,10 @@ static const u8 po1030_sensor_param1[][8] = {
1116static const u8 po2030n_sensor_init[][8] = { 1181static const u8 po2030n_sensor_init[][8] = {
1117 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, 1182 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1118 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, 1183 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1119 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ 1184 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1120 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, 1185 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1121 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, 1186 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1122 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ 1187 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1123 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, 1188 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1124 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, 1189 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1125 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, 1190 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
@@ -1168,7 +1233,7 @@ static const u8 po2030n_sensor_init[][8] = {
1168}; 1233};
1169static const u8 po2030n_sensor_param1[][8] = { 1234static const u8 po2030n_sensor_param1[][8] = {
1170 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, 1235 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1171 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ 1236 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1172 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, 1237 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1173 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, 1238 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10}, 1239 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
@@ -1182,16 +1247,16 @@ static const u8 po2030n_sensor_param1[][8] = {
1182 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10}, 1247 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1183/*after start*/ 1248/*after start*/
1184 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10}, 1249 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1185 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ 1250 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1186 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10}, 1251 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1187 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ 1252 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1188 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10}, 1253 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1189 {} 1254 {}
1190}; 1255};
1191 1256
1192static const u8 soi768_sensor_init[][8] = { 1257static const u8 soi768_sensor_init[][8] = {
1193 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ 1258 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1194 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ 1259 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1195 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, 1260 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, 1261 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, 1262 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
@@ -1310,6 +1375,7 @@ static const u8 (*sensor_init[])[8] = {
1310[SENSOR_GC0307] = gc0307_sensor_init, 1375[SENSOR_GC0307] = gc0307_sensor_init,
1311[SENSOR_HV7131R] = hv7131r_sensor_init, 1376[SENSOR_HV7131R] = hv7131r_sensor_init,
1312[SENSOR_MI0360] = mi0360_sensor_init, 1377[SENSOR_MI0360] = mi0360_sensor_init,
1378[SENSOR_MI0360B] = mi0360b_sensor_init,
1313[SENSOR_MO4000] = mo4000_sensor_init, 1379[SENSOR_MO4000] = mo4000_sensor_init,
1314[SENSOR_MT9V111] = mt9v111_sensor_init, 1380[SENSOR_MT9V111] = mt9v111_sensor_init,
1315[SENSOR_OM6802] = om6802_sensor_init, 1381[SENSOR_OM6802] = om6802_sensor_init,
@@ -1326,13 +1392,17 @@ static const u8 (*sensor_init[])[8] = {
1326static void reg_r(struct gspca_dev *gspca_dev, 1392static void reg_r(struct gspca_dev *gspca_dev,
1327 u16 value, int len) 1393 u16 value, int len)
1328{ 1394{
1395 int ret;
1396
1397 if (gspca_dev->usb_err < 0)
1398 return;
1329#ifdef GSPCA_DEBUG 1399#ifdef GSPCA_DEBUG
1330 if (len > USB_BUF_SZ) { 1400 if (len > USB_BUF_SZ) {
1331 err("reg_r: buffer overflow"); 1401 err("reg_r: buffer overflow");
1332 return; 1402 return;
1333 } 1403 }
1334#endif 1404#endif
1335 usb_control_msg(gspca_dev->dev, 1405 ret = usb_control_msg(gspca_dev->dev,
1336 usb_rcvctrlpipe(gspca_dev->dev, 0), 1406 usb_rcvctrlpipe(gspca_dev->dev, 0),
1337 0, 1407 0,
1338 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1408 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1340,15 +1410,23 @@ static void reg_r(struct gspca_dev *gspca_dev,
1340 gspca_dev->usb_buf, len, 1410 gspca_dev->usb_buf, len,
1341 500); 1411 500);
1342 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); 1412 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
1413 if (ret < 0) {
1414 err("reg_r err %d", ret);
1415 gspca_dev->usb_err = ret;
1416 }
1343} 1417}
1344 1418
1345static void reg_w1(struct gspca_dev *gspca_dev, 1419static void reg_w1(struct gspca_dev *gspca_dev,
1346 u16 value, 1420 u16 value,
1347 u8 data) 1421 u8 data)
1348{ 1422{
1423 int ret;
1424
1425 if (gspca_dev->usb_err < 0)
1426 return;
1349 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); 1427 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
1350 gspca_dev->usb_buf[0] = data; 1428 gspca_dev->usb_buf[0] = data;
1351 usb_control_msg(gspca_dev->dev, 1429 ret = usb_control_msg(gspca_dev->dev,
1352 usb_sndctrlpipe(gspca_dev->dev, 0), 1430 usb_sndctrlpipe(gspca_dev->dev, 0),
1353 0x08, 1431 0x08,
1354 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1432 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1356,12 +1434,20 @@ static void reg_w1(struct gspca_dev *gspca_dev,
1356 0, 1434 0,
1357 gspca_dev->usb_buf, 1, 1435 gspca_dev->usb_buf, 1,
1358 500); 1436 500);
1437 if (ret < 0) {
1438 err("reg_w1 err %d", ret);
1439 gspca_dev->usb_err = ret;
1440 }
1359} 1441}
1360static void reg_w(struct gspca_dev *gspca_dev, 1442static void reg_w(struct gspca_dev *gspca_dev,
1361 u16 value, 1443 u16 value,
1362 const u8 *buffer, 1444 const u8 *buffer,
1363 int len) 1445 int len)
1364{ 1446{
1447 int ret;
1448
1449 if (gspca_dev->usb_err < 0)
1450 return;
1365 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", 1451 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1366 value, buffer[0], buffer[1]); 1452 value, buffer[0], buffer[1]);
1367#ifdef GSPCA_DEBUG 1453#ifdef GSPCA_DEBUG
@@ -1371,20 +1457,27 @@ static void reg_w(struct gspca_dev *gspca_dev,
1371 } 1457 }
1372#endif 1458#endif
1373 memcpy(gspca_dev->usb_buf, buffer, len); 1459 memcpy(gspca_dev->usb_buf, buffer, len);
1374 usb_control_msg(gspca_dev->dev, 1460 ret = usb_control_msg(gspca_dev->dev,
1375 usb_sndctrlpipe(gspca_dev->dev, 0), 1461 usb_sndctrlpipe(gspca_dev->dev, 0),
1376 0x08, 1462 0x08,
1377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1463 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1378 value, 0, 1464 value, 0,
1379 gspca_dev->usb_buf, len, 1465 gspca_dev->usb_buf, len,
1380 500); 1466 500);
1467 if (ret < 0) {
1468 err("reg_w err %d", ret);
1469 gspca_dev->usb_err = ret;
1470 }
1381} 1471}
1382 1472
1383/* I2C write 1 byte */ 1473/* I2C write 1 byte */
1384static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 1474static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1385{ 1475{
1386 struct sd *sd = (struct sd *) gspca_dev; 1476 struct sd *sd = (struct sd *) gspca_dev;
1477 int ret;
1387 1478
1479 if (gspca_dev->usb_err < 0)
1480 return;
1388 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); 1481 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
1389 switch (sd->sensor) { 1482 switch (sd->sensor) {
1390 case SENSOR_ADCM1700: 1483 case SENSOR_ADCM1700:
@@ -1403,7 +1496,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1403 gspca_dev->usb_buf[5] = 0; 1496 gspca_dev->usb_buf[5] = 0;
1404 gspca_dev->usb_buf[6] = 0; 1497 gspca_dev->usb_buf[6] = 0;
1405 gspca_dev->usb_buf[7] = 0x10; 1498 gspca_dev->usb_buf[7] = 0x10;
1406 usb_control_msg(gspca_dev->dev, 1499 ret = usb_control_msg(gspca_dev->dev,
1407 usb_sndctrlpipe(gspca_dev->dev, 0), 1500 usb_sndctrlpipe(gspca_dev->dev, 0),
1408 0x08, 1501 0x08,
1409 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1502 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1411,16 +1504,24 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1411 0, 1504 0,
1412 gspca_dev->usb_buf, 8, 1505 gspca_dev->usb_buf, 8,
1413 500); 1506 500);
1507 if (ret < 0) {
1508 err("i2c_w1 err %d", ret);
1509 gspca_dev->usb_err = ret;
1510 }
1414} 1511}
1415 1512
1416/* I2C write 8 bytes */ 1513/* I2C write 8 bytes */
1417static void i2c_w8(struct gspca_dev *gspca_dev, 1514static void i2c_w8(struct gspca_dev *gspca_dev,
1418 const u8 *buffer) 1515 const u8 *buffer)
1419{ 1516{
1517 int ret;
1518
1519 if (gspca_dev->usb_err < 0)
1520 return;
1420 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", 1521 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1421 buffer[2], buffer[3]); 1522 buffer[2], buffer[3]);
1422 memcpy(gspca_dev->usb_buf, buffer, 8); 1523 memcpy(gspca_dev->usb_buf, buffer, 8);
1423 usb_control_msg(gspca_dev->dev, 1524 ret = usb_control_msg(gspca_dev->dev,
1424 usb_sndctrlpipe(gspca_dev->dev, 0), 1525 usb_sndctrlpipe(gspca_dev->dev, 0),
1425 0x08, 1526 0x08,
1426 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1527 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1428,6 +1529,10 @@ static void i2c_w8(struct gspca_dev *gspca_dev,
1428 gspca_dev->usb_buf, 8, 1529 gspca_dev->usb_buf, 8,
1429 500); 1530 500);
1430 msleep(2); 1531 msleep(2);
1532 if (ret < 0) {
1533 err("i2c_w8 err %d", ret);
1534 gspca_dev->usb_err = ret;
1535 }
1431} 1536}
1432 1537
1433/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ 1538/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
@@ -1466,7 +1571,7 @@ static void i2c_w_seq(struct gspca_dev *gspca_dev,
1466 const u8 (*data)[8]) 1571 const u8 (*data)[8])
1467{ 1572{
1468 while ((*data)[0] != 0) { 1573 while ((*data)[0] != 0) {
1469 if ((*data)[0] != 0xdd) 1574 if ((*data)[0] != DELAY)
1470 i2c_w8(gspca_dev, *data); 1575 i2c_w8(gspca_dev, *data);
1471 else 1576 else
1472 msleep((*data)[1]); 1577 msleep((*data)[1]);
@@ -1529,7 +1634,13 @@ static void mi0360_probe(struct gspca_dev *gspca_dev)
1529 if (val != 0xffff) 1634 if (val != 0xffff)
1530 break; 1635 break;
1531 } 1636 }
1637 if (gspca_dev->usb_err < 0)
1638 return;
1532 switch (val) { 1639 switch (val) {
1640 case 0x8221:
1641 PDEBUG(D_PROBE, "Sensor mi0360b");
1642 sd->sensor = SENSOR_MI0360B;
1643 break;
1533 case 0x823a: 1644 case 0x823a:
1534 PDEBUG(D_PROBE, "Sensor mt9v111"); 1645 PDEBUG(D_PROBE, "Sensor mt9v111");
1535 sd->sensor = SENSOR_MT9V111; 1646 sd->sensor = SENSOR_MT9V111;
@@ -1556,6 +1667,8 @@ static void ov7630_probe(struct gspca_dev *gspca_dev)
1556 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1667 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1557 reg_w1(gspca_dev, 0x01, 0x29); 1668 reg_w1(gspca_dev, 0x01, 0x29);
1558 reg_w1(gspca_dev, 0x17, 0x42); 1669 reg_w1(gspca_dev, 0x17, 0x42);
1670 if (gspca_dev->usb_err < 0)
1671 return;
1559 if (val == 0x7628) { /* soi768 */ 1672 if (val == 0x7628) { /* soi768 */
1560 sd->sensor = SENSOR_SOI768; 1673 sd->sensor = SENSOR_SOI768;
1561/*fixme: only valid for 0c45:613e?*/ 1674/*fixme: only valid for 0c45:613e?*/
@@ -1593,13 +1706,14 @@ static void ov7648_probe(struct gspca_dev *gspca_dev)
1593 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1706 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1594 reg_w1(gspca_dev, 0x01, 0x29); 1707 reg_w1(gspca_dev, 0x01, 0x29);
1595 reg_w1(gspca_dev, 0x17, 0x42); 1708 reg_w1(gspca_dev, 0x17, 0x42);
1709 if (gspca_dev->usb_err < 0)
1710 return;
1596 if (val == 0x1030) { /* po1030 */ 1711 if (val == 0x1030) { /* po1030 */
1597 PDEBUG(D_PROBE, "Sensor po1030"); 1712 PDEBUG(D_PROBE, "Sensor po1030");
1598 sd->sensor = SENSOR_PO1030; 1713 sd->sensor = SENSOR_PO1030;
1599 return; 1714 return;
1600 } 1715 }
1601 1716 err("Unknown sensor %04x", val);
1602 PDEBUG(D_PROBE, "Unknown sensor %04x", val);
1603} 1717}
1604 1718
1605/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ 1719/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
@@ -1631,11 +1745,13 @@ static void po2030n_probe(struct gspca_dev *gspca_dev)
1631 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1745 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1632 reg_w1(gspca_dev, 0x01, 0x29); 1746 reg_w1(gspca_dev, 0x01, 0x29);
1633 reg_w1(gspca_dev, 0x17, 0x42); 1747 reg_w1(gspca_dev, 0x17, 0x42);
1748 if (gspca_dev->usb_err < 0)
1749 return;
1634 if (val == 0x2030) { 1750 if (val == 0x2030) {
1635 PDEBUG(D_PROBE, "Sensor po2030n"); 1751 PDEBUG(D_PROBE, "Sensor po2030n");
1636/* sd->sensor = SENSOR_PO2030N; */ 1752/* sd->sensor = SENSOR_PO2030N; */
1637 } else { 1753 } else {
1638 PDEBUG(D_PROBE, "Unknown sensor ID %04x", val); 1754 err("Unknown sensor ID %04x", val);
1639 } 1755 }
1640} 1756}
1641 1757
@@ -1697,6 +1813,12 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1697 reg_w1(gspca_dev, 0x01, 0x40); 1813 reg_w1(gspca_dev, 0x01, 0x40);
1698 msleep(50); 1814 msleep(50);
1699 break; 1815 break;
1816 case SENSOR_MI0360B:
1817 reg_w1(gspca_dev, 0x01, 0x61);
1818 reg_w1(gspca_dev, 0x17, 0x60);
1819 reg_w1(gspca_dev, 0x01, 0x60);
1820 reg_w1(gspca_dev, 0x01, 0x40);
1821 break;
1700 case SENSOR_MT9V111: 1822 case SENSOR_MT9V111:
1701 reg_w1(gspca_dev, 0x01, 0x61); 1823 reg_w1(gspca_dev, 0x01, 0x61);
1702 reg_w1(gspca_dev, 0x17, 0x61); 1824 reg_w1(gspca_dev, 0x17, 0x61);
@@ -1762,8 +1884,7 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1762 reg_w1(gspca_dev, 0x01, 0x43); 1884 reg_w1(gspca_dev, 0x01, 0x43);
1763 reg_w1(gspca_dev, 0x17, 0x61); 1885 reg_w1(gspca_dev, 0x17, 0x61);
1764 reg_w1(gspca_dev, 0x01, 0x42); 1886 reg_w1(gspca_dev, 0x01, 0x42);
1765 if (sd->sensor == SENSOR_HV7131R 1887 if (sd->sensor == SENSOR_HV7131R)
1766 && sd->bridge == BRIDGE_SN9C102P)
1767 hv7131r_probe(gspca_dev); 1888 hv7131r_probe(gspca_dev);
1768 break; 1889 break;
1769 } 1890 }
@@ -1788,26 +1909,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
1788 cam->nmodes = ARRAY_SIZE(vga_mode); 1909 cam->nmodes = ARRAY_SIZE(vga_mode);
1789 } 1910 }
1790 cam->npkt = 24; /* 24 packets per ISOC message */ 1911 cam->npkt = 24; /* 24 packets per ISOC message */
1912 cam->ctrls = sd->ctrls;
1791 1913
1792 sd->brightness = BRIGHTNESS_DEF;
1793 sd->contrast = CONTRAST_DEF;
1794 sd->colors = COLOR_DEF;
1795 sd->blue = BLUE_BALANCE_DEF;
1796 sd->red = RED_BALANCE_DEF;
1797 sd->gamma = GAMMA_DEF;
1798 sd->autogain = AUTOGAIN_DEF;
1799 sd->ag_cnt = -1; 1914 sd->ag_cnt = -1;
1800 sd->vflip = VFLIP_DEF;
1801 switch (sd->sensor) {
1802 case SENSOR_OM6802:
1803 sd->sharpness = 0x10;
1804 break;
1805 default:
1806 sd->sharpness = SHARPNESS_DEF;
1807 break;
1808 }
1809 sd->infrared = INFRARED_DEF;
1810 sd->freq = FREQ_DEF;
1811 sd->quality = QUALITY_DEF; 1915 sd->quality = QUALITY_DEF;
1812 sd->jpegqual = 80; 1916 sd->jpegqual = 80;
1813 1917
@@ -1828,6 +1932,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
1828 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); 1932 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1829 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ 1933 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1830 regF1 = gspca_dev->usb_buf[0]; 1934 regF1 = gspca_dev->usb_buf[0];
1935 if (gspca_dev->usb_err < 0)
1936 return gspca_dev->usb_err;
1831 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); 1937 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1832 switch (sd->bridge) { 1938 switch (sd->bridge) {
1833 case BRIDGE_SN9C102P: 1939 case BRIDGE_SN9C102P:
@@ -1871,6 +1977,9 @@ static int sd_init(struct gspca_dev *gspca_dev)
1871 break; 1977 break;
1872 } 1978 }
1873 1979
1980 if (sd->sensor == SENSOR_OM6802)
1981 sd->ctrls[SHARPNESS].def = 0x10;
1982
1874 /* Note we do not disable the sensor clock here (power saving mode), 1983 /* Note we do not disable the sensor clock here (power saving mode),
1875 as that also disables the button on the cam. */ 1984 as that also disables the button on the cam. */
1876 reg_w1(gspca_dev, 0xf1, 0x00); 1985 reg_w1(gspca_dev, 0xf1, 0x00);
@@ -1881,7 +1990,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
1881 1990
1882 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; 1991 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1883 1992
1884 return 0; 1993 return gspca_dev->usb_err;
1885} 1994}
1886 1995
1887static u32 setexposure(struct gspca_dev *gspca_dev, 1996static u32 setexposure(struct gspca_dev *gspca_dev,
@@ -1912,7 +2021,8 @@ static u32 setexposure(struct gspca_dev *gspca_dev,
1912 i2c_w8(gspca_dev, Expodoit); 2021 i2c_w8(gspca_dev, Expodoit);
1913 break; 2022 break;
1914 } 2023 }
1915 case SENSOR_MI0360: { 2024 case SENSOR_MI0360:
2025 case SENSOR_MI0360B: {
1916 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ 2026 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1917 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; 2027 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
1918 static const u8 doit[] = /* update sensor */ 2028 static const u8 doit[] = /* update sensor */
@@ -1991,16 +2101,18 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1991{ 2101{
1992 struct sd *sd = (struct sd *) gspca_dev; 2102 struct sd *sd = (struct sd *) gspca_dev;
1993 unsigned int expo; 2103 unsigned int expo;
2104 int brightness;
1994 u8 k2; 2105 u8 k2;
1995 2106
1996 k2 = ((int) sd->brightness - 0x8000) >> 10; 2107 brightness = sd->ctrls[BRIGHTNESS].val;
2108 k2 = (brightness - 0x80) >> 2;
1997 switch (sd->sensor) { 2109 switch (sd->sensor) {
1998 case SENSOR_ADCM1700: 2110 case SENSOR_ADCM1700:
1999 if (k2 > 0x1f) 2111 if (k2 > 0x1f)
2000 k2 = 0; /* only positive Y offset */ 2112 k2 = 0; /* only positive Y offset */
2001 break; 2113 break;
2002 case SENSOR_HV7131R: 2114 case SENSOR_HV7131R:
2003 expo = sd->brightness << 4; 2115 expo = brightness << 12;
2004 if (expo > 0x002dc6c0) 2116 if (expo > 0x002dc6c0)
2005 expo = 0x002dc6c0; 2117 expo = 0x002dc6c0;
2006 else if (expo < 0x02a0) 2118 else if (expo < 0x02a0)
@@ -2009,18 +2121,22 @@ static void setbrightness(struct gspca_dev *gspca_dev)
2009 break; 2121 break;
2010 case SENSOR_MI0360: 2122 case SENSOR_MI0360:
2011 case SENSOR_MO4000: 2123 case SENSOR_MO4000:
2012 expo = sd->brightness >> 4; 2124 expo = brightness << 4;
2125 sd->exposure = setexposure(gspca_dev, expo);
2126 break;
2127 case SENSOR_MI0360B:
2128 expo = brightness << 2;
2013 sd->exposure = setexposure(gspca_dev, expo); 2129 sd->exposure = setexposure(gspca_dev, expo);
2014 break; 2130 break;
2015 case SENSOR_GC0307: 2131 case SENSOR_GC0307:
2016 case SENSOR_MT9V111: 2132 case SENSOR_MT9V111:
2017 expo = sd->brightness >> 8; 2133 expo = brightness;
2018 sd->exposure = setexposure(gspca_dev, expo); 2134 sd->exposure = setexposure(gspca_dev, expo);
2019 return; /* don't set the Y offset */ 2135 return; /* don't set the Y offset */
2020 case SENSOR_OM6802: 2136 case SENSOR_OM6802:
2021 expo = sd->brightness >> 6; 2137 expo = brightness << 2;
2022 sd->exposure = setexposure(gspca_dev, expo); 2138 sd->exposure = setexposure(gspca_dev, expo);
2023 k2 = sd->brightness >> 11; 2139 k2 = brightness >> 3;
2024 break; 2140 break;
2025 } 2141 }
2026 2142
@@ -2033,7 +2149,8 @@ static void setcontrast(struct gspca_dev *gspca_dev)
2033 u8 k2; 2149 u8 k2;
2034 u8 contrast[6]; 2150 u8 contrast[6];
2035 2151
2036 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ 2152 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2153 + 0x10; /* 10..40 */
2037 contrast[0] = (k2 + 1) / 2; /* red */ 2154 contrast[0] = (k2 + 1) / 2; /* red */
2038 contrast[1] = 0; 2155 contrast[1] = 0;
2039 contrast[2] = k2; /* green */ 2156 contrast[2] = k2; /* green */
@@ -2046,15 +2163,25 @@ static void setcontrast(struct gspca_dev *gspca_dev)
2046static void setcolors(struct gspca_dev *gspca_dev) 2163static void setcolors(struct gspca_dev *gspca_dev)
2047{ 2164{
2048 struct sd *sd = (struct sd *) gspca_dev; 2165 struct sd *sd = (struct sd *) gspca_dev;
2049 int i, v; 2166 int i, v, colors;
2167 const s16 *uv;
2050 u8 reg8a[12]; /* U & V gains */ 2168 u8 reg8a[12]; /* U & V gains */
2051 static const s16 uv[6] = { /* same as reg84 in signed decimal */ 2169 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
2052 -24, -38, 64, /* UR UG UB */ 2170 -24, -38, 64, /* UR UG UB */
2053 62, -51, -9 /* VR VG VB */ 2171 62, -51, -9 /* VR VG VB */
2054 }; 2172 };
2173 static const s16 uv_mi0360b[6] = {
2174 -20, -38, 64, /* UR UG UB */
2175 60, -51, -9 /* VR VG VB */
2176 };
2055 2177
2178 colors = sd->ctrls[COLORS].val;
2179 if (sd->sensor == SENSOR_MI0360B)
2180 uv = uv_mi0360b;
2181 else
2182 uv = uv_com;
2056 for (i = 0; i < 6; i++) { 2183 for (i = 0; i < 6; i++) {
2057 v = uv[i] * sd->colors / COLOR_DEF; 2184 v = uv[i] * colors / COLORS_DEF;
2058 reg8a[i * 2] = v; 2185 reg8a[i * 2] = v;
2059 reg8a[i * 2 + 1] = (v >> 8) & 0x0f; 2186 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
2060 } 2187 }
@@ -2065,15 +2192,15 @@ static void setredblue(struct gspca_dev *gspca_dev)
2065{ 2192{
2066 struct sd *sd = (struct sd *) gspca_dev; 2193 struct sd *sd = (struct sd *) gspca_dev;
2067 2194
2068 reg_w1(gspca_dev, 0x05, sd->red); 2195 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
2069/* reg_w1(gspca_dev, 0x07, 32); */ 2196/* reg_w1(gspca_dev, 0x07, 32); */
2070 reg_w1(gspca_dev, 0x06, sd->blue); 2197 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
2071} 2198}
2072 2199
2073static void setgamma(struct gspca_dev *gspca_dev) 2200static void setgamma(struct gspca_dev *gspca_dev)
2074{ 2201{
2075 struct sd *sd = (struct sd *) gspca_dev; 2202 struct sd *sd = (struct sd *) gspca_dev;
2076 int i; 2203 int i, val;
2077 u8 gamma[17]; 2204 u8 gamma[17];
2078 const u8 *gamma_base; 2205 const u8 *gamma_base;
2079 static const u8 delta[17] = { 2206 static const u8 delta[17] = {
@@ -2086,6 +2213,7 @@ static void setgamma(struct gspca_dev *gspca_dev)
2086 gamma_base = gamma_spec_0; 2213 gamma_base = gamma_spec_0;
2087 break; 2214 break;
2088 case SENSOR_HV7131R: 2215 case SENSOR_HV7131R:
2216 case SENSOR_MI0360B:
2089 case SENSOR_MT9V111: 2217 case SENSOR_MT9V111:
2090 gamma_base = gamma_spec_1; 2218 gamma_base = gamma_spec_1;
2091 break; 2219 break;
@@ -2100,9 +2228,10 @@ static void setgamma(struct gspca_dev *gspca_dev)
2100 break; 2228 break;
2101 } 2229 }
2102 2230
2231 val = sd->ctrls[GAMMA].val;
2103 for (i = 0; i < sizeof gamma; i++) 2232 for (i = 0; i < sizeof gamma; i++)
2104 gamma[i] = gamma_base[i] 2233 gamma[i] = gamma_base[i]
2105 + delta[i] * (sd->gamma - GAMMA_DEF) / 32; 2234 + delta[i] * (val - GAMMA_DEF) / 32;
2106 reg_w(gspca_dev, 0x20, gamma, sizeof gamma); 2235 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2107} 2236}
2108 2237
@@ -2110,7 +2239,7 @@ static void setautogain(struct gspca_dev *gspca_dev)
2110{ 2239{
2111 struct sd *sd = (struct sd *) gspca_dev; 2240 struct sd *sd = (struct sd *) gspca_dev;
2112 2241
2113 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) 2242 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
2114 return; 2243 return;
2115 switch (sd->sensor) { 2244 switch (sd->sensor) {
2116 case SENSOR_OV7630: 2245 case SENSOR_OV7630:
@@ -2121,74 +2250,91 @@ static void setautogain(struct gspca_dev *gspca_dev)
2121 comb = 0xc0; 2250 comb = 0xc0;
2122 else 2251 else
2123 comb = 0xa0; 2252 comb = 0xa0;
2124 if (sd->autogain) 2253 if (sd->ctrls[AUTOGAIN].val)
2125 comb |= 0x03; 2254 comb |= 0x03;
2126 i2c_w1(&sd->gspca_dev, 0x13, comb); 2255 i2c_w1(&sd->gspca_dev, 0x13, comb);
2127 return; 2256 return;
2128 } 2257 }
2129 } 2258 }
2130 if (sd->autogain) 2259 if (sd->ctrls[AUTOGAIN].val)
2131 sd->ag_cnt = AG_CNT_START; 2260 sd->ag_cnt = AG_CNT_START;
2132 else 2261 else
2133 sd->ag_cnt = -1; 2262 sd->ag_cnt = -1;
2134} 2263}
2135 2264
2136/* hv7131r/ov7630/ov7648 only */ 2265static void sethvflip(struct gspca_dev *gspca_dev)
2137static void setvflip(struct sd *sd)
2138{ 2266{
2267 struct sd *sd = (struct sd *) gspca_dev;
2139 u8 comn; 2268 u8 comn;
2140 2269
2141 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2142 return;
2143 switch (sd->sensor) { 2270 switch (sd->sensor) {
2144 case SENSOR_HV7131R: 2271 case SENSOR_HV7131R:
2145 comn = 0x18; /* clkdiv = 1, ablcen = 1 */ 2272 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2146 if (sd->vflip) 2273 if (sd->ctrls[VFLIP].val)
2147 comn |= 0x01; 2274 comn |= 0x01;
2148 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */ 2275 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
2149 break; 2276 break;
2150 case SENSOR_OV7630: 2277 case SENSOR_OV7630:
2151 comn = 0x02; 2278 comn = 0x02;
2152 if (!sd->vflip) 2279 if (!sd->ctrls[VFLIP].val)
2153 comn |= 0x80; 2280 comn |= 0x80;
2154 i2c_w1(&sd->gspca_dev, 0x75, comn); 2281 i2c_w1(gspca_dev, 0x75, comn);
2155 break; 2282 break;
2156 default: 2283 case SENSOR_OV7648:
2157/* case SENSOR_OV7648: */
2158 comn = 0x06; 2284 comn = 0x06;
2159 if (sd->vflip) 2285 if (sd->ctrls[VFLIP].val)
2286 comn |= 0x80;
2287 i2c_w1(gspca_dev, 0x75, comn);
2288 break;
2289 case SENSOR_PO2030N:
2290 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2291 * (reset value: 0x0A)
2292 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2293 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2294 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2295 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2296 * bit3-0: X
2297 */
2298 comn = 0x0a;
2299 if (sd->ctrls[HFLIP].val)
2160 comn |= 0x80; 2300 comn |= 0x80;
2161 i2c_w1(&sd->gspca_dev, 0x75, comn); 2301 if (sd->ctrls[VFLIP].val)
2302 comn |= 0x40;
2303 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2162 break; 2304 break;
2163 } 2305 }
2164} 2306}
2165 2307
2166static void setsharpness(struct sd *sd) 2308static void setsharpness(struct gspca_dev *gspca_dev)
2167{ 2309{
2168 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness); 2310 struct sd *sd = (struct sd *) gspca_dev;
2311
2312 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
2169} 2313}
2170 2314
2171static void setinfrared(struct sd *sd) 2315static void setinfrared(struct gspca_dev *gspca_dev)
2172{ 2316{
2173 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) 2317 struct sd *sd = (struct sd *) gspca_dev;
2318
2319 if (gspca_dev->ctrl_dis & (1 << INFRARED))
2174 return; 2320 return;
2175/*fixme: different sequence for StarCam Clip and StarCam 370i */ 2321/*fixme: different sequence for StarCam Clip and StarCam 370i */
2176/* Clip */ 2322/* Clip */
2177 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ 2323 i2c_w1(gspca_dev, 0x02, /* gpio */
2178 sd->infrared ? 0x66 : 0x64); 2324 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
2179} 2325}
2180 2326
2181static void setfreq(struct gspca_dev *gspca_dev) 2327static void setfreq(struct gspca_dev *gspca_dev)
2182{ 2328{
2183 struct sd *sd = (struct sd *) gspca_dev; 2329 struct sd *sd = (struct sd *) gspca_dev;
2184 2330
2185 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) 2331 if (gspca_dev->ctrl_dis & (1 << FREQ))
2186 return; 2332 return;
2187 if (sd->sensor == SENSOR_OV7660) { 2333 if (sd->sensor == SENSOR_OV7660) {
2188 u8 com8; 2334 u8 com8;
2189 2335
2190 com8 = 0xdf; /* auto gain/wb/expo */ 2336 com8 = 0xdf; /* auto gain/wb/expo */
2191 switch (sd->freq) { 2337 switch (sd->ctrls[FREQ].val) {
2192 case 0: /* Banding filter disabled */ 2338 case 0: /* Banding filter disabled */
2193 i2c_w1(gspca_dev, 0x13, com8 | 0x20); 2339 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
2194 break; 2340 break;
@@ -2216,7 +2362,7 @@ static void setfreq(struct gspca_dev *gspca_dev)
2216 break; 2362 break;
2217 } 2363 }
2218 2364
2219 switch (sd->freq) { 2365 switch (sd->ctrls[FREQ].val) {
2220 case 0: /* Banding filter disabled */ 2366 case 0: /* Banding filter disabled */
2221 break; 2367 break;
2222 case 1: /* 50 hz (filter on and framerate adj) */ 2368 case 1: /* 50 hz (filter on and framerate adj) */
@@ -2334,6 +2480,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2334 reg17 = 0xa2; 2480 reg17 = 0xa2;
2335 break; 2481 break;
2336 case SENSOR_MT9V111: 2482 case SENSOR_MT9V111:
2483 case SENSOR_MI0360B:
2337 reg17 = 0xe0; 2484 reg17 = 0xe0;
2338 break; 2485 break;
2339 case SENSOR_ADCM1700: 2486 case SENSOR_ADCM1700:
@@ -2375,6 +2522,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2375 break; 2522 break;
2376 case SENSOR_GC0307: 2523 case SENSOR_GC0307:
2377 case SENSOR_MT9V111: 2524 case SENSOR_MT9V111:
2525 case SENSOR_MI0360B:
2378 reg_w1(gspca_dev, 0x9a, 0x07); 2526 reg_w1(gspca_dev, 0x9a, 0x07);
2379 break; 2527 break;
2380 case SENSOR_OV7630: 2528 case SENSOR_OV7630:
@@ -2389,7 +2537,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2389 reg_w1(gspca_dev, 0x9a, 0x08); 2537 reg_w1(gspca_dev, 0x9a, 0x08);
2390 break; 2538 break;
2391 } 2539 }
2392 setsharpness(sd); 2540 setsharpness(gspca_dev);
2393 2541
2394 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2542 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2395 reg_w1(gspca_dev, 0x05, 0x20); /* red */ 2543 reg_w1(gspca_dev, 0x05, 0x20); /* red */
@@ -2414,6 +2562,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
2414 reg17 = 0xa2; 2562 reg17 = 0xa2;
2415 reg1 = 0x44; 2563 reg1 = 0x44;
2416 break; 2564 break;
2565 case SENSOR_MI0360B:
2566 init = mi0360b_sensor_param1;
2567 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2568 reg17 = 0xe2;
2569 break;
2417 case SENSOR_MO4000: 2570 case SENSOR_MO4000:
2418 if (mode) { 2571 if (mode) {
2419/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ 2572/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
@@ -2474,8 +2627,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2474 reg1 = 0x44; 2627 reg1 = 0x44;
2475 reg17 = 0xa2; 2628 reg17 = 0xa2;
2476 break; 2629 break;
2477 default: 2630 case SENSOR_SP80708:
2478/* case SENSOR_SP80708: */
2479 init = sp80708_sensor_param1; 2631 init = sp80708_sensor_param1;
2480 if (mode) { 2632 if (mode) {
2481/*?? reg1 = 0x04; * 320 clk 48Mhz */ 2633/*?? reg1 = 0x04; * 320 clk 48Mhz */
@@ -2526,7 +2678,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
2526 break; 2678 break;
2527 } 2679 }
2528 2680
2529
2530 /* here change size mode 0 -> VGA; 1 -> CIF */ 2681 /* here change size mode 0 -> VGA; 1 -> CIF */
2531 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; 2682 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2532 reg_w1(gspca_dev, 0x18, sd->reg18); 2683 reg_w1(gspca_dev, 0x18, sd->reg18);
@@ -2535,13 +2686,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
2535 reg_w1(gspca_dev, 0x17, reg17); 2686 reg_w1(gspca_dev, 0x17, reg17);
2536 reg_w1(gspca_dev, 0x01, reg1); 2687 reg_w1(gspca_dev, 0x01, reg1);
2537 2688
2538 setvflip(sd); 2689 sethvflip(gspca_dev);
2539 setbrightness(gspca_dev); 2690 setbrightness(gspca_dev);
2540 setcontrast(gspca_dev); 2691 setcontrast(gspca_dev);
2541 setcolors(gspca_dev); 2692 setcolors(gspca_dev);
2542 setautogain(gspca_dev); 2693 setautogain(gspca_dev);
2543 setfreq(gspca_dev); 2694 setfreq(gspca_dev);
2544 return 0; 2695 return gspca_dev->usb_err;
2545} 2696}
2546 2697
2547static void sd_stopN(struct gspca_dev *gspca_dev) 2698static void sd_stopN(struct gspca_dev *gspca_dev)
@@ -2568,6 +2719,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2568 data = 0x2b; 2719 data = 0x2b;
2569 break; 2720 break;
2570 case SENSOR_MI0360: 2721 case SENSOR_MI0360:
2722 case SENSOR_MI0360B:
2571 i2c_w8(gspca_dev, stopmi0360); 2723 i2c_w8(gspca_dev, stopmi0360);
2572 data = 0x29; 2724 data = 0x29;
2573 break; 2725 break;
@@ -2641,6 +2793,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
2641 default: 2793 default:
2642/* case SENSOR_MO4000: */ 2794/* case SENSOR_MO4000: */
2643/* case SENSOR_MI0360: */ 2795/* case SENSOR_MI0360: */
2796/* case SENSOR_MI0360B: */
2644/* case SENSOR_MT9V111: */ 2797/* case SENSOR_MT9V111: */
2645 expotimes = sd->exposure; 2798 expotimes = sd->exposure;
2646 expotimes += (luma_mean - delta) >> 6; 2799 expotimes += (luma_mean - delta) >> 6;
@@ -2663,236 +2816,52 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2663 struct sd *sd = (struct sd *) gspca_dev; 2816 struct sd *sd = (struct sd *) gspca_dev;
2664 int sof, avg_lum; 2817 int sof, avg_lum;
2665 2818
2666 sof = len - 64; 2819 /* the image ends on a 64 bytes block starting with
2667 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) { 2820 * ff d9 ff ff 00 c4 c4 96
2821 * and followed by various information including luminosity */
2822 /* this block may be splitted between two packets */
2823 /* a new image always starts in a new packet */
2824 switch (gspca_dev->last_packet_type) {
2825 case DISCARD_PACKET: /* restart image building */
2826 sof = len - 64;
2827 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2828 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2829 return;
2830 case LAST_PACKET: /* put the JPEG 422 header */
2831 gspca_frame_add(gspca_dev, FIRST_PACKET,
2832 sd->jpeg_hdr, JPEG_HDR_SZ);
2833 break;
2834 }
2835 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2836
2837 data = gspca_dev->image;
2838 if (data == NULL)
2839 return;
2840 sof = gspca_dev->image_len - 64;
2841 if (data[sof] != 0xff
2842 || data[sof + 1] != 0xd9)
2843 return;
2668 2844
2669 /* end of frame */ 2845 /* end of image found - remove the trailing data */
2670 gspca_frame_add(gspca_dev, LAST_PACKET, 2846 gspca_dev->image_len = sof + 2;
2671 data, sof + 2); 2847 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2672 if (sd->ag_cnt < 0) 2848 if (sd->ag_cnt < 0)
2673 return; 2849 return;
2674/* w1 w2 w3 */ 2850/* w1 w2 w3 */
2675/* w4 w5 w6 */ 2851/* w4 w5 w6 */
2676/* w7 w8 */ 2852/* w7 w8 */
2677/* w4 */ 2853/* w4 */
2678 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6; 2854 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2679/* w6 */ 2855/* w6 */
2680 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6; 2856 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2681/* w2 */ 2857/* w2 */
2682 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6; 2858 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2683/* w8 */ 2859/* w8 */
2684 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6; 2860 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2685/* w5 */ 2861/* w5 */
2686 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4; 2862 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2687 avg_lum >>= 4; 2863 avg_lum >>= 4;
2688 atomic_set(&sd->avg_lum, avg_lum); 2864 atomic_set(&sd->avg_lum, avg_lum);
2689 return;
2690 }
2691 if (gspca_dev->last_packet_type == LAST_PACKET) {
2692
2693 /* put the JPEG 422 header */
2694 gspca_frame_add(gspca_dev, FIRST_PACKET,
2695 sd->jpeg_hdr, JPEG_HDR_SZ);
2696 }
2697 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2698}
2699
2700static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2701{
2702 struct sd *sd = (struct sd *) gspca_dev;
2703
2704 sd->brightness = val;
2705 if (gspca_dev->streaming)
2706 setbrightness(gspca_dev);
2707 return 0;
2708}
2709
2710static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2711{
2712 struct sd *sd = (struct sd *) gspca_dev;
2713
2714 *val = sd->brightness;
2715 return 0;
2716}
2717
2718static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2719{
2720 struct sd *sd = (struct sd *) gspca_dev;
2721
2722 sd->contrast = val;
2723 if (gspca_dev->streaming)
2724 setcontrast(gspca_dev);
2725 return 0;
2726}
2727
2728static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2729{
2730 struct sd *sd = (struct sd *) gspca_dev;
2731
2732 *val = sd->contrast;
2733 return 0;
2734}
2735
2736static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2737{
2738 struct sd *sd = (struct sd *) gspca_dev;
2739
2740 sd->colors = val;
2741 if (gspca_dev->streaming)
2742 setcolors(gspca_dev);
2743 return 0;
2744}
2745
2746static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2747{
2748 struct sd *sd = (struct sd *) gspca_dev;
2749
2750 *val = sd->colors;
2751 return 0;
2752}
2753
2754static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2755{
2756 struct sd *sd = (struct sd *) gspca_dev;
2757
2758 sd->blue = val;
2759 if (gspca_dev->streaming)
2760 setredblue(gspca_dev);
2761 return 0;
2762}
2763
2764static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2765{
2766 struct sd *sd = (struct sd *) gspca_dev;
2767
2768 *val = sd->blue;
2769 return 0;
2770}
2771
2772static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2773{
2774 struct sd *sd = (struct sd *) gspca_dev;
2775
2776 sd->red = val;
2777 if (gspca_dev->streaming)
2778 setredblue(gspca_dev);
2779 return 0;
2780}
2781
2782static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2783{
2784 struct sd *sd = (struct sd *) gspca_dev;
2785
2786 *val = sd->red;
2787 return 0;
2788}
2789
2790static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2791{
2792 struct sd *sd = (struct sd *) gspca_dev;
2793
2794 sd->gamma = val;
2795 if (gspca_dev->streaming)
2796 setgamma(gspca_dev);
2797 return 0;
2798}
2799
2800static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2801{
2802 struct sd *sd = (struct sd *) gspca_dev;
2803
2804 *val = sd->gamma;
2805 return 0;
2806}
2807
2808static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2809{
2810 struct sd *sd = (struct sd *) gspca_dev;
2811
2812 sd->autogain = val;
2813 if (gspca_dev->streaming)
2814 setautogain(gspca_dev);
2815 return 0;
2816}
2817
2818static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2819{
2820 struct sd *sd = (struct sd *) gspca_dev;
2821
2822 *val = sd->autogain;
2823 return 0;
2824}
2825
2826static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2827{
2828 struct sd *sd = (struct sd *) gspca_dev;
2829
2830 sd->sharpness = val;
2831 if (gspca_dev->streaming)
2832 setsharpness(sd);
2833 return 0;
2834}
2835
2836static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2837{
2838 struct sd *sd = (struct sd *) gspca_dev;
2839
2840 *val = sd->sharpness;
2841 return 0;
2842}
2843
2844static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2845{
2846 struct sd *sd = (struct sd *) gspca_dev;
2847
2848 sd->vflip = val;
2849 if (gspca_dev->streaming)
2850 setvflip(sd);
2851 return 0;
2852}
2853
2854static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2855{
2856 struct sd *sd = (struct sd *) gspca_dev;
2857
2858 *val = sd->vflip;
2859 return 0;
2860}
2861
2862static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2863{
2864 struct sd *sd = (struct sd *) gspca_dev;
2865
2866 sd->infrared = val;
2867 if (gspca_dev->streaming)
2868 setinfrared(sd);
2869 return 0;
2870}
2871
2872static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2873{
2874 struct sd *sd = (struct sd *) gspca_dev;
2875
2876 *val = sd->infrared;
2877 return 0;
2878}
2879
2880static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2881{
2882 struct sd *sd = (struct sd *) gspca_dev;
2883
2884 sd->freq = val;
2885 if (gspca_dev->streaming)
2886 setfreq(gspca_dev);
2887 return 0;
2888}
2889
2890static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2891{
2892 struct sd *sd = (struct sd *) gspca_dev;
2893
2894 *val = sd->freq;
2895 return 0;
2896} 2865}
2897 2866
2898static int sd_set_jcomp(struct gspca_dev *gspca_dev, 2867static int sd_set_jcomp(struct gspca_dev *gspca_dev,
@@ -2944,7 +2913,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
2944 return -EINVAL; 2913 return -EINVAL;
2945} 2914}
2946 2915
2947#ifdef CONFIG_INPUT 2916#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2948static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 2917static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2949 u8 *data, /* interrupt packet data */ 2918 u8 *data, /* interrupt packet data */
2950 int len) /* interrupt packet length */ 2919 int len) /* interrupt packet length */
@@ -2967,7 +2936,7 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2967static const struct sd_desc sd_desc = { 2936static const struct sd_desc sd_desc = {
2968 .name = MODULE_NAME, 2937 .name = MODULE_NAME,
2969 .ctrls = sd_ctrls, 2938 .ctrls = sd_ctrls,
2970 .nctrls = ARRAY_SIZE(sd_ctrls), 2939 .nctrls = NCTRLS,
2971 .config = sd_config, 2940 .config = sd_config,
2972 .init = sd_init, 2941 .init = sd_init,
2973 .start = sd_start, 2942 .start = sd_start,
@@ -2977,7 +2946,7 @@ static const struct sd_desc sd_desc = {
2977 .get_jcomp = sd_get_jcomp, 2946 .get_jcomp = sd_get_jcomp,
2978 .set_jcomp = sd_set_jcomp, 2947 .set_jcomp = sd_set_jcomp,
2979 .querymenu = sd_querymenu, 2948 .querymenu = sd_querymenu,
2980#ifdef CONFIG_INPUT 2949#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2981 .int_pkt_scan = sd_int_pkt_scan, 2950 .int_pkt_scan = sd_int_pkt_scan,
2982#endif 2951#endif
2983}; 2952};
@@ -3005,6 +2974,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3005 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, 2974 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3006/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ 2975/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3007 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, 2976 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2977 /* or MT9V111 */
3008/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ 2978/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3009/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ 2979/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3010/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ 2980/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
@@ -3019,7 +2989,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3019 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, 2989 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
3020#endif 2990#endif
3021 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ 2991 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
3022/* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, * / GC0305*/ 2992 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
3023/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ 2993/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3024 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ 2994 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3025 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ 2995 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
@@ -3031,12 +3001,12 @@ static const __devinitdata struct usb_device_id device_table[] = {
3031 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ 3001 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
3032/*bw600.inf:*/ 3002/*bw600.inf:*/
3033 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ 3003 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
3004 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
3034 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, 3005 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3035 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, 3006 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3036/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ 3007/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
3037#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3038 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, 3008 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
3039#endif 3009 /* or MT9V111 / MI0360B */
3040/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ 3010/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3041 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, 3011 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3042 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, 3012 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
@@ -3076,17 +3046,11 @@ static struct usb_driver sd_driver = {
3076/* -- module insert / remove -- */ 3046/* -- module insert / remove -- */
3077static int __init sd_mod_init(void) 3047static int __init sd_mod_init(void)
3078{ 3048{
3079 int ret; 3049 return usb_register(&sd_driver);
3080 ret = usb_register(&sd_driver);
3081 if (ret < 0)
3082 return ret;
3083 info("registered");
3084 return 0;
3085} 3050}
3086static void __exit sd_mod_exit(void) 3051static void __exit sd_mod_exit(void)
3087{ 3052{
3088 usb_deregister(&sd_driver); 3053 usb_deregister(&sd_driver);
3089 info("deregistered");
3090} 3054}
3091 3055
3092module_init(sd_mod_init); 3056module_init(sd_mod_init);