aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-01-15 06:01:32 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:31 -0400
commit592f4eb9a2dc63afdbe78e2874d728f6e9e1e9f0 (patch)
tree1108851e114b4084f223c7507bc0713b06b01226 /drivers/media/video/gspca/sonixj.c
parent625deb3d25a45102b155764beb2e8f232b8d5864 (diff)
V4L/DVB (10361): gspca - sonixj: Gamma control added.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c57
1 files changed, 55 insertions, 2 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index d1c85ce39e56..db8db0c6bbb9 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -44,6 +44,7 @@ struct sd {
44 __u8 autogain; 44 __u8 autogain;
45 __u8 blue; 45 __u8 blue;
46 __u8 red; 46 __u8 red;
47 u8 gamma;
47 __u8 vflip; /* ov7630 only */ 48 __u8 vflip; /* ov7630 only */
48 __u8 infrared; /* mi0360 only */ 49 __u8 infrared; /* mi0360 only */
49 50
@@ -78,6 +79,8 @@ static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
78static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); 79static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
79static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); 80static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
80static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); 81static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
82static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
83static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
81static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 84static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
82static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 85static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
83static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 86static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
@@ -158,6 +161,20 @@ static struct ctrl sd_ctrls[] = {
158 .set = sd_setred_balance, 161 .set = sd_setred_balance,
159 .get = sd_getred_balance, 162 .get = sd_getred_balance,
160 }, 163 },
164 {
165 {
166 .id = V4L2_CID_GAMMA,
167 .type = V4L2_CTRL_TYPE_INTEGER,
168 .name = "Gamma",
169 .minimum = 0,
170 .maximum = 40,
171 .step = 1,
172#define GAMMA_DEF 20
173 .default_value = GAMMA_DEF,
174 },
175 .set = sd_setgamma,
176 .get = sd_getgamma,
177 },
161#define AUTOGAIN_IDX 5 178#define AUTOGAIN_IDX 5
162 { 179 {
163 { 180 {
@@ -332,11 +349,12 @@ static const u8 *sn_tb[] = {
332 sn_ov7660 349 sn_ov7660
333}; 350};
334 351
335static const __u8 gamma_def[] = { 352static const __u8 gamma_def[17] = {
336 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, 353 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
337 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff 354 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
338}; 355};
339 356
357
340/* color matrix and offsets */ 358/* color matrix and offsets */
341static const __u8 reg84[] = { 359static const __u8 reg84[] = {
342 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ 360 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
@@ -1027,6 +1045,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1027 sd->colors = COLOR_DEF; 1045 sd->colors = COLOR_DEF;
1028 sd->blue = BLUE_BALANCE_DEF; 1046 sd->blue = BLUE_BALANCE_DEF;
1029 sd->red = RED_BALANCE_DEF; 1047 sd->red = RED_BALANCE_DEF;
1048 sd->gamma = GAMMA_DEF;
1030 sd->autogain = AUTOGAIN_DEF; 1049 sd->autogain = AUTOGAIN_DEF;
1031 sd->ag_cnt = -1; 1050 sd->ag_cnt = -1;
1032 sd->vflip = VFLIP_DEF; 1051 sd->vflip = VFLIP_DEF;
@@ -1231,6 +1250,22 @@ static void setredblue(struct gspca_dev *gspca_dev)
1231 reg_w1(gspca_dev, 0x06, sd->blue); 1250 reg_w1(gspca_dev, 0x06, sd->blue);
1232} 1251}
1233 1252
1253static void setgamma(struct gspca_dev *gspca_dev)
1254{
1255 struct sd *sd = (struct sd *) gspca_dev;
1256 int i;
1257 u8 gamma[17];
1258 static const u8 delta[17] = {
1259 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1260 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1261 };
1262
1263 for (i = 0; i < sizeof gamma; i++)
1264 gamma[i] = gamma_def[i]
1265 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1266 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1267}
1268
1234static void setautogain(struct gspca_dev *gspca_dev) 1269static void setautogain(struct gspca_dev *gspca_dev)
1235{ 1270{
1236 struct sd *sd = (struct sd *) gspca_dev; 1271 struct sd *sd = (struct sd *) gspca_dev;
@@ -1310,7 +1345,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
1310 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ 1345 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1311 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ 1346 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
1312 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); 1347 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1313 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); 1348 setgamma(gspca_dev);
1314 for (i = 0; i < 8; i++) 1349 for (i = 0; i < 8; i++)
1315 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1350 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1316 switch (sd->sensor) { 1351 switch (sd->sensor) {
@@ -1640,6 +1675,24 @@ static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
1640 return 0; 1675 return 0;
1641} 1676}
1642 1677
1678static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
1679{
1680 struct sd *sd = (struct sd *) gspca_dev;
1681
1682 sd->gamma = val;
1683 if (gspca_dev->streaming)
1684 setgamma(gspca_dev);
1685 return 0;
1686}
1687
1688static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
1689{
1690 struct sd *sd = (struct sd *) gspca_dev;
1691
1692 *val = sd->gamma;
1693 return 0;
1694}
1695
1643static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) 1696static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
1644{ 1697{
1645 struct sd *sd = (struct sd *) gspca_dev; 1698 struct sd *sd = (struct sd *) gspca_dev;