aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 12:35:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 12:35:11 -0400
commit0851668fdd97e526b2a41f794b785c204dd3d3e0 (patch)
tree4ef7c20a8be8393006c6fe9627eb29dd30877d61 /drivers/media/video/gspca
parent00ebb6382b8d9c7c15b5f8ad230670d8161d38dd (diff)
parent7655e594945289b418af39f6669fea4666a7b520 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (505 commits) [media] af9015: Fix max I2C message size when used with tda18271 [media] IR: initialize ir_raw_event in few more drivers [media] Guard a divide in v4l1 compat layer [media] imon: fix nomouse modprobe option [media] imon: remove redundant change_protocol call [media] imon: fix my egregious brown paper bag w/rdev/idev split [media] cafe_ccic: Configure ov7670 correctly [media] ov7670: allow configuration of image size, clock speed, and I/O method [media] af9015: support for DigitalNow TinyTwin v3 [1f4d:9016] [media] af9015: map DigitalNow TinyTwin v2 remote [media] DigitalNow TinyTwin remote controller [media] af9015: RC fixes and improvements videodev2.h.xml: Update to reflect the latest changes at videodev2.h [media] v4l: document new Bayer and monochrome pixel formats [media] DocBook/v4l: Add missing formats used on gspca cpia1 and sn9c2028 [media] firedtv: add parameter to fake ca_system_ids in CA_INFO [media] tm6000: fix a macro coding style issue tm6000: Remove some ugly debug code [media] Nova-S-Plus audio line input [media] [RFC,1/1] V4L2: Use new CAP bits in existing RDS capable drivers ...
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/Kconfig18
-rw-r--r--drivers/media/video/gspca/Makefile4
-rw-r--r--drivers/media/video/gspca/benq.c23
-rw-r--r--drivers/media/video/gspca/conex.c14
-rw-r--r--drivers/media/video/gspca/cpia1.c133
-rw-r--r--drivers/media/video/gspca/etoms.c12
-rw-r--r--drivers/media/video/gspca/finepix.c15
-rw-r--r--drivers/media/video/gspca/gl860/gl860-mi2020.c6
-rw-r--r--drivers/media/video/gspca/gl860/gl860.c6
-rw-r--r--drivers/media/video/gspca/gspca.c161
-rw-r--r--drivers/media/video/gspca/gspca.h12
-rw-r--r--drivers/media/video/gspca/jeilinj.c15
-rw-r--r--drivers/media/video/gspca/konica.c646
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c8
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.c48
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.h14
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.c70
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov7660.h9
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c102
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.h12
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.c136
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.h13
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.c28
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.h14
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.h12
-rw-r--r--drivers/media/video/gspca/mars.c327
-rw-r--r--drivers/media/video/gspca/mr97310a.c56
-rw-r--r--drivers/media/video/gspca/ov519.c389
-rw-r--r--drivers/media/video/gspca/ov534.c19
-rw-r--r--drivers/media/video/gspca/ov534_9.c19
-rw-r--r--drivers/media/video/gspca/pac207.c26
-rw-r--r--drivers/media/video/gspca/pac7302.c32
-rw-r--r--drivers/media/video/gspca/pac7311.c32
-rw-r--r--drivers/media/video/gspca/sn9c2028.c19
-rw-r--r--drivers/media/video/gspca/sn9c20x.c65
-rw-r--r--drivers/media/video/gspca/sonixb.c21
-rw-r--r--drivers/media/video/gspca/sonixj.c926
-rw-r--r--drivers/media/video/gspca/spca1528.c15
-rw-r--r--drivers/media/video/gspca/spca500.c14
-rw-r--r--drivers/media/video/gspca/spca501.c16
-rw-r--r--drivers/media/video/gspca/spca505.c18
-rw-r--r--drivers/media/video/gspca/spca508.c16
-rw-r--r--drivers/media/video/gspca/spca561.c16
-rw-r--r--drivers/media/video/gspca/sq905.c21
-rw-r--r--drivers/media/video/gspca/sq905c.c15
-rw-r--r--drivers/media/video/gspca/sq930x.c23
-rw-r--r--drivers/media/video/gspca/stk014.c174
-rw-r--r--drivers/media/video/gspca/stv0680.c17
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.c14
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.h2
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c19
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h2
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_st6422.c2
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c2
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h4
-rw-r--r--drivers/media/video/gspca/sunplus.c27
-rw-r--r--drivers/media/video/gspca/t613.c10
-rw-r--r--drivers/media/video/gspca/tv8532.c8
-rw-r--r--drivers/media/video/gspca/vc032x.c19
-rw-r--r--drivers/media/video/gspca/w996Xcf.c10
-rw-r--r--drivers/media/video/gspca/xirlink_cit.c3253
-rw-r--r--drivers/media/video/gspca/zc3xx.c37
62 files changed, 5386 insertions, 1830 deletions
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig
index 23db0c29f68c..dda56ff834f4 100644
--- a/drivers/media/video/gspca/Kconfig
+++ b/drivers/media/video/gspca/Kconfig
@@ -77,6 +77,15 @@ config USB_GSPCA_JEILINJ
77 To compile this driver as a module, choose M here: the 77 To compile this driver as a module, choose M here: the
78 module will be called gspca_jeilinj. 78 module will be called gspca_jeilinj.
79 79
80config USB_GSPCA_KONICA
81 tristate "Konica USB Camera V4L2 driver"
82 depends on VIDEO_V4L2 && USB_GSPCA
83 help
84 Say Y here if you want support for cameras based on the Konica chip.
85
86 To compile this driver as a module, choose M here: the
87 module will be called gspca_konica.
88
80config USB_GSPCA_MARS 89config USB_GSPCA_MARS
81 tristate "Mars USB Camera Driver" 90 tristate "Mars USB Camera Driver"
82 depends on VIDEO_V4L2 && USB_GSPCA 91 depends on VIDEO_V4L2 && USB_GSPCA
@@ -337,6 +346,15 @@ config USB_GSPCA_VC032X
337 To compile this driver as a module, choose M here: the 346 To compile this driver as a module, choose M here: the
338 module will be called gspca_vc032x. 347 module will be called gspca_vc032x.
339 348
349config USB_GSPCA_XIRLINK_CIT
350 tristate "Xirlink C-It USB Camera Driver"
351 depends on VIDEO_V4L2 && USB_GSPCA
352 help
353 Say Y here if you want support for Xirlink C-It bases cameras.
354
355 To compile this driver as a module, choose M here: the
356 module will be called gspca_xirlink_cit.
357
340config USB_GSPCA_ZC3XX 358config USB_GSPCA_ZC3XX
341 tristate "ZC3XX USB Camera Driver" 359 tristate "ZC3XX USB Camera Driver"
342 depends on VIDEO_V4L2 && USB_GSPCA 360 depends on VIDEO_V4L2 && USB_GSPCA
diff --git a/drivers/media/video/gspca/Makefile b/drivers/media/video/gspca/Makefile
index f6616db0b7f8..24e695b8b077 100644
--- a/drivers/media/video/gspca/Makefile
+++ b/drivers/media/video/gspca/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_USB_GSPCA_CPIA1) += gspca_cpia1.o
5obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o 5obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o
6obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o 6obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o
7obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o 7obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o
8obj-$(CONFIG_USB_GSPCA_KONICA) += gspca_konica.o
8obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o 9obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o
9obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o 10obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o
10obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o 11obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o
@@ -33,6 +34,7 @@ obj-$(CONFIG_USB_GSPCA_STV0680) += gspca_stv0680.o
33obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o 34obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
34obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o 35obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o
35obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o 36obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o
37obj-$(CONFIG_USB_GSPCA_XIRLINK_CIT) += gspca_xirlink_cit.o
36obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o 38obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o
37 39
38gspca_main-objs := gspca.o 40gspca_main-objs := gspca.o
@@ -42,6 +44,7 @@ gspca_cpia1-objs := cpia1.o
42gspca_etoms-objs := etoms.o 44gspca_etoms-objs := etoms.o
43gspca_finepix-objs := finepix.o 45gspca_finepix-objs := finepix.o
44gspca_jeilinj-objs := jeilinj.o 46gspca_jeilinj-objs := jeilinj.o
47gspca_konica-objs := konica.o
45gspca_mars-objs := mars.o 48gspca_mars-objs := mars.o
46gspca_mr97310a-objs := mr97310a.o 49gspca_mr97310a-objs := mr97310a.o
47gspca_ov519-objs := ov519.o 50gspca_ov519-objs := ov519.o
@@ -70,6 +73,7 @@ gspca_sunplus-objs := sunplus.o
70gspca_t613-objs := t613.o 73gspca_t613-objs := t613.o
71gspca_tv8532-objs := tv8532.o 74gspca_tv8532-objs := tv8532.o
72gspca_vc032x-objs := vc032x.o 75gspca_vc032x-objs := vc032x.o
76gspca_xirlink_cit-objs := xirlink_cit.o
73gspca_zc3xx-objs := zc3xx.o 77gspca_zc3xx-objs := zc3xx.o
74 78
75obj-$(CONFIG_USB_M5602) += m5602/ 79obj-$(CONFIG_USB_M5602) += m5602/
diff --git a/drivers/media/video/gspca/benq.c b/drivers/media/video/gspca/benq.c
index fce8d9492641..629043933501 100644
--- a/drivers/media/video/gspca/benq.c
+++ b/drivers/media/video/gspca/benq.c
@@ -62,7 +62,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
62 0, 62 0,
63 500); 63 500);
64 if (ret < 0) { 64 if (ret < 0) {
65 PDEBUG(D_ERR, "reg_w err %d", ret); 65 err("reg_w err %d", ret);
66 gspca_dev->usb_err = ret; 66 gspca_dev->usb_err = ret;
67 } 67 }
68} 68}
@@ -152,7 +152,8 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
152 reg_w(gspca_dev, 0x003c, 0x0005); 152 reg_w(gspca_dev, 0x003c, 0x0005);
153 reg_w(gspca_dev, 0x003c, 0x0006); 153 reg_w(gspca_dev, 0x003c, 0x0006);
154 reg_w(gspca_dev, 0x003c, 0x0007); 154 reg_w(gspca_dev, 0x003c, 0x0007);
155 usb_set_interface(gspca_dev->dev, gspca_dev->iface, gspca_dev->nbalt - 1); 155 usb_set_interface(gspca_dev->dev, gspca_dev->iface,
156 gspca_dev->nbalt - 1);
156} 157}
157 158
158static void sd_pkt_scan(struct gspca_dev *gspca_dev, 159static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -180,7 +181,7 @@ static void sd_isoc_irq(struct urb *urb)
180 if (gspca_dev->frozen) 181 if (gspca_dev->frozen)
181 return; 182 return;
182#endif 183#endif
183 PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status); 184 err("urb status: %d", urb->status);
184 return; 185 return;
185 } 186 }
186 187
@@ -208,8 +209,7 @@ static void sd_isoc_irq(struct urb *urb)
208 if (st == 0) 209 if (st == 0)
209 st = urb->iso_frame_desc[i].status; 210 st = urb->iso_frame_desc[i].status;
210 if (st) { 211 if (st) {
211 PDEBUG(D_ERR, 212 err("ISOC data error: [%d] status=%d",
212 "ISOC data error: [%d] status=%d",
213 i, st); 213 i, st);
214 gspca_dev->last_packet_type = DISCARD_PACKET; 214 gspca_dev->last_packet_type = DISCARD_PACKET;
215 continue; 215 continue;
@@ -256,10 +256,10 @@ static void sd_isoc_irq(struct urb *urb)
256 /* resubmit the URBs */ 256 /* resubmit the URBs */
257 st = usb_submit_urb(urb0, GFP_ATOMIC); 257 st = usb_submit_urb(urb0, GFP_ATOMIC);
258 if (st < 0) 258 if (st < 0)
259 PDEBUG(D_ERR|D_PACK, "usb_submit_urb(0) ret %d", st); 259 err("usb_submit_urb(0) ret %d", st);
260 st = usb_submit_urb(urb, GFP_ATOMIC); 260 st = usb_submit_urb(urb, GFP_ATOMIC);
261 if (st < 0) 261 if (st < 0)
262 PDEBUG(D_ERR|D_PACK, "usb_submit_urb() ret %d", st); 262 err("usb_submit_urb() ret %d", st);
263} 263}
264 264
265/* sub-driver description */ 265/* sub-driver description */
@@ -304,18 +304,11 @@ static struct usb_driver sd_driver = {
304/* -- module insert / remove -- */ 304/* -- module insert / remove -- */
305static int __init sd_mod_init(void) 305static int __init sd_mod_init(void)
306{ 306{
307 int ret; 307 return usb_register(&sd_driver);
308
309 ret = usb_register(&sd_driver);
310 if (ret < 0)
311 return ret;
312 info("registered");
313 return 0;
314} 308}
315static void __exit sd_mod_exit(void) 309static void __exit sd_mod_exit(void)
316{ 310{
317 usb_deregister(&sd_driver); 311 usb_deregister(&sd_driver);
318 info("deregistered");
319} 312}
320 313
321module_init(sd_mod_init); 314module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index d6a75772f3f8..1eacb6c7926d 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -687,7 +687,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
687 reg_w_val(gspca_dev, 0x00c0, 0x00); 687 reg_w_val(gspca_dev, 0x00c0, 0x00);
688 reg_r(gspca_dev, 0x0001, 1); 688 reg_r(gspca_dev, 0x0001, 1);
689 length = 8; 689 length = 8;
690 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { 690 switch (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv) {
691 case 0: 691 case 0:
692 for (i = 0; i < 27; i++) { 692 for (i = 0; i < 27; i++) {
693 if (i == 26) 693 if (i == 26)
@@ -901,7 +901,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
901 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 901 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
902} 902}
903 903
904static void setbrightness(struct gspca_dev*gspca_dev) 904static void setbrightness(struct gspca_dev *gspca_dev)
905{ 905{
906 struct sd *sd = (struct sd *) gspca_dev; 906 struct sd *sd = (struct sd *) gspca_dev;
907 __u8 regE5cbx[] = { 0x88, 0x00, 0xd4, 0x01, 0x88, 0x01, 0x01, 0x01 }; 907 __u8 regE5cbx[] = { 0x88, 0x00, 0xd4, 0x01, 0x88, 0x01, 0x01, 0x01 };
@@ -924,7 +924,7 @@ static void setbrightness(struct gspca_dev*gspca_dev)
924 reg_w_val(gspca_dev, 0x0070, reg70); 924 reg_w_val(gspca_dev, 0x0070, reg70);
925} 925}
926 926
927static void setcontrast(struct gspca_dev*gspca_dev) 927static void setcontrast(struct gspca_dev *gspca_dev)
928{ 928{
929 struct sd *sd = (struct sd *) gspca_dev; 929 struct sd *sd = (struct sd *) gspca_dev;
930 __u8 regE5acx[] = { 0x88, 0x0a, 0x0c, 0x01 }; /* seem MSB */ 930 __u8 regE5acx[] = { 0x88, 0x0a, 0x0c, 0x01 }; /* seem MSB */
@@ -1068,17 +1068,11 @@ static struct usb_driver sd_driver = {
1068/* -- module insert / remove -- */ 1068/* -- module insert / remove -- */
1069static int __init sd_mod_init(void) 1069static int __init sd_mod_init(void)
1070{ 1070{
1071 int ret; 1071 return usb_register(&sd_driver);
1072 ret = usb_register(&sd_driver);
1073 if (ret < 0)
1074 return ret;
1075 PDEBUG(D_PROBE, "registered");
1076 return 0;
1077} 1072}
1078static void __exit sd_mod_exit(void) 1073static void __exit sd_mod_exit(void)
1079{ 1074{
1080 usb_deregister(&sd_driver); 1075 usb_deregister(&sd_driver);
1081 PDEBUG(D_PROBE, "deregistered");
1082} 1076}
1083 1077
1084module_init(sd_mod_init); 1078module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c
index 3747a1dcff54..9b121681d135 100644
--- a/drivers/media/video/gspca/cpia1.c
+++ b/drivers/media/video/gspca/cpia1.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * cpia CPiA (1) gspca driver 2 * cpia CPiA (1) gspca driver
3 * 3 *
4 * Copyright (C) 2010 Hans de Goede <hdgoede@redhat.com> 4 * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
5 * 5 *
6 * This module is adapted from the in kernel v4l1 cpia driver which is : 6 * This module is adapted from the in kernel v4l1 cpia driver which is :
7 * 7 *
@@ -30,7 +30,7 @@
30 30
31#include "gspca.h" 31#include "gspca.h"
32 32
33MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); 33MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
34MODULE_DESCRIPTION("Vision CPiA"); 34MODULE_DESCRIPTION("Vision CPiA");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
@@ -373,9 +373,14 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
373static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 373static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
374static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val); 374static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val);
375static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val); 375static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val);
376static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val);
377static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val);
378static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val);
379static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val);
376 380
377static const struct ctrl sd_ctrls[] = { 381static const struct ctrl sd_ctrls[] = {
378 { 382 {
383#define BRIGHTNESS_IDX 0
379 { 384 {
380 .id = V4L2_CID_BRIGHTNESS, 385 .id = V4L2_CID_BRIGHTNESS,
381 .type = V4L2_CTRL_TYPE_INTEGER, 386 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -390,6 +395,7 @@ static const struct ctrl sd_ctrls[] = {
390 .set = sd_setbrightness, 395 .set = sd_setbrightness,
391 .get = sd_getbrightness, 396 .get = sd_getbrightness,
392 }, 397 },
398#define CONTRAST_IDX 1
393 { 399 {
394 { 400 {
395 .id = V4L2_CID_CONTRAST, 401 .id = V4L2_CID_CONTRAST,
@@ -404,6 +410,7 @@ static const struct ctrl sd_ctrls[] = {
404 .set = sd_setcontrast, 410 .set = sd_setcontrast,
405 .get = sd_getcontrast, 411 .get = sd_getcontrast,
406 }, 412 },
413#define SATURATION_IDX 2
407 { 414 {
408 { 415 {
409 .id = V4L2_CID_SATURATION, 416 .id = V4L2_CID_SATURATION,
@@ -418,6 +425,7 @@ static const struct ctrl sd_ctrls[] = {
418 .set = sd_setsaturation, 425 .set = sd_setsaturation,
419 .get = sd_getsaturation, 426 .get = sd_getsaturation,
420 }, 427 },
428#define POWER_LINE_FREQUENCY_IDX 3
421 { 429 {
422 { 430 {
423 .id = V4L2_CID_POWER_LINE_FREQUENCY, 431 .id = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -432,6 +440,37 @@ static const struct ctrl sd_ctrls[] = {
432 .set = sd_setfreq, 440 .set = sd_setfreq,
433 .get = sd_getfreq, 441 .get = sd_getfreq,
434 }, 442 },
443#define ILLUMINATORS_1_IDX 4
444 {
445 {
446 .id = V4L2_CID_ILLUMINATORS_1,
447 .type = V4L2_CTRL_TYPE_BOOLEAN,
448 .name = "Illuminator 1",
449 .minimum = 0,
450 .maximum = 1,
451 .step = 1,
452#define ILLUMINATORS_1_DEF 0
453 .default_value = ILLUMINATORS_1_DEF,
454 },
455 .set = sd_setilluminator1,
456 .get = sd_getilluminator1,
457 },
458#define ILLUMINATORS_2_IDX 5
459 {
460 {
461 .id = V4L2_CID_ILLUMINATORS_2,
462 .type = V4L2_CTRL_TYPE_BOOLEAN,
463 .name = "Illuminator 2",
464 .minimum = 0,
465 .maximum = 1,
466 .step = 1,
467#define ILLUMINATORS_2_DEF 0
468 .default_value = ILLUMINATORS_2_DEF,
469 },
470 .set = sd_setilluminator2,
471 .get = sd_getilluminator2,
472 },
473#define COMP_TARGET_IDX 6
435 { 474 {
436 { 475 {
437#define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE 476#define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE
@@ -510,7 +549,7 @@ retry:
510 gspca_dev->usb_buf, databytes, 1000); 549 gspca_dev->usb_buf, databytes, 1000);
511 550
512 if (ret < 0) 551 if (ret < 0)
513 PDEBUG(D_ERR, "usb_control_msg %02x, error %d", command[1], 552 err("usb_control_msg %02x, error %d", command[1],
514 ret); 553 ret);
515 554
516 if (ret == -EPIPE && retries > 0) { 555 if (ret == -EPIPE && retries > 0) {
@@ -1059,7 +1098,6 @@ static int command_resume(struct gspca_dev *gspca_dev)
1059 0, sd->params.streamStartLine, 0, 0); 1098 0, sd->params.streamStartLine, 0, 0);
1060} 1099}
1061 1100
1062#if 0 /* Currently unused */
1063static int command_setlights(struct gspca_dev *gspca_dev) 1101static int command_setlights(struct gspca_dev *gspca_dev)
1064{ 1102{
1065 struct sd *sd = (struct sd *) gspca_dev; 1103 struct sd *sd = (struct sd *) gspca_dev;
@@ -1079,7 +1117,6 @@ static int command_setlights(struct gspca_dev *gspca_dev)
1079 return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0, 1117 return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0,
1080 p1 | p2 | 0xE0, 0); 1118 p1 | p2 | 0xE0, 0);
1081} 1119}
1082#endif
1083 1120
1084static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) 1121static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply)
1085{ 1122{
@@ -1236,7 +1273,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev)
1236 cmd[7] = 0; 1273 cmd[7] = 0;
1237 ret = cpia_usb_transferCmd(gspca_dev, cmd); 1274 ret = cpia_usb_transferCmd(gspca_dev, cmd);
1238 if (ret) { 1275 if (ret) {
1239 PDEBUG(D_ERR, "ReadVPRegs(30,4,9,8) - failed: %d", ret); 1276 err("ReadVPRegs(30,4,9,8) - failed: %d", ret);
1240 return; 1277 return;
1241 } 1278 }
1242 exp_acc = gspca_dev->usb_buf[0]; 1279 exp_acc = gspca_dev->usb_buf[0];
@@ -1716,7 +1753,9 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1716/* this function is called at probe and resume time */ 1753/* this function is called at probe and resume time */
1717static int sd_init(struct gspca_dev *gspca_dev) 1754static int sd_init(struct gspca_dev *gspca_dev)
1718{ 1755{
1756#ifdef GSPCA_DEBUG
1719 struct sd *sd = (struct sd *) gspca_dev; 1757 struct sd *sd = (struct sd *) gspca_dev;
1758#endif
1720 int ret; 1759 int ret;
1721 1760
1722 /* Start / Stop the camera to make sure we are talking to 1761 /* Start / Stop the camera to make sure we are talking to
@@ -1726,6 +1765,14 @@ static int sd_init(struct gspca_dev *gspca_dev)
1726 if (ret) 1765 if (ret)
1727 return ret; 1766 return ret;
1728 1767
1768 /* Ensure the QX3 illuminators' states are restored upon resume,
1769 or disable the illuminator controls, if this isn't a QX3 */
1770 if (sd->params.qx3.qx3_detected)
1771 command_setlights(gspca_dev);
1772 else
1773 gspca_dev->ctrl_dis |=
1774 ((1 << ILLUMINATORS_1_IDX) | (1 << ILLUMINATORS_2_IDX));
1775
1729 sd_stopN(gspca_dev); 1776 sd_stopN(gspca_dev);
1730 1777
1731 PDEBUG(D_PROBE, "CPIA Version: %d.%02d (%d.%d)", 1778 PDEBUG(D_PROBE, "CPIA Version: %d.%02d (%d.%d)",
@@ -1929,6 +1976,72 @@ static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val)
1929 return 0; 1976 return 0;
1930} 1977}
1931 1978
1979static int sd_setilluminator(struct gspca_dev *gspca_dev, __s32 val, int n)
1980{
1981 struct sd *sd = (struct sd *) gspca_dev;
1982 int ret;
1983
1984 if (!sd->params.qx3.qx3_detected)
1985 return -EINVAL;
1986
1987 switch (n) {
1988 case 1:
1989 sd->params.qx3.bottomlight = val ? 1 : 0;
1990 break;
1991 case 2:
1992 sd->params.qx3.toplight = val ? 1 : 0;
1993 break;
1994 default:
1995 return -EINVAL;
1996 }
1997
1998 ret = command_setlights(gspca_dev);
1999 if (ret && ret != -EINVAL)
2000 ret = -EBUSY;
2001
2002 return ret;
2003}
2004
2005static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val)
2006{
2007 return sd_setilluminator(gspca_dev, val, 1);
2008}
2009
2010static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val)
2011{
2012 return sd_setilluminator(gspca_dev, val, 2);
2013}
2014
2015static int sd_getilluminator(struct gspca_dev *gspca_dev, __s32 *val, int n)
2016{
2017 struct sd *sd = (struct sd *) gspca_dev;
2018
2019 if (!sd->params.qx3.qx3_detected)
2020 return -EINVAL;
2021
2022 switch (n) {
2023 case 1:
2024 *val = sd->params.qx3.bottomlight;
2025 break;
2026 case 2:
2027 *val = sd->params.qx3.toplight;
2028 break;
2029 default:
2030 return -EINVAL;
2031 }
2032 return 0;
2033}
2034
2035static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val)
2036{
2037 return sd_getilluminator(gspca_dev, val, 1);
2038}
2039
2040static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val)
2041{
2042 return sd_getilluminator(gspca_dev, val, 2);
2043}
2044
1932static int sd_querymenu(struct gspca_dev *gspca_dev, 2045static int sd_querymenu(struct gspca_dev *gspca_dev,
1933 struct v4l2_querymenu *menu) 2046 struct v4l2_querymenu *menu)
1934{ 2047{
@@ -2004,17 +2117,11 @@ static struct usb_driver sd_driver = {
2004/* -- module insert / remove -- */ 2117/* -- module insert / remove -- */
2005static int __init sd_mod_init(void) 2118static int __init sd_mod_init(void)
2006{ 2119{
2007 int ret; 2120 return usb_register(&sd_driver);
2008 ret = usb_register(&sd_driver);
2009 if (ret < 0)
2010 return ret;
2011 PDEBUG(D_PROBE, "registered");
2012 return 0;
2013} 2121}
2014static void __exit sd_mod_exit(void) 2122static void __exit sd_mod_exit(void)
2015{ 2123{
2016 usb_deregister(&sd_driver); 2124 usb_deregister(&sd_driver);
2017 PDEBUG(D_PROBE, "deregistered");
2018} 2125}
2019 2126
2020module_init(sd_mod_init); 2127module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index ecd4d743d2bc..a594b36d6199 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -710,9 +710,9 @@ static void Et_setgainG(struct gspca_dev *gspca_dev, __u8 gain)
710} 710}
711 711
712#define BLIMIT(bright) \ 712#define BLIMIT(bright) \
713 (__u8)((bright > 0x1f)?0x1f:((bright < 4)?3:bright)) 713 (u8)((bright > 0x1f) ? 0x1f : ((bright < 4) ? 3 : bright))
714#define LIMIT(color) \ 714#define LIMIT(color) \
715 (unsigned char)((color > 0xff)?0xff:((color < 0)?0:color)) 715 (u8)((color > 0xff) ? 0xff : ((color < 0) ? 0 : color))
716 716
717static void do_autogain(struct gspca_dev *gspca_dev) 717static void do_autogain(struct gspca_dev *gspca_dev)
718{ 718{
@@ -896,18 +896,12 @@ static struct usb_driver sd_driver = {
896/* -- module insert / remove -- */ 896/* -- module insert / remove -- */
897static int __init sd_mod_init(void) 897static int __init sd_mod_init(void)
898{ 898{
899 int ret; 899 return usb_register(&sd_driver);
900 ret = usb_register(&sd_driver);
901 if (ret < 0)
902 return ret;
903 PDEBUG(D_PROBE, "registered");
904 return 0;
905} 900}
906 901
907static void __exit sd_mod_exit(void) 902static void __exit sd_mod_exit(void)
908{ 903{
909 usb_deregister(&sd_driver); 904 usb_deregister(&sd_driver);
910 PDEBUG(D_PROBE, "deregistered");
911} 905}
912 906
913module_init(sd_mod_init); 907module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 5d90e7448579..d78226455d1f 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -182,7 +182,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
182 /* Init the device */ 182 /* Init the device */
183 ret = command(gspca_dev, 0); 183 ret = command(gspca_dev, 0);
184 if (ret < 0) { 184 if (ret < 0) {
185 PDEBUG(D_STREAM, "init failed %d", ret); 185 err("init failed %d", ret);
186 return ret; 186 return ret;
187 } 187 }
188 188
@@ -194,14 +194,14 @@ static int sd_start(struct gspca_dev *gspca_dev)
194 FPIX_MAX_TRANSFER, &len, 194 FPIX_MAX_TRANSFER, &len,
195 FPIX_TIMEOUT); 195 FPIX_TIMEOUT);
196 if (ret < 0) { 196 if (ret < 0) {
197 PDEBUG(D_STREAM, "usb_bulk_msg failed %d", ret); 197 err("usb_bulk_msg failed %d", ret);
198 return ret; 198 return ret;
199 } 199 }
200 200
201 /* Request a frame, but don't read it */ 201 /* Request a frame, but don't read it */
202 ret = command(gspca_dev, 1); 202 ret = command(gspca_dev, 1);
203 if (ret < 0) { 203 if (ret < 0) {
204 PDEBUG(D_STREAM, "frame request failed %d", ret); 204 err("frame request failed %d", ret);
205 return ret; 205 return ret;
206 } 206 }
207 207
@@ -291,19 +291,12 @@ static struct usb_driver sd_driver = {
291/* -- module insert / remove -- */ 291/* -- module insert / remove -- */
292static int __init sd_mod_init(void) 292static int __init sd_mod_init(void)
293{ 293{
294 int ret; 294 return usb_register(&sd_driver);
295
296 ret = usb_register(&sd_driver);
297 if (ret < 0)
298 return ret;
299 PDEBUG(D_PROBE, "registered");
300 return 0;
301} 295}
302 296
303static void __exit sd_mod_exit(void) 297static void __exit sd_mod_exit(void)
304{ 298{
305 usb_deregister(&sd_driver); 299 usb_deregister(&sd_driver);
306 PDEBUG(D_PROBE, "deregistered");
307} 300}
308 301
309module_init(sd_mod_init); 302module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/gl860/gl860-mi2020.c b/drivers/media/video/gspca/gl860/gl860-mi2020.c
index 57782e011c9e..2edda6b7d653 100644
--- a/drivers/media/video/gspca/gl860/gl860-mi2020.c
+++ b/drivers/media/video/gspca/gl860/gl860-mi2020.c
@@ -69,15 +69,15 @@ static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 };
69static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; 69static u8 dat_multi6[] = { 0x90, 0x00, 0x05 };
70 70
71static struct validx tbl_init_at_startup[] = { 71static struct validx tbl_init_at_startup[] = {
72 {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001,0x00c1}, 72 {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1},
73 {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d}, 73 {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d},
74 {53, 0xffff}, 74 {53, 0xffff},
75 {0x0040, 0x0000}, {0x0063, 0x0006}, 75 {0x0040, 0x0000}, {0x0063, 0x0006},
76}; 76};
77 77
78static struct validx tbl_common_0B[] = { 78static struct validx tbl_common_0B[] = {
79 {0x0002, 0x0004}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a,0x000d}, 79 {0x0002, 0x0004}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a, 0x000d},
80 {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042,0x00c2}, 80 {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2},
81 {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000}, 81 {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000},
82}; 82};
83 83
diff --git a/drivers/media/video/gspca/gl860/gl860.c b/drivers/media/video/gspca/gl860/gl860.c
index e86eb8b4aedc..b05bec7321b5 100644
--- a/drivers/media/video/gspca/gl860/gl860.c
+++ b/drivers/media/video/gspca/gl860/gl860.c
@@ -540,15 +540,12 @@ static int __init sd_mod_init(void)
540 540
541 if (usb_register(&sd_driver) < 0) 541 if (usb_register(&sd_driver) < 0)
542 return -1; 542 return -1;
543 PDEBUG(D_PROBE, "driver registered");
544
545 return 0; 543 return 0;
546} 544}
547 545
548static void __exit sd_mod_exit(void) 546static void __exit sd_mod_exit(void)
549{ 547{
550 usb_deregister(&sd_driver); 548 usb_deregister(&sd_driver);
551 PDEBUG(D_PROBE, "driver deregistered");
552} 549}
553 550
554module_init(sd_mod_init); 551module_init(sd_mod_init);
@@ -588,8 +585,7 @@ int gl860_RTx(struct gspca_dev *gspca_dev,
588 } 585 }
589 586
590 if (r < 0) 587 if (r < 0)
591 PDEBUG(D_ERR, 588 err("ctrl transfer failed %4d "
592 "ctrl transfer failed %4d "
593 "[p%02x r%d v%04x i%04x len%d]", 589 "[p%02x r%d v%04x i%04x len%d]",
594 r, pref, req, val, index, len); 590 r, pref, req, val, index, len);
595 else if (len > 1 && r < len) 591 else if (len > 1 && r < len)
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 78abc1c1f9d5..8fe8fb486d62 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -148,7 +148,7 @@ static void int_irq(struct urb *urb)
148 if (ret == 0) { 148 if (ret == 0) {
149 ret = usb_submit_urb(urb, GFP_ATOMIC); 149 ret = usb_submit_urb(urb, GFP_ATOMIC);
150 if (ret < 0) 150 if (ret < 0)
151 PDEBUG(D_ERR, "Resubmit URB failed with error %i", ret); 151 err("Resubmit URB failed with error %i", ret);
152 } 152 }
153} 153}
154 154
@@ -177,8 +177,8 @@ static int gspca_input_connect(struct gspca_dev *dev)
177 177
178 err = input_register_device(input_dev); 178 err = input_register_device(input_dev);
179 if (err) { 179 if (err) {
180 PDEBUG(D_ERR, "Input device registration failed " 180 err("Input device registration failed with error %i",
181 "with error %i", err); 181 err);
182 input_dev->dev.parent = NULL; 182 input_dev->dev.parent = NULL;
183 input_free_device(input_dev); 183 input_free_device(input_dev);
184 } else { 184 } else {
@@ -328,8 +328,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
328 } 328 }
329 st = urb->iso_frame_desc[i].status; 329 st = urb->iso_frame_desc[i].status;
330 if (st) { 330 if (st) {
331 PDEBUG(D_ERR, 331 err("ISOC data error: [%d] len=%d, status=%d",
332 "ISOC data error: [%d] len=%d, status=%d",
333 i, len, st); 332 i, len, st);
334 gspca_dev->last_packet_type = DISCARD_PACKET; 333 gspca_dev->last_packet_type = DISCARD_PACKET;
335 continue; 334 continue;
@@ -347,7 +346,7 @@ resubmit:
347 /* resubmit the URB */ 346 /* resubmit the URB */
348 st = usb_submit_urb(urb, GFP_ATOMIC); 347 st = usb_submit_urb(urb, GFP_ATOMIC);
349 if (st < 0) 348 if (st < 0)
350 PDEBUG(D_ERR|D_PACK, "usb_submit_urb() ret %d", st); 349 err("usb_submit_urb() ret %d", st);
351} 350}
352 351
353/* 352/*
@@ -401,7 +400,7 @@ resubmit:
401 if (gspca_dev->cam.bulk_nurbs != 0) { 400 if (gspca_dev->cam.bulk_nurbs != 0) {
402 st = usb_submit_urb(urb, GFP_ATOMIC); 401 st = usb_submit_urb(urb, GFP_ATOMIC);
403 if (st < 0) 402 if (st < 0)
404 PDEBUG(D_ERR|D_PACK, "usb_submit_urb() ret %d", st); 403 err("usb_submit_urb() ret %d", st);
405 } 404 }
406} 405}
407 406
@@ -433,12 +432,13 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
433 /* if there are no queued buffer, discard the whole frame */ 432 /* if there are no queued buffer, discard the whole frame */
434 if (i == atomic_read(&gspca_dev->fr_q)) { 433 if (i == atomic_read(&gspca_dev->fr_q)) {
435 gspca_dev->last_packet_type = DISCARD_PACKET; 434 gspca_dev->last_packet_type = DISCARD_PACKET;
435 gspca_dev->sequence++;
436 return; 436 return;
437 } 437 }
438 j = gspca_dev->fr_queue[i]; 438 j = gspca_dev->fr_queue[i];
439 frame = &gspca_dev->frame[j]; 439 frame = &gspca_dev->frame[j];
440 frame->v4l2_buf.timestamp = ktime_to_timeval(ktime_get()); 440 frame->v4l2_buf.timestamp = ktime_to_timeval(ktime_get());
441 frame->v4l2_buf.sequence = ++gspca_dev->sequence; 441 frame->v4l2_buf.sequence = gspca_dev->sequence++;
442 gspca_dev->image = frame->data; 442 gspca_dev->image = frame->data;
443 gspca_dev->image_len = 0; 443 gspca_dev->image_len = 0;
444 } else { 444 } else {
@@ -590,7 +590,7 @@ static int gspca_set_alt0(struct gspca_dev *gspca_dev)
590 return 0; 590 return 0;
591 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0); 591 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0);
592 if (ret < 0) 592 if (ret < 0)
593 PDEBUG(D_ERR|D_STREAM, "set alt 0 err %d", ret); 593 err("set alt 0 err %d", ret);
594 return ret; 594 return ret;
595} 595}
596 596
@@ -652,7 +652,7 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev)
652 : USB_ENDPOINT_XFER_ISOC; 652 : USB_ENDPOINT_XFER_ISOC;
653 i = gspca_dev->alt; /* previous alt setting */ 653 i = gspca_dev->alt; /* previous alt setting */
654 if (gspca_dev->cam.reverse_alts) { 654 if (gspca_dev->cam.reverse_alts) {
655 if (gspca_dev->audio) 655 if (gspca_dev->audio && i < gspca_dev->nbalt - 2)
656 i++; 656 i++;
657 while (++i < gspca_dev->nbalt) { 657 while (++i < gspca_dev->nbalt) {
658 ep = alt_xfer(&intf->altsetting[i], xfer); 658 ep = alt_xfer(&intf->altsetting[i], xfer);
@@ -660,7 +660,7 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev)
660 break; 660 break;
661 } 661 }
662 } else { 662 } else {
663 if (gspca_dev->audio) 663 if (gspca_dev->audio && i > 1)
664 i--; 664 i--;
665 while (--i >= 0) { 665 while (--i >= 0) {
666 ep = alt_xfer(&intf->altsetting[i], xfer); 666 ep = alt_xfer(&intf->altsetting[i], xfer);
@@ -850,8 +850,7 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
850 break; 850 break;
851 gspca_stream_off(gspca_dev); 851 gspca_stream_off(gspca_dev);
852 if (ret != -ENOSPC) { 852 if (ret != -ENOSPC) {
853 PDEBUG(D_ERR|D_STREAM, 853 err("usb_submit_urb alt %d err %d",
854 "usb_submit_urb alt %d err %d",
855 gspca_dev->alt, ret); 854 gspca_dev->alt, ret);
856 goto out; 855 goto out;
857 } 856 }
@@ -880,6 +879,7 @@ out:
880 879
881static void gspca_set_default_mode(struct gspca_dev *gspca_dev) 880static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
882{ 881{
882 struct gspca_ctrl *ctrl;
883 int i; 883 int i;
884 884
885 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ 885 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */
@@ -887,6 +887,16 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
887 gspca_dev->width = gspca_dev->cam.cam_mode[i].width; 887 gspca_dev->width = gspca_dev->cam.cam_mode[i].width;
888 gspca_dev->height = gspca_dev->cam.cam_mode[i].height; 888 gspca_dev->height = gspca_dev->cam.cam_mode[i].height;
889 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat; 889 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat;
890
891 /* set the current control values to their default values
892 * which may have changed in sd_init() */
893 ctrl = gspca_dev->cam.ctrls;
894 if (ctrl != NULL) {
895 for (i = 0;
896 i < gspca_dev->sd_desc->nctrls;
897 i++, ctrl++)
898 ctrl->val = ctrl->def;
899 }
890} 900}
891 901
892static int wxh_to_mode(struct gspca_dev *gspca_dev, 902static int wxh_to_mode(struct gspca_dev *gspca_dev,
@@ -1310,7 +1320,7 @@ out:
1310 return ret; 1320 return ret;
1311} 1321}
1312 1322
1313static const struct ctrl *get_ctrl(struct gspca_dev *gspca_dev, 1323static int get_ctrl(struct gspca_dev *gspca_dev,
1314 int id) 1324 int id)
1315{ 1325{
1316 const struct ctrl *ctrls; 1326 const struct ctrl *ctrls;
@@ -1322,9 +1332,9 @@ static const struct ctrl *get_ctrl(struct gspca_dev *gspca_dev,
1322 if (gspca_dev->ctrl_dis & (1 << i)) 1332 if (gspca_dev->ctrl_dis & (1 << i))
1323 continue; 1333 continue;
1324 if (id == ctrls->qctrl.id) 1334 if (id == ctrls->qctrl.id)
1325 return ctrls; 1335 return i;
1326 } 1336 }
1327 return NULL; 1337 return -1;
1328} 1338}
1329 1339
1330static int vidioc_queryctrl(struct file *file, void *priv, 1340static int vidioc_queryctrl(struct file *file, void *priv,
@@ -1332,34 +1342,40 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1332{ 1342{
1333 struct gspca_dev *gspca_dev = priv; 1343 struct gspca_dev *gspca_dev = priv;
1334 const struct ctrl *ctrls; 1344 const struct ctrl *ctrls;
1335 int i; 1345 struct gspca_ctrl *gspca_ctrl;
1346 int i, idx;
1336 u32 id; 1347 u32 id;
1337 1348
1338 ctrls = NULL;
1339 id = q_ctrl->id; 1349 id = q_ctrl->id;
1340 if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { 1350 if (id & V4L2_CTRL_FLAG_NEXT_CTRL) {
1341 id &= V4L2_CTRL_ID_MASK; 1351 id &= V4L2_CTRL_ID_MASK;
1342 id++; 1352 id++;
1353 idx = -1;
1343 for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { 1354 for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
1344 if (gspca_dev->ctrl_dis & (1 << i)) 1355 if (gspca_dev->ctrl_dis & (1 << i))
1345 continue; 1356 continue;
1346 if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) 1357 if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id)
1347 continue; 1358 continue;
1348 if (ctrls && gspca_dev->sd_desc->ctrls[i].qctrl.id 1359 if (idx >= 0
1349 > ctrls->qctrl.id) 1360 && gspca_dev->sd_desc->ctrls[i].qctrl.id
1361 > gspca_dev->sd_desc->ctrls[idx].qctrl.id)
1350 continue; 1362 continue;
1351 ctrls = &gspca_dev->sd_desc->ctrls[i]; 1363 idx = i;
1352 } 1364 }
1353 if (ctrls == NULL)
1354 return -EINVAL;
1355 } else { 1365 } else {
1356 ctrls = get_ctrl(gspca_dev, id); 1366 idx = get_ctrl(gspca_dev, id);
1357 if (ctrls == NULL)
1358 return -EINVAL;
1359 i = ctrls - gspca_dev->sd_desc->ctrls;
1360 } 1367 }
1361 memcpy(q_ctrl, ctrls, sizeof *q_ctrl); 1368 if (idx < 0)
1362 if (gspca_dev->ctrl_inac & (1 << i)) 1369 return -EINVAL;
1370 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1371 memcpy(q_ctrl, &ctrls->qctrl, sizeof *q_ctrl);
1372 if (gspca_dev->cam.ctrls != NULL) {
1373 gspca_ctrl = &gspca_dev->cam.ctrls[idx];
1374 q_ctrl->default_value = gspca_ctrl->def;
1375 q_ctrl->minimum = gspca_ctrl->min;
1376 q_ctrl->maximum = gspca_ctrl->max;
1377 }
1378 if (gspca_dev->ctrl_inac & (1 << idx))
1363 q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 1379 q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
1364 return 0; 1380 return 0;
1365} 1381}
@@ -1369,23 +1385,46 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1369{ 1385{
1370 struct gspca_dev *gspca_dev = priv; 1386 struct gspca_dev *gspca_dev = priv;
1371 const struct ctrl *ctrls; 1387 const struct ctrl *ctrls;
1372 int ret; 1388 struct gspca_ctrl *gspca_ctrl;
1389 int idx, ret;
1373 1390
1374 ctrls = get_ctrl(gspca_dev, ctrl->id); 1391 idx = get_ctrl(gspca_dev, ctrl->id);
1375 if (ctrls == NULL) 1392 if (idx < 0)
1376 return -EINVAL; 1393 return -EINVAL;
1377 1394 if (gspca_dev->ctrl_inac & (1 << idx))
1378 if (ctrl->value < ctrls->qctrl.minimum 1395 return -EINVAL;
1379 || ctrl->value > ctrls->qctrl.maximum) 1396 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1380 return -ERANGE; 1397 if (gspca_dev->cam.ctrls != NULL) {
1398 gspca_ctrl = &gspca_dev->cam.ctrls[idx];
1399 if (ctrl->value < gspca_ctrl->min
1400 || ctrl->value > gspca_ctrl->max)
1401 return -ERANGE;
1402 } else {
1403 gspca_ctrl = NULL;
1404 if (ctrl->value < ctrls->qctrl.minimum
1405 || ctrl->value > ctrls->qctrl.maximum)
1406 return -ERANGE;
1407 }
1381 PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value); 1408 PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value);
1382 if (mutex_lock_interruptible(&gspca_dev->usb_lock)) 1409 if (mutex_lock_interruptible(&gspca_dev->usb_lock))
1383 return -ERESTARTSYS; 1410 return -ERESTARTSYS;
1411 if (!gspca_dev->present) {
1412 ret = -ENODEV;
1413 goto out;
1414 }
1384 gspca_dev->usb_err = 0; 1415 gspca_dev->usb_err = 0;
1385 if (gspca_dev->present) 1416 if (ctrls->set != NULL) {
1386 ret = ctrls->set(gspca_dev, ctrl->value); 1417 ret = ctrls->set(gspca_dev, ctrl->value);
1387 else 1418 goto out;
1388 ret = -ENODEV; 1419 }
1420 if (gspca_ctrl != NULL) {
1421 gspca_ctrl->val = ctrl->value;
1422 if (ctrls->set_control != NULL
1423 && gspca_dev->streaming)
1424 ctrls->set_control(gspca_dev);
1425 }
1426 ret = gspca_dev->usb_err;
1427out:
1389 mutex_unlock(&gspca_dev->usb_lock); 1428 mutex_unlock(&gspca_dev->usb_lock);
1390 return ret; 1429 return ret;
1391} 1430}
@@ -1395,19 +1434,28 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1395{ 1434{
1396 struct gspca_dev *gspca_dev = priv; 1435 struct gspca_dev *gspca_dev = priv;
1397 const struct ctrl *ctrls; 1436 const struct ctrl *ctrls;
1398 int ret; 1437 int idx, ret;
1399 1438
1400 ctrls = get_ctrl(gspca_dev, ctrl->id); 1439 idx = get_ctrl(gspca_dev, ctrl->id);
1401 if (ctrls == NULL) 1440 if (idx < 0)
1402 return -EINVAL; 1441 return -EINVAL;
1442 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1403 1443
1404 if (mutex_lock_interruptible(&gspca_dev->usb_lock)) 1444 if (mutex_lock_interruptible(&gspca_dev->usb_lock))
1405 return -ERESTARTSYS; 1445 return -ERESTARTSYS;
1446 if (!gspca_dev->present) {
1447 ret = -ENODEV;
1448 goto out;
1449 }
1406 gspca_dev->usb_err = 0; 1450 gspca_dev->usb_err = 0;
1407 if (gspca_dev->present) 1451 if (ctrls->get != NULL) {
1408 ret = ctrls->get(gspca_dev, &ctrl->value); 1452 ret = ctrls->get(gspca_dev, &ctrl->value);
1409 else 1453 goto out;
1410 ret = -ENODEV; 1454 }
1455 if (gspca_dev->cam.ctrls != NULL)
1456 ctrl->value = gspca_dev->cam.ctrls[idx].val;
1457 ret = 0;
1458out:
1411 mutex_unlock(&gspca_dev->usb_lock); 1459 mutex_unlock(&gspca_dev->usb_lock);
1412 return ret; 1460 return ret;
1413} 1461}
@@ -2127,6 +2175,22 @@ static struct video_device gspca_template = {
2127 .release = gspca_release, 2175 .release = gspca_release,
2128}; 2176};
2129 2177
2178/* initialize the controls */
2179static void ctrls_init(struct gspca_dev *gspca_dev)
2180{
2181 struct gspca_ctrl *ctrl;
2182 int i;
2183
2184 for (i = 0, ctrl = gspca_dev->cam.ctrls;
2185 i < gspca_dev->sd_desc->nctrls;
2186 i++, ctrl++) {
2187 ctrl->def = gspca_dev->sd_desc->ctrls[i].qctrl.default_value;
2188 ctrl->val = ctrl->def;
2189 ctrl->min = gspca_dev->sd_desc->ctrls[i].qctrl.minimum;
2190 ctrl->max = gspca_dev->sd_desc->ctrls[i].qctrl.maximum;
2191 }
2192}
2193
2130/* 2194/*
2131 * probe and create a new gspca device 2195 * probe and create a new gspca device
2132 * 2196 *
@@ -2188,6 +2252,8 @@ int gspca_dev_probe2(struct usb_interface *intf,
2188 ret = sd_desc->config(gspca_dev, id); 2252 ret = sd_desc->config(gspca_dev, id);
2189 if (ret < 0) 2253 if (ret < 0)
2190 goto out; 2254 goto out;
2255 if (gspca_dev->cam.ctrls != NULL)
2256 ctrls_init(gspca_dev);
2191 ret = sd_desc->init(gspca_dev); 2257 ret = sd_desc->init(gspca_dev);
2192 if (ret < 0) 2258 if (ret < 0)
2193 goto out; 2259 goto out;
@@ -2243,7 +2309,7 @@ int gspca_dev_probe(struct usb_interface *intf,
2243 2309
2244 /* we don't handle multi-config cameras */ 2310 /* we don't handle multi-config cameras */
2245 if (dev->descriptor.bNumConfigurations != 1) { 2311 if (dev->descriptor.bNumConfigurations != 1) {
2246 PDEBUG(D_ERR, "%04x:%04x too many config", 2312 err("%04x:%04x too many config",
2247 id->idVendor, id->idProduct); 2313 id->idVendor, id->idProduct);
2248 return -ENODEV; 2314 return -ENODEV;
2249 } 2315 }
@@ -2428,7 +2494,7 @@ EXPORT_SYMBOL(gspca_auto_gain_n_exposure);
2428/* -- module insert / remove -- */ 2494/* -- module insert / remove -- */
2429static int __init gspca_init(void) 2495static int __init gspca_init(void)
2430{ 2496{
2431 info("main v%d.%d.%d registered", 2497 info("v%d.%d.%d registered",
2432 (DRIVER_VERSION_NUMBER >> 16) & 0xff, 2498 (DRIVER_VERSION_NUMBER >> 16) & 0xff,
2433 (DRIVER_VERSION_NUMBER >> 8) & 0xff, 2499 (DRIVER_VERSION_NUMBER >> 8) & 0xff,
2434 DRIVER_VERSION_NUMBER & 0xff); 2500 DRIVER_VERSION_NUMBER & 0xff);
@@ -2436,7 +2502,6 @@ static int __init gspca_init(void)
2436} 2502}
2437static void __exit gspca_exit(void) 2503static void __exit gspca_exit(void)
2438{ 2504{
2439 info("main deregistered");
2440} 2505}
2441 2506
2442module_init(gspca_init); 2507module_init(gspca_init);
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index b749c36d9f7e..d4d210b56b49 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -52,11 +52,20 @@ struct framerates {
52 int nrates; 52 int nrates;
53}; 53};
54 54
55/* control definition */
56struct gspca_ctrl {
57 s16 val; /* current value */
58 s16 def; /* default value */
59 s16 min, max; /* minimum and maximum values */
60};
61
55/* device information - set at probe time */ 62/* device information - set at probe time */
56struct cam { 63struct cam {
57 const struct v4l2_pix_format *cam_mode; /* size nmodes */ 64 const struct v4l2_pix_format *cam_mode; /* size nmodes */
58 const struct framerates *mode_framerates; /* must have size nmode, 65 const struct framerates *mode_framerates; /* must have size nmode,
59 * just like cam_mode */ 66 * just like cam_mode */
67 struct gspca_ctrl *ctrls; /* control table - size nctrls */
68 /* may be NULL */
60 u32 bulk_size; /* buffer size when image transfer by bulk */ 69 u32 bulk_size; /* buffer size when image transfer by bulk */
61 u32 input_flags; /* value for ENUM_INPUT status flags */ 70 u32 input_flags; /* value for ENUM_INPUT status flags */
62 u8 nmodes; /* size of cam_mode */ 71 u8 nmodes; /* size of cam_mode */
@@ -99,6 +108,7 @@ struct ctrl {
99 struct v4l2_queryctrl qctrl; 108 struct v4l2_queryctrl qctrl;
100 int (*set)(struct gspca_dev *, __s32); 109 int (*set)(struct gspca_dev *, __s32);
101 int (*get)(struct gspca_dev *, __s32 *); 110 int (*get)(struct gspca_dev *, __s32 *);
111 cam_v_op set_control;
102}; 112};
103 113
104/* subdriver description */ 114/* subdriver description */
@@ -106,7 +116,7 @@ struct sd_desc {
106/* information */ 116/* information */
107 const char *name; /* sub-driver name */ 117 const char *name; /* sub-driver name */
108/* controls */ 118/* controls */
109 const struct ctrl *ctrls; 119 const struct ctrl *ctrls; /* static control definition */
110 int nctrls; 120 int nctrls;
111/* mandatory operations */ 121/* mandatory operations */
112 cam_cf_op config; /* called on probe */ 122 cam_cf_op config; /* called on probe */
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index 12d9cf4caba2..a35e87bb0388 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -82,7 +82,7 @@ static int jlj_write2(struct gspca_dev *gspca_dev, unsigned char *command)
82 usb_sndbulkpipe(gspca_dev->dev, 3), 82 usb_sndbulkpipe(gspca_dev->dev, 3),
83 gspca_dev->usb_buf, 2, NULL, 500); 83 gspca_dev->usb_buf, 2, NULL, 500);
84 if (retval < 0) 84 if (retval < 0)
85 PDEBUG(D_ERR, "command write [%02x] error %d", 85 err("command write [%02x] error %d",
86 gspca_dev->usb_buf[0], retval); 86 gspca_dev->usb_buf[0], retval);
87 return retval; 87 return retval;
88} 88}
@@ -97,7 +97,7 @@ static int jlj_read1(struct gspca_dev *gspca_dev, unsigned char response)
97 gspca_dev->usb_buf, 1, NULL, 500); 97 gspca_dev->usb_buf, 1, NULL, 500);
98 response = gspca_dev->usb_buf[0]; 98 response = gspca_dev->usb_buf[0];
99 if (retval < 0) 99 if (retval < 0)
100 PDEBUG(D_ERR, "read command [%02x] error %d", 100 err("read command [%02x] error %d",
101 gspca_dev->usb_buf[0], retval); 101 gspca_dev->usb_buf[0], retval);
102 return retval; 102 return retval;
103} 103}
@@ -191,7 +191,7 @@ static void jlj_dostream(struct work_struct *work)
191 191
192 buffer = kmalloc(JEILINJ_MAX_TRANSFER, GFP_KERNEL | GFP_DMA); 192 buffer = kmalloc(JEILINJ_MAX_TRANSFER, GFP_KERNEL | GFP_DMA);
193 if (!buffer) { 193 if (!buffer) {
194 PDEBUG(D_ERR, "Couldn't allocate USB buffer"); 194 err("Couldn't allocate USB buffer");
195 goto quit_stream; 195 goto quit_stream;
196 } 196 }
197 while (gspca_dev->present && gspca_dev->streaming) { 197 while (gspca_dev->present && gspca_dev->streaming) {
@@ -354,19 +354,12 @@ static struct usb_driver sd_driver = {
354/* -- module insert / remove -- */ 354/* -- module insert / remove -- */
355static int __init sd_mod_init(void) 355static int __init sd_mod_init(void)
356{ 356{
357 int ret; 357 return usb_register(&sd_driver);
358
359 ret = usb_register(&sd_driver);
360 if (ret < 0)
361 return ret;
362 PDEBUG(D_PROBE, "registered");
363 return 0;
364} 358}
365 359
366static void __exit sd_mod_exit(void) 360static void __exit sd_mod_exit(void)
367{ 361{
368 usb_deregister(&sd_driver); 362 usb_deregister(&sd_driver);
369 PDEBUG(D_PROBE, "deregistered");
370} 363}
371 364
372module_init(sd_mod_init); 365module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/konica.c b/drivers/media/video/gspca/konica.c
new file mode 100644
index 000000000000..d2ce65dcbfdc
--- /dev/null
+++ b/drivers/media/video/gspca/konica.c
@@ -0,0 +1,646 @@
1/*
2 * Driver for USB webcams based on Konica chipset. This
3 * chipset is used in Intel YC76 camera.
4 *
5 * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
6 *
7 * Based on the usbvideo v4l1 konicawc driver which is:
8 *
9 * Copyright (C) 2002 Simon Evans <spse@secret.org.uk>
10 *
11 * The code for making gspca work with a webcam with 2 isoc endpoints was
12 * taken from the benq gspca subdriver which is:
13 *
14 * Copyright (C) 2009 Jean-Francois Moine (http://moinejf.free.fr)
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */
30
31#define MODULE_NAME "konica"
32
33#include <linux/input.h>
34#include "gspca.h"
35
36MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
37MODULE_DESCRIPTION("Konica chipset USB Camera Driver");
38MODULE_LICENSE("GPL");
39
40#define WHITEBAL_REG 0x01
41#define BRIGHTNESS_REG 0x02
42#define SHARPNESS_REG 0x03
43#define CONTRAST_REG 0x04
44#define SATURATION_REG 0x05
45
46/* specific webcam descriptor */
47struct sd {
48 struct gspca_dev gspca_dev; /* !! must be the first item */
49 struct urb *last_data_urb;
50 u8 snapshot_pressed;
51 u8 brightness;
52 u8 contrast;
53 u8 saturation;
54 u8 whitebal;
55 u8 sharpness;
56};
57
58/* V4L2 controls supported by the driver */
59static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
60static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
61static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
62static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
63static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val);
64static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val);
65static int sd_setwhitebal(struct gspca_dev *gspca_dev, __s32 val);
66static int sd_getwhitebal(struct gspca_dev *gspca_dev, __s32 *val);
67static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
68static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
69
70static const struct ctrl sd_ctrls[] = {
71#define SD_BRIGHTNESS 0
72 {
73 {
74 .id = V4L2_CID_BRIGHTNESS,
75 .type = V4L2_CTRL_TYPE_INTEGER,
76 .name = "Brightness",
77 .minimum = 0,
78 .maximum = 9,
79 .step = 1,
80#define BRIGHTNESS_DEFAULT 4
81 .default_value = BRIGHTNESS_DEFAULT,
82 .flags = 0,
83 },
84 .set = sd_setbrightness,
85 .get = sd_getbrightness,
86 },
87#define SD_CONTRAST 1
88 {
89 {
90 .id = V4L2_CID_CONTRAST,
91 .type = V4L2_CTRL_TYPE_INTEGER,
92 .name = "Contrast",
93 .minimum = 0,
94 .maximum = 9,
95 .step = 4,
96#define CONTRAST_DEFAULT 10
97 .default_value = CONTRAST_DEFAULT,
98 .flags = 0,
99 },
100 .set = sd_setcontrast,
101 .get = sd_getcontrast,
102 },
103#define SD_SATURATION 2
104 {
105 {
106 .id = V4L2_CID_SATURATION,
107 .type = V4L2_CTRL_TYPE_INTEGER,
108 .name = "Saturation",
109 .minimum = 0,
110 .maximum = 9,
111 .step = 1,
112#define SATURATION_DEFAULT 4
113 .default_value = SATURATION_DEFAULT,
114 .flags = 0,
115 },
116 .set = sd_setsaturation,
117 .get = sd_getsaturation,
118 },
119#define SD_WHITEBAL 3
120 {
121 {
122 .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
123 .type = V4L2_CTRL_TYPE_INTEGER,
124 .name = "White Balance",
125 .minimum = 0,
126 .maximum = 33,
127 .step = 1,
128#define WHITEBAL_DEFAULT 25
129 .default_value = WHITEBAL_DEFAULT,
130 .flags = 0,
131 },
132 .set = sd_setwhitebal,
133 .get = sd_getwhitebal,
134 },
135#define SD_SHARPNESS 4
136 {
137 {
138 .id = V4L2_CID_SHARPNESS,
139 .type = V4L2_CTRL_TYPE_INTEGER,
140 .name = "Sharpness",
141 .minimum = 0,
142 .maximum = 9,
143 .step = 1,
144#define SHARPNESS_DEFAULT 4
145 .default_value = SHARPNESS_DEFAULT,
146 .flags = 0,
147 },
148 .set = sd_setsharpness,
149 .get = sd_getsharpness,
150 },
151};
152
153/* .priv is what goes to register 8 for this mode, known working values:
154 0x00 -> 176x144, cropped
155 0x01 -> 176x144, cropped
156 0x02 -> 176x144, cropped
157 0x03 -> 176x144, cropped
158 0x04 -> 176x144, binned
159 0x05 -> 320x240
160 0x06 -> 320x240
161 0x07 -> 160x120, cropped
162 0x08 -> 160x120, cropped
163 0x09 -> 160x120, binned (note has 136 lines)
164 0x0a -> 160x120, binned (note has 136 lines)
165 0x0b -> 160x120, cropped
166*/
167static const struct v4l2_pix_format vga_mode[] = {
168 {160, 120, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
169 .bytesperline = 160,
170 .sizeimage = 160 * 136 * 3 / 2 + 960,
171 .colorspace = V4L2_COLORSPACE_SRGB,
172 .priv = 0x0a},
173 {176, 144, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
174 .bytesperline = 176,
175 .sizeimage = 176 * 144 * 3 / 2 + 960,
176 .colorspace = V4L2_COLORSPACE_SRGB,
177 .priv = 0x04},
178 {320, 240, V4L2_PIX_FMT_KONICA420, V4L2_FIELD_NONE,
179 .bytesperline = 320,
180 .sizeimage = 320 * 240 * 3 / 2 + 960,
181 .colorspace = V4L2_COLORSPACE_SRGB,
182 .priv = 0x05},
183};
184
185static void sd_isoc_irq(struct urb *urb);
186
187static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
188{
189 struct usb_device *dev = gspca_dev->dev;
190 int ret;
191
192 if (gspca_dev->usb_err < 0)
193 return;
194 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
195 0x02,
196 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
197 value,
198 index,
199 NULL,
200 0,
201 1000);
202 if (ret < 0) {
203 err("reg_w err %d", ret);
204 gspca_dev->usb_err = ret;
205 }
206}
207
208static void reg_r(struct gspca_dev *gspca_dev, u16 value, u16 index)
209{
210 struct usb_device *dev = gspca_dev->dev;
211 int ret;
212
213 if (gspca_dev->usb_err < 0)
214 return;
215 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
216 0x03,
217 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
218 value,
219 index,
220 gspca_dev->usb_buf,
221 2,
222 1000);
223 if (ret < 0) {
224 err("reg_w err %d", ret);
225 gspca_dev->usb_err = ret;
226 }
227}
228
229static void konica_stream_on(struct gspca_dev *gspca_dev)
230{
231 reg_w(gspca_dev, 1, 0x0b);
232}
233
234static void konica_stream_off(struct gspca_dev *gspca_dev)
235{
236 reg_w(gspca_dev, 0, 0x0b);
237}
238
239/* this function is called at probe time */
240static int sd_config(struct gspca_dev *gspca_dev,
241 const struct usb_device_id *id)
242{
243 struct sd *sd = (struct sd *) gspca_dev;
244
245 gspca_dev->cam.cam_mode = vga_mode;
246 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode);
247 gspca_dev->cam.no_urb_create = 1;
248 /* The highest alt setting has an isoc packetsize of 0, so we
249 don't want to use it */
250 gspca_dev->nbalt--;
251
252 sd->brightness = BRIGHTNESS_DEFAULT;
253 sd->contrast = CONTRAST_DEFAULT;
254 sd->saturation = SATURATION_DEFAULT;
255 sd->whitebal = WHITEBAL_DEFAULT;
256 sd->sharpness = SHARPNESS_DEFAULT;
257
258 return 0;
259}
260
261/* this function is called at probe and resume time */
262static int sd_init(struct gspca_dev *gspca_dev)
263{
264 /* HDG not sure if these 2 reads are needed */
265 reg_r(gspca_dev, 0, 0x10);
266 PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x",
267 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
268 reg_r(gspca_dev, 0, 0x10);
269 PDEBUG(D_PROBE, "Reg 0x10 reads: %02x %02x",
270 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
271 reg_w(gspca_dev, 0, 0x0d);
272
273 return 0;
274}
275
276static int sd_start(struct gspca_dev *gspca_dev)
277{
278 struct sd *sd = (struct sd *) gspca_dev;
279 struct urb *urb;
280 int i, n, packet_size;
281 struct usb_host_interface *alt;
282 struct usb_interface *intf;
283
284 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
285 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
286 if (!alt) {
287 err("Couldn't get altsetting");
288 return -EIO;
289 }
290
291 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
292
293 reg_w(gspca_dev, sd->brightness, BRIGHTNESS_REG);
294 reg_w(gspca_dev, sd->whitebal, WHITEBAL_REG);
295 reg_w(gspca_dev, sd->contrast, CONTRAST_REG);
296 reg_w(gspca_dev, sd->saturation, SATURATION_REG);
297 reg_w(gspca_dev, sd->sharpness, SHARPNESS_REG);
298
299 n = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
300 reg_w(gspca_dev, n, 0x08);
301
302 konica_stream_on(gspca_dev);
303
304 if (gspca_dev->usb_err)
305 return gspca_dev->usb_err;
306
307 /* create 4 URBs - 2 on endpoint 0x83 and 2 on 0x082 */
308#if MAX_NURBS < 4
309#error "Not enough URBs in the gspca table"
310#endif
311#define SD_NPKT 32
312 for (n = 0; n < 4; n++) {
313 i = n & 1 ? 0 : 1;
314 packet_size =
315 le16_to_cpu(alt->endpoint[i].desc.wMaxPacketSize);
316 urb = usb_alloc_urb(SD_NPKT, GFP_KERNEL);
317 if (!urb) {
318 err("usb_alloc_urb failed");
319 return -ENOMEM;
320 }
321 gspca_dev->urb[n] = urb;
322 urb->transfer_buffer = usb_alloc_coherent(gspca_dev->dev,
323 packet_size * SD_NPKT,
324 GFP_KERNEL,
325 &urb->transfer_dma);
326 if (urb->transfer_buffer == NULL) {
327 err("usb_buffer_alloc failed");
328 return -ENOMEM;
329 }
330
331 urb->dev = gspca_dev->dev;
332 urb->context = gspca_dev;
333 urb->transfer_buffer_length = packet_size * SD_NPKT;
334 urb->pipe = usb_rcvisocpipe(gspca_dev->dev,
335 n & 1 ? 0x81 : 0x82);
336 urb->transfer_flags = URB_ISO_ASAP
337 | URB_NO_TRANSFER_DMA_MAP;
338 urb->interval = 1;
339 urb->complete = sd_isoc_irq;
340 urb->number_of_packets = SD_NPKT;
341 for (i = 0; i < SD_NPKT; i++) {
342 urb->iso_frame_desc[i].length = packet_size;
343 urb->iso_frame_desc[i].offset = packet_size * i;
344 }
345 }
346
347 return 0;
348}
349
350static void sd_stopN(struct gspca_dev *gspca_dev)
351{
352 struct sd *sd = (struct sd *) gspca_dev;
353
354 konica_stream_off(gspca_dev);
355#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
356 /* Don't keep the button in the pressed state "forever" if it was
357 pressed when streaming is stopped */
358 if (sd->snapshot_pressed) {
359 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
360 input_sync(gspca_dev->input_dev);
361 sd->snapshot_pressed = 0;
362 }
363#endif
364}
365
366/* reception of an URB */
367static void sd_isoc_irq(struct urb *urb)
368{
369 struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;
370 struct sd *sd = (struct sd *) gspca_dev;
371 struct urb *data_urb, *status_urb;
372 u8 *data;
373 int i, st;
374
375 PDEBUG(D_PACK, "sd isoc irq");
376 if (!gspca_dev->streaming)
377 return;
378
379 if (urb->status != 0) {
380 if (urb->status == -ESHUTDOWN)
381 return; /* disconnection */
382#ifdef CONFIG_PM
383 if (gspca_dev->frozen)
384 return;
385#endif
386 PDEBUG(D_ERR, "urb status: %d", urb->status);
387 st = usb_submit_urb(urb, GFP_ATOMIC);
388 if (st < 0)
389 err("resubmit urb error %d", st);
390 return;
391 }
392
393 /* if this is a data URB (ep 0x82), wait */
394 if (urb->transfer_buffer_length > 32) {
395 sd->last_data_urb = urb;
396 return;
397 }
398
399 status_urb = urb;
400 data_urb = sd->last_data_urb;
401 sd->last_data_urb = NULL;
402
403 if (!data_urb || data_urb->start_frame != status_urb->start_frame) {
404 PDEBUG(D_ERR|D_PACK, "lost sync on frames");
405 goto resubmit;
406 }
407
408 if (data_urb->number_of_packets != status_urb->number_of_packets) {
409 PDEBUG(D_ERR|D_PACK,
410 "no packets does not match, data: %d, status: %d",
411 data_urb->number_of_packets,
412 status_urb->number_of_packets);
413 goto resubmit;
414 }
415
416 for (i = 0; i < status_urb->number_of_packets; i++) {
417 if (data_urb->iso_frame_desc[i].status ||
418 status_urb->iso_frame_desc[i].status) {
419 PDEBUG(D_ERR|D_PACK,
420 "pkt %d data-status %d, status-status %d", i,
421 data_urb->iso_frame_desc[i].status,
422 status_urb->iso_frame_desc[i].status);
423 gspca_dev->last_packet_type = DISCARD_PACKET;
424 continue;
425 }
426
427 if (status_urb->iso_frame_desc[i].actual_length != 1) {
428 PDEBUG(D_ERR|D_PACK,
429 "bad status packet length %d",
430 status_urb->iso_frame_desc[i].actual_length);
431 gspca_dev->last_packet_type = DISCARD_PACKET;
432 continue;
433 }
434
435 st = *((u8 *)status_urb->transfer_buffer
436 + status_urb->iso_frame_desc[i].offset);
437
438 data = (u8 *)data_urb->transfer_buffer
439 + data_urb->iso_frame_desc[i].offset;
440
441 /* st: 0x80-0xff: frame start with frame number (ie 0-7f)
442 * otherwise:
443 * bit 0 0: keep packet
444 * 1: drop packet (padding data)
445 *
446 * bit 4 0 button not clicked
447 * 1 button clicked
448 * button is used to `take a picture' (in software)
449 */
450 if (st & 0x80) {
451 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
452 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
453 } else {
454#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
455 u8 button_state = st & 0x40 ? 1 : 0;
456 if (sd->snapshot_pressed != button_state) {
457 input_report_key(gspca_dev->input_dev,
458 KEY_CAMERA,
459 button_state);
460 input_sync(gspca_dev->input_dev);
461 sd->snapshot_pressed = button_state;
462 }
463#endif
464 if (st & 0x01)
465 continue;
466 }
467 gspca_frame_add(gspca_dev, INTER_PACKET, data,
468 data_urb->iso_frame_desc[i].actual_length);
469 }
470
471resubmit:
472 if (data_urb) {
473 st = usb_submit_urb(data_urb, GFP_ATOMIC);
474 if (st < 0)
475 PDEBUG(D_ERR|D_PACK,
476 "usb_submit_urb(data_urb) ret %d", st);
477 }
478 st = usb_submit_urb(status_urb, GFP_ATOMIC);
479 if (st < 0)
480 err("usb_submit_urb(status_urb) ret %d", st);
481}
482
483static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
484{
485 struct sd *sd = (struct sd *) gspca_dev;
486
487 sd->brightness = val;
488 if (gspca_dev->streaming) {
489 konica_stream_off(gspca_dev);
490 reg_w(gspca_dev, sd->brightness, BRIGHTNESS_REG);
491 konica_stream_on(gspca_dev);
492 }
493
494 return 0;
495}
496
497static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
498{
499 struct sd *sd = (struct sd *) gspca_dev;
500
501 *val = sd->brightness;
502
503 return 0;
504}
505
506static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
507{
508 struct sd *sd = (struct sd *) gspca_dev;
509
510 sd->contrast = val;
511 if (gspca_dev->streaming) {
512 konica_stream_off(gspca_dev);
513 reg_w(gspca_dev, sd->contrast, CONTRAST_REG);
514 konica_stream_on(gspca_dev);
515 }
516
517 return 0;
518}
519
520static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
521{
522 struct sd *sd = (struct sd *) gspca_dev;
523
524 *val = sd->contrast;
525
526 return 0;
527}
528
529static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val)
530{
531 struct sd *sd = (struct sd *) gspca_dev;
532
533 sd->saturation = val;
534 if (gspca_dev->streaming) {
535 konica_stream_off(gspca_dev);
536 reg_w(gspca_dev, sd->saturation, SATURATION_REG);
537 konica_stream_on(gspca_dev);
538 }
539 return 0;
540}
541
542static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val)
543{
544 struct sd *sd = (struct sd *) gspca_dev;
545
546 *val = sd->saturation;
547
548 return 0;
549}
550
551static int sd_setwhitebal(struct gspca_dev *gspca_dev, __s32 val)
552{
553 struct sd *sd = (struct sd *) gspca_dev;
554
555 sd->whitebal = val;
556 if (gspca_dev->streaming) {
557 konica_stream_off(gspca_dev);
558 reg_w(gspca_dev, sd->whitebal, WHITEBAL_REG);
559 konica_stream_on(gspca_dev);
560 }
561 return 0;
562}
563
564static int sd_getwhitebal(struct gspca_dev *gspca_dev, __s32 *val)
565{
566 struct sd *sd = (struct sd *) gspca_dev;
567
568 *val = sd->whitebal;
569
570 return 0;
571}
572
573static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
574{
575 struct sd *sd = (struct sd *) gspca_dev;
576
577 sd->sharpness = val;
578 if (gspca_dev->streaming) {
579 konica_stream_off(gspca_dev);
580 reg_w(gspca_dev, sd->sharpness, SHARPNESS_REG);
581 konica_stream_on(gspca_dev);
582 }
583 return 0;
584}
585
586static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
587{
588 struct sd *sd = (struct sd *) gspca_dev;
589
590 *val = sd->sharpness;
591
592 return 0;
593}
594
595/* sub-driver description */
596static const struct sd_desc sd_desc = {
597 .name = MODULE_NAME,
598 .ctrls = sd_ctrls,
599 .nctrls = ARRAY_SIZE(sd_ctrls),
600 .config = sd_config,
601 .init = sd_init,
602 .start = sd_start,
603 .stopN = sd_stopN,
604#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
605 .other_input = 1,
606#endif
607};
608
609/* -- module initialisation -- */
610static const __devinitdata struct usb_device_id device_table[] = {
611 {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */
612 {}
613};
614MODULE_DEVICE_TABLE(usb, device_table);
615
616/* -- device connect -- */
617static int sd_probe(struct usb_interface *intf,
618 const struct usb_device_id *id)
619{
620 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
621 THIS_MODULE);
622}
623
624static struct usb_driver sd_driver = {
625 .name = MODULE_NAME,
626 .id_table = device_table,
627 .probe = sd_probe,
628 .disconnect = gspca_disconnect,
629#ifdef CONFIG_PM
630 .suspend = gspca_suspend,
631 .resume = gspca_resume,
632#endif
633};
634
635/* -- module insert / remove -- */
636static int __init sd_mod_init(void)
637{
638 return usb_register(&sd_driver);
639}
640static void __exit sd_mod_exit(void)
641{
642 usb_deregister(&sd_driver);
643}
644
645module_init(sd_mod_init);
646module_exit(sd_mod_exit);
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index b073d66acd04..c872b93a3351 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -406,18 +406,12 @@ static struct usb_driver sd_driver = {
406/* -- module insert / remove -- */ 406/* -- module insert / remove -- */
407static int __init mod_m5602_init(void) 407static int __init mod_m5602_init(void)
408{ 408{
409 int ret; 409 return usb_register(&sd_driver);
410 ret = usb_register(&sd_driver);
411 if (ret < 0)
412 return ret;
413 PDEBUG(D_PROBE, "registered");
414 return 0;
415} 410}
416 411
417static void __exit mod_m5602_exit(void) 412static void __exit mod_m5602_exit(void)
418{ 413{
419 usb_deregister(&sd_driver); 414 usb_deregister(&sd_driver);
420 PDEBUG(D_PROBE, "deregistered");
421} 415}
422 416
423module_init(mod_m5602_init); 417module_init(mod_m5602_init);
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index c0722fa64606..0d605a52b924 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -109,14 +109,14 @@ static const struct ctrl mt9m111_ctrls[] = {
109#define GREEN_BALANCE_IDX 4 109#define GREEN_BALANCE_IDX 4
110 { 110 {
111 { 111 {
112 .id = M5602_V4L2_CID_GREEN_BALANCE, 112 .id = M5602_V4L2_CID_GREEN_BALANCE,
113 .type = V4L2_CTRL_TYPE_INTEGER, 113 .type = V4L2_CTRL_TYPE_INTEGER,
114 .name = "green balance", 114 .name = "green balance",
115 .minimum = 0x00, 115 .minimum = 0x00,
116 .maximum = 0x7ff, 116 .maximum = 0x7ff,
117 .step = 0x1, 117 .step = 0x1,
118 .default_value = MT9M111_GREEN_GAIN_DEFAULT, 118 .default_value = MT9M111_GREEN_GAIN_DEFAULT,
119 .flags = V4L2_CTRL_FLAG_SLIDER 119 .flags = V4L2_CTRL_FLAG_SLIDER
120 }, 120 },
121 .set = mt9m111_set_green_balance, 121 .set = mt9m111_set_green_balance,
122 .get = mt9m111_get_green_balance 122 .get = mt9m111_get_green_balance
@@ -124,14 +124,14 @@ static const struct ctrl mt9m111_ctrls[] = {
124#define BLUE_BALANCE_IDX 5 124#define BLUE_BALANCE_IDX 5
125 { 125 {
126 { 126 {
127 .id = V4L2_CID_BLUE_BALANCE, 127 .id = V4L2_CID_BLUE_BALANCE,
128 .type = V4L2_CTRL_TYPE_INTEGER, 128 .type = V4L2_CTRL_TYPE_INTEGER,
129 .name = "blue balance", 129 .name = "blue balance",
130 .minimum = 0x00, 130 .minimum = 0x00,
131 .maximum = 0x7ff, 131 .maximum = 0x7ff,
132 .step = 0x1, 132 .step = 0x1,
133 .default_value = MT9M111_BLUE_GAIN_DEFAULT, 133 .default_value = MT9M111_BLUE_GAIN_DEFAULT,
134 .flags = V4L2_CTRL_FLAG_SLIDER 134 .flags = V4L2_CTRL_FLAG_SLIDER
135 }, 135 },
136 .set = mt9m111_set_blue_balance, 136 .set = mt9m111_set_blue_balance,
137 .get = mt9m111_get_blue_balance 137 .get = mt9m111_get_blue_balance
@@ -139,14 +139,14 @@ static const struct ctrl mt9m111_ctrls[] = {
139#define RED_BALANCE_IDX 5 139#define RED_BALANCE_IDX 5
140 { 140 {
141 { 141 {
142 .id = V4L2_CID_RED_BALANCE, 142 .id = V4L2_CID_RED_BALANCE,
143 .type = V4L2_CTRL_TYPE_INTEGER, 143 .type = V4L2_CTRL_TYPE_INTEGER,
144 .name = "red balance", 144 .name = "red balance",
145 .minimum = 0x00, 145 .minimum = 0x00,
146 .maximum = 0x7ff, 146 .maximum = 0x7ff,
147 .step = 0x1, 147 .step = 0x1,
148 .default_value = MT9M111_RED_GAIN_DEFAULT, 148 .default_value = MT9M111_RED_GAIN_DEFAULT,
149 .flags = V4L2_CTRL_FLAG_SLIDER 149 .flags = V4L2_CTRL_FLAG_SLIDER
150 }, 150 },
151 .set = mt9m111_set_red_balance, 151 .set = mt9m111_set_red_balance,
152 .get = mt9m111_get_red_balance 152 .get = mt9m111_get_red_balance
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
index b3de77823091..b1f0c492036a 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
@@ -70,7 +70,7 @@
70#define MT9M111_COLORPIPE 0x01 70#define MT9M111_COLORPIPE 0x01
71#define MT9M111_CAMERA_CONTROL 0x02 71#define MT9M111_CAMERA_CONTROL 0x02
72 72
73#define MT9M111_RESET (1 << 0) 73#define MT9M111_RESET (1 << 0)
74#define MT9M111_RESTART (1 << 1) 74#define MT9M111_RESTART (1 << 1)
75#define MT9M111_ANALOG_STANDBY (1 << 2) 75#define MT9M111_ANALOG_STANDBY (1 << 2)
76#define MT9M111_CHIP_ENABLE (1 << 3) 76#define MT9M111_CHIP_ENABLE (1 << 3)
@@ -97,7 +97,7 @@
97#define MT9M111_2D_DEFECT_CORRECTION_ENABLE (1 << 0) 97#define MT9M111_2D_DEFECT_CORRECTION_ENABLE (1 << 0)
98 98
99#define INITIAL_MAX_GAIN 64 99#define INITIAL_MAX_GAIN 64
100#define MT9M111_DEFAULT_GAIN 283 100#define MT9M111_DEFAULT_GAIN 283
101#define MT9M111_GREEN_GAIN_DEFAULT 0x20 101#define MT9M111_GREEN_GAIN_DEFAULT 0x20
102#define MT9M111_BLUE_GAIN_DEFAULT 0x20 102#define MT9M111_BLUE_GAIN_DEFAULT 0x20
103#define MT9M111_RED_GAIN_DEFAULT 0x20 103#define MT9M111_RED_GAIN_DEFAULT 0x20
@@ -125,8 +125,7 @@ static const struct m5602_sensor mt9m111 = {
125 .start = mt9m111_start, 125 .start = mt9m111_start,
126}; 126};
127 127
128static const unsigned char preinit_mt9m111[][4] = 128static const unsigned char preinit_mt9m111[][4] = {
129{
130 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00}, 129 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
131 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00}, 130 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
132 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 131 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
@@ -165,8 +164,7 @@ static const unsigned char preinit_mt9m111[][4] =
165 {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00} 164 {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a, 0x00}
166}; 165};
167 166
168static const unsigned char init_mt9m111[][4] = 167static const unsigned char init_mt9m111[][4] = {
169{
170 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00}, 168 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
171 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00}, 169 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
172 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 170 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
@@ -257,8 +255,7 @@ static const unsigned char init_mt9m111[][4] =
257 {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0x90}, 255 {SENSOR, MT9M111_SC_SHUTTER_WIDTH, 0x01, 0x90},
258}; 256};
259 257
260static const unsigned char start_mt9m111[][4] = 258static const unsigned char start_mt9m111[][4] = {
261{
262 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00}, 259 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
263 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, 260 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
264 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00}, 261 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -271,5 +268,4 @@ static const unsigned char start_mt9m111[][4] =
271 {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, 268 {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
272 {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00}, 269 {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
273}; 270};
274
275#endif 271#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.c b/drivers/media/video/gspca/m5602/m5602_ov7660.c
index 62c1cbf06666..b12f60464b3b 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov7660.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.c
@@ -54,13 +54,13 @@ static const struct ctrl ov7660_ctrls[] = {
54#define AUTO_WHITE_BALANCE_IDX 4 54#define AUTO_WHITE_BALANCE_IDX 4
55 { 55 {
56 { 56 {
57 .id = V4L2_CID_AUTO_WHITE_BALANCE, 57 .id = V4L2_CID_AUTO_WHITE_BALANCE,
58 .type = V4L2_CTRL_TYPE_BOOLEAN, 58 .type = V4L2_CTRL_TYPE_BOOLEAN,
59 .name = "auto white balance", 59 .name = "auto white balance",
60 .minimum = 0, 60 .minimum = 0,
61 .maximum = 1, 61 .maximum = 1,
62 .step = 1, 62 .step = 1,
63 .default_value = 1 63 .default_value = 1
64 }, 64 },
65 .set = ov7660_set_auto_white_balance, 65 .set = ov7660_set_auto_white_balance,
66 .get = ov7660_get_auto_white_balance 66 .get = ov7660_get_auto_white_balance
@@ -68,13 +68,13 @@ static const struct ctrl ov7660_ctrls[] = {
68#define AUTO_GAIN_CTRL_IDX 5 68#define AUTO_GAIN_CTRL_IDX 5
69 { 69 {
70 { 70 {
71 .id = V4L2_CID_AUTOGAIN, 71 .id = V4L2_CID_AUTOGAIN,
72 .type = V4L2_CTRL_TYPE_BOOLEAN, 72 .type = V4L2_CTRL_TYPE_BOOLEAN,
73 .name = "auto gain control", 73 .name = "auto gain control",
74 .minimum = 0, 74 .minimum = 0,
75 .maximum = 1, 75 .maximum = 1,
76 .step = 1, 76 .step = 1,
77 .default_value = 1 77 .default_value = 1
78 }, 78 },
79 .set = ov7660_set_auto_gain, 79 .set = ov7660_set_auto_gain,
80 .get = ov7660_get_auto_gain 80 .get = ov7660_get_auto_gain
@@ -82,13 +82,13 @@ static const struct ctrl ov7660_ctrls[] = {
82#define AUTO_EXPOSURE_IDX 6 82#define AUTO_EXPOSURE_IDX 6
83 { 83 {
84 { 84 {
85 .id = V4L2_CID_EXPOSURE_AUTO, 85 .id = V4L2_CID_EXPOSURE_AUTO,
86 .type = V4L2_CTRL_TYPE_BOOLEAN, 86 .type = V4L2_CTRL_TYPE_BOOLEAN,
87 .name = "auto exposure", 87 .name = "auto exposure",
88 .minimum = 0, 88 .minimum = 0,
89 .maximum = 1, 89 .maximum = 1,
90 .step = 1, 90 .step = 1,
91 .default_value = 1 91 .default_value = 1
92 }, 92 },
93 .set = ov7660_set_auto_exposure, 93 .set = ov7660_set_auto_exposure,
94 .get = ov7660_get_auto_exposure 94 .get = ov7660_get_auto_exposure
@@ -96,13 +96,13 @@ static const struct ctrl ov7660_ctrls[] = {
96#define HFLIP_IDX 7 96#define HFLIP_IDX 7
97 { 97 {
98 { 98 {
99 .id = V4L2_CID_HFLIP, 99 .id = V4L2_CID_HFLIP,
100 .type = V4L2_CTRL_TYPE_BOOLEAN, 100 .type = V4L2_CTRL_TYPE_BOOLEAN,
101 .name = "horizontal flip", 101 .name = "horizontal flip",
102 .minimum = 0, 102 .minimum = 0,
103 .maximum = 1, 103 .maximum = 1,
104 .step = 1, 104 .step = 1,
105 .default_value = 0 105 .default_value = 0
106 }, 106 },
107 .set = ov7660_set_hflip, 107 .set = ov7660_set_hflip,
108 .get = ov7660_get_hflip 108 .get = ov7660_get_hflip
@@ -110,13 +110,13 @@ static const struct ctrl ov7660_ctrls[] = {
110#define VFLIP_IDX 8 110#define VFLIP_IDX 8
111 { 111 {
112 { 112 {
113 .id = V4L2_CID_VFLIP, 113 .id = V4L2_CID_VFLIP,
114 .type = V4L2_CTRL_TYPE_BOOLEAN, 114 .type = V4L2_CTRL_TYPE_BOOLEAN,
115 .name = "vertical flip", 115 .name = "vertical flip",
116 .minimum = 0, 116 .minimum = 0,
117 .maximum = 1, 117 .maximum = 1,
118 .step = 1, 118 .step = 1,
119 .default_value = 0 119 .default_value = 0
120 }, 120 },
121 .set = ov7660_set_vflip, 121 .set = ov7660_set_vflip,
122 .get = ov7660_get_vflip 122 .get = ov7660_get_vflip
diff --git a/drivers/media/video/gspca/m5602/m5602_ov7660.h b/drivers/media/video/gspca/m5602/m5602_ov7660.h
index 4d9dcf29da2e..2efd607987ec 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov7660.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov7660.h
@@ -80,7 +80,7 @@
80 80
81#define OV7660_DEFAULT_GAIN 0x0e 81#define OV7660_DEFAULT_GAIN 0x0e
82#define OV7660_DEFAULT_RED_GAIN 0x80 82#define OV7660_DEFAULT_RED_GAIN 0x80
83#define OV7660_DEFAULT_BLUE_GAIN 0x80 83#define OV7660_DEFAULT_BLUE_GAIN 0x80
84#define OV7660_DEFAULT_SATURATION 0x00 84#define OV7660_DEFAULT_SATURATION 0x00
85#define OV7660_DEFAULT_EXPOSURE 0x20 85#define OV7660_DEFAULT_EXPOSURE 0x20
86 86
@@ -105,8 +105,7 @@ static const struct m5602_sensor ov7660 = {
105 .disconnect = ov7660_disconnect, 105 .disconnect = ov7660_disconnect,
106}; 106};
107 107
108static const unsigned char preinit_ov7660[][4] = 108static const unsigned char preinit_ov7660[][4] = {
109{
110 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 109 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
111 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 110 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
112 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, 111 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
@@ -140,8 +139,7 @@ static const unsigned char preinit_ov7660[][4] =
140 {BRIDGE, M5602_XB_GPIO_EN_L, 0x00} 139 {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}
141}; 140};
142 141
143static const unsigned char init_ov7660[][4] = 142static const unsigned char init_ov7660[][4] = {
144{
145 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 143 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
146 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 144 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
147 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, 145 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
@@ -259,5 +257,4 @@ static const unsigned char init_ov7660[][4] =
259 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, 257 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
260 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0}, 258 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
261}; 259};
262
263#endif 260#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index 069ba0044f8b..8ded8b100576 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -121,8 +121,8 @@ static const struct ctrl ov9650_ctrls[] = {
121 .minimum = 0x00, 121 .minimum = 0x00,
122 .maximum = 0x1ff, 122 .maximum = 0x1ff,
123 .step = 0x4, 123 .step = 0x4,
124 .default_value = EXPOSURE_DEFAULT, 124 .default_value = EXPOSURE_DEFAULT,
125 .flags = V4L2_CTRL_FLAG_SLIDER 125 .flags = V4L2_CTRL_FLAG_SLIDER
126 }, 126 },
127 .set = ov9650_set_exposure, 127 .set = ov9650_set_exposure,
128 .get = ov9650_get_exposure 128 .get = ov9650_get_exposure
@@ -146,13 +146,13 @@ static const struct ctrl ov9650_ctrls[] = {
146 { 146 {
147 { 147 {
148 .id = V4L2_CID_RED_BALANCE, 148 .id = V4L2_CID_RED_BALANCE,
149 .type = V4L2_CTRL_TYPE_INTEGER, 149 .type = V4L2_CTRL_TYPE_INTEGER,
150 .name = "red balance", 150 .name = "red balance",
151 .minimum = 0x00, 151 .minimum = 0x00,
152 .maximum = 0xff, 152 .maximum = 0xff,
153 .step = 0x1, 153 .step = 0x1,
154 .default_value = RED_GAIN_DEFAULT, 154 .default_value = RED_GAIN_DEFAULT,
155 .flags = V4L2_CTRL_FLAG_SLIDER 155 .flags = V4L2_CTRL_FLAG_SLIDER
156 }, 156 },
157 .set = ov9650_set_red_balance, 157 .set = ov9650_set_red_balance,
158 .get = ov9650_get_red_balance 158 .get = ov9650_get_red_balance
@@ -161,13 +161,13 @@ static const struct ctrl ov9650_ctrls[] = {
161 { 161 {
162 { 162 {
163 .id = V4L2_CID_BLUE_BALANCE, 163 .id = V4L2_CID_BLUE_BALANCE,
164 .type = V4L2_CTRL_TYPE_INTEGER, 164 .type = V4L2_CTRL_TYPE_INTEGER,
165 .name = "blue balance", 165 .name = "blue balance",
166 .minimum = 0x00, 166 .minimum = 0x00,
167 .maximum = 0xff, 167 .maximum = 0xff,
168 .step = 0x1, 168 .step = 0x1,
169 .default_value = BLUE_GAIN_DEFAULT, 169 .default_value = BLUE_GAIN_DEFAULT,
170 .flags = V4L2_CTRL_FLAG_SLIDER 170 .flags = V4L2_CTRL_FLAG_SLIDER
171 }, 171 },
172 .set = ov9650_set_blue_balance, 172 .set = ov9650_set_blue_balance,
173 .get = ov9650_get_blue_balance 173 .get = ov9650_get_blue_balance
@@ -175,13 +175,13 @@ static const struct ctrl ov9650_ctrls[] = {
175#define HFLIP_IDX 4 175#define HFLIP_IDX 4
176 { 176 {
177 { 177 {
178 .id = V4L2_CID_HFLIP, 178 .id = V4L2_CID_HFLIP,
179 .type = V4L2_CTRL_TYPE_BOOLEAN, 179 .type = V4L2_CTRL_TYPE_BOOLEAN,
180 .name = "horizontal flip", 180 .name = "horizontal flip",
181 .minimum = 0, 181 .minimum = 0,
182 .maximum = 1, 182 .maximum = 1,
183 .step = 1, 183 .step = 1,
184 .default_value = 0 184 .default_value = 0
185 }, 185 },
186 .set = ov9650_set_hflip, 186 .set = ov9650_set_hflip,
187 .get = ov9650_get_hflip 187 .get = ov9650_get_hflip
@@ -189,13 +189,13 @@ static const struct ctrl ov9650_ctrls[] = {
189#define VFLIP_IDX 5 189#define VFLIP_IDX 5
190 { 190 {
191 { 191 {
192 .id = V4L2_CID_VFLIP, 192 .id = V4L2_CID_VFLIP,
193 .type = V4L2_CTRL_TYPE_BOOLEAN, 193 .type = V4L2_CTRL_TYPE_BOOLEAN,
194 .name = "vertical flip", 194 .name = "vertical flip",
195 .minimum = 0, 195 .minimum = 0,
196 .maximum = 1, 196 .maximum = 1,
197 .step = 1, 197 .step = 1,
198 .default_value = 0 198 .default_value = 0
199 }, 199 },
200 .set = ov9650_set_vflip, 200 .set = ov9650_set_vflip,
201 .get = ov9650_get_vflip 201 .get = ov9650_get_vflip
@@ -203,13 +203,13 @@ static const struct ctrl ov9650_ctrls[] = {
203#define AUTO_WHITE_BALANCE_IDX 6 203#define AUTO_WHITE_BALANCE_IDX 6
204 { 204 {
205 { 205 {
206 .id = V4L2_CID_AUTO_WHITE_BALANCE, 206 .id = V4L2_CID_AUTO_WHITE_BALANCE,
207 .type = V4L2_CTRL_TYPE_BOOLEAN, 207 .type = V4L2_CTRL_TYPE_BOOLEAN,
208 .name = "auto white balance", 208 .name = "auto white balance",
209 .minimum = 0, 209 .minimum = 0,
210 .maximum = 1, 210 .maximum = 1,
211 .step = 1, 211 .step = 1,
212 .default_value = 1 212 .default_value = 1
213 }, 213 },
214 .set = ov9650_set_auto_white_balance, 214 .set = ov9650_set_auto_white_balance,
215 .get = ov9650_get_auto_white_balance 215 .get = ov9650_get_auto_white_balance
@@ -217,13 +217,13 @@ static const struct ctrl ov9650_ctrls[] = {
217#define AUTO_GAIN_CTRL_IDX 7 217#define AUTO_GAIN_CTRL_IDX 7
218 { 218 {
219 { 219 {
220 .id = V4L2_CID_AUTOGAIN, 220 .id = V4L2_CID_AUTOGAIN,
221 .type = V4L2_CTRL_TYPE_BOOLEAN, 221 .type = V4L2_CTRL_TYPE_BOOLEAN,
222 .name = "auto gain control", 222 .name = "auto gain control",
223 .minimum = 0, 223 .minimum = 0,
224 .maximum = 1, 224 .maximum = 1,
225 .step = 1, 225 .step = 1,
226 .default_value = 1 226 .default_value = 1
227 }, 227 },
228 .set = ov9650_set_auto_gain, 228 .set = ov9650_set_auto_gain,
229 .get = ov9650_get_auto_gain 229 .get = ov9650_get_auto_gain
@@ -231,13 +231,13 @@ static const struct ctrl ov9650_ctrls[] = {
231#define AUTO_EXPOSURE_IDX 8 231#define AUTO_EXPOSURE_IDX 8
232 { 232 {
233 { 233 {
234 .id = V4L2_CID_EXPOSURE_AUTO, 234 .id = V4L2_CID_EXPOSURE_AUTO,
235 .type = V4L2_CTRL_TYPE_BOOLEAN, 235 .type = V4L2_CTRL_TYPE_BOOLEAN,
236 .name = "auto exposure", 236 .name = "auto exposure",
237 .minimum = 0, 237 .minimum = 0,
238 .maximum = 1, 238 .maximum = 1,
239 .step = 1, 239 .step = 1,
240 .default_value = 1 240 .default_value = 1
241 }, 241 },
242 .set = ov9650_set_auto_exposure, 242 .set = ov9650_set_auto_exposure,
243 .get = ov9650_get_auto_exposure 243 .get = ov9650_get_auto_exposure
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h
index c98c40d69e05..da9a129b739d 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h
@@ -110,7 +110,7 @@
110 110
111#define OV9650_VARIOPIXEL (1 << 2) 111#define OV9650_VARIOPIXEL (1 << 2)
112#define OV9650_SYSTEM_CLK_SEL (1 << 7) 112#define OV9650_SYSTEM_CLK_SEL (1 << 7)
113#define OV9650_SLAM_MODE (1 << 4) 113#define OV9650_SLAM_MODE (1 << 4)
114 114
115#define OV9650_QVGA_VARIOPIXEL (1 << 7) 115#define OV9650_QVGA_VARIOPIXEL (1 << 7)
116 116
@@ -154,8 +154,7 @@ static const struct m5602_sensor ov9650 = {
154 .disconnect = ov9650_disconnect, 154 .disconnect = ov9650_disconnect,
155}; 155};
156 156
157static const unsigned char preinit_ov9650[][3] = 157static const unsigned char preinit_ov9650[][3] = {
158{
159 /* [INITCAM] */ 158 /* [INITCAM] */
160 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 159 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
161 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 160 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
@@ -180,8 +179,7 @@ static const unsigned char preinit_ov9650[][3] =
180 {SENSOR, OV9650_OFON, 0x40} 179 {SENSOR, OV9650_OFON, 0x40}
181}; 180};
182 181
183static const unsigned char init_ov9650[][3] = 182static const unsigned char init_ov9650[][3] = {
184{
185 /* [INITCAM] */ 183 /* [INITCAM] */
186 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 184 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
187 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 185 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
@@ -297,8 +295,7 @@ static const unsigned char init_ov9650[][3] =
297 {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X}, 295 {SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},
298}; 296};
299 297
300static const unsigned char res_init_ov9650[][3] = 298static const unsigned char res_init_ov9650[][3] = {
301{
302 {SENSOR, OV9650_COM2, OV9650_OUTPUT_DRIVE_2X}, 299 {SENSOR, OV9650_COM2, OV9650_OUTPUT_DRIVE_2X},
303 300
304 {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x82}, 301 {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x82},
@@ -307,5 +304,4 @@ static const unsigned char res_init_ov9650[][3] =
307 {BRIDGE, M5602_XB_PIX_OF_LINE_L, 0x00}, 304 {BRIDGE, M5602_XB_PIX_OF_LINE_L, 0x00},
308 {BRIDGE, M5602_XB_SIG_INI, 0x01} 305 {BRIDGE, M5602_XB_SIG_INI, 0x01}
309}; 306};
310
311#endif 307#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c
index 925b87d66f40..1febd34c2f05 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.c
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.c
@@ -58,14 +58,14 @@ static const struct ctrl po1030_ctrls[] = {
58#define GAIN_IDX 0 58#define GAIN_IDX 0
59 { 59 {
60 { 60 {
61 .id = V4L2_CID_GAIN, 61 .id = V4L2_CID_GAIN,
62 .type = V4L2_CTRL_TYPE_INTEGER, 62 .type = V4L2_CTRL_TYPE_INTEGER,
63 .name = "gain", 63 .name = "gain",
64 .minimum = 0x00, 64 .minimum = 0x00,
65 .maximum = 0x4f, 65 .maximum = 0x4f,
66 .step = 0x1, 66 .step = 0x1,
67 .default_value = PO1030_GLOBAL_GAIN_DEFAULT, 67 .default_value = PO1030_GLOBAL_GAIN_DEFAULT,
68 .flags = V4L2_CTRL_FLAG_SLIDER 68 .flags = V4L2_CTRL_FLAG_SLIDER
69 }, 69 },
70 .set = po1030_set_gain, 70 .set = po1030_set_gain,
71 .get = po1030_get_gain 71 .get = po1030_get_gain
@@ -73,14 +73,14 @@ static const struct ctrl po1030_ctrls[] = {
73#define EXPOSURE_IDX 1 73#define EXPOSURE_IDX 1
74 { 74 {
75 { 75 {
76 .id = V4L2_CID_EXPOSURE, 76 .id = V4L2_CID_EXPOSURE,
77 .type = V4L2_CTRL_TYPE_INTEGER, 77 .type = V4L2_CTRL_TYPE_INTEGER,
78 .name = "exposure", 78 .name = "exposure",
79 .minimum = 0x00, 79 .minimum = 0x00,
80 .maximum = 0x02ff, 80 .maximum = 0x02ff,
81 .step = 0x1, 81 .step = 0x1,
82 .default_value = PO1030_EXPOSURE_DEFAULT, 82 .default_value = PO1030_EXPOSURE_DEFAULT,
83 .flags = V4L2_CTRL_FLAG_SLIDER 83 .flags = V4L2_CTRL_FLAG_SLIDER
84 }, 84 },
85 .set = po1030_set_exposure, 85 .set = po1030_set_exposure,
86 .get = po1030_get_exposure 86 .get = po1030_get_exposure
@@ -88,14 +88,14 @@ static const struct ctrl po1030_ctrls[] = {
88#define RED_BALANCE_IDX 2 88#define RED_BALANCE_IDX 2
89 { 89 {
90 { 90 {
91 .id = V4L2_CID_RED_BALANCE, 91 .id = V4L2_CID_RED_BALANCE,
92 .type = V4L2_CTRL_TYPE_INTEGER, 92 .type = V4L2_CTRL_TYPE_INTEGER,
93 .name = "red balance", 93 .name = "red balance",
94 .minimum = 0x00, 94 .minimum = 0x00,
95 .maximum = 0xff, 95 .maximum = 0xff,
96 .step = 0x1, 96 .step = 0x1,
97 .default_value = PO1030_RED_GAIN_DEFAULT, 97 .default_value = PO1030_RED_GAIN_DEFAULT,
98 .flags = V4L2_CTRL_FLAG_SLIDER 98 .flags = V4L2_CTRL_FLAG_SLIDER
99 }, 99 },
100 .set = po1030_set_red_balance, 100 .set = po1030_set_red_balance,
101 .get = po1030_get_red_balance 101 .get = po1030_get_red_balance
@@ -103,14 +103,14 @@ static const struct ctrl po1030_ctrls[] = {
103#define BLUE_BALANCE_IDX 3 103#define BLUE_BALANCE_IDX 3
104 { 104 {
105 { 105 {
106 .id = V4L2_CID_BLUE_BALANCE, 106 .id = V4L2_CID_BLUE_BALANCE,
107 .type = V4L2_CTRL_TYPE_INTEGER, 107 .type = V4L2_CTRL_TYPE_INTEGER,
108 .name = "blue balance", 108 .name = "blue balance",
109 .minimum = 0x00, 109 .minimum = 0x00,
110 .maximum = 0xff, 110 .maximum = 0xff,
111 .step = 0x1, 111 .step = 0x1,
112 .default_value = PO1030_BLUE_GAIN_DEFAULT, 112 .default_value = PO1030_BLUE_GAIN_DEFAULT,
113 .flags = V4L2_CTRL_FLAG_SLIDER 113 .flags = V4L2_CTRL_FLAG_SLIDER
114 }, 114 },
115 .set = po1030_set_blue_balance, 115 .set = po1030_set_blue_balance,
116 .get = po1030_get_blue_balance 116 .get = po1030_get_blue_balance
@@ -118,13 +118,13 @@ static const struct ctrl po1030_ctrls[] = {
118#define HFLIP_IDX 4 118#define HFLIP_IDX 4
119 { 119 {
120 { 120 {
121 .id = V4L2_CID_HFLIP, 121 .id = V4L2_CID_HFLIP,
122 .type = V4L2_CTRL_TYPE_BOOLEAN, 122 .type = V4L2_CTRL_TYPE_BOOLEAN,
123 .name = "horizontal flip", 123 .name = "horizontal flip",
124 .minimum = 0, 124 .minimum = 0,
125 .maximum = 1, 125 .maximum = 1,
126 .step = 1, 126 .step = 1,
127 .default_value = 0, 127 .default_value = 0,
128 }, 128 },
129 .set = po1030_set_hflip, 129 .set = po1030_set_hflip,
130 .get = po1030_get_hflip 130 .get = po1030_get_hflip
@@ -132,13 +132,13 @@ static const struct ctrl po1030_ctrls[] = {
132#define VFLIP_IDX 5 132#define VFLIP_IDX 5
133 { 133 {
134 { 134 {
135 .id = V4L2_CID_VFLIP, 135 .id = V4L2_CID_VFLIP,
136 .type = V4L2_CTRL_TYPE_BOOLEAN, 136 .type = V4L2_CTRL_TYPE_BOOLEAN,
137 .name = "vertical flip", 137 .name = "vertical flip",
138 .minimum = 0, 138 .minimum = 0,
139 .maximum = 1, 139 .maximum = 1,
140 .step = 1, 140 .step = 1,
141 .default_value = 0, 141 .default_value = 0,
142 }, 142 },
143 .set = po1030_set_vflip, 143 .set = po1030_set_vflip,
144 .get = po1030_get_vflip 144 .get = po1030_get_vflip
@@ -146,13 +146,13 @@ static const struct ctrl po1030_ctrls[] = {
146#define AUTO_WHITE_BALANCE_IDX 6 146#define AUTO_WHITE_BALANCE_IDX 6
147 { 147 {
148 { 148 {
149 .id = V4L2_CID_AUTO_WHITE_BALANCE, 149 .id = V4L2_CID_AUTO_WHITE_BALANCE,
150 .type = V4L2_CTRL_TYPE_BOOLEAN, 150 .type = V4L2_CTRL_TYPE_BOOLEAN,
151 .name = "auto white balance", 151 .name = "auto white balance",
152 .minimum = 0, 152 .minimum = 0,
153 .maximum = 1, 153 .maximum = 1,
154 .step = 1, 154 .step = 1,
155 .default_value = 0, 155 .default_value = 0,
156 }, 156 },
157 .set = po1030_set_auto_white_balance, 157 .set = po1030_set_auto_white_balance,
158 .get = po1030_get_auto_white_balance 158 .get = po1030_get_auto_white_balance
@@ -160,13 +160,13 @@ static const struct ctrl po1030_ctrls[] = {
160#define AUTO_EXPOSURE_IDX 7 160#define AUTO_EXPOSURE_IDX 7
161 { 161 {
162 { 162 {
163 .id = V4L2_CID_EXPOSURE_AUTO, 163 .id = V4L2_CID_EXPOSURE_AUTO,
164 .type = V4L2_CTRL_TYPE_BOOLEAN, 164 .type = V4L2_CTRL_TYPE_BOOLEAN,
165 .name = "auto exposure", 165 .name = "auto exposure",
166 .minimum = 0, 166 .minimum = 0,
167 .maximum = 1, 167 .maximum = 1,
168 .step = 1, 168 .step = 1,
169 .default_value = 0, 169 .default_value = 0,
170 }, 170 },
171 .set = po1030_set_auto_exposure, 171 .set = po1030_set_auto_exposure,
172 .get = po1030_get_auto_exposure 172 .get = po1030_get_auto_exposure
@@ -174,14 +174,14 @@ static const struct ctrl po1030_ctrls[] = {
174#define GREEN_BALANCE_IDX 8 174#define GREEN_BALANCE_IDX 8
175 { 175 {
176 { 176 {
177 .id = M5602_V4L2_CID_GREEN_BALANCE, 177 .id = M5602_V4L2_CID_GREEN_BALANCE,
178 .type = V4L2_CTRL_TYPE_INTEGER, 178 .type = V4L2_CTRL_TYPE_INTEGER,
179 .name = "green balance", 179 .name = "green balance",
180 .minimum = 0x00, 180 .minimum = 0x00,
181 .maximum = 0xff, 181 .maximum = 0xff,
182 .step = 0x1, 182 .step = 0x1,
183 .default_value = PO1030_GREEN_GAIN_DEFAULT, 183 .default_value = PO1030_GREEN_GAIN_DEFAULT,
184 .flags = V4L2_CTRL_FLAG_SLIDER 184 .flags = V4L2_CTRL_FLAG_SLIDER
185 }, 185 },
186 .set = po1030_set_green_balance, 186 .set = po1030_set_green_balance,
187 .get = po1030_get_green_balance 187 .get = po1030_get_green_balance
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h
index 1ea380b2bbe7..338359596398 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.h
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.h
@@ -139,9 +139,9 @@
139 139
140#define PO1030_GLOBAL_GAIN_DEFAULT 0x12 140#define PO1030_GLOBAL_GAIN_DEFAULT 0x12
141#define PO1030_EXPOSURE_DEFAULT 0x0085 141#define PO1030_EXPOSURE_DEFAULT 0x0085
142#define PO1030_BLUE_GAIN_DEFAULT 0x36 142#define PO1030_BLUE_GAIN_DEFAULT 0x36
143#define PO1030_RED_GAIN_DEFAULT 0x36 143#define PO1030_RED_GAIN_DEFAULT 0x36
144#define PO1030_GREEN_GAIN_DEFAULT 0x40 144#define PO1030_GREEN_GAIN_DEFAULT 0x40
145 145
146/*****************************************************************************/ 146/*****************************************************************************/
147 147
@@ -166,8 +166,7 @@ static const struct m5602_sensor po1030 = {
166 .disconnect = po1030_disconnect, 166 .disconnect = po1030_disconnect,
167}; 167};
168 168
169static const unsigned char preinit_po1030[][3] = 169static const unsigned char preinit_po1030[][3] = {
170{
171 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 170 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
172 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 171 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
173 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, 172 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
@@ -193,8 +192,7 @@ static const unsigned char preinit_po1030[][3] =
193 {BRIDGE, M5602_XB_GPIO_DAT, 0x00} 192 {BRIDGE, M5602_XB_GPIO_DAT, 0x00}
194}; 193};
195 194
196static const unsigned char init_po1030[][3] = 195static const unsigned char init_po1030[][3] = {
197{
198 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02}, 196 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
199 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0}, 197 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
200 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00}, 198 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
@@ -271,5 +269,4 @@ static const unsigned char init_po1030[][3] =
271 {BRIDGE, M5602_XB_GPIO_EN_H, 0x06}, 269 {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
272 {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}, 270 {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
273}; 271};
274
275#endif 272#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index da0a38c78708..d27280be9852 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -143,13 +143,13 @@ static const struct ctrl s5k4aa_ctrls[] = {
143#define VFLIP_IDX 0 143#define VFLIP_IDX 0
144 { 144 {
145 { 145 {
146 .id = V4L2_CID_VFLIP, 146 .id = V4L2_CID_VFLIP,
147 .type = V4L2_CTRL_TYPE_BOOLEAN, 147 .type = V4L2_CTRL_TYPE_BOOLEAN,
148 .name = "vertical flip", 148 .name = "vertical flip",
149 .minimum = 0, 149 .minimum = 0,
150 .maximum = 1, 150 .maximum = 1,
151 .step = 1, 151 .step = 1,
152 .default_value = 0 152 .default_value = 0
153 }, 153 },
154 .set = s5k4aa_set_vflip, 154 .set = s5k4aa_set_vflip,
155 .get = s5k4aa_get_vflip 155 .get = s5k4aa_get_vflip
@@ -157,13 +157,13 @@ static const struct ctrl s5k4aa_ctrls[] = {
157#define HFLIP_IDX 1 157#define HFLIP_IDX 1
158 { 158 {
159 { 159 {
160 .id = V4L2_CID_HFLIP, 160 .id = V4L2_CID_HFLIP,
161 .type = V4L2_CTRL_TYPE_BOOLEAN, 161 .type = V4L2_CTRL_TYPE_BOOLEAN,
162 .name = "horizontal flip", 162 .name = "horizontal flip",
163 .minimum = 0, 163 .minimum = 0,
164 .maximum = 1, 164 .maximum = 1,
165 .step = 1, 165 .step = 1,
166 .default_value = 0 166 .default_value = 0
167 }, 167 },
168 .set = s5k4aa_set_hflip, 168 .set = s5k4aa_set_hflip,
169 .get = s5k4aa_get_hflip 169 .get = s5k4aa_get_hflip
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
index 4440da4e7f0f..8cc7a3f6da72 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
@@ -83,8 +83,7 @@ static const struct m5602_sensor s5k4aa = {
83 .disconnect = s5k4aa_disconnect, 83 .disconnect = s5k4aa_disconnect,
84}; 84};
85 85
86static const unsigned char preinit_s5k4aa[][4] = 86static const unsigned char preinit_s5k4aa[][4] = {
87{
88 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00}, 87 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
89 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00}, 88 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
90 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 89 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
@@ -127,8 +126,7 @@ static const unsigned char preinit_s5k4aa[][4] =
127 {SENSOR, S5K4AA_PAGE_MAP, 0x00, 0x00} 126 {SENSOR, S5K4AA_PAGE_MAP, 0x00, 0x00}
128}; 127};
129 128
130static const unsigned char init_s5k4aa[][4] = 129static const unsigned char init_s5k4aa[][4] = {
131{
132 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00}, 130 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
133 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00}, 131 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
134 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 132 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
@@ -179,8 +177,7 @@ static const unsigned char init_s5k4aa[][4] =
179 {SENSOR, 0x37, 0x00, 0x00}, 177 {SENSOR, 0x37, 0x00, 0x00},
180}; 178};
181 179
182static const unsigned char VGA_s5k4aa[][4] = 180static const unsigned char VGA_s5k4aa[][4] = {
183{
184 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00}, 181 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
185 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, 182 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
186 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00}, 183 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -235,8 +232,7 @@ static const unsigned char VGA_s5k4aa[][4] =
235 {SENSOR, 0x02, 0x0e, 0x00}, 232 {SENSOR, 0x02, 0x0e, 0x00},
236}; 233};
237 234
238static const unsigned char SXGA_s5k4aa[][4] = 235static const unsigned char SXGA_s5k4aa[][4] = {
239{
240 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00}, 236 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
241 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, 237 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
242 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00}, 238 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -284,6 +280,4 @@ static const unsigned char SXGA_s5k4aa[][4] =
284 {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00}, 280 {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00},
285 {SENSOR, 0x02, 0x0e, 0x00}, 281 {SENSOR, 0x02, 0x0e, 0x00},
286}; 282};
287
288
289#endif 283#endif
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
index 7814b078acde..80a63a236e24 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
@@ -35,7 +35,7 @@
35#define S5K83A_MAXIMUM_EXPOSURE 0x3c 35#define S5K83A_MAXIMUM_EXPOSURE 0x3c
36#define S5K83A_FLIP_MASK 0x10 36#define S5K83A_FLIP_MASK 0x10
37#define S5K83A_GPIO_LED_MASK 0x10 37#define S5K83A_GPIO_LED_MASK 0x10
38#define S5K83A_GPIO_ROTATION_MASK 0x40 38#define S5K83A_GPIO_ROTATION_MASK 0x40
39 39
40/*****************************************************************************/ 40/*****************************************************************************/
41 41
@@ -67,8 +67,7 @@ struct s5k83a_priv {
67 s32 *settings; 67 s32 *settings;
68}; 68};
69 69
70static const unsigned char preinit_s5k83a[][4] = 70static const unsigned char preinit_s5k83a[][4] = {
71{
72 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00}, 71 {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
73 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00}, 72 {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
74 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 73 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
@@ -108,8 +107,7 @@ static const unsigned char preinit_s5k83a[][4] =
108/* This could probably be considerably shortened. 107/* This could probably be considerably shortened.
109 I don't have the hardware to experiment with it, patches welcome 108 I don't have the hardware to experiment with it, patches welcome
110*/ 109*/
111static const unsigned char init_s5k83a[][4] = 110static const unsigned char init_s5k83a[][4] = {
112{
113 /* The following sequence is useless after a clean boot 111 /* The following sequence is useless after a clean boot
114 but is necessary after resume from suspend */ 112 but is necessary after resume from suspend */
115 {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00}, 113 {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
@@ -166,8 +164,7 @@ static const unsigned char init_s5k83a[][4] =
166 {SENSOR, 0x00, 0x06, 0x00}, 164 {SENSOR, 0x00, 0x06, 0x00},
167}; 165};
168 166
169static const unsigned char start_s5k83a[][4] = 167static const unsigned char start_s5k83a[][4] = {
170{
171 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00}, 168 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
172 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, 169 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
173 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00}, 170 {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
@@ -193,5 +190,4 @@ static const unsigned char start_s5k83a[][4] =
193 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00}, 190 {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
194 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00}, 191 {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
195}; 192};
196
197#endif 193#endif
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index 031f7195ce0d..a81536e78698 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -28,14 +28,23 @@ MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
28MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
31/* controls */
32enum e_ctrl {
33 BRIGHTNESS,
34 COLORS,
35 GAMMA,
36 SHARPNESS,
37 ILLUM_TOP,
38 ILLUM_BOT,
39 NCTRLS /* number of controls */
40};
41
31/* specific webcam descriptor */ 42/* specific webcam descriptor */
32struct sd { 43struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 44 struct gspca_dev gspca_dev; /* !! must be the first item */
34 45
35 u8 brightness; 46 struct gspca_ctrl ctrls[NCTRLS];
36 u8 colors; 47
37 u8 gamma;
38 u8 sharpness;
39 u8 quality; 48 u8 quality;
40#define QUALITY_MIN 40 49#define QUALITY_MIN 40
41#define QUALITY_MAX 70 50#define QUALITY_MAX 70
@@ -45,17 +54,15 @@ struct sd {
45}; 54};
46 55
47/* V4L2 controls supported by the driver */ 56/* V4L2 controls supported by the driver */
48static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); 57static void setbrightness(struct gspca_dev *gspca_dev);
49static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 58static void setcolors(struct gspca_dev *gspca_dev);
50static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); 59static void setgamma(struct gspca_dev *gspca_dev);
51static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 60static void setsharpness(struct gspca_dev *gspca_dev);
52static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); 61static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val);
53static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); 62static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val);
54static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); 63
55static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); 64static const struct ctrl sd_ctrls[NCTRLS] = {
56 65[BRIGHTNESS] = {
57static const struct ctrl sd_ctrls[] = {
58 {
59 { 66 {
60 .id = V4L2_CID_BRIGHTNESS, 67 .id = V4L2_CID_BRIGHTNESS,
61 .type = V4L2_CTRL_TYPE_INTEGER, 68 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -63,13 +70,11 @@ static const struct ctrl sd_ctrls[] = {
63 .minimum = 0, 70 .minimum = 0,
64 .maximum = 30, 71 .maximum = 30,
65 .step = 1, 72 .step = 1,
66#define BRIGHTNESS_DEF 15 73 .default_value = 15,
67 .default_value = BRIGHTNESS_DEF,
68 }, 74 },
69 .set = sd_setbrightness, 75 .set_control = setbrightness
70 .get = sd_getbrightness,
71 }, 76 },
72 { 77[COLORS] = {
73 { 78 {
74 .id = V4L2_CID_SATURATION, 79 .id = V4L2_CID_SATURATION,
75 .type = V4L2_CTRL_TYPE_INTEGER, 80 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -77,13 +82,11 @@ static const struct ctrl sd_ctrls[] = {
77 .minimum = 1, 82 .minimum = 1,
78 .maximum = 255, 83 .maximum = 255,
79 .step = 1, 84 .step = 1,
80#define COLOR_DEF 200 85 .default_value = 200,
81 .default_value = COLOR_DEF,
82 }, 86 },
83 .set = sd_setcolors, 87 .set_control = setcolors
84 .get = sd_getcolors,
85 }, 88 },
86 { 89[GAMMA] = {
87 { 90 {
88 .id = V4L2_CID_GAMMA, 91 .id = V4L2_CID_GAMMA,
89 .type = V4L2_CTRL_TYPE_INTEGER, 92 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -91,13 +94,11 @@ static const struct ctrl sd_ctrls[] = {
91 .minimum = 0, 94 .minimum = 0,
92 .maximum = 3, 95 .maximum = 3,
93 .step = 1, 96 .step = 1,
94#define GAMMA_DEF 1 97 .default_value = 1,
95 .default_value = GAMMA_DEF,
96 }, 98 },
97 .set = sd_setgamma, 99 .set_control = setgamma
98 .get = sd_getgamma,
99 }, 100 },
100 { 101[SHARPNESS] = {
101 { 102 {
102 .id = V4L2_CID_SHARPNESS, 103 .id = V4L2_CID_SHARPNESS,
103 .type = V4L2_CTRL_TYPE_INTEGER, 104 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -105,11 +106,35 @@ static const struct ctrl sd_ctrls[] = {
105 .minimum = 0, 106 .minimum = 0,
106 .maximum = 2, 107 .maximum = 2,
107 .step = 1, 108 .step = 1,
108#define SHARPNESS_DEF 1 109 .default_value = 1,
109 .default_value = SHARPNESS_DEF, 110 },
111 .set_control = setsharpness
112 },
113[ILLUM_TOP] = {
114 {
115 .id = V4L2_CID_ILLUMINATORS_1,
116 .type = V4L2_CTRL_TYPE_BOOLEAN,
117 .name = "Top illuminator",
118 .minimum = 0,
119 .maximum = 1,
120 .step = 1,
121 .default_value = 0,
122 .flags = V4L2_CTRL_FLAG_UPDATE,
123 },
124 .set = sd_setilluminator1
125 },
126[ILLUM_BOT] = {
127 {
128 .id = V4L2_CID_ILLUMINATORS_2,
129 .type = V4L2_CTRL_TYPE_BOOLEAN,
130 .name = "Bottom illuminator",
131 .minimum = 0,
132 .maximum = 1,
133 .step = 1,
134 .default_value = 0,
135 .flags = V4L2_CTRL_FLAG_UPDATE,
110 }, 136 },
111 .set = sd_setsharpness, 137 .set = sd_setilluminator2
112 .get = sd_getsharpness,
113 }, 138 },
114}; 139};
115 140
@@ -138,21 +163,25 @@ static const __u8 mi_data[0x20] = {
138}; 163};
139 164
140/* write <len> bytes from gspca_dev->usb_buf */ 165/* write <len> bytes from gspca_dev->usb_buf */
141static int reg_w(struct gspca_dev *gspca_dev, 166static void reg_w(struct gspca_dev *gspca_dev,
142 int len) 167 int len)
143{ 168{
144 int alen, ret; 169 int alen, ret;
145 170
171 if (gspca_dev->usb_err < 0)
172 return;
173
146 ret = usb_bulk_msg(gspca_dev->dev, 174 ret = usb_bulk_msg(gspca_dev->dev,
147 usb_sndbulkpipe(gspca_dev->dev, 4), 175 usb_sndbulkpipe(gspca_dev->dev, 4),
148 gspca_dev->usb_buf, 176 gspca_dev->usb_buf,
149 len, 177 len,
150 &alen, 178 &alen,
151 500); /* timeout in milliseconds */ 179 500); /* timeout in milliseconds */
152 if (ret < 0) 180 if (ret < 0) {
153 PDEBUG(D_ERR, "reg write [%02x] error %d", 181 err("reg write [%02x] error %d",
154 gspca_dev->usb_buf[0], ret); 182 gspca_dev->usb_buf[0], ret);
155 return ret; 183 gspca_dev->usb_err = ret;
184 }
156} 185}
157 186
158static void mi_w(struct gspca_dev *gspca_dev, 187static void mi_w(struct gspca_dev *gspca_dev,
@@ -167,6 +196,59 @@ static void mi_w(struct gspca_dev *gspca_dev,
167 reg_w(gspca_dev, 4); 196 reg_w(gspca_dev, 4);
168} 197}
169 198
199static void setbrightness(struct gspca_dev *gspca_dev)
200{
201 struct sd *sd = (struct sd *) gspca_dev;
202
203 gspca_dev->usb_buf[0] = 0x61;
204 gspca_dev->usb_buf[1] = sd->ctrls[BRIGHTNESS].val;
205 reg_w(gspca_dev, 2);
206}
207
208static void setcolors(struct gspca_dev *gspca_dev)
209{
210 struct sd *sd = (struct sd *) gspca_dev;
211 s16 val;
212
213 val = sd->ctrls[COLORS].val;
214 gspca_dev->usb_buf[0] = 0x5f;
215 gspca_dev->usb_buf[1] = val << 3;
216 gspca_dev->usb_buf[2] = ((val >> 2) & 0xf8) | 0x04;
217 reg_w(gspca_dev, 3);
218}
219
220static void setgamma(struct gspca_dev *gspca_dev)
221{
222 struct sd *sd = (struct sd *) gspca_dev;
223
224 gspca_dev->usb_buf[0] = 0x06;
225 gspca_dev->usb_buf[1] = sd->ctrls[GAMMA].val * 0x40;
226 reg_w(gspca_dev, 2);
227}
228
229static void setsharpness(struct gspca_dev *gspca_dev)
230{
231 struct sd *sd = (struct sd *) gspca_dev;
232
233 gspca_dev->usb_buf[0] = 0x67;
234 gspca_dev->usb_buf[1] = sd->ctrls[SHARPNESS].val * 4 + 3;
235 reg_w(gspca_dev, 2);
236}
237
238static void setilluminators(struct gspca_dev *gspca_dev)
239{
240 struct sd *sd = (struct sd *) gspca_dev;
241
242 gspca_dev->usb_buf[0] = 0x22;
243 if (sd->ctrls[ILLUM_TOP].val)
244 gspca_dev->usb_buf[1] = 0x76;
245 else if (sd->ctrls[ILLUM_BOT].val)
246 gspca_dev->usb_buf[1] = 0x7a;
247 else
248 gspca_dev->usb_buf[1] = 0x7e;
249 reg_w(gspca_dev, 2);
250}
251
170/* this function is called at probe time */ 252/* this function is called at probe time */
171static int sd_config(struct gspca_dev *gspca_dev, 253static int sd_config(struct gspca_dev *gspca_dev,
172 const struct usb_device_id *id) 254 const struct usb_device_id *id)
@@ -177,10 +259,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
177 cam = &gspca_dev->cam; 259 cam = &gspca_dev->cam;
178 cam->cam_mode = vga_mode; 260 cam->cam_mode = vga_mode;
179 cam->nmodes = ARRAY_SIZE(vga_mode); 261 cam->nmodes = ARRAY_SIZE(vga_mode);
180 sd->brightness = BRIGHTNESS_DEF; 262 cam->ctrls = sd->ctrls;
181 sd->colors = COLOR_DEF;
182 sd->gamma = GAMMA_DEF;
183 sd->sharpness = SHARPNESS_DEF;
184 sd->quality = QUALITY_DEF; 263 sd->quality = QUALITY_DEF;
185 gspca_dev->nbalt = 9; /* use the altsetting 08 */ 264 gspca_dev->nbalt = 9; /* use the altsetting 08 */
186 return 0; 265 return 0;
@@ -189,13 +268,13 @@ static int sd_config(struct gspca_dev *gspca_dev,
189/* this function is called at probe and resume time */ 268/* this function is called at probe and resume time */
190static int sd_init(struct gspca_dev *gspca_dev) 269static int sd_init(struct gspca_dev *gspca_dev)
191{ 270{
271 gspca_dev->ctrl_inac = (1 << ILLUM_TOP) | (1 << ILLUM_BOT);
192 return 0; 272 return 0;
193} 273}
194 274
195static int sd_start(struct gspca_dev *gspca_dev) 275static int sd_start(struct gspca_dev *gspca_dev)
196{ 276{
197 struct sd *sd = (struct sd *) gspca_dev; 277 struct sd *sd = (struct sd *) gspca_dev;
198 int err_code;
199 u8 *data; 278 u8 *data;
200 int i; 279 int i;
201 280
@@ -208,9 +287,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
208 287
209 data[0] = 0x01; /* address */ 288 data[0] = 0x01; /* address */
210 data[1] = 0x01; 289 data[1] = 0x01;
211 err_code = reg_w(gspca_dev, 2); 290 reg_w(gspca_dev, 2);
212 if (err_code < 0)
213 return err_code;
214 291
215 /* 292 /*
216 Initialize the MR97113 chip register 293 Initialize the MR97113 chip register
@@ -223,7 +300,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
223 data[5] = 0x30; /* reg 4, MI, PAS5101 : 300 data[5] = 0x30; /* reg 4, MI, PAS5101 :
224 * 0x30 for 24mhz , 0x28 for 12mhz */ 301 * 0x30 for 24mhz , 0x28 for 12mhz */
225 data[6] = 0x02; /* reg 5, H start - was 0x04 */ 302 data[6] = 0x02; /* reg 5, H start - was 0x04 */
226 data[7] = sd->gamma * 0x40; /* reg 0x06: gamma */ 303 data[7] = sd->ctrls[GAMMA].val * 0x40; /* reg 0x06: gamma */
227 data[8] = 0x01; /* reg 7, V start - was 0x03 */ 304 data[8] = 0x01; /* reg 7, V start - was 0x03 */
228/* if (h_size == 320 ) */ 305/* if (h_size == 320 ) */
229/* data[9]= 0x56; * reg 8, 24MHz, 2:1 scale down */ 306/* data[9]= 0x56; * reg 8, 24MHz, 2:1 scale down */
@@ -232,16 +309,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
232/*jfm: from win trace*/ 309/*jfm: from win trace*/
233 data[10] = 0x18; 310 data[10] = 0x18;
234 311
235 err_code = reg_w(gspca_dev, 11); 312 reg_w(gspca_dev, 11);
236 if (err_code < 0)
237 return err_code;
238 313
239 data[0] = 0x23; /* address */ 314 data[0] = 0x23; /* address */
240 data[1] = 0x09; /* reg 35, append frame header */ 315 data[1] = 0x09; /* reg 35, append frame header */
241 316
242 err_code = reg_w(gspca_dev, 2); 317 reg_w(gspca_dev, 2);
243 if (err_code < 0)
244 return err_code;
245 318
246 data[0] = 0x3c; /* address */ 319 data[0] = 0x3c; /* address */
247/* if (gspca_dev->width == 1280) */ 320/* if (gspca_dev->width == 1280) */
@@ -250,9 +323,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
250/* else */ 323/* else */
251 data[1] = 50; /* 50 reg 60, pc-cam frame size 324 data[1] = 50; /* 50 reg 60, pc-cam frame size
252 * (unit: 4KB) 200KB */ 325 * (unit: 4KB) 200KB */
253 err_code = reg_w(gspca_dev, 2); 326 reg_w(gspca_dev, 2);
254 if (err_code < 0)
255 return err_code;
256 327
257 /* auto dark-gain */ 328 /* auto dark-gain */
258 data[0] = 0x5e; /* address */ 329 data[0] = 0x5e; /* address */
@@ -261,37 +332,29 @@ static int sd_start(struct gspca_dev *gspca_dev)
261 /* reg 0x5f/0x60 (LE) = saturation */ 332 /* reg 0x5f/0x60 (LE) = saturation */
262 /* h (60): xxxx x100 333 /* h (60): xxxx x100
263 * l (5f): xxxx x000 */ 334 * l (5f): xxxx x000 */
264 data[2] = sd->colors << 3; 335 data[2] = sd->ctrls[COLORS].val << 3;
265 data[3] = ((sd->colors >> 2) & 0xf8) | 0x04; 336 data[3] = ((sd->ctrls[COLORS].val >> 2) & 0xf8) | 0x04;
266 data[4] = sd->brightness; /* reg 0x61 = brightness */ 337 data[4] = sd->ctrls[BRIGHTNESS].val; /* reg 0x61 = brightness */
267 data[5] = 0x00; 338 data[5] = 0x00;
268 339
269 err_code = reg_w(gspca_dev, 6); 340 reg_w(gspca_dev, 6);
270 if (err_code < 0)
271 return err_code;
272 341
273 data[0] = 0x67; 342 data[0] = 0x67;
274/*jfm: from win trace*/ 343/*jfm: from win trace*/
275 data[1] = sd->sharpness * 4 + 3; 344 data[1] = sd->ctrls[SHARPNESS].val * 4 + 3;
276 data[2] = 0x14; 345 data[2] = 0x14;
277 err_code = reg_w(gspca_dev, 3); 346 reg_w(gspca_dev, 3);
278 if (err_code < 0)
279 return err_code;
280 347
281 data[0] = 0x69; 348 data[0] = 0x69;
282 data[1] = 0x2f; 349 data[1] = 0x2f;
283 data[2] = 0x28; 350 data[2] = 0x28;
284 data[3] = 0x42; 351 data[3] = 0x42;
285 err_code = reg_w(gspca_dev, 4); 352 reg_w(gspca_dev, 4);
286 if (err_code < 0)
287 return err_code;
288 353
289 data[0] = 0x63; 354 data[0] = 0x63;
290 data[1] = 0x07; 355 data[1] = 0x07;
291 err_code = reg_w(gspca_dev, 2); 356 reg_w(gspca_dev, 2);
292/*jfm: win trace - many writes here to reg 0x64*/ 357/*jfm: win trace - many writes here to reg 0x64*/
293 if (err_code < 0)
294 return err_code;
295 358
296 /* initialize the MI sensor */ 359 /* initialize the MI sensor */
297 for (i = 0; i < sizeof mi_data; i++) 360 for (i = 0; i < sizeof mi_data; i++)
@@ -300,18 +363,26 @@ static int sd_start(struct gspca_dev *gspca_dev)
300 data[0] = 0x00; 363 data[0] = 0x00;
301 data[1] = 0x4d; /* ISOC transfering enable... */ 364 data[1] = 0x4d; /* ISOC transfering enable... */
302 reg_w(gspca_dev, 2); 365 reg_w(gspca_dev, 2);
303 return 0; 366
367 gspca_dev->ctrl_inac = 0; /* activate the illuminator controls */
368 return gspca_dev->usb_err;
304} 369}
305 370
306static void sd_stopN(struct gspca_dev *gspca_dev) 371static void sd_stopN(struct gspca_dev *gspca_dev)
307{ 372{
308 int result; 373 struct sd *sd = (struct sd *) gspca_dev;
374
375 gspca_dev->ctrl_inac = (1 << ILLUM_TOP) | (1 << ILLUM_BOT);
376 if (sd->ctrls[ILLUM_TOP].val || sd->ctrls[ILLUM_BOT].val) {
377 sd->ctrls[ILLUM_TOP].val = 0;
378 sd->ctrls[ILLUM_BOT].val = 0;
379 setilluminators(gspca_dev);
380 msleep(20);
381 }
309 382
310 gspca_dev->usb_buf[0] = 1; 383 gspca_dev->usb_buf[0] = 1;
311 gspca_dev->usb_buf[1] = 0; 384 gspca_dev->usb_buf[1] = 0;
312 result = reg_w(gspca_dev, 2); 385 reg_w(gspca_dev, 2);
313 if (result < 0)
314 PDEBUG(D_ERR, "Camera Stop failed");
315} 386}
316 387
317static void sd_pkt_scan(struct gspca_dev *gspca_dev, 388static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -352,91 +423,28 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
352 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 423 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
353} 424}
354 425
355static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 426static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val)
356{
357 struct sd *sd = (struct sd *) gspca_dev;
358
359 sd->brightness = val;
360 if (gspca_dev->streaming) {
361 gspca_dev->usb_buf[0] = 0x61;
362 gspca_dev->usb_buf[1] = val;
363 reg_w(gspca_dev, 2);
364 }
365 return 0;
366}
367
368static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
369{ 427{
370 struct sd *sd = (struct sd *) gspca_dev; 428 struct sd *sd = (struct sd *) gspca_dev;
371 429
372 *val = sd->brightness; 430 /* only one illuminator may be on */
373 return 0; 431 sd->ctrls[ILLUM_TOP].val = val;
432 if (val)
433 sd->ctrls[ILLUM_BOT].val = 0;
434 setilluminators(gspca_dev);
435 return gspca_dev->usb_err;
374} 436}
375 437
376static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) 438static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val)
377{ 439{
378 struct sd *sd = (struct sd *) gspca_dev; 440 struct sd *sd = (struct sd *) gspca_dev;
379 441
380 sd->colors = val; 442 /* only one illuminator may be on */
381 if (gspca_dev->streaming) { 443 sd->ctrls[ILLUM_BOT].val = val;
382 444 if (val)
383 /* see sd_start */ 445 sd->ctrls[ILLUM_TOP].val = 0;
384 gspca_dev->usb_buf[0] = 0x5f; 446 setilluminators(gspca_dev);
385 gspca_dev->usb_buf[1] = sd->colors << 3; 447 return gspca_dev->usb_err;
386 gspca_dev->usb_buf[2] = ((sd->colors >> 2) & 0xf8) | 0x04;
387 reg_w(gspca_dev, 3);
388 }
389 return 0;
390}
391
392static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
393{
394 struct sd *sd = (struct sd *) gspca_dev;
395
396 *val = sd->colors;
397 return 0;
398}
399
400static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
401{
402 struct sd *sd = (struct sd *) gspca_dev;
403
404 sd->gamma = val;
405 if (gspca_dev->streaming) {
406 gspca_dev->usb_buf[0] = 0x06;
407 gspca_dev->usb_buf[1] = val * 0x40;
408 reg_w(gspca_dev, 2);
409 }
410 return 0;
411}
412
413static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
414{
415 struct sd *sd = (struct sd *) gspca_dev;
416
417 *val = sd->gamma;
418 return 0;
419}
420
421static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
422{
423 struct sd *sd = (struct sd *) gspca_dev;
424
425 sd->sharpness = val;
426 if (gspca_dev->streaming) {
427 gspca_dev->usb_buf[0] = 0x67;
428 gspca_dev->usb_buf[1] = val * 4 + 3;
429 reg_w(gspca_dev, 2);
430 }
431 return 0;
432}
433
434static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
435{
436 struct sd *sd = (struct sd *) gspca_dev;
437
438 *val = sd->sharpness;
439 return 0;
440} 448}
441 449
442static int sd_set_jcomp(struct gspca_dev *gspca_dev, 450static int sd_set_jcomp(struct gspca_dev *gspca_dev,
@@ -471,7 +479,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
471static const struct sd_desc sd_desc = { 479static const struct sd_desc sd_desc = {
472 .name = MODULE_NAME, 480 .name = MODULE_NAME,
473 .ctrls = sd_ctrls, 481 .ctrls = sd_ctrls,
474 .nctrls = ARRAY_SIZE(sd_ctrls), 482 .nctrls = NCTRLS,
475 .config = sd_config, 483 .config = sd_config,
476 .init = sd_init, 484 .init = sd_init,
477 .start = sd_start, 485 .start = sd_start,
@@ -510,18 +518,11 @@ static struct usb_driver sd_driver = {
510/* -- module insert / remove -- */ 518/* -- module insert / remove -- */
511static int __init sd_mod_init(void) 519static int __init sd_mod_init(void)
512{ 520{
513 int ret; 521 return usb_register(&sd_driver);
514
515 ret = usb_register(&sd_driver);
516 if (ret < 0)
517 return ret;
518 PDEBUG(D_PROBE, "registered");
519 return 0;
520} 522}
521static void __exit sd_mod_exit(void) 523static void __exit sd_mod_exit(void)
522{ 524{
523 usb_deregister(&sd_driver); 525 usb_deregister(&sd_driver);
524 PDEBUG(D_PROBE, "deregistered");
525} 526}
526 527
527module_init(sd_mod_init); 528module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
index 33744e724eaa..7607a288b51c 100644
--- a/drivers/media/video/gspca/mr97310a.c
+++ b/drivers/media/video/gspca/mr97310a.c
@@ -9,14 +9,14 @@
9 * is Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu> 9 * is Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu>
10 * 10 *
11 * Support for the control settings for the CIF cameras is 11 * Support for the control settings for the CIF cameras is
12 * Copyright (C) 2009 Hans de Goede <hdgoede@redhat.com> and 12 * Copyright (C) 2009 Hans de Goede <hdegoede@redhat.com> and
13 * Thomas Kaiser <thomas@kaiser-linux.li> 13 * Thomas Kaiser <thomas@kaiser-linux.li>
14 * 14 *
15 * Support for the control settings for the VGA cameras is 15 * Support for the control settings for the VGA cameras is
16 * Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu> 16 * Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu>
17 * 17 *
18 * Several previously unsupported cameras are owned and have been tested by 18 * Several previously unsupported cameras are owned and have been tested by
19 * Hans de Goede <hdgoede@redhat.com> and 19 * Hans de Goede <hdegoede@redhat.com> and
20 * Thomas Kaiser <thomas@kaiser-linux.li> and 20 * Thomas Kaiser <thomas@kaiser-linux.li> and
21 * Theodore Kilgore <kilgota@auburn.edu> and 21 * Theodore Kilgore <kilgota@auburn.edu> and
22 * Edmond Rodriguez <erodrig_97@yahoo.com> and 22 * Edmond Rodriguez <erodrig_97@yahoo.com> and
@@ -267,7 +267,7 @@ static int mr_write(struct gspca_dev *gspca_dev, int len)
267 usb_sndbulkpipe(gspca_dev->dev, 4), 267 usb_sndbulkpipe(gspca_dev->dev, 4),
268 gspca_dev->usb_buf, len, NULL, 500); 268 gspca_dev->usb_buf, len, NULL, 500);
269 if (rc < 0) 269 if (rc < 0)
270 PDEBUG(D_ERR, "reg write [%02x] error %d", 270 err("reg write [%02x] error %d",
271 gspca_dev->usb_buf[0], rc); 271 gspca_dev->usb_buf[0], rc);
272 return rc; 272 return rc;
273} 273}
@@ -281,7 +281,7 @@ static int mr_read(struct gspca_dev *gspca_dev, int len)
281 usb_rcvbulkpipe(gspca_dev->dev, 3), 281 usb_rcvbulkpipe(gspca_dev->dev, 3),
282 gspca_dev->usb_buf, len, NULL, 500); 282 gspca_dev->usb_buf, len, NULL, 500);
283 if (rc < 0) 283 if (rc < 0)
284 PDEBUG(D_ERR, "reg read [%02x] error %d", 284 err("reg read [%02x] error %d",
285 gspca_dev->usb_buf[0], rc); 285 gspca_dev->usb_buf[0], rc);
286 return rc; 286 return rc;
287} 287}
@@ -540,7 +540,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
540 sd->sensor_type = 1; 540 sd->sensor_type = 1;
541 break; 541 break;
542 default: 542 default:
543 PDEBUG(D_ERR, "Unknown CIF Sensor id : %02x", 543 err("Unknown CIF Sensor id : %02x",
544 gspca_dev->usb_buf[1]); 544 gspca_dev->usb_buf[1]);
545 return -ENODEV; 545 return -ENODEV;
546 } 546 }
@@ -575,10 +575,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
575 sd->sensor_type = 2; 575 sd->sensor_type = 2;
576 } else if ((gspca_dev->usb_buf[0] != 0x03) && 576 } else if ((gspca_dev->usb_buf[0] != 0x03) &&
577 (gspca_dev->usb_buf[0] != 0x04)) { 577 (gspca_dev->usb_buf[0] != 0x04)) {
578 PDEBUG(D_ERR, "Unknown VGA Sensor id Byte 0: %02x", 578 err("Unknown VGA Sensor id Byte 0: %02x",
579 gspca_dev->usb_buf[0]); 579 gspca_dev->usb_buf[0]);
580 PDEBUG(D_ERR, "Defaults assumed, may not work"); 580 err("Defaults assumed, may not work");
581 PDEBUG(D_ERR, "Please report this"); 581 err("Please report this");
582 } 582 }
583 /* Sakar Digital color needs to be adjusted. */ 583 /* Sakar Digital color needs to be adjusted. */
584 if ((gspca_dev->usb_buf[0] == 0x03) && 584 if ((gspca_dev->usb_buf[0] == 0x03) &&
@@ -595,12 +595,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
595 /* Nothing to do here. */ 595 /* Nothing to do here. */
596 break; 596 break;
597 default: 597 default:
598 PDEBUG(D_ERR, 598 err("Unknown VGA Sensor id Byte 1: %02x",
599 "Unknown VGA Sensor id Byte 1: %02x",
600 gspca_dev->usb_buf[1]); 599 gspca_dev->usb_buf[1]);
601 PDEBUG(D_ERR, 600 err("Defaults assumed, may not work");
602 "Defaults assumed, may not work"); 601 err("Please report this");
603 PDEBUG(D_ERR, "Please report this");
604 } 602 }
605 } 603 }
606 PDEBUG(D_PROBE, "MR97310A VGA camera detected, sensor: %d", 604 PDEBUG(D_PROBE, "MR97310A VGA camera detected, sensor: %d",
@@ -675,7 +673,7 @@ static int start_cif_cam(struct gspca_dev *gspca_dev)
675 struct sd *sd = (struct sd *) gspca_dev; 673 struct sd *sd = (struct sd *) gspca_dev;
676 __u8 *data = gspca_dev->usb_buf; 674 __u8 *data = gspca_dev->usb_buf;
677 int err_code; 675 int err_code;
678 const __u8 startup_string[] = { 676 static const __u8 startup_string[] = {
679 0x00, 677 0x00,
680 0x0d, 678 0x0d,
681 0x01, 679 0x01,
@@ -721,7 +719,7 @@ static int start_cif_cam(struct gspca_dev *gspca_dev)
721 return err_code; 719 return err_code;
722 720
723 if (!sd->sensor_type) { 721 if (!sd->sensor_type) {
724 const struct sensor_w_data cif_sensor0_init_data[] = { 722 static const struct sensor_w_data cif_sensor0_init_data[] = {
725 {0x02, 0x00, {0x03, 0x5a, 0xb5, 0x01, 723 {0x02, 0x00, {0x03, 0x5a, 0xb5, 0x01,
726 0x0f, 0x14, 0x0f, 0x10}, 8}, 724 0x0f, 0x14, 0x0f, 0x10}, 8},
727 {0x0c, 0x00, {0x04, 0x01, 0x01, 0x00, 0x1f}, 5}, 725 {0x0c, 0x00, {0x04, 0x01, 0x01, 0x00, 0x1f}, 5},
@@ -742,7 +740,7 @@ static int start_cif_cam(struct gspca_dev *gspca_dev)
742 err_code = sensor_write_regs(gspca_dev, cif_sensor0_init_data, 740 err_code = sensor_write_regs(gspca_dev, cif_sensor0_init_data,
743 ARRAY_SIZE(cif_sensor0_init_data)); 741 ARRAY_SIZE(cif_sensor0_init_data));
744 } else { /* sd->sensor_type = 1 */ 742 } else { /* sd->sensor_type = 1 */
745 const struct sensor_w_data cif_sensor1_init_data[] = { 743 static const struct sensor_w_data cif_sensor1_init_data[] = {
746 /* Reg 3,4, 7,8 get set by the controls */ 744 /* Reg 3,4, 7,8 get set by the controls */
747 {0x02, 0x00, {0x10}, 1}, 745 {0x02, 0x00, {0x10}, 1},
748 {0x05, 0x01, {0x22}, 1}, /* 5/6 also seen as 65h/32h */ 746 {0x05, 0x01, {0x22}, 1}, /* 5/6 also seen as 65h/32h */
@@ -777,8 +775,9 @@ static int start_vga_cam(struct gspca_dev *gspca_dev)
777 struct sd *sd = (struct sd *) gspca_dev; 775 struct sd *sd = (struct sd *) gspca_dev;
778 __u8 *data = gspca_dev->usb_buf; 776 __u8 *data = gspca_dev->usb_buf;
779 int err_code; 777 int err_code;
780 const __u8 startup_string[] = {0x00, 0x0d, 0x01, 0x00, 0x00, 0x2b, 778 static const __u8 startup_string[] =
781 0x00, 0x00, 0x00, 0x50, 0xc0}; 779 {0x00, 0x0d, 0x01, 0x00, 0x00, 0x2b, 0x00, 0x00,
780 0x00, 0x50, 0xc0};
782 /* What some of these mean is explained in start_cif_cam(), above */ 781 /* What some of these mean is explained in start_cif_cam(), above */
783 782
784 memcpy(data, startup_string, 11); 783 memcpy(data, startup_string, 11);
@@ -830,7 +829,7 @@ static int start_vga_cam(struct gspca_dev *gspca_dev)
830 return err_code; 829 return err_code;
831 830
832 if (!sd->sensor_type) { 831 if (!sd->sensor_type) {
833 const struct sensor_w_data vga_sensor0_init_data[] = { 832 static const struct sensor_w_data vga_sensor0_init_data[] = {
834 {0x01, 0x00, {0x0c, 0x00, 0x04}, 3}, 833 {0x01, 0x00, {0x0c, 0x00, 0x04}, 3},
835 {0x14, 0x00, {0x01, 0xe4, 0x02, 0x84}, 4}, 834 {0x14, 0x00, {0x01, 0xe4, 0x02, 0x84}, 4},
836 {0x20, 0x00, {0x00, 0x80, 0x00, 0x08}, 4}, 835 {0x20, 0x00, {0x00, 0x80, 0x00, 0x08}, 4},
@@ -841,20 +840,20 @@ static int start_vga_cam(struct gspca_dev *gspca_dev)
841 err_code = sensor_write_regs(gspca_dev, vga_sensor0_init_data, 840 err_code = sensor_write_regs(gspca_dev, vga_sensor0_init_data,
842 ARRAY_SIZE(vga_sensor0_init_data)); 841 ARRAY_SIZE(vga_sensor0_init_data));
843 } else if (sd->sensor_type == 1) { 842 } else if (sd->sensor_type == 1) {
844 const struct sensor_w_data color_adj[] = { 843 static const struct sensor_w_data color_adj[] = {
845 {0x02, 0x00, {0x06, 0x59, 0x0c, 0x16, 0x00, 844 {0x02, 0x00, {0x06, 0x59, 0x0c, 0x16, 0x00,
846 /* adjusted blue, green, red gain correct 845 /* adjusted blue, green, red gain correct
847 too much blue from the Sakar Digital */ 846 too much blue from the Sakar Digital */
848 0x05, 0x01, 0x04}, 8} 847 0x05, 0x01, 0x04}, 8}
849 }; 848 };
850 849
851 const struct sensor_w_data color_no_adj[] = { 850 static const struct sensor_w_data color_no_adj[] = {
852 {0x02, 0x00, {0x06, 0x59, 0x0c, 0x16, 0x00, 851 {0x02, 0x00, {0x06, 0x59, 0x0c, 0x16, 0x00,
853 /* default blue, green, red gain settings */ 852 /* default blue, green, red gain settings */
854 0x07, 0x00, 0x01}, 8} 853 0x07, 0x00, 0x01}, 8}
855 }; 854 };
856 855
857 const struct sensor_w_data vga_sensor1_init_data[] = { 856 static const struct sensor_w_data vga_sensor1_init_data[] = {
858 {0x11, 0x04, {0x01}, 1}, 857 {0x11, 0x04, {0x01}, 1},
859 {0x0a, 0x00, {0x00, 0x01, 0x00, 0x00, 0x01, 858 {0x0a, 0x00, {0x00, 0x01, 0x00, 0x00, 0x01,
860 /* These settings may be better for some cameras */ 859 /* These settings may be better for some cameras */
@@ -879,7 +878,7 @@ static int start_vga_cam(struct gspca_dev *gspca_dev)
879 err_code = sensor_write_regs(gspca_dev, vga_sensor1_init_data, 878 err_code = sensor_write_regs(gspca_dev, vga_sensor1_init_data,
880 ARRAY_SIZE(vga_sensor1_init_data)); 879 ARRAY_SIZE(vga_sensor1_init_data));
881 } else { /* sensor type == 2 */ 880 } else { /* sensor type == 2 */
882 const struct sensor_w_data vga_sensor2_init_data[] = { 881 static const struct sensor_w_data vga_sensor2_init_data[] = {
883 882
884 {0x01, 0x00, {0x48}, 1}, 883 {0x01, 0x00, {0x48}, 1},
885 {0x02, 0x00, {0x22}, 1}, 884 {0x02, 0x00, {0x22}, 1},
@@ -976,7 +975,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
976 u8 val; 975 u8 val;
977 u8 sign_reg = 7; /* This reg and the next one used on CIF cams. */ 976 u8 sign_reg = 7; /* This reg and the next one used on CIF cams. */
978 u8 value_reg = 8; /* VGA cams seem to use regs 0x0b and 0x0c */ 977 u8 value_reg = 8; /* VGA cams seem to use regs 0x0b and 0x0c */
979 const u8 quick_clix_table[] = 978 static const u8 quick_clix_table[] =
980 /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 979 /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
981 { 0, 4, 8, 12, 1, 2, 3, 5, 6, 9, 7, 10, 13, 11, 14, 15}; 980 { 0, 4, 8, 12, 1, 2, 3, 5, 6, 9, 7, 10, 13, 11, 14, 15};
982 /* 981 /*
@@ -1261,18 +1260,11 @@ static struct usb_driver sd_driver = {
1261/* -- module insert / remove -- */ 1260/* -- module insert / remove -- */
1262static int __init sd_mod_init(void) 1261static int __init sd_mod_init(void)
1263{ 1262{
1264 int ret; 1263 return usb_register(&sd_driver);
1265
1266 ret = usb_register(&sd_driver);
1267 if (ret < 0)
1268 return ret;
1269 PDEBUG(D_PROBE, "registered");
1270 return 0;
1271} 1264}
1272static void __exit sd_mod_exit(void) 1265static void __exit sd_mod_exit(void)
1273{ 1266{
1274 usb_deregister(&sd_driver); 1267 usb_deregister(&sd_driver);
1275 PDEBUG(D_PROBE, "deregistered");
1276} 1268}
1277 1269
1278module_init(sd_mod_init); 1270module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index 2b2cbdbf03fe..6cf6855aa506 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -57,10 +57,24 @@ static int frame_rate;
57 * are getting "Failed to read sensor ID..." */ 57 * are getting "Failed to read sensor ID..." */
58static int i2c_detect_tries = 10; 58static int i2c_detect_tries = 10;
59 59
60/* controls */
61enum e_ctrl {
62 BRIGHTNESS,
63 CONTRAST,
64 COLORS,
65 HFLIP,
66 VFLIP,
67 AUTOBRIGHT,
68 FREQ,
69 NCTRL /* number of controls */
70};
71
60/* ov519 device descriptor */ 72/* ov519 device descriptor */
61struct sd { 73struct sd {
62 struct gspca_dev gspca_dev; /* !! must be the first item */ 74 struct gspca_dev gspca_dev; /* !! must be the first item */
63 75
76 struct gspca_ctrl ctrls[NCTRL];
77
64 __u8 packet_nr; 78 __u8 packet_nr;
65 79
66 char bridge; 80 char bridge;
@@ -82,13 +96,6 @@ struct sd {
82 /* Determined by sensor type */ 96 /* Determined by sensor type */
83 __u8 sif; 97 __u8 sif;
84 98
85 __u8 brightness;
86 __u8 contrast;
87 __u8 colors;
88 __u8 hflip;
89 __u8 vflip;
90 __u8 autobrightness;
91 __u8 freq;
92 __u8 quality; 99 __u8 quality;
93#define QUALITY_MIN 50 100#define QUALITY_MIN 50
94#define QUALITY_MAX 70 101#define QUALITY_MAX 70
@@ -130,29 +137,16 @@ struct sd {
130#include "w996Xcf.c" 137#include "w996Xcf.c"
131 138
132/* V4L2 controls supported by the driver */ 139/* V4L2 controls supported by the driver */
133static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
134static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
135static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
136static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
137static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
138static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
139static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
140static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
141static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
142static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
143static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val);
144static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val);
145static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
146static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
147static void setbrightness(struct gspca_dev *gspca_dev); 140static void setbrightness(struct gspca_dev *gspca_dev);
148static void setcontrast(struct gspca_dev *gspca_dev); 141static void setcontrast(struct gspca_dev *gspca_dev);
149static void setcolors(struct gspca_dev *gspca_dev); 142static void setcolors(struct gspca_dev *gspca_dev);
150static void setautobrightness(struct sd *sd); 143static void sethvflip(struct gspca_dev *gspca_dev);
151static void setfreq(struct sd *sd); 144static void setautobright(struct gspca_dev *gspca_dev);
145static void setfreq(struct gspca_dev *gspca_dev);
146static void setfreq_i(struct sd *sd);
152 147
153static const struct ctrl sd_ctrls[] = { 148static const struct ctrl sd_ctrls[] = {
154#define BRIGHTNESS_IDX 0 149[BRIGHTNESS] = {
155 {
156 { 150 {
157 .id = V4L2_CID_BRIGHTNESS, 151 .id = V4L2_CID_BRIGHTNESS,
158 .type = V4L2_CTRL_TYPE_INTEGER, 152 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -160,14 +154,11 @@ static const struct ctrl sd_ctrls[] = {
160 .minimum = 0, 154 .minimum = 0,
161 .maximum = 255, 155 .maximum = 255,
162 .step = 1, 156 .step = 1,
163#define BRIGHTNESS_DEF 127 157 .default_value = 127,
164 .default_value = BRIGHTNESS_DEF,
165 }, 158 },
166 .set = sd_setbrightness, 159 .set_control = setbrightness,
167 .get = sd_getbrightness,
168 }, 160 },
169#define CONTRAST_IDX 1 161[CONTRAST] = {
170 {
171 { 162 {
172 .id = V4L2_CID_CONTRAST, 163 .id = V4L2_CID_CONTRAST,
173 .type = V4L2_CTRL_TYPE_INTEGER, 164 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -175,14 +166,11 @@ static const struct ctrl sd_ctrls[] = {
175 .minimum = 0, 166 .minimum = 0,
176 .maximum = 255, 167 .maximum = 255,
177 .step = 1, 168 .step = 1,
178#define CONTRAST_DEF 127 169 .default_value = 127,
179 .default_value = CONTRAST_DEF,
180 }, 170 },
181 .set = sd_setcontrast, 171 .set_control = setcontrast,
182 .get = sd_getcontrast,
183 }, 172 },
184#define COLOR_IDX 2 173[COLORS] = {
185 {
186 { 174 {
187 .id = V4L2_CID_SATURATION, 175 .id = V4L2_CID_SATURATION,
188 .type = V4L2_CTRL_TYPE_INTEGER, 176 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -190,15 +178,12 @@ static const struct ctrl sd_ctrls[] = {
190 .minimum = 0, 178 .minimum = 0,
191 .maximum = 255, 179 .maximum = 255,
192 .step = 1, 180 .step = 1,
193#define COLOR_DEF 127 181 .default_value = 127,
194 .default_value = COLOR_DEF,
195 }, 182 },
196 .set = sd_setcolors, 183 .set_control = setcolors,
197 .get = sd_getcolors,
198 }, 184 },
199/* The flip controls work with ov7670 only */ 185/* The flip controls work with ov7670 only */
200#define HFLIP_IDX 3 186[HFLIP] = {
201 {
202 { 187 {
203 .id = V4L2_CID_HFLIP, 188 .id = V4L2_CID_HFLIP,
204 .type = V4L2_CTRL_TYPE_BOOLEAN, 189 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -206,14 +191,11 @@ static const struct ctrl sd_ctrls[] = {
206 .minimum = 0, 191 .minimum = 0,
207 .maximum = 1, 192 .maximum = 1,
208 .step = 1, 193 .step = 1,
209#define HFLIP_DEF 0 194 .default_value = 0,
210 .default_value = HFLIP_DEF,
211 }, 195 },
212 .set = sd_sethflip, 196 .set_control = sethvflip,
213 .get = sd_gethflip,
214 }, 197 },
215#define VFLIP_IDX 4 198[VFLIP] = {
216 {
217 { 199 {
218 .id = V4L2_CID_VFLIP, 200 .id = V4L2_CID_VFLIP,
219 .type = V4L2_CTRL_TYPE_BOOLEAN, 201 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -221,14 +203,11 @@ static const struct ctrl sd_ctrls[] = {
221 .minimum = 0, 203 .minimum = 0,
222 .maximum = 1, 204 .maximum = 1,
223 .step = 1, 205 .step = 1,
224#define VFLIP_DEF 0 206 .default_value = 0,
225 .default_value = VFLIP_DEF,
226 }, 207 },
227 .set = sd_setvflip, 208 .set_control = sethvflip,
228 .get = sd_getvflip,
229 }, 209 },
230#define AUTOBRIGHT_IDX 5 210[AUTOBRIGHT] = {
231 {
232 { 211 {
233 .id = V4L2_CID_AUTOBRIGHTNESS, 212 .id = V4L2_CID_AUTOBRIGHTNESS,
234 .type = V4L2_CTRL_TYPE_BOOLEAN, 213 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -236,14 +215,11 @@ static const struct ctrl sd_ctrls[] = {
236 .minimum = 0, 215 .minimum = 0,
237 .maximum = 1, 216 .maximum = 1,
238 .step = 1, 217 .step = 1,
239#define AUTOBRIGHT_DEF 1 218 .default_value = 1,
240 .default_value = AUTOBRIGHT_DEF,
241 }, 219 },
242 .set = sd_setautobrightness, 220 .set_control = setautobright,
243 .get = sd_getautobrightness,
244 }, 221 },
245#define FREQ_IDX 6 222[FREQ] = {
246 {
247 { 223 {
248 .id = V4L2_CID_POWER_LINE_FREQUENCY, 224 .id = V4L2_CID_POWER_LINE_FREQUENCY,
249 .type = V4L2_CTRL_TYPE_MENU, 225 .type = V4L2_CTRL_TYPE_MENU,
@@ -251,26 +227,9 @@ static const struct ctrl sd_ctrls[] = {
251 .minimum = 0, 227 .minimum = 0,
252 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ 228 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
253 .step = 1, 229 .step = 1,
254#define FREQ_DEF 0 230 .default_value = 0,
255 .default_value = FREQ_DEF,
256 },
257 .set = sd_setfreq,
258 .get = sd_getfreq,
259 },
260#define OV7670_FREQ_IDX 7
261 {
262 {
263 .id = V4L2_CID_POWER_LINE_FREQUENCY,
264 .type = V4L2_CTRL_TYPE_MENU,
265 .name = "Light frequency filter",
266 .minimum = 0,
267 .maximum = 3, /* 0: 0, 1: 50Hz, 2:60Hz 3: Auto Hz */
268 .step = 1,
269#define OV7670_FREQ_DEF 3
270 .default_value = OV7670_FREQ_DEF,
271 }, 231 },
272 .set = sd_setfreq, 232 .set_control = setfreq,
273 .get = sd_getfreq,
274 }, 233 },
275}; 234};
276 235
@@ -456,10 +415,10 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = {
456 415
457/* Registers common to OV511 / OV518 */ 416/* Registers common to OV511 / OV518 */
458#define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */ 417#define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */
459#define R51x_SYS_RESET 0x50 418#define R51x_SYS_RESET 0x50
460 /* Reset type flags */ 419 /* Reset type flags */
461 #define OV511_RESET_OMNICE 0x08 420 #define OV511_RESET_OMNICE 0x08
462#define R51x_SYS_INIT 0x53 421#define R51x_SYS_INIT 0x53
463#define R51x_SYS_SNAP 0x52 422#define R51x_SYS_SNAP 0x52
464#define R51x_SYS_CUST_ID 0x5F 423#define R51x_SYS_CUST_ID 0x5F
465#define R51x_COMP_LUT_BEGIN 0x80 424#define R51x_COMP_LUT_BEGIN 0x80
@@ -644,13 +603,11 @@ struct ov_i2c_regvals {
644}; 603};
645 604
646/* Settings for OV2610 camera chip */ 605/* Settings for OV2610 camera chip */
647static const struct ov_i2c_regvals norm_2610[] = 606static const struct ov_i2c_regvals norm_2610[] = {
648{
649 { 0x12, 0x80 }, /* reset */ 607 { 0x12, 0x80 }, /* reset */
650}; 608};
651 609
652static const struct ov_i2c_regvals norm_3620b[] = 610static const struct ov_i2c_regvals norm_3620b[] = {
653{
654 /* 611 /*
655 * From the datasheet: "Note that after writing to register COMH 612 * From the datasheet: "Note that after writing to register COMH
656 * (0x12) to change the sensor mode, registers related to the 613 * (0x12) to change the sensor mode, registers related to the
@@ -1900,7 +1857,7 @@ static int reg_w(struct sd *sd, __u16 index, __u16 value)
1900 sd->gspca_dev.usb_buf, 1, 500); 1857 sd->gspca_dev.usb_buf, 1, 500);
1901leave: 1858leave:
1902 if (ret < 0) { 1859 if (ret < 0) {
1903 PDEBUG(D_ERR, "Write reg 0x%04x -> [0x%02x] failed", 1860 err("Write reg 0x%04x -> [0x%02x] failed",
1904 value, index); 1861 value, index);
1905 return ret; 1862 return ret;
1906 } 1863 }
@@ -1938,7 +1895,7 @@ static int reg_r(struct sd *sd, __u16 index)
1938 ret = sd->gspca_dev.usb_buf[0]; 1895 ret = sd->gspca_dev.usb_buf[0];
1939 PDEBUG(D_USBI, "Read reg [0x%02X] -> 0x%04X", index, ret); 1896 PDEBUG(D_USBI, "Read reg [0x%02X] -> 0x%04X", index, ret);
1940 } else 1897 } else
1941 PDEBUG(D_ERR, "Read reg [0x%02x] failed", index); 1898 err("Read reg [0x%02x] failed", index);
1942 1899
1943 return ret; 1900 return ret;
1944} 1901}
@@ -1958,7 +1915,7 @@ static int reg_r8(struct sd *sd,
1958 if (ret >= 0) 1915 if (ret >= 0)
1959 ret = sd->gspca_dev.usb_buf[0]; 1916 ret = sd->gspca_dev.usb_buf[0];
1960 else 1917 else
1961 PDEBUG(D_ERR, "Read reg 8 [0x%02x] failed", index); 1918 err("Read reg 8 [0x%02x] failed", index);
1962 1919
1963 return ret; 1920 return ret;
1964} 1921}
@@ -2006,7 +1963,7 @@ static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n)
2006 0, index, 1963 0, index,
2007 sd->gspca_dev.usb_buf, n, 500); 1964 sd->gspca_dev.usb_buf, n, 500);
2008 if (ret < 0) { 1965 if (ret < 0) {
2009 PDEBUG(D_ERR, "Write reg32 [%02x] %08x failed", index, value); 1966 err("Write reg32 [%02x] %08x failed", index, value);
2010 return ret; 1967 return ret;
2011 } 1968 }
2012 1969
@@ -2203,7 +2160,7 @@ static int ovfx2_i2c_w(struct sd *sd, __u8 reg, __u8 value)
2203 (__u16)value, (__u16)reg, NULL, 0, 500); 2160 (__u16)value, (__u16)reg, NULL, 0, 500);
2204 2161
2205 if (ret < 0) { 2162 if (ret < 0) {
2206 PDEBUG(D_ERR, "i2c 0x%02x -> [0x%02x] failed", value, reg); 2163 err("i2c 0x%02x -> [0x%02x] failed", value, reg);
2207 return ret; 2164 return ret;
2208 } 2165 }
2209 2166
@@ -2225,7 +2182,7 @@ static int ovfx2_i2c_r(struct sd *sd, __u8 reg)
2225 ret = sd->gspca_dev.usb_buf[0]; 2182 ret = sd->gspca_dev.usb_buf[0];
2226 PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, ret); 2183 PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, ret);
2227 } else 2184 } else
2228 PDEBUG(D_ERR, "i2c read [0x%02x] failed", reg); 2185 err("i2c read [0x%02x] failed", reg);
2229 2186
2230 return ret; 2187 return ret;
2231} 2188}
@@ -2481,7 +2438,7 @@ static int ov_hires_configure(struct sd *sd)
2481 int high, low; 2438 int high, low;
2482 2439
2483 if (sd->bridge != BRIDGE_OVFX2) { 2440 if (sd->bridge != BRIDGE_OVFX2) {
2484 PDEBUG(D_ERR, "error hires sensors only supported with ovfx2"); 2441 err("error hires sensors only supported with ovfx2");
2485 return -1; 2442 return -1;
2486 } 2443 }
2487 2444
@@ -2498,7 +2455,7 @@ static int ov_hires_configure(struct sd *sd)
2498 PDEBUG(D_PROBE, "Sensor is an OV3610"); 2455 PDEBUG(D_PROBE, "Sensor is an OV3610");
2499 sd->sensor = SEN_OV3610; 2456 sd->sensor = SEN_OV3610;
2500 } else { 2457 } else {
2501 PDEBUG(D_ERR, "Error unknown sensor type: 0x%02x%02x", 2458 err("Error unknown sensor type: 0x%02x%02x",
2502 high, low); 2459 high, low);
2503 return -1; 2460 return -1;
2504 } 2461 }
@@ -2526,7 +2483,7 @@ static int ov8xx0_configure(struct sd *sd)
2526 if ((rc & 3) == 1) { 2483 if ((rc & 3) == 1) {
2527 sd->sensor = SEN_OV8610; 2484 sd->sensor = SEN_OV8610;
2528 } else { 2485 } else {
2529 PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); 2486 err("Unknown image sensor version: %d", rc & 3);
2530 return -1; 2487 return -1;
2531 } 2488 }
2532 2489
@@ -2589,9 +2546,8 @@ static int ov7xx0_configure(struct sd *sd)
2589 if (high == 0x76) { 2546 if (high == 0x76) {
2590 switch (low) { 2547 switch (low) {
2591 case 0x30: 2548 case 0x30:
2592 PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); 2549 err("Sensor is an OV7630/OV7635");
2593 PDEBUG(D_ERR, 2550 err("7630 is not supported by this driver");
2594 "7630 is not supported by this driver");
2595 return -1; 2551 return -1;
2596 case 0x40: 2552 case 0x40:
2597 PDEBUG(D_PROBE, "Sensor is an OV7645"); 2553 PDEBUG(D_PROBE, "Sensor is an OV7645");
@@ -2614,7 +2570,7 @@ static int ov7xx0_configure(struct sd *sd)
2614 sd->sensor = SEN_OV7620; 2570 sd->sensor = SEN_OV7620;
2615 } 2571 }
2616 } else { 2572 } else {
2617 PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); 2573 err("Unknown image sensor version: %d", rc & 3);
2618 return -1; 2574 return -1;
2619 } 2575 }
2620 2576
@@ -2641,9 +2597,8 @@ static int ov6xx0_configure(struct sd *sd)
2641 switch (rc) { 2597 switch (rc) {
2642 case 0x00: 2598 case 0x00:
2643 sd->sensor = SEN_OV6630; 2599 sd->sensor = SEN_OV6630;
2644 PDEBUG(D_ERR, 2600 warn("WARNING: Sensor is an OV66308. Your camera may have");
2645 "WARNING: Sensor is an OV66308. Your camera may have"); 2601 warn("been misdetected in previous driver versions.");
2646 PDEBUG(D_ERR, "been misdetected in previous driver versions.");
2647 break; 2602 break;
2648 case 0x01: 2603 case 0x01:
2649 sd->sensor = SEN_OV6620; 2604 sd->sensor = SEN_OV6620;
@@ -2659,12 +2614,11 @@ static int ov6xx0_configure(struct sd *sd)
2659 break; 2614 break;
2660 case 0x90: 2615 case 0x90:
2661 sd->sensor = SEN_OV6630; 2616 sd->sensor = SEN_OV6630;
2662 PDEBUG(D_ERR, 2617 warn("WARNING: Sensor is an OV66307. Your camera may have");
2663 "WARNING: Sensor is an OV66307. Your camera may have"); 2618 warn("been misdetected in previous driver versions.");
2664 PDEBUG(D_ERR, "been misdetected in previous driver versions.");
2665 break; 2619 break;
2666 default: 2620 default:
2667 PDEBUG(D_ERR, "FATAL: Unknown sensor version: 0x%02x", rc); 2621 err("FATAL: Unknown sensor version: 0x%02x", rc);
2668 return -1; 2622 return -1;
2669 } 2623 }
2670 2624
@@ -2823,7 +2777,7 @@ static int ov511_configure(struct gspca_dev *gspca_dev)
2823 }; 2777 };
2824 2778
2825 const struct ov_regvals norm_511[] = { 2779 const struct ov_regvals norm_511[] = {
2826 { R511_DRAM_FLOW_CTL, 0x01 }, 2780 { R511_DRAM_FLOW_CTL, 0x01 },
2827 { R51x_SYS_SNAP, 0x00 }, 2781 { R51x_SYS_SNAP, 0x00 },
2828 { R51x_SYS_SNAP, 0x02 }, 2782 { R51x_SYS_SNAP, 0x02 },
2829 { R51x_SYS_SNAP, 0x00 }, 2783 { R51x_SYS_SNAP, 0x00 },
@@ -2907,7 +2861,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev)
2907 const struct ov_regvals norm_518[] = { 2861 const struct ov_regvals norm_518[] = {
2908 { R51x_SYS_SNAP, 0x02 }, /* Reset */ 2862 { R51x_SYS_SNAP, 0x02 }, /* Reset */
2909 { R51x_SYS_SNAP, 0x01 }, /* Enable */ 2863 { R51x_SYS_SNAP, 0x01 }, /* Enable */
2910 { 0x31, 0x0f }, 2864 { 0x31, 0x0f },
2911 { 0x5d, 0x03 }, 2865 { 0x5d, 0x03 },
2912 { 0x24, 0x9f }, 2866 { 0x24, 0x9f },
2913 { 0x25, 0x90 }, 2867 { 0x25, 0x90 },
@@ -2920,7 +2874,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev)
2920 const struct ov_regvals norm_518_p[] = { 2874 const struct ov_regvals norm_518_p[] = {
2921 { R51x_SYS_SNAP, 0x02 }, /* Reset */ 2875 { R51x_SYS_SNAP, 0x02 }, /* Reset */
2922 { R51x_SYS_SNAP, 0x01 }, /* Enable */ 2876 { R51x_SYS_SNAP, 0x01 }, /* Enable */
2923 { 0x31, 0x0f }, 2877 { 0x31, 0x0f },
2924 { 0x5d, 0x03 }, 2878 { 0x5d, 0x03 },
2925 { 0x24, 0x9f }, 2879 { 0x24, 0x9f },
2926 { 0x25, 0x90 }, 2880 { 0x25, 0x90 },
@@ -3082,7 +3036,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
3082 goto error; 3036 goto error;
3083 } 3037 }
3084 } else { 3038 } else {
3085 PDEBUG(D_ERR, "Can't determine sensor slave IDs"); 3039 err("Can't determine sensor slave IDs");
3086 goto error; 3040 goto error;
3087 } 3041 }
3088 3042
@@ -3142,36 +3096,23 @@ static int sd_config(struct gspca_dev *gspca_dev,
3142 goto error; 3096 goto error;
3143 break; 3097 break;
3144 } 3098 }
3145 sd->brightness = BRIGHTNESS_DEF; 3099 gspca_dev->cam.ctrls = sd->ctrls;
3146 if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF) 3100 if (sd->sensor == SEN_OV7670)
3147 sd->contrast = 200; /* The default is too low for the ov6630 */ 3101 gspca_dev->ctrl_dis = 1 << COLORS;
3148 else 3102 else
3149 sd->contrast = CONTRAST_DEF; 3103 gspca_dev->ctrl_dis = (1 << HFLIP) | (1 << VFLIP);
3150 sd->colors = COLOR_DEF;
3151 sd->hflip = HFLIP_DEF;
3152 sd->vflip = VFLIP_DEF;
3153 sd->autobrightness = AUTOBRIGHT_DEF;
3154 if (sd->sensor == SEN_OV7670) {
3155 sd->freq = OV7670_FREQ_DEF;
3156 gspca_dev->ctrl_dis = (1 << FREQ_IDX) | (1 << COLOR_IDX);
3157 } else {
3158 sd->freq = FREQ_DEF;
3159 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) |
3160 (1 << OV7670_FREQ_IDX);
3161 }
3162 sd->quality = QUALITY_DEF; 3104 sd->quality = QUALITY_DEF;
3163 if (sd->sensor == SEN_OV7640 || 3105 if (sd->sensor == SEN_OV7640 ||
3164 sd->sensor == SEN_OV7648) 3106 sd->sensor == SEN_OV7648)
3165 gspca_dev->ctrl_dis |= (1 << AUTOBRIGHT_IDX) | 3107 gspca_dev->ctrl_dis |= (1 << AUTOBRIGHT) | (1 << CONTRAST);
3166 (1 << CONTRAST_IDX);
3167 if (sd->sensor == SEN_OV7670) 3108 if (sd->sensor == SEN_OV7670)
3168 gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT_IDX; 3109 gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT;
3169 /* OV8610 Frequency filter control should work but needs testing */ 3110 /* OV8610 Frequency filter control should work but needs testing */
3170 if (sd->sensor == SEN_OV8610) 3111 if (sd->sensor == SEN_OV8610)
3171 gspca_dev->ctrl_dis |= 1 << FREQ_IDX; 3112 gspca_dev->ctrl_dis |= 1 << FREQ;
3172 /* No controls for the OV2610/OV3610 */ 3113 /* No controls for the OV2610/OV3610 */
3173 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) 3114 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
3174 gspca_dev->ctrl_dis |= 0xFF; 3115 gspca_dev->ctrl_dis |= (1 << NCTRL) - 1;
3175 3116
3176 return 0; 3117 return 0;
3177error: 3118error:
@@ -3206,6 +3147,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
3206 break; 3147 break;
3207 case SEN_OV6630: 3148 case SEN_OV6630:
3208 case SEN_OV66308AF: 3149 case SEN_OV66308AF:
3150 sd->ctrls[CONTRAST].def = 200;
3151 /* The default is too low for the ov6630 */
3209 if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) 3152 if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30)))
3210 return -EIO; 3153 return -EIO;
3211 break; 3154 break;
@@ -3228,6 +3171,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
3228 return -EIO; 3171 return -EIO;
3229 break; 3172 break;
3230 case SEN_OV7670: 3173 case SEN_OV7670:
3174 sd->ctrls[FREQ].max = 3; /* auto */
3175 sd->ctrls[FREQ].def = 3;
3231 if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) 3176 if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670)))
3232 return -EIO; 3177 return -EIO;
3233 break; 3178 break;
@@ -3253,7 +3198,7 @@ static int ov511_mode_init_regs(struct sd *sd)
3253 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 3198 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
3254 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 3199 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
3255 if (!alt) { 3200 if (!alt) {
3256 PDEBUG(D_ERR, "Couldn't get altsetting"); 3201 err("Couldn't get altsetting");
3257 return -EIO; 3202 return -EIO;
3258 } 3203 }
3259 3204
@@ -3377,7 +3322,7 @@ static int ov518_mode_init_regs(struct sd *sd)
3377 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 3322 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
3378 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 3323 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
3379 if (!alt) { 3324 if (!alt) {
3380 PDEBUG(D_ERR, "Couldn't get altsetting"); 3325 err("Couldn't get altsetting");
3381 return -EIO; 3326 return -EIO;
3382 } 3327 }
3383 3328
@@ -3706,7 +3651,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd)
3706 break; 3651 break;
3707 case SEN_OV7610: 3652 case SEN_OV7610:
3708 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); 3653 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20);
3709 i2c_w(sd, 0x35, qvga?0x1e:0x9e); 3654 i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e);
3710 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ 3655 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */
3711 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ 3656 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */
3712 break; 3657 break;
@@ -3798,15 +3743,17 @@ static int mode_init_ov_sensor_regs(struct sd *sd)
3798 return 0; 3743 return 0;
3799} 3744}
3800 3745
3801static void sethvflip(struct sd *sd) 3746static void sethvflip(struct gspca_dev *gspca_dev)
3802{ 3747{
3748 struct sd *sd = (struct sd *) gspca_dev;
3749
3803 if (sd->sensor != SEN_OV7670) 3750 if (sd->sensor != SEN_OV7670)
3804 return; 3751 return;
3805 if (sd->gspca_dev.streaming) 3752 if (sd->gspca_dev.streaming)
3806 ov51x_stop(sd); 3753 ov51x_stop(sd);
3807 i2c_w_mask(sd, OV7670_REG_MVFP, 3754 i2c_w_mask(sd, OV7670_REG_MVFP,
3808 OV7670_MVFP_MIRROR * sd->hflip 3755 OV7670_MVFP_MIRROR * sd->ctrls[HFLIP].val
3809 | OV7670_MVFP_VFLIP * sd->vflip, 3756 | OV7670_MVFP_VFLIP * sd->ctrls[VFLIP].val,
3810 OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP); 3757 OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP);
3811 if (sd->gspca_dev.streaming) 3758 if (sd->gspca_dev.streaming)
3812 ov51x_restart(sd); 3759 ov51x_restart(sd);
@@ -3957,9 +3904,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
3957 setcontrast(gspca_dev); 3904 setcontrast(gspca_dev);
3958 setbrightness(gspca_dev); 3905 setbrightness(gspca_dev);
3959 setcolors(gspca_dev); 3906 setcolors(gspca_dev);
3960 sethvflip(sd); 3907 sethvflip(gspca_dev);
3961 setautobrightness(sd); 3908 setautobright(gspca_dev);
3962 setfreq(sd); 3909 setfreq_i(sd);
3963 3910
3964 /* Force clear snapshot state in case the snapshot button was 3911 /* Force clear snapshot state in case the snapshot button was
3965 pressed while we weren't streaming */ 3912 pressed while we weren't streaming */
@@ -4000,7 +3947,7 @@ static void ov51x_handle_button(struct gspca_dev *gspca_dev, u8 state)
4000 struct sd *sd = (struct sd *) gspca_dev; 3947 struct sd *sd = (struct sd *) gspca_dev;
4001 3948
4002 if (sd->snapshot_pressed != state) { 3949 if (sd->snapshot_pressed != state) {
4003#ifdef CONFIG_INPUT 3950#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
4004 input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); 3951 input_report_key(gspca_dev->input_dev, KEY_CAMERA, state);
4005 input_sync(gspca_dev->input_dev); 3952 input_sync(gspca_dev->input_dev);
4006#endif 3953#endif
@@ -4214,7 +4161,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
4214 struct sd *sd = (struct sd *) gspca_dev; 4161 struct sd *sd = (struct sd *) gspca_dev;
4215 int val; 4162 int val;
4216 4163
4217 val = sd->brightness; 4164 val = sd->ctrls[BRIGHTNESS].val;
4218 switch (sd->sensor) { 4165 switch (sd->sensor) {
4219 case SEN_OV8610: 4166 case SEN_OV8610:
4220 case SEN_OV7610: 4167 case SEN_OV7610:
@@ -4229,7 +4176,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
4229 case SEN_OV7620: 4176 case SEN_OV7620:
4230 case SEN_OV7620AE: 4177 case SEN_OV7620AE:
4231 /* 7620 doesn't like manual changes when in auto mode */ 4178 /* 7620 doesn't like manual changes when in auto mode */
4232 if (!sd->autobrightness) 4179 if (!sd->ctrls[AUTOBRIGHT].val)
4233 i2c_w(sd, OV7610_REG_BRT, val); 4180 i2c_w(sd, OV7610_REG_BRT, val);
4234 break; 4181 break;
4235 case SEN_OV7670: 4182 case SEN_OV7670:
@@ -4245,7 +4192,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
4245 struct sd *sd = (struct sd *) gspca_dev; 4192 struct sd *sd = (struct sd *) gspca_dev;
4246 int val; 4193 int val;
4247 4194
4248 val = sd->contrast; 4195 val = sd->ctrls[CONTRAST].val;
4249 switch (sd->sensor) { 4196 switch (sd->sensor) {
4250 case SEN_OV7610: 4197 case SEN_OV7610:
4251 case SEN_OV6620: 4198 case SEN_OV6620:
@@ -4287,7 +4234,7 @@ static void setcolors(struct gspca_dev *gspca_dev)
4287 struct sd *sd = (struct sd *) gspca_dev; 4234 struct sd *sd = (struct sd *) gspca_dev;
4288 int val; 4235 int val;
4289 4236
4290 val = sd->colors; 4237 val = sd->ctrls[COLORS].val;
4291 switch (sd->sensor) { 4238 switch (sd->sensor) {
4292 case SEN_OV8610: 4239 case SEN_OV8610:
4293 case SEN_OV7610: 4240 case SEN_OV7610:
@@ -4317,23 +4264,25 @@ static void setcolors(struct gspca_dev *gspca_dev)
4317 } 4264 }
4318} 4265}
4319 4266
4320static void setautobrightness(struct sd *sd) 4267static void setautobright(struct gspca_dev *gspca_dev)
4321{ 4268{
4269 struct sd *sd = (struct sd *) gspca_dev;
4270
4322 if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7648 || 4271 if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7648 ||
4323 sd->sensor == SEN_OV7670 || 4272 sd->sensor == SEN_OV7670 ||
4324 sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) 4273 sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
4325 return; 4274 return;
4326 4275
4327 i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10); 4276 i2c_w_mask(sd, 0x2d, sd->ctrls[AUTOBRIGHT].val ? 0x10 : 0x00, 0x10);
4328} 4277}
4329 4278
4330static void setfreq(struct sd *sd) 4279static void setfreq_i(struct sd *sd)
4331{ 4280{
4332 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) 4281 if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610)
4333 return; 4282 return;
4334 4283
4335 if (sd->sensor == SEN_OV7670) { 4284 if (sd->sensor == SEN_OV7670) {
4336 switch (sd->freq) { 4285 switch (sd->ctrls[FREQ].val) {
4337 case 0: /* Banding filter disabled */ 4286 case 0: /* Banding filter disabled */
4338 i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT); 4287 i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT);
4339 break; 4288 break;
@@ -4355,7 +4304,7 @@ static void setfreq(struct sd *sd)
4355 break; 4304 break;
4356 } 4305 }
4357 } else { 4306 } else {
4358 switch (sd->freq) { 4307 switch (sd->ctrls[FREQ].val) {
4359 case 0: /* Banding filter disabled */ 4308 case 0: /* Banding filter disabled */
4360 i2c_w_mask(sd, 0x2d, 0x00, 0x04); 4309 i2c_w_mask(sd, 0x2d, 0x00, 0x04);
4361 i2c_w_mask(sd, 0x2a, 0x00, 0x80); 4310 i2c_w_mask(sd, 0x2a, 0x00, 0x80);
@@ -4387,135 +4336,15 @@ static void setfreq(struct sd *sd)
4387 } 4336 }
4388 } 4337 }
4389} 4338}
4390 4339static void setfreq(struct gspca_dev *gspca_dev)
4391static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
4392{
4393 struct sd *sd = (struct sd *) gspca_dev;
4394
4395 sd->brightness = val;
4396 if (gspca_dev->streaming)
4397 setbrightness(gspca_dev);
4398 return 0;
4399}
4400
4401static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
4402{
4403 struct sd *sd = (struct sd *) gspca_dev;
4404
4405 *val = sd->brightness;
4406 return 0;
4407}
4408
4409static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
4410{
4411 struct sd *sd = (struct sd *) gspca_dev;
4412
4413 sd->contrast = val;
4414 if (gspca_dev->streaming)
4415 setcontrast(gspca_dev);
4416 return 0;
4417}
4418
4419static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
4420{
4421 struct sd *sd = (struct sd *) gspca_dev;
4422
4423 *val = sd->contrast;
4424 return 0;
4425}
4426
4427static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
4428{
4429 struct sd *sd = (struct sd *) gspca_dev;
4430
4431 sd->colors = val;
4432 if (gspca_dev->streaming)
4433 setcolors(gspca_dev);
4434 return 0;
4435}
4436
4437static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
4438{
4439 struct sd *sd = (struct sd *) gspca_dev;
4440
4441 *val = sd->colors;
4442 return 0;
4443}
4444
4445static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
4446{
4447 struct sd *sd = (struct sd *) gspca_dev;
4448
4449 sd->hflip = val;
4450 if (gspca_dev->streaming)
4451 sethvflip(sd);
4452 return 0;
4453}
4454
4455static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
4456{
4457 struct sd *sd = (struct sd *) gspca_dev;
4458
4459 *val = sd->hflip;
4460 return 0;
4461}
4462
4463static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
4464{
4465 struct sd *sd = (struct sd *) gspca_dev;
4466
4467 sd->vflip = val;
4468 if (gspca_dev->streaming)
4469 sethvflip(sd);
4470 return 0;
4471}
4472
4473static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
4474{
4475 struct sd *sd = (struct sd *) gspca_dev;
4476
4477 *val = sd->vflip;
4478 return 0;
4479}
4480
4481static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val)
4482{
4483 struct sd *sd = (struct sd *) gspca_dev;
4484
4485 sd->autobrightness = val;
4486 if (gspca_dev->streaming)
4487 setautobrightness(sd);
4488 return 0;
4489}
4490
4491static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val)
4492{
4493 struct sd *sd = (struct sd *) gspca_dev;
4494
4495 *val = sd->autobrightness;
4496 return 0;
4497}
4498
4499static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
4500{ 4340{
4501 struct sd *sd = (struct sd *) gspca_dev; 4341 struct sd *sd = (struct sd *) gspca_dev;
4502 4342
4503 sd->freq = val; 4343 setfreq_i(sd);
4504 if (gspca_dev->streaming) {
4505 setfreq(sd);
4506 /* Ugly but necessary */
4507 if (sd->bridge == BRIDGE_W9968CF)
4508 w9968cf_set_crop_window(sd);
4509 }
4510 return 0;
4511}
4512
4513static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
4514{
4515 struct sd *sd = (struct sd *) gspca_dev;
4516 4344
4517 *val = sd->freq; 4345 /* Ugly but necessary */
4518 return 0; 4346 if (sd->bridge == BRIDGE_W9968CF)
4347 w9968cf_set_crop_window(sd);
4519} 4348}
4520 4349
4521static int sd_querymenu(struct gspca_dev *gspca_dev, 4350static int sd_querymenu(struct gspca_dev *gspca_dev,
@@ -4601,7 +4430,7 @@ static const struct sd_desc sd_desc = {
4601 .querymenu = sd_querymenu, 4430 .querymenu = sd_querymenu,
4602 .get_jcomp = sd_get_jcomp, 4431 .get_jcomp = sd_get_jcomp,
4603 .set_jcomp = sd_set_jcomp, 4432 .set_jcomp = sd_set_jcomp,
4604#ifdef CONFIG_INPUT 4433#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
4605 .other_input = 1, 4434 .other_input = 1,
4606#endif 4435#endif
4607}; 4436};
@@ -4663,17 +4492,11 @@ static struct usb_driver sd_driver = {
4663/* -- module insert / remove -- */ 4492/* -- module insert / remove -- */
4664static int __init sd_mod_init(void) 4493static int __init sd_mod_init(void)
4665{ 4494{
4666 int ret; 4495 return usb_register(&sd_driver);
4667 ret = usb_register(&sd_driver);
4668 if (ret < 0)
4669 return ret;
4670 PDEBUG(D_PROBE, "registered");
4671 return 0;
4672} 4496}
4673static void __exit sd_mod_exit(void) 4497static void __exit sd_mod_exit(void)
4674{ 4498{
4675 usb_deregister(&sd_driver); 4499 usb_deregister(&sd_driver);
4676 PDEBUG(D_PROBE, "deregistered");
4677} 4500}
4678 4501
4679module_init(sd_mod_init); 4502module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index 96cb3a976581..88ef03f6235b 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -487,7 +487,7 @@ static void ov534_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val)
487 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 487 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
488 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 488 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
489 if (ret < 0) 489 if (ret < 0)
490 PDEBUG(D_ERR, "write failed"); 490 err("write failed %d", ret);
491} 491}
492 492
493static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) 493static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg)
@@ -502,7 +502,7 @@ static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg)
502 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 502 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
503 PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, gspca_dev->usb_buf[0]); 503 PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, gspca_dev->usb_buf[0]);
504 if (ret < 0) 504 if (ret < 0)
505 PDEBUG(D_ERR, "read failed"); 505 err("read failed %d", ret);
506 return gspca_dev->usb_buf[0]; 506 return gspca_dev->usb_buf[0];
507} 507}
508 508
@@ -564,7 +564,7 @@ static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val)
564 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); 564 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3);
565 565
566 if (!sccb_check_status(gspca_dev)) 566 if (!sccb_check_status(gspca_dev))
567 PDEBUG(D_ERR, "sccb_reg_write failed"); 567 err("sccb_reg_write failed");
568} 568}
569 569
570static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) 570static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg)
@@ -572,11 +572,11 @@ static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg)
572 ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); 572 ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg);
573 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2); 573 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2);
574 if (!sccb_check_status(gspca_dev)) 574 if (!sccb_check_status(gspca_dev))
575 PDEBUG(D_ERR, "sccb_reg_read failed 1"); 575 err("sccb_reg_read failed 1");
576 576
577 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2); 577 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2);
578 if (!sccb_check_status(gspca_dev)) 578 if (!sccb_check_status(gspca_dev))
579 PDEBUG(D_ERR, "sccb_reg_read failed 2"); 579 err("sccb_reg_read failed 2");
580 580
581 return ov534_reg_read(gspca_dev, OV534_REG_READ); 581 return ov534_reg_read(gspca_dev, OV534_REG_READ);
582} 582}
@@ -1327,19 +1327,12 @@ static struct usb_driver sd_driver = {
1327/* -- module insert / remove -- */ 1327/* -- module insert / remove -- */
1328static int __init sd_mod_init(void) 1328static int __init sd_mod_init(void)
1329{ 1329{
1330 int ret; 1330 return usb_register(&sd_driver);
1331
1332 ret = usb_register(&sd_driver);
1333 if (ret < 0)
1334 return ret;
1335 PDEBUG(D_PROBE, "registered");
1336 return 0;
1337} 1331}
1338 1332
1339static void __exit sd_mod_exit(void) 1333static void __exit sd_mod_exit(void)
1340{ 1334{
1341 usb_deregister(&sd_driver); 1335 usb_deregister(&sd_driver);
1342 PDEBUG(D_PROBE, "deregistered");
1343} 1336}
1344 1337
1345module_init(sd_mod_init); 1338module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/ov534_9.c b/drivers/media/video/gspca/ov534_9.c
index bbe5a030e3b4..e831f0d280ea 100644
--- a/drivers/media/video/gspca/ov534_9.c
+++ b/drivers/media/video/gspca/ov534_9.c
@@ -785,7 +785,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev, u16 reg, u8 val)
785 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 785 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
786 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 786 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
787 if (ret < 0) { 787 if (ret < 0) {
788 PDEBUG(D_ERR, "reg_w failed %d", ret); 788 err("reg_w failed %d", ret);
789 gspca_dev->usb_err = ret; 789 gspca_dev->usb_err = ret;
790 } 790 }
791} 791}
@@ -810,7 +810,7 @@ static u8 reg_r(struct gspca_dev *gspca_dev, u16 reg)
810 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 810 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
811 PDEBUG(D_USBI, "reg_r [%04x] -> %02x", reg, gspca_dev->usb_buf[0]); 811 PDEBUG(D_USBI, "reg_r [%04x] -> %02x", reg, gspca_dev->usb_buf[0]);
812 if (ret < 0) { 812 if (ret < 0) {
813 PDEBUG(D_ERR, "reg_r err %d", ret); 813 err("reg_r err %d", ret);
814 gspca_dev->usb_err = ret; 814 gspca_dev->usb_err = ret;
815 } 815 }
816 return gspca_dev->usb_buf[0]; 816 return gspca_dev->usb_buf[0];
@@ -848,7 +848,7 @@ static void sccb_write(struct gspca_dev *gspca_dev, u8 reg, u8 val)
848 reg_w_i(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); 848 reg_w_i(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3);
849 849
850 if (!sccb_check_status(gspca_dev)) 850 if (!sccb_check_status(gspca_dev))
851 PDEBUG(D_ERR, "sccb_write failed"); 851 err("sccb_write failed");
852} 852}
853 853
854static u8 sccb_read(struct gspca_dev *gspca_dev, u16 reg) 854static u8 sccb_read(struct gspca_dev *gspca_dev, u16 reg)
@@ -856,11 +856,11 @@ static u8 sccb_read(struct gspca_dev *gspca_dev, u16 reg)
856 reg_w(gspca_dev, OV534_REG_SUBADDR, reg); 856 reg_w(gspca_dev, OV534_REG_SUBADDR, reg);
857 reg_w(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2); 857 reg_w(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2);
858 if (!sccb_check_status(gspca_dev)) 858 if (!sccb_check_status(gspca_dev))
859 PDEBUG(D_ERR, "sccb_read failed 1"); 859 err("sccb_read failed 1");
860 860
861 reg_w(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2); 861 reg_w(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2);
862 if (!sccb_check_status(gspca_dev)) 862 if (!sccb_check_status(gspca_dev))
863 PDEBUG(D_ERR, "sccb_read failed 2"); 863 err("sccb_read failed 2");
864 864
865 return reg_r(gspca_dev, OV534_REG_READ); 865 return reg_r(gspca_dev, OV534_REG_READ);
866} 866}
@@ -1458,19 +1458,12 @@ static struct usb_driver sd_driver = {
1458/* -- module insert / remove -- */ 1458/* -- module insert / remove -- */
1459static int __init sd_mod_init(void) 1459static int __init sd_mod_init(void)
1460{ 1460{
1461 int ret; 1461 return usb_register(&sd_driver);
1462
1463 ret = usb_register(&sd_driver);
1464 if (ret < 0)
1465 return ret;
1466 PDEBUG(D_PROBE, "registered");
1467 return 0;
1468} 1462}
1469 1463
1470static void __exit sd_mod_exit(void) 1464static void __exit sd_mod_exit(void)
1471{ 1465{
1472 usb_deregister(&sd_driver); 1466 usb_deregister(&sd_driver);
1473 PDEBUG(D_PROBE, "deregistered");
1474} 1467}
1475 1468
1476module_init(sd_mod_init); 1469module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index a40f8893310d..15e97fa4c337 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Pixart PAC207BCA library 2 * Pixart PAC207BCA library
3 * 3 *
4 * Copyright (C) 2008 Hans de Goede <hdgoede@redhat.com> 4 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
5 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li 5 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
6 * Copyleft (C) 2005 Michel Xhaard mxhaard@magic.fr 6 * Copyleft (C) 2005 Michel Xhaard mxhaard@magic.fr
7 * 7 *
@@ -28,7 +28,7 @@
28#include <linux/input.h> 28#include <linux/input.h>
29#include "gspca.h" 29#include "gspca.h"
30 30
31MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); 31MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
32MODULE_DESCRIPTION("Pixart PAC207"); 32MODULE_DESCRIPTION("Pixart PAC207");
33MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
34 34
@@ -45,7 +45,7 @@ MODULE_LICENSE("GPL");
45 45
46#define PAC207_GAIN_MIN 0 46#define PAC207_GAIN_MIN 0
47#define PAC207_GAIN_MAX 31 47#define PAC207_GAIN_MAX 31
48#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */ 48#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */
49#define PAC207_GAIN_KNEE 31 49#define PAC207_GAIN_KNEE 31
50 50
51#define PAC207_AUTOGAIN_DEADZONE 30 51#define PAC207_AUTOGAIN_DEADZONE 30
@@ -178,8 +178,7 @@ static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
178 0x00, index, 178 0x00, index,
179 gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT); 179 gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT);
180 if (err < 0) 180 if (err < 0)
181 PDEBUG(D_ERR, 181 err("Failed to write registers to index 0x%04X, error %d)",
182 "Failed to write registers to index 0x%04X, error %d)",
183 index, err); 182 index, err);
184 183
185 return err; 184 return err;
@@ -195,7 +194,7 @@ static int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
195 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 194 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
196 value, index, NULL, 0, PAC207_CTRL_TIMEOUT); 195 value, index, NULL, 0, PAC207_CTRL_TIMEOUT);
197 if (err) 196 if (err)
198 PDEBUG(D_ERR, "Failed to write a register (index 0x%04X," 197 err("Failed to write a register (index 0x%04X,"
199 " value 0x%02X, error %d)", index, value, err); 198 " value 0x%02X, error %d)", index, value, err);
200 199
201 return err; 200 return err;
@@ -211,8 +210,7 @@ static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
211 0x00, index, 210 0x00, index,
212 gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT); 211 gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT);
213 if (res < 0) { 212 if (res < 0) {
214 PDEBUG(D_ERR, 213 err("Failed to read a register (index 0x%04X, error %d)",
215 "Failed to read a register (index 0x%04X, error %d)",
216 index, res); 214 index, res);
217 return res; 215 return res;
218 } 216 }
@@ -496,7 +494,7 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
496 return 0; 494 return 0;
497} 495}
498 496
499#ifdef CONFIG_INPUT 497#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
500static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 498static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
501 u8 *data, /* interrupt packet data */ 499 u8 *data, /* interrupt packet data */
502 int len) /* interrput packet length */ 500 int len) /* interrput packet length */
@@ -526,7 +524,7 @@ static const struct sd_desc sd_desc = {
526 .stopN = sd_stopN, 524 .stopN = sd_stopN,
527 .dq_callback = pac207_do_auto_gain, 525 .dq_callback = pac207_do_auto_gain,
528 .pkt_scan = sd_pkt_scan, 526 .pkt_scan = sd_pkt_scan,
529#ifdef CONFIG_INPUT 527#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
530 .int_pkt_scan = sd_int_pkt_scan, 528 .int_pkt_scan = sd_int_pkt_scan,
531#endif 529#endif
532}; 530};
@@ -572,17 +570,11 @@ static struct usb_driver sd_driver = {
572/* -- module insert / remove -- */ 570/* -- module insert / remove -- */
573static int __init sd_mod_init(void) 571static int __init sd_mod_init(void)
574{ 572{
575 int ret; 573 return usb_register(&sd_driver);
576 ret = usb_register(&sd_driver);
577 if (ret < 0)
578 return ret;
579 PDEBUG(D_PROBE, "registered");
580 return 0;
581} 574}
582static void __exit sd_mod_exit(void) 575static void __exit sd_mod_exit(void)
583{ 576{
584 usb_deregister(&sd_driver); 577 usb_deregister(&sd_driver);
585 PDEBUG(D_PROBE, "deregistered");
586} 578}
587 579
588module_init(sd_mod_init); 580module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c
index a66df07d7625..55fbea7381b0 100644
--- a/drivers/media/video/gspca/pac7302.c
+++ b/drivers/media/video/gspca/pac7302.c
@@ -408,9 +408,8 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
408 index, gspca_dev->usb_buf, len, 408 index, gspca_dev->usb_buf, len,
409 500); 409 500);
410 if (ret < 0) { 410 if (ret < 0) {
411 PDEBUG(D_ERR, "reg_w_buf(): " 411 err("reg_w_buf failed index 0x%02x, error %d",
412 "Failed to write registers to index 0x%x, error %i", 412 index, ret);
413 index, ret);
414 gspca_dev->usb_err = ret; 413 gspca_dev->usb_err = ret;
415 } 414 }
416} 415}
@@ -432,9 +431,8 @@ static void reg_w(struct gspca_dev *gspca_dev,
432 0, index, gspca_dev->usb_buf, 1, 431 0, index, gspca_dev->usb_buf, 1,
433 500); 432 500);
434 if (ret < 0) { 433 if (ret < 0) {
435 PDEBUG(D_ERR, "reg_w(): " 434 err("reg_w() failed index 0x%02x, value 0x%02x, error %d",
436 "Failed to write register to index 0x%x, value 0x%x, error %i", 435 index, value, ret);
437 index, value, ret);
438 gspca_dev->usb_err = ret; 436 gspca_dev->usb_err = ret;
439 } 437 }
440} 438}
@@ -468,10 +466,9 @@ static void reg_w_page(struct gspca_dev *gspca_dev,
468 0, index, gspca_dev->usb_buf, 1, 466 0, index, gspca_dev->usb_buf, 1,
469 500); 467 500);
470 if (ret < 0) { 468 if (ret < 0) {
471 PDEBUG(D_ERR, "reg_w_page(): " 469 err("reg_w_page() failed index 0x%02x, "
472 "Failed to write register to index 0x%x, " 470 "value 0x%02x, error %d",
473 "value 0x%x, error %i", 471 index, page[index], ret);
474 index, page[index], ret);
475 gspca_dev->usb_err = ret; 472 gspca_dev->usb_err = ret;
476 break; 473 break;
477 } 474 }
@@ -900,9 +897,8 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
900 struct sd *sd = (struct sd *) gspca_dev; 897 struct sd *sd = (struct sd *) gspca_dev;
901 898
902 sd->contrast = val; 899 sd->contrast = val;
903 if (gspca_dev->streaming) { 900 if (gspca_dev->streaming)
904 setbrightcont(gspca_dev); 901 setbrightcont(gspca_dev);
905 }
906 return gspca_dev->usb_err; 902 return gspca_dev->usb_err;
907} 903}
908 904
@@ -1135,7 +1131,7 @@ static int sd_chip_ident(struct gspca_dev *gspca_dev,
1135} 1131}
1136#endif 1132#endif
1137 1133
1138#ifdef CONFIG_INPUT 1134#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1139static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 1135static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
1140 u8 *data, /* interrupt packet data */ 1136 u8 *data, /* interrupt packet data */
1141 int len) /* interrput packet length */ 1137 int len) /* interrput packet length */
@@ -1182,7 +1178,7 @@ static const struct sd_desc sd_desc = {
1182 .set_register = sd_dbg_s_register, 1178 .set_register = sd_dbg_s_register,
1183 .get_chip_ident = sd_chip_ident, 1179 .get_chip_ident = sd_chip_ident,
1184#endif 1180#endif
1185#ifdef CONFIG_INPUT 1181#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1186 .int_pkt_scan = sd_int_pkt_scan, 1182 .int_pkt_scan = sd_int_pkt_scan,
1187#endif 1183#endif
1188}; 1184};
@@ -1226,17 +1222,11 @@ static struct usb_driver sd_driver = {
1226/* -- module insert / remove -- */ 1222/* -- module insert / remove -- */
1227static int __init sd_mod_init(void) 1223static int __init sd_mod_init(void)
1228{ 1224{
1229 int ret; 1225 return usb_register(&sd_driver);
1230 ret = usb_register(&sd_driver);
1231 if (ret < 0)
1232 return ret;
1233 PDEBUG(D_PROBE, "registered");
1234 return 0;
1235} 1226}
1236static void __exit sd_mod_exit(void) 1227static void __exit sd_mod_exit(void)
1237{ 1228{
1238 usb_deregister(&sd_driver); 1229 usb_deregister(&sd_driver);
1239 PDEBUG(D_PROBE, "deregistered");
1240} 1230}
1241 1231
1242module_init(sd_mod_init); 1232module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 1cb7e99e92bd..7657b43b3203 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -276,9 +276,8 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
276 index, gspca_dev->usb_buf, len, 276 index, gspca_dev->usb_buf, len,
277 500); 277 500);
278 if (ret < 0) { 278 if (ret < 0) {
279 PDEBUG(D_ERR, "reg_w_buf(): " 279 err("reg_w_buf() failed index 0x%02x, error %d",
280 "Failed to write registers to index 0x%x, error %i", 280 index, ret);
281 index, ret);
282 gspca_dev->usb_err = ret; 281 gspca_dev->usb_err = ret;
283 } 282 }
284} 283}
@@ -300,9 +299,8 @@ static void reg_w(struct gspca_dev *gspca_dev,
300 0, index, gspca_dev->usb_buf, 1, 299 0, index, gspca_dev->usb_buf, 1,
301 500); 300 500);
302 if (ret < 0) { 301 if (ret < 0) {
303 PDEBUG(D_ERR, "reg_w(): " 302 err("reg_w() failed index 0x%02x, value 0x%02x, error %d",
304 "Failed to write register to index 0x%x, value 0x%x, error %i", 303 index, value, ret);
305 index, value, ret);
306 gspca_dev->usb_err = ret; 304 gspca_dev->usb_err = ret;
307 } 305 }
308} 306}
@@ -336,10 +334,9 @@ static void reg_w_page(struct gspca_dev *gspca_dev,
336 0, index, gspca_dev->usb_buf, 1, 334 0, index, gspca_dev->usb_buf, 1,
337 500); 335 500);
338 if (ret < 0) { 336 if (ret < 0) {
339 PDEBUG(D_ERR, "reg_w_page(): " 337 err("reg_w_page() failed index 0x%02x, "
340 "Failed to write register to index 0x%x, " 338 "value 0x%02x, error %d",
341 "value 0x%x, error %i", 339 index, page[index], ret);
342 index, page[index], ret);
343 gspca_dev->usb_err = ret; 340 gspca_dev->usb_err = ret;
344 break; 341 break;
345 } 342 }
@@ -675,9 +672,8 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
675 struct sd *sd = (struct sd *) gspca_dev; 672 struct sd *sd = (struct sd *) gspca_dev;
676 673
677 sd->contrast = val; 674 sd->contrast = val;
678 if (gspca_dev->streaming) { 675 if (gspca_dev->streaming)
679 setcontrast(gspca_dev); 676 setcontrast(gspca_dev);
680 }
681 return gspca_dev->usb_err; 677 return gspca_dev->usb_err;
682} 678}
683 679
@@ -792,7 +788,7 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
792 return 0; 788 return 0;
793} 789}
794 790
795#ifdef CONFIG_INPUT 791#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
796static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 792static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
797 u8 *data, /* interrupt packet data */ 793 u8 *data, /* interrupt packet data */
798 int len) /* interrupt packet length */ 794 int len) /* interrupt packet length */
@@ -835,7 +831,7 @@ static const struct sd_desc sd_desc = {
835 .stop0 = sd_stop0, 831 .stop0 = sd_stop0,
836 .pkt_scan = sd_pkt_scan, 832 .pkt_scan = sd_pkt_scan,
837 .dq_callback = do_autogain, 833 .dq_callback = do_autogain,
838#ifdef CONFIG_INPUT 834#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
839 .int_pkt_scan = sd_int_pkt_scan, 835 .int_pkt_scan = sd_int_pkt_scan,
840#endif 836#endif
841}; 837};
@@ -874,17 +870,11 @@ static struct usb_driver sd_driver = {
874/* -- module insert / remove -- */ 870/* -- module insert / remove -- */
875static int __init sd_mod_init(void) 871static int __init sd_mod_init(void)
876{ 872{
877 int ret; 873 return usb_register(&sd_driver);
878 ret = usb_register(&sd_driver);
879 if (ret < 0)
880 return ret;
881 PDEBUG(D_PROBE, "registered");
882 return 0;
883} 874}
884static void __exit sd_mod_exit(void) 875static void __exit sd_mod_exit(void)
885{ 876{
886 usb_deregister(&sd_driver); 877 usb_deregister(&sd_driver);
887 PDEBUG(D_PROBE, "deregistered");
888} 878}
889 879
890module_init(sd_mod_init); 880module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sn9c2028.c b/drivers/media/video/gspca/sn9c2028.c
index 71d9447a7986..40a06680502d 100644
--- a/drivers/media/video/gspca/sn9c2028.c
+++ b/drivers/media/video/gspca/sn9c2028.c
@@ -75,7 +75,7 @@ static int sn9c2028_command(struct gspca_dev *gspca_dev, u8 *command)
75 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 75 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
76 2, 0, gspca_dev->usb_buf, 6, 500); 76 2, 0, gspca_dev->usb_buf, 6, 500);
77 if (rc < 0) { 77 if (rc < 0) {
78 PDEBUG(D_ERR, "command write [%02x] error %d", 78 err("command write [%02x] error %d",
79 gspca_dev->usb_buf[0], rc); 79 gspca_dev->usb_buf[0], rc);
80 return rc; 80 return rc;
81 } 81 }
@@ -93,7 +93,7 @@ static int sn9c2028_read1(struct gspca_dev *gspca_dev)
93 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 93 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
94 1, 0, gspca_dev->usb_buf, 1, 500); 94 1, 0, gspca_dev->usb_buf, 1, 500);
95 if (rc != 1) { 95 if (rc != 1) {
96 PDEBUG(D_ERR, "read1 error %d", rc); 96 err("read1 error %d", rc);
97 return (rc < 0) ? rc : -EIO; 97 return (rc < 0) ? rc : -EIO;
98 } 98 }
99 PDEBUG(D_USBI, "read1 response %02x", gspca_dev->usb_buf[0]); 99 PDEBUG(D_USBI, "read1 response %02x", gspca_dev->usb_buf[0]);
@@ -109,7 +109,7 @@ static int sn9c2028_read4(struct gspca_dev *gspca_dev, u8 *reading)
109 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 109 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
110 4, 0, gspca_dev->usb_buf, 4, 500); 110 4, 0, gspca_dev->usb_buf, 4, 500);
111 if (rc != 4) { 111 if (rc != 4) {
112 PDEBUG(D_ERR, "read4 error %d", rc); 112 err("read4 error %d", rc);
113 return (rc < 0) ? rc : -EIO; 113 return (rc < 0) ? rc : -EIO;
114 } 114 }
115 memcpy(reading, gspca_dev->usb_buf, 4); 115 memcpy(reading, gspca_dev->usb_buf, 4);
@@ -131,7 +131,7 @@ static int sn9c2028_long_command(struct gspca_dev *gspca_dev, u8 *command)
131 for (i = 0; i < 256 && status < 2; i++) 131 for (i = 0; i < 256 && status < 2; i++)
132 status = sn9c2028_read1(gspca_dev); 132 status = sn9c2028_read1(gspca_dev);
133 if (status != 2) { 133 if (status != 2) {
134 PDEBUG(D_ERR, "long command status read error %d", status); 134 err("long command status read error %d", status);
135 return (status < 0) ? status : -EIO; 135 return (status < 0) ? status : -EIO;
136 } 136 }
137 137
@@ -638,7 +638,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
638 err_code = start_vivitar_cam(gspca_dev); 638 err_code = start_vivitar_cam(gspca_dev);
639 break; 639 break;
640 default: 640 default:
641 PDEBUG(D_ERR, "Starting unknown camera, please report this"); 641 err("Starting unknown camera, please report this");
642 return -ENXIO; 642 return -ENXIO;
643 } 643 }
644 644
@@ -738,19 +738,12 @@ static struct usb_driver sd_driver = {
738/* -- module insert / remove -- */ 738/* -- module insert / remove -- */
739static int __init sd_mod_init(void) 739static int __init sd_mod_init(void)
740{ 740{
741 int ret; 741 return usb_register(&sd_driver);
742
743 ret = usb_register(&sd_driver);
744 if (ret < 0)
745 return ret;
746 PDEBUG(D_PROBE, "registered");
747 return 0;
748} 742}
749 743
750static void __exit sd_mod_exit(void) 744static void __exit sd_mod_exit(void)
751{ 745{
752 usb_deregister(&sd_driver); 746 usb_deregister(&sd_driver);
753 PDEBUG(D_PROBE, "deregistered");
754} 747}
755 748
756module_init(sd_mod_init); 749module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index 9052d5702556..6b155ae3a746 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -18,9 +18,7 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#ifdef CONFIG_INPUT
22#include <linux/input.h> 21#include <linux/input.h>
23#endif
24 22
25#include "gspca.h" 23#include "gspca.h"
26#include "jpeg.h" 24#include "jpeg.h"
@@ -347,8 +345,8 @@ static const struct ctrl sd_ctrls[] = {
347 345
348static const struct v4l2_pix_format vga_mode[] = { 346static const struct v4l2_pix_format vga_mode[] = {
349 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 347 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
350 .bytesperline = 240, 348 .bytesperline = 160,
351 .sizeimage = 240 * 120, 349 .sizeimage = 160 * 120 * 4 / 8 + 590,
352 .colorspace = V4L2_COLORSPACE_JPEG, 350 .colorspace = V4L2_COLORSPACE_JPEG,
353 .priv = 0 | MODE_JPEG}, 351 .priv = 0 | MODE_JPEG},
354 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 352 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -357,13 +355,13 @@ static const struct v4l2_pix_format vga_mode[] = {
357 .colorspace = V4L2_COLORSPACE_SRGB, 355 .colorspace = V4L2_COLORSPACE_SRGB,
358 .priv = 0 | MODE_RAW}, 356 .priv = 0 | MODE_RAW},
359 {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 357 {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
360 .bytesperline = 240, 358 .bytesperline = 160,
361 .sizeimage = 240 * 120, 359 .sizeimage = 240 * 120,
362 .colorspace = V4L2_COLORSPACE_SRGB, 360 .colorspace = V4L2_COLORSPACE_SRGB,
363 .priv = 0}, 361 .priv = 0},
364 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 362 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
365 .bytesperline = 480, 363 .bytesperline = 320,
366 .sizeimage = 480 * 240 , 364 .sizeimage = 320 * 240 * 3 / 8 + 590,
367 .colorspace = V4L2_COLORSPACE_JPEG, 365 .colorspace = V4L2_COLORSPACE_JPEG,
368 .priv = 1 | MODE_JPEG}, 366 .priv = 1 | MODE_JPEG},
369 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 367 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -372,13 +370,13 @@ static const struct v4l2_pix_format vga_mode[] = {
372 .colorspace = V4L2_COLORSPACE_SRGB, 370 .colorspace = V4L2_COLORSPACE_SRGB,
373 .priv = 1 | MODE_RAW}, 371 .priv = 1 | MODE_RAW},
374 {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 372 {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
375 .bytesperline = 480, 373 .bytesperline = 320,
376 .sizeimage = 480 * 240 , 374 .sizeimage = 480 * 240 ,
377 .colorspace = V4L2_COLORSPACE_SRGB, 375 .colorspace = V4L2_COLORSPACE_SRGB,
378 .priv = 1}, 376 .priv = 1},
379 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 377 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
380 .bytesperline = 960, 378 .bytesperline = 640,
381 .sizeimage = 960 * 480, 379 .sizeimage = 640 * 480 * 3 / 8 + 590,
382 .colorspace = V4L2_COLORSPACE_JPEG, 380 .colorspace = V4L2_COLORSPACE_JPEG,
383 .priv = 2 | MODE_JPEG}, 381 .priv = 2 | MODE_JPEG},
384 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 382 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -387,7 +385,7 @@ static const struct v4l2_pix_format vga_mode[] = {
387 .colorspace = V4L2_COLORSPACE_SRGB, 385 .colorspace = V4L2_COLORSPACE_SRGB,
388 .priv = 2 | MODE_RAW}, 386 .priv = 2 | MODE_RAW},
389 {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 387 {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
390 .bytesperline = 960, 388 .bytesperline = 640,
391 .sizeimage = 960 * 480, 389 .sizeimage = 960 * 480,
392 .colorspace = V4L2_COLORSPACE_SRGB, 390 .colorspace = V4L2_COLORSPACE_SRGB,
393 .priv = 2}, 391 .priv = 2},
@@ -395,8 +393,8 @@ static const struct v4l2_pix_format vga_mode[] = {
395 393
396static const struct v4l2_pix_format sxga_mode[] = { 394static const struct v4l2_pix_format sxga_mode[] = {
397 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 395 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
398 .bytesperline = 240, 396 .bytesperline = 160,
399 .sizeimage = 240 * 120, 397 .sizeimage = 160 * 120 * 4 / 8 + 590,
400 .colorspace = V4L2_COLORSPACE_JPEG, 398 .colorspace = V4L2_COLORSPACE_JPEG,
401 .priv = 0 | MODE_JPEG}, 399 .priv = 0 | MODE_JPEG},
402 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 400 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -405,13 +403,13 @@ static const struct v4l2_pix_format sxga_mode[] = {
405 .colorspace = V4L2_COLORSPACE_SRGB, 403 .colorspace = V4L2_COLORSPACE_SRGB,
406 .priv = 0 | MODE_RAW}, 404 .priv = 0 | MODE_RAW},
407 {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 405 {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
408 .bytesperline = 240, 406 .bytesperline = 160,
409 .sizeimage = 240 * 120, 407 .sizeimage = 240 * 120,
410 .colorspace = V4L2_COLORSPACE_SRGB, 408 .colorspace = V4L2_COLORSPACE_SRGB,
411 .priv = 0}, 409 .priv = 0},
412 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 410 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
413 .bytesperline = 480, 411 .bytesperline = 320,
414 .sizeimage = 480 * 240 , 412 .sizeimage = 320 * 240 * 3 / 8 + 590,
415 .colorspace = V4L2_COLORSPACE_JPEG, 413 .colorspace = V4L2_COLORSPACE_JPEG,
416 .priv = 1 | MODE_JPEG}, 414 .priv = 1 | MODE_JPEG},
417 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 415 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -420,13 +418,13 @@ static const struct v4l2_pix_format sxga_mode[] = {
420 .colorspace = V4L2_COLORSPACE_SRGB, 418 .colorspace = V4L2_COLORSPACE_SRGB,
421 .priv = 1 | MODE_RAW}, 419 .priv = 1 | MODE_RAW},
422 {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 420 {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
423 .bytesperline = 480, 421 .bytesperline = 320,
424 .sizeimage = 480 * 240 , 422 .sizeimage = 480 * 240 ,
425 .colorspace = V4L2_COLORSPACE_SRGB, 423 .colorspace = V4L2_COLORSPACE_SRGB,
426 .priv = 1}, 424 .priv = 1},
427 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 425 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
428 .bytesperline = 960, 426 .bytesperline = 640,
429 .sizeimage = 960 * 480, 427 .sizeimage = 640 * 480 * 3 / 8 + 590,
430 .colorspace = V4L2_COLORSPACE_JPEG, 428 .colorspace = V4L2_COLORSPACE_JPEG,
431 .priv = 2 | MODE_JPEG}, 429 .priv = 2 | MODE_JPEG},
432 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 430 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
@@ -435,13 +433,13 @@ static const struct v4l2_pix_format sxga_mode[] = {
435 .colorspace = V4L2_COLORSPACE_SRGB, 433 .colorspace = V4L2_COLORSPACE_SRGB,
436 .priv = 2 | MODE_RAW}, 434 .priv = 2 | MODE_RAW},
437 {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, 435 {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE,
438 .bytesperline = 960, 436 .bytesperline = 640,
439 .sizeimage = 960 * 480, 437 .sizeimage = 960 * 480,
440 .colorspace = V4L2_COLORSPACE_SRGB, 438 .colorspace = V4L2_COLORSPACE_SRGB,
441 .priv = 2}, 439 .priv = 2},
442 {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 440 {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
443 .bytesperline = 1280, 441 .bytesperline = 1280,
444 .sizeimage = (1280 * 1024) + 64, 442 .sizeimage = 1280 * 1024,
445 .colorspace = V4L2_COLORSPACE_SRGB, 443 .colorspace = V4L2_COLORSPACE_SRGB,
446 .priv = 3 | MODE_RAW | MODE_SXGA}, 444 .priv = 3 | MODE_RAW | MODE_SXGA},
447}; 445};
@@ -1272,7 +1270,8 @@ static int soi968_init_sensor(struct gspca_dev *gspca_dev)
1272 } 1270 }
1273 } 1271 }
1274 /* disable hflip and vflip */ 1272 /* disable hflip and vflip */
1275 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << EXPOSURE_IDX); 1273 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX)
1274 | (1 << EXPOSURE_IDX);
1276 sd->hstart = 60; 1275 sd->hstart = 60;
1277 sd->vstart = 11; 1276 sd->vstart = 11;
1278 return 0; 1277 return 0;
@@ -1351,7 +1350,9 @@ static int mt9v_init_sensor(struct gspca_dev *gspca_dev)
1351 return -ENODEV; 1350 return -ENODEV;
1352 } 1351 }
1353 } 1352 }
1354 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); 1353 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX)
1354 | (1 << AUTOGAIN_IDX)
1355 | (1 << GAIN_IDX);
1355 sd->hstart = 2; 1356 sd->hstart = 2;
1356 sd->vstart = 2; 1357 sd->vstart = 2;
1357 sd->sensor = SENSOR_MT9V111; 1358 sd->sensor = SENSOR_MT9V111;
@@ -1395,7 +1396,8 @@ static int mt9m112_init_sensor(struct gspca_dev *gspca_dev)
1395 return -ENODEV; 1396 return -ENODEV;
1396 } 1397 }
1397 } 1398 }
1398 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); 1399 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX)
1400 | (1 << GAIN_IDX);
1399 sd->hstart = 0; 1401 sd->hstart = 0;
1400 sd->vstart = 2; 1402 sd->vstart = 2;
1401 return 0; 1403 return 0;
@@ -1412,7 +1414,8 @@ static int mt9m111_init_sensor(struct gspca_dev *gspca_dev)
1412 return -ENODEV; 1414 return -ENODEV;
1413 } 1415 }
1414 } 1416 }
1415 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); 1417 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX)
1418 | (1 << GAIN_IDX);
1416 sd->hstart = 0; 1419 sd->hstart = 0;
1417 sd->vstart = 2; 1420 sd->vstart = 2;
1418 return 0; 1421 return 0;
@@ -2304,7 +2307,7 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev)
2304 do_autoexposure(gspca_dev, avg_lum); 2307 do_autoexposure(gspca_dev, avg_lum);
2305} 2308}
2306 2309
2307#ifdef CONFIG_INPUT 2310#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2308static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 2311static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2309 u8 *data, /* interrupt packet */ 2312 u8 *data, /* interrupt packet */
2310 int len) /* interrupt packet length */ 2313 int len) /* interrupt packet length */
@@ -2386,7 +2389,7 @@ static const struct sd_desc sd_desc = {
2386 .start = sd_start, 2389 .start = sd_start,
2387 .stopN = sd_stopN, 2390 .stopN = sd_stopN,
2388 .pkt_scan = sd_pkt_scan, 2391 .pkt_scan = sd_pkt_scan,
2389#ifdef CONFIG_INPUT 2392#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2390 .int_pkt_scan = sd_int_pkt_scan, 2393 .int_pkt_scan = sd_int_pkt_scan,
2391#endif 2394#endif
2392 .dq_callback = sd_dqcallback, 2395 .dq_callback = sd_dqcallback,
@@ -2467,17 +2470,11 @@ static struct usb_driver sd_driver = {
2467/* -- module insert / remove -- */ 2470/* -- module insert / remove -- */
2468static int __init sd_mod_init(void) 2471static int __init sd_mod_init(void)
2469{ 2472{
2470 int ret; 2473 return usb_register(&sd_driver);
2471 ret = usb_register(&sd_driver);
2472 if (ret < 0)
2473 return ret;
2474 info("registered");
2475 return 0;
2476} 2474}
2477static void __exit sd_mod_exit(void) 2475static void __exit sd_mod_exit(void)
2478{ 2476{
2479 usb_deregister(&sd_driver); 2477 usb_deregister(&sd_driver);
2480 info("deregistered");
2481} 2478}
2482 2479
2483module_init(sd_mod_init); 2480module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 204bb3af4559..706f96f92654 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -323,10 +323,9 @@ static const __u8 initOv6650[] = {
323 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, 323 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b,
324 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07 324 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07
325}; 325};
326static const __u8 ov6650_sensor_init[][8] = 326static const __u8 ov6650_sensor_init[][8] = {
327{
328 /* Bright, contrast, etc are set through SCBB interface. 327 /* Bright, contrast, etc are set through SCBB interface.
329 * AVCAP on win2 do not send any data on this controls. */ 328 * AVCAP on win2 do not send any data on this controls. */
330 /* Anyway, some registers appears to alter bright and constrat */ 329 /* Anyway, some registers appears to alter bright and constrat */
331 330
332 /* Reset sensor */ 331 /* Reset sensor */
@@ -544,7 +543,7 @@ static const __u8 initTas5130[] = {
544 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c 543 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c
545}; 544};
546static const __u8 tas5130_sensor_init[][8] = { 545static const __u8 tas5130_sensor_init[][8] = {
547/* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10}, 546/* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10},
548 * shutter 0x47 short exposure? */ 547 * shutter 0x47 short exposure? */
549 {0x30, 0x11, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10}, 548 {0x30, 0x11, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10},
550 /* shutter 0x01 long exposure */ 549 /* shutter 0x01 long exposure */
@@ -861,7 +860,7 @@ static void setexposure(struct gspca_dev *gspca_dev)
861 i2c[4] |= reg11 - 1; 860 i2c[4] |= reg11 - 1;
862 861
863 /* If register 11 didn't change, don't change it */ 862 /* If register 11 didn't change, don't change it */
864 if (sd->reg11 == reg11 ) 863 if (sd->reg11 == reg11)
865 i2c[0] = 0xa0; 864 i2c[0] = 0xa0;
866 865
867 if (i2c_w(gspca_dev, i2c) == 0) 866 if (i2c_w(gspca_dev, i2c) == 0)
@@ -1388,7 +1387,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
1388 return -EINVAL; 1387 return -EINVAL;
1389} 1388}
1390 1389
1391#ifdef CONFIG_INPUT 1390#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1392static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 1391static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
1393 u8 *data, /* interrupt packet data */ 1392 u8 *data, /* interrupt packet data */
1394 int len) /* interrupt packet length */ 1393 int len) /* interrupt packet length */
@@ -1419,7 +1418,7 @@ static const struct sd_desc sd_desc = {
1419 .pkt_scan = sd_pkt_scan, 1418 .pkt_scan = sd_pkt_scan,
1420 .querymenu = sd_querymenu, 1419 .querymenu = sd_querymenu,
1421 .dq_callback = do_autogain, 1420 .dq_callback = do_autogain,
1422#ifdef CONFIG_INPUT 1421#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1423 .int_pkt_scan = sd_int_pkt_scan, 1422 .int_pkt_scan = sd_int_pkt_scan,
1424#endif 1423#endif
1425}; 1424};
@@ -1479,17 +1478,11 @@ static struct usb_driver sd_driver = {
1479/* -- module insert / remove -- */ 1478/* -- module insert / remove -- */
1480static int __init sd_mod_init(void) 1479static int __init sd_mod_init(void)
1481{ 1480{
1482 int ret; 1481 return usb_register(&sd_driver);
1483 ret = usb_register(&sd_driver);
1484 if (ret < 0)
1485 return ret;
1486 PDEBUG(D_PROBE, "registered");
1487 return 0;
1488} 1482}
1489static void __exit sd_mod_exit(void) 1483static void __exit sd_mod_exit(void)
1490{ 1484{
1491 usb_deregister(&sd_driver); 1485 usb_deregister(&sd_driver);
1492 PDEBUG(D_PROBE, "deregistered");
1493} 1486}
1494 1487
1495module_init(sd_mod_init); 1488module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 370544361be2..330dadc00106 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -31,24 +31,32 @@ MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33 33
34/* controls */
35enum e_ctrl {
36 BRIGHTNESS,
37 CONTRAST,
38 COLORS,
39 BLUE,
40 RED,
41 GAMMA,
42 AUTOGAIN,
43 HFLIP,
44 VFLIP,
45 SHARPNESS,
46 INFRARED,
47 FREQ,
48 NCTRLS /* number of controls */
49};
50
34/* specific webcam descriptor */ 51/* specific webcam descriptor */
35struct sd { 52struct sd {
36 struct gspca_dev gspca_dev; /* !! must be the first item */ 53 struct gspca_dev gspca_dev; /* !! must be the first item */
37 54
55 struct gspca_ctrl ctrls[NCTRLS];
56
38 atomic_t avg_lum; 57 atomic_t avg_lum;
39 u32 exposure; 58 u32 exposure;
40 59
41 u16 brightness;
42 u8 contrast;
43 u8 colors;
44 u8 autogain;
45 u8 blue;
46 u8 red;
47 u8 gamma;
48 u8 vflip; /* ov7630/ov7648 only */
49 u8 sharpness;
50 u8 infrared; /* mt9v111 only */
51 u8 freq; /* ov76xx only */
52 u8 quality; /* image quality */ 60 u8 quality; /* image quality */
53#define QUALITY_MIN 60 61#define QUALITY_MIN 60
54#define QUALITY_MAX 95 62#define QUALITY_MAX 95
@@ -75,6 +83,7 @@ enum sensors {
75 SENSOR_GC0307, 83 SENSOR_GC0307,
76 SENSOR_HV7131R, 84 SENSOR_HV7131R,
77 SENSOR_MI0360, 85 SENSOR_MI0360,
86 SENSOR_MI0360B,
78 SENSOR_MO4000, 87 SENSOR_MO4000,
79 SENSOR_MT9V111, 88 SENSOR_MT9V111,
80 SENSOR_OM6802, 89 SENSOR_OM6802,
@@ -88,48 +97,31 @@ enum sensors {
88}; 97};
89 98
90/* V4L2 controls supported by the driver */ 99/* V4L2 controls supported by the driver */
91static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); 100static void setbrightness(struct gspca_dev *gspca_dev);
92static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 101static void setcontrast(struct gspca_dev *gspca_dev);
93static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); 102static void setcolors(struct gspca_dev *gspca_dev);
94static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 103static void setredblue(struct gspca_dev *gspca_dev);
95static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); 104static void setgamma(struct gspca_dev *gspca_dev);
96static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 105static void setautogain(struct gspca_dev *gspca_dev);
97static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); 106static void sethvflip(struct gspca_dev *gspca_dev);
98static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); 107static void setsharpness(struct gspca_dev *gspca_dev);
99static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); 108static void setinfrared(struct gspca_dev *gspca_dev);
100static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); 109static void setfreq(struct gspca_dev *gspca_dev);
101static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); 110
102static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); 111static const struct ctrl sd_ctrls[NCTRLS] = {
103static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 112[BRIGHTNESS] = {
104static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
105static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
106static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
107static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
108static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
109static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
110static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
111static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
112static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
113
114static const struct ctrl sd_ctrls[] = {
115#define BRIGHTNESS_IDX 0
116 {
117 { 113 {
118 .id = V4L2_CID_BRIGHTNESS, 114 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER, 115 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness", 116 .name = "Brightness",
121 .minimum = 0, 117 .minimum = 0,
122#define BRIGHTNESS_MAX 0xffff 118 .maximum = 0xff,
123 .maximum = BRIGHTNESS_MAX,
124 .step = 1, 119 .step = 1,
125#define BRIGHTNESS_DEF 0x8000 120 .default_value = 0x80,
126 .default_value = BRIGHTNESS_DEF,
127 }, 121 },
128 .set = sd_setbrightness, 122 .set_control = setbrightness
129 .get = sd_getbrightness,
130 }, 123 },
131#define CONTRAST_IDX 1 124[CONTRAST] = {
132 {
133 { 125 {
134 .id = V4L2_CID_CONTRAST, 126 .id = V4L2_CID_CONTRAST,
135 .type = V4L2_CTRL_TYPE_INTEGER, 127 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -138,14 +130,11 @@ static const struct ctrl sd_ctrls[] = {
138#define CONTRAST_MAX 127 130#define CONTRAST_MAX 127
139 .maximum = CONTRAST_MAX, 131 .maximum = CONTRAST_MAX,
140 .step = 1, 132 .step = 1,
141#define CONTRAST_DEF 63 133 .default_value = 63,
142 .default_value = CONTRAST_DEF,
143 }, 134 },
144 .set = sd_setcontrast, 135 .set_control = setcontrast
145 .get = sd_getcontrast,
146 }, 136 },
147#define COLOR_IDX 2 137[COLORS] = {
148 {
149 { 138 {
150 .id = V4L2_CID_SATURATION, 139 .id = V4L2_CID_SATURATION,
151 .type = V4L2_CTRL_TYPE_INTEGER, 140 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -153,14 +142,12 @@ static const struct ctrl sd_ctrls[] = {
153 .minimum = 0, 142 .minimum = 0,
154 .maximum = 40, 143 .maximum = 40,
155 .step = 1, 144 .step = 1,
156#define COLOR_DEF 25 145#define COLORS_DEF 25
157 .default_value = COLOR_DEF, 146 .default_value = COLORS_DEF,
158 }, 147 },
159 .set = sd_setcolors, 148 .set_control = setcolors
160 .get = sd_getcolors,
161 }, 149 },
162#define BLUE_BALANCE_IDX 3 150[BLUE] = {
163 {
164 { 151 {
165 .id = V4L2_CID_BLUE_BALANCE, 152 .id = V4L2_CID_BLUE_BALANCE,
166 .type = V4L2_CTRL_TYPE_INTEGER, 153 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -168,14 +155,11 @@ static const struct ctrl sd_ctrls[] = {
168 .minimum = 24, 155 .minimum = 24,
169 .maximum = 40, 156 .maximum = 40,
170 .step = 1, 157 .step = 1,
171#define BLUE_BALANCE_DEF 32 158 .default_value = 32,
172 .default_value = BLUE_BALANCE_DEF,
173 }, 159 },
174 .set = sd_setblue_balance, 160 .set_control = setredblue
175 .get = sd_getblue_balance,
176 }, 161 },
177#define RED_BALANCE_IDX 4 162[RED] = {
178 {
179 { 163 {
180 .id = V4L2_CID_RED_BALANCE, 164 .id = V4L2_CID_RED_BALANCE,
181 .type = V4L2_CTRL_TYPE_INTEGER, 165 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -183,14 +167,11 @@ static const struct ctrl sd_ctrls[] = {
183 .minimum = 24, 167 .minimum = 24,
184 .maximum = 40, 168 .maximum = 40,
185 .step = 1, 169 .step = 1,
186#define RED_BALANCE_DEF 32 170 .default_value = 32,
187 .default_value = RED_BALANCE_DEF,
188 }, 171 },
189 .set = sd_setred_balance, 172 .set_control = setredblue
190 .get = sd_getred_balance,
191 }, 173 },
192#define GAMMA_IDX 5 174[GAMMA] = {
193 {
194 { 175 {
195 .id = V4L2_CID_GAMMA, 176 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER, 177 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -201,11 +182,9 @@ static const struct ctrl sd_ctrls[] = {
201#define GAMMA_DEF 20 182#define GAMMA_DEF 20
202 .default_value = GAMMA_DEF, 183 .default_value = GAMMA_DEF,
203 }, 184 },
204 .set = sd_setgamma, 185 .set_control = setgamma
205 .get = sd_getgamma,
206 }, 186 },
207#define AUTOGAIN_IDX 6 187[AUTOGAIN] = {
208 {
209 { 188 {
210 .id = V4L2_CID_AUTOGAIN, 189 .id = V4L2_CID_AUTOGAIN,
211 .type = V4L2_CTRL_TYPE_BOOLEAN, 190 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -213,15 +192,23 @@ static const struct ctrl sd_ctrls[] = {
213 .minimum = 0, 192 .minimum = 0,
214 .maximum = 1, 193 .maximum = 1,
215 .step = 1, 194 .step = 1,
216#define AUTOGAIN_DEF 1 195 .default_value = 1
217 .default_value = AUTOGAIN_DEF, 196 },
197 .set_control = setautogain
198 },
199[HFLIP] = {
200 {
201 .id = V4L2_CID_HFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
203 .name = "Mirror",
204 .minimum = 0,
205 .maximum = 1,
206 .step = 1,
207 .default_value = 0,
218 }, 208 },
219 .set = sd_setautogain, 209 .set_control = sethvflip
220 .get = sd_getautogain,
221 }, 210 },
222/* ov7630/ov7648 only */ 211[VFLIP] = {
223#define VFLIP_IDX 7
224 {
225 { 212 {
226 .id = V4L2_CID_VFLIP, 213 .id = V4L2_CID_VFLIP,
227 .type = V4L2_CTRL_TYPE_BOOLEAN, 214 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -229,14 +216,11 @@ static const struct ctrl sd_ctrls[] = {
229 .minimum = 0, 216 .minimum = 0,
230 .maximum = 1, 217 .maximum = 1,
231 .step = 1, 218 .step = 1,
232#define VFLIP_DEF 0 219 .default_value = 0,
233 .default_value = VFLIP_DEF,
234 }, 220 },
235 .set = sd_setvflip, 221 .set_control = sethvflip
236 .get = sd_getvflip,
237 }, 222 },
238#define SHARPNESS_IDX 8 223[SHARPNESS] = {
239 {
240 { 224 {
241 .id = V4L2_CID_SHARPNESS, 225 .id = V4L2_CID_SHARPNESS,
242 .type = V4L2_CTRL_TYPE_INTEGER, 226 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -244,15 +228,12 @@ static const struct ctrl sd_ctrls[] = {
244 .minimum = 0, 228 .minimum = 0,
245 .maximum = 255, 229 .maximum = 255,
246 .step = 1, 230 .step = 1,
247#define SHARPNESS_DEF 90 231 .default_value = 90,
248 .default_value = SHARPNESS_DEF,
249 }, 232 },
250 .set = sd_setsharpness, 233 .set_control = setsharpness
251 .get = sd_getsharpness,
252 }, 234 },
253/* mt9v111 only */ 235/* mt9v111 only */
254#define INFRARED_IDX 9 236[INFRARED] = {
255 {
256 { 237 {
257 .id = V4L2_CID_INFRARED, 238 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN, 239 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -260,15 +241,12 @@ static const struct ctrl sd_ctrls[] = {
260 .minimum = 0, 241 .minimum = 0,
261 .maximum = 1, 242 .maximum = 1,
262 .step = 1, 243 .step = 1,
263#define INFRARED_DEF 0 244 .default_value = 0,
264 .default_value = INFRARED_DEF,
265 }, 245 },
266 .set = sd_setinfrared, 246 .set_control = setinfrared
267 .get = sd_getinfrared,
268 }, 247 },
269/* ov7630/ov7648/ov7660 only */ 248/* ov7630/ov7648/ov7660 only */
270#define FREQ_IDX 10 249[FREQ] = {
271 {
272 { 250 {
273 .id = V4L2_CID_POWER_LINE_FREQUENCY, 251 .id = V4L2_CID_POWER_LINE_FREQUENCY,
274 .type = V4L2_CTRL_TYPE_MENU, 252 .type = V4L2_CTRL_TYPE_MENU,
@@ -276,69 +254,85 @@ static const struct ctrl sd_ctrls[] = {
276 .minimum = 0, 254 .minimum = 0,
277 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ 255 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
278 .step = 1, 256 .step = 1,
279#define FREQ_DEF 1 257 .default_value = 1,
280 .default_value = FREQ_DEF,
281 }, 258 },
282 .set = sd_setfreq, 259 .set_control = setfreq
283 .get = sd_getfreq,
284 }, 260 },
285}; 261};
286 262
287/* table of the disabled controls */ 263/* table of the disabled controls */
288static const __u32 ctrl_dis[] = { 264static const __u32 ctrl_dis[] = {
289[SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) | 265[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
290 (1 << INFRARED_IDX) | 266 (1 << INFRARED) |
291 (1 << VFLIP_IDX) | 267 (1 << HFLIP) |
292 (1 << FREQ_IDX), 268 (1 << VFLIP) |
293 269 (1 << FREQ),
294[SENSOR_GC0307] = (1 << INFRARED_IDX) | 270
295 (1 << VFLIP_IDX) | 271[SENSOR_GC0307] = (1 << INFRARED) |
296 (1 << FREQ_IDX), 272 (1 << HFLIP) |
297 273 (1 << VFLIP) |
298[SENSOR_HV7131R] = (1 << INFRARED_IDX) | 274 (1 << FREQ),
299 (1 << FREQ_IDX), 275
300 276[SENSOR_HV7131R] = (1 << INFRARED) |
301[SENSOR_MI0360] = (1 << INFRARED_IDX) | 277 (1 << HFLIP) |
302 (1 << VFLIP_IDX) | 278 (1 << FREQ),
303 (1 << FREQ_IDX), 279
304 280[SENSOR_MI0360] = (1 << INFRARED) |
305[SENSOR_MO4000] = (1 << INFRARED_IDX) | 281 (1 << HFLIP) |
306 (1 << VFLIP_IDX) | 282 (1 << VFLIP) |
307 (1 << FREQ_IDX), 283 (1 << FREQ),
308 284
309[SENSOR_MT9V111] = (1 << VFLIP_IDX) | 285[SENSOR_MI0360B] = (1 << INFRARED) |
310 (1 << FREQ_IDX), 286 (1 << HFLIP) |
311 287 (1 << VFLIP) |
312[SENSOR_OM6802] = (1 << INFRARED_IDX) | 288 (1 << FREQ),
313 (1 << VFLIP_IDX) | 289
314 (1 << FREQ_IDX), 290[SENSOR_MO4000] = (1 << INFRARED) |
315 291 (1 << HFLIP) |
316[SENSOR_OV7630] = (1 << INFRARED_IDX), 292 (1 << VFLIP) |
317 293 (1 << FREQ),
318[SENSOR_OV7648] = (1 << INFRARED_IDX), 294
319 295[SENSOR_MT9V111] = (1 << HFLIP) |
320[SENSOR_OV7660] = (1 << AUTOGAIN_IDX) | 296 (1 << VFLIP) |
321 (1 << INFRARED_IDX) | 297 (1 << FREQ),
322 (1 << VFLIP_IDX), 298
323 299[SENSOR_OM6802] = (1 << INFRARED) |
324[SENSOR_PO1030] = (1 << AUTOGAIN_IDX) | 300 (1 << HFLIP) |
325 (1 << INFRARED_IDX) | 301 (1 << VFLIP) |
326 (1 << VFLIP_IDX) | 302 (1 << FREQ),
327 (1 << FREQ_IDX), 303
328 304[SENSOR_OV7630] = (1 << INFRARED) |
329[SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) | 305 (1 << HFLIP),
330 (1 << INFRARED_IDX) | 306
331 (1 << VFLIP_IDX) | 307[SENSOR_OV7648] = (1 << INFRARED) |
332 (1 << FREQ_IDX), 308 (1 << HFLIP),
333[SENSOR_SOI768] = (1 << AUTOGAIN_IDX) | 309
334 (1 << INFRARED_IDX) | 310[SENSOR_OV7660] = (1 << AUTOGAIN) |
335 (1 << VFLIP_IDX) | 311 (1 << INFRARED) |
336 (1 << FREQ_IDX), 312 (1 << HFLIP) |
337 313 (1 << VFLIP),
338[SENSOR_SP80708] = (1 << AUTOGAIN_IDX) | 314
339 (1 << INFRARED_IDX) | 315[SENSOR_PO1030] = (1 << AUTOGAIN) |
340 (1 << VFLIP_IDX) | 316 (1 << INFRARED) |
341 (1 << FREQ_IDX), 317 (1 << HFLIP) |
318 (1 << VFLIP) |
319 (1 << FREQ),
320
321[SENSOR_PO2030N] = (1 << AUTOGAIN) |
322 (1 << INFRARED) |
323 (1 << FREQ),
324
325[SENSOR_SOI768] = (1 << AUTOGAIN) |
326 (1 << INFRARED) |
327 (1 << HFLIP) |
328 (1 << VFLIP) |
329 (1 << FREQ),
330
331[SENSOR_SP80708] = (1 << AUTOGAIN) |
332 (1 << INFRARED) |
333 (1 << HFLIP) |
334 (1 << VFLIP) |
335 (1 << FREQ),
342}; 336};
343 337
344static const struct v4l2_pix_format cif_mode[] = { 338static const struct v4l2_pix_format cif_mode[] = {
@@ -411,6 +405,17 @@ static const u8 sn_mi0360[0x1c] = {
411 0x06, 0x00, 0x00, 0x00 405 0x06, 0x00, 0x00, 0x00
412}; 406};
413 407
408static const u8 sn_mi0360b[0x1c] = {
409/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
410 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
411/* reg8 reg9 rega regb regc regd rege regf */
412 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
414 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
415/* reg18 reg19 reg1a reg1b */
416 0x06, 0x00, 0x00, 0x00
417};
418
414static const u8 sn_mo4000[0x1c] = { 419static const u8 sn_mo4000[0x1c] = {
415/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 420/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
416 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, 421 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
@@ -527,6 +532,7 @@ static const u8 *sn_tb[] = {
527[SENSOR_GC0307] = sn_gc0307, 532[SENSOR_GC0307] = sn_gc0307,
528[SENSOR_HV7131R] = sn_hv7131, 533[SENSOR_HV7131R] = sn_hv7131,
529[SENSOR_MI0360] = sn_mi0360, 534[SENSOR_MI0360] = sn_mi0360,
535[SENSOR_MI0360B] = sn_mi0360b,
530[SENSOR_MO4000] = sn_mo4000, 536[SENSOR_MO4000] = sn_mo4000,
531[SENSOR_MT9V111] = sn_mt9v111, 537[SENSOR_MT9V111] = sn_mt9v111,
532[SENSOR_OM6802] = sn_om6802, 538[SENSOR_OM6802] = sn_om6802,
@@ -572,20 +578,23 @@ static const u8 reg84[] = {
572 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ 578 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
573 0x00, 0x00, 0x00 /* YUV offsets */ 579 0x00, 0x00, 0x00 /* YUV offsets */
574}; 580};
581
582#define DELAY 0xdd
583
575static const u8 adcm1700_sensor_init[][8] = { 584static const u8 adcm1700_sensor_init[][8] = {
576 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, 585 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
577 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ 586 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
578 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 587 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
579 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, 588 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
580 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 589 {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
581 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, 590 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
582 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, 591 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
583 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, 592 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
584 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, 593 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
585 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, 594 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
586 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 595 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
587 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, 596 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
588 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 597 {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
589 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, 598 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
590 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, 599 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
591 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, 600 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
@@ -629,7 +638,7 @@ static const u8 gc0307_sensor_init[][8] = {
629 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, 638 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, 639 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, 640 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
632 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ 641 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
633 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, 642 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, 643 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, 644 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
@@ -747,6 +756,62 @@ static const u8 mi0360_sensor_init[][8] = {
747 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ 756 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
748 {} 757 {}
749}; 758};
759static const u8 mi0360b_sensor_init[][8] = {
760 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
761 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
762 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
763 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
764 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
765 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
766 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
767 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
769 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
770 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
771 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
773 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
774 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
775 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
784 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
785 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
787 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
789 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
791 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
793 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
794 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
795
796 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
797 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
798 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
799 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
800 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
801 {}
802};
803static const u8 mi0360b_sensor_param1[][8] = {
804 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
807 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
808
809 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
810 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
811 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
812 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
813 {}
814};
750static const u8 mo4000_sensor_init[][8] = { 815static const u8 mo4000_sensor_init[][8] = {
751 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, 816 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, 817 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
@@ -772,7 +837,7 @@ static const u8 mo4000_sensor_init[][8] = {
772}; 837};
773static const u8 mt9v111_sensor_init[][8] = { 838static const u8 mt9v111_sensor_init[][8] = {
774 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ 839 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
775 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 840 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
776 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, 841 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
777 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ 842 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
778 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ 843 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
@@ -860,10 +925,10 @@ static const u8 om6802_sensor_param1[][8] = {
860static const u8 ov7630_sensor_init[][8] = { 925static const u8 ov7630_sensor_init[][8] = {
861 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, 926 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, 927 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
863 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 928 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
864 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, 929 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, 930 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
866 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 931 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
867 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, 932 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
868/* win: i2c_r from 00 to 80 */ 933/* win: i2c_r from 00 to 80 */
869 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, 934 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
@@ -917,7 +982,7 @@ static const u8 ov7630_sensor_param1[][8] = {
917static const u8 ov7648_sensor_init[][8] = { 982static const u8 ov7648_sensor_init[][8] = {
918 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, 983 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ 984 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
920 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 985 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
921 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, 986 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
922 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, 987 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
923 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, 988 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
@@ -966,7 +1031,7 @@ static const u8 ov7648_sensor_param1[][8] = {
966 1031
967static const u8 ov7660_sensor_init[][8] = { 1032static const u8 ov7660_sensor_init[][8] = {
968 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ 1033 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
969 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 1034 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
970 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 1035 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
971 /* Outformat = rawRGB */ 1036 /* Outformat = rawRGB */
972 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 1037 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
@@ -1062,7 +1127,7 @@ static const u8 ov7660_sensor_param1[][8] = {
1062static const u8 po1030_sensor_init[][8] = { 1127static const u8 po1030_sensor_init[][8] = {
1063/* the sensor registers are described in m5602/m5602_po1030.h */ 1128/* the sensor registers are described in m5602/m5602_po1030.h */
1064 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ 1129 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1065 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ 1130 {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1066 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, 1131 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1067 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, 1132 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1068 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, 1133 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
@@ -1116,10 +1181,10 @@ static const u8 po1030_sensor_param1[][8] = {
1116static const u8 po2030n_sensor_init[][8] = { 1181static const u8 po2030n_sensor_init[][8] = {
1117 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, 1182 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1118 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, 1183 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1119 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ 1184 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1120 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, 1185 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1121 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, 1186 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1122 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ 1187 {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1123 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, 1188 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1124 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, 1189 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1125 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, 1190 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
@@ -1168,7 +1233,7 @@ static const u8 po2030n_sensor_init[][8] = {
1168}; 1233};
1169static const u8 po2030n_sensor_param1[][8] = { 1234static const u8 po2030n_sensor_param1[][8] = {
1170 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, 1235 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1171 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ 1236 {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1172 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, 1237 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1173 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, 1238 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10}, 1239 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
@@ -1182,16 +1247,16 @@ static const u8 po2030n_sensor_param1[][8] = {
1182 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10}, 1247 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1183/*after start*/ 1248/*after start*/
1184 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10}, 1249 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1185 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ 1250 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1186 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10}, 1251 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1187 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ 1252 {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1188 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10}, 1253 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1189 {} 1254 {}
1190}; 1255};
1191 1256
1192static const u8 soi768_sensor_init[][8] = { 1257static const u8 soi768_sensor_init[][8] = {
1193 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ 1258 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1194 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ 1259 {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1195 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, 1260 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, 1261 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, 1262 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
@@ -1310,6 +1375,7 @@ static const u8 (*sensor_init[])[8] = {
1310[SENSOR_GC0307] = gc0307_sensor_init, 1375[SENSOR_GC0307] = gc0307_sensor_init,
1311[SENSOR_HV7131R] = hv7131r_sensor_init, 1376[SENSOR_HV7131R] = hv7131r_sensor_init,
1312[SENSOR_MI0360] = mi0360_sensor_init, 1377[SENSOR_MI0360] = mi0360_sensor_init,
1378[SENSOR_MI0360B] = mi0360b_sensor_init,
1313[SENSOR_MO4000] = mo4000_sensor_init, 1379[SENSOR_MO4000] = mo4000_sensor_init,
1314[SENSOR_MT9V111] = mt9v111_sensor_init, 1380[SENSOR_MT9V111] = mt9v111_sensor_init,
1315[SENSOR_OM6802] = om6802_sensor_init, 1381[SENSOR_OM6802] = om6802_sensor_init,
@@ -1326,13 +1392,17 @@ static const u8 (*sensor_init[])[8] = {
1326static void reg_r(struct gspca_dev *gspca_dev, 1392static void reg_r(struct gspca_dev *gspca_dev,
1327 u16 value, int len) 1393 u16 value, int len)
1328{ 1394{
1395 int ret;
1396
1397 if (gspca_dev->usb_err < 0)
1398 return;
1329#ifdef GSPCA_DEBUG 1399#ifdef GSPCA_DEBUG
1330 if (len > USB_BUF_SZ) { 1400 if (len > USB_BUF_SZ) {
1331 err("reg_r: buffer overflow"); 1401 err("reg_r: buffer overflow");
1332 return; 1402 return;
1333 } 1403 }
1334#endif 1404#endif
1335 usb_control_msg(gspca_dev->dev, 1405 ret = usb_control_msg(gspca_dev->dev,
1336 usb_rcvctrlpipe(gspca_dev->dev, 0), 1406 usb_rcvctrlpipe(gspca_dev->dev, 0),
1337 0, 1407 0,
1338 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1408 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1340,15 +1410,23 @@ static void reg_r(struct gspca_dev *gspca_dev,
1340 gspca_dev->usb_buf, len, 1410 gspca_dev->usb_buf, len,
1341 500); 1411 500);
1342 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); 1412 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
1413 if (ret < 0) {
1414 err("reg_r err %d", ret);
1415 gspca_dev->usb_err = ret;
1416 }
1343} 1417}
1344 1418
1345static void reg_w1(struct gspca_dev *gspca_dev, 1419static void reg_w1(struct gspca_dev *gspca_dev,
1346 u16 value, 1420 u16 value,
1347 u8 data) 1421 u8 data)
1348{ 1422{
1423 int ret;
1424
1425 if (gspca_dev->usb_err < 0)
1426 return;
1349 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); 1427 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
1350 gspca_dev->usb_buf[0] = data; 1428 gspca_dev->usb_buf[0] = data;
1351 usb_control_msg(gspca_dev->dev, 1429 ret = usb_control_msg(gspca_dev->dev,
1352 usb_sndctrlpipe(gspca_dev->dev, 0), 1430 usb_sndctrlpipe(gspca_dev->dev, 0),
1353 0x08, 1431 0x08,
1354 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1432 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1356,12 +1434,20 @@ static void reg_w1(struct gspca_dev *gspca_dev,
1356 0, 1434 0,
1357 gspca_dev->usb_buf, 1, 1435 gspca_dev->usb_buf, 1,
1358 500); 1436 500);
1437 if (ret < 0) {
1438 err("reg_w1 err %d", ret);
1439 gspca_dev->usb_err = ret;
1440 }
1359} 1441}
1360static void reg_w(struct gspca_dev *gspca_dev, 1442static void reg_w(struct gspca_dev *gspca_dev,
1361 u16 value, 1443 u16 value,
1362 const u8 *buffer, 1444 const u8 *buffer,
1363 int len) 1445 int len)
1364{ 1446{
1447 int ret;
1448
1449 if (gspca_dev->usb_err < 0)
1450 return;
1365 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", 1451 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1366 value, buffer[0], buffer[1]); 1452 value, buffer[0], buffer[1]);
1367#ifdef GSPCA_DEBUG 1453#ifdef GSPCA_DEBUG
@@ -1371,20 +1457,27 @@ static void reg_w(struct gspca_dev *gspca_dev,
1371 } 1457 }
1372#endif 1458#endif
1373 memcpy(gspca_dev->usb_buf, buffer, len); 1459 memcpy(gspca_dev->usb_buf, buffer, len);
1374 usb_control_msg(gspca_dev->dev, 1460 ret = usb_control_msg(gspca_dev->dev,
1375 usb_sndctrlpipe(gspca_dev->dev, 0), 1461 usb_sndctrlpipe(gspca_dev->dev, 0),
1376 0x08, 1462 0x08,
1377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1463 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1378 value, 0, 1464 value, 0,
1379 gspca_dev->usb_buf, len, 1465 gspca_dev->usb_buf, len,
1380 500); 1466 500);
1467 if (ret < 0) {
1468 err("reg_w err %d", ret);
1469 gspca_dev->usb_err = ret;
1470 }
1381} 1471}
1382 1472
1383/* I2C write 1 byte */ 1473/* I2C write 1 byte */
1384static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 1474static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1385{ 1475{
1386 struct sd *sd = (struct sd *) gspca_dev; 1476 struct sd *sd = (struct sd *) gspca_dev;
1477 int ret;
1387 1478
1479 if (gspca_dev->usb_err < 0)
1480 return;
1388 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); 1481 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
1389 switch (sd->sensor) { 1482 switch (sd->sensor) {
1390 case SENSOR_ADCM1700: 1483 case SENSOR_ADCM1700:
@@ -1403,7 +1496,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1403 gspca_dev->usb_buf[5] = 0; 1496 gspca_dev->usb_buf[5] = 0;
1404 gspca_dev->usb_buf[6] = 0; 1497 gspca_dev->usb_buf[6] = 0;
1405 gspca_dev->usb_buf[7] = 0x10; 1498 gspca_dev->usb_buf[7] = 0x10;
1406 usb_control_msg(gspca_dev->dev, 1499 ret = usb_control_msg(gspca_dev->dev,
1407 usb_sndctrlpipe(gspca_dev->dev, 0), 1500 usb_sndctrlpipe(gspca_dev->dev, 0),
1408 0x08, 1501 0x08,
1409 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1502 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1411,16 +1504,24 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1411 0, 1504 0,
1412 gspca_dev->usb_buf, 8, 1505 gspca_dev->usb_buf, 8,
1413 500); 1506 500);
1507 if (ret < 0) {
1508 err("i2c_w1 err %d", ret);
1509 gspca_dev->usb_err = ret;
1510 }
1414} 1511}
1415 1512
1416/* I2C write 8 bytes */ 1513/* I2C write 8 bytes */
1417static void i2c_w8(struct gspca_dev *gspca_dev, 1514static void i2c_w8(struct gspca_dev *gspca_dev,
1418 const u8 *buffer) 1515 const u8 *buffer)
1419{ 1516{
1517 int ret;
1518
1519 if (gspca_dev->usb_err < 0)
1520 return;
1420 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", 1521 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1421 buffer[2], buffer[3]); 1522 buffer[2], buffer[3]);
1422 memcpy(gspca_dev->usb_buf, buffer, 8); 1523 memcpy(gspca_dev->usb_buf, buffer, 8);
1423 usb_control_msg(gspca_dev->dev, 1524 ret = usb_control_msg(gspca_dev->dev,
1424 usb_sndctrlpipe(gspca_dev->dev, 0), 1525 usb_sndctrlpipe(gspca_dev->dev, 0),
1425 0x08, 1526 0x08,
1426 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 1527 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -1428,6 +1529,10 @@ static void i2c_w8(struct gspca_dev *gspca_dev,
1428 gspca_dev->usb_buf, 8, 1529 gspca_dev->usb_buf, 8,
1429 500); 1530 500);
1430 msleep(2); 1531 msleep(2);
1532 if (ret < 0) {
1533 err("i2c_w8 err %d", ret);
1534 gspca_dev->usb_err = ret;
1535 }
1431} 1536}
1432 1537
1433/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ 1538/* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
@@ -1466,7 +1571,7 @@ static void i2c_w_seq(struct gspca_dev *gspca_dev,
1466 const u8 (*data)[8]) 1571 const u8 (*data)[8])
1467{ 1572{
1468 while ((*data)[0] != 0) { 1573 while ((*data)[0] != 0) {
1469 if ((*data)[0] != 0xdd) 1574 if ((*data)[0] != DELAY)
1470 i2c_w8(gspca_dev, *data); 1575 i2c_w8(gspca_dev, *data);
1471 else 1576 else
1472 msleep((*data)[1]); 1577 msleep((*data)[1]);
@@ -1529,7 +1634,13 @@ static void mi0360_probe(struct gspca_dev *gspca_dev)
1529 if (val != 0xffff) 1634 if (val != 0xffff)
1530 break; 1635 break;
1531 } 1636 }
1637 if (gspca_dev->usb_err < 0)
1638 return;
1532 switch (val) { 1639 switch (val) {
1640 case 0x8221:
1641 PDEBUG(D_PROBE, "Sensor mi0360b");
1642 sd->sensor = SENSOR_MI0360B;
1643 break;
1533 case 0x823a: 1644 case 0x823a:
1534 PDEBUG(D_PROBE, "Sensor mt9v111"); 1645 PDEBUG(D_PROBE, "Sensor mt9v111");
1535 sd->sensor = SENSOR_MT9V111; 1646 sd->sensor = SENSOR_MT9V111;
@@ -1556,6 +1667,8 @@ static void ov7630_probe(struct gspca_dev *gspca_dev)
1556 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1667 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1557 reg_w1(gspca_dev, 0x01, 0x29); 1668 reg_w1(gspca_dev, 0x01, 0x29);
1558 reg_w1(gspca_dev, 0x17, 0x42); 1669 reg_w1(gspca_dev, 0x17, 0x42);
1670 if (gspca_dev->usb_err < 0)
1671 return;
1559 if (val == 0x7628) { /* soi768 */ 1672 if (val == 0x7628) { /* soi768 */
1560 sd->sensor = SENSOR_SOI768; 1673 sd->sensor = SENSOR_SOI768;
1561/*fixme: only valid for 0c45:613e?*/ 1674/*fixme: only valid for 0c45:613e?*/
@@ -1593,13 +1706,14 @@ static void ov7648_probe(struct gspca_dev *gspca_dev)
1593 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1706 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1594 reg_w1(gspca_dev, 0x01, 0x29); 1707 reg_w1(gspca_dev, 0x01, 0x29);
1595 reg_w1(gspca_dev, 0x17, 0x42); 1708 reg_w1(gspca_dev, 0x17, 0x42);
1709 if (gspca_dev->usb_err < 0)
1710 return;
1596 if (val == 0x1030) { /* po1030 */ 1711 if (val == 0x1030) { /* po1030 */
1597 PDEBUG(D_PROBE, "Sensor po1030"); 1712 PDEBUG(D_PROBE, "Sensor po1030");
1598 sd->sensor = SENSOR_PO1030; 1713 sd->sensor = SENSOR_PO1030;
1599 return; 1714 return;
1600 } 1715 }
1601 1716 err("Unknown sensor %04x", val);
1602 PDEBUG(D_PROBE, "Unknown sensor %04x", val);
1603} 1717}
1604 1718
1605/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ 1719/* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
@@ -1631,11 +1745,13 @@ static void po2030n_probe(struct gspca_dev *gspca_dev)
1631 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; 1745 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1632 reg_w1(gspca_dev, 0x01, 0x29); 1746 reg_w1(gspca_dev, 0x01, 0x29);
1633 reg_w1(gspca_dev, 0x17, 0x42); 1747 reg_w1(gspca_dev, 0x17, 0x42);
1748 if (gspca_dev->usb_err < 0)
1749 return;
1634 if (val == 0x2030) { 1750 if (val == 0x2030) {
1635 PDEBUG(D_PROBE, "Sensor po2030n"); 1751 PDEBUG(D_PROBE, "Sensor po2030n");
1636/* sd->sensor = SENSOR_PO2030N; */ 1752/* sd->sensor = SENSOR_PO2030N; */
1637 } else { 1753 } else {
1638 PDEBUG(D_PROBE, "Unknown sensor ID %04x", val); 1754 err("Unknown sensor ID %04x", val);
1639 } 1755 }
1640} 1756}
1641 1757
@@ -1697,6 +1813,12 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1697 reg_w1(gspca_dev, 0x01, 0x40); 1813 reg_w1(gspca_dev, 0x01, 0x40);
1698 msleep(50); 1814 msleep(50);
1699 break; 1815 break;
1816 case SENSOR_MI0360B:
1817 reg_w1(gspca_dev, 0x01, 0x61);
1818 reg_w1(gspca_dev, 0x17, 0x60);
1819 reg_w1(gspca_dev, 0x01, 0x60);
1820 reg_w1(gspca_dev, 0x01, 0x40);
1821 break;
1700 case SENSOR_MT9V111: 1822 case SENSOR_MT9V111:
1701 reg_w1(gspca_dev, 0x01, 0x61); 1823 reg_w1(gspca_dev, 0x01, 0x61);
1702 reg_w1(gspca_dev, 0x17, 0x61); 1824 reg_w1(gspca_dev, 0x17, 0x61);
@@ -1762,8 +1884,7 @@ static void bridge_init(struct gspca_dev *gspca_dev,
1762 reg_w1(gspca_dev, 0x01, 0x43); 1884 reg_w1(gspca_dev, 0x01, 0x43);
1763 reg_w1(gspca_dev, 0x17, 0x61); 1885 reg_w1(gspca_dev, 0x17, 0x61);
1764 reg_w1(gspca_dev, 0x01, 0x42); 1886 reg_w1(gspca_dev, 0x01, 0x42);
1765 if (sd->sensor == SENSOR_HV7131R 1887 if (sd->sensor == SENSOR_HV7131R)
1766 && sd->bridge == BRIDGE_SN9C102P)
1767 hv7131r_probe(gspca_dev); 1888 hv7131r_probe(gspca_dev);
1768 break; 1889 break;
1769 } 1890 }
@@ -1788,26 +1909,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
1788 cam->nmodes = ARRAY_SIZE(vga_mode); 1909 cam->nmodes = ARRAY_SIZE(vga_mode);
1789 } 1910 }
1790 cam->npkt = 24; /* 24 packets per ISOC message */ 1911 cam->npkt = 24; /* 24 packets per ISOC message */
1912 cam->ctrls = sd->ctrls;
1791 1913
1792 sd->brightness = BRIGHTNESS_DEF;
1793 sd->contrast = CONTRAST_DEF;
1794 sd->colors = COLOR_DEF;
1795 sd->blue = BLUE_BALANCE_DEF;
1796 sd->red = RED_BALANCE_DEF;
1797 sd->gamma = GAMMA_DEF;
1798 sd->autogain = AUTOGAIN_DEF;
1799 sd->ag_cnt = -1; 1914 sd->ag_cnt = -1;
1800 sd->vflip = VFLIP_DEF;
1801 switch (sd->sensor) {
1802 case SENSOR_OM6802:
1803 sd->sharpness = 0x10;
1804 break;
1805 default:
1806 sd->sharpness = SHARPNESS_DEF;
1807 break;
1808 }
1809 sd->infrared = INFRARED_DEF;
1810 sd->freq = FREQ_DEF;
1811 sd->quality = QUALITY_DEF; 1915 sd->quality = QUALITY_DEF;
1812 sd->jpegqual = 80; 1916 sd->jpegqual = 80;
1813 1917
@@ -1828,6 +1932,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
1828 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); 1932 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1829 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ 1933 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1830 regF1 = gspca_dev->usb_buf[0]; 1934 regF1 = gspca_dev->usb_buf[0];
1935 if (gspca_dev->usb_err < 0)
1936 return gspca_dev->usb_err;
1831 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); 1937 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1832 switch (sd->bridge) { 1938 switch (sd->bridge) {
1833 case BRIDGE_SN9C102P: 1939 case BRIDGE_SN9C102P:
@@ -1871,6 +1977,9 @@ static int sd_init(struct gspca_dev *gspca_dev)
1871 break; 1977 break;
1872 } 1978 }
1873 1979
1980 if (sd->sensor == SENSOR_OM6802)
1981 sd->ctrls[SHARPNESS].def = 0x10;
1982
1874 /* Note we do not disable the sensor clock here (power saving mode), 1983 /* Note we do not disable the sensor clock here (power saving mode),
1875 as that also disables the button on the cam. */ 1984 as that also disables the button on the cam. */
1876 reg_w1(gspca_dev, 0xf1, 0x00); 1985 reg_w1(gspca_dev, 0xf1, 0x00);
@@ -1881,7 +1990,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
1881 1990
1882 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; 1991 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1883 1992
1884 return 0; 1993 return gspca_dev->usb_err;
1885} 1994}
1886 1995
1887static u32 setexposure(struct gspca_dev *gspca_dev, 1996static u32 setexposure(struct gspca_dev *gspca_dev,
@@ -1912,7 +2021,8 @@ static u32 setexposure(struct gspca_dev *gspca_dev,
1912 i2c_w8(gspca_dev, Expodoit); 2021 i2c_w8(gspca_dev, Expodoit);
1913 break; 2022 break;
1914 } 2023 }
1915 case SENSOR_MI0360: { 2024 case SENSOR_MI0360:
2025 case SENSOR_MI0360B: {
1916 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ 2026 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1917 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; 2027 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
1918 static const u8 doit[] = /* update sensor */ 2028 static const u8 doit[] = /* update sensor */
@@ -1991,16 +2101,18 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1991{ 2101{
1992 struct sd *sd = (struct sd *) gspca_dev; 2102 struct sd *sd = (struct sd *) gspca_dev;
1993 unsigned int expo; 2103 unsigned int expo;
2104 int brightness;
1994 u8 k2; 2105 u8 k2;
1995 2106
1996 k2 = ((int) sd->brightness - 0x8000) >> 10; 2107 brightness = sd->ctrls[BRIGHTNESS].val;
2108 k2 = (brightness - 0x80) >> 2;
1997 switch (sd->sensor) { 2109 switch (sd->sensor) {
1998 case SENSOR_ADCM1700: 2110 case SENSOR_ADCM1700:
1999 if (k2 > 0x1f) 2111 if (k2 > 0x1f)
2000 k2 = 0; /* only positive Y offset */ 2112 k2 = 0; /* only positive Y offset */
2001 break; 2113 break;
2002 case SENSOR_HV7131R: 2114 case SENSOR_HV7131R:
2003 expo = sd->brightness << 4; 2115 expo = brightness << 12;
2004 if (expo > 0x002dc6c0) 2116 if (expo > 0x002dc6c0)
2005 expo = 0x002dc6c0; 2117 expo = 0x002dc6c0;
2006 else if (expo < 0x02a0) 2118 else if (expo < 0x02a0)
@@ -2009,18 +2121,22 @@ static void setbrightness(struct gspca_dev *gspca_dev)
2009 break; 2121 break;
2010 case SENSOR_MI0360: 2122 case SENSOR_MI0360:
2011 case SENSOR_MO4000: 2123 case SENSOR_MO4000:
2012 expo = sd->brightness >> 4; 2124 expo = brightness << 4;
2125 sd->exposure = setexposure(gspca_dev, expo);
2126 break;
2127 case SENSOR_MI0360B:
2128 expo = brightness << 2;
2013 sd->exposure = setexposure(gspca_dev, expo); 2129 sd->exposure = setexposure(gspca_dev, expo);
2014 break; 2130 break;
2015 case SENSOR_GC0307: 2131 case SENSOR_GC0307:
2016 case SENSOR_MT9V111: 2132 case SENSOR_MT9V111:
2017 expo = sd->brightness >> 8; 2133 expo = brightness;
2018 sd->exposure = setexposure(gspca_dev, expo); 2134 sd->exposure = setexposure(gspca_dev, expo);
2019 return; /* don't set the Y offset */ 2135 return; /* don't set the Y offset */
2020 case SENSOR_OM6802: 2136 case SENSOR_OM6802:
2021 expo = sd->brightness >> 6; 2137 expo = brightness << 2;
2022 sd->exposure = setexposure(gspca_dev, expo); 2138 sd->exposure = setexposure(gspca_dev, expo);
2023 k2 = sd->brightness >> 11; 2139 k2 = brightness >> 3;
2024 break; 2140 break;
2025 } 2141 }
2026 2142
@@ -2033,7 +2149,8 @@ static void setcontrast(struct gspca_dev *gspca_dev)
2033 u8 k2; 2149 u8 k2;
2034 u8 contrast[6]; 2150 u8 contrast[6];
2035 2151
2036 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ 2152 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2153 + 0x10; /* 10..40 */
2037 contrast[0] = (k2 + 1) / 2; /* red */ 2154 contrast[0] = (k2 + 1) / 2; /* red */
2038 contrast[1] = 0; 2155 contrast[1] = 0;
2039 contrast[2] = k2; /* green */ 2156 contrast[2] = k2; /* green */
@@ -2046,15 +2163,25 @@ static void setcontrast(struct gspca_dev *gspca_dev)
2046static void setcolors(struct gspca_dev *gspca_dev) 2163static void setcolors(struct gspca_dev *gspca_dev)
2047{ 2164{
2048 struct sd *sd = (struct sd *) gspca_dev; 2165 struct sd *sd = (struct sd *) gspca_dev;
2049 int i, v; 2166 int i, v, colors;
2167 const s16 *uv;
2050 u8 reg8a[12]; /* U & V gains */ 2168 u8 reg8a[12]; /* U & V gains */
2051 static const s16 uv[6] = { /* same as reg84 in signed decimal */ 2169 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
2052 -24, -38, 64, /* UR UG UB */ 2170 -24, -38, 64, /* UR UG UB */
2053 62, -51, -9 /* VR VG VB */ 2171 62, -51, -9 /* VR VG VB */
2054 }; 2172 };
2173 static const s16 uv_mi0360b[6] = {
2174 -20, -38, 64, /* UR UG UB */
2175 60, -51, -9 /* VR VG VB */
2176 };
2055 2177
2178 colors = sd->ctrls[COLORS].val;
2179 if (sd->sensor == SENSOR_MI0360B)
2180 uv = uv_mi0360b;
2181 else
2182 uv = uv_com;
2056 for (i = 0; i < 6; i++) { 2183 for (i = 0; i < 6; i++) {
2057 v = uv[i] * sd->colors / COLOR_DEF; 2184 v = uv[i] * colors / COLORS_DEF;
2058 reg8a[i * 2] = v; 2185 reg8a[i * 2] = v;
2059 reg8a[i * 2 + 1] = (v >> 8) & 0x0f; 2186 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
2060 } 2187 }
@@ -2065,15 +2192,15 @@ static void setredblue(struct gspca_dev *gspca_dev)
2065{ 2192{
2066 struct sd *sd = (struct sd *) gspca_dev; 2193 struct sd *sd = (struct sd *) gspca_dev;
2067 2194
2068 reg_w1(gspca_dev, 0x05, sd->red); 2195 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
2069/* reg_w1(gspca_dev, 0x07, 32); */ 2196/* reg_w1(gspca_dev, 0x07, 32); */
2070 reg_w1(gspca_dev, 0x06, sd->blue); 2197 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
2071} 2198}
2072 2199
2073static void setgamma(struct gspca_dev *gspca_dev) 2200static void setgamma(struct gspca_dev *gspca_dev)
2074{ 2201{
2075 struct sd *sd = (struct sd *) gspca_dev; 2202 struct sd *sd = (struct sd *) gspca_dev;
2076 int i; 2203 int i, val;
2077 u8 gamma[17]; 2204 u8 gamma[17];
2078 const u8 *gamma_base; 2205 const u8 *gamma_base;
2079 static const u8 delta[17] = { 2206 static const u8 delta[17] = {
@@ -2086,6 +2213,7 @@ static void setgamma(struct gspca_dev *gspca_dev)
2086 gamma_base = gamma_spec_0; 2213 gamma_base = gamma_spec_0;
2087 break; 2214 break;
2088 case SENSOR_HV7131R: 2215 case SENSOR_HV7131R:
2216 case SENSOR_MI0360B:
2089 case SENSOR_MT9V111: 2217 case SENSOR_MT9V111:
2090 gamma_base = gamma_spec_1; 2218 gamma_base = gamma_spec_1;
2091 break; 2219 break;
@@ -2100,9 +2228,10 @@ static void setgamma(struct gspca_dev *gspca_dev)
2100 break; 2228 break;
2101 } 2229 }
2102 2230
2231 val = sd->ctrls[GAMMA].val;
2103 for (i = 0; i < sizeof gamma; i++) 2232 for (i = 0; i < sizeof gamma; i++)
2104 gamma[i] = gamma_base[i] 2233 gamma[i] = gamma_base[i]
2105 + delta[i] * (sd->gamma - GAMMA_DEF) / 32; 2234 + delta[i] * (val - GAMMA_DEF) / 32;
2106 reg_w(gspca_dev, 0x20, gamma, sizeof gamma); 2235 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2107} 2236}
2108 2237
@@ -2110,7 +2239,7 @@ static void setautogain(struct gspca_dev *gspca_dev)
2110{ 2239{
2111 struct sd *sd = (struct sd *) gspca_dev; 2240 struct sd *sd = (struct sd *) gspca_dev;
2112 2241
2113 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) 2242 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
2114 return; 2243 return;
2115 switch (sd->sensor) { 2244 switch (sd->sensor) {
2116 case SENSOR_OV7630: 2245 case SENSOR_OV7630:
@@ -2121,74 +2250,91 @@ static void setautogain(struct gspca_dev *gspca_dev)
2121 comb = 0xc0; 2250 comb = 0xc0;
2122 else 2251 else
2123 comb = 0xa0; 2252 comb = 0xa0;
2124 if (sd->autogain) 2253 if (sd->ctrls[AUTOGAIN].val)
2125 comb |= 0x03; 2254 comb |= 0x03;
2126 i2c_w1(&sd->gspca_dev, 0x13, comb); 2255 i2c_w1(&sd->gspca_dev, 0x13, comb);
2127 return; 2256 return;
2128 } 2257 }
2129 } 2258 }
2130 if (sd->autogain) 2259 if (sd->ctrls[AUTOGAIN].val)
2131 sd->ag_cnt = AG_CNT_START; 2260 sd->ag_cnt = AG_CNT_START;
2132 else 2261 else
2133 sd->ag_cnt = -1; 2262 sd->ag_cnt = -1;
2134} 2263}
2135 2264
2136/* hv7131r/ov7630/ov7648 only */ 2265static void sethvflip(struct gspca_dev *gspca_dev)
2137static void setvflip(struct sd *sd)
2138{ 2266{
2267 struct sd *sd = (struct sd *) gspca_dev;
2139 u8 comn; 2268 u8 comn;
2140 2269
2141 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2142 return;
2143 switch (sd->sensor) { 2270 switch (sd->sensor) {
2144 case SENSOR_HV7131R: 2271 case SENSOR_HV7131R:
2145 comn = 0x18; /* clkdiv = 1, ablcen = 1 */ 2272 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2146 if (sd->vflip) 2273 if (sd->ctrls[VFLIP].val)
2147 comn |= 0x01; 2274 comn |= 0x01;
2148 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */ 2275 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
2149 break; 2276 break;
2150 case SENSOR_OV7630: 2277 case SENSOR_OV7630:
2151 comn = 0x02; 2278 comn = 0x02;
2152 if (!sd->vflip) 2279 if (!sd->ctrls[VFLIP].val)
2153 comn |= 0x80; 2280 comn |= 0x80;
2154 i2c_w1(&sd->gspca_dev, 0x75, comn); 2281 i2c_w1(gspca_dev, 0x75, comn);
2155 break; 2282 break;
2156 default: 2283 case SENSOR_OV7648:
2157/* case SENSOR_OV7648: */
2158 comn = 0x06; 2284 comn = 0x06;
2159 if (sd->vflip) 2285 if (sd->ctrls[VFLIP].val)
2286 comn |= 0x80;
2287 i2c_w1(gspca_dev, 0x75, comn);
2288 break;
2289 case SENSOR_PO2030N:
2290 /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2)
2291 * (reset value: 0x0A)
2292 * bit7: HM: Horizontal Mirror: 0: disable, 1: enable
2293 * bit6: VM: Vertical Mirror: 0: disable, 1: enable
2294 * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical
2295 * bit4: FT: Single Frame Transfer: 0: disable, 1: enable
2296 * bit3-0: X
2297 */
2298 comn = 0x0a;
2299 if (sd->ctrls[HFLIP].val)
2160 comn |= 0x80; 2300 comn |= 0x80;
2161 i2c_w1(&sd->gspca_dev, 0x75, comn); 2301 if (sd->ctrls[VFLIP].val)
2302 comn |= 0x40;
2303 i2c_w1(&sd->gspca_dev, 0x1e, comn);
2162 break; 2304 break;
2163 } 2305 }
2164} 2306}
2165 2307
2166static void setsharpness(struct sd *sd) 2308static void setsharpness(struct gspca_dev *gspca_dev)
2167{ 2309{
2168 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness); 2310 struct sd *sd = (struct sd *) gspca_dev;
2311
2312 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
2169} 2313}
2170 2314
2171static void setinfrared(struct sd *sd) 2315static void setinfrared(struct gspca_dev *gspca_dev)
2172{ 2316{
2173 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) 2317 struct sd *sd = (struct sd *) gspca_dev;
2318
2319 if (gspca_dev->ctrl_dis & (1 << INFRARED))
2174 return; 2320 return;
2175/*fixme: different sequence for StarCam Clip and StarCam 370i */ 2321/*fixme: different sequence for StarCam Clip and StarCam 370i */
2176/* Clip */ 2322/* Clip */
2177 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ 2323 i2c_w1(gspca_dev, 0x02, /* gpio */
2178 sd->infrared ? 0x66 : 0x64); 2324 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
2179} 2325}
2180 2326
2181static void setfreq(struct gspca_dev *gspca_dev) 2327static void setfreq(struct gspca_dev *gspca_dev)
2182{ 2328{
2183 struct sd *sd = (struct sd *) gspca_dev; 2329 struct sd *sd = (struct sd *) gspca_dev;
2184 2330
2185 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) 2331 if (gspca_dev->ctrl_dis & (1 << FREQ))
2186 return; 2332 return;
2187 if (sd->sensor == SENSOR_OV7660) { 2333 if (sd->sensor == SENSOR_OV7660) {
2188 u8 com8; 2334 u8 com8;
2189 2335
2190 com8 = 0xdf; /* auto gain/wb/expo */ 2336 com8 = 0xdf; /* auto gain/wb/expo */
2191 switch (sd->freq) { 2337 switch (sd->ctrls[FREQ].val) {
2192 case 0: /* Banding filter disabled */ 2338 case 0: /* Banding filter disabled */
2193 i2c_w1(gspca_dev, 0x13, com8 | 0x20); 2339 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
2194 break; 2340 break;
@@ -2216,7 +2362,7 @@ static void setfreq(struct gspca_dev *gspca_dev)
2216 break; 2362 break;
2217 } 2363 }
2218 2364
2219 switch (sd->freq) { 2365 switch (sd->ctrls[FREQ].val) {
2220 case 0: /* Banding filter disabled */ 2366 case 0: /* Banding filter disabled */
2221 break; 2367 break;
2222 case 1: /* 50 hz (filter on and framerate adj) */ 2368 case 1: /* 50 hz (filter on and framerate adj) */
@@ -2334,6 +2480,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2334 reg17 = 0xa2; 2480 reg17 = 0xa2;
2335 break; 2481 break;
2336 case SENSOR_MT9V111: 2482 case SENSOR_MT9V111:
2483 case SENSOR_MI0360B:
2337 reg17 = 0xe0; 2484 reg17 = 0xe0;
2338 break; 2485 break;
2339 case SENSOR_ADCM1700: 2486 case SENSOR_ADCM1700:
@@ -2375,6 +2522,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2375 break; 2522 break;
2376 case SENSOR_GC0307: 2523 case SENSOR_GC0307:
2377 case SENSOR_MT9V111: 2524 case SENSOR_MT9V111:
2525 case SENSOR_MI0360B:
2378 reg_w1(gspca_dev, 0x9a, 0x07); 2526 reg_w1(gspca_dev, 0x9a, 0x07);
2379 break; 2527 break;
2380 case SENSOR_OV7630: 2528 case SENSOR_OV7630:
@@ -2389,7 +2537,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2389 reg_w1(gspca_dev, 0x9a, 0x08); 2537 reg_w1(gspca_dev, 0x9a, 0x08);
2390 break; 2538 break;
2391 } 2539 }
2392 setsharpness(sd); 2540 setsharpness(gspca_dev);
2393 2541
2394 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 2542 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2395 reg_w1(gspca_dev, 0x05, 0x20); /* red */ 2543 reg_w1(gspca_dev, 0x05, 0x20); /* red */
@@ -2414,6 +2562,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
2414 reg17 = 0xa2; 2562 reg17 = 0xa2;
2415 reg1 = 0x44; 2563 reg1 = 0x44;
2416 break; 2564 break;
2565 case SENSOR_MI0360B:
2566 init = mi0360b_sensor_param1;
2567 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2568 reg17 = 0xe2;
2569 break;
2417 case SENSOR_MO4000: 2570 case SENSOR_MO4000:
2418 if (mode) { 2571 if (mode) {
2419/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ 2572/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
@@ -2474,8 +2627,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2474 reg1 = 0x44; 2627 reg1 = 0x44;
2475 reg17 = 0xa2; 2628 reg17 = 0xa2;
2476 break; 2629 break;
2477 default: 2630 case SENSOR_SP80708:
2478/* case SENSOR_SP80708: */
2479 init = sp80708_sensor_param1; 2631 init = sp80708_sensor_param1;
2480 if (mode) { 2632 if (mode) {
2481/*?? reg1 = 0x04; * 320 clk 48Mhz */ 2633/*?? reg1 = 0x04; * 320 clk 48Mhz */
@@ -2526,7 +2678,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
2526 break; 2678 break;
2527 } 2679 }
2528 2680
2529
2530 /* here change size mode 0 -> VGA; 1 -> CIF */ 2681 /* here change size mode 0 -> VGA; 1 -> CIF */
2531 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; 2682 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2532 reg_w1(gspca_dev, 0x18, sd->reg18); 2683 reg_w1(gspca_dev, 0x18, sd->reg18);
@@ -2535,13 +2686,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
2535 reg_w1(gspca_dev, 0x17, reg17); 2686 reg_w1(gspca_dev, 0x17, reg17);
2536 reg_w1(gspca_dev, 0x01, reg1); 2687 reg_w1(gspca_dev, 0x01, reg1);
2537 2688
2538 setvflip(sd); 2689 sethvflip(gspca_dev);
2539 setbrightness(gspca_dev); 2690 setbrightness(gspca_dev);
2540 setcontrast(gspca_dev); 2691 setcontrast(gspca_dev);
2541 setcolors(gspca_dev); 2692 setcolors(gspca_dev);
2542 setautogain(gspca_dev); 2693 setautogain(gspca_dev);
2543 setfreq(gspca_dev); 2694 setfreq(gspca_dev);
2544 return 0; 2695 return gspca_dev->usb_err;
2545} 2696}
2546 2697
2547static void sd_stopN(struct gspca_dev *gspca_dev) 2698static void sd_stopN(struct gspca_dev *gspca_dev)
@@ -2568,6 +2719,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2568 data = 0x2b; 2719 data = 0x2b;
2569 break; 2720 break;
2570 case SENSOR_MI0360: 2721 case SENSOR_MI0360:
2722 case SENSOR_MI0360B:
2571 i2c_w8(gspca_dev, stopmi0360); 2723 i2c_w8(gspca_dev, stopmi0360);
2572 data = 0x29; 2724 data = 0x29;
2573 break; 2725 break;
@@ -2641,6 +2793,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
2641 default: 2793 default:
2642/* case SENSOR_MO4000: */ 2794/* case SENSOR_MO4000: */
2643/* case SENSOR_MI0360: */ 2795/* case SENSOR_MI0360: */
2796/* case SENSOR_MI0360B: */
2644/* case SENSOR_MT9V111: */ 2797/* case SENSOR_MT9V111: */
2645 expotimes = sd->exposure; 2798 expotimes = sd->exposure;
2646 expotimes += (luma_mean - delta) >> 6; 2799 expotimes += (luma_mean - delta) >> 6;
@@ -2663,236 +2816,52 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2663 struct sd *sd = (struct sd *) gspca_dev; 2816 struct sd *sd = (struct sd *) gspca_dev;
2664 int sof, avg_lum; 2817 int sof, avg_lum;
2665 2818
2666 sof = len - 64; 2819 /* the image ends on a 64 bytes block starting with
2667 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) { 2820 * ff d9 ff ff 00 c4 c4 96
2821 * and followed by various information including luminosity */
2822 /* this block may be splitted between two packets */
2823 /* a new image always starts in a new packet */
2824 switch (gspca_dev->last_packet_type) {
2825 case DISCARD_PACKET: /* restart image building */
2826 sof = len - 64;
2827 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2828 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2829 return;
2830 case LAST_PACKET: /* put the JPEG 422 header */
2831 gspca_frame_add(gspca_dev, FIRST_PACKET,
2832 sd->jpeg_hdr, JPEG_HDR_SZ);
2833 break;
2834 }
2835 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2836
2837 data = gspca_dev->image;
2838 if (data == NULL)
2839 return;
2840 sof = gspca_dev->image_len - 64;
2841 if (data[sof] != 0xff
2842 || data[sof + 1] != 0xd9)
2843 return;
2668 2844
2669 /* end of frame */ 2845 /* end of image found - remove the trailing data */
2670 gspca_frame_add(gspca_dev, LAST_PACKET, 2846 gspca_dev->image_len = sof + 2;
2671 data, sof + 2); 2847 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2672 if (sd->ag_cnt < 0) 2848 if (sd->ag_cnt < 0)
2673 return; 2849 return;
2674/* w1 w2 w3 */ 2850/* w1 w2 w3 */
2675/* w4 w5 w6 */ 2851/* w4 w5 w6 */
2676/* w7 w8 */ 2852/* w7 w8 */
2677/* w4 */ 2853/* w4 */
2678 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6; 2854 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2679/* w6 */ 2855/* w6 */
2680 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6; 2856 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2681/* w2 */ 2857/* w2 */
2682 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6; 2858 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2683/* w8 */ 2859/* w8 */
2684 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6; 2860 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2685/* w5 */ 2861/* w5 */
2686 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4; 2862 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2687 avg_lum >>= 4; 2863 avg_lum >>= 4;
2688 atomic_set(&sd->avg_lum, avg_lum); 2864 atomic_set(&sd->avg_lum, avg_lum);
2689 return;
2690 }
2691 if (gspca_dev->last_packet_type == LAST_PACKET) {
2692
2693 /* put the JPEG 422 header */
2694 gspca_frame_add(gspca_dev, FIRST_PACKET,
2695 sd->jpeg_hdr, JPEG_HDR_SZ);
2696 }
2697 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2698}
2699
2700static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2701{
2702 struct sd *sd = (struct sd *) gspca_dev;
2703
2704 sd->brightness = val;
2705 if (gspca_dev->streaming)
2706 setbrightness(gspca_dev);
2707 return 0;
2708}
2709
2710static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2711{
2712 struct sd *sd = (struct sd *) gspca_dev;
2713
2714 *val = sd->brightness;
2715 return 0;
2716}
2717
2718static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2719{
2720 struct sd *sd = (struct sd *) gspca_dev;
2721
2722 sd->contrast = val;
2723 if (gspca_dev->streaming)
2724 setcontrast(gspca_dev);
2725 return 0;
2726}
2727
2728static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2729{
2730 struct sd *sd = (struct sd *) gspca_dev;
2731
2732 *val = sd->contrast;
2733 return 0;
2734}
2735
2736static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2737{
2738 struct sd *sd = (struct sd *) gspca_dev;
2739
2740 sd->colors = val;
2741 if (gspca_dev->streaming)
2742 setcolors(gspca_dev);
2743 return 0;
2744}
2745
2746static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2747{
2748 struct sd *sd = (struct sd *) gspca_dev;
2749
2750 *val = sd->colors;
2751 return 0;
2752}
2753
2754static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2755{
2756 struct sd *sd = (struct sd *) gspca_dev;
2757
2758 sd->blue = val;
2759 if (gspca_dev->streaming)
2760 setredblue(gspca_dev);
2761 return 0;
2762}
2763
2764static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2765{
2766 struct sd *sd = (struct sd *) gspca_dev;
2767
2768 *val = sd->blue;
2769 return 0;
2770}
2771
2772static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2773{
2774 struct sd *sd = (struct sd *) gspca_dev;
2775
2776 sd->red = val;
2777 if (gspca_dev->streaming)
2778 setredblue(gspca_dev);
2779 return 0;
2780}
2781
2782static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2783{
2784 struct sd *sd = (struct sd *) gspca_dev;
2785
2786 *val = sd->red;
2787 return 0;
2788}
2789
2790static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2791{
2792 struct sd *sd = (struct sd *) gspca_dev;
2793
2794 sd->gamma = val;
2795 if (gspca_dev->streaming)
2796 setgamma(gspca_dev);
2797 return 0;
2798}
2799
2800static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2801{
2802 struct sd *sd = (struct sd *) gspca_dev;
2803
2804 *val = sd->gamma;
2805 return 0;
2806}
2807
2808static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2809{
2810 struct sd *sd = (struct sd *) gspca_dev;
2811
2812 sd->autogain = val;
2813 if (gspca_dev->streaming)
2814 setautogain(gspca_dev);
2815 return 0;
2816}
2817
2818static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2819{
2820 struct sd *sd = (struct sd *) gspca_dev;
2821
2822 *val = sd->autogain;
2823 return 0;
2824}
2825
2826static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2827{
2828 struct sd *sd = (struct sd *) gspca_dev;
2829
2830 sd->sharpness = val;
2831 if (gspca_dev->streaming)
2832 setsharpness(sd);
2833 return 0;
2834}
2835
2836static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2837{
2838 struct sd *sd = (struct sd *) gspca_dev;
2839
2840 *val = sd->sharpness;
2841 return 0;
2842}
2843
2844static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2845{
2846 struct sd *sd = (struct sd *) gspca_dev;
2847
2848 sd->vflip = val;
2849 if (gspca_dev->streaming)
2850 setvflip(sd);
2851 return 0;
2852}
2853
2854static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2855{
2856 struct sd *sd = (struct sd *) gspca_dev;
2857
2858 *val = sd->vflip;
2859 return 0;
2860}
2861
2862static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2863{
2864 struct sd *sd = (struct sd *) gspca_dev;
2865
2866 sd->infrared = val;
2867 if (gspca_dev->streaming)
2868 setinfrared(sd);
2869 return 0;
2870}
2871
2872static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2873{
2874 struct sd *sd = (struct sd *) gspca_dev;
2875
2876 *val = sd->infrared;
2877 return 0;
2878}
2879
2880static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2881{
2882 struct sd *sd = (struct sd *) gspca_dev;
2883
2884 sd->freq = val;
2885 if (gspca_dev->streaming)
2886 setfreq(gspca_dev);
2887 return 0;
2888}
2889
2890static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2891{
2892 struct sd *sd = (struct sd *) gspca_dev;
2893
2894 *val = sd->freq;
2895 return 0;
2896} 2865}
2897 2866
2898static int sd_set_jcomp(struct gspca_dev *gspca_dev, 2867static int sd_set_jcomp(struct gspca_dev *gspca_dev,
@@ -2944,7 +2913,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
2944 return -EINVAL; 2913 return -EINVAL;
2945} 2914}
2946 2915
2947#ifdef CONFIG_INPUT 2916#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2948static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 2917static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2949 u8 *data, /* interrupt packet data */ 2918 u8 *data, /* interrupt packet data */
2950 int len) /* interrupt packet length */ 2919 int len) /* interrupt packet length */
@@ -2967,7 +2936,7 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2967static const struct sd_desc sd_desc = { 2936static const struct sd_desc sd_desc = {
2968 .name = MODULE_NAME, 2937 .name = MODULE_NAME,
2969 .ctrls = sd_ctrls, 2938 .ctrls = sd_ctrls,
2970 .nctrls = ARRAY_SIZE(sd_ctrls), 2939 .nctrls = NCTRLS,
2971 .config = sd_config, 2940 .config = sd_config,
2972 .init = sd_init, 2941 .init = sd_init,
2973 .start = sd_start, 2942 .start = sd_start,
@@ -2977,7 +2946,7 @@ static const struct sd_desc sd_desc = {
2977 .get_jcomp = sd_get_jcomp, 2946 .get_jcomp = sd_get_jcomp,
2978 .set_jcomp = sd_set_jcomp, 2947 .set_jcomp = sd_set_jcomp,
2979 .querymenu = sd_querymenu, 2948 .querymenu = sd_querymenu,
2980#ifdef CONFIG_INPUT 2949#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2981 .int_pkt_scan = sd_int_pkt_scan, 2950 .int_pkt_scan = sd_int_pkt_scan,
2982#endif 2951#endif
2983}; 2952};
@@ -3005,6 +2974,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3005 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, 2974 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3006/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ 2975/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3007 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, 2976 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2977 /* or MT9V111 */
3008/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ 2978/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3009/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ 2979/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3010/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ 2980/* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
@@ -3019,7 +2989,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
3019 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, 2989 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
3020#endif 2990#endif
3021 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ 2991 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
3022/* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, * / GC0305*/ 2992 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
3023/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ 2993/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3024 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ 2994 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3025 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ 2995 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
@@ -3031,12 +3001,12 @@ static const __devinitdata struct usb_device_id device_table[] = {
3031 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ 3001 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
3032/*bw600.inf:*/ 3002/*bw600.inf:*/
3033 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ 3003 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
3004 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
3034 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, 3005 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3035 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, 3006 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3036/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ 3007/* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
3037#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3038 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, 3008 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
3039#endif 3009 /* or MT9V111 / MI0360B */
3040/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ 3010/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3041 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, 3011 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3042 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, 3012 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
@@ -3076,17 +3046,11 @@ static struct usb_driver sd_driver = {
3076/* -- module insert / remove -- */ 3046/* -- module insert / remove -- */
3077static int __init sd_mod_init(void) 3047static int __init sd_mod_init(void)
3078{ 3048{
3079 int ret; 3049 return usb_register(&sd_driver);
3080 ret = usb_register(&sd_driver);
3081 if (ret < 0)
3082 return ret;
3083 info("registered");
3084 return 0;
3085} 3050}
3086static void __exit sd_mod_exit(void) 3051static void __exit sd_mod_exit(void)
3087{ 3052{
3088 usb_deregister(&sd_driver); 3053 usb_deregister(&sd_driver);
3089 info("deregistered");
3090} 3054}
3091 3055
3092module_init(sd_mod_init); 3056module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca1528.c b/drivers/media/video/gspca/spca1528.c
index 3f514eb1d99d..e64338664410 100644
--- a/drivers/media/video/gspca/spca1528.c
+++ b/drivers/media/video/gspca/spca1528.c
@@ -171,7 +171,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
171 PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", req, index, 171 PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", req, index,
172 gspca_dev->usb_buf[0]); 172 gspca_dev->usb_buf[0]);
173 if (ret < 0) { 173 if (ret < 0) {
174 PDEBUG(D_ERR, "reg_r err %d", ret); 174 err("reg_r err %d", ret);
175 gspca_dev->usb_err = ret; 175 gspca_dev->usb_err = ret;
176 } 176 }
177} 177}
@@ -193,7 +193,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
193 value, index, 193 value, index,
194 NULL, 0, 500); 194 NULL, 0, 500);
195 if (ret < 0) { 195 if (ret < 0) {
196 PDEBUG(D_ERR, "reg_w err %d", ret); 196 err("reg_w err %d", ret);
197 gspca_dev->usb_err = ret; 197 gspca_dev->usb_err = ret;
198 } 198 }
199} 199}
@@ -217,7 +217,7 @@ static void reg_wb(struct gspca_dev *gspca_dev,
217 value, index, 217 value, index,
218 gspca_dev->usb_buf, 1, 500); 218 gspca_dev->usb_buf, 1, 500);
219 if (ret < 0) { 219 if (ret < 0) {
220 PDEBUG(D_ERR, "reg_w err %d", ret); 220 err("reg_w err %d", ret);
221 gspca_dev->usb_err = ret; 221 gspca_dev->usb_err = ret;
222 } 222 }
223} 223}
@@ -587,18 +587,11 @@ static struct usb_driver sd_driver = {
587/* -- module insert / remove -- */ 587/* -- module insert / remove -- */
588static int __init sd_mod_init(void) 588static int __init sd_mod_init(void)
589{ 589{
590 int ret; 590 return usb_register(&sd_driver);
591
592 ret = usb_register(&sd_driver);
593 if (ret < 0)
594 return ret;
595 info("registered");
596 return 0;
597} 591}
598static void __exit sd_mod_exit(void) 592static void __exit sd_mod_exit(void)
599{ 593{
600 usb_deregister(&sd_driver); 594 usb_deregister(&sd_driver);
601 info("deregistered");
602} 595}
603 596
604module_init(sd_mod_init); 597module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index c02beb6c1e93..8e202b9039f1 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -396,7 +396,7 @@ static int reg_w(struct gspca_dev *gspca_dev,
396 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 396 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
397 value, index, NULL, 0, 500); 397 value, index, NULL, 0, 500);
398 if (ret < 0) 398 if (ret < 0)
399 PDEBUG(D_ERR, "reg write: error %d", ret); 399 err("reg write: error %d", ret);
400 return ret; 400 return ret;
401} 401}
402 402
@@ -418,8 +418,8 @@ static int reg_r_12(struct gspca_dev *gspca_dev,
418 gspca_dev->usb_buf, length, 418 gspca_dev->usb_buf, length,
419 500); /* timeout */ 419 500); /* timeout */
420 if (ret < 0) { 420 if (ret < 0) {
421 PDEBUG(D_ERR, "reg_r_12 err %d", ret); 421 err("reg_r_12 err %d", ret);
422 return -1; 422 return ret;
423 } 423 }
424 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; 424 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
425} 425}
@@ -1093,17 +1093,11 @@ static struct usb_driver sd_driver = {
1093/* -- module insert / remove -- */ 1093/* -- module insert / remove -- */
1094static int __init sd_mod_init(void) 1094static int __init sd_mod_init(void)
1095{ 1095{
1096 int ret; 1096 return usb_register(&sd_driver);
1097 ret = usb_register(&sd_driver);
1098 if (ret < 0)
1099 return ret;
1100 PDEBUG(D_PROBE, "registered");
1101 return 0;
1102} 1097}
1103static void __exit sd_mod_exit(void) 1098static void __exit sd_mod_exit(void)
1104{ 1099{
1105 usb_deregister(&sd_driver); 1100 usb_deregister(&sd_driver);
1106 PDEBUG(D_PROBE, "deregistered");
1107} 1101}
1108 1102
1109module_init(sd_mod_init); 1103module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index c99333933e32..642839a11e8d 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -1724,7 +1724,7 @@ static const __u16 spca501c_mysterious_init_data[][3] = {
1724 {0x00, 0x0000, 0x0048}, 1724 {0x00, 0x0000, 0x0048},
1725 {0x00, 0x0000, 0x0049}, 1725 {0x00, 0x0000, 0x0049},
1726 {0x00, 0x0008, 0x004a}, 1726 {0x00, 0x0008, 0x004a},
1727/* DSP Registers */ 1727/* DSP Registers */
1728 {0x01, 0x00a6, 0x0000}, 1728 {0x01, 0x00a6, 0x0000},
1729 {0x01, 0x0028, 0x0001}, 1729 {0x01, 0x0028, 0x0001},
1730 {0x01, 0x0000, 0x0002}, 1730 {0x01, 0x0000, 0x0002},
@@ -1788,7 +1788,7 @@ static const __u16 spca501c_mysterious_init_data[][3] = {
1788 {0x05, 0x0022, 0x0004}, 1788 {0x05, 0x0022, 0x0004},
1789 {0x05, 0x0025, 0x0001}, 1789 {0x05, 0x0025, 0x0001},
1790 {0x05, 0x0000, 0x0000}, 1790 {0x05, 0x0000, 0x0000},
1791/* Part 4 */ 1791/* Part 4 */
1792 {0x05, 0x0026, 0x0001}, 1792 {0x05, 0x0026, 0x0001},
1793 {0x05, 0x0001, 0x0000}, 1793 {0x05, 0x0001, 0x0000},
1794 {0x05, 0x0027, 0x0001}, 1794 {0x05, 0x0027, 0x0001},
@@ -1806,7 +1806,7 @@ static const __u16 spca501c_mysterious_init_data[][3] = {
1806 {0x05, 0x0001, 0x0000}, 1806 {0x05, 0x0001, 0x0000},
1807 {0x05, 0x0027, 0x0001}, 1807 {0x05, 0x0027, 0x0001},
1808 {0x05, 0x004e, 0x0000}, 1808 {0x05, 0x004e, 0x0000},
1809/* Part 5 */ 1809/* Part 5 */
1810 {0x01, 0x0003, 0x003f}, 1810 {0x01, 0x0003, 0x003f},
1811 {0x01, 0x0001, 0x0056}, 1811 {0x01, 0x0001, 0x0056},
1812 {0x01, 0x000f, 0x0008}, 1812 {0x01, 0x000f, 0x0008},
@@ -1852,7 +1852,7 @@ static int reg_write(struct usb_device *dev,
1852 PDEBUG(D_USBO, "reg write: 0x%02x 0x%02x 0x%02x", 1852 PDEBUG(D_USBO, "reg write: 0x%02x 0x%02x 0x%02x",
1853 req, index, value); 1853 req, index, value);
1854 if (ret < 0) 1854 if (ret < 0)
1855 PDEBUG(D_ERR, "reg write: error %d", ret); 1855 err("reg write: error %d", ret);
1856 return ret; 1856 return ret;
1857} 1857}
1858 1858
@@ -2189,17 +2189,11 @@ static struct usb_driver sd_driver = {
2189/* -- module insert / remove -- */ 2189/* -- module insert / remove -- */
2190static int __init sd_mod_init(void) 2190static int __init sd_mod_init(void)
2191{ 2191{
2192 int ret; 2192 return usb_register(&sd_driver);
2193 ret = usb_register(&sd_driver);
2194 if (ret < 0)
2195 return ret;
2196 PDEBUG(D_PROBE, "registered");
2197 return 0;
2198} 2193}
2199static void __exit sd_mod_exit(void) 2194static void __exit sd_mod_exit(void)
2200{ 2195{
2201 usb_deregister(&sd_driver); 2196 usb_deregister(&sd_driver);
2202 PDEBUG(D_PROBE, "deregistered");
2203} 2197}
2204 2198
2205module_init(sd_mod_init); 2199module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index c576eed73abe..bc9dd9034ab4 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -368,10 +368,6 @@ static const u8 spca505b_init_data[][3] = {
368 {0x08, 0x00, 0x00}, 368 {0x08, 0x00, 0x00},
369 {0x08, 0x00, 0x01}, 369 {0x08, 0x00, 0x01},
370 {0x08, 0x00, 0x02}, 370 {0x08, 0x00, 0x02},
371 {0x00, 0x01, 0x00},
372 {0x00, 0x01, 0x01},
373 {0x00, 0x01, 0x34},
374 {0x00, 0x01, 0x35},
375 {0x06, 0x18, 0x08}, 371 {0x06, 0x18, 0x08},
376 {0x06, 0xfc, 0x09}, 372 {0x06, 0xfc, 0x09},
377 {0x06, 0xfc, 0x0a}, 373 {0x06, 0xfc, 0x0a},
@@ -582,7 +578,7 @@ static int reg_write(struct usb_device *dev,
582 PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", 578 PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d",
583 req, index, value, ret); 579 req, index, value, ret);
584 if (ret < 0) 580 if (ret < 0)
585 PDEBUG(D_ERR, "reg write: error %d", ret); 581 err("reg write: error %d", ret);
586 return ret; 582 return ret;
587} 583}
588 584
@@ -689,8 +685,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
689 return ret; 685 return ret;
690 } 686 }
691 if (ret != 0x0101) { 687 if (ret != 0x0101) {
692 PDEBUG(D_ERR|D_CONF, 688 err("After vector read returns 0x%04x should be 0x0101",
693 "After vector read returns 0x%04x should be 0x0101",
694 ret); 689 ret);
695 } 690 }
696 691
@@ -821,18 +816,11 @@ static struct usb_driver sd_driver = {
821/* -- module insert / remove -- */ 816/* -- module insert / remove -- */
822static int __init sd_mod_init(void) 817static int __init sd_mod_init(void)
823{ 818{
824 int ret; 819 return usb_register(&sd_driver);
825
826 ret = usb_register(&sd_driver);
827 if (ret < 0)
828 return ret;
829 PDEBUG(D_PROBE, "registered");
830 return 0;
831} 820}
832static void __exit sd_mod_exit(void) 821static void __exit sd_mod_exit(void)
833{ 822{
834 usb_deregister(&sd_driver); 823 usb_deregister(&sd_driver);
835 PDEBUG(D_PROBE, "deregistered");
836} 824}
837 825
838module_init(sd_mod_init); 826module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index edf0fe157501..7307638ac91d 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -92,8 +92,7 @@ static const struct v4l2_pix_format sif_mode[] = {
92 * Initialization data: this is the first set-up data written to the 92 * Initialization data: this is the first set-up data written to the
93 * device (before the open data). 93 * device (before the open data).
94 */ 94 */
95static const u16 spca508_init_data[][2] = 95static const u16 spca508_init_data[][2] = {
96{
97 {0x0000, 0x870b}, 96 {0x0000, 0x870b},
98 97
99 {0x0020, 0x8112}, /* Video drop enable, ISO streaming disable */ 98 {0x0020, 0x8112}, /* Video drop enable, ISO streaming disable */
@@ -1276,7 +1275,7 @@ static int reg_write(struct usb_device *dev,
1276 PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x", 1275 PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x",
1277 index, value); 1276 index, value);
1278 if (ret < 0) 1277 if (ret < 0)
1279 PDEBUG(D_ERR|D_USBO, "reg write: error %d", ret); 1278 err("reg write: error %d", ret);
1280 return ret; 1279 return ret;
1281} 1280}
1282 1281
@@ -1298,7 +1297,7 @@ static int reg_read(struct gspca_dev *gspca_dev,
1298 PDEBUG(D_USBI, "reg read i:%04x --> %02x", 1297 PDEBUG(D_USBI, "reg read i:%04x --> %02x",
1299 index, gspca_dev->usb_buf[0]); 1298 index, gspca_dev->usb_buf[0]);
1300 if (ret < 0) { 1299 if (ret < 0) {
1301 PDEBUG(D_ERR|D_USBI, "reg_read err %d", ret); 1300 err("reg_read err %d", ret);
1302 return ret; 1301 return ret;
1303 } 1302 }
1304 return gspca_dev->usb_buf[0]; 1303 return gspca_dev->usb_buf[0];
@@ -1543,18 +1542,11 @@ static struct usb_driver sd_driver = {
1543/* -- module insert / remove -- */ 1542/* -- module insert / remove -- */
1544static int __init sd_mod_init(void) 1543static int __init sd_mod_init(void)
1545{ 1544{
1546 int ret; 1545 return usb_register(&sd_driver);
1547
1548 ret = usb_register(&sd_driver);
1549 if (ret < 0)
1550 return ret;
1551 PDEBUG(D_PROBE, "registered");
1552 return 0;
1553} 1546}
1554static void __exit sd_mod_exit(void) 1547static void __exit sd_mod_exit(void)
1555{ 1548{
1556 usb_deregister(&sd_driver); 1549 usb_deregister(&sd_driver);
1557 PDEBUG(D_PROBE, "deregistered");
1558} 1550}
1559 1551
1560module_init(sd_mod_init); 1552module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 7bb2355005dc..ad73f4812c05 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -315,7 +315,7 @@ static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value)
315 value, index, NULL, 0, 500); 315 value, index, NULL, 0, 500);
316 PDEBUG(D_USBO, "reg write: 0x%02x:0x%02x", index, value); 316 PDEBUG(D_USBO, "reg write: 0x%02x:0x%02x", index, value);
317 if (ret < 0) 317 if (ret < 0)
318 PDEBUG(D_ERR, "reg write: error %d", ret); 318 err("reg write: error %d", ret);
319} 319}
320 320
321static void write_vector(struct gspca_dev *gspca_dev, 321static void write_vector(struct gspca_dev *gspca_dev,
@@ -787,7 +787,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
787 return; 787 return;
788 } 788 }
789 789
790#ifdef CONFIG_INPUT 790#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
791 if (data[0] & 0x20) { 791 if (data[0] & 0x20) {
792 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 792 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
793 input_sync(gspca_dev->input_dev); 793 input_sync(gspca_dev->input_dev);
@@ -1037,7 +1037,7 @@ static const struct sd_desc sd_desc_12a = {
1037 .start = sd_start_12a, 1037 .start = sd_start_12a,
1038 .stopN = sd_stopN, 1038 .stopN = sd_stopN,
1039 .pkt_scan = sd_pkt_scan, 1039 .pkt_scan = sd_pkt_scan,
1040#ifdef CONFIG_INPUT 1040#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1041 .other_input = 1, 1041 .other_input = 1,
1042#endif 1042#endif
1043}; 1043};
@@ -1051,7 +1051,7 @@ static const struct sd_desc sd_desc_72a = {
1051 .stopN = sd_stopN, 1051 .stopN = sd_stopN,
1052 .pkt_scan = sd_pkt_scan, 1052 .pkt_scan = sd_pkt_scan,
1053 .dq_callback = do_autogain, 1053 .dq_callback = do_autogain,
1054#ifdef CONFIG_INPUT 1054#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1055 .other_input = 1, 1055 .other_input = 1,
1056#endif 1056#endif
1057}; 1057};
@@ -1107,17 +1107,11 @@ static struct usb_driver sd_driver = {
1107/* -- module insert / remove -- */ 1107/* -- module insert / remove -- */
1108static int __init sd_mod_init(void) 1108static int __init sd_mod_init(void)
1109{ 1109{
1110 int ret; 1110 return usb_register(&sd_driver);
1111 ret = usb_register(&sd_driver);
1112 if (ret < 0)
1113 return ret;
1114 PDEBUG(D_PROBE, "registered");
1115 return 0;
1116} 1111}
1117static void __exit sd_mod_exit(void) 1112static void __exit sd_mod_exit(void)
1118{ 1113{
1119 usb_deregister(&sd_driver); 1114 usb_deregister(&sd_driver);
1120 PDEBUG(D_PROBE, "deregistered");
1121} 1115}
1122 1116
1123module_init(sd_mod_init); 1117module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c
index 09b3f93fa4d6..404067745775 100644
--- a/drivers/media/video/gspca/sq905.c
+++ b/drivers/media/video/gspca/sq905.c
@@ -123,7 +123,7 @@ static int sq905_command(struct gspca_dev *gspca_dev, u16 index)
123 SQ905_COMMAND, index, gspca_dev->usb_buf, 1, 123 SQ905_COMMAND, index, gspca_dev->usb_buf, 1,
124 SQ905_CMD_TIMEOUT); 124 SQ905_CMD_TIMEOUT);
125 if (ret < 0) { 125 if (ret < 0) {
126 PDEBUG(D_ERR, "%s: usb_control_msg failed (%d)", 126 err("%s: usb_control_msg failed (%d)",
127 __func__, ret); 127 __func__, ret);
128 return ret; 128 return ret;
129 } 129 }
@@ -135,7 +135,7 @@ static int sq905_command(struct gspca_dev *gspca_dev, u16 index)
135 SQ905_PING, 0, gspca_dev->usb_buf, 1, 135 SQ905_PING, 0, gspca_dev->usb_buf, 1,
136 SQ905_CMD_TIMEOUT); 136 SQ905_CMD_TIMEOUT);
137 if (ret < 0) { 137 if (ret < 0) {
138 PDEBUG(D_ERR, "%s: usb_control_msg failed 2 (%d)", 138 err("%s: usb_control_msg failed 2 (%d)",
139 __func__, ret); 139 __func__, ret);
140 return ret; 140 return ret;
141 } 141 }
@@ -158,7 +158,7 @@ static int sq905_ack_frame(struct gspca_dev *gspca_dev)
158 SQ905_READ_DONE, 0, gspca_dev->usb_buf, 1, 158 SQ905_READ_DONE, 0, gspca_dev->usb_buf, 1,
159 SQ905_CMD_TIMEOUT); 159 SQ905_CMD_TIMEOUT);
160 if (ret < 0) { 160 if (ret < 0) {
161 PDEBUG(D_ERR, "%s: usb_control_msg failed (%d)", __func__, ret); 161 err("%s: usb_control_msg failed (%d)", __func__, ret);
162 return ret; 162 return ret;
163 } 163 }
164 164
@@ -186,7 +186,7 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock)
186 if (need_lock) 186 if (need_lock)
187 mutex_unlock(&gspca_dev->usb_lock); 187 mutex_unlock(&gspca_dev->usb_lock);
188 if (ret < 0) { 188 if (ret < 0) {
189 PDEBUG(D_ERR, "%s: usb_control_msg failed (%d)", __func__, ret); 189 err("%s: usb_control_msg failed (%d)", __func__, ret);
190 return ret; 190 return ret;
191 } 191 }
192 ret = usb_bulk_msg(gspca_dev->dev, 192 ret = usb_bulk_msg(gspca_dev->dev,
@@ -195,7 +195,7 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock)
195 195
196 /* successful, it returns 0, otherwise negative */ 196 /* successful, it returns 0, otherwise negative */
197 if (ret < 0 || act_len != size) { 197 if (ret < 0 || act_len != size) {
198 PDEBUG(D_ERR, "bulk read fail (%d) len %d/%d", 198 err("bulk read fail (%d) len %d/%d",
199 ret, act_len, size); 199 ret, act_len, size);
200 return -EIO; 200 return -EIO;
201 } 201 }
@@ -226,7 +226,7 @@ static void sq905_dostream(struct work_struct *work)
226 226
227 buffer = kmalloc(SQ905_MAX_TRANSFER, GFP_KERNEL | GFP_DMA); 227 buffer = kmalloc(SQ905_MAX_TRANSFER, GFP_KERNEL | GFP_DMA);
228 if (!buffer) { 228 if (!buffer) {
229 PDEBUG(D_ERR, "Couldn't allocate USB buffer"); 229 err("Couldn't allocate USB buffer");
230 goto quit_stream; 230 goto quit_stream;
231 } 231 }
232 232
@@ -436,19 +436,12 @@ static struct usb_driver sd_driver = {
436/* -- module insert / remove -- */ 436/* -- module insert / remove -- */
437static int __init sd_mod_init(void) 437static int __init sd_mod_init(void)
438{ 438{
439 int ret; 439 return usb_register(&sd_driver);
440
441 ret = usb_register(&sd_driver);
442 if (ret < 0)
443 return ret;
444 PDEBUG(D_PROBE, "registered");
445 return 0;
446} 440}
447 441
448static void __exit sd_mod_exit(void) 442static void __exit sd_mod_exit(void)
449{ 443{
450 usb_deregister(&sd_driver); 444 usb_deregister(&sd_driver);
451 PDEBUG(D_PROBE, "deregistered");
452} 445}
453 446
454module_init(sd_mod_init); 447module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 4c70628ca615..c2e88b5303cb 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -95,7 +95,7 @@ static int sq905c_command(struct gspca_dev *gspca_dev, u16 command, u16 index)
95 command, index, NULL, 0, 95 command, index, NULL, 0,
96 SQ905C_CMD_TIMEOUT); 96 SQ905C_CMD_TIMEOUT);
97 if (ret < 0) { 97 if (ret < 0) {
98 PDEBUG(D_ERR, "%s: usb_control_msg failed (%d)", 98 err("%s: usb_control_msg failed (%d)",
99 __func__, ret); 99 __func__, ret);
100 return ret; 100 return ret;
101 } 101 }
@@ -115,7 +115,7 @@ static int sq905c_read(struct gspca_dev *gspca_dev, u16 command, u16 index,
115 command, index, gspca_dev->usb_buf, size, 115 command, index, gspca_dev->usb_buf, size,
116 SQ905C_CMD_TIMEOUT); 116 SQ905C_CMD_TIMEOUT);
117 if (ret < 0) { 117 if (ret < 0) {
118 PDEBUG(D_ERR, "%s: usb_control_msg failed (%d)", 118 err("%s: usb_control_msg failed (%d)",
119 __func__, ret); 119 __func__, ret);
120 return ret; 120 return ret;
121 } 121 }
@@ -146,7 +146,7 @@ static void sq905c_dostream(struct work_struct *work)
146 146
147 buffer = kmalloc(SQ905C_MAX_TRANSFER, GFP_KERNEL | GFP_DMA); 147 buffer = kmalloc(SQ905C_MAX_TRANSFER, GFP_KERNEL | GFP_DMA);
148 if (!buffer) { 148 if (!buffer) {
149 PDEBUG(D_ERR, "Couldn't allocate USB buffer"); 149 err("Couldn't allocate USB buffer");
150 goto quit_stream; 150 goto quit_stream;
151 } 151 }
152 152
@@ -341,19 +341,12 @@ static struct usb_driver sd_driver = {
341/* -- module insert / remove -- */ 341/* -- module insert / remove -- */
342static int __init sd_mod_init(void) 342static int __init sd_mod_init(void)
343{ 343{
344 int ret; 344 return usb_register(&sd_driver);
345
346 ret = usb_register(&sd_driver);
347 if (ret < 0)
348 return ret;
349 PDEBUG(D_PROBE, "registered");
350 return 0;
351} 345}
352 346
353static void __exit sd_mod_exit(void) 347static void __exit sd_mod_exit(void)
354{ 348{
355 usb_deregister(&sd_driver); 349 usb_deregister(&sd_driver);
356 PDEBUG(D_PROBE, "deregistered");
357} 350}
358 351
359module_init(sd_mod_init); 352module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/sq930x.c b/drivers/media/video/gspca/sq930x.c
index 7ae6522d4edf..3e4b0b94c700 100644
--- a/drivers/media/video/gspca/sq930x.c
+++ b/drivers/media/video/gspca/sq930x.c
@@ -468,7 +468,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
468 value, 0, gspca_dev->usb_buf, len, 468 value, 0, gspca_dev->usb_buf, len,
469 500); 469 500);
470 if (ret < 0) { 470 if (ret < 0) {
471 PDEBUG(D_ERR, "reg_r %04x failed %d", value, ret); 471 err("reg_r %04x failed %d", value, ret);
472 gspca_dev->usb_err = ret; 472 gspca_dev->usb_err = ret;
473 } 473 }
474} 474}
@@ -488,7 +488,7 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 value, u16 index)
488 500); 488 500);
489 msleep(30); 489 msleep(30);
490 if (ret < 0) { 490 if (ret < 0) {
491 PDEBUG(D_ERR, "reg_w %04x %04x failed %d", value, index, ret); 491 err("reg_w %04x %04x failed %d", value, index, ret);
492 gspca_dev->usb_err = ret; 492 gspca_dev->usb_err = ret;
493 } 493 }
494} 494}
@@ -511,7 +511,7 @@ static void reg_wb(struct gspca_dev *gspca_dev, u16 value, u16 index,
511 1000); 511 1000);
512 msleep(30); 512 msleep(30);
513 if (ret < 0) { 513 if (ret < 0) {
514 PDEBUG(D_ERR, "reg_wb %04x %04x failed %d", value, index, ret); 514 err("reg_wb %04x %04x failed %d", value, index, ret);
515 gspca_dev->usb_err = ret; 515 gspca_dev->usb_err = ret;
516 } 516 }
517} 517}
@@ -556,7 +556,7 @@ static void i2c_write(struct sd *sd,
556 gspca_dev->usb_buf, buf - gspca_dev->usb_buf, 556 gspca_dev->usb_buf, buf - gspca_dev->usb_buf,
557 500); 557 500);
558 if (ret < 0) { 558 if (ret < 0) {
559 PDEBUG(D_ERR, "i2c_write failed %d", ret); 559 err("i2c_write failed %d", ret);
560 gspca_dev->usb_err = ret; 560 gspca_dev->usb_err = ret;
561 } 561 }
562} 562}
@@ -612,7 +612,7 @@ static void ucbus_write(struct gspca_dev *gspca_dev,
612 gspca_dev->usb_buf, buf - gspca_dev->usb_buf, 612 gspca_dev->usb_buf, buf - gspca_dev->usb_buf,
613 500); 613 500);
614 if (ret < 0) { 614 if (ret < 0) {
615 PDEBUG(D_ERR, "ucbus_write failed %d", ret); 615 err("ucbus_write failed %d", ret);
616 gspca_dev->usb_err = ret; 616 gspca_dev->usb_err = ret;
617 return; 617 return;
618 } 618 }
@@ -688,7 +688,7 @@ static void cmos_probe(struct gspca_dev *gspca_dev)
688 break; 688 break;
689 } 689 }
690 if (i >= ARRAY_SIZE(probe_order)) 690 if (i >= ARRAY_SIZE(probe_order))
691 PDEBUG(D_PROBE, "Unknown sensor"); 691 err("Unknown sensor");
692 else 692 else
693 sd->sensor = probe_order[i]; 693 sd->sensor = probe_order[i];
694} 694}
@@ -1079,7 +1079,7 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev)
1079 gspca_dev->cam.bulk_nurbs = 1; 1079 gspca_dev->cam.bulk_nurbs = 1;
1080 ret = usb_submit_urb(gspca_dev->urb[0], GFP_ATOMIC); 1080 ret = usb_submit_urb(gspca_dev->urb[0], GFP_ATOMIC);
1081 if (ret < 0) 1081 if (ret < 0)
1082 PDEBUG(D_ERR|D_PACK, "sd_dq_callback() err %d", ret); 1082 err("sd_dq_callback() err %d", ret);
1083 1083
1084 /* wait a little time, otherwise the webcam crashes */ 1084 /* wait a little time, otherwise the webcam crashes */
1085 msleep(100); 1085 msleep(100);
@@ -1185,18 +1185,11 @@ static struct usb_driver sd_driver = {
1185/* -- module insert / remove -- */ 1185/* -- module insert / remove -- */
1186static int __init sd_mod_init(void) 1186static int __init sd_mod_init(void)
1187{ 1187{
1188 int ret; 1188 return usb_register(&sd_driver);
1189
1190 ret = usb_register(&sd_driver);
1191 if (ret < 0)
1192 return ret;
1193 info("registered");
1194 return 0;
1195} 1189}
1196static void __exit sd_mod_exit(void) 1190static void __exit sd_mod_exit(void)
1197{ 1191{
1198 usb_deregister(&sd_driver); 1192 usb_deregister(&sd_driver);
1199 info("deregistered");
1200} 1193}
1201 1194
1202module_init(sd_mod_init); 1195module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index 2aedf4b1bfa3..11a192b95ed4 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -27,14 +27,21 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
27MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); 27MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver");
28MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
29 29
30/* controls */
31enum e_ctrl {
32 BRIGHTNESS,
33 CONTRAST,
34 COLORS,
35 LIGHTFREQ,
36 NCTRLS /* number of controls */
37};
38
30/* specific webcam descriptor */ 39/* specific webcam descriptor */
31struct sd { 40struct sd {
32 struct gspca_dev gspca_dev; /* !! must be the first item */ 41 struct gspca_dev gspca_dev; /* !! must be the first item */
33 42
34 unsigned char brightness; 43 struct gspca_ctrl ctrls[NCTRLS];
35 unsigned char contrast; 44
36 unsigned char colors;
37 unsigned char lightfreq;
38 u8 quality; 45 u8 quality;
39#define QUALITY_MIN 70 46#define QUALITY_MIN 70
40#define QUALITY_MAX 95 47#define QUALITY_MAX 95
@@ -44,17 +51,13 @@ struct sd {
44}; 51};
45 52
46/* V4L2 controls supported by the driver */ 53/* V4L2 controls supported by the driver */
47static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); 54static void setbrightness(struct gspca_dev *gspca_dev);
48static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 55static void setcontrast(struct gspca_dev *gspca_dev);
49static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); 56static void setcolors(struct gspca_dev *gspca_dev);
50static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 57static void setlightfreq(struct gspca_dev *gspca_dev);
51static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); 58
52static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 59static const struct ctrl sd_ctrls[NCTRLS] = {
53static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); 60[BRIGHTNESS] = {
54static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
55
56static const struct ctrl sd_ctrls[] = {
57 {
58 { 61 {
59 .id = V4L2_CID_BRIGHTNESS, 62 .id = V4L2_CID_BRIGHTNESS,
60 .type = V4L2_CTRL_TYPE_INTEGER, 63 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -62,13 +65,11 @@ static const struct ctrl sd_ctrls[] = {
62 .minimum = 0, 65 .minimum = 0,
63 .maximum = 255, 66 .maximum = 255,
64 .step = 1, 67 .step = 1,
65#define BRIGHTNESS_DEF 127 68 .default_value = 127,
66 .default_value = BRIGHTNESS_DEF,
67 }, 69 },
68 .set = sd_setbrightness, 70 .set_control = setbrightness
69 .get = sd_getbrightness,
70 }, 71 },
71 { 72[CONTRAST] = {
72 { 73 {
73 .id = V4L2_CID_CONTRAST, 74 .id = V4L2_CID_CONTRAST,
74 .type = V4L2_CTRL_TYPE_INTEGER, 75 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -76,13 +77,11 @@ static const struct ctrl sd_ctrls[] = {
76 .minimum = 0, 77 .minimum = 0,
77 .maximum = 255, 78 .maximum = 255,
78 .step = 1, 79 .step = 1,
79#define CONTRAST_DEF 127 80 .default_value = 127,
80 .default_value = CONTRAST_DEF,
81 }, 81 },
82 .set = sd_setcontrast, 82 .set_control = setcontrast
83 .get = sd_getcontrast,
84 }, 83 },
85 { 84[COLORS] = {
86 { 85 {
87 .id = V4L2_CID_SATURATION, 86 .id = V4L2_CID_SATURATION,
88 .type = V4L2_CTRL_TYPE_INTEGER, 87 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -90,13 +89,11 @@ static const struct ctrl sd_ctrls[] = {
90 .minimum = 0, 89 .minimum = 0,
91 .maximum = 255, 90 .maximum = 255,
92 .step = 1, 91 .step = 1,
93#define COLOR_DEF 127 92 .default_value = 127,
94 .default_value = COLOR_DEF,
95 }, 93 },
96 .set = sd_setcolors, 94 .set_control = setcolors
97 .get = sd_getcolors,
98 }, 95 },
99 { 96[LIGHTFREQ] = {
100 { 97 {
101 .id = V4L2_CID_POWER_LINE_FREQUENCY, 98 .id = V4L2_CID_POWER_LINE_FREQUENCY,
102 .type = V4L2_CTRL_TYPE_MENU, 99 .type = V4L2_CTRL_TYPE_MENU,
@@ -104,11 +101,9 @@ static const struct ctrl sd_ctrls[] = {
104 .minimum = 1, 101 .minimum = 1,
105 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ 102 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
106 .step = 1, 103 .step = 1,
107#define FREQ_DEF 1 104 .default_value = 1,
108 .default_value = FREQ_DEF,
109 }, 105 },
110 .set = sd_setfreq, 106 .set_control = setlightfreq
111 .get = sd_getfreq,
112 }, 107 },
113}; 108};
114 109
@@ -142,7 +137,7 @@ static u8 reg_r(struct gspca_dev *gspca_dev,
142 gspca_dev->usb_buf, 1, 137 gspca_dev->usb_buf, 1,
143 500); 138 500);
144 if (ret < 0) { 139 if (ret < 0) {
145 PDEBUG(D_ERR, "reg_r err %d", ret); 140 err("reg_r err %d", ret);
146 gspca_dev->usb_err = ret; 141 gspca_dev->usb_err = ret;
147 return 0; 142 return 0;
148 } 143 }
@@ -167,7 +162,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
167 0, 162 0,
168 500); 163 500);
169 if (ret < 0) { 164 if (ret < 0) {
170 PDEBUG(D_ERR, "reg_w err %d", ret); 165 err("reg_w err %d", ret);
171 gspca_dev->usb_err = ret; 166 gspca_dev->usb_err = ret;
172 } 167 }
173} 168}
@@ -197,7 +192,7 @@ static void rcv_val(struct gspca_dev *gspca_dev,
197 &alen, 192 &alen,
198 500); /* timeout in milliseconds */ 193 500); /* timeout in milliseconds */
199 if (ret < 0) { 194 if (ret < 0) {
200 PDEBUG(D_ERR, "rcv_val err %d", ret); 195 err("rcv_val err %d", ret);
201 gspca_dev->usb_err = ret; 196 gspca_dev->usb_err = ret;
202 } 197 }
203} 198}
@@ -240,7 +235,7 @@ static void snd_val(struct gspca_dev *gspca_dev,
240 &alen, 235 &alen,
241 500); /* timeout in milliseconds */ 236 500); /* timeout in milliseconds */
242 if (ret < 0) { 237 if (ret < 0) {
243 PDEBUG(D_ERR, "snd_val err %d", ret); 238 err("snd_val err %d", ret);
244 gspca_dev->usb_err = ret; 239 gspca_dev->usb_err = ret;
245 } else { 240 } else {
246 if (ads == 0x003f08) { 241 if (ads == 0x003f08) {
@@ -264,7 +259,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
264 int parval; 259 int parval;
265 260
266 parval = 0x06000000 /* whiteness */ 261 parval = 0x06000000 /* whiteness */
267 + (sd->brightness << 16); 262 + (sd->ctrls[BRIGHTNESS].val << 16);
268 set_par(gspca_dev, parval); 263 set_par(gspca_dev, parval);
269} 264}
270 265
@@ -274,7 +269,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
274 int parval; 269 int parval;
275 270
276 parval = 0x07000000 /* contrast */ 271 parval = 0x07000000 /* contrast */
277 + (sd->contrast << 16); 272 + (sd->ctrls[CONTRAST].val << 16);
278 set_par(gspca_dev, parval); 273 set_par(gspca_dev, parval);
279} 274}
280 275
@@ -284,15 +279,15 @@ static void setcolors(struct gspca_dev *gspca_dev)
284 int parval; 279 int parval;
285 280
286 parval = 0x08000000 /* saturation */ 281 parval = 0x08000000 /* saturation */
287 + (sd->colors << 16); 282 + (sd->ctrls[COLORS].val << 16);
288 set_par(gspca_dev, parval); 283 set_par(gspca_dev, parval);
289} 284}
290 285
291static void setfreq(struct gspca_dev *gspca_dev) 286static void setlightfreq(struct gspca_dev *gspca_dev)
292{ 287{
293 struct sd *sd = (struct sd *) gspca_dev; 288 struct sd *sd = (struct sd *) gspca_dev;
294 289
295 set_par(gspca_dev, sd->lightfreq == 1 290 set_par(gspca_dev, sd->ctrls[LIGHTFREQ].val == 1
296 ? 0x33640000 /* 50 Hz */ 291 ? 0x33640000 /* 50 Hz */
297 : 0x33780000); /* 60 Hz */ 292 : 0x33780000); /* 60 Hz */
298} 293}
@@ -305,10 +300,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
305 300
306 gspca_dev->cam.cam_mode = vga_mode; 301 gspca_dev->cam.cam_mode = vga_mode;
307 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); 302 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode);
308 sd->brightness = BRIGHTNESS_DEF; 303 gspca_dev->cam.ctrls = sd->ctrls;
309 sd->contrast = CONTRAST_DEF;
310 sd->colors = COLOR_DEF;
311 sd->lightfreq = FREQ_DEF;
312 sd->quality = QUALITY_DEF; 304 sd->quality = QUALITY_DEF;
313 return 0; 305 return 0;
314} 306}
@@ -323,7 +315,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
323 ret = reg_r(gspca_dev, 0x0740); 315 ret = reg_r(gspca_dev, 0x0740);
324 if (gspca_dev->usb_err >= 0) { 316 if (gspca_dev->usb_err >= 0) {
325 if (ret != 0xff) { 317 if (ret != 0xff) {
326 PDEBUG(D_ERR|D_STREAM, "init reg: 0x%02x", ret); 318 err("init reg: 0x%02x", ret);
327 gspca_dev->usb_err = -EIO; 319 gspca_dev->usb_err = -EIO;
328 } 320 }
329 } 321 }
@@ -357,7 +349,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
357 gspca_dev->iface, 349 gspca_dev->iface,
358 gspca_dev->alt); 350 gspca_dev->alt);
359 if (ret < 0) { 351 if (ret < 0) {
360 PDEBUG(D_ERR|D_STREAM, "set intf %d %d failed", 352 err("set intf %d %d failed",
361 gspca_dev->iface, gspca_dev->alt); 353 gspca_dev->iface, gspca_dev->alt);
362 gspca_dev->usb_err = ret; 354 gspca_dev->usb_err = ret;
363 goto out; 355 goto out;
@@ -378,7 +370,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
378 set_par(gspca_dev, 0x0a800000); /* Green ? */ 370 set_par(gspca_dev, 0x0a800000); /* Green ? */
379 set_par(gspca_dev, 0x0b800000); /* Blue ? */ 371 set_par(gspca_dev, 0x0b800000); /* Blue ? */
380 set_par(gspca_dev, 0x0d030000); /* Gamma ? */ 372 set_par(gspca_dev, 0x0d030000); /* Gamma ? */
381 setfreq(gspca_dev); /* light frequency */ 373 setlightfreq(gspca_dev);
382 374
383 /* start the video flow */ 375 /* start the video flow */
384 set_par(gspca_dev, 0x01000000); 376 set_par(gspca_dev, 0x01000000);
@@ -441,78 +433,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
441 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 433 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
442} 434}
443 435
444static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
445{
446 struct sd *sd = (struct sd *) gspca_dev;
447
448 sd->brightness = val;
449 if (gspca_dev->streaming)
450 setbrightness(gspca_dev);
451 return gspca_dev->usb_err;
452}
453
454static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
455{
456 struct sd *sd = (struct sd *) gspca_dev;
457
458 *val = sd->brightness;
459 return 0;
460}
461
462static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
463{
464 struct sd *sd = (struct sd *) gspca_dev;
465
466 sd->contrast = val;
467 if (gspca_dev->streaming)
468 setcontrast(gspca_dev);
469 return gspca_dev->usb_err;
470}
471
472static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
473{
474 struct sd *sd = (struct sd *) gspca_dev;
475
476 *val = sd->contrast;
477 return 0;
478}
479
480static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
481{
482 struct sd *sd = (struct sd *) gspca_dev;
483
484 sd->colors = val;
485 if (gspca_dev->streaming)
486 setcolors(gspca_dev);
487 return gspca_dev->usb_err;
488}
489
490static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
491{
492 struct sd *sd = (struct sd *) gspca_dev;
493
494 *val = sd->colors;
495 return 0;
496}
497
498static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
499{
500 struct sd *sd = (struct sd *) gspca_dev;
501
502 sd->lightfreq = val;
503 if (gspca_dev->streaming)
504 setfreq(gspca_dev);
505 return gspca_dev->usb_err;
506}
507
508static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
509{
510 struct sd *sd = (struct sd *) gspca_dev;
511
512 *val = sd->lightfreq;
513 return 0;
514}
515
516static int sd_querymenu(struct gspca_dev *gspca_dev, 436static int sd_querymenu(struct gspca_dev *gspca_dev,
517 struct v4l2_querymenu *menu) 437 struct v4l2_querymenu *menu)
518{ 438{
@@ -563,7 +483,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
563static const struct sd_desc sd_desc = { 483static const struct sd_desc sd_desc = {
564 .name = MODULE_NAME, 484 .name = MODULE_NAME,
565 .ctrls = sd_ctrls, 485 .ctrls = sd_ctrls,
566 .nctrls = ARRAY_SIZE(sd_ctrls), 486 .nctrls = NCTRLS,
567 .config = sd_config, 487 .config = sd_config,
568 .init = sd_init, 488 .init = sd_init,
569 .start = sd_start, 489 .start = sd_start,
@@ -603,17 +523,11 @@ static struct usb_driver sd_driver = {
603/* -- module insert / remove -- */ 523/* -- module insert / remove -- */
604static int __init sd_mod_init(void) 524static int __init sd_mod_init(void)
605{ 525{
606 int ret; 526 return usb_register(&sd_driver);
607 ret = usb_register(&sd_driver);
608 if (ret < 0)
609 return ret;
610 info("registered");
611 return 0;
612} 527}
613static void __exit sd_mod_exit(void) 528static void __exit sd_mod_exit(void)
614{ 529{
615 usb_deregister(&sd_driver); 530 usb_deregister(&sd_driver);
616 info("deregistered");
617} 531}
618 532
619module_init(sd_mod_init); 533module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/stv0680.c b/drivers/media/video/gspca/stv0680.c
index e50dd7693f74..b199ad4666bd 100644
--- a/drivers/media/video/gspca/stv0680.c
+++ b/drivers/media/video/gspca/stv0680.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * STV0680 USB Camera Driver 2 * STV0680 USB Camera Driver
3 * 3 *
4 * Copyright (C) 2009 Hans de Goede <hdgoede@redhat.com> 4 * Copyright (C) 2009 Hans de Goede <hdegoede@redhat.com>
5 * 5 *
6 * This module is adapted from the in kernel v4l1 stv680 driver: 6 * This module is adapted from the in kernel v4l1 stv680 driver:
7 * 7 *
@@ -31,7 +31,7 @@
31 31
32#include "gspca.h" 32#include "gspca.h"
33 33
34MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); 34MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
35MODULE_DESCRIPTION("STV0680 USB Camera Driver"); 35MODULE_DESCRIPTION("STV0680 USB Camera Driver");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
@@ -79,8 +79,7 @@ static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val,
79 val, 0, gspca_dev->usb_buf, size, 500); 79 val, 0, gspca_dev->usb_buf, size, 500);
80 80
81 if ((ret < 0) && (req != 0x0a)) 81 if ((ret < 0) && (req != 0x0a))
82 PDEBUG(D_ERR, 82 err("usb_control_msg error %i, request = 0x%x, error = %i",
83 "usb_control_msg error %i, request = 0x%x, error = %i",
84 set, req, ret); 83 set, req, ret);
85 84
86 return ret; 85 return ret;
@@ -237,7 +236,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
237 236
238 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0100, 0x12) != 0x12 || 237 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0100, 0x12) != 0x12 ||
239 gspca_dev->usb_buf[8] != 0x53 || gspca_dev->usb_buf[9] != 0x05) { 238 gspca_dev->usb_buf[8] != 0x53 || gspca_dev->usb_buf[9] != 0x05) {
240 PDEBUG(D_ERR, "Could not get descriptor 0100."); 239 err("Could not get descriptor 0100.");
241 return stv0680_handle_error(gspca_dev, -EIO); 240 return stv0680_handle_error(gspca_dev, -EIO);
242 } 241 }
243 242
@@ -357,17 +356,11 @@ static struct usb_driver sd_driver = {
357/* -- module insert / remove -- */ 356/* -- module insert / remove -- */
358static int __init sd_mod_init(void) 357static int __init sd_mod_init(void)
359{ 358{
360 int ret; 359 return usb_register(&sd_driver);
361 ret = usb_register(&sd_driver);
362 if (ret < 0)
363 return ret;
364 PDEBUG(D_PROBE, "registered");
365 return 0;
366} 360}
367static void __exit sd_mod_exit(void) 361static void __exit sd_mod_exit(void)
368{ 362{
369 usb_deregister(&sd_driver); 363 usb_deregister(&sd_driver);
370 PDEBUG(D_PROBE, "deregistered");
371} 364}
372 365
373module_init(sd_mod_init); 366module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c
index 14f179a19485..086de44a6e57 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.c
@@ -189,7 +189,7 @@ int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value)
189 0x04, 0x40, 0x1400, 0, buf, I2C_BUFFER_LENGTH, 189 0x04, 0x40, 0x1400, 0, buf, I2C_BUFFER_LENGTH,
190 STV06XX_URB_MSG_TIMEOUT); 190 STV06XX_URB_MSG_TIMEOUT);
191 if (err < 0) { 191 if (err < 0) {
192 PDEBUG(D_ERR, "I2C: Read error writing address: %d", err); 192 err("I2C: Read error writing address: %d", err);
193 return err; 193 return err;
194 } 194 }
195 195
@@ -428,7 +428,7 @@ frame_data:
428 } 428 }
429} 429}
430 430
431#ifdef CONFIG_INPUT 431#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
432static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 432static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
433 u8 *data, /* interrupt packet data */ 433 u8 *data, /* interrupt packet data */
434 int len) /* interrupt packet length */ 434 int len) /* interrupt packet length */
@@ -462,7 +462,7 @@ static const struct sd_desc sd_desc = {
462 .start = stv06xx_start, 462 .start = stv06xx_start,
463 .stopN = stv06xx_stopN, 463 .stopN = stv06xx_stopN,
464 .pkt_scan = stv06xx_pkt_scan, 464 .pkt_scan = stv06xx_pkt_scan,
465#ifdef CONFIG_INPUT 465#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
466 .int_pkt_scan = sd_int_pkt_scan, 466 .int_pkt_scan = sd_int_pkt_scan,
467#endif 467#endif
468}; 468};
@@ -562,17 +562,11 @@ static struct usb_driver sd_driver = {
562/* -- module insert / remove -- */ 562/* -- module insert / remove -- */
563static int __init sd_mod_init(void) 563static int __init sd_mod_init(void)
564{ 564{
565 int ret; 565 return usb_register(&sd_driver);
566 ret = usb_register(&sd_driver);
567 if (ret < 0)
568 return ret;
569 PDEBUG(D_PROBE, "registered");
570 return 0;
571} 566}
572static void __exit sd_mod_exit(void) 567static void __exit sd_mod_exit(void)
573{ 568{
574 usb_deregister(&sd_driver); 569 usb_deregister(&sd_driver);
575 PDEBUG(D_PROBE, "deregistered");
576} 570}
577 571
578module_init(sd_mod_init); 572module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.h b/drivers/media/video/gspca/stv06xx/stv06xx.h
index 053a27e3a400..e0f63c51f40d 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.h
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.h
@@ -37,7 +37,7 @@
37 37
38#define STV_ISOC_ENDPOINT_ADDR 0x81 38#define STV_ISOC_ENDPOINT_ADDR 0x81
39 39
40#define STV_REG23 0x0423 40#define STV_REG23 0x0423
41 41
42/* Control registers of the STV0600 ASIC */ 42/* Control registers of the STV0600 ASIC */
43#define STV_I2C_PARTNER 0x1420 43#define STV_I2C_PARTNER 0x1420
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c
index 706e08dc5254..17531b41a073 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c
@@ -39,8 +39,8 @@ static const struct ctrl hdcs1x00_ctrl[] = {
39 .minimum = 0x00, 39 .minimum = 0x00,
40 .maximum = 0xff, 40 .maximum = 0xff,
41 .step = 0x1, 41 .step = 0x1,
42 .default_value = HDCS_DEFAULT_EXPOSURE, 42 .default_value = HDCS_DEFAULT_EXPOSURE,
43 .flags = V4L2_CTRL_FLAG_SLIDER 43 .flags = V4L2_CTRL_FLAG_SLIDER
44 }, 44 },
45 .set = hdcs_set_exposure, 45 .set = hdcs_set_exposure,
46 .get = hdcs_get_exposure 46 .get = hdcs_get_exposure
@@ -52,8 +52,8 @@ static const struct ctrl hdcs1x00_ctrl[] = {
52 .minimum = 0x00, 52 .minimum = 0x00,
53 .maximum = 0xff, 53 .maximum = 0xff,
54 .step = 0x1, 54 .step = 0x1,
55 .default_value = HDCS_DEFAULT_GAIN, 55 .default_value = HDCS_DEFAULT_GAIN,
56 .flags = V4L2_CTRL_FLAG_SLIDER 56 .flags = V4L2_CTRL_FLAG_SLIDER
57 }, 57 },
58 .set = hdcs_set_gain, 58 .set = hdcs_set_gain,
59 .get = hdcs_get_gain 59 .get = hdcs_get_gain
@@ -83,8 +83,8 @@ static const struct ctrl hdcs1020_ctrl[] = {
83 .minimum = 0x00, 83 .minimum = 0x00,
84 .maximum = 0xffff, 84 .maximum = 0xffff,
85 .step = 0x1, 85 .step = 0x1,
86 .default_value = HDCS_DEFAULT_EXPOSURE, 86 .default_value = HDCS_DEFAULT_EXPOSURE,
87 .flags = V4L2_CTRL_FLAG_SLIDER 87 .flags = V4L2_CTRL_FLAG_SLIDER
88 }, 88 },
89 .set = hdcs_set_exposure, 89 .set = hdcs_set_exposure,
90 .get = hdcs_get_exposure 90 .get = hdcs_get_exposure
@@ -96,8 +96,8 @@ static const struct ctrl hdcs1020_ctrl[] = {
96 .minimum = 0x00, 96 .minimum = 0x00,
97 .maximum = 0xff, 97 .maximum = 0xff,
98 .step = 0x1, 98 .step = 0x1,
99 .default_value = HDCS_DEFAULT_GAIN, 99 .default_value = HDCS_DEFAULT_GAIN,
100 .flags = V4L2_CTRL_FLAG_SLIDER 100 .flags = V4L2_CTRL_FLAG_SLIDER
101 }, 101 },
102 .set = hdcs_set_gain, 102 .set = hdcs_set_gain,
103 .get = hdcs_get_gain 103 .get = hdcs_get_gain
@@ -163,7 +163,8 @@ static int hdcs_reg_write_seq(struct sd *sd, u8 reg, u8 *vals, u8 len)
163 for (i = 0; i < len; i++) { 163 for (i = 0; i < len; i++) {
164 regs[2 * i] = reg; 164 regs[2 * i] = reg;
165 regs[2 * i + 1] = vals[i]; 165 regs[2 * i + 1] = vals[i];
166 /* All addresses are shifted left one bit as bit 0 toggles r/w */ 166 /* All addresses are shifted left one bit
167 * as bit 0 toggles r/w */
167 reg += 2; 168 reg += 2;
168 } 169 }
169 170
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h
index 37b31c99d956..cf3d0ccc1121 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h
@@ -37,7 +37,7 @@
37#define HDCS_REG_CONTROL(sd) (IS_1020(sd) ? HDCS20_CONTROL : HDCS00_CONTROL) 37#define HDCS_REG_CONTROL(sd) (IS_1020(sd) ? HDCS20_CONTROL : HDCS00_CONTROL)
38 38
39#define HDCS_1X00_DEF_WIDTH 360 39#define HDCS_1X00_DEF_WIDTH 360
40#define HDCS_1X00_DEF_HEIGHT 296 40#define HDCS_1X00_DEF_HEIGHT 296
41 41
42#define HDCS_1020_DEF_WIDTH 352 42#define HDCS_1020_DEF_WIDTH 352
43#define HDCS_1020_DEF_HEIGHT 292 43#define HDCS_1020_DEF_HEIGHT 292
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c
index c11f06e4ae76..3af53264a364 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c
@@ -246,7 +246,7 @@ static int st6422_start(struct sd *sd)
246 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 246 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
247 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 247 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
248 if (!alt) { 248 if (!alt) {
249 PDEBUG(D_ERR, "Couldn't get altsetting"); 249 err("Couldn't get altsetting");
250 return -EIO; 250 return -EIO;
251 } 251 }
252 252
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
index 11a0c002f5dc..f8398434c328 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.c
@@ -66,7 +66,7 @@ static const struct ctrl vv6410_ctrl[] = {
66 .minimum = 0, 66 .minimum = 0,
67 .maximum = 1, 67 .maximum = 1,
68 .step = 1, 68 .step = 1,
69 .default_value = 0 69 .default_value = 0
70 }, 70 },
71 .set = vv6410_set_vflip, 71 .set = vv6410_set_vflip,
72 .get = vv6410_get_vflip 72 .get = vv6410_get_vflip
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
index 96c61926d372..b3b5508473bc 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
@@ -157,8 +157,8 @@
157/* Audio Amplifier Setup Register */ 157/* Audio Amplifier Setup Register */
158#define VV6410_AT1 0x79 158#define VV6410_AT1 0x79
159 159
160#define VV6410_HFLIP (1 << 3) 160#define VV6410_HFLIP (1 << 3)
161#define VV6410_VFLIP (1 << 4) 161#define VV6410_VFLIP (1 << 4)
162 162
163#define VV6410_LOW_POWER_MODE (1 << 0) 163#define VV6410_LOW_POWER_MODE (1 << 0)
164#define VV6410_SOFT_RESET (1 << 2) 164#define VV6410_SOFT_RESET (1 << 2)
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index 9494f86b9a85..a9cbcd6011d9 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -343,7 +343,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
343 len ? gspca_dev->usb_buf : NULL, len, 343 len ? gspca_dev->usb_buf : NULL, len,
344 500); 344 500);
345 if (ret < 0) { 345 if (ret < 0) {
346 PDEBUG(D_ERR, "reg_r err %d", ret); 346 err("reg_r err %d", ret);
347 gspca_dev->usb_err = ret; 347 gspca_dev->usb_err = ret;
348 } 348 }
349} 349}
@@ -368,7 +368,7 @@ static void reg_w_1(struct gspca_dev *gspca_dev,
368 gspca_dev->usb_buf, 1, 368 gspca_dev->usb_buf, 1,
369 500); 369 500);
370 if (ret < 0) { 370 if (ret < 0) {
371 PDEBUG(D_ERR, "reg_w_1 err %d", ret); 371 err("reg_w_1 err %d", ret);
372 gspca_dev->usb_err = ret; 372 gspca_dev->usb_err = ret;
373 } 373 }
374} 374}
@@ -388,7 +388,7 @@ static void reg_w_riv(struct gspca_dev *gspca_dev,
388 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 388 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
389 value, index, NULL, 0, 500); 389 value, index, NULL, 0, 500);
390 if (ret < 0) { 390 if (ret < 0) {
391 PDEBUG(D_ERR, "reg_w_riv err %d", ret); 391 err("reg_w_riv err %d", ret);
392 gspca_dev->usb_err = ret; 392 gspca_dev->usb_err = ret;
393 return; 393 return;
394 } 394 }
@@ -413,7 +413,7 @@ static u8 reg_r_1(struct gspca_dev *gspca_dev,
413 gspca_dev->usb_buf, 1, 413 gspca_dev->usb_buf, 1,
414 500); /* timeout */ 414 500); /* timeout */
415 if (ret < 0) { 415 if (ret < 0) {
416 PDEBUG(D_ERR, "reg_r_1 err %d", ret); 416 err("reg_r_1 err %d", ret);
417 gspca_dev->usb_err = ret; 417 gspca_dev->usb_err = ret;
418 return 0; 418 return 0;
419 } 419 }
@@ -440,7 +440,7 @@ static u16 reg_r_12(struct gspca_dev *gspca_dev,
440 gspca_dev->usb_buf, length, 440 gspca_dev->usb_buf, length,
441 500); 441 500);
442 if (ret < 0) { 442 if (ret < 0) {
443 PDEBUG(D_ERR, "reg_r_12 err %d", ret); 443 err("reg_r_12 err %d", ret);
444 gspca_dev->usb_err = ret; 444 gspca_dev->usb_err = ret;
445 return 0; 445 return 0;
446 } 446 }
@@ -463,7 +463,7 @@ static void setup_qtable(struct gspca_dev *gspca_dev,
463 463
464 /* loop over y components */ 464 /* loop over y components */
465 for (i = 0; i < 64; i++) 465 for (i = 0; i < 64; i++)
466 reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]); 466 reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]);
467 467
468 /* loop over c components */ 468 /* loop over c components */
469 for (i = 0; i < 64; i++) 469 for (i = 0; i < 64; i++)
@@ -712,8 +712,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
712 sd->subtype = id->driver_info; 712 sd->subtype = id->driver_info;
713 713
714 if (sd->subtype == AiptekMiniPenCam13) { 714 if (sd->subtype == AiptekMiniPenCam13) {
715/* try to get the firmware as some cam answer 2.0.1.2.2 715
716 * and should be a spca504b then overwrite that setting */ 716 /* try to get the firmware as some cam answer 2.0.1.2.2
717 * and should be a spca504b then overwrite that setting */
717 reg_r(gspca_dev, 0x20, 0, 1); 718 reg_r(gspca_dev, 0x20, 0, 1);
718 switch (gspca_dev->usb_buf[0]) { 719 switch (gspca_dev->usb_buf[0]) {
719 case 1: 720 case 1:
@@ -733,7 +734,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
733/* case BRIDGE_SPCA504: */ 734/* case BRIDGE_SPCA504: */
734/* case BRIDGE_SPCA536: */ 735/* case BRIDGE_SPCA536: */
735 cam->cam_mode = vga_mode; 736 cam->cam_mode = vga_mode;
736 cam->nmodes =ARRAY_SIZE(vga_mode); 737 cam->nmodes = ARRAY_SIZE(vga_mode);
737 break; 738 break;
738 case BRIDGE_SPCA533: 739 case BRIDGE_SPCA533:
739 cam->cam_mode = custom_mode; 740 cam->cam_mode = custom_mode;
@@ -1247,17 +1248,11 @@ static struct usb_driver sd_driver = {
1247/* -- module insert / remove -- */ 1248/* -- module insert / remove -- */
1248static int __init sd_mod_init(void) 1249static int __init sd_mod_init(void)
1249{ 1250{
1250 int ret; 1251 return usb_register(&sd_driver);
1251 ret = usb_register(&sd_driver);
1252 if (ret < 0)
1253 return ret;
1254 PDEBUG(D_PROBE, "registered");
1255 return 0;
1256} 1252}
1257static void __exit sd_mod_exit(void) 1253static void __exit sd_mod_exit(void)
1258{ 1254{
1259 usb_deregister(&sd_driver); 1255 usb_deregister(&sd_driver);
1260 PDEBUG(D_PROBE, "deregistered");
1261} 1256}
1262 1257
1263module_init(sd_mod_init); 1258module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 3b3b983f2b9d..b45f4d0f3997 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -892,7 +892,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
892 sd->sensor = SENSOR_OM6802; 892 sd->sensor = SENSOR_OM6802;
893 break; 893 break;
894 default: 894 default:
895 PDEBUG(D_ERR|D_PROBE, "unknown sensor %04x", sensor_id); 895 err("unknown sensor %04x", sensor_id);
896 return -EINVAL; 896 return -EINVAL;
897 } 897 }
898 898
@@ -1444,17 +1444,11 @@ static struct usb_driver sd_driver = {
1444/* -- module insert / remove -- */ 1444/* -- module insert / remove -- */
1445static int __init sd_mod_init(void) 1445static int __init sd_mod_init(void)
1446{ 1446{
1447 int ret; 1447 return usb_register(&sd_driver);
1448 ret = usb_register(&sd_driver);
1449 if (ret < 0)
1450 return ret;
1451 PDEBUG(D_PROBE, "registered");
1452 return 0;
1453} 1448}
1454static void __exit sd_mod_exit(void) 1449static void __exit sd_mod_exit(void)
1455{ 1450{
1456 usb_deregister(&sd_driver); 1451 usb_deregister(&sd_driver);
1457 PDEBUG(D_PROBE, "deregistered");
1458} 1452}
1459 1453
1460module_init(sd_mod_init); 1454module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index d9c5bf3449d4..d9e3c6050781 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -421,18 +421,12 @@ static struct usb_driver sd_driver = {
421/* -- module insert / remove -- */ 421/* -- module insert / remove -- */
422static int __init sd_mod_init(void) 422static int __init sd_mod_init(void)
423{ 423{
424 int ret; 424 return usb_register(&sd_driver);
425 ret = usb_register(&sd_driver);
426 if (ret < 0)
427 return ret;
428 PDEBUG(D_PROBE, "registered");
429 return 0;
430} 425}
431 426
432static void __exit sd_mod_exit(void) 427static void __exit sd_mod_exit(void)
433{ 428{
434 usb_deregister(&sd_driver); 429 usb_deregister(&sd_driver);
435 PDEBUG(D_PROBE, "deregistered");
436} 430}
437 431
438module_init(sd_mod_init); 432module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index b16fd47e8ced..38a6efe1a5f9 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -3164,7 +3164,7 @@ static void reg_r_i(struct gspca_dev *gspca_dev,
3164 index, gspca_dev->usb_buf, len, 3164 index, gspca_dev->usb_buf, len,
3165 500); 3165 500);
3166 if (ret < 0) { 3166 if (ret < 0) {
3167 PDEBUG(D_ERR, "reg_r err %d", ret); 3167 err("reg_r err %d", ret);
3168 gspca_dev->usb_err = ret; 3168 gspca_dev->usb_err = ret;
3169 } 3169 }
3170} 3170}
@@ -3205,7 +3205,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev,
3205 value, index, NULL, 0, 3205 value, index, NULL, 0,
3206 500); 3206 500);
3207 if (ret < 0) { 3207 if (ret < 0) {
3208 PDEBUG(D_ERR, "reg_w err %d", ret); 3208 err("reg_w err %d", ret);
3209 gspca_dev->usb_err = ret; 3209 gspca_dev->usb_err = ret;
3210 } 3210 }
3211} 3211}
@@ -3230,7 +3230,7 @@ static u16 read_sensor_register(struct gspca_dev *gspca_dev,
3230 3230
3231 reg_r(gspca_dev, 0xa1, 0xb33f, 1); 3231 reg_r(gspca_dev, 0xa1, 0xb33f, 1);
3232 if (!(gspca_dev->usb_buf[0] & 0x02)) { 3232 if (!(gspca_dev->usb_buf[0] & 0x02)) {
3233 PDEBUG(D_ERR, "I2c Bus Busy Wait %02x", 3233 err("I2c Bus Busy Wait %02x",
3234 gspca_dev->usb_buf[0]); 3234 gspca_dev->usb_buf[0]);
3235 return 0; 3235 return 0;
3236 } 3236 }
@@ -3344,7 +3344,7 @@ static void i2c_write(struct gspca_dev *gspca_dev,
3344 msleep(20); 3344 msleep(20);
3345 } while (--retry > 0); 3345 } while (--retry > 0);
3346 if (retry <= 0) 3346 if (retry <= 0)
3347 PDEBUG(D_ERR, "i2c_write timeout"); 3347 err("i2c_write timeout");
3348} 3348}
3349 3349
3350static void put_tab_to_reg(struct gspca_dev *gspca_dev, 3350static void put_tab_to_reg(struct gspca_dev *gspca_dev,
@@ -3440,7 +3440,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
3440 3440
3441 switch (sensor) { 3441 switch (sensor) {
3442 case -1: 3442 case -1:
3443 PDEBUG(D_PROBE, "Unknown sensor..."); 3443 err("Unknown sensor...");
3444 return -EINVAL; 3444 return -EINVAL;
3445 case SENSOR_HV7131R: 3445 case SENSOR_HV7131R:
3446 PDEBUG(D_PROBE, "Find Sensor HV7131R"); 3446 PDEBUG(D_PROBE, "Find Sensor HV7131R");
@@ -4226,18 +4226,11 @@ static struct usb_driver sd_driver = {
4226/* -- module insert / remove -- */ 4226/* -- module insert / remove -- */
4227static int __init sd_mod_init(void) 4227static int __init sd_mod_init(void)
4228{ 4228{
4229 int ret; 4229 return usb_register(&sd_driver);
4230
4231 ret = usb_register(&sd_driver);
4232 if (ret < 0)
4233 return ret;
4234 PDEBUG(D_PROBE, "registered");
4235 return 0;
4236} 4230}
4237static void __exit sd_mod_exit(void) 4231static void __exit sd_mod_exit(void)
4238{ 4232{
4239 usb_deregister(&sd_driver); 4233 usb_deregister(&sd_driver);
4240 PDEBUG(D_PROBE, "deregistered");
4241} 4234}
4242 4235
4243module_init(sd_mod_init); 4236module_init(sd_mod_init);
diff --git a/drivers/media/video/gspca/w996Xcf.c b/drivers/media/video/gspca/w996Xcf.c
index 38a68591ce48..4066ac8c45a0 100644
--- a/drivers/media/video/gspca/w996Xcf.c
+++ b/drivers/media/video/gspca/w996Xcf.c
@@ -67,7 +67,7 @@ static int reg_w(struct sd *sd, __u16 index, __u16 value);
67 --------------------------------------------------------------------------*/ 67 --------------------------------------------------------------------------*/
68static int w9968cf_write_fsb(struct sd *sd, u16* data) 68static int w9968cf_write_fsb(struct sd *sd, u16* data)
69{ 69{
70 struct usb_device* udev = sd->gspca_dev.dev; 70 struct usb_device *udev = sd->gspca_dev.dev;
71 u16 value; 71 u16 value;
72 int ret; 72 int ret;
73 73
@@ -78,7 +78,7 @@ static int w9968cf_write_fsb(struct sd *sd, u16* data)
78 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 78 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
79 value, 0x06, sd->gspca_dev.usb_buf, 6, 500); 79 value, 0x06, sd->gspca_dev.usb_buf, 6, 500);
80 if (ret < 0) { 80 if (ret < 0) {
81 PDEBUG(D_ERR, "Write FSB registers failed (%d)", ret); 81 err("Write FSB registers failed (%d)", ret);
82 return ret; 82 return ret;
83 } 83 }
84 84
@@ -104,7 +104,7 @@ static int w9968cf_write_sb(struct sd *sd, u16 value)
104 udelay(W9968CF_I2C_BUS_DELAY); 104 udelay(W9968CF_I2C_BUS_DELAY);
105 105
106 if (ret < 0) { 106 if (ret < 0) {
107 PDEBUG(D_ERR, "Write SB reg [01] %04x failed", value); 107 err("Write SB reg [01] %04x failed", value);
108 return ret; 108 return ret;
109 } 109 }
110 110
@@ -130,7 +130,7 @@ static int w9968cf_read_sb(struct sd *sd)
130 ret = sd->gspca_dev.usb_buf[0] | 130 ret = sd->gspca_dev.usb_buf[0] |
131 (sd->gspca_dev.usb_buf[1] << 8); 131 (sd->gspca_dev.usb_buf[1] << 8);
132 else 132 else
133 PDEBUG(D_ERR, "Read SB reg [01] failed"); 133 err("Read SB reg [01] failed");
134 134
135 udelay(W9968CF_I2C_BUS_DELAY); 135 udelay(W9968CF_I2C_BUS_DELAY);
136 136
@@ -437,7 +437,7 @@ static int w9968cf_set_crop_window(struct sd *sd)
437 if (sd->sensor == SEN_OV7620) { 437 if (sd->sensor == SEN_OV7620) {
438 /* Sigh, this is dependend on the clock / framerate changes 438 /* Sigh, this is dependend on the clock / framerate changes
439 made by the frequency control, sick. */ 439 made by the frequency control, sick. */
440 if (sd->freq == 1) { 440 if (sd->ctrls[FREQ].val == 1) {
441 start_cropx = 277; 441 start_cropx = 277;
442 start_cropy = 37; 442 start_cropy = 37;
443 } else { 443 } else {
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c
new file mode 100644
index 000000000000..8715577bc2d8
--- /dev/null
+++ b/drivers/media/video/gspca/xirlink_cit.c
@@ -0,0 +1,3253 @@
1/*
2 * USB IBM C-It Video Camera driver
3 *
4 * Supports Xirlink C-It Video Camera, IBM PC Camera,
5 * IBM NetCamera and Veo Stingray.
6 *
7 * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
8 *
9 * This driver is based on earlier work of:
10 *
11 * (C) Copyright 1999 Johannes Erdfelt
12 * (C) Copyright 1999 Randy Dunlap
13 *
14 * 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
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */
29
30#define MODULE_NAME "xirlink-cit"
31
32#include "gspca.h"
33
34MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
35MODULE_DESCRIPTION("Xirlink C-IT");
36MODULE_LICENSE("GPL");
37
38/* FIXME we should autodetect this */
39static int ibm_netcam_pro;
40module_param(ibm_netcam_pro, int, 0);
41MODULE_PARM_DESC(ibm_netcam_pro,
42 "Use IBM Netcamera Pro init sequences for Model 3 cams");
43
44/* FIXME this should be handled through the V4L2 input selection API */
45static int rca_input;
46module_param(rca_input, int, 0644);
47MODULE_PARM_DESC(rca_input,
48 "Use rca input instead of ccd sensor on Model 3 cams");
49
50/* specific webcam descriptor */
51struct sd {
52 struct gspca_dev gspca_dev; /* !! must be the first item */
53 u8 model;
54#define CIT_MODEL0 0 /* bcd version 0.01 cams ie the xvp-500 */
55#define CIT_MODEL1 1 /* The model 1 - 4 nomenclature comes from the old */
56#define CIT_MODEL2 2 /* ibmcam driver */
57#define CIT_MODEL3 3
58#define CIT_MODEL4 4
59#define CIT_IBM_NETCAM_PRO 5
60 u8 input_index;
61 u8 stop_on_control_change;
62 u8 sof_read;
63 u8 sof_len;
64 u8 contrast;
65 u8 brightness;
66 u8 hue;
67 u8 sharpness;
68 u8 lighting;
69 u8 hflip;
70};
71
72/* V4L2 controls supported by the driver */
73static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
74static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
75static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
76static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
77static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val);
78static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val);
79static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
80static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
81static int sd_setlighting(struct gspca_dev *gspca_dev, __s32 val);
82static int sd_getlighting(struct gspca_dev *gspca_dev, __s32 *val);
83static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
84static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
85static void sd_stop0(struct gspca_dev *gspca_dev);
86
87static const struct ctrl sd_ctrls[] = {
88#define SD_BRIGHTNESS 0
89 {
90 {
91 .id = V4L2_CID_BRIGHTNESS,
92 .type = V4L2_CTRL_TYPE_INTEGER,
93 .name = "Brightness",
94 .minimum = 0,
95 .maximum = 63,
96 .step = 1,
97#define BRIGHTNESS_DEFAULT 32
98 .default_value = BRIGHTNESS_DEFAULT,
99 .flags = 0,
100 },
101 .set = sd_setbrightness,
102 .get = sd_getbrightness,
103 },
104#define SD_CONTRAST 1
105 {
106 {
107 .id = V4L2_CID_CONTRAST,
108 .type = V4L2_CTRL_TYPE_INTEGER,
109 .name = "contrast",
110 .minimum = 0,
111 .maximum = 20,
112 .step = 1,
113#define CONTRAST_DEFAULT 10
114 .default_value = CONTRAST_DEFAULT,
115 .flags = 0,
116 },
117 .set = sd_setcontrast,
118 .get = sd_getcontrast,
119 },
120#define SD_HUE 2
121 {
122 {
123 .id = V4L2_CID_HUE,
124 .type = V4L2_CTRL_TYPE_INTEGER,
125 .name = "Hue",
126 .minimum = 0,
127 .maximum = 127,
128 .step = 1,
129#define HUE_DEFAULT 63
130 .default_value = HUE_DEFAULT,
131 .flags = 0,
132 },
133 .set = sd_sethue,
134 .get = sd_gethue,
135 },
136#define SD_SHARPNESS 3
137 {
138 {
139 .id = V4L2_CID_SHARPNESS,
140 .type = V4L2_CTRL_TYPE_INTEGER,
141 .name = "Sharpness",
142 .minimum = 0,
143 .maximum = 6,
144 .step = 1,
145#define SHARPNESS_DEFAULT 3
146 .default_value = SHARPNESS_DEFAULT,
147 .flags = 0,
148 },
149 .set = sd_setsharpness,
150 .get = sd_getsharpness,
151 },
152#define SD_LIGHTING 4
153 {
154 {
155 .id = V4L2_CID_BACKLIGHT_COMPENSATION,
156 .type = V4L2_CTRL_TYPE_INTEGER,
157 .name = "Lighting",
158 .minimum = 0,
159 .maximum = 2,
160 .step = 1,
161#define LIGHTING_DEFAULT 1
162 .default_value = LIGHTING_DEFAULT,
163 .flags = 0,
164 },
165 .set = sd_setlighting,
166 .get = sd_getlighting,
167 },
168#define SD_HFLIP 5
169 {
170 {
171 .id = V4L2_CID_HFLIP,
172 .type = V4L2_CTRL_TYPE_BOOLEAN,
173 .name = "Mirror",
174 .minimum = 0,
175 .maximum = 1,
176 .step = 1,
177#define HFLIP_DEFAULT 0
178 .default_value = HFLIP_DEFAULT,
179 },
180 .set = sd_sethflip,
181 .get = sd_gethflip,
182 },
183};
184
185static const struct v4l2_pix_format cif_yuv_mode[] = {
186 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
187 .bytesperline = 176,
188 .sizeimage = 176 * 144 * 3 / 2,
189 .colorspace = V4L2_COLORSPACE_SRGB},
190 {352, 288, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
191 .bytesperline = 352,
192 .sizeimage = 352 * 288 * 3 / 2,
193 .colorspace = V4L2_COLORSPACE_SRGB},
194};
195
196static const struct v4l2_pix_format vga_yuv_mode[] = {
197 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
198 .bytesperline = 160,
199 .sizeimage = 160 * 120 * 3 / 2,
200 .colorspace = V4L2_COLORSPACE_SRGB},
201 {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
202 .bytesperline = 320,
203 .sizeimage = 320 * 240 * 3 / 2,
204 .colorspace = V4L2_COLORSPACE_SRGB},
205 {640, 480, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
206 .bytesperline = 640,
207 .sizeimage = 640 * 480 * 3 / 2,
208 .colorspace = V4L2_COLORSPACE_SRGB},
209};
210
211static const struct v4l2_pix_format model0_mode[] = {
212 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
213 .bytesperline = 160,
214 .sizeimage = 160 * 120 * 3 / 2,
215 .colorspace = V4L2_COLORSPACE_SRGB},
216 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
217 .bytesperline = 176,
218 .sizeimage = 176 * 144 * 3 / 2,
219 .colorspace = V4L2_COLORSPACE_SRGB},
220 {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
221 .bytesperline = 320,
222 .sizeimage = 320 * 240 * 3 / 2,
223 .colorspace = V4L2_COLORSPACE_SRGB},
224};
225
226static const struct v4l2_pix_format model2_mode[] = {
227 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
228 .bytesperline = 160,
229 .sizeimage = 160 * 120 * 3 / 2,
230 .colorspace = V4L2_COLORSPACE_SRGB},
231 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
232 .bytesperline = 176,
233 .sizeimage = 176 * 144 * 3 / 2,
234 .colorspace = V4L2_COLORSPACE_SRGB},
235 {320, 240, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE,
236 .bytesperline = 320,
237 .sizeimage = 320 * 240,
238 .colorspace = V4L2_COLORSPACE_SRGB},
239 {352, 288, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE,
240 .bytesperline = 352,
241 .sizeimage = 352 * 288,
242 .colorspace = V4L2_COLORSPACE_SRGB},
243};
244
245/*
246 * 01.01.08 - Added for RCA video in support -LO
247 * This struct is used to init the Model3 cam to use the RCA video in port
248 * instead of the CCD sensor.
249 */
250static const u16 rca_initdata[][3] = {
251 {0, 0x0000, 0x010c},
252 {0, 0x0006, 0x012c},
253 {0, 0x0078, 0x012d},
254 {0, 0x0046, 0x012f},
255 {0, 0xd141, 0x0124},
256 {0, 0x0000, 0x0127},
257 {0, 0xfea8, 0x0124},
258 {1, 0x0000, 0x0116},
259 {0, 0x0064, 0x0116},
260 {1, 0x0000, 0x0115},
261 {0, 0x0003, 0x0115},
262 {0, 0x0008, 0x0123},
263 {0, 0x0000, 0x0117},
264 {0, 0x0000, 0x0112},
265 {0, 0x0080, 0x0100},
266 {0, 0x0000, 0x0100},
267 {1, 0x0000, 0x0116},
268 {0, 0x0060, 0x0116},
269 {0, 0x0002, 0x0112},
270 {0, 0x0000, 0x0123},
271 {0, 0x0001, 0x0117},
272 {0, 0x0040, 0x0108},
273 {0, 0x0019, 0x012c},
274 {0, 0x0040, 0x0116},
275 {0, 0x000a, 0x0115},
276 {0, 0x000b, 0x0115},
277 {0, 0x0078, 0x012d},
278 {0, 0x0046, 0x012f},
279 {0, 0xd141, 0x0124},
280 {0, 0x0000, 0x0127},
281 {0, 0xfea8, 0x0124},
282 {0, 0x0064, 0x0116},
283 {0, 0x0000, 0x0115},
284 {0, 0x0001, 0x0115},
285 {0, 0xffff, 0x0124},
286 {0, 0xfff9, 0x0124},
287 {0, 0x0086, 0x0127},
288 {0, 0xfff8, 0x0124},
289 {0, 0xfffd, 0x0124},
290 {0, 0x00aa, 0x0127},
291 {0, 0xfff8, 0x0124},
292 {0, 0xfffd, 0x0124},
293 {0, 0x0000, 0x0127},
294 {0, 0xfff8, 0x0124},
295 {0, 0xfffd, 0x0124},
296 {0, 0xfffa, 0x0124},
297 {0, 0xffff, 0x0124},
298 {0, 0xfff9, 0x0124},
299 {0, 0x0086, 0x0127},
300 {0, 0xfff8, 0x0124},
301 {0, 0xfffd, 0x0124},
302 {0, 0x00f2, 0x0127},
303 {0, 0xfff8, 0x0124},
304 {0, 0xfffd, 0x0124},
305 {0, 0x000f, 0x0127},
306 {0, 0xfff8, 0x0124},
307 {0, 0xfffd, 0x0124},
308 {0, 0xfffa, 0x0124},
309 {0, 0xffff, 0x0124},
310 {0, 0xfff9, 0x0124},
311 {0, 0x0086, 0x0127},
312 {0, 0xfff8, 0x0124},
313 {0, 0xfffd, 0x0124},
314 {0, 0x00f8, 0x0127},
315 {0, 0xfff8, 0x0124},
316 {0, 0xfffd, 0x0124},
317 {0, 0x00fc, 0x0127},
318 {0, 0xfff8, 0x0124},
319 {0, 0xfffd, 0x0124},
320 {0, 0xfffa, 0x0124},
321 {0, 0xffff, 0x0124},
322 {0, 0xfff9, 0x0124},
323 {0, 0x0086, 0x0127},
324 {0, 0xfff8, 0x0124},
325 {0, 0xfffd, 0x0124},
326 {0, 0x00f9, 0x0127},
327 {0, 0xfff8, 0x0124},
328 {0, 0xfffd, 0x0124},
329 {0, 0x003c, 0x0127},
330 {0, 0xfff8, 0x0124},
331 {0, 0xfffd, 0x0124},
332 {0, 0xfffa, 0x0124},
333 {0, 0xffff, 0x0124},
334 {0, 0xfff9, 0x0124},
335 {0, 0x0086, 0x0127},
336 {0, 0xfff8, 0x0124},
337 {0, 0xfffd, 0x0124},
338 {0, 0x0027, 0x0127},
339 {0, 0xfff8, 0x0124},
340 {0, 0xfffd, 0x0124},
341 {0, 0x0019, 0x0127},
342 {0, 0xfff8, 0x0124},
343 {0, 0xfffd, 0x0124},
344 {0, 0xfffa, 0x0124},
345 {0, 0xfff9, 0x0124},
346 {0, 0x0086, 0x0127},
347 {0, 0xfff8, 0x0124},
348 {0, 0xfffd, 0x0124},
349 {0, 0x0037, 0x0127},
350 {0, 0xfff8, 0x0124},
351 {0, 0xfffd, 0x0124},
352 {0, 0x0000, 0x0127},
353 {0, 0xfff8, 0x0124},
354 {0, 0xfffd, 0x0124},
355 {0, 0x0021, 0x0127},
356 {0, 0xfff8, 0x0124},
357 {0, 0xfffd, 0x0124},
358 {0, 0xfffa, 0x0124},
359 {0, 0xfff9, 0x0124},
360 {0, 0x0086, 0x0127},
361 {0, 0xfff8, 0x0124},
362 {0, 0xfffd, 0x0124},
363 {0, 0x0038, 0x0127},
364 {0, 0xfff8, 0x0124},
365 {0, 0xfffd, 0x0124},
366 {0, 0x0006, 0x0127},
367 {0, 0xfff8, 0x0124},
368 {0, 0xfffd, 0x0124},
369 {0, 0x0045, 0x0127},
370 {0, 0xfff8, 0x0124},
371 {0, 0xfffd, 0x0124},
372 {0, 0xfffa, 0x0124},
373 {0, 0xfff9, 0x0124},
374 {0, 0x0086, 0x0127},
375 {0, 0xfff8, 0x0124},
376 {0, 0xfffd, 0x0124},
377 {0, 0x0037, 0x0127},
378 {0, 0xfff8, 0x0124},
379 {0, 0xfffd, 0x0124},
380 {0, 0x0001, 0x0127},
381 {0, 0xfff8, 0x0124},
382 {0, 0xfffd, 0x0124},
383 {0, 0x002a, 0x0127},
384 {0, 0xfff8, 0x0124},
385 {0, 0xfffd, 0x0124},
386 {0, 0xfffa, 0x0124},
387 {0, 0xfff9, 0x0124},
388 {0, 0x0086, 0x0127},
389 {0, 0xfff8, 0x0124},
390 {0, 0xfffd, 0x0124},
391 {0, 0x0038, 0x0127},
392 {0, 0xfff8, 0x0124},
393 {0, 0xfffd, 0x0124},
394 {0, 0x0000, 0x0127},
395 {0, 0xfff8, 0x0124},
396 {0, 0xfffd, 0x0124},
397 {0, 0x000e, 0x0127},
398 {0, 0xfff8, 0x0124},
399 {0, 0xfffd, 0x0124},
400 {0, 0xfffa, 0x0124},
401 {0, 0xfff9, 0x0124},
402 {0, 0x0086, 0x0127},
403 {0, 0xfff8, 0x0124},
404 {0, 0xfffd, 0x0124},
405 {0, 0x0037, 0x0127},
406 {0, 0xfff8, 0x0124},
407 {0, 0xfffd, 0x0124},
408 {0, 0x0001, 0x0127},
409 {0, 0xfff8, 0x0124},
410 {0, 0xfffd, 0x0124},
411 {0, 0x002b, 0x0127},
412 {0, 0xfff8, 0x0124},
413 {0, 0xfffd, 0x0124},
414 {0, 0xfffa, 0x0124},
415 {0, 0xfff9, 0x0124},
416 {0, 0x0086, 0x0127},
417 {0, 0xfff8, 0x0124},
418 {0, 0xfffd, 0x0124},
419 {0, 0x0038, 0x0127},
420 {0, 0xfff8, 0x0124},
421 {0, 0xfffd, 0x0124},
422 {0, 0x0001, 0x0127},
423 {0, 0xfff8, 0x0124},
424 {0, 0xfffd, 0x0124},
425 {0, 0x00f4, 0x0127},
426 {0, 0xfff8, 0x0124},
427 {0, 0xfffd, 0x0124},
428 {0, 0xfffa, 0x0124},
429 {0, 0xfff9, 0x0124},
430 {0, 0x0086, 0x0127},
431 {0, 0xfff8, 0x0124},
432 {0, 0xfffd, 0x0124},
433 {0, 0x0037, 0x0127},
434 {0, 0xfff8, 0x0124},
435 {0, 0xfffd, 0x0124},
436 {0, 0x0001, 0x0127},
437 {0, 0xfff8, 0x0124},
438 {0, 0xfffd, 0x0124},
439 {0, 0x002c, 0x0127},
440 {0, 0xfff8, 0x0124},
441 {0, 0xfffd, 0x0124},
442 {0, 0xfffa, 0x0124},
443 {0, 0xfff9, 0x0124},
444 {0, 0x0086, 0x0127},
445 {0, 0xfff8, 0x0124},
446 {0, 0xfffd, 0x0124},
447 {0, 0x0038, 0x0127},
448 {0, 0xfff8, 0x0124},
449 {0, 0xfffd, 0x0124},
450 {0, 0x0001, 0x0127},
451 {0, 0xfff8, 0x0124},
452 {0, 0xfffd, 0x0124},
453 {0, 0x0004, 0x0127},
454 {0, 0xfff8, 0x0124},
455 {0, 0xfffd, 0x0124},
456 {0, 0xfffa, 0x0124},
457 {0, 0xfff9, 0x0124},
458 {0, 0x0086, 0x0127},
459 {0, 0xfff8, 0x0124},
460 {0, 0xfffd, 0x0124},
461 {0, 0x0037, 0x0127},
462 {0, 0xfff8, 0x0124},
463 {0, 0xfffd, 0x0124},
464 {0, 0x0001, 0x0127},
465 {0, 0xfff8, 0x0124},
466 {0, 0xfffd, 0x0124},
467 {0, 0x002d, 0x0127},
468 {0, 0xfff8, 0x0124},
469 {0, 0xfffd, 0x0124},
470 {0, 0xfffa, 0x0124},
471 {0, 0xfff9, 0x0124},
472 {0, 0x0086, 0x0127},
473 {0, 0xfff8, 0x0124},
474 {0, 0xfffd, 0x0124},
475 {0, 0x0038, 0x0127},
476 {0, 0xfff8, 0x0124},
477 {0, 0xfffd, 0x0124},
478 {0, 0x0000, 0x0127},
479 {0, 0xfff8, 0x0124},
480 {0, 0xfffd, 0x0124},
481 {0, 0x0014, 0x0127},
482 {0, 0xfff8, 0x0124},
483 {0, 0xfffd, 0x0124},
484 {0, 0xfffa, 0x0124},
485 {0, 0xfff9, 0x0124},
486 {0, 0x0086, 0x0127},
487 {0, 0xfff8, 0x0124},
488 {0, 0xfffd, 0x0124},
489 {0, 0x0037, 0x0127},
490 {0, 0xfff8, 0x0124},
491 {0, 0xfffd, 0x0124},
492 {0, 0x0001, 0x0127},
493 {0, 0xfff8, 0x0124},
494 {0, 0xfffd, 0x0124},
495 {0, 0x002e, 0x0127},
496 {0, 0xfff8, 0x0124},
497 {0, 0xfffd, 0x0124},
498 {0, 0xfffa, 0x0124},
499 {0, 0xfff9, 0x0124},
500 {0, 0x0086, 0x0127},
501 {0, 0xfff8, 0x0124},
502 {0, 0xfffd, 0x0124},
503 {0, 0x0038, 0x0127},
504 {0, 0xfff8, 0x0124},
505 {0, 0xfffd, 0x0124},
506 {0, 0x0003, 0x0127},
507 {0, 0xfff8, 0x0124},
508 {0, 0xfffd, 0x0124},
509 {0, 0x0000, 0x0127},
510 {0, 0xfff8, 0x0124},
511 {0, 0xfffd, 0x0124},
512 {0, 0xfffa, 0x0124},
513 {0, 0xfff9, 0x0124},
514 {0, 0x0086, 0x0127},
515 {0, 0xfff8, 0x0124},
516 {0, 0xfffd, 0x0124},
517 {0, 0x0037, 0x0127},
518 {0, 0xfff8, 0x0124},
519 {0, 0xfffd, 0x0124},
520 {0, 0x0001, 0x0127},
521 {0, 0xfff8, 0x0124},
522 {0, 0xfffd, 0x0124},
523 {0, 0x002f, 0x0127},
524 {0, 0xfff8, 0x0124},
525 {0, 0xfffd, 0x0124},
526 {0, 0xfffa, 0x0124},
527 {0, 0xfff9, 0x0124},
528 {0, 0x0086, 0x0127},
529 {0, 0xfff8, 0x0124},
530 {0, 0xfffd, 0x0124},
531 {0, 0x0038, 0x0127},
532 {0, 0xfff8, 0x0124},
533 {0, 0xfffd, 0x0124},
534 {0, 0x0003, 0x0127},
535 {0, 0xfff8, 0x0124},
536 {0, 0xfffd, 0x0124},
537 {0, 0x0014, 0x0127},
538 {0, 0xfff8, 0x0124},
539 {0, 0xfffd, 0x0124},
540 {0, 0xfffa, 0x0124},
541 {0, 0xfff9, 0x0124},
542 {0, 0x0086, 0x0127},
543 {0, 0xfff8, 0x0124},
544 {0, 0xfffd, 0x0124},
545 {0, 0x0037, 0x0127},
546 {0, 0xfff8, 0x0124},
547 {0, 0xfffd, 0x0124},
548 {0, 0x0001, 0x0127},
549 {0, 0xfff8, 0x0124},
550 {0, 0xfffd, 0x0124},
551 {0, 0x0040, 0x0127},
552 {0, 0xfff8, 0x0124},
553 {0, 0xfffd, 0x0124},
554 {0, 0xfffa, 0x0124},
555 {0, 0xfff9, 0x0124},
556 {0, 0x0086, 0x0127},
557 {0, 0xfff8, 0x0124},
558 {0, 0xfffd, 0x0124},
559 {0, 0x0038, 0x0127},
560 {0, 0xfff8, 0x0124},
561 {0, 0xfffd, 0x0124},
562 {0, 0x0000, 0x0127},
563 {0, 0xfff8, 0x0124},
564 {0, 0xfffd, 0x0124},
565 {0, 0x0040, 0x0127},
566 {0, 0xfff8, 0x0124},
567 {0, 0xfffd, 0x0124},
568 {0, 0xfffa, 0x0124},
569 {0, 0xfff9, 0x0124},
570 {0, 0x0086, 0x0127},
571 {0, 0xfff8, 0x0124},
572 {0, 0xfffd, 0x0124},
573 {0, 0x0037, 0x0127},
574 {0, 0xfff8, 0x0124},
575 {0, 0xfffd, 0x0124},
576 {0, 0x0001, 0x0127},
577 {0, 0xfff8, 0x0124},
578 {0, 0xfffd, 0x0124},
579 {0, 0x0053, 0x0127},
580 {0, 0xfff8, 0x0124},
581 {0, 0xfffd, 0x0124},
582 {0, 0xfffa, 0x0124},
583 {0, 0xfff9, 0x0124},
584 {0, 0x0086, 0x0127},
585 {0, 0xfff8, 0x0124},
586 {0, 0xfffd, 0x0124},
587 {0, 0x0038, 0x0127},
588 {0, 0xfff8, 0x0124},
589 {0, 0xfffd, 0x0124},
590 {0, 0x0000, 0x0127},
591 {0, 0xfff8, 0x0124},
592 {0, 0xfffd, 0x0124},
593 {0, 0x0038, 0x0127},
594 {0, 0xfff8, 0x0124},
595 {0, 0xfffd, 0x0124},
596 {0, 0xfffa, 0x0124},
597 {0, 0x0000, 0x0101},
598 {0, 0x00a0, 0x0103},
599 {0, 0x0078, 0x0105},
600 {0, 0x0000, 0x010a},
601 {0, 0x0024, 0x010b},
602 {0, 0x0028, 0x0119},
603 {0, 0x0088, 0x011b},
604 {0, 0x0002, 0x011d},
605 {0, 0x0003, 0x011e},
606 {0, 0x0000, 0x0129},
607 {0, 0x00fc, 0x012b},
608 {0, 0x0008, 0x0102},
609 {0, 0x0000, 0x0104},
610 {0, 0x0008, 0x011a},
611 {0, 0x0028, 0x011c},
612 {0, 0x0021, 0x012a},
613 {0, 0x0000, 0x0118},
614 {0, 0x0000, 0x0132},
615 {0, 0x0000, 0x0109},
616 {0, 0xfff9, 0x0124},
617 {0, 0x0086, 0x0127},
618 {0, 0xfff8, 0x0124},
619 {0, 0xfffd, 0x0124},
620 {0, 0x0037, 0x0127},
621 {0, 0xfff8, 0x0124},
622 {0, 0xfffd, 0x0124},
623 {0, 0x0001, 0x0127},
624 {0, 0xfff8, 0x0124},
625 {0, 0xfffd, 0x0124},
626 {0, 0x0031, 0x0127},
627 {0, 0xfff8, 0x0124},
628 {0, 0xfffd, 0x0124},
629 {0, 0xfffa, 0x0124},
630 {0, 0xfff9, 0x0124},
631 {0, 0x0086, 0x0127},
632 {0, 0xfff8, 0x0124},
633 {0, 0xfffd, 0x0124},
634 {0, 0x0038, 0x0127},
635 {0, 0xfff8, 0x0124},
636 {0, 0xfffd, 0x0124},
637 {0, 0x0000, 0x0127},
638 {0, 0xfff8, 0x0124},
639 {0, 0xfffd, 0x0124},
640 {0, 0x0000, 0x0127},
641 {0, 0xfff8, 0x0124},
642 {0, 0xfffd, 0x0124},
643 {0, 0xfffa, 0x0124},
644 {0, 0xfff9, 0x0124},
645 {0, 0x0086, 0x0127},
646 {0, 0xfff8, 0x0124},
647 {0, 0xfffd, 0x0124},
648 {0, 0x0037, 0x0127},
649 {0, 0xfff8, 0x0124},
650 {0, 0xfffd, 0x0124},
651 {0, 0x0001, 0x0127},
652 {0, 0xfff8, 0x0124},
653 {0, 0xfffd, 0x0124},
654 {0, 0x0040, 0x0127},
655 {0, 0xfff8, 0x0124},
656 {0, 0xfffd, 0x0124},
657 {0, 0xfffa, 0x0124},
658 {0, 0xfff9, 0x0124},
659 {0, 0x0086, 0x0127},
660 {0, 0xfff8, 0x0124},
661 {0, 0xfffd, 0x0124},
662 {0, 0x0038, 0x0127},
663 {0, 0xfff8, 0x0124},
664 {0, 0xfffd, 0x0124},
665 {0, 0x0000, 0x0127},
666 {0, 0xfff8, 0x0124},
667 {0, 0xfffd, 0x0124},
668 {0, 0x0040, 0x0127},
669 {0, 0xfff8, 0x0124},
670 {0, 0xfffd, 0x0124},
671 {0, 0xfffa, 0x0124},
672 {0, 0xfff9, 0x0124},
673 {0, 0x0086, 0x0127},
674 {0, 0xfff8, 0x0124},
675 {0, 0xfffd, 0x0124},
676 {0, 0x0037, 0x0127},
677 {0, 0xfff8, 0x0124},
678 {0, 0xfffd, 0x0124},
679 {0, 0x0000, 0x0127},
680 {0, 0xfff8, 0x0124},
681 {0, 0xfffd, 0x0124},
682 {0, 0x00dc, 0x0127},
683 {0, 0xfff8, 0x0124},
684 {0, 0xfffd, 0x0124},
685 {0, 0xfffa, 0x0124},
686 {0, 0xfff9, 0x0124},
687 {0, 0x0086, 0x0127},
688 {0, 0xfff8, 0x0124},
689 {0, 0xfffd, 0x0124},
690 {0, 0x0038, 0x0127},
691 {0, 0xfff8, 0x0124},
692 {0, 0xfffd, 0x0124},
693 {0, 0x0000, 0x0127},
694 {0, 0xfff8, 0x0124},
695 {0, 0xfffd, 0x0124},
696 {0, 0x0000, 0x0127},
697 {0, 0xfff8, 0x0124},
698 {0, 0xfffd, 0x0124},
699 {0, 0xfffa, 0x0124},
700 {0, 0xfff9, 0x0124},
701 {0, 0x0086, 0x0127},
702 {0, 0xfff8, 0x0124},
703 {0, 0xfffd, 0x0124},
704 {0, 0x0037, 0x0127},
705 {0, 0xfff8, 0x0124},
706 {0, 0xfffd, 0x0124},
707 {0, 0x0001, 0x0127},
708 {0, 0xfff8, 0x0124},
709 {0, 0xfffd, 0x0124},
710 {0, 0x0032, 0x0127},
711 {0, 0xfff8, 0x0124},
712 {0, 0xfffd, 0x0124},
713 {0, 0xfffa, 0x0124},
714 {0, 0xfff9, 0x0124},
715 {0, 0x0086, 0x0127},
716 {0, 0xfff8, 0x0124},
717 {0, 0xfffd, 0x0124},
718 {0, 0x0038, 0x0127},
719 {0, 0xfff8, 0x0124},
720 {0, 0xfffd, 0x0124},
721 {0, 0x0001, 0x0127},
722 {0, 0xfff8, 0x0124},
723 {0, 0xfffd, 0x0124},
724 {0, 0x0020, 0x0127},
725 {0, 0xfff8, 0x0124},
726 {0, 0xfffd, 0x0124},
727 {0, 0xfffa, 0x0124},
728 {0, 0xfff9, 0x0124},
729 {0, 0x0086, 0x0127},
730 {0, 0xfff8, 0x0124},
731 {0, 0xfffd, 0x0124},
732 {0, 0x0037, 0x0127},
733 {0, 0xfff8, 0x0124},
734 {0, 0xfffd, 0x0124},
735 {0, 0x0001, 0x0127},
736 {0, 0xfff8, 0x0124},
737 {0, 0xfffd, 0x0124},
738 {0, 0x0040, 0x0127},
739 {0, 0xfff8, 0x0124},
740 {0, 0xfffd, 0x0124},
741 {0, 0xfffa, 0x0124},
742 {0, 0xfff9, 0x0124},
743 {0, 0x0086, 0x0127},
744 {0, 0xfff8, 0x0124},
745 {0, 0xfffd, 0x0124},
746 {0, 0x0038, 0x0127},
747 {0, 0xfff8, 0x0124},
748 {0, 0xfffd, 0x0124},
749 {0, 0x0000, 0x0127},
750 {0, 0xfff8, 0x0124},
751 {0, 0xfffd, 0x0124},
752 {0, 0x0040, 0x0127},
753 {0, 0xfff8, 0x0124},
754 {0, 0xfffd, 0x0124},
755 {0, 0xfffa, 0x0124},
756 {0, 0xfff9, 0x0124},
757 {0, 0x0086, 0x0127},
758 {0, 0xfff8, 0x0124},
759 {0, 0xfffd, 0x0124},
760 {0, 0x0037, 0x0127},
761 {0, 0xfff8, 0x0124},
762 {0, 0xfffd, 0x0124},
763 {0, 0x0000, 0x0127},
764 {0, 0xfff8, 0x0124},
765 {0, 0xfffd, 0x0124},
766 {0, 0x0030, 0x0127},
767 {0, 0xfff8, 0x0124},
768 {0, 0xfffd, 0x0124},
769 {0, 0xfffa, 0x0124},
770 {0, 0xfff9, 0x0124},
771 {0, 0x0086, 0x0127},
772 {0, 0xfff8, 0x0124},
773 {0, 0xfffd, 0x0124},
774 {0, 0x0038, 0x0127},
775 {0, 0xfff8, 0x0124},
776 {0, 0xfffd, 0x0124},
777 {0, 0x0008, 0x0127},
778 {0, 0xfff8, 0x0124},
779 {0, 0xfffd, 0x0124},
780 {0, 0x0000, 0x0127},
781 {0, 0xfff8, 0x0124},
782 {0, 0xfffd, 0x0124},
783 {0, 0xfffa, 0x0124},
784 {0, 0x0003, 0x0111},
785};
786
787/* TESTME the old ibmcam driver repeats certain commands to Model1 cameras, we
788 do the same for now (testing needed to see if this is really necessary) */
789static const int cit_model1_ntries = 5;
790static const int cit_model1_ntries2 = 2;
791
792static int cit_write_reg(struct gspca_dev *gspca_dev, u16 value, u16 index)
793{
794 struct usb_device *udev = gspca_dev->dev;
795 int err;
796
797 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00,
798 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
799 value, index, NULL, 0, 1000);
800 if (err < 0)
801 err("Failed to write a register (index 0x%04X,"
802 " value 0x%02X, error %d)", index, value, err);
803
804 return 0;
805}
806
807static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index)
808{
809 struct usb_device *udev = gspca_dev->dev;
810 __u8 *buf = gspca_dev->usb_buf;
811 int res;
812
813 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x01,
814 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
815 0x00, index, buf, 8, 1000);
816 if (res < 0) {
817 err("Failed to read a register (index 0x%04X, error %d)",
818 index, res);
819 return res;
820 }
821
822 PDEBUG(D_PROBE,
823 "Register %04x value: %02x %02x %02x %02x %02x %02x %02x %02x",
824 index,
825 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
826
827 return 0;
828}
829
830/*
831 * cit_send_FF_04_02()
832 *
833 * This procedure sends magic 3-command prefix to the camera.
834 * The purpose of this prefix is not known.
835 *
836 * History:
837 * 1/2/00 Created.
838 */
839static void cit_send_FF_04_02(struct gspca_dev *gspca_dev)
840{
841 cit_write_reg(gspca_dev, 0x00FF, 0x0127);
842 cit_write_reg(gspca_dev, 0x0004, 0x0124);
843 cit_write_reg(gspca_dev, 0x0002, 0x0124);
844}
845
846static void cit_send_00_04_06(struct gspca_dev *gspca_dev)
847{
848 cit_write_reg(gspca_dev, 0x0000, 0x0127);
849 cit_write_reg(gspca_dev, 0x0004, 0x0124);
850 cit_write_reg(gspca_dev, 0x0006, 0x0124);
851}
852
853static void cit_send_x_00(struct gspca_dev *gspca_dev, unsigned short x)
854{
855 cit_write_reg(gspca_dev, x, 0x0127);
856 cit_write_reg(gspca_dev, 0x0000, 0x0124);
857}
858
859static void cit_send_x_00_05(struct gspca_dev *gspca_dev, unsigned short x)
860{
861 cit_send_x_00(gspca_dev, x);
862 cit_write_reg(gspca_dev, 0x0005, 0x0124);
863}
864
865static void cit_send_x_00_05_02(struct gspca_dev *gspca_dev, unsigned short x)
866{
867 cit_write_reg(gspca_dev, x, 0x0127);
868 cit_write_reg(gspca_dev, 0x0000, 0x0124);
869 cit_write_reg(gspca_dev, 0x0005, 0x0124);
870 cit_write_reg(gspca_dev, 0x0002, 0x0124);
871}
872
873static void cit_send_x_01_00_05(struct gspca_dev *gspca_dev, u16 x)
874{
875 cit_write_reg(gspca_dev, x, 0x0127);
876 cit_write_reg(gspca_dev, 0x0001, 0x0124);
877 cit_write_reg(gspca_dev, 0x0000, 0x0124);
878 cit_write_reg(gspca_dev, 0x0005, 0x0124);
879}
880
881static void cit_send_x_00_05_02_01(struct gspca_dev *gspca_dev, u16 x)
882{
883 cit_write_reg(gspca_dev, x, 0x0127);
884 cit_write_reg(gspca_dev, 0x0000, 0x0124);
885 cit_write_reg(gspca_dev, 0x0005, 0x0124);
886 cit_write_reg(gspca_dev, 0x0002, 0x0124);
887 cit_write_reg(gspca_dev, 0x0001, 0x0124);
888}
889
890static void cit_send_x_00_05_02_08_01(struct gspca_dev *gspca_dev, u16 x)
891{
892 cit_write_reg(gspca_dev, x, 0x0127);
893 cit_write_reg(gspca_dev, 0x0000, 0x0124);
894 cit_write_reg(gspca_dev, 0x0005, 0x0124);
895 cit_write_reg(gspca_dev, 0x0002, 0x0124);
896 cit_write_reg(gspca_dev, 0x0008, 0x0124);
897 cit_write_reg(gspca_dev, 0x0001, 0x0124);
898}
899
900static void cit_Packet_Format1(struct gspca_dev *gspca_dev, u16 fkey, u16 val)
901{
902 cit_send_x_01_00_05(gspca_dev, 0x0088);
903 cit_send_x_00_05(gspca_dev, fkey);
904 cit_send_x_00_05_02_08_01(gspca_dev, val);
905 cit_send_x_00_05(gspca_dev, 0x0088);
906 cit_send_x_00_05_02_01(gspca_dev, fkey);
907 cit_send_x_00_05(gspca_dev, 0x0089);
908 cit_send_x_00(gspca_dev, fkey);
909 cit_send_00_04_06(gspca_dev);
910 cit_read_reg(gspca_dev, 0x0126);
911 cit_send_FF_04_02(gspca_dev);
912}
913
914static void cit_PacketFormat2(struct gspca_dev *gspca_dev, u16 fkey, u16 val)
915{
916 cit_send_x_01_00_05(gspca_dev, 0x0088);
917 cit_send_x_00_05(gspca_dev, fkey);
918 cit_send_x_00_05_02(gspca_dev, val);
919}
920
921static void cit_model2_Packet2(struct gspca_dev *gspca_dev)
922{
923 cit_write_reg(gspca_dev, 0x00ff, 0x012d);
924 cit_write_reg(gspca_dev, 0xfea3, 0x0124);
925}
926
927static void cit_model2_Packet1(struct gspca_dev *gspca_dev, u16 v1, u16 v2)
928{
929 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
930 cit_write_reg(gspca_dev, 0x00ff, 0x012e);
931 cit_write_reg(gspca_dev, v1, 0x012f);
932 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
933 cit_write_reg(gspca_dev, 0xc719, 0x0124);
934 cit_write_reg(gspca_dev, v2, 0x0127);
935
936 cit_model2_Packet2(gspca_dev);
937}
938
939/*
940 * cit_model3_Packet1()
941 *
942 * 00_0078_012d
943 * 00_0097_012f
944 * 00_d141_0124
945 * 00_0096_0127
946 * 00_fea8_0124
947*/
948static void cit_model3_Packet1(struct gspca_dev *gspca_dev, u16 v1, u16 v2)
949{
950 cit_write_reg(gspca_dev, 0x0078, 0x012d);
951 cit_write_reg(gspca_dev, v1, 0x012f);
952 cit_write_reg(gspca_dev, 0xd141, 0x0124);
953 cit_write_reg(gspca_dev, v2, 0x0127);
954 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
955}
956
957static void cit_model4_Packet1(struct gspca_dev *gspca_dev, u16 v1, u16 v2)
958{
959 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
960 cit_write_reg(gspca_dev, v1, 0x012f);
961 cit_write_reg(gspca_dev, 0xd141, 0x0124);
962 cit_write_reg(gspca_dev, v2, 0x0127);
963 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
964}
965
966static void cit_model4_BrightnessPacket(struct gspca_dev *gspca_dev, u16 val)
967{
968 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
969 cit_write_reg(gspca_dev, 0x0026, 0x012f);
970 cit_write_reg(gspca_dev, 0xd141, 0x0124);
971 cit_write_reg(gspca_dev, val, 0x0127);
972 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
973 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
974 cit_write_reg(gspca_dev, 0x0038, 0x012d);
975 cit_write_reg(gspca_dev, 0x0004, 0x012f);
976 cit_write_reg(gspca_dev, 0xd145, 0x0124);
977 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
978}
979
980/* this function is called at probe time */
981static int sd_config(struct gspca_dev *gspca_dev,
982 const struct usb_device_id *id)
983{
984 struct sd *sd = (struct sd *) gspca_dev;
985 struct cam *cam;
986
987 sd->model = id->driver_info;
988 if (sd->model == CIT_MODEL3 && ibm_netcam_pro)
989 sd->model = CIT_IBM_NETCAM_PRO;
990
991 cam = &gspca_dev->cam;
992 switch (sd->model) {
993 case CIT_MODEL0:
994 cam->cam_mode = model0_mode;
995 cam->nmodes = ARRAY_SIZE(model0_mode);
996 cam->reverse_alts = 1;
997 gspca_dev->ctrl_dis = ~((1 << SD_CONTRAST) | (1 << SD_HFLIP));
998 sd->sof_len = 4;
999 break;
1000 case CIT_MODEL1:
1001 cam->cam_mode = cif_yuv_mode;
1002 cam->nmodes = ARRAY_SIZE(cif_yuv_mode);
1003 cam->reverse_alts = 1;
1004 gspca_dev->ctrl_dis = (1 << SD_HUE) | (1 << SD_HFLIP);
1005 sd->sof_len = 4;
1006 break;
1007 case CIT_MODEL2:
1008 cam->cam_mode = model2_mode + 1; /* no 160x120 */
1009 cam->nmodes = 3;
1010 gspca_dev->ctrl_dis = (1 << SD_CONTRAST) |
1011 (1 << SD_SHARPNESS) |
1012 (1 << SD_HFLIP);
1013 break;
1014 case CIT_MODEL3:
1015 cam->cam_mode = vga_yuv_mode;
1016 cam->nmodes = ARRAY_SIZE(vga_yuv_mode);
1017 gspca_dev->ctrl_dis = (1 << SD_HUE) |
1018 (1 << SD_LIGHTING) |
1019 (1 << SD_HFLIP);
1020 sd->stop_on_control_change = 1;
1021 sd->sof_len = 4;
1022 break;
1023 case CIT_MODEL4:
1024 cam->cam_mode = model2_mode;
1025 cam->nmodes = ARRAY_SIZE(model2_mode);
1026 gspca_dev->ctrl_dis = (1 << SD_CONTRAST) |
1027 (1 << SD_SHARPNESS) |
1028 (1 << SD_LIGHTING) |
1029 (1 << SD_HFLIP);
1030 break;
1031 case CIT_IBM_NETCAM_PRO:
1032 cam->cam_mode = vga_yuv_mode;
1033 cam->nmodes = 2; /* no 640 x 480 */
1034 cam->input_flags = V4L2_IN_ST_VFLIP;
1035 gspca_dev->ctrl_dis = ~(1 << SD_CONTRAST);
1036 sd->stop_on_control_change = 1;
1037 sd->sof_len = 4;
1038 break;
1039 }
1040
1041 sd->brightness = BRIGHTNESS_DEFAULT;
1042 sd->contrast = CONTRAST_DEFAULT;
1043 sd->hue = HUE_DEFAULT;
1044 sd->sharpness = SHARPNESS_DEFAULT;
1045 sd->lighting = LIGHTING_DEFAULT;
1046 sd->hflip = HFLIP_DEFAULT;
1047
1048 return 0;
1049}
1050
1051static int cit_init_model0(struct gspca_dev *gspca_dev)
1052{
1053 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* turn on led */
1054 cit_write_reg(gspca_dev, 0x0001, 0x0112); /* turn on autogain ? */
1055 cit_write_reg(gspca_dev, 0x0000, 0x0400);
1056 cit_write_reg(gspca_dev, 0x0001, 0x0400);
1057 cit_write_reg(gspca_dev, 0x0000, 0x0420);
1058 cit_write_reg(gspca_dev, 0x0001, 0x0420);
1059 cit_write_reg(gspca_dev, 0x000d, 0x0409);
1060 cit_write_reg(gspca_dev, 0x0002, 0x040a);
1061 cit_write_reg(gspca_dev, 0x0018, 0x0405);
1062 cit_write_reg(gspca_dev, 0x0008, 0x0435);
1063 cit_write_reg(gspca_dev, 0x0026, 0x040b);
1064 cit_write_reg(gspca_dev, 0x0007, 0x0437);
1065 cit_write_reg(gspca_dev, 0x0015, 0x042f);
1066 cit_write_reg(gspca_dev, 0x002b, 0x0439);
1067 cit_write_reg(gspca_dev, 0x0026, 0x043a);
1068 cit_write_reg(gspca_dev, 0x0008, 0x0438);
1069 cit_write_reg(gspca_dev, 0x001e, 0x042b);
1070 cit_write_reg(gspca_dev, 0x0041, 0x042c);
1071
1072 return 0;
1073}
1074
1075static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev)
1076{
1077 cit_read_reg(gspca_dev, 0x128);
1078 cit_write_reg(gspca_dev, 0x0003, 0x0133);
1079 cit_write_reg(gspca_dev, 0x0000, 0x0117);
1080 cit_write_reg(gspca_dev, 0x0008, 0x0123);
1081 cit_write_reg(gspca_dev, 0x0000, 0x0100);
1082 cit_read_reg(gspca_dev, 0x0116);
1083 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1084 cit_write_reg(gspca_dev, 0x0002, 0x0112);
1085 cit_write_reg(gspca_dev, 0x0000, 0x0133);
1086 cit_write_reg(gspca_dev, 0x0000, 0x0123);
1087 cit_write_reg(gspca_dev, 0x0001, 0x0117);
1088 cit_write_reg(gspca_dev, 0x0040, 0x0108);
1089 cit_write_reg(gspca_dev, 0x0019, 0x012c);
1090 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1091 cit_write_reg(gspca_dev, 0x0002, 0x0115);
1092 cit_write_reg(gspca_dev, 0x000b, 0x0115);
1093
1094 cit_write_reg(gspca_dev, 0x0078, 0x012d);
1095 cit_write_reg(gspca_dev, 0x0001, 0x012f);
1096 cit_write_reg(gspca_dev, 0xd141, 0x0124);
1097 cit_write_reg(gspca_dev, 0x0079, 0x012d);
1098 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
1099 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
1100 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
1101 cit_read_reg(gspca_dev, 0x0126);
1102
1103 cit_model3_Packet1(gspca_dev, 0x0000, 0x0000);
1104 cit_model3_Packet1(gspca_dev, 0x0000, 0x0001);
1105 cit_model3_Packet1(gspca_dev, 0x000b, 0x0000);
1106 cit_model3_Packet1(gspca_dev, 0x000c, 0x0008);
1107 cit_model3_Packet1(gspca_dev, 0x000d, 0x003a);
1108 cit_model3_Packet1(gspca_dev, 0x000e, 0x0060);
1109 cit_model3_Packet1(gspca_dev, 0x000f, 0x0060);
1110 cit_model3_Packet1(gspca_dev, 0x0010, 0x0008);
1111 cit_model3_Packet1(gspca_dev, 0x0011, 0x0004);
1112 cit_model3_Packet1(gspca_dev, 0x0012, 0x0028);
1113 cit_model3_Packet1(gspca_dev, 0x0013, 0x0002);
1114 cit_model3_Packet1(gspca_dev, 0x0014, 0x0000);
1115 cit_model3_Packet1(gspca_dev, 0x0015, 0x00fb);
1116 cit_model3_Packet1(gspca_dev, 0x0016, 0x0002);
1117 cit_model3_Packet1(gspca_dev, 0x0017, 0x0037);
1118 cit_model3_Packet1(gspca_dev, 0x0018, 0x0036);
1119 cit_model3_Packet1(gspca_dev, 0x001e, 0x0000);
1120 cit_model3_Packet1(gspca_dev, 0x001f, 0x0008);
1121 cit_model3_Packet1(gspca_dev, 0x0020, 0x00c1);
1122 cit_model3_Packet1(gspca_dev, 0x0021, 0x0034);
1123 cit_model3_Packet1(gspca_dev, 0x0022, 0x0034);
1124 cit_model3_Packet1(gspca_dev, 0x0025, 0x0002);
1125 cit_model3_Packet1(gspca_dev, 0x0028, 0x0022);
1126 cit_model3_Packet1(gspca_dev, 0x0029, 0x000a);
1127 cit_model3_Packet1(gspca_dev, 0x002b, 0x0000);
1128 cit_model3_Packet1(gspca_dev, 0x002c, 0x0000);
1129 cit_model3_Packet1(gspca_dev, 0x002d, 0x00ff);
1130 cit_model3_Packet1(gspca_dev, 0x002e, 0x00ff);
1131 cit_model3_Packet1(gspca_dev, 0x002f, 0x00ff);
1132 cit_model3_Packet1(gspca_dev, 0x0030, 0x00ff);
1133 cit_model3_Packet1(gspca_dev, 0x0031, 0x00ff);
1134 cit_model3_Packet1(gspca_dev, 0x0032, 0x0007);
1135 cit_model3_Packet1(gspca_dev, 0x0033, 0x0005);
1136 cit_model3_Packet1(gspca_dev, 0x0037, 0x0040);
1137 cit_model3_Packet1(gspca_dev, 0x0039, 0x0000);
1138 cit_model3_Packet1(gspca_dev, 0x003a, 0x0000);
1139 cit_model3_Packet1(gspca_dev, 0x003b, 0x0001);
1140 cit_model3_Packet1(gspca_dev, 0x003c, 0x0000);
1141 cit_model3_Packet1(gspca_dev, 0x0040, 0x000c);
1142 cit_model3_Packet1(gspca_dev, 0x0041, 0x00fb);
1143 cit_model3_Packet1(gspca_dev, 0x0042, 0x0002);
1144 cit_model3_Packet1(gspca_dev, 0x0043, 0x0000);
1145 cit_model3_Packet1(gspca_dev, 0x0045, 0x0000);
1146 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000);
1147 cit_model3_Packet1(gspca_dev, 0x0047, 0x0000);
1148 cit_model3_Packet1(gspca_dev, 0x0048, 0x0000);
1149 cit_model3_Packet1(gspca_dev, 0x0049, 0x0000);
1150 cit_model3_Packet1(gspca_dev, 0x004a, 0x00ff);
1151 cit_model3_Packet1(gspca_dev, 0x004b, 0x00ff);
1152 cit_model3_Packet1(gspca_dev, 0x004c, 0x00ff);
1153 cit_model3_Packet1(gspca_dev, 0x004f, 0x0000);
1154 cit_model3_Packet1(gspca_dev, 0x0050, 0x0000);
1155 cit_model3_Packet1(gspca_dev, 0x0051, 0x0002);
1156 cit_model3_Packet1(gspca_dev, 0x0055, 0x0000);
1157 cit_model3_Packet1(gspca_dev, 0x0056, 0x0000);
1158 cit_model3_Packet1(gspca_dev, 0x0057, 0x0000);
1159 cit_model3_Packet1(gspca_dev, 0x0058, 0x0002);
1160 cit_model3_Packet1(gspca_dev, 0x0059, 0x0000);
1161 cit_model3_Packet1(gspca_dev, 0x005c, 0x0016);
1162 cit_model3_Packet1(gspca_dev, 0x005d, 0x0022);
1163 cit_model3_Packet1(gspca_dev, 0x005e, 0x003c);
1164 cit_model3_Packet1(gspca_dev, 0x005f, 0x0050);
1165 cit_model3_Packet1(gspca_dev, 0x0060, 0x0044);
1166 cit_model3_Packet1(gspca_dev, 0x0061, 0x0005);
1167 cit_model3_Packet1(gspca_dev, 0x006a, 0x007e);
1168 cit_model3_Packet1(gspca_dev, 0x006f, 0x0000);
1169 cit_model3_Packet1(gspca_dev, 0x0072, 0x001b);
1170 cit_model3_Packet1(gspca_dev, 0x0073, 0x0005);
1171 cit_model3_Packet1(gspca_dev, 0x0074, 0x000a);
1172 cit_model3_Packet1(gspca_dev, 0x0075, 0x001b);
1173 cit_model3_Packet1(gspca_dev, 0x0076, 0x002a);
1174 cit_model3_Packet1(gspca_dev, 0x0077, 0x003c);
1175 cit_model3_Packet1(gspca_dev, 0x0078, 0x0050);
1176 cit_model3_Packet1(gspca_dev, 0x007b, 0x0000);
1177 cit_model3_Packet1(gspca_dev, 0x007c, 0x0011);
1178 cit_model3_Packet1(gspca_dev, 0x007d, 0x0024);
1179 cit_model3_Packet1(gspca_dev, 0x007e, 0x0043);
1180 cit_model3_Packet1(gspca_dev, 0x007f, 0x005a);
1181 cit_model3_Packet1(gspca_dev, 0x0084, 0x0020);
1182 cit_model3_Packet1(gspca_dev, 0x0085, 0x0033);
1183 cit_model3_Packet1(gspca_dev, 0x0086, 0x000a);
1184 cit_model3_Packet1(gspca_dev, 0x0087, 0x0030);
1185 cit_model3_Packet1(gspca_dev, 0x0088, 0x0070);
1186 cit_model3_Packet1(gspca_dev, 0x008b, 0x0008);
1187 cit_model3_Packet1(gspca_dev, 0x008f, 0x0000);
1188 cit_model3_Packet1(gspca_dev, 0x0090, 0x0006);
1189 cit_model3_Packet1(gspca_dev, 0x0091, 0x0028);
1190 cit_model3_Packet1(gspca_dev, 0x0092, 0x005a);
1191 cit_model3_Packet1(gspca_dev, 0x0093, 0x0082);
1192 cit_model3_Packet1(gspca_dev, 0x0096, 0x0014);
1193 cit_model3_Packet1(gspca_dev, 0x0097, 0x0020);
1194 cit_model3_Packet1(gspca_dev, 0x0098, 0x0000);
1195 cit_model3_Packet1(gspca_dev, 0x00b0, 0x0046);
1196 cit_model3_Packet1(gspca_dev, 0x00b1, 0x0000);
1197 cit_model3_Packet1(gspca_dev, 0x00b2, 0x0000);
1198 cit_model3_Packet1(gspca_dev, 0x00b3, 0x0004);
1199 cit_model3_Packet1(gspca_dev, 0x00b4, 0x0007);
1200 cit_model3_Packet1(gspca_dev, 0x00b6, 0x0002);
1201 cit_model3_Packet1(gspca_dev, 0x00b7, 0x0004);
1202 cit_model3_Packet1(gspca_dev, 0x00bb, 0x0000);
1203 cit_model3_Packet1(gspca_dev, 0x00bc, 0x0001);
1204 cit_model3_Packet1(gspca_dev, 0x00bd, 0x0000);
1205 cit_model3_Packet1(gspca_dev, 0x00bf, 0x0000);
1206 cit_model3_Packet1(gspca_dev, 0x00c0, 0x00c8);
1207 cit_model3_Packet1(gspca_dev, 0x00c1, 0x0014);
1208 cit_model3_Packet1(gspca_dev, 0x00c2, 0x0001);
1209 cit_model3_Packet1(gspca_dev, 0x00c3, 0x0000);
1210 cit_model3_Packet1(gspca_dev, 0x00c4, 0x0004);
1211 cit_model3_Packet1(gspca_dev, 0x00cb, 0x00bf);
1212 cit_model3_Packet1(gspca_dev, 0x00cc, 0x00bf);
1213 cit_model3_Packet1(gspca_dev, 0x00cd, 0x00bf);
1214 cit_model3_Packet1(gspca_dev, 0x00ce, 0x0000);
1215 cit_model3_Packet1(gspca_dev, 0x00cf, 0x0020);
1216 cit_model3_Packet1(gspca_dev, 0x00d0, 0x0040);
1217 cit_model3_Packet1(gspca_dev, 0x00d1, 0x00bf);
1218 cit_model3_Packet1(gspca_dev, 0x00d1, 0x00bf);
1219 cit_model3_Packet1(gspca_dev, 0x00d2, 0x00bf);
1220 cit_model3_Packet1(gspca_dev, 0x00d3, 0x00bf);
1221 cit_model3_Packet1(gspca_dev, 0x00ea, 0x0008);
1222 cit_model3_Packet1(gspca_dev, 0x00eb, 0x0000);
1223 cit_model3_Packet1(gspca_dev, 0x00ec, 0x00e8);
1224 cit_model3_Packet1(gspca_dev, 0x00ed, 0x0001);
1225 cit_model3_Packet1(gspca_dev, 0x00ef, 0x0022);
1226 cit_model3_Packet1(gspca_dev, 0x00f0, 0x0000);
1227 cit_model3_Packet1(gspca_dev, 0x00f2, 0x0028);
1228 cit_model3_Packet1(gspca_dev, 0x00f4, 0x0002);
1229 cit_model3_Packet1(gspca_dev, 0x00f5, 0x0000);
1230 cit_model3_Packet1(gspca_dev, 0x00fa, 0x0000);
1231 cit_model3_Packet1(gspca_dev, 0x00fb, 0x0001);
1232 cit_model3_Packet1(gspca_dev, 0x00fc, 0x0000);
1233 cit_model3_Packet1(gspca_dev, 0x00fd, 0x0000);
1234 cit_model3_Packet1(gspca_dev, 0x00fe, 0x0000);
1235 cit_model3_Packet1(gspca_dev, 0x00ff, 0x0000);
1236
1237 cit_model3_Packet1(gspca_dev, 0x00be, 0x0003);
1238 cit_model3_Packet1(gspca_dev, 0x00c8, 0x0000);
1239 cit_model3_Packet1(gspca_dev, 0x00c9, 0x0020);
1240 cit_model3_Packet1(gspca_dev, 0x00ca, 0x0040);
1241 cit_model3_Packet1(gspca_dev, 0x0053, 0x0001);
1242 cit_model3_Packet1(gspca_dev, 0x0082, 0x000e);
1243 cit_model3_Packet1(gspca_dev, 0x0083, 0x0020);
1244 cit_model3_Packet1(gspca_dev, 0x0034, 0x003c);
1245 cit_model3_Packet1(gspca_dev, 0x006e, 0x0055);
1246 cit_model3_Packet1(gspca_dev, 0x0062, 0x0005);
1247 cit_model3_Packet1(gspca_dev, 0x0063, 0x0008);
1248 cit_model3_Packet1(gspca_dev, 0x0066, 0x000a);
1249 cit_model3_Packet1(gspca_dev, 0x0067, 0x0006);
1250 cit_model3_Packet1(gspca_dev, 0x006b, 0x0010);
1251 cit_model3_Packet1(gspca_dev, 0x005a, 0x0001);
1252 cit_model3_Packet1(gspca_dev, 0x005b, 0x000a);
1253 cit_model3_Packet1(gspca_dev, 0x0023, 0x0006);
1254 cit_model3_Packet1(gspca_dev, 0x0026, 0x0004);
1255 cit_model3_Packet1(gspca_dev, 0x0036, 0x0069);
1256 cit_model3_Packet1(gspca_dev, 0x0038, 0x0064);
1257 cit_model3_Packet1(gspca_dev, 0x003d, 0x0003);
1258 cit_model3_Packet1(gspca_dev, 0x003e, 0x0001);
1259 cit_model3_Packet1(gspca_dev, 0x00b8, 0x0014);
1260 cit_model3_Packet1(gspca_dev, 0x00b9, 0x0014);
1261 cit_model3_Packet1(gspca_dev, 0x00e6, 0x0004);
1262 cit_model3_Packet1(gspca_dev, 0x00e8, 0x0001);
1263
1264 return 0;
1265}
1266
1267/* this function is called at probe and resume time */
1268static int sd_init(struct gspca_dev *gspca_dev)
1269{
1270 struct sd *sd = (struct sd *) gspca_dev;
1271
1272 switch (sd->model) {
1273 case CIT_MODEL0:
1274 cit_init_model0(gspca_dev);
1275 sd_stop0(gspca_dev);
1276 break;
1277 case CIT_MODEL1:
1278 case CIT_MODEL2:
1279 case CIT_MODEL3:
1280 case CIT_MODEL4:
1281 break; /* All is done in sd_start */
1282 case CIT_IBM_NETCAM_PRO:
1283 cit_init_ibm_netcam_pro(gspca_dev);
1284 sd_stop0(gspca_dev);
1285 break;
1286 }
1287 return 0;
1288}
1289
1290static int cit_set_brightness(struct gspca_dev *gspca_dev)
1291{
1292 struct sd *sd = (struct sd *) gspca_dev;
1293 int i;
1294
1295 switch (sd->model) {
1296 case CIT_MODEL0:
1297 case CIT_IBM_NETCAM_PRO:
1298 /* No (known) brightness control for these */
1299 break;
1300 case CIT_MODEL1:
1301 /* Model 1: Brightness range 0 - 63 */
1302 cit_Packet_Format1(gspca_dev, 0x0031, sd->brightness);
1303 cit_Packet_Format1(gspca_dev, 0x0032, sd->brightness);
1304 cit_Packet_Format1(gspca_dev, 0x0033, sd->brightness);
1305 break;
1306 case CIT_MODEL2:
1307 /* Model 2: Brightness range 0x60 - 0xee */
1308 /* Scale 0 - 63 to 0x60 - 0xee */
1309 i = 0x60 + sd->brightness * 2254 / 1000;
1310 cit_model2_Packet1(gspca_dev, 0x001a, i);
1311 break;
1312 case CIT_MODEL3:
1313 /* Model 3: Brightness range 'i' in [0x0C..0x3F] */
1314 i = sd->brightness;
1315 if (i < 0x0c)
1316 i = 0x0c;
1317 cit_model3_Packet1(gspca_dev, 0x0036, i);
1318 break;
1319 case CIT_MODEL4:
1320 /* Model 4: Brightness range 'i' in [0x04..0xb4] */
1321 /* Scale 0 - 63 to 0x04 - 0xb4 */
1322 i = 0x04 + sd->brightness * 2794 / 1000;
1323 cit_model4_BrightnessPacket(gspca_dev, i);
1324 break;
1325 }
1326
1327 return 0;
1328}
1329
1330static int cit_set_contrast(struct gspca_dev *gspca_dev)
1331{
1332 struct sd *sd = (struct sd *) gspca_dev;
1333
1334 switch (sd->model) {
1335 case CIT_MODEL0: {
1336 int i;
1337 /* gain 0-15, 0-20 -> 0-15 */
1338 i = sd->contrast * 1000 / 1333;
1339 cit_write_reg(gspca_dev, i, 0x0422);
1340 /* gain 0-31, may not be lower then 0x0422, 0-20 -> 0-31 */
1341 i = sd->contrast * 2000 / 1333;
1342 cit_write_reg(gspca_dev, i, 0x0423);
1343 /* gain 0-127, may not be lower then 0x0423, 0-20 -> 0-63 */
1344 i = sd->contrast * 4000 / 1333;
1345 cit_write_reg(gspca_dev, i, 0x0424);
1346 /* gain 0-127, may not be lower then 0x0424, , 0-20 -> 0-127 */
1347 i = sd->contrast * 8000 / 1333;
1348 cit_write_reg(gspca_dev, i, 0x0425);
1349 break;
1350 }
1351 case CIT_MODEL2:
1352 case CIT_MODEL4:
1353 /* These models do not have this control. */
1354 break;
1355 case CIT_MODEL1:
1356 {
1357 /* Scale 0 - 20 to 15 - 0 */
1358 int i, new_contrast = (20 - sd->contrast) * 1000 / 1333;
1359 for (i = 0; i < cit_model1_ntries; i++) {
1360 cit_Packet_Format1(gspca_dev, 0x0014, new_contrast);
1361 cit_send_FF_04_02(gspca_dev);
1362 }
1363 break;
1364 }
1365 case CIT_MODEL3:
1366 { /* Preset hardware values */
1367 static const struct {
1368 unsigned short cv1;
1369 unsigned short cv2;
1370 unsigned short cv3;
1371 } cv[7] = {
1372 { 0x05, 0x05, 0x0f }, /* Minimum */
1373 { 0x04, 0x04, 0x16 },
1374 { 0x02, 0x03, 0x16 },
1375 { 0x02, 0x08, 0x16 },
1376 { 0x01, 0x0c, 0x16 },
1377 { 0x01, 0x0e, 0x16 },
1378 { 0x01, 0x10, 0x16 } /* Maximum */
1379 };
1380 int i = sd->contrast / 3;
1381 cit_model3_Packet1(gspca_dev, 0x0067, cv[i].cv1);
1382 cit_model3_Packet1(gspca_dev, 0x005b, cv[i].cv2);
1383 cit_model3_Packet1(gspca_dev, 0x005c, cv[i].cv3);
1384 break;
1385 }
1386 case CIT_IBM_NETCAM_PRO:
1387 cit_model3_Packet1(gspca_dev, 0x005b, sd->contrast + 1);
1388 break;
1389 }
1390 return 0;
1391}
1392
1393static int cit_set_hue(struct gspca_dev *gspca_dev)
1394{
1395 struct sd *sd = (struct sd *) gspca_dev;
1396
1397 switch (sd->model) {
1398 case CIT_MODEL0:
1399 case CIT_MODEL1:
1400 case CIT_IBM_NETCAM_PRO:
1401 /* No hue control for these models */
1402 break;
1403 case CIT_MODEL2:
1404 cit_model2_Packet1(gspca_dev, 0x0024, sd->hue);
1405 /* cit_model2_Packet1(gspca_dev, 0x0020, sat); */
1406 break;
1407 case CIT_MODEL3: {
1408 /* Model 3: Brightness range 'i' in [0x05..0x37] */
1409 /* TESTME according to the ibmcam driver this does not work */
1410 if (0) {
1411 /* Scale 0 - 127 to 0x05 - 0x37 */
1412 int i = 0x05 + sd->hue * 1000 / 2540;
1413 cit_model3_Packet1(gspca_dev, 0x007e, i);
1414 }
1415 break;
1416 }
1417 case CIT_MODEL4:
1418 /* HDG: taken from ibmcam, setting the color gains does not
1419 * really belong here.
1420 *
1421 * I am not sure r/g/b_gain variables exactly control gain
1422 * of those channels. Most likely they subtly change some
1423 * very internal image processing settings in the camera.
1424 * In any case, here is what they do, and feel free to tweak:
1425 *
1426 * r_gain: seriously affects red gain
1427 * g_gain: seriously affects green gain
1428 * b_gain: seriously affects blue gain
1429 * hue: changes average color from violet (0) to red (0xFF)
1430 */
1431 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
1432 cit_write_reg(gspca_dev, 0x001e, 0x012f);
1433 cit_write_reg(gspca_dev, 0xd141, 0x0124);
1434 cit_write_reg(gspca_dev, 160, 0x0127); /* Green gain */
1435 cit_write_reg(gspca_dev, 160, 0x012e); /* Red gain */
1436 cit_write_reg(gspca_dev, 160, 0x0130); /* Blue gain */
1437 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
1438 cit_write_reg(gspca_dev, sd->hue, 0x012d); /* Hue */
1439 cit_write_reg(gspca_dev, 0xf545, 0x0124);
1440 break;
1441 }
1442 return 0;
1443}
1444
1445static int cit_set_sharpness(struct gspca_dev *gspca_dev)
1446{
1447 struct sd *sd = (struct sd *) gspca_dev;
1448
1449 switch (sd->model) {
1450 case CIT_MODEL0:
1451 case CIT_MODEL2:
1452 case CIT_MODEL4:
1453 case CIT_IBM_NETCAM_PRO:
1454 /* These models do not have this control */
1455 break;
1456 case CIT_MODEL1: {
1457 int i;
1458 const unsigned short sa[] = {
1459 0x11, 0x13, 0x16, 0x18, 0x1a, 0x8, 0x0a };
1460
1461 for (i = 0; i < cit_model1_ntries; i++)
1462 cit_PacketFormat2(gspca_dev, 0x0013, sa[sd->sharpness]);
1463 break;
1464 }
1465 case CIT_MODEL3:
1466 { /*
1467 * "Use a table of magic numbers.
1468 * This setting doesn't really change much.
1469 * But that's how Windows does it."
1470 */
1471 static const struct {
1472 unsigned short sv1;
1473 unsigned short sv2;
1474 unsigned short sv3;
1475 unsigned short sv4;
1476 } sv[7] = {
1477 { 0x00, 0x00, 0x05, 0x14 }, /* Smoothest */
1478 { 0x01, 0x04, 0x05, 0x14 },
1479 { 0x02, 0x04, 0x05, 0x14 },
1480 { 0x03, 0x04, 0x05, 0x14 },
1481 { 0x03, 0x05, 0x05, 0x14 },
1482 { 0x03, 0x06, 0x05, 0x14 },
1483 { 0x03, 0x07, 0x05, 0x14 } /* Sharpest */
1484 };
1485 cit_model3_Packet1(gspca_dev, 0x0060, sv[sd->sharpness].sv1);
1486 cit_model3_Packet1(gspca_dev, 0x0061, sv[sd->sharpness].sv2);
1487 cit_model3_Packet1(gspca_dev, 0x0062, sv[sd->sharpness].sv3);
1488 cit_model3_Packet1(gspca_dev, 0x0063, sv[sd->sharpness].sv4);
1489 break;
1490 }
1491 }
1492 return 0;
1493}
1494
1495/*
1496 * cit_set_lighting()
1497 *
1498 * Camera model 1:
1499 * We have 3 levels of lighting conditions: 0=Bright, 1=Medium, 2=Low.
1500 *
1501 * Camera model 2:
1502 * We have 16 levels of lighting, 0 for bright light and up to 15 for
1503 * low light. But values above 5 or so are useless because camera is
1504 * not really capable to produce anything worth viewing at such light.
1505 * This setting may be altered only in certain camera state.
1506 *
1507 * Low lighting forces slower FPS.
1508 *
1509 * History:
1510 * 1/5/00 Created.
1511 * 2/20/00 Added support for Model 2 cameras.
1512 */
1513static void cit_set_lighting(struct gspca_dev *gspca_dev)
1514{
1515 struct sd *sd = (struct sd *) gspca_dev;
1516
1517 switch (sd->model) {
1518 case CIT_MODEL0:
1519 case CIT_MODEL2:
1520 case CIT_MODEL3:
1521 case CIT_MODEL4:
1522 case CIT_IBM_NETCAM_PRO:
1523 break;
1524 case CIT_MODEL1: {
1525 int i;
1526 for (i = 0; i < cit_model1_ntries; i++)
1527 cit_Packet_Format1(gspca_dev, 0x0027, sd->lighting);
1528 break;
1529 }
1530 }
1531}
1532
1533static void cit_set_hflip(struct gspca_dev *gspca_dev)
1534{
1535 struct sd *sd = (struct sd *) gspca_dev;
1536
1537 switch (sd->model) {
1538 case CIT_MODEL0:
1539 if (sd->hflip)
1540 cit_write_reg(gspca_dev, 0x0020, 0x0115);
1541 else
1542 cit_write_reg(gspca_dev, 0x0040, 0x0115);
1543 break;
1544 case CIT_MODEL1:
1545 case CIT_MODEL2:
1546 case CIT_MODEL3:
1547 case CIT_MODEL4:
1548 case CIT_IBM_NETCAM_PRO:
1549 break;
1550 }
1551}
1552
1553static int cit_restart_stream(struct gspca_dev *gspca_dev)
1554{
1555 struct sd *sd = (struct sd *) gspca_dev;
1556
1557 switch (sd->model) {
1558 case CIT_MODEL0:
1559 case CIT_MODEL1:
1560 case CIT_MODEL3:
1561 case CIT_IBM_NETCAM_PRO:
1562 cit_write_reg(gspca_dev, 0x0001, 0x0114);
1563 /* Fall through */
1564 case CIT_MODEL2:
1565 case CIT_MODEL4:
1566 cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */
1567 usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe);
1568 /* This happens repeatedly while streaming with the ibm netcam
1569 pro and the ibmcam driver did it for model3 after changing
1570 settings, but it does not seem to have any effect. */
1571 /* cit_write_reg(gspca_dev, 0x0001, 0x0113); */
1572 break;
1573 }
1574
1575 sd->sof_read = 0;
1576
1577 return 0;
1578}
1579
1580static int cit_get_packet_size(struct gspca_dev *gspca_dev)
1581{
1582 struct usb_host_interface *alt;
1583 struct usb_interface *intf;
1584
1585 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface);
1586 alt = usb_altnum_to_altsetting(intf, gspca_dev->alt);
1587 if (!alt) {
1588 err("Couldn't get altsetting");
1589 return -EIO;
1590 }
1591
1592 return le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
1593}
1594
1595/* Calculate the clockdiv giving us max fps given the available bandwidth */
1596static int cit_get_clock_div(struct gspca_dev *gspca_dev)
1597{
1598 int clock_div = 7; /* 0=30 1=25 2=20 3=15 4=12 5=7.5 6=6 7=3fps ?? */
1599 int fps[8] = { 30, 25, 20, 15, 12, 8, 6, 3 };
1600 int packet_size;
1601
1602 packet_size = cit_get_packet_size(gspca_dev);
1603 if (packet_size < 0)
1604 return packet_size;
1605
1606 while (clock_div > 3 &&
1607 1000 * packet_size >
1608 gspca_dev->width * gspca_dev->height *
1609 fps[clock_div - 1] * 3 / 2)
1610 clock_div--;
1611
1612 PDEBUG(D_PROBE,
1613 "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)",
1614 packet_size, gspca_dev->width, gspca_dev->height, clock_div,
1615 fps[clock_div]);
1616
1617 return clock_div;
1618}
1619
1620static int cit_start_model0(struct gspca_dev *gspca_dev)
1621{
1622 const unsigned short compression = 0; /* 0=none, 7=best frame rate */
1623 int clock_div;
1624
1625 clock_div = cit_get_clock_div(gspca_dev);
1626 if (clock_div < 0)
1627 return clock_div;
1628
1629 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* turn on led */
1630 cit_write_reg(gspca_dev, 0x0003, 0x0438);
1631 cit_write_reg(gspca_dev, 0x001e, 0x042b);
1632 cit_write_reg(gspca_dev, 0x0041, 0x042c);
1633 cit_write_reg(gspca_dev, 0x0008, 0x0436);
1634 cit_write_reg(gspca_dev, 0x0024, 0x0403);
1635 cit_write_reg(gspca_dev, 0x002c, 0x0404);
1636 cit_write_reg(gspca_dev, 0x0002, 0x0426);
1637 cit_write_reg(gspca_dev, 0x0014, 0x0427);
1638
1639 switch (gspca_dev->width) {
1640 case 160: /* 160x120 */
1641 cit_write_reg(gspca_dev, 0x0004, 0x010b);
1642 cit_write_reg(gspca_dev, 0x0001, 0x010a);
1643 cit_write_reg(gspca_dev, 0x0010, 0x0102);
1644 cit_write_reg(gspca_dev, 0x00a0, 0x0103);
1645 cit_write_reg(gspca_dev, 0x0000, 0x0104);
1646 cit_write_reg(gspca_dev, 0x0078, 0x0105);
1647 break;
1648
1649 case 176: /* 176x144 */
1650 cit_write_reg(gspca_dev, 0x0006, 0x010b);
1651 cit_write_reg(gspca_dev, 0x0000, 0x010a);
1652 cit_write_reg(gspca_dev, 0x0005, 0x0102);
1653 cit_write_reg(gspca_dev, 0x00b0, 0x0103);
1654 cit_write_reg(gspca_dev, 0x0000, 0x0104);
1655 cit_write_reg(gspca_dev, 0x0090, 0x0105);
1656 break;
1657
1658 case 320: /* 320x240 */
1659 cit_write_reg(gspca_dev, 0x0008, 0x010b);
1660 cit_write_reg(gspca_dev, 0x0004, 0x010a);
1661 cit_write_reg(gspca_dev, 0x0005, 0x0102);
1662 cit_write_reg(gspca_dev, 0x00a0, 0x0103);
1663 cit_write_reg(gspca_dev, 0x0010, 0x0104);
1664 cit_write_reg(gspca_dev, 0x0078, 0x0105);
1665 break;
1666 }
1667
1668 cit_write_reg(gspca_dev, compression, 0x0109);
1669 cit_write_reg(gspca_dev, clock_div, 0x0111);
1670
1671 return 0;
1672}
1673
1674static int cit_start_model1(struct gspca_dev *gspca_dev)
1675{
1676 struct sd *sd = (struct sd *) gspca_dev;
1677 int i, clock_div;
1678
1679 clock_div = cit_get_clock_div(gspca_dev);
1680 if (clock_div < 0)
1681 return clock_div;
1682
1683 cit_read_reg(gspca_dev, 0x0128);
1684 cit_read_reg(gspca_dev, 0x0100);
1685 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */
1686 cit_read_reg(gspca_dev, 0x0100);
1687 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */
1688 cit_read_reg(gspca_dev, 0x0100);
1689 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */
1690 cit_write_reg(gspca_dev, 0x01, 0x0108);
1691
1692 cit_write_reg(gspca_dev, 0x03, 0x0112);
1693 cit_read_reg(gspca_dev, 0x0115);
1694 cit_write_reg(gspca_dev, 0x06, 0x0115);
1695 cit_read_reg(gspca_dev, 0x0116);
1696 cit_write_reg(gspca_dev, 0x44, 0x0116);
1697 cit_read_reg(gspca_dev, 0x0116);
1698 cit_write_reg(gspca_dev, 0x40, 0x0116);
1699 cit_read_reg(gspca_dev, 0x0115);
1700 cit_write_reg(gspca_dev, 0x0e, 0x0115);
1701 cit_write_reg(gspca_dev, 0x19, 0x012c);
1702
1703 cit_Packet_Format1(gspca_dev, 0x00, 0x1e);
1704 cit_Packet_Format1(gspca_dev, 0x39, 0x0d);
1705 cit_Packet_Format1(gspca_dev, 0x39, 0x09);
1706 cit_Packet_Format1(gspca_dev, 0x3b, 0x00);
1707 cit_Packet_Format1(gspca_dev, 0x28, 0x22);
1708 cit_Packet_Format1(gspca_dev, 0x27, 0x00);
1709 cit_Packet_Format1(gspca_dev, 0x2b, 0x1f);
1710 cit_Packet_Format1(gspca_dev, 0x39, 0x08);
1711
1712 for (i = 0; i < cit_model1_ntries; i++)
1713 cit_Packet_Format1(gspca_dev, 0x2c, 0x00);
1714
1715 for (i = 0; i < cit_model1_ntries; i++)
1716 cit_Packet_Format1(gspca_dev, 0x30, 0x14);
1717
1718 cit_PacketFormat2(gspca_dev, 0x39, 0x02);
1719 cit_PacketFormat2(gspca_dev, 0x01, 0xe1);
1720 cit_PacketFormat2(gspca_dev, 0x02, 0xcd);
1721 cit_PacketFormat2(gspca_dev, 0x03, 0xcd);
1722 cit_PacketFormat2(gspca_dev, 0x04, 0xfa);
1723 cit_PacketFormat2(gspca_dev, 0x3f, 0xff);
1724 cit_PacketFormat2(gspca_dev, 0x39, 0x00);
1725
1726 cit_PacketFormat2(gspca_dev, 0x39, 0x02);
1727 cit_PacketFormat2(gspca_dev, 0x0a, 0x37);
1728 cit_PacketFormat2(gspca_dev, 0x0b, 0xb8);
1729 cit_PacketFormat2(gspca_dev, 0x0c, 0xf3);
1730 cit_PacketFormat2(gspca_dev, 0x0d, 0xe3);
1731 cit_PacketFormat2(gspca_dev, 0x0e, 0x0d);
1732 cit_PacketFormat2(gspca_dev, 0x0f, 0xf2);
1733 cit_PacketFormat2(gspca_dev, 0x10, 0xd5);
1734 cit_PacketFormat2(gspca_dev, 0x11, 0xba);
1735 cit_PacketFormat2(gspca_dev, 0x12, 0x53);
1736 cit_PacketFormat2(gspca_dev, 0x3f, 0xff);
1737 cit_PacketFormat2(gspca_dev, 0x39, 0x00);
1738
1739 cit_PacketFormat2(gspca_dev, 0x39, 0x02);
1740 cit_PacketFormat2(gspca_dev, 0x16, 0x00);
1741 cit_PacketFormat2(gspca_dev, 0x17, 0x28);
1742 cit_PacketFormat2(gspca_dev, 0x18, 0x7d);
1743 cit_PacketFormat2(gspca_dev, 0x19, 0xbe);
1744 cit_PacketFormat2(gspca_dev, 0x3f, 0xff);
1745 cit_PacketFormat2(gspca_dev, 0x39, 0x00);
1746
1747 for (i = 0; i < cit_model1_ntries; i++)
1748 cit_Packet_Format1(gspca_dev, 0x00, 0x18);
1749 for (i = 0; i < cit_model1_ntries; i++)
1750 cit_Packet_Format1(gspca_dev, 0x13, 0x18);
1751 for (i = 0; i < cit_model1_ntries; i++)
1752 cit_Packet_Format1(gspca_dev, 0x14, 0x06);
1753
1754 /* TESTME These are handled through controls
1755 KEEP until someone can test leaving this out is ok */
1756 if (0) {
1757 /* This is default brightness */
1758 for (i = 0; i < cit_model1_ntries; i++)
1759 cit_Packet_Format1(gspca_dev, 0x31, 0x37);
1760 for (i = 0; i < cit_model1_ntries; i++)
1761 cit_Packet_Format1(gspca_dev, 0x32, 0x46);
1762 for (i = 0; i < cit_model1_ntries; i++)
1763 cit_Packet_Format1(gspca_dev, 0x33, 0x55);
1764 }
1765
1766 cit_Packet_Format1(gspca_dev, 0x2e, 0x04);
1767 for (i = 0; i < cit_model1_ntries; i++)
1768 cit_Packet_Format1(gspca_dev, 0x2d, 0x04);
1769 for (i = 0; i < cit_model1_ntries; i++)
1770 cit_Packet_Format1(gspca_dev, 0x29, 0x80);
1771 cit_Packet_Format1(gspca_dev, 0x2c, 0x01);
1772 cit_Packet_Format1(gspca_dev, 0x30, 0x17);
1773 cit_Packet_Format1(gspca_dev, 0x39, 0x08);
1774 for (i = 0; i < cit_model1_ntries; i++)
1775 cit_Packet_Format1(gspca_dev, 0x34, 0x00);
1776
1777 cit_write_reg(gspca_dev, 0x00, 0x0101);
1778 cit_write_reg(gspca_dev, 0x00, 0x010a);
1779
1780 switch (gspca_dev->width) {
1781 case 128: /* 128x96 */
1782 cit_write_reg(gspca_dev, 0x80, 0x0103);
1783 cit_write_reg(gspca_dev, 0x60, 0x0105);
1784 cit_write_reg(gspca_dev, 0x0c, 0x010b);
1785 cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */
1786 cit_write_reg(gspca_dev, 0x0b, 0x011d);
1787 cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */
1788 cit_write_reg(gspca_dev, 0x00, 0x0129);
1789 break;
1790 case 176: /* 176x144 */
1791 cit_write_reg(gspca_dev, 0xb0, 0x0103);
1792 cit_write_reg(gspca_dev, 0x8f, 0x0105);
1793 cit_write_reg(gspca_dev, 0x06, 0x010b);
1794 cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */
1795 cit_write_reg(gspca_dev, 0x0d, 0x011d);
1796 cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */
1797 cit_write_reg(gspca_dev, 0x03, 0x0129);
1798 break;
1799 case 352: /* 352x288 */
1800 cit_write_reg(gspca_dev, 0xb0, 0x0103);
1801 cit_write_reg(gspca_dev, 0x90, 0x0105);
1802 cit_write_reg(gspca_dev, 0x02, 0x010b);
1803 cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */
1804 cit_write_reg(gspca_dev, 0x05, 0x011d);
1805 cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */
1806 cit_write_reg(gspca_dev, 0x00, 0x0129);
1807 break;
1808 }
1809
1810 cit_write_reg(gspca_dev, 0xff, 0x012b);
1811
1812 /* TESTME These are handled through controls
1813 KEEP until someone can test leaving this out is ok */
1814 if (0) {
1815 /* This is another brightness - don't know why */
1816 for (i = 0; i < cit_model1_ntries; i++)
1817 cit_Packet_Format1(gspca_dev, 0x31, 0xc3);
1818 for (i = 0; i < cit_model1_ntries; i++)
1819 cit_Packet_Format1(gspca_dev, 0x32, 0xd2);
1820 for (i = 0; i < cit_model1_ntries; i++)
1821 cit_Packet_Format1(gspca_dev, 0x33, 0xe1);
1822
1823 /* Default contrast */
1824 for (i = 0; i < cit_model1_ntries; i++)
1825 cit_Packet_Format1(gspca_dev, 0x14, 0x0a);
1826
1827 /* Default sharpness */
1828 for (i = 0; i < cit_model1_ntries2; i++)
1829 cit_PacketFormat2(gspca_dev, 0x13, 0x1a);
1830
1831 /* Default lighting conditions */
1832 cit_Packet_Format1(gspca_dev, 0x0027, sd->lighting);
1833 }
1834
1835 /* Assorted init */
1836 switch (gspca_dev->width) {
1837 case 128: /* 128x96 */
1838 cit_Packet_Format1(gspca_dev, 0x2b, 0x1e);
1839 cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */
1840 cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */
1841 cit_write_reg(gspca_dev, 0x36, 0x0102);
1842 cit_write_reg(gspca_dev, 0x1a, 0x0104);
1843 cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */
1844 cit_write_reg(gspca_dev, 0x2b, 0x011c);
1845 cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */
1846 break;
1847 case 176: /* 176x144 */
1848 cit_Packet_Format1(gspca_dev, 0x2b, 0x1e);
1849 cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */
1850 cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */
1851 cit_write_reg(gspca_dev, 0x04, 0x0102);
1852 cit_write_reg(gspca_dev, 0x02, 0x0104);
1853 cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */
1854 cit_write_reg(gspca_dev, 0x2b, 0x011c);
1855 cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */
1856 break;
1857 case 352: /* 352x288 */
1858 cit_Packet_Format1(gspca_dev, 0x2b, 0x1f);
1859 cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */
1860 cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */
1861 cit_write_reg(gspca_dev, 0x08, 0x0102);
1862 cit_write_reg(gspca_dev, 0x01, 0x0104);
1863 cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */
1864 cit_write_reg(gspca_dev, 0x2f, 0x011c);
1865 cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */
1866 break;
1867 }
1868
1869 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */
1870 cit_write_reg(gspca_dev, clock_div, 0x0111);
1871
1872 return 0;
1873}
1874
1875static int cit_start_model2(struct gspca_dev *gspca_dev)
1876{
1877 struct sd *sd = (struct sd *) gspca_dev;
1878 int clock_div = 0;
1879
1880 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */
1881 cit_read_reg(gspca_dev, 0x0116);
1882 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1883 cit_write_reg(gspca_dev, 0x0002, 0x0112);
1884 cit_write_reg(gspca_dev, 0x00bc, 0x012c);
1885 cit_write_reg(gspca_dev, 0x0008, 0x012b);
1886 cit_write_reg(gspca_dev, 0x0000, 0x0108);
1887 cit_write_reg(gspca_dev, 0x0001, 0x0133);
1888 cit_write_reg(gspca_dev, 0x0001, 0x0102);
1889 switch (gspca_dev->width) {
1890 case 176: /* 176x144 */
1891 cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */
1892 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */
1893 cit_write_reg(gspca_dev, 0x0024, 0x0105); /* 176x144, 352x288 */
1894 cit_write_reg(gspca_dev, 0x00b9, 0x010a); /* Unique to this mode */
1895 cit_write_reg(gspca_dev, 0x0038, 0x0119); /* Unique to this mode */
1896 /* TESTME HDG: this does not seem right
1897 (it is 2 for all other resolutions) */
1898 sd->sof_len = 10;
1899 break;
1900 case 320: /* 320x240 */
1901 cit_write_reg(gspca_dev, 0x0028, 0x0103); /* Unique to this mode */
1902 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */
1903 cit_write_reg(gspca_dev, 0x001e, 0x0105); /* 320x240, 352x240 */
1904 cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */
1905 cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */
1906 sd->sof_len = 2;
1907 break;
1908 /* case VIDEOSIZE_352x240: */
1909 cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */
1910 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */
1911 cit_write_reg(gspca_dev, 0x001e, 0x0105); /* 320x240, 352x240 */
1912 cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */
1913 cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */
1914 sd->sof_len = 2;
1915 break;
1916 case 352: /* 352x288 */
1917 cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */
1918 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */
1919 cit_write_reg(gspca_dev, 0x0024, 0x0105); /* 176x144, 352x288 */
1920 cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */
1921 cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */
1922 sd->sof_len = 2;
1923 break;
1924 }
1925
1926 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */
1927
1928 switch (gspca_dev->width) {
1929 case 176: /* 176x144 */
1930 cit_write_reg(gspca_dev, 0x0050, 0x0111);
1931 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
1932 break;
1933 case 320: /* 320x240 */
1934 case 352: /* 352x288 */
1935 cit_write_reg(gspca_dev, 0x0040, 0x0111);
1936 cit_write_reg(gspca_dev, 0x00c0, 0x0111);
1937 break;
1938 }
1939 cit_write_reg(gspca_dev, 0x009b, 0x010f);
1940 cit_write_reg(gspca_dev, 0x00bb, 0x010f);
1941
1942 /*
1943 * Hardware settings, may affect CMOS sensor; not user controls!
1944 * -------------------------------------------------------------
1945 * 0x0004: no effect
1946 * 0x0006: hardware effect
1947 * 0x0008: no effect
1948 * 0x000a: stops video stream, probably important h/w setting
1949 * 0x000c: changes color in hardware manner (not user setting)
1950 * 0x0012: changes number of colors (does not affect speed)
1951 * 0x002a: no effect
1952 * 0x002c: hardware setting (related to scan lines)
1953 * 0x002e: stops video stream, probably important h/w setting
1954 */
1955 cit_model2_Packet1(gspca_dev, 0x000a, 0x005c);
1956 cit_model2_Packet1(gspca_dev, 0x0004, 0x0000);
1957 cit_model2_Packet1(gspca_dev, 0x0006, 0x00fb);
1958 cit_model2_Packet1(gspca_dev, 0x0008, 0x0000);
1959 cit_model2_Packet1(gspca_dev, 0x000c, 0x0009);
1960 cit_model2_Packet1(gspca_dev, 0x0012, 0x000a);
1961 cit_model2_Packet1(gspca_dev, 0x002a, 0x0000);
1962 cit_model2_Packet1(gspca_dev, 0x002c, 0x0000);
1963 cit_model2_Packet1(gspca_dev, 0x002e, 0x0008);
1964
1965 /*
1966 * Function 0x0030 pops up all over the place. Apparently
1967 * it is a hardware control register, with every bit assigned to
1968 * do something.
1969 */
1970 cit_model2_Packet1(gspca_dev, 0x0030, 0x0000);
1971
1972 /*
1973 * Magic control of CMOS sensor. Only lower values like
1974 * 0-3 work, and picture shifts left or right. Don't change.
1975 */
1976 switch (gspca_dev->width) {
1977 case 176: /* 176x144 */
1978 cit_model2_Packet1(gspca_dev, 0x0014, 0x0002);
1979 cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */
1980 cit_model2_Packet1(gspca_dev, 0x0018, 0x004a); /* Another hardware setting */
1981 clock_div = 6;
1982 break;
1983 case 320: /* 320x240 */
1984 cit_model2_Packet1(gspca_dev, 0x0014, 0x0009);
1985 cit_model2_Packet1(gspca_dev, 0x0016, 0x0005); /* Horizontal shift */
1986 cit_model2_Packet1(gspca_dev, 0x0018, 0x0044); /* Another hardware setting */
1987 clock_div = 8;
1988 break;
1989 /* case VIDEOSIZE_352x240: */
1990 /* This mode doesn't work as Windows programs it; changed to work */
1991 cit_model2_Packet1(gspca_dev, 0x0014, 0x0009); /* Windows sets this to 8 */
1992 cit_model2_Packet1(gspca_dev, 0x0016, 0x0003); /* Horizontal shift */
1993 cit_model2_Packet1(gspca_dev, 0x0018, 0x0044); /* Windows sets this to 0x0045 */
1994 clock_div = 10;
1995 break;
1996 case 352: /* 352x288 */
1997 cit_model2_Packet1(gspca_dev, 0x0014, 0x0003);
1998 cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */
1999 cit_model2_Packet1(gspca_dev, 0x0018, 0x004a); /* Another hardware setting */
2000 clock_div = 16;
2001 break;
2002 }
2003
2004 /* TESTME These are handled through controls
2005 KEEP until someone can test leaving this out is ok */
2006 if (0)
2007 cit_model2_Packet1(gspca_dev, 0x001a, 0x005a);
2008
2009 /*
2010 * We have our own frame rate setting varying from 0 (slowest) to 6
2011 * (fastest). The camera model 2 allows frame rate in range [0..0x1F]
2012 # where 0 is also the slowest setting. However for all practical
2013 # reasons high settings make no sense because USB is not fast enough
2014 # to support high FPS. Be aware that the picture datastream will be
2015 # severely disrupted if you ask for frame rate faster than allowed
2016 # for the video size - see below:
2017 *
2018 * Allowable ranges (obtained experimentally on OHCI, K6-3, 450 MHz):
2019 * -----------------------------------------------------------------
2020 * 176x144: [6..31]
2021 * 320x240: [8..31]
2022 * 352x240: [10..31]
2023 * 352x288: [16..31] I have to raise lower threshold for stability...
2024 *
2025 * As usual, slower FPS provides better sensitivity.
2026 */
2027 cit_model2_Packet1(gspca_dev, 0x001c, clock_div);
2028
2029 /*
2030 * This setting does not visibly affect pictures; left it here
2031 * because it was present in Windows USB data stream. This function
2032 * does not allow arbitrary values and apparently is a bit mask, to
2033 * be activated only at appropriate time. Don't change it randomly!
2034 */
2035 switch (gspca_dev->width) {
2036 case 176: /* 176x144 */
2037 cit_model2_Packet1(gspca_dev, 0x0026, 0x00c2);
2038 break;
2039 case 320: /* 320x240 */
2040 cit_model2_Packet1(gspca_dev, 0x0026, 0x0044);
2041 break;
2042 /* case VIDEOSIZE_352x240: */
2043 cit_model2_Packet1(gspca_dev, 0x0026, 0x0046);
2044 break;
2045 case 352: /* 352x288 */
2046 cit_model2_Packet1(gspca_dev, 0x0026, 0x0048);
2047 break;
2048 }
2049
2050 /* FIXME this cannot be changed while streaming, so we
2051 should report a grabbed flag for this control. */
2052 cit_model2_Packet1(gspca_dev, 0x0028, sd->lighting);
2053 /* color balance rg2 */
2054 cit_model2_Packet1(gspca_dev, 0x001e, 0x002f);
2055 /* saturation */
2056 cit_model2_Packet1(gspca_dev, 0x0020, 0x0034);
2057 /* color balance yb */
2058 cit_model2_Packet1(gspca_dev, 0x0022, 0x00a0);
2059
2060 /* Hardware control command */
2061 cit_model2_Packet1(gspca_dev, 0x0030, 0x0004);
2062
2063 return 0;
2064}
2065
2066static int cit_start_model3(struct gspca_dev *gspca_dev)
2067{
2068 const unsigned short compression = 0; /* 0=none, 7=best frame rate */
2069 int i, clock_div = 0;
2070
2071 /* HDG not in ibmcam driver, added to see if it helps with
2072 auto-detecting between model3 and ibm netcamera pro */
2073 cit_read_reg(gspca_dev, 0x128);
2074
2075 cit_write_reg(gspca_dev, 0x0000, 0x0100);
2076 cit_read_reg(gspca_dev, 0x0116);
2077 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2078 cit_write_reg(gspca_dev, 0x0002, 0x0112);
2079 cit_write_reg(gspca_dev, 0x0000, 0x0123);
2080 cit_write_reg(gspca_dev, 0x0001, 0x0117);
2081 cit_write_reg(gspca_dev, 0x0040, 0x0108);
2082 cit_write_reg(gspca_dev, 0x0019, 0x012c);
2083 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2084 cit_write_reg(gspca_dev, 0x0002, 0x0115);
2085 cit_write_reg(gspca_dev, 0x0003, 0x0115);
2086 cit_read_reg(gspca_dev, 0x0115);
2087 cit_write_reg(gspca_dev, 0x000b, 0x0115);
2088
2089 /* TESTME HDG not in ibmcam driver, added to see if it helps with
2090 auto-detecting between model3 and ibm netcamera pro */
2091 if (0) {
2092 cit_write_reg(gspca_dev, 0x0078, 0x012d);
2093 cit_write_reg(gspca_dev, 0x0001, 0x012f);
2094 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2095 cit_write_reg(gspca_dev, 0x0079, 0x012d);
2096 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
2097 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
2098 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2099 cit_read_reg(gspca_dev, 0x0126);
2100 }
2101
2102 cit_model3_Packet1(gspca_dev, 0x000a, 0x0040);
2103 cit_model3_Packet1(gspca_dev, 0x000b, 0x00f6);
2104 cit_model3_Packet1(gspca_dev, 0x000c, 0x0002);
2105 cit_model3_Packet1(gspca_dev, 0x000d, 0x0020);
2106 cit_model3_Packet1(gspca_dev, 0x000e, 0x0033);
2107 cit_model3_Packet1(gspca_dev, 0x000f, 0x0007);
2108 cit_model3_Packet1(gspca_dev, 0x0010, 0x0000);
2109 cit_model3_Packet1(gspca_dev, 0x0011, 0x0070);
2110 cit_model3_Packet1(gspca_dev, 0x0012, 0x0030);
2111 cit_model3_Packet1(gspca_dev, 0x0013, 0x0000);
2112 cit_model3_Packet1(gspca_dev, 0x0014, 0x0001);
2113 cit_model3_Packet1(gspca_dev, 0x0015, 0x0001);
2114 cit_model3_Packet1(gspca_dev, 0x0016, 0x0001);
2115 cit_model3_Packet1(gspca_dev, 0x0017, 0x0001);
2116 cit_model3_Packet1(gspca_dev, 0x0018, 0x0000);
2117 cit_model3_Packet1(gspca_dev, 0x001e, 0x00c3);
2118 cit_model3_Packet1(gspca_dev, 0x0020, 0x0000);
2119 cit_model3_Packet1(gspca_dev, 0x0028, 0x0010);
2120 cit_model3_Packet1(gspca_dev, 0x0029, 0x0054);
2121 cit_model3_Packet1(gspca_dev, 0x002a, 0x0013);
2122 cit_model3_Packet1(gspca_dev, 0x002b, 0x0007);
2123 cit_model3_Packet1(gspca_dev, 0x002d, 0x0028);
2124 cit_model3_Packet1(gspca_dev, 0x002e, 0x0000);
2125 cit_model3_Packet1(gspca_dev, 0x0031, 0x0000);
2126 cit_model3_Packet1(gspca_dev, 0x0032, 0x0000);
2127 cit_model3_Packet1(gspca_dev, 0x0033, 0x0000);
2128 cit_model3_Packet1(gspca_dev, 0x0034, 0x0000);
2129 cit_model3_Packet1(gspca_dev, 0x0035, 0x0038);
2130 cit_model3_Packet1(gspca_dev, 0x003a, 0x0001);
2131 cit_model3_Packet1(gspca_dev, 0x003c, 0x001e);
2132 cit_model3_Packet1(gspca_dev, 0x003f, 0x000a);
2133 cit_model3_Packet1(gspca_dev, 0x0041, 0x0000);
2134 cit_model3_Packet1(gspca_dev, 0x0046, 0x003f);
2135 cit_model3_Packet1(gspca_dev, 0x0047, 0x0000);
2136 cit_model3_Packet1(gspca_dev, 0x0050, 0x0005);
2137 cit_model3_Packet1(gspca_dev, 0x0052, 0x001a);
2138 cit_model3_Packet1(gspca_dev, 0x0053, 0x0003);
2139 cit_model3_Packet1(gspca_dev, 0x005a, 0x006b);
2140 cit_model3_Packet1(gspca_dev, 0x005d, 0x001e);
2141 cit_model3_Packet1(gspca_dev, 0x005e, 0x0030);
2142 cit_model3_Packet1(gspca_dev, 0x005f, 0x0041);
2143 cit_model3_Packet1(gspca_dev, 0x0064, 0x0008);
2144 cit_model3_Packet1(gspca_dev, 0x0065, 0x0015);
2145 cit_model3_Packet1(gspca_dev, 0x0068, 0x000f);
2146 cit_model3_Packet1(gspca_dev, 0x0079, 0x0000);
2147 cit_model3_Packet1(gspca_dev, 0x007a, 0x0000);
2148 cit_model3_Packet1(gspca_dev, 0x007c, 0x003f);
2149 cit_model3_Packet1(gspca_dev, 0x0082, 0x000f);
2150 cit_model3_Packet1(gspca_dev, 0x0085, 0x0000);
2151 cit_model3_Packet1(gspca_dev, 0x0099, 0x0000);
2152 cit_model3_Packet1(gspca_dev, 0x009b, 0x0023);
2153 cit_model3_Packet1(gspca_dev, 0x009c, 0x0022);
2154 cit_model3_Packet1(gspca_dev, 0x009d, 0x0096);
2155 cit_model3_Packet1(gspca_dev, 0x009e, 0x0096);
2156 cit_model3_Packet1(gspca_dev, 0x009f, 0x000a);
2157
2158 switch (gspca_dev->width) {
2159 case 160:
2160 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2161 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2162 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2163 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
2164 cit_write_reg(gspca_dev, 0x0024, 0x010b); /* Differs everywhere */
2165 cit_write_reg(gspca_dev, 0x00a9, 0x0119);
2166 cit_write_reg(gspca_dev, 0x0016, 0x011b);
2167 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
2168 cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
2169 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
2170 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
2171 cit_write_reg(gspca_dev, 0x0018, 0x0102);
2172 cit_write_reg(gspca_dev, 0x0004, 0x0104);
2173 cit_write_reg(gspca_dev, 0x0004, 0x011a);
2174 cit_write_reg(gspca_dev, 0x0028, 0x011c);
2175 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
2176 cit_write_reg(gspca_dev, 0x0000, 0x0118);
2177 cit_write_reg(gspca_dev, 0x0000, 0x0132);
2178 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
2179 cit_write_reg(gspca_dev, compression, 0x0109);
2180 clock_div = 3;
2181 break;
2182 case 320:
2183 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2184 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2185 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2186 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
2187 cit_write_reg(gspca_dev, 0x0028, 0x010b); /* Differs everywhere */
2188 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same */
2189 cit_write_reg(gspca_dev, 0x0000, 0x011e);
2190 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
2191 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
2192 /* 4 commands from 160x120 skipped */
2193 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
2194 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
2195 cit_write_reg(gspca_dev, compression, 0x0109);
2196 cit_write_reg(gspca_dev, 0x00d9, 0x0119);
2197 cit_write_reg(gspca_dev, 0x0006, 0x011b);
2198 cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
2199 cit_write_reg(gspca_dev, 0x0010, 0x0104);
2200 cit_write_reg(gspca_dev, 0x0004, 0x011a);
2201 cit_write_reg(gspca_dev, 0x003f, 0x011c);
2202 cit_write_reg(gspca_dev, 0x001c, 0x0118);
2203 cit_write_reg(gspca_dev, 0x0000, 0x0132);
2204 clock_div = 5;
2205 break;
2206 case 640:
2207 cit_write_reg(gspca_dev, 0x00f0, 0x0105);
2208 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
2209 cit_write_reg(gspca_dev, 0x0038, 0x010b); /* Differs everywhere */
2210 cit_write_reg(gspca_dev, 0x00d9, 0x0119); /* Same on 320x240, 640x480 */
2211 cit_write_reg(gspca_dev, 0x0006, 0x011b); /* Same on 320x240, 640x480 */
2212 cit_write_reg(gspca_dev, 0x0004, 0x011d); /* NC */
2213 cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
2214 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
2215 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
2216 cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
2217 cit_write_reg(gspca_dev, 0x0016, 0x0104); /* NC */
2218 cit_write_reg(gspca_dev, 0x0004, 0x011a); /* Same on 320x240, 640x480 */
2219 cit_write_reg(gspca_dev, 0x003f, 0x011c); /* Same on 320x240, 640x480 */
2220 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
2221 cit_write_reg(gspca_dev, 0x001c, 0x0118); /* Same on 320x240, 640x480 */
2222 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
2223 cit_write_reg(gspca_dev, compression, 0x0109);
2224 cit_write_reg(gspca_dev, 0x0040, 0x0101);
2225 cit_write_reg(gspca_dev, 0x0040, 0x0103);
2226 cit_write_reg(gspca_dev, 0x0000, 0x0132); /* Same on 320x240, 640x480 */
2227 clock_div = 7;
2228 break;
2229 }
2230
2231 cit_model3_Packet1(gspca_dev, 0x007e, 0x000e); /* Hue */
2232 cit_model3_Packet1(gspca_dev, 0x0036, 0x0011); /* Brightness */
2233 cit_model3_Packet1(gspca_dev, 0x0060, 0x0002); /* Sharpness */
2234 cit_model3_Packet1(gspca_dev, 0x0061, 0x0004); /* Sharpness */
2235 cit_model3_Packet1(gspca_dev, 0x0062, 0x0005); /* Sharpness */
2236 cit_model3_Packet1(gspca_dev, 0x0063, 0x0014); /* Sharpness */
2237 cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */
2238 cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */
2239 cit_model3_Packet1(gspca_dev, 0x0067, 0x0001); /* Contrast */
2240 cit_model3_Packet1(gspca_dev, 0x005b, 0x000c); /* Contrast */
2241 cit_model3_Packet1(gspca_dev, 0x005c, 0x0016); /* Contrast */
2242 cit_model3_Packet1(gspca_dev, 0x0098, 0x000b);
2243 cit_model3_Packet1(gspca_dev, 0x002c, 0x0003); /* Was 1, broke 640x480 */
2244 cit_model3_Packet1(gspca_dev, 0x002f, 0x002a);
2245 cit_model3_Packet1(gspca_dev, 0x0030, 0x0029);
2246 cit_model3_Packet1(gspca_dev, 0x0037, 0x0002);
2247 cit_model3_Packet1(gspca_dev, 0x0038, 0x0059);
2248 cit_model3_Packet1(gspca_dev, 0x003d, 0x002e);
2249 cit_model3_Packet1(gspca_dev, 0x003e, 0x0028);
2250 cit_model3_Packet1(gspca_dev, 0x0078, 0x0005);
2251 cit_model3_Packet1(gspca_dev, 0x007b, 0x0011);
2252 cit_model3_Packet1(gspca_dev, 0x007d, 0x004b);
2253 cit_model3_Packet1(gspca_dev, 0x007f, 0x0022);
2254 cit_model3_Packet1(gspca_dev, 0x0080, 0x000c);
2255 cit_model3_Packet1(gspca_dev, 0x0081, 0x000b);
2256 cit_model3_Packet1(gspca_dev, 0x0083, 0x00fd);
2257 cit_model3_Packet1(gspca_dev, 0x0086, 0x000b);
2258 cit_model3_Packet1(gspca_dev, 0x0087, 0x000b);
2259 cit_model3_Packet1(gspca_dev, 0x007e, 0x000e);
2260 cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */
2261 cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */
2262 cit_model3_Packet1(gspca_dev, 0x0098, 0x000b);
2263
2264 /* FIXME we should probably use cit_get_clock_div() here (in
2265 combination with isoc negotiation using the programmable isoc size)
2266 like with the IBM netcam pro). */
2267 cit_write_reg(gspca_dev, clock_div, 0x0111); /* Clock Divider */
2268
2269 switch (gspca_dev->width) {
2270 case 160:
2271 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */
2272 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */
2273 cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */
2274 cit_model3_Packet1(gspca_dev, 0x0040, 0x000a);
2275 cit_model3_Packet1(gspca_dev, 0x0051, 0x000a);
2276 break;
2277 case 320:
2278 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */
2279 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */
2280 cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */
2281 cit_model3_Packet1(gspca_dev, 0x0040, 0x0008);
2282 cit_model3_Packet1(gspca_dev, 0x0051, 0x000b);
2283 break;
2284 case 640:
2285 cit_model3_Packet1(gspca_dev, 0x001f, 0x0002); /* !Same */
2286 cit_model3_Packet1(gspca_dev, 0x0039, 0x003e); /* !Same */
2287 cit_model3_Packet1(gspca_dev, 0x0040, 0x0008);
2288 cit_model3_Packet1(gspca_dev, 0x0051, 0x000a);
2289 break;
2290 }
2291
2292/* if (sd->input_index) { */
2293 if (rca_input) {
2294 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
2295 if (rca_initdata[i][0])
2296 cit_read_reg(gspca_dev, rca_initdata[i][2]);
2297 else
2298 cit_write_reg(gspca_dev, rca_initdata[i][1],
2299 rca_initdata[i][2]);
2300 }
2301 }
2302
2303 return 0;
2304}
2305
2306static int cit_start_model4(struct gspca_dev *gspca_dev)
2307{
2308 struct sd *sd = (struct sd *) gspca_dev;
2309
2310 cit_write_reg(gspca_dev, 0x0000, 0x0100);
2311 cit_write_reg(gspca_dev, 0x00c0, 0x0111);
2312 cit_write_reg(gspca_dev, 0x00bc, 0x012c);
2313 cit_write_reg(gspca_dev, 0x0080, 0x012b);
2314 cit_write_reg(gspca_dev, 0x0000, 0x0108);
2315 cit_write_reg(gspca_dev, 0x0001, 0x0133);
2316 cit_write_reg(gspca_dev, 0x009b, 0x010f);
2317 cit_write_reg(gspca_dev, 0x00bb, 0x010f);
2318 cit_model4_Packet1(gspca_dev, 0x0038, 0x0000);
2319 cit_model4_Packet1(gspca_dev, 0x000a, 0x005c);
2320
2321 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2322 cit_write_reg(gspca_dev, 0x0004, 0x012f);
2323 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2324 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2325 cit_write_reg(gspca_dev, 0x00fb, 0x012e);
2326 cit_write_reg(gspca_dev, 0x0000, 0x0130);
2327 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2328 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2329 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2330 cit_write_reg(gspca_dev, 0x000c, 0x0127);
2331 cit_write_reg(gspca_dev, 0x0009, 0x012e);
2332 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2333
2334 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2335 cit_write_reg(gspca_dev, 0x0012, 0x012f);
2336 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2337 cit_write_reg(gspca_dev, 0x0008, 0x0127);
2338 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2339 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2340 cit_write_reg(gspca_dev, 0x002a, 0x012d);
2341 cit_write_reg(gspca_dev, 0x0000, 0x012f);
2342 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2343 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2344 cit_model4_Packet1(gspca_dev, 0x0034, 0x0000);
2345
2346 switch (gspca_dev->width) {
2347 case 128: /* 128x96 */
2348 cit_write_reg(gspca_dev, 0x0070, 0x0119);
2349 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
2350 cit_write_reg(gspca_dev, 0x0039, 0x010a);
2351 cit_write_reg(gspca_dev, 0x0001, 0x0102);
2352 cit_write_reg(gspca_dev, 0x0028, 0x0103);
2353 cit_write_reg(gspca_dev, 0x0000, 0x0104);
2354 cit_write_reg(gspca_dev, 0x001e, 0x0105);
2355 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2356 cit_write_reg(gspca_dev, 0x0016, 0x012f);
2357 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2358 cit_write_reg(gspca_dev, 0x000a, 0x0127);
2359 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2360 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2361 cit_write_reg(gspca_dev, 0x0014, 0x012d);
2362 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2363 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2364 cit_write_reg(gspca_dev, 0x00aa, 0x012e);
2365 cit_write_reg(gspca_dev, 0x001a, 0x0130);
2366 cit_write_reg(gspca_dev, 0x8a0a, 0x0124);
2367 cit_write_reg(gspca_dev, 0x005a, 0x012d);
2368 cit_write_reg(gspca_dev, 0x9545, 0x0124);
2369 cit_write_reg(gspca_dev, 0x00aa, 0x0127);
2370 cit_write_reg(gspca_dev, 0x0018, 0x012e);
2371 cit_write_reg(gspca_dev, 0x0043, 0x0130);
2372 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2373 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2374 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2375 cit_write_reg(gspca_dev, 0x001c, 0x0127);
2376 cit_write_reg(gspca_dev, 0x00eb, 0x012e);
2377 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2378 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2379 cit_write_reg(gspca_dev, 0x0032, 0x012f);
2380 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2381 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2382 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2383 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2384 cit_write_reg(gspca_dev, 0x0036, 0x012d);
2385 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2386 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2387 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2388 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2389 cit_write_reg(gspca_dev, 0x001e, 0x012f);
2390 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2391 cit_write_reg(gspca_dev, 0x0017, 0x0127);
2392 cit_write_reg(gspca_dev, 0x0013, 0x012e);
2393 cit_write_reg(gspca_dev, 0x0031, 0x0130);
2394 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2395 cit_write_reg(gspca_dev, 0x0017, 0x012d);
2396 cit_write_reg(gspca_dev, 0x0078, 0x012f);
2397 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2398 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2399 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
2400 sd->sof_len = 2;
2401 break;
2402 case 160: /* 160x120 */
2403 cit_write_reg(gspca_dev, 0x0038, 0x0119);
2404 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
2405 cit_write_reg(gspca_dev, 0x00b9, 0x010a);
2406 cit_write_reg(gspca_dev, 0x0001, 0x0102);
2407 cit_write_reg(gspca_dev, 0x0028, 0x0103);
2408 cit_write_reg(gspca_dev, 0x0000, 0x0104);
2409 cit_write_reg(gspca_dev, 0x001e, 0x0105);
2410 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2411 cit_write_reg(gspca_dev, 0x0016, 0x012f);
2412 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2413 cit_write_reg(gspca_dev, 0x000b, 0x0127);
2414 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2415 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2416 cit_write_reg(gspca_dev, 0x0014, 0x012d);
2417 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2418 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2419 cit_write_reg(gspca_dev, 0x00aa, 0x012e);
2420 cit_write_reg(gspca_dev, 0x001a, 0x0130);
2421 cit_write_reg(gspca_dev, 0x8a0a, 0x0124);
2422 cit_write_reg(gspca_dev, 0x005a, 0x012d);
2423 cit_write_reg(gspca_dev, 0x9545, 0x0124);
2424 cit_write_reg(gspca_dev, 0x00aa, 0x0127);
2425 cit_write_reg(gspca_dev, 0x0018, 0x012e);
2426 cit_write_reg(gspca_dev, 0x0043, 0x0130);
2427 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2428 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2429 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2430 cit_write_reg(gspca_dev, 0x001c, 0x0127);
2431 cit_write_reg(gspca_dev, 0x00c7, 0x012e);
2432 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2433 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2434 cit_write_reg(gspca_dev, 0x0032, 0x012f);
2435 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2436 cit_write_reg(gspca_dev, 0x0025, 0x0127);
2437 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2438 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2439 cit_write_reg(gspca_dev, 0x0036, 0x012d);
2440 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2441 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2442 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2443 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2444 cit_write_reg(gspca_dev, 0x001e, 0x012f);
2445 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2446 cit_write_reg(gspca_dev, 0x0048, 0x0127);
2447 cit_write_reg(gspca_dev, 0x0035, 0x012e);
2448 cit_write_reg(gspca_dev, 0x00d0, 0x0130);
2449 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2450 cit_write_reg(gspca_dev, 0x0048, 0x012d);
2451 cit_write_reg(gspca_dev, 0x0090, 0x012f);
2452 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2453 cit_write_reg(gspca_dev, 0x0001, 0x0127);
2454 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
2455 sd->sof_len = 2;
2456 break;
2457 case 176: /* 176x144 */
2458 cit_write_reg(gspca_dev, 0x0038, 0x0119);
2459 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
2460 cit_write_reg(gspca_dev, 0x00b9, 0x010a);
2461 cit_write_reg(gspca_dev, 0x0001, 0x0102);
2462 cit_write_reg(gspca_dev, 0x002c, 0x0103);
2463 cit_write_reg(gspca_dev, 0x0000, 0x0104);
2464 cit_write_reg(gspca_dev, 0x0024, 0x0105);
2465 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2466 cit_write_reg(gspca_dev, 0x0016, 0x012f);
2467 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2468 cit_write_reg(gspca_dev, 0x0007, 0x0127);
2469 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2470 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2471 cit_write_reg(gspca_dev, 0x0014, 0x012d);
2472 cit_write_reg(gspca_dev, 0x0001, 0x012f);
2473 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2474 cit_write_reg(gspca_dev, 0x00aa, 0x012e);
2475 cit_write_reg(gspca_dev, 0x001a, 0x0130);
2476 cit_write_reg(gspca_dev, 0x8a0a, 0x0124);
2477 cit_write_reg(gspca_dev, 0x005e, 0x012d);
2478 cit_write_reg(gspca_dev, 0x9545, 0x0124);
2479 cit_write_reg(gspca_dev, 0x00aa, 0x0127);
2480 cit_write_reg(gspca_dev, 0x0018, 0x012e);
2481 cit_write_reg(gspca_dev, 0x0049, 0x0130);
2482 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2483 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2484 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2485 cit_write_reg(gspca_dev, 0x001c, 0x0127);
2486 cit_write_reg(gspca_dev, 0x00c7, 0x012e);
2487 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2488 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2489 cit_write_reg(gspca_dev, 0x0032, 0x012f);
2490 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2491 cit_write_reg(gspca_dev, 0x0028, 0x0127);
2492 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2493 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2494 cit_write_reg(gspca_dev, 0x0036, 0x012d);
2495 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2496 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2497 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2498 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2499 cit_write_reg(gspca_dev, 0x001e, 0x012f);
2500 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2501 cit_write_reg(gspca_dev, 0x0010, 0x0127);
2502 cit_write_reg(gspca_dev, 0x0013, 0x012e);
2503 cit_write_reg(gspca_dev, 0x002a, 0x0130);
2504 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2505 cit_write_reg(gspca_dev, 0x0010, 0x012d);
2506 cit_write_reg(gspca_dev, 0x006d, 0x012f);
2507 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2508 cit_write_reg(gspca_dev, 0x0001, 0x0127);
2509 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
2510 /* TESTME HDG: this does not seem right
2511 (it is 2 for all other resolutions) */
2512 sd->sof_len = 10;
2513 break;
2514 case 320: /* 320x240 */
2515 cit_write_reg(gspca_dev, 0x0070, 0x0119);
2516 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
2517 cit_write_reg(gspca_dev, 0x0039, 0x010a);
2518 cit_write_reg(gspca_dev, 0x0001, 0x0102);
2519 cit_write_reg(gspca_dev, 0x0028, 0x0103);
2520 cit_write_reg(gspca_dev, 0x0000, 0x0104);
2521 cit_write_reg(gspca_dev, 0x001e, 0x0105);
2522 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2523 cit_write_reg(gspca_dev, 0x0016, 0x012f);
2524 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2525 cit_write_reg(gspca_dev, 0x000a, 0x0127);
2526 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2527 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2528 cit_write_reg(gspca_dev, 0x0014, 0x012d);
2529 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2530 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2531 cit_write_reg(gspca_dev, 0x00aa, 0x012e);
2532 cit_write_reg(gspca_dev, 0x001a, 0x0130);
2533 cit_write_reg(gspca_dev, 0x8a0a, 0x0124);
2534 cit_write_reg(gspca_dev, 0x005a, 0x012d);
2535 cit_write_reg(gspca_dev, 0x9545, 0x0124);
2536 cit_write_reg(gspca_dev, 0x00aa, 0x0127);
2537 cit_write_reg(gspca_dev, 0x0018, 0x012e);
2538 cit_write_reg(gspca_dev, 0x0043, 0x0130);
2539 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2540 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2541 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2542 cit_write_reg(gspca_dev, 0x001c, 0x0127);
2543 cit_write_reg(gspca_dev, 0x00eb, 0x012e);
2544 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2545 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2546 cit_write_reg(gspca_dev, 0x0032, 0x012f);
2547 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2548 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2549 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2550 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2551 cit_write_reg(gspca_dev, 0x0036, 0x012d);
2552 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2553 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2554 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2555 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2556 cit_write_reg(gspca_dev, 0x001e, 0x012f);
2557 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2558 cit_write_reg(gspca_dev, 0x0017, 0x0127);
2559 cit_write_reg(gspca_dev, 0x0013, 0x012e);
2560 cit_write_reg(gspca_dev, 0x0031, 0x0130);
2561 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2562 cit_write_reg(gspca_dev, 0x0017, 0x012d);
2563 cit_write_reg(gspca_dev, 0x0078, 0x012f);
2564 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2565 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2566 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
2567 sd->sof_len = 2;
2568 break;
2569 case 352: /* 352x288 */
2570 cit_write_reg(gspca_dev, 0x0070, 0x0119);
2571 cit_write_reg(gspca_dev, 0x00c0, 0x0111);
2572 cit_write_reg(gspca_dev, 0x0039, 0x010a);
2573 cit_write_reg(gspca_dev, 0x0001, 0x0102);
2574 cit_write_reg(gspca_dev, 0x002c, 0x0103);
2575 cit_write_reg(gspca_dev, 0x0000, 0x0104);
2576 cit_write_reg(gspca_dev, 0x0024, 0x0105);
2577 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2578 cit_write_reg(gspca_dev, 0x0016, 0x012f);
2579 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2580 cit_write_reg(gspca_dev, 0x0006, 0x0127);
2581 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2582 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2583 cit_write_reg(gspca_dev, 0x0014, 0x012d);
2584 cit_write_reg(gspca_dev, 0x0002, 0x012f);
2585 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2586 cit_write_reg(gspca_dev, 0x00aa, 0x012e);
2587 cit_write_reg(gspca_dev, 0x001a, 0x0130);
2588 cit_write_reg(gspca_dev, 0x8a0a, 0x0124);
2589 cit_write_reg(gspca_dev, 0x005e, 0x012d);
2590 cit_write_reg(gspca_dev, 0x9545, 0x0124);
2591 cit_write_reg(gspca_dev, 0x00aa, 0x0127);
2592 cit_write_reg(gspca_dev, 0x0018, 0x012e);
2593 cit_write_reg(gspca_dev, 0x0049, 0x0130);
2594 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2595 cit_write_reg(gspca_dev, 0x00aa, 0x012f);
2596 cit_write_reg(gspca_dev, 0xd055, 0x0124);
2597 cit_write_reg(gspca_dev, 0x001c, 0x0127);
2598 cit_write_reg(gspca_dev, 0x00cf, 0x012e);
2599 cit_write_reg(gspca_dev, 0xaa28, 0x0124);
2600 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2601 cit_write_reg(gspca_dev, 0x0032, 0x012f);
2602 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2603 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2604 cit_write_reg(gspca_dev, 0x00aa, 0x0130);
2605 cit_write_reg(gspca_dev, 0x82a8, 0x0124);
2606 cit_write_reg(gspca_dev, 0x0036, 0x012d);
2607 cit_write_reg(gspca_dev, 0x0008, 0x012f);
2608 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2609 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2610 cit_write_reg(gspca_dev, 0x00aa, 0x012d);
2611 cit_write_reg(gspca_dev, 0x001e, 0x012f);
2612 cit_write_reg(gspca_dev, 0xd141, 0x0124);
2613 cit_write_reg(gspca_dev, 0x0010, 0x0127);
2614 cit_write_reg(gspca_dev, 0x0013, 0x012e);
2615 cit_write_reg(gspca_dev, 0x0025, 0x0130);
2616 cit_write_reg(gspca_dev, 0x8a28, 0x0124);
2617 cit_write_reg(gspca_dev, 0x0010, 0x012d);
2618 cit_write_reg(gspca_dev, 0x0048, 0x012f);
2619 cit_write_reg(gspca_dev, 0xd145, 0x0124);
2620 cit_write_reg(gspca_dev, 0x0000, 0x0127);
2621 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
2622 sd->sof_len = 2;
2623 break;
2624 }
2625
2626 cit_model4_Packet1(gspca_dev, 0x0038, 0x0004);
2627
2628 return 0;
2629}
2630
2631static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev)
2632{
2633 const unsigned short compression = 0; /* 0=none, 7=best frame rate */
2634 int i, clock_div;
2635
2636 clock_div = cit_get_clock_div(gspca_dev);
2637 if (clock_div < 0)
2638 return clock_div;
2639
2640 cit_write_reg(gspca_dev, 0x0003, 0x0133);
2641 cit_write_reg(gspca_dev, 0x0000, 0x0117);
2642 cit_write_reg(gspca_dev, 0x0008, 0x0123);
2643 cit_write_reg(gspca_dev, 0x0000, 0x0100);
2644 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2645 /* cit_write_reg(gspca_dev, 0x0002, 0x0112); see sd_stop0 */
2646 cit_write_reg(gspca_dev, 0x0000, 0x0133);
2647 cit_write_reg(gspca_dev, 0x0000, 0x0123);
2648 cit_write_reg(gspca_dev, 0x0001, 0x0117);
2649 cit_write_reg(gspca_dev, 0x0040, 0x0108);
2650 cit_write_reg(gspca_dev, 0x0019, 0x012c);
2651 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2652 /* cit_write_reg(gspca_dev, 0x000b, 0x0115); see sd_stop0 */
2653
2654 cit_model3_Packet1(gspca_dev, 0x0049, 0x0000);
2655
2656 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2657 cit_write_reg(gspca_dev, 0x003a, 0x0102); /* Hstart */
2658 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2659 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2660 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
2661 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
2662 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
2663 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
2664 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
2665
2666 switch (gspca_dev->width) {
2667 case 160: /* 160x120 */
2668 cit_write_reg(gspca_dev, 0x0024, 0x010b);
2669 cit_write_reg(gspca_dev, 0x0089, 0x0119);
2670 cit_write_reg(gspca_dev, 0x000a, 0x011b);
2671 cit_write_reg(gspca_dev, 0x0003, 0x011e);
2672 cit_write_reg(gspca_dev, 0x0007, 0x0104);
2673 cit_write_reg(gspca_dev, 0x0009, 0x011a);
2674 cit_write_reg(gspca_dev, 0x008b, 0x011c);
2675 cit_write_reg(gspca_dev, 0x0008, 0x0118);
2676 cit_write_reg(gspca_dev, 0x0000, 0x0132);
2677 break;
2678 case 320: /* 320x240 */
2679 cit_write_reg(gspca_dev, 0x0028, 0x010b);
2680 cit_write_reg(gspca_dev, 0x00d9, 0x0119);
2681 cit_write_reg(gspca_dev, 0x0006, 0x011b);
2682 cit_write_reg(gspca_dev, 0x0000, 0x011e);
2683 cit_write_reg(gspca_dev, 0x000e, 0x0104);
2684 cit_write_reg(gspca_dev, 0x0004, 0x011a);
2685 cit_write_reg(gspca_dev, 0x003f, 0x011c);
2686 cit_write_reg(gspca_dev, 0x000c, 0x0118);
2687 cit_write_reg(gspca_dev, 0x0000, 0x0132);
2688 break;
2689 }
2690
2691 cit_model3_Packet1(gspca_dev, 0x0019, 0x0031);
2692 cit_model3_Packet1(gspca_dev, 0x001a, 0x0003);
2693 cit_model3_Packet1(gspca_dev, 0x001b, 0x0038);
2694 cit_model3_Packet1(gspca_dev, 0x001c, 0x0000);
2695 cit_model3_Packet1(gspca_dev, 0x0024, 0x0001);
2696 cit_model3_Packet1(gspca_dev, 0x0027, 0x0001);
2697 cit_model3_Packet1(gspca_dev, 0x002a, 0x0004);
2698 cit_model3_Packet1(gspca_dev, 0x0035, 0x000b);
2699 cit_model3_Packet1(gspca_dev, 0x003f, 0x0001);
2700 cit_model3_Packet1(gspca_dev, 0x0044, 0x0000);
2701 cit_model3_Packet1(gspca_dev, 0x0054, 0x0000);
2702 cit_model3_Packet1(gspca_dev, 0x00c4, 0x0000);
2703 cit_model3_Packet1(gspca_dev, 0x00e7, 0x0001);
2704 cit_model3_Packet1(gspca_dev, 0x00e9, 0x0001);
2705 cit_model3_Packet1(gspca_dev, 0x00ee, 0x0000);
2706 cit_model3_Packet1(gspca_dev, 0x00f3, 0x00c0);
2707
2708 cit_write_reg(gspca_dev, compression, 0x0109);
2709 cit_write_reg(gspca_dev, clock_div, 0x0111);
2710
2711/* if (sd->input_index) { */
2712 if (rca_input) {
2713 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
2714 if (rca_initdata[i][0])
2715 cit_read_reg(gspca_dev, rca_initdata[i][2]);
2716 else
2717 cit_write_reg(gspca_dev, rca_initdata[i][1],
2718 rca_initdata[i][2]);
2719 }
2720 }
2721
2722 return 0;
2723}
2724
2725/* -- start the camera -- */
2726static int sd_start(struct gspca_dev *gspca_dev)
2727{
2728 struct sd *sd = (struct sd *) gspca_dev;
2729 int packet_size;
2730
2731 packet_size = cit_get_packet_size(gspca_dev);
2732 if (packet_size < 0)
2733 return packet_size;
2734
2735 switch (sd->model) {
2736 case CIT_MODEL0:
2737 cit_start_model0(gspca_dev);
2738 break;
2739 case CIT_MODEL1:
2740 cit_start_model1(gspca_dev);
2741 break;
2742 case CIT_MODEL2:
2743 cit_start_model2(gspca_dev);
2744 break;
2745 case CIT_MODEL3:
2746 cit_start_model3(gspca_dev);
2747 break;
2748 case CIT_MODEL4:
2749 cit_start_model4(gspca_dev);
2750 break;
2751 case CIT_IBM_NETCAM_PRO:
2752 cit_start_ibm_netcam_pro(gspca_dev);
2753 break;
2754 }
2755
2756 cit_set_brightness(gspca_dev);
2757 cit_set_contrast(gspca_dev);
2758 cit_set_hue(gspca_dev);
2759 cit_set_sharpness(gspca_dev);
2760 cit_set_lighting(gspca_dev);
2761 cit_set_hflip(gspca_dev);
2762
2763 /* Program max isoc packet size */
2764 cit_write_reg(gspca_dev, packet_size >> 8, 0x0106);
2765 cit_write_reg(gspca_dev, packet_size & 0xff, 0x0107);
2766
2767 cit_restart_stream(gspca_dev);
2768
2769 return 0;
2770}
2771
2772static int sd_isoc_nego(struct gspca_dev *gspca_dev)
2773{
2774 int ret, packet_size;
2775 struct usb_host_interface *alt;
2776
2777 alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1];
2778 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
2779 packet_size -= 100;
2780 if (packet_size < 300)
2781 return -EIO;
2782 alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size);
2783
2784 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
2785 if (ret < 0)
2786 err("set alt 1 err %d", ret);
2787
2788 return ret;
2789}
2790
2791static void sd_stopN(struct gspca_dev *gspca_dev)
2792{
2793 cit_write_reg(gspca_dev, 0x0000, 0x010c);
2794}
2795
2796static void sd_stop0(struct gspca_dev *gspca_dev)
2797{
2798 struct sd *sd = (struct sd *) gspca_dev;
2799 struct usb_host_interface *alt;
2800
2801 /* We cannot use gspca_dev->present here as that is not set when
2802 sd_init gets called and we get called from sd_init */
2803 if (!gspca_dev->dev)
2804 return;
2805
2806 alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1];
2807
2808 switch (sd->model) {
2809 case CIT_MODEL0:
2810 /* HDG windows does this, but it causes the cams autogain to
2811 restart from a gain of 0, which does not look good when
2812 changing resolutions. */
2813 /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */
2814 cit_write_reg(gspca_dev, 0x00c0, 0x0100); /* LED Off */
2815 break;
2816 case CIT_MODEL1:
2817 cit_send_FF_04_02(gspca_dev);
2818 cit_read_reg(gspca_dev, 0x0100);
2819 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */
2820 break;
2821 case CIT_MODEL2:
2822 case CIT_MODEL4:
2823 cit_model2_Packet1(gspca_dev, 0x0030, 0x0004);
2824
2825 cit_write_reg(gspca_dev, 0x0080, 0x0100); /* LED Off */
2826 cit_write_reg(gspca_dev, 0x0020, 0x0111);
2827 cit_write_reg(gspca_dev, 0x00a0, 0x0111);
2828
2829 cit_model2_Packet1(gspca_dev, 0x0030, 0x0002);
2830
2831 cit_write_reg(gspca_dev, 0x0020, 0x0111);
2832 cit_write_reg(gspca_dev, 0x0000, 0x0112);
2833 break;
2834 case CIT_MODEL3:
2835 cit_write_reg(gspca_dev, 0x0006, 0x012c);
2836 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000);
2837 cit_read_reg(gspca_dev, 0x0116);
2838 cit_write_reg(gspca_dev, 0x0064, 0x0116);
2839 cit_read_reg(gspca_dev, 0x0115);
2840 cit_write_reg(gspca_dev, 0x0003, 0x0115);
2841 cit_write_reg(gspca_dev, 0x0008, 0x0123);
2842 cit_write_reg(gspca_dev, 0x0000, 0x0117);
2843 cit_write_reg(gspca_dev, 0x0000, 0x0112);
2844 cit_write_reg(gspca_dev, 0x0080, 0x0100);
2845 break;
2846 case CIT_IBM_NETCAM_PRO:
2847 cit_model3_Packet1(gspca_dev, 0x0049, 0x00ff);
2848 cit_write_reg(gspca_dev, 0x0006, 0x012c);
2849 cit_write_reg(gspca_dev, 0x0000, 0x0116);
2850 /* HDG windows does this, but I cannot get the camera
2851 to restart with this without redoing the entire init
2852 sequence which makes switching modes really slow */
2853 /* cit_write_reg(gspca_dev, 0x0006, 0x0115); */
2854 cit_write_reg(gspca_dev, 0x0008, 0x0123);
2855 cit_write_reg(gspca_dev, 0x0000, 0x0117);
2856 cit_write_reg(gspca_dev, 0x0003, 0x0133);
2857 cit_write_reg(gspca_dev, 0x0000, 0x0111);
2858 /* HDG windows does this, but I get a green picture when
2859 restarting the stream after this */
2860 /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */
2861 cit_write_reg(gspca_dev, 0x00c0, 0x0100);
2862
2863 /* Start isoc bandwidth "negotiation" at max isoc bandwith
2864 next stream start */
2865 alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(1022);
2866 break;
2867 }
2868}
2869
2870static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len)
2871{
2872 struct sd *sd = (struct sd *) gspca_dev;
2873 u8 byte3 = 0, byte4 = 0;
2874 int i;
2875
2876 switch (sd->model) {
2877 case CIT_MODEL0:
2878 case CIT_MODEL1:
2879 case CIT_MODEL3:
2880 case CIT_IBM_NETCAM_PRO:
2881 switch (gspca_dev->width) {
2882 case 160: /* 160x120 */
2883 byte3 = 0x02;
2884 byte4 = 0x0a;
2885 break;
2886 case 176: /* 176x144 */
2887 byte3 = 0x02;
2888 byte4 = 0x0e;
2889 break;
2890 case 320: /* 320x240 */
2891 byte3 = 0x02;
2892 byte4 = 0x08;
2893 break;
2894 case 352: /* 352x288 */
2895 byte3 = 0x02;
2896 byte4 = 0x00;
2897 break;
2898 case 640:
2899 byte3 = 0x03;
2900 byte4 = 0x08;
2901 break;
2902 }
2903
2904 /* These have a different byte3 */
2905 if (sd->model <= CIT_MODEL1)
2906 byte3 = 0x00;
2907
2908 for (i = 0; i < len; i++) {
2909 /* For this model the SOF always starts at offset 0
2910 so no need to search the entire frame */
2911 if (sd->model == CIT_MODEL0 && sd->sof_read != i)
2912 break;
2913
2914 switch (sd->sof_read) {
2915 case 0:
2916 if (data[i] == 0x00)
2917 sd->sof_read++;
2918 break;
2919 case 1:
2920 if (data[i] == 0xff)
2921 sd->sof_read++;
2922 else if (data[i] == 0x00)
2923 sd->sof_read = 1;
2924 else
2925 sd->sof_read = 0;
2926 break;
2927 case 2:
2928 if (data[i] == byte3)
2929 sd->sof_read++;
2930 else if (data[i] == 0x00)
2931 sd->sof_read = 1;
2932 else
2933 sd->sof_read = 0;
2934 break;
2935 case 3:
2936 if (data[i] == byte4) {
2937 sd->sof_read = 0;
2938 return data + i + (sd->sof_len - 3);
2939 }
2940 if (byte3 == 0x00 && data[i] == 0xff)
2941 sd->sof_read = 2;
2942 else if (data[i] == 0x00)
2943 sd->sof_read = 1;
2944 else
2945 sd->sof_read = 0;
2946 break;
2947 }
2948 }
2949 break;
2950 case CIT_MODEL2:
2951 case CIT_MODEL4:
2952 /* TESTME we need to find a longer sof signature to avoid
2953 false positives */
2954 for (i = 0; i < len; i++) {
2955 switch (sd->sof_read) {
2956 case 0:
2957 if (data[i] == 0x00)
2958 sd->sof_read++;
2959 break;
2960 case 1:
2961 sd->sof_read = 0;
2962 if (data[i] == 0xff) {
2963 if (i >= 4)
2964 PDEBUG(D_FRAM,
2965 "header found at offset: %d: %02x %02x 00 %02x %02x %02x\n",
2966 i - 1,
2967 data[i - 4],
2968 data[i - 3],
2969 data[i],
2970 data[i + 1],
2971 data[i + 2]);
2972 else
2973 PDEBUG(D_FRAM,
2974 "header found at offset: %d: 00 %02x %02x %02x\n",
2975 i - 1,
2976 data[i],
2977 data[i + 1],
2978 data[i + 2]);
2979 return data + i + (sd->sof_len - 1);
2980 }
2981 break;
2982 }
2983 }
2984 break;
2985 }
2986 return NULL;
2987}
2988
2989static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2990 u8 *data, int len)
2991{
2992 struct sd *sd = (struct sd *) gspca_dev;
2993 unsigned char *sof;
2994
2995 sof = cit_find_sof(gspca_dev, data, len);
2996 if (sof) {
2997 int n;
2998
2999 /* finish decoding current frame */
3000 n = sof - data;
3001 if (n > sd->sof_len)
3002 n -= sd->sof_len;
3003 else
3004 n = 0;
3005 gspca_frame_add(gspca_dev, LAST_PACKET,
3006 data, n);
3007 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
3008 len -= sof - data;
3009 data = sof;
3010 }
3011
3012 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
3013}
3014
3015static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
3016{
3017 struct sd *sd = (struct sd *) gspca_dev;
3018
3019 sd->brightness = val;
3020 if (gspca_dev->streaming) {
3021 if (sd->stop_on_control_change)
3022 sd_stopN(gspca_dev);
3023 cit_set_brightness(gspca_dev);
3024 if (sd->stop_on_control_change)
3025 cit_restart_stream(gspca_dev);
3026 }
3027
3028 return 0;
3029}
3030
3031static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
3032{
3033 struct sd *sd = (struct sd *) gspca_dev;
3034
3035 *val = sd->brightness;
3036
3037 return 0;
3038}
3039
3040static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
3041{
3042 struct sd *sd = (struct sd *) gspca_dev;
3043
3044 sd->contrast = val;
3045 if (gspca_dev->streaming) {
3046 if (sd->stop_on_control_change)
3047 sd_stopN(gspca_dev);
3048 cit_set_contrast(gspca_dev);
3049 if (sd->stop_on_control_change)
3050 cit_restart_stream(gspca_dev);
3051 }
3052
3053 return 0;
3054}
3055
3056static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
3057{
3058 struct sd *sd = (struct sd *) gspca_dev;
3059
3060 *val = sd->contrast;
3061
3062 return 0;
3063}
3064
3065static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val)
3066{
3067 struct sd *sd = (struct sd *) gspca_dev;
3068
3069 sd->hue = val;
3070 if (gspca_dev->streaming) {
3071 if (sd->stop_on_control_change)
3072 sd_stopN(gspca_dev);
3073 cit_set_hue(gspca_dev);
3074 if (sd->stop_on_control_change)
3075 cit_restart_stream(gspca_dev);
3076 }
3077 return 0;
3078}
3079
3080static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val)
3081{
3082 struct sd *sd = (struct sd *) gspca_dev;
3083
3084 *val = sd->hue;
3085
3086 return 0;
3087}
3088
3089static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
3090{
3091 struct sd *sd = (struct sd *) gspca_dev;
3092
3093 sd->sharpness = val;
3094 if (gspca_dev->streaming) {
3095 if (sd->stop_on_control_change)
3096 sd_stopN(gspca_dev);
3097 cit_set_sharpness(gspca_dev);
3098 if (sd->stop_on_control_change)
3099 cit_restart_stream(gspca_dev);
3100 }
3101 return 0;
3102}
3103
3104static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
3105{
3106 struct sd *sd = (struct sd *) gspca_dev;
3107
3108 *val = sd->sharpness;
3109
3110 return 0;
3111}
3112
3113static int sd_setlighting(struct gspca_dev *gspca_dev, __s32 val)
3114{
3115 struct sd *sd = (struct sd *) gspca_dev;
3116
3117 sd->lighting = val;
3118 if (gspca_dev->streaming) {
3119 if (sd->stop_on_control_change)
3120 sd_stopN(gspca_dev);
3121 cit_set_lighting(gspca_dev);
3122 if (sd->stop_on_control_change)
3123 cit_restart_stream(gspca_dev);
3124 }
3125 return 0;
3126}
3127
3128static int sd_getlighting(struct gspca_dev *gspca_dev, __s32 *val)
3129{
3130 struct sd *sd = (struct sd *) gspca_dev;
3131
3132 *val = sd->lighting;
3133
3134 return 0;
3135}
3136
3137static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
3138{
3139 struct sd *sd = (struct sd *) gspca_dev;
3140
3141 sd->hflip = val;
3142 if (gspca_dev->streaming) {
3143 if (sd->stop_on_control_change)
3144 sd_stopN(gspca_dev);
3145 cit_set_hflip(gspca_dev);
3146 if (sd->stop_on_control_change)
3147 cit_restart_stream(gspca_dev);
3148 }
3149 return 0;
3150}
3151
3152static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
3153{
3154 struct sd *sd = (struct sd *) gspca_dev;
3155
3156 *val = sd->hflip;
3157
3158 return 0;
3159}
3160
3161
3162/* sub-driver description */
3163static const struct sd_desc sd_desc = {
3164 .name = MODULE_NAME,
3165 .ctrls = sd_ctrls,
3166 .nctrls = ARRAY_SIZE(sd_ctrls),
3167 .config = sd_config,
3168 .init = sd_init,
3169 .start = sd_start,
3170 .stopN = sd_stopN,
3171 .stop0 = sd_stop0,
3172 .pkt_scan = sd_pkt_scan,
3173};
3174
3175static const struct sd_desc sd_desc_isoc_nego = {
3176 .name = MODULE_NAME,
3177 .ctrls = sd_ctrls,
3178 .nctrls = ARRAY_SIZE(sd_ctrls),
3179 .config = sd_config,
3180 .init = sd_init,
3181 .start = sd_start,
3182 .isoc_nego = sd_isoc_nego,
3183 .stopN = sd_stopN,
3184 .stop0 = sd_stop0,
3185 .pkt_scan = sd_pkt_scan,
3186};
3187
3188/* -- module initialisation -- */
3189static const __devinitdata struct usb_device_id device_table[] = {
3190 { USB_DEVICE_VER(0x0545, 0x8080, 0x0001, 0x0001), .driver_info = CIT_MODEL0 },
3191 { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info = CIT_MODEL1 },
3192 { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info = CIT_MODEL2 },
3193 { USB_DEVICE_VER(0x0545, 0x8080, 0x0301, 0x0301), .driver_info = CIT_MODEL3 },
3194 { USB_DEVICE_VER(0x0545, 0x8002, 0x030a, 0x030a), .driver_info = CIT_MODEL4 },
3195 { USB_DEVICE_VER(0x0545, 0x800c, 0x030a, 0x030a), .driver_info = CIT_MODEL2 },
3196 { USB_DEVICE_VER(0x0545, 0x800d, 0x030a, 0x030a), .driver_info = CIT_MODEL4 },
3197 {}
3198};
3199MODULE_DEVICE_TABLE(usb, device_table);
3200
3201/* -- device connect -- */
3202static int sd_probe(struct usb_interface *intf,
3203 const struct usb_device_id *id)
3204{
3205 const struct sd_desc *desc = &sd_desc;
3206
3207 switch (id->driver_info) {
3208 case CIT_MODEL0:
3209 case CIT_MODEL1:
3210 if (intf->cur_altsetting->desc.bInterfaceNumber != 2)
3211 return -ENODEV;
3212 break;
3213 case CIT_MODEL2:
3214 case CIT_MODEL4:
3215 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
3216 return -ENODEV;
3217 break;
3218 case CIT_MODEL3:
3219 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
3220 return -ENODEV;
3221 /* FIXME this likely applies to all model3 cams and probably
3222 to other models too. */
3223 if (ibm_netcam_pro)
3224 desc = &sd_desc_isoc_nego;
3225 break;
3226 }
3227
3228 return gspca_dev_probe2(intf, id, desc, sizeof(struct sd), THIS_MODULE);
3229}
3230
3231static struct usb_driver sd_driver = {
3232 .name = MODULE_NAME,
3233 .id_table = device_table,
3234 .probe = sd_probe,
3235 .disconnect = gspca_disconnect,
3236#ifdef CONFIG_PM
3237 .suspend = gspca_suspend,
3238 .resume = gspca_resume,
3239#endif
3240};
3241
3242/* -- module insert / remove -- */
3243static int __init sd_mod_init(void)
3244{
3245 return usb_register(&sd_driver);
3246}
3247static void __exit sd_mod_exit(void)
3248{
3249 usb_deregister(&sd_driver);
3250}
3251
3252module_init(sd_mod_init);
3253module_exit(sd_mod_exit);
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 0666038a51b0..c7e1970ca284 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -21,9 +21,7 @@
21 21
22#define MODULE_NAME "zc3xx" 22#define MODULE_NAME "zc3xx"
23 23
24#ifdef CONFIG_INPUT
25#include <linux/input.h> 24#include <linux/input.h>
26#endif
27#include "gspca.h" 25#include "gspca.h"
28#include "jpeg.h" 26#include "jpeg.h"
29 27
@@ -2953,7 +2951,7 @@ static const struct usb_action mc501cb_Initial[] = {
2953 {} 2951 {}
2954}; 2952};
2955 2953
2956static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */ 2954static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */
2957 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */ 2955 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */
2958 {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */ 2956 {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */
2959 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */ 2957 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */
@@ -3731,7 +3729,6 @@ static const struct usb_action pas106b_InitialScale[] = { /* 176x144 */
3731 {0xaa, 0x0d, 0x0000}, 3729 {0xaa, 0x0d, 0x0000},
3732 {0xaa, 0x0e, 0x0002}, 3730 {0xaa, 0x0e, 0x0002},
3733 {0xaa, 0x14, 0x0081}, 3731 {0xaa, 0x14, 0x0081},
3734
3735/* Other registers */ 3732/* Other registers */
3736 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, 3733 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
3737/* Frame retreiving */ 3734/* Frame retreiving */
@@ -3785,7 +3782,6 @@ static const struct usb_action pas106b_InitialScale[] = { /* 176x144 */
3785 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, 3782 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH},
3786 {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, 3783 {0xa0, 0x14, ZC3XX_R186_WINYCENTER},
3787 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, 3784 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE},
3788
3789/* Auto exposure and white balance */ 3785/* Auto exposure and white balance */
3790 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, 3786 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},
3791 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, 3787 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID},
@@ -3849,7 +3845,6 @@ static const struct usb_action pas106b_Initial[] = { /* 352x288 */
3849 {0xaa, 0x0d, 0x0000}, 3845 {0xaa, 0x0d, 0x0000},
3850 {0xaa, 0x0e, 0x0002}, 3846 {0xaa, 0x0e, 0x0002},
3851 {0xaa, 0x14, 0x0081}, 3847 {0xaa, 0x14, 0x0081},
3852
3853/* Other registers */ 3848/* Other registers */
3854 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, 3849 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
3855/* Frame retreiving */ 3850/* Frame retreiving */
@@ -5698,7 +5693,7 @@ static u8 reg_r_i(struct gspca_dev *gspca_dev,
5698 index, gspca_dev->usb_buf, 1, 5693 index, gspca_dev->usb_buf, 1,
5699 500); 5694 500);
5700 if (ret < 0) { 5695 if (ret < 0) {
5701 PDEBUG(D_ERR, "reg_r_i err %d", ret); 5696 err("reg_r_i err %d", ret);
5702 gspca_dev->usb_err = ret; 5697 gspca_dev->usb_err = ret;
5703 return 0; 5698 return 0;
5704 } 5699 }
@@ -5730,7 +5725,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev,
5730 value, index, NULL, 0, 5725 value, index, NULL, 0,
5731 500); 5726 500);
5732 if (ret < 0) { 5727 if (ret < 0) {
5733 PDEBUG(D_ERR, "reg_w_i err %d", ret); 5728 err("reg_w_i err %d", ret);
5734 gspca_dev->usb_err = ret; 5729 gspca_dev->usb_err = ret;
5735 } 5730 }
5736} 5731}
@@ -6309,8 +6304,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6309 if (chipset_revision_sensor[i].revision == retword) { 6304 if (chipset_revision_sensor[i].revision == retword) {
6310 sd->chip_revision = retword; 6305 sd->chip_revision = retword;
6311 send_unknown(gspca_dev, SENSOR_PB0330); 6306 send_unknown(gspca_dev, SENSOR_PB0330);
6312 return chipset_revision_sensor[i] 6307 return chipset_revision_sensor[i].internal_sensor_id;
6313 .internal_sensor_id;
6314 } 6308 }
6315 } 6309 }
6316 6310
@@ -6503,8 +6497,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
6503 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)"); 6497 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)");
6504 break; 6498 break;
6505 default: 6499 default:
6506 PDEBUG(D_PROBE, 6500 warn("Unknown sensor - set to TAS5130C");
6507 "Unknown sensor - set to TAS5130C");
6508 sd->sensor = SENSOR_TAS5130C; 6501 sd->sensor = SENSOR_TAS5130C;
6509 } 6502 }
6510 break; 6503 break;
@@ -6610,7 +6603,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
6610 sd->sensor = SENSOR_OV7620; /* same sensor (?) */ 6603 sd->sensor = SENSOR_OV7620; /* same sensor (?) */
6611 break; 6604 break;
6612 default: 6605 default:
6613 PDEBUG(D_ERR|D_PROBE, "Unknown sensor %04x", sensor); 6606 err("Unknown sensor %04x", sensor);
6614 return -EINVAL; 6607 return -EINVAL;
6615 } 6608 }
6616 } 6609 }
@@ -6790,7 +6783,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6790 /* fall thru */ 6783 /* fall thru */
6791 case SENSOR_PAS202B: 6784 case SENSOR_PAS202B:
6792 case SENSOR_PO2030: 6785 case SENSOR_PO2030:
6793/* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); * (from win traces) */ 6786/* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); in win traces */
6794 reg_r(gspca_dev, 0x0180); 6787 reg_r(gspca_dev, 0x0180);
6795 break; 6788 break;
6796 case SENSOR_OV7620: 6789 case SENSOR_OV7620:
@@ -6798,7 +6791,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6798 reg_w(gspca_dev, 0x15, 0x01ae); 6791 reg_w(gspca_dev, 0x15, 0x01ae);
6799 i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */ 6792 i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */
6800 i2c_write(gspca_dev, 0x13, 0xa3, 0x00); 6793 i2c_write(gspca_dev, 0x13, 0xa3, 0x00);
6801 /*fixme: returned value to send? */ 6794 /*fixme: returned value to send? */
6802 reg_w(gspca_dev, 0x40, 0x0117); 6795 reg_w(gspca_dev, 0x40, 0x0117);
6803 reg_r(gspca_dev, 0x0180); 6796 reg_r(gspca_dev, 0x0180);
6804 break; 6797 break;
@@ -6841,7 +6834,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
6841 /* remove the webcam's header: 6834 /* remove the webcam's header:
6842 * ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp 6835 * ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp
6843 * - 'ss ss' is the frame sequence number (BE) 6836 * - 'ss ss' is the frame sequence number (BE)
6844 * - 'ww ww' and 'hh hh' are the window dimensions (BE) 6837 * - 'ww ww' and 'hh hh' are the window dimensions (BE)
6845 * - 'pp pp' is the packet sequence number (BE) 6838 * - 'pp pp' is the packet sequence number (BE)
6846 */ 6839 */
6847 data += 18; 6840 data += 18;
@@ -7007,7 +7000,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
7007 return 0; 7000 return 0;
7008} 7001}
7009 7002
7010#ifdef CONFIG_INPUT 7003#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
7011static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 7004static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
7012 u8 *data, /* interrupt packet data */ 7005 u8 *data, /* interrupt packet data */
7013 int len) /* interrput packet length */ 7006 int len) /* interrput packet length */
@@ -7035,7 +7028,7 @@ static const struct sd_desc sd_desc = {
7035 .querymenu = sd_querymenu, 7028 .querymenu = sd_querymenu,
7036 .get_jcomp = sd_get_jcomp, 7029 .get_jcomp = sd_get_jcomp,
7037 .set_jcomp = sd_set_jcomp, 7030 .set_jcomp = sd_set_jcomp,
7038#ifdef CONFIG_INPUT 7031#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
7039 .int_pkt_scan = sd_int_pkt_scan, 7032 .int_pkt_scan = sd_int_pkt_scan,
7040#endif 7033#endif
7041}; 7034};
@@ -7120,18 +7113,12 @@ static struct usb_driver sd_driver = {
7120 7113
7121static int __init sd_mod_init(void) 7114static int __init sd_mod_init(void)
7122{ 7115{
7123 int ret; 7116 return usb_register(&sd_driver);
7124 ret = usb_register(&sd_driver);
7125 if (ret < 0)
7126 return ret;
7127 PDEBUG(D_PROBE, "registered");
7128 return 0;
7129} 7117}
7130 7118
7131static void __exit sd_mod_exit(void) 7119static void __exit sd_mod_exit(void)
7132{ 7120{
7133 usb_deregister(&sd_driver); 7121 usb_deregister(&sd_driver);
7134 PDEBUG(D_PROBE, "deregistered");
7135} 7122}
7136 7123
7137module_init(sd_mod_init); 7124module_init(sd_mod_init);