aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/ov534.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/ov534.c')
-rw-r--r--drivers/media/video/gspca/ov534.c205
1 files changed, 197 insertions, 8 deletions
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index fa28316c06ed..b665c84ca864 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -10,6 +10,8 @@
10 * https://jim.sh/svn/jim/devl/playstation/ps3/eye/test/ 10 * https://jim.sh/svn/jim/devl/playstation/ps3/eye/test/
11 * 11 *
12 * PS3 Eye camera enhanced by Richard Kaswy http://kaswy.free.fr 12 * PS3 Eye camera enhanced by Richard Kaswy http://kaswy.free.fr
13 * PS3 Eye camera, brightness, contrast, hue, AWB control added
14 * by Max Thrun <bear24rw@gmail.com>
13 * 15 *
14 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
@@ -53,11 +55,16 @@ struct sd {
53 __u32 last_pts; 55 __u32 last_pts;
54 u16 last_fid; 56 u16 last_fid;
55 u8 frame_rate; 57 u8 frame_rate;
58
59 u8 brightness;
60 u8 contrast;
56 u8 gain; 61 u8 gain;
57 u8 exposure; 62 u8 exposure;
58 u8 redblc; 63 u8 redblc;
59 u8 blueblc; 64 u8 blueblc;
65 u8 hue;
60 u8 autogain; 66 u8 autogain;
67 u8 awb;
61 u8 sharpness; 68 u8 sharpness;
62 u8 hflip; 69 u8 hflip;
63 u8 vflip; 70 u8 vflip;
@@ -84,10 +91,46 @@ static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
84static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); 91static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
85static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 92static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
86static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); 93static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
94static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val);
95static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val);
96static int sd_setawb(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getawb(struct gspca_dev *gspca_dev, __s32 *val);
98static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
100static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
101static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
87 102
88static struct ctrl sd_ctrls_ov772x[] = { 103static struct ctrl sd_ctrls_ov772x[] = {
89 { 104 {
90 { 105 {
106 .id = V4L2_CID_BRIGHTNESS,
107 .type = V4L2_CTRL_TYPE_INTEGER,
108 .name = "Brightness",
109 .minimum = 0,
110 .maximum = 255,
111 .step = 1,
112#define BRIGHTNESS_DEF 20
113 .default_value = BRIGHTNESS_DEF,
114 },
115 .set = sd_setbrightness,
116 .get = sd_getbrightness,
117 },
118 {
119 {
120 .id = V4L2_CID_CONTRAST,
121 .type = V4L2_CTRL_TYPE_INTEGER,
122 .name = "Contrast",
123 .minimum = 0,
124 .maximum = 255,
125 .step = 1,
126#define CONTRAST_DEF 37
127 .default_value = CONTRAST_DEF,
128 },
129 .set = sd_setcontrast,
130 .get = sd_getcontrast,
131 },
132 {
133 {
91 .id = V4L2_CID_GAIN, 134 .id = V4L2_CID_GAIN,
92 .type = V4L2_CTRL_TYPE_INTEGER, 135 .type = V4L2_CTRL_TYPE_INTEGER,
93 .name = "Main Gain", 136 .name = "Main Gain",
@@ -108,7 +151,7 @@ static struct ctrl sd_ctrls_ov772x[] = {
108 .minimum = 0, 151 .minimum = 0,
109 .maximum = 255, 152 .maximum = 255,
110 .step = 1, 153 .step = 1,
111#define EXPO_DEF 255 154#define EXPO_DEF 120
112 .default_value = EXPO_DEF, 155 .default_value = EXPO_DEF,
113 }, 156 },
114 .set = sd_setexposure, 157 .set = sd_setexposure,
@@ -144,13 +187,27 @@ static struct ctrl sd_ctrls_ov772x[] = {
144 }, 187 },
145 { 188 {
146 { 189 {
190 .id = V4L2_CID_HUE,
191 .type = V4L2_CTRL_TYPE_INTEGER,
192 .name = "Hue",
193 .minimum = 0,
194 .maximum = 255,
195 .step = 1,
196#define HUE_DEF 143
197 .default_value = HUE_DEF,
198 },
199 .set = sd_sethue,
200 .get = sd_gethue,
201 },
202 {
203 {
147 .id = V4L2_CID_AUTOGAIN, 204 .id = V4L2_CID_AUTOGAIN,
148 .type = V4L2_CTRL_TYPE_BOOLEAN, 205 .type = V4L2_CTRL_TYPE_BOOLEAN,
149 .name = "Autogain", 206 .name = "Autogain",
150 .minimum = 0, 207 .minimum = 0,
151 .maximum = 1, 208 .maximum = 1,
152 .step = 1, 209 .step = 1,
153#define AUTOGAIN_DEF 1 210#define AUTOGAIN_DEF 0
154 .default_value = AUTOGAIN_DEF, 211 .default_value = AUTOGAIN_DEF,
155 }, 212 },
156 .set = sd_setautogain, 213 .set = sd_setautogain,
@@ -158,13 +215,27 @@ static struct ctrl sd_ctrls_ov772x[] = {
158 }, 215 },
159 { 216 {
160 { 217 {
218 .id = V4L2_CID_AUTO_WHITE_BALANCE,
219 .type = V4L2_CTRL_TYPE_BOOLEAN,
220 .name = "Auto White Balance",
221 .minimum = 0,
222 .maximum = 1,
223 .step = 1,
224#define AWB_DEF 0
225 .default_value = AWB_DEF,
226 },
227 .set = sd_setawb,
228 .get = sd_getawb,
229 },
230 {
231 {
161 .id = V4L2_CID_SHARPNESS, 232 .id = V4L2_CID_SHARPNESS,
162 .type = V4L2_CTRL_TYPE_INTEGER, 233 .type = V4L2_CTRL_TYPE_INTEGER,
163 .name = "Sharpness", 234 .name = "Sharpness",
164 .minimum = 0, 235 .minimum = 0,
165 .maximum = 63, 236 .maximum = 63,
166 .step = 1, 237 .step = 1,
167#define SHARPNESS_DEF 4 238#define SHARPNESS_DEF 0
168 .default_value = SHARPNESS_DEF, 239 .default_value = SHARPNESS_DEF,
169 }, 240 },
170 .set = sd_setsharpness, 241 .set = sd_setsharpness,
@@ -206,7 +277,7 @@ static const struct v4l2_pix_format vga_yuyv_mode[] = {
206 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 277 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
207 .bytesperline = 320 * 2, 278 .bytesperline = 320 * 2,
208 .sizeimage = 320 * 240 * 2, 279 .sizeimage = 320 * 240 * 2,
209 .colorspace = V4L2_COLORSPACE_JPEG, 280 .colorspace = V4L2_COLORSPACE_SRGB,
210 .priv = 1}, 281 .priv = 1},
211 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 282 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
212 .bytesperline = 640 * 2, 283 .bytesperline = 640 * 2,
@@ -311,10 +382,10 @@ static const u8 sensor_init_ov772x[][2] = {
311 { 0x65, 0x20 }, 382 { 0x65, 0x20 },
312 { 0x11, 0x01 }, 383 { 0x11, 0x01 },
313 { 0x42, 0x7f }, 384 { 0x42, 0x7f },
314 { 0x63, 0xaa }, /* was e0 */ 385 { 0x63, 0xaa }, /* AWB - was e0 */
315 { 0x64, 0xff }, 386 { 0x64, 0xff },
316 { 0x66, 0x00 }, 387 { 0x66, 0x00 },
317 { 0x13, 0xf0 }, 388 { 0x13, 0xf0 }, /* com8 */
318 { 0x0d, 0x41 }, 389 { 0x0d, 0x41 },
319 { 0x0f, 0xc5 }, 390 { 0x0f, 0xc5 },
320 { 0x14, 0x11 }, 391 { 0x14, 0x11 },
@@ -327,7 +398,7 @@ static const u8 sensor_init_ov772x[][2] = {
327 { 0x2a, 0x00 }, 398 { 0x2a, 0x00 },
328 { 0x2b, 0x00 }, 399 { 0x2b, 0x00 },
329 { 0x6b, 0xaa }, 400 { 0x6b, 0xaa },
330 { 0x13, 0xff }, 401 { 0x13, 0xff }, /* AWB */
331 402
332 { 0x90, 0x05 }, 403 { 0x90, 0x05 },
333 { 0x91, 0x01 }, 404 { 0x91, 0x01 },
@@ -375,7 +446,7 @@ static const u8 sensor_init_ov772x[][2] = {
375 { 0x14, 0x41 }, 446 { 0x14, 0x41 },
376 { 0x0e, 0xcd }, 447 { 0x0e, 0xcd },
377 { 0xac, 0xbf }, 448 { 0xac, 0xbf },
378 { 0x8e, 0x00 }, 449 { 0x8e, 0x00 }, /* De-noise threshold */
379 { 0x0c, 0xd0 } 450 { 0x0c, 0xd0 }
380}; 451};
381static const u8 bridge_start_ov772x_vga[][2] = { 452static const u8 bridge_start_ov772x_vga[][2] = {
@@ -397,6 +468,7 @@ static const u8 sensor_start_ov772x_vga[][2] = {
397 {0x1a, 0xf0}, 468 {0x1a, 0xf0},
398 {0x29, 0xa0}, 469 {0x29, 0xa0},
399 {0x2c, 0xf0}, 470 {0x2c, 0xf0},
471 {0x65, 0x20},
400}; 472};
401static const u8 bridge_start_ov772x_qvga[][2] = { 473static const u8 bridge_start_ov772x_qvga[][2] = {
402 {0x1c, 0x00}, 474 {0x1c, 0x00},
@@ -417,6 +489,7 @@ static const u8 sensor_start_ov772x_qvga[][2] = {
417 {0x1a, 0x78}, 489 {0x1a, 0x78},
418 {0x29, 0x50}, 490 {0x29, 0x50},
419 {0x2c, 0x78}, 491 {0x2c, 0x78},
492 {0x65, 0x2f},
420}; 493};
421 494
422static const u8 bridge_init_ov965x[][2] = { 495static const u8 bridge_init_ov965x[][2] = {
@@ -1000,6 +1073,20 @@ static void ov534_set_frame_rate(struct gspca_dev *gspca_dev)
1000} 1073}
1001 1074
1002/* ov772x controls */ 1075/* ov772x controls */
1076static void setbrightness(struct gspca_dev *gspca_dev)
1077{
1078 struct sd *sd = (struct sd *) gspca_dev;
1079
1080 sccb_reg_write(gspca_dev, 0x9B, sd->brightness);
1081}
1082
1083static void setcontrast(struct gspca_dev *gspca_dev)
1084{
1085 struct sd *sd = (struct sd *) gspca_dev;
1086
1087 sccb_reg_write(gspca_dev, 0x9C, sd->contrast);
1088}
1089
1003static void setgain(struct gspca_dev *gspca_dev) 1090static void setgain(struct gspca_dev *gspca_dev)
1004{ 1091{
1005 struct sd *sd = (struct sd *) gspca_dev; 1092 struct sd *sd = (struct sd *) gspca_dev;
@@ -1051,6 +1138,13 @@ static void setblueblc(struct gspca_dev *gspca_dev)
1051 sccb_reg_write(gspca_dev, 0x42, sd->blueblc); 1138 sccb_reg_write(gspca_dev, 0x42, sd->blueblc);
1052} 1139}
1053 1140
1141static void sethue(struct gspca_dev *gspca_dev)
1142{
1143 struct sd *sd = (struct sd *) gspca_dev;
1144
1145 sccb_reg_write(gspca_dev, 0x01, sd->hue);
1146}
1147
1054static void setautogain(struct gspca_dev *gspca_dev) 1148static void setautogain(struct gspca_dev *gspca_dev)
1055{ 1149{
1056 struct sd *sd = (struct sd *) gspca_dev; 1150 struct sd *sd = (struct sd *) gspca_dev;
@@ -1066,6 +1160,16 @@ static void setautogain(struct gspca_dev *gspca_dev)
1066 } 1160 }
1067} 1161}
1068 1162
1163static void setawb(struct gspca_dev *gspca_dev)
1164{
1165 struct sd *sd = (struct sd *) gspca_dev;
1166
1167 if (sd->awb)
1168 sccb_reg_write(gspca_dev, 0x63, 0xe0); /* AWB on */
1169 else
1170 sccb_reg_write(gspca_dev, 0x63, 0xaa); /* AWB off */
1171}
1172
1069static void setsharpness(struct gspca_dev *gspca_dev) 1173static void setsharpness(struct gspca_dev *gspca_dev)
1070{ 1174{
1071 struct sd *sd = (struct sd *) gspca_dev; 1175 struct sd *sd = (struct sd *) gspca_dev;
@@ -1124,11 +1228,20 @@ static int sd_config(struct gspca_dev *gspca_dev,
1124 } 1228 }
1125 1229
1126 sd->frame_rate = 30; 1230 sd->frame_rate = 30;
1231
1232 sd->brightness = BRIGHTNESS_DEF;
1233 sd->contrast = CONTRAST_DEF;
1127 sd->gain = GAIN_DEF; 1234 sd->gain = GAIN_DEF;
1128 sd->exposure = EXPO_DEF; 1235 sd->exposure = EXPO_DEF;
1129 sd->redblc = RED_BALANCE_DEF; 1236 sd->redblc = RED_BALANCE_DEF;
1130 sd->blueblc = BLUE_BALANCE_DEF; 1237 sd->blueblc = BLUE_BALANCE_DEF;
1238 sd->hue = HUE_DEF;
1239#if AUTOGAIN_DEF != 0
1131 sd->autogain = AUTOGAIN_DEF; 1240 sd->autogain = AUTOGAIN_DEF;
1241#endif
1242#if AWB_DEF != 0
1243 sd->awb = AWB_DEF
1244#endif
1132 sd->sharpness = SHARPNESS_DEF; 1245 sd->sharpness = SHARPNESS_DEF;
1133#if HFLIP_DEF != 0 1246#if HFLIP_DEF != 0
1134 sd->hflip = HFLIP_DEF; 1247 sd->hflip = HFLIP_DEF;
@@ -1219,10 +1332,14 @@ static int sd_start_ov772x(struct gspca_dev *gspca_dev)
1219 ov534_set_frame_rate(gspca_dev); 1332 ov534_set_frame_rate(gspca_dev);
1220 1333
1221 setautogain(gspca_dev); 1334 setautogain(gspca_dev);
1335 setawb(gspca_dev);
1222 setgain(gspca_dev); 1336 setgain(gspca_dev);
1223 setredblc(gspca_dev); 1337 setredblc(gspca_dev);
1224 setblueblc(gspca_dev); 1338 setblueblc(gspca_dev);
1339 sethue(gspca_dev);
1225 setexposure(gspca_dev); 1340 setexposure(gspca_dev);
1341 setbrightness(gspca_dev);
1342 setcontrast(gspca_dev);
1226 setsharpness(gspca_dev); 1343 setsharpness(gspca_dev);
1227 setvflip(gspca_dev); 1344 setvflip(gspca_dev);
1228 sethflip(gspca_dev); 1345 sethflip(gspca_dev);
@@ -1395,6 +1512,42 @@ static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
1395 return 0; 1512 return 0;
1396} 1513}
1397 1514
1515static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1516{
1517 struct sd *sd = (struct sd *) gspca_dev;
1518
1519 sd->brightness = val;
1520 if (gspca_dev->streaming)
1521 setcontrast(gspca_dev);
1522 return 0;
1523}
1524
1525static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1526{
1527 struct sd *sd = (struct sd *) gspca_dev;
1528
1529 *val = sd->brightness;
1530 return 0;
1531}
1532
1533static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1534{
1535 struct sd *sd = (struct sd *) gspca_dev;
1536
1537 sd->contrast = val;
1538 if (gspca_dev->streaming)
1539 setcontrast(gspca_dev);
1540 return 0;
1541}
1542
1543static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
1544{
1545 struct sd *sd = (struct sd *) gspca_dev;
1546
1547 *val = sd->contrast;
1548 return 0;
1549}
1550
1398static int sd_setredblc(struct gspca_dev *gspca_dev, __s32 val) 1551static int sd_setredblc(struct gspca_dev *gspca_dev, __s32 val)
1399{ 1552{
1400 struct sd *sd = (struct sd *) gspca_dev; 1553 struct sd *sd = (struct sd *) gspca_dev;
@@ -1431,6 +1584,24 @@ static int sd_getblueblc(struct gspca_dev *gspca_dev, __s32 *val)
1431 return 0; 1584 return 0;
1432} 1585}
1433 1586
1587static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val)
1588{
1589 struct sd *sd = (struct sd *) gspca_dev;
1590
1591 sd->hue = val;
1592 if (gspca_dev->streaming)
1593 sethue(gspca_dev);
1594 return 0;
1595}
1596
1597static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val)
1598{
1599 struct sd *sd = (struct sd *) gspca_dev;
1600
1601 *val = sd->hue;
1602 return 0;
1603}
1604
1434static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) 1605static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
1435{ 1606{
1436 struct sd *sd = (struct sd *) gspca_dev; 1607 struct sd *sd = (struct sd *) gspca_dev;
@@ -1449,6 +1620,24 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
1449 return 0; 1620 return 0;
1450} 1621}
1451 1622
1623static int sd_setawb(struct gspca_dev *gspca_dev, __s32 val)
1624{
1625 struct sd *sd = (struct sd *) gspca_dev;
1626
1627 sd->awb = val;
1628 if (gspca_dev->streaming)
1629 setawb(gspca_dev);
1630 return 0;
1631}
1632
1633static int sd_getawb(struct gspca_dev *gspca_dev, __s32 *val)
1634{
1635 struct sd *sd = (struct sd *) gspca_dev;
1636
1637 *val = sd->awb;
1638 return 0;
1639}
1640
1452static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val) 1641static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
1453{ 1642{
1454 struct sd *sd = (struct sd *) gspca_dev; 1643 struct sd *sd = (struct sd *) gspca_dev;