Lines Matching +full:0 +full:x10 +full:- +full:0 +full:x14

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2009-2011 Jean-François Moine <http://moinejf.free.fr>
14 0x10 high nibble red gain low nibble blue gain
15 0x11 low nibble green gain
17 0x05 red gain 0-127
18 0x06 blue gain 0-127
19 0x07 green gain 0-127
21 0x08-0x0f i2c / 3wire registers
22 0x12 hstart
23 0x13 vstart
24 0x15 hsize (hsize = register-value * 16)
25 0x16 vsize (vsize = register-value * 16)
26 0x17 bit 0 toggle compression quality (according to sn9c102 driver)
27 0x18 bit 7 enables compression, bit 4-5 set image down scaling:
29 0x19 high-nibble is sensor clock divider, changes exposure on sensors which
31 0x1c auto_exposure area (for avg_lum) startx (startx = register-value * 32)
32 0x1d auto_exposure area (for avg_lum) starty (starty = register-value * 32)
33 0x1e auto_exposure area (for avg_lum) stopx (hsize = (0x1e - 0x1c) * 32)
34 0x1f auto_exposure area (for avg_lum) stopy (vsize = (0x1f - 0x1d) * 32)
42 MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
63 #define BRIDGE_101 0
64 #define BRIDGE_102 0 /* We make no difference between 101 and 102 */
68 #define SENSOR_HV7131D 0
91 #define F_SIF 0x01 /* sif or vga */
94 #define MODE_RAW 0x10 /* raw bayer mode */
95 #define MODE_REDUCED_SIF 0x20 /* vga mode (320x240 / 160x120) on sif cam */
97 #define COMP 0xc7 /* 0x87 //0x07 */
98 #define COMP1 0xc9 /* 0x89 //0x09 */
100 #define MCK_INIT 0x63
101 #define MCK_INIT1 0x20 /*fixme: Bayer - 0x50 for JPEG ??*/
103 #define SYS_CLK 0x04
139 .priv = 0},
166 .priv = 0 | MODE_REDUCED_SIF},
171 .priv = 0},
175 0x04, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00,
176 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x02, 0x02, 0x00,
178 0x28, 0x1e, 0x60, 0x8e, 0x42,
181 {0xa0, 0x11, 0x01, 0x04, 0x00, 0x00, 0x00, 0x17},
182 {0xa0, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x17},
183 {0xa0, 0x11, 0x28, 0x00, 0x00, 0x00, 0x00, 0x17},
184 {0xa0, 0x11, 0x30, 0x30, 0x00, 0x00, 0x00, 0x17}, /* reset level */
185 {0xa0, 0x11, 0x34, 0x02, 0x00, 0x00, 0x00, 0x17}, /* pixel bias volt */
189 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00,
190 0x00, 0x00,
191 0x00, 0x00, 0x00, 0x02, 0x01, 0x00,
192 0x28, 0x1e, 0x60, 0x8a, 0x20,
195 {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10},
196 {0xa0, 0x11, 0x01, 0x08, 0x2a, 0x2e, 0x00, 0x10},
197 {0xb0, 0x11, 0x20, 0x00, 0xd0, 0x2e, 0x00, 0x10},
198 {0xc0, 0x11, 0x25, 0x03, 0x0e, 0x28, 0x00, 0x16},
199 {0xa0, 0x11, 0x30, 0x10, 0x0e, 0x28, 0x00, 0x15},
202 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
203 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b,
205 0x10,
213 {0xa0, 0x60, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
214 /* Set clock register 0x11 low nibble is clock divider */
215 {0xd0, 0x60, 0x11, 0xc0, 0x1b, 0x18, 0xc1, 0x10},
217 {0xb0, 0x60, 0x15, 0x00, 0x02, 0x18, 0xc1, 0x10},
218 /* {0xa0, 0x60, 0x1b, 0x01, 0x02, 0x18, 0xc1, 0x10},
222 {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10}, /* format out? */
223 {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10},
224 {0xa0, 0x60, 0x30, 0x3d, 0x0a, 0xd8, 0xa4, 0x10},
226 {0xa0, 0x60, 0x61, 0x08, 0x00, 0x00, 0x00, 0x10},
227 /* HDG: Note windows uses the line below, which sets both register 0x60
228 and 0x61 I believe these registers of the ov6650 are identical as
233 {0xb0, 0x60, 0x60, 0x66, 0x68, 0xd8, 0xa4, 0x10}, */
235 {0xa0, 0x60, 0x68, 0x04, 0x68, 0xd8, 0xa4, 0x10},
236 {0xd0, 0x60, 0x17, 0x24, 0xd6, 0x04, 0x94, 0x10}, /* Clipreg */
240 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* r01 .. r08 */
241 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */
242 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */
243 0x28, 0x1e, /* H & V sizes r15 .. r16 */
244 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */
247 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
248 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10},
249 /* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */
250 {0xd0, 0x21, 0x12, 0x5c, 0x00, 0x80, 0x34, 0x10}, /* jfm */
251 {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10},
252 {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10},
253 {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10},
254 {0xd0, 0x21, 0x26, 0xa0, 0x9a, 0xa0, 0x30, 0x10},
255 {0xb0, 0x21, 0x2a, 0x80, 0x00, 0xa0, 0x30, 0x10},
256 {0xb0, 0x21, 0x2f, 0x3d, 0x24, 0xa0, 0x30, 0x10},
257 {0xa0, 0x21, 0x32, 0x86, 0x24, 0xa0, 0x30, 0x10},
258 {0xb0, 0x21, 0x60, 0xa9, 0x4a, 0xa0, 0x30, 0x10},
259 /* {0xb0, 0x21, 0x60, 0xa9, 0x42, 0xa0, 0x30, 0x10}, * jfm */
260 {0xa0, 0x21, 0x65, 0x00, 0x42, 0xa0, 0x30, 0x10},
261 {0xa0, 0x21, 0x69, 0x38, 0x42, 0xa0, 0x30, 0x10},
262 {0xc0, 0x21, 0x6f, 0x88, 0x0b, 0x00, 0x30, 0x10},
263 {0xc0, 0x21, 0x74, 0x21, 0x8e, 0x00, 0x30, 0x10},
264 {0xa0, 0x21, 0x7d, 0xf7, 0x8e, 0x00, 0x30, 0x10},
265 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10},
269 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00,
270 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
272 0x16, 0x12, 0x24, COMP1, MCK_INIT1,
274 /* compression 0x86 mckinit1 0x2b */
277 0x02 clock divider
278 0x03 Variable framerate bits 4-11
279 0x04 Var framerate bits 0-3, one must leave the 4 msb's at 0 !!
282 0x05 Shutter Time Line Offset, this can be used as an exposure control:
283 0 = use full frame time, 255 = no exposure at all
284 Note this may never be larger then "var-framerate control" / 2 - 2.
285 When var-framerate control is < 514, no exposure is reached at the max
287 0x06 Shutter Time Pixel Offset, like reg05 this influences exposure, but
288 only a very little bit, leave at 0xcd
289 0x07 offset sign bit (bit0 1 > negative offset)
290 0x08 offset
291 0x09 Blue Gain
292 0x0a Green1 Gain
293 0x0b Green2 Gain
294 0x0c Red Gain
295 0x0e Global gain
296 0x13 Write 1 to commit settings to sensor
301 { 0xa1, 0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x14 },
302 /* Frame Time MSB (also seen as 0x12) */
303 { 0xa1, 0x40, 0x03, 0x13, 0x00, 0x00, 0x00, 0x14 },
304 /* Frame Time LSB (also seen as 0x05) */
305 { 0xa1, 0x40, 0x04, 0x06, 0x00, 0x00, 0x00, 0x14 },
306 /* Shutter Time Line Offset (also seen as 0x6d) */
307 { 0xa1, 0x40, 0x05, 0x65, 0x00, 0x00, 0x00, 0x14 },
308 /* Shutter Time Pixel Offset (also seen as 0xb1) */
309 { 0xa1, 0x40, 0x06, 0xcd, 0x00, 0x00, 0x00, 0x14 },
310 /* Black Level Subtract Sign (also seen 0x00) */
311 { 0xa1, 0x40, 0x07, 0xc1, 0x00, 0x00, 0x00, 0x14 },
312 /* Black Level Subtract Level (also seen 0x01) */
313 { 0xa1, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0x14 },
314 { 0xa1, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0x14 },
316 { 0xa1, 0x40, 0x09, 0x05, 0x00, 0x00, 0x00, 0x14 },
318 { 0xa1, 0x40, 0x0a, 0x04, 0x00, 0x00, 0x00, 0x14 },
319 /* Color Gain G2 Pixel 1 0 5 */
320 { 0xa1, 0x40, 0x0b, 0x04, 0x00, 0x00, 0x00, 0x14 },
322 { 0xa1, 0x40, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x14 },
324 { 0xa1, 0x40, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x14 },
326 { 0xa1, 0x40, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x14 },
328 { 0xa1, 0x40, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x14 },
330 { 0xa1, 0x40, 0x10, 0x06, 0x00, 0x00, 0x00, 0x14 },
332 { 0xa1, 0x40, 0x11, 0x06, 0x00, 0x00, 0x00, 0x14 },
334 { 0xa1, 0x40, 0x12, 0x06, 0x00, 0x00, 0x00, 0x14 },
336 { 0xa1, 0x40, 0x14, 0x02, 0x00, 0x00, 0x00, 0x14 },
338 { 0xa1, 0x40, 0x13, 0x01, 0x00, 0x00, 0x00, 0x14 },
342 0x44, 0x44, 0x21, 0x30, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00,
343 0x00, 0x00,
344 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a,
345 0x28, 0x1e, 0x20, 0x89, 0x20,
349 0x02 clock divider
350 0x04 Variable framerate bits 6-11 (*)
351 0x05 Var framerate bits 0-5, one must leave the 2 msb's at 0 !!
352 0x07 Blue Gain
353 0x08 Green Gain
354 0x09 Red Gain
355 0x0b offset sign bit (bit0 1 > negative offset)
356 0x0c offset
357 0x0e Unknown image is slightly brighter when bit 0 is 0, if reg0f is 0 too,
359 0x0f Exposure 0-255, 0 = use full frame time, 255 = no exposure at all
360 0x10 Master gain 0 - 31
361 0x11 write 1 to apply changes
366 /* Set the clock divider to 4 -> 30 / 4 = 7.5 fps, we would like
369 {0xa0, 0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x10},
370 {0xd0, 0x40, 0x04, 0x07, 0x34, 0x00, 0x09, 0x10},
371 {0xd0, 0x40, 0x08, 0x01, 0x00, 0x00, 0x01, 0x10},
372 {0xd0, 0x40, 0x0c, 0x00, 0x0c, 0x01, 0x32, 0x10},
373 {0xd0, 0x40, 0x10, 0x00, 0x01, 0x00, 0x63, 0x10},
374 {0xa0, 0x40, 0x15, 0x70, 0x01, 0x00, 0x63, 0x10},
375 {0xa0, 0x40, 0x18, 0x00, 0x01, 0x00, 0x63, 0x10},
376 {0xa0, 0x40, 0x11, 0x01, 0x01, 0x00, 0x63, 0x10},
377 {0xa0, 0x40, 0x03, 0x56, 0x01, 0x00, 0x63, 0x10},
378 {0xa0, 0x40, 0x11, 0x01, 0x01, 0x00, 0x63, 0x10},
382 0x44, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00,
383 0x00, 0x00,
384 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a,
385 0x16, 0x12, 0x60, 0x86, 0x2b,
389 0x44, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00,
390 0x00, 0x00,
391 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a,
392 0x16, 0x12, 0x60, 0x86, 0x2b,
396 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10},
397 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10},
400 * reg02: gain, bit order reversed!! 0 == max gain, 255 == min gain
405 {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, /* reset */
409 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00,
410 0x00, 0x00,
411 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a,
412 0x28, 0x1e, 0x60, COMP, MCK_INIT,
415 /* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10},
416 * shutter 0x47 short exposure? */
417 {0x30, 0x11, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10},
418 /* shutter 0x01 long exposure */
419 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10},
423 SENS(initHv7131d, hv7131d_sensor_init, 0, 0),
424 SENS(initHv7131r, hv7131r_sensor_init, 0, 0),
425 SENS(initOv6650, ov6650_sensor_init, F_SIF, 0x60),
426 SENS(initOv7630, ov7630_sensor_init, 0, 0x21),
427 SENS(initPas106, pas106_sensor_init, F_SIF, 0),
428 SENS(initPas202, pas202_sensor_init, 0, 0),
429 SENS(initTas5110c, tas5110c_sensor_init, F_SIF, 0),
430 SENS(initTas5110d, tas5110d_sensor_init, F_SIF, 0),
431 SENS(initTas5130, tas5130_sensor_init, 0, 0),
434 /* get one byte in gspca_dev->usb_buf */
440 if (gspca_dev->usb_err < 0) in reg_r()
443 res = usb_control_msg(gspca_dev->dev, in reg_r()
444 usb_rcvctrlpipe(gspca_dev->dev, 0), in reg_r()
445 0, /* request */ in reg_r()
448 0, /* index */ in reg_r()
449 gspca_dev->usb_buf, 1, in reg_r()
452 if (res < 0) { in reg_r()
453 dev_err(gspca_dev->v4l2_dev.dev, in reg_r()
455 gspca_dev->usb_err = res; in reg_r()
460 gspca_dev->usb_buf[0] = 0; in reg_r()
471 if (gspca_dev->usb_err < 0) in reg_w()
474 memcpy(gspca_dev->usb_buf, buffer, len); in reg_w()
475 res = usb_control_msg(gspca_dev->dev, in reg_w()
476 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w()
477 0x08, /* request */ in reg_w()
480 0, /* index */ in reg_w()
481 gspca_dev->usb_buf, len, in reg_w()
484 if (res < 0) { in reg_w()
485 dev_err(gspca_dev->v4l2_dev.dev, in reg_w()
487 gspca_dev->usb_err = res; in reg_w()
495 if (gspca_dev->usb_err < 0) in i2c_w()
499 reg_w(gspca_dev, 0x08, buf, 8); in i2c_w()
500 while (retry--) { in i2c_w()
501 if (gspca_dev->usb_err < 0) in i2c_w()
504 reg_r(gspca_dev, 0x08); in i2c_w()
505 if (gspca_dev->usb_buf[0] & 0x04) { in i2c_w()
506 if (gspca_dev->usb_buf[0] & 0x08) { in i2c_w()
507 dev_err(gspca_dev->v4l2_dev.dev, in i2c_w()
509 gspca_dev->usb_err = -EIO; in i2c_w()
515 dev_err(gspca_dev->v4l2_dev.dev, "i2c write timeout\n"); in i2c_w()
516 gspca_dev->usb_err = -EIO; in i2c_w()
523 if (gspca_dev->usb_err < 0) in i2c_w_vector()
526 len -= 8; in i2c_w_vector()
527 if (len <= 0) in i2c_w_vector()
537 switch (sd->sensor) { in setbrightness()
541 {0xa0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}; in setbrightness()
543 /* change reg 0x06 */ in setbrightness()
544 i2cOV[1] = sensor_data[sd->sensor].sensor_addr; in setbrightness()
545 i2cOV[3] = sd->brightness->val; in setbrightness()
552 {0xb0, 0x40, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x16}; in setbrightness()
554 {0xa0, 0x40, 0x11, 0x01, 0x00, 0x00, 0x00, 0x16}; in setbrightness()
557 if (sd->sensor == SENSOR_PAS106) { in setbrightness()
559 i2cpdoit[2] = 0x13; in setbrightness()
562 if (sd->brightness->val < 127) { in setbrightness()
563 /* change reg 0x0b, signreg */ in setbrightness()
564 i2cpbright[3] = 0x01; in setbrightness()
565 /* set reg 0x0c, offset */ in setbrightness()
566 i2cpbright[4] = 127 - sd->brightness->val; in setbrightness()
568 i2cpbright[4] = sd->brightness->val - 127; in setbrightness()
582 u8 gain = gspca_dev->gain->val; in setgain()
584 switch (sd->sensor) { in setgain()
587 {0xc0, 0x11, 0x31, 0x00, 0x00, 0x00, 0x00, 0x17}; in setgain()
589 i2c[3] = 0x3f - gain; in setgain()
590 i2c[4] = 0x3f - gain; in setgain()
591 i2c[5] = 0x3f - gain; in setgain()
599 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; in setgain()
601 i2c[4] = 255 - gain; in setgain()
607 0xb0, 0x61, 0x02, 0x00, 0x10, 0x00, 0x00, 0x17 }; in setgain()
608 gain = 255 - gain; in setgain()
610 i2c[3] |= (gain & 0x80) >> 7; in setgain()
611 i2c[3] |= (gain & 0x40) >> 5; in setgain()
612 i2c[3] |= (gain & 0x20) >> 3; in setgain()
613 i2c[3] |= (gain & 0x10) >> 1; in setgain()
614 i2c[3] |= (gain & 0x08) << 1; in setgain()
615 i2c[3] |= (gain & 0x04) << 3; in setgain()
616 i2c[3] |= (gain & 0x02) << 5; in setgain()
617 i2c[3] |= (gain & 0x01) << 7; in setgain()
623 __u8 i2c[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; in setgain()
627 * same level as at 16, so skip 32-47 (of the 0-63 scale). in setgain()
629 if (sd->sensor == SENSOR_OV7630 && gain >= 32) in setgain()
632 i2c[1] = sensor_data[sd->sensor].sensor_addr; in setgain()
640 {0xa0, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x15}; in setgain()
642 {0xc0, 0x40, 0x07, 0x00, 0x00, 0x00, 0x00, 0x15}; in setgain()
644 {0xa0, 0x40, 0x11, 0x01, 0x00, 0x00, 0x00, 0x16}; in setgain()
647 if (sd->sensor == SENSOR_PAS106) { in setgain()
648 i2cpgain[2] = 0x0e; in setgain()
649 i2cpcolorgain[0] = 0xd0; in setgain()
650 i2cpcolorgain[2] = 0x09; in setgain()
651 i2cpdoit[2] = 0x13; in setgain()
666 if (sd->bridge == BRIDGE_103) { in setgain()
668 reg_w(gspca_dev, 0x05, buf, 3); in setgain()
671 buf[0] = gain << 4 | gain; /* Red and blue */ in setgain()
673 reg_w(gspca_dev, 0x10, buf, 2); in setgain()
682 switch (sd->sensor) { in setexposure()
685 0x26 and 0x27, testing has shown 0x25 + 0x26 */ in setexposure()
686 __u8 i2c[] = {0xc0, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x17}; in setexposure()
687 u16 reg = gspca_dev->exposure->val; in setexposure()
690 i2c[4] = reg & 0xff; in setexposure()
699 u8 reg = gspca_dev->exposure->val; in setexposure()
701 reg = (reg << 4) | 0x0b; in setexposure()
702 reg_w(gspca_dev, 0x19, &reg, 1); in setexposure()
714 actual exposure as quotient of the full exposure, with 0 in setexposure()
718 The code maps our 0 - 510 ms exposure ctrl to these 2 in setexposure()
721 __u8 i2c[] = {0xb0, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}; in setexposure()
729 the ov6645. The ov7630 datasheet says the max is 0x41. */ in setexposure()
730 if (sd->sensor == SENSOR_OV6650) { in setexposure()
731 reg10_max = 0x4d; in setexposure()
732 i2c[4] = 0xc0; /* OV6650 needs non default vsync pol */ in setexposure()
734 reg10_max = 0x41; in setexposure()
736 reg11 = (15 * gspca_dev->exposure->val + 999) / 1000; in setexposure()
745 if (gspca_dev->pixfmt.width == 640 && reg11 < 4) in setexposure()
748 /* frame exposure time in ms = 1000 * reg11 / 30 -> in setexposure()
749 reg10 = (gspca_dev->exposure->val / 2) * reg10_max in setexposure()
751 reg10 = (gspca_dev->exposure->val * 15 * reg10_max) in setexposure()
758 if (gspca_dev->autogain->val && reg10 < 10) in setexposure()
764 i2c[1] = sensor_data[sd->sensor].sensor_addr; in setexposure()
766 i2c[4] |= reg11 - 1; in setexposure()
769 if (sd->reg11 == reg11) in setexposure()
770 i2c[0] = 0xa0; in setexposure()
773 if (gspca_dev->usb_err == 0) in setexposure()
774 sd->reg11 = reg11; in setexposure()
779 {0xb0, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x16}; in setexposure()
781 {0xa0, 0x40, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x16}; in setexposure()
783 {0xa0, 0x40, 0x11, 0x01, 0x00, 0x00, 0x00, 0x16}; in setexposure()
796 if (gspca_dev->exposure->val < 200) { in setexposure()
797 i2cpexpo[3] = 255 - (gspca_dev->exposure->val * 255) in setexposure()
801 /* The PAS202's exposure control goes from 0 - 4095, in setexposure()
803 our 200-1023 to 500-4095 */ in setexposure()
804 framerate_ctrl = (gspca_dev->exposure->val - 200) in setexposure()
809 i2cpframerate[4] = framerate_ctrl & 0x3f; in setexposure()
817 {0xb1, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x14}; in setexposure()
819 {0xa1, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x14}; in setexposure()
821 {0xa1, 0x40, 0x13, 0x01, 0x00, 0x00, 0x00, 0x14}; in setexposure()
826 if (gspca_dev->exposure->val < 150) { in setexposure()
827 i2cpexpo[3] = 150 - gspca_dev->exposure->val; in setexposure()
830 /* The PAS106's exposure control goes from 0 - 4095, in setexposure()
832 our 150-1023 to 300-4095 */ in setexposure()
833 framerate_ctrl = (gspca_dev->exposure->val - 150) in setexposure()
838 i2cpframerate[4] = framerate_ctrl & 0x0f; in setexposure()
853 if (sd->sensor == SENSOR_OV6650 || sd->sensor == SENSOR_OV7630) { in setfreq()
856 0x2b register, see ov6630 datasheet. in setfreq()
857 0x4f / 0x8a -> (30 fps -> 25 fps), 0x00 -> no adjustment */ in setfreq()
858 __u8 i2c[] = {0xa0, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}; in setfreq()
859 switch (sd->plfreq->val) { in setfreq()
861 /* case 0: * no filter*/ in setfreq()
863 i2c[3] = 0; in setfreq()
866 i2c[3] = (sd->sensor == SENSOR_OV6650) in setfreq()
867 ? 0x4f : 0x8a; in setfreq()
870 i2c[1] = sensor_data[sd->sensor].sensor_addr; in setfreq()
880 avg_lum = atomic_read(&sd->avg_lum); in do_autogain()
881 if (avg_lum == -1) in do_autogain()
884 if (sd->autogain_ignore_frames > 0) { in do_autogain()
885 sd->autogain_ignore_frames--; in do_autogain()
891 if (sensor_data[sd->sensor].flags & F_SIF) { in do_autogain()
900 if (sd->brightness) in do_autogain()
901 desired_avg_lum = sd->brightness->val * desired_avg_lum / 127; in do_autogain()
903 if (gspca_dev->exposure->maximum < 500) { in do_autogain()
906 sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; in do_autogain()
908 int gain_knee = (s32)gspca_dev->gain->maximum * 9 / 10; in do_autogain()
910 deadzone, gain_knee, sd->exposure_knee)) in do_autogain()
911 sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; in do_autogain()
922 reg_r(gspca_dev, 0x00); in sd_config()
923 if (gspca_dev->usb_buf[0] != 0x10) in sd_config()
924 return -ENODEV; in sd_config()
927 sd->sensor = id->driver_info >> 8; in sd_config()
928 sd->bridge = id->driver_info & 0xff; in sd_config()
930 cam = &gspca_dev->cam; in sd_config()
931 if (!(sensor_data[sd->sensor].flags & F_SIF)) { in sd_config()
932 cam->cam_mode = vga_mode; in sd_config()
933 cam->nmodes = ARRAY_SIZE(vga_mode); in sd_config()
935 cam->cam_mode = sif_mode; in sd_config()
936 cam->nmodes = ARRAY_SIZE(sif_mode); in sd_config()
938 cam->npkt = 36; /* 36 packets per ISOC message */ in sd_config()
940 return 0; in sd_config()
946 const __u8 stop = 0x09; /* Disable stream turn of LED */ in sd_init()
948 reg_w(gspca_dev, 0x01, &stop, 1); in sd_init()
950 return gspca_dev->usb_err; in sd_init()
956 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
959 gspca_dev->usb_err = 0; in sd_s_ctrl()
961 if (ctrl->id == V4L2_CID_AUTOGAIN && ctrl->is_new && ctrl->val) { in sd_s_ctrl()
966 gspca_dev->gain->val = gspca_dev->gain->default_value; in sd_s_ctrl()
967 gspca_dev->exposure->val = gspca_dev->exposure->default_value; in sd_s_ctrl()
968 sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; in sd_s_ctrl()
971 if (!gspca_dev->streaming) in sd_s_ctrl()
972 return 0; in sd_s_ctrl()
974 switch (ctrl->id) { in sd_s_ctrl()
979 if (gspca_dev->exposure->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
981 if (gspca_dev->gain->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
988 return -EINVAL; in sd_s_ctrl()
990 return gspca_dev->usb_err; in sd_s_ctrl()
1001 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
1003 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
1006 if (sd->sensor == SENSOR_OV6650 || sd->sensor == SENSOR_OV7630 || in sd_init_controls()
1007 sd->sensor == SENSOR_PAS106 || sd->sensor == SENSOR_PAS202) in sd_init_controls()
1008 sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1009 V4L2_CID_BRIGHTNESS, 0, 255, 1, 127); in sd_init_controls()
1012 switch (sd->sensor) { in sd_init_controls()
1016 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1017 V4L2_CID_GAIN, 0, 31, 1, 15); in sd_init_controls()
1020 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1021 V4L2_CID_GAIN, 0, 47, 1, 31); in sd_init_controls()
1024 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1025 V4L2_CID_GAIN, 0, 63, 1, 31); in sd_init_controls()
1030 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1031 V4L2_CID_GAIN, 0, 255, 1, 127); in sd_init_controls()
1034 if (sd->bridge == BRIDGE_103) { in sd_init_controls()
1035 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1036 V4L2_CID_GAIN, 0, 127, 1, 63); in sd_init_controls()
1038 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1039 V4L2_CID_GAIN, 0, 15, 1, 7); in sd_init_controls()
1044 switch (sd->sensor) { in sd_init_controls()
1046 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1047 V4L2_CID_EXPOSURE, 0, 8191, 1, 482); in sd_init_controls()
1048 sd->exposure_knee = 964; in sd_init_controls()
1054 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1055 V4L2_CID_EXPOSURE, 0, 1023, 1, 66); in sd_init_controls()
1056 sd->exposure_knee = 200; in sd_init_controls()
1060 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1065 if (gspca_dev->exposure) { in sd_init_controls()
1066 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1067 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); in sd_init_controls()
1070 if (sd->sensor == SENSOR_OV6650 || sd->sensor == SENSOR_OV7630) in sd_init_controls()
1071 sd->plfreq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, in sd_init_controls()
1073 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0, in sd_init_controls()
1076 if (hdl->error) { in sd_init_controls()
1078 return hdl->error; in sd_init_controls()
1081 if (gspca_dev->autogain) in sd_init_controls()
1082 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
1084 return 0; in sd_init_controls()
1087 /* -- start the camera -- */
1091 struct cam *cam = &gspca_dev->cam; in sd_start()
1093 __u8 regs[0x31]; in sd_start()
1095 mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; in sd_start()
1096 /* Copy registers 0x01 - 0x19 from the template */ in sd_start()
1097 memcpy(&regs[0x01], sensor_data[sd->sensor].bridge_init, 0x19); in sd_start()
1099 regs[0x18] |= mode << 4; in sd_start()
1102 if (sd->bridge == BRIDGE_103) { in sd_start()
1103 regs[0x05] = 0x20; /* Red */ in sd_start()
1104 regs[0x06] = 0x20; /* Green */ in sd_start()
1105 regs[0x07] = 0x20; /* Blue */ in sd_start()
1107 regs[0x10] = 0x00; /* Red and blue */ in sd_start()
1108 regs[0x11] = 0x00; /* Green */ in sd_start()
1112 if (sensor_data[sd->sensor].flags & F_SIF) { in sd_start()
1113 regs[0x1a] = 0x14; /* HO_SIZE 640, makes no sense */ in sd_start()
1114 regs[0x1b] = 0x0a; /* VO_SIZE 320, makes no sense */ in sd_start()
1115 regs[0x1c] = 0x02; /* AE H-start 64 */ in sd_start()
1116 regs[0x1d] = 0x02; /* AE V-start 64 */ in sd_start()
1117 regs[0x1e] = 0x09; /* AE H-end 288 */ in sd_start()
1118 regs[0x1f] = 0x07; /* AE V-end 224 */ in sd_start()
1120 regs[0x1a] = 0x1d; /* HO_SIZE 960, makes no sense */ in sd_start()
1121 regs[0x1b] = 0x10; /* VO_SIZE 512, makes no sense */ in sd_start()
1122 regs[0x1c] = 0x05; /* AE H-start 160 */ in sd_start()
1123 regs[0x1d] = 0x03; /* AE V-start 96 */ in sd_start()
1124 regs[0x1e] = 0x0f; /* AE H-end 480 */ in sd_start()
1125 regs[0x1f] = 0x0c; /* AE V-end 384 */ in sd_start()
1129 for (i = 0; i < 16; i++) in sd_start()
1130 regs[0x20 + i] = i * 16; in sd_start()
1131 regs[0x20 + i] = 255; in sd_start()
1134 switch (sd->sensor) { in sd_start()
1138 nibble of 0x19 is exposure (clock divider) just as with in sd_start()
1140 regs[0x19] = mode ? 0x23 : 0x43; in sd_start()
1144 clock is set to 12 Mhz (reg1 == 0x04), rather then 24. in sd_start()
1147 if (sd->bridge == BRIDGE_103) { in sd_start()
1148 regs[0x01] = 0x44; /* Select 24 Mhz clock */ in sd_start()
1149 regs[0x12] = 0x02; /* Set hstart to 2 */ in sd_start()
1155 if (sd->bridge == BRIDGE_103) in sd_start()
1156 regs[0x12] += 1; in sd_start()
1160 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) in sd_start()
1161 regs[0x18] &= ~0x80; in sd_start()
1164 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { in sd_start()
1165 regs[0x12] += 16; /* hstart adjust */ in sd_start()
1166 regs[0x13] += 24; /* vstart adjust */ in sd_start()
1167 regs[0x15] = 320 / 16; /* hsize */ in sd_start()
1168 regs[0x16] = 240 / 16; /* vsize */ in sd_start()
1171 /* reg 0x01 bit 2 video transfert on */ in sd_start()
1172 reg_w(gspca_dev, 0x01, &regs[0x01], 1); in sd_start()
1173 /* reg 0x17 SensorClk enable inv Clk 0x60 */ in sd_start()
1174 reg_w(gspca_dev, 0x17, &regs[0x17], 1); in sd_start()
1176 reg_w(gspca_dev, 0x01, &regs[0x01], in sd_start()
1177 (sd->bridge == BRIDGE_103) ? 0x30 : 0x1f); in sd_start()
1180 i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, in sd_start()
1181 sensor_data[sd->sensor].sensor_init_size); in sd_start()
1184 switch (sd->sensor) { in sd_start()
1187 {0xa0, 0x40, 0x02, 0x03, 0x00, 0x00, 0x00, 0x10}; in sd_start()
1188 /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */ in sd_start()
1196 if (sd->bridge == BRIDGE_103) { in sd_start()
1197 const __u8 i2c[] = { 0xa0, 0x21, 0x13, in sd_start()
1198 0x80, 0x00, 0x00, 0x00, 0x10 }; in sd_start()
1203 /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ in sd_start()
1204 reg_w(gspca_dev, 0x15, &regs[0x15], 2); in sd_start()
1206 reg_w(gspca_dev, 0x18, &regs[0x18], 1); in sd_start()
1208 reg_w(gspca_dev, 0x12, &regs[0x12], 1); in sd_start()
1210 reg_w(gspca_dev, 0x13, &regs[0x13], 1); in sd_start()
1211 /* reset 0x17 SensorClk enable inv Clk 0x60 */ in sd_start()
1213 reg_w(gspca_dev, 0x17, &regs[0x17], 1); in sd_start()
1214 /*MCKSIZE ->3 */ /*fixme: not ov7630*/ in sd_start()
1215 reg_w(gspca_dev, 0x19, &regs[0x19], 1); in sd_start()
1217 reg_w(gspca_dev, 0x1c, &regs[0x1c], 4); in sd_start()
1219 reg_w(gspca_dev, 0x01, &regs[0x01], 1); in sd_start()
1221 reg_w(gspca_dev, 0x18, &regs[0x18], 2); in sd_start()
1224 sd->reg11 = -1; in sd_start()
1231 sd->frames_to_drop = 0; in sd_start()
1232 sd->autogain_ignore_frames = 0; in sd_start()
1233 gspca_dev->exp_too_high_cnt = 0; in sd_start()
1234 gspca_dev->exp_too_low_cnt = 0; in sd_start()
1235 atomic_set(&sd->avg_lum, -1); in sd_start()
1236 return gspca_dev->usb_err; in sd_start()
1247 int i, header_size = (sd->bridge == BRIDGE_103) ? 18 : 12; in find_sof()
1253 * (xx) (idem - extra byte for sn9c103) in find_sof()
1258 for (i = 0; i < len; i++) { in find_sof()
1259 switch (sd->header_read) { in find_sof()
1260 case 0: in find_sof()
1261 if (data[i] == 0xff) in find_sof()
1262 sd->header_read++; in find_sof()
1265 if (data[i] == 0xff) in find_sof()
1266 sd->header_read++; in find_sof()
1268 sd->header_read = 0; in find_sof()
1271 if (data[i] == 0x00) in find_sof()
1272 sd->header_read++; in find_sof()
1273 else if (data[i] != 0xff) in find_sof()
1274 sd->header_read = 0; in find_sof()
1277 if (data[i] == 0xc4) in find_sof()
1278 sd->header_read++; in find_sof()
1279 else if (data[i] == 0xff) in find_sof()
1280 sd->header_read = 1; in find_sof()
1282 sd->header_read = 0; in find_sof()
1285 if (data[i] == 0xc4) in find_sof()
1286 sd->header_read++; in find_sof()
1287 else if (data[i] == 0xff) in find_sof()
1288 sd->header_read = 1; in find_sof()
1290 sd->header_read = 0; in find_sof()
1293 if (data[i] == 0x96) in find_sof()
1294 sd->header_read++; in find_sof()
1295 else if (data[i] == 0xff) in find_sof()
1296 sd->header_read = 1; in find_sof()
1298 sd->header_read = 0; in find_sof()
1301 sd->header[sd->header_read - 6] = data[i]; in find_sof()
1302 sd->header_read++; in find_sof()
1303 if (sd->header_read == header_size) { in find_sof()
1304 sd->header_read = 0; in find_sof()
1316 int fr_h_sz = 0, lum_offset = 0, len_after_sof = 0; in sd_pkt_scan()
1318 struct cam *cam = &gspca_dev->cam; in sd_pkt_scan()
1323 if (sd->bridge == BRIDGE_103) { in sd_pkt_scan()
1331 len_after_sof = len - (sof - data); in sd_pkt_scan()
1332 len = (sof - data) - fr_h_sz; in sd_pkt_scan()
1333 if (len < 0) in sd_pkt_scan()
1334 len = 0; in sd_pkt_scan()
1337 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) { in sd_pkt_scan()
1341 int size = cam->cam_mode[gspca_dev->curr_mode].sizeimage; in sd_pkt_scan()
1343 used = gspca_dev->image_len; in sd_pkt_scan()
1345 len = size - used; in sd_pkt_scan()
1351 int lum = sd->header[lum_offset] + in sd_pkt_scan()
1352 (sd->header[lum_offset + 1] << 8); in sd_pkt_scan()
1355 get a lum of 0 in this case drop 2 frames in sd_pkt_scan()
1358 *really* is 0 (cam used in low light with in sd_pkt_scan()
1360 if the previous lum was 0 too. */ in sd_pkt_scan()
1361 if (lum == 0 && sd->prev_avg_lum != 0) { in sd_pkt_scan()
1362 lum = -1; in sd_pkt_scan()
1363 sd->frames_to_drop = 2; in sd_pkt_scan()
1364 sd->prev_avg_lum = 0; in sd_pkt_scan()
1366 sd->prev_avg_lum = lum; in sd_pkt_scan()
1367 atomic_set(&sd->avg_lum, lum); in sd_pkt_scan()
1369 if (sd->frames_to_drop) in sd_pkt_scan()
1370 sd->frames_to_drop--; in sd_pkt_scan()
1372 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); in sd_pkt_scan()
1383 int ret = -EINVAL; in sd_int_pkt_scan()
1385 if (len == 1 && data[0] == 1) { in sd_int_pkt_scan()
1386 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); in sd_int_pkt_scan()
1387 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
1388 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); in sd_int_pkt_scan()
1389 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
1390 ret = 0; in sd_int_pkt_scan()
1397 /* sub-driver description */
1412 /* -- module initialisation -- */
1418 {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */
1419 {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */
1420 {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */
1421 {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)},
1422 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)},
1423 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)},
1424 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)},
1425 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)},
1426 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)},
1427 {USB_DEVICE(0x0c45, 0x6027), SB(OV7630, 101)}, /* Genius Eye 310 */
1428 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)},
1429 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)},
1430 {USB_DEVICE(0x0c45, 0x602a), SB(HV7131D, 102)},
1431 /* {USB_DEVICE(0x0c45, 0x602b), SB(MI0343, 102)}, */
1432 {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)},
1433 {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)},
1434 {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)},
1435 /* {USB_DEVICE(0x0c45, 0x6030), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */
1436 /* {USB_DEVICE(0x0c45, 0x6082), SB(MI03XX, 103)}, */ /* MI0343 MI0360 */
1437 {USB_DEVICE(0x0c45, 0x6083), SB(HV7131D, 103)},
1438 {USB_DEVICE(0x0c45, 0x608c), SB(HV7131R, 103)},
1439 /* {USB_DEVICE(0x0c45, 0x608e), SB(CISVF10, 103)}, */
1440 {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)},
1441 {USB_DEVICE(0x0c45, 0x60a8), SB(PAS106, 103)},
1442 {USB_DEVICE(0x0c45, 0x60aa), SB(TAS5130CXX, 103)},
1443 {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)},
1444 {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)},
1449 /* -- device connect -- */