diff options
author | Antonio Ospite <ospite@studenti.unina.it> | 2012-05-14 07:07:43 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-14 08:45:48 -0400 |
commit | e0fde595e3fbf8138a7f5b0c877ab90a0d07a347 (patch) | |
tree | 05f33e7471470d75a87593307e5bafb87ddb5250 | |
parent | 6a6c70b8f26e1a59fa884e87b304ac50d4214602 (diff) |
[media] gspca - ov534: Add Saturation control
Also merge the "COLORS" control into it as it was V4L2_CID_SATURATION
anyway.
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/ov534.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c index 04753391de3e..c15cf23d7758 100644 --- a/drivers/media/video/gspca/ov534.c +++ b/drivers/media/video/gspca/ov534.c | |||
@@ -53,6 +53,7 @@ MODULE_LICENSE("GPL"); | |||
53 | 53 | ||
54 | /* controls */ | 54 | /* controls */ |
55 | enum e_ctrl { | 55 | enum e_ctrl { |
56 | SATURATION, | ||
56 | BRIGHTNESS, | 57 | BRIGHTNESS, |
57 | CONTRAST, | 58 | CONTRAST, |
58 | GAIN, | 59 | GAIN, |
@@ -63,7 +64,6 @@ enum e_ctrl { | |||
63 | SHARPNESS, | 64 | SHARPNESS, |
64 | HFLIP, | 65 | HFLIP, |
65 | VFLIP, | 66 | VFLIP, |
66 | COLORS, | ||
67 | LIGHTFREQ, | 67 | LIGHTFREQ, |
68 | NCTRLS /* number of controls */ | 68 | NCTRLS /* number of controls */ |
69 | }; | 69 | }; |
@@ -87,6 +87,7 @@ enum sensors { | |||
87 | }; | 87 | }; |
88 | 88 | ||
89 | /* V4L2 controls supported by the driver */ | 89 | /* V4L2 controls supported by the driver */ |
90 | static void setsaturation(struct gspca_dev *gspca_dev); | ||
90 | static void setbrightness(struct gspca_dev *gspca_dev); | 91 | static void setbrightness(struct gspca_dev *gspca_dev); |
91 | static void setcontrast(struct gspca_dev *gspca_dev); | 92 | static void setcontrast(struct gspca_dev *gspca_dev); |
92 | static void setgain(struct gspca_dev *gspca_dev); | 93 | static void setgain(struct gspca_dev *gspca_dev); |
@@ -96,13 +97,24 @@ static void setawb(struct gspca_dev *gspca_dev); | |||
96 | static void setaec(struct gspca_dev *gspca_dev); | 97 | static void setaec(struct gspca_dev *gspca_dev); |
97 | static void setsharpness(struct gspca_dev *gspca_dev); | 98 | static void setsharpness(struct gspca_dev *gspca_dev); |
98 | static void sethvflip(struct gspca_dev *gspca_dev); | 99 | static void sethvflip(struct gspca_dev *gspca_dev); |
99 | static void setcolors(struct gspca_dev *gspca_dev); | ||
100 | static void setlightfreq(struct gspca_dev *gspca_dev); | 100 | static void setlightfreq(struct gspca_dev *gspca_dev); |
101 | 101 | ||
102 | static int sd_start(struct gspca_dev *gspca_dev); | 102 | static int sd_start(struct gspca_dev *gspca_dev); |
103 | static void sd_stopN(struct gspca_dev *gspca_dev); | 103 | static void sd_stopN(struct gspca_dev *gspca_dev); |
104 | 104 | ||
105 | static const struct ctrl sd_ctrls[] = { | 105 | static const struct ctrl sd_ctrls[] = { |
106 | [SATURATION] = { | ||
107 | { | ||
108 | .id = V4L2_CID_SATURATION, | ||
109 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
110 | .name = "Saturation", | ||
111 | .minimum = 0, | ||
112 | .maximum = 255, | ||
113 | .step = 1, | ||
114 | .default_value = 64, | ||
115 | }, | ||
116 | .set_control = setsaturation | ||
117 | }, | ||
106 | [BRIGHTNESS] = { | 118 | [BRIGHTNESS] = { |
107 | { | 119 | { |
108 | .id = V4L2_CID_BRIGHTNESS, | 120 | .id = V4L2_CID_BRIGHTNESS, |
@@ -223,18 +235,6 @@ static const struct ctrl sd_ctrls[] = { | |||
223 | }, | 235 | }, |
224 | .set_control = sethvflip | 236 | .set_control = sethvflip |
225 | }, | 237 | }, |
226 | [COLORS] = { | ||
227 | { | ||
228 | .id = V4L2_CID_SATURATION, | ||
229 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
230 | .name = "Saturation", | ||
231 | .minimum = 0, | ||
232 | .maximum = 6, | ||
233 | .step = 1, | ||
234 | .default_value = 3, | ||
235 | }, | ||
236 | .set_control = setcolors | ||
237 | }, | ||
238 | [LIGHTFREQ] = { | 238 | [LIGHTFREQ] = { |
239 | { | 239 | { |
240 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 240 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
@@ -684,7 +684,7 @@ static const u8 sensor_init_772x[][2] = { | |||
684 | { 0x9c, 0x20 }, | 684 | { 0x9c, 0x20 }, |
685 | { 0x9e, 0x81 }, | 685 | { 0x9e, 0x81 }, |
686 | 686 | ||
687 | { 0xa6, 0x04 }, | 687 | { 0xa6, 0x06 }, |
688 | { 0x7e, 0x0c }, | 688 | { 0x7e, 0x0c }, |
689 | { 0x7f, 0x16 }, | 689 | { 0x7f, 0x16 }, |
690 | { 0x80, 0x2a }, | 690 | { 0x80, 0x2a }, |
@@ -955,6 +955,32 @@ static void set_frame_rate(struct gspca_dev *gspca_dev) | |||
955 | PDEBUG(D_PROBE, "frame_rate: %d", r->fps); | 955 | PDEBUG(D_PROBE, "frame_rate: %d", r->fps); |
956 | } | 956 | } |
957 | 957 | ||
958 | static void setsaturation(struct gspca_dev *gspca_dev) | ||
959 | { | ||
960 | struct sd *sd = (struct sd *) gspca_dev; | ||
961 | int val; | ||
962 | |||
963 | val = sd->ctrls[SATURATION].val; | ||
964 | if (sd->sensor == SENSOR_OV767x) { | ||
965 | int i; | ||
966 | static u8 color_tb[][6] = { | ||
967 | {0x42, 0x42, 0x00, 0x11, 0x30, 0x41}, | ||
968 | {0x52, 0x52, 0x00, 0x16, 0x3c, 0x52}, | ||
969 | {0x66, 0x66, 0x00, 0x1b, 0x4b, 0x66}, | ||
970 | {0x80, 0x80, 0x00, 0x22, 0x5e, 0x80}, | ||
971 | {0x9a, 0x9a, 0x00, 0x29, 0x71, 0x9a}, | ||
972 | {0xb8, 0xb8, 0x00, 0x31, 0x87, 0xb8}, | ||
973 | {0xdd, 0xdd, 0x00, 0x3b, 0xa2, 0xdd}, | ||
974 | }; | ||
975 | |||
976 | for (i = 0; i < ARRAY_SIZE(color_tb[0]); i++) | ||
977 | sccb_reg_write(gspca_dev, 0x4f + i, color_tb[val][i]); | ||
978 | } else { | ||
979 | sccb_reg_write(gspca_dev, 0xa7, val); /* U saturation */ | ||
980 | sccb_reg_write(gspca_dev, 0xa8, val); /* V saturation */ | ||
981 | } | ||
982 | } | ||
983 | |||
958 | static void setbrightness(struct gspca_dev *gspca_dev) | 984 | static void setbrightness(struct gspca_dev *gspca_dev) |
959 | { | 985 | { |
960 | struct sd *sd = (struct sd *) gspca_dev; | 986 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1132,26 +1158,6 @@ static void sethvflip(struct gspca_dev *gspca_dev) | |||
1132 | } | 1158 | } |
1133 | } | 1159 | } |
1134 | 1160 | ||
1135 | static void setcolors(struct gspca_dev *gspca_dev) | ||
1136 | { | ||
1137 | struct sd *sd = (struct sd *) gspca_dev; | ||
1138 | u8 val; | ||
1139 | int i; | ||
1140 | static u8 color_tb[][6] = { | ||
1141 | {0x42, 0x42, 0x00, 0x11, 0x30, 0x41}, | ||
1142 | {0x52, 0x52, 0x00, 0x16, 0x3c, 0x52}, | ||
1143 | {0x66, 0x66, 0x00, 0x1b, 0x4b, 0x66}, | ||
1144 | {0x80, 0x80, 0x00, 0x22, 0x5e, 0x80}, | ||
1145 | {0x9a, 0x9a, 0x00, 0x29, 0x71, 0x9a}, | ||
1146 | {0xb8, 0xb8, 0x00, 0x31, 0x87, 0xb8}, | ||
1147 | {0xdd, 0xdd, 0x00, 0x3b, 0xa2, 0xdd}, | ||
1148 | }; | ||
1149 | |||
1150 | val = sd->ctrls[COLORS].val; | ||
1151 | for (i = 0; i < ARRAY_SIZE(color_tb[0]); i++) | ||
1152 | sccb_reg_write(gspca_dev, 0x4f + i, color_tb[val][i]); | ||
1153 | } | ||
1154 | |||
1155 | static void setlightfreq(struct gspca_dev *gspca_dev) | 1161 | static void setlightfreq(struct gspca_dev *gspca_dev) |
1156 | { | 1162 | { |
1157 | struct sd *sd = (struct sd *) gspca_dev; | 1163 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1228,6 +1234,9 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1228 | gspca_dev->ctrl_dis = (1 << GAIN) | | 1234 | gspca_dev->ctrl_dis = (1 << GAIN) | |
1229 | (1 << AGC) | | 1235 | (1 << AGC) | |
1230 | (1 << SHARPNESS); /* auto */ | 1236 | (1 << SHARPNESS); /* auto */ |
1237 | sd->ctrls[SATURATION].min = 0, | ||
1238 | sd->ctrls[SATURATION].max = 6, | ||
1239 | sd->ctrls[SATURATION].def = 3, | ||
1231 | sd->ctrls[BRIGHTNESS].min = -127; | 1240 | sd->ctrls[BRIGHTNESS].min = -127; |
1232 | sd->ctrls[BRIGHTNESS].max = 127; | 1241 | sd->ctrls[BRIGHTNESS].max = 127; |
1233 | sd->ctrls[BRIGHTNESS].def = 0; | 1242 | sd->ctrls[BRIGHTNESS].def = 0; |
@@ -1243,7 +1252,6 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1243 | gspca_dev->cam.nmodes = ARRAY_SIZE(ov767x_mode); | 1252 | gspca_dev->cam.nmodes = ARRAY_SIZE(ov767x_mode); |
1244 | } else { | 1253 | } else { |
1245 | sd->sensor = SENSOR_OV772x; | 1254 | sd->sensor = SENSOR_OV772x; |
1246 | gspca_dev->ctrl_dis = (1 << COLORS); | ||
1247 | gspca_dev->cam.bulk = 1; | 1255 | gspca_dev->cam.bulk = 1; |
1248 | gspca_dev->cam.bulk_size = 16384; | 1256 | gspca_dev->cam.bulk_size = 16384; |
1249 | gspca_dev->cam.bulk_nurbs = 2; | 1257 | gspca_dev->cam.bulk_nurbs = 2; |
@@ -1302,6 +1310,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1302 | 1310 | ||
1303 | set_frame_rate(gspca_dev); | 1311 | set_frame_rate(gspca_dev); |
1304 | 1312 | ||
1313 | setsaturation(gspca_dev); | ||
1305 | if (!(gspca_dev->ctrl_dis & (1 << AGC))) | 1314 | if (!(gspca_dev->ctrl_dis & (1 << AGC))) |
1306 | setagc(gspca_dev); | 1315 | setagc(gspca_dev); |
1307 | setawb(gspca_dev); | 1316 | setawb(gspca_dev); |
@@ -1314,8 +1323,6 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1314 | if (!(gspca_dev->ctrl_dis & (1 << SHARPNESS))) | 1323 | if (!(gspca_dev->ctrl_dis & (1 << SHARPNESS))) |
1315 | setsharpness(gspca_dev); | 1324 | setsharpness(gspca_dev); |
1316 | sethvflip(gspca_dev); | 1325 | sethvflip(gspca_dev); |
1317 | if (!(gspca_dev->ctrl_dis & (1 << COLORS))) | ||
1318 | setcolors(gspca_dev); | ||
1319 | setlightfreq(gspca_dev); | 1326 | setlightfreq(gspca_dev); |
1320 | 1327 | ||
1321 | ov534_set_led(gspca_dev, 1); | 1328 | ov534_set_led(gspca_dev, 1); |