diff options
author | Jean-François Moine <moinejf@free.fr> | 2011-01-13 04:39:11 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-19 08:45:42 -0500 |
commit | 3afef85bfefa65a31f4dbf8e7921c7938adb24f4 (patch) | |
tree | 2d5da90bedb58248a75d378597dc0c4b939143ad /drivers/media/video/gspca | |
parent | 14b67c2969ebf50bd5534b2a0c441f8569a9361e (diff) |
[media] gspca - sonixj: Infrared bug fix and enhancement
The infrared was set by sensor write instead of bridge GPIO.
It is now settable by the standard control ILLUMINATOR_1.
A module parameter permits to set the right GPIO bit according
to the StarCam model.
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 3e41653f11c1..c634dc113f94 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -25,12 +25,12 @@ | |||
25 | #include "gspca.h" | 25 | #include "gspca.h" |
26 | #include "jpeg.h" | 26 | #include "jpeg.h" |
27 | 27 | ||
28 | #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) | ||
29 | |||
30 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); | 28 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); |
31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); | 29 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
32 | MODULE_LICENSE("GPL"); | 30 | MODULE_LICENSE("GPL"); |
33 | 31 | ||
32 | static int starcam; | ||
33 | |||
34 | /* controls */ | 34 | /* controls */ |
35 | enum e_ctrl { | 35 | enum e_ctrl { |
36 | BRIGHTNESS, | 36 | BRIGHTNESS, |
@@ -43,7 +43,7 @@ enum e_ctrl { | |||
43 | HFLIP, | 43 | HFLIP, |
44 | VFLIP, | 44 | VFLIP, |
45 | SHARPNESS, | 45 | SHARPNESS, |
46 | INFRARED, | 46 | ILLUM, |
47 | FREQ, | 47 | FREQ, |
48 | NCTRLS /* number of controls */ | 48 | NCTRLS /* number of controls */ |
49 | }; | 49 | }; |
@@ -100,7 +100,8 @@ enum sensors { | |||
100 | }; | 100 | }; |
101 | 101 | ||
102 | /* device flags */ | 102 | /* device flags */ |
103 | #define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */ | 103 | #define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */ |
104 | #define F_ILLUM 0x02 /* presence of illuminator */ | ||
104 | 105 | ||
105 | /* sn9c1xx definitions */ | 106 | /* sn9c1xx definitions */ |
106 | /* register 0x01 */ | 107 | /* register 0x01 */ |
@@ -124,7 +125,7 @@ static void setgamma(struct gspca_dev *gspca_dev); | |||
124 | static void setautogain(struct gspca_dev *gspca_dev); | 125 | static void setautogain(struct gspca_dev *gspca_dev); |
125 | static void sethvflip(struct gspca_dev *gspca_dev); | 126 | static void sethvflip(struct gspca_dev *gspca_dev); |
126 | static void setsharpness(struct gspca_dev *gspca_dev); | 127 | static void setsharpness(struct gspca_dev *gspca_dev); |
127 | static void setinfrared(struct gspca_dev *gspca_dev); | 128 | static void setillum(struct gspca_dev *gspca_dev); |
128 | static void setfreq(struct gspca_dev *gspca_dev); | 129 | static void setfreq(struct gspca_dev *gspca_dev); |
129 | 130 | ||
130 | static const struct ctrl sd_ctrls[NCTRLS] = { | 131 | static const struct ctrl sd_ctrls[NCTRLS] = { |
@@ -251,18 +252,17 @@ static const struct ctrl sd_ctrls[NCTRLS] = { | |||
251 | }, | 252 | }, |
252 | .set_control = setsharpness | 253 | .set_control = setsharpness |
253 | }, | 254 | }, |
254 | /* mt9v111 only */ | 255 | [ILLUM] = { |
255 | [INFRARED] = { | ||
256 | { | 256 | { |
257 | .id = V4L2_CID_INFRARED, | 257 | .id = V4L2_CID_ILLUMINATORS_1, |
258 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 258 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
259 | .name = "Infrared", | 259 | .name = "Illuminator / infrared", |
260 | .minimum = 0, | 260 | .minimum = 0, |
261 | .maximum = 1, | 261 | .maximum = 1, |
262 | .step = 1, | 262 | .step = 1, |
263 | .default_value = 0, | 263 | .default_value = 0, |
264 | }, | 264 | }, |
265 | .set_control = setinfrared | 265 | .set_control = setillum |
266 | }, | 266 | }, |
267 | /* ov7630/ov7648/ov7660 only */ | 267 | /* ov7630/ov7648/ov7660 only */ |
268 | [FREQ] = { | 268 | [FREQ] = { |
@@ -282,32 +282,26 @@ static const struct ctrl sd_ctrls[NCTRLS] = { | |||
282 | /* table of the disabled controls */ | 282 | /* table of the disabled controls */ |
283 | static const __u32 ctrl_dis[] = { | 283 | static const __u32 ctrl_dis[] = { |
284 | [SENSOR_ADCM1700] = (1 << AUTOGAIN) | | 284 | [SENSOR_ADCM1700] = (1 << AUTOGAIN) | |
285 | (1 << INFRARED) | | ||
286 | (1 << HFLIP) | | 285 | (1 << HFLIP) | |
287 | (1 << VFLIP) | | 286 | (1 << VFLIP) | |
288 | (1 << FREQ), | 287 | (1 << FREQ), |
289 | 288 | ||
290 | [SENSOR_GC0307] = (1 << INFRARED) | | 289 | [SENSOR_GC0307] = (1 << HFLIP) | |
291 | (1 << HFLIP) | | ||
292 | (1 << VFLIP) | | 290 | (1 << VFLIP) | |
293 | (1 << FREQ), | 291 | (1 << FREQ), |
294 | 292 | ||
295 | [SENSOR_HV7131R] = (1 << INFRARED) | | 293 | [SENSOR_HV7131R] = (1 << HFLIP) | |
296 | (1 << HFLIP) | | ||
297 | (1 << FREQ), | 294 | (1 << FREQ), |
298 | 295 | ||
299 | [SENSOR_MI0360] = (1 << INFRARED) | | 296 | [SENSOR_MI0360] = (1 << HFLIP) | |
300 | (1 << HFLIP) | | ||
301 | (1 << VFLIP) | | 297 | (1 << VFLIP) | |
302 | (1 << FREQ), | 298 | (1 << FREQ), |
303 | 299 | ||
304 | [SENSOR_MI0360B] = (1 << INFRARED) | | 300 | [SENSOR_MI0360B] = (1 << HFLIP) | |
305 | (1 << HFLIP) | | ||
306 | (1 << VFLIP) | | 301 | (1 << VFLIP) | |
307 | (1 << FREQ), | 302 | (1 << FREQ), |
308 | 303 | ||
309 | [SENSOR_MO4000] = (1 << INFRARED) | | 304 | [SENSOR_MO4000] = (1 << HFLIP) | |
310 | (1 << HFLIP) | | ||
311 | (1 << VFLIP) | | 305 | (1 << VFLIP) | |
312 | (1 << FREQ), | 306 | (1 << FREQ), |
313 | 307 | ||
@@ -315,40 +309,32 @@ static const __u32 ctrl_dis[] = { | |||
315 | (1 << VFLIP) | | 309 | (1 << VFLIP) | |
316 | (1 << FREQ), | 310 | (1 << FREQ), |
317 | 311 | ||
318 | [SENSOR_OM6802] = (1 << INFRARED) | | 312 | [SENSOR_OM6802] = (1 << HFLIP) | |
319 | (1 << HFLIP) | | ||
320 | (1 << VFLIP) | | 313 | (1 << VFLIP) | |
321 | (1 << FREQ), | 314 | (1 << FREQ), |
322 | 315 | ||
323 | [SENSOR_OV7630] = (1 << INFRARED) | | 316 | [SENSOR_OV7630] = (1 << HFLIP), |
324 | (1 << HFLIP), | ||
325 | 317 | ||
326 | [SENSOR_OV7648] = (1 << INFRARED) | | 318 | [SENSOR_OV7648] = (1 << HFLIP), |
327 | (1 << HFLIP), | ||
328 | 319 | ||
329 | [SENSOR_OV7660] = (1 << AUTOGAIN) | | 320 | [SENSOR_OV7660] = (1 << AUTOGAIN) | |
330 | (1 << INFRARED) | | ||
331 | (1 << HFLIP) | | 321 | (1 << HFLIP) | |
332 | (1 << VFLIP), | 322 | (1 << VFLIP), |
333 | 323 | ||
334 | [SENSOR_PO1030] = (1 << AUTOGAIN) | | 324 | [SENSOR_PO1030] = (1 << AUTOGAIN) | |
335 | (1 << INFRARED) | | ||
336 | (1 << HFLIP) | | 325 | (1 << HFLIP) | |
337 | (1 << VFLIP) | | 326 | (1 << VFLIP) | |
338 | (1 << FREQ), | 327 | (1 << FREQ), |
339 | 328 | ||
340 | [SENSOR_PO2030N] = (1 << AUTOGAIN) | | 329 | [SENSOR_PO2030N] = (1 << AUTOGAIN) | |
341 | (1 << INFRARED) | | ||
342 | (1 << FREQ), | 330 | (1 << FREQ), |
343 | 331 | ||
344 | [SENSOR_SOI768] = (1 << AUTOGAIN) | | 332 | [SENSOR_SOI768] = (1 << AUTOGAIN) | |
345 | (1 << INFRARED) | | ||
346 | (1 << HFLIP) | | 333 | (1 << HFLIP) | |
347 | (1 << VFLIP) | | 334 | (1 << VFLIP) | |
348 | (1 << FREQ), | 335 | (1 << FREQ), |
349 | 336 | ||
350 | [SENSOR_SP80708] = (1 << AUTOGAIN) | | 337 | [SENSOR_SP80708] = (1 << AUTOGAIN) | |
351 | (1 << INFRARED) | | ||
352 | (1 << HFLIP) | | 338 | (1 << HFLIP) | |
353 | (1 << VFLIP) | | 339 | (1 << VFLIP) | |
354 | (1 << FREQ), | 340 | (1 << FREQ), |
@@ -1876,6 +1862,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1876 | sd->i2c_addr = sn9c1xx[9]; | 1862 | sd->i2c_addr = sn9c1xx[9]; |
1877 | 1863 | ||
1878 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; | 1864 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
1865 | if (!(sd->flags & F_ILLUM)) | ||
1866 | gspca_dev->ctrl_dis |= (1 << ILLUM); | ||
1879 | 1867 | ||
1880 | return gspca_dev->usb_err; | 1868 | return gspca_dev->usb_err; |
1881 | } | 1869 | } |
@@ -2199,16 +2187,20 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
2199 | reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val); | 2187 | reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val); |
2200 | } | 2188 | } |
2201 | 2189 | ||
2202 | static void setinfrared(struct gspca_dev *gspca_dev) | 2190 | static void setillum(struct gspca_dev *gspca_dev) |
2203 | { | 2191 | { |
2204 | struct sd *sd = (struct sd *) gspca_dev; | 2192 | struct sd *sd = (struct sd *) gspca_dev; |
2205 | 2193 | ||
2206 | if (gspca_dev->ctrl_dis & (1 << INFRARED)) | 2194 | if (gspca_dev->ctrl_dis & (1 << ILLUM)) |
2207 | return; | 2195 | return; |
2208 | /*fixme: different sequence for StarCam Clip and StarCam 370i */ | 2196 | if (starcam) |
2209 | /* Clip */ | 2197 | reg_w1(gspca_dev, 0x02, /* gpio */ |
2210 | i2c_w1(gspca_dev, 0x02, /* gpio */ | 2198 | sd->ctrls[ILLUM].val ? |
2211 | sd->ctrls[INFRARED].val ? 0x66 : 0x64); | 2199 | 0x55 : 0x54); /* 370i */ |
2200 | else | ||
2201 | reg_w1(gspca_dev, 0x02, | ||
2202 | sd->ctrls[ILLUM].val ? | ||
2203 | 0x66 : 0x64); /* Clip */ | ||
2212 | } | 2204 | } |
2213 | 2205 | ||
2214 | static void setfreq(struct gspca_dev *gspca_dev) | 2206 | static void setfreq(struct gspca_dev *gspca_dev) |
@@ -2346,7 +2338,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2346 | /* sensor clock already enabled in sd_init */ | 2338 | /* sensor clock already enabled in sd_init */ |
2347 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | 2339 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ |
2348 | reg01 = sn9c1xx[1]; | 2340 | reg01 = sn9c1xx[1]; |
2349 | if (sd->flags & PDN_INV) | 2341 | if (sd->flags & F_PDN_INV) |
2350 | reg01 ^= S_PDN_INV; /* power down inverted */ | 2342 | reg01 ^= S_PDN_INV; /* power down inverted */ |
2351 | reg_w1(gspca_dev, 0x01, reg01); | 2343 | reg_w1(gspca_dev, 0x01, reg01); |
2352 | 2344 | ||
@@ -2912,8 +2904,8 @@ static const struct sd_desc sd_desc = { | |||
2912 | static const struct usb_device_id device_table[] = { | 2904 | static const struct usb_device_id device_table[] = { |
2913 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, | 2905 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, |
2914 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, | 2906 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, |
2915 | {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)}, | 2907 | {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)}, |
2916 | {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)}, | 2908 | {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)}, |
2917 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, | 2909 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, |
2918 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, | 2910 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, |
2919 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, | 2911 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, |
@@ -2925,7 +2917,7 @@ static const struct usb_device_id device_table[] = { | |||
2925 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ | 2917 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ |
2926 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, | 2918 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, |
2927 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ | 2919 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ |
2928 | {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, | 2920 | {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)}, |
2929 | /* or MT9V111 */ | 2921 | /* or MT9V111 */ |
2930 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ | 2922 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ |
2931 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ | 2923 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ |
@@ -3004,3 +2996,7 @@ static void __exit sd_mod_exit(void) | |||
3004 | 2996 | ||
3005 | module_init(sd_mod_init); | 2997 | module_init(sd_mod_init); |
3006 | module_exit(sd_mod_exit); | 2998 | module_exit(sd_mod_exit); |
2999 | |||
3000 | module_param(starcam, int, 0644); | ||
3001 | MODULE_PARM_DESC(starcam, | ||
3002 | "StarCam model. 0: Clip, 1: 370i"); | ||