aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/gspca/sonixj.c117
1 files changed, 99 insertions, 18 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 83564e09eeea..504976960ce1 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -41,6 +41,8 @@ struct sd {
41 unsigned char contrast; 41 unsigned char contrast;
42 unsigned char colors; 42 unsigned char colors;
43 unsigned char autogain; 43 unsigned char autogain;
44 __u8 blue;
45 __u8 red;
44 __u8 vflip; /* ov7630 only */ 46 __u8 vflip; /* ov7630 only */
45 __u8 infrared; /* mi0360 only */ 47 __u8 infrared; /* mi0360 only */
46 48
@@ -72,6 +74,10 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
72static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 74static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
73static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); 75static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
74static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 76static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
77static 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_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
80static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
75static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 81static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
76static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 82static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
77static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); 83static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
@@ -116,7 +122,7 @@ static struct ctrl sd_ctrls[] = {
116 .type = V4L2_CTRL_TYPE_INTEGER, 122 .type = V4L2_CTRL_TYPE_INTEGER,
117 .name = "Color", 123 .name = "Color",
118 .minimum = 0, 124 .minimum = 0,
119 .maximum = 64, 125 .maximum = 40,
120 .step = 1, 126 .step = 1,
121#define COLOR_DEF 32 127#define COLOR_DEF 32
122 .default_value = COLOR_DEF, 128 .default_value = COLOR_DEF,
@@ -124,7 +130,35 @@ static struct ctrl sd_ctrls[] = {
124 .set = sd_setcolors, 130 .set = sd_setcolors,
125 .get = sd_getcolors, 131 .get = sd_getcolors,
126 }, 132 },
127#define AUTOGAIN_IDX 3 133 {
134 {
135 .id = V4L2_CID_BLUE_BALANCE,
136 .type = V4L2_CTRL_TYPE_INTEGER,
137 .name = "Blue Balance",
138 .minimum = 24,
139 .maximum = 40,
140 .step = 1,
141#define BLUE_BALANCE_DEF 32
142 .default_value = BLUE_BALANCE_DEF,
143 },
144 .set = sd_setblue_balance,
145 .get = sd_getblue_balance,
146 },
147 {
148 {
149 .id = V4L2_CID_RED_BALANCE,
150 .type = V4L2_CTRL_TYPE_INTEGER,
151 .name = "Red Balance",
152 .minimum = 24,
153 .maximum = 40,
154 .step = 1,
155#define RED_BALANCE_DEF 32
156 .default_value = RED_BALANCE_DEF,
157 },
158 .set = sd_setred_balance,
159 .get = sd_getred_balance,
160 },
161#define AUTOGAIN_IDX 5
128 { 162 {
129 { 163 {
130 .id = V4L2_CID_AUTOGAIN, 164 .id = V4L2_CID_AUTOGAIN,
@@ -140,7 +174,7 @@ static struct ctrl sd_ctrls[] = {
140 .get = sd_getautogain, 174 .get = sd_getautogain,
141 }, 175 },
142/* ov7630 only */ 176/* ov7630 only */
143#define VFLIP_IDX 4 177#define VFLIP_IDX 6
144 { 178 {
145 { 179 {
146 .id = V4L2_CID_VFLIP, 180 .id = V4L2_CID_VFLIP,
@@ -156,7 +190,7 @@ static struct ctrl sd_ctrls[] = {
156 .get = sd_getvflip, 190 .get = sd_getvflip,
157 }, 191 },
158/* mi0360 only */ 192/* mi0360 only */
159#define INFRARED_IDX 5 193#define INFRARED_IDX 7
160 { 194 {
161 { 195 {
162 .id = V4L2_CID_INFRARED, 196 .id = V4L2_CID_INFRARED,
@@ -981,6 +1015,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
981 sd->brightness = BRIGHTNESS_DEF; 1015 sd->brightness = BRIGHTNESS_DEF;
982 sd->contrast = CONTRAST_DEF; 1016 sd->contrast = CONTRAST_DEF;
983 sd->colors = COLOR_DEF; 1017 sd->colors = COLOR_DEF;
1018 sd->blue = BLUE_BALANCE_DEF;
1019 sd->red = RED_BALANCE_DEF;
984 sd->autogain = AUTOGAIN_DEF; 1020 sd->autogain = AUTOGAIN_DEF;
985 sd->ag_cnt = -1; 1021 sd->ag_cnt = -1;
986 sd->vflip = VFLIP_DEF; 1022 sd->vflip = VFLIP_DEF;
@@ -1170,18 +1206,27 @@ static void setcontrast(struct gspca_dev *gspca_dev)
1170static void setcolors(struct gspca_dev *gspca_dev) 1206static void setcolors(struct gspca_dev *gspca_dev)
1171{ 1207{
1172 struct sd *sd = (struct sd *) gspca_dev; 1208 struct sd *sd = (struct sd *) gspca_dev;
1173 __u8 blue, red; 1209 int i, v;
1174 1210 __u8 rega0[12]; /* U & V gains */
1175 if (sd->colors >= 32) { 1211 static __s16 uv[6] = { /* same as reg84 in signed decimal */
1176 red = 32 + (sd->colors - 32) / 2; 1212 -24, -38, 64, /* UR UG UB */
1177 blue = 64 - sd->colors; 1213 62, -51, -9 /* VR VG VB */
1178 } else { 1214 };
1179 red = sd->colors; 1215 for (i = 0; i < 6; i++) {
1180 blue = 32 + (32 - sd->colors) / 2; 1216 v = uv[i] * sd->colors / COLOR_DEF;
1217 rega0[i * 2] = v;
1218 rega0[i * 2 + 1] = (v >> 8) & 0x0f;
1181 } 1219 }
1182 reg_w1(gspca_dev, 0x05, red); 1220 reg_w(gspca_dev, 0x84, rega0, sizeof rega0);
1221}
1222
1223static void setredblue(struct gspca_dev *gspca_dev)
1224{
1225 struct sd *sd = (struct sd *) gspca_dev;
1226
1227 reg_w1(gspca_dev, 0x05, sd->red);
1183/* reg_w1(gspca_dev, 0x07, 32); */ 1228/* reg_w1(gspca_dev, 0x07, 32); */
1184 reg_w1(gspca_dev, 0x06, blue); 1229 reg_w1(gspca_dev, 0x06, sd->blue);
1185} 1230}
1186 1231
1187static void setautogain(struct gspca_dev *gspca_dev) 1232static void setautogain(struct gspca_dev *gspca_dev)
@@ -1259,9 +1304,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1259 } 1304 }
1260 reg_w1(gspca_dev, 0x17, reg17); 1305 reg_w1(gspca_dev, 0x17, reg17);
1261/* set reg1 was here */ 1306/* set reg1 was here */
1262 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); 1307 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1263 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); 1308 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1264 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); 1309 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
1265 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); 1310 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1266 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); 1311 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def);
1267 for (i = 0; i < 8; i++) 1312 for (i = 0; i < 8; i++)
@@ -1462,7 +1507,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
1462 expotimes = 0; 1507 expotimes = 0;
1463 sd->exposure = setexposure(gspca_dev, 1508 sd->exposure = setexposure(gspca_dev,
1464 (unsigned int) expotimes); 1509 (unsigned int) expotimes);
1465 setcolors(gspca_dev); 1510 setredblue(gspca_dev);
1466 break; 1511 break;
1467 } 1512 }
1468 } 1513 }
@@ -1565,6 +1610,42 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
1565 return 0; 1610 return 0;
1566} 1611}
1567 1612
1613static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
1614{
1615 struct sd *sd = (struct sd *) gspca_dev;
1616
1617 sd->blue = val;
1618 if (gspca_dev->streaming)
1619 setredblue(gspca_dev);
1620 return 0;
1621}
1622
1623static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
1624{
1625 struct sd *sd = (struct sd *) gspca_dev;
1626
1627 *val = sd->blue;
1628 return 0;
1629}
1630
1631static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
1632{
1633 struct sd *sd = (struct sd *) gspca_dev;
1634
1635 sd->red = val;
1636 if (gspca_dev->streaming)
1637 setredblue(gspca_dev);
1638 return 0;
1639}
1640
1641static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
1642{
1643 struct sd *sd = (struct sd *) gspca_dev;
1644
1645 *val = sd->red;
1646 return 0;
1647}
1648
1568static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) 1649static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
1569{ 1650{
1570 struct sd *sd = (struct sd *) gspca_dev; 1651 struct sd *sd = (struct sd *) gspca_dev;