diff options
author | Jose Alberto Reguero <jareguero@telefonica.net> | 2012-03-16 05:59:38 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 21:27:01 -0400 |
commit | d9ef28a9154b07e991ccd6295ca839f4dc9f4e5c (patch) | |
tree | 8832861f0d911ea9302c6f905423b32edcf42aaf /drivers/media | |
parent | cd7f98fcd8573bb29f768f70c58e3d1f8057f7e3 (diff) |
[media] gspca - ov534_9: Add brightness to OmniVision 5621 sensor
This patch adds brightness control to the OmniVision 5621 sensor.
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/ov534_9.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/drivers/media/video/gspca/ov534_9.c b/drivers/media/video/gspca/ov534_9.c index fbfa02affa13..e6601b886032 100644 --- a/drivers/media/video/gspca/ov534_9.c +++ b/drivers/media/video/gspca/ov534_9.c | |||
@@ -1107,16 +1107,34 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1107 | { | 1107 | { |
1108 | struct sd *sd = (struct sd *) gspca_dev; | 1108 | struct sd *sd = (struct sd *) gspca_dev; |
1109 | u8 val; | 1109 | u8 val; |
1110 | s8 sval; | ||
1110 | 1111 | ||
1111 | if (gspca_dev->ctrl_dis & (1 << BRIGHTNESS)) | 1112 | if (gspca_dev->ctrl_dis & (1 << BRIGHTNESS)) |
1112 | return; | 1113 | return; |
1113 | val = sd->ctrls[BRIGHTNESS].val; | 1114 | if (sd->sensor == SENSOR_OV562x) { |
1114 | if (val < 8) | 1115 | sval = sd->ctrls[BRIGHTNESS].val; |
1115 | val = 15 - val; /* f .. 8 */ | 1116 | val = 0x76; |
1116 | else | 1117 | val += sval; |
1117 | val = val - 8; /* 0 .. 7 */ | 1118 | sccb_write(gspca_dev, 0x24, val); |
1118 | sccb_write(gspca_dev, 0x55, /* brtn - brightness adjustment */ | 1119 | val = 0x6a; |
1119 | 0x0f | (val << 4)); | 1120 | val += sval; |
1121 | sccb_write(gspca_dev, 0x25, val); | ||
1122 | if (sval < -40) | ||
1123 | val = 0x71; | ||
1124 | else if (sval < 20) | ||
1125 | val = 0x94; | ||
1126 | else | ||
1127 | val = 0xe6; | ||
1128 | sccb_write(gspca_dev, 0x26, val); | ||
1129 | } else { | ||
1130 | val = sd->ctrls[BRIGHTNESS].val; | ||
1131 | if (val < 8) | ||
1132 | val = 15 - val; /* f .. 8 */ | ||
1133 | else | ||
1134 | val = val - 8; /* 0 .. 7 */ | ||
1135 | sccb_write(gspca_dev, 0x55, /* brtn - brightness adjustment */ | ||
1136 | 0x0f | (val << 4)); | ||
1137 | } | ||
1120 | } | 1138 | } |
1121 | 1139 | ||
1122 | static void setcontrast(struct gspca_dev *gspca_dev) | 1140 | static void setcontrast(struct gspca_dev *gspca_dev) |
@@ -1339,7 +1357,16 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1339 | reg_w(gspca_dev, 0x56, 0x17); | 1357 | reg_w(gspca_dev, 0x56, 0x17); |
1340 | } else if ((sensor_id & 0xfff0) == 0x5620) { | 1358 | } else if ((sensor_id & 0xfff0) == 0x5620) { |
1341 | sd->sensor = SENSOR_OV562x; | 1359 | sd->sensor = SENSOR_OV562x; |
1342 | 1360 | gspca_dev->ctrl_dis = (1 << CONTRAST) | | |
1361 | (1 << AUTOGAIN) | | ||
1362 | (1 << EXPOSURE) | | ||
1363 | (1 << SHARPNESS) | | ||
1364 | (1 << SATUR) | | ||
1365 | (1 << LIGHTFREQ); | ||
1366 | |||
1367 | sd->ctrls[BRIGHTNESS].min = -90; | ||
1368 | sd->ctrls[BRIGHTNESS].max = 90; | ||
1369 | sd->ctrls[BRIGHTNESS].def = 0; | ||
1343 | gspca_dev->cam.cam_mode = ov562x_mode; | 1370 | gspca_dev->cam.cam_mode = ov562x_mode; |
1344 | gspca_dev->cam.nmodes = ARRAY_SIZE(ov562x_mode); | 1371 | gspca_dev->cam.nmodes = ARRAY_SIZE(ov562x_mode); |
1345 | 1372 | ||
@@ -1360,8 +1387,12 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1360 | { | 1387 | { |
1361 | struct sd *sd = (struct sd *) gspca_dev; | 1388 | struct sd *sd = (struct sd *) gspca_dev; |
1362 | 1389 | ||
1363 | if (sd->sensor == SENSOR_OV971x || sd->sensor == SENSOR_OV562x) | 1390 | if (sd->sensor == SENSOR_OV971x) |
1364 | return gspca_dev->usb_err; | 1391 | return gspca_dev->usb_err; |
1392 | else if (sd->sensor == SENSOR_OV562x) { | ||
1393 | setbrightness(gspca_dev); | ||
1394 | return gspca_dev->usb_err; | ||
1395 | } | ||
1365 | switch (gspca_dev->curr_mode) { | 1396 | switch (gspca_dev->curr_mode) { |
1366 | case QVGA_MODE: /* 320x240 */ | 1397 | case QVGA_MODE: /* 320x240 */ |
1367 | sccb_w_array(gspca_dev, ov965x_start_1_vga, | 1398 | sccb_w_array(gspca_dev, ov965x_start_1_vga, |