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.c341
1 files changed, 264 insertions, 77 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 0bd36a00dd2a..83d5773d4629 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -21,6 +21,7 @@
21 21
22#define MODULE_NAME "sonixj" 22#define MODULE_NAME "sonixj"
23 23
24#include <linux/input.h>
24#include "gspca.h" 25#include "gspca.h"
25#include "jpeg.h" 26#include "jpeg.h"
26 27
@@ -45,6 +46,7 @@ struct sd {
45 u8 red; 46 u8 red;
46 u8 gamma; 47 u8 gamma;
47 u8 vflip; /* ov7630/ov7648 only */ 48 u8 vflip; /* ov7630/ov7648 only */
49 u8 sharpness;
48 u8 infrared; /* mt9v111 only */ 50 u8 infrared; /* mt9v111 only */
49 u8 freq; /* ov76xx only */ 51 u8 freq; /* ov76xx only */
50 u8 quality; /* image quality */ 52 u8 quality; /* image quality */
@@ -64,16 +66,17 @@ struct sd {
64#define BRIDGE_SN9C110 2 66#define BRIDGE_SN9C110 2
65#define BRIDGE_SN9C120 3 67#define BRIDGE_SN9C120 3
66 u8 sensor; /* Type of image sensor chip */ 68 u8 sensor; /* Type of image sensor chip */
67#define SENSOR_HV7131R 0 69#define SENSOR_ADCM1700 0
68#define SENSOR_MI0360 1 70#define SENSOR_HV7131R 1
69#define SENSOR_MO4000 2 71#define SENSOR_MI0360 2
70#define SENSOR_MT9V111 3 72#define SENSOR_MO4000 3
71#define SENSOR_OM6802 4 73#define SENSOR_MT9V111 4
72#define SENSOR_OV7630 5 74#define SENSOR_OM6802 5
73#define SENSOR_OV7648 6 75#define SENSOR_OV7630 6
74#define SENSOR_OV7660 7 76#define SENSOR_OV7648 7
75#define SENSOR_PO1030 8 77#define SENSOR_OV7660 8
76#define SENSOR_SP80708 9 78#define SENSOR_PO1030 9
79#define SENSOR_SP80708 10
77 u8 i2c_addr; 80 u8 i2c_addr;
78 81
79 u8 *jpeg_hdr; 82 u8 *jpeg_hdr;
@@ -96,12 +99,14 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 99static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
97static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 100static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); 101static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
102static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
103static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
99static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); 104static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
100static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); 105static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
101static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); 106static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
102static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 107static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
103 108
104static struct ctrl sd_ctrls[] = { 109static const struct ctrl sd_ctrls[] = {
105#define BRIGHTNESS_IDX 0 110#define BRIGHTNESS_IDX 0
106 { 111 {
107 { 112 {
@@ -225,8 +230,23 @@ static struct ctrl sd_ctrls[] = {
225 .set = sd_setvflip, 230 .set = sd_setvflip,
226 .get = sd_getvflip, 231 .get = sd_getvflip,
227 }, 232 },
233#define SHARPNESS_IDX 8
234 {
235 {
236 .id = V4L2_CID_SHARPNESS,
237 .type = V4L2_CTRL_TYPE_INTEGER,
238 .name = "Sharpness",
239 .minimum = 0,
240 .maximum = 255,
241 .step = 1,
242#define SHARPNESS_DEF 90
243 .default_value = SHARPNESS_DEF,
244 },
245 .set = sd_setsharpness,
246 .get = sd_getsharpness,
247 },
228/* mt9v111 only */ 248/* mt9v111 only */
229#define INFRARED_IDX 8 249#define INFRARED_IDX 9
230 { 250 {
231 { 251 {
232 .id = V4L2_CID_INFRARED, 252 .id = V4L2_CID_INFRARED,
@@ -242,7 +262,7 @@ static struct ctrl sd_ctrls[] = {
242 .get = sd_getinfrared, 262 .get = sd_getinfrared,
243 }, 263 },
244/* ov7630/ov7648/ov7660 only */ 264/* ov7630/ov7648/ov7660 only */
245#define FREQ_IDX 9 265#define FREQ_IDX 10
246 { 266 {
247 { 267 {
248 .id = V4L2_CID_POWER_LINE_FREQUENCY, 268 .id = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -261,28 +281,37 @@ static struct ctrl sd_ctrls[] = {
261 281
262/* table of the disabled controls */ 282/* table of the disabled controls */
263static __u32 ctrl_dis[] = { 283static __u32 ctrl_dis[] = {
284 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX) |
285 (1 << AUTOGAIN_IDX), /* SENSOR_ADCM1700 0 */
286 (1 << INFRARED_IDX) | (1 << FREQ_IDX),
287 /* SENSOR_HV7131R 1 */
264 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), 288 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
265 /* SENSOR_HV7131R 0 */ 289 /* SENSOR_MI0360 2 */
266 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), 290 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
267 /* SENSOR_MI0360 1 */ 291 /* SENSOR_MO4000 3 */
268 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
269 /* SENSOR_MO4000 2 */
270 (1 << VFLIP_IDX) | (1 << FREQ_IDX), 292 (1 << VFLIP_IDX) | (1 << FREQ_IDX),
271 /* SENSOR_MT9V111 3 */ 293 /* SENSOR_MT9V111 4 */
272 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), 294 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
273 /* SENSOR_OM6802 4 */ 295 /* SENSOR_OM6802 5 */
274 (1 << INFRARED_IDX), 296 (1 << INFRARED_IDX),
275 /* SENSOR_OV7630 5 */ 297 /* SENSOR_OV7630 6 */
276 (1 << INFRARED_IDX), 298 (1 << INFRARED_IDX),
277 /* SENSOR_OV7648 6 */ 299 /* SENSOR_OV7648 7 */
278 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 300 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
279 /* SENSOR_OV7660 7 */ 301 /* SENSOR_OV7660 8 */
280 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | 302 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
281 (1 << FREQ_IDX), /* SENSOR_PO1030 8 */ 303 (1 << FREQ_IDX), /* SENSOR_PO1030 9 */
282 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | 304 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
283 (1 << FREQ_IDX), /* SENSOR_SP80708 9 */ 305 (1 << FREQ_IDX), /* SENSOR_SP80708 10 */
284}; 306};
285 307
308static const struct v4l2_pix_format cif_mode[] = {
309 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
310 .bytesperline = 352,
311 .sizeimage = 352 * 288 * 4 / 8 + 590,
312 .colorspace = V4L2_COLORSPACE_JPEG,
313 .priv = 0},
314};
286static const struct v4l2_pix_format vga_mode[] = { 315static const struct v4l2_pix_format vga_mode[] = {
287 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 316 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
288 .bytesperline = 160, 317 .bytesperline = 160,
@@ -302,6 +331,17 @@ static const struct v4l2_pix_format vga_mode[] = {
302 .priv = 0}, 331 .priv = 0},
303}; 332};
304 333
334static const u8 sn_adcm1700[0x1c] = {
335/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
336 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
337/* reg8 reg9 rega regb regc regd rege regf */
338 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
340 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
341/* reg18 reg19 reg1a reg1b */
342 0x06, 0x00, 0x00, 0x00
343};
344
305/*Data from sn9c102p+hv7131r */ 345/*Data from sn9c102p+hv7131r */
306static const u8 sn_hv7131[0x1c] = { 346static const u8 sn_hv7131[0x1c] = {
307/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 347/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
@@ -415,6 +455,7 @@ static const u8 sn_sp80708[0x1c] = {
415 455
416/* sequence specific to the sensors - !! index = SENSOR_xxx */ 456/* sequence specific to the sensors - !! index = SENSOR_xxx */
417static const u8 *sn_tb[] = { 457static const u8 *sn_tb[] = {
458 sn_adcm1700,
418 sn_hv7131, 459 sn_hv7131,
419 sn_mi0360, 460 sn_mi0360,
420 sn_mo4000, 461 sn_mo4000,
@@ -432,6 +473,11 @@ static const u8 gamma_def[17] = {
432 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, 473 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
433 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff 474 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
434}; 475};
476/* gamma for sensor ADCM1700 */
477static const u8 gamma_spec_0[17] = {
478 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
479 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
480};
435/* gamma for sensors HV7131R and MT9V111 */ 481/* gamma for sensors HV7131R and MT9V111 */
436static const u8 gamma_spec_1[17] = { 482static const u8 gamma_spec_1[17] = {
437 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d, 483 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
@@ -450,6 +496,42 @@ static const u8 reg84[] = {
450 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ 496 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
451 0x00, 0x00, 0x00 /* YUV offsets */ 497 0x00, 0x00, 0x00 /* YUV offsets */
452}; 498};
499static const u8 adcm1700_sensor_init[][8] = {
500 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
502 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
503 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
504 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
505 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
506 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
507 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
508 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
509 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
510 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
511 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
512 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
513 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
514 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
515 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
516 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
517 {}
518};
519static const u8 adcm1700_sensor_param1[][8] = {
520 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
521 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
522
523 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
524 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
525 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
526 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
527 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
528
529 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
530 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
531 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
532 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
533 {}
534};
453static const u8 hv7131r_sensor_init[][8] = { 535static const u8 hv7131r_sensor_init[][8] = {
454 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, 536 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
455 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10}, 537 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
@@ -986,17 +1068,18 @@ static const u8 sp80708_sensor_param1[][8] = {
986 {} 1068 {}
987}; 1069};
988 1070
989static const u8 (*sensor_init[10])[8] = { 1071static const u8 (*sensor_init[11])[8] = {
990 hv7131r_sensor_init, /* HV7131R 0 */ 1072 adcm1700_sensor_init, /* ADCM1700 0 */
991 mi0360_sensor_init, /* MI0360 1 */ 1073 hv7131r_sensor_init, /* HV7131R 1 */
992 mo4000_sensor_init, /* MO4000 2 */ 1074 mi0360_sensor_init, /* MI0360 2 */
993 mt9v111_sensor_init, /* MT9V111 3 */ 1075 mo4000_sensor_init, /* MO4000 3 */
994 om6802_sensor_init, /* OM6802 4 */ 1076 mt9v111_sensor_init, /* MT9V111 4 */
995 ov7630_sensor_init, /* OV7630 5 */ 1077 om6802_sensor_init, /* OM6802 5 */
996 ov7648_sensor_init, /* OV7648 6 */ 1078 ov7630_sensor_init, /* OV7630 6 */
997 ov7660_sensor_init, /* OV7660 7 */ 1079 ov7648_sensor_init, /* OV7648 7 */
998 po1030_sensor_init, /* PO1030 8 */ 1080 ov7660_sensor_init, /* OV7660 8 */
999 sp80708_sensor_init, /* SP80708 9 */ 1081 po1030_sensor_init, /* PO1030 9 */
1082 sp80708_sensor_init, /* SP80708 10 */
1000}; 1083};
1001 1084
1002/* read <len> bytes to gspca_dev->usb_buf */ 1085/* read <len> bytes to gspca_dev->usb_buf */
@@ -1064,6 +1147,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1064 1147
1065 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val); 1148 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
1066 switch (sd->sensor) { 1149 switch (sd->sensor) {
1150 case SENSOR_ADCM1700:
1067 case SENSOR_OM6802: /* i2c command = a0 (100 kHz) */ 1151 case SENSOR_OM6802: /* i2c command = a0 (100 kHz) */
1068 gspca_dev->usb_buf[0] = 0x80 | (2 << 4); 1152 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1069 break; 1153 break;
@@ -1110,6 +1194,7 @@ static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
1110 u8 mode[8]; 1194 u8 mode[8];
1111 1195
1112 switch (sd->sensor) { 1196 switch (sd->sensor) {
1197 case SENSOR_ADCM1700:
1113 case SENSOR_OM6802: /* i2c command = 90 (100 kHz) */ 1198 case SENSOR_OM6802: /* i2c command = 90 (100 kHz) */
1114 mode[0] = 0x80 | 0x10; 1199 mode[0] = 0x80 | 0x10;
1115 break; 1200 break;
@@ -1260,7 +1345,8 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1260 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; 1345 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1261 static const u8 regd4[] = {0x60, 0x00, 0x00}; 1346 static const u8 regd4[] = {0x60, 0x00, 0x00};
1262 1347
1263 reg_w1(gspca_dev, 0xf1, 0x00); 1348 /* sensor clock already enabled in sd_init */
1349 /* reg_w1(gspca_dev, 0xf1, 0x00); */
1264 reg_w1(gspca_dev, 0x01, sn9c1xx[1]); 1350 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1265 1351
1266 /* configure gpio */ 1352 /* configure gpio */
@@ -1284,6 +1370,12 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1284 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); 1370 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1285 1371
1286 switch (sd->sensor) { 1372 switch (sd->sensor) {
1373 case SENSOR_ADCM1700:
1374 reg_w1(gspca_dev, 0x01, 0x43);
1375 reg_w1(gspca_dev, 0x17, 0x62);
1376 reg_w1(gspca_dev, 0x01, 0x42);
1377 reg_w1(gspca_dev, 0x01, 0x42);
1378 break;
1287 case SENSOR_MT9V111: 1379 case SENSOR_MT9V111:
1288 reg_w1(gspca_dev, 0x01, 0x61); 1380 reg_w1(gspca_dev, 0x01, 0x61);
1289 reg_w1(gspca_dev, 0x17, 0x61); 1381 reg_w1(gspca_dev, 0x17, 0x61);
@@ -1357,14 +1449,19 @@ static int sd_config(struct gspca_dev *gspca_dev,
1357 struct sd *sd = (struct sd *) gspca_dev; 1449 struct sd *sd = (struct sd *) gspca_dev;
1358 struct cam *cam; 1450 struct cam *cam;
1359 1451
1360 cam = &gspca_dev->cam;
1361 cam->cam_mode = vga_mode;
1362 cam->nmodes = ARRAY_SIZE(vga_mode);
1363 cam->npkt = 24; /* 24 packets per ISOC message */
1364
1365 sd->bridge = id->driver_info >> 16; 1452 sd->bridge = id->driver_info >> 16;
1366 sd->sensor = id->driver_info; 1453 sd->sensor = id->driver_info;
1367 1454
1455 cam = &gspca_dev->cam;
1456 if (sd->sensor == SENSOR_ADCM1700) {
1457 cam->cam_mode = cif_mode;
1458 cam->nmodes = ARRAY_SIZE(cif_mode);
1459 } else {
1460 cam->cam_mode = vga_mode;
1461 cam->nmodes = ARRAY_SIZE(vga_mode);
1462 }
1463 cam->npkt = 24; /* 24 packets per ISOC message */
1464
1368 sd->brightness = BRIGHTNESS_DEF; 1465 sd->brightness = BRIGHTNESS_DEF;
1369 sd->contrast = CONTRAST_DEF; 1466 sd->contrast = CONTRAST_DEF;
1370 sd->colors = COLOR_DEF; 1467 sd->colors = COLOR_DEF;
@@ -1374,6 +1471,14 @@ static int sd_config(struct gspca_dev *gspca_dev,
1374 sd->autogain = AUTOGAIN_DEF; 1471 sd->autogain = AUTOGAIN_DEF;
1375 sd->ag_cnt = -1; 1472 sd->ag_cnt = -1;
1376 sd->vflip = VFLIP_DEF; 1473 sd->vflip = VFLIP_DEF;
1474 switch (sd->sensor) {
1475 case SENSOR_OM6802:
1476 sd->sharpness = 0x10;
1477 break;
1478 default:
1479 sd->sharpness = SHARPNESS_DEF;
1480 break;
1481 }
1377 sd->infrared = INFRARED_DEF; 1482 sd->infrared = INFRARED_DEF;
1378 sd->freq = FREQ_DEF; 1483 sd->freq = FREQ_DEF;
1379 sd->quality = QUALITY_DEF; 1484 sd->quality = QUALITY_DEF;
@@ -1433,7 +1538,9 @@ static int sd_init(struct gspca_dev *gspca_dev)
1433 break; 1538 break;
1434 } 1539 }
1435 1540
1436 reg_w1(gspca_dev, 0xf1, 0x01); 1541 /* Note we do not disable the sensor clock here (power saving mode),
1542 as that also disables the button on the cam. */
1543 reg_w1(gspca_dev, 0xf1, 0x00);
1437 1544
1438 /* set the i2c address */ 1545 /* set the i2c address */
1439 sn9c1xx = sn_tb[sd->sensor]; 1546 sn9c1xx = sn_tb[sd->sensor];
@@ -1543,6 +1650,10 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1543 1650
1544 k2 = ((int) sd->brightness - 0x8000) >> 10; 1651 k2 = ((int) sd->brightness - 0x8000) >> 10;
1545 switch (sd->sensor) { 1652 switch (sd->sensor) {
1653 case SENSOR_ADCM1700:
1654 if (k2 > 0x1f)
1655 k2 = 0; /* only positive Y offset */
1656 break;
1546 case SENSOR_HV7131R: 1657 case SENSOR_HV7131R:
1547 expo = sd->brightness << 4; 1658 expo = sd->brightness << 4;
1548 if (expo > 0x002dc6c0) 1659 if (expo > 0x002dc6c0)
@@ -1625,6 +1736,9 @@ static void setgamma(struct gspca_dev *gspca_dev)
1625 }; 1736 };
1626 1737
1627 switch (sd->sensor) { 1738 switch (sd->sensor) {
1739 case SENSOR_ADCM1700:
1740 gamma_base = gamma_spec_0;
1741 break;
1628 case SENSOR_HV7131R: 1742 case SENSOR_HV7131R:
1629 case SENSOR_MT9V111: 1743 case SENSOR_MT9V111:
1630 gamma_base = gamma_spec_1; 1744 gamma_base = gamma_spec_1;
@@ -1670,23 +1784,39 @@ static void setautogain(struct gspca_dev *gspca_dev)
1670 sd->ag_cnt = -1; 1784 sd->ag_cnt = -1;
1671} 1785}
1672 1786
1673/* ov7630/ov7648 only */ 1787/* hv7131r/ov7630/ov7648 only */
1674static void setvflip(struct sd *sd) 1788static void setvflip(struct sd *sd)
1675{ 1789{
1676 u8 comn; 1790 u8 comn;
1677 1791
1678 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX)) 1792 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
1679 return; 1793 return;
1680 if (sd->sensor == SENSOR_OV7630) { 1794 switch (sd->sensor) {
1795 case SENSOR_HV7131R:
1796 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
1797 if (sd->vflip)
1798 comn |= 0x01;
1799 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
1800 break;
1801 case SENSOR_OV7630:
1681 comn = 0x02; 1802 comn = 0x02;
1682 if (!sd->vflip) 1803 if (!sd->vflip)
1683 comn |= 0x80; 1804 comn |= 0x80;
1684 } else { 1805 i2c_w1(&sd->gspca_dev, 0x75, comn);
1806 break;
1807 default:
1808/* case SENSOR_OV7648: */
1685 comn = 0x06; 1809 comn = 0x06;
1686 if (sd->vflip) 1810 if (sd->vflip)
1687 comn |= 0x80; 1811 comn |= 0x80;
1812 i2c_w1(&sd->gspca_dev, 0x75, comn);
1813 break;
1688 } 1814 }
1689 i2c_w1(&sd->gspca_dev, 0x75, comn); 1815}
1816
1817static void setsharpness(struct sd *sd)
1818{
1819 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
1690} 1820}
1691 1821
1692static void setinfrared(struct sd *sd) 1822static void setinfrared(struct sd *sd)
@@ -1804,6 +1934,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
1804 int mode; 1934 int mode;
1805 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 1935 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1806 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 1936 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1937 static const u8 CA_adcm1700[] =
1938 { 0x14, 0xec, 0x0a, 0xf6 };
1807 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ 1939 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1808 static const u8 CE_ov76xx[] = 1940 static const u8 CE_ov76xx[] =
1809 { 0x32, 0xdd, 0x32, 0xdd }; 1941 { 0x32, 0xdd, 0x32, 0xdd };
@@ -1824,6 +1956,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1824 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); 1956 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
1825 1957
1826 switch (sd->sensor) { 1958 switch (sd->sensor) {
1959 case SENSOR_ADCM1700:
1960 reg2 = 0x60;
1961 break;
1827 case SENSOR_OM6802: 1962 case SENSOR_OM6802:
1828 reg2 = 0x71; 1963 reg2 = 0x71;
1829 break; 1964 break;
@@ -1842,17 +1977,28 @@ static int sd_start(struct gspca_dev *gspca_dev)
1842 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); 1977 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1843 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]); 1978 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1844 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); 1979 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1845 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */ 1980 if (sd->sensor == SENSOR_ADCM1700) {
1846 reg_w1(gspca_dev, 0xd3, 0x50); 1981 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
1982 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
1983 } else {
1984 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
1985 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
1986 }
1847 reg_w1(gspca_dev, 0xc6, 0x00); 1987 reg_w1(gspca_dev, 0xc6, 0x00);
1848 reg_w1(gspca_dev, 0xc7, 0x00); 1988 reg_w1(gspca_dev, 0xc7, 0x00);
1849 reg_w1(gspca_dev, 0xc8, 0x50); 1989 if (sd->sensor == SENSOR_ADCM1700) {
1850 reg_w1(gspca_dev, 0xc9, 0x3c); 1990 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
1991 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
1992 } else {
1993 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
1994 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
1995 }
1851 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); 1996 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1852 switch (sd->sensor) { 1997 switch (sd->sensor) {
1853 case SENSOR_MT9V111: 1998 case SENSOR_MT9V111:
1854 reg17 = 0xe0; 1999 reg17 = 0xe0;
1855 break; 2000 break;
2001 case SENSOR_ADCM1700:
1856 case SENSOR_OV7630: 2002 case SENSOR_OV7630:
1857 reg17 = 0xe2; 2003 reg17 = 0xe2;
1858 break; 2004 break;
@@ -1870,44 +2016,39 @@ static int sd_start(struct gspca_dev *gspca_dev)
1870 break; 2016 break;
1871 } 2017 }
1872 reg_w1(gspca_dev, 0x17, reg17); 2018 reg_w1(gspca_dev, 0x17, reg17);
1873/* set reg1 was here */ 2019
1874 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */ 2020 reg_w1(gspca_dev, 0x05, 0x00); /* red */
1875 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ 2021 reg_w1(gspca_dev, 0x07, 0x00); /* green */
1876 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ 2022 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
1877 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); 2023 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1878 2024
1879 setgamma(gspca_dev); 2025 setgamma(gspca_dev);
1880 2026
2027/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
1881 for (i = 0; i < 8; i++) 2028 for (i = 0; i < 8; i++)
1882 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2029 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1883 switch (sd->sensor) { 2030 switch (sd->sensor) {
2031 case SENSOR_ADCM1700:
2032 case SENSOR_OV7660:
2033 case SENSOR_SP80708:
2034 reg_w1(gspca_dev, 0x9a, 0x05);
2035 break;
1884 case SENSOR_MT9V111: 2036 case SENSOR_MT9V111:
1885 reg_w1(gspca_dev, 0x9a, 0x07); 2037 reg_w1(gspca_dev, 0x9a, 0x07);
1886 reg_w1(gspca_dev, 0x99, 0x59);
1887 break;
1888 case SENSOR_OM6802:
1889 reg_w1(gspca_dev, 0x9a, 0x08);
1890 reg_w1(gspca_dev, 0x99, 0x10);
1891 break; 2038 break;
1892 case SENSOR_OV7648: 2039 case SENSOR_OV7648:
1893 reg_w1(gspca_dev, 0x9a, 0x0a); 2040 reg_w1(gspca_dev, 0x9a, 0x0a);
1894 reg_w1(gspca_dev, 0x99, 0x60);
1895 break;
1896 case SENSOR_OV7660:
1897 case SENSOR_SP80708:
1898 reg_w1(gspca_dev, 0x9a, 0x05);
1899 reg_w1(gspca_dev, 0x99, 0x59);
1900 break; 2041 break;
1901 default: 2042 default:
1902 reg_w1(gspca_dev, 0x9a, 0x08); 2043 reg_w1(gspca_dev, 0x9a, 0x08);
1903 reg_w1(gspca_dev, 0x99, 0x59);
1904 break; 2044 break;
1905 } 2045 }
2046 setsharpness(sd);
1906 2047
1907 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2048 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1908 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */ 2049 reg_w1(gspca_dev, 0x05, 0x20); /* red */
1909 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ 2050 reg_w1(gspca_dev, 0x07, 0x20); /* green */
1910 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ 2051 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
1911 2052
1912 init = NULL; 2053 init = NULL;
1913 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 2054 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
@@ -1917,6 +2058,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
1917 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */ 2058 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1918 reg17 = 0x61; /* 0x:20: enable sensor clock */ 2059 reg17 = 0x61; /* 0x:20: enable sensor clock */
1919 switch (sd->sensor) { 2060 switch (sd->sensor) {
2061 case SENSOR_ADCM1700:
2062 init = adcm1700_sensor_param1;
2063 reg1 = 0x46;
2064 reg17 = 0xe2;
2065 break;
1920 case SENSOR_MO4000: 2066 case SENSOR_MO4000:
1921 if (mode) { 2067 if (mode) {
1922/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ 2068/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
@@ -1940,7 +2086,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
1940 reg17 = 0x64; /* 640 MCKSIZE */ 2086 reg17 = 0x64; /* 640 MCKSIZE */
1941 break; 2087 break;
1942 case SENSOR_OV7630: 2088 case SENSOR_OV7630:
1943 setvflip(sd);
1944 reg17 = 0xe2; 2089 reg17 = 0xe2;
1945 reg1 = 0x44; 2090 reg1 = 0x44;
1946 break; 2091 break;
@@ -1986,8 +2131,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
1986 } 2131 }
1987 2132
1988 reg_w(gspca_dev, 0xc0, C0, 6); 2133 reg_w(gspca_dev, 0xc0, C0, 6);
1989 reg_w(gspca_dev, 0xca, CA, 4); 2134 if (sd->sensor == SENSOR_ADCM1700)
2135 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
2136 else
2137 reg_w(gspca_dev, 0xca, CA, 4);
1990 switch (sd->sensor) { 2138 switch (sd->sensor) {
2139 case SENSOR_ADCM1700:
1991 case SENSOR_OV7630: 2140 case SENSOR_OV7630:
1992 case SENSOR_OV7648: 2141 case SENSOR_OV7648:
1993 case SENSOR_OV7660: 2142 case SENSOR_OV7660:
@@ -2008,11 +2157,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2008 reg_w1(gspca_dev, 0x17, reg17); 2157 reg_w1(gspca_dev, 0x17, reg17);
2009 reg_w1(gspca_dev, 0x01, reg1); 2158 reg_w1(gspca_dev, 0x01, reg1);
2010 2159
2011 switch (sd->sensor) { 2160 setvflip(sd);
2012 case SENSOR_OV7630:
2013 setvflip(sd);
2014 break;
2015 }
2016 setbrightness(gspca_dev); 2161 setbrightness(gspca_dev);
2017 setcontrast(gspca_dev); 2162 setcontrast(gspca_dev);
2018 setautogain(gspca_dev); 2163 setautogain(gspca_dev);
@@ -2056,7 +2201,8 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2056 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); 2201 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2057 reg_w1(gspca_dev, 0x01, sn9c1xx[1]); 2202 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2058 reg_w1(gspca_dev, 0x01, data); 2203 reg_w1(gspca_dev, 0x01, data);
2059 reg_w1(gspca_dev, 0xf1, 0x00); 2204 /* Don't disable sensor clock as that disables the button on the cam */
2205 /* reg_w1(gspca_dev, 0xf1, 0x01); */
2060} 2206}
2061 2207
2062static void sd_stop0(struct gspca_dev *gspca_dev) 2208static void sd_stop0(struct gspca_dev *gspca_dev)
@@ -2288,6 +2434,24 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2288 return 0; 2434 return 0;
2289} 2435}
2290 2436
2437static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2438{
2439 struct sd *sd = (struct sd *) gspca_dev;
2440
2441 sd->sharpness = val;
2442 if (gspca_dev->streaming)
2443 setsharpness(sd);
2444 return 0;
2445}
2446
2447static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2448{
2449 struct sd *sd = (struct sd *) gspca_dev;
2450
2451 *val = sd->sharpness;
2452 return 0;
2453}
2454
2291static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) 2455static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2292{ 2456{
2293 struct sd *sd = (struct sd *) gspca_dev; 2457 struct sd *sd = (struct sd *) gspca_dev;
@@ -2391,6 +2555,25 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
2391 return -EINVAL; 2555 return -EINVAL;
2392} 2556}
2393 2557
2558#ifdef CONFIG_INPUT
2559static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2560 u8 *data, /* interrupt packet data */
2561 int len) /* interrupt packet length */
2562{
2563 int ret = -EINVAL;
2564
2565 if (len == 1 && data[0] == 1) {
2566 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2567 input_sync(gspca_dev->input_dev);
2568 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2569 input_sync(gspca_dev->input_dev);
2570 ret = 0;
2571 }
2572
2573 return ret;
2574}
2575#endif
2576
2394/* sub-driver description */ 2577/* sub-driver description */
2395static const struct sd_desc sd_desc = { 2578static const struct sd_desc sd_desc = {
2396 .name = MODULE_NAME, 2579 .name = MODULE_NAME,
@@ -2406,6 +2589,9 @@ static const struct sd_desc sd_desc = {
2406 .get_jcomp = sd_get_jcomp, 2589 .get_jcomp = sd_get_jcomp,
2407 .set_jcomp = sd_set_jcomp, 2590 .set_jcomp = sd_set_jcomp,
2408 .querymenu = sd_querymenu, 2591 .querymenu = sd_querymenu,
2592#ifdef CONFIG_INPUT
2593 .int_pkt_scan = sd_int_pkt_scan,
2594#endif
2409}; 2595};
2410 2596
2411/* -- module initialisation -- */ 2597/* -- module initialisation -- */
@@ -2472,6 +2658,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
2472/* {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, *sn9c120b*/ 2658/* {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, *sn9c120b*/
2473 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ 2659 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2474 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ 2660 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
2661 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
2475 {} 2662 {}
2476}; 2663};
2477MODULE_DEVICE_TABLE(usb, device_table); 2664MODULE_DEVICE_TABLE(usb, device_table);