aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-12-30 02:53:07 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:10:28 -0500
commit878b35aedb930a31a72298b717a22990b6773a03 (patch)
treec6a4caa3070f27a2a8ef05ca4f036fa71635e5ea
parent83c94a186382307508cbe800588219607fb38148 (diff)
V4L/DVB (13894): gspca - sonixj: Add more controls.
- sharpness - brightness for adcm1700 - adjust brightness/exposure for adcm1700 - add some comments Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/gspca/sonixj.c120
1 files changed, 83 insertions, 37 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 1f21c6a7a72c..94af964772d0 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -45,6 +45,7 @@ struct sd {
45 u8 red; 45 u8 red;
46 u8 gamma; 46 u8 gamma;
47 u8 vflip; /* ov7630/ov7648 only */ 47 u8 vflip; /* ov7630/ov7648 only */
48 u8 sharpness;
48 u8 infrared; /* mt9v111 only */ 49 u8 infrared; /* mt9v111 only */
49 u8 freq; /* ov76xx only */ 50 u8 freq; /* ov76xx only */
50 u8 quality; /* image quality */ 51 u8 quality; /* image quality */
@@ -97,6 +98,8 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 98static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
98static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 99static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); 100static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
101static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
102static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
100static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); 103static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
101static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); 104static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
102static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); 105static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
@@ -226,8 +229,23 @@ static struct ctrl sd_ctrls[] = {
226 .set = sd_setvflip, 229 .set = sd_setvflip,
227 .get = sd_getvflip, 230 .get = sd_getvflip,
228 }, 231 },
232#define SHARPNESS_IDX 8
233 {
234 {
235 .id = V4L2_CID_SHARPNESS,
236 .type = V4L2_CTRL_TYPE_INTEGER,
237 .name = "Sharpness",
238 .minimum = 0,
239 .maximum = 255,
240 .step = 1,
241#define SHARPNESS_DEF 90
242 .default_value = SHARPNESS_DEF,
243 },
244 .set = sd_setsharpness,
245 .get = sd_getsharpness,
246 },
229/* mt9v111 only */ 247/* mt9v111 only */
230#define INFRARED_IDX 8 248#define INFRARED_IDX 9
231 { 249 {
232 { 250 {
233 .id = V4L2_CID_INFRARED, 251 .id = V4L2_CID_INFRARED,
@@ -243,7 +261,7 @@ static struct ctrl sd_ctrls[] = {
243 .get = sd_getinfrared, 261 .get = sd_getinfrared,
244 }, 262 },
245/* ov7630/ov7648/ov7660 only */ 263/* ov7630/ov7648/ov7660 only */
246#define FREQ_IDX 9 264#define FREQ_IDX 10
247 { 265 {
248 { 266 {
249 .id = V4L2_CID_POWER_LINE_FREQUENCY, 267 .id = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -263,7 +281,7 @@ static struct ctrl sd_ctrls[] = {
263/* table of the disabled controls */ 281/* table of the disabled controls */
264static __u32 ctrl_dis[] = { 282static __u32 ctrl_dis[] = {
265 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX) | 283 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX) |
266 (1 << AUTOGAIN_IDX) | (1 << BRIGHTNESS_IDX), /* SENSOR_ADCM1700 0 */ 284 (1 << AUTOGAIN_IDX), /* SENSOR_ADCM1700 0 */
267 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), 285 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
268 /* SENSOR_HV7131R 1 */ 286 /* SENSOR_HV7131R 1 */
269 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), 287 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
@@ -314,7 +332,7 @@ static const struct v4l2_pix_format vga_mode[] = {
314 332
315static const u8 sn_adcm1700[0x1c] = { 333static const u8 sn_adcm1700[0x1c] = {
316/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 334/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
317 0x00, 0x42, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, 335 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
318/* reg8 reg9 rega regb regc regd rege regf */ 336/* reg8 reg9 rega regb regc regd rege regf */
319 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 337 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
320/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ 338/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
@@ -479,7 +497,7 @@ static const u8 reg84[] = {
479}; 497};
480static const u8 adcm1700_sensor_init[][8] = { 498static const u8 adcm1700_sensor_init[][8] = {
481 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, 499 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
482 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, 500 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
483 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 501 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
484 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, 502 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
485 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 503 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
@@ -498,15 +516,19 @@ static const u8 adcm1700_sensor_init[][8] = {
498 {} 516 {}
499}; 517};
500static const u8 adcm1700_sensor_param1[][8] = { 518static const u8 adcm1700_sensor_param1[][8] = {
501 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, 519 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
502 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10}, 520 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
503 521
504 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10}, 522 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
505 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10}, 523 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
506 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, 524 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
507 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10}, 525 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
508 {0xd0, 0x51, 0x1e, 0x8e, 0x91, 0x91, 0x8e, 0x10}, 526 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
509 527
528 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
529 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
530 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
531 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
510 {} 532 {}
511}; 533};
512static const u8 hv7131r_sensor_init[][8] = { 534static const u8 hv7131r_sensor_init[][8] = {
@@ -1347,7 +1369,7 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1347 1369
1348 switch (sd->sensor) { 1370 switch (sd->sensor) {
1349 case SENSOR_ADCM1700: 1371 case SENSOR_ADCM1700:
1350 reg_w1(gspca_dev, 0x01, 0x42); 1372 reg_w1(gspca_dev, 0x01, 0x43);
1351 reg_w1(gspca_dev, 0x17, 0x62); 1373 reg_w1(gspca_dev, 0x17, 0x62);
1352 reg_w1(gspca_dev, 0x01, 0x42); 1374 reg_w1(gspca_dev, 0x01, 0x42);
1353 reg_w1(gspca_dev, 0x01, 0x42); 1375 reg_w1(gspca_dev, 0x01, 0x42);
@@ -1447,6 +1469,14 @@ static int sd_config(struct gspca_dev *gspca_dev,
1447 sd->autogain = AUTOGAIN_DEF; 1469 sd->autogain = AUTOGAIN_DEF;
1448 sd->ag_cnt = -1; 1470 sd->ag_cnt = -1;
1449 sd->vflip = VFLIP_DEF; 1471 sd->vflip = VFLIP_DEF;
1472 switch (sd->sensor) {
1473 case SENSOR_OM6802:
1474 sd->sharpness = 0x10;
1475 break;
1476 default:
1477 sd->sharpness = SHARPNESS_DEF;
1478 break;
1479 }
1450 sd->infrared = INFRARED_DEF; 1480 sd->infrared = INFRARED_DEF;
1451 sd->freq = FREQ_DEF; 1481 sd->freq = FREQ_DEF;
1452 sd->quality = QUALITY_DEF; 1482 sd->quality = QUALITY_DEF;
@@ -1617,7 +1647,9 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1617 k2 = ((int) sd->brightness - 0x8000) >> 10; 1647 k2 = ((int) sd->brightness - 0x8000) >> 10;
1618 switch (sd->sensor) { 1648 switch (sd->sensor) {
1619 case SENSOR_ADCM1700: 1649 case SENSOR_ADCM1700:
1620 return; 1650 if (k2 > 0x1f)
1651 k2 = 0; /* only positive Y offset */
1652 break;
1621 case SENSOR_HV7131R: 1653 case SENSOR_HV7131R:
1622 expo = sd->brightness << 4; 1654 expo = sd->brightness << 4;
1623 if (expo > 0x002dc6c0) 1655 if (expo > 0x002dc6c0)
@@ -1767,6 +1799,11 @@ static void setvflip(struct sd *sd)
1767 i2c_w1(&sd->gspca_dev, 0x75, comn); 1799 i2c_w1(&sd->gspca_dev, 0x75, comn);
1768} 1800}
1769 1801
1802static void setsharpness(struct sd *sd)
1803{
1804 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
1805}
1806
1770static void setinfrared(struct sd *sd) 1807static void setinfrared(struct sd *sd)
1771{ 1808{
1772 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) 1809 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
@@ -1926,20 +1963,20 @@ static int sd_start(struct gspca_dev *gspca_dev)
1926 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]); 1963 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1927 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); 1964 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1928 if (sd->sensor == SENSOR_ADCM1700) { 1965 if (sd->sensor == SENSOR_ADCM1700) {
1929 reg_w1(gspca_dev, 0xd2, 0x3a); /* DC29 */ 1966 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
1930 reg_w1(gspca_dev, 0xd3, 0x30); 1967 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
1931 } else { 1968 } else {
1932 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */ 1969 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
1933 reg_w1(gspca_dev, 0xd3, 0x50); 1970 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
1934 } 1971 }
1935 reg_w1(gspca_dev, 0xc6, 0x00); 1972 reg_w1(gspca_dev, 0xc6, 0x00);
1936 reg_w1(gspca_dev, 0xc7, 0x00); 1973 reg_w1(gspca_dev, 0xc7, 0x00);
1937 if (sd->sensor == SENSOR_ADCM1700) { 1974 if (sd->sensor == SENSOR_ADCM1700) {
1938 reg_w1(gspca_dev, 0xc8, 0x2c); 1975 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
1939 reg_w1(gspca_dev, 0xc9, 0x24); 1976 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
1940 } else { 1977 } else {
1941 reg_w1(gspca_dev, 0xc8, 0x50); 1978 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
1942 reg_w1(gspca_dev, 0xc9, 0x3c); 1979 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
1943 } 1980 }
1944 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); 1981 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1945 switch (sd->sensor) { 1982 switch (sd->sensor) {
@@ -1964,48 +2001,39 @@ static int sd_start(struct gspca_dev *gspca_dev)
1964 break; 2001 break;
1965 } 2002 }
1966 reg_w1(gspca_dev, 0x17, reg17); 2003 reg_w1(gspca_dev, 0x17, reg17);
1967/* set reg1 was here */ 2004
1968 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */ 2005 reg_w1(gspca_dev, 0x05, 0x00); /* red */
1969 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ 2006 reg_w1(gspca_dev, 0x07, 0x00); /* green */
1970 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ 2007 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
1971 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); 2008 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1972 2009
1973 setgamma(gspca_dev); 2010 setgamma(gspca_dev);
1974 2011
2012/*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
1975 for (i = 0; i < 8; i++) 2013 for (i = 0; i < 8; i++)
1976 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2014 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1977 switch (sd->sensor) { 2015 switch (sd->sensor) {
1978 case SENSOR_ADCM1700: 2016 case SENSOR_ADCM1700:
2017 case SENSOR_OV7660:
2018 case SENSOR_SP80708:
1979 reg_w1(gspca_dev, 0x9a, 0x05); 2019 reg_w1(gspca_dev, 0x9a, 0x05);
1980 reg_w1(gspca_dev, 0x99, 0x60);
1981 break; 2020 break;
1982 case SENSOR_MT9V111: 2021 case SENSOR_MT9V111:
1983 reg_w1(gspca_dev, 0x9a, 0x07); 2022 reg_w1(gspca_dev, 0x9a, 0x07);
1984 reg_w1(gspca_dev, 0x99, 0x59);
1985 break;
1986 case SENSOR_OM6802:
1987 reg_w1(gspca_dev, 0x9a, 0x08);
1988 reg_w1(gspca_dev, 0x99, 0x10);
1989 break; 2023 break;
1990 case SENSOR_OV7648: 2024 case SENSOR_OV7648:
1991 reg_w1(gspca_dev, 0x9a, 0x0a); 2025 reg_w1(gspca_dev, 0x9a, 0x0a);
1992 reg_w1(gspca_dev, 0x99, 0x60);
1993 break;
1994 case SENSOR_OV7660:
1995 case SENSOR_SP80708:
1996 reg_w1(gspca_dev, 0x9a, 0x05);
1997 reg_w1(gspca_dev, 0x99, 0x59);
1998 break; 2026 break;
1999 default: 2027 default:
2000 reg_w1(gspca_dev, 0x9a, 0x08); 2028 reg_w1(gspca_dev, 0x9a, 0x08);
2001 reg_w1(gspca_dev, 0x99, 0x59);
2002 break; 2029 break;
2003 } 2030 }
2031 setsharpness(sd);
2004 2032
2005 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2033 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2006 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */ 2034 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2007 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ 2035 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2008 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ 2036 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
2009 2037
2010 init = NULL; 2038 init = NULL;
2011 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 2039 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
@@ -2395,6 +2423,24 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2395 return 0; 2423 return 0;
2396} 2424}
2397 2425
2426static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2427{
2428 struct sd *sd = (struct sd *) gspca_dev;
2429
2430 sd->sharpness = val;
2431 if (gspca_dev->streaming)
2432 setsharpness(sd);
2433 return 0;
2434}
2435
2436static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2437{
2438 struct sd *sd = (struct sd *) gspca_dev;
2439
2440 *val = sd->sharpness;
2441 return 0;
2442}
2443
2398static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) 2444static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2399{ 2445{
2400 struct sd *sd = (struct sd *) gspca_dev; 2446 struct sd *sd = (struct sd *) gspca_dev;