diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/media/video/gspca | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/media/video/gspca')
74 files changed, 12648 insertions, 4957 deletions
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig index 23db0c29f68c..34ae2c299799 100644 --- a/drivers/media/video/gspca/Kconfig +++ b/drivers/media/video/gspca/Kconfig | |||
@@ -77,6 +77,24 @@ 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 | ||
80 | config USB_GSPCA_KINECT | ||
81 | tristate "Kinect sensor device USB Camera Driver" | ||
82 | depends on VIDEO_V4L2 && USB_GSPCA | ||
83 | help | ||
84 | Say Y here if you want support for the Microsoft Kinect sensor device. | ||
85 | |||
86 | To compile this driver as a module, choose M here: the | ||
87 | module will be called gspca_kinect. | ||
88 | |||
89 | config USB_GSPCA_KONICA | ||
90 | tristate "Konica USB Camera V4L2 driver" | ||
91 | depends on VIDEO_V4L2 && USB_GSPCA | ||
92 | help | ||
93 | Say Y here if you want support for cameras based on the Konica chip. | ||
94 | |||
95 | To compile this driver as a module, choose M here: the | ||
96 | module will be called gspca_konica. | ||
97 | |||
80 | config USB_GSPCA_MARS | 98 | config USB_GSPCA_MARS |
81 | tristate "Mars USB Camera Driver" | 99 | tristate "Mars USB Camera Driver" |
82 | depends on VIDEO_V4L2 && USB_GSPCA | 100 | depends on VIDEO_V4L2 && USB_GSPCA |
@@ -95,6 +113,15 @@ config USB_GSPCA_MR97310A | |||
95 | To compile this driver as a module, choose M here: the | 113 | To compile this driver as a module, choose M here: the |
96 | module will be called gspca_mr97310a. | 114 | module will be called gspca_mr97310a. |
97 | 115 | ||
116 | config USB_GSPCA_NW80X | ||
117 | tristate "Divio based (NW80x) USB Camera Driver" | ||
118 | depends on VIDEO_V4L2 && USB_GSPCA | ||
119 | help | ||
120 | Say Y here if you want support for cameras based on the NW80x chips. | ||
121 | |||
122 | To compile this driver as a module, choose M here: the | ||
123 | module will be called gspca_nw80x. | ||
124 | |||
98 | config USB_GSPCA_OV519 | 125 | config USB_GSPCA_OV519 |
99 | tristate "OV51x / OVFX2 / W996xCF USB Camera Driver" | 126 | tristate "OV51x / OVFX2 / W996xCF USB Camera Driver" |
100 | depends on VIDEO_V4L2 && USB_GSPCA | 127 | depends on VIDEO_V4L2 && USB_GSPCA |
@@ -337,6 +364,25 @@ config USB_GSPCA_VC032X | |||
337 | To compile this driver as a module, choose M here: the | 364 | To compile this driver as a module, choose M here: the |
338 | module will be called gspca_vc032x. | 365 | module will be called gspca_vc032x. |
339 | 366 | ||
367 | config USB_GSPCA_VICAM | ||
368 | tristate "ViCam USB Camera Driver" | ||
369 | depends on VIDEO_V4L2 && USB_GSPCA | ||
370 | help | ||
371 | Say Y here if you want support for the 3com homeconnect camera | ||
372 | (vicam). | ||
373 | |||
374 | To compile this driver as a module, choose M here: the | ||
375 | module will be called gspca_vicam. | ||
376 | |||
377 | config USB_GSPCA_XIRLINK_CIT | ||
378 | tristate "Xirlink C-It USB Camera Driver" | ||
379 | depends on VIDEO_V4L2 && USB_GSPCA | ||
380 | help | ||
381 | Say Y here if you want support for Xirlink C-It bases cameras. | ||
382 | |||
383 | To compile this driver as a module, choose M here: the | ||
384 | module will be called gspca_xirlink_cit. | ||
385 | |||
340 | config USB_GSPCA_ZC3XX | 386 | config USB_GSPCA_ZC3XX |
341 | tristate "ZC3XX USB Camera Driver" | 387 | tristate "ZC3XX USB Camera Driver" |
342 | depends on VIDEO_V4L2 && USB_GSPCA | 388 | depends on VIDEO_V4L2 && USB_GSPCA |
diff --git a/drivers/media/video/gspca/Makefile b/drivers/media/video/gspca/Makefile index f6616db0b7f8..802fbe1bff4a 100644 --- a/drivers/media/video/gspca/Makefile +++ b/drivers/media/video/gspca/Makefile | |||
@@ -5,8 +5,11 @@ obj-$(CONFIG_USB_GSPCA_CPIA1) += gspca_cpia1.o | |||
5 | obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o | 5 | obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o |
6 | obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o | 6 | obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o |
7 | obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o | 7 | obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o |
8 | obj-$(CONFIG_USB_GSPCA_KINECT) += gspca_kinect.o | ||
9 | obj-$(CONFIG_USB_GSPCA_KONICA) += gspca_konica.o | ||
8 | obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o | 10 | obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o |
9 | obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o | 11 | obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o |
12 | obj-$(CONFIG_USB_GSPCA_NW80X) += gspca_nw80x.o | ||
10 | obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o | 13 | obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o |
11 | obj-$(CONFIG_USB_GSPCA_OV534) += gspca_ov534.o | 14 | obj-$(CONFIG_USB_GSPCA_OV534) += gspca_ov534.o |
12 | obj-$(CONFIG_USB_GSPCA_OV534_9) += gspca_ov534_9.o | 15 | obj-$(CONFIG_USB_GSPCA_OV534_9) += gspca_ov534_9.o |
@@ -33,6 +36,8 @@ obj-$(CONFIG_USB_GSPCA_STV0680) += gspca_stv0680.o | |||
33 | obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o | 36 | obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o |
34 | obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o | 37 | obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o |
35 | obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o | 38 | obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o |
39 | obj-$(CONFIG_USB_GSPCA_VICAM) += gspca_vicam.o | ||
40 | obj-$(CONFIG_USB_GSPCA_XIRLINK_CIT) += gspca_xirlink_cit.o | ||
36 | obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o | 41 | obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o |
37 | 42 | ||
38 | gspca_main-objs := gspca.o | 43 | gspca_main-objs := gspca.o |
@@ -42,8 +47,11 @@ gspca_cpia1-objs := cpia1.o | |||
42 | gspca_etoms-objs := etoms.o | 47 | gspca_etoms-objs := etoms.o |
43 | gspca_finepix-objs := finepix.o | 48 | gspca_finepix-objs := finepix.o |
44 | gspca_jeilinj-objs := jeilinj.o | 49 | gspca_jeilinj-objs := jeilinj.o |
50 | gspca_kinect-objs := kinect.o | ||
51 | gspca_konica-objs := konica.o | ||
45 | gspca_mars-objs := mars.o | 52 | gspca_mars-objs := mars.o |
46 | gspca_mr97310a-objs := mr97310a.o | 53 | gspca_mr97310a-objs := mr97310a.o |
54 | gspca_nw80x-objs := nw80x.o | ||
47 | gspca_ov519-objs := ov519.o | 55 | gspca_ov519-objs := ov519.o |
48 | gspca_ov534-objs := ov534.o | 56 | gspca_ov534-objs := ov534.o |
49 | gspca_ov534_9-objs := ov534_9.o | 57 | gspca_ov534_9-objs := ov534_9.o |
@@ -70,6 +78,8 @@ gspca_sunplus-objs := sunplus.o | |||
70 | gspca_t613-objs := t613.o | 78 | gspca_t613-objs := t613.o |
71 | gspca_tv8532-objs := tv8532.o | 79 | gspca_tv8532-objs := tv8532.o |
72 | gspca_vc032x-objs := vc032x.o | 80 | gspca_vc032x-objs := vc032x.o |
81 | gspca_vicam-objs := vicam.o | ||
82 | gspca_xirlink_cit-objs := xirlink_cit.o | ||
73 | gspca_zc3xx-objs := zc3xx.o | 83 | gspca_zc3xx-objs := zc3xx.o |
74 | 84 | ||
75 | obj-$(CONFIG_USB_M5602) += m5602/ | 85 | obj-$(CONFIG_USB_M5602) += m5602/ |
diff --git a/drivers/media/video/gspca/autogain_functions.h b/drivers/media/video/gspca/autogain_functions.h new file mode 100644 index 000000000000..46777eee678b --- /dev/null +++ b/drivers/media/video/gspca/autogain_functions.h | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * Functions for auto gain. | ||
3 | * | ||
4 | * Copyright (C) 2010-2011 Hans de Goede <hdegoede@redhat.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | /* auto gain and exposure algorithm based on the knee algorithm described here: | ||
22 | http://ytse.tricolour.net/docs/LowLightOptimization.html | ||
23 | |||
24 | Returns 0 if no changes were made, 1 if the gain and or exposure settings | ||
25 | where changed. */ | ||
26 | static inline int auto_gain_n_exposure( | ||
27 | struct gspca_dev *gspca_dev, | ||
28 | int avg_lum, | ||
29 | int desired_avg_lum, | ||
30 | int deadzone, | ||
31 | int gain_knee, | ||
32 | int exposure_knee) | ||
33 | { | ||
34 | struct sd *sd = (struct sd *) gspca_dev; | ||
35 | int i, steps, gain, orig_gain, exposure, orig_exposure; | ||
36 | int retval = 0; | ||
37 | |||
38 | orig_gain = gain = sd->ctrls[GAIN].val; | ||
39 | orig_exposure = exposure = sd->ctrls[EXPOSURE].val; | ||
40 | |||
41 | /* If we are of a multiple of deadzone, do multiple steps to reach the | ||
42 | desired lumination fast (with the risc of a slight overshoot) */ | ||
43 | steps = abs(desired_avg_lum - avg_lum) / deadzone; | ||
44 | |||
45 | PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d", | ||
46 | avg_lum, desired_avg_lum, steps); | ||
47 | |||
48 | for (i = 0; i < steps; i++) { | ||
49 | if (avg_lum > desired_avg_lum) { | ||
50 | if (gain > gain_knee) | ||
51 | gain--; | ||
52 | else if (exposure > exposure_knee) | ||
53 | exposure--; | ||
54 | else if (gain > sd->ctrls[GAIN].def) | ||
55 | gain--; | ||
56 | else if (exposure > sd->ctrls[EXPOSURE].min) | ||
57 | exposure--; | ||
58 | else if (gain > sd->ctrls[GAIN].min) | ||
59 | gain--; | ||
60 | else | ||
61 | break; | ||
62 | } else { | ||
63 | if (gain < sd->ctrls[GAIN].def) | ||
64 | gain++; | ||
65 | else if (exposure < exposure_knee) | ||
66 | exposure++; | ||
67 | else if (gain < gain_knee) | ||
68 | gain++; | ||
69 | else if (exposure < sd->ctrls[EXPOSURE].max) | ||
70 | exposure++; | ||
71 | else if (gain < sd->ctrls[GAIN].max) | ||
72 | gain++; | ||
73 | else | ||
74 | break; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | if (gain != orig_gain) { | ||
79 | sd->ctrls[GAIN].val = gain; | ||
80 | setgain(gspca_dev); | ||
81 | retval = 1; | ||
82 | } | ||
83 | if (exposure != orig_exposure) { | ||
84 | sd->ctrls[EXPOSURE].val = exposure; | ||
85 | setexposure(gspca_dev); | ||
86 | retval = 1; | ||
87 | } | ||
88 | |||
89 | if (retval) | ||
90 | PDEBUG(D_FRAM, "autogain: changed gain: %d, expo: %d", | ||
91 | gain, exposure); | ||
92 | return retval; | ||
93 | } | ||
94 | |||
95 | /* Autogain + exposure algorithm for cameras with a coarse exposure control | ||
96 | (usually this means we can only control the clockdiv to change exposure) | ||
97 | As changing the clockdiv so that the fps drops from 30 to 15 fps for | ||
98 | example, will lead to a huge exposure change (it effectively doubles), | ||
99 | this algorithm normally tries to only adjust the gain (between 40 and | ||
100 | 80 %) and if that does not help, only then changes exposure. This leads | ||
101 | to a much more stable image then using the knee algorithm which at | ||
102 | certain points of the knee graph will only try to adjust exposure, | ||
103 | which leads to oscilating as one exposure step is huge. | ||
104 | |||
105 | Note this assumes that the sd struct for the cam in question has | ||
106 | exp_too_high_cnt and exp_too_high_cnt int members for use by this function. | ||
107 | |||
108 | Returns 0 if no changes were made, 1 if the gain and or exposure settings | ||
109 | where changed. */ | ||
110 | static inline int coarse_grained_expo_autogain( | ||
111 | struct gspca_dev *gspca_dev, | ||
112 | int avg_lum, | ||
113 | int desired_avg_lum, | ||
114 | int deadzone) | ||
115 | { | ||
116 | struct sd *sd = (struct sd *) gspca_dev; | ||
117 | int steps, gain, orig_gain, exposure, orig_exposure; | ||
118 | int gain_low, gain_high; | ||
119 | int retval = 0; | ||
120 | |||
121 | orig_gain = gain = sd->ctrls[GAIN].val; | ||
122 | orig_exposure = exposure = sd->ctrls[EXPOSURE].val; | ||
123 | |||
124 | gain_low = (sd->ctrls[GAIN].max - sd->ctrls[GAIN].min) / 5 * 2; | ||
125 | gain_low += sd->ctrls[GAIN].min; | ||
126 | gain_high = (sd->ctrls[GAIN].max - sd->ctrls[GAIN].min) / 5 * 4; | ||
127 | gain_high += sd->ctrls[GAIN].min; | ||
128 | |||
129 | /* If we are of a multiple of deadzone, do multiple steps to reach the | ||
130 | desired lumination fast (with the risc of a slight overshoot) */ | ||
131 | steps = (desired_avg_lum - avg_lum) / deadzone; | ||
132 | |||
133 | PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d", | ||
134 | avg_lum, desired_avg_lum, steps); | ||
135 | |||
136 | if ((gain + steps) > gain_high && | ||
137 | exposure < sd->ctrls[EXPOSURE].max) { | ||
138 | gain = gain_high; | ||
139 | sd->exp_too_low_cnt++; | ||
140 | sd->exp_too_high_cnt = 0; | ||
141 | } else if ((gain + steps) < gain_low && | ||
142 | exposure > sd->ctrls[EXPOSURE].min) { | ||
143 | gain = gain_low; | ||
144 | sd->exp_too_high_cnt++; | ||
145 | sd->exp_too_low_cnt = 0; | ||
146 | } else { | ||
147 | gain += steps; | ||
148 | if (gain > sd->ctrls[GAIN].max) | ||
149 | gain = sd->ctrls[GAIN].max; | ||
150 | else if (gain < sd->ctrls[GAIN].min) | ||
151 | gain = sd->ctrls[GAIN].min; | ||
152 | sd->exp_too_high_cnt = 0; | ||
153 | sd->exp_too_low_cnt = 0; | ||
154 | } | ||
155 | |||
156 | if (sd->exp_too_high_cnt > 3) { | ||
157 | exposure--; | ||
158 | sd->exp_too_high_cnt = 0; | ||
159 | } else if (sd->exp_too_low_cnt > 3) { | ||
160 | exposure++; | ||
161 | sd->exp_too_low_cnt = 0; | ||
162 | } | ||
163 | |||
164 | if (gain != orig_gain) { | ||
165 | sd->ctrls[GAIN].val = gain; | ||
166 | setgain(gspca_dev); | ||
167 | retval = 1; | ||
168 | } | ||
169 | if (exposure != orig_exposure) { | ||
170 | sd->ctrls[EXPOSURE].val = exposure; | ||
171 | setexposure(gspca_dev); | ||
172 | retval = 1; | ||
173 | } | ||
174 | |||
175 | if (retval) | ||
176 | PDEBUG(D_FRAM, "autogain: changed gain: %d, expo: %d", | ||
177 | gain, exposure); | ||
178 | return retval; | ||
179 | } | ||
diff --git a/drivers/media/video/gspca/benq.c b/drivers/media/video/gspca/benq.c index fce8d9492641..a09c4709d613 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 | ||
158 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 159 | static 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 */ |
@@ -276,7 +276,7 @@ static const struct sd_desc sd_desc = { | |||
276 | }; | 276 | }; |
277 | 277 | ||
278 | /* -- module initialisation -- */ | 278 | /* -- module initialisation -- */ |
279 | static const __devinitdata struct usb_device_id device_table[] = { | 279 | static const struct usb_device_id device_table[] = { |
280 | {USB_DEVICE(0x04a5, 0x3035)}, | 280 | {USB_DEVICE(0x04a5, 0x3035)}, |
281 | {} | 281 | {} |
282 | }; | 282 | }; |
@@ -304,18 +304,11 @@ static struct usb_driver sd_driver = { | |||
304 | /* -- module insert / remove -- */ | 304 | /* -- module insert / remove -- */ |
305 | static int __init sd_mod_init(void) | 305 | static 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 | } |
315 | static void __exit sd_mod_exit(void) | 309 | static 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 | ||
321 | module_init(sd_mod_init); | 314 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/coarse_expo_autogain.h b/drivers/media/video/gspca/coarse_expo_autogain.h deleted file mode 100644 index 1cb9d941eaf6..000000000000 --- a/drivers/media/video/gspca/coarse_expo_autogain.h +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | /* | ||
2 | * Auto gain algorithm for camera's with a coarse exposure control | ||
3 | * | ||
4 | * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | /* Autogain + exposure algorithm for cameras with a coarse exposure control | ||
22 | (usually this means we can only control the clockdiv to change exposure) | ||
23 | As changing the clockdiv so that the fps drops from 30 to 15 fps for | ||
24 | example, will lead to a huge exposure change (it effectively doubles), | ||
25 | this algorithm normally tries to only adjust the gain (between 40 and | ||
26 | 80 %) and if that does not help, only then changes exposure. This leads | ||
27 | to a much more stable image then using the knee algorithm which at | ||
28 | certain points of the knee graph will only try to adjust exposure, | ||
29 | which leads to oscilating as one exposure step is huge. | ||
30 | |||
31 | Note this assumes that the sd struct for the cam in question has | ||
32 | exp_too_high_cnt and exp_too_high_cnt int members for use by this function. | ||
33 | |||
34 | Returns 0 if no changes were made, 1 if the gain and or exposure settings | ||
35 | where changed. */ | ||
36 | static int gspca_coarse_grained_expo_autogain(struct gspca_dev *gspca_dev, | ||
37 | int avg_lum, int desired_avg_lum, int deadzone) | ||
38 | { | ||
39 | int i, steps, gain, orig_gain, exposure, orig_exposure; | ||
40 | int gain_low, gain_high; | ||
41 | const struct ctrl *gain_ctrl = NULL; | ||
42 | const struct ctrl *exposure_ctrl = NULL; | ||
43 | struct sd *sd = (struct sd *) gspca_dev; | ||
44 | int retval = 0; | ||
45 | |||
46 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | ||
47 | if (gspca_dev->ctrl_dis & (1 << i)) | ||
48 | continue; | ||
49 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id == V4L2_CID_GAIN) | ||
50 | gain_ctrl = &gspca_dev->sd_desc->ctrls[i]; | ||
51 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id == V4L2_CID_EXPOSURE) | ||
52 | exposure_ctrl = &gspca_dev->sd_desc->ctrls[i]; | ||
53 | } | ||
54 | if (!gain_ctrl || !exposure_ctrl) { | ||
55 | PDEBUG(D_ERR, "Error: gspca_coarse_grained_expo_autogain " | ||
56 | "called on cam without gain or exposure"); | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | if (gain_ctrl->get(gspca_dev, &gain) || | ||
61 | exposure_ctrl->get(gspca_dev, &exposure)) | ||
62 | return 0; | ||
63 | |||
64 | orig_gain = gain; | ||
65 | orig_exposure = exposure; | ||
66 | gain_low = | ||
67 | (gain_ctrl->qctrl.maximum - gain_ctrl->qctrl.minimum) / 5 * 2; | ||
68 | gain_low += gain_ctrl->qctrl.minimum; | ||
69 | gain_high = | ||
70 | (gain_ctrl->qctrl.maximum - gain_ctrl->qctrl.minimum) / 5 * 4; | ||
71 | gain_high += gain_ctrl->qctrl.minimum; | ||
72 | |||
73 | /* If we are of a multiple of deadzone, do multiple steps to reach the | ||
74 | desired lumination fast (with the risc of a slight overshoot) */ | ||
75 | steps = (desired_avg_lum - avg_lum) / deadzone; | ||
76 | |||
77 | PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d", | ||
78 | avg_lum, desired_avg_lum, steps); | ||
79 | |||
80 | if ((gain + steps) > gain_high && | ||
81 | sd->exposure < exposure_ctrl->qctrl.maximum) { | ||
82 | gain = gain_high; | ||
83 | sd->exp_too_low_cnt++; | ||
84 | } else if ((gain + steps) < gain_low && | ||
85 | sd->exposure > exposure_ctrl->qctrl.minimum) { | ||
86 | gain = gain_low; | ||
87 | sd->exp_too_high_cnt++; | ||
88 | } else { | ||
89 | gain += steps; | ||
90 | if (gain > gain_ctrl->qctrl.maximum) | ||
91 | gain = gain_ctrl->qctrl.maximum; | ||
92 | else if (gain < gain_ctrl->qctrl.minimum) | ||
93 | gain = gain_ctrl->qctrl.minimum; | ||
94 | sd->exp_too_high_cnt = 0; | ||
95 | sd->exp_too_low_cnt = 0; | ||
96 | } | ||
97 | |||
98 | if (sd->exp_too_high_cnt > 3) { | ||
99 | exposure--; | ||
100 | sd->exp_too_high_cnt = 0; | ||
101 | } else if (sd->exp_too_low_cnt > 3) { | ||
102 | exposure++; | ||
103 | sd->exp_too_low_cnt = 0; | ||
104 | } | ||
105 | |||
106 | if (gain != orig_gain) { | ||
107 | gain_ctrl->set(gspca_dev, gain); | ||
108 | retval = 1; | ||
109 | } | ||
110 | if (exposure != orig_exposure) { | ||
111 | exposure_ctrl->set(gspca_dev, exposure); | ||
112 | retval = 1; | ||
113 | } | ||
114 | |||
115 | return retval; | ||
116 | } | ||
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index d6a75772f3f8..8b398493f96b 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 | ||
904 | static void setbrightness(struct gspca_dev*gspca_dev) | 904 | static 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 | ||
927 | static void setcontrast(struct gspca_dev*gspca_dev) | 927 | static 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 */ |
@@ -1040,14 +1040,14 @@ static const struct sd_desc sd_desc = { | |||
1040 | }; | 1040 | }; |
1041 | 1041 | ||
1042 | /* -- module initialisation -- */ | 1042 | /* -- module initialisation -- */ |
1043 | static const struct usb_device_id device_table[] __devinitconst = { | 1043 | static const struct usb_device_id device_table[] = { |
1044 | {USB_DEVICE(0x0572, 0x0041)}, | 1044 | {USB_DEVICE(0x0572, 0x0041)}, |
1045 | {} | 1045 | {} |
1046 | }; | 1046 | }; |
1047 | MODULE_DEVICE_TABLE(usb, device_table); | 1047 | MODULE_DEVICE_TABLE(usb, device_table); |
1048 | 1048 | ||
1049 | /* -- device connect -- */ | 1049 | /* -- device connect -- */ |
1050 | static int __devinit sd_probe(struct usb_interface *intf, | 1050 | static int sd_probe(struct usb_interface *intf, |
1051 | const struct usb_device_id *id) | 1051 | const struct usb_device_id *id) |
1052 | { | 1052 | { |
1053 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 1053 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
@@ -1068,17 +1068,11 @@ static struct usb_driver sd_driver = { | |||
1068 | /* -- module insert / remove -- */ | 1068 | /* -- module insert / remove -- */ |
1069 | static int __init sd_mod_init(void) | 1069 | static 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 | } |
1078 | static void __exit sd_mod_exit(void) | 1073 | static 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 | ||
1084 | module_init(sd_mod_init); | 1078 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c index 3747a1dcff54..f2a9451eea19 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-2011 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 | * |
@@ -28,16 +28,17 @@ | |||
28 | 28 | ||
29 | #define MODULE_NAME "cpia1" | 29 | #define MODULE_NAME "cpia1" |
30 | 30 | ||
31 | #include <linux/input.h> | ||
31 | #include "gspca.h" | 32 | #include "gspca.h" |
32 | 33 | ||
33 | MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); | 34 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
34 | MODULE_DESCRIPTION("Vision CPiA"); | 35 | MODULE_DESCRIPTION("Vision CPiA"); |
35 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
36 | 37 | ||
37 | /* constant value's */ | 38 | /* constant value's */ |
38 | #define MAGIC_0 0x19 | 39 | #define MAGIC_0 0x19 |
39 | #define MAGIC_1 0x68 | 40 | #define MAGIC_1 0x68 |
40 | #define DATA_IN 0xC0 | 41 | #define DATA_IN 0xc0 |
41 | #define DATA_OUT 0x40 | 42 | #define DATA_OUT 0x40 |
42 | #define VIDEOSIZE_QCIF 0 /* 176x144 */ | 43 | #define VIDEOSIZE_QCIF 0 /* 176x144 */ |
43 | #define VIDEOSIZE_CIF 1 /* 352x288 */ | 44 | #define VIDEOSIZE_CIF 1 /* 352x288 */ |
@@ -373,9 +374,14 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | |||
373 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | 374 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); |
374 | static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val); | 375 | static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val); |
375 | static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val); | 376 | static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val); |
377 | static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val); | ||
378 | static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val); | ||
379 | static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val); | ||
380 | static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val); | ||
376 | 381 | ||
377 | static const struct ctrl sd_ctrls[] = { | 382 | static const struct ctrl sd_ctrls[] = { |
378 | { | 383 | { |
384 | #define BRIGHTNESS_IDX 0 | ||
379 | { | 385 | { |
380 | .id = V4L2_CID_BRIGHTNESS, | 386 | .id = V4L2_CID_BRIGHTNESS, |
381 | .type = V4L2_CTRL_TYPE_INTEGER, | 387 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -390,6 +396,7 @@ static const struct ctrl sd_ctrls[] = { | |||
390 | .set = sd_setbrightness, | 396 | .set = sd_setbrightness, |
391 | .get = sd_getbrightness, | 397 | .get = sd_getbrightness, |
392 | }, | 398 | }, |
399 | #define CONTRAST_IDX 1 | ||
393 | { | 400 | { |
394 | { | 401 | { |
395 | .id = V4L2_CID_CONTRAST, | 402 | .id = V4L2_CID_CONTRAST, |
@@ -404,6 +411,7 @@ static const struct ctrl sd_ctrls[] = { | |||
404 | .set = sd_setcontrast, | 411 | .set = sd_setcontrast, |
405 | .get = sd_getcontrast, | 412 | .get = sd_getcontrast, |
406 | }, | 413 | }, |
414 | #define SATURATION_IDX 2 | ||
407 | { | 415 | { |
408 | { | 416 | { |
409 | .id = V4L2_CID_SATURATION, | 417 | .id = V4L2_CID_SATURATION, |
@@ -418,6 +426,7 @@ static const struct ctrl sd_ctrls[] = { | |||
418 | .set = sd_setsaturation, | 426 | .set = sd_setsaturation, |
419 | .get = sd_getsaturation, | 427 | .get = sd_getsaturation, |
420 | }, | 428 | }, |
429 | #define POWER_LINE_FREQUENCY_IDX 3 | ||
421 | { | 430 | { |
422 | { | 431 | { |
423 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 432 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
@@ -432,6 +441,37 @@ static const struct ctrl sd_ctrls[] = { | |||
432 | .set = sd_setfreq, | 441 | .set = sd_setfreq, |
433 | .get = sd_getfreq, | 442 | .get = sd_getfreq, |
434 | }, | 443 | }, |
444 | #define ILLUMINATORS_1_IDX 4 | ||
445 | { | ||
446 | { | ||
447 | .id = V4L2_CID_ILLUMINATORS_1, | ||
448 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
449 | .name = "Illuminator 1", | ||
450 | .minimum = 0, | ||
451 | .maximum = 1, | ||
452 | .step = 1, | ||
453 | #define ILLUMINATORS_1_DEF 0 | ||
454 | .default_value = ILLUMINATORS_1_DEF, | ||
455 | }, | ||
456 | .set = sd_setilluminator1, | ||
457 | .get = sd_getilluminator1, | ||
458 | }, | ||
459 | #define ILLUMINATORS_2_IDX 5 | ||
460 | { | ||
461 | { | ||
462 | .id = V4L2_CID_ILLUMINATORS_2, | ||
463 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
464 | .name = "Illuminator 2", | ||
465 | .minimum = 0, | ||
466 | .maximum = 1, | ||
467 | .step = 1, | ||
468 | #define ILLUMINATORS_2_DEF 0 | ||
469 | .default_value = ILLUMINATORS_2_DEF, | ||
470 | }, | ||
471 | .set = sd_setilluminator2, | ||
472 | .get = sd_getilluminator2, | ||
473 | }, | ||
474 | #define COMP_TARGET_IDX 6 | ||
435 | { | 475 | { |
436 | { | 476 | { |
437 | #define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE | 477 | #define V4L2_CID_COMP_TARGET V4L2_CID_PRIVATE_BASE |
@@ -510,7 +550,7 @@ retry: | |||
510 | gspca_dev->usb_buf, databytes, 1000); | 550 | gspca_dev->usb_buf, databytes, 1000); |
511 | 551 | ||
512 | if (ret < 0) | 552 | if (ret < 0) |
513 | PDEBUG(D_ERR, "usb_control_msg %02x, error %d", command[1], | 553 | err("usb_control_msg %02x, error %d", command[1], |
514 | ret); | 554 | ret); |
515 | 555 | ||
516 | if (ret == -EPIPE && retries > 0) { | 556 | if (ret == -EPIPE && retries > 0) { |
@@ -614,16 +654,21 @@ static int do_command(struct gspca_dev *gspca_dev, u16 command, | |||
614 | break; | 654 | break; |
615 | 655 | ||
616 | case CPIA_COMMAND_ReadMCPorts: | 656 | case CPIA_COMMAND_ReadMCPorts: |
617 | if (!sd->params.qx3.qx3_detected) | ||
618 | break; | ||
619 | /* test button press */ | 657 | /* test button press */ |
620 | sd->params.qx3.button = ((gspca_dev->usb_buf[1] & 0x02) == 0); | 658 | a = ((gspca_dev->usb_buf[1] & 0x02) == 0); |
659 | if (a != sd->params.qx3.button) { | ||
660 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
661 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, a); | ||
662 | input_sync(gspca_dev->input_dev); | ||
663 | #endif | ||
664 | sd->params.qx3.button = a; | ||
665 | } | ||
621 | if (sd->params.qx3.button) { | 666 | if (sd->params.qx3.button) { |
622 | /* button pressed - unlock the latch */ | 667 | /* button pressed - unlock the latch */ |
623 | do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, | 668 | do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, |
624 | 3, 0xDF, 0xDF, 0); | 669 | 3, 0xdf, 0xdf, 0); |
625 | do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, | 670 | do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, |
626 | 3, 0xFF, 0xFF, 0); | 671 | 3, 0xff, 0xff, 0); |
627 | } | 672 | } |
628 | 673 | ||
629 | /* test whether microscope is cradled */ | 674 | /* test whether microscope is cradled */ |
@@ -790,7 +835,7 @@ static int goto_low_power(struct gspca_dev *gspca_dev) | |||
790 | if (ret) | 835 | if (ret) |
791 | return ret; | 836 | return ret; |
792 | 837 | ||
793 | do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); | 838 | ret = do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); |
794 | if (ret) | 839 | if (ret) |
795 | return ret; | 840 | return ret; |
796 | 841 | ||
@@ -1059,7 +1104,6 @@ static int command_resume(struct gspca_dev *gspca_dev) | |||
1059 | 0, sd->params.streamStartLine, 0, 0); | 1104 | 0, sd->params.streamStartLine, 0, 0); |
1060 | } | 1105 | } |
1061 | 1106 | ||
1062 | #if 0 /* Currently unused */ | ||
1063 | static int command_setlights(struct gspca_dev *gspca_dev) | 1107 | static int command_setlights(struct gspca_dev *gspca_dev) |
1064 | { | 1108 | { |
1065 | struct sd *sd = (struct sd *) gspca_dev; | 1109 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1072,14 +1116,13 @@ static int command_setlights(struct gspca_dev *gspca_dev) | |||
1072 | p2 = (sd->params.qx3.toplight == 0) << 3; | 1116 | p2 = (sd->params.qx3.toplight == 0) << 3; |
1073 | 1117 | ||
1074 | ret = do_command(gspca_dev, CPIA_COMMAND_WriteVCReg, | 1118 | ret = do_command(gspca_dev, CPIA_COMMAND_WriteVCReg, |
1075 | 0x90, 0x8F, 0x50, 0); | 1119 | 0x90, 0x8f, 0x50, 0); |
1076 | if (ret) | 1120 | if (ret) |
1077 | return ret; | 1121 | return ret; |
1078 | 1122 | ||
1079 | return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0, | 1123 | return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0, |
1080 | p1 | p2 | 0xE0, 0); | 1124 | p1 | p2 | 0xe0, 0); |
1081 | } | 1125 | } |
1082 | #endif | ||
1083 | 1126 | ||
1084 | static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) | 1127 | static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) |
1085 | { | 1128 | { |
@@ -1219,7 +1262,7 @@ static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) | |||
1219 | static void monitor_exposure(struct gspca_dev *gspca_dev) | 1262 | static void monitor_exposure(struct gspca_dev *gspca_dev) |
1220 | { | 1263 | { |
1221 | struct sd *sd = (struct sd *) gspca_dev; | 1264 | struct sd *sd = (struct sd *) gspca_dev; |
1222 | u8 exp_acc, bcomp, gain, coarseL, cmd[8]; | 1265 | u8 exp_acc, bcomp, cmd[8]; |
1223 | int ret, light_exp, dark_exp, very_dark_exp; | 1266 | int ret, light_exp, dark_exp, very_dark_exp; |
1224 | int old_exposure, new_exposure, framerate; | 1267 | int old_exposure, new_exposure, framerate; |
1225 | int setfps = 0, setexp = 0, setflicker = 0; | 1268 | int setfps = 0, setexp = 0, setflicker = 0; |
@@ -1236,13 +1279,11 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) | |||
1236 | cmd[7] = 0; | 1279 | cmd[7] = 0; |
1237 | ret = cpia_usb_transferCmd(gspca_dev, cmd); | 1280 | ret = cpia_usb_transferCmd(gspca_dev, cmd); |
1238 | if (ret) { | 1281 | if (ret) { |
1239 | PDEBUG(D_ERR, "ReadVPRegs(30,4,9,8) - failed: %d", ret); | 1282 | err("ReadVPRegs(30,4,9,8) - failed: %d", ret); |
1240 | return; | 1283 | return; |
1241 | } | 1284 | } |
1242 | exp_acc = gspca_dev->usb_buf[0]; | 1285 | exp_acc = gspca_dev->usb_buf[0]; |
1243 | bcomp = gspca_dev->usb_buf[1]; | 1286 | bcomp = gspca_dev->usb_buf[1]; |
1244 | gain = gspca_dev->usb_buf[2]; | ||
1245 | coarseL = gspca_dev->usb_buf[3]; | ||
1246 | 1287 | ||
1247 | light_exp = sd->params.colourParams.brightness + | 1288 | light_exp = sd->params.colourParams.brightness + |
1248 | TC - 50 + EXP_ACC_LIGHT; | 1289 | TC - 50 + EXP_ACC_LIGHT; |
@@ -1363,7 +1404,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) | |||
1363 | if ((sd->exposure_status == EXPOSURE_VERY_DARK || | 1404 | if ((sd->exposure_status == EXPOSURE_VERY_DARK || |
1364 | sd->exposure_status == EXPOSURE_DARK) && | 1405 | sd->exposure_status == EXPOSURE_DARK) && |
1365 | sd->exposure_count >= DARK_TIME * framerate && | 1406 | sd->exposure_count >= DARK_TIME * framerate && |
1366 | sd->params.sensorFps.divisor < 3) { | 1407 | sd->params.sensorFps.divisor < 2) { |
1367 | 1408 | ||
1368 | /* dark for too long */ | 1409 | /* dark for too long */ |
1369 | ++sd->params.sensorFps.divisor; | 1410 | ++sd->params.sensorFps.divisor; |
@@ -1419,7 +1460,7 @@ static void monitor_exposure(struct gspca_dev *gspca_dev) | |||
1419 | if ((sd->exposure_status == EXPOSURE_VERY_DARK || | 1460 | if ((sd->exposure_status == EXPOSURE_VERY_DARK || |
1420 | sd->exposure_status == EXPOSURE_DARK) && | 1461 | sd->exposure_status == EXPOSURE_DARK) && |
1421 | sd->exposure_count >= DARK_TIME * framerate && | 1462 | sd->exposure_count >= DARK_TIME * framerate && |
1422 | sd->params.sensorFps.divisor < 3) { | 1463 | sd->params.sensorFps.divisor < 2) { |
1423 | 1464 | ||
1424 | /* dark for too long */ | 1465 | /* dark for too long */ |
1425 | ++sd->params.sensorFps.divisor; | 1466 | ++sd->params.sensorFps.divisor; |
@@ -1701,6 +1742,8 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1701 | 1742 | ||
1702 | static void sd_stopN(struct gspca_dev *gspca_dev) | 1743 | static void sd_stopN(struct gspca_dev *gspca_dev) |
1703 | { | 1744 | { |
1745 | struct sd *sd = (struct sd *) gspca_dev; | ||
1746 | |||
1704 | command_pause(gspca_dev); | 1747 | command_pause(gspca_dev); |
1705 | 1748 | ||
1706 | /* save camera state for later open (developers guide ch 3.5.3) */ | 1749 | /* save camera state for later open (developers guide ch 3.5.3) */ |
@@ -1711,6 +1754,17 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1711 | 1754 | ||
1712 | /* Update the camera status */ | 1755 | /* Update the camera status */ |
1713 | do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); | 1756 | do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); |
1757 | |||
1758 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
1759 | /* If the last button state is pressed, release it now! */ | ||
1760 | if (sd->params.qx3.button) { | ||
1761 | /* The camera latch will hold the pressed state until we reset | ||
1762 | the latch, so we do not reset sd->params.qx3.button now, to | ||
1763 | avoid a false keypress being reported the next sd_start */ | ||
1764 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | ||
1765 | input_sync(gspca_dev->input_dev); | ||
1766 | } | ||
1767 | #endif | ||
1714 | } | 1768 | } |
1715 | 1769 | ||
1716 | /* this function is called at probe and resume time */ | 1770 | /* this function is called at probe and resume time */ |
@@ -1726,6 +1780,14 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1726 | if (ret) | 1780 | if (ret) |
1727 | return ret; | 1781 | return ret; |
1728 | 1782 | ||
1783 | /* Ensure the QX3 illuminators' states are restored upon resume, | ||
1784 | or disable the illuminator controls, if this isn't a QX3 */ | ||
1785 | if (sd->params.qx3.qx3_detected) | ||
1786 | command_setlights(gspca_dev); | ||
1787 | else | ||
1788 | gspca_dev->ctrl_dis |= | ||
1789 | ((1 << ILLUMINATORS_1_IDX) | (1 << ILLUMINATORS_2_IDX)); | ||
1790 | |||
1729 | sd_stopN(gspca_dev); | 1791 | sd_stopN(gspca_dev); |
1730 | 1792 | ||
1731 | PDEBUG(D_PROBE, "CPIA Version: %d.%02d (%d.%d)", | 1793 | PDEBUG(D_PROBE, "CPIA Version: %d.%02d (%d.%d)", |
@@ -1805,8 +1867,7 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev) | |||
1805 | 1867 | ||
1806 | /* Update our knowledge of the camera state */ | 1868 | /* Update our knowledge of the camera state */ |
1807 | do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0); | 1869 | do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0); |
1808 | if (sd->params.qx3.qx3_detected) | 1870 | do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0); |
1809 | do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0); | ||
1810 | } | 1871 | } |
1811 | 1872 | ||
1812 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 1873 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
@@ -1929,6 +1990,72 @@ static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val) | |||
1929 | return 0; | 1990 | return 0; |
1930 | } | 1991 | } |
1931 | 1992 | ||
1993 | static int sd_setilluminator(struct gspca_dev *gspca_dev, __s32 val, int n) | ||
1994 | { | ||
1995 | struct sd *sd = (struct sd *) gspca_dev; | ||
1996 | int ret; | ||
1997 | |||
1998 | if (!sd->params.qx3.qx3_detected) | ||
1999 | return -EINVAL; | ||
2000 | |||
2001 | switch (n) { | ||
2002 | case 1: | ||
2003 | sd->params.qx3.bottomlight = val ? 1 : 0; | ||
2004 | break; | ||
2005 | case 2: | ||
2006 | sd->params.qx3.toplight = val ? 1 : 0; | ||
2007 | break; | ||
2008 | default: | ||
2009 | return -EINVAL; | ||
2010 | } | ||
2011 | |||
2012 | ret = command_setlights(gspca_dev); | ||
2013 | if (ret && ret != -EINVAL) | ||
2014 | ret = -EBUSY; | ||
2015 | |||
2016 | return ret; | ||
2017 | } | ||
2018 | |||
2019 | static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val) | ||
2020 | { | ||
2021 | return sd_setilluminator(gspca_dev, val, 1); | ||
2022 | } | ||
2023 | |||
2024 | static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val) | ||
2025 | { | ||
2026 | return sd_setilluminator(gspca_dev, val, 2); | ||
2027 | } | ||
2028 | |||
2029 | static int sd_getilluminator(struct gspca_dev *gspca_dev, __s32 *val, int n) | ||
2030 | { | ||
2031 | struct sd *sd = (struct sd *) gspca_dev; | ||
2032 | |||
2033 | if (!sd->params.qx3.qx3_detected) | ||
2034 | return -EINVAL; | ||
2035 | |||
2036 | switch (n) { | ||
2037 | case 1: | ||
2038 | *val = sd->params.qx3.bottomlight; | ||
2039 | break; | ||
2040 | case 2: | ||
2041 | *val = sd->params.qx3.toplight; | ||
2042 | break; | ||
2043 | default: | ||
2044 | return -EINVAL; | ||
2045 | } | ||
2046 | return 0; | ||
2047 | } | ||
2048 | |||
2049 | static int sd_getilluminator1(struct gspca_dev *gspca_dev, __s32 *val) | ||
2050 | { | ||
2051 | return sd_getilluminator(gspca_dev, val, 1); | ||
2052 | } | ||
2053 | |||
2054 | static int sd_getilluminator2(struct gspca_dev *gspca_dev, __s32 *val) | ||
2055 | { | ||
2056 | return sd_getilluminator(gspca_dev, val, 2); | ||
2057 | } | ||
2058 | |||
1932 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 2059 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
1933 | struct v4l2_querymenu *menu) | 2060 | struct v4l2_querymenu *menu) |
1934 | { | 2061 | { |
@@ -1972,10 +2099,13 @@ static const struct sd_desc sd_desc = { | |||
1972 | .dq_callback = sd_dq_callback, | 2099 | .dq_callback = sd_dq_callback, |
1973 | .pkt_scan = sd_pkt_scan, | 2100 | .pkt_scan = sd_pkt_scan, |
1974 | .querymenu = sd_querymenu, | 2101 | .querymenu = sd_querymenu, |
2102 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
2103 | .other_input = 1, | ||
2104 | #endif | ||
1975 | }; | 2105 | }; |
1976 | 2106 | ||
1977 | /* -- module initialisation -- */ | 2107 | /* -- module initialisation -- */ |
1978 | static const __devinitdata struct usb_device_id device_table[] = { | 2108 | static const struct usb_device_id device_table[] = { |
1979 | {USB_DEVICE(0x0553, 0x0002)}, | 2109 | {USB_DEVICE(0x0553, 0x0002)}, |
1980 | {USB_DEVICE(0x0813, 0x0001)}, | 2110 | {USB_DEVICE(0x0813, 0x0001)}, |
1981 | {} | 2111 | {} |
@@ -2004,17 +2134,11 @@ static struct usb_driver sd_driver = { | |||
2004 | /* -- module insert / remove -- */ | 2134 | /* -- module insert / remove -- */ |
2005 | static int __init sd_mod_init(void) | 2135 | static int __init sd_mod_init(void) |
2006 | { | 2136 | { |
2007 | int ret; | 2137 | 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 | } | 2138 | } |
2014 | static void __exit sd_mod_exit(void) | 2139 | static void __exit sd_mod_exit(void) |
2015 | { | 2140 | { |
2016 | usb_deregister(&sd_driver); | 2141 | usb_deregister(&sd_driver); |
2017 | PDEBUG(D_PROBE, "deregistered"); | ||
2018 | } | 2142 | } |
2019 | 2143 | ||
2020 | module_init(sd_mod_init); | 2144 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c index ecd4d743d2bc..4b2c483fce6f 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 | ||
717 | static void do_autogain(struct gspca_dev *gspca_dev) | 717 | static void do_autogain(struct gspca_dev *gspca_dev) |
718 | { | 718 | { |
@@ -864,7 +864,7 @@ static const struct sd_desc sd_desc = { | |||
864 | }; | 864 | }; |
865 | 865 | ||
866 | /* -- module initialisation -- */ | 866 | /* -- module initialisation -- */ |
867 | static const struct usb_device_id device_table[] __devinitconst = { | 867 | static const struct usb_device_id device_table[] = { |
868 | {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, | 868 | {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, |
869 | #if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE | 869 | #if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE |
870 | {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, | 870 | {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, |
@@ -875,7 +875,7 @@ static const struct usb_device_id device_table[] __devinitconst = { | |||
875 | MODULE_DEVICE_TABLE(usb, device_table); | 875 | MODULE_DEVICE_TABLE(usb, device_table); |
876 | 876 | ||
877 | /* -- device connect -- */ | 877 | /* -- device connect -- */ |
878 | static int __devinit sd_probe(struct usb_interface *intf, | 878 | static int sd_probe(struct usb_interface *intf, |
879 | const struct usb_device_id *id) | 879 | const struct usb_device_id *id) |
880 | { | 880 | { |
881 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 881 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
@@ -896,18 +896,12 @@ static struct usb_driver sd_driver = { | |||
896 | /* -- module insert / remove -- */ | 896 | /* -- module insert / remove -- */ |
897 | static int __init sd_mod_init(void) | 897 | static 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 | ||
907 | static void __exit sd_mod_exit(void) | 902 | static 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 | ||
913 | module_init(sd_mod_init); | 907 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c index 5d90e7448579..987b4b69d7ab 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 | ||
@@ -229,7 +229,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
229 | } | 229 | } |
230 | 230 | ||
231 | /* Table of supported USB devices */ | 231 | /* Table of supported USB devices */ |
232 | static const __devinitdata struct usb_device_id device_table[] = { | 232 | static const struct usb_device_id device_table[] = { |
233 | {USB_DEVICE(0x04cb, 0x0104)}, | 233 | {USB_DEVICE(0x04cb, 0x0104)}, |
234 | {USB_DEVICE(0x04cb, 0x0109)}, | 234 | {USB_DEVICE(0x04cb, 0x0109)}, |
235 | {USB_DEVICE(0x04cb, 0x010b)}, | 235 | {USB_DEVICE(0x04cb, 0x010b)}, |
@@ -291,19 +291,12 @@ static struct usb_driver sd_driver = { | |||
291 | /* -- module insert / remove -- */ | 291 | /* -- module insert / remove -- */ |
292 | static int __init sd_mod_init(void) | 292 | static 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 | ||
303 | static void __exit sd_mod_exit(void) | 297 | static 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 | ||
309 | module_init(sd_mod_init); | 302 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/gl860/gl860-mi1320.c b/drivers/media/video/gspca/gl860/gl860-mi1320.c index c276a7debdec..b57160e04866 100644 --- a/drivers/media/video/gspca/gl860/gl860-mi1320.c +++ b/drivers/media/video/gspca/gl860/gl860-mi1320.c | |||
@@ -201,7 +201,7 @@ void mi1320_init_settings(struct gspca_dev *gspca_dev) | |||
201 | sd->vmax.backlight = 2; | 201 | sd->vmax.backlight = 2; |
202 | sd->vmax.brightness = 8; | 202 | sd->vmax.brightness = 8; |
203 | sd->vmax.sharpness = 7; | 203 | sd->vmax.sharpness = 7; |
204 | sd->vmax.contrast = 0; /* 10 but not working with tihs driver */ | 204 | sd->vmax.contrast = 0; /* 10 but not working with this driver */ |
205 | sd->vmax.gamma = 40; | 205 | sd->vmax.gamma = 40; |
206 | sd->vmax.hue = 5 + 1; | 206 | sd->vmax.hue = 5 + 1; |
207 | sd->vmax.saturation = 8; | 207 | sd->vmax.saturation = 8; |
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 }; | |||
69 | static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; | 69 | static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; |
70 | 70 | ||
71 | static struct validx tbl_init_at_startup[] = { | 71 | static 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 | ||
78 | static struct validx tbl_common_0B[] = { | 78 | static 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..e8e071aa212f 100644 --- a/drivers/media/video/gspca/gl860/gl860.c +++ b/drivers/media/video/gspca/gl860/gl860.c | |||
@@ -488,7 +488,7 @@ static void sd_callback(struct gspca_dev *gspca_dev) | |||
488 | 488 | ||
489 | /*=================== USB driver structure initialisation ==================*/ | 489 | /*=================== USB driver structure initialisation ==================*/ |
490 | 490 | ||
491 | static const __devinitdata struct usb_device_id device_table[] = { | 491 | static const struct usb_device_id device_table[] = { |
492 | {USB_DEVICE(0x05e3, 0x0503)}, | 492 | {USB_DEVICE(0x05e3, 0x0503)}, |
493 | {USB_DEVICE(0x05e3, 0xf191)}, | 493 | {USB_DEVICE(0x05e3, 0xf191)}, |
494 | {} | 494 | {} |
@@ -499,21 +499,8 @@ MODULE_DEVICE_TABLE(usb, device_table); | |||
499 | static int sd_probe(struct usb_interface *intf, | 499 | static int sd_probe(struct usb_interface *intf, |
500 | const struct usb_device_id *id) | 500 | const struct usb_device_id *id) |
501 | { | 501 | { |
502 | struct gspca_dev *gspca_dev; | 502 | return gspca_dev_probe(intf, id, |
503 | s32 ret; | ||
504 | |||
505 | ret = gspca_dev_probe(intf, id, | ||
506 | &sd_desc_mi1320, sizeof(struct sd), THIS_MODULE); | 503 | &sd_desc_mi1320, sizeof(struct sd), THIS_MODULE); |
507 | |||
508 | if (ret >= 0) { | ||
509 | gspca_dev = usb_get_intfdata(intf); | ||
510 | |||
511 | PDEBUG(D_PROBE, | ||
512 | "Camera is now controlling video device %s", | ||
513 | video_device_node_name(&gspca_dev->vdev)); | ||
514 | } | ||
515 | |||
516 | return ret; | ||
517 | } | 504 | } |
518 | 505 | ||
519 | static void sd_disconnect(struct usb_interface *intf) | 506 | static void sd_disconnect(struct usb_interface *intf) |
@@ -540,15 +527,12 @@ static int __init sd_mod_init(void) | |||
540 | 527 | ||
541 | if (usb_register(&sd_driver) < 0) | 528 | if (usb_register(&sd_driver) < 0) |
542 | return -1; | 529 | return -1; |
543 | PDEBUG(D_PROBE, "driver registered"); | ||
544 | |||
545 | return 0; | 530 | return 0; |
546 | } | 531 | } |
547 | 532 | ||
548 | static void __exit sd_mod_exit(void) | 533 | static void __exit sd_mod_exit(void) |
549 | { | 534 | { |
550 | usb_deregister(&sd_driver); | 535 | usb_deregister(&sd_driver); |
551 | PDEBUG(D_PROBE, "driver deregistered"); | ||
552 | } | 536 | } |
553 | 537 | ||
554 | module_init(sd_mod_init); | 538 | module_init(sd_mod_init); |
@@ -588,8 +572,7 @@ int gl860_RTx(struct gspca_dev *gspca_dev, | |||
588 | } | 572 | } |
589 | 573 | ||
590 | if (r < 0) | 574 | if (r < 0) |
591 | PDEBUG(D_ERR, | 575 | err("ctrl transfer failed %4d " |
592 | "ctrl transfer failed %4d " | ||
593 | "[p%02x r%d v%04x i%04x len%d]", | 576 | "[p%02x r%d v%04x i%04x len%d]", |
594 | r, pref, req, val, index, len); | 577 | r, pref, req, val, index, len); |
595 | else if (len > 1 && r < len) | 578 | else if (len > 1 && r < len) |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 78abc1c1f9d5..08ce9948d99b 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Main USB camera driver | 2 | * Main USB camera driver |
3 | * | 3 | * |
4 | * Copyright (C) 2008-2010 Jean-François Moine <http://moinejf.free.fr> | 4 | * Copyright (C) 2008-2011 Jean-François Moine <http://moinejf.free.fr> |
5 | * | 5 | * |
6 | * Camera button input handling by Márton Németh | 6 | * Camera button input handling by Márton Németh |
7 | * Copyright (C) 2009-2010 Márton Németh <nm127@freemail.hu> | 7 | * Copyright (C) 2009-2010 Márton Németh <nm127@freemail.hu> |
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); | |||
55 | MODULE_DESCRIPTION("GSPCA USB Camera Driver"); | 55 | MODULE_DESCRIPTION("GSPCA USB Camera Driver"); |
56 | MODULE_LICENSE("GPL"); | 56 | MODULE_LICENSE("GPL"); |
57 | 57 | ||
58 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 10, 0) | 58 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 13, 0) |
59 | 59 | ||
60 | #ifdef GSPCA_DEBUG | 60 | #ifdef GSPCA_DEBUG |
61 | int gspca_debug = D_ERR | D_PROBE; | 61 | int gspca_debug = D_ERR | D_PROBE; |
@@ -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 { |
@@ -224,12 +224,12 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev, | |||
224 | buffer, buffer_len, | 224 | buffer, buffer_len, |
225 | int_irq, (void *)gspca_dev, interval); | 225 | int_irq, (void *)gspca_dev, interval); |
226 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 226 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
227 | gspca_dev->int_urb = urb; | ||
228 | ret = usb_submit_urb(urb, GFP_KERNEL); | 227 | ret = usb_submit_urb(urb, GFP_KERNEL); |
229 | if (ret < 0) { | 228 | if (ret < 0) { |
230 | PDEBUG(D_ERR, "submit int URB failed with error %i", ret); | 229 | PDEBUG(D_ERR, "submit int URB failed with error %i", ret); |
231 | goto error_submit; | 230 | goto error_submit; |
232 | } | 231 | } |
232 | gspca_dev->int_urb = urb; | ||
233 | return ret; | 233 | return ret; |
234 | 234 | ||
235 | error_submit: | 235 | error_submit: |
@@ -318,22 +318,21 @@ static void fill_frame(struct gspca_dev *gspca_dev, | |||
318 | } | 318 | } |
319 | pkt_scan = gspca_dev->sd_desc->pkt_scan; | 319 | pkt_scan = gspca_dev->sd_desc->pkt_scan; |
320 | for (i = 0; i < urb->number_of_packets; i++) { | 320 | for (i = 0; i < urb->number_of_packets; i++) { |
321 | len = urb->iso_frame_desc[i].actual_length; | ||
321 | 322 | ||
322 | /* check the packet status and length */ | 323 | /* check the packet status and length */ |
323 | len = urb->iso_frame_desc[i].actual_length; | ||
324 | if (len == 0) { | ||
325 | if (gspca_dev->empty_packet == 0) | ||
326 | gspca_dev->empty_packet = 1; | ||
327 | continue; | ||
328 | } | ||
329 | st = urb->iso_frame_desc[i].status; | 324 | st = urb->iso_frame_desc[i].status; |
330 | if (st) { | 325 | if (st) { |
331 | PDEBUG(D_ERR, | 326 | err("ISOC data error: [%d] len=%d, status=%d", |
332 | "ISOC data error: [%d] len=%d, status=%d", | ||
333 | i, len, st); | 327 | i, len, st); |
334 | gspca_dev->last_packet_type = DISCARD_PACKET; | 328 | gspca_dev->last_packet_type = DISCARD_PACKET; |
335 | continue; | 329 | continue; |
336 | } | 330 | } |
331 | if (len == 0) { | ||
332 | if (gspca_dev->empty_packet == 0) | ||
333 | gspca_dev->empty_packet = 1; | ||
334 | continue; | ||
335 | } | ||
337 | 336 | ||
338 | /* let the packet be analyzed by the subdriver */ | 337 | /* let the packet be analyzed by the subdriver */ |
339 | PDEBUG(D_PACK, "packet [%d] o:%d l:%d", | 338 | PDEBUG(D_PACK, "packet [%d] o:%d l:%d", |
@@ -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 | ||
@@ -415,7 +414,6 @@ resubmit: | |||
415 | * - 0 or many INTER_PACKETs | 414 | * - 0 or many INTER_PACKETs |
416 | * - one LAST_PACKET | 415 | * - one LAST_PACKET |
417 | * DISCARD_PACKET invalidates the whole frame. | 416 | * DISCARD_PACKET invalidates the whole frame. |
418 | * On LAST_PACKET, a new frame is returned. | ||
419 | */ | 417 | */ |
420 | void gspca_frame_add(struct gspca_dev *gspca_dev, | 418 | void gspca_frame_add(struct gspca_dev *gspca_dev, |
421 | enum gspca_packet_type packet_type, | 419 | enum gspca_packet_type packet_type, |
@@ -433,12 +431,13 @@ void gspca_frame_add(struct gspca_dev *gspca_dev, | |||
433 | /* if there are no queued buffer, discard the whole frame */ | 431 | /* if there are no queued buffer, discard the whole frame */ |
434 | if (i == atomic_read(&gspca_dev->fr_q)) { | 432 | if (i == atomic_read(&gspca_dev->fr_q)) { |
435 | gspca_dev->last_packet_type = DISCARD_PACKET; | 433 | gspca_dev->last_packet_type = DISCARD_PACKET; |
434 | gspca_dev->sequence++; | ||
436 | return; | 435 | return; |
437 | } | 436 | } |
438 | j = gspca_dev->fr_queue[i]; | 437 | j = gspca_dev->fr_queue[i]; |
439 | frame = &gspca_dev->frame[j]; | 438 | frame = &gspca_dev->frame[j]; |
440 | frame->v4l2_buf.timestamp = ktime_to_timeval(ktime_get()); | 439 | frame->v4l2_buf.timestamp = ktime_to_timeval(ktime_get()); |
441 | frame->v4l2_buf.sequence = ++gspca_dev->sequence; | 440 | frame->v4l2_buf.sequence = gspca_dev->sequence++; |
442 | gspca_dev->image = frame->data; | 441 | gspca_dev->image = frame->data; |
443 | gspca_dev->image_len = 0; | 442 | gspca_dev->image_len = 0; |
444 | } else { | 443 | } else { |
@@ -508,8 +507,8 @@ static int gspca_is_compressed(__u32 format) | |||
508 | return 0; | 507 | return 0; |
509 | } | 508 | } |
510 | 509 | ||
511 | static int frame_alloc(struct gspca_dev *gspca_dev, | 510 | static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file, |
512 | unsigned int count) | 511 | enum v4l2_memory memory, unsigned int count) |
513 | { | 512 | { |
514 | struct gspca_frame *frame; | 513 | struct gspca_frame *frame; |
515 | unsigned int frsz; | 514 | unsigned int frsz; |
@@ -519,7 +518,6 @@ static int frame_alloc(struct gspca_dev *gspca_dev, | |||
519 | frsz = gspca_dev->cam.cam_mode[i].sizeimage; | 518 | frsz = gspca_dev->cam.cam_mode[i].sizeimage; |
520 | PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); | 519 | PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); |
521 | frsz = PAGE_ALIGN(frsz); | 520 | frsz = PAGE_ALIGN(frsz); |
522 | gspca_dev->frsz = frsz; | ||
523 | if (count >= GSPCA_MAX_FRAMES) | 521 | if (count >= GSPCA_MAX_FRAMES) |
524 | count = GSPCA_MAX_FRAMES - 1; | 522 | count = GSPCA_MAX_FRAMES - 1; |
525 | gspca_dev->frbuf = vmalloc_32(frsz * count); | 523 | gspca_dev->frbuf = vmalloc_32(frsz * count); |
@@ -527,6 +525,9 @@ static int frame_alloc(struct gspca_dev *gspca_dev, | |||
527 | err("frame alloc failed"); | 525 | err("frame alloc failed"); |
528 | return -ENOMEM; | 526 | return -ENOMEM; |
529 | } | 527 | } |
528 | gspca_dev->capt_file = file; | ||
529 | gspca_dev->memory = memory; | ||
530 | gspca_dev->frsz = frsz; | ||
530 | gspca_dev->nframes = count; | 531 | gspca_dev->nframes = count; |
531 | for (i = 0; i < count; i++) { | 532 | for (i = 0; i < count; i++) { |
532 | frame = &gspca_dev->frame[i]; | 533 | frame = &gspca_dev->frame[i]; |
@@ -535,7 +536,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev, | |||
535 | frame->v4l2_buf.flags = 0; | 536 | frame->v4l2_buf.flags = 0; |
536 | frame->v4l2_buf.field = V4L2_FIELD_NONE; | 537 | frame->v4l2_buf.field = V4L2_FIELD_NONE; |
537 | frame->v4l2_buf.length = frsz; | 538 | frame->v4l2_buf.length = frsz; |
538 | frame->v4l2_buf.memory = gspca_dev->memory; | 539 | frame->v4l2_buf.memory = memory; |
539 | frame->v4l2_buf.sequence = 0; | 540 | frame->v4l2_buf.sequence = 0; |
540 | frame->data = gspca_dev->frbuf + i * frsz; | 541 | frame->data = gspca_dev->frbuf + i * frsz; |
541 | frame->v4l2_buf.m.offset = i * frsz; | 542 | frame->v4l2_buf.m.offset = i * frsz; |
@@ -558,6 +559,9 @@ static void frame_free(struct gspca_dev *gspca_dev) | |||
558 | gspca_dev->frame[i].data = NULL; | 559 | gspca_dev->frame[i].data = NULL; |
559 | } | 560 | } |
560 | gspca_dev->nframes = 0; | 561 | gspca_dev->nframes = 0; |
562 | gspca_dev->frsz = 0; | ||
563 | gspca_dev->capt_file = NULL; | ||
564 | gspca_dev->memory = GSPCA_MEMORY_NO; | ||
561 | } | 565 | } |
562 | 566 | ||
563 | static void destroy_urbs(struct gspca_dev *gspca_dev) | 567 | static void destroy_urbs(struct gspca_dev *gspca_dev) |
@@ -590,7 +594,7 @@ static int gspca_set_alt0(struct gspca_dev *gspca_dev) | |||
590 | return 0; | 594 | return 0; |
591 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0); | 595 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0); |
592 | if (ret < 0) | 596 | if (ret < 0) |
593 | PDEBUG(D_ERR|D_STREAM, "set alt 0 err %d", ret); | 597 | err("set alt 0 err %d", ret); |
594 | return ret; | 598 | return ret; |
595 | } | 599 | } |
596 | 600 | ||
@@ -626,7 +630,8 @@ static struct usb_host_endpoint *alt_xfer(struct usb_host_interface *alt, | |||
626 | ep = &alt->endpoint[i]; | 630 | ep = &alt->endpoint[i]; |
627 | attr = ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | 631 | attr = ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; |
628 | if (attr == xfer | 632 | if (attr == xfer |
629 | && ep->desc.wMaxPacketSize != 0) | 633 | && ep->desc.wMaxPacketSize != 0 |
634 | && usb_endpoint_dir_in(&ep->desc)) | ||
630 | return ep; | 635 | return ep; |
631 | } | 636 | } |
632 | return NULL; | 637 | return NULL; |
@@ -652,16 +657,12 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev) | |||
652 | : USB_ENDPOINT_XFER_ISOC; | 657 | : USB_ENDPOINT_XFER_ISOC; |
653 | i = gspca_dev->alt; /* previous alt setting */ | 658 | i = gspca_dev->alt; /* previous alt setting */ |
654 | if (gspca_dev->cam.reverse_alts) { | 659 | if (gspca_dev->cam.reverse_alts) { |
655 | if (gspca_dev->audio) | ||
656 | i++; | ||
657 | while (++i < gspca_dev->nbalt) { | 660 | while (++i < gspca_dev->nbalt) { |
658 | ep = alt_xfer(&intf->altsetting[i], xfer); | 661 | ep = alt_xfer(&intf->altsetting[i], xfer); |
659 | if (ep) | 662 | if (ep) |
660 | break; | 663 | break; |
661 | } | 664 | } |
662 | } else { | 665 | } else { |
663 | if (gspca_dev->audio) | ||
664 | i--; | ||
665 | while (--i >= 0) { | 666 | while (--i >= 0) { |
666 | ep = alt_xfer(&intf->altsetting[i], xfer); | 667 | ep = alt_xfer(&intf->altsetting[i], xfer); |
667 | if (ep) | 668 | if (ep) |
@@ -676,13 +677,11 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev) | |||
676 | i, ep->desc.bEndpointAddress); | 677 | i, ep->desc.bEndpointAddress); |
677 | gspca_dev->alt = i; /* memorize the current alt setting */ | 678 | gspca_dev->alt = i; /* memorize the current alt setting */ |
678 | if (gspca_dev->nbalt > 1) { | 679 | if (gspca_dev->nbalt > 1) { |
679 | gspca_input_destroy_urb(gspca_dev); | ||
680 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, i); | 680 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, i); |
681 | if (ret < 0) { | 681 | if (ret < 0) { |
682 | err("set alt %d err %d", i, ret); | 682 | err("set alt %d err %d", i, ret); |
683 | ep = NULL; | 683 | ep = NULL; |
684 | } | 684 | } |
685 | gspca_input_create_urb(gspca_dev); | ||
686 | } | 685 | } |
687 | return ep; | 686 | return ep; |
688 | } | 687 | } |
@@ -759,7 +758,7 @@ static int create_urbs(struct gspca_dev *gspca_dev, | |||
759 | } | 758 | } |
760 | } else { /* bulk */ | 759 | } else { /* bulk */ |
761 | urb->pipe = usb_rcvbulkpipe(gspca_dev->dev, | 760 | urb->pipe = usb_rcvbulkpipe(gspca_dev->dev, |
762 | ep->desc.bEndpointAddress), | 761 | ep->desc.bEndpointAddress); |
763 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | 762 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; |
764 | urb->complete = bulk_irq; | 763 | urb->complete = bulk_irq; |
765 | } | 764 | } |
@@ -781,7 +780,7 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) | |||
781 | 780 | ||
782 | if (!gspca_dev->present) { | 781 | if (!gspca_dev->present) { |
783 | ret = -ENODEV; | 782 | ret = -ENODEV; |
784 | goto out; | 783 | goto unlock; |
785 | } | 784 | } |
786 | 785 | ||
787 | /* reset the streaming variables */ | 786 | /* reset the streaming variables */ |
@@ -802,8 +801,10 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) | |||
802 | if (gspca_dev->sd_desc->isoc_init) { | 801 | if (gspca_dev->sd_desc->isoc_init) { |
803 | ret = gspca_dev->sd_desc->isoc_init(gspca_dev); | 802 | ret = gspca_dev->sd_desc->isoc_init(gspca_dev); |
804 | if (ret < 0) | 803 | if (ret < 0) |
805 | goto out; | 804 | goto unlock; |
806 | } | 805 | } |
806 | |||
807 | gspca_input_destroy_urb(gspca_dev); | ||
807 | ep = get_ep(gspca_dev); | 808 | ep = get_ep(gspca_dev); |
808 | if (ep == NULL) { | 809 | if (ep == NULL) { |
809 | ret = -EIO; | 810 | ret = -EIO; |
@@ -850,14 +851,13 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) | |||
850 | break; | 851 | break; |
851 | gspca_stream_off(gspca_dev); | 852 | gspca_stream_off(gspca_dev); |
852 | if (ret != -ENOSPC) { | 853 | if (ret != -ENOSPC) { |
853 | PDEBUG(D_ERR|D_STREAM, | 854 | err("usb_submit_urb alt %d err %d", |
854 | "usb_submit_urb alt %d err %d", | ||
855 | gspca_dev->alt, ret); | 855 | gspca_dev->alt, ret); |
856 | goto out; | 856 | goto out; |
857 | } | 857 | } |
858 | 858 | ||
859 | /* the bandwidth is not wide enough | 859 | /* the bandwidth is not wide enough |
860 | * negociate or try a lower alternate setting */ | 860 | * negotiate or try a lower alternate setting */ |
861 | PDEBUG(D_ERR|D_STREAM, | 861 | PDEBUG(D_ERR|D_STREAM, |
862 | "bandwidth not wide enough - trying again"); | 862 | "bandwidth not wide enough - trying again"); |
863 | msleep(20); /* wait for kill complete */ | 863 | msleep(20); /* wait for kill complete */ |
@@ -874,12 +874,15 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) | |||
874 | } | 874 | } |
875 | } | 875 | } |
876 | out: | 876 | out: |
877 | gspca_input_create_urb(gspca_dev); | ||
878 | unlock: | ||
877 | mutex_unlock(&gspca_dev->usb_lock); | 879 | mutex_unlock(&gspca_dev->usb_lock); |
878 | return ret; | 880 | return ret; |
879 | } | 881 | } |
880 | 882 | ||
881 | static void gspca_set_default_mode(struct gspca_dev *gspca_dev) | 883 | static void gspca_set_default_mode(struct gspca_dev *gspca_dev) |
882 | { | 884 | { |
885 | struct gspca_ctrl *ctrl; | ||
883 | int i; | 886 | int i; |
884 | 887 | ||
885 | i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ | 888 | i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ |
@@ -887,6 +890,16 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev) | |||
887 | gspca_dev->width = gspca_dev->cam.cam_mode[i].width; | 890 | gspca_dev->width = gspca_dev->cam.cam_mode[i].width; |
888 | gspca_dev->height = gspca_dev->cam.cam_mode[i].height; | 891 | gspca_dev->height = gspca_dev->cam.cam_mode[i].height; |
889 | gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat; | 892 | gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat; |
893 | |||
894 | /* set the current control values to their default values | ||
895 | * which may have changed in sd_init() */ | ||
896 | ctrl = gspca_dev->cam.ctrls; | ||
897 | if (ctrl != NULL) { | ||
898 | for (i = 0; | ||
899 | i < gspca_dev->sd_desc->nctrls; | ||
900 | i++, ctrl++) | ||
901 | ctrl->val = ctrl->def; | ||
902 | } | ||
890 | } | 903 | } |
891 | 904 | ||
892 | static int wxh_to_mode(struct gspca_dev *gspca_dev, | 905 | static int wxh_to_mode(struct gspca_dev *gspca_dev, |
@@ -1202,29 +1215,15 @@ static void gspca_release(struct video_device *vfd) | |||
1202 | static int dev_open(struct file *file) | 1215 | static int dev_open(struct file *file) |
1203 | { | 1216 | { |
1204 | struct gspca_dev *gspca_dev; | 1217 | struct gspca_dev *gspca_dev; |
1205 | int ret; | ||
1206 | 1218 | ||
1207 | PDEBUG(D_STREAM, "[%s] open", current->comm); | 1219 | PDEBUG(D_STREAM, "[%s] open", current->comm); |
1208 | gspca_dev = (struct gspca_dev *) video_devdata(file); | 1220 | gspca_dev = (struct gspca_dev *) video_devdata(file); |
1209 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | 1221 | if (!gspca_dev->present) |
1210 | return -ERESTARTSYS; | 1222 | return -ENODEV; |
1211 | if (!gspca_dev->present) { | ||
1212 | ret = -ENODEV; | ||
1213 | goto out; | ||
1214 | } | ||
1215 | |||
1216 | if (gspca_dev->users > 4) { /* (arbitrary value) */ | ||
1217 | ret = -EBUSY; | ||
1218 | goto out; | ||
1219 | } | ||
1220 | 1223 | ||
1221 | /* protect the subdriver against rmmod */ | 1224 | /* protect the subdriver against rmmod */ |
1222 | if (!try_module_get(gspca_dev->module)) { | 1225 | if (!try_module_get(gspca_dev->module)) |
1223 | ret = -ENODEV; | 1226 | return -ENODEV; |
1224 | goto out; | ||
1225 | } | ||
1226 | |||
1227 | gspca_dev->users++; | ||
1228 | 1227 | ||
1229 | file->private_data = gspca_dev; | 1228 | file->private_data = gspca_dev; |
1230 | #ifdef GSPCA_DEBUG | 1229 | #ifdef GSPCA_DEBUG |
@@ -1236,14 +1235,7 @@ static int dev_open(struct file *file) | |||
1236 | gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL | 1235 | gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL |
1237 | | V4L2_DEBUG_IOCTL_ARG); | 1236 | | V4L2_DEBUG_IOCTL_ARG); |
1238 | #endif | 1237 | #endif |
1239 | ret = 0; | 1238 | return 0; |
1240 | out: | ||
1241 | mutex_unlock(&gspca_dev->queue_lock); | ||
1242 | if (ret != 0) | ||
1243 | PDEBUG(D_ERR|D_STREAM, "open failed err %d", ret); | ||
1244 | else | ||
1245 | PDEBUG(D_STREAM, "open done"); | ||
1246 | return ret; | ||
1247 | } | 1239 | } |
1248 | 1240 | ||
1249 | static int dev_close(struct file *file) | 1241 | static int dev_close(struct file *file) |
@@ -1253,7 +1245,6 @@ static int dev_close(struct file *file) | |||
1253 | PDEBUG(D_STREAM, "[%s] close", current->comm); | 1245 | PDEBUG(D_STREAM, "[%s] close", current->comm); |
1254 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | 1246 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) |
1255 | return -ERESTARTSYS; | 1247 | return -ERESTARTSYS; |
1256 | gspca_dev->users--; | ||
1257 | 1248 | ||
1258 | /* if the file did the capture, free the streaming resources */ | 1249 | /* if the file did the capture, free the streaming resources */ |
1259 | if (gspca_dev->capt_file == file) { | 1250 | if (gspca_dev->capt_file == file) { |
@@ -1264,8 +1255,6 @@ static int dev_close(struct file *file) | |||
1264 | mutex_unlock(&gspca_dev->usb_lock); | 1255 | mutex_unlock(&gspca_dev->usb_lock); |
1265 | } | 1256 | } |
1266 | frame_free(gspca_dev); | 1257 | frame_free(gspca_dev); |
1267 | gspca_dev->capt_file = NULL; | ||
1268 | gspca_dev->memory = GSPCA_MEMORY_NO; | ||
1269 | } | 1258 | } |
1270 | file->private_data = NULL; | 1259 | file->private_data = NULL; |
1271 | module_put(gspca_dev->module); | 1260 | module_put(gspca_dev->module); |
@@ -1289,17 +1278,19 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
1289 | ret = -ENODEV; | 1278 | ret = -ENODEV; |
1290 | goto out; | 1279 | goto out; |
1291 | } | 1280 | } |
1292 | strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver); | 1281 | strncpy((char *) cap->driver, gspca_dev->sd_desc->name, |
1282 | sizeof cap->driver); | ||
1293 | if (gspca_dev->dev->product != NULL) { | 1283 | if (gspca_dev->dev->product != NULL) { |
1294 | strncpy(cap->card, gspca_dev->dev->product, | 1284 | strncpy((char *) cap->card, gspca_dev->dev->product, |
1295 | sizeof cap->card); | 1285 | sizeof cap->card); |
1296 | } else { | 1286 | } else { |
1297 | snprintf(cap->card, sizeof cap->card, | 1287 | snprintf((char *) cap->card, sizeof cap->card, |
1298 | "USB Camera (%04x:%04x)", | 1288 | "USB Camera (%04x:%04x)", |
1299 | le16_to_cpu(gspca_dev->dev->descriptor.idVendor), | 1289 | le16_to_cpu(gspca_dev->dev->descriptor.idVendor), |
1300 | le16_to_cpu(gspca_dev->dev->descriptor.idProduct)); | 1290 | le16_to_cpu(gspca_dev->dev->descriptor.idProduct)); |
1301 | } | 1291 | } |
1302 | usb_make_path(gspca_dev->dev, cap->bus_info, sizeof(cap->bus_info)); | 1292 | usb_make_path(gspca_dev->dev, (char *) cap->bus_info, |
1293 | sizeof(cap->bus_info)); | ||
1303 | cap->version = DRIVER_VERSION_NUMBER; | 1294 | cap->version = DRIVER_VERSION_NUMBER; |
1304 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | 1295 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
1305 | | V4L2_CAP_STREAMING | 1296 | | V4L2_CAP_STREAMING |
@@ -1310,7 +1301,7 @@ out: | |||
1310 | return ret; | 1301 | return ret; |
1311 | } | 1302 | } |
1312 | 1303 | ||
1313 | static const struct ctrl *get_ctrl(struct gspca_dev *gspca_dev, | 1304 | static int get_ctrl(struct gspca_dev *gspca_dev, |
1314 | int id) | 1305 | int id) |
1315 | { | 1306 | { |
1316 | const struct ctrl *ctrls; | 1307 | const struct ctrl *ctrls; |
@@ -1322,9 +1313,9 @@ static const struct ctrl *get_ctrl(struct gspca_dev *gspca_dev, | |||
1322 | if (gspca_dev->ctrl_dis & (1 << i)) | 1313 | if (gspca_dev->ctrl_dis & (1 << i)) |
1323 | continue; | 1314 | continue; |
1324 | if (id == ctrls->qctrl.id) | 1315 | if (id == ctrls->qctrl.id) |
1325 | return ctrls; | 1316 | return i; |
1326 | } | 1317 | } |
1327 | return NULL; | 1318 | return -1; |
1328 | } | 1319 | } |
1329 | 1320 | ||
1330 | static int vidioc_queryctrl(struct file *file, void *priv, | 1321 | static int vidioc_queryctrl(struct file *file, void *priv, |
@@ -1332,34 +1323,40 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
1332 | { | 1323 | { |
1333 | struct gspca_dev *gspca_dev = priv; | 1324 | struct gspca_dev *gspca_dev = priv; |
1334 | const struct ctrl *ctrls; | 1325 | const struct ctrl *ctrls; |
1335 | int i; | 1326 | struct gspca_ctrl *gspca_ctrl; |
1327 | int i, idx; | ||
1336 | u32 id; | 1328 | u32 id; |
1337 | 1329 | ||
1338 | ctrls = NULL; | ||
1339 | id = q_ctrl->id; | 1330 | id = q_ctrl->id; |
1340 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 1331 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
1341 | id &= V4L2_CTRL_ID_MASK; | 1332 | id &= V4L2_CTRL_ID_MASK; |
1342 | id++; | 1333 | id++; |
1334 | idx = -1; | ||
1343 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 1335 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
1344 | if (gspca_dev->ctrl_dis & (1 << i)) | 1336 | if (gspca_dev->ctrl_dis & (1 << i)) |
1345 | continue; | 1337 | continue; |
1346 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) | 1338 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) |
1347 | continue; | 1339 | continue; |
1348 | if (ctrls && gspca_dev->sd_desc->ctrls[i].qctrl.id | 1340 | if (idx >= 0 |
1349 | > ctrls->qctrl.id) | 1341 | && gspca_dev->sd_desc->ctrls[i].qctrl.id |
1342 | > gspca_dev->sd_desc->ctrls[idx].qctrl.id) | ||
1350 | continue; | 1343 | continue; |
1351 | ctrls = &gspca_dev->sd_desc->ctrls[i]; | 1344 | idx = i; |
1352 | } | 1345 | } |
1353 | if (ctrls == NULL) | ||
1354 | return -EINVAL; | ||
1355 | } else { | 1346 | } else { |
1356 | ctrls = get_ctrl(gspca_dev, id); | 1347 | idx = get_ctrl(gspca_dev, id); |
1357 | if (ctrls == NULL) | ||
1358 | return -EINVAL; | ||
1359 | i = ctrls - gspca_dev->sd_desc->ctrls; | ||
1360 | } | 1348 | } |
1361 | memcpy(q_ctrl, ctrls, sizeof *q_ctrl); | 1349 | if (idx < 0) |
1362 | if (gspca_dev->ctrl_inac & (1 << i)) | 1350 | return -EINVAL; |
1351 | ctrls = &gspca_dev->sd_desc->ctrls[idx]; | ||
1352 | memcpy(q_ctrl, &ctrls->qctrl, sizeof *q_ctrl); | ||
1353 | if (gspca_dev->cam.ctrls != NULL) { | ||
1354 | gspca_ctrl = &gspca_dev->cam.ctrls[idx]; | ||
1355 | q_ctrl->default_value = gspca_ctrl->def; | ||
1356 | q_ctrl->minimum = gspca_ctrl->min; | ||
1357 | q_ctrl->maximum = gspca_ctrl->max; | ||
1358 | } | ||
1359 | if (gspca_dev->ctrl_inac & (1 << idx)) | ||
1363 | q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; | 1360 | q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; |
1364 | return 0; | 1361 | return 0; |
1365 | } | 1362 | } |
@@ -1369,23 +1366,46 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1369 | { | 1366 | { |
1370 | struct gspca_dev *gspca_dev = priv; | 1367 | struct gspca_dev *gspca_dev = priv; |
1371 | const struct ctrl *ctrls; | 1368 | const struct ctrl *ctrls; |
1372 | int ret; | 1369 | struct gspca_ctrl *gspca_ctrl; |
1370 | int idx, ret; | ||
1373 | 1371 | ||
1374 | ctrls = get_ctrl(gspca_dev, ctrl->id); | 1372 | idx = get_ctrl(gspca_dev, ctrl->id); |
1375 | if (ctrls == NULL) | 1373 | if (idx < 0) |
1376 | return -EINVAL; | 1374 | return -EINVAL; |
1377 | 1375 | if (gspca_dev->ctrl_inac & (1 << idx)) | |
1378 | if (ctrl->value < ctrls->qctrl.minimum | 1376 | return -EINVAL; |
1379 | || ctrl->value > ctrls->qctrl.maximum) | 1377 | ctrls = &gspca_dev->sd_desc->ctrls[idx]; |
1380 | return -ERANGE; | 1378 | if (gspca_dev->cam.ctrls != NULL) { |
1379 | gspca_ctrl = &gspca_dev->cam.ctrls[idx]; | ||
1380 | if (ctrl->value < gspca_ctrl->min | ||
1381 | || ctrl->value > gspca_ctrl->max) | ||
1382 | return -ERANGE; | ||
1383 | } else { | ||
1384 | gspca_ctrl = NULL; | ||
1385 | if (ctrl->value < ctrls->qctrl.minimum | ||
1386 | || ctrl->value > ctrls->qctrl.maximum) | ||
1387 | return -ERANGE; | ||
1388 | } | ||
1381 | PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value); | 1389 | PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value); |
1382 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1390 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1383 | return -ERESTARTSYS; | 1391 | return -ERESTARTSYS; |
1392 | if (!gspca_dev->present) { | ||
1393 | ret = -ENODEV; | ||
1394 | goto out; | ||
1395 | } | ||
1384 | gspca_dev->usb_err = 0; | 1396 | gspca_dev->usb_err = 0; |
1385 | if (gspca_dev->present) | 1397 | if (ctrls->set != NULL) { |
1386 | ret = ctrls->set(gspca_dev, ctrl->value); | 1398 | ret = ctrls->set(gspca_dev, ctrl->value); |
1387 | else | 1399 | goto out; |
1388 | ret = -ENODEV; | 1400 | } |
1401 | if (gspca_ctrl != NULL) { | ||
1402 | gspca_ctrl->val = ctrl->value; | ||
1403 | if (ctrls->set_control != NULL | ||
1404 | && gspca_dev->streaming) | ||
1405 | ctrls->set_control(gspca_dev); | ||
1406 | } | ||
1407 | ret = gspca_dev->usb_err; | ||
1408 | out: | ||
1389 | mutex_unlock(&gspca_dev->usb_lock); | 1409 | mutex_unlock(&gspca_dev->usb_lock); |
1390 | return ret; | 1410 | return ret; |
1391 | } | 1411 | } |
@@ -1395,19 +1415,28 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
1395 | { | 1415 | { |
1396 | struct gspca_dev *gspca_dev = priv; | 1416 | struct gspca_dev *gspca_dev = priv; |
1397 | const struct ctrl *ctrls; | 1417 | const struct ctrl *ctrls; |
1398 | int ret; | 1418 | int idx, ret; |
1399 | 1419 | ||
1400 | ctrls = get_ctrl(gspca_dev, ctrl->id); | 1420 | idx = get_ctrl(gspca_dev, ctrl->id); |
1401 | if (ctrls == NULL) | 1421 | if (idx < 0) |
1402 | return -EINVAL; | 1422 | return -EINVAL; |
1423 | ctrls = &gspca_dev->sd_desc->ctrls[idx]; | ||
1403 | 1424 | ||
1404 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1425 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1405 | return -ERESTARTSYS; | 1426 | return -ERESTARTSYS; |
1427 | if (!gspca_dev->present) { | ||
1428 | ret = -ENODEV; | ||
1429 | goto out; | ||
1430 | } | ||
1406 | gspca_dev->usb_err = 0; | 1431 | gspca_dev->usb_err = 0; |
1407 | if (gspca_dev->present) | 1432 | if (ctrls->get != NULL) { |
1408 | ret = ctrls->get(gspca_dev, &ctrl->value); | 1433 | ret = ctrls->get(gspca_dev, &ctrl->value); |
1409 | else | 1434 | goto out; |
1410 | ret = -ENODEV; | 1435 | } |
1436 | if (gspca_dev->cam.ctrls != NULL) | ||
1437 | ctrl->value = gspca_dev->cam.ctrls[idx].val; | ||
1438 | ret = 0; | ||
1439 | out: | ||
1411 | mutex_unlock(&gspca_dev->usb_lock); | 1440 | mutex_unlock(&gspca_dev->usb_lock); |
1412 | return ret; | 1441 | return ret; |
1413 | } | 1442 | } |
@@ -1468,6 +1497,7 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
1468 | return -ERESTARTSYS; | 1497 | return -ERESTARTSYS; |
1469 | 1498 | ||
1470 | if (gspca_dev->memory != GSPCA_MEMORY_NO | 1499 | if (gspca_dev->memory != GSPCA_MEMORY_NO |
1500 | && gspca_dev->memory != GSPCA_MEMORY_READ | ||
1471 | && gspca_dev->memory != rb->memory) { | 1501 | && gspca_dev->memory != rb->memory) { |
1472 | ret = -EBUSY; | 1502 | ret = -EBUSY; |
1473 | goto out; | 1503 | goto out; |
@@ -1495,20 +1525,21 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
1495 | gspca_dev->usb_err = 0; | 1525 | gspca_dev->usb_err = 0; |
1496 | gspca_stream_off(gspca_dev); | 1526 | gspca_stream_off(gspca_dev); |
1497 | mutex_unlock(&gspca_dev->usb_lock); | 1527 | mutex_unlock(&gspca_dev->usb_lock); |
1528 | |||
1529 | /* Don't restart the stream when switching from read | ||
1530 | * to mmap mode */ | ||
1531 | if (gspca_dev->memory == GSPCA_MEMORY_READ) | ||
1532 | streaming = 0; | ||
1498 | } | 1533 | } |
1499 | 1534 | ||
1500 | /* free the previous allocated buffers, if any */ | 1535 | /* free the previous allocated buffers, if any */ |
1501 | if (gspca_dev->nframes != 0) { | 1536 | if (gspca_dev->nframes != 0) |
1502 | frame_free(gspca_dev); | 1537 | frame_free(gspca_dev); |
1503 | gspca_dev->capt_file = NULL; | ||
1504 | } | ||
1505 | if (rb->count == 0) /* unrequest */ | 1538 | if (rb->count == 0) /* unrequest */ |
1506 | goto out; | 1539 | goto out; |
1507 | gspca_dev->memory = rb->memory; | 1540 | ret = frame_alloc(gspca_dev, file, rb->memory, rb->count); |
1508 | ret = frame_alloc(gspca_dev, rb->count); | ||
1509 | if (ret == 0) { | 1541 | if (ret == 0) { |
1510 | rb->count = gspca_dev->nframes; | 1542 | rb->count = gspca_dev->nframes; |
1511 | gspca_dev->capt_file = file; | ||
1512 | if (streaming) | 1543 | if (streaming) |
1513 | ret = gspca_init_transfer(gspca_dev); | 1544 | ret = gspca_init_transfer(gspca_dev); |
1514 | } | 1545 | } |
@@ -1582,11 +1613,15 @@ static int vidioc_streamoff(struct file *file, void *priv, | |||
1582 | 1613 | ||
1583 | if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1614 | if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1584 | return -EINVAL; | 1615 | return -EINVAL; |
1585 | if (!gspca_dev->streaming) | 1616 | |
1586 | return 0; | ||
1587 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | 1617 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) |
1588 | return -ERESTARTSYS; | 1618 | return -ERESTARTSYS; |
1589 | 1619 | ||
1620 | if (!gspca_dev->streaming) { | ||
1621 | ret = 0; | ||
1622 | goto out; | ||
1623 | } | ||
1624 | |||
1590 | /* check the capture file */ | 1625 | /* check the capture file */ |
1591 | if (gspca_dev->capt_file != file) { | 1626 | if (gspca_dev->capt_file != file) { |
1592 | ret = -EBUSY; | 1627 | ret = -EBUSY; |
@@ -1601,6 +1636,8 @@ static int vidioc_streamoff(struct file *file, void *priv, | |||
1601 | gspca_dev->usb_err = 0; | 1636 | gspca_dev->usb_err = 0; |
1602 | gspca_stream_off(gspca_dev); | 1637 | gspca_stream_off(gspca_dev); |
1603 | mutex_unlock(&gspca_dev->usb_lock); | 1638 | mutex_unlock(&gspca_dev->usb_lock); |
1639 | /* In case another thread is waiting in dqbuf */ | ||
1640 | wake_up_interruptible(&gspca_dev->wq); | ||
1604 | 1641 | ||
1605 | /* empty the transfer queues */ | 1642 | /* empty the transfer queues */ |
1606 | atomic_set(&gspca_dev->fr_q, 0); | 1643 | atomic_set(&gspca_dev->fr_q, 0); |
@@ -1662,12 +1699,13 @@ static int vidioc_g_parm(struct file *filp, void *priv, | |||
1662 | 1699 | ||
1663 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1700 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1664 | return -ERESTARTSYS; | 1701 | return -ERESTARTSYS; |
1665 | gspca_dev->usb_err = 0; | 1702 | if (gspca_dev->present) { |
1666 | if (gspca_dev->present) | 1703 | gspca_dev->usb_err = 0; |
1667 | ret = gspca_dev->sd_desc->get_streamparm(gspca_dev, | 1704 | gspca_dev->sd_desc->get_streamparm(gspca_dev, parm); |
1668 | parm); | 1705 | ret = gspca_dev->usb_err; |
1669 | else | 1706 | } else { |
1670 | ret = -ENODEV; | 1707 | ret = -ENODEV; |
1708 | } | ||
1671 | mutex_unlock(&gspca_dev->usb_lock); | 1709 | mutex_unlock(&gspca_dev->usb_lock); |
1672 | return ret; | 1710 | return ret; |
1673 | } | 1711 | } |
@@ -1692,12 +1730,13 @@ static int vidioc_s_parm(struct file *filp, void *priv, | |||
1692 | 1730 | ||
1693 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 1731 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
1694 | return -ERESTARTSYS; | 1732 | return -ERESTARTSYS; |
1695 | gspca_dev->usb_err = 0; | 1733 | if (gspca_dev->present) { |
1696 | if (gspca_dev->present) | 1734 | gspca_dev->usb_err = 0; |
1697 | ret = gspca_dev->sd_desc->set_streamparm(gspca_dev, | 1735 | gspca_dev->sd_desc->set_streamparm(gspca_dev, parm); |
1698 | parm); | 1736 | ret = gspca_dev->usb_err; |
1699 | else | 1737 | } else { |
1700 | ret = -ENODEV; | 1738 | ret = -ENODEV; |
1739 | } | ||
1701 | mutex_unlock(&gspca_dev->usb_lock); | 1740 | mutex_unlock(&gspca_dev->usb_lock); |
1702 | return ret; | 1741 | return ret; |
1703 | } | 1742 | } |
@@ -1777,33 +1816,77 @@ out: | |||
1777 | return ret; | 1816 | return ret; |
1778 | } | 1817 | } |
1779 | 1818 | ||
1819 | static int frame_ready_nolock(struct gspca_dev *gspca_dev, struct file *file, | ||
1820 | enum v4l2_memory memory) | ||
1821 | { | ||
1822 | if (!gspca_dev->present) | ||
1823 | return -ENODEV; | ||
1824 | if (gspca_dev->capt_file != file || gspca_dev->memory != memory || | ||
1825 | !gspca_dev->streaming) | ||
1826 | return -EINVAL; | ||
1827 | |||
1828 | /* check if a frame is ready */ | ||
1829 | return gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i); | ||
1830 | } | ||
1831 | |||
1832 | static int frame_ready(struct gspca_dev *gspca_dev, struct file *file, | ||
1833 | enum v4l2_memory memory) | ||
1834 | { | ||
1835 | int ret; | ||
1836 | |||
1837 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | ||
1838 | return -ERESTARTSYS; | ||
1839 | ret = frame_ready_nolock(gspca_dev, file, memory); | ||
1840 | mutex_unlock(&gspca_dev->queue_lock); | ||
1841 | return ret; | ||
1842 | } | ||
1843 | |||
1780 | /* | 1844 | /* |
1781 | * wait for a video frame | 1845 | * dequeue a video buffer |
1782 | * | 1846 | * |
1783 | * If a frame is ready, its index is returned. | 1847 | * If nonblock_ing is false, block until a buffer is available. |
1784 | */ | 1848 | */ |
1785 | static int frame_wait(struct gspca_dev *gspca_dev, | 1849 | static int vidioc_dqbuf(struct file *file, void *priv, |
1786 | int nonblock_ing) | 1850 | struct v4l2_buffer *v4l2_buf) |
1787 | { | 1851 | { |
1788 | int i, ret; | 1852 | struct gspca_dev *gspca_dev = priv; |
1853 | struct gspca_frame *frame; | ||
1854 | int i, j, ret; | ||
1789 | 1855 | ||
1790 | /* check if a frame is ready */ | 1856 | PDEBUG(D_FRAM, "dqbuf"); |
1791 | i = gspca_dev->fr_o; | 1857 | |
1792 | if (i == atomic_read(&gspca_dev->fr_i)) { | 1858 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) |
1793 | if (nonblock_ing) | 1859 | return -ERESTARTSYS; |
1860 | |||
1861 | for (;;) { | ||
1862 | ret = frame_ready_nolock(gspca_dev, file, v4l2_buf->memory); | ||
1863 | if (ret < 0) | ||
1864 | goto out; | ||
1865 | if (ret > 0) | ||
1866 | break; | ||
1867 | |||
1868 | mutex_unlock(&gspca_dev->queue_lock); | ||
1869 | |||
1870 | if (file->f_flags & O_NONBLOCK) | ||
1794 | return -EAGAIN; | 1871 | return -EAGAIN; |
1795 | 1872 | ||
1796 | /* wait till a frame is ready */ | 1873 | /* wait till a frame is ready */ |
1797 | ret = wait_event_interruptible_timeout(gspca_dev->wq, | 1874 | ret = wait_event_interruptible_timeout(gspca_dev->wq, |
1798 | i != atomic_read(&gspca_dev->fr_i) || | 1875 | frame_ready(gspca_dev, file, v4l2_buf->memory), |
1799 | !gspca_dev->streaming || !gspca_dev->present, | ||
1800 | msecs_to_jiffies(3000)); | 1876 | msecs_to_jiffies(3000)); |
1801 | if (ret < 0) | 1877 | if (ret < 0) |
1802 | return ret; | 1878 | return ret; |
1803 | if (ret == 0 || !gspca_dev->streaming || !gspca_dev->present) | 1879 | if (ret == 0) |
1804 | return -EIO; | 1880 | return -EIO; |
1881 | |||
1882 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | ||
1883 | return -ERESTARTSYS; | ||
1805 | } | 1884 | } |
1806 | 1885 | ||
1886 | i = gspca_dev->fr_o; | ||
1887 | j = gspca_dev->fr_queue[i]; | ||
1888 | frame = &gspca_dev->frame[j]; | ||
1889 | |||
1807 | gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES; | 1890 | gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES; |
1808 | 1891 | ||
1809 | if (gspca_dev->sd_desc->dq_callback) { | 1892 | if (gspca_dev->sd_desc->dq_callback) { |
@@ -1813,46 +1896,12 @@ static int frame_wait(struct gspca_dev *gspca_dev, | |||
1813 | gspca_dev->sd_desc->dq_callback(gspca_dev); | 1896 | gspca_dev->sd_desc->dq_callback(gspca_dev); |
1814 | mutex_unlock(&gspca_dev->usb_lock); | 1897 | mutex_unlock(&gspca_dev->usb_lock); |
1815 | } | 1898 | } |
1816 | return gspca_dev->fr_queue[i]; | ||
1817 | } | ||
1818 | |||
1819 | /* | ||
1820 | * dequeue a video buffer | ||
1821 | * | ||
1822 | * If nonblock_ing is false, block until a buffer is available. | ||
1823 | */ | ||
1824 | static int vidioc_dqbuf(struct file *file, void *priv, | ||
1825 | struct v4l2_buffer *v4l2_buf) | ||
1826 | { | ||
1827 | struct gspca_dev *gspca_dev = priv; | ||
1828 | struct gspca_frame *frame; | ||
1829 | int i, ret; | ||
1830 | 1899 | ||
1831 | PDEBUG(D_FRAM, "dqbuf"); | 1900 | frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; |
1832 | if (v4l2_buf->memory != gspca_dev->memory) | 1901 | memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf); |
1833 | return -EINVAL; | 1902 | PDEBUG(D_FRAM, "dqbuf %d", j); |
1834 | 1903 | ret = 0; | |
1835 | if (!gspca_dev->present) | ||
1836 | return -ENODEV; | ||
1837 | |||
1838 | /* if not streaming, be sure the application will not loop forever */ | ||
1839 | if (!(file->f_flags & O_NONBLOCK) | ||
1840 | && !gspca_dev->streaming && gspca_dev->users == 1) | ||
1841 | return -EINVAL; | ||
1842 | |||
1843 | /* only the capturing file may dequeue */ | ||
1844 | if (gspca_dev->capt_file != file) | ||
1845 | return -EINVAL; | ||
1846 | |||
1847 | /* only one dequeue / read at a time */ | ||
1848 | if (mutex_lock_interruptible(&gspca_dev->read_lock)) | ||
1849 | return -ERESTARTSYS; | ||
1850 | 1904 | ||
1851 | ret = frame_wait(gspca_dev, file->f_flags & O_NONBLOCK); | ||
1852 | if (ret < 0) | ||
1853 | goto out; | ||
1854 | i = ret; /* frame index */ | ||
1855 | frame = &gspca_dev->frame[i]; | ||
1856 | if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { | 1905 | if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { |
1857 | if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, | 1906 | if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, |
1858 | frame->data, | 1907 | frame->data, |
@@ -1860,15 +1909,10 @@ static int vidioc_dqbuf(struct file *file, void *priv, | |||
1860 | PDEBUG(D_ERR|D_STREAM, | 1909 | PDEBUG(D_ERR|D_STREAM, |
1861 | "dqbuf cp to user failed"); | 1910 | "dqbuf cp to user failed"); |
1862 | ret = -EFAULT; | 1911 | ret = -EFAULT; |
1863 | goto out; | ||
1864 | } | 1912 | } |
1865 | } | 1913 | } |
1866 | frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE; | ||
1867 | memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf); | ||
1868 | PDEBUG(D_FRAM, "dqbuf %d", i); | ||
1869 | ret = 0; | ||
1870 | out: | 1914 | out: |
1871 | mutex_unlock(&gspca_dev->read_lock); | 1915 | mutex_unlock(&gspca_dev->queue_lock); |
1872 | return ret; | 1916 | return ret; |
1873 | } | 1917 | } |
1874 | 1918 | ||
@@ -1983,9 +2027,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait) | |||
1983 | poll_wait(file, &gspca_dev->wq, wait); | 2027 | poll_wait(file, &gspca_dev->wq, wait); |
1984 | 2028 | ||
1985 | /* if reqbufs is not done, the user would use read() */ | 2029 | /* if reqbufs is not done, the user would use read() */ |
1986 | if (gspca_dev->nframes == 0) { | 2030 | if (gspca_dev->memory == GSPCA_MEMORY_NO) { |
1987 | if (gspca_dev->memory != GSPCA_MEMORY_NO) | ||
1988 | return POLLERR; /* not the 1st time */ | ||
1989 | ret = read_alloc(gspca_dev, file); | 2031 | ret = read_alloc(gspca_dev, file); |
1990 | if (ret != 0) | 2032 | if (ret != 0) |
1991 | return POLLERR; | 2033 | return POLLERR; |
@@ -2017,18 +2059,10 @@ static ssize_t dev_read(struct file *file, char __user *data, | |||
2017 | PDEBUG(D_FRAM, "read (%zd)", count); | 2059 | PDEBUG(D_FRAM, "read (%zd)", count); |
2018 | if (!gspca_dev->present) | 2060 | if (!gspca_dev->present) |
2019 | return -ENODEV; | 2061 | return -ENODEV; |
2020 | switch (gspca_dev->memory) { | 2062 | if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* first time ? */ |
2021 | case GSPCA_MEMORY_NO: /* first time */ | ||
2022 | ret = read_alloc(gspca_dev, file); | 2063 | ret = read_alloc(gspca_dev, file); |
2023 | if (ret != 0) | 2064 | if (ret != 0) |
2024 | return ret; | 2065 | return ret; |
2025 | break; | ||
2026 | case GSPCA_MEMORY_READ: | ||
2027 | if (gspca_dev->capt_file == file) | ||
2028 | break; | ||
2029 | /* fall thru */ | ||
2030 | default: | ||
2031 | return -EINVAL; | ||
2032 | } | 2066 | } |
2033 | 2067 | ||
2034 | /* get a frame */ | 2068 | /* get a frame */ |
@@ -2120,13 +2154,29 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = { | |||
2120 | .vidioc_g_chip_ident = vidioc_g_chip_ident, | 2154 | .vidioc_g_chip_ident = vidioc_g_chip_ident, |
2121 | }; | 2155 | }; |
2122 | 2156 | ||
2123 | static struct video_device gspca_template = { | 2157 | static const struct video_device gspca_template = { |
2124 | .name = "gspca main driver", | 2158 | .name = "gspca main driver", |
2125 | .fops = &dev_fops, | 2159 | .fops = &dev_fops, |
2126 | .ioctl_ops = &dev_ioctl_ops, | 2160 | .ioctl_ops = &dev_ioctl_ops, |
2127 | .release = gspca_release, | 2161 | .release = gspca_release, |
2128 | }; | 2162 | }; |
2129 | 2163 | ||
2164 | /* initialize the controls */ | ||
2165 | static void ctrls_init(struct gspca_dev *gspca_dev) | ||
2166 | { | ||
2167 | struct gspca_ctrl *ctrl; | ||
2168 | int i; | ||
2169 | |||
2170 | for (i = 0, ctrl = gspca_dev->cam.ctrls; | ||
2171 | i < gspca_dev->sd_desc->nctrls; | ||
2172 | i++, ctrl++) { | ||
2173 | ctrl->def = gspca_dev->sd_desc->ctrls[i].qctrl.default_value; | ||
2174 | ctrl->val = ctrl->def; | ||
2175 | ctrl->min = gspca_dev->sd_desc->ctrls[i].qctrl.minimum; | ||
2176 | ctrl->max = gspca_dev->sd_desc->ctrls[i].qctrl.maximum; | ||
2177 | } | ||
2178 | } | ||
2179 | |||
2130 | /* | 2180 | /* |
2131 | * probe and create a new gspca device | 2181 | * probe and create a new gspca device |
2132 | * | 2182 | * |
@@ -2188,6 +2238,8 @@ int gspca_dev_probe2(struct usb_interface *intf, | |||
2188 | ret = sd_desc->config(gspca_dev, id); | 2238 | ret = sd_desc->config(gspca_dev, id); |
2189 | if (ret < 0) | 2239 | if (ret < 0) |
2190 | goto out; | 2240 | goto out; |
2241 | if (gspca_dev->cam.ctrls != NULL) | ||
2242 | ctrls_init(gspca_dev); | ||
2191 | ret = sd_desc->init(gspca_dev); | 2243 | ret = sd_desc->init(gspca_dev); |
2192 | if (ret < 0) | 2244 | if (ret < 0) |
2193 | goto out; | 2245 | goto out; |
@@ -2198,7 +2250,6 @@ int gspca_dev_probe2(struct usb_interface *intf, | |||
2198 | goto out; | 2250 | goto out; |
2199 | 2251 | ||
2200 | mutex_init(&gspca_dev->usb_lock); | 2252 | mutex_init(&gspca_dev->usb_lock); |
2201 | mutex_init(&gspca_dev->read_lock); | ||
2202 | mutex_init(&gspca_dev->queue_lock); | 2253 | mutex_init(&gspca_dev->queue_lock); |
2203 | init_waitqueue_head(&gspca_dev->wq); | 2254 | init_waitqueue_head(&gspca_dev->wq); |
2204 | 2255 | ||
@@ -2243,7 +2294,7 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
2243 | 2294 | ||
2244 | /* we don't handle multi-config cameras */ | 2295 | /* we don't handle multi-config cameras */ |
2245 | if (dev->descriptor.bNumConfigurations != 1) { | 2296 | if (dev->descriptor.bNumConfigurations != 1) { |
2246 | PDEBUG(D_ERR, "%04x:%04x too many config", | 2297 | err("%04x:%04x too many config", |
2247 | id->idVendor, id->idProduct); | 2298 | id->idVendor, id->idProduct); |
2248 | return -ENODEV; | 2299 | return -ENODEV; |
2249 | } | 2300 | } |
@@ -2273,12 +2324,11 @@ void gspca_disconnect(struct usb_interface *intf) | |||
2273 | PDEBUG(D_PROBE, "%s disconnect", | 2324 | PDEBUG(D_PROBE, "%s disconnect", |
2274 | video_device_node_name(&gspca_dev->vdev)); | 2325 | video_device_node_name(&gspca_dev->vdev)); |
2275 | mutex_lock(&gspca_dev->usb_lock); | 2326 | mutex_lock(&gspca_dev->usb_lock); |
2327 | |||
2276 | gspca_dev->present = 0; | 2328 | gspca_dev->present = 0; |
2329 | wake_up_interruptible(&gspca_dev->wq); | ||
2277 | 2330 | ||
2278 | if (gspca_dev->streaming) { | 2331 | destroy_urbs(gspca_dev); |
2279 | destroy_urbs(gspca_dev); | ||
2280 | wake_up_interruptible(&gspca_dev->wq); | ||
2281 | } | ||
2282 | 2332 | ||
2283 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2333 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
2284 | gspca_input_destroy_urb(gspca_dev); | 2334 | gspca_input_destroy_urb(gspca_dev); |
@@ -2296,7 +2346,7 @@ void gspca_disconnect(struct usb_interface *intf) | |||
2296 | usb_set_intfdata(intf, NULL); | 2346 | usb_set_intfdata(intf, NULL); |
2297 | 2347 | ||
2298 | /* release the device */ | 2348 | /* release the device */ |
2299 | /* (this will call gspca_release() immediatly or on last close) */ | 2349 | /* (this will call gspca_release() immediately or on last close) */ |
2300 | video_unregister_device(&gspca_dev->vdev); | 2350 | video_unregister_device(&gspca_dev->vdev); |
2301 | 2351 | ||
2302 | /* PDEBUG(D_PROBE, "disconnect complete"); */ | 2352 | /* PDEBUG(D_PROBE, "disconnect complete"); */ |
@@ -2428,7 +2478,7 @@ EXPORT_SYMBOL(gspca_auto_gain_n_exposure); | |||
2428 | /* -- module insert / remove -- */ | 2478 | /* -- module insert / remove -- */ |
2429 | static int __init gspca_init(void) | 2479 | static int __init gspca_init(void) |
2430 | { | 2480 | { |
2431 | info("main v%d.%d.%d registered", | 2481 | info("v%d.%d.%d registered", |
2432 | (DRIVER_VERSION_NUMBER >> 16) & 0xff, | 2482 | (DRIVER_VERSION_NUMBER >> 16) & 0xff, |
2433 | (DRIVER_VERSION_NUMBER >> 8) & 0xff, | 2483 | (DRIVER_VERSION_NUMBER >> 8) & 0xff, |
2434 | DRIVER_VERSION_NUMBER & 0xff); | 2484 | DRIVER_VERSION_NUMBER & 0xff); |
@@ -2436,7 +2486,6 @@ static int __init gspca_init(void) | |||
2436 | } | 2486 | } |
2437 | static void __exit gspca_exit(void) | 2487 | static void __exit gspca_exit(void) |
2438 | { | 2488 | { |
2439 | info("main deregistered"); | ||
2440 | } | 2489 | } |
2441 | 2490 | ||
2442 | module_init(gspca_init); | 2491 | module_init(gspca_init); |
@@ -2446,6 +2495,6 @@ module_exit(gspca_exit); | |||
2446 | module_param_named(debug, gspca_debug, int, 0644); | 2495 | module_param_named(debug, gspca_debug, int, 0644); |
2447 | MODULE_PARM_DESC(debug, | 2496 | MODULE_PARM_DESC(debug, |
2448 | "Debug (bit) 0x01:error 0x02:probe 0x04:config" | 2497 | "Debug (bit) 0x01:error 0x02:probe 0x04:config" |
2449 | " 0x08:stream 0x10:frame 0x20:packet 0x40:USBin 0x80:USBout" | 2498 | " 0x08:stream 0x10:frame 0x20:packet" |
2450 | " 0x0100: v4l2"); | 2499 | " 0x0100: v4l2"); |
2451 | #endif | 2500 | #endif |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index b749c36d9f7e..49e2fcbe81fb 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/mutex.h> | 9 | #include <linux/mutex.h> |
10 | 10 | ||
11 | /* compilation option */ | 11 | /* compilation option */ |
12 | #define GSPCA_DEBUG 1 | 12 | /*#define GSPCA_DEBUG 1*/ |
13 | 13 | ||
14 | #ifdef GSPCA_DEBUG | 14 | #ifdef GSPCA_DEBUG |
15 | /* GSPCA our debug messages */ | 15 | /* GSPCA our debug messages */ |
@@ -25,8 +25,8 @@ extern int gspca_debug; | |||
25 | #define D_STREAM 0x08 | 25 | #define D_STREAM 0x08 |
26 | #define D_FRAM 0x10 | 26 | #define D_FRAM 0x10 |
27 | #define D_PACK 0x20 | 27 | #define D_PACK 0x20 |
28 | #define D_USBI 0x40 | 28 | #define D_USBI 0x00 |
29 | #define D_USBO 0x80 | 29 | #define D_USBO 0x00 |
30 | #define D_V4L2 0x0100 | 30 | #define D_V4L2 0x0100 |
31 | #else | 31 | #else |
32 | #define PDEBUG(level, fmt, args...) | 32 | #define PDEBUG(level, fmt, args...) |
@@ -52,11 +52,20 @@ struct framerates { | |||
52 | int nrates; | 52 | int nrates; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* control definition */ | ||
56 | struct 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 */ |
56 | struct cam { | 63 | struct 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 nmodes, |
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 */ |
@@ -84,7 +93,7 @@ typedef int (*cam_reg_op) (struct gspca_dev *, | |||
84 | struct v4l2_dbg_register *); | 93 | struct v4l2_dbg_register *); |
85 | typedef int (*cam_ident_op) (struct gspca_dev *, | 94 | typedef int (*cam_ident_op) (struct gspca_dev *, |
86 | struct v4l2_dbg_chip_ident *); | 95 | struct v4l2_dbg_chip_ident *); |
87 | typedef int (*cam_streamparm_op) (struct gspca_dev *, | 96 | typedef void (*cam_streamparm_op) (struct gspca_dev *, |
88 | struct v4l2_streamparm *); | 97 | struct v4l2_streamparm *); |
89 | typedef int (*cam_qmnu_op) (struct gspca_dev *, | 98 | typedef int (*cam_qmnu_op) (struct gspca_dev *, |
90 | struct v4l2_querymenu *); | 99 | struct v4l2_querymenu *); |
@@ -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 */ |
@@ -195,14 +205,12 @@ struct gspca_dev { | |||
195 | 205 | ||
196 | wait_queue_head_t wq; /* wait queue */ | 206 | wait_queue_head_t wq; /* wait queue */ |
197 | struct mutex usb_lock; /* usb exchange protection */ | 207 | struct mutex usb_lock; /* usb exchange protection */ |
198 | struct mutex read_lock; /* read protection */ | ||
199 | struct mutex queue_lock; /* ISOC queue protection */ | 208 | struct mutex queue_lock; /* ISOC queue protection */ |
200 | int usb_err; /* USB error - protected by usb_lock */ | 209 | int usb_err; /* USB error - protected by usb_lock */ |
201 | u16 pkt_size; /* ISOC packet size */ | 210 | u16 pkt_size; /* ISOC packet size */ |
202 | #ifdef CONFIG_PM | 211 | #ifdef CONFIG_PM |
203 | char frozen; /* suspend - resume */ | 212 | char frozen; /* suspend - resume */ |
204 | #endif | 213 | #endif |
205 | char users; /* number of opens */ | ||
206 | char present; /* device connected */ | 214 | char present; /* device connected */ |
207 | char nbufread; /* number of buffers for read() */ | 215 | char nbufread; /* number of buffers for read() */ |
208 | char memory; /* memory type (V4L2_MEMORY_xxx) */ | 216 | char memory; /* memory type (V4L2_MEMORY_xxx) */ |
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c index 12d9cf4caba2..1bd9c4b542dd 100644 --- a/drivers/media/video/gspca/jeilinj.c +++ b/drivers/media/video/gspca/jeilinj.c | |||
@@ -6,6 +6,9 @@ | |||
6 | * | 6 | * |
7 | * Copyright (C) 2009 Theodore Kilgore | 7 | * Copyright (C) 2009 Theodore Kilgore |
8 | * | 8 | * |
9 | * Sportscam DV15 support and control settings are | ||
10 | * Copyright (C) 2011 Patrice Chotard | ||
11 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
@@ -23,7 +26,6 @@ | |||
23 | 26 | ||
24 | #define MODULE_NAME "jeilinj" | 27 | #define MODULE_NAME "jeilinj" |
25 | 28 | ||
26 | #include <linux/workqueue.h> | ||
27 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
28 | #include "gspca.h" | 30 | #include "gspca.h" |
29 | #include "jpeg.h" | 31 | #include "jpeg.h" |
@@ -34,29 +36,51 @@ MODULE_LICENSE("GPL"); | |||
34 | 36 | ||
35 | /* Default timeouts, in ms */ | 37 | /* Default timeouts, in ms */ |
36 | #define JEILINJ_CMD_TIMEOUT 500 | 38 | #define JEILINJ_CMD_TIMEOUT 500 |
39 | #define JEILINJ_CMD_DELAY 160 | ||
37 | #define JEILINJ_DATA_TIMEOUT 1000 | 40 | #define JEILINJ_DATA_TIMEOUT 1000 |
38 | 41 | ||
39 | /* Maximum transfer size to use. */ | 42 | /* Maximum transfer size to use. */ |
40 | #define JEILINJ_MAX_TRANSFER 0x200 | 43 | #define JEILINJ_MAX_TRANSFER 0x200 |
41 | |||
42 | #define FRAME_HEADER_LEN 0x10 | 44 | #define FRAME_HEADER_LEN 0x10 |
45 | #define FRAME_START 0xFFFFFFFF | ||
46 | |||
47 | enum { | ||
48 | SAKAR_57379, | ||
49 | SPORTSCAM_DV15, | ||
50 | }; | ||
51 | |||
52 | #define CAMQUALITY_MIN 0 /* highest cam quality */ | ||
53 | #define CAMQUALITY_MAX 97 /* lowest cam quality */ | ||
54 | |||
55 | enum e_ctrl { | ||
56 | LIGHTFREQ, | ||
57 | AUTOGAIN, | ||
58 | RED, | ||
59 | GREEN, | ||
60 | BLUE, | ||
61 | NCTRLS /* number of controls */ | ||
62 | }; | ||
43 | 63 | ||
44 | /* Structure to hold all of our device specific stuff */ | 64 | /* Structure to hold all of our device specific stuff */ |
45 | struct sd { | 65 | struct sd { |
46 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 66 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
67 | struct gspca_ctrl ctrls[NCTRLS]; | ||
68 | int blocks_left; | ||
47 | const struct v4l2_pix_format *cap_mode; | 69 | const struct v4l2_pix_format *cap_mode; |
48 | /* Driver stuff */ | 70 | /* Driver stuff */ |
49 | struct work_struct work_struct; | 71 | u8 type; |
50 | struct workqueue_struct *work_thread; | ||
51 | u8 quality; /* image quality */ | 72 | u8 quality; /* image quality */ |
52 | u8 jpegqual; /* webcam quality */ | 73 | #define QUALITY_MIN 35 |
74 | #define QUALITY_MAX 85 | ||
75 | #define QUALITY_DEF 85 | ||
53 | u8 jpeg_hdr[JPEG_HDR_SZ]; | 76 | u8 jpeg_hdr[JPEG_HDR_SZ]; |
54 | }; | 77 | }; |
55 | 78 | ||
56 | struct jlj_command { | 79 | struct jlj_command { |
57 | unsigned char instruction[2]; | 80 | unsigned char instruction[2]; |
58 | unsigned char ack_wanted; | 81 | unsigned char ack_wanted; |
59 | }; | 82 | unsigned char delay; |
83 | }; | ||
60 | 84 | ||
61 | /* AFAICT these cameras will only do 320x240. */ | 85 | /* AFAICT these cameras will only do 320x240. */ |
62 | static struct v4l2_pix_format jlj_mode[] = { | 86 | static struct v4l2_pix_format jlj_mode[] = { |
@@ -64,6 +88,11 @@ static struct v4l2_pix_format jlj_mode[] = { | |||
64 | .bytesperline = 320, | 88 | .bytesperline = 320, |
65 | .sizeimage = 320 * 240, | 89 | .sizeimage = 320 * 240, |
66 | .colorspace = V4L2_COLORSPACE_JPEG, | 90 | .colorspace = V4L2_COLORSPACE_JPEG, |
91 | .priv = 0}, | ||
92 | { 640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
93 | .bytesperline = 640, | ||
94 | .sizeimage = 640 * 480, | ||
95 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
67 | .priv = 0} | 96 | .priv = 0} |
68 | }; | 97 | }; |
69 | 98 | ||
@@ -73,180 +102,295 @@ static struct v4l2_pix_format jlj_mode[] = { | |||
73 | */ | 102 | */ |
74 | 103 | ||
75 | /* All commands are two bytes only */ | 104 | /* All commands are two bytes only */ |
76 | static int jlj_write2(struct gspca_dev *gspca_dev, unsigned char *command) | 105 | static void jlj_write2(struct gspca_dev *gspca_dev, unsigned char *command) |
77 | { | 106 | { |
78 | int retval; | 107 | int retval; |
79 | 108 | ||
109 | if (gspca_dev->usb_err < 0) | ||
110 | return; | ||
80 | memcpy(gspca_dev->usb_buf, command, 2); | 111 | memcpy(gspca_dev->usb_buf, command, 2); |
81 | retval = usb_bulk_msg(gspca_dev->dev, | 112 | retval = usb_bulk_msg(gspca_dev->dev, |
82 | usb_sndbulkpipe(gspca_dev->dev, 3), | 113 | usb_sndbulkpipe(gspca_dev->dev, 3), |
83 | gspca_dev->usb_buf, 2, NULL, 500); | 114 | gspca_dev->usb_buf, 2, NULL, 500); |
84 | if (retval < 0) | 115 | if (retval < 0) { |
85 | PDEBUG(D_ERR, "command write [%02x] error %d", | 116 | err("command write [%02x] error %d", |
86 | gspca_dev->usb_buf[0], retval); | 117 | gspca_dev->usb_buf[0], retval); |
87 | return retval; | 118 | gspca_dev->usb_err = retval; |
119 | } | ||
88 | } | 120 | } |
89 | 121 | ||
90 | /* Responses are one byte only */ | 122 | /* Responses are one byte only */ |
91 | static int jlj_read1(struct gspca_dev *gspca_dev, unsigned char response) | 123 | static void jlj_read1(struct gspca_dev *gspca_dev, unsigned char response) |
92 | { | 124 | { |
93 | int retval; | 125 | int retval; |
94 | 126 | ||
127 | if (gspca_dev->usb_err < 0) | ||
128 | return; | ||
95 | retval = usb_bulk_msg(gspca_dev->dev, | 129 | retval = usb_bulk_msg(gspca_dev->dev, |
96 | usb_rcvbulkpipe(gspca_dev->dev, 0x84), | 130 | usb_rcvbulkpipe(gspca_dev->dev, 0x84), |
97 | gspca_dev->usb_buf, 1, NULL, 500); | 131 | gspca_dev->usb_buf, 1, NULL, 500); |
98 | response = gspca_dev->usb_buf[0]; | 132 | response = gspca_dev->usb_buf[0]; |
99 | if (retval < 0) | 133 | if (retval < 0) { |
100 | PDEBUG(D_ERR, "read command [%02x] error %d", | 134 | err("read command [%02x] error %d", |
101 | gspca_dev->usb_buf[0], retval); | 135 | gspca_dev->usb_buf[0], retval); |
102 | return retval; | 136 | gspca_dev->usb_err = retval; |
137 | } | ||
103 | } | 138 | } |
104 | 139 | ||
105 | static int jlj_start(struct gspca_dev *gspca_dev) | 140 | static void setfreq(struct gspca_dev *gspca_dev) |
106 | { | 141 | { |
107 | int i; | 142 | struct sd *sd = (struct sd *) gspca_dev; |
108 | int retval = -1; | 143 | u8 freq_commands[][2] = { |
109 | u8 response = 0xff; | 144 | {0x71, 0x80}, |
110 | struct jlj_command start_commands[] = { | 145 | {0x70, 0x07} |
111 | {{0x71, 0x81}, 0}, | ||
112 | {{0x70, 0x05}, 0}, | ||
113 | {{0x95, 0x70}, 1}, | ||
114 | {{0x71, 0x81}, 0}, | ||
115 | {{0x70, 0x04}, 0}, | ||
116 | {{0x95, 0x70}, 1}, | ||
117 | {{0x71, 0x00}, 0}, | ||
118 | {{0x70, 0x08}, 0}, | ||
119 | {{0x95, 0x70}, 1}, | ||
120 | {{0x94, 0x02}, 0}, | ||
121 | {{0xde, 0x24}, 0}, | ||
122 | {{0x94, 0x02}, 0}, | ||
123 | {{0xdd, 0xf0}, 0}, | ||
124 | {{0x94, 0x02}, 0}, | ||
125 | {{0xe3, 0x2c}, 0}, | ||
126 | {{0x94, 0x02}, 0}, | ||
127 | {{0xe4, 0x00}, 0}, | ||
128 | {{0x94, 0x02}, 0}, | ||
129 | {{0xe5, 0x00}, 0}, | ||
130 | {{0x94, 0x02}, 0}, | ||
131 | {{0xe6, 0x2c}, 0}, | ||
132 | {{0x94, 0x03}, 0}, | ||
133 | {{0xaa, 0x00}, 0}, | ||
134 | {{0x71, 0x1e}, 0}, | ||
135 | {{0x70, 0x06}, 0}, | ||
136 | {{0x71, 0x80}, 0}, | ||
137 | {{0x70, 0x07}, 0} | ||
138 | }; | 146 | }; |
139 | for (i = 0; i < ARRAY_SIZE(start_commands); i++) { | 147 | |
140 | retval = jlj_write2(gspca_dev, start_commands[i].instruction); | 148 | freq_commands[0][1] |= (sd->ctrls[LIGHTFREQ].val >> 1); |
141 | if (retval < 0) | 149 | |
142 | return retval; | 150 | jlj_write2(gspca_dev, freq_commands[0]); |
143 | if (start_commands[i].ack_wanted) | 151 | jlj_write2(gspca_dev, freq_commands[1]); |
144 | retval = jlj_read1(gspca_dev, response); | 152 | } |
145 | if (retval < 0) | 153 | |
146 | return retval; | 154 | static void setcamquality(struct gspca_dev *gspca_dev) |
147 | } | 155 | { |
148 | PDEBUG(D_ERR, "jlj_start retval is %d", retval); | 156 | struct sd *sd = (struct sd *) gspca_dev; |
149 | return retval; | 157 | u8 quality_commands[][2] = { |
158 | {0x71, 0x1E}, | ||
159 | {0x70, 0x06} | ||
160 | }; | ||
161 | u8 camquality; | ||
162 | |||
163 | /* adapt camera quality from jpeg quality */ | ||
164 | camquality = ((QUALITY_MAX - sd->quality) * CAMQUALITY_MAX) | ||
165 | / (QUALITY_MAX - QUALITY_MIN); | ||
166 | quality_commands[0][1] += camquality; | ||
167 | |||
168 | jlj_write2(gspca_dev, quality_commands[0]); | ||
169 | jlj_write2(gspca_dev, quality_commands[1]); | ||
170 | } | ||
171 | |||
172 | static void setautogain(struct gspca_dev *gspca_dev) | ||
173 | { | ||
174 | struct sd *sd = (struct sd *) gspca_dev; | ||
175 | u8 autogain_commands[][2] = { | ||
176 | {0x94, 0x02}, | ||
177 | {0xcf, 0x00} | ||
178 | }; | ||
179 | |||
180 | autogain_commands[1][1] = (sd->ctrls[AUTOGAIN].val << 4); | ||
181 | |||
182 | jlj_write2(gspca_dev, autogain_commands[0]); | ||
183 | jlj_write2(gspca_dev, autogain_commands[1]); | ||
184 | } | ||
185 | |||
186 | static void setred(struct gspca_dev *gspca_dev) | ||
187 | { | ||
188 | struct sd *sd = (struct sd *) gspca_dev; | ||
189 | u8 setred_commands[][2] = { | ||
190 | {0x94, 0x02}, | ||
191 | {0xe6, 0x00} | ||
192 | }; | ||
193 | |||
194 | setred_commands[1][1] = sd->ctrls[RED].val; | ||
195 | |||
196 | jlj_write2(gspca_dev, setred_commands[0]); | ||
197 | jlj_write2(gspca_dev, setred_commands[1]); | ||
150 | } | 198 | } |
151 | 199 | ||
152 | static int jlj_stop(struct gspca_dev *gspca_dev) | 200 | static void setgreen(struct gspca_dev *gspca_dev) |
201 | { | ||
202 | struct sd *sd = (struct sd *) gspca_dev; | ||
203 | u8 setgreen_commands[][2] = { | ||
204 | {0x94, 0x02}, | ||
205 | {0xe7, 0x00} | ||
206 | }; | ||
207 | |||
208 | setgreen_commands[1][1] = sd->ctrls[GREEN].val; | ||
209 | |||
210 | jlj_write2(gspca_dev, setgreen_commands[0]); | ||
211 | jlj_write2(gspca_dev, setgreen_commands[1]); | ||
212 | } | ||
213 | |||
214 | static void setblue(struct gspca_dev *gspca_dev) | ||
215 | { | ||
216 | struct sd *sd = (struct sd *) gspca_dev; | ||
217 | u8 setblue_commands[][2] = { | ||
218 | {0x94, 0x02}, | ||
219 | {0xe9, 0x00} | ||
220 | }; | ||
221 | |||
222 | setblue_commands[1][1] = sd->ctrls[BLUE].val; | ||
223 | |||
224 | jlj_write2(gspca_dev, setblue_commands[0]); | ||
225 | jlj_write2(gspca_dev, setblue_commands[1]); | ||
226 | } | ||
227 | |||
228 | static const struct ctrl sd_ctrls[NCTRLS] = { | ||
229 | [LIGHTFREQ] = { | ||
230 | { | ||
231 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
232 | .type = V4L2_CTRL_TYPE_MENU, | ||
233 | .name = "Light frequency filter", | ||
234 | .minimum = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED, /* 1 */ | ||
235 | .maximum = V4L2_CID_POWER_LINE_FREQUENCY_60HZ, /* 2 */ | ||
236 | .step = 1, | ||
237 | .default_value = V4L2_CID_POWER_LINE_FREQUENCY_60HZ, | ||
238 | }, | ||
239 | .set_control = setfreq | ||
240 | }, | ||
241 | [AUTOGAIN] = { | ||
242 | { | ||
243 | .id = V4L2_CID_AUTOGAIN, | ||
244 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
245 | .name = "Automatic Gain (and Exposure)", | ||
246 | .minimum = 0, | ||
247 | .maximum = 3, | ||
248 | .step = 1, | ||
249 | #define AUTOGAIN_DEF 0 | ||
250 | .default_value = AUTOGAIN_DEF, | ||
251 | }, | ||
252 | .set_control = setautogain | ||
253 | }, | ||
254 | [RED] = { | ||
255 | { | ||
256 | .id = V4L2_CID_RED_BALANCE, | ||
257 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
258 | .name = "red balance", | ||
259 | .minimum = 0, | ||
260 | .maximum = 3, | ||
261 | .step = 1, | ||
262 | #define RED_BALANCE_DEF 2 | ||
263 | .default_value = RED_BALANCE_DEF, | ||
264 | }, | ||
265 | .set_control = setred | ||
266 | }, | ||
267 | |||
268 | [GREEN] = { | ||
269 | { | ||
270 | .id = V4L2_CID_GAIN, | ||
271 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
272 | .name = "green balance", | ||
273 | .minimum = 0, | ||
274 | .maximum = 3, | ||
275 | .step = 1, | ||
276 | #define GREEN_BALANCE_DEF 2 | ||
277 | .default_value = GREEN_BALANCE_DEF, | ||
278 | }, | ||
279 | .set_control = setgreen | ||
280 | }, | ||
281 | [BLUE] = { | ||
282 | { | ||
283 | .id = V4L2_CID_BLUE_BALANCE, | ||
284 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
285 | .name = "blue balance", | ||
286 | .minimum = 0, | ||
287 | .maximum = 3, | ||
288 | .step = 1, | ||
289 | #define BLUE_BALANCE_DEF 2 | ||
290 | .default_value = BLUE_BALANCE_DEF, | ||
291 | }, | ||
292 | .set_control = setblue | ||
293 | }, | ||
294 | }; | ||
295 | |||
296 | static int jlj_start(struct gspca_dev *gspca_dev) | ||
153 | { | 297 | { |
154 | int i; | 298 | int i; |
155 | int retval; | 299 | int start_commands_size; |
156 | struct jlj_command stop_commands[] = { | 300 | u8 response = 0xff; |
157 | {{0x71, 0x00}, 0}, | 301 | struct sd *sd = (struct sd *) gspca_dev; |
158 | {{0x70, 0x09}, 0}, | 302 | struct jlj_command start_commands[] = { |
159 | {{0x71, 0x80}, 0}, | 303 | {{0x71, 0x81}, 0, 0}, |
160 | {{0x70, 0x05}, 0} | 304 | {{0x70, 0x05}, 0, JEILINJ_CMD_DELAY}, |
305 | {{0x95, 0x70}, 1, 0}, | ||
306 | {{0x71, 0x81 - gspca_dev->curr_mode}, 0, 0}, | ||
307 | {{0x70, 0x04}, 0, JEILINJ_CMD_DELAY}, | ||
308 | {{0x95, 0x70}, 1, 0}, | ||
309 | {{0x71, 0x00}, 0, 0}, /* start streaming ??*/ | ||
310 | {{0x70, 0x08}, 0, JEILINJ_CMD_DELAY}, | ||
311 | {{0x95, 0x70}, 1, 0}, | ||
312 | #define SPORTSCAM_DV15_CMD_SIZE 9 | ||
313 | {{0x94, 0x02}, 0, 0}, | ||
314 | {{0xde, 0x24}, 0, 0}, | ||
315 | {{0x94, 0x02}, 0, 0}, | ||
316 | {{0xdd, 0xf0}, 0, 0}, | ||
317 | {{0x94, 0x02}, 0, 0}, | ||
318 | {{0xe3, 0x2c}, 0, 0}, | ||
319 | {{0x94, 0x02}, 0, 0}, | ||
320 | {{0xe4, 0x00}, 0, 0}, | ||
321 | {{0x94, 0x02}, 0, 0}, | ||
322 | {{0xe5, 0x00}, 0, 0}, | ||
323 | {{0x94, 0x02}, 0, 0}, | ||
324 | {{0xe6, 0x2c}, 0, 0}, | ||
325 | {{0x94, 0x03}, 0, 0}, | ||
326 | {{0xaa, 0x00}, 0, 0} | ||
161 | }; | 327 | }; |
162 | for (i = 0; i < ARRAY_SIZE(stop_commands); i++) { | 328 | |
163 | retval = jlj_write2(gspca_dev, stop_commands[i].instruction); | 329 | sd->blocks_left = 0; |
164 | if (retval < 0) | 330 | /* Under Windows, USB spy shows that only the 9 first start |
165 | return retval; | 331 | * commands are used for SPORTSCAM_DV15 webcam |
332 | */ | ||
333 | if (sd->type == SPORTSCAM_DV15) | ||
334 | start_commands_size = SPORTSCAM_DV15_CMD_SIZE; | ||
335 | else | ||
336 | start_commands_size = ARRAY_SIZE(start_commands); | ||
337 | |||
338 | for (i = 0; i < start_commands_size; i++) { | ||
339 | jlj_write2(gspca_dev, start_commands[i].instruction); | ||
340 | if (start_commands[i].delay) | ||
341 | msleep(start_commands[i].delay); | ||
342 | if (start_commands[i].ack_wanted) | ||
343 | jlj_read1(gspca_dev, response); | ||
166 | } | 344 | } |
167 | return retval; | 345 | setcamquality(gspca_dev); |
346 | msleep(2); | ||
347 | setfreq(gspca_dev); | ||
348 | if (gspca_dev->usb_err < 0) | ||
349 | PDEBUG(D_ERR, "Start streaming command failed"); | ||
350 | return gspca_dev->usb_err; | ||
168 | } | 351 | } |
169 | 352 | ||
170 | /* This function is called as a workqueue function and runs whenever the camera | 353 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
171 | * is streaming data. Because it is a workqueue function it is allowed to sleep | 354 | u8 *data, int len) |
172 | * so we can use synchronous USB calls. To avoid possible collisions with other | ||
173 | * threads attempting to use the camera's USB interface the gspca usb_lock is | ||
174 | * used when performing the one USB control operation inside the workqueue, | ||
175 | * which tells the camera to close the stream. In practice the only thing | ||
176 | * which needs to be protected against is the usb_set_interface call that | ||
177 | * gspca makes during stream_off. Otherwise the camera doesn't provide any | ||
178 | * controls that the user could try to change. | ||
179 | */ | ||
180 | |||
181 | static void jlj_dostream(struct work_struct *work) | ||
182 | { | 355 | { |
183 | struct sd *dev = container_of(work, struct sd, work_struct); | 356 | struct sd *sd = (struct sd *) gspca_dev; |
184 | struct gspca_dev *gspca_dev = &dev->gspca_dev; | ||
185 | int blocks_left; /* 0x200-sized blocks remaining in current frame. */ | ||
186 | int size_in_blocks; | ||
187 | int act_len; | ||
188 | int packet_type; | 357 | int packet_type; |
189 | int ret; | 358 | u32 header_marker; |
190 | u8 *buffer; | ||
191 | 359 | ||
192 | buffer = kmalloc(JEILINJ_MAX_TRANSFER, GFP_KERNEL | GFP_DMA); | 360 | PDEBUG(D_STREAM, "Got %d bytes out of %d for Block 0", |
193 | if (!buffer) { | 361 | len, JEILINJ_MAX_TRANSFER); |
194 | PDEBUG(D_ERR, "Couldn't allocate USB buffer"); | 362 | if (len != JEILINJ_MAX_TRANSFER) { |
195 | goto quit_stream; | 363 | PDEBUG(D_PACK, "bad length"); |
364 | goto discard; | ||
196 | } | 365 | } |
197 | while (gspca_dev->present && gspca_dev->streaming) { | 366 | /* check if it's start of frame */ |
198 | /* | 367 | header_marker = ((u32 *)data)[0]; |
199 | * Now request data block 0. Line 0 reports the size | 368 | if (header_marker == FRAME_START) { |
200 | * to download, in blocks of size 0x200, and also tells the | 369 | sd->blocks_left = data[0x0a] - 1; |
201 | * "actual" data size, in bytes, which seems best to ignore. | 370 | PDEBUG(D_STREAM, "blocks_left = 0x%x", sd->blocks_left); |
202 | */ | ||
203 | ret = usb_bulk_msg(gspca_dev->dev, | ||
204 | usb_rcvbulkpipe(gspca_dev->dev, 0x82), | ||
205 | buffer, JEILINJ_MAX_TRANSFER, &act_len, | ||
206 | JEILINJ_DATA_TIMEOUT); | ||
207 | PDEBUG(D_STREAM, | ||
208 | "Got %d bytes out of %d for Block 0", | ||
209 | act_len, JEILINJ_MAX_TRANSFER); | ||
210 | if (ret < 0 || act_len < FRAME_HEADER_LEN) | ||
211 | goto quit_stream; | ||
212 | size_in_blocks = buffer[0x0a]; | ||
213 | blocks_left = buffer[0x0a] - 1; | ||
214 | PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left); | ||
215 | |||
216 | /* Start a new frame, and add the JPEG header, first thing */ | 371 | /* Start a new frame, and add the JPEG header, first thing */ |
217 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 372 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
218 | dev->jpeg_hdr, JPEG_HDR_SZ); | 373 | sd->jpeg_hdr, JPEG_HDR_SZ); |
219 | /* Toss line 0 of data block 0, keep the rest. */ | 374 | /* Toss line 0 of data block 0, keep the rest. */ |
220 | gspca_frame_add(gspca_dev, INTER_PACKET, | 375 | gspca_frame_add(gspca_dev, INTER_PACKET, |
221 | buffer + FRAME_HEADER_LEN, | 376 | data + FRAME_HEADER_LEN, |
222 | JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN); | 377 | JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN); |
223 | 378 | } else if (sd->blocks_left > 0) { | |
224 | while (blocks_left > 0) { | 379 | PDEBUG(D_STREAM, "%d blocks remaining for frame", |
225 | if (!gspca_dev->present) | 380 | sd->blocks_left); |
226 | goto quit_stream; | 381 | sd->blocks_left -= 1; |
227 | ret = usb_bulk_msg(gspca_dev->dev, | 382 | if (sd->blocks_left == 0) |
228 | usb_rcvbulkpipe(gspca_dev->dev, 0x82), | 383 | packet_type = LAST_PACKET; |
229 | buffer, JEILINJ_MAX_TRANSFER, &act_len, | 384 | else |
230 | JEILINJ_DATA_TIMEOUT); | 385 | packet_type = INTER_PACKET; |
231 | if (ret < 0 || act_len < JEILINJ_MAX_TRANSFER) | 386 | gspca_frame_add(gspca_dev, packet_type, |
232 | goto quit_stream; | 387 | data, JEILINJ_MAX_TRANSFER); |
233 | PDEBUG(D_STREAM, | 388 | } else |
234 | "%d blocks remaining for frame", blocks_left); | 389 | goto discard; |
235 | blocks_left -= 1; | 390 | return; |
236 | if (blocks_left == 0) | 391 | discard: |
237 | packet_type = LAST_PACKET; | 392 | /* Discard data until a new frame starts. */ |
238 | else | 393 | gspca_dev->last_packet_type = DISCARD_PACKET; |
239 | packet_type = INTER_PACKET; | ||
240 | gspca_frame_add(gspca_dev, packet_type, | ||
241 | buffer, JEILINJ_MAX_TRANSFER); | ||
242 | } | ||
243 | } | ||
244 | quit_stream: | ||
245 | mutex_lock(&gspca_dev->usb_lock); | ||
246 | if (gspca_dev->present) | ||
247 | jlj_stop(gspca_dev); | ||
248 | mutex_unlock(&gspca_dev->usb_lock); | ||
249 | kfree(buffer); | ||
250 | } | 394 | } |
251 | 395 | ||
252 | /* This function is called at probe time just before sd_init */ | 396 | /* This function is called at probe time just before sd_init */ |
@@ -256,78 +400,169 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
256 | struct cam *cam = &gspca_dev->cam; | 400 | struct cam *cam = &gspca_dev->cam; |
257 | struct sd *dev = (struct sd *) gspca_dev; | 401 | struct sd *dev = (struct sd *) gspca_dev; |
258 | 402 | ||
259 | dev->quality = 85; | 403 | dev->type = id->driver_info; |
260 | dev->jpegqual = 85; | 404 | gspca_dev->cam.ctrls = dev->ctrls; |
405 | dev->quality = QUALITY_DEF; | ||
406 | dev->ctrls[LIGHTFREQ].def = V4L2_CID_POWER_LINE_FREQUENCY_60HZ; | ||
407 | dev->ctrls[RED].def = RED_BALANCE_DEF; | ||
408 | dev->ctrls[GREEN].def = GREEN_BALANCE_DEF; | ||
409 | dev->ctrls[BLUE].def = BLUE_BALANCE_DEF; | ||
261 | PDEBUG(D_PROBE, | 410 | PDEBUG(D_PROBE, |
262 | "JEILINJ camera detected" | 411 | "JEILINJ camera detected" |
263 | " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); | 412 | " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); |
264 | cam->cam_mode = jlj_mode; | 413 | cam->cam_mode = jlj_mode; |
265 | cam->nmodes = 1; | 414 | cam->nmodes = ARRAY_SIZE(jlj_mode); |
266 | cam->bulk = 1; | 415 | cam->bulk = 1; |
267 | /* We don't use the buffer gspca allocates so make it small. */ | 416 | cam->bulk_nurbs = 1; |
268 | cam->bulk_size = 32; | 417 | cam->bulk_size = JEILINJ_MAX_TRANSFER; |
269 | INIT_WORK(&dev->work_struct, jlj_dostream); | ||
270 | return 0; | 418 | return 0; |
271 | } | 419 | } |
272 | 420 | ||
273 | /* called on streamoff with alt==0 and on disconnect */ | 421 | static void sd_stopN(struct gspca_dev *gspca_dev) |
274 | /* the usb_lock is held at entry - restore on exit */ | ||
275 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
276 | { | 422 | { |
277 | struct sd *dev = (struct sd *) gspca_dev; | 423 | int i; |
424 | u8 *buf; | ||
425 | u8 stop_commands[][2] = { | ||
426 | {0x71, 0x00}, | ||
427 | {0x70, 0x09}, | ||
428 | {0x71, 0x80}, | ||
429 | {0x70, 0x05} | ||
430 | }; | ||
431 | |||
432 | for (;;) { | ||
433 | /* get the image remaining blocks */ | ||
434 | usb_bulk_msg(gspca_dev->dev, | ||
435 | gspca_dev->urb[0]->pipe, | ||
436 | gspca_dev->urb[0]->transfer_buffer, | ||
437 | JEILINJ_MAX_TRANSFER, NULL, | ||
438 | JEILINJ_DATA_TIMEOUT); | ||
439 | |||
440 | /* search for 0xff 0xd9 (EOF for JPEG) */ | ||
441 | i = 0; | ||
442 | buf = gspca_dev->urb[0]->transfer_buffer; | ||
443 | while ((i < (JEILINJ_MAX_TRANSFER - 1)) && | ||
444 | ((buf[i] != 0xff) || (buf[i+1] != 0xd9))) | ||
445 | i++; | ||
446 | |||
447 | if (i != (JEILINJ_MAX_TRANSFER - 1)) | ||
448 | /* last remaining block found */ | ||
449 | break; | ||
450 | } | ||
278 | 451 | ||
279 | /* wait for the work queue to terminate */ | 452 | for (i = 0; i < ARRAY_SIZE(stop_commands); i++) |
280 | mutex_unlock(&gspca_dev->usb_lock); | 453 | jlj_write2(gspca_dev, stop_commands[i]); |
281 | /* This waits for jlj_dostream to finish */ | ||
282 | destroy_workqueue(dev->work_thread); | ||
283 | dev->work_thread = NULL; | ||
284 | mutex_lock(&gspca_dev->usb_lock); | ||
285 | } | 454 | } |
286 | 455 | ||
287 | /* this function is called at probe and resume time */ | 456 | /* this function is called at probe and resume time */ |
288 | static int sd_init(struct gspca_dev *gspca_dev) | 457 | static int sd_init(struct gspca_dev *gspca_dev) |
289 | { | 458 | { |
290 | return 0; | 459 | return gspca_dev->usb_err; |
291 | } | 460 | } |
292 | 461 | ||
293 | /* Set up for getting frames. */ | 462 | /* Set up for getting frames. */ |
294 | static int sd_start(struct gspca_dev *gspca_dev) | 463 | static int sd_start(struct gspca_dev *gspca_dev) |
295 | { | 464 | { |
296 | struct sd *dev = (struct sd *) gspca_dev; | 465 | struct sd *dev = (struct sd *) gspca_dev; |
297 | int ret; | ||
298 | 466 | ||
299 | /* create the JPEG header */ | 467 | /* create the JPEG header */ |
300 | jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width, | 468 | jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
301 | 0x21); /* JPEG 422 */ | 469 | 0x21); /* JPEG 422 */ |
302 | jpeg_set_qual(dev->jpeg_hdr, dev->quality); | 470 | jpeg_set_qual(dev->jpeg_hdr, dev->quality); |
303 | PDEBUG(D_STREAM, "Start streaming at 320x240"); | 471 | PDEBUG(D_STREAM, "Start streaming at %dx%d", |
304 | ret = jlj_start(gspca_dev); | 472 | gspca_dev->height, gspca_dev->width); |
305 | if (ret < 0) { | 473 | jlj_start(gspca_dev); |
306 | PDEBUG(D_ERR, "Start streaming command failed"); | 474 | return gspca_dev->usb_err; |
307 | return ret; | ||
308 | } | ||
309 | /* Start the workqueue function to do the streaming */ | ||
310 | dev->work_thread = create_singlethread_workqueue(MODULE_NAME); | ||
311 | queue_work(dev->work_thread, &dev->work_struct); | ||
312 | |||
313 | return 0; | ||
314 | } | 475 | } |
315 | 476 | ||
316 | /* Table of supported USB devices */ | 477 | /* Table of supported USB devices */ |
317 | static const __devinitdata struct usb_device_id device_table[] = { | 478 | static const struct usb_device_id device_table[] = { |
318 | {USB_DEVICE(0x0979, 0x0280)}, | 479 | {USB_DEVICE(0x0979, 0x0280), .driver_info = SAKAR_57379}, |
480 | {USB_DEVICE(0x0979, 0x0270), .driver_info = SPORTSCAM_DV15}, | ||
319 | {} | 481 | {} |
320 | }; | 482 | }; |
321 | 483 | ||
322 | MODULE_DEVICE_TABLE(usb, device_table); | 484 | MODULE_DEVICE_TABLE(usb, device_table); |
323 | 485 | ||
486 | static int sd_querymenu(struct gspca_dev *gspca_dev, | ||
487 | struct v4l2_querymenu *menu) | ||
488 | { | ||
489 | switch (menu->id) { | ||
490 | case V4L2_CID_POWER_LINE_FREQUENCY: | ||
491 | switch (menu->index) { | ||
492 | case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ | ||
493 | strcpy((char *) menu->name, "disable"); | ||
494 | return 0; | ||
495 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | ||
496 | strcpy((char *) menu->name, "50 Hz"); | ||
497 | return 0; | ||
498 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | ||
499 | strcpy((char *) menu->name, "60 Hz"); | ||
500 | return 0; | ||
501 | } | ||
502 | break; | ||
503 | } | ||
504 | return -EINVAL; | ||
505 | } | ||
506 | |||
507 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | ||
508 | struct v4l2_jpegcompression *jcomp) | ||
509 | { | ||
510 | struct sd *sd = (struct sd *) gspca_dev; | ||
511 | |||
512 | if (jcomp->quality < QUALITY_MIN) | ||
513 | sd->quality = QUALITY_MIN; | ||
514 | else if (jcomp->quality > QUALITY_MAX) | ||
515 | sd->quality = QUALITY_MAX; | ||
516 | else | ||
517 | sd->quality = jcomp->quality; | ||
518 | if (gspca_dev->streaming) { | ||
519 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | ||
520 | setcamquality(gspca_dev); | ||
521 | } | ||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, | ||
526 | struct v4l2_jpegcompression *jcomp) | ||
527 | { | ||
528 | struct sd *sd = (struct sd *) gspca_dev; | ||
529 | |||
530 | memset(jcomp, 0, sizeof *jcomp); | ||
531 | jcomp->quality = sd->quality; | ||
532 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT | ||
533 | | V4L2_JPEG_MARKER_DQT; | ||
534 | return 0; | ||
535 | } | ||
536 | |||
537 | |||
324 | /* sub-driver description */ | 538 | /* sub-driver description */ |
325 | static const struct sd_desc sd_desc = { | 539 | static const struct sd_desc sd_desc_sakar_57379 = { |
326 | .name = MODULE_NAME, | 540 | .name = MODULE_NAME, |
327 | .config = sd_config, | 541 | .config = sd_config, |
328 | .init = sd_init, | 542 | .init = sd_init, |
329 | .start = sd_start, | 543 | .start = sd_start, |
330 | .stop0 = sd_stop0, | 544 | .stopN = sd_stopN, |
545 | .pkt_scan = sd_pkt_scan, | ||
546 | }; | ||
547 | |||
548 | /* sub-driver description */ | ||
549 | static const struct sd_desc sd_desc_sportscam_dv15 = { | ||
550 | .name = MODULE_NAME, | ||
551 | .config = sd_config, | ||
552 | .init = sd_init, | ||
553 | .start = sd_start, | ||
554 | .stopN = sd_stopN, | ||
555 | .pkt_scan = sd_pkt_scan, | ||
556 | .ctrls = sd_ctrls, | ||
557 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
558 | .querymenu = sd_querymenu, | ||
559 | .get_jcomp = sd_get_jcomp, | ||
560 | .set_jcomp = sd_set_jcomp, | ||
561 | }; | ||
562 | |||
563 | static const struct sd_desc *sd_desc[2] = { | ||
564 | &sd_desc_sakar_57379, | ||
565 | &sd_desc_sportscam_dv15 | ||
331 | }; | 566 | }; |
332 | 567 | ||
333 | /* -- device connect -- */ | 568 | /* -- device connect -- */ |
@@ -335,7 +570,7 @@ static int sd_probe(struct usb_interface *intf, | |||
335 | const struct usb_device_id *id) | 570 | const struct usb_device_id *id) |
336 | { | 571 | { |
337 | return gspca_dev_probe(intf, id, | 572 | return gspca_dev_probe(intf, id, |
338 | &sd_desc, | 573 | sd_desc[id->driver_info], |
339 | sizeof(struct sd), | 574 | sizeof(struct sd), |
340 | THIS_MODULE); | 575 | THIS_MODULE); |
341 | } | 576 | } |
@@ -354,19 +589,12 @@ static struct usb_driver sd_driver = { | |||
354 | /* -- module insert / remove -- */ | 589 | /* -- module insert / remove -- */ |
355 | static int __init sd_mod_init(void) | 590 | static int __init sd_mod_init(void) |
356 | { | 591 | { |
357 | int ret; | 592 | 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 | } | 593 | } |
365 | 594 | ||
366 | static void __exit sd_mod_exit(void) | 595 | static void __exit sd_mod_exit(void) |
367 | { | 596 | { |
368 | usb_deregister(&sd_driver); | 597 | usb_deregister(&sd_driver); |
369 | PDEBUG(D_PROBE, "deregistered"); | ||
370 | } | 598 | } |
371 | 599 | ||
372 | module_init(sd_mod_init); | 600 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/jpeg.h b/drivers/media/video/gspca/jpeg.h index de63c36806c0..ab54910418b4 100644 --- a/drivers/media/video/gspca/jpeg.h +++ b/drivers/media/video/gspca/jpeg.h | |||
@@ -141,9 +141,9 @@ static void jpeg_define(u8 *jpeg_hdr, | |||
141 | memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head); | 141 | memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head); |
142 | #ifndef CONEX_CAM | 142 | #ifndef CONEX_CAM |
143 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8; | 143 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8; |
144 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height & 0xff; | 144 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height; |
145 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8; | 145 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8; |
146 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width & 0xff; | 146 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width; |
147 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY; | 147 | jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY; |
148 | #endif | 148 | #endif |
149 | } | 149 | } |
diff --git a/drivers/media/video/gspca/kinect.c b/drivers/media/video/gspca/kinect.c new file mode 100644 index 000000000000..26fc206f095e --- /dev/null +++ b/drivers/media/video/gspca/kinect.c | |||
@@ -0,0 +1,429 @@ | |||
1 | /* | ||
2 | * kinect sensor device camera, gspca driver | ||
3 | * | ||
4 | * Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it> | ||
5 | * | ||
6 | * Based on the OpenKinect project and libfreenect | ||
7 | * http://openkinect.org/wiki/Init_Analysis | ||
8 | * | ||
9 | * Special thanks to Steven Toth and kernellabs.com for sponsoring a Kinect | ||
10 | * sensor device which I tested the driver on. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | #define MODULE_NAME "kinect" | ||
28 | |||
29 | #include "gspca.h" | ||
30 | |||
31 | #define CTRL_TIMEOUT 500 | ||
32 | |||
33 | MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>"); | ||
34 | MODULE_DESCRIPTION("GSPCA/Kinect Sensor Device USB Camera Driver"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | |||
37 | #ifdef GSPCA_DEBUG | ||
38 | int gspca_debug = D_ERR | D_PROBE | D_CONF | D_STREAM | D_FRAM | D_PACK | | ||
39 | D_USBI | D_USBO | D_V4L2; | ||
40 | #endif | ||
41 | |||
42 | struct pkt_hdr { | ||
43 | uint8_t magic[2]; | ||
44 | uint8_t pad; | ||
45 | uint8_t flag; | ||
46 | uint8_t unk1; | ||
47 | uint8_t seq; | ||
48 | uint8_t unk2; | ||
49 | uint8_t unk3; | ||
50 | uint32_t timestamp; | ||
51 | }; | ||
52 | |||
53 | struct cam_hdr { | ||
54 | uint8_t magic[2]; | ||
55 | uint16_t len; | ||
56 | uint16_t cmd; | ||
57 | uint16_t tag; | ||
58 | }; | ||
59 | |||
60 | /* specific webcam descriptor */ | ||
61 | struct sd { | ||
62 | struct gspca_dev gspca_dev; /* !! must be the first item */ | ||
63 | uint16_t cam_tag; /* a sequence number for packets */ | ||
64 | uint8_t stream_flag; /* to identify different stream types */ | ||
65 | uint8_t obuf[0x400]; /* output buffer for control commands */ | ||
66 | uint8_t ibuf[0x200]; /* input buffer for control commands */ | ||
67 | }; | ||
68 | |||
69 | /* V4L2 controls supported by the driver */ | ||
70 | /* controls prototypes here */ | ||
71 | |||
72 | static const struct ctrl sd_ctrls[] = { | ||
73 | }; | ||
74 | |||
75 | #define MODE_640x480 0x0001 | ||
76 | #define MODE_640x488 0x0002 | ||
77 | #define MODE_1280x1024 0x0004 | ||
78 | |||
79 | #define FORMAT_BAYER 0x0010 | ||
80 | #define FORMAT_UYVY 0x0020 | ||
81 | #define FORMAT_Y10B 0x0040 | ||
82 | |||
83 | #define FPS_HIGH 0x0100 | ||
84 | |||
85 | static const struct v4l2_pix_format video_camera_mode[] = { | ||
86 | {640, 480, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
87 | .bytesperline = 640, | ||
88 | .sizeimage = 640 * 480, | ||
89 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
90 | .priv = MODE_640x480 | FORMAT_BAYER | FPS_HIGH}, | ||
91 | {640, 480, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE, | ||
92 | .bytesperline = 640 * 2, | ||
93 | .sizeimage = 640 * 480 * 2, | ||
94 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
95 | .priv = MODE_640x480 | FORMAT_UYVY}, | ||
96 | {1280, 1024, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
97 | .bytesperline = 1280, | ||
98 | .sizeimage = 1280 * 1024, | ||
99 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
100 | .priv = MODE_1280x1024 | FORMAT_BAYER}, | ||
101 | {640, 488, V4L2_PIX_FMT_Y10BPACK, V4L2_FIELD_NONE, | ||
102 | .bytesperline = 640 * 10 / 8, | ||
103 | .sizeimage = 640 * 488 * 10 / 8, | ||
104 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
105 | .priv = MODE_640x488 | FORMAT_Y10B | FPS_HIGH}, | ||
106 | {1280, 1024, V4L2_PIX_FMT_Y10BPACK, V4L2_FIELD_NONE, | ||
107 | .bytesperline = 1280 * 10 / 8, | ||
108 | .sizeimage = 1280 * 1024 * 10 / 8, | ||
109 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
110 | .priv = MODE_1280x1024 | FORMAT_Y10B}, | ||
111 | }; | ||
112 | |||
113 | static int kinect_write(struct usb_device *udev, uint8_t *data, | ||
114 | uint16_t wLength) | ||
115 | { | ||
116 | return usb_control_msg(udev, | ||
117 | usb_sndctrlpipe(udev, 0), | ||
118 | 0x00, | ||
119 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
120 | 0, 0, data, wLength, CTRL_TIMEOUT); | ||
121 | } | ||
122 | |||
123 | static int kinect_read(struct usb_device *udev, uint8_t *data, uint16_t wLength) | ||
124 | { | ||
125 | return usb_control_msg(udev, | ||
126 | usb_rcvctrlpipe(udev, 0), | ||
127 | 0x00, | ||
128 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
129 | 0, 0, data, wLength, CTRL_TIMEOUT); | ||
130 | } | ||
131 | |||
132 | static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf, | ||
133 | unsigned int cmd_len, void *replybuf, unsigned int reply_len) | ||
134 | { | ||
135 | struct sd *sd = (struct sd *) gspca_dev; | ||
136 | struct usb_device *udev = gspca_dev->dev; | ||
137 | int res, actual_len; | ||
138 | uint8_t *obuf = sd->obuf; | ||
139 | uint8_t *ibuf = sd->ibuf; | ||
140 | struct cam_hdr *chdr = (void *)obuf; | ||
141 | struct cam_hdr *rhdr = (void *)ibuf; | ||
142 | |||
143 | if (cmd_len & 1 || cmd_len > (0x400 - sizeof(*chdr))) { | ||
144 | err("send_cmd: Invalid command length (0x%x)", cmd_len); | ||
145 | return -1; | ||
146 | } | ||
147 | |||
148 | chdr->magic[0] = 0x47; | ||
149 | chdr->magic[1] = 0x4d; | ||
150 | chdr->cmd = cpu_to_le16(cmd); | ||
151 | chdr->tag = cpu_to_le16(sd->cam_tag); | ||
152 | chdr->len = cpu_to_le16(cmd_len / 2); | ||
153 | |||
154 | memcpy(obuf+sizeof(*chdr), cmdbuf, cmd_len); | ||
155 | |||
156 | res = kinect_write(udev, obuf, cmd_len + sizeof(*chdr)); | ||
157 | PDEBUG(D_USBO, "Control cmd=%04x tag=%04x len=%04x: %d", cmd, | ||
158 | sd->cam_tag, cmd_len, res); | ||
159 | if (res < 0) { | ||
160 | err("send_cmd: Output control transfer failed (%d)", res); | ||
161 | return res; | ||
162 | } | ||
163 | |||
164 | do { | ||
165 | actual_len = kinect_read(udev, ibuf, 0x200); | ||
166 | } while (actual_len == 0); | ||
167 | PDEBUG(D_USBO, "Control reply: %d", res); | ||
168 | if (actual_len < sizeof(*rhdr)) { | ||
169 | err("send_cmd: Input control transfer failed (%d)", res); | ||
170 | return res; | ||
171 | } | ||
172 | actual_len -= sizeof(*rhdr); | ||
173 | |||
174 | if (rhdr->magic[0] != 0x52 || rhdr->magic[1] != 0x42) { | ||
175 | err("send_cmd: Bad magic %02x %02x", rhdr->magic[0], | ||
176 | rhdr->magic[1]); | ||
177 | return -1; | ||
178 | } | ||
179 | if (rhdr->cmd != chdr->cmd) { | ||
180 | err("send_cmd: Bad cmd %02x != %02x", rhdr->cmd, chdr->cmd); | ||
181 | return -1; | ||
182 | } | ||
183 | if (rhdr->tag != chdr->tag) { | ||
184 | err("send_cmd: Bad tag %04x != %04x", rhdr->tag, chdr->tag); | ||
185 | return -1; | ||
186 | } | ||
187 | if (cpu_to_le16(rhdr->len) != (actual_len/2)) { | ||
188 | err("send_cmd: Bad len %04x != %04x", | ||
189 | cpu_to_le16(rhdr->len), (int)(actual_len/2)); | ||
190 | return -1; | ||
191 | } | ||
192 | |||
193 | if (actual_len > reply_len) { | ||
194 | warn("send_cmd: Data buffer is %d bytes long, but got %d bytes", | ||
195 | reply_len, actual_len); | ||
196 | memcpy(replybuf, ibuf+sizeof(*rhdr), reply_len); | ||
197 | } else { | ||
198 | memcpy(replybuf, ibuf+sizeof(*rhdr), actual_len); | ||
199 | } | ||
200 | |||
201 | sd->cam_tag++; | ||
202 | |||
203 | return actual_len; | ||
204 | } | ||
205 | |||
206 | static int write_register(struct gspca_dev *gspca_dev, uint16_t reg, | ||
207 | uint16_t data) | ||
208 | { | ||
209 | uint16_t reply[2]; | ||
210 | uint16_t cmd[2]; | ||
211 | int res; | ||
212 | |||
213 | cmd[0] = cpu_to_le16(reg); | ||
214 | cmd[1] = cpu_to_le16(data); | ||
215 | |||
216 | PDEBUG(D_USBO, "Write Reg 0x%04x <= 0x%02x", reg, data); | ||
217 | res = send_cmd(gspca_dev, 0x03, cmd, 4, reply, 4); | ||
218 | if (res < 0) | ||
219 | return res; | ||
220 | if (res != 2) { | ||
221 | warn("send_cmd returned %d [%04x %04x], 0000 expected", | ||
222 | res, reply[0], reply[1]); | ||
223 | } | ||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | /* this function is called at probe time */ | ||
228 | static int sd_config(struct gspca_dev *gspca_dev, | ||
229 | const struct usb_device_id *id) | ||
230 | { | ||
231 | struct sd *sd = (struct sd *) gspca_dev; | ||
232 | struct cam *cam; | ||
233 | |||
234 | sd->cam_tag = 0; | ||
235 | |||
236 | /* Only video stream is supported for now, | ||
237 | * which has stream flag = 0x80 */ | ||
238 | sd->stream_flag = 0x80; | ||
239 | |||
240 | cam = &gspca_dev->cam; | ||
241 | |||
242 | cam->cam_mode = video_camera_mode; | ||
243 | cam->nmodes = ARRAY_SIZE(video_camera_mode); | ||
244 | |||
245 | #if 0 | ||
246 | /* Setting those values is not needed for video stream */ | ||
247 | cam->npkt = 15; | ||
248 | gspca_dev->pkt_size = 960 * 2; | ||
249 | #endif | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | /* this function is called at probe and resume time */ | ||
255 | static int sd_init(struct gspca_dev *gspca_dev) | ||
256 | { | ||
257 | PDEBUG(D_PROBE, "Kinect Camera device."); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static int sd_start(struct gspca_dev *gspca_dev) | ||
263 | { | ||
264 | int mode; | ||
265 | uint8_t fmt_reg, fmt_val; | ||
266 | uint8_t res_reg, res_val; | ||
267 | uint8_t fps_reg, fps_val; | ||
268 | uint8_t mode_val; | ||
269 | |||
270 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; | ||
271 | |||
272 | if (mode & FORMAT_Y10B) { | ||
273 | fmt_reg = 0x19; | ||
274 | res_reg = 0x1a; | ||
275 | fps_reg = 0x1b; | ||
276 | mode_val = 0x03; | ||
277 | } else { | ||
278 | fmt_reg = 0x0c; | ||
279 | res_reg = 0x0d; | ||
280 | fps_reg = 0x0e; | ||
281 | mode_val = 0x01; | ||
282 | } | ||
283 | |||
284 | /* format */ | ||
285 | if (mode & FORMAT_UYVY) | ||
286 | fmt_val = 0x05; | ||
287 | else | ||
288 | fmt_val = 0x00; | ||
289 | |||
290 | if (mode & MODE_1280x1024) | ||
291 | res_val = 0x02; | ||
292 | else | ||
293 | res_val = 0x01; | ||
294 | |||
295 | if (mode & FPS_HIGH) | ||
296 | fps_val = 0x1e; | ||
297 | else | ||
298 | fps_val = 0x0f; | ||
299 | |||
300 | |||
301 | /* turn off IR-reset function */ | ||
302 | write_register(gspca_dev, 0x105, 0x00); | ||
303 | |||
304 | /* Reset video stream */ | ||
305 | write_register(gspca_dev, 0x05, 0x00); | ||
306 | |||
307 | /* Due to some ridiculous condition in the firmware, we have to start | ||
308 | * and stop the depth stream before the camera will hand us 1280x1024 | ||
309 | * IR. This is a stupid workaround, but we've yet to find a better | ||
310 | * solution. | ||
311 | * | ||
312 | * Thanks to Drew Fisher for figuring this out. | ||
313 | */ | ||
314 | if (mode & (FORMAT_Y10B | MODE_1280x1024)) { | ||
315 | write_register(gspca_dev, 0x13, 0x01); | ||
316 | write_register(gspca_dev, 0x14, 0x1e); | ||
317 | write_register(gspca_dev, 0x06, 0x02); | ||
318 | write_register(gspca_dev, 0x06, 0x00); | ||
319 | } | ||
320 | |||
321 | write_register(gspca_dev, fmt_reg, fmt_val); | ||
322 | write_register(gspca_dev, res_reg, res_val); | ||
323 | write_register(gspca_dev, fps_reg, fps_val); | ||
324 | |||
325 | /* Start video stream */ | ||
326 | write_register(gspca_dev, 0x05, mode_val); | ||
327 | |||
328 | /* disable Hflip */ | ||
329 | write_register(gspca_dev, 0x47, 0x00); | ||
330 | |||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
335 | { | ||
336 | /* reset video stream */ | ||
337 | write_register(gspca_dev, 0x05, 0x00); | ||
338 | } | ||
339 | |||
340 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, u8 *__data, int len) | ||
341 | { | ||
342 | struct sd *sd = (struct sd *) gspca_dev; | ||
343 | |||
344 | struct pkt_hdr *hdr = (void *)__data; | ||
345 | uint8_t *data = __data + sizeof(*hdr); | ||
346 | int datalen = len - sizeof(*hdr); | ||
347 | |||
348 | uint8_t sof = sd->stream_flag | 1; | ||
349 | uint8_t mof = sd->stream_flag | 2; | ||
350 | uint8_t eof = sd->stream_flag | 5; | ||
351 | |||
352 | if (len < 12) | ||
353 | return; | ||
354 | |||
355 | if (hdr->magic[0] != 'R' || hdr->magic[1] != 'B') { | ||
356 | warn("[Stream %02x] Invalid magic %02x%02x", sd->stream_flag, | ||
357 | hdr->magic[0], hdr->magic[1]); | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | if (hdr->flag == sof) | ||
362 | gspca_frame_add(gspca_dev, FIRST_PACKET, data, datalen); | ||
363 | |||
364 | else if (hdr->flag == mof) | ||
365 | gspca_frame_add(gspca_dev, INTER_PACKET, data, datalen); | ||
366 | |||
367 | else if (hdr->flag == eof) | ||
368 | gspca_frame_add(gspca_dev, LAST_PACKET, data, datalen); | ||
369 | |||
370 | else | ||
371 | warn("Packet type not recognized..."); | ||
372 | } | ||
373 | |||
374 | /* sub-driver description */ | ||
375 | static const struct sd_desc sd_desc = { | ||
376 | .name = MODULE_NAME, | ||
377 | .ctrls = sd_ctrls, | ||
378 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
379 | .config = sd_config, | ||
380 | .init = sd_init, | ||
381 | .start = sd_start, | ||
382 | .stopN = sd_stopN, | ||
383 | .pkt_scan = sd_pkt_scan, | ||
384 | /* | ||
385 | .querymenu = sd_querymenu, | ||
386 | .get_streamparm = sd_get_streamparm, | ||
387 | .set_streamparm = sd_set_streamparm, | ||
388 | */ | ||
389 | }; | ||
390 | |||
391 | /* -- module initialisation -- */ | ||
392 | static const struct usb_device_id device_table[] = { | ||
393 | {USB_DEVICE(0x045e, 0x02ae)}, | ||
394 | {} | ||
395 | }; | ||
396 | |||
397 | MODULE_DEVICE_TABLE(usb, device_table); | ||
398 | |||
399 | /* -- device connect -- */ | ||
400 | static int sd_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
401 | { | ||
402 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | ||
403 | THIS_MODULE); | ||
404 | } | ||
405 | |||
406 | static struct usb_driver sd_driver = { | ||
407 | .name = MODULE_NAME, | ||
408 | .id_table = device_table, | ||
409 | .probe = sd_probe, | ||
410 | .disconnect = gspca_disconnect, | ||
411 | #ifdef CONFIG_PM | ||
412 | .suspend = gspca_suspend, | ||
413 | .resume = gspca_resume, | ||
414 | #endif | ||
415 | }; | ||
416 | |||
417 | /* -- module insert / remove -- */ | ||
418 | static int __init sd_mod_init(void) | ||
419 | { | ||
420 | return usb_register(&sd_driver); | ||
421 | } | ||
422 | |||
423 | static void __exit sd_mod_exit(void) | ||
424 | { | ||
425 | usb_deregister(&sd_driver); | ||
426 | } | ||
427 | |||
428 | module_init(sd_mod_init); | ||
429 | module_exit(sd_mod_exit); | ||
diff --git a/drivers/media/video/gspca/konica.c b/drivers/media/video/gspca/konica.c new file mode 100644 index 000000000000..5964691c0e95 --- /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 | |||
36 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | ||
37 | MODULE_DESCRIPTION("Konica chipset USB Camera Driver"); | ||
38 | MODULE_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 */ | ||
47 | struct 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 */ | ||
59 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
60 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
61 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
62 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
63 | static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val); | ||
64 | static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val); | ||
65 | static int sd_setwhitebal(struct gspca_dev *gspca_dev, __s32 val); | ||
66 | static int sd_getwhitebal(struct gspca_dev *gspca_dev, __s32 *val); | ||
67 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | ||
68 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | ||
69 | |||
70 | static 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 | */ | ||
167 | static 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 | |||
185 | static void sd_isoc_irq(struct urb *urb); | ||
186 | |||
187 | static 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 | |||
208 | static 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 | |||
229 | static void konica_stream_on(struct gspca_dev *gspca_dev) | ||
230 | { | ||
231 | reg_w(gspca_dev, 1, 0x0b); | ||
232 | } | ||
233 | |||
234 | static 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 */ | ||
240 | static 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 */ | ||
262 | static 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 | |||
276 | static 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 | |||
350 | static 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 */ | ||
367 | static 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 | |||
471 | resubmit: | ||
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 | |||
483 | static 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 | |||
497 | static 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 | |||
506 | static 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 | |||
520 | static 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 | |||
529 | static 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 | |||
542 | static 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 | |||
551 | static 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 | |||
564 | static 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 | |||
573 | static 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 | |||
586 | static 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 */ | ||
596 | static 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 -- */ | ||
610 | static const struct usb_device_id device_table[] = { | ||
611 | {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */ | ||
612 | {} | ||
613 | }; | ||
614 | MODULE_DEVICE_TABLE(usb, device_table); | ||
615 | |||
616 | /* -- device connect -- */ | ||
617 | static 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 | |||
624 | static 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 -- */ | ||
636 | static int __init sd_mod_init(void) | ||
637 | { | ||
638 | return usb_register(&sd_driver); | ||
639 | } | ||
640 | static void __exit sd_mod_exit(void) | ||
641 | { | ||
642 | usb_deregister(&sd_driver); | ||
643 | } | ||
644 | |||
645 | module_init(sd_mod_init); | ||
646 | module_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..a7722b1aef9b 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c | |||
@@ -28,7 +28,7 @@ int force_sensor; | |||
28 | static int dump_bridge; | 28 | static int dump_bridge; |
29 | int dump_sensor; | 29 | int dump_sensor; |
30 | 30 | ||
31 | static const __devinitdata struct usb_device_id m5602_table[] = { | 31 | static const struct usb_device_id m5602_table[] = { |
32 | {USB_DEVICE(0x0402, 0x5602)}, | 32 | {USB_DEVICE(0x0402, 0x5602)}, |
33 | {} | 33 | {} |
34 | }; | 34 | }; |
@@ -406,18 +406,12 @@ static struct usb_driver sd_driver = { | |||
406 | /* -- module insert / remove -- */ | 406 | /* -- module insert / remove -- */ |
407 | static int __init mod_m5602_init(void) | 407 | static 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 | ||
417 | static void __exit mod_m5602_exit(void) | 412 | static 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 | ||
423 | module_init(mod_m5602_init); | 417 | module_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 | ||
128 | static const unsigned char preinit_mt9m111[][4] = | 128 | static 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 | ||
168 | static const unsigned char init_mt9m111[][4] = | 167 | static 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 | ||
260 | static const unsigned char start_mt9m111[][4] = | 258 | static 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 | ||
108 | static const unsigned char preinit_ov7660[][4] = | 108 | static 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 | ||
143 | static const unsigned char init_ov7660[][4] = | 142 | static 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..703d48670a24 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 |
@@ -624,7 +624,7 @@ static int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
624 | 624 | ||
625 | /* Mask away all uninteresting bits */ | 625 | /* Mask away all uninteresting bits */ |
626 | i2c_data = ((val & 0x0300) >> 2) | | 626 | i2c_data = ((val & 0x0300) >> 2) | |
627 | (i2c_data & 0x3F); | 627 | (i2c_data & 0x3f); |
628 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); | 628 | err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); |
629 | if (err < 0) | 629 | if (err < 0) |
630 | return err; | 630 | return err; |
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 | ||
157 | static const unsigned char preinit_ov9650[][3] = | 157 | static 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 | ||
183 | static const unsigned char init_ov9650[][3] = | 182 | static 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 | ||
300 | static const unsigned char res_init_ov9650[][3] = | 298 | static 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 | ||
169 | static const unsigned char preinit_po1030[][3] = | 169 | static 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 | ||
196 | static const unsigned char init_po1030[][3] = | 195 | static 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 | ||
86 | static const unsigned char preinit_s5k4aa[][4] = | 86 | static 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 | ||
130 | static const unsigned char init_s5k4aa[][4] = | 129 | static 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 | ||
182 | static const unsigned char VGA_s5k4aa[][4] = | 180 | static 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 | ||
238 | static const unsigned char SXGA_s5k4aa[][4] = | 235 | static 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 | ||
70 | static const unsigned char preinit_s5k83a[][4] = | 70 | static 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 | */ |
111 | static const unsigned char init_s5k83a[][4] = | 110 | static 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 | ||
169 | static const unsigned char start_s5k83a[][4] = | 167 | static 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..0196209a948a 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>"); | |||
28 | MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver"); | 28 | MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver"); |
29 | MODULE_LICENSE("GPL"); | 29 | MODULE_LICENSE("GPL"); |
30 | 30 | ||
31 | /* controls */ | ||
32 | enum 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 */ |
32 | struct sd { | 43 | struct 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 */ |
48 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 57 | static void setbrightness(struct gspca_dev *gspca_dev); |
49 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 58 | static void setcolors(struct gspca_dev *gspca_dev); |
50 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | 59 | static void setgamma(struct gspca_dev *gspca_dev); |
51 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 60 | static void setsharpness(struct gspca_dev *gspca_dev); |
52 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); | 61 | static int sd_setilluminator1(struct gspca_dev *gspca_dev, __s32 val); |
53 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); | 62 | static int sd_setilluminator2(struct gspca_dev *gspca_dev, __s32 val); |
54 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | 63 | |
55 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | 64 | static const struct ctrl sd_ctrls[NCTRLS] = { |
56 | 65 | [BRIGHTNESS] = { | |
57 | static 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 */ |
141 | static int reg_w(struct gspca_dev *gspca_dev, | 166 | static 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 | ||
158 | static void mi_w(struct gspca_dev *gspca_dev, | 187 | static 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 | ||
199 | static 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 | |||
208 | static 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 | |||
220 | static 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 | |||
229 | static 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 | |||
238 | static 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 */ |
171 | static int sd_config(struct gspca_dev *gspca_dev, | 253 | static 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 */ |
190 | static int sd_init(struct gspca_dev *gspca_dev) | 269 | static 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 | ||
195 | static int sd_start(struct gspca_dev *gspca_dev) | 275 | static 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,57 +332,57 @@ 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++) |
298 | mi_w(gspca_dev, i + 1, mi_data[i]); | 361 | mi_w(gspca_dev, i + 1, mi_data[i]); |
299 | 362 | ||
300 | data[0] = 0x00; | 363 | data[0] = 0x00; |
301 | data[1] = 0x4d; /* ISOC transfering enable... */ | 364 | data[1] = 0x4d; /* ISOC transferring 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 | ||
306 | static void sd_stopN(struct gspca_dev *gspca_dev) | 371 | static 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 | ||
317 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 388 | static 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 | ||
355 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 426 | static 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 | |||
368 | static 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 | ||
376 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) | 438 | static 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 | |||
392 | static 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 | |||
400 | static 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 | |||
413 | static 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 | |||
421 | static 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 | |||
434 | static 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 | ||
442 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | 450 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, |
@@ -471,7 +479,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
471 | static const struct sd_desc sd_desc = { | 479 | static 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, |
@@ -482,7 +490,7 @@ static const struct sd_desc sd_desc = { | |||
482 | }; | 490 | }; |
483 | 491 | ||
484 | /* -- module initialisation -- */ | 492 | /* -- module initialisation -- */ |
485 | static const __devinitdata struct usb_device_id device_table[] = { | 493 | static const struct usb_device_id device_table[] = { |
486 | {USB_DEVICE(0x093a, 0x050f)}, | 494 | {USB_DEVICE(0x093a, 0x050f)}, |
487 | {} | 495 | {} |
488 | }; | 496 | }; |
@@ -510,18 +518,11 @@ static struct usb_driver sd_driver = { | |||
510 | /* -- module insert / remove -- */ | 518 | /* -- module insert / remove -- */ |
511 | static int __init sd_mod_init(void) | 519 | static 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 | } |
521 | static void __exit sd_mod_exit(void) | 523 | static 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 | ||
527 | module_init(sd_mod_init); | 528 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c index 33744e724eaa..97e507967434 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 | } |
@@ -469,7 +469,7 @@ static void lcd_stop(struct gspca_dev *gspca_dev) | |||
469 | static int isoc_enable(struct gspca_dev *gspca_dev) | 469 | static int isoc_enable(struct gspca_dev *gspca_dev) |
470 | { | 470 | { |
471 | gspca_dev->usb_buf[0] = 0x00; | 471 | gspca_dev->usb_buf[0] = 0x00; |
472 | gspca_dev->usb_buf[1] = 0x4d; /* ISOC transfering enable... */ | 472 | gspca_dev->usb_buf[1] = 0x4d; /* ISOC transferring enable... */ |
473 | return mr_write(gspca_dev, 2); | 473 | return mr_write(gspca_dev, 2); |
474 | } | 474 | } |
475 | 475 | ||
@@ -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 | /* |
@@ -1230,7 +1229,7 @@ static const struct sd_desc sd_desc = { | |||
1230 | }; | 1229 | }; |
1231 | 1230 | ||
1232 | /* -- module initialisation -- */ | 1231 | /* -- module initialisation -- */ |
1233 | static const __devinitdata struct usb_device_id device_table[] = { | 1232 | static const struct usb_device_id device_table[] = { |
1234 | {USB_DEVICE(0x08ca, 0x0110)}, /* Trust Spyc@m 100 */ | 1233 | {USB_DEVICE(0x08ca, 0x0110)}, /* Trust Spyc@m 100 */ |
1235 | {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */ | 1234 | {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */ |
1236 | {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */ | 1235 | {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */ |
@@ -1261,18 +1260,11 @@ static struct usb_driver sd_driver = { | |||
1261 | /* -- module insert / remove -- */ | 1260 | /* -- module insert / remove -- */ |
1262 | static int __init sd_mod_init(void) | 1261 | static 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 | } |
1272 | static void __exit sd_mod_exit(void) | 1265 | static 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 | ||
1278 | module_init(sd_mod_init); | 1270 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/nw80x.c b/drivers/media/video/gspca/nw80x.c new file mode 100644 index 000000000000..8e754fd4dc5e --- /dev/null +++ b/drivers/media/video/gspca/nw80x.c | |||
@@ -0,0 +1,2145 @@ | |||
1 | /* | ||
2 | * DivIO nw80x subdriver | ||
3 | * | ||
4 | * Copyright (C) 2011 Jean-François Moine (http://moinejf.free.fr) | ||
5 | * Copyright (C) 2003 Sylvain Munaut <tnt@246tNt.com> | ||
6 | * Kjell Claesson <keyson@users.sourceforge.net> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #define MODULE_NAME "nw80x" | ||
24 | |||
25 | #include "gspca.h" | ||
26 | |||
27 | MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); | ||
28 | MODULE_DESCRIPTION("NW80x USB Camera Driver"); | ||
29 | MODULE_LICENSE("GPL"); | ||
30 | |||
31 | static int webcam; | ||
32 | |||
33 | /* controls */ | ||
34 | enum e_ctrl { | ||
35 | GAIN, | ||
36 | EXPOSURE, | ||
37 | AUTOGAIN, | ||
38 | NCTRLS /* number of controls */ | ||
39 | }; | ||
40 | |||
41 | #define AUTOGAIN_DEF 1 | ||
42 | |||
43 | /* specific webcam descriptor */ | ||
44 | struct sd { | ||
45 | struct gspca_dev gspca_dev; /* !! must be the first item */ | ||
46 | |||
47 | struct gspca_ctrl ctrls[NCTRLS]; | ||
48 | |||
49 | u32 ae_res; | ||
50 | s8 ag_cnt; | ||
51 | #define AG_CNT_START 13 | ||
52 | u8 exp_too_low_cnt; | ||
53 | u8 exp_too_high_cnt; | ||
54 | |||
55 | u8 bridge; | ||
56 | u8 webcam; | ||
57 | }; | ||
58 | |||
59 | enum bridges { | ||
60 | BRIDGE_NW800, /* and et31x110 */ | ||
61 | BRIDGE_NW801, | ||
62 | BRIDGE_NW802, | ||
63 | }; | ||
64 | enum webcams { | ||
65 | Generic800, | ||
66 | SpaceCam, /* Trust 120 SpaceCam */ | ||
67 | SpaceCam2, /* other Trust 120 SpaceCam */ | ||
68 | Cvideopro, /* Conceptronic Video Pro */ | ||
69 | Dlink350c, | ||
70 | DS3303u, | ||
71 | Kr651us, | ||
72 | Kritter, | ||
73 | Mustek300, | ||
74 | Proscope, | ||
75 | Twinkle, | ||
76 | DvcV6, | ||
77 | P35u, | ||
78 | Generic802, | ||
79 | NWEBCAMS /* number of webcams */ | ||
80 | }; | ||
81 | |||
82 | static const u8 webcam_chip[NWEBCAMS] = { | ||
83 | [Generic800] = BRIDGE_NW800, /* 06a5:0000 | ||
84 | * Typhoon Webcam 100 USB */ | ||
85 | |||
86 | [SpaceCam] = BRIDGE_NW800, /* 06a5:d800 | ||
87 | * Trust SpaceCam120 or SpaceCam100 PORTABLE */ | ||
88 | |||
89 | [SpaceCam2] = BRIDGE_NW800, /* 06a5:d800 - pas106 | ||
90 | * other Trust SpaceCam120 or SpaceCam100 PORTABLE */ | ||
91 | |||
92 | [Cvideopro] = BRIDGE_NW802, /* 06a5:d001 | ||
93 | * Conceptronic Video Pro 'CVIDEOPRO USB Webcam CCD' */ | ||
94 | |||
95 | [Dlink350c] = BRIDGE_NW802, /* 06a5:d001 | ||
96 | * D-Link NetQam Pro 250plus */ | ||
97 | |||
98 | [DS3303u] = BRIDGE_NW801, /* 06a5:d001 | ||
99 | * Plustek Opticam 500U or ProLink DS3303u */ | ||
100 | |||
101 | [Kr651us] = BRIDGE_NW802, /* 06a5:d001 | ||
102 | * Panasonic GP-KR651US */ | ||
103 | |||
104 | [Kritter] = BRIDGE_NW802, /* 06a5:d001 | ||
105 | * iRez Kritter cam */ | ||
106 | |||
107 | [Mustek300] = BRIDGE_NW802, /* 055f:d001 | ||
108 | * Mustek Wcam 300 mini */ | ||
109 | |||
110 | [Proscope] = BRIDGE_NW802, /* 06a5:d001 | ||
111 | * Scalar USB Microscope (ProScope) */ | ||
112 | |||
113 | [Twinkle] = BRIDGE_NW800, /* 06a5:d800 - hv7121b? (seems pas106) | ||
114 | * Divio Chicony TwinkleCam | ||
115 | * DSB-C110 */ | ||
116 | |||
117 | [DvcV6] = BRIDGE_NW802, /* 0502:d001 | ||
118 | * DVC V6 */ | ||
119 | |||
120 | [P35u] = BRIDGE_NW801, /* 052b:d001, 06a5:d001 and 06be:d001 | ||
121 | * EZCam Pro p35u */ | ||
122 | |||
123 | [Generic802] = BRIDGE_NW802, | ||
124 | }; | ||
125 | /* | ||
126 | * other webcams: | ||
127 | * - nw801 046d:d001 | ||
128 | * Logitech QuickCam Pro (dark focus ring) | ||
129 | * - nw801 0728:d001 | ||
130 | * AVerMedia Camguard | ||
131 | * - nw??? 06a5:d001 | ||
132 | * D-Link NetQam Pro 250plus | ||
133 | * - nw800 065a:d800 | ||
134 | * Showcam NGS webcam | ||
135 | * - nw??? ????:???? | ||
136 | * Sceptre svc300 | ||
137 | */ | ||
138 | |||
139 | /* | ||
140 | * registers | ||
141 | * nw800/et31x110 nw801 nw802 | ||
142 | * 0000..009e 0000..00a1 0000..009e | ||
143 | * 0200..0211 id id | ||
144 | * 0300..0302 id id | ||
145 | * 0400..0406 (inex) 0400..0406 | ||
146 | * 0500..0505 0500..0506 (inex) | ||
147 | * 0600..061a 0600..0601 0600..0601 | ||
148 | * 0800..0814 id id | ||
149 | * 1000..109c 1000..10a1 1000..109a | ||
150 | */ | ||
151 | |||
152 | /* resolutions | ||
153 | * nw800: 320x240, 352x288 | ||
154 | * nw801/802: 320x240, 640x480 | ||
155 | */ | ||
156 | static const struct v4l2_pix_format cif_mode[] = { | ||
157 | {320, 240, V4L2_PIX_FMT_JPGL, V4L2_FIELD_NONE, | ||
158 | .bytesperline = 320, | ||
159 | .sizeimage = 320 * 240 * 4 / 8, | ||
160 | .colorspace = V4L2_COLORSPACE_JPEG}, | ||
161 | {352, 288, V4L2_PIX_FMT_JPGL, V4L2_FIELD_NONE, | ||
162 | .bytesperline = 352, | ||
163 | .sizeimage = 352 * 288 * 4 / 8, | ||
164 | .colorspace = V4L2_COLORSPACE_JPEG} | ||
165 | }; | ||
166 | static const struct v4l2_pix_format vga_mode[] = { | ||
167 | {320, 240, V4L2_PIX_FMT_JPGL, V4L2_FIELD_NONE, | ||
168 | .bytesperline = 320, | ||
169 | .sizeimage = 320 * 240 * 4 / 8, | ||
170 | .colorspace = V4L2_COLORSPACE_JPEG}, | ||
171 | {640, 480, V4L2_PIX_FMT_JPGL, V4L2_FIELD_NONE, | ||
172 | .bytesperline = 640, | ||
173 | .sizeimage = 640 * 480 * 3 / 8, | ||
174 | .colorspace = V4L2_COLORSPACE_JPEG}, | ||
175 | }; | ||
176 | |||
177 | /* | ||
178 | * The sequences below contain: | ||
179 | * - 1st and 2nd bytes: either | ||
180 | * - register number (BE) | ||
181 | * - I2C0 + i2c address | ||
182 | * - 3rd byte: data length (=0 for end of sequence) | ||
183 | * - n bytes: data | ||
184 | */ | ||
185 | #define I2C0 0xff | ||
186 | |||
187 | static const u8 nw800_init[] = { | ||
188 | 0x04, 0x05, 0x01, 0x61, | ||
189 | 0x04, 0x04, 0x01, 0x01, | ||
190 | 0x04, 0x06, 0x01, 0x04, | ||
191 | 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, | ||
192 | 0x05, 0x05, 0x01, 0x00, | ||
193 | 0, 0, 0 | ||
194 | }; | ||
195 | static const u8 nw800_start[] = { | ||
196 | 0x04, 0x06, 0x01, 0xc0, | ||
197 | 0x00, 0x00, 0x40, 0x10, 0x43, 0x00, 0xb4, 0x01, 0x10, 0x00, 0x4f, | ||
198 | 0xef, 0x0e, 0x00, 0x74, 0x01, 0x01, 0x00, 0x19, | ||
199 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
200 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x3e, 0x00, 0x24, | ||
201 | 0x03, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
202 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
203 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
204 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
205 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
206 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
207 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
208 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
209 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
210 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
211 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
212 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
213 | 0x00, 0x80, 0x1f, 0xa0, 0x48, 0xc3, 0x02, 0x88, 0x0c, 0x68, 0x00, | ||
214 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x08, | ||
215 | 0x00, 0x32, 0x01, 0x01, 0x00, 0x16, 0x00, 0x04, | ||
216 | 0x00, 0x4b, 0x00, 0x76, 0x00, 0x86, 0x00, | ||
217 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
218 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
219 | 0x40, 0x20, | ||
220 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
221 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x61, 0xc0, | ||
222 | 0x05, 0x00, 0x06, 0xe8, 0x00, 0x00, 0x00, 0x20, 0x20, | ||
223 | 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
224 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
225 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
226 | 0x00, 0x00, 0x00, | ||
227 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
228 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
229 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
230 | 0x10, 0x00, 0x40, 0x83, 0x02, 0x20, 0x00, 0x13, 0x00, 0x00, 0x00, | ||
231 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
232 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
233 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
234 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
235 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
236 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
237 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
238 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
239 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
240 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
241 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
242 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
243 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
244 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
245 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
246 | 0x10, 0x80, 0x1d, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
247 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x62, | ||
248 | 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, 0x20, | ||
249 | 0x01, 0x60, 0x01, 0x00, 0x00, | ||
250 | |||
251 | 0x04, 0x04, 0x01, 0xff, | ||
252 | 0x04, 0x06, 0x01, 0xc4, | ||
253 | |||
254 | 0x04, 0x06, 0x01, 0xc0, | ||
255 | 0x00, 0x00, 0x40, 0x10, 0x43, 0x00, 0xb4, 0x01, 0x10, 0x00, 0x4f, | ||
256 | 0xef, 0x0e, 0x00, 0x74, 0x01, 0x01, 0x00, 0x19, | ||
257 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
258 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x3e, 0x00, 0x24, | ||
259 | 0x03, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
260 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
261 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
262 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
263 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
264 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
265 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
266 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
267 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
268 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
269 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
270 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
271 | 0x00, 0x80, 0x1f, 0xa0, 0x48, 0xc3, 0x02, 0x88, 0x0c, 0x68, 0x00, | ||
272 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x08, | ||
273 | 0x00, 0x32, 0x01, 0x01, 0x00, 0x16, 0x00, 0x04, | ||
274 | 0x00, 0x4b, 0x00, 0x76, 0x00, 0x86, 0x00, | ||
275 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
276 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
277 | 0x40, 0x20, | ||
278 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
279 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x61, 0xc0, | ||
280 | 0x05, 0x00, 0x06, 0xe8, 0x00, 0x00, 0x00, 0x20, 0x20, | ||
281 | 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
282 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
283 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
284 | 0x00, 0x00, 0x00, | ||
285 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
286 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
287 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
288 | 0x10, 0x00, 0x40, 0x83, 0x02, 0x20, 0x00, 0x13, 0x00, 0x00, 0x00, | ||
289 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
290 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
291 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
293 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
294 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
295 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
296 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
297 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
298 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
299 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
300 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
301 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
302 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
303 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
304 | 0x10, 0x80, 0x1d, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
305 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x62, | ||
306 | 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, 0x20, | ||
307 | 0x01, 0x60, 0x01, 0x00, 0x00, | ||
308 | |||
309 | 0x02, 0x00, 0x11, 0x48, 0x58, 0x9e, 0x48, 0x58, 0x00, 0x00, 0x00, | ||
310 | 0x00, 0x84, 0x36, 0x05, 0x01, 0xf2, 0x86, 0x65, | ||
311 | 0x40, | ||
312 | 0x00, 0x80, 0x01, 0xa0, | ||
313 | 0x10, 0x1a, 0x01, 0x00, | ||
314 | 0x00, 0x91, 0x02, 0x6c, 0x01, | ||
315 | 0x00, 0x03, 0x02, 0xc8, 0x01, | ||
316 | 0x10, 0x1a, 0x01, 0x00, | ||
317 | 0x10, 0x00, 0x01, 0x83, | ||
318 | 0x10, 0x8f, 0x0c, 0x62, 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, | ||
319 | 0x20, 0x01, 0x60, 0x01, | ||
320 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
321 | 0x10, 0x1b, 0x02, 0x69, 0x00, | ||
322 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
323 | 0x05, 0x02, 0x01, 0x02, | ||
324 | 0x06, 0x00, 0x02, 0x04, 0xd9, | ||
325 | 0x05, 0x05, 0x01, 0x20, | ||
326 | 0x05, 0x05, 0x01, 0x21, | ||
327 | 0x10, 0x0e, 0x01, 0x08, | ||
328 | 0x10, 0x41, 0x11, 0x00, 0x08, 0x21, 0x3d, 0x52, 0x63, 0x75, 0x83, | ||
329 | 0x91, 0x9e, 0xaa, 0xb6, 0xc1, 0xcc, 0xd6, 0xe0, | ||
330 | 0xea, | ||
331 | 0x10, 0x03, 0x01, 0x00, | ||
332 | 0x10, 0x0f, 0x02, 0x13, 0x13, | ||
333 | 0x10, 0x03, 0x01, 0x14, | ||
334 | 0x10, 0x41, 0x11, 0x00, 0x08, 0x21, 0x3d, 0x52, 0x63, 0x75, 0x83, | ||
335 | 0x91, 0x9e, 0xaa, 0xb6, 0xc1, 0xcc, 0xd6, 0xe0, | ||
336 | 0xea, | ||
337 | 0x10, 0x0b, 0x01, 0x14, | ||
338 | 0x10, 0x0d, 0x01, 0x20, | ||
339 | 0x10, 0x0c, 0x01, 0x34, | ||
340 | 0x04, 0x06, 0x01, 0xc3, | ||
341 | 0x04, 0x04, 0x01, 0x00, | ||
342 | 0x05, 0x02, 0x01, 0x02, | ||
343 | 0x06, 0x00, 0x02, 0x00, 0x48, | ||
344 | 0x05, 0x05, 0x01, 0x20, | ||
345 | 0x05, 0x05, 0x01, 0x21, | ||
346 | 0, 0, 0 | ||
347 | }; | ||
348 | |||
349 | /* 06a5:d001 - nw801 - Panasonic | ||
350 | * P35u */ | ||
351 | static const u8 nw801_start_1[] = { | ||
352 | 0x05, 0x06, 0x01, 0x04, | ||
353 | 0x00, 0x00, 0x40, 0x0e, 0x00, 0x00, 0xf9, 0x02, 0x11, 0x00, 0x0e, | ||
354 | 0x01, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
355 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
356 | 0x00, 0x01, 0x00, 0x19, 0x00, 0xce, 0x00, 0xf4, | ||
357 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
358 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
359 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
360 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
361 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
362 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
363 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
364 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
365 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
366 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
367 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
368 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
369 | 0x00, 0x80, 0x22, 0xb4, 0x6f, 0x3f, 0x0f, 0x88, 0x20, 0x08, 0x00, | ||
370 | 0x00, 0x00, 0x00, 0x00, 0x69, 0xa8, 0x1f, 0x00, | ||
371 | 0x0d, 0x02, 0x07, 0x00, 0x01, 0x00, 0x19, 0x00, | ||
372 | 0xf2, 0x00, 0x18, 0x06, 0x10, 0x06, 0x10, 0x00, | ||
373 | 0x36, 0x00, | ||
374 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
375 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
376 | 0x40, 0x20, | ||
377 | 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
378 | 0x05, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
379 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
380 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
381 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
382 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
383 | 0x10, 0x00, 0x40, 0x22, 0x02, 0x80, 0x00, 0x1e, 0x00, 0x00, 0x00, | ||
384 | 0x00, 0x00, 0x00, 0x0a, 0x15, 0x08, 0x08, 0x0a, | ||
385 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
386 | 0x00, 0x01, 0x35, 0xfd, 0x07, 0x3d, 0x00, 0x00, | ||
387 | 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x14, 0x02, | ||
388 | 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, | ||
389 | 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x06, | ||
390 | 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, 0xf7, | ||
391 | 0x10, 0x40, 0x40, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, 0x80, | ||
392 | 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, 0xa4, | ||
393 | 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, 0xcf, | ||
394 | 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, 0x64, | ||
395 | 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, 0xe2, | ||
396 | 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
397 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
398 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
399 | 0x10, 0x80, 0x22, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
400 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, 0x00, | ||
401 | 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x82, 0x02, | ||
402 | 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, 0x01, | ||
403 | 0xf0, 0x00, | ||
404 | 0, 0, 0, | ||
405 | }; | ||
406 | static const u8 nw801_start_qvga[] = { | ||
407 | 0x02, 0x00, 0x10, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
408 | 0x00, 0x78, 0x18, 0x0b, 0x06, 0xa2, 0x86, 0x78, | ||
409 | 0x02, 0x0f, 0x01, 0x6b, | ||
410 | 0x10, 0x1a, 0x01, 0x15, | ||
411 | 0x00, 0x00, 0x01, 0x1e, | ||
412 | 0x10, 0x00, 0x01, 0x2f, | ||
413 | 0x10, 0x8c, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
414 | 0x10, 0x11, 0x08, 0x29, 0x00, 0x18, 0x01, 0x1f, 0x00, 0xd2, 0x00, | ||
415 | /* AE window */ | ||
416 | 0, 0, 0, | ||
417 | }; | ||
418 | static const u8 nw801_start_vga[] = { | ||
419 | 0x02, 0x00, 0x10, 0x78, 0xa0, 0x97, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
420 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xf0, | ||
421 | 0x02, 0x0f, 0x01, 0xd5, | ||
422 | 0x10, 0x1a, 0x01, 0x15, | ||
423 | 0x00, 0x00, 0x01, 0x0e, | ||
424 | 0x10, 0x00, 0x01, 0x22, | ||
425 | 0x10, 0x8c, 0x08, 0x00, 0x00, 0x7f, 0x02, 0x00, 0x00, 0xdf, 0x01, | ||
426 | 0x10, 0x11, 0x08, 0x51, 0x00, 0x30, 0x02, 0x3d, 0x00, 0xa4, 0x01, | ||
427 | 0, 0, 0, | ||
428 | }; | ||
429 | static const u8 nw801_start_2[] = { | ||
430 | 0x10, 0x04, 0x01, 0x1a, | ||
431 | 0x10, 0x19, 0x01, 0x09, /* clock */ | ||
432 | 0x10, 0x24, 0x06, 0xc0, 0x00, 0x3f, 0x02, 0x00, 0x01, | ||
433 | /* .. gain .. */ | ||
434 | 0x00, 0x03, 0x02, 0x92, 0x03, | ||
435 | 0x00, 0x1d, 0x04, 0xf2, 0x00, 0x24, 0x07, | ||
436 | 0x00, 0x7b, 0x01, 0xcf, | ||
437 | 0x10, 0x94, 0x01, 0x07, | ||
438 | 0x05, 0x05, 0x01, 0x01, | ||
439 | 0x05, 0x04, 0x01, 0x01, | ||
440 | 0x10, 0x0e, 0x01, 0x08, | ||
441 | 0x10, 0x48, 0x11, 0x00, 0x37, 0x55, 0x6b, 0x7d, 0x8d, 0x9b, 0xa8, | ||
442 | 0xb4, 0xbf, 0xca, 0xd4, 0xdd, 0xe6, 0xef, 0xf0, | ||
443 | 0xf0, | ||
444 | 0x10, 0x03, 0x01, 0x00, | ||
445 | 0x10, 0x0f, 0x02, 0x0c, 0x0c, | ||
446 | 0x10, 0x03, 0x01, 0x08, | ||
447 | 0x10, 0x48, 0x11, 0x00, 0x37, 0x55, 0x6b, 0x7d, 0x8d, 0x9b, 0xa8, | ||
448 | 0xb4, 0xbf, 0xca, 0xd4, 0xdd, 0xe6, 0xef, 0xf0, | ||
449 | 0xf0, | ||
450 | 0x10, 0x0b, 0x01, 0x0b, | ||
451 | 0x10, 0x0d, 0x01, 0x0b, | ||
452 | 0x10, 0x0c, 0x01, 0x1f, | ||
453 | 0x05, 0x06, 0x01, 0x03, | ||
454 | 0, 0, 0 | ||
455 | }; | ||
456 | |||
457 | /* nw802 (sharp IR3Y38M?) */ | ||
458 | static const u8 nw802_start[] = { | ||
459 | 0x04, 0x06, 0x01, 0x04, | ||
460 | 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0xf9, 0x02, 0x10, 0x00, 0x4d, | ||
461 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
462 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
463 | 0x00, 0x01, 0x00, 0x19, 0x00, 0xce, 0x00, 0xf4, | ||
464 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
465 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
466 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
467 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
468 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
469 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
470 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
471 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
472 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
473 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
474 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
475 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
476 | 0x00, 0x80, 0x1f, 0xb4, 0x6f, 0x3f, 0x0f, 0x88, 0x20, 0x68, 0x00, | ||
477 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
478 | 0x00, 0x0c, 0x02, 0x01, 0x00, 0x16, 0x00, 0x94, | ||
479 | 0x00, 0x10, 0x06, 0x08, 0x00, 0x18, 0x00, | ||
480 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
481 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
482 | 0x40, 0x20, | ||
483 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
484 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, | ||
485 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
486 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
487 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
488 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
489 | 0x10, 0x00, 0x40, 0xa1, 0x02, 0x80, 0x00, 0x1d, 0x00, 0x00, 0x00, | ||
490 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
491 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
492 | 0x00, 0x49, 0x13, 0xff, 0x01, 0xc0, 0x00, 0x14, | ||
493 | 0x02, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
494 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
495 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
496 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
497 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
498 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
499 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
500 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
501 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
502 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
503 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
504 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
505 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
506 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x05, 0x82, | ||
507 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
508 | 0x01, 0xf0, 0x00, | ||
509 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
510 | 0x00, 0x78, 0x3f, 0x10, 0x02, 0xf2, 0x8f, 0x78, | ||
511 | 0x40, | ||
512 | 0x10, 0x1a, 0x01, 0x00, | ||
513 | 0x10, 0x00, 0x01, 0xad, | ||
514 | 0x00, 0x00, 0x01, 0x08, | ||
515 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
516 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
517 | 0x10, 0x11, 0x08, 0x51, 0x00, 0xf0, 0x00, 0x3d, 0x00, 0xb4, 0x00, | ||
518 | 0x10, 0x1d, 0x08, 0x00, 0xa0, 0x00, 0xa0, 0x00, 0xa0, 0x00, 0xa0, | ||
519 | 0x10, 0x0e, 0x01, 0x27, | ||
520 | 0x10, 0x41, 0x11, 0x00, 0x0e, 0x35, 0x4f, 0x62, 0x71, 0x7f, 0x8b, | ||
521 | 0x96, 0xa0, 0xa9, 0xb2, 0xbb, 0xc3, 0xca, 0xd2, | ||
522 | 0xd8, | ||
523 | 0x10, 0x03, 0x01, 0x00, | ||
524 | 0x10, 0x0f, 0x02, 0x14, 0x14, | ||
525 | 0x10, 0x03, 0x01, 0x0c, | ||
526 | 0x10, 0x41, 0x11, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, 0x64, 0x74, | ||
527 | 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, 0xe2, 0xf1, | ||
528 | 0xff, | ||
529 | /* 0x00, 0x0e, 0x35, 0x4f, 0x62, 0x71, 0x7f, 0x8b, | ||
530 | * 0x96, 0xa0, 0xa9, 0xb2, 0xbb, 0xc3, 0xca, 0xd2, | ||
531 | * 0xd8, */ | ||
532 | 0x10, 0x0b, 0x01, 0x10, | ||
533 | 0x10, 0x0d, 0x01, 0x11, | ||
534 | 0x10, 0x0c, 0x01, 0x1c, | ||
535 | 0x04, 0x06, 0x01, 0x03, | ||
536 | 0x04, 0x04, 0x01, 0x00, | ||
537 | 0, 0, 0 | ||
538 | }; | ||
539 | /* et31x110 - Trust 120 SpaceCam */ | ||
540 | static const u8 spacecam_init[] = { | ||
541 | 0x04, 0x05, 0x01, 0x01, | ||
542 | 0x04, 0x04, 0x01, 0x01, | ||
543 | 0x04, 0x06, 0x01, 0x04, | ||
544 | 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, | ||
545 | 0x05, 0x05, 0x01, 0x00, | ||
546 | 0, 0, 0 | ||
547 | }; | ||
548 | static const u8 spacecam_start[] = { | ||
549 | 0x04, 0x06, 0x01, 0x44, | ||
550 | 0x00, 0x00, 0x40, 0x10, 0x43, 0x00, 0xb4, 0x01, 0x10, 0x00, 0x4f, | ||
551 | 0xef, 0x0e, 0x00, 0x74, 0x01, 0x01, 0x00, 0x19, | ||
552 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
553 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x3e, 0x00, 0x24, | ||
554 | 0x03, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
555 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
556 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
557 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
558 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
559 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
560 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
561 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
562 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
563 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
564 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
565 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
566 | 0x00, 0x80, 0x1f, 0xa0, 0x48, 0xc3, 0x02, 0x88, 0x0c, 0x68, 0x00, | ||
567 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x08, | ||
568 | 0x00, 0x32, 0x01, 0x01, 0x00, 0x16, 0x00, 0x04, | ||
569 | 0x00, 0x4b, 0x00, 0x7c, 0x00, 0x80, 0x00, | ||
570 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
571 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
572 | 0x40, 0x20, | ||
573 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
574 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
575 | 0x05, 0x00, 0x06, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
576 | 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
577 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
578 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
579 | 0x00, 0x00, 0x00, | ||
580 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
581 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
582 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
583 | 0x10, 0x00, 0x40, 0x83, 0x02, 0x20, 0x00, 0x11, 0x00, 0x00, 0x00, | ||
584 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
585 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
586 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
587 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
588 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
589 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
590 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
591 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
592 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
593 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
594 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
595 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
596 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
597 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
598 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
599 | 0x10, 0x80, 0x1d, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
600 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x62, | ||
601 | 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, 0x20, | ||
602 | 0x01, 0x60, 0x01, 0x00, 0x00, | ||
603 | 0x04, 0x06, 0x01, 0xc0, | ||
604 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
605 | 0x02, 0x00, 0x11, 0x48, 0x58, 0x9e, 0x48, 0x58, 0x00, 0x00, 0x00, | ||
606 | 0x00, 0x84, 0x36, 0x05, 0x01, 0xf2, 0x86, 0x65, | ||
607 | 0x40, | ||
608 | 0x00, 0x80, 0x01, 0xa0, | ||
609 | 0x10, 0x1a, 0x01, 0x00, | ||
610 | 0x00, 0x91, 0x02, 0x32, 0x01, | ||
611 | 0x00, 0x03, 0x02, 0x08, 0x02, | ||
612 | 0x10, 0x00, 0x01, 0x83, | ||
613 | 0x10, 0x8f, 0x0c, 0x62, 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, | ||
614 | 0x20, 0x01, 0x60, 0x01, | ||
615 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
616 | 0x10, 0x0e, 0x01, 0x08, | ||
617 | 0x10, 0x41, 0x11, 0x00, 0x64, 0x99, 0xc0, 0xe2, 0xf9, 0xf9, 0xf9, | ||
618 | 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, | ||
619 | 0xf9, | ||
620 | 0x10, 0x03, 0x01, 0x00, | ||
621 | 0x10, 0x0f, 0x02, 0x13, 0x13, | ||
622 | 0x10, 0x03, 0x01, 0x06, | ||
623 | 0x10, 0x41, 0x11, 0x00, 0x64, 0x99, 0xc0, 0xe2, 0xf9, 0xf9, 0xf9, | ||
624 | 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, | ||
625 | 0xf9, | ||
626 | 0x10, 0x0b, 0x01, 0x08, | ||
627 | 0x10, 0x0d, 0x01, 0x10, | ||
628 | 0x10, 0x0c, 0x01, 0x1f, | ||
629 | 0x04, 0x06, 0x01, 0xc3, | ||
630 | 0x04, 0x05, 0x01, 0x40, | ||
631 | 0x04, 0x04, 0x01, 0x40, | ||
632 | 0, 0, 0 | ||
633 | }; | ||
634 | /* et31x110 - pas106 - other Trust SpaceCam120 */ | ||
635 | static const u8 spacecam2_start[] = { | ||
636 | 0x04, 0x06, 0x01, 0x44, | ||
637 | 0x04, 0x06, 0x01, 0x00, | ||
638 | 0x00, 0x00, 0x40, 0x14, 0x83, 0x00, 0xba, 0x01, 0x10, 0x00, 0x4f, | ||
639 | 0xef, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0x19, | ||
640 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
641 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x06, 0x00, 0xfc, | ||
642 | 0x01, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
643 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
644 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
645 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
646 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
647 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
648 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
649 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
650 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
651 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
652 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
653 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
654 | 0x00, 0x80, 0x1f, 0xb8, 0x48, 0x0f, 0x04, 0x88, 0x14, 0x68, 0x00, | ||
655 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x03, | ||
656 | 0x00, 0x24, 0x01, 0x01, 0x00, 0x16, 0x00, 0x04, | ||
657 | 0x00, 0x4b, 0x00, 0x76, 0x00, 0x86, 0x00, | ||
658 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
659 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
660 | 0x40, 0x20, | ||
661 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
662 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x61, 0x00, | ||
663 | 0x05, 0x00, 0x06, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
664 | 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
665 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
666 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
667 | 0x00, 0x00, 0x00, | ||
668 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
669 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
670 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
671 | 0x10, 0x00, 0x40, 0x80, 0x02, 0x20, 0x00, 0x13, 0x00, 0x00, 0x00, | ||
672 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
673 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
674 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
675 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
676 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
677 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
678 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
679 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
680 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
681 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
682 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
683 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
684 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
685 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
686 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
687 | 0x10, 0x80, 0x1d, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
688 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x62, | ||
689 | 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, 0x20, | ||
690 | 0x01, 0x60, 0x01, 0x00, 0x00, | ||
691 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
692 | 0x04, 0x04, 0x01, 0x40, | ||
693 | 0x04, 0x04, 0x01, 0x00, | ||
694 | I2C0, 0x40, 0x0c, 0x02, 0x0c, 0x12, 0x07, 0x00, 0x00, 0x00, 0x05, | ||
695 | 0x00, 0x00, 0x05, 0x05, | ||
696 | I2C0, 0x40, 0x02, 0x11, 0x06, | ||
697 | I2C0, 0x40, 0x02, 0x14, 0x00, | ||
698 | I2C0, 0x40, 0x02, 0x13, 0x01, /* i2c end */ | ||
699 | 0x02, 0x00, 0x11, 0x48, 0x58, 0x9e, 0x48, 0x58, 0x00, 0x00, 0x00, | ||
700 | 0x00, 0x84, 0x36, 0x05, 0x01, 0xf2, 0x86, 0x65, | ||
701 | 0x40, | ||
702 | I2C0, 0x40, 0x02, 0x02, 0x0c, /* pixel clock */ | ||
703 | I2C0, 0x40, 0x02, 0x0f, 0x00, | ||
704 | I2C0, 0x40, 0x02, 0x13, 0x01, /* i2c end */ | ||
705 | 0x10, 0x00, 0x01, 0x01, | ||
706 | 0x10, 0x8f, 0x0c, 0x62, 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, | ||
707 | 0x20, 0x01, 0x60, 0x01, | ||
708 | I2C0, 0x40, 0x02, 0x05, 0x0f, /* exposure */ | ||
709 | I2C0, 0x40, 0x02, 0x13, 0x01, /* i2c end */ | ||
710 | I2C0, 0x40, 0x07, 0x09, 0x0b, 0x0f, 0x05, 0x05, 0x0f, 0x00, | ||
711 | /* gains */ | ||
712 | I2C0, 0x40, 0x03, 0x12, 0x04, 0x01, | ||
713 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
714 | 0x10, 0x0e, 0x01, 0x08, | ||
715 | 0x10, 0x41, 0x11, 0x00, 0x17, 0x3f, 0x69, 0x7b, 0x8c, 0x9a, 0xa7, | ||
716 | 0xb3, 0xbf, 0xc9, 0xd3, 0xdd, 0xe6, 0xef, 0xf7, | ||
717 | 0xf9, | ||
718 | 0x10, 0x03, 0x01, 0x00, | ||
719 | 0x10, 0x0f, 0x02, 0x13, 0x13, | ||
720 | 0x10, 0x03, 0x01, 0x06, | ||
721 | 0x10, 0x41, 0x11, 0x00, 0x17, 0x3f, 0x69, 0x7b, 0x8c, 0x9a, 0xa7, | ||
722 | 0xb3, 0xbf, 0xc9, 0xd3, 0xdd, 0xe6, 0xef, 0xf7, | ||
723 | 0xf9, | ||
724 | 0x10, 0x0b, 0x01, 0x11, | ||
725 | 0x10, 0x0d, 0x01, 0x10, | ||
726 | 0x10, 0x0c, 0x01, 0x14, | ||
727 | 0x04, 0x06, 0x01, 0x03, | ||
728 | 0x04, 0x05, 0x01, 0x61, | ||
729 | 0x04, 0x04, 0x01, 0x00, | ||
730 | 0, 0, 0 | ||
731 | }; | ||
732 | |||
733 | /* nw802 - Conceptronic Video Pro */ | ||
734 | static const u8 cvideopro_start[] = { | ||
735 | 0x04, 0x06, 0x01, 0x04, | ||
736 | 0x00, 0x00, 0x40, 0x54, 0x96, 0x98, 0xf9, 0x02, 0x18, 0x00, 0x4c, | ||
737 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
738 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
739 | 0x00, 0x0b, 0x00, 0x1b, 0x00, 0xc8, 0x00, 0xf4, | ||
740 | 0x05, 0xb4, 0x00, 0xcc, 0x00, 0x01, 0x00, 0x01, | ||
741 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
742 | 0x00, 0xa2, 0x00, 0xc6, 0x00, 0x60, 0x00, 0xc6, | ||
743 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
744 | 0x00, 0x40, 0x40, 0x00, 0xae, 0x00, 0xd2, 0x00, 0xae, 0x00, 0xd2, | ||
745 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
746 | 0x00, 0xa8, 0x00, 0xc0, 0x00, 0x66, 0x00, 0xc0, | ||
747 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
748 | 0x00, 0x0a, 0x00, 0x54, 0x00, 0x0a, 0x00, 0x54, | ||
749 | 0x00, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
750 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, | ||
751 | 0x00, 0x5d, 0x00, 0xc7, 0x00, 0x7e, 0x00, 0x30, | ||
752 | 0x00, 0x80, 0x1f, 0x98, 0x43, 0x3f, 0x0d, 0x88, 0x20, 0x80, 0x3f, | ||
753 | 0x47, 0xaf, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
754 | 0x00, 0x0c, 0x02, 0x0c, 0x00, 0x1c, 0x00, 0x94, | ||
755 | 0x00, 0x10, 0x06, 0x24, 0x00, 0x4a, 0x00, | ||
756 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
757 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
758 | 0x40, 0x20, | ||
759 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
760 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0xff, 0x00, | ||
761 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
762 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
763 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
764 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
765 | 0x10, 0x00, 0x40, 0xa0, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
766 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
767 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
768 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xe0, 0x00, 0x0c, | ||
769 | 0x00, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
770 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
771 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
772 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
773 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
774 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
775 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
776 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
777 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
778 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
779 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
780 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
781 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
782 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x05, 0x82, | ||
783 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
784 | 0x01, 0xf0, 0x00, | ||
785 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x8c, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
786 | 0x00, 0x78, 0x3f, 0x3f, 0x06, 0xf2, 0x8f, 0xf0, | ||
787 | 0x40, | ||
788 | 0x10, 0x1a, 0x01, 0x03, | ||
789 | 0x10, 0x00, 0x01, 0xac, | ||
790 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
791 | 0x10, 0x1b, 0x02, 0x3b, 0x01, | ||
792 | 0x10, 0x11, 0x08, 0x61, 0x00, 0xe0, 0x00, 0x49, 0x00, 0xa8, 0x00, | ||
793 | 0x10, 0x1f, 0x06, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
794 | 0x10, 0x1d, 0x02, 0x40, 0x06, | ||
795 | 0x10, 0x0e, 0x01, 0x08, | ||
796 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x46, 0x62, 0x76, 0x86, 0x94, 0xa0, | ||
797 | 0xab, 0xb6, 0xbf, 0xc8, 0xcf, 0xd7, 0xdc, 0xdc, | ||
798 | 0xdc, | ||
799 | 0x10, 0x03, 0x01, 0x00, | ||
800 | 0x10, 0x0f, 0x02, 0x12, 0x12, | ||
801 | 0x10, 0x03, 0x01, 0x0c, | ||
802 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x46, 0x62, 0x76, 0x86, 0x94, 0xa0, | ||
803 | 0xab, 0xb6, 0xbf, 0xc8, 0xcf, 0xd7, 0xdc, 0xdc, | ||
804 | 0xdc, | ||
805 | 0x10, 0x0b, 0x01, 0x09, | ||
806 | 0x10, 0x0d, 0x01, 0x10, | ||
807 | 0x10, 0x0c, 0x01, 0x2f, | ||
808 | 0x04, 0x06, 0x01, 0x03, | ||
809 | 0x04, 0x04, 0x01, 0x00, | ||
810 | 0, 0, 0 | ||
811 | }; | ||
812 | |||
813 | /* nw802 - D-link dru-350c cam */ | ||
814 | static const u8 dlink_start[] = { | ||
815 | 0x04, 0x06, 0x01, 0x04, | ||
816 | 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x92, 0x03, 0x10, 0x00, 0x4d, | ||
817 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
818 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
819 | 0x00, 0x01, 0x00, 0x19, 0x00, 0xce, 0x00, 0xf4, | ||
820 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
821 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
822 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
823 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
824 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
825 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
826 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
827 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
828 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
829 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
830 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
831 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
832 | 0x00, 0x80, 0x1f, 0xb4, 0x6f, 0x3f, 0x0f, 0x88, 0x20, 0x68, 0x00, | ||
833 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
834 | 0x00, 0x0c, 0x02, 0x01, 0x00, 0x16, 0x00, 0x94, | ||
835 | 0x00, 0x10, 0x06, 0x10, 0x00, 0x36, 0x00, | ||
836 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
837 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
838 | 0x40, 0x20, | ||
839 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
840 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, | ||
841 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
842 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
843 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
844 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
845 | 0x10, 0x00, 0x40, 0xa1, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
846 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
847 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
848 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xc0, 0x00, 0x14, | ||
849 | 0x02, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
850 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
851 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
852 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
853 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
854 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
855 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
856 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
857 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
858 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
859 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
860 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
861 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
862 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x01, 0x82, | ||
863 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
864 | 0x01, 0xf0, 0x00, | ||
865 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
866 | 0x00, 0x78, 0x3f, 0x10, 0x02, 0xf2, 0x8f, 0x78, | ||
867 | 0x40, | ||
868 | 0x10, 0x1a, 0x01, 0x00, | ||
869 | 0x10, 0x00, 0x01, 0xad, | ||
870 | 0x00, 0x00, 0x01, 0x08, | ||
871 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
872 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
873 | 0x10, 0x11, 0x08, 0x51, 0x00, 0xf0, 0x00, 0x3d, 0x00, 0xb4, 0x00, | ||
874 | 0x10, 0x1d, 0x08, 0x40, 0x06, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
875 | 0x10, 0x0e, 0x01, 0x20, | ||
876 | 0x10, 0x41, 0x11, 0x00, 0x07, 0x1e, 0x38, 0x4d, 0x60, 0x70, 0x7f, | ||
877 | 0x8e, 0x9b, 0xa8, 0xb4, 0xbf, 0xca, 0xd5, 0xdf, | ||
878 | 0xea, | ||
879 | 0x10, 0x03, 0x01, 0x00, | ||
880 | 0x10, 0x0f, 0x02, 0x11, 0x11, | ||
881 | 0x10, 0x03, 0x01, 0x10, | ||
882 | 0x10, 0x41, 0x11, 0x00, 0x07, 0x1e, 0x38, 0x4d, 0x60, 0x70, 0x7f, | ||
883 | 0x8e, 0x9b, 0xa8, 0xb4, 0xbf, 0xca, 0xd5, 0xdf, | ||
884 | 0xea, | ||
885 | 0x10, 0x0b, 0x01, 0x19, | ||
886 | 0x10, 0x0d, 0x01, 0x10, | ||
887 | 0x10, 0x0c, 0x01, 0x1e, | ||
888 | 0x04, 0x06, 0x01, 0x03, | ||
889 | 0x04, 0x04, 0x01, 0x00, | ||
890 | 0, 0, 0 | ||
891 | }; | ||
892 | |||
893 | /* 06a5:d001 - nw801 - Sony | ||
894 | * Plustek Opticam 500U or ProLink DS3303u (Hitachi HD49322BF) */ | ||
895 | /*fixme: 320x240 only*/ | ||
896 | static const u8 ds3303_start[] = { | ||
897 | 0x05, 0x06, 0x01, 0x04, | ||
898 | 0x00, 0x00, 0x40, 0x16, 0x00, 0x00, 0xf9, 0x02, 0x11, 0x00, 0x0e, | ||
899 | 0x01, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
900 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
901 | 0x00, 0x01, 0x00, 0x19, 0x00, 0xce, 0x00, 0xf4, | ||
902 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
903 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
904 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
905 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
906 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
907 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
908 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
909 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
910 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
911 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
912 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
913 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
914 | 0x00, 0x80, 0x22, 0xb4, 0x6f, 0x3f, 0x0f, 0x88, 0x20, 0x08, 0x00, | ||
915 | 0x00, 0x00, 0x00, 0x00, 0xa9, 0xa8, 0x1f, 0x00, | ||
916 | 0x0d, 0x02, 0x07, 0x00, 0x01, 0x00, 0x19, 0x00, | ||
917 | 0xf2, 0x00, 0x18, 0x06, 0x10, 0x06, 0x10, 0x00, | ||
918 | 0x36, 0x00, | ||
919 | 0x02, 0x00, 0x12, 0x03, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
920 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0x50, | ||
921 | 0x40, 0x20, | ||
922 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
923 | 0x05, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0xff, 0x00, | ||
924 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
925 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
926 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
927 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
928 | 0x10, 0x00, 0x40, 0x2f, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
929 | 0x00, 0x00, 0x00, 0x10, 0x1f, 0x10, 0x08, 0x0a, | ||
930 | 0x0a, 0x51, 0x00, 0xf1, 0x00, 0x3c, 0x00, 0xb4, | ||
931 | 0x00, 0x01, 0x15, 0xfd, 0x07, 0x3d, 0x00, 0x00, | ||
932 | 0x00, 0x00, 0x00, 0x00, 0x8c, 0x04, 0x01, 0x20, | ||
933 | 0x02, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, | ||
934 | 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x03, | ||
935 | 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, 0xf7, | ||
936 | 0x10, 0x40, 0x40, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, 0x80, | ||
937 | 0x00, 0x2d, 0x46, 0x58, 0x67, 0x74, 0x7f, 0x88, | ||
938 | 0x94, 0x9d, 0xa6, 0xae, 0xb5, 0xbd, 0xc4, 0xcb, | ||
939 | 0xd1, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, 0x64, | ||
940 | 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, 0xe2, | ||
941 | 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
942 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
943 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
944 | 0x10, 0x80, 0x22, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
945 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x3f, 0x01, | ||
946 | 0x00, 0x00, 0xef, 0x00, 0x02, 0x0a, 0x82, 0x02, | ||
947 | 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, 0x01, | ||
948 | 0xf0, 0x00, | ||
949 | |||
950 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
951 | 0x00, 0x78, 0x3f, 0x3f, 0x00, 0xf2, 0x8f, 0x81, | ||
952 | 0x40, | ||
953 | 0x10, 0x1a, 0x01, 0x15, | ||
954 | 0x10, 0x00, 0x01, 0x2f, | ||
955 | 0x10, 0x8c, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
956 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
957 | 0x10, 0x11, 0x08, 0x61, 0x00, 0xe0, 0x00, 0x49, 0x00, 0xa8, 0x00, | ||
958 | 0x10, 0x26, 0x06, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
959 | 0x10, 0x24, 0x02, 0x40, 0x06, | ||
960 | 0x10, 0x0e, 0x01, 0x08, | ||
961 | 0x10, 0x48, 0x11, 0x00, 0x15, 0x40, 0x67, 0x84, 0x9d, 0xb2, 0xc6, | ||
962 | 0xd6, 0xe7, 0xf6, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, | ||
963 | 0xf9, | ||
964 | 0x10, 0x03, 0x01, 0x00, | ||
965 | 0x10, 0x0f, 0x02, 0x16, 0x16, | ||
966 | 0x10, 0x03, 0x01, 0x0c, | ||
967 | 0x10, 0x48, 0x11, 0x00, 0x15, 0x40, 0x67, 0x84, 0x9d, 0xb2, 0xc6, | ||
968 | 0xd6, 0xe7, 0xf6, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, | ||
969 | 0xf9, | ||
970 | 0x10, 0x0b, 0x01, 0x26, | ||
971 | 0x10, 0x0d, 0x01, 0x10, | ||
972 | 0x10, 0x0c, 0x01, 0x1c, | ||
973 | 0x05, 0x06, 0x01, 0x03, | ||
974 | 0x05, 0x04, 0x01, 0x00, | ||
975 | 0, 0, 0 | ||
976 | }; | ||
977 | |||
978 | /* 06a5:d001 - nw802 - Panasonic | ||
979 | * GP-KR651US (Philips TDA8786) */ | ||
980 | static const u8 kr651_start_1[] = { | ||
981 | 0x04, 0x06, 0x01, 0x04, | ||
982 | 0x00, 0x00, 0x40, 0x44, 0x96, 0x98, 0xf9, 0x02, 0x18, 0x00, 0x48, | ||
983 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
984 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
985 | 0x00, 0x0b, 0x00, 0x1b, 0x00, 0xc8, 0x00, 0xf4, | ||
986 | 0x05, 0xb4, 0x00, 0xcc, 0x00, 0x01, 0x00, 0x01, | ||
987 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
988 | 0x00, 0xa2, 0x00, 0xc6, 0x00, 0x60, 0x00, 0xc6, | ||
989 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
990 | 0x00, 0x40, 0x40, 0x00, 0xae, 0x00, 0xd2, 0x00, 0xae, 0x00, 0xd2, | ||
991 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
992 | 0x00, 0xa8, 0x00, 0xc0, 0x00, 0x66, 0x00, 0xc0, | ||
993 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
994 | 0x00, 0x0a, 0x00, 0x54, 0x00, 0x0a, 0x00, 0x54, | ||
995 | 0x00, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
996 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, | ||
997 | 0x00, 0x5d, 0x00, 0xc7, 0x00, 0x7e, 0x00, 0x30, | ||
998 | 0x00, 0x80, 0x1f, 0x18, 0x43, 0x3f, 0x0d, 0x88, 0x20, 0x80, 0x3f, | ||
999 | 0x47, 0xaf, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
1000 | 0x00, 0x0c, 0x02, 0x0c, 0x00, 0x1c, 0x00, 0x94, | ||
1001 | 0x00, 0x10, 0x06, 0x24, 0x00, 0x4a, 0x00, | ||
1002 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1003 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1004 | 0x40, 0x20, | ||
1005 | 0x03, 0x00, 0x03, 0x02, 0x00, 0x00, | ||
1006 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, | ||
1007 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
1008 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1009 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1010 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1011 | 0x10, 0x00, 0x40, 0xa0, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
1012 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
1013 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1014 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xe0, 0x00, 0x0c, | ||
1015 | 0x00, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
1016 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1017 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
1018 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
1019 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
1020 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
1021 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1022 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1023 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1024 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1025 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1026 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1027 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
1028 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x05, 0x82, | ||
1029 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
1030 | 0x01, 0xf0, 0x00, | ||
1031 | 0, 0, 0 | ||
1032 | }; | ||
1033 | static const u8 kr651_start_qvga[] = { | ||
1034 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
1035 | 0x00, 0x78, 0x3f, 0x10, 0x02, 0xf2, 0x8f, 0x78, | ||
1036 | 0x40, | ||
1037 | 0x10, 0x1a, 0x01, 0x03, | ||
1038 | 0x10, 0x00, 0x01, 0xac, | ||
1039 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1040 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
1041 | 0x10, 0x11, 0x08, 0x29, 0x00, 0x18, 0x01, 0x1f, 0x00, 0xd2, 0x00, | ||
1042 | 0x10, 0x1d, 0x06, 0xe0, 0x00, 0x0c, 0x00, 0x52, 0x00, | ||
1043 | 0x10, 0x1d, 0x02, 0x28, 0x01, | ||
1044 | 0, 0, 0 | ||
1045 | }; | ||
1046 | static const u8 kr651_start_vga[] = { | ||
1047 | 0x02, 0x00, 0x11, 0x78, 0xa0, 0x8c, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1048 | 0x00, 0xf0, 0x30, 0x03, 0x01, 0x82, 0x82, 0x98, | ||
1049 | 0x80, | ||
1050 | 0x10, 0x1a, 0x01, 0x03, | ||
1051 | 0x10, 0x00, 0x01, 0xa0, | ||
1052 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x7f, 0x02, 0x00, 0x00, 0xdf, 0x01, | ||
1053 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
1054 | 0x10, 0x11, 0x08, 0x51, 0x00, 0x30, 0x02, 0x3d, 0x00, 0xa4, 0x01, | ||
1055 | 0x10, 0x1d, 0x06, 0xe0, 0x00, 0x0c, 0x00, 0x52, 0x00, | ||
1056 | 0x10, 0x1d, 0x02, 0x68, 0x00, | ||
1057 | }; | ||
1058 | static const u8 kr651_start_2[] = { | ||
1059 | 0x10, 0x0e, 0x01, 0x08, | ||
1060 | 0x10, 0x41, 0x11, 0x00, 0x11, 0x3c, 0x5c, 0x74, 0x88, 0x99, 0xa8, | ||
1061 | 0xb7, 0xc4, 0xd0, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, | ||
1062 | 0xdc, | ||
1063 | 0x10, 0x03, 0x01, 0x00, | ||
1064 | 0x10, 0x0f, 0x02, 0x0c, 0x0c, | ||
1065 | 0x10, 0x03, 0x01, 0x0c, | ||
1066 | 0x10, 0x41, 0x11, 0x00, 0x11, 0x3c, 0x5c, 0x74, 0x88, 0x99, 0xa8, | ||
1067 | 0xb7, 0xc4, 0xd0, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, | ||
1068 | 0xdc, | ||
1069 | 0x10, 0x0b, 0x01, 0x10, | ||
1070 | 0x10, 0x0d, 0x01, 0x10, | ||
1071 | 0x10, 0x0c, 0x01, 0x2d, | ||
1072 | 0x04, 0x06, 0x01, 0x03, | ||
1073 | 0x04, 0x04, 0x01, 0x00, | ||
1074 | 0, 0, 0 | ||
1075 | }; | ||
1076 | |||
1077 | /* nw802 - iRez Kritter cam */ | ||
1078 | static const u8 kritter_start[] = { | ||
1079 | 0x04, 0x06, 0x01, 0x06, | ||
1080 | 0x00, 0x00, 0x40, 0x44, 0x96, 0x98, 0x94, 0x03, 0x18, 0x00, 0x48, | ||
1081 | 0x0f, 0x1e, 0x00, 0x0c, 0x02, 0x01, 0x00, 0x19, | ||
1082 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
1083 | 0x00, 0x0b, 0x00, 0x1b, 0x00, 0x0a, 0x01, 0x28, | ||
1084 | 0x07, 0xb4, 0x00, 0xcc, 0x00, 0x01, 0x00, 0x01, | ||
1085 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1086 | 0x00, 0xa2, 0x00, 0xc6, 0x00, 0x60, 0x00, 0xc6, | ||
1087 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1088 | 0x00, 0x40, 0x40, 0x00, 0xae, 0x00, 0xd2, 0x00, 0xae, 0x00, 0xd2, | ||
1089 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1090 | 0x00, 0xa8, 0x00, 0xc0, 0x00, 0x66, 0x00, 0xc0, | ||
1091 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1092 | 0x00, 0x0a, 0x00, 0x54, 0x00, 0x0a, 0x00, 0x54, | ||
1093 | 0x00, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
1094 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, | ||
1095 | 0x00, 0x5d, 0x00, 0x0e, 0x00, 0x7e, 0x00, 0x30, | ||
1096 | 0x00, 0x80, 0x1f, 0x18, 0x43, 0x3f, 0x0d, 0x88, 0x20, 0x80, 0x3f, | ||
1097 | 0x47, 0xaf, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
1098 | 0x00, 0x0b, 0x02, 0x0c, 0x00, 0x1c, 0x00, 0x94, | ||
1099 | 0x00, 0x10, 0x06, 0x24, 0x00, 0x4a, 0x00, | ||
1100 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1101 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1102 | 0x40, 0x20, | ||
1103 | 0x03, 0x00, 0x03, 0x02, 0x00, 0x00, | ||
1104 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0xff, 0x00, | ||
1105 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
1106 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1108 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1109 | 0x10, 0x00, 0x40, 0xa0, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
1110 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
1111 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1112 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xe0, 0x00, 0x0c, | ||
1113 | 0x00, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
1114 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1115 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
1116 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
1117 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
1118 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
1119 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1120 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1121 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1122 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1123 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1124 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1125 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
1126 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x82, | ||
1127 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
1128 | 0x01, 0xf0, 0x00, | ||
1129 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x8c, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
1130 | 0x00, 0x78, 0x3f, 0x3f, 0x06, 0xf2, 0x8f, 0xf0, | ||
1131 | 0x40, | ||
1132 | 0x10, 0x1a, 0x01, 0x03, | ||
1133 | 0x10, 0x00, 0x01, 0xaf, | ||
1134 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1135 | 0x10, 0x1b, 0x02, 0x3b, 0x01, | ||
1136 | 0x10, 0x11, 0x08, 0x61, 0x00, 0xe0, 0x00, 0x49, 0x00, 0xa8, 0x00, | ||
1137 | 0x10, 0x1d, 0x06, 0xe0, 0x00, 0x0c, 0x00, 0x52, 0x00, | ||
1138 | 0x10, 0x1d, 0x02, 0x00, 0x00, | ||
1139 | 0x10, 0x0e, 0x01, 0x08, | ||
1140 | 0x10, 0x41, 0x11, 0x00, 0x0d, 0x36, 0x4e, 0x60, 0x6f, 0x7b, 0x86, | ||
1141 | 0x90, 0x98, 0xa1, 0xa9, 0xb1, 0xb7, 0xbe, 0xc4, | ||
1142 | 0xcb, | ||
1143 | 0x10, 0x03, 0x01, 0x00, | ||
1144 | 0x10, 0x0f, 0x02, 0x0d, 0x0d, | ||
1145 | 0x10, 0x03, 0x01, 0x02, | ||
1146 | 0x10, 0x41, 0x11, 0x00, 0x0d, 0x36, 0x4e, 0x60, 0x6f, 0x7b, 0x86, | ||
1147 | 0x90, 0x98, 0xa1, 0xa9, 0xb1, 0xb7, 0xbe, 0xc4, | ||
1148 | 0xcb, | ||
1149 | 0x10, 0x0b, 0x01, 0x17, | ||
1150 | 0x10, 0x0d, 0x01, 0x10, | ||
1151 | 0x10, 0x0c, 0x01, 0x1e, | ||
1152 | 0x04, 0x06, 0x01, 0x03, | ||
1153 | 0x04, 0x04, 0x01, 0x00, | ||
1154 | 0, 0, 0 | ||
1155 | }; | ||
1156 | |||
1157 | /* nw802 - Mustek Wcam 300 mini */ | ||
1158 | static const u8 mustek_start[] = { | ||
1159 | 0x04, 0x06, 0x01, 0x04, | ||
1160 | 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x92, 0x03, 0x10, 0x00, 0x4d, | ||
1161 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
1162 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
1163 | 0x00, 0x01, 0x00, 0x19, 0x00, 0xce, 0x00, 0xf4, | ||
1164 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
1165 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
1166 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
1167 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
1168 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
1169 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1170 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
1171 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1172 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
1173 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
1174 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
1175 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
1176 | 0x00, 0x80, 0x1f, 0xb4, 0x6f, 0x3f, 0x0f, 0x88, 0x20, 0x68, 0x00, | ||
1177 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
1178 | 0x00, 0x0c, 0x02, 0x01, 0x00, 0x16, 0x00, 0x94, | ||
1179 | 0x00, 0x10, 0x06, 0xfc, 0x05, 0x0c, 0x06, | ||
1180 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1181 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1182 | 0x40, 0x20, | ||
1183 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
1184 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, | ||
1185 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
1186 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1187 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1188 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1189 | 0x10, 0x00, 0x40, 0xa1, 0x02, 0x80, 0x00, 0x13, 0x00, 0x00, 0x00, | ||
1190 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
1191 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1192 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xc0, 0x00, 0x14, | ||
1193 | 0x02, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
1194 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1195 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
1196 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
1197 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
1198 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
1199 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1200 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1201 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1202 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1203 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1204 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1205 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
1206 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x01, 0x82, | ||
1207 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
1208 | 0x01, 0xf0, 0x00, | ||
1209 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
1210 | 0x00, 0x78, 0x3f, 0x10, 0x02, 0xf2, 0x8f, 0x78, | ||
1211 | 0x40, | ||
1212 | 0x10, 0x1a, 0x01, 0x00, | ||
1213 | 0x10, 0x00, 0x01, 0xad, | ||
1214 | 0x00, 0x00, 0x01, 0x08, | ||
1215 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1216 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
1217 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1218 | 0x10, 0x1d, 0x08, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, | ||
1219 | 0x10, 0x0e, 0x01, 0x0f, | ||
1220 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x29, 0x4a, 0x64, 0x7a, 0x8c, 0x9e, | ||
1221 | 0xad, 0xba, 0xc7, 0xd3, 0xde, 0xe8, 0xf1, 0xf9, | ||
1222 | 0xff, | ||
1223 | 0x10, 0x0f, 0x02, 0x11, 0x11, | ||
1224 | 0x10, 0x03, 0x01, 0x0c, | ||
1225 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x29, 0x4a, 0x64, 0x7a, 0x8c, 0x9e, | ||
1226 | 0xad, 0xba, 0xc7, 0xd3, 0xde, 0xe8, 0xf1, 0xf9, | ||
1227 | 0xff, | ||
1228 | 0x10, 0x0b, 0x01, 0x1c, | ||
1229 | 0x10, 0x0d, 0x01, 0x1a, | ||
1230 | 0x10, 0x0c, 0x01, 0x34, | ||
1231 | 0x04, 0x05, 0x01, 0x61, | ||
1232 | 0x04, 0x04, 0x01, 0x40, | ||
1233 | 0x04, 0x06, 0x01, 0x03, | ||
1234 | 0, 0, 0 | ||
1235 | }; | ||
1236 | |||
1237 | /* nw802 - Scope USB Microscope M2 (ProScope) (Hitachi HD49322BF) */ | ||
1238 | static const u8 proscope_init[] = { | ||
1239 | 0x04, 0x05, 0x01, 0x21, | ||
1240 | 0x04, 0x04, 0x01, 0x01, | ||
1241 | 0, 0, 0 | ||
1242 | }; | ||
1243 | static const u8 proscope_start_1[] = { | ||
1244 | 0x04, 0x06, 0x01, 0x04, | ||
1245 | 0x00, 0x00, 0x40, 0x10, 0x01, 0x00, 0xf9, 0x02, 0x10, 0x00, 0x04, | ||
1246 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
1247 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
1248 | 0x00, 0x08, 0x00, 0x17, 0x00, 0xce, 0x00, 0xf4, | ||
1249 | 0x05, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
1250 | 0x00, 0xce, 0x00, 0xf8, 0x03, 0x3e, 0x00, 0x86, | ||
1251 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
1252 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
1253 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0xb6, | ||
1254 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1255 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
1256 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1257 | 0x00, 0xf6, 0x03, 0x34, 0x04, 0xf6, 0x03, 0x34, | ||
1258 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
1259 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xe8, | ||
1260 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
1261 | 0x00, 0x80, 0x1f, 0xb4, 0x6f, 0x1f, 0x0f, 0x08, 0x20, 0xa8, 0x00, | ||
1262 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
1263 | 0x00, 0x0c, 0x02, 0x01, 0x00, 0x19, 0x00, 0x94, | ||
1264 | 0x00, 0x10, 0x06, 0x10, 0x00, 0x36, 0x00, | ||
1265 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1266 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1267 | 0x40, 0x20, | ||
1268 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
1269 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, | ||
1270 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
1271 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1272 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1273 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1274 | 0x10, 0x00, 0x40, 0xad, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
1275 | 0x00, 0x00, 0x00, 0x10, 0x1f, 0x10, 0x08, 0x0a, | ||
1276 | 0x0a, 0x51, 0x00, 0xf1, 0x00, 0x3c, 0x00, 0xb4, | ||
1277 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x8c, 0x04, 0x01, | ||
1278 | 0x20, 0x02, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, | ||
1279 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1280 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
1281 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
1282 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x2d, 0x46, 0x58, 0x67, 0x74, 0x7f, | ||
1283 | 0x88, 0x94, 0x9d, 0xa6, 0xae, 0xb5, 0xbd, 0xc4, | ||
1284 | 0xcb, 0xd1, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1285 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1286 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1287 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1288 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1289 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1290 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x3f, | ||
1291 | 0x01, 0x00, 0x00, 0xef, 0x00, 0x09, 0x05, 0x82, | ||
1292 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
1293 | 0x01, 0xf0, 0x00, | ||
1294 | 0, 0, 0 | ||
1295 | }; | ||
1296 | static const u8 proscope_start_qvga[] = { | ||
1297 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x9e, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
1298 | 0x00, 0x78, 0x3f, 0x10, 0x02, 0xf2, 0x8f, 0x78, | ||
1299 | 0x40, | ||
1300 | 0x10, 0x1a, 0x01, 0x06, | ||
1301 | 0x00, 0x03, 0x02, 0xf9, 0x02, | ||
1302 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1303 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
1304 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1305 | 0x10, 0x1d, 0x08, 0xc0, 0x0d, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
1306 | 0x10, 0x0e, 0x01, 0x10, | ||
1307 | 0, 0, 0 | ||
1308 | }; | ||
1309 | static const u8 proscope_start_vga[] = { | ||
1310 | 0x00, 0x03, 0x02, 0xf9, 0x02, | ||
1311 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x7f, 0x02, 0x00, 0x00, 0xdf, 0x01, | ||
1312 | 0x02, 0x00, 0x11, 0x78, 0xa0, 0x8c, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1313 | 0x00, 0xf0, 0x16, 0x00, 0x00, 0x82, 0x84, 0x00, | ||
1314 | 0x80, | ||
1315 | 0x10, 0x1a, 0x01, 0x06, | ||
1316 | 0x10, 0x00, 0x01, 0xa1, | ||
1317 | 0x10, 0x1b, 0x02, 0x00, 0x00, | ||
1318 | 0x10, 0x1d, 0x08, 0xc0, 0x0d, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
1319 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x7f, 0x02, 0x00, 0x00, 0xdf, 0x01, | ||
1320 | 0x10, 0x0e, 0x01, 0x10, | ||
1321 | 0x10, 0x41, 0x11, 0x00, 0x10, 0x51, 0x6e, 0x83, 0x93, 0xa1, 0xae, | ||
1322 | 0xb9, 0xc3, 0xcc, 0xd4, 0xdd, 0xe4, 0xeb, 0xf2, | ||
1323 | 0xf9, | ||
1324 | 0x10, 0x03, 0x01, 0x00, | ||
1325 | 0, 0, 0 | ||
1326 | }; | ||
1327 | static const u8 proscope_start_2[] = { | ||
1328 | 0x10, 0x0f, 0x02, 0x0c, 0x0c, | ||
1329 | 0x10, 0x03, 0x01, 0x0c, | ||
1330 | 0x10, 0x41, 0x11, 0x00, 0x10, 0x51, 0x6e, 0x83, 0x93, 0xa1, 0xae, | ||
1331 | 0xb9, 0xc3, 0xcc, 0xd4, 0xdd, 0xe4, 0xeb, 0xf2, | ||
1332 | 0xf9, | ||
1333 | 0x10, 0x0b, 0x01, 0x0b, | ||
1334 | 0x10, 0x0d, 0x01, 0x10, | ||
1335 | 0x10, 0x0c, 0x01, 0x1b, | ||
1336 | 0x04, 0x06, 0x01, 0x03, | ||
1337 | 0x04, 0x05, 0x01, 0x21, | ||
1338 | 0x04, 0x04, 0x01, 0x00, | ||
1339 | 0, 0, 0 | ||
1340 | }; | ||
1341 | |||
1342 | /* nw800 - hv7121b? (seems pas106) - Divio Chicony TwinkleCam */ | ||
1343 | static const u8 twinkle_start[] = { | ||
1344 | 0x04, 0x06, 0x01, 0x44, | ||
1345 | 0x04, 0x06, 0x01, 0x00, | ||
1346 | 0x00, 0x00, 0x40, 0x14, 0x83, 0x00, 0xba, 0x01, 0x10, 0x00, 0x4f, | ||
1347 | 0xef, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0x19, | ||
1348 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
1349 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x06, 0x00, 0xfc, | ||
1350 | 0x01, 0x3e, 0x00, 0x86, 0x00, 0x3e, 0x00, 0x86, | ||
1351 | 0x00, 0x3e, 0x00, 0x86, 0x00, 0x01, 0x00, 0x01, | ||
1352 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x56, 0x00, 0x9e, | ||
1353 | 0x00, 0x56, 0x00, 0x9e, 0x00, 0x01, 0x00, 0x01, | ||
1354 | 0x00, 0x40, 0x40, 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
1355 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1356 | 0x00, 0x6e, 0x00, 0xb6, 0x00, 0x6e, 0x00, 0x78, | ||
1357 | 0x04, 0x6e, 0x00, 0xb6, 0x00, 0x01, 0x00, 0x01, | ||
1358 | 0x00, 0xca, 0x03, 0x46, 0x04, 0xca, 0x03, 0x46, | ||
1359 | 0x04, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
1360 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, | ||
1361 | 0x00, 0x3e, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x2e, | ||
1362 | 0x00, 0x80, 0x1f, 0xb8, 0x48, 0x0f, 0x04, 0x88, 0x14, 0x68, 0x00, | ||
1363 | 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x03, | ||
1364 | 0x00, 0x24, 0x01, 0x01, 0x00, 0x16, 0x00, 0x04, | ||
1365 | 0x00, 0x4b, 0x00, 0x76, 0x00, 0x86, 0x00, | ||
1366 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1367 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1368 | 0x40, 0x20, | ||
1369 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
1370 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0x61, 0x00, | ||
1371 | 0x05, 0x00, 0x06, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1372 | 0x06, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1373 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1374 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1375 | 0x00, 0x00, 0x00, | ||
1376 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1377 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1378 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1379 | 0x10, 0x00, 0x40, 0x80, 0x02, 0x20, 0x00, 0x11, 0x00, 0x00, 0x00, | ||
1380 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x08, | ||
1381 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1382 | 0x00, 0x49, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1383 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
1384 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1385 | 0x03, 0x00, 0x00, 0x10, 0x00, 0x20, 0x10, 0x06, | ||
1386 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x00, 0x80, | ||
1387 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
1388 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
1389 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1390 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1391 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1392 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1393 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1394 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1395 | 0x10, 0x80, 0x1d, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
1396 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x62, | ||
1397 | 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, 0x20, | ||
1398 | 0x01, 0x60, 0x01, 0x00, 0x00, | ||
1399 | |||
1400 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
1401 | 0x04, 0x04, 0x01, 0x10, | ||
1402 | 0x04, 0x04, 0x01, 0x00, | ||
1403 | 0x04, 0x05, 0x01, 0x61, | ||
1404 | 0x04, 0x04, 0x01, 0x01, | ||
1405 | I2C0, 0x40, 0x0c, 0x02, 0x0c, 0x12, 0x07, 0x00, 0x00, 0x00, 0x00, | ||
1406 | 0x00, 0x00, 0x00, 0x0a, | ||
1407 | I2C0, 0x40, 0x02, 0x11, 0x06, | ||
1408 | I2C0, 0x40, 0x02, 0x14, 0x00, | ||
1409 | I2C0, 0x40, 0x02, 0x13, 0x01, /* i2c end */ | ||
1410 | I2C0, 0x40, 0x02, 0x07, 0x01, | ||
1411 | 0x02, 0x00, 0x11, 0x48, 0x58, 0x9e, 0x48, 0x58, 0x00, 0x00, 0x00, | ||
1412 | 0x00, 0x84, 0x36, 0x05, 0x01, 0xf2, 0x86, 0x65, | ||
1413 | 0x40, | ||
1414 | I2C0, 0x40, 0x02, 0x02, 0x0c, | ||
1415 | I2C0, 0x40, 0x02, 0x13, 0x01, | ||
1416 | 0x10, 0x00, 0x01, 0x01, | ||
1417 | 0x10, 0x8f, 0x0c, 0x62, 0x01, 0x24, 0x01, 0x62, 0x01, 0x24, 0x01, | ||
1418 | 0x20, 0x01, 0x60, 0x01, | ||
1419 | I2C0, 0x40, 0x02, 0x05, 0x0f, | ||
1420 | I2C0, 0x40, 0x02, 0x13, 0x01, | ||
1421 | I2C0, 0x40, 0x08, 0x08, 0x04, 0x0b, 0x01, 0x01, 0x02, 0x00, 0x17, | ||
1422 | I2C0, 0x40, 0x03, 0x12, 0x00, 0x01, | ||
1423 | 0x10, 0x11, 0x08, 0x00, 0x00, 0x5f, 0x01, 0x00, 0x00, 0x1f, 0x01, | ||
1424 | I2C0, 0x40, 0x02, 0x12, 0x00, | ||
1425 | I2C0, 0x40, 0x02, 0x0e, 0x00, | ||
1426 | I2C0, 0x40, 0x02, 0x11, 0x06, | ||
1427 | 0x10, 0x41, 0x11, 0x00, 0x17, 0x3f, 0x69, 0x7b, 0x8c, 0x9a, 0xa7, | ||
1428 | 0xb3, 0xbf, 0xc9, 0xd3, 0xdd, 0xe6, 0xef, 0xf7, | ||
1429 | 0xf9, | ||
1430 | 0x10, 0x03, 0x01, 0x00, | ||
1431 | 0x10, 0x0f, 0x02, 0x0c, 0x0c, | ||
1432 | 0x10, 0x03, 0x01, 0x06, | ||
1433 | 0x10, 0x41, 0x11, 0x00, 0x17, 0x3f, 0x69, 0x7b, 0x8c, 0x9a, 0xa7, | ||
1434 | 0xb3, 0xbf, 0xc9, 0xd3, 0xdd, 0xe6, 0xef, 0xf7, | ||
1435 | 0xf9, | ||
1436 | 0x10, 0x0b, 0x01, 0x19, | ||
1437 | 0x10, 0x0d, 0x01, 0x10, | ||
1438 | 0x10, 0x0c, 0x01, 0x0d, | ||
1439 | 0x04, 0x06, 0x01, 0x03, | ||
1440 | 0x04, 0x05, 0x01, 0x61, | ||
1441 | 0x04, 0x04, 0x01, 0x41, | ||
1442 | 0, 0, 0 | ||
1443 | }; | ||
1444 | |||
1445 | /* nw802 dvc-v6 */ | ||
1446 | static const u8 dvcv6_start[] = { | ||
1447 | 0x04, 0x06, 0x01, 0x06, | ||
1448 | 0x00, 0x00, 0x40, 0x54, 0x96, 0x98, 0xf9, 0x02, 0x18, 0x00, 0x4c, | ||
1449 | 0x0f, 0x1f, 0x00, 0x0d, 0x02, 0x01, 0x00, 0x19, | ||
1450 | 0x00, 0x01, 0x00, 0x19, 0x00, 0x01, 0x00, 0x19, | ||
1451 | 0x00, 0x0b, 0x00, 0x1b, 0x00, 0xc8, 0x00, 0xf4, | ||
1452 | 0x05, 0xb4, 0x00, 0xcc, 0x00, 0x01, 0x00, 0x01, | ||
1453 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1454 | 0x00, 0xa2, 0x00, 0xc6, 0x00, 0x60, 0x00, 0xc6, | ||
1455 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1456 | 0x00, 0x40, 0x40, 0x00, 0xae, 0x00, 0xd2, 0x00, 0xae, 0x00, 0xd2, | ||
1457 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1458 | 0x00, 0xa8, 0x00, 0xc0, 0x00, 0x66, 0x00, 0xc0, | ||
1459 | 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, | ||
1460 | 0x00, 0x0a, 0x00, 0x54, 0x00, 0x0a, 0x00, 0x54, | ||
1461 | 0x00, 0x10, 0x00, 0x36, 0x00, 0xd2, 0x00, 0xee, | ||
1462 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, | ||
1463 | 0x00, 0x5d, 0x00, 0xc7, 0x00, 0x7e, 0x00, 0x30, | ||
1464 | 0x00, 0x80, 0x1f, 0x98, 0x43, 0x3f, 0x0d, 0x88, 0x20, 0x80, 0x3f, | ||
1465 | 0x47, 0xaf, 0x00, 0x00, 0xa8, 0x08, 0x00, 0x11, | ||
1466 | 0x00, 0x0c, 0x02, 0x0c, 0x00, 0x1c, 0x00, 0x94, | ||
1467 | 0x00, 0x10, 0x06, 0x24, 0x00, 0x4a, 0x00, | ||
1468 | 0x02, 0x00, 0x12, 0x78, 0xa0, 0x9e, 0x78, 0xa0, 0x00, 0x00, 0x00, | ||
1469 | 0x00, 0xf0, 0x18, 0x0b, 0x06, 0x62, 0x82, 0xa0, | ||
1470 | 0x40, 0x20, | ||
1471 | 0x03, 0x00, 0x03, 0x03, 0x00, 0x00, | ||
1472 | 0x04, 0x00, 0x07, 0x01, 0x10, 0x00, 0x00, 0x00, 0xff, 0x00, | ||
1473 | 0x06, 0x00, 0x02, 0x09, 0x99, | ||
1474 | 0x08, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1475 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1476 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1477 | 0x10, 0x00, 0x40, 0xa0, 0x02, 0x80, 0x00, 0x12, 0x00, 0x00, 0x00, | ||
1478 | 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x08, 0x0a, | ||
1479 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
1480 | 0x00, 0x49, 0x13, 0x00, 0x00, 0xe0, 0x00, 0x0c, | ||
1481 | 0x00, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, | ||
1482 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, | ||
1483 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x06, | ||
1484 | 0xf7, 0xee, 0x1c, 0x1c, 0xe9, 0xfc, 0x10, 0x80, | ||
1485 | 0x10, 0x40, 0x40, 0x80, 0x00, 0x05, 0x35, 0x5e, 0x78, 0x8b, 0x99, | ||
1486 | 0xa4, 0xae, 0xb5, 0xbc, 0xc1, 0xc6, 0xc9, 0xcc, | ||
1487 | 0xcf, 0xd0, 0x00, 0x11, 0x22, 0x32, 0x43, 0x54, | ||
1488 | 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, 0xd2, | ||
1489 | 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, 0x43, | ||
1490 | 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, 0xc3, | ||
1491 | 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x11, 0x22, 0x32, | ||
1492 | 0x43, 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb3, | ||
1493 | 0x10, 0x80, 0x1b, 0xc3, 0xd2, 0xe2, 0xf1, 0xff, 0x00, 0x00, 0x00, | ||
1494 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x05, 0x82, | ||
1495 | 0x02, 0xe4, 0x01, 0x40, 0x01, 0xf0, 0x00, 0x40, | ||
1496 | 0x01, 0xf0, 0x00, | ||
1497 | 0x00, 0x03, 0x02, 0x94, 0x03, | ||
1498 | 0x00, 0x1d, 0x04, 0x0a, 0x01, 0x28, 0x07, | ||
1499 | 0x00, 0x7b, 0x02, 0xe0, 0x00, | ||
1500 | 0x10, 0x8d, 0x01, 0x00, | ||
1501 | 0x00, 0x09, 0x04, 0x1e, 0x00, 0x0c, 0x02, | ||
1502 | 0x00, 0x91, 0x02, 0x0b, 0x02, | ||
1503 | 0x10, 0x00, 0x01, 0xaf, | ||
1504 | 0x02, 0x00, 0x11, 0x3c, 0x50, 0x8f, 0x3c, 0x50, 0x00, 0x00, 0x00, | ||
1505 | 0x00, 0x78, 0x3f, 0x3f, 0x06, 0xf2, 0x8f, 0xf0, | ||
1506 | 0x40, | ||
1507 | 0x10, 0x1a, 0x01, 0x02, | ||
1508 | 0x10, 0x00, 0x01, 0xaf, | ||
1509 | 0x10, 0x85, 0x08, 0x00, 0x00, 0x3f, 0x01, 0x00, 0x00, 0xef, 0x00, | ||
1510 | 0x10, 0x1b, 0x02, 0x07, 0x01, | ||
1511 | 0x10, 0x11, 0x08, 0x61, 0x00, 0xe0, 0x00, 0x49, 0x00, 0xa8, 0x00, | ||
1512 | 0x10, 0x1f, 0x06, 0x01, 0x20, 0x02, 0xe8, 0x03, 0x00, | ||
1513 | 0x10, 0x1d, 0x02, 0x40, 0x06, | ||
1514 | 0x10, 0x0e, 0x01, 0x08, | ||
1515 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x54, 0x6f, 0x82, 0x91, 0x9f, 0xaa, | ||
1516 | 0xb4, 0xbd, 0xc5, 0xcd, 0xd5, 0xdb, 0xdc, 0xdc, | ||
1517 | 0xdc, | ||
1518 | 0x10, 0x03, 0x01, 0x00, | ||
1519 | 0x10, 0x0f, 0x02, 0x12, 0x12, | ||
1520 | 0x10, 0x03, 0x01, 0x11, | ||
1521 | 0x10, 0x41, 0x11, 0x00, 0x0f, 0x54, 0x6f, 0x82, 0x91, 0x9f, 0xaa, | ||
1522 | 0xb4, 0xbd, 0xc5, 0xcd, 0xd5, 0xdb, 0xdc, 0xdc, | ||
1523 | 0xdc, | ||
1524 | 0x10, 0x0b, 0x01, 0x16, | ||
1525 | 0x10, 0x0d, 0x01, 0x10, | ||
1526 | 0x10, 0x0c, 0x01, 0x1a, | ||
1527 | 0x04, 0x06, 0x01, 0x03, | ||
1528 | 0x04, 0x04, 0x01, 0x00, | ||
1529 | }; | ||
1530 | |||
1531 | static const u8 *webcam_start[] = { | ||
1532 | [Generic800] = nw800_start, | ||
1533 | [SpaceCam] = spacecam_start, | ||
1534 | [SpaceCam2] = spacecam2_start, | ||
1535 | [Cvideopro] = cvideopro_start, | ||
1536 | [Dlink350c] = dlink_start, | ||
1537 | [DS3303u] = ds3303_start, | ||
1538 | [Kr651us] = kr651_start_1, | ||
1539 | [Kritter] = kritter_start, | ||
1540 | [Mustek300] = mustek_start, | ||
1541 | [Proscope] = proscope_start_1, | ||
1542 | [Twinkle] = twinkle_start, | ||
1543 | [DvcV6] = dvcv6_start, | ||
1544 | [P35u] = nw801_start_1, | ||
1545 | [Generic802] = nw802_start, | ||
1546 | }; | ||
1547 | |||
1548 | /* -- write a register -- */ | ||
1549 | static void reg_w(struct gspca_dev *gspca_dev, | ||
1550 | u16 index, | ||
1551 | const u8 *data, | ||
1552 | int len) | ||
1553 | { | ||
1554 | struct usb_device *dev = gspca_dev->dev; | ||
1555 | int ret; | ||
1556 | |||
1557 | if (gspca_dev->usb_err < 0) | ||
1558 | return; | ||
1559 | if (len == 1) | ||
1560 | PDEBUG(D_USBO, "SET 00 0000 %04x %02x", index, *data); | ||
1561 | else | ||
1562 | PDEBUG(D_USBO, "SET 00 0000 %04x %02x %02x ...", | ||
1563 | index, *data, data[1]); | ||
1564 | memcpy(gspca_dev->usb_buf, data, len); | ||
1565 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1566 | 0x00, | ||
1567 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
1568 | 0x00, /* value */ | ||
1569 | index, | ||
1570 | gspca_dev->usb_buf, | ||
1571 | len, | ||
1572 | 500); | ||
1573 | if (ret < 0) { | ||
1574 | err("reg_w err %d", ret); | ||
1575 | gspca_dev->usb_err = ret; | ||
1576 | } | ||
1577 | } | ||
1578 | |||
1579 | /* -- read registers in usb_buf -- */ | ||
1580 | static void reg_r(struct gspca_dev *gspca_dev, | ||
1581 | u16 index, | ||
1582 | int len) | ||
1583 | { | ||
1584 | struct usb_device *dev = gspca_dev->dev; | ||
1585 | int ret; | ||
1586 | |||
1587 | if (gspca_dev->usb_err < 0) | ||
1588 | return; | ||
1589 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
1590 | 0x00, | ||
1591 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
1592 | 0x00, index, | ||
1593 | gspca_dev->usb_buf, len, 500); | ||
1594 | if (ret < 0) { | ||
1595 | err("reg_r err %d", ret); | ||
1596 | gspca_dev->usb_err = ret; | ||
1597 | return; | ||
1598 | } | ||
1599 | if (len == 1) | ||
1600 | PDEBUG(D_USBI, "GET 00 0000 %04x %02x", | ||
1601 | index, gspca_dev->usb_buf[0]); | ||
1602 | else | ||
1603 | PDEBUG(D_USBI, "GET 00 0000 %04x %02x %02x ..", | ||
1604 | index, gspca_dev->usb_buf[0], | ||
1605 | gspca_dev->usb_buf[1]); | ||
1606 | } | ||
1607 | |||
1608 | static void i2c_w(struct gspca_dev *gspca_dev, | ||
1609 | u8 i2c_addr, | ||
1610 | const u8 *data, | ||
1611 | int len) | ||
1612 | { | ||
1613 | u8 val[2]; | ||
1614 | int i; | ||
1615 | |||
1616 | reg_w(gspca_dev, 0x0600, data + 1, len - 1); | ||
1617 | reg_w(gspca_dev, 0x0600, data, len); | ||
1618 | val[0] = len; | ||
1619 | val[1] = i2c_addr; | ||
1620 | reg_w(gspca_dev, 0x0502, val, 2); | ||
1621 | val[0] = 0x01; | ||
1622 | reg_w(gspca_dev, 0x0501, val, 1); | ||
1623 | for (i = 5; --i >= 0; ) { | ||
1624 | msleep(4); | ||
1625 | reg_r(gspca_dev, 0x0505, 1); | ||
1626 | if (gspca_dev->usb_err < 0) | ||
1627 | return; | ||
1628 | if (gspca_dev->usb_buf[0] == 0) | ||
1629 | return; | ||
1630 | } | ||
1631 | gspca_dev->usb_err = -ETIME; | ||
1632 | } | ||
1633 | |||
1634 | static void reg_w_buf(struct gspca_dev *gspca_dev, | ||
1635 | const u8 *cmd) | ||
1636 | { | ||
1637 | u16 reg; | ||
1638 | int len; | ||
1639 | |||
1640 | for (;;) { | ||
1641 | reg = *cmd++ << 8; | ||
1642 | reg += *cmd++; | ||
1643 | len = *cmd++; | ||
1644 | if (len == 0) | ||
1645 | break; | ||
1646 | if (cmd[-3] != I2C0) | ||
1647 | reg_w(gspca_dev, reg, cmd, len); | ||
1648 | else | ||
1649 | i2c_w(gspca_dev, reg, cmd, len); | ||
1650 | cmd += len; | ||
1651 | } | ||
1652 | } | ||
1653 | |||
1654 | static int swap_bits(int v) | ||
1655 | { | ||
1656 | int r, i; | ||
1657 | |||
1658 | r = 0; | ||
1659 | for (i = 0; i < 8; i++) { | ||
1660 | r <<= 1; | ||
1661 | if (v & 1) | ||
1662 | r++; | ||
1663 | v >>= 1; | ||
1664 | } | ||
1665 | return r; | ||
1666 | } | ||
1667 | |||
1668 | static void setgain(struct gspca_dev *gspca_dev) | ||
1669 | { | ||
1670 | struct sd *sd = (struct sd *) gspca_dev; | ||
1671 | u8 val, v[2]; | ||
1672 | |||
1673 | val = sd->ctrls[GAIN].val; | ||
1674 | switch (sd->webcam) { | ||
1675 | case P35u: | ||
1676 | /* Note the control goes from 0-255 not 0-127, but anything | ||
1677 | above 127 just means amplifying noise */ | ||
1678 | val >>= 1; /* 0 - 255 -> 0 - 127 */ | ||
1679 | reg_w(gspca_dev, 0x1026, &val, 1); | ||
1680 | break; | ||
1681 | case Kr651us: | ||
1682 | /* 0 - 253 */ | ||
1683 | val = swap_bits(val); | ||
1684 | v[0] = val << 3; | ||
1685 | v[1] = val >> 5; | ||
1686 | reg_w(gspca_dev, 0x101d, v, 2); /* SIF reg0/1 (AGC) */ | ||
1687 | break; | ||
1688 | } | ||
1689 | } | ||
1690 | |||
1691 | static void setexposure(struct gspca_dev *gspca_dev) | ||
1692 | { | ||
1693 | struct sd *sd = (struct sd *) gspca_dev; | ||
1694 | s16 val; | ||
1695 | u8 v[2]; | ||
1696 | |||
1697 | val = sd->ctrls[EXPOSURE].val; | ||
1698 | switch (sd->webcam) { | ||
1699 | case P35u: | ||
1700 | v[0] = ((9 - val) << 3) | 0x01; | ||
1701 | reg_w(gspca_dev, 0x1019, v, 1); | ||
1702 | break; | ||
1703 | case Cvideopro: | ||
1704 | case DvcV6: | ||
1705 | case Kritter: | ||
1706 | case Kr651us: | ||
1707 | v[0] = val; | ||
1708 | v[1] = val >> 8; | ||
1709 | reg_w(gspca_dev, 0x101b, v, 2); | ||
1710 | break; | ||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | static void setautogain(struct gspca_dev *gspca_dev) | ||
1715 | { | ||
1716 | struct sd *sd = (struct sd *) gspca_dev; | ||
1717 | int w, h; | ||
1718 | |||
1719 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN)) | ||
1720 | return; | ||
1721 | if (!sd->ctrls[AUTOGAIN].val) { | ||
1722 | sd->ag_cnt = -1; | ||
1723 | return; | ||
1724 | } | ||
1725 | sd->ag_cnt = AG_CNT_START; | ||
1726 | |||
1727 | reg_r(gspca_dev, 0x1004, 1); | ||
1728 | if (gspca_dev->usb_buf[0] & 0x04) { /* if AE_FULL_FRM */ | ||
1729 | sd->ae_res = gspca_dev->width * gspca_dev->height; | ||
1730 | } else { /* get the AE window size */ | ||
1731 | reg_r(gspca_dev, 0x1011, 8); | ||
1732 | w = (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0] | ||
1733 | - (gspca_dev->usb_buf[3] << 8) - gspca_dev->usb_buf[2]; | ||
1734 | h = (gspca_dev->usb_buf[5] << 8) + gspca_dev->usb_buf[4] | ||
1735 | - (gspca_dev->usb_buf[7] << 8) - gspca_dev->usb_buf[6]; | ||
1736 | sd->ae_res = h * w; | ||
1737 | if (sd->ae_res == 0) | ||
1738 | sd->ae_res = gspca_dev->width * gspca_dev->height; | ||
1739 | } | ||
1740 | } | ||
1741 | |||
1742 | static int nw802_test_reg(struct gspca_dev *gspca_dev, | ||
1743 | u16 index, | ||
1744 | u8 value) | ||
1745 | { | ||
1746 | /* write the value */ | ||
1747 | reg_w(gspca_dev, index, &value, 1); | ||
1748 | |||
1749 | /* read it */ | ||
1750 | reg_r(gspca_dev, index, 1); | ||
1751 | |||
1752 | return gspca_dev->usb_buf[0] == value; | ||
1753 | } | ||
1754 | |||
1755 | /* this function is called at probe time */ | ||
1756 | static int sd_config(struct gspca_dev *gspca_dev, | ||
1757 | const struct usb_device_id *id) | ||
1758 | { | ||
1759 | struct sd *sd = (struct sd *) gspca_dev; | ||
1760 | |||
1761 | if ((unsigned) webcam >= NWEBCAMS) | ||
1762 | webcam = 0; | ||
1763 | sd->webcam = webcam; | ||
1764 | gspca_dev->cam.reverse_alts = 1; | ||
1765 | gspca_dev->cam.ctrls = sd->ctrls; | ||
1766 | sd->ag_cnt = -1; | ||
1767 | |||
1768 | /* | ||
1769 | * Autodetect sequence inspired from some log. | ||
1770 | * We try to detect what registers exist or not. | ||
1771 | * If 0x0500 does not exist => NW802 | ||
1772 | * If it does, test 0x109b. If it doesn't exist, | ||
1773 | * then it's a NW801. Else, a NW800 | ||
1774 | * If a et31x110 (nw800 and 06a5:d800) | ||
1775 | * get the sensor ID | ||
1776 | */ | ||
1777 | if (!nw802_test_reg(gspca_dev, 0x0500, 0x55)) { | ||
1778 | sd->bridge = BRIDGE_NW802; | ||
1779 | if (sd->webcam == Generic800) | ||
1780 | sd->webcam = Generic802; | ||
1781 | } else if (!nw802_test_reg(gspca_dev, 0x109b, 0xaa)) { | ||
1782 | sd->bridge = BRIDGE_NW801; | ||
1783 | if (sd->webcam == Generic800) | ||
1784 | sd->webcam = P35u; | ||
1785 | } else if (id->idVendor == 0x06a5 && id->idProduct == 0xd800) { | ||
1786 | reg_r(gspca_dev, 0x0403, 1); /* GPIO */ | ||
1787 | PDEBUG(D_PROBE, "et31x110 sensor type %02x", | ||
1788 | gspca_dev->usb_buf[0]); | ||
1789 | switch (gspca_dev->usb_buf[0] >> 1) { | ||
1790 | case 0x00: /* ?? */ | ||
1791 | if (sd->webcam == Generic800) | ||
1792 | sd->webcam = SpaceCam; | ||
1793 | break; | ||
1794 | case 0x01: /* Hynix? */ | ||
1795 | if (sd->webcam == Generic800) | ||
1796 | sd->webcam = Twinkle; | ||
1797 | break; | ||
1798 | case 0x0a: /* Pixart */ | ||
1799 | if (sd->webcam == Generic800) | ||
1800 | sd->webcam = SpaceCam2; | ||
1801 | break; | ||
1802 | } | ||
1803 | } | ||
1804 | if (webcam_chip[sd->webcam] != sd->bridge) { | ||
1805 | err("Bad webcam type %d for NW80%d", sd->webcam, sd->bridge); | ||
1806 | gspca_dev->usb_err = -ENODEV; | ||
1807 | return gspca_dev->usb_err; | ||
1808 | } | ||
1809 | PDEBUG(D_PROBE, "Bridge nw80%d - type: %d", sd->bridge, sd->webcam); | ||
1810 | |||
1811 | if (sd->bridge == BRIDGE_NW800) { | ||
1812 | switch (sd->webcam) { | ||
1813 | case DS3303u: | ||
1814 | gspca_dev->cam.cam_mode = cif_mode; /* qvga */ | ||
1815 | break; | ||
1816 | default: | ||
1817 | gspca_dev->cam.cam_mode = &cif_mode[1]; /* cif */ | ||
1818 | break; | ||
1819 | } | ||
1820 | gspca_dev->cam.nmodes = 1; | ||
1821 | } else { | ||
1822 | gspca_dev->cam.cam_mode = vga_mode; | ||
1823 | switch (sd->webcam) { | ||
1824 | case Kr651us: | ||
1825 | case Proscope: | ||
1826 | case P35u: | ||
1827 | gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); | ||
1828 | break; | ||
1829 | default: | ||
1830 | gspca_dev->cam.nmodes = 1; /* qvga only */ | ||
1831 | break; | ||
1832 | } | ||
1833 | } | ||
1834 | switch (sd->webcam) { | ||
1835 | case P35u: | ||
1836 | /* sd->ctrls[EXPOSURE].max = 9; | ||
1837 | * sd->ctrls[EXPOSURE].def = 9; */ | ||
1838 | /* coarse expo auto gain function gain minimum, to avoid | ||
1839 | * a large settings jump the first auto adjustment */ | ||
1840 | sd->ctrls[GAIN].def = 255 / 5 * 2; | ||
1841 | break; | ||
1842 | case Cvideopro: | ||
1843 | case DvcV6: | ||
1844 | case Kritter: | ||
1845 | gspca_dev->ctrl_dis = (1 << GAIN) | (1 << AUTOGAIN); | ||
1846 | /* fall thru */ | ||
1847 | case Kr651us: | ||
1848 | sd->ctrls[EXPOSURE].max = 315; | ||
1849 | sd->ctrls[EXPOSURE].def = 150; | ||
1850 | break; | ||
1851 | default: | ||
1852 | gspca_dev->ctrl_dis = (1 << GAIN) | (1 << EXPOSURE) | ||
1853 | | (1 << AUTOGAIN); | ||
1854 | break; | ||
1855 | } | ||
1856 | |||
1857 | #if AUTOGAIN_DEF | ||
1858 | if (!(gspca_dev->ctrl_dis & (1 << AUTOGAIN))) | ||
1859 | gspca_dev->ctrl_inac = (1 << GAIN) | (1 << EXPOSURE); | ||
1860 | #endif | ||
1861 | return gspca_dev->usb_err; | ||
1862 | } | ||
1863 | |||
1864 | /* this function is called at probe and resume time */ | ||
1865 | static int sd_init(struct gspca_dev *gspca_dev) | ||
1866 | { | ||
1867 | struct sd *sd = (struct sd *) gspca_dev; | ||
1868 | |||
1869 | switch (sd->bridge) { | ||
1870 | case BRIDGE_NW800: | ||
1871 | switch (sd->webcam) { | ||
1872 | case SpaceCam: | ||
1873 | reg_w_buf(gspca_dev, spacecam_init); | ||
1874 | break; | ||
1875 | default: | ||
1876 | reg_w_buf(gspca_dev, nw800_init); | ||
1877 | break; | ||
1878 | } | ||
1879 | break; | ||
1880 | default: | ||
1881 | switch (sd->webcam) { | ||
1882 | case Mustek300: | ||
1883 | case P35u: | ||
1884 | case Proscope: | ||
1885 | reg_w_buf(gspca_dev, proscope_init); | ||
1886 | break; | ||
1887 | } | ||
1888 | break; | ||
1889 | } | ||
1890 | return gspca_dev->usb_err; | ||
1891 | } | ||
1892 | |||
1893 | /* -- start the camera -- */ | ||
1894 | static int sd_start(struct gspca_dev *gspca_dev) | ||
1895 | { | ||
1896 | struct sd *sd = (struct sd *) gspca_dev; | ||
1897 | const u8 *cmd; | ||
1898 | |||
1899 | cmd = webcam_start[sd->webcam]; | ||
1900 | reg_w_buf(gspca_dev, cmd); | ||
1901 | switch (sd->webcam) { | ||
1902 | case P35u: | ||
1903 | if (gspca_dev->width == 320) | ||
1904 | reg_w_buf(gspca_dev, nw801_start_qvga); | ||
1905 | else | ||
1906 | reg_w_buf(gspca_dev, nw801_start_vga); | ||
1907 | reg_w_buf(gspca_dev, nw801_start_2); | ||
1908 | break; | ||
1909 | case Kr651us: | ||
1910 | if (gspca_dev->width == 320) | ||
1911 | reg_w_buf(gspca_dev, kr651_start_qvga); | ||
1912 | else | ||
1913 | reg_w_buf(gspca_dev, kr651_start_vga); | ||
1914 | reg_w_buf(gspca_dev, kr651_start_2); | ||
1915 | break; | ||
1916 | case Proscope: | ||
1917 | if (gspca_dev->width == 320) | ||
1918 | reg_w_buf(gspca_dev, proscope_start_qvga); | ||
1919 | else | ||
1920 | reg_w_buf(gspca_dev, proscope_start_vga); | ||
1921 | reg_w_buf(gspca_dev, proscope_start_2); | ||
1922 | break; | ||
1923 | } | ||
1924 | |||
1925 | setgain(gspca_dev); | ||
1926 | setexposure(gspca_dev); | ||
1927 | setautogain(gspca_dev); | ||
1928 | sd->exp_too_high_cnt = 0; | ||
1929 | sd->exp_too_low_cnt = 0; | ||
1930 | return gspca_dev->usb_err; | ||
1931 | } | ||
1932 | |||
1933 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
1934 | { | ||
1935 | struct sd *sd = (struct sd *) gspca_dev; | ||
1936 | u8 value; | ||
1937 | |||
1938 | /* 'go' off */ | ||
1939 | if (sd->bridge != BRIDGE_NW801) { | ||
1940 | value = 0x02; | ||
1941 | reg_w(gspca_dev, 0x0406, &value, 1); | ||
1942 | } | ||
1943 | |||
1944 | /* LED off */ | ||
1945 | switch (sd->webcam) { | ||
1946 | case Cvideopro: | ||
1947 | case Kr651us: | ||
1948 | case DvcV6: | ||
1949 | case Kritter: | ||
1950 | value = 0xff; | ||
1951 | break; | ||
1952 | case Dlink350c: | ||
1953 | value = 0x21; | ||
1954 | break; | ||
1955 | case SpaceCam: | ||
1956 | case SpaceCam2: | ||
1957 | case Proscope: | ||
1958 | case Twinkle: | ||
1959 | value = 0x01; | ||
1960 | break; | ||
1961 | default: | ||
1962 | return; | ||
1963 | } | ||
1964 | reg_w(gspca_dev, 0x0404, &value, 1); | ||
1965 | } | ||
1966 | |||
1967 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
1968 | u8 *data, /* isoc packet */ | ||
1969 | int len) /* iso packet length */ | ||
1970 | { | ||
1971 | /* | ||
1972 | * frame header = '00 00 hh ww ss xx ff ff' | ||
1973 | * with: | ||
1974 | * - 'hh': height / 4 | ||
1975 | * - 'ww': width / 4 | ||
1976 | * - 'ss': frame sequence number c0..dd | ||
1977 | */ | ||
1978 | if (data[0] == 0x00 && data[1] == 0x00 | ||
1979 | && data[6] == 0xff && data[7] == 0xff) { | ||
1980 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); | ||
1981 | gspca_frame_add(gspca_dev, FIRST_PACKET, data + 8, len - 8); | ||
1982 | } else { | ||
1983 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | ||
1984 | } | ||
1985 | } | ||
1986 | |||
1987 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | ||
1988 | { | ||
1989 | struct sd *sd = (struct sd *) gspca_dev; | ||
1990 | |||
1991 | sd->ctrls[AUTOGAIN].val = val; | ||
1992 | if (val) | ||
1993 | gspca_dev->ctrl_inac = (1 << GAIN) | (1 << EXPOSURE); | ||
1994 | else | ||
1995 | gspca_dev->ctrl_inac = 0; | ||
1996 | if (gspca_dev->streaming) | ||
1997 | setautogain(gspca_dev); | ||
1998 | return gspca_dev->usb_err; | ||
1999 | } | ||
2000 | |||
2001 | #include "autogain_functions.h" | ||
2002 | |||
2003 | static void do_autogain(struct gspca_dev *gspca_dev) | ||
2004 | { | ||
2005 | struct sd *sd = (struct sd *) gspca_dev; | ||
2006 | int luma; | ||
2007 | |||
2008 | if (sd->ag_cnt < 0) | ||
2009 | return; | ||
2010 | if (--sd->ag_cnt >= 0) | ||
2011 | return; | ||
2012 | sd->ag_cnt = AG_CNT_START; | ||
2013 | |||
2014 | /* get the average luma */ | ||
2015 | reg_r(gspca_dev, sd->bridge == BRIDGE_NW801 ? 0x080d : 0x080c, 4); | ||
2016 | luma = (gspca_dev->usb_buf[3] << 24) + (gspca_dev->usb_buf[2] << 16) | ||
2017 | + (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; | ||
2018 | luma /= sd->ae_res; | ||
2019 | |||
2020 | switch (sd->webcam) { | ||
2021 | case P35u: | ||
2022 | coarse_grained_expo_autogain(gspca_dev, luma, 100, 5); | ||
2023 | break; | ||
2024 | default: | ||
2025 | auto_gain_n_exposure(gspca_dev, luma, 100, 5, 230, 0); | ||
2026 | break; | ||
2027 | } | ||
2028 | } | ||
2029 | |||
2030 | /* V4L2 controls supported by the driver */ | ||
2031 | static const struct ctrl sd_ctrls[NCTRLS] = { | ||
2032 | [GAIN] = { | ||
2033 | { | ||
2034 | .id = V4L2_CID_GAIN, | ||
2035 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
2036 | .name = "Gain", | ||
2037 | .minimum = 0, | ||
2038 | .maximum = 253, | ||
2039 | .step = 1, | ||
2040 | .default_value = 128 | ||
2041 | }, | ||
2042 | .set_control = setgain | ||
2043 | }, | ||
2044 | [EXPOSURE] = { | ||
2045 | { | ||
2046 | .id = V4L2_CID_EXPOSURE, | ||
2047 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
2048 | .name = "Exposure", | ||
2049 | .minimum = 0, | ||
2050 | .maximum = 9, | ||
2051 | .step = 1, | ||
2052 | .default_value = 9 | ||
2053 | }, | ||
2054 | .set_control = setexposure | ||
2055 | }, | ||
2056 | [AUTOGAIN] = { | ||
2057 | { | ||
2058 | .id = V4L2_CID_AUTOGAIN, | ||
2059 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
2060 | .name = "Auto Gain", | ||
2061 | .minimum = 0, | ||
2062 | .maximum = 1, | ||
2063 | .step = 1, | ||
2064 | .default_value = AUTOGAIN_DEF, | ||
2065 | .flags = V4L2_CTRL_FLAG_UPDATE | ||
2066 | }, | ||
2067 | .set = sd_setautogain | ||
2068 | }, | ||
2069 | }; | ||
2070 | |||
2071 | /* sub-driver description */ | ||
2072 | static const struct sd_desc sd_desc = { | ||
2073 | .name = MODULE_NAME, | ||
2074 | .ctrls = sd_ctrls, | ||
2075 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
2076 | .config = sd_config, | ||
2077 | .init = sd_init, | ||
2078 | .start = sd_start, | ||
2079 | .stopN = sd_stopN, | ||
2080 | .pkt_scan = sd_pkt_scan, | ||
2081 | .dq_callback = do_autogain, | ||
2082 | }; | ||
2083 | |||
2084 | /* -- module initialisation -- */ | ||
2085 | static const struct usb_device_id device_table[] = { | ||
2086 | {USB_DEVICE(0x046d, 0xd001)}, | ||
2087 | {USB_DEVICE(0x0502, 0xd001)}, | ||
2088 | {USB_DEVICE(0x052b, 0xd001)}, | ||
2089 | {USB_DEVICE(0x055f, 0xd001)}, | ||
2090 | {USB_DEVICE(0x06a5, 0x0000)}, | ||
2091 | {USB_DEVICE(0x06a5, 0xd001)}, | ||
2092 | {USB_DEVICE(0x06a5, 0xd800)}, | ||
2093 | {USB_DEVICE(0x06be, 0xd001)}, | ||
2094 | {USB_DEVICE(0x0728, 0xd001)}, | ||
2095 | {} | ||
2096 | }; | ||
2097 | MODULE_DEVICE_TABLE(usb, device_table); | ||
2098 | |||
2099 | /* -- device connect -- */ | ||
2100 | static int sd_probe(struct usb_interface *intf, | ||
2101 | const struct usb_device_id *id) | ||
2102 | { | ||
2103 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | ||
2104 | THIS_MODULE); | ||
2105 | } | ||
2106 | |||
2107 | static struct usb_driver sd_driver = { | ||
2108 | .name = MODULE_NAME, | ||
2109 | .id_table = device_table, | ||
2110 | .probe = sd_probe, | ||
2111 | .disconnect = gspca_disconnect, | ||
2112 | #ifdef CONFIG_PM | ||
2113 | .suspend = gspca_suspend, | ||
2114 | .resume = gspca_resume, | ||
2115 | #endif | ||
2116 | }; | ||
2117 | |||
2118 | /* -- module insert / remove -- */ | ||
2119 | static int __init sd_mod_init(void) | ||
2120 | { | ||
2121 | return usb_register(&sd_driver); | ||
2122 | } | ||
2123 | static void __exit sd_mod_exit(void) | ||
2124 | { | ||
2125 | usb_deregister(&sd_driver); | ||
2126 | } | ||
2127 | |||
2128 | module_init(sd_mod_init); | ||
2129 | module_exit(sd_mod_exit); | ||
2130 | |||
2131 | module_param(webcam, int, 0644); | ||
2132 | MODULE_PARM_DESC(webcam, | ||
2133 | "Webcam type\n" | ||
2134 | "0: generic\n" | ||
2135 | "1: Trust 120 SpaceCam\n" | ||
2136 | "2: other Trust 120 SpaceCam\n" | ||
2137 | "3: Conceptronic Video Pro\n" | ||
2138 | "4: D-link dru-350c\n" | ||
2139 | "5: Plustek Opticam 500U\n" | ||
2140 | "6: Panasonic GP-KR651US\n" | ||
2141 | "7: iRez Kritter\n" | ||
2142 | "8: Mustek Wcam 300 mini\n" | ||
2143 | "9: Scalar USB Microscope M2 (Proscope)\n" | ||
2144 | "10: Divio Chicony TwinkleCam\n" | ||
2145 | "11: DVC-V6\n"); | ||
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 2b2cbdbf03fe..057e287b9152 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /** | 1 | /** |
2 | * OV519 driver | 2 | * OV519 driver |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Jean-Francois Moine (http://moinejf.free.fr) | 4 | * Copyright (C) 2008-2011 Jean-François Moine <moinejf@free.fr> |
5 | * Copyright (C) 2009 Hans de Goede <hdegoede@redhat.com> | 5 | * Copyright (C) 2009 Hans de Goede <hdegoede@redhat.com> |
6 | * | 6 | * |
7 | * This module is adapted from the ov51x-jpeg package, which itself | 7 | * This module is adapted from the ov51x-jpeg package, which itself |
@@ -57,18 +57,34 @@ static int frame_rate; | |||
57 | * are getting "Failed to read sensor ID..." */ | 57 | * are getting "Failed to read sensor ID..." */ |
58 | static int i2c_detect_tries = 10; | 58 | static int i2c_detect_tries = 10; |
59 | 59 | ||
60 | /* controls */ | ||
61 | enum e_ctrl { | ||
62 | BRIGHTNESS, | ||
63 | CONTRAST, | ||
64 | EXPOSURE, | ||
65 | COLORS, | ||
66 | HFLIP, | ||
67 | VFLIP, | ||
68 | AUTOBRIGHT, | ||
69 | AUTOGAIN, | ||
70 | FREQ, | ||
71 | NCTRL /* number of controls */ | ||
72 | }; | ||
73 | |||
60 | /* ov519 device descriptor */ | 74 | /* ov519 device descriptor */ |
61 | struct sd { | 75 | struct sd { |
62 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 76 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
63 | 77 | ||
64 | __u8 packet_nr; | 78 | struct gspca_ctrl ctrls[NCTRL]; |
79 | |||
80 | u8 packet_nr; | ||
65 | 81 | ||
66 | char bridge; | 82 | char bridge; |
67 | #define BRIDGE_OV511 0 | 83 | #define BRIDGE_OV511 0 |
68 | #define BRIDGE_OV511PLUS 1 | 84 | #define BRIDGE_OV511PLUS 1 |
69 | #define BRIDGE_OV518 2 | 85 | #define BRIDGE_OV518 2 |
70 | #define BRIDGE_OV518PLUS 3 | 86 | #define BRIDGE_OV518PLUS 3 |
71 | #define BRIDGE_OV519 4 | 87 | #define BRIDGE_OV519 4 /* = ov530 */ |
72 | #define BRIDGE_OVFX2 5 | 88 | #define BRIDGE_OVFX2 5 |
73 | #define BRIDGE_W9968CF 6 | 89 | #define BRIDGE_W9968CF 6 |
74 | #define BRIDGE_MASK 7 | 90 | #define BRIDGE_MASK 7 |
@@ -80,49 +96,45 @@ struct sd { | |||
80 | char snapshot_needs_reset; | 96 | char snapshot_needs_reset; |
81 | 97 | ||
82 | /* Determined by sensor type */ | 98 | /* Determined by sensor type */ |
83 | __u8 sif; | 99 | u8 sif; |
84 | 100 | ||
85 | __u8 brightness; | 101 | u8 quality; |
86 | __u8 contrast; | ||
87 | __u8 colors; | ||
88 | __u8 hflip; | ||
89 | __u8 vflip; | ||
90 | __u8 autobrightness; | ||
91 | __u8 freq; | ||
92 | __u8 quality; | ||
93 | #define QUALITY_MIN 50 | 102 | #define QUALITY_MIN 50 |
94 | #define QUALITY_MAX 70 | 103 | #define QUALITY_MAX 70 |
95 | #define QUALITY_DEF 50 | 104 | #define QUALITY_DEF 50 |
96 | 105 | ||
97 | __u8 stopped; /* Streaming is temporarily paused */ | 106 | u8 stopped; /* Streaming is temporarily paused */ |
98 | __u8 first_frame; | 107 | u8 first_frame; |
99 | 108 | ||
100 | __u8 frame_rate; /* current Framerate */ | 109 | u8 frame_rate; /* current Framerate */ |
101 | __u8 clockdiv; /* clockdiv override */ | 110 | u8 clockdiv; /* clockdiv override */ |
102 | 111 | ||
103 | char sensor; /* Type of image sensor chip (SEN_*) */ | 112 | s8 sensor; /* Type of image sensor chip (SEN_*) */ |
104 | #define SEN_UNKNOWN 0 | ||
105 | #define SEN_OV2610 1 | ||
106 | #define SEN_OV3610 2 | ||
107 | #define SEN_OV6620 3 | ||
108 | #define SEN_OV6630 4 | ||
109 | #define SEN_OV66308AF 5 | ||
110 | #define SEN_OV7610 6 | ||
111 | #define SEN_OV7620 7 | ||
112 | #define SEN_OV7620AE 8 | ||
113 | #define SEN_OV7640 9 | ||
114 | #define SEN_OV7648 10 | ||
115 | #define SEN_OV7670 11 | ||
116 | #define SEN_OV76BE 12 | ||
117 | #define SEN_OV8610 13 | ||
118 | 113 | ||
119 | u8 sensor_addr; | 114 | u8 sensor_addr; |
120 | int sensor_width; | 115 | u16 sensor_width; |
121 | int sensor_height; | 116 | u16 sensor_height; |
122 | int sensor_reg_cache[256]; | 117 | s16 sensor_reg_cache[256]; |
123 | 118 | ||
124 | u8 jpeg_hdr[JPEG_HDR_SZ]; | 119 | u8 jpeg_hdr[JPEG_HDR_SZ]; |
125 | }; | 120 | }; |
121 | enum sensors { | ||
122 | SEN_OV2610, | ||
123 | SEN_OV2610AE, | ||
124 | SEN_OV3610, | ||
125 | SEN_OV6620, | ||
126 | SEN_OV6630, | ||
127 | SEN_OV66308AF, | ||
128 | SEN_OV7610, | ||
129 | SEN_OV7620, | ||
130 | SEN_OV7620AE, | ||
131 | SEN_OV7640, | ||
132 | SEN_OV7648, | ||
133 | SEN_OV7660, | ||
134 | SEN_OV7670, | ||
135 | SEN_OV76BE, | ||
136 | SEN_OV8610, | ||
137 | }; | ||
126 | 138 | ||
127 | /* Note this is a bit of a hack, but the w9968cf driver needs the code for all | 139 | /* Note this is a bit of a hack, but the w9968cf driver needs the code for all |
128 | the ov sensors which is already present here. When we have the time we | 140 | the ov sensors which is already present here. When we have the time we |
@@ -130,29 +142,18 @@ struct sd { | |||
130 | #include "w996Xcf.c" | 142 | #include "w996Xcf.c" |
131 | 143 | ||
132 | /* V4L2 controls supported by the driver */ | 144 | /* V4L2 controls supported by the driver */ |
133 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
134 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
135 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
136 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
137 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | ||
138 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | ||
139 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | ||
140 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
141 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | ||
142 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
143 | static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
144 | static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
145 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
146 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
147 | static void setbrightness(struct gspca_dev *gspca_dev); | 145 | static void setbrightness(struct gspca_dev *gspca_dev); |
148 | static void setcontrast(struct gspca_dev *gspca_dev); | 146 | static void setcontrast(struct gspca_dev *gspca_dev); |
147 | static void setexposure(struct gspca_dev *gspca_dev); | ||
149 | static void setcolors(struct gspca_dev *gspca_dev); | 148 | static void setcolors(struct gspca_dev *gspca_dev); |
150 | static void setautobrightness(struct sd *sd); | 149 | static void sethvflip(struct gspca_dev *gspca_dev); |
151 | static void setfreq(struct sd *sd); | 150 | static void setautobright(struct gspca_dev *gspca_dev); |
151 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | ||
152 | static void setfreq(struct gspca_dev *gspca_dev); | ||
153 | static void setfreq_i(struct sd *sd); | ||
152 | 154 | ||
153 | static const struct ctrl sd_ctrls[] = { | 155 | static const struct ctrl sd_ctrls[] = { |
154 | #define BRIGHTNESS_IDX 0 | 156 | [BRIGHTNESS] = { |
155 | { | ||
156 | { | 157 | { |
157 | .id = V4L2_CID_BRIGHTNESS, | 158 | .id = V4L2_CID_BRIGHTNESS, |
158 | .type = V4L2_CTRL_TYPE_INTEGER, | 159 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -160,14 +161,11 @@ static const struct ctrl sd_ctrls[] = { | |||
160 | .minimum = 0, | 161 | .minimum = 0, |
161 | .maximum = 255, | 162 | .maximum = 255, |
162 | .step = 1, | 163 | .step = 1, |
163 | #define BRIGHTNESS_DEF 127 | 164 | .default_value = 127, |
164 | .default_value = BRIGHTNESS_DEF, | ||
165 | }, | 165 | }, |
166 | .set = sd_setbrightness, | 166 | .set_control = setbrightness, |
167 | .get = sd_getbrightness, | ||
168 | }, | 167 | }, |
169 | #define CONTRAST_IDX 1 | 168 | [CONTRAST] = { |
170 | { | ||
171 | { | 169 | { |
172 | .id = V4L2_CID_CONTRAST, | 170 | .id = V4L2_CID_CONTRAST, |
173 | .type = V4L2_CTRL_TYPE_INTEGER, | 171 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -175,14 +173,23 @@ static const struct ctrl sd_ctrls[] = { | |||
175 | .minimum = 0, | 173 | .minimum = 0, |
176 | .maximum = 255, | 174 | .maximum = 255, |
177 | .step = 1, | 175 | .step = 1, |
178 | #define CONTRAST_DEF 127 | 176 | .default_value = 127, |
179 | .default_value = CONTRAST_DEF, | 177 | }, |
178 | .set_control = setcontrast, | ||
179 | }, | ||
180 | [EXPOSURE] = { | ||
181 | { | ||
182 | .id = V4L2_CID_EXPOSURE, | ||
183 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
184 | .name = "Exposure", | ||
185 | .minimum = 0, | ||
186 | .maximum = 255, | ||
187 | .step = 1, | ||
188 | .default_value = 127, | ||
180 | }, | 189 | }, |
181 | .set = sd_setcontrast, | 190 | .set_control = setexposure, |
182 | .get = sd_getcontrast, | ||
183 | }, | 191 | }, |
184 | #define COLOR_IDX 2 | 192 | [COLORS] = { |
185 | { | ||
186 | { | 193 | { |
187 | .id = V4L2_CID_SATURATION, | 194 | .id = V4L2_CID_SATURATION, |
188 | .type = V4L2_CTRL_TYPE_INTEGER, | 195 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -190,15 +197,12 @@ static const struct ctrl sd_ctrls[] = { | |||
190 | .minimum = 0, | 197 | .minimum = 0, |
191 | .maximum = 255, | 198 | .maximum = 255, |
192 | .step = 1, | 199 | .step = 1, |
193 | #define COLOR_DEF 127 | 200 | .default_value = 127, |
194 | .default_value = COLOR_DEF, | ||
195 | }, | 201 | }, |
196 | .set = sd_setcolors, | 202 | .set_control = setcolors, |
197 | .get = sd_getcolors, | ||
198 | }, | 203 | }, |
199 | /* The flip controls work with ov7670 only */ | 204 | /* The flip controls work for sensors ov7660 and ov7670 only */ |
200 | #define HFLIP_IDX 3 | 205 | [HFLIP] = { |
201 | { | ||
202 | { | 206 | { |
203 | .id = V4L2_CID_HFLIP, | 207 | .id = V4L2_CID_HFLIP, |
204 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 208 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -206,14 +210,11 @@ static const struct ctrl sd_ctrls[] = { | |||
206 | .minimum = 0, | 210 | .minimum = 0, |
207 | .maximum = 1, | 211 | .maximum = 1, |
208 | .step = 1, | 212 | .step = 1, |
209 | #define HFLIP_DEF 0 | 213 | .default_value = 0, |
210 | .default_value = HFLIP_DEF, | ||
211 | }, | 214 | }, |
212 | .set = sd_sethflip, | 215 | .set_control = sethvflip, |
213 | .get = sd_gethflip, | ||
214 | }, | 216 | }, |
215 | #define VFLIP_IDX 4 | 217 | [VFLIP] = { |
216 | { | ||
217 | { | 218 | { |
218 | .id = V4L2_CID_VFLIP, | 219 | .id = V4L2_CID_VFLIP, |
219 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 220 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -221,14 +222,11 @@ static const struct ctrl sd_ctrls[] = { | |||
221 | .minimum = 0, | 222 | .minimum = 0, |
222 | .maximum = 1, | 223 | .maximum = 1, |
223 | .step = 1, | 224 | .step = 1, |
224 | #define VFLIP_DEF 0 | 225 | .default_value = 0, |
225 | .default_value = VFLIP_DEF, | ||
226 | }, | 226 | }, |
227 | .set = sd_setvflip, | 227 | .set_control = sethvflip, |
228 | .get = sd_getvflip, | ||
229 | }, | 228 | }, |
230 | #define AUTOBRIGHT_IDX 5 | 229 | [AUTOBRIGHT] = { |
231 | { | ||
232 | { | 230 | { |
233 | .id = V4L2_CID_AUTOBRIGHTNESS, | 231 | .id = V4L2_CID_AUTOBRIGHTNESS, |
234 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 232 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -236,44 +234,114 @@ static const struct ctrl sd_ctrls[] = { | |||
236 | .minimum = 0, | 234 | .minimum = 0, |
237 | .maximum = 1, | 235 | .maximum = 1, |
238 | .step = 1, | 236 | .step = 1, |
239 | #define AUTOBRIGHT_DEF 1 | 237 | .default_value = 1, |
240 | .default_value = AUTOBRIGHT_DEF, | ||
241 | }, | 238 | }, |
242 | .set = sd_setautobrightness, | 239 | .set_control = setautobright, |
243 | .get = sd_getautobrightness, | ||
244 | }, | 240 | }, |
245 | #define FREQ_IDX 6 | 241 | [AUTOGAIN] = { |
246 | { | ||
247 | { | 242 | { |
248 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 243 | .id = V4L2_CID_AUTOGAIN, |
249 | .type = V4L2_CTRL_TYPE_MENU, | 244 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
250 | .name = "Light frequency filter", | 245 | .name = "Auto Gain", |
251 | .minimum = 0, | 246 | .minimum = 0, |
252 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | 247 | .maximum = 1, |
253 | .step = 1, | 248 | .step = 1, |
254 | #define FREQ_DEF 0 | 249 | .default_value = 1, |
255 | .default_value = FREQ_DEF, | 250 | .flags = V4L2_CTRL_FLAG_UPDATE |
256 | }, | 251 | }, |
257 | .set = sd_setfreq, | 252 | .set = sd_setautogain, |
258 | .get = sd_getfreq, | ||
259 | }, | 253 | }, |
260 | #define OV7670_FREQ_IDX 7 | 254 | [FREQ] = { |
261 | { | ||
262 | { | 255 | { |
263 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 256 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
264 | .type = V4L2_CTRL_TYPE_MENU, | 257 | .type = V4L2_CTRL_TYPE_MENU, |
265 | .name = "Light frequency filter", | 258 | .name = "Light frequency filter", |
266 | .minimum = 0, | 259 | .minimum = 0, |
267 | .maximum = 3, /* 0: 0, 1: 50Hz, 2:60Hz 3: Auto Hz */ | 260 | .maximum = 2, /* 0: no flicker, 1: 50Hz, 2:60Hz, 3: auto */ |
268 | .step = 1, | 261 | .step = 1, |
269 | #define OV7670_FREQ_DEF 3 | 262 | .default_value = 0, |
270 | .default_value = OV7670_FREQ_DEF, | ||
271 | }, | 263 | }, |
272 | .set = sd_setfreq, | 264 | .set_control = setfreq, |
273 | .get = sd_getfreq, | ||
274 | }, | 265 | }, |
275 | }; | 266 | }; |
276 | 267 | ||
268 | /* table of the disabled controls */ | ||
269 | static const unsigned ctrl_dis[] = { | ||
270 | [SEN_OV2610] = ((1 << NCTRL) - 1) /* no control */ | ||
271 | ^ ((1 << EXPOSURE) /* but exposure */ | ||
272 | | (1 << AUTOGAIN)), /* and autogain */ | ||
273 | |||
274 | [SEN_OV2610AE] = ((1 << NCTRL) - 1) /* no control */ | ||
275 | ^ ((1 << EXPOSURE) /* but exposure */ | ||
276 | | (1 << AUTOGAIN)), /* and autogain */ | ||
277 | |||
278 | [SEN_OV3610] = (1 << NCTRL) - 1, /* no control */ | ||
279 | |||
280 | [SEN_OV6620] = (1 << HFLIP) | | ||
281 | (1 << VFLIP) | | ||
282 | (1 << EXPOSURE) | | ||
283 | (1 << AUTOGAIN), | ||
284 | |||
285 | [SEN_OV6630] = (1 << HFLIP) | | ||
286 | (1 << VFLIP) | | ||
287 | (1 << EXPOSURE) | | ||
288 | (1 << AUTOGAIN), | ||
289 | |||
290 | [SEN_OV66308AF] = (1 << HFLIP) | | ||
291 | (1 << VFLIP) | | ||
292 | (1 << EXPOSURE) | | ||
293 | (1 << AUTOGAIN), | ||
294 | |||
295 | [SEN_OV7610] = (1 << HFLIP) | | ||
296 | (1 << VFLIP) | | ||
297 | (1 << EXPOSURE) | | ||
298 | (1 << AUTOGAIN), | ||
299 | |||
300 | [SEN_OV7620] = (1 << HFLIP) | | ||
301 | (1 << VFLIP) | | ||
302 | (1 << EXPOSURE) | | ||
303 | (1 << AUTOGAIN), | ||
304 | |||
305 | [SEN_OV7620AE] = (1 << HFLIP) | | ||
306 | (1 << VFLIP) | | ||
307 | (1 << EXPOSURE) | | ||
308 | (1 << AUTOGAIN), | ||
309 | |||
310 | [SEN_OV7640] = (1 << HFLIP) | | ||
311 | (1 << VFLIP) | | ||
312 | (1 << AUTOBRIGHT) | | ||
313 | (1 << CONTRAST) | | ||
314 | (1 << EXPOSURE) | | ||
315 | (1 << AUTOGAIN), | ||
316 | |||
317 | [SEN_OV7648] = (1 << HFLIP) | | ||
318 | (1 << VFLIP) | | ||
319 | (1 << AUTOBRIGHT) | | ||
320 | (1 << CONTRAST) | | ||
321 | (1 << EXPOSURE) | | ||
322 | (1 << AUTOGAIN), | ||
323 | |||
324 | [SEN_OV7660] = (1 << AUTOBRIGHT) | | ||
325 | (1 << EXPOSURE) | | ||
326 | (1 << AUTOGAIN), | ||
327 | |||
328 | [SEN_OV7670] = (1 << COLORS) | | ||
329 | (1 << AUTOBRIGHT) | | ||
330 | (1 << EXPOSURE) | | ||
331 | (1 << AUTOGAIN), | ||
332 | |||
333 | [SEN_OV76BE] = (1 << HFLIP) | | ||
334 | (1 << VFLIP) | | ||
335 | (1 << EXPOSURE) | | ||
336 | (1 << AUTOGAIN), | ||
337 | |||
338 | [SEN_OV8610] = (1 << HFLIP) | | ||
339 | (1 << VFLIP) | | ||
340 | (1 << EXPOSURE) | | ||
341 | (1 << AUTOGAIN) | | ||
342 | (1 << FREQ), | ||
343 | }; | ||
344 | |||
277 | static const struct v4l2_pix_format ov519_vga_mode[] = { | 345 | static const struct v4l2_pix_format ov519_vga_mode[] = { |
278 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 346 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
279 | .bytesperline = 320, | 347 | .bytesperline = 320, |
@@ -313,7 +381,7 @@ static const struct v4l2_pix_format ov519_sif_mode[] = { | |||
313 | larger then necessary, however they need to be this big as the ov511 / | 381 | larger then necessary, however they need to be this big as the ov511 / |
314 | ov518 always fills the entire isoc frame, using 0 padding bytes when | 382 | ov518 always fills the entire isoc frame, using 0 padding bytes when |
315 | it doesn't have any data. So with low framerates the amount of data | 383 | it doesn't have any data. So with low framerates the amount of data |
316 | transfered can become quite large (libv4l will remove all the 0 padding | 384 | transferred can become quite large (libv4l will remove all the 0 padding |
317 | in userspace). */ | 385 | in userspace). */ |
318 | static const struct v4l2_pix_format ov518_vga_mode[] = { | 386 | static const struct v4l2_pix_format ov518_vga_mode[] = { |
319 | {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | 387 | {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, |
@@ -420,6 +488,11 @@ static const struct v4l2_pix_format ovfx2_cif_mode[] = { | |||
420 | .priv = 0}, | 488 | .priv = 0}, |
421 | }; | 489 | }; |
422 | static const struct v4l2_pix_format ovfx2_ov2610_mode[] = { | 490 | static const struct v4l2_pix_format ovfx2_ov2610_mode[] = { |
491 | {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | ||
492 | .bytesperline = 800, | ||
493 | .sizeimage = 800 * 600, | ||
494 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
495 | .priv = 1}, | ||
423 | {1600, 1200, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 496 | {1600, 1200, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
424 | .bytesperline = 1600, | 497 | .bytesperline = 1600, |
425 | .sizeimage = 1600 * 1200, | 498 | .sizeimage = 1600 * 1200, |
@@ -453,15 +526,14 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = { | |||
453 | .priv = 0}, | 526 | .priv = 0}, |
454 | }; | 527 | }; |
455 | 528 | ||
456 | |||
457 | /* Registers common to OV511 / OV518 */ | 529 | /* Registers common to OV511 / OV518 */ |
458 | #define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */ | 530 | #define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */ |
459 | #define R51x_SYS_RESET 0x50 | 531 | #define R51x_SYS_RESET 0x50 |
460 | /* Reset type flags */ | 532 | /* Reset type flags */ |
461 | #define OV511_RESET_OMNICE 0x08 | 533 | #define OV511_RESET_OMNICE 0x08 |
462 | #define R51x_SYS_INIT 0x53 | 534 | #define R51x_SYS_INIT 0x53 |
463 | #define R51x_SYS_SNAP 0x52 | 535 | #define R51x_SYS_SNAP 0x52 |
464 | #define R51x_SYS_CUST_ID 0x5F | 536 | #define R51x_SYS_CUST_ID 0x5f |
465 | #define R51x_COMP_LUT_BEGIN 0x80 | 537 | #define R51x_COMP_LUT_BEGIN 0x80 |
466 | 538 | ||
467 | /* OV511 Camera interface register numbers */ | 539 | /* OV511 Camera interface register numbers */ |
@@ -476,13 +548,12 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = { | |||
476 | #define R511_CAM_OPTS 0x18 | 548 | #define R511_CAM_OPTS 0x18 |
477 | 549 | ||
478 | #define R511_SNAP_FRAME 0x19 | 550 | #define R511_SNAP_FRAME 0x19 |
479 | #define R511_SNAP_PXCNT 0x1A | 551 | #define R511_SNAP_PXCNT 0x1a |
480 | #define R511_SNAP_LNCNT 0x1B | 552 | #define R511_SNAP_LNCNT 0x1b |
481 | #define R511_SNAP_PXDIV 0x1C | 553 | #define R511_SNAP_PXDIV 0x1c |
482 | #define R511_SNAP_LNDIV 0x1D | 554 | #define R511_SNAP_LNDIV 0x1d |
483 | #define R511_SNAP_UV_EN 0x1E | 555 | #define R511_SNAP_UV_EN 0x1e |
484 | #define R511_SNAP_UV_EN 0x1E | 556 | #define R511_SNAP_OPTS 0x1f |
485 | #define R511_SNAP_OPTS 0x1F | ||
486 | 557 | ||
487 | #define R511_DRAM_FLOW_CTL 0x20 | 558 | #define R511_DRAM_FLOW_CTL 0x20 |
488 | #define R511_FIFO_OPTS 0x31 | 559 | #define R511_FIFO_OPTS 0x31 |
@@ -507,13 +578,14 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = { | |||
507 | #define OV519_R25_FORMAT 0x25 | 578 | #define OV519_R25_FORMAT 0x25 |
508 | 579 | ||
509 | /* OV519 System Controller register numbers */ | 580 | /* OV519 System Controller register numbers */ |
510 | #define OV519_SYS_RESET1 0x51 | 581 | #define OV519_R51_RESET1 0x51 |
511 | #define OV519_SYS_EN_CLK1 0x54 | 582 | #define OV519_R54_EN_CLK1 0x54 |
583 | #define OV519_R57_SNAPSHOT 0x57 | ||
512 | 584 | ||
513 | #define OV519_GPIO_DATA_OUT0 0x71 | 585 | #define OV519_GPIO_DATA_OUT0 0x71 |
514 | #define OV519_GPIO_IO_CTRL0 0x72 | 586 | #define OV519_GPIO_IO_CTRL0 0x72 |
515 | 587 | ||
516 | #define OV511_ENDPOINT_ADDRESS 1 /* Isoc endpoint number */ | 588 | /*#define OV511_ENDPOINT_ADDRESS 1 * Isoc endpoint number */ |
517 | 589 | ||
518 | /* | 590 | /* |
519 | * The FX2 chip does not give us a zero length read at end of frame. | 591 | * The FX2 chip does not give us a zero length read at end of frame. |
@@ -537,6 +609,7 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = { | |||
537 | * buffers, there are some pretty strict real time constraints for | 609 | * buffers, there are some pretty strict real time constraints for |
538 | * isochronous transfer for larger frame sizes). | 610 | * isochronous transfer for larger frame sizes). |
539 | */ | 611 | */ |
612 | /*jfm: this value does not work for 800x600 - see isoc_init */ | ||
540 | #define OVFX2_BULK_SIZE (13 * 4096) | 613 | #define OVFX2_BULK_SIZE (13 * 4096) |
541 | 614 | ||
542 | /* I2C registers */ | 615 | /* I2C registers */ |
@@ -567,90 +640,107 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = { | |||
567 | #define OV7610_REG_ID_LOW 0x1d /* manufacturer ID LSB */ | 640 | #define OV7610_REG_ID_LOW 0x1d /* manufacturer ID LSB */ |
568 | #define OV7610_REG_COM_I 0x29 /* misc settings */ | 641 | #define OV7610_REG_COM_I 0x29 /* misc settings */ |
569 | 642 | ||
570 | /* OV7670 registers */ | 643 | /* OV7660 and OV7670 registers */ |
571 | #define OV7670_REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */ | 644 | #define OV7670_R00_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */ |
572 | #define OV7670_REG_BLUE 0x01 /* blue gain */ | 645 | #define OV7670_R01_BLUE 0x01 /* blue gain */ |
573 | #define OV7670_REG_RED 0x02 /* red gain */ | 646 | #define OV7670_R02_RED 0x02 /* red gain */ |
574 | #define OV7670_REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */ | 647 | #define OV7670_R03_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */ |
575 | #define OV7670_REG_COM1 0x04 /* Control 1 */ | 648 | #define OV7670_R04_COM1 0x04 /* Control 1 */ |
576 | #define OV7670_REG_AECHH 0x07 /* AEC MS 5 bits */ | 649 | /*#define OV7670_R07_AECHH 0x07 * AEC MS 5 bits */ |
577 | #define OV7670_REG_COM3 0x0c /* Control 3 */ | 650 | #define OV7670_R0C_COM3 0x0c /* Control 3 */ |
578 | #define OV7670_REG_COM4 0x0d /* Control 4 */ | 651 | #define OV7670_R0D_COM4 0x0d /* Control 4 */ |
579 | #define OV7670_REG_COM5 0x0e /* All "reserved" */ | 652 | #define OV7670_R0E_COM5 0x0e /* All "reserved" */ |
580 | #define OV7670_REG_COM6 0x0f /* Control 6 */ | 653 | #define OV7670_R0F_COM6 0x0f /* Control 6 */ |
581 | #define OV7670_REG_AECH 0x10 /* More bits of AEC value */ | 654 | #define OV7670_R10_AECH 0x10 /* More bits of AEC value */ |
582 | #define OV7670_REG_CLKRC 0x11 /* Clock control */ | 655 | #define OV7670_R11_CLKRC 0x11 /* Clock control */ |
583 | #define OV7670_REG_COM7 0x12 /* Control 7 */ | 656 | #define OV7670_R12_COM7 0x12 /* Control 7 */ |
584 | #define OV7670_COM7_FMT_VGA 0x00 | 657 | #define OV7670_COM7_FMT_VGA 0x00 |
585 | #define OV7670_COM7_YUV 0x00 /* YUV */ | 658 | /*#define OV7670_COM7_YUV 0x00 * YUV */ |
586 | #define OV7670_COM7_FMT_QVGA 0x10 /* QVGA format */ | 659 | #define OV7670_COM7_FMT_QVGA 0x10 /* QVGA format */ |
587 | #define OV7670_COM7_FMT_MASK 0x38 | 660 | #define OV7670_COM7_FMT_MASK 0x38 |
588 | #define OV7670_COM7_RESET 0x80 /* Register reset */ | 661 | #define OV7670_COM7_RESET 0x80 /* Register reset */ |
589 | #define OV7670_REG_COM8 0x13 /* Control 8 */ | 662 | #define OV7670_R13_COM8 0x13 /* Control 8 */ |
590 | #define OV7670_COM8_AEC 0x01 /* Auto exposure enable */ | 663 | #define OV7670_COM8_AEC 0x01 /* Auto exposure enable */ |
591 | #define OV7670_COM8_AWB 0x02 /* White balance enable */ | 664 | #define OV7670_COM8_AWB 0x02 /* White balance enable */ |
592 | #define OV7670_COM8_AGC 0x04 /* Auto gain enable */ | 665 | #define OV7670_COM8_AGC 0x04 /* Auto gain enable */ |
593 | #define OV7670_COM8_BFILT 0x20 /* Band filter enable */ | 666 | #define OV7670_COM8_BFILT 0x20 /* Band filter enable */ |
594 | #define OV7670_COM8_AECSTEP 0x40 /* Unlimited AEC step size */ | 667 | #define OV7670_COM8_AECSTEP 0x40 /* Unlimited AEC step size */ |
595 | #define OV7670_COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */ | 668 | #define OV7670_COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */ |
596 | #define OV7670_REG_COM9 0x14 /* Control 9 - gain ceiling */ | 669 | #define OV7670_R14_COM9 0x14 /* Control 9 - gain ceiling */ |
597 | #define OV7670_REG_COM10 0x15 /* Control 10 */ | 670 | #define OV7670_R15_COM10 0x15 /* Control 10 */ |
598 | #define OV7670_REG_HSTART 0x17 /* Horiz start high bits */ | 671 | #define OV7670_R17_HSTART 0x17 /* Horiz start high bits */ |
599 | #define OV7670_REG_HSTOP 0x18 /* Horiz stop high bits */ | 672 | #define OV7670_R18_HSTOP 0x18 /* Horiz stop high bits */ |
600 | #define OV7670_REG_VSTART 0x19 /* Vert start high bits */ | 673 | #define OV7670_R19_VSTART 0x19 /* Vert start high bits */ |
601 | #define OV7670_REG_VSTOP 0x1a /* Vert stop high bits */ | 674 | #define OV7670_R1A_VSTOP 0x1a /* Vert stop high bits */ |
602 | #define OV7670_REG_MVFP 0x1e /* Mirror / vflip */ | 675 | #define OV7670_R1E_MVFP 0x1e /* Mirror / vflip */ |
603 | #define OV7670_MVFP_VFLIP 0x10 /* vertical flip */ | 676 | #define OV7670_MVFP_VFLIP 0x10 /* vertical flip */ |
604 | #define OV7670_MVFP_MIRROR 0x20 /* Mirror image */ | 677 | #define OV7670_MVFP_MIRROR 0x20 /* Mirror image */ |
605 | #define OV7670_REG_AEW 0x24 /* AGC upper limit */ | 678 | #define OV7670_R24_AEW 0x24 /* AGC upper limit */ |
606 | #define OV7670_REG_AEB 0x25 /* AGC lower limit */ | 679 | #define OV7670_R25_AEB 0x25 /* AGC lower limit */ |
607 | #define OV7670_REG_VPT 0x26 /* AGC/AEC fast mode op region */ | 680 | #define OV7670_R26_VPT 0x26 /* AGC/AEC fast mode op region */ |
608 | #define OV7670_REG_HREF 0x32 /* HREF pieces */ | 681 | #define OV7670_R32_HREF 0x32 /* HREF pieces */ |
609 | #define OV7670_REG_TSLB 0x3a /* lots of stuff */ | 682 | #define OV7670_R3A_TSLB 0x3a /* lots of stuff */ |
610 | #define OV7670_REG_COM11 0x3b /* Control 11 */ | 683 | #define OV7670_R3B_COM11 0x3b /* Control 11 */ |
611 | #define OV7670_COM11_EXP 0x02 | 684 | #define OV7670_COM11_EXP 0x02 |
612 | #define OV7670_COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */ | 685 | #define OV7670_COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */ |
613 | #define OV7670_REG_COM12 0x3c /* Control 12 */ | 686 | #define OV7670_R3C_COM12 0x3c /* Control 12 */ |
614 | #define OV7670_REG_COM13 0x3d /* Control 13 */ | 687 | #define OV7670_R3D_COM13 0x3d /* Control 13 */ |
615 | #define OV7670_COM13_GAMMA 0x80 /* Gamma enable */ | 688 | #define OV7670_COM13_GAMMA 0x80 /* Gamma enable */ |
616 | #define OV7670_COM13_UVSAT 0x40 /* UV saturation auto adjustment */ | 689 | #define OV7670_COM13_UVSAT 0x40 /* UV saturation auto adjustment */ |
617 | #define OV7670_REG_COM14 0x3e /* Control 14 */ | 690 | #define OV7670_R3E_COM14 0x3e /* Control 14 */ |
618 | #define OV7670_REG_EDGE 0x3f /* Edge enhancement factor */ | 691 | #define OV7670_R3F_EDGE 0x3f /* Edge enhancement factor */ |
619 | #define OV7670_REG_COM15 0x40 /* Control 15 */ | 692 | #define OV7670_R40_COM15 0x40 /* Control 15 */ |
620 | #define OV7670_COM15_R00FF 0xc0 /* 00 to FF */ | 693 | /*#define OV7670_COM15_R00FF 0xc0 * 00 to FF */ |
621 | #define OV7670_REG_COM16 0x41 /* Control 16 */ | 694 | #define OV7670_R41_COM16 0x41 /* Control 16 */ |
622 | #define OV7670_COM16_AWBGAIN 0x08 /* AWB gain enable */ | 695 | #define OV7670_COM16_AWBGAIN 0x08 /* AWB gain enable */ |
623 | #define OV7670_REG_BRIGHT 0x55 /* Brightness */ | 696 | /* end of ov7660 common registers */ |
624 | #define OV7670_REG_CONTRAS 0x56 /* Contrast control */ | 697 | #define OV7670_R55_BRIGHT 0x55 /* Brightness */ |
625 | #define OV7670_REG_GFIX 0x69 /* Fix gain control */ | 698 | #define OV7670_R56_CONTRAS 0x56 /* Contrast control */ |
626 | #define OV7670_REG_RGB444 0x8c /* RGB 444 control */ | 699 | #define OV7670_R69_GFIX 0x69 /* Fix gain control */ |
627 | #define OV7670_REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */ | 700 | /*#define OV7670_R8C_RGB444 0x8c * RGB 444 control */ |
628 | #define OV7670_REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */ | 701 | #define OV7670_R9F_HAECC1 0x9f /* Hist AEC/AGC control 1 */ |
629 | #define OV7670_REG_BD50MAX 0xa5 /* 50hz banding step limit */ | 702 | #define OV7670_RA0_HAECC2 0xa0 /* Hist AEC/AGC control 2 */ |
630 | #define OV7670_REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */ | 703 | #define OV7670_RA5_BD50MAX 0xa5 /* 50hz banding step limit */ |
631 | #define OV7670_REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */ | 704 | #define OV7670_RA6_HAECC3 0xa6 /* Hist AEC/AGC control 3 */ |
632 | #define OV7670_REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */ | 705 | #define OV7670_RA7_HAECC4 0xa7 /* Hist AEC/AGC control 4 */ |
633 | #define OV7670_REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */ | 706 | #define OV7670_RA8_HAECC5 0xa8 /* Hist AEC/AGC control 5 */ |
634 | #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */ | 707 | #define OV7670_RA9_HAECC6 0xa9 /* Hist AEC/AGC control 6 */ |
635 | #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */ | 708 | #define OV7670_RAA_HAECC7 0xaa /* Hist AEC/AGC control 7 */ |
709 | #define OV7670_RAB_BD60MAX 0xab /* 60hz banding step limit */ | ||
636 | 710 | ||
637 | struct ov_regvals { | 711 | struct ov_regvals { |
638 | __u8 reg; | 712 | u8 reg; |
639 | __u8 val; | 713 | u8 val; |
640 | }; | 714 | }; |
641 | struct ov_i2c_regvals { | 715 | struct ov_i2c_regvals { |
642 | __u8 reg; | 716 | u8 reg; |
643 | __u8 val; | 717 | u8 val; |
644 | }; | 718 | }; |
645 | 719 | ||
646 | /* Settings for OV2610 camera chip */ | 720 | /* Settings for OV2610 camera chip */ |
647 | static const struct ov_i2c_regvals norm_2610[] = | 721 | static const struct ov_i2c_regvals norm_2610[] = { |
648 | { | ||
649 | { 0x12, 0x80 }, /* reset */ | 722 | { 0x12, 0x80 }, /* reset */ |
650 | }; | 723 | }; |
651 | 724 | ||
652 | static const struct ov_i2c_regvals norm_3620b[] = | 725 | static const struct ov_i2c_regvals norm_2610ae[] = { |
653 | { | 726 | {0x12, 0x80}, /* reset */ |
727 | {0x13, 0xcd}, | ||
728 | {0x09, 0x01}, | ||
729 | {0x0d, 0x00}, | ||
730 | {0x11, 0x80}, | ||
731 | {0x12, 0x20}, /* 1600x1200 */ | ||
732 | {0x33, 0x0c}, | ||
733 | {0x35, 0x90}, | ||
734 | {0x36, 0x37}, | ||
735 | /* ms-win traces */ | ||
736 | {0x11, 0x83}, /* clock / 3 ? */ | ||
737 | {0x2d, 0x00}, /* 60 Hz filter */ | ||
738 | {0x24, 0xb0}, /* normal colors */ | ||
739 | {0x25, 0x90}, | ||
740 | {0x10, 0x43}, | ||
741 | }; | ||
742 | |||
743 | static const struct ov_i2c_regvals norm_3620b[] = { | ||
654 | /* | 744 | /* |
655 | * From the datasheet: "Note that after writing to register COMH | 745 | * From the datasheet: "Note that after writing to register COMH |
656 | * (0x12) to change the sensor mode, registers related to the | 746 | * (0x12) to change the sensor mode, registers related to the |
@@ -660,7 +750,6 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
660 | * "wait 4096 external clock ... to make sure the sensor is | 750 | * "wait 4096 external clock ... to make sure the sensor is |
661 | * stable and ready to access registers" i.e. 160us at 24MHz | 751 | * stable and ready to access registers" i.e. 160us at 24MHz |
662 | */ | 752 | */ |
663 | |||
664 | { 0x12, 0x80 }, /* COMH reset */ | 753 | { 0x12, 0x80 }, /* COMH reset */ |
665 | { 0x12, 0x00 }, /* QXGA, master */ | 754 | { 0x12, 0x00 }, /* QXGA, master */ |
666 | 755 | ||
@@ -693,7 +782,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
693 | * COMI[0] "Exposure control" | 782 | * COMI[0] "Exposure control" |
694 | * = 0 (0x00) .......0 "Manual" | 783 | * = 0 (0x00) .......0 "Manual" |
695 | */ | 784 | */ |
696 | { 0x13, 0xC0 }, | 785 | { 0x13, 0xc0 }, |
697 | 786 | ||
698 | /* | 787 | /* |
699 | * 09 COMC "Common Control C" | 788 | * 09 COMC "Common Control C" |
@@ -749,7 +838,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
749 | * COME[0] "Auto zero circuit select" | 838 | * COME[0] "Auto zero circuit select" |
750 | * = 1 (0x01) .......1 "On" | 839 | * = 1 (0x01) .......1 "On" |
751 | */ | 840 | */ |
752 | { 0x0d, 0xA1 }, | 841 | { 0x0d, 0xa1 }, |
753 | 842 | ||
754 | /* | 843 | /* |
755 | * 0E COMF "Common Control F" | 844 | * 0E COMF "Common Control F" |
@@ -813,7 +902,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
813 | * COMJ[0] "Reserved" | 902 | * COMJ[0] "Reserved" |
814 | * = 0 (0x00) .......0 | 903 | * = 0 (0x00) .......0 |
815 | */ | 904 | */ |
816 | { 0x14, 0xC6 }, | 905 | { 0x14, 0xc6 }, |
817 | 906 | ||
818 | /* | 907 | /* |
819 | * 15 COMK "Common Control K" | 908 | * 15 COMK "Common Control K" |
@@ -919,7 +1008,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
919 | * FVOPT[7:0] "Range" | 1008 | * FVOPT[7:0] "Range" |
920 | * = 31 (0x1F) 00011111 | 1009 | * = 31 (0x1F) 00011111 |
921 | */ | 1010 | */ |
922 | { 0x3c, 0x1F }, | 1011 | { 0x3c, 0x1f }, |
923 | 1012 | ||
924 | /* | 1013 | /* |
925 | * 44 Undocumented = 0 (0x00) 00000000 | 1014 | * 44 Undocumented = 0 (0x00) 00000000 |
@@ -968,7 +1057,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
968 | * 48[7:0] "It's a secret" | 1057 | * 48[7:0] "It's a secret" |
969 | * = 192 (0xC0) 11000000 | 1058 | * = 192 (0xC0) 11000000 |
970 | */ | 1059 | */ |
971 | { 0x48, 0xC0 }, | 1060 | { 0x48, 0xc0 }, |
972 | 1061 | ||
973 | /* | 1062 | /* |
974 | * 49 Undocumented = 25 (0x19) 00011001 | 1063 | * 49 Undocumented = 25 (0x19) 00011001 |
@@ -982,18 +1071,18 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
982 | * 4B[7:0] "It's a secret" | 1071 | * 4B[7:0] "It's a secret" |
983 | * = 128 (0x80) 10000000 | 1072 | * = 128 (0x80) 10000000 |
984 | */ | 1073 | */ |
985 | { 0x4B, 0x80 }, | 1074 | { 0x4b, 0x80 }, |
986 | 1075 | ||
987 | /* | 1076 | /* |
988 | * 4D Undocumented = 196 (0xC4) 11000100 | 1077 | * 4D Undocumented = 196 (0xC4) 11000100 |
989 | * 4D[7:0] "It's a secret" | 1078 | * 4D[7:0] "It's a secret" |
990 | * = 196 (0xC4) 11000100 | 1079 | * = 196 (0xC4) 11000100 |
991 | */ | 1080 | */ |
992 | { 0x4D, 0xC4 }, | 1081 | { 0x4d, 0xc4 }, |
993 | 1082 | ||
994 | /* | 1083 | /* |
995 | * 35 VREF "Reference Voltage Control" | 1084 | * 35 VREF "Reference Voltage Control" |
996 | * = 76 (0x4C) 01001100 | 1085 | * = 76 (0x4c) 01001100 |
997 | * VREF[7:5] "Column high reference control" | 1086 | * VREF[7:5] "Column high reference control" |
998 | * = 2 (0x02) 010..... "higher voltage" | 1087 | * = 2 (0x02) 010..... "higher voltage" |
999 | * VREF[4:2] "Column low reference control" | 1088 | * VREF[4:2] "Column low reference control" |
@@ -1001,21 +1090,21 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1001 | * VREF[1:0] "Reserved" | 1090 | * VREF[1:0] "Reserved" |
1002 | * = 0 (0x00) ......00 | 1091 | * = 0 (0x00) ......00 |
1003 | */ | 1092 | */ |
1004 | { 0x35, 0x4C }, | 1093 | { 0x35, 0x4c }, |
1005 | 1094 | ||
1006 | /* | 1095 | /* |
1007 | * 3D Undocumented = 0 (0x00) 00000000 | 1096 | * 3D Undocumented = 0 (0x00) 00000000 |
1008 | * 3D[7:0] "It's a secret" | 1097 | * 3D[7:0] "It's a secret" |
1009 | * = 0 (0x00) 00000000 | 1098 | * = 0 (0x00) 00000000 |
1010 | */ | 1099 | */ |
1011 | { 0x3D, 0x00 }, | 1100 | { 0x3d, 0x00 }, |
1012 | 1101 | ||
1013 | /* | 1102 | /* |
1014 | * 3E Undocumented = 0 (0x00) 00000000 | 1103 | * 3E Undocumented = 0 (0x00) 00000000 |
1015 | * 3E[7:0] "It's a secret" | 1104 | * 3E[7:0] "It's a secret" |
1016 | * = 0 (0x00) 00000000 | 1105 | * = 0 (0x00) 00000000 |
1017 | */ | 1106 | */ |
1018 | { 0x3E, 0x00 }, | 1107 | { 0x3e, 0x00 }, |
1019 | 1108 | ||
1020 | /* | 1109 | /* |
1021 | * 3B FREFB "Internal Reference Adjustment" | 1110 | * 3B FREFB "Internal Reference Adjustment" |
@@ -1055,7 +1144,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1055 | * VBLM[3:0] "Sensor current control" | 1144 | * VBLM[3:0] "Sensor current control" |
1056 | * = 10 (0x0A) ....1010 | 1145 | * = 10 (0x0A) ....1010 |
1057 | */ | 1146 | */ |
1058 | { 0x34, 0x5A }, | 1147 | { 0x34, 0x5a }, |
1059 | 1148 | ||
1060 | /* | 1149 | /* |
1061 | * 3B FREFB "Internal Reference Adjustment" | 1150 | * 3B FREFB "Internal Reference Adjustment" |
@@ -1121,7 +1210,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1121 | * HREFST[7:0] "Horizontal window start, 8 MSBs" | 1210 | * HREFST[7:0] "Horizontal window start, 8 MSBs" |
1122 | * = 31 (0x1F) 00011111 | 1211 | * = 31 (0x1F) 00011111 |
1123 | */ | 1212 | */ |
1124 | { 0x17, 0x1F }, | 1213 | { 0x17, 0x1f }, |
1125 | 1214 | ||
1126 | /* | 1215 | /* |
1127 | * 18 HREFEND "Horizontal window end" | 1216 | * 18 HREFEND "Horizontal window end" |
@@ -1129,7 +1218,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1129 | * HREFEND[7:0] "Horizontal Window End, 8 MSBs" | 1218 | * HREFEND[7:0] "Horizontal Window End, 8 MSBs" |
1130 | * = 95 (0x5F) 01011111 | 1219 | * = 95 (0x5F) 01011111 |
1131 | */ | 1220 | */ |
1132 | { 0x18, 0x5F }, | 1221 | { 0x18, 0x5f }, |
1133 | 1222 | ||
1134 | /* | 1223 | /* |
1135 | * 19 VSTRT "Vertical window start" | 1224 | * 19 VSTRT "Vertical window start" |
@@ -1169,7 +1258,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1169 | * COMA[1:0] "Vertical window start line control 2 LSBs" | 1258 | * COMA[1:0] "Vertical window start line control 2 LSBs" |
1170 | * = 2 (0x02) ......10 | 1259 | * = 2 (0x02) ......10 |
1171 | */ | 1260 | */ |
1172 | { 0x03, 0x4A }, | 1261 | { 0x03, 0x4a }, |
1173 | 1262 | ||
1174 | /* | 1263 | /* |
1175 | * 11 CLKRC "Clock Rate Control" | 1264 | * 11 CLKRC "Clock Rate Control" |
@@ -1226,7 +1315,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1226 | * HREFST[7:0] "Horizontal window start, 8 MSBs" | 1315 | * HREFST[7:0] "Horizontal window start, 8 MSBs" |
1227 | * = 31 (0x1F) 00011111 | 1316 | * = 31 (0x1F) 00011111 |
1228 | */ | 1317 | */ |
1229 | { 0x17, 0x1F }, | 1318 | { 0x17, 0x1f }, |
1230 | 1319 | ||
1231 | /* | 1320 | /* |
1232 | * 18 HREFEND "Horizontal window end" | 1321 | * 18 HREFEND "Horizontal window end" |
@@ -1234,7 +1323,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1234 | * HREFEND[7:0] "Horizontal Window End, 8 MSBs" | 1323 | * HREFEND[7:0] "Horizontal Window End, 8 MSBs" |
1235 | * = 95 (0x5F) 01011111 | 1324 | * = 95 (0x5F) 01011111 |
1236 | */ | 1325 | */ |
1237 | { 0x18, 0x5F }, | 1326 | { 0x18, 0x5f }, |
1238 | 1327 | ||
1239 | /* | 1328 | /* |
1240 | * 19 VSTRT "Vertical window start" | 1329 | * 19 VSTRT "Vertical window start" |
@@ -1274,7 +1363,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1274 | * COMA[1:0] "Vertical window start line control 2 LSBs" | 1363 | * COMA[1:0] "Vertical window start line control 2 LSBs" |
1275 | * = 2 (0x02) ......10 | 1364 | * = 2 (0x02) ......10 |
1276 | */ | 1365 | */ |
1277 | { 0x03, 0x4A }, | 1366 | { 0x03, 0x4a }, |
1278 | 1367 | ||
1279 | /* | 1368 | /* |
1280 | * 02 RED "Red Gain Control" | 1369 | * 02 RED "Red Gain Control" |
@@ -1284,7 +1373,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1284 | * RED[6:0] "Value" | 1373 | * RED[6:0] "Value" |
1285 | * = 47 (0x2F) .0101111 | 1374 | * = 47 (0x2F) .0101111 |
1286 | */ | 1375 | */ |
1287 | { 0x02, 0xAF }, | 1376 | { 0x02, 0xaf }, |
1288 | 1377 | ||
1289 | /* | 1378 | /* |
1290 | * 2D ADDVSL "VSYNC Pulse Width" | 1379 | * 2D ADDVSL "VSYNC Pulse Width" |
@@ -1292,7 +1381,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1292 | * ADDVSL[7:0] "VSYNC pulse width, LSB" | 1381 | * ADDVSL[7:0] "VSYNC pulse width, LSB" |
1293 | * = 210 (0xD2) 11010010 | 1382 | * = 210 (0xD2) 11010010 |
1294 | */ | 1383 | */ |
1295 | { 0x2d, 0xD2 }, | 1384 | { 0x2d, 0xd2 }, |
1296 | 1385 | ||
1297 | /* | 1386 | /* |
1298 | * 00 GAIN = 24 (0x18) 00011000 | 1387 | * 00 GAIN = 24 (0x18) 00011000 |
@@ -1315,7 +1404,7 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1315 | * BLUE[6:0] "Value" | 1404 | * BLUE[6:0] "Value" |
1316 | * = 112 (0x70) .1110000 | 1405 | * = 112 (0x70) .1110000 |
1317 | */ | 1406 | */ |
1318 | { 0x01, 0xF0 }, | 1407 | { 0x01, 0xf0 }, |
1319 | 1408 | ||
1320 | /* | 1409 | /* |
1321 | * 10 AEC "Automatic Exposure Control" | 1410 | * 10 AEC "Automatic Exposure Control" |
@@ -1323,14 +1412,14 @@ static const struct ov_i2c_regvals norm_3620b[] = | |||
1323 | * AEC[7:0] "Automatic Exposure Control, 8 MSBs" | 1412 | * AEC[7:0] "Automatic Exposure Control, 8 MSBs" |
1324 | * = 10 (0x0A) 00001010 | 1413 | * = 10 (0x0A) 00001010 |
1325 | */ | 1414 | */ |
1326 | { 0x10, 0x0A }, | 1415 | { 0x10, 0x0a }, |
1327 | 1416 | ||
1328 | { 0xE1, 0x67 }, | 1417 | { 0xe1, 0x67 }, |
1329 | { 0xE3, 0x03 }, | 1418 | { 0xe3, 0x03 }, |
1330 | { 0xE4, 0x26 }, | 1419 | { 0xe4, 0x26 }, |
1331 | { 0xE5, 0x3E }, | 1420 | { 0xe5, 0x3e }, |
1332 | { 0xF8, 0x01 }, | 1421 | { 0xf8, 0x01 }, |
1333 | { 0xFF, 0x01 }, | 1422 | { 0xff, 0x01 }, |
1334 | }; | 1423 | }; |
1335 | 1424 | ||
1336 | static const struct ov_i2c_regvals norm_6x20[] = { | 1425 | static const struct ov_i2c_regvals norm_6x20[] = { |
@@ -1339,7 +1428,7 @@ static const struct ov_i2c_regvals norm_6x20[] = { | |||
1339 | { 0x03, 0x60 }, | 1428 | { 0x03, 0x60 }, |
1340 | { 0x05, 0x7f }, /* For when autoadjust is off */ | 1429 | { 0x05, 0x7f }, /* For when autoadjust is off */ |
1341 | { 0x07, 0xa8 }, | 1430 | { 0x07, 0xa8 }, |
1342 | /* The ratio of 0x0c and 0x0d controls the white point */ | 1431 | /* The ratio of 0x0c and 0x0d controls the white point */ |
1343 | { 0x0c, 0x24 }, | 1432 | { 0x0c, 0x24 }, |
1344 | { 0x0d, 0x24 }, | 1433 | { 0x0d, 0x24 }, |
1345 | { 0x0f, 0x15 }, /* COMS */ | 1434 | { 0x0f, 0x15 }, /* COMS */ |
@@ -1507,7 +1596,7 @@ static const struct ov_i2c_regvals norm_7620[] = { | |||
1507 | { 0x00, 0x00 }, /* gain */ | 1596 | { 0x00, 0x00 }, /* gain */ |
1508 | { 0x01, 0x80 }, /* blue gain */ | 1597 | { 0x01, 0x80 }, /* blue gain */ |
1509 | { 0x02, 0x80 }, /* red gain */ | 1598 | { 0x02, 0x80 }, /* red gain */ |
1510 | { 0x03, 0xc0 }, /* OV7670_REG_VREF */ | 1599 | { 0x03, 0xc0 }, /* OV7670_R03_VREF */ |
1511 | { 0x06, 0x60 }, | 1600 | { 0x06, 0x60 }, |
1512 | { 0x07, 0x00 }, | 1601 | { 0x07, 0x00 }, |
1513 | { 0x0c, 0x24 }, | 1602 | { 0x0c, 0x24 }, |
@@ -1575,33 +1664,177 @@ static const struct ov_i2c_regvals norm_7640[] = { | |||
1575 | { 0x12, 0x14 }, | 1664 | { 0x12, 0x14 }, |
1576 | }; | 1665 | }; |
1577 | 1666 | ||
1667 | static const struct ov_regvals init_519_ov7660[] = { | ||
1668 | { 0x5d, 0x03 }, /* Turn off suspend mode */ | ||
1669 | { 0x53, 0x9b }, /* 0x9f enables the (unused) microcontroller */ | ||
1670 | { 0x54, 0x0f }, /* bit2 (jpeg enable) */ | ||
1671 | { 0xa2, 0x20 }, /* a2-a5 are undocumented */ | ||
1672 | { 0xa3, 0x18 }, | ||
1673 | { 0xa4, 0x04 }, | ||
1674 | { 0xa5, 0x28 }, | ||
1675 | { 0x37, 0x00 }, /* SetUsbInit */ | ||
1676 | { 0x55, 0x02 }, /* 4.096 Mhz audio clock */ | ||
1677 | /* Enable both fields, YUV Input, disable defect comp (why?) */ | ||
1678 | { 0x20, 0x0c }, /* 0x0d does U <-> V swap */ | ||
1679 | { 0x21, 0x38 }, | ||
1680 | { 0x22, 0x1d }, | ||
1681 | { 0x17, 0x50 }, /* undocumented */ | ||
1682 | { 0x37, 0x00 }, /* undocumented */ | ||
1683 | { 0x40, 0xff }, /* I2C timeout counter */ | ||
1684 | { 0x46, 0x00 }, /* I2C clock prescaler */ | ||
1685 | }; | ||
1686 | static const struct ov_i2c_regvals norm_7660[] = { | ||
1687 | {OV7670_R12_COM7, OV7670_COM7_RESET}, | ||
1688 | {OV7670_R11_CLKRC, 0x81}, | ||
1689 | {0x92, 0x00}, /* DM_LNL */ | ||
1690 | {0x93, 0x00}, /* DM_LNH */ | ||
1691 | {0x9d, 0x4c}, /* BD50ST */ | ||
1692 | {0x9e, 0x3f}, /* BD60ST */ | ||
1693 | {OV7670_R3B_COM11, 0x02}, | ||
1694 | {OV7670_R13_COM8, 0xf5}, | ||
1695 | {OV7670_R10_AECH, 0x00}, | ||
1696 | {OV7670_R00_GAIN, 0x00}, | ||
1697 | {OV7670_R01_BLUE, 0x7c}, | ||
1698 | {OV7670_R02_RED, 0x9d}, | ||
1699 | {OV7670_R12_COM7, 0x00}, | ||
1700 | {OV7670_R04_COM1, 00}, | ||
1701 | {OV7670_R18_HSTOP, 0x01}, | ||
1702 | {OV7670_R17_HSTART, 0x13}, | ||
1703 | {OV7670_R32_HREF, 0x92}, | ||
1704 | {OV7670_R19_VSTART, 0x02}, | ||
1705 | {OV7670_R1A_VSTOP, 0x7a}, | ||
1706 | {OV7670_R03_VREF, 0x00}, | ||
1707 | {OV7670_R0E_COM5, 0x04}, | ||
1708 | {OV7670_R0F_COM6, 0x62}, | ||
1709 | {OV7670_R15_COM10, 0x00}, | ||
1710 | {0x16, 0x02}, /* RSVD */ | ||
1711 | {0x1b, 0x00}, /* PSHFT */ | ||
1712 | {OV7670_R1E_MVFP, 0x01}, | ||
1713 | {0x29, 0x3c}, /* RSVD */ | ||
1714 | {0x33, 0x00}, /* CHLF */ | ||
1715 | {0x34, 0x07}, /* ARBLM */ | ||
1716 | {0x35, 0x84}, /* RSVD */ | ||
1717 | {0x36, 0x00}, /* RSVD */ | ||
1718 | {0x37, 0x04}, /* ADC */ | ||
1719 | {0x39, 0x43}, /* OFON */ | ||
1720 | {OV7670_R3A_TSLB, 0x00}, | ||
1721 | {OV7670_R3C_COM12, 0x6c}, | ||
1722 | {OV7670_R3D_COM13, 0x98}, | ||
1723 | {OV7670_R3F_EDGE, 0x23}, | ||
1724 | {OV7670_R40_COM15, 0xc1}, | ||
1725 | {OV7670_R41_COM16, 0x22}, | ||
1726 | {0x6b, 0x0a}, /* DBLV */ | ||
1727 | {0xa1, 0x08}, /* RSVD */ | ||
1728 | {0x69, 0x80}, /* HV */ | ||
1729 | {0x43, 0xf0}, /* RSVD.. */ | ||
1730 | {0x44, 0x10}, | ||
1731 | {0x45, 0x78}, | ||
1732 | {0x46, 0xa8}, | ||
1733 | {0x47, 0x60}, | ||
1734 | {0x48, 0x80}, | ||
1735 | {0x59, 0xba}, | ||
1736 | {0x5a, 0x9a}, | ||
1737 | {0x5b, 0x22}, | ||
1738 | {0x5c, 0xb9}, | ||
1739 | {0x5d, 0x9b}, | ||
1740 | {0x5e, 0x10}, | ||
1741 | {0x5f, 0xe0}, | ||
1742 | {0x60, 0x85}, | ||
1743 | {0x61, 0x60}, | ||
1744 | {0x9f, 0x9d}, /* RSVD */ | ||
1745 | {0xa0, 0xa0}, /* DSPC2 */ | ||
1746 | {0x4f, 0x60}, /* matrix */ | ||
1747 | {0x50, 0x64}, | ||
1748 | {0x51, 0x04}, | ||
1749 | {0x52, 0x18}, | ||
1750 | {0x53, 0x3c}, | ||
1751 | {0x54, 0x54}, | ||
1752 | {0x55, 0x40}, | ||
1753 | {0x56, 0x40}, | ||
1754 | {0x57, 0x40}, | ||
1755 | {0x58, 0x0d}, /* matrix sign */ | ||
1756 | {0x8b, 0xcc}, /* RSVD */ | ||
1757 | {0x8c, 0xcc}, | ||
1758 | {0x8d, 0xcf}, | ||
1759 | {0x6c, 0x40}, /* gamma curve */ | ||
1760 | {0x6d, 0xe0}, | ||
1761 | {0x6e, 0xa0}, | ||
1762 | {0x6f, 0x80}, | ||
1763 | {0x70, 0x70}, | ||
1764 | {0x71, 0x80}, | ||
1765 | {0x72, 0x60}, | ||
1766 | {0x73, 0x60}, | ||
1767 | {0x74, 0x50}, | ||
1768 | {0x75, 0x40}, | ||
1769 | {0x76, 0x38}, | ||
1770 | {0x77, 0x3c}, | ||
1771 | {0x78, 0x32}, | ||
1772 | {0x79, 0x1a}, | ||
1773 | {0x7a, 0x28}, | ||
1774 | {0x7b, 0x24}, | ||
1775 | {0x7c, 0x04}, /* gamma curve */ | ||
1776 | {0x7d, 0x12}, | ||
1777 | {0x7e, 0x26}, | ||
1778 | {0x7f, 0x46}, | ||
1779 | {0x80, 0x54}, | ||
1780 | {0x81, 0x64}, | ||
1781 | {0x82, 0x70}, | ||
1782 | {0x83, 0x7c}, | ||
1783 | {0x84, 0x86}, | ||
1784 | {0x85, 0x8e}, | ||
1785 | {0x86, 0x9c}, | ||
1786 | {0x87, 0xab}, | ||
1787 | {0x88, 0xc4}, | ||
1788 | {0x89, 0xd1}, | ||
1789 | {0x8a, 0xe5}, | ||
1790 | {OV7670_R14_COM9, 0x1e}, | ||
1791 | {OV7670_R24_AEW, 0x80}, | ||
1792 | {OV7670_R25_AEB, 0x72}, | ||
1793 | {OV7670_R26_VPT, 0xb3}, | ||
1794 | {0x62, 0x80}, /* LCC1 */ | ||
1795 | {0x63, 0x80}, /* LCC2 */ | ||
1796 | {0x64, 0x06}, /* LCC3 */ | ||
1797 | {0x65, 0x00}, /* LCC4 */ | ||
1798 | {0x66, 0x01}, /* LCC5 */ | ||
1799 | {0x94, 0x0e}, /* RSVD.. */ | ||
1800 | {0x95, 0x14}, | ||
1801 | {OV7670_R13_COM8, OV7670_COM8_FASTAEC | ||
1802 | | OV7670_COM8_AECSTEP | ||
1803 | | OV7670_COM8_BFILT | ||
1804 | | 0x10 | ||
1805 | | OV7670_COM8_AGC | ||
1806 | | OV7670_COM8_AWB | ||
1807 | | OV7670_COM8_AEC}, | ||
1808 | {0xa1, 0xc8} | ||
1809 | }; | ||
1810 | |||
1578 | /* 7670. Defaults taken from OmniVision provided data, | 1811 | /* 7670. Defaults taken from OmniVision provided data, |
1579 | * as provided by Jonathan Corbet of OLPC */ | 1812 | * as provided by Jonathan Corbet of OLPC */ |
1580 | static const struct ov_i2c_regvals norm_7670[] = { | 1813 | static const struct ov_i2c_regvals norm_7670[] = { |
1581 | { OV7670_REG_COM7, OV7670_COM7_RESET }, | 1814 | { OV7670_R12_COM7, OV7670_COM7_RESET }, |
1582 | { OV7670_REG_TSLB, 0x04 }, /* OV */ | 1815 | { OV7670_R3A_TSLB, 0x04 }, /* OV */ |
1583 | { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ | 1816 | { OV7670_R12_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ |
1584 | { OV7670_REG_CLKRC, 0x01 }, | 1817 | { OV7670_R11_CLKRC, 0x01 }, |
1585 | /* | 1818 | /* |
1586 | * Set the hardware window. These values from OV don't entirely | 1819 | * Set the hardware window. These values from OV don't entirely |
1587 | * make sense - hstop is less than hstart. But they work... | 1820 | * make sense - hstop is less than hstart. But they work... |
1588 | */ | 1821 | */ |
1589 | { OV7670_REG_HSTART, 0x13 }, | 1822 | { OV7670_R17_HSTART, 0x13 }, |
1590 | { OV7670_REG_HSTOP, 0x01 }, | 1823 | { OV7670_R18_HSTOP, 0x01 }, |
1591 | { OV7670_REG_HREF, 0xb6 }, | 1824 | { OV7670_R32_HREF, 0xb6 }, |
1592 | { OV7670_REG_VSTART, 0x02 }, | 1825 | { OV7670_R19_VSTART, 0x02 }, |
1593 | { OV7670_REG_VSTOP, 0x7a }, | 1826 | { OV7670_R1A_VSTOP, 0x7a }, |
1594 | { OV7670_REG_VREF, 0x0a }, | 1827 | { OV7670_R03_VREF, 0x0a }, |
1595 | 1828 | ||
1596 | { OV7670_REG_COM3, 0x00 }, | 1829 | { OV7670_R0C_COM3, 0x00 }, |
1597 | { OV7670_REG_COM14, 0x00 }, | 1830 | { OV7670_R3E_COM14, 0x00 }, |
1598 | /* Mystery scaling numbers */ | 1831 | /* Mystery scaling numbers */ |
1599 | { 0x70, 0x3a }, | 1832 | { 0x70, 0x3a }, |
1600 | { 0x71, 0x35 }, | 1833 | { 0x71, 0x35 }, |
1601 | { 0x72, 0x11 }, | 1834 | { 0x72, 0x11 }, |
1602 | { 0x73, 0xf0 }, | 1835 | { 0x73, 0xf0 }, |
1603 | { 0xa2, 0x02 }, | 1836 | { 0xa2, 0x02 }, |
1604 | /* { OV7670_REG_COM10, 0x0 }, */ | 1837 | /* { OV7670_R15_COM10, 0x0 }, */ |
1605 | 1838 | ||
1606 | /* Gamma curve values */ | 1839 | /* Gamma curve values */ |
1607 | { 0x7a, 0x20 }, | 1840 | { 0x7a, 0x20 }, |
@@ -1623,37 +1856,37 @@ static const struct ov_i2c_regvals norm_7670[] = { | |||
1623 | 1856 | ||
1624 | /* AGC and AEC parameters. Note we start by disabling those features, | 1857 | /* AGC and AEC parameters. Note we start by disabling those features, |
1625 | then turn them only after tweaking the values. */ | 1858 | then turn them only after tweaking the values. */ |
1626 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | 1859 | { OV7670_R13_COM8, OV7670_COM8_FASTAEC |
1627 | | OV7670_COM8_AECSTEP | 1860 | | OV7670_COM8_AECSTEP |
1628 | | OV7670_COM8_BFILT }, | 1861 | | OV7670_COM8_BFILT }, |
1629 | { OV7670_REG_GAIN, 0x00 }, | 1862 | { OV7670_R00_GAIN, 0x00 }, |
1630 | { OV7670_REG_AECH, 0x00 }, | 1863 | { OV7670_R10_AECH, 0x00 }, |
1631 | { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */ | 1864 | { OV7670_R0D_COM4, 0x40 }, /* magic reserved bit */ |
1632 | { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ | 1865 | { OV7670_R14_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ |
1633 | { OV7670_REG_BD50MAX, 0x05 }, | 1866 | { OV7670_RA5_BD50MAX, 0x05 }, |
1634 | { OV7670_REG_BD60MAX, 0x07 }, | 1867 | { OV7670_RAB_BD60MAX, 0x07 }, |
1635 | { OV7670_REG_AEW, 0x95 }, | 1868 | { OV7670_R24_AEW, 0x95 }, |
1636 | { OV7670_REG_AEB, 0x33 }, | 1869 | { OV7670_R25_AEB, 0x33 }, |
1637 | { OV7670_REG_VPT, 0xe3 }, | 1870 | { OV7670_R26_VPT, 0xe3 }, |
1638 | { OV7670_REG_HAECC1, 0x78 }, | 1871 | { OV7670_R9F_HAECC1, 0x78 }, |
1639 | { OV7670_REG_HAECC2, 0x68 }, | 1872 | { OV7670_RA0_HAECC2, 0x68 }, |
1640 | { 0xa1, 0x03 }, /* magic */ | 1873 | { 0xa1, 0x03 }, /* magic */ |
1641 | { OV7670_REG_HAECC3, 0xd8 }, | 1874 | { OV7670_RA6_HAECC3, 0xd8 }, |
1642 | { OV7670_REG_HAECC4, 0xd8 }, | 1875 | { OV7670_RA7_HAECC4, 0xd8 }, |
1643 | { OV7670_REG_HAECC5, 0xf0 }, | 1876 | { OV7670_RA8_HAECC5, 0xf0 }, |
1644 | { OV7670_REG_HAECC6, 0x90 }, | 1877 | { OV7670_RA9_HAECC6, 0x90 }, |
1645 | { OV7670_REG_HAECC7, 0x94 }, | 1878 | { OV7670_RAA_HAECC7, 0x94 }, |
1646 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | 1879 | { OV7670_R13_COM8, OV7670_COM8_FASTAEC |
1647 | | OV7670_COM8_AECSTEP | 1880 | | OV7670_COM8_AECSTEP |
1648 | | OV7670_COM8_BFILT | 1881 | | OV7670_COM8_BFILT |
1649 | | OV7670_COM8_AGC | 1882 | | OV7670_COM8_AGC |
1650 | | OV7670_COM8_AEC }, | 1883 | | OV7670_COM8_AEC }, |
1651 | 1884 | ||
1652 | /* Almost all of these are magic "reserved" values. */ | 1885 | /* Almost all of these are magic "reserved" values. */ |
1653 | { OV7670_REG_COM5, 0x61 }, | 1886 | { OV7670_R0E_COM5, 0x61 }, |
1654 | { OV7670_REG_COM6, 0x4b }, | 1887 | { OV7670_R0F_COM6, 0x4b }, |
1655 | { 0x16, 0x02 }, | 1888 | { 0x16, 0x02 }, |
1656 | { OV7670_REG_MVFP, 0x07 }, | 1889 | { OV7670_R1E_MVFP, 0x07 }, |
1657 | { 0x21, 0x02 }, | 1890 | { 0x21, 0x02 }, |
1658 | { 0x22, 0x91 }, | 1891 | { 0x22, 0x91 }, |
1659 | { 0x29, 0x07 }, | 1892 | { 0x29, 0x07 }, |
@@ -1662,10 +1895,10 @@ static const struct ov_i2c_regvals norm_7670[] = { | |||
1662 | { 0x37, 0x1d }, | 1895 | { 0x37, 0x1d }, |
1663 | { 0x38, 0x71 }, | 1896 | { 0x38, 0x71 }, |
1664 | { 0x39, 0x2a }, | 1897 | { 0x39, 0x2a }, |
1665 | { OV7670_REG_COM12, 0x78 }, | 1898 | { OV7670_R3C_COM12, 0x78 }, |
1666 | { 0x4d, 0x40 }, | 1899 | { 0x4d, 0x40 }, |
1667 | { 0x4e, 0x20 }, | 1900 | { 0x4e, 0x20 }, |
1668 | { OV7670_REG_GFIX, 0x00 }, | 1901 | { OV7670_R69_GFIX, 0x00 }, |
1669 | { 0x6b, 0x4a }, | 1902 | { 0x6b, 0x4a }, |
1670 | { 0x74, 0x10 }, | 1903 | { 0x74, 0x10 }, |
1671 | { 0x8d, 0x4f }, | 1904 | { 0x8d, 0x4f }, |
@@ -1697,12 +1930,11 @@ static const struct ov_i2c_regvals norm_7670[] = { | |||
1697 | { 0x6c, 0x0a }, | 1930 | { 0x6c, 0x0a }, |
1698 | { 0x6d, 0x55 }, | 1931 | { 0x6d, 0x55 }, |
1699 | { 0x6e, 0x11 }, | 1932 | { 0x6e, 0x11 }, |
1700 | { 0x6f, 0x9f }, | 1933 | { 0x6f, 0x9f }, /* "9e for advance AWB" */ |
1701 | /* "9e for advance AWB" */ | ||
1702 | { 0x6a, 0x40 }, | 1934 | { 0x6a, 0x40 }, |
1703 | { OV7670_REG_BLUE, 0x40 }, | 1935 | { OV7670_R01_BLUE, 0x40 }, |
1704 | { OV7670_REG_RED, 0x60 }, | 1936 | { OV7670_R02_RED, 0x60 }, |
1705 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | 1937 | { OV7670_R13_COM8, OV7670_COM8_FASTAEC |
1706 | | OV7670_COM8_AECSTEP | 1938 | | OV7670_COM8_AECSTEP |
1707 | | OV7670_COM8_BFILT | 1939 | | OV7670_COM8_BFILT |
1708 | | OV7670_COM8_AGC | 1940 | | OV7670_COM8_AGC |
@@ -1718,22 +1950,22 @@ static const struct ov_i2c_regvals norm_7670[] = { | |||
1718 | { 0x54, 0x80 }, | 1950 | { 0x54, 0x80 }, |
1719 | { 0x58, 0x9e }, | 1951 | { 0x58, 0x9e }, |
1720 | 1952 | ||
1721 | { OV7670_REG_COM16, OV7670_COM16_AWBGAIN }, | 1953 | { OV7670_R41_COM16, OV7670_COM16_AWBGAIN }, |
1722 | { OV7670_REG_EDGE, 0x00 }, | 1954 | { OV7670_R3F_EDGE, 0x00 }, |
1723 | { 0x75, 0x05 }, | 1955 | { 0x75, 0x05 }, |
1724 | { 0x76, 0xe1 }, | 1956 | { 0x76, 0xe1 }, |
1725 | { 0x4c, 0x00 }, | 1957 | { 0x4c, 0x00 }, |
1726 | { 0x77, 0x01 }, | 1958 | { 0x77, 0x01 }, |
1727 | { OV7670_REG_COM13, OV7670_COM13_GAMMA | 1959 | { OV7670_R3D_COM13, OV7670_COM13_GAMMA |
1728 | | OV7670_COM13_UVSAT | 1960 | | OV7670_COM13_UVSAT |
1729 | | 2}, /* was 3 */ | 1961 | | 2}, /* was 3 */ |
1730 | { 0x4b, 0x09 }, | 1962 | { 0x4b, 0x09 }, |
1731 | { 0xc9, 0x60 }, | 1963 | { 0xc9, 0x60 }, |
1732 | { OV7670_REG_COM16, 0x38 }, | 1964 | { OV7670_R41_COM16, 0x38 }, |
1733 | { 0x56, 0x40 }, | 1965 | { 0x56, 0x40 }, |
1734 | 1966 | ||
1735 | { 0x34, 0x11 }, | 1967 | { 0x34, 0x11 }, |
1736 | { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, | 1968 | { OV7670_R3B_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, |
1737 | { 0xa4, 0x88 }, | 1969 | { 0xa4, 0x88 }, |
1738 | { 0x96, 0x00 }, | 1970 | { 0x96, 0x00 }, |
1739 | { 0x97, 0x30 }, | 1971 | { 0x97, 0x30 }, |
@@ -1868,10 +2100,13 @@ static unsigned char ov7670_abs_to_sm(unsigned char v) | |||
1868 | } | 2100 | } |
1869 | 2101 | ||
1870 | /* Write a OV519 register */ | 2102 | /* Write a OV519 register */ |
1871 | static int reg_w(struct sd *sd, __u16 index, __u16 value) | 2103 | static void reg_w(struct sd *sd, u16 index, u16 value) |
1872 | { | 2104 | { |
1873 | int ret, req = 0; | 2105 | int ret, req = 0; |
1874 | 2106 | ||
2107 | if (sd->gspca_dev.usb_err < 0) | ||
2108 | return; | ||
2109 | |||
1875 | switch (sd->bridge) { | 2110 | switch (sd->bridge) { |
1876 | case BRIDGE_OV511: | 2111 | case BRIDGE_OV511: |
1877 | case BRIDGE_OV511PLUS: | 2112 | case BRIDGE_OV511PLUS: |
@@ -1881,6 +2116,8 @@ static int reg_w(struct sd *sd, __u16 index, __u16 value) | |||
1881 | req = 0x0a; | 2116 | req = 0x0a; |
1882 | /* fall through */ | 2117 | /* fall through */ |
1883 | case BRIDGE_W9968CF: | 2118 | case BRIDGE_W9968CF: |
2119 | PDEBUG(D_USBO, "SET %02x %04x %04x", | ||
2120 | req, value, index); | ||
1884 | ret = usb_control_msg(sd->gspca_dev.dev, | 2121 | ret = usb_control_msg(sd->gspca_dev.dev, |
1885 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), | 2122 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), |
1886 | req, | 2123 | req, |
@@ -1891,6 +2128,8 @@ static int reg_w(struct sd *sd, __u16 index, __u16 value) | |||
1891 | req = 1; | 2128 | req = 1; |
1892 | } | 2129 | } |
1893 | 2130 | ||
2131 | PDEBUG(D_USBO, "SET %02x 0000 %04x %02x", | ||
2132 | req, index, value); | ||
1894 | sd->gspca_dev.usb_buf[0] = value; | 2133 | sd->gspca_dev.usb_buf[0] = value; |
1895 | ret = usb_control_msg(sd->gspca_dev.dev, | 2134 | ret = usb_control_msg(sd->gspca_dev.dev, |
1896 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), | 2135 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), |
@@ -1900,22 +2139,22 @@ static int reg_w(struct sd *sd, __u16 index, __u16 value) | |||
1900 | sd->gspca_dev.usb_buf, 1, 500); | 2139 | sd->gspca_dev.usb_buf, 1, 500); |
1901 | leave: | 2140 | leave: |
1902 | if (ret < 0) { | 2141 | if (ret < 0) { |
1903 | PDEBUG(D_ERR, "Write reg 0x%04x -> [0x%02x] failed", | 2142 | err("reg_w %02x failed %d", index, ret); |
1904 | value, index); | 2143 | sd->gspca_dev.usb_err = ret; |
1905 | return ret; | 2144 | return; |
1906 | } | 2145 | } |
1907 | |||
1908 | PDEBUG(D_USBO, "Write reg 0x%04x -> [0x%02x]", value, index); | ||
1909 | return 0; | ||
1910 | } | 2146 | } |
1911 | 2147 | ||
1912 | /* Read from a OV519 register, note not valid for the w9968cf!! */ | 2148 | /* Read from a OV519 register, note not valid for the w9968cf!! */ |
1913 | /* returns: negative is error, pos or zero is data */ | 2149 | /* returns: negative is error, pos or zero is data */ |
1914 | static int reg_r(struct sd *sd, __u16 index) | 2150 | static int reg_r(struct sd *sd, u16 index) |
1915 | { | 2151 | { |
1916 | int ret; | 2152 | int ret; |
1917 | int req; | 2153 | int req; |
1918 | 2154 | ||
2155 | if (sd->gspca_dev.usb_err < 0) | ||
2156 | return -1; | ||
2157 | |||
1919 | switch (sd->bridge) { | 2158 | switch (sd->bridge) { |
1920 | case BRIDGE_OV511: | 2159 | case BRIDGE_OV511: |
1921 | case BRIDGE_OV511PLUS: | 2160 | case BRIDGE_OV511PLUS: |
@@ -1936,29 +2175,37 @@ static int reg_r(struct sd *sd, __u16 index) | |||
1936 | 2175 | ||
1937 | if (ret >= 0) { | 2176 | if (ret >= 0) { |
1938 | ret = sd->gspca_dev.usb_buf[0]; | 2177 | ret = sd->gspca_dev.usb_buf[0]; |
1939 | PDEBUG(D_USBI, "Read reg [0x%02X] -> 0x%04X", index, ret); | 2178 | PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", |
1940 | } else | 2179 | req, index, ret); |
1941 | PDEBUG(D_ERR, "Read reg [0x%02x] failed", index); | 2180 | } else { |
2181 | err("reg_r %02x failed %d", index, ret); | ||
2182 | sd->gspca_dev.usb_err = ret; | ||
2183 | } | ||
1942 | 2184 | ||
1943 | return ret; | 2185 | return ret; |
1944 | } | 2186 | } |
1945 | 2187 | ||
1946 | /* Read 8 values from a OV519 register */ | 2188 | /* Read 8 values from a OV519 register */ |
1947 | static int reg_r8(struct sd *sd, | 2189 | static int reg_r8(struct sd *sd, |
1948 | __u16 index) | 2190 | u16 index) |
1949 | { | 2191 | { |
1950 | int ret; | 2192 | int ret; |
1951 | 2193 | ||
2194 | if (sd->gspca_dev.usb_err < 0) | ||
2195 | return -1; | ||
2196 | |||
1952 | ret = usb_control_msg(sd->gspca_dev.dev, | 2197 | ret = usb_control_msg(sd->gspca_dev.dev, |
1953 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), | 2198 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), |
1954 | 1, /* REQ_IO */ | 2199 | 1, /* REQ_IO */ |
1955 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 2200 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
1956 | 0, index, sd->gspca_dev.usb_buf, 8, 500); | 2201 | 0, index, sd->gspca_dev.usb_buf, 8, 500); |
1957 | 2202 | ||
1958 | if (ret >= 0) | 2203 | if (ret >= 0) { |
1959 | ret = sd->gspca_dev.usb_buf[0]; | 2204 | ret = sd->gspca_dev.usb_buf[0]; |
1960 | else | 2205 | } else { |
1961 | PDEBUG(D_ERR, "Read reg 8 [0x%02x] failed", index); | 2206 | err("reg_r8 %02x failed %d", index, ret); |
2207 | sd->gspca_dev.usb_err = ret; | ||
2208 | } | ||
1962 | 2209 | ||
1963 | return ret; | 2210 | return ret; |
1964 | } | 2211 | } |
@@ -1969,34 +2216,37 @@ static int reg_r8(struct sd *sd, | |||
1969 | * that are in the same position as 0's in "mask" are preserved, regardless | 2216 | * that are in the same position as 0's in "mask" are preserved, regardless |
1970 | * of their respective state in "value". | 2217 | * of their respective state in "value". |
1971 | */ | 2218 | */ |
1972 | static int reg_w_mask(struct sd *sd, | 2219 | static void reg_w_mask(struct sd *sd, |
1973 | __u16 index, | 2220 | u16 index, |
1974 | __u8 value, | 2221 | u8 value, |
1975 | __u8 mask) | 2222 | u8 mask) |
1976 | { | 2223 | { |
1977 | int ret; | 2224 | int ret; |
1978 | __u8 oldval; | 2225 | u8 oldval; |
1979 | 2226 | ||
1980 | if (mask != 0xff) { | 2227 | if (mask != 0xff) { |
1981 | value &= mask; /* Enforce mask on value */ | 2228 | value &= mask; /* Enforce mask on value */ |
1982 | ret = reg_r(sd, index); | 2229 | ret = reg_r(sd, index); |
1983 | if (ret < 0) | 2230 | if (ret < 0) |
1984 | return ret; | 2231 | return; |
1985 | 2232 | ||
1986 | oldval = ret & ~mask; /* Clear the masked bits */ | 2233 | oldval = ret & ~mask; /* Clear the masked bits */ |
1987 | value |= oldval; /* Set the desired bits */ | 2234 | value |= oldval; /* Set the desired bits */ |
1988 | } | 2235 | } |
1989 | return reg_w(sd, index, value); | 2236 | reg_w(sd, index, value); |
1990 | } | 2237 | } |
1991 | 2238 | ||
1992 | /* | 2239 | /* |
1993 | * Writes multiple (n) byte value to a single register. Only valid with certain | 2240 | * Writes multiple (n) byte value to a single register. Only valid with certain |
1994 | * registers (0x30 and 0xc4 - 0xce). | 2241 | * registers (0x30 and 0xc4 - 0xce). |
1995 | */ | 2242 | */ |
1996 | static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n) | 2243 | static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) |
1997 | { | 2244 | { |
1998 | int ret; | 2245 | int ret; |
1999 | 2246 | ||
2247 | if (sd->gspca_dev.usb_err < 0) | ||
2248 | return; | ||
2249 | |||
2000 | *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); | 2250 | *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); |
2001 | 2251 | ||
2002 | ret = usb_control_msg(sd->gspca_dev.dev, | 2252 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -2006,69 +2256,55 @@ static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n) | |||
2006 | 0, index, | 2256 | 0, index, |
2007 | sd->gspca_dev.usb_buf, n, 500); | 2257 | sd->gspca_dev.usb_buf, n, 500); |
2008 | if (ret < 0) { | 2258 | if (ret < 0) { |
2009 | PDEBUG(D_ERR, "Write reg32 [%02x] %08x failed", index, value); | 2259 | err("reg_w32 %02x failed %d", index, ret); |
2010 | return ret; | 2260 | sd->gspca_dev.usb_err = ret; |
2011 | } | 2261 | } |
2012 | |||
2013 | return 0; | ||
2014 | } | 2262 | } |
2015 | 2263 | ||
2016 | static int ov511_i2c_w(struct sd *sd, __u8 reg, __u8 value) | 2264 | static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) |
2017 | { | 2265 | { |
2018 | int rc, retries; | 2266 | int rc, retries; |
2019 | 2267 | ||
2020 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | 2268 | PDEBUG(D_USBO, "ov511_i2c_w %02x %02x", reg, value); |
2021 | 2269 | ||
2022 | /* Three byte write cycle */ | 2270 | /* Three byte write cycle */ |
2023 | for (retries = 6; ; ) { | 2271 | for (retries = 6; ; ) { |
2024 | /* Select camera register */ | 2272 | /* Select camera register */ |
2025 | rc = reg_w(sd, R51x_I2C_SADDR_3, reg); | 2273 | reg_w(sd, R51x_I2C_SADDR_3, reg); |
2026 | if (rc < 0) | ||
2027 | return rc; | ||
2028 | 2274 | ||
2029 | /* Write "value" to I2C data port of OV511 */ | 2275 | /* Write "value" to I2C data port of OV511 */ |
2030 | rc = reg_w(sd, R51x_I2C_DATA, value); | 2276 | reg_w(sd, R51x_I2C_DATA, value); |
2031 | if (rc < 0) | ||
2032 | return rc; | ||
2033 | 2277 | ||
2034 | /* Initiate 3-byte write cycle */ | 2278 | /* Initiate 3-byte write cycle */ |
2035 | rc = reg_w(sd, R511_I2C_CTL, 0x01); | 2279 | reg_w(sd, R511_I2C_CTL, 0x01); |
2036 | if (rc < 0) | ||
2037 | return rc; | ||
2038 | 2280 | ||
2039 | do { | 2281 | do { |
2040 | rc = reg_r(sd, R511_I2C_CTL); | 2282 | rc = reg_r(sd, R511_I2C_CTL); |
2041 | } while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ | 2283 | } while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ |
2042 | 2284 | ||
2043 | if (rc < 0) | 2285 | if (rc < 0) |
2044 | return rc; | 2286 | return; |
2045 | 2287 | ||
2046 | if ((rc & 2) == 0) /* Ack? */ | 2288 | if ((rc & 2) == 0) /* Ack? */ |
2047 | break; | 2289 | break; |
2048 | if (--retries < 0) { | 2290 | if (--retries < 0) { |
2049 | PDEBUG(D_USBO, "i2c write retries exhausted"); | 2291 | PDEBUG(D_USBO, "i2c write retries exhausted"); |
2050 | return -1; | 2292 | return; |
2051 | } | 2293 | } |
2052 | } | 2294 | } |
2053 | |||
2054 | return 0; | ||
2055 | } | 2295 | } |
2056 | 2296 | ||
2057 | static int ov511_i2c_r(struct sd *sd, __u8 reg) | 2297 | static int ov511_i2c_r(struct sd *sd, u8 reg) |
2058 | { | 2298 | { |
2059 | int rc, value, retries; | 2299 | int rc, value, retries; |
2060 | 2300 | ||
2061 | /* Two byte write cycle */ | 2301 | /* Two byte write cycle */ |
2062 | for (retries = 6; ; ) { | 2302 | for (retries = 6; ; ) { |
2063 | /* Select camera register */ | 2303 | /* Select camera register */ |
2064 | rc = reg_w(sd, R51x_I2C_SADDR_2, reg); | 2304 | reg_w(sd, R51x_I2C_SADDR_2, reg); |
2065 | if (rc < 0) | ||
2066 | return rc; | ||
2067 | 2305 | ||
2068 | /* Initiate 2-byte write cycle */ | 2306 | /* Initiate 2-byte write cycle */ |
2069 | rc = reg_w(sd, R511_I2C_CTL, 0x03); | 2307 | reg_w(sd, R511_I2C_CTL, 0x03); |
2070 | if (rc < 0) | ||
2071 | return rc; | ||
2072 | 2308 | ||
2073 | do { | 2309 | do { |
2074 | rc = reg_r(sd, R511_I2C_CTL); | 2310 | rc = reg_r(sd, R511_I2C_CTL); |
@@ -2092,9 +2328,7 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg) | |||
2092 | /* Two byte read cycle */ | 2328 | /* Two byte read cycle */ |
2093 | for (retries = 6; ; ) { | 2329 | for (retries = 6; ; ) { |
2094 | /* Initiate 2-byte read cycle */ | 2330 | /* Initiate 2-byte read cycle */ |
2095 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | 2331 | reg_w(sd, R511_I2C_CTL, 0x05); |
2096 | if (rc < 0) | ||
2097 | return rc; | ||
2098 | 2332 | ||
2099 | do { | 2333 | do { |
2100 | rc = reg_r(sd, R511_I2C_CTL); | 2334 | rc = reg_r(sd, R511_I2C_CTL); |
@@ -2107,9 +2341,7 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg) | |||
2107 | break; | 2341 | break; |
2108 | 2342 | ||
2109 | /* I2C abort */ | 2343 | /* I2C abort */ |
2110 | rc = reg_w(sd, R511_I2C_CTL, 0x10); | 2344 | reg_w(sd, R511_I2C_CTL, 0x10); |
2111 | if (rc < 0) | ||
2112 | return rc; | ||
2113 | 2345 | ||
2114 | if (--retries < 0) { | 2346 | if (--retries < 0) { |
2115 | PDEBUG(D_USBI, "i2c read retries exhausted"); | 2347 | PDEBUG(D_USBI, "i2c read retries exhausted"); |
@@ -2119,12 +2351,10 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg) | |||
2119 | 2351 | ||
2120 | value = reg_r(sd, R51x_I2C_DATA); | 2352 | value = reg_r(sd, R51x_I2C_DATA); |
2121 | 2353 | ||
2122 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 2354 | PDEBUG(D_USBI, "ov511_i2c_r %02x %02x", reg, value); |
2123 | 2355 | ||
2124 | /* This is needed to make i2c_w() work */ | 2356 | /* This is needed to make i2c_w() work */ |
2125 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | 2357 | reg_w(sd, R511_I2C_CTL, 0x05); |
2126 | if (rc < 0) | ||
2127 | return rc; | ||
2128 | 2358 | ||
2129 | return value; | 2359 | return value; |
2130 | } | 2360 | } |
@@ -2134,32 +2364,24 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg) | |||
2134 | * This is normally only called from i2c_w(). Note that this function | 2364 | * This is normally only called from i2c_w(). Note that this function |
2135 | * always succeeds regardless of whether the sensor is present and working. | 2365 | * always succeeds regardless of whether the sensor is present and working. |
2136 | */ | 2366 | */ |
2137 | static int ov518_i2c_w(struct sd *sd, | 2367 | static void ov518_i2c_w(struct sd *sd, |
2138 | __u8 reg, | 2368 | u8 reg, |
2139 | __u8 value) | 2369 | u8 value) |
2140 | { | 2370 | { |
2141 | int rc; | 2371 | PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value); |
2142 | |||
2143 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | ||
2144 | 2372 | ||
2145 | /* Select camera register */ | 2373 | /* Select camera register */ |
2146 | rc = reg_w(sd, R51x_I2C_SADDR_3, reg); | 2374 | reg_w(sd, R51x_I2C_SADDR_3, reg); |
2147 | if (rc < 0) | ||
2148 | return rc; | ||
2149 | 2375 | ||
2150 | /* Write "value" to I2C data port of OV511 */ | 2376 | /* Write "value" to I2C data port of OV511 */ |
2151 | rc = reg_w(sd, R51x_I2C_DATA, value); | 2377 | reg_w(sd, R51x_I2C_DATA, value); |
2152 | if (rc < 0) | ||
2153 | return rc; | ||
2154 | 2378 | ||
2155 | /* Initiate 3-byte write cycle */ | 2379 | /* Initiate 3-byte write cycle */ |
2156 | rc = reg_w(sd, R518_I2C_CTL, 0x01); | 2380 | reg_w(sd, R518_I2C_CTL, 0x01); |
2157 | if (rc < 0) | ||
2158 | return rc; | ||
2159 | 2381 | ||
2160 | /* wait for write complete */ | 2382 | /* wait for write complete */ |
2161 | msleep(4); | 2383 | msleep(4); |
2162 | return reg_r8(sd, R518_I2C_CTL); | 2384 | reg_r8(sd, R518_I2C_CTL); |
2163 | } | 2385 | } |
2164 | 2386 | ||
2165 | /* | 2387 | /* |
@@ -2169,105 +2391,102 @@ static int ov518_i2c_w(struct sd *sd, | |||
2169 | * This is normally only called from i2c_r(). Note that this function | 2391 | * This is normally only called from i2c_r(). Note that this function |
2170 | * always succeeds regardless of whether the sensor is present and working. | 2392 | * always succeeds regardless of whether the sensor is present and working. |
2171 | */ | 2393 | */ |
2172 | static int ov518_i2c_r(struct sd *sd, __u8 reg) | 2394 | static int ov518_i2c_r(struct sd *sd, u8 reg) |
2173 | { | 2395 | { |
2174 | int rc, value; | 2396 | int value; |
2175 | 2397 | ||
2176 | /* Select camera register */ | 2398 | /* Select camera register */ |
2177 | rc = reg_w(sd, R51x_I2C_SADDR_2, reg); | 2399 | reg_w(sd, R51x_I2C_SADDR_2, reg); |
2178 | if (rc < 0) | ||
2179 | return rc; | ||
2180 | 2400 | ||
2181 | /* Initiate 2-byte write cycle */ | 2401 | /* Initiate 2-byte write cycle */ |
2182 | rc = reg_w(sd, R518_I2C_CTL, 0x03); | 2402 | reg_w(sd, R518_I2C_CTL, 0x03); |
2183 | if (rc < 0) | ||
2184 | return rc; | ||
2185 | 2403 | ||
2186 | /* Initiate 2-byte read cycle */ | 2404 | /* Initiate 2-byte read cycle */ |
2187 | rc = reg_w(sd, R518_I2C_CTL, 0x05); | 2405 | reg_w(sd, R518_I2C_CTL, 0x05); |
2188 | if (rc < 0) | ||
2189 | return rc; | ||
2190 | value = reg_r(sd, R51x_I2C_DATA); | 2406 | value = reg_r(sd, R51x_I2C_DATA); |
2191 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 2407 | PDEBUG(D_USBI, "ov518_i2c_r %02x %02x", reg, value); |
2192 | return value; | 2408 | return value; |
2193 | } | 2409 | } |
2194 | 2410 | ||
2195 | static int ovfx2_i2c_w(struct sd *sd, __u8 reg, __u8 value) | 2411 | static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) |
2196 | { | 2412 | { |
2197 | int ret; | 2413 | int ret; |
2198 | 2414 | ||
2415 | if (sd->gspca_dev.usb_err < 0) | ||
2416 | return; | ||
2417 | |||
2199 | ret = usb_control_msg(sd->gspca_dev.dev, | 2418 | ret = usb_control_msg(sd->gspca_dev.dev, |
2200 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), | 2419 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), |
2201 | 0x02, | 2420 | 0x02, |
2202 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 2421 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
2203 | (__u16)value, (__u16)reg, NULL, 0, 500); | 2422 | (u16) value, (u16) reg, NULL, 0, 500); |
2204 | 2423 | ||
2205 | if (ret < 0) { | 2424 | if (ret < 0) { |
2206 | PDEBUG(D_ERR, "i2c 0x%02x -> [0x%02x] failed", value, reg); | 2425 | err("ovfx2_i2c_w %02x failed %d", reg, ret); |
2207 | return ret; | 2426 | sd->gspca_dev.usb_err = ret; |
2208 | } | 2427 | } |
2209 | 2428 | ||
2210 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | 2429 | PDEBUG(D_USBO, "ovfx2_i2c_w %02x %02x", reg, value); |
2211 | return 0; | ||
2212 | } | 2430 | } |
2213 | 2431 | ||
2214 | static int ovfx2_i2c_r(struct sd *sd, __u8 reg) | 2432 | static int ovfx2_i2c_r(struct sd *sd, u8 reg) |
2215 | { | 2433 | { |
2216 | int ret; | 2434 | int ret; |
2217 | 2435 | ||
2436 | if (sd->gspca_dev.usb_err < 0) | ||
2437 | return -1; | ||
2438 | |||
2218 | ret = usb_control_msg(sd->gspca_dev.dev, | 2439 | ret = usb_control_msg(sd->gspca_dev.dev, |
2219 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), | 2440 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), |
2220 | 0x03, | 2441 | 0x03, |
2221 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 2442 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
2222 | 0, (__u16)reg, sd->gspca_dev.usb_buf, 1, 500); | 2443 | 0, (u16) reg, sd->gspca_dev.usb_buf, 1, 500); |
2223 | 2444 | ||
2224 | if (ret >= 0) { | 2445 | if (ret >= 0) { |
2225 | ret = sd->gspca_dev.usb_buf[0]; | 2446 | ret = sd->gspca_dev.usb_buf[0]; |
2226 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, ret); | 2447 | PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret); |
2227 | } else | 2448 | } else { |
2228 | PDEBUG(D_ERR, "i2c read [0x%02x] failed", reg); | 2449 | err("ovfx2_i2c_r %02x failed %d", reg, ret); |
2450 | sd->gspca_dev.usb_err = ret; | ||
2451 | } | ||
2229 | 2452 | ||
2230 | return ret; | 2453 | return ret; |
2231 | } | 2454 | } |
2232 | 2455 | ||
2233 | static int i2c_w(struct sd *sd, __u8 reg, __u8 value) | 2456 | static void i2c_w(struct sd *sd, u8 reg, u8 value) |
2234 | { | 2457 | { |
2235 | int ret = -1; | ||
2236 | |||
2237 | if (sd->sensor_reg_cache[reg] == value) | 2458 | if (sd->sensor_reg_cache[reg] == value) |
2238 | return 0; | 2459 | return; |
2239 | 2460 | ||
2240 | switch (sd->bridge) { | 2461 | switch (sd->bridge) { |
2241 | case BRIDGE_OV511: | 2462 | case BRIDGE_OV511: |
2242 | case BRIDGE_OV511PLUS: | 2463 | case BRIDGE_OV511PLUS: |
2243 | ret = ov511_i2c_w(sd, reg, value); | 2464 | ov511_i2c_w(sd, reg, value); |
2244 | break; | 2465 | break; |
2245 | case BRIDGE_OV518: | 2466 | case BRIDGE_OV518: |
2246 | case BRIDGE_OV518PLUS: | 2467 | case BRIDGE_OV518PLUS: |
2247 | case BRIDGE_OV519: | 2468 | case BRIDGE_OV519: |
2248 | ret = ov518_i2c_w(sd, reg, value); | 2469 | ov518_i2c_w(sd, reg, value); |
2249 | break; | 2470 | break; |
2250 | case BRIDGE_OVFX2: | 2471 | case BRIDGE_OVFX2: |
2251 | ret = ovfx2_i2c_w(sd, reg, value); | 2472 | ovfx2_i2c_w(sd, reg, value); |
2252 | break; | 2473 | break; |
2253 | case BRIDGE_W9968CF: | 2474 | case BRIDGE_W9968CF: |
2254 | ret = w9968cf_i2c_w(sd, reg, value); | 2475 | w9968cf_i2c_w(sd, reg, value); |
2255 | break; | 2476 | break; |
2256 | } | 2477 | } |
2257 | 2478 | ||
2258 | if (ret >= 0) { | 2479 | if (sd->gspca_dev.usb_err >= 0) { |
2259 | /* Up on sensor reset empty the register cache */ | 2480 | /* Up on sensor reset empty the register cache */ |
2260 | if (reg == 0x12 && (value & 0x80)) | 2481 | if (reg == 0x12 && (value & 0x80)) |
2261 | memset(sd->sensor_reg_cache, -1, | 2482 | memset(sd->sensor_reg_cache, -1, |
2262 | sizeof(sd->sensor_reg_cache)); | 2483 | sizeof(sd->sensor_reg_cache)); |
2263 | else | 2484 | else |
2264 | sd->sensor_reg_cache[reg] = value; | 2485 | sd->sensor_reg_cache[reg] = value; |
2265 | } | 2486 | } |
2266 | |||
2267 | return ret; | ||
2268 | } | 2487 | } |
2269 | 2488 | ||
2270 | static int i2c_r(struct sd *sd, __u8 reg) | 2489 | static int i2c_r(struct sd *sd, u8 reg) |
2271 | { | 2490 | { |
2272 | int ret = -1; | 2491 | int ret = -1; |
2273 | 2492 | ||
@@ -2303,95 +2522,99 @@ static int i2c_r(struct sd *sd, __u8 reg) | |||
2303 | * that are in the same position as 0's in "mask" are preserved, regardless | 2522 | * that are in the same position as 0's in "mask" are preserved, regardless |
2304 | * of their respective state in "value". | 2523 | * of their respective state in "value". |
2305 | */ | 2524 | */ |
2306 | static int i2c_w_mask(struct sd *sd, | 2525 | static void i2c_w_mask(struct sd *sd, |
2307 | __u8 reg, | 2526 | u8 reg, |
2308 | __u8 value, | 2527 | u8 value, |
2309 | __u8 mask) | 2528 | u8 mask) |
2310 | { | 2529 | { |
2311 | int rc; | 2530 | int rc; |
2312 | __u8 oldval; | 2531 | u8 oldval; |
2313 | 2532 | ||
2314 | value &= mask; /* Enforce mask on value */ | 2533 | value &= mask; /* Enforce mask on value */ |
2315 | rc = i2c_r(sd, reg); | 2534 | rc = i2c_r(sd, reg); |
2316 | if (rc < 0) | 2535 | if (rc < 0) |
2317 | return rc; | 2536 | return; |
2318 | oldval = rc & ~mask; /* Clear the masked bits */ | 2537 | oldval = rc & ~mask; /* Clear the masked bits */ |
2319 | value |= oldval; /* Set the desired bits */ | 2538 | value |= oldval; /* Set the desired bits */ |
2320 | return i2c_w(sd, reg, value); | 2539 | i2c_w(sd, reg, value); |
2321 | } | 2540 | } |
2322 | 2541 | ||
2323 | /* Temporarily stops OV511 from functioning. Must do this before changing | 2542 | /* Temporarily stops OV511 from functioning. Must do this before changing |
2324 | * registers while the camera is streaming */ | 2543 | * registers while the camera is streaming */ |
2325 | static inline int ov51x_stop(struct sd *sd) | 2544 | static inline void ov51x_stop(struct sd *sd) |
2326 | { | 2545 | { |
2327 | PDEBUG(D_STREAM, "stopping"); | 2546 | PDEBUG(D_STREAM, "stopping"); |
2328 | sd->stopped = 1; | 2547 | sd->stopped = 1; |
2329 | switch (sd->bridge) { | 2548 | switch (sd->bridge) { |
2330 | case BRIDGE_OV511: | 2549 | case BRIDGE_OV511: |
2331 | case BRIDGE_OV511PLUS: | 2550 | case BRIDGE_OV511PLUS: |
2332 | return reg_w(sd, R51x_SYS_RESET, 0x3d); | 2551 | reg_w(sd, R51x_SYS_RESET, 0x3d); |
2552 | break; | ||
2333 | case BRIDGE_OV518: | 2553 | case BRIDGE_OV518: |
2334 | case BRIDGE_OV518PLUS: | 2554 | case BRIDGE_OV518PLUS: |
2335 | return reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a); | 2555 | reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a); |
2556 | break; | ||
2336 | case BRIDGE_OV519: | 2557 | case BRIDGE_OV519: |
2337 | return reg_w(sd, OV519_SYS_RESET1, 0x0f); | 2558 | reg_w(sd, OV519_R51_RESET1, 0x0f); |
2559 | reg_w(sd, OV519_R51_RESET1, 0x00); | ||
2560 | reg_w(sd, 0x22, 0x00); /* FRAR */ | ||
2561 | break; | ||
2338 | case BRIDGE_OVFX2: | 2562 | case BRIDGE_OVFX2: |
2339 | return reg_w_mask(sd, 0x0f, 0x00, 0x02); | 2563 | reg_w_mask(sd, 0x0f, 0x00, 0x02); |
2564 | break; | ||
2340 | case BRIDGE_W9968CF: | 2565 | case BRIDGE_W9968CF: |
2341 | return reg_w(sd, 0x3c, 0x0a05); /* stop USB transfer */ | 2566 | reg_w(sd, 0x3c, 0x0a05); /* stop USB transfer */ |
2567 | break; | ||
2342 | } | 2568 | } |
2343 | |||
2344 | return 0; | ||
2345 | } | 2569 | } |
2346 | 2570 | ||
2347 | /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not | 2571 | /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not |
2348 | * actually stopped (for performance). */ | 2572 | * actually stopped (for performance). */ |
2349 | static inline int ov51x_restart(struct sd *sd) | 2573 | static inline void ov51x_restart(struct sd *sd) |
2350 | { | 2574 | { |
2351 | int rc; | ||
2352 | |||
2353 | PDEBUG(D_STREAM, "restarting"); | 2575 | PDEBUG(D_STREAM, "restarting"); |
2354 | if (!sd->stopped) | 2576 | if (!sd->stopped) |
2355 | return 0; | 2577 | return; |
2356 | sd->stopped = 0; | 2578 | sd->stopped = 0; |
2357 | 2579 | ||
2358 | /* Reinitialize the stream */ | 2580 | /* Reinitialize the stream */ |
2359 | switch (sd->bridge) { | 2581 | switch (sd->bridge) { |
2360 | case BRIDGE_OV511: | 2582 | case BRIDGE_OV511: |
2361 | case BRIDGE_OV511PLUS: | 2583 | case BRIDGE_OV511PLUS: |
2362 | return reg_w(sd, R51x_SYS_RESET, 0x00); | 2584 | reg_w(sd, R51x_SYS_RESET, 0x00); |
2585 | break; | ||
2363 | case BRIDGE_OV518: | 2586 | case BRIDGE_OV518: |
2364 | case BRIDGE_OV518PLUS: | 2587 | case BRIDGE_OV518PLUS: |
2365 | rc = reg_w(sd, 0x2f, 0x80); | 2588 | reg_w(sd, 0x2f, 0x80); |
2366 | if (rc < 0) | 2589 | reg_w(sd, R51x_SYS_RESET, 0x00); |
2367 | return rc; | 2590 | break; |
2368 | return reg_w(sd, R51x_SYS_RESET, 0x00); | ||
2369 | case BRIDGE_OV519: | 2591 | case BRIDGE_OV519: |
2370 | return reg_w(sd, OV519_SYS_RESET1, 0x00); | 2592 | reg_w(sd, OV519_R51_RESET1, 0x0f); |
2593 | reg_w(sd, OV519_R51_RESET1, 0x00); | ||
2594 | reg_w(sd, 0x22, 0x1d); /* FRAR */ | ||
2595 | break; | ||
2371 | case BRIDGE_OVFX2: | 2596 | case BRIDGE_OVFX2: |
2372 | return reg_w_mask(sd, 0x0f, 0x02, 0x02); | 2597 | reg_w_mask(sd, 0x0f, 0x02, 0x02); |
2598 | break; | ||
2373 | case BRIDGE_W9968CF: | 2599 | case BRIDGE_W9968CF: |
2374 | return reg_w(sd, 0x3c, 0x8a05); /* USB FIFO enable */ | 2600 | reg_w(sd, 0x3c, 0x8a05); /* USB FIFO enable */ |
2601 | break; | ||
2375 | } | 2602 | } |
2376 | |||
2377 | return 0; | ||
2378 | } | 2603 | } |
2379 | 2604 | ||
2380 | static int ov51x_set_slave_ids(struct sd *sd, __u8 slave); | 2605 | static void ov51x_set_slave_ids(struct sd *sd, u8 slave); |
2381 | 2606 | ||
2382 | /* This does an initial reset of an OmniVision sensor and ensures that I2C | 2607 | /* This does an initial reset of an OmniVision sensor and ensures that I2C |
2383 | * is synchronized. Returns <0 on failure. | 2608 | * is synchronized. Returns <0 on failure. |
2384 | */ | 2609 | */ |
2385 | static int init_ov_sensor(struct sd *sd, __u8 slave) | 2610 | static int init_ov_sensor(struct sd *sd, u8 slave) |
2386 | { | 2611 | { |
2387 | int i; | 2612 | int i; |
2388 | 2613 | ||
2389 | if (ov51x_set_slave_ids(sd, slave) < 0) | 2614 | ov51x_set_slave_ids(sd, slave); |
2390 | return -EIO; | ||
2391 | 2615 | ||
2392 | /* Reset the sensor */ | 2616 | /* Reset the sensor */ |
2393 | if (i2c_w(sd, 0x12, 0x80) < 0) | 2617 | i2c_w(sd, 0x12, 0x80); |
2394 | return -EIO; | ||
2395 | 2618 | ||
2396 | /* Wait for it to initialize */ | 2619 | /* Wait for it to initialize */ |
2397 | msleep(150); | 2620 | msleep(150); |
@@ -2404,15 +2627,16 @@ static int init_ov_sensor(struct sd *sd, __u8 slave) | |||
2404 | } | 2627 | } |
2405 | 2628 | ||
2406 | /* Reset the sensor */ | 2629 | /* Reset the sensor */ |
2407 | if (i2c_w(sd, 0x12, 0x80) < 0) | 2630 | i2c_w(sd, 0x12, 0x80); |
2408 | return -EIO; | 2631 | |
2409 | /* Wait for it to initialize */ | 2632 | /* Wait for it to initialize */ |
2410 | msleep(150); | 2633 | msleep(150); |
2634 | |||
2411 | /* Dummy read to sync I2C */ | 2635 | /* Dummy read to sync I2C */ |
2412 | if (i2c_r(sd, 0x00) < 0) | 2636 | if (i2c_r(sd, 0x00) < 0) |
2413 | return -EIO; | 2637 | return -1; |
2414 | } | 2638 | } |
2415 | return -EIO; | 2639 | return -1; |
2416 | } | 2640 | } |
2417 | 2641 | ||
2418 | /* Set the read and write slave IDs. The "slave" argument is the write slave, | 2642 | /* Set the read and write slave IDs. The "slave" argument is the write slave, |
@@ -2420,53 +2644,40 @@ static int init_ov_sensor(struct sd *sd, __u8 slave) | |||
2420 | * This should not be called from outside the i2c I/O functions. | 2644 | * This should not be called from outside the i2c I/O functions. |
2421 | * Sets I2C read and write slave IDs. Returns <0 for error | 2645 | * Sets I2C read and write slave IDs. Returns <0 for error |
2422 | */ | 2646 | */ |
2423 | static int ov51x_set_slave_ids(struct sd *sd, | 2647 | static void ov51x_set_slave_ids(struct sd *sd, |
2424 | __u8 slave) | 2648 | u8 slave) |
2425 | { | 2649 | { |
2426 | int rc; | ||
2427 | |||
2428 | switch (sd->bridge) { | 2650 | switch (sd->bridge) { |
2429 | case BRIDGE_OVFX2: | 2651 | case BRIDGE_OVFX2: |
2430 | return reg_w(sd, OVFX2_I2C_ADDR, slave); | 2652 | reg_w(sd, OVFX2_I2C_ADDR, slave); |
2653 | return; | ||
2431 | case BRIDGE_W9968CF: | 2654 | case BRIDGE_W9968CF: |
2432 | sd->sensor_addr = slave; | 2655 | sd->sensor_addr = slave; |
2433 | return 0; | 2656 | return; |
2434 | } | 2657 | } |
2435 | 2658 | ||
2436 | rc = reg_w(sd, R51x_I2C_W_SID, slave); | 2659 | reg_w(sd, R51x_I2C_W_SID, slave); |
2437 | if (rc < 0) | 2660 | reg_w(sd, R51x_I2C_R_SID, slave + 1); |
2438 | return rc; | ||
2439 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); | ||
2440 | } | 2661 | } |
2441 | 2662 | ||
2442 | static int write_regvals(struct sd *sd, | 2663 | static void write_regvals(struct sd *sd, |
2443 | const struct ov_regvals *regvals, | 2664 | const struct ov_regvals *regvals, |
2444 | int n) | 2665 | int n) |
2445 | { | 2666 | { |
2446 | int rc; | ||
2447 | |||
2448 | while (--n >= 0) { | 2667 | while (--n >= 0) { |
2449 | rc = reg_w(sd, regvals->reg, regvals->val); | 2668 | reg_w(sd, regvals->reg, regvals->val); |
2450 | if (rc < 0) | ||
2451 | return rc; | ||
2452 | regvals++; | 2669 | regvals++; |
2453 | } | 2670 | } |
2454 | return 0; | ||
2455 | } | 2671 | } |
2456 | 2672 | ||
2457 | static int write_i2c_regvals(struct sd *sd, | 2673 | static void write_i2c_regvals(struct sd *sd, |
2458 | const struct ov_i2c_regvals *regvals, | 2674 | const struct ov_i2c_regvals *regvals, |
2459 | int n) | 2675 | int n) |
2460 | { | 2676 | { |
2461 | int rc; | ||
2462 | |||
2463 | while (--n >= 0) { | 2677 | while (--n >= 0) { |
2464 | rc = i2c_w(sd, regvals->reg, regvals->val); | 2678 | i2c_w(sd, regvals->reg, regvals->val); |
2465 | if (rc < 0) | ||
2466 | return rc; | ||
2467 | regvals++; | 2679 | regvals++; |
2468 | } | 2680 | } |
2469 | return 0; | ||
2470 | } | 2681 | } |
2471 | 2682 | ||
2472 | /**************************************************************************** | 2683 | /**************************************************************************** |
@@ -2476,13 +2687,13 @@ static int write_i2c_regvals(struct sd *sd, | |||
2476 | ***************************************************************************/ | 2687 | ***************************************************************************/ |
2477 | 2688 | ||
2478 | /* This initializes the OV2x10 / OV3610 / OV3620 */ | 2689 | /* This initializes the OV2x10 / OV3610 / OV3620 */ |
2479 | static int ov_hires_configure(struct sd *sd) | 2690 | static void ov_hires_configure(struct sd *sd) |
2480 | { | 2691 | { |
2481 | int high, low; | 2692 | int high, low; |
2482 | 2693 | ||
2483 | if (sd->bridge != BRIDGE_OVFX2) { | 2694 | if (sd->bridge != BRIDGE_OVFX2) { |
2484 | PDEBUG(D_ERR, "error hires sensors only supported with ovfx2"); | 2695 | err("error hires sensors only supported with ovfx2"); |
2485 | return -1; | 2696 | return; |
2486 | } | 2697 | } |
2487 | 2698 | ||
2488 | PDEBUG(D_PROBE, "starting ov hires configuration"); | 2699 | PDEBUG(D_PROBE, "starting ov hires configuration"); |
@@ -2494,24 +2705,22 @@ static int ov_hires_configure(struct sd *sd) | |||
2494 | if (high == 0x96 && low == 0x40) { | 2705 | if (high == 0x96 && low == 0x40) { |
2495 | PDEBUG(D_PROBE, "Sensor is an OV2610"); | 2706 | PDEBUG(D_PROBE, "Sensor is an OV2610"); |
2496 | sd->sensor = SEN_OV2610; | 2707 | sd->sensor = SEN_OV2610; |
2708 | } else if (high == 0x96 && low == 0x41) { | ||
2709 | PDEBUG(D_PROBE, "Sensor is an OV2610AE"); | ||
2710 | sd->sensor = SEN_OV2610AE; | ||
2497 | } else if (high == 0x36 && (low & 0x0f) == 0x00) { | 2711 | } else if (high == 0x36 && (low & 0x0f) == 0x00) { |
2498 | PDEBUG(D_PROBE, "Sensor is an OV3610"); | 2712 | PDEBUG(D_PROBE, "Sensor is an OV3610"); |
2499 | sd->sensor = SEN_OV3610; | 2713 | sd->sensor = SEN_OV3610; |
2500 | } else { | 2714 | } else { |
2501 | PDEBUG(D_ERR, "Error unknown sensor type: 0x%02x%02x", | 2715 | err("Error unknown sensor type: %02x%02x", |
2502 | high, low); | 2716 | high, low); |
2503 | return -1; | ||
2504 | } | 2717 | } |
2505 | |||
2506 | /* Set sensor-specific vars */ | ||
2507 | return 0; | ||
2508 | } | 2718 | } |
2509 | 2719 | ||
2510 | |||
2511 | /* This initializes the OV8110, OV8610 sensor. The OV8110 uses | 2720 | /* This initializes the OV8110, OV8610 sensor. The OV8110 uses |
2512 | * the same register settings as the OV8610, since they are very similar. | 2721 | * the same register settings as the OV8610, since they are very similar. |
2513 | */ | 2722 | */ |
2514 | static int ov8xx0_configure(struct sd *sd) | 2723 | static void ov8xx0_configure(struct sd *sd) |
2515 | { | 2724 | { |
2516 | int rc; | 2725 | int rc; |
2517 | 2726 | ||
@@ -2521,27 +2730,21 @@ static int ov8xx0_configure(struct sd *sd) | |||
2521 | rc = i2c_r(sd, OV7610_REG_COM_I); | 2730 | rc = i2c_r(sd, OV7610_REG_COM_I); |
2522 | if (rc < 0) { | 2731 | if (rc < 0) { |
2523 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2732 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2524 | return -1; | 2733 | return; |
2525 | } | 2734 | } |
2526 | if ((rc & 3) == 1) { | 2735 | if ((rc & 3) == 1) |
2527 | sd->sensor = SEN_OV8610; | 2736 | sd->sensor = SEN_OV8610; |
2528 | } else { | 2737 | else |
2529 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); | 2738 | err("Unknown image sensor version: %d", rc & 3); |
2530 | return -1; | ||
2531 | } | ||
2532 | |||
2533 | /* Set sensor-specific vars */ | ||
2534 | return 0; | ||
2535 | } | 2739 | } |
2536 | 2740 | ||
2537 | /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses | 2741 | /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses |
2538 | * the same register settings as the OV7610, since they are very similar. | 2742 | * the same register settings as the OV7610, since they are very similar. |
2539 | */ | 2743 | */ |
2540 | static int ov7xx0_configure(struct sd *sd) | 2744 | static void ov7xx0_configure(struct sd *sd) |
2541 | { | 2745 | { |
2542 | int rc, high, low; | 2746 | int rc, high, low; |
2543 | 2747 | ||
2544 | |||
2545 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); | 2748 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); |
2546 | 2749 | ||
2547 | /* Detect sensor (sub)type */ | 2750 | /* Detect sensor (sub)type */ |
@@ -2551,15 +2754,15 @@ static int ov7xx0_configure(struct sd *sd) | |||
2551 | * it appears to be wrongly detected as a 7610 by default */ | 2754 | * it appears to be wrongly detected as a 7610 by default */ |
2552 | if (rc < 0) { | 2755 | if (rc < 0) { |
2553 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2756 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2554 | return -1; | 2757 | return; |
2555 | } | 2758 | } |
2556 | if ((rc & 3) == 3) { | 2759 | if ((rc & 3) == 3) { |
2557 | /* quick hack to make OV7670s work */ | 2760 | /* quick hack to make OV7670s work */ |
2558 | high = i2c_r(sd, 0x0a); | 2761 | high = i2c_r(sd, 0x0a); |
2559 | low = i2c_r(sd, 0x0b); | 2762 | low = i2c_r(sd, 0x0b); |
2560 | /* info("%x, %x", high, low); */ | 2763 | /* info("%x, %x", high, low); */ |
2561 | if (high == 0x76 && low == 0x73) { | 2764 | if (high == 0x76 && (low & 0xf0) == 0x70) { |
2562 | PDEBUG(D_PROBE, "Sensor is an OV7670"); | 2765 | PDEBUG(D_PROBE, "Sensor is an OV76%02x", low); |
2563 | sd->sensor = SEN_OV7670; | 2766 | sd->sensor = SEN_OV7670; |
2564 | } else { | 2767 | } else { |
2565 | PDEBUG(D_PROBE, "Sensor is an OV7610"); | 2768 | PDEBUG(D_PROBE, "Sensor is an OV7610"); |
@@ -2579,20 +2782,19 @@ static int ov7xx0_configure(struct sd *sd) | |||
2579 | high = i2c_r(sd, 0x0a); | 2782 | high = i2c_r(sd, 0x0a); |
2580 | if (high < 0) { | 2783 | if (high < 0) { |
2581 | PDEBUG(D_ERR, "Error detecting camera chip PID"); | 2784 | PDEBUG(D_ERR, "Error detecting camera chip PID"); |
2582 | return high; | 2785 | return; |
2583 | } | 2786 | } |
2584 | low = i2c_r(sd, 0x0b); | 2787 | low = i2c_r(sd, 0x0b); |
2585 | if (low < 0) { | 2788 | if (low < 0) { |
2586 | PDEBUG(D_ERR, "Error detecting camera chip VER"); | 2789 | PDEBUG(D_ERR, "Error detecting camera chip VER"); |
2587 | return low; | 2790 | return; |
2588 | } | 2791 | } |
2589 | if (high == 0x76) { | 2792 | if (high == 0x76) { |
2590 | switch (low) { | 2793 | switch (low) { |
2591 | case 0x30: | 2794 | case 0x30: |
2592 | PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); | 2795 | err("Sensor is an OV7630/OV7635"); |
2593 | PDEBUG(D_ERR, | 2796 | err("7630 is not supported by this driver"); |
2594 | "7630 is not supported by this driver"); | 2797 | return; |
2595 | return -1; | ||
2596 | case 0x40: | 2798 | case 0x40: |
2597 | PDEBUG(D_PROBE, "Sensor is an OV7645"); | 2799 | PDEBUG(D_PROBE, "Sensor is an OV7645"); |
2598 | sd->sensor = SEN_OV7640; /* FIXME */ | 2800 | sd->sensor = SEN_OV7640; /* FIXME */ |
@@ -2605,25 +2807,26 @@ static int ov7xx0_configure(struct sd *sd) | |||
2605 | PDEBUG(D_PROBE, "Sensor is an OV7648"); | 2807 | PDEBUG(D_PROBE, "Sensor is an OV7648"); |
2606 | sd->sensor = SEN_OV7648; | 2808 | sd->sensor = SEN_OV7648; |
2607 | break; | 2809 | break; |
2810 | case 0x60: | ||
2811 | PDEBUG(D_PROBE, "Sensor is a OV7660"); | ||
2812 | sd->sensor = SEN_OV7660; | ||
2813 | sd->invert_led = 0; | ||
2814 | break; | ||
2608 | default: | 2815 | default: |
2609 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); | 2816 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); |
2610 | return -1; | 2817 | return; |
2611 | } | 2818 | } |
2612 | } else { | 2819 | } else { |
2613 | PDEBUG(D_PROBE, "Sensor is an OV7620"); | 2820 | PDEBUG(D_PROBE, "Sensor is an OV7620"); |
2614 | sd->sensor = SEN_OV7620; | 2821 | sd->sensor = SEN_OV7620; |
2615 | } | 2822 | } |
2616 | } else { | 2823 | } else { |
2617 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); | 2824 | err("Unknown image sensor version: %d", rc & 3); |
2618 | return -1; | ||
2619 | } | 2825 | } |
2620 | |||
2621 | /* Set sensor-specific vars */ | ||
2622 | return 0; | ||
2623 | } | 2826 | } |
2624 | 2827 | ||
2625 | /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */ | 2828 | /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */ |
2626 | static int ov6xx0_configure(struct sd *sd) | 2829 | static void ov6xx0_configure(struct sd *sd) |
2627 | { | 2830 | { |
2628 | int rc; | 2831 | int rc; |
2629 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); | 2832 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); |
@@ -2632,7 +2835,7 @@ static int ov6xx0_configure(struct sd *sd) | |||
2632 | rc = i2c_r(sd, OV7610_REG_COM_I); | 2835 | rc = i2c_r(sd, OV7610_REG_COM_I); |
2633 | if (rc < 0) { | 2836 | if (rc < 0) { |
2634 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2837 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2635 | return -1; | 2838 | return; |
2636 | } | 2839 | } |
2637 | 2840 | ||
2638 | /* Ugh. The first two bits are the version bits, but | 2841 | /* Ugh. The first two bits are the version bits, but |
@@ -2641,9 +2844,8 @@ static int ov6xx0_configure(struct sd *sd) | |||
2641 | switch (rc) { | 2844 | switch (rc) { |
2642 | case 0x00: | 2845 | case 0x00: |
2643 | sd->sensor = SEN_OV6630; | 2846 | sd->sensor = SEN_OV6630; |
2644 | PDEBUG(D_ERR, | 2847 | warn("WARNING: Sensor is an OV66308. Your camera may have"); |
2645 | "WARNING: Sensor is an OV66308. Your camera may have"); | 2848 | warn("been misdetected in previous driver versions."); |
2646 | PDEBUG(D_ERR, "been misdetected in previous driver versions."); | ||
2647 | break; | 2849 | break; |
2648 | case 0x01: | 2850 | case 0x01: |
2649 | sd->sensor = SEN_OV6620; | 2851 | sd->sensor = SEN_OV6620; |
@@ -2659,19 +2861,16 @@ static int ov6xx0_configure(struct sd *sd) | |||
2659 | break; | 2861 | break; |
2660 | case 0x90: | 2862 | case 0x90: |
2661 | sd->sensor = SEN_OV6630; | 2863 | sd->sensor = SEN_OV6630; |
2662 | PDEBUG(D_ERR, | 2864 | warn("WARNING: Sensor is an OV66307. Your camera may have"); |
2663 | "WARNING: Sensor is an OV66307. Your camera may have"); | 2865 | warn("been misdetected in previous driver versions."); |
2664 | PDEBUG(D_ERR, "been misdetected in previous driver versions."); | ||
2665 | break; | 2866 | break; |
2666 | default: | 2867 | default: |
2667 | PDEBUG(D_ERR, "FATAL: Unknown sensor version: 0x%02x", rc); | 2868 | err("FATAL: Unknown sensor version: 0x%02x", rc); |
2668 | return -1; | 2869 | return; |
2669 | } | 2870 | } |
2670 | 2871 | ||
2671 | /* Set sensor-specific vars */ | 2872 | /* Set sensor-specific vars */ |
2672 | sd->sif = 1; | 2873 | sd->sif = 1; |
2673 | |||
2674 | return 0; | ||
2675 | } | 2874 | } |
2676 | 2875 | ||
2677 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ | 2876 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ |
@@ -2683,14 +2882,14 @@ static void ov51x_led_control(struct sd *sd, int on) | |||
2683 | switch (sd->bridge) { | 2882 | switch (sd->bridge) { |
2684 | /* OV511 has no LED control */ | 2883 | /* OV511 has no LED control */ |
2685 | case BRIDGE_OV511PLUS: | 2884 | case BRIDGE_OV511PLUS: |
2686 | reg_w(sd, R511_SYS_LED_CTL, on ? 1 : 0); | 2885 | reg_w(sd, R511_SYS_LED_CTL, on); |
2687 | break; | 2886 | break; |
2688 | case BRIDGE_OV518: | 2887 | case BRIDGE_OV518: |
2689 | case BRIDGE_OV518PLUS: | 2888 | case BRIDGE_OV518PLUS: |
2690 | reg_w_mask(sd, R518_GPIO_OUT, on ? 0x02 : 0x00, 0x02); | 2889 | reg_w_mask(sd, R518_GPIO_OUT, 0x02 * on, 0x02); |
2691 | break; | 2890 | break; |
2692 | case BRIDGE_OV519: | 2891 | case BRIDGE_OV519: |
2693 | reg_w_mask(sd, OV519_GPIO_DATA_OUT0, !on, 1); /* 0 / 1 */ | 2892 | reg_w_mask(sd, OV519_GPIO_DATA_OUT0, on, 1); |
2694 | break; | 2893 | break; |
2695 | } | 2894 | } |
2696 | } | 2895 | } |
@@ -2725,7 +2924,7 @@ static void sd_reset_snapshot(struct gspca_dev *gspca_dev) | |||
2725 | } | 2924 | } |
2726 | } | 2925 | } |
2727 | 2926 | ||
2728 | static int ov51x_upload_quan_tables(struct sd *sd) | 2927 | static void ov51x_upload_quan_tables(struct sd *sd) |
2729 | { | 2928 | { |
2730 | const unsigned char yQuanTable511[] = { | 2929 | const unsigned char yQuanTable511[] = { |
2731 | 0, 1, 1, 2, 2, 3, 3, 4, | 2930 | 0, 1, 1, 2, 2, 3, 3, 4, |
@@ -2756,7 +2955,6 @@ static int ov51x_upload_quan_tables(struct sd *sd) | |||
2756 | 6, 6, 6, 6, 7, 7, 7, 8, | 2955 | 6, 6, 6, 6, 7, 7, 7, 8, |
2757 | 7, 7, 6, 7, 7, 7, 8, 8 | 2956 | 7, 7, 6, 7, 7, 7, 8, 8 |
2758 | }; | 2957 | }; |
2759 | |||
2760 | const unsigned char uvQuanTable518[] = { | 2958 | const unsigned char uvQuanTable518[] = { |
2761 | 6, 6, 6, 7, 7, 7, 7, 7, | 2959 | 6, 6, 6, 7, 7, 7, 7, 7, |
2762 | 6, 6, 6, 7, 7, 7, 7, 7, | 2960 | 6, 6, 6, 7, 7, 7, 7, 7, |
@@ -2766,18 +2964,18 @@ static int ov51x_upload_quan_tables(struct sd *sd) | |||
2766 | 2964 | ||
2767 | const unsigned char *pYTable, *pUVTable; | 2965 | const unsigned char *pYTable, *pUVTable; |
2768 | unsigned char val0, val1; | 2966 | unsigned char val0, val1; |
2769 | int i, size, rc, reg = R51x_COMP_LUT_BEGIN; | 2967 | int i, size, reg = R51x_COMP_LUT_BEGIN; |
2770 | 2968 | ||
2771 | PDEBUG(D_PROBE, "Uploading quantization tables"); | 2969 | PDEBUG(D_PROBE, "Uploading quantization tables"); |
2772 | 2970 | ||
2773 | if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { | 2971 | if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { |
2774 | pYTable = yQuanTable511; | 2972 | pYTable = yQuanTable511; |
2775 | pUVTable = uvQuanTable511; | 2973 | pUVTable = uvQuanTable511; |
2776 | size = 32; | 2974 | size = 32; |
2777 | } else { | 2975 | } else { |
2778 | pYTable = yQuanTable518; | 2976 | pYTable = yQuanTable518; |
2779 | pUVTable = uvQuanTable518; | 2977 | pUVTable = uvQuanTable518; |
2780 | size = 16; | 2978 | size = 16; |
2781 | } | 2979 | } |
2782 | 2980 | ||
2783 | for (i = 0; i < size; i++) { | 2981 | for (i = 0; i < size; i++) { |
@@ -2786,30 +2984,23 @@ static int ov51x_upload_quan_tables(struct sd *sd) | |||
2786 | val0 &= 0x0f; | 2984 | val0 &= 0x0f; |
2787 | val1 &= 0x0f; | 2985 | val1 &= 0x0f; |
2788 | val0 |= val1 << 4; | 2986 | val0 |= val1 << 4; |
2789 | rc = reg_w(sd, reg, val0); | 2987 | reg_w(sd, reg, val0); |
2790 | if (rc < 0) | ||
2791 | return rc; | ||
2792 | 2988 | ||
2793 | val0 = *pUVTable++; | 2989 | val0 = *pUVTable++; |
2794 | val1 = *pUVTable++; | 2990 | val1 = *pUVTable++; |
2795 | val0 &= 0x0f; | 2991 | val0 &= 0x0f; |
2796 | val1 &= 0x0f; | 2992 | val1 &= 0x0f; |
2797 | val0 |= val1 << 4; | 2993 | val0 |= val1 << 4; |
2798 | rc = reg_w(sd, reg + size, val0); | 2994 | reg_w(sd, reg + size, val0); |
2799 | if (rc < 0) | ||
2800 | return rc; | ||
2801 | 2995 | ||
2802 | reg++; | 2996 | reg++; |
2803 | } | 2997 | } |
2804 | |||
2805 | return 0; | ||
2806 | } | 2998 | } |
2807 | 2999 | ||
2808 | /* This initializes the OV511/OV511+ and the sensor */ | 3000 | /* This initializes the OV511/OV511+ and the sensor */ |
2809 | static int ov511_configure(struct gspca_dev *gspca_dev) | 3001 | static void ov511_configure(struct gspca_dev *gspca_dev) |
2810 | { | 3002 | { |
2811 | struct sd *sd = (struct sd *) gspca_dev; | 3003 | struct sd *sd = (struct sd *) gspca_dev; |
2812 | int rc; | ||
2813 | 3004 | ||
2814 | /* For 511 and 511+ */ | 3005 | /* For 511 and 511+ */ |
2815 | const struct ov_regvals init_511[] = { | 3006 | const struct ov_regvals init_511[] = { |
@@ -2823,7 +3014,7 @@ static int ov511_configure(struct gspca_dev *gspca_dev) | |||
2823 | }; | 3014 | }; |
2824 | 3015 | ||
2825 | const struct ov_regvals norm_511[] = { | 3016 | const struct ov_regvals norm_511[] = { |
2826 | { R511_DRAM_FLOW_CTL, 0x01 }, | 3017 | { R511_DRAM_FLOW_CTL, 0x01 }, |
2827 | { R51x_SYS_SNAP, 0x00 }, | 3018 | { R51x_SYS_SNAP, 0x00 }, |
2828 | { R51x_SYS_SNAP, 0x02 }, | 3019 | { R51x_SYS_SNAP, 0x02 }, |
2829 | { R51x_SYS_SNAP, 0x00 }, | 3020 | { R51x_SYS_SNAP, 0x00 }, |
@@ -2855,42 +3046,27 @@ static int ov511_configure(struct gspca_dev *gspca_dev) | |||
2855 | 3046 | ||
2856 | PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); | 3047 | PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); |
2857 | 3048 | ||
2858 | rc = write_regvals(sd, init_511, ARRAY_SIZE(init_511)); | 3049 | write_regvals(sd, init_511, ARRAY_SIZE(init_511)); |
2859 | if (rc < 0) | ||
2860 | return rc; | ||
2861 | 3050 | ||
2862 | switch (sd->bridge) { | 3051 | switch (sd->bridge) { |
2863 | case BRIDGE_OV511: | 3052 | case BRIDGE_OV511: |
2864 | rc = write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); | 3053 | write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); |
2865 | if (rc < 0) | ||
2866 | return rc; | ||
2867 | break; | 3054 | break; |
2868 | case BRIDGE_OV511PLUS: | 3055 | case BRIDGE_OV511PLUS: |
2869 | rc = write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); | 3056 | write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); |
2870 | if (rc < 0) | ||
2871 | return rc; | ||
2872 | break; | 3057 | break; |
2873 | } | 3058 | } |
2874 | 3059 | ||
2875 | /* Init compression */ | 3060 | /* Init compression */ |
2876 | rc = write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); | 3061 | write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); |
2877 | if (rc < 0) | ||
2878 | return rc; | ||
2879 | 3062 | ||
2880 | rc = ov51x_upload_quan_tables(sd); | 3063 | ov51x_upload_quan_tables(sd); |
2881 | if (rc < 0) { | ||
2882 | PDEBUG(D_ERR, "Error uploading quantization tables"); | ||
2883 | return rc; | ||
2884 | } | ||
2885 | |||
2886 | return 0; | ||
2887 | } | 3064 | } |
2888 | 3065 | ||
2889 | /* This initializes the OV518/OV518+ and the sensor */ | 3066 | /* This initializes the OV518/OV518+ and the sensor */ |
2890 | static int ov518_configure(struct gspca_dev *gspca_dev) | 3067 | static void ov518_configure(struct gspca_dev *gspca_dev) |
2891 | { | 3068 | { |
2892 | struct sd *sd = (struct sd *) gspca_dev; | 3069 | struct sd *sd = (struct sd *) gspca_dev; |
2893 | int rc; | ||
2894 | 3070 | ||
2895 | /* For 518 and 518+ */ | 3071 | /* For 518 and 518+ */ |
2896 | const struct ov_regvals init_518[] = { | 3072 | const struct ov_regvals init_518[] = { |
@@ -2907,7 +3083,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
2907 | const struct ov_regvals norm_518[] = { | 3083 | const struct ov_regvals norm_518[] = { |
2908 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ | 3084 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ |
2909 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ | 3085 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ |
2910 | { 0x31, 0x0f }, | 3086 | { 0x31, 0x0f }, |
2911 | { 0x5d, 0x03 }, | 3087 | { 0x5d, 0x03 }, |
2912 | { 0x24, 0x9f }, | 3088 | { 0x24, 0x9f }, |
2913 | { 0x25, 0x90 }, | 3089 | { 0x25, 0x90 }, |
@@ -2920,7 +3096,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
2920 | const struct ov_regvals norm_518_p[] = { | 3096 | const struct ov_regvals norm_518_p[] = { |
2921 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ | 3097 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ |
2922 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ | 3098 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ |
2923 | { 0x31, 0x0f }, | 3099 | { 0x31, 0x0f }, |
2924 | { 0x5d, 0x03 }, | 3100 | { 0x5d, 0x03 }, |
2925 | { 0x24, 0x9f }, | 3101 | { 0x24, 0x9f }, |
2926 | { 0x25, 0x90 }, | 3102 | { 0x25, 0x90 }, |
@@ -2938,65 +3114,49 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
2938 | 3114 | ||
2939 | /* First 5 bits of custom ID reg are a revision ID on OV518 */ | 3115 | /* First 5 bits of custom ID reg are a revision ID on OV518 */ |
2940 | PDEBUG(D_PROBE, "Device revision %d", | 3116 | PDEBUG(D_PROBE, "Device revision %d", |
2941 | 0x1F & reg_r(sd, R51x_SYS_CUST_ID)); | 3117 | 0x1f & reg_r(sd, R51x_SYS_CUST_ID)); |
2942 | 3118 | ||
2943 | rc = write_regvals(sd, init_518, ARRAY_SIZE(init_518)); | 3119 | write_regvals(sd, init_518, ARRAY_SIZE(init_518)); |
2944 | if (rc < 0) | ||
2945 | return rc; | ||
2946 | 3120 | ||
2947 | /* Set LED GPIO pin to output mode */ | 3121 | /* Set LED GPIO pin to output mode */ |
2948 | rc = reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02); | 3122 | reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02); |
2949 | if (rc < 0) | ||
2950 | return rc; | ||
2951 | 3123 | ||
2952 | switch (sd->bridge) { | 3124 | switch (sd->bridge) { |
2953 | case BRIDGE_OV518: | 3125 | case BRIDGE_OV518: |
2954 | rc = write_regvals(sd, norm_518, ARRAY_SIZE(norm_518)); | 3126 | write_regvals(sd, norm_518, ARRAY_SIZE(norm_518)); |
2955 | if (rc < 0) | ||
2956 | return rc; | ||
2957 | break; | 3127 | break; |
2958 | case BRIDGE_OV518PLUS: | 3128 | case BRIDGE_OV518PLUS: |
2959 | rc = write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p)); | 3129 | write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p)); |
2960 | if (rc < 0) | ||
2961 | return rc; | ||
2962 | break; | 3130 | break; |
2963 | } | 3131 | } |
2964 | 3132 | ||
2965 | rc = ov51x_upload_quan_tables(sd); | 3133 | ov51x_upload_quan_tables(sd); |
2966 | if (rc < 0) { | ||
2967 | PDEBUG(D_ERR, "Error uploading quantization tables"); | ||
2968 | return rc; | ||
2969 | } | ||
2970 | 3134 | ||
2971 | rc = reg_w(sd, 0x2f, 0x80); | 3135 | reg_w(sd, 0x2f, 0x80); |
2972 | if (rc < 0) | ||
2973 | return rc; | ||
2974 | |||
2975 | return 0; | ||
2976 | } | 3136 | } |
2977 | 3137 | ||
2978 | static int ov519_configure(struct sd *sd) | 3138 | static void ov519_configure(struct sd *sd) |
2979 | { | 3139 | { |
2980 | static const struct ov_regvals init_519[] = { | 3140 | static const struct ov_regvals init_519[] = { |
2981 | { 0x5a, 0x6d }, /* EnableSystem */ | 3141 | { 0x5a, 0x6d }, /* EnableSystem */ |
2982 | { 0x53, 0x9b }, | 3142 | { 0x53, 0x9b }, /* don't enable the microcontroller */ |
2983 | { 0x54, 0xff }, /* set bit2 to enable jpeg */ | 3143 | { OV519_R54_EN_CLK1, 0xff }, /* set bit2 to enable jpeg */ |
2984 | { 0x5d, 0x03 }, | 3144 | { 0x5d, 0x03 }, |
2985 | { 0x49, 0x01 }, | 3145 | { 0x49, 0x01 }, |
2986 | { 0x48, 0x00 }, | 3146 | { 0x48, 0x00 }, |
2987 | /* Set LED pin to output mode. Bit 4 must be cleared or sensor | 3147 | /* Set LED pin to output mode. Bit 4 must be cleared or sensor |
2988 | * detection will fail. This deserves further investigation. */ | 3148 | * detection will fail. This deserves further investigation. */ |
2989 | { OV519_GPIO_IO_CTRL0, 0xee }, | 3149 | { OV519_GPIO_IO_CTRL0, 0xee }, |
2990 | { 0x51, 0x0f }, /* SetUsbInit */ | 3150 | { OV519_R51_RESET1, 0x0f }, |
2991 | { 0x51, 0x00 }, | 3151 | { OV519_R51_RESET1, 0x00 }, |
2992 | { 0x22, 0x00 }, | 3152 | { 0x22, 0x00 }, |
2993 | /* windows reads 0x55 at this point*/ | 3153 | /* windows reads 0x55 at this point*/ |
2994 | }; | 3154 | }; |
2995 | 3155 | ||
2996 | return write_regvals(sd, init_519, ARRAY_SIZE(init_519)); | 3156 | write_regvals(sd, init_519, ARRAY_SIZE(init_519)); |
2997 | } | 3157 | } |
2998 | 3158 | ||
2999 | static int ovfx2_configure(struct sd *sd) | 3159 | static void ovfx2_configure(struct sd *sd) |
3000 | { | 3160 | { |
3001 | static const struct ov_regvals init_fx2[] = { | 3161 | static const struct ov_regvals init_fx2[] = { |
3002 | { 0x00, 0x60 }, | 3162 | { 0x00, 0x60 }, |
@@ -3010,7 +3170,99 @@ static int ovfx2_configure(struct sd *sd) | |||
3010 | 3170 | ||
3011 | sd->stopped = 1; | 3171 | sd->stopped = 1; |
3012 | 3172 | ||
3013 | return write_regvals(sd, init_fx2, ARRAY_SIZE(init_fx2)); | 3173 | write_regvals(sd, init_fx2, ARRAY_SIZE(init_fx2)); |
3174 | } | ||
3175 | |||
3176 | /* set the mode */ | ||
3177 | /* This function works for ov7660 only */ | ||
3178 | static void ov519_set_mode(struct sd *sd) | ||
3179 | { | ||
3180 | static const struct ov_regvals bridge_ov7660[2][10] = { | ||
3181 | {{0x10, 0x14}, {0x11, 0x1e}, {0x12, 0x00}, {0x13, 0x00}, | ||
3182 | {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c}, | ||
3183 | {0x25, 0x01}, {0x26, 0x00}}, | ||
3184 | {{0x10, 0x28}, {0x11, 0x3c}, {0x12, 0x00}, {0x13, 0x00}, | ||
3185 | {0x14, 0x00}, {0x15, 0x00}, {0x16, 0x00}, {0x20, 0x0c}, | ||
3186 | {0x25, 0x03}, {0x26, 0x00}} | ||
3187 | }; | ||
3188 | static const struct ov_i2c_regvals sensor_ov7660[2][3] = { | ||
3189 | {{0x12, 0x00}, {0x24, 0x00}, {0x0c, 0x0c}}, | ||
3190 | {{0x12, 0x00}, {0x04, 0x00}, {0x0c, 0x00}} | ||
3191 | }; | ||
3192 | static const struct ov_i2c_regvals sensor_ov7660_2[] = { | ||
3193 | {OV7670_R17_HSTART, 0x13}, | ||
3194 | {OV7670_R18_HSTOP, 0x01}, | ||
3195 | {OV7670_R32_HREF, 0x92}, | ||
3196 | {OV7670_R19_VSTART, 0x02}, | ||
3197 | {OV7670_R1A_VSTOP, 0x7a}, | ||
3198 | {OV7670_R03_VREF, 0x00}, | ||
3199 | /* {0x33, 0x00}, */ | ||
3200 | /* {0x34, 0x07}, */ | ||
3201 | /* {0x36, 0x00}, */ | ||
3202 | /* {0x6b, 0x0a}, */ | ||
3203 | }; | ||
3204 | |||
3205 | write_regvals(sd, bridge_ov7660[sd->gspca_dev.curr_mode], | ||
3206 | ARRAY_SIZE(bridge_ov7660[0])); | ||
3207 | write_i2c_regvals(sd, sensor_ov7660[sd->gspca_dev.curr_mode], | ||
3208 | ARRAY_SIZE(sensor_ov7660[0])); | ||
3209 | write_i2c_regvals(sd, sensor_ov7660_2, | ||
3210 | ARRAY_SIZE(sensor_ov7660_2)); | ||
3211 | } | ||
3212 | |||
3213 | /* set the frame rate */ | ||
3214 | /* This function works for sensors ov7640, ov7648 ov7660 and ov7670 only */ | ||
3215 | static void ov519_set_fr(struct sd *sd) | ||
3216 | { | ||
3217 | int fr; | ||
3218 | u8 clock; | ||
3219 | /* frame rate table with indices: | ||
3220 | * - mode = 0: 320x240, 1: 640x480 | ||
3221 | * - fr rate = 0: 30, 1: 25, 2: 20, 3: 15, 4: 10, 5: 5 | ||
3222 | * - reg = 0: bridge a4, 1: bridge 23, 2: sensor 11 (clock) | ||
3223 | */ | ||
3224 | static const u8 fr_tb[2][6][3] = { | ||
3225 | {{0x04, 0xff, 0x00}, | ||
3226 | {0x04, 0x1f, 0x00}, | ||
3227 | {0x04, 0x1b, 0x00}, | ||
3228 | {0x04, 0x15, 0x00}, | ||
3229 | {0x04, 0x09, 0x00}, | ||
3230 | {0x04, 0x01, 0x00}}, | ||
3231 | {{0x0c, 0xff, 0x00}, | ||
3232 | {0x0c, 0x1f, 0x00}, | ||
3233 | {0x0c, 0x1b, 0x00}, | ||
3234 | {0x04, 0xff, 0x01}, | ||
3235 | {0x04, 0x1f, 0x01}, | ||
3236 | {0x04, 0x1b, 0x01}}, | ||
3237 | }; | ||
3238 | |||
3239 | if (frame_rate > 0) | ||
3240 | sd->frame_rate = frame_rate; | ||
3241 | if (sd->frame_rate >= 30) | ||
3242 | fr = 0; | ||
3243 | else if (sd->frame_rate >= 25) | ||
3244 | fr = 1; | ||
3245 | else if (sd->frame_rate >= 20) | ||
3246 | fr = 2; | ||
3247 | else if (sd->frame_rate >= 15) | ||
3248 | fr = 3; | ||
3249 | else if (sd->frame_rate >= 10) | ||
3250 | fr = 4; | ||
3251 | else | ||
3252 | fr = 5; | ||
3253 | reg_w(sd, 0xa4, fr_tb[sd->gspca_dev.curr_mode][fr][0]); | ||
3254 | reg_w(sd, 0x23, fr_tb[sd->gspca_dev.curr_mode][fr][1]); | ||
3255 | clock = fr_tb[sd->gspca_dev.curr_mode][fr][2]; | ||
3256 | if (sd->sensor == SEN_OV7660) | ||
3257 | clock |= 0x80; /* enable double clock */ | ||
3258 | ov518_i2c_w(sd, OV7670_R11_CLKRC, clock); | ||
3259 | } | ||
3260 | |||
3261 | static void setautogain(struct gspca_dev *gspca_dev) | ||
3262 | { | ||
3263 | struct sd *sd = (struct sd *) gspca_dev; | ||
3264 | |||
3265 | i2c_w_mask(sd, 0x13, sd->ctrls[AUTOGAIN].val ? 0x05 : 0x00, 0x05); | ||
3014 | } | 3266 | } |
3015 | 3267 | ||
3016 | /* this function is called at probe time */ | 3268 | /* this function is called at probe time */ |
@@ -3019,221 +3271,250 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3019 | { | 3271 | { |
3020 | struct sd *sd = (struct sd *) gspca_dev; | 3272 | struct sd *sd = (struct sd *) gspca_dev; |
3021 | struct cam *cam = &gspca_dev->cam; | 3273 | struct cam *cam = &gspca_dev->cam; |
3022 | int ret = 0; | ||
3023 | 3274 | ||
3024 | sd->bridge = id->driver_info & BRIDGE_MASK; | 3275 | sd->bridge = id->driver_info & BRIDGE_MASK; |
3025 | sd->invert_led = id->driver_info & BRIDGE_INVERT_LED; | 3276 | sd->invert_led = (id->driver_info & BRIDGE_INVERT_LED) != 0; |
3026 | 3277 | ||
3027 | switch (sd->bridge) { | 3278 | switch (sd->bridge) { |
3028 | case BRIDGE_OV511: | 3279 | case BRIDGE_OV511: |
3029 | case BRIDGE_OV511PLUS: | 3280 | case BRIDGE_OV511PLUS: |
3030 | ret = ov511_configure(gspca_dev); | 3281 | cam->cam_mode = ov511_vga_mode; |
3282 | cam->nmodes = ARRAY_SIZE(ov511_vga_mode); | ||
3031 | break; | 3283 | break; |
3032 | case BRIDGE_OV518: | 3284 | case BRIDGE_OV518: |
3033 | case BRIDGE_OV518PLUS: | 3285 | case BRIDGE_OV518PLUS: |
3034 | ret = ov518_configure(gspca_dev); | 3286 | cam->cam_mode = ov518_vga_mode; |
3287 | cam->nmodes = ARRAY_SIZE(ov518_vga_mode); | ||
3035 | break; | 3288 | break; |
3036 | case BRIDGE_OV519: | 3289 | case BRIDGE_OV519: |
3037 | ret = ov519_configure(sd); | 3290 | cam->cam_mode = ov519_vga_mode; |
3291 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); | ||
3292 | sd->invert_led = !sd->invert_led; | ||
3038 | break; | 3293 | break; |
3039 | case BRIDGE_OVFX2: | 3294 | case BRIDGE_OVFX2: |
3040 | ret = ovfx2_configure(sd); | 3295 | cam->cam_mode = ov519_vga_mode; |
3296 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); | ||
3041 | cam->bulk_size = OVFX2_BULK_SIZE; | 3297 | cam->bulk_size = OVFX2_BULK_SIZE; |
3042 | cam->bulk_nurbs = MAX_NURBS; | 3298 | cam->bulk_nurbs = MAX_NURBS; |
3043 | cam->bulk = 1; | 3299 | cam->bulk = 1; |
3044 | break; | 3300 | break; |
3045 | case BRIDGE_W9968CF: | 3301 | case BRIDGE_W9968CF: |
3046 | ret = w9968cf_configure(sd); | 3302 | cam->cam_mode = w9968cf_vga_mode; |
3303 | cam->nmodes = ARRAY_SIZE(w9968cf_vga_mode); | ||
3047 | cam->reverse_alts = 1; | 3304 | cam->reverse_alts = 1; |
3048 | break; | 3305 | break; |
3049 | } | 3306 | } |
3050 | 3307 | ||
3051 | if (ret) | 3308 | gspca_dev->cam.ctrls = sd->ctrls; |
3052 | goto error; | 3309 | sd->quality = QUALITY_DEF; |
3310 | sd->frame_rate = 15; | ||
3053 | 3311 | ||
3054 | ov51x_led_control(sd, 0); /* turn LED off */ | 3312 | return 0; |
3313 | } | ||
3314 | |||
3315 | /* this function is called at probe and resume time */ | ||
3316 | static int sd_init(struct gspca_dev *gspca_dev) | ||
3317 | { | ||
3318 | struct sd *sd = (struct sd *) gspca_dev; | ||
3319 | struct cam *cam = &gspca_dev->cam; | ||
3320 | |||
3321 | switch (sd->bridge) { | ||
3322 | case BRIDGE_OV511: | ||
3323 | case BRIDGE_OV511PLUS: | ||
3324 | ov511_configure(gspca_dev); | ||
3325 | break; | ||
3326 | case BRIDGE_OV518: | ||
3327 | case BRIDGE_OV518PLUS: | ||
3328 | ov518_configure(gspca_dev); | ||
3329 | break; | ||
3330 | case BRIDGE_OV519: | ||
3331 | ov519_configure(sd); | ||
3332 | break; | ||
3333 | case BRIDGE_OVFX2: | ||
3334 | ovfx2_configure(sd); | ||
3335 | break; | ||
3336 | case BRIDGE_W9968CF: | ||
3337 | w9968cf_configure(sd); | ||
3338 | break; | ||
3339 | } | ||
3055 | 3340 | ||
3056 | /* The OV519 must be more aggressive about sensor detection since | 3341 | /* The OV519 must be more aggressive about sensor detection since |
3057 | * I2C write will never fail if the sensor is not present. We have | 3342 | * I2C write will never fail if the sensor is not present. We have |
3058 | * to try to initialize the sensor to detect its presence */ | 3343 | * to try to initialize the sensor to detect its presence */ |
3344 | sd->sensor = -1; | ||
3059 | 3345 | ||
3060 | /* Test for 76xx */ | 3346 | /* Test for 76xx */ |
3061 | if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { | 3347 | if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { |
3062 | if (ov7xx0_configure(sd) < 0) { | 3348 | ov7xx0_configure(sd); |
3063 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | 3349 | |
3064 | goto error; | ||
3065 | } | ||
3066 | /* Test for 6xx0 */ | 3350 | /* Test for 6xx0 */ |
3067 | } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { | 3351 | } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { |
3068 | if (ov6xx0_configure(sd) < 0) { | 3352 | ov6xx0_configure(sd); |
3069 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | 3353 | |
3070 | goto error; | ||
3071 | } | ||
3072 | /* Test for 8xx0 */ | 3354 | /* Test for 8xx0 */ |
3073 | } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { | 3355 | } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { |
3074 | if (ov8xx0_configure(sd) < 0) { | 3356 | ov8xx0_configure(sd); |
3075 | PDEBUG(D_ERR, "Failed to configure OV8xx0"); | 3357 | |
3076 | goto error; | ||
3077 | } | ||
3078 | /* Test for 3xxx / 2xxx */ | 3358 | /* Test for 3xxx / 2xxx */ |
3079 | } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { | 3359 | } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { |
3080 | if (ov_hires_configure(sd) < 0) { | 3360 | ov_hires_configure(sd); |
3081 | PDEBUG(D_ERR, "Failed to configure high res OV"); | ||
3082 | goto error; | ||
3083 | } | ||
3084 | } else { | 3361 | } else { |
3085 | PDEBUG(D_ERR, "Can't determine sensor slave IDs"); | 3362 | err("Can't determine sensor slave IDs"); |
3086 | goto error; | 3363 | goto error; |
3087 | } | 3364 | } |
3088 | 3365 | ||
3366 | if (sd->sensor < 0) | ||
3367 | goto error; | ||
3368 | |||
3369 | ov51x_led_control(sd, 0); /* turn LED off */ | ||
3370 | |||
3089 | switch (sd->bridge) { | 3371 | switch (sd->bridge) { |
3090 | case BRIDGE_OV511: | 3372 | case BRIDGE_OV511: |
3091 | case BRIDGE_OV511PLUS: | 3373 | case BRIDGE_OV511PLUS: |
3092 | if (!sd->sif) { | 3374 | if (sd->sif) { |
3093 | cam->cam_mode = ov511_vga_mode; | ||
3094 | cam->nmodes = ARRAY_SIZE(ov511_vga_mode); | ||
3095 | } else { | ||
3096 | cam->cam_mode = ov511_sif_mode; | 3375 | cam->cam_mode = ov511_sif_mode; |
3097 | cam->nmodes = ARRAY_SIZE(ov511_sif_mode); | 3376 | cam->nmodes = ARRAY_SIZE(ov511_sif_mode); |
3098 | } | 3377 | } |
3099 | break; | 3378 | break; |
3100 | case BRIDGE_OV518: | 3379 | case BRIDGE_OV518: |
3101 | case BRIDGE_OV518PLUS: | 3380 | case BRIDGE_OV518PLUS: |
3102 | if (!sd->sif) { | 3381 | if (sd->sif) { |
3103 | cam->cam_mode = ov518_vga_mode; | ||
3104 | cam->nmodes = ARRAY_SIZE(ov518_vga_mode); | ||
3105 | } else { | ||
3106 | cam->cam_mode = ov518_sif_mode; | 3382 | cam->cam_mode = ov518_sif_mode; |
3107 | cam->nmodes = ARRAY_SIZE(ov518_sif_mode); | 3383 | cam->nmodes = ARRAY_SIZE(ov518_sif_mode); |
3108 | } | 3384 | } |
3109 | break; | 3385 | break; |
3110 | case BRIDGE_OV519: | 3386 | case BRIDGE_OV519: |
3111 | if (!sd->sif) { | 3387 | if (sd->sif) { |
3112 | cam->cam_mode = ov519_vga_mode; | ||
3113 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); | ||
3114 | } else { | ||
3115 | cam->cam_mode = ov519_sif_mode; | 3388 | cam->cam_mode = ov519_sif_mode; |
3116 | cam->nmodes = ARRAY_SIZE(ov519_sif_mode); | 3389 | cam->nmodes = ARRAY_SIZE(ov519_sif_mode); |
3117 | } | 3390 | } |
3118 | break; | 3391 | break; |
3119 | case BRIDGE_OVFX2: | 3392 | case BRIDGE_OVFX2: |
3120 | if (sd->sensor == SEN_OV2610) { | 3393 | switch (sd->sensor) { |
3394 | case SEN_OV2610: | ||
3395 | case SEN_OV2610AE: | ||
3121 | cam->cam_mode = ovfx2_ov2610_mode; | 3396 | cam->cam_mode = ovfx2_ov2610_mode; |
3122 | cam->nmodes = ARRAY_SIZE(ovfx2_ov2610_mode); | 3397 | cam->nmodes = ARRAY_SIZE(ovfx2_ov2610_mode); |
3123 | } else if (sd->sensor == SEN_OV3610) { | 3398 | break; |
3399 | case SEN_OV3610: | ||
3124 | cam->cam_mode = ovfx2_ov3610_mode; | 3400 | cam->cam_mode = ovfx2_ov3610_mode; |
3125 | cam->nmodes = ARRAY_SIZE(ovfx2_ov3610_mode); | 3401 | cam->nmodes = ARRAY_SIZE(ovfx2_ov3610_mode); |
3126 | } else if (!sd->sif) { | 3402 | break; |
3127 | cam->cam_mode = ov519_vga_mode; | 3403 | default: |
3128 | cam->nmodes = ARRAY_SIZE(ov519_vga_mode); | 3404 | if (sd->sif) { |
3129 | } else { | 3405 | cam->cam_mode = ov519_sif_mode; |
3130 | cam->cam_mode = ov519_sif_mode; | 3406 | cam->nmodes = ARRAY_SIZE(ov519_sif_mode); |
3131 | cam->nmodes = ARRAY_SIZE(ov519_sif_mode); | 3407 | } |
3408 | break; | ||
3132 | } | 3409 | } |
3133 | break; | 3410 | break; |
3134 | case BRIDGE_W9968CF: | 3411 | case BRIDGE_W9968CF: |
3135 | cam->cam_mode = w9968cf_vga_mode; | ||
3136 | cam->nmodes = ARRAY_SIZE(w9968cf_vga_mode); | ||
3137 | if (sd->sif) | 3412 | if (sd->sif) |
3138 | cam->nmodes--; | 3413 | cam->nmodes = ARRAY_SIZE(w9968cf_vga_mode) - 1; |
3139 | 3414 | ||
3140 | /* w9968cf needs initialisation once the sensor is known */ | 3415 | /* w9968cf needs initialisation once the sensor is known */ |
3141 | if (w9968cf_init(sd) < 0) | 3416 | w9968cf_init(sd); |
3142 | goto error; | ||
3143 | break; | 3417 | break; |
3144 | } | 3418 | } |
3145 | sd->brightness = BRIGHTNESS_DEF; | ||
3146 | if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF) | ||
3147 | sd->contrast = 200; /* The default is too low for the ov6630 */ | ||
3148 | else | ||
3149 | sd->contrast = CONTRAST_DEF; | ||
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; | ||
3163 | if (sd->sensor == SEN_OV7640 || | ||
3164 | sd->sensor == SEN_OV7648) | ||
3165 | gspca_dev->ctrl_dis |= (1 << AUTOBRIGHT_IDX) | | ||
3166 | (1 << CONTRAST_IDX); | ||
3167 | if (sd->sensor == SEN_OV7670) | ||
3168 | gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT_IDX; | ||
3169 | /* OV8610 Frequency filter control should work but needs testing */ | ||
3170 | if (sd->sensor == SEN_OV8610) | ||
3171 | gspca_dev->ctrl_dis |= 1 << FREQ_IDX; | ||
3172 | /* No controls for the OV2610/OV3610 */ | ||
3173 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | ||
3174 | gspca_dev->ctrl_dis |= 0xFF; | ||
3175 | |||
3176 | return 0; | ||
3177 | error: | ||
3178 | PDEBUG(D_ERR, "OV519 Config failed"); | ||
3179 | return -EBUSY; | ||
3180 | } | ||
3181 | 3419 | ||
3182 | /* this function is called at probe and resume time */ | 3420 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
3183 | static int sd_init(struct gspca_dev *gspca_dev) | ||
3184 | { | ||
3185 | struct sd *sd = (struct sd *) gspca_dev; | ||
3186 | 3421 | ||
3187 | /* initialize the sensor */ | 3422 | /* initialize the sensor */ |
3188 | switch (sd->sensor) { | 3423 | switch (sd->sensor) { |
3189 | case SEN_OV2610: | 3424 | case SEN_OV2610: |
3190 | if (write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610))) | 3425 | write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610)); |
3191 | return -EIO; | 3426 | |
3192 | /* Enable autogain, autoexpo, awb, bandfilter */ | 3427 | /* Enable autogain, autoexpo, awb, bandfilter */ |
3193 | if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0) | 3428 | i2c_w_mask(sd, 0x13, 0x27, 0x27); |
3194 | return -EIO; | 3429 | break; |
3430 | case SEN_OV2610AE: | ||
3431 | write_i2c_regvals(sd, norm_2610ae, ARRAY_SIZE(norm_2610ae)); | ||
3432 | |||
3433 | /* enable autoexpo */ | ||
3434 | i2c_w_mask(sd, 0x13, 0x05, 0x05); | ||
3195 | break; | 3435 | break; |
3196 | case SEN_OV3610: | 3436 | case SEN_OV3610: |
3197 | if (write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b))) | 3437 | write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b)); |
3198 | return -EIO; | 3438 | |
3199 | /* Enable autogain, autoexpo, awb, bandfilter */ | 3439 | /* Enable autogain, autoexpo, awb, bandfilter */ |
3200 | if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0) | 3440 | i2c_w_mask(sd, 0x13, 0x27, 0x27); |
3201 | return -EIO; | ||
3202 | break; | 3441 | break; |
3203 | case SEN_OV6620: | 3442 | case SEN_OV6620: |
3204 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | 3443 | write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20)); |
3205 | return -EIO; | ||
3206 | break; | 3444 | break; |
3207 | case SEN_OV6630: | 3445 | case SEN_OV6630: |
3208 | case SEN_OV66308AF: | 3446 | case SEN_OV66308AF: |
3209 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | 3447 | sd->ctrls[CONTRAST].def = 200; |
3210 | return -EIO; | 3448 | /* The default is too low for the ov6630 */ |
3449 | write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30)); | ||
3211 | break; | 3450 | break; |
3212 | default: | 3451 | default: |
3213 | /* case SEN_OV7610: */ | 3452 | /* case SEN_OV7610: */ |
3214 | /* case SEN_OV76BE: */ | 3453 | /* case SEN_OV76BE: */ |
3215 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | 3454 | write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610)); |
3216 | return -EIO; | 3455 | i2c_w_mask(sd, 0x0e, 0x00, 0x40); |
3217 | if (i2c_w_mask(sd, 0x0e, 0x00, 0x40)) | ||
3218 | return -EIO; | ||
3219 | break; | 3456 | break; |
3220 | case SEN_OV7620: | 3457 | case SEN_OV7620: |
3221 | case SEN_OV7620AE: | 3458 | case SEN_OV7620AE: |
3222 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | 3459 | write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620)); |
3223 | return -EIO; | ||
3224 | break; | 3460 | break; |
3225 | case SEN_OV7640: | 3461 | case SEN_OV7640: |
3226 | case SEN_OV7648: | 3462 | case SEN_OV7648: |
3227 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | 3463 | write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640)); |
3228 | return -EIO; | 3464 | break; |
3465 | case SEN_OV7660: | ||
3466 | i2c_w(sd, OV7670_R12_COM7, OV7670_COM7_RESET); | ||
3467 | msleep(14); | ||
3468 | reg_w(sd, OV519_R57_SNAPSHOT, 0x23); | ||
3469 | write_regvals(sd, init_519_ov7660, | ||
3470 | ARRAY_SIZE(init_519_ov7660)); | ||
3471 | write_i2c_regvals(sd, norm_7660, ARRAY_SIZE(norm_7660)); | ||
3472 | sd->gspca_dev.curr_mode = 1; /* 640x480 */ | ||
3473 | ov519_set_mode(sd); | ||
3474 | ov519_set_fr(sd); | ||
3475 | sd->ctrls[COLORS].max = 4; /* 0..4 */ | ||
3476 | sd->ctrls[COLORS].val = | ||
3477 | sd->ctrls[COLORS].def = 2; | ||
3478 | setcolors(gspca_dev); | ||
3479 | sd->ctrls[CONTRAST].max = 6; /* 0..6 */ | ||
3480 | sd->ctrls[CONTRAST].val = | ||
3481 | sd->ctrls[CONTRAST].def = 3; | ||
3482 | setcontrast(gspca_dev); | ||
3483 | sd->ctrls[BRIGHTNESS].max = 6; /* 0..6 */ | ||
3484 | sd->ctrls[BRIGHTNESS].val = | ||
3485 | sd->ctrls[BRIGHTNESS].def = 3; | ||
3486 | setbrightness(gspca_dev); | ||
3487 | sd_reset_snapshot(gspca_dev); | ||
3488 | ov51x_restart(sd); | ||
3489 | ov51x_stop(sd); /* not in win traces */ | ||
3490 | ov51x_led_control(sd, 0); | ||
3229 | break; | 3491 | break; |
3230 | case SEN_OV7670: | 3492 | case SEN_OV7670: |
3231 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | 3493 | sd->ctrls[FREQ].max = 3; /* auto */ |
3232 | return -EIO; | 3494 | sd->ctrls[FREQ].def = 3; |
3495 | write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670)); | ||
3233 | break; | 3496 | break; |
3234 | case SEN_OV8610: | 3497 | case SEN_OV8610: |
3235 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | 3498 | write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610)); |
3236 | return -EIO; | 3499 | break; |
3500 | } | ||
3501 | return gspca_dev->usb_err; | ||
3502 | error: | ||
3503 | PDEBUG(D_ERR, "OV519 Config failed"); | ||
3504 | return -EINVAL; | ||
3505 | } | ||
3506 | |||
3507 | /* function called at start time before URB creation */ | ||
3508 | static int sd_isoc_init(struct gspca_dev *gspca_dev) | ||
3509 | { | ||
3510 | struct sd *sd = (struct sd *) gspca_dev; | ||
3511 | |||
3512 | switch (sd->bridge) { | ||
3513 | case BRIDGE_OVFX2: | ||
3514 | if (gspca_dev->width != 800) | ||
3515 | gspca_dev->cam.bulk_size = OVFX2_BULK_SIZE; | ||
3516 | else | ||
3517 | gspca_dev->cam.bulk_size = 7 * 4096; | ||
3237 | break; | 3518 | break; |
3238 | } | 3519 | } |
3239 | return 0; | 3520 | return 0; |
@@ -3243,7 +3524,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3243 | * | 3524 | * |
3244 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3525 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3245 | */ | 3526 | */ |
3246 | static int ov511_mode_init_regs(struct sd *sd) | 3527 | static void ov511_mode_init_regs(struct sd *sd) |
3247 | { | 3528 | { |
3248 | int hsegs, vsegs, packet_size, fps, needed; | 3529 | int hsegs, vsegs, packet_size, fps, needed; |
3249 | int interlaced = 0; | 3530 | int interlaced = 0; |
@@ -3253,8 +3534,9 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3253 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | 3534 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); |
3254 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | 3535 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); |
3255 | if (!alt) { | 3536 | if (!alt) { |
3256 | PDEBUG(D_ERR, "Couldn't get altsetting"); | 3537 | err("Couldn't get altsetting"); |
3257 | return -EIO; | 3538 | sd->gspca_dev.usb_err = -EIO; |
3539 | return; | ||
3258 | } | 3540 | } |
3259 | 3541 | ||
3260 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 3542 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); |
@@ -3357,8 +3639,6 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3357 | 3639 | ||
3358 | reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); | 3640 | reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); |
3359 | reg_w(sd, R51x_SYS_RESET, 0); | 3641 | reg_w(sd, R51x_SYS_RESET, 0); |
3360 | |||
3361 | return 0; | ||
3362 | } | 3642 | } |
3363 | 3643 | ||
3364 | /* Sets up the OV518/OV518+ with the given image parameters | 3644 | /* Sets up the OV518/OV518+ with the given image parameters |
@@ -3368,7 +3648,7 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3368 | * | 3648 | * |
3369 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3649 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3370 | */ | 3650 | */ |
3371 | static int ov518_mode_init_regs(struct sd *sd) | 3651 | static void ov518_mode_init_regs(struct sd *sd) |
3372 | { | 3652 | { |
3373 | int hsegs, vsegs, packet_size; | 3653 | int hsegs, vsegs, packet_size; |
3374 | struct usb_host_interface *alt; | 3654 | struct usb_host_interface *alt; |
@@ -3377,15 +3657,15 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3377 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | 3657 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); |
3378 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | 3658 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); |
3379 | if (!alt) { | 3659 | if (!alt) { |
3380 | PDEBUG(D_ERR, "Couldn't get altsetting"); | 3660 | err("Couldn't get altsetting"); |
3381 | return -EIO; | 3661 | sd->gspca_dev.usb_err = -EIO; |
3662 | return; | ||
3382 | } | 3663 | } |
3383 | 3664 | ||
3384 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 3665 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); |
3385 | ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2); | 3666 | ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2); |
3386 | 3667 | ||
3387 | /******** Set the mode ********/ | 3668 | /******** Set the mode ********/ |
3388 | |||
3389 | reg_w(sd, 0x2b, 0); | 3669 | reg_w(sd, 0x2b, 0); |
3390 | reg_w(sd, 0x2c, 0); | 3670 | reg_w(sd, 0x2c, 0); |
3391 | reg_w(sd, 0x2d, 0); | 3671 | reg_w(sd, 0x2d, 0); |
@@ -3419,7 +3699,7 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3419 | /* Windows driver does this here; who knows why */ | 3699 | /* Windows driver does this here; who knows why */ |
3420 | reg_w(sd, 0x2f, 0x80); | 3700 | reg_w(sd, 0x2f, 0x80); |
3421 | 3701 | ||
3422 | /******** Set the framerate ********/ | 3702 | /******** Set the framerate ********/ |
3423 | sd->clockdiv = 1; | 3703 | sd->clockdiv = 1; |
3424 | 3704 | ||
3425 | /* Mode independent, but framerate dependent, regs */ | 3705 | /* Mode independent, but framerate dependent, regs */ |
@@ -3482,11 +3762,8 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3482 | } | 3762 | } |
3483 | 3763 | ||
3484 | reg_w(sd, 0x2f, 0x80); | 3764 | reg_w(sd, 0x2f, 0x80); |
3485 | |||
3486 | return 0; | ||
3487 | } | 3765 | } |
3488 | 3766 | ||
3489 | |||
3490 | /* Sets up the OV519 with the given image parameters | 3767 | /* Sets up the OV519 with the given image parameters |
3491 | * | 3768 | * |
3492 | * OV519 needs a completely different approach, until we can figure out what | 3769 | * OV519 needs a completely different approach, until we can figure out what |
@@ -3494,12 +3771,12 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3494 | * | 3771 | * |
3495 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3772 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3496 | */ | 3773 | */ |
3497 | static int ov519_mode_init_regs(struct sd *sd) | 3774 | static void ov519_mode_init_regs(struct sd *sd) |
3498 | { | 3775 | { |
3499 | static const struct ov_regvals mode_init_519_ov7670[] = { | 3776 | static const struct ov_regvals mode_init_519_ov7670[] = { |
3500 | { 0x5d, 0x03 }, /* Turn off suspend mode */ | 3777 | { 0x5d, 0x03 }, /* Turn off suspend mode */ |
3501 | { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ | 3778 | { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ |
3502 | { 0x54, 0x0f }, /* bit2 (jpeg enable) */ | 3779 | { OV519_R54_EN_CLK1, 0x0f }, /* bit2 (jpeg enable) */ |
3503 | { 0xa2, 0x20 }, /* a2-a5 are undocumented */ | 3780 | { 0xa2, 0x20 }, /* a2-a5 are undocumented */ |
3504 | { 0xa3, 0x18 }, | 3781 | { 0xa3, 0x18 }, |
3505 | { 0xa4, 0x04 }, | 3782 | { 0xa4, 0x04 }, |
@@ -3522,7 +3799,7 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
3522 | static const struct ov_regvals mode_init_519[] = { | 3799 | static const struct ov_regvals mode_init_519[] = { |
3523 | { 0x5d, 0x03 }, /* Turn off suspend mode */ | 3800 | { 0x5d, 0x03 }, /* Turn off suspend mode */ |
3524 | { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ | 3801 | { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ |
3525 | { 0x54, 0x0f }, /* bit2 (jpeg enable) */ | 3802 | { OV519_R54_EN_CLK1, 0x0f }, /* bit2 (jpeg enable) */ |
3526 | { 0xa2, 0x20 }, /* a2-a5 are undocumented */ | 3803 | { 0xa2, 0x20 }, /* a2-a5 are undocumented */ |
3527 | { 0xa3, 0x18 }, | 3804 | { 0xa3, 0x18 }, |
3528 | { 0xa4, 0x04 }, | 3805 | { 0xa4, 0x04 }, |
@@ -3541,19 +3818,21 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
3541 | }; | 3818 | }; |
3542 | 3819 | ||
3543 | /******** Set the mode ********/ | 3820 | /******** Set the mode ********/ |
3544 | if (sd->sensor != SEN_OV7670) { | 3821 | switch (sd->sensor) { |
3545 | if (write_regvals(sd, mode_init_519, | 3822 | default: |
3546 | ARRAY_SIZE(mode_init_519))) | 3823 | write_regvals(sd, mode_init_519, ARRAY_SIZE(mode_init_519)); |
3547 | return -EIO; | ||
3548 | if (sd->sensor == SEN_OV7640 || | 3824 | if (sd->sensor == SEN_OV7640 || |
3549 | sd->sensor == SEN_OV7648) { | 3825 | sd->sensor == SEN_OV7648) { |
3550 | /* Select 8-bit input mode */ | 3826 | /* Select 8-bit input mode */ |
3551 | reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10); | 3827 | reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10); |
3552 | } | 3828 | } |
3553 | } else { | 3829 | break; |
3554 | if (write_regvals(sd, mode_init_519_ov7670, | 3830 | case SEN_OV7660: |
3555 | ARRAY_SIZE(mode_init_519_ov7670))) | 3831 | return; /* done by ov519_set_mode/fr() */ |
3556 | return -EIO; | 3832 | case SEN_OV7670: |
3833 | write_regvals(sd, mode_init_519_ov7670, | ||
3834 | ARRAY_SIZE(mode_init_519_ov7670)); | ||
3835 | break; | ||
3557 | } | 3836 | } |
3558 | 3837 | ||
3559 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); | 3838 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); |
@@ -3649,17 +3928,16 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
3649 | } | 3928 | } |
3650 | break; | 3929 | break; |
3651 | } | 3930 | } |
3652 | return 0; | ||
3653 | } | 3931 | } |
3654 | 3932 | ||
3655 | static int mode_init_ov_sensor_regs(struct sd *sd) | 3933 | static void mode_init_ov_sensor_regs(struct sd *sd) |
3656 | { | 3934 | { |
3657 | struct gspca_dev *gspca_dev; | 3935 | struct gspca_dev *gspca_dev; |
3658 | int qvga, xstart, xend, ystart, yend; | 3936 | int qvga, xstart, xend, ystart, yend; |
3659 | __u8 v; | 3937 | u8 v; |
3660 | 3938 | ||
3661 | gspca_dev = &sd->gspca_dev; | 3939 | gspca_dev = &sd->gspca_dev; |
3662 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1; | 3940 | qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; |
3663 | 3941 | ||
3664 | /******** Mode (VGA/QVGA) and sensor specific regs ********/ | 3942 | /******** Mode (VGA/QVGA) and sensor specific regs ********/ |
3665 | switch (sd->sensor) { | 3943 | switch (sd->sensor) { |
@@ -3671,7 +3949,26 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3671 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); | 3949 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); |
3672 | i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); | 3950 | i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); |
3673 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); | 3951 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); |
3674 | return 0; | 3952 | return; |
3953 | case SEN_OV2610AE: { | ||
3954 | u8 v; | ||
3955 | |||
3956 | /* frame rates: | ||
3957 | * 10fps / 5 fps for 1600x1200 | ||
3958 | * 40fps / 20fps for 800x600 | ||
3959 | */ | ||
3960 | v = 80; | ||
3961 | if (qvga) { | ||
3962 | if (sd->frame_rate < 25) | ||
3963 | v = 0x81; | ||
3964 | } else { | ||
3965 | if (sd->frame_rate < 10) | ||
3966 | v = 0x81; | ||
3967 | } | ||
3968 | i2c_w(sd, 0x11, v); | ||
3969 | i2c_w(sd, 0x12, qvga ? 0x60 : 0x20); | ||
3970 | return; | ||
3971 | } | ||
3675 | case SEN_OV3610: | 3972 | case SEN_OV3610: |
3676 | if (qvga) { | 3973 | if (qvga) { |
3677 | xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4); | 3974 | xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4); |
@@ -3695,7 +3992,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3695 | i2c_w(sd, 0x18, xend >> 4); | 3992 | i2c_w(sd, 0x18, xend >> 4); |
3696 | i2c_w(sd, 0x19, ystart >> 3); | 3993 | i2c_w(sd, 0x19, ystart >> 3); |
3697 | i2c_w(sd, 0x1a, yend >> 3); | 3994 | i2c_w(sd, 0x1a, yend >> 3); |
3698 | return 0; | 3995 | return; |
3699 | case SEN_OV8610: | 3996 | case SEN_OV8610: |
3700 | /* For OV8610 qvga means qsvga */ | 3997 | /* For OV8610 qvga means qsvga */ |
3701 | i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); | 3998 | i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); |
@@ -3706,7 +4003,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3706 | break; | 4003 | break; |
3707 | case SEN_OV7610: | 4004 | case SEN_OV7610: |
3708 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 4005 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
3709 | i2c_w(sd, 0x35, qvga?0x1e:0x9e); | 4006 | i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e); |
3710 | i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ | 4007 | 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 */ | 4008 | i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ |
3712 | break; | 4009 | break; |
@@ -3742,11 +4039,11 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3742 | /* set COM7_FMT_VGA or COM7_FMT_QVGA | 4039 | /* set COM7_FMT_VGA or COM7_FMT_QVGA |
3743 | * do we need to set anything else? | 4040 | * do we need to set anything else? |
3744 | * HSTART etc are set in set_ov_sensor_window itself */ | 4041 | * HSTART etc are set in set_ov_sensor_window itself */ |
3745 | i2c_w_mask(sd, OV7670_REG_COM7, | 4042 | i2c_w_mask(sd, OV7670_R12_COM7, |
3746 | qvga ? OV7670_COM7_FMT_QVGA : OV7670_COM7_FMT_VGA, | 4043 | qvga ? OV7670_COM7_FMT_QVGA : OV7670_COM7_FMT_VGA, |
3747 | OV7670_COM7_FMT_MASK); | 4044 | OV7670_COM7_FMT_MASK); |
3748 | i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ | 4045 | i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ |
3749 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_AWB, | 4046 | i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_AWB, |
3750 | OV7670_COM8_AWB); | 4047 | OV7670_COM8_AWB); |
3751 | if (qvga) { /* QVGA from ov7670.c by | 4048 | if (qvga) { /* QVGA from ov7670.c by |
3752 | * Jonathan Corbet */ | 4049 | * Jonathan Corbet */ |
@@ -3762,21 +4059,21 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3762 | } | 4059 | } |
3763 | /* OV7670 hardware window registers are split across | 4060 | /* OV7670 hardware window registers are split across |
3764 | * multiple locations */ | 4061 | * multiple locations */ |
3765 | i2c_w(sd, OV7670_REG_HSTART, xstart >> 3); | 4062 | i2c_w(sd, OV7670_R17_HSTART, xstart >> 3); |
3766 | i2c_w(sd, OV7670_REG_HSTOP, xend >> 3); | 4063 | i2c_w(sd, OV7670_R18_HSTOP, xend >> 3); |
3767 | v = i2c_r(sd, OV7670_REG_HREF); | 4064 | v = i2c_r(sd, OV7670_R32_HREF); |
3768 | v = (v & 0xc0) | ((xend & 0x7) << 3) | (xstart & 0x07); | 4065 | v = (v & 0xc0) | ((xend & 0x7) << 3) | (xstart & 0x07); |
3769 | msleep(10); /* need to sleep between read and write to | 4066 | msleep(10); /* need to sleep between read and write to |
3770 | * same reg! */ | 4067 | * same reg! */ |
3771 | i2c_w(sd, OV7670_REG_HREF, v); | 4068 | i2c_w(sd, OV7670_R32_HREF, v); |
3772 | 4069 | ||
3773 | i2c_w(sd, OV7670_REG_VSTART, ystart >> 2); | 4070 | i2c_w(sd, OV7670_R19_VSTART, ystart >> 2); |
3774 | i2c_w(sd, OV7670_REG_VSTOP, yend >> 2); | 4071 | i2c_w(sd, OV7670_R1A_VSTOP, yend >> 2); |
3775 | v = i2c_r(sd, OV7670_REG_VREF); | 4072 | v = i2c_r(sd, OV7670_R03_VREF); |
3776 | v = (v & 0xc0) | ((yend & 0x3) << 2) | (ystart & 0x03); | 4073 | v = (v & 0xc0) | ((yend & 0x3) << 2) | (ystart & 0x03); |
3777 | msleep(10); /* need to sleep between read and write to | 4074 | msleep(10); /* need to sleep between read and write to |
3778 | * same reg! */ | 4075 | * same reg! */ |
3779 | i2c_w(sd, OV7670_REG_VREF, v); | 4076 | i2c_w(sd, OV7670_R03_VREF, v); |
3780 | break; | 4077 | break; |
3781 | case SEN_OV6620: | 4078 | case SEN_OV6620: |
3782 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 4079 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
@@ -3789,44 +4086,51 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3789 | i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ | 4086 | i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ |
3790 | break; | 4087 | break; |
3791 | default: | 4088 | default: |
3792 | return -EINVAL; | 4089 | return; |
3793 | } | 4090 | } |
3794 | 4091 | ||
3795 | /******** Clock programming ********/ | 4092 | /******** Clock programming ********/ |
3796 | i2c_w(sd, 0x11, sd->clockdiv); | 4093 | i2c_w(sd, 0x11, sd->clockdiv); |
3797 | |||
3798 | return 0; | ||
3799 | } | 4094 | } |
3800 | 4095 | ||
3801 | static void sethvflip(struct sd *sd) | 4096 | /* this function works for bridge ov519 and sensors ov7660 and ov7670 only */ |
4097 | static void sethvflip(struct gspca_dev *gspca_dev) | ||
3802 | { | 4098 | { |
3803 | if (sd->sensor != SEN_OV7670) | 4099 | struct sd *sd = (struct sd *) gspca_dev; |
3804 | return; | 4100 | |
3805 | if (sd->gspca_dev.streaming) | 4101 | if (sd->gspca_dev.streaming) |
3806 | ov51x_stop(sd); | 4102 | reg_w(sd, OV519_R51_RESET1, 0x0f); /* block stream */ |
3807 | i2c_w_mask(sd, OV7670_REG_MVFP, | 4103 | i2c_w_mask(sd, OV7670_R1E_MVFP, |
3808 | OV7670_MVFP_MIRROR * sd->hflip | 4104 | OV7670_MVFP_MIRROR * sd->ctrls[HFLIP].val |
3809 | | OV7670_MVFP_VFLIP * sd->vflip, | 4105 | | OV7670_MVFP_VFLIP * sd->ctrls[VFLIP].val, |
3810 | OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP); | 4106 | OV7670_MVFP_MIRROR | OV7670_MVFP_VFLIP); |
3811 | if (sd->gspca_dev.streaming) | 4107 | if (sd->gspca_dev.streaming) |
3812 | ov51x_restart(sd); | 4108 | reg_w(sd, OV519_R51_RESET1, 0x00); /* restart stream */ |
3813 | } | 4109 | } |
3814 | 4110 | ||
3815 | static int set_ov_sensor_window(struct sd *sd) | 4111 | static void set_ov_sensor_window(struct sd *sd) |
3816 | { | 4112 | { |
3817 | struct gspca_dev *gspca_dev; | 4113 | struct gspca_dev *gspca_dev; |
3818 | int qvga, crop; | 4114 | int qvga, crop; |
3819 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; | 4115 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; |
3820 | int ret; | ||
3821 | 4116 | ||
3822 | /* mode setup is fully handled in mode_init_ov_sensor_regs for these */ | 4117 | /* mode setup is fully handled in mode_init_ov_sensor_regs for these */ |
3823 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610 || | 4118 | switch (sd->sensor) { |
3824 | sd->sensor == SEN_OV7670) | 4119 | case SEN_OV2610: |
3825 | return mode_init_ov_sensor_regs(sd); | 4120 | case SEN_OV2610AE: |
4121 | case SEN_OV3610: | ||
4122 | case SEN_OV7670: | ||
4123 | mode_init_ov_sensor_regs(sd); | ||
4124 | return; | ||
4125 | case SEN_OV7660: | ||
4126 | ov519_set_mode(sd); | ||
4127 | ov519_set_fr(sd); | ||
4128 | return; | ||
4129 | } | ||
3826 | 4130 | ||
3827 | gspca_dev = &sd->gspca_dev; | 4131 | gspca_dev = &sd->gspca_dev; |
3828 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1; | 4132 | qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; |
3829 | crop = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 2; | 4133 | crop = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 2; |
3830 | 4134 | ||
3831 | /* The different sensor ICs handle setting up of window differently. | 4135 | /* The different sensor ICs handle setting up of window differently. |
3832 | * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */ | 4136 | * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */ |
@@ -3873,7 +4177,7 @@ static int set_ov_sensor_window(struct sd *sd) | |||
3873 | vwsbase = vwebase = 0x03; | 4177 | vwsbase = vwebase = 0x03; |
3874 | break; | 4178 | break; |
3875 | default: | 4179 | default: |
3876 | return -EINVAL; | 4180 | return; |
3877 | } | 4181 | } |
3878 | 4182 | ||
3879 | switch (sd->sensor) { | 4183 | switch (sd->sensor) { |
@@ -3908,23 +4212,18 @@ static int set_ov_sensor_window(struct sd *sd) | |||
3908 | } | 4212 | } |
3909 | } | 4213 | } |
3910 | 4214 | ||
3911 | ret = mode_init_ov_sensor_regs(sd); | 4215 | mode_init_ov_sensor_regs(sd); |
3912 | if (ret < 0) | ||
3913 | return ret; | ||
3914 | 4216 | ||
3915 | i2c_w(sd, 0x17, hwsbase); | 4217 | i2c_w(sd, 0x17, hwsbase); |
3916 | i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); | 4218 | i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); |
3917 | i2c_w(sd, 0x19, vwsbase); | 4219 | i2c_w(sd, 0x19, vwsbase); |
3918 | i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); | 4220 | i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); |
3919 | |||
3920 | return 0; | ||
3921 | } | 4221 | } |
3922 | 4222 | ||
3923 | /* -- start the camera -- */ | 4223 | /* -- start the camera -- */ |
3924 | static int sd_start(struct gspca_dev *gspca_dev) | 4224 | static int sd_start(struct gspca_dev *gspca_dev) |
3925 | { | 4225 | { |
3926 | struct sd *sd = (struct sd *) gspca_dev; | 4226 | struct sd *sd = (struct sd *) gspca_dev; |
3927 | int ret = 0; | ||
3928 | 4227 | ||
3929 | /* Default for most bridges, allow bridge_mode_init_regs to override */ | 4228 | /* Default for most bridges, allow bridge_mode_init_regs to override */ |
3930 | sd->sensor_width = sd->gspca_dev.width; | 4229 | sd->sensor_width = sd->gspca_dev.width; |
@@ -3933,50 +4232,50 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
3933 | switch (sd->bridge) { | 4232 | switch (sd->bridge) { |
3934 | case BRIDGE_OV511: | 4233 | case BRIDGE_OV511: |
3935 | case BRIDGE_OV511PLUS: | 4234 | case BRIDGE_OV511PLUS: |
3936 | ret = ov511_mode_init_regs(sd); | 4235 | ov511_mode_init_regs(sd); |
3937 | break; | 4236 | break; |
3938 | case BRIDGE_OV518: | 4237 | case BRIDGE_OV518: |
3939 | case BRIDGE_OV518PLUS: | 4238 | case BRIDGE_OV518PLUS: |
3940 | ret = ov518_mode_init_regs(sd); | 4239 | ov518_mode_init_regs(sd); |
3941 | break; | 4240 | break; |
3942 | case BRIDGE_OV519: | 4241 | case BRIDGE_OV519: |
3943 | ret = ov519_mode_init_regs(sd); | 4242 | ov519_mode_init_regs(sd); |
3944 | break; | 4243 | break; |
3945 | /* case BRIDGE_OVFX2: nothing to do */ | 4244 | /* case BRIDGE_OVFX2: nothing to do */ |
3946 | case BRIDGE_W9968CF: | 4245 | case BRIDGE_W9968CF: |
3947 | ret = w9968cf_mode_init_regs(sd); | 4246 | w9968cf_mode_init_regs(sd); |
3948 | break; | 4247 | break; |
3949 | } | 4248 | } |
3950 | if (ret < 0) | ||
3951 | goto out; | ||
3952 | 4249 | ||
3953 | ret = set_ov_sensor_window(sd); | 4250 | set_ov_sensor_window(sd); |
3954 | if (ret < 0) | ||
3955 | goto out; | ||
3956 | 4251 | ||
3957 | setcontrast(gspca_dev); | 4252 | if (!(sd->gspca_dev.ctrl_dis & (1 << CONTRAST))) |
3958 | setbrightness(gspca_dev); | 4253 | setcontrast(gspca_dev); |
3959 | setcolors(gspca_dev); | 4254 | if (!(sd->gspca_dev.ctrl_dis & (1 << BRIGHTNESS))) |
3960 | sethvflip(sd); | 4255 | setbrightness(gspca_dev); |
3961 | setautobrightness(sd); | 4256 | if (!(sd->gspca_dev.ctrl_dis & (1 << EXPOSURE))) |
3962 | setfreq(sd); | 4257 | setexposure(gspca_dev); |
4258 | if (!(sd->gspca_dev.ctrl_dis & (1 << COLORS))) | ||
4259 | setcolors(gspca_dev); | ||
4260 | if (!(sd->gspca_dev.ctrl_dis & ((1 << HFLIP) | (1 << VFLIP)))) | ||
4261 | sethvflip(gspca_dev); | ||
4262 | if (!(sd->gspca_dev.ctrl_dis & (1 << AUTOBRIGHT))) | ||
4263 | setautobright(gspca_dev); | ||
4264 | if (!(sd->gspca_dev.ctrl_dis & (1 << AUTOGAIN))) | ||
4265 | setautogain(gspca_dev); | ||
4266 | if (!(sd->gspca_dev.ctrl_dis & (1 << FREQ))) | ||
4267 | setfreq_i(sd); | ||
3963 | 4268 | ||
3964 | /* Force clear snapshot state in case the snapshot button was | 4269 | /* Force clear snapshot state in case the snapshot button was |
3965 | pressed while we weren't streaming */ | 4270 | pressed while we weren't streaming */ |
3966 | sd->snapshot_needs_reset = 1; | 4271 | sd->snapshot_needs_reset = 1; |
3967 | sd_reset_snapshot(gspca_dev); | 4272 | sd_reset_snapshot(gspca_dev); |
3968 | sd->snapshot_pressed = 0; | ||
3969 | 4273 | ||
3970 | sd->first_frame = 3; | 4274 | sd->first_frame = 3; |
3971 | 4275 | ||
3972 | ret = ov51x_restart(sd); | 4276 | ov51x_restart(sd); |
3973 | if (ret < 0) | ||
3974 | goto out; | ||
3975 | ov51x_led_control(sd, 1); | 4277 | ov51x_led_control(sd, 1); |
3976 | return 0; | 4278 | return gspca_dev->usb_err; |
3977 | out: | ||
3978 | PDEBUG(D_ERR, "camera start error:%d", ret); | ||
3979 | return ret; | ||
3980 | } | 4279 | } |
3981 | 4280 | ||
3982 | static void sd_stopN(struct gspca_dev *gspca_dev) | 4281 | static void sd_stopN(struct gspca_dev *gspca_dev) |
@@ -3991,8 +4290,21 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
3991 | { | 4290 | { |
3992 | struct sd *sd = (struct sd *) gspca_dev; | 4291 | struct sd *sd = (struct sd *) gspca_dev; |
3993 | 4292 | ||
4293 | if (!sd->gspca_dev.present) | ||
4294 | return; | ||
3994 | if (sd->bridge == BRIDGE_W9968CF) | 4295 | if (sd->bridge == BRIDGE_W9968CF) |
3995 | w9968cf_stop0(sd); | 4296 | w9968cf_stop0(sd); |
4297 | |||
4298 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
4299 | /* If the last button state is pressed, release it now! */ | ||
4300 | if (sd->snapshot_pressed) { | ||
4301 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | ||
4302 | input_sync(gspca_dev->input_dev); | ||
4303 | sd->snapshot_pressed = 0; | ||
4304 | } | ||
4305 | #endif | ||
4306 | if (sd->bridge == BRIDGE_OV519) | ||
4307 | reg_w(sd, OV519_R57_SNAPSHOT, 0x23); | ||
3996 | } | 4308 | } |
3997 | 4309 | ||
3998 | static void ov51x_handle_button(struct gspca_dev *gspca_dev, u8 state) | 4310 | static void ov51x_handle_button(struct gspca_dev *gspca_dev, u8 state) |
@@ -4000,7 +4312,7 @@ static void ov51x_handle_button(struct gspca_dev *gspca_dev, u8 state) | |||
4000 | struct sd *sd = (struct sd *) gspca_dev; | 4312 | struct sd *sd = (struct sd *) gspca_dev; |
4001 | 4313 | ||
4002 | if (sd->snapshot_pressed != state) { | 4314 | if (sd->snapshot_pressed != state) { |
4003 | #ifdef CONFIG_INPUT | 4315 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
4004 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); | 4316 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); |
4005 | input_sync(gspca_dev->input_dev); | 4317 | input_sync(gspca_dev->input_dev); |
4006 | #endif | 4318 | #endif |
@@ -4056,7 +4368,7 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev, | |||
4056 | gspca_dev->last_packet_type = DISCARD_PACKET; | 4368 | gspca_dev->last_packet_type = DISCARD_PACKET; |
4057 | return; | 4369 | return; |
4058 | } | 4370 | } |
4059 | /* Add 11 byte footer to frame, might be usefull */ | 4371 | /* Add 11 byte footer to frame, might be useful */ |
4060 | gspca_frame_add(gspca_dev, LAST_PACKET, in, 11); | 4372 | gspca_frame_add(gspca_dev, LAST_PACKET, in, 11); |
4061 | return; | 4373 | return; |
4062 | } else { | 4374 | } else { |
@@ -4166,7 +4478,7 @@ static void ovfx2_pkt_scan(struct gspca_dev *gspca_dev, | |||
4166 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 4478 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
4167 | 4479 | ||
4168 | /* A short read signals EOF */ | 4480 | /* A short read signals EOF */ |
4169 | if (len < OVFX2_BULK_SIZE) { | 4481 | if (len < gspca_dev->cam.bulk_size) { |
4170 | /* If the frame is short, and it is one of the first ones | 4482 | /* If the frame is short, and it is one of the first ones |
4171 | the sensor and bridge are still syncing, so drop it. */ | 4483 | the sensor and bridge are still syncing, so drop it. */ |
4172 | if (sd->first_frame) { | 4484 | if (sd->first_frame) { |
@@ -4213,8 +4525,24 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
4213 | { | 4525 | { |
4214 | struct sd *sd = (struct sd *) gspca_dev; | 4526 | struct sd *sd = (struct sd *) gspca_dev; |
4215 | int val; | 4527 | int val; |
4528 | static const struct ov_i2c_regvals brit_7660[][7] = { | ||
4529 | {{0x0f, 0x6a}, {0x24, 0x40}, {0x25, 0x2b}, {0x26, 0x90}, | ||
4530 | {0x27, 0xe0}, {0x28, 0xe0}, {0x2c, 0xe0}}, | ||
4531 | {{0x0f, 0x6a}, {0x24, 0x50}, {0x25, 0x40}, {0x26, 0xa1}, | ||
4532 | {0x27, 0xc0}, {0x28, 0xc0}, {0x2c, 0xc0}}, | ||
4533 | {{0x0f, 0x6a}, {0x24, 0x68}, {0x25, 0x58}, {0x26, 0xc2}, | ||
4534 | {0x27, 0xa0}, {0x28, 0xa0}, {0x2c, 0xa0}}, | ||
4535 | {{0x0f, 0x6a}, {0x24, 0x70}, {0x25, 0x68}, {0x26, 0xd3}, | ||
4536 | {0x27, 0x80}, {0x28, 0x80}, {0x2c, 0x80}}, | ||
4537 | {{0x0f, 0x6a}, {0x24, 0x80}, {0x25, 0x70}, {0x26, 0xd3}, | ||
4538 | {0x27, 0x20}, {0x28, 0x20}, {0x2c, 0x20}}, | ||
4539 | {{0x0f, 0x6a}, {0x24, 0x88}, {0x25, 0x78}, {0x26, 0xd3}, | ||
4540 | {0x27, 0x40}, {0x28, 0x40}, {0x2c, 0x40}}, | ||
4541 | {{0x0f, 0x6a}, {0x24, 0x90}, {0x25, 0x80}, {0x26, 0xd4}, | ||
4542 | {0x27, 0x60}, {0x28, 0x60}, {0x2c, 0x60}} | ||
4543 | }; | ||
4216 | 4544 | ||
4217 | val = sd->brightness; | 4545 | val = sd->ctrls[BRIGHTNESS].val; |
4218 | switch (sd->sensor) { | 4546 | switch (sd->sensor) { |
4219 | case SEN_OV8610: | 4547 | case SEN_OV8610: |
4220 | case SEN_OV7610: | 4548 | case SEN_OV7610: |
@@ -4229,13 +4557,17 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
4229 | case SEN_OV7620: | 4557 | case SEN_OV7620: |
4230 | case SEN_OV7620AE: | 4558 | case SEN_OV7620AE: |
4231 | /* 7620 doesn't like manual changes when in auto mode */ | 4559 | /* 7620 doesn't like manual changes when in auto mode */ |
4232 | if (!sd->autobrightness) | 4560 | if (!sd->ctrls[AUTOBRIGHT].val) |
4233 | i2c_w(sd, OV7610_REG_BRT, val); | 4561 | i2c_w(sd, OV7610_REG_BRT, val); |
4234 | break; | 4562 | break; |
4563 | case SEN_OV7660: | ||
4564 | write_i2c_regvals(sd, brit_7660[val], | ||
4565 | ARRAY_SIZE(brit_7660[0])); | ||
4566 | break; | ||
4235 | case SEN_OV7670: | 4567 | case SEN_OV7670: |
4236 | /*win trace | 4568 | /*win trace |
4237 | * i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_AEC); */ | 4569 | * i2c_w_mask(sd, OV7670_R13_COM8, 0, OV7670_COM8_AEC); */ |
4238 | i2c_w(sd, OV7670_REG_BRIGHT, ov7670_abs_to_sm(val)); | 4570 | i2c_w(sd, OV7670_R55_BRIGHT, ov7670_abs_to_sm(val)); |
4239 | break; | 4571 | break; |
4240 | } | 4572 | } |
4241 | } | 4573 | } |
@@ -4244,8 +4576,66 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
4244 | { | 4576 | { |
4245 | struct sd *sd = (struct sd *) gspca_dev; | 4577 | struct sd *sd = (struct sd *) gspca_dev; |
4246 | int val; | 4578 | int val; |
4579 | static const struct ov_i2c_regvals contrast_7660[][31] = { | ||
4580 | {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0xa0}, | ||
4581 | {0x70, 0x58}, {0x71, 0x38}, {0x72, 0x30}, {0x73, 0x30}, | ||
4582 | {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x24}, {0x77, 0x24}, | ||
4583 | {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x34}, | ||
4584 | {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x65}, | ||
4585 | {0x80, 0x70}, {0x81, 0x77}, {0x82, 0x7d}, {0x83, 0x83}, | ||
4586 | {0x84, 0x88}, {0x85, 0x8d}, {0x86, 0x96}, {0x87, 0x9f}, | ||
4587 | {0x88, 0xb0}, {0x89, 0xc4}, {0x8a, 0xd9}}, | ||
4588 | {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf8}, {0x6f, 0x94}, | ||
4589 | {0x70, 0x58}, {0x71, 0x40}, {0x72, 0x30}, {0x73, 0x30}, | ||
4590 | {0x74, 0x30}, {0x75, 0x30}, {0x76, 0x2c}, {0x77, 0x24}, | ||
4591 | {0x78, 0x22}, {0x79, 0x28}, {0x7a, 0x2a}, {0x7b, 0x31}, | ||
4592 | {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3d}, {0x7f, 0x62}, | ||
4593 | {0x80, 0x6d}, {0x81, 0x75}, {0x82, 0x7b}, {0x83, 0x81}, | ||
4594 | {0x84, 0x87}, {0x85, 0x8d}, {0x86, 0x98}, {0x87, 0xa1}, | ||
4595 | {0x88, 0xb2}, {0x89, 0xc6}, {0x8a, 0xdb}}, | ||
4596 | {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x84}, | ||
4597 | {0x70, 0x58}, {0x71, 0x48}, {0x72, 0x40}, {0x73, 0x40}, | ||
4598 | {0x74, 0x28}, {0x75, 0x28}, {0x76, 0x28}, {0x77, 0x24}, | ||
4599 | {0x78, 0x26}, {0x79, 0x28}, {0x7a, 0x28}, {0x7b, 0x34}, | ||
4600 | {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x5d}, | ||
4601 | {0x80, 0x68}, {0x81, 0x71}, {0x82, 0x79}, {0x83, 0x81}, | ||
4602 | {0x84, 0x86}, {0x85, 0x8b}, {0x86, 0x95}, {0x87, 0x9e}, | ||
4603 | {0x88, 0xb1}, {0x89, 0xc5}, {0x8a, 0xd9}}, | ||
4604 | {{0x6c, 0xf0}, {0x6d, 0xf0}, {0x6e, 0xf0}, {0x6f, 0x70}, | ||
4605 | {0x70, 0x58}, {0x71, 0x58}, {0x72, 0x48}, {0x73, 0x48}, | ||
4606 | {0x74, 0x38}, {0x75, 0x40}, {0x76, 0x34}, {0x77, 0x34}, | ||
4607 | {0x78, 0x2e}, {0x79, 0x28}, {0x7a, 0x24}, {0x7b, 0x22}, | ||
4608 | {0x7c, 0x0f}, {0x7d, 0x1e}, {0x7e, 0x3c}, {0x7f, 0x58}, | ||
4609 | {0x80, 0x63}, {0x81, 0x6e}, {0x82, 0x77}, {0x83, 0x80}, | ||
4610 | {0x84, 0x87}, {0x85, 0x8f}, {0x86, 0x9c}, {0x87, 0xa9}, | ||
4611 | {0x88, 0xc0}, {0x89, 0xd4}, {0x8a, 0xe6}}, | ||
4612 | {{0x6c, 0xa0}, {0x6d, 0xf0}, {0x6e, 0x90}, {0x6f, 0x80}, | ||
4613 | {0x70, 0x70}, {0x71, 0x80}, {0x72, 0x60}, {0x73, 0x60}, | ||
4614 | {0x74, 0x58}, {0x75, 0x60}, {0x76, 0x4c}, {0x77, 0x38}, | ||
4615 | {0x78, 0x38}, {0x79, 0x2a}, {0x7a, 0x20}, {0x7b, 0x0e}, | ||
4616 | {0x7c, 0x0a}, {0x7d, 0x14}, {0x7e, 0x26}, {0x7f, 0x46}, | ||
4617 | {0x80, 0x54}, {0x81, 0x64}, {0x82, 0x70}, {0x83, 0x7c}, | ||
4618 | {0x84, 0x87}, {0x85, 0x93}, {0x86, 0xa6}, {0x87, 0xb4}, | ||
4619 | {0x88, 0xd0}, {0x89, 0xe5}, {0x8a, 0xf5}}, | ||
4620 | {{0x6c, 0x60}, {0x6d, 0x80}, {0x6e, 0x60}, {0x6f, 0x80}, | ||
4621 | {0x70, 0x80}, {0x71, 0x80}, {0x72, 0x88}, {0x73, 0x30}, | ||
4622 | {0x74, 0x70}, {0x75, 0x68}, {0x76, 0x64}, {0x77, 0x50}, | ||
4623 | {0x78, 0x3c}, {0x79, 0x22}, {0x7a, 0x10}, {0x7b, 0x08}, | ||
4624 | {0x7c, 0x06}, {0x7d, 0x0e}, {0x7e, 0x1a}, {0x7f, 0x3a}, | ||
4625 | {0x80, 0x4a}, {0x81, 0x5a}, {0x82, 0x6b}, {0x83, 0x7b}, | ||
4626 | {0x84, 0x89}, {0x85, 0x96}, {0x86, 0xaf}, {0x87, 0xc3}, | ||
4627 | {0x88, 0xe1}, {0x89, 0xf2}, {0x8a, 0xfa}}, | ||
4628 | {{0x6c, 0x20}, {0x6d, 0x40}, {0x6e, 0x20}, {0x6f, 0x60}, | ||
4629 | {0x70, 0x88}, {0x71, 0xc8}, {0x72, 0xc0}, {0x73, 0xb8}, | ||
4630 | {0x74, 0xa8}, {0x75, 0xb8}, {0x76, 0x80}, {0x77, 0x5c}, | ||
4631 | {0x78, 0x26}, {0x79, 0x10}, {0x7a, 0x08}, {0x7b, 0x04}, | ||
4632 | {0x7c, 0x02}, {0x7d, 0x06}, {0x7e, 0x0a}, {0x7f, 0x22}, | ||
4633 | {0x80, 0x33}, {0x81, 0x4c}, {0x82, 0x64}, {0x83, 0x7b}, | ||
4634 | {0x84, 0x90}, {0x85, 0xa7}, {0x86, 0xc7}, {0x87, 0xde}, | ||
4635 | {0x88, 0xf1}, {0x89, 0xf9}, {0x8a, 0xfd}}, | ||
4636 | }; | ||
4247 | 4637 | ||
4248 | val = sd->contrast; | 4638 | val = sd->ctrls[CONTRAST].val; |
4249 | switch (sd->sensor) { | 4639 | switch (sd->sensor) { |
4250 | case SEN_OV7610: | 4640 | case SEN_OV7610: |
4251 | case SEN_OV6620: | 4641 | case SEN_OV6620: |
@@ -4256,7 +4646,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
4256 | i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); | 4646 | i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); |
4257 | break; | 4647 | break; |
4258 | case SEN_OV8610: { | 4648 | case SEN_OV8610: { |
4259 | static const __u8 ctab[] = { | 4649 | static const u8 ctab[] = { |
4260 | 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f | 4650 | 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f |
4261 | }; | 4651 | }; |
4262 | 4652 | ||
@@ -4266,7 +4656,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
4266 | } | 4656 | } |
4267 | case SEN_OV7620: | 4657 | case SEN_OV7620: |
4268 | case SEN_OV7620AE: { | 4658 | case SEN_OV7620AE: { |
4269 | static const __u8 ctab[] = { | 4659 | static const u8 ctab[] = { |
4270 | 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57, | 4660 | 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57, |
4271 | 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff | 4661 | 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff |
4272 | }; | 4662 | }; |
@@ -4275,19 +4665,43 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
4275 | i2c_w(sd, 0x64, ctab[val >> 4]); | 4665 | i2c_w(sd, 0x64, ctab[val >> 4]); |
4276 | break; | 4666 | break; |
4277 | } | 4667 | } |
4668 | case SEN_OV7660: | ||
4669 | write_i2c_regvals(sd, contrast_7660[val], | ||
4670 | ARRAY_SIZE(contrast_7660[0])); | ||
4671 | break; | ||
4278 | case SEN_OV7670: | 4672 | case SEN_OV7670: |
4279 | /* check that this isn't just the same as ov7610 */ | 4673 | /* check that this isn't just the same as ov7610 */ |
4280 | i2c_w(sd, OV7670_REG_CONTRAS, val >> 1); | 4674 | i2c_w(sd, OV7670_R56_CONTRAS, val >> 1); |
4281 | break; | 4675 | break; |
4282 | } | 4676 | } |
4283 | } | 4677 | } |
4284 | 4678 | ||
4679 | static void setexposure(struct gspca_dev *gspca_dev) | ||
4680 | { | ||
4681 | struct sd *sd = (struct sd *) gspca_dev; | ||
4682 | |||
4683 | if (!sd->ctrls[AUTOGAIN].val) | ||
4684 | i2c_w(sd, 0x10, sd->ctrls[EXPOSURE].val); | ||
4685 | } | ||
4686 | |||
4285 | static void setcolors(struct gspca_dev *gspca_dev) | 4687 | static void setcolors(struct gspca_dev *gspca_dev) |
4286 | { | 4688 | { |
4287 | struct sd *sd = (struct sd *) gspca_dev; | 4689 | struct sd *sd = (struct sd *) gspca_dev; |
4288 | int val; | 4690 | int val; |
4691 | static const struct ov_i2c_regvals colors_7660[][6] = { | ||
4692 | {{0x4f, 0x28}, {0x50, 0x2a}, {0x51, 0x02}, {0x52, 0x0a}, | ||
4693 | {0x53, 0x19}, {0x54, 0x23}}, | ||
4694 | {{0x4f, 0x47}, {0x50, 0x4a}, {0x51, 0x03}, {0x52, 0x11}, | ||
4695 | {0x53, 0x2c}, {0x54, 0x3e}}, | ||
4696 | {{0x4f, 0x66}, {0x50, 0x6b}, {0x51, 0x05}, {0x52, 0x19}, | ||
4697 | {0x53, 0x40}, {0x54, 0x59}}, | ||
4698 | {{0x4f, 0x84}, {0x50, 0x8b}, {0x51, 0x06}, {0x52, 0x20}, | ||
4699 | {0x53, 0x53}, {0x54, 0x73}}, | ||
4700 | {{0x4f, 0xa3}, {0x50, 0xab}, {0x51, 0x08}, {0x52, 0x28}, | ||
4701 | {0x53, 0x66}, {0x54, 0x8e}}, | ||
4702 | }; | ||
4289 | 4703 | ||
4290 | val = sd->colors; | 4704 | val = sd->ctrls[COLORS].val; |
4291 | switch (sd->sensor) { | 4705 | switch (sd->sensor) { |
4292 | case SEN_OV8610: | 4706 | case SEN_OV8610: |
4293 | case SEN_OV7610: | 4707 | case SEN_OV7610: |
@@ -4309,6 +4723,10 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
4309 | case SEN_OV7648: | 4723 | case SEN_OV7648: |
4310 | i2c_w(sd, OV7610_REG_SAT, val & 0xf0); | 4724 | i2c_w(sd, OV7610_REG_SAT, val & 0xf0); |
4311 | break; | 4725 | break; |
4726 | case SEN_OV7660: | ||
4727 | write_i2c_regvals(sd, colors_7660[val], | ||
4728 | ARRAY_SIZE(colors_7660[0])); | ||
4729 | break; | ||
4312 | case SEN_OV7670: | 4730 | case SEN_OV7670: |
4313 | /* supported later once I work out how to do it | 4731 | /* supported later once I work out how to do it |
4314 | * transparently fail now! */ | 4732 | * transparently fail now! */ |
@@ -4317,45 +4735,56 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
4317 | } | 4735 | } |
4318 | } | 4736 | } |
4319 | 4737 | ||
4320 | static void setautobrightness(struct sd *sd) | 4738 | static void setautobright(struct gspca_dev *gspca_dev) |
4321 | { | 4739 | { |
4322 | if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7648 || | 4740 | struct sd *sd = (struct sd *) gspca_dev; |
4323 | sd->sensor == SEN_OV7670 || | ||
4324 | sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | ||
4325 | return; | ||
4326 | 4741 | ||
4327 | i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10); | 4742 | i2c_w_mask(sd, 0x2d, sd->ctrls[AUTOBRIGHT].val ? 0x10 : 0x00, 0x10); |
4328 | } | 4743 | } |
4329 | 4744 | ||
4330 | static void setfreq(struct sd *sd) | 4745 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
4331 | { | 4746 | { |
4332 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610) | 4747 | struct sd *sd = (struct sd *) gspca_dev; |
4333 | return; | ||
4334 | 4748 | ||
4335 | if (sd->sensor == SEN_OV7670) { | 4749 | sd->ctrls[AUTOGAIN].val = val; |
4336 | switch (sd->freq) { | 4750 | if (val) { |
4751 | gspca_dev->ctrl_inac |= (1 << EXPOSURE); | ||
4752 | } else { | ||
4753 | gspca_dev->ctrl_inac &= ~(1 << EXPOSURE); | ||
4754 | sd->ctrls[EXPOSURE].val = i2c_r(sd, 0x10); | ||
4755 | } | ||
4756 | if (gspca_dev->streaming) | ||
4757 | setautogain(gspca_dev); | ||
4758 | return gspca_dev->usb_err; | ||
4759 | } | ||
4760 | |||
4761 | static void setfreq_i(struct sd *sd) | ||
4762 | { | ||
4763 | if (sd->sensor == SEN_OV7660 | ||
4764 | || sd->sensor == SEN_OV7670) { | ||
4765 | switch (sd->ctrls[FREQ].val) { | ||
4337 | case 0: /* Banding filter disabled */ | 4766 | case 0: /* Banding filter disabled */ |
4338 | i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT); | 4767 | i2c_w_mask(sd, OV7670_R13_COM8, 0, OV7670_COM8_BFILT); |
4339 | break; | 4768 | break; |
4340 | case 1: /* 50 hz */ | 4769 | case 1: /* 50 hz */ |
4341 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | 4770 | i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, |
4342 | OV7670_COM8_BFILT); | 4771 | OV7670_COM8_BFILT); |
4343 | i2c_w_mask(sd, OV7670_REG_COM11, 0x08, 0x18); | 4772 | i2c_w_mask(sd, OV7670_R3B_COM11, 0x08, 0x18); |
4344 | break; | 4773 | break; |
4345 | case 2: /* 60 hz */ | 4774 | case 2: /* 60 hz */ |
4346 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | 4775 | i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, |
4347 | OV7670_COM8_BFILT); | 4776 | OV7670_COM8_BFILT); |
4348 | i2c_w_mask(sd, OV7670_REG_COM11, 0x00, 0x18); | 4777 | i2c_w_mask(sd, OV7670_R3B_COM11, 0x00, 0x18); |
4349 | break; | 4778 | break; |
4350 | case 3: /* Auto hz */ | 4779 | case 3: /* Auto hz - ov7670 only */ |
4351 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | 4780 | i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, |
4352 | OV7670_COM8_BFILT); | 4781 | OV7670_COM8_BFILT); |
4353 | i2c_w_mask(sd, OV7670_REG_COM11, OV7670_COM11_HZAUTO, | 4782 | i2c_w_mask(sd, OV7670_R3B_COM11, OV7670_COM11_HZAUTO, |
4354 | 0x18); | 4783 | 0x18); |
4355 | break; | 4784 | break; |
4356 | } | 4785 | } |
4357 | } else { | 4786 | } else { |
4358 | switch (sd->freq) { | 4787 | switch (sd->ctrls[FREQ].val) { |
4359 | case 0: /* Banding filter disabled */ | 4788 | case 0: /* Banding filter disabled */ |
4360 | i2c_w_mask(sd, 0x2d, 0x00, 0x04); | 4789 | i2c_w_mask(sd, 0x2d, 0x00, 0x04); |
4361 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); | 4790 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); |
@@ -4387,135 +4816,15 @@ static void setfreq(struct sd *sd) | |||
4387 | } | 4816 | } |
4388 | } | 4817 | } |
4389 | } | 4818 | } |
4390 | 4819 | static void setfreq(struct gspca_dev *gspca_dev) | |
4391 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
4392 | { | 4820 | { |
4393 | struct sd *sd = (struct sd *) gspca_dev; | 4821 | struct sd *sd = (struct sd *) gspca_dev; |
4394 | 4822 | ||
4395 | sd->brightness = val; | 4823 | setfreq_i(sd); |
4396 | if (gspca_dev->streaming) | ||
4397 | setbrightness(gspca_dev); | ||
4398 | return 0; | ||
4399 | } | ||
4400 | |||
4401 | static 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 | |||
4409 | static 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 | |||
4419 | static 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 | 4824 | ||
4427 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) | 4825 | /* Ugly but necessary */ |
4428 | { | 4826 | if (sd->bridge == BRIDGE_W9968CF) |
4429 | struct sd *sd = (struct sd *) gspca_dev; | 4827 | w9968cf_set_crop_window(sd); |
4430 | |||
4431 | sd->colors = val; | ||
4432 | if (gspca_dev->streaming) | ||
4433 | setcolors(gspca_dev); | ||
4434 | return 0; | ||
4435 | } | ||
4436 | |||
4437 | static 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 | |||
4445 | static 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 | |||
4455 | static 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 | |||
4463 | static 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 | |||
4473 | static 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 | |||
4481 | static 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 | |||
4491 | static 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 | |||
4499 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
4500 | { | ||
4501 | struct sd *sd = (struct sd *) gspca_dev; | ||
4502 | |||
4503 | sd->freq = val; | ||
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 | |||
4513 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
4514 | { | ||
4515 | struct sd *sd = (struct sd *) gspca_dev; | ||
4516 | |||
4517 | *val = sd->freq; | ||
4518 | return 0; | ||
4519 | } | 4828 | } |
4520 | 4829 | ||
4521 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 4830 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
@@ -4593,6 +4902,7 @@ static const struct sd_desc sd_desc = { | |||
4593 | .nctrls = ARRAY_SIZE(sd_ctrls), | 4902 | .nctrls = ARRAY_SIZE(sd_ctrls), |
4594 | .config = sd_config, | 4903 | .config = sd_config, |
4595 | .init = sd_init, | 4904 | .init = sd_init, |
4905 | .isoc_init = sd_isoc_init, | ||
4596 | .start = sd_start, | 4906 | .start = sd_start, |
4597 | .stopN = sd_stopN, | 4907 | .stopN = sd_stopN, |
4598 | .stop0 = sd_stop0, | 4908 | .stop0 = sd_stop0, |
@@ -4601,27 +4911,27 @@ static const struct sd_desc sd_desc = { | |||
4601 | .querymenu = sd_querymenu, | 4911 | .querymenu = sd_querymenu, |
4602 | .get_jcomp = sd_get_jcomp, | 4912 | .get_jcomp = sd_get_jcomp, |
4603 | .set_jcomp = sd_set_jcomp, | 4913 | .set_jcomp = sd_set_jcomp, |
4604 | #ifdef CONFIG_INPUT | 4914 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
4605 | .other_input = 1, | 4915 | .other_input = 1, |
4606 | #endif | 4916 | #endif |
4607 | }; | 4917 | }; |
4608 | 4918 | ||
4609 | /* -- module initialisation -- */ | 4919 | /* -- module initialisation -- */ |
4610 | static const __devinitdata struct usb_device_id device_table[] = { | 4920 | static const struct usb_device_id device_table[] = { |
4611 | {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, | 4921 | {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, |
4612 | {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 }, | 4922 | {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 }, |
4613 | {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, | 4923 | {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, |
4614 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, | 4924 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, |
4615 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, | 4925 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, |
4616 | {USB_DEVICE(0x041e, 0x4064), | 4926 | {USB_DEVICE(0x041e, 0x4064), |
4617 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | 4927 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
4618 | {USB_DEVICE(0x041e, 0x4067), .driver_info = BRIDGE_OV519 }, | 4928 | {USB_DEVICE(0x041e, 0x4067), .driver_info = BRIDGE_OV519 }, |
4619 | {USB_DEVICE(0x041e, 0x4068), | 4929 | {USB_DEVICE(0x041e, 0x4068), |
4620 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | 4930 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
4621 | {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 }, | 4931 | {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 }, |
4622 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, | 4932 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, |
4623 | {USB_DEVICE(0x054c, 0x0155), | 4933 | {USB_DEVICE(0x054c, 0x0155), |
4624 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | 4934 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
4625 | {USB_DEVICE(0x05a9, 0x0511), .driver_info = BRIDGE_OV511 }, | 4935 | {USB_DEVICE(0x05a9, 0x0511), .driver_info = BRIDGE_OV511 }, |
4626 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, | 4936 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, |
4627 | {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 }, | 4937 | {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 }, |
@@ -4635,7 +4945,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
4635 | {USB_DEVICE(0x0b62, 0x0059), .driver_info = BRIDGE_OVFX2 }, | 4945 | {USB_DEVICE(0x0b62, 0x0059), .driver_info = BRIDGE_OVFX2 }, |
4636 | {USB_DEVICE(0x0e96, 0xc001), .driver_info = BRIDGE_OVFX2 }, | 4946 | {USB_DEVICE(0x0e96, 0xc001), .driver_info = BRIDGE_OVFX2 }, |
4637 | {USB_DEVICE(0x1046, 0x9967), .driver_info = BRIDGE_W9968CF }, | 4947 | {USB_DEVICE(0x1046, 0x9967), .driver_info = BRIDGE_W9968CF }, |
4638 | {USB_DEVICE(0x8020, 0xEF04), .driver_info = BRIDGE_OVFX2 }, | 4948 | {USB_DEVICE(0x8020, 0xef04), .driver_info = BRIDGE_OVFX2 }, |
4639 | {} | 4949 | {} |
4640 | }; | 4950 | }; |
4641 | 4951 | ||
@@ -4663,17 +4973,11 @@ static struct usb_driver sd_driver = { | |||
4663 | /* -- module insert / remove -- */ | 4973 | /* -- module insert / remove -- */ |
4664 | static int __init sd_mod_init(void) | 4974 | static int __init sd_mod_init(void) |
4665 | { | 4975 | { |
4666 | int ret; | 4976 | 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 | } | 4977 | } |
4673 | static void __exit sd_mod_exit(void) | 4978 | static void __exit sd_mod_exit(void) |
4674 | { | 4979 | { |
4675 | usb_deregister(&sd_driver); | 4980 | usb_deregister(&sd_driver); |
4676 | PDEBUG(D_PROBE, "deregistered"); | ||
4677 | } | 4981 | } |
4678 | 4982 | ||
4679 | module_init(sd_mod_init); | 4983 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c index 96cb3a976581..0c6369b7fe18 100644 --- a/drivers/media/video/gspca/ov534.c +++ b/drivers/media/video/gspca/ov534.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * ov534-ov772x gspca driver | 2 | * ov534-ov7xxx gspca driver |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Antonio Ospite <ospite@studenti.unina.it> | 4 | * Copyright (C) 2008 Antonio Ospite <ospite@studenti.unina.it> |
5 | * Copyright (C) 2008 Jim Paris <jim@jtan.com> | 5 | * Copyright (C) 2008 Jim Paris <jim@jtan.com> |
@@ -49,54 +49,59 @@ MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>"); | |||
49 | MODULE_DESCRIPTION("GSPCA/OV534 USB Camera Driver"); | 49 | MODULE_DESCRIPTION("GSPCA/OV534 USB Camera Driver"); |
50 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
51 | 51 | ||
52 | /* controls */ | ||
53 | enum e_ctrl { | ||
54 | BRIGHTNESS, | ||
55 | CONTRAST, | ||
56 | GAIN, | ||
57 | EXPOSURE, | ||
58 | AGC, | ||
59 | AWB, | ||
60 | AEC, | ||
61 | SHARPNESS, | ||
62 | HFLIP, | ||
63 | VFLIP, | ||
64 | COLORS, | ||
65 | LIGHTFREQ, | ||
66 | NCTRLS /* number of controls */ | ||
67 | }; | ||
68 | |||
52 | /* specific webcam descriptor */ | 69 | /* specific webcam descriptor */ |
53 | struct sd { | 70 | struct sd { |
54 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 71 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
72 | |||
73 | struct gspca_ctrl ctrls[NCTRLS]; | ||
74 | |||
55 | __u32 last_pts; | 75 | __u32 last_pts; |
56 | u16 last_fid; | 76 | u16 last_fid; |
57 | u8 frame_rate; | 77 | u8 frame_rate; |
58 | 78 | ||
59 | u8 brightness; | 79 | u8 sensor; |
60 | u8 contrast; | 80 | }; |
61 | u8 gain; | 81 | enum sensors { |
62 | u8 exposure; | 82 | SENSOR_OV767x, |
63 | u8 agc; | 83 | SENSOR_OV772x, |
64 | u8 awb; | 84 | NSENSORS |
65 | u8 aec; | ||
66 | s8 sharpness; | ||
67 | u8 hflip; | ||
68 | u8 vflip; | ||
69 | u8 freqfltr; | ||
70 | }; | 85 | }; |
71 | 86 | ||
72 | /* V4L2 controls supported by the driver */ | 87 | /* V4L2 controls supported by the driver */ |
73 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val); | 88 | static void setbrightness(struct gspca_dev *gspca_dev); |
74 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); | 89 | static void setcontrast(struct gspca_dev *gspca_dev); |
75 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); | 90 | static void setgain(struct gspca_dev *gspca_dev); |
76 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); | 91 | static void setexposure(struct gspca_dev *gspca_dev); |
77 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val); | 92 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val); |
78 | static int sd_getagc(struct gspca_dev *gspca_dev, __s32 *val); | 93 | static void setawb(struct gspca_dev *gspca_dev); |
79 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | 94 | static void setaec(struct gspca_dev *gspca_dev); |
80 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | 95 | static void setsharpness(struct gspca_dev *gspca_dev); |
81 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | 96 | static void sethvflip(struct gspca_dev *gspca_dev); |
82 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | 97 | static void setcolors(struct gspca_dev *gspca_dev); |
83 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | 98 | static void setlightfreq(struct gspca_dev *gspca_dev); |
84 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | 99 | |
85 | static int sd_setawb(struct gspca_dev *gspca_dev, __s32 val); | 100 | static int sd_start(struct gspca_dev *gspca_dev); |
86 | static int sd_getawb(struct gspca_dev *gspca_dev, __s32 *val); | 101 | static void sd_stopN(struct gspca_dev *gspca_dev); |
87 | static int sd_setaec(struct gspca_dev *gspca_dev, __s32 val); | ||
88 | static int sd_getaec(struct gspca_dev *gspca_dev, __s32 *val); | ||
89 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
90 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
91 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
92 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
93 | static int sd_setfreqfltr(struct gspca_dev *gspca_dev, __s32 val); | ||
94 | static int sd_getfreqfltr(struct gspca_dev *gspca_dev, __s32 *val); | ||
95 | static int sd_querymenu(struct gspca_dev *gspca_dev, | ||
96 | struct v4l2_querymenu *menu); | ||
97 | 102 | ||
98 | static const struct ctrl sd_ctrls[] = { | 103 | static const struct ctrl sd_ctrls[] = { |
99 | { /* 0 */ | 104 | [BRIGHTNESS] = { |
100 | { | 105 | { |
101 | .id = V4L2_CID_BRIGHTNESS, | 106 | .id = V4L2_CID_BRIGHTNESS, |
102 | .type = V4L2_CTRL_TYPE_INTEGER, | 107 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -104,13 +109,11 @@ static const struct ctrl sd_ctrls[] = { | |||
104 | .minimum = 0, | 109 | .minimum = 0, |
105 | .maximum = 255, | 110 | .maximum = 255, |
106 | .step = 1, | 111 | .step = 1, |
107 | #define BRIGHTNESS_DEF 0 | 112 | .default_value = 0, |
108 | .default_value = BRIGHTNESS_DEF, | ||
109 | }, | 113 | }, |
110 | .set = sd_setbrightness, | 114 | .set_control = setbrightness |
111 | .get = sd_getbrightness, | ||
112 | }, | 115 | }, |
113 | { /* 1 */ | 116 | [CONTRAST] = { |
114 | { | 117 | { |
115 | .id = V4L2_CID_CONTRAST, | 118 | .id = V4L2_CID_CONTRAST, |
116 | .type = V4L2_CTRL_TYPE_INTEGER, | 119 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -118,13 +121,11 @@ static const struct ctrl sd_ctrls[] = { | |||
118 | .minimum = 0, | 121 | .minimum = 0, |
119 | .maximum = 255, | 122 | .maximum = 255, |
120 | .step = 1, | 123 | .step = 1, |
121 | #define CONTRAST_DEF 32 | 124 | .default_value = 32, |
122 | .default_value = CONTRAST_DEF, | ||
123 | }, | 125 | }, |
124 | .set = sd_setcontrast, | 126 | .set_control = setcontrast |
125 | .get = sd_getcontrast, | ||
126 | }, | 127 | }, |
127 | { /* 2 */ | 128 | [GAIN] = { |
128 | { | 129 | { |
129 | .id = V4L2_CID_GAIN, | 130 | .id = V4L2_CID_GAIN, |
130 | .type = V4L2_CTRL_TYPE_INTEGER, | 131 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -132,13 +133,11 @@ static const struct ctrl sd_ctrls[] = { | |||
132 | .minimum = 0, | 133 | .minimum = 0, |
133 | .maximum = 63, | 134 | .maximum = 63, |
134 | .step = 1, | 135 | .step = 1, |
135 | #define GAIN_DEF 20 | 136 | .default_value = 20, |
136 | .default_value = GAIN_DEF, | ||
137 | }, | 137 | }, |
138 | .set = sd_setgain, | 138 | .set_control = setgain |
139 | .get = sd_getgain, | ||
140 | }, | 139 | }, |
141 | { /* 3 */ | 140 | [EXPOSURE] = { |
142 | { | 141 | { |
143 | .id = V4L2_CID_EXPOSURE, | 142 | .id = V4L2_CID_EXPOSURE, |
144 | .type = V4L2_CTRL_TYPE_INTEGER, | 143 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -146,13 +145,11 @@ static const struct ctrl sd_ctrls[] = { | |||
146 | .minimum = 0, | 145 | .minimum = 0, |
147 | .maximum = 255, | 146 | .maximum = 255, |
148 | .step = 1, | 147 | .step = 1, |
149 | #define EXPO_DEF 120 | 148 | .default_value = 120, |
150 | .default_value = EXPO_DEF, | ||
151 | }, | 149 | }, |
152 | .set = sd_setexposure, | 150 | .set_control = setexposure |
153 | .get = sd_getexposure, | ||
154 | }, | 151 | }, |
155 | { /* 4 */ | 152 | [AGC] = { |
156 | { | 153 | { |
157 | .id = V4L2_CID_AUTOGAIN, | 154 | .id = V4L2_CID_AUTOGAIN, |
158 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 155 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -160,14 +157,11 @@ static const struct ctrl sd_ctrls[] = { | |||
160 | .minimum = 0, | 157 | .minimum = 0, |
161 | .maximum = 1, | 158 | .maximum = 1, |
162 | .step = 1, | 159 | .step = 1, |
163 | #define AGC_DEF 1 | 160 | .default_value = 1, |
164 | .default_value = AGC_DEF, | ||
165 | }, | 161 | }, |
166 | .set = sd_setagc, | 162 | .set = sd_setagc |
167 | .get = sd_getagc, | ||
168 | }, | 163 | }, |
169 | #define AWB_IDX 5 | 164 | [AWB] = { |
170 | { /* 5 */ | ||
171 | { | 165 | { |
172 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | 166 | .id = V4L2_CID_AUTO_WHITE_BALANCE, |
173 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 167 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -175,13 +169,11 @@ static const struct ctrl sd_ctrls[] = { | |||
175 | .minimum = 0, | 169 | .minimum = 0, |
176 | .maximum = 1, | 170 | .maximum = 1, |
177 | .step = 1, | 171 | .step = 1, |
178 | #define AWB_DEF 1 | 172 | .default_value = 1, |
179 | .default_value = AWB_DEF, | ||
180 | }, | 173 | }, |
181 | .set = sd_setawb, | 174 | .set_control = setawb |
182 | .get = sd_getawb, | ||
183 | }, | 175 | }, |
184 | { /* 6 */ | 176 | [AEC] = { |
185 | { | 177 | { |
186 | .id = V4L2_CID_EXPOSURE_AUTO, | 178 | .id = V4L2_CID_EXPOSURE_AUTO, |
187 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 179 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -189,13 +181,11 @@ static const struct ctrl sd_ctrls[] = { | |||
189 | .minimum = 0, | 181 | .minimum = 0, |
190 | .maximum = 1, | 182 | .maximum = 1, |
191 | .step = 1, | 183 | .step = 1, |
192 | #define AEC_DEF 1 | 184 | .default_value = 1, |
193 | .default_value = AEC_DEF, | ||
194 | }, | 185 | }, |
195 | .set = sd_setaec, | 186 | .set_control = setaec |
196 | .get = sd_getaec, | ||
197 | }, | 187 | }, |
198 | { /* 7 */ | 188 | [SHARPNESS] = { |
199 | { | 189 | { |
200 | .id = V4L2_CID_SHARPNESS, | 190 | .id = V4L2_CID_SHARPNESS, |
201 | .type = V4L2_CTRL_TYPE_INTEGER, | 191 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -203,13 +193,11 @@ static const struct ctrl sd_ctrls[] = { | |||
203 | .minimum = 0, | 193 | .minimum = 0, |
204 | .maximum = 63, | 194 | .maximum = 63, |
205 | .step = 1, | 195 | .step = 1, |
206 | #define SHARPNESS_DEF 0 | 196 | .default_value = 0, |
207 | .default_value = SHARPNESS_DEF, | ||
208 | }, | 197 | }, |
209 | .set = sd_setsharpness, | 198 | .set_control = setsharpness |
210 | .get = sd_getsharpness, | ||
211 | }, | 199 | }, |
212 | { /* 8 */ | 200 | [HFLIP] = { |
213 | { | 201 | { |
214 | .id = V4L2_CID_HFLIP, | 202 | .id = V4L2_CID_HFLIP, |
215 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 203 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -217,13 +205,11 @@ static const struct ctrl sd_ctrls[] = { | |||
217 | .minimum = 0, | 205 | .minimum = 0, |
218 | .maximum = 1, | 206 | .maximum = 1, |
219 | .step = 1, | 207 | .step = 1, |
220 | #define HFLIP_DEF 0 | 208 | .default_value = 0, |
221 | .default_value = HFLIP_DEF, | ||
222 | }, | 209 | }, |
223 | .set = sd_sethflip, | 210 | .set_control = sethvflip |
224 | .get = sd_gethflip, | ||
225 | }, | 211 | }, |
226 | { /* 9 */ | 212 | [VFLIP] = { |
227 | { | 213 | { |
228 | .id = V4L2_CID_VFLIP, | 214 | .id = V4L2_CID_VFLIP, |
229 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 215 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -231,13 +217,23 @@ static const struct ctrl sd_ctrls[] = { | |||
231 | .minimum = 0, | 217 | .minimum = 0, |
232 | .maximum = 1, | 218 | .maximum = 1, |
233 | .step = 1, | 219 | .step = 1, |
234 | #define VFLIP_DEF 0 | 220 | .default_value = 0, |
235 | .default_value = VFLIP_DEF, | ||
236 | }, | 221 | }, |
237 | .set = sd_setvflip, | 222 | .set_control = sethvflip |
238 | .get = sd_getvflip, | ||
239 | }, | 223 | }, |
240 | { /* 10 */ | 224 | [COLORS] = { |
225 | { | ||
226 | .id = V4L2_CID_SATURATION, | ||
227 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
228 | .name = "Saturation", | ||
229 | .minimum = 0, | ||
230 | .maximum = 6, | ||
231 | .step = 1, | ||
232 | .default_value = 3, | ||
233 | }, | ||
234 | .set_control = setcolors | ||
235 | }, | ||
236 | [LIGHTFREQ] = { | ||
241 | { | 237 | { |
242 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 238 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
243 | .type = V4L2_CTRL_TYPE_MENU, | 239 | .type = V4L2_CTRL_TYPE_MENU, |
@@ -245,11 +241,9 @@ static const struct ctrl sd_ctrls[] = { | |||
245 | .minimum = 0, | 241 | .minimum = 0, |
246 | .maximum = 1, | 242 | .maximum = 1, |
247 | .step = 1, | 243 | .step = 1, |
248 | #define FREQFLTR_DEF 0 | 244 | .default_value = 0, |
249 | .default_value = FREQFLTR_DEF, | ||
250 | }, | 245 | }, |
251 | .set = sd_setfreqfltr, | 246 | .set_control = setlightfreq |
252 | .get = sd_getfreqfltr, | ||
253 | }, | 247 | }, |
254 | }; | 248 | }; |
255 | 249 | ||
@@ -265,6 +259,16 @@ static const struct v4l2_pix_format ov772x_mode[] = { | |||
265 | .colorspace = V4L2_COLORSPACE_SRGB, | 259 | .colorspace = V4L2_COLORSPACE_SRGB, |
266 | .priv = 0}, | 260 | .priv = 0}, |
267 | }; | 261 | }; |
262 | static const struct v4l2_pix_format ov767x_mode[] = { | ||
263 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
264 | .bytesperline = 320, | ||
265 | .sizeimage = 320 * 240 * 3 / 8 + 590, | ||
266 | .colorspace = V4L2_COLORSPACE_JPEG}, | ||
267 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
268 | .bytesperline = 640, | ||
269 | .sizeimage = 640 * 480 * 3 / 8 + 590, | ||
270 | .colorspace = V4L2_COLORSPACE_JPEG}, | ||
271 | }; | ||
268 | 272 | ||
269 | static const u8 qvga_rates[] = {125, 100, 75, 60, 50, 40, 30}; | 273 | static const u8 qvga_rates[] = {125, 100, 75, 60, 50, 40, 30}; |
270 | static const u8 vga_rates[] = {60, 50, 40, 30, 15}; | 274 | static const u8 vga_rates[] = {60, 50, 40, 30, 15}; |
@@ -280,7 +284,288 @@ static const struct framerates ov772x_framerates[] = { | |||
280 | }, | 284 | }, |
281 | }; | 285 | }; |
282 | 286 | ||
283 | static const u8 bridge_init[][2] = { | 287 | struct reg_array { |
288 | const u8 (*val)[2]; | ||
289 | int len; | ||
290 | }; | ||
291 | |||
292 | static const u8 bridge_init_767x[][2] = { | ||
293 | /* comments from the ms-win file apollo7670.set */ | ||
294 | /* str1 */ | ||
295 | {0xf1, 0x42}, | ||
296 | {0x88, 0xf8}, | ||
297 | {0x89, 0xff}, | ||
298 | {0x76, 0x03}, | ||
299 | {0x92, 0x03}, | ||
300 | {0x95, 0x10}, | ||
301 | {0xe2, 0x00}, | ||
302 | {0xe7, 0x3e}, | ||
303 | {0x8d, 0x1c}, | ||
304 | {0x8e, 0x00}, | ||
305 | {0x8f, 0x00}, | ||
306 | {0x1f, 0x00}, | ||
307 | {0xc3, 0xf9}, | ||
308 | {0x89, 0xff}, | ||
309 | {0x88, 0xf8}, | ||
310 | {0x76, 0x03}, | ||
311 | {0x92, 0x01}, | ||
312 | {0x93, 0x18}, | ||
313 | {0x1c, 0x00}, | ||
314 | {0x1d, 0x48}, | ||
315 | {0x1d, 0x00}, | ||
316 | {0x1d, 0xff}, | ||
317 | {0x1d, 0x02}, | ||
318 | {0x1d, 0x58}, | ||
319 | {0x1d, 0x00}, | ||
320 | {0x1c, 0x0a}, | ||
321 | {0x1d, 0x0a}, | ||
322 | {0x1d, 0x0e}, | ||
323 | {0xc0, 0x50}, /* HSize 640 */ | ||
324 | {0xc1, 0x3c}, /* VSize 480 */ | ||
325 | {0x34, 0x05}, /* enable Audio Suspend mode */ | ||
326 | {0xc2, 0x0c}, /* Input YUV */ | ||
327 | {0xc3, 0xf9}, /* enable PRE */ | ||
328 | {0x34, 0x05}, /* enable Audio Suspend mode */ | ||
329 | {0xe7, 0x2e}, /* this solves failure of "SuspendResumeTest" */ | ||
330 | {0x31, 0xf9}, /* enable 1.8V Suspend */ | ||
331 | {0x35, 0x02}, /* turn on JPEG */ | ||
332 | {0xd9, 0x10}, | ||
333 | {0x25, 0x42}, /* GPIO[8]:Input */ | ||
334 | {0x94, 0x11}, /* If the default setting is loaded when | ||
335 | * system boots up, this flag is closed here */ | ||
336 | }; | ||
337 | static const u8 sensor_init_767x[][2] = { | ||
338 | {0x12, 0x80}, | ||
339 | {0x11, 0x03}, | ||
340 | {0x3a, 0x04}, | ||
341 | {0x12, 0x00}, | ||
342 | {0x17, 0x13}, | ||
343 | {0x18, 0x01}, | ||
344 | {0x32, 0xb6}, | ||
345 | {0x19, 0x02}, | ||
346 | {0x1a, 0x7a}, | ||
347 | {0x03, 0x0a}, | ||
348 | {0x0c, 0x00}, | ||
349 | {0x3e, 0x00}, | ||
350 | {0x70, 0x3a}, | ||
351 | {0x71, 0x35}, | ||
352 | {0x72, 0x11}, | ||
353 | {0x73, 0xf0}, | ||
354 | {0xa2, 0x02}, | ||
355 | {0x7a, 0x2a}, /* set Gamma=1.6 below */ | ||
356 | {0x7b, 0x12}, | ||
357 | {0x7c, 0x1d}, | ||
358 | {0x7d, 0x2d}, | ||
359 | {0x7e, 0x45}, | ||
360 | {0x7f, 0x50}, | ||
361 | {0x80, 0x59}, | ||
362 | {0x81, 0x62}, | ||
363 | {0x82, 0x6b}, | ||
364 | {0x83, 0x73}, | ||
365 | {0x84, 0x7b}, | ||
366 | {0x85, 0x8a}, | ||
367 | {0x86, 0x98}, | ||
368 | {0x87, 0xb2}, | ||
369 | {0x88, 0xca}, | ||
370 | {0x89, 0xe0}, | ||
371 | {0x13, 0xe0}, | ||
372 | {0x00, 0x00}, | ||
373 | {0x10, 0x00}, | ||
374 | {0x0d, 0x40}, | ||
375 | {0x14, 0x38}, /* gain max 16x */ | ||
376 | {0xa5, 0x05}, | ||
377 | {0xab, 0x07}, | ||
378 | {0x24, 0x95}, | ||
379 | {0x25, 0x33}, | ||
380 | {0x26, 0xe3}, | ||
381 | {0x9f, 0x78}, | ||
382 | {0xa0, 0x68}, | ||
383 | {0xa1, 0x03}, | ||
384 | {0xa6, 0xd8}, | ||
385 | {0xa7, 0xd8}, | ||
386 | {0xa8, 0xf0}, | ||
387 | {0xa9, 0x90}, | ||
388 | {0xaa, 0x94}, | ||
389 | {0x13, 0xe5}, | ||
390 | {0x0e, 0x61}, | ||
391 | {0x0f, 0x4b}, | ||
392 | {0x16, 0x02}, | ||
393 | {0x21, 0x02}, | ||
394 | {0x22, 0x91}, | ||
395 | {0x29, 0x07}, | ||
396 | {0x33, 0x0b}, | ||
397 | {0x35, 0x0b}, | ||
398 | {0x37, 0x1d}, | ||
399 | {0x38, 0x71}, | ||
400 | {0x39, 0x2a}, | ||
401 | {0x3c, 0x78}, | ||
402 | {0x4d, 0x40}, | ||
403 | {0x4e, 0x20}, | ||
404 | {0x69, 0x00}, | ||
405 | {0x6b, 0x4a}, | ||
406 | {0x74, 0x10}, | ||
407 | {0x8d, 0x4f}, | ||
408 | {0x8e, 0x00}, | ||
409 | {0x8f, 0x00}, | ||
410 | {0x90, 0x00}, | ||
411 | {0x91, 0x00}, | ||
412 | {0x96, 0x00}, | ||
413 | {0x9a, 0x80}, | ||
414 | {0xb0, 0x84}, | ||
415 | {0xb1, 0x0c}, | ||
416 | {0xb2, 0x0e}, | ||
417 | {0xb3, 0x82}, | ||
418 | {0xb8, 0x0a}, | ||
419 | {0x43, 0x0a}, | ||
420 | {0x44, 0xf0}, | ||
421 | {0x45, 0x34}, | ||
422 | {0x46, 0x58}, | ||
423 | {0x47, 0x28}, | ||
424 | {0x48, 0x3a}, | ||
425 | {0x59, 0x88}, | ||
426 | {0x5a, 0x88}, | ||
427 | {0x5b, 0x44}, | ||
428 | {0x5c, 0x67}, | ||
429 | {0x5d, 0x49}, | ||
430 | {0x5e, 0x0e}, | ||
431 | {0x6c, 0x0a}, | ||
432 | {0x6d, 0x55}, | ||
433 | {0x6e, 0x11}, | ||
434 | {0x6f, 0x9f}, | ||
435 | {0x6a, 0x40}, | ||
436 | {0x01, 0x40}, | ||
437 | {0x02, 0x40}, | ||
438 | {0x13, 0xe7}, | ||
439 | {0x4f, 0x80}, | ||
440 | {0x50, 0x80}, | ||
441 | {0x51, 0x00}, | ||
442 | {0x52, 0x22}, | ||
443 | {0x53, 0x5e}, | ||
444 | {0x54, 0x80}, | ||
445 | {0x58, 0x9e}, | ||
446 | {0x41, 0x08}, | ||
447 | {0x3f, 0x00}, | ||
448 | {0x75, 0x04}, | ||
449 | {0x76, 0xe1}, | ||
450 | {0x4c, 0x00}, | ||
451 | {0x77, 0x01}, | ||
452 | {0x3d, 0xc2}, | ||
453 | {0x4b, 0x09}, | ||
454 | {0xc9, 0x60}, | ||
455 | {0x41, 0x38}, /* jfm: auto sharpness + auto de-noise */ | ||
456 | {0x56, 0x40}, | ||
457 | {0x34, 0x11}, | ||
458 | {0x3b, 0xc2}, | ||
459 | {0xa4, 0x8a}, /* Night mode trigger point */ | ||
460 | {0x96, 0x00}, | ||
461 | {0x97, 0x30}, | ||
462 | {0x98, 0x20}, | ||
463 | {0x99, 0x20}, | ||
464 | {0x9a, 0x84}, | ||
465 | {0x9b, 0x29}, | ||
466 | {0x9c, 0x03}, | ||
467 | {0x9d, 0x4c}, | ||
468 | {0x9e, 0x3f}, | ||
469 | {0x78, 0x04}, | ||
470 | {0x79, 0x01}, | ||
471 | {0xc8, 0xf0}, | ||
472 | {0x79, 0x0f}, | ||
473 | {0xc8, 0x00}, | ||
474 | {0x79, 0x10}, | ||
475 | {0xc8, 0x7e}, | ||
476 | {0x79, 0x0a}, | ||
477 | {0xc8, 0x80}, | ||
478 | {0x79, 0x0b}, | ||
479 | {0xc8, 0x01}, | ||
480 | {0x79, 0x0c}, | ||
481 | {0xc8, 0x0f}, | ||
482 | {0x79, 0x0d}, | ||
483 | {0xc8, 0x20}, | ||
484 | {0x79, 0x09}, | ||
485 | {0xc8, 0x80}, | ||
486 | {0x79, 0x02}, | ||
487 | {0xc8, 0xc0}, | ||
488 | {0x79, 0x03}, | ||
489 | {0xc8, 0x20}, | ||
490 | {0x79, 0x26}, | ||
491 | }; | ||
492 | static const u8 bridge_start_vga_767x[][2] = { | ||
493 | /* str59 JPG */ | ||
494 | {0x94, 0xaa}, | ||
495 | {0xf1, 0x42}, | ||
496 | {0xe5, 0x04}, | ||
497 | {0xc0, 0x50}, | ||
498 | {0xc1, 0x3c}, | ||
499 | {0xc2, 0x0c}, | ||
500 | {0x35, 0x02}, /* turn on JPEG */ | ||
501 | {0xd9, 0x10}, | ||
502 | {0xda, 0x00}, /* for higher clock rate(30fps) */ | ||
503 | {0x34, 0x05}, /* enable Audio Suspend mode */ | ||
504 | {0xc3, 0xf9}, /* enable PRE */ | ||
505 | {0x8c, 0x00}, /* CIF VSize LSB[2:0] */ | ||
506 | {0x8d, 0x1c}, /* output YUV */ | ||
507 | /* {0x34, 0x05}, * enable Audio Suspend mode (?) */ | ||
508 | {0x50, 0x00}, /* H/V divider=0 */ | ||
509 | {0x51, 0xa0}, /* input H=640/4 */ | ||
510 | {0x52, 0x3c}, /* input V=480/4 */ | ||
511 | {0x53, 0x00}, /* offset X=0 */ | ||
512 | {0x54, 0x00}, /* offset Y=0 */ | ||
513 | {0x55, 0x00}, /* H/V size[8]=0 */ | ||
514 | {0x57, 0x00}, /* H-size[9]=0 */ | ||
515 | {0x5c, 0x00}, /* output size[9:8]=0 */ | ||
516 | {0x5a, 0xa0}, /* output H=640/4 */ | ||
517 | {0x5b, 0x78}, /* output V=480/4 */ | ||
518 | {0x1c, 0x0a}, | ||
519 | {0x1d, 0x0a}, | ||
520 | {0x94, 0x11}, | ||
521 | }; | ||
522 | static const u8 sensor_start_vga_767x[][2] = { | ||
523 | {0x11, 0x01}, | ||
524 | {0x1e, 0x04}, | ||
525 | {0x19, 0x02}, | ||
526 | {0x1a, 0x7a}, | ||
527 | }; | ||
528 | static const u8 bridge_start_qvga_767x[][2] = { | ||
529 | /* str86 JPG */ | ||
530 | {0x94, 0xaa}, | ||
531 | {0xf1, 0x42}, | ||
532 | {0xe5, 0x04}, | ||
533 | {0xc0, 0x80}, | ||
534 | {0xc1, 0x60}, | ||
535 | {0xc2, 0x0c}, | ||
536 | {0x35, 0x02}, /* turn on JPEG */ | ||
537 | {0xd9, 0x10}, | ||
538 | {0xc0, 0x50}, /* CIF HSize 640 */ | ||
539 | {0xc1, 0x3c}, /* CIF VSize 480 */ | ||
540 | {0x8c, 0x00}, /* CIF VSize LSB[2:0] */ | ||
541 | {0x8d, 0x1c}, /* output YUV */ | ||
542 | {0x34, 0x05}, /* enable Audio Suspend mode */ | ||
543 | {0xc2, 0x4c}, /* output YUV and Enable DCW */ | ||
544 | {0xc3, 0xf9}, /* enable PRE */ | ||
545 | {0x1c, 0x00}, /* indirect addressing */ | ||
546 | {0x1d, 0x48}, /* output YUV422 */ | ||
547 | {0x50, 0x89}, /* H/V divider=/2; plus DCW AVG */ | ||
548 | {0x51, 0xa0}, /* DCW input H=640/4 */ | ||
549 | {0x52, 0x78}, /* DCW input V=480/4 */ | ||
550 | {0x53, 0x00}, /* offset X=0 */ | ||
551 | {0x54, 0x00}, /* offset Y=0 */ | ||
552 | {0x55, 0x00}, /* H/V size[8]=0 */ | ||
553 | {0x57, 0x00}, /* H-size[9]=0 */ | ||
554 | {0x5c, 0x00}, /* DCW output size[9:8]=0 */ | ||
555 | {0x5a, 0x50}, /* DCW output H=320/4 */ | ||
556 | {0x5b, 0x3c}, /* DCW output V=240/4 */ | ||
557 | {0x1c, 0x0a}, | ||
558 | {0x1d, 0x0a}, | ||
559 | {0x94, 0x11}, | ||
560 | }; | ||
561 | static const u8 sensor_start_qvga_767x[][2] = { | ||
562 | {0x11, 0x01}, | ||
563 | {0x1e, 0x04}, | ||
564 | {0x19, 0x02}, | ||
565 | {0x1a, 0x7a}, | ||
566 | }; | ||
567 | |||
568 | static const u8 bridge_init_772x[][2] = { | ||
284 | { 0xc2, 0x0c }, | 569 | { 0xc2, 0x0c }, |
285 | { 0x88, 0xf8 }, | 570 | { 0x88, 0xf8 }, |
286 | { 0xc3, 0x69 }, | 571 | { 0xc3, 0x69 }, |
@@ -338,7 +623,7 @@ static const u8 bridge_init[][2] = { | |||
338 | { 0xc1, 0x3c }, | 623 | { 0xc1, 0x3c }, |
339 | { 0xc2, 0x0c }, | 624 | { 0xc2, 0x0c }, |
340 | }; | 625 | }; |
341 | static const u8 sensor_init[][2] = { | 626 | static const u8 sensor_init_772x[][2] = { |
342 | { 0x12, 0x80 }, | 627 | { 0x12, 0x80 }, |
343 | { 0x11, 0x01 }, | 628 | { 0x11, 0x01 }, |
344 | /*fixme: better have a delay?*/ | 629 | /*fixme: better have a delay?*/ |
@@ -431,7 +716,7 @@ static const u8 sensor_init[][2] = { | |||
431 | { 0x8e, 0x00 }, /* De-noise threshold */ | 716 | { 0x8e, 0x00 }, /* De-noise threshold */ |
432 | { 0x0c, 0xd0 } | 717 | { 0x0c, 0xd0 } |
433 | }; | 718 | }; |
434 | static const u8 bridge_start_vga[][2] = { | 719 | static const u8 bridge_start_vga_772x[][2] = { |
435 | {0x1c, 0x00}, | 720 | {0x1c, 0x00}, |
436 | {0x1d, 0x40}, | 721 | {0x1d, 0x40}, |
437 | {0x1d, 0x02}, | 722 | {0x1d, 0x02}, |
@@ -442,7 +727,7 @@ static const u8 bridge_start_vga[][2] = { | |||
442 | {0xc0, 0x50}, | 727 | {0xc0, 0x50}, |
443 | {0xc1, 0x3c}, | 728 | {0xc1, 0x3c}, |
444 | }; | 729 | }; |
445 | static const u8 sensor_start_vga[][2] = { | 730 | static const u8 sensor_start_vga_772x[][2] = { |
446 | {0x12, 0x00}, | 731 | {0x12, 0x00}, |
447 | {0x17, 0x26}, | 732 | {0x17, 0x26}, |
448 | {0x18, 0xa0}, | 733 | {0x18, 0xa0}, |
@@ -452,7 +737,7 @@ static const u8 sensor_start_vga[][2] = { | |||
452 | {0x2c, 0xf0}, | 737 | {0x2c, 0xf0}, |
453 | {0x65, 0x20}, | 738 | {0x65, 0x20}, |
454 | }; | 739 | }; |
455 | static const u8 bridge_start_qvga[][2] = { | 740 | static const u8 bridge_start_qvga_772x[][2] = { |
456 | {0x1c, 0x00}, | 741 | {0x1c, 0x00}, |
457 | {0x1d, 0x40}, | 742 | {0x1d, 0x40}, |
458 | {0x1d, 0x02}, | 743 | {0x1d, 0x02}, |
@@ -463,7 +748,7 @@ static const u8 bridge_start_qvga[][2] = { | |||
463 | {0xc0, 0x28}, | 748 | {0xc0, 0x28}, |
464 | {0xc1, 0x1e}, | 749 | {0xc1, 0x1e}, |
465 | }; | 750 | }; |
466 | static const u8 sensor_start_qvga[][2] = { | 751 | static const u8 sensor_start_qvga_772x[][2] = { |
467 | {0x12, 0x40}, | 752 | {0x12, 0x40}, |
468 | {0x17, 0x3f}, | 753 | {0x17, 0x3f}, |
469 | {0x18, 0x50}, | 754 | {0x18, 0x50}, |
@@ -479,15 +764,20 @@ static void ov534_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val) | |||
479 | struct usb_device *udev = gspca_dev->dev; | 764 | struct usb_device *udev = gspca_dev->dev; |
480 | int ret; | 765 | int ret; |
481 | 766 | ||
482 | PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val); | 767 | if (gspca_dev->usb_err < 0) |
768 | return; | ||
769 | |||
770 | PDEBUG(D_USBO, "SET 01 0000 %04x %02x", reg, val); | ||
483 | gspca_dev->usb_buf[0] = val; | 771 | gspca_dev->usb_buf[0] = val; |
484 | ret = usb_control_msg(udev, | 772 | ret = usb_control_msg(udev, |
485 | usb_sndctrlpipe(udev, 0), | 773 | usb_sndctrlpipe(udev, 0), |
486 | 0x01, | 774 | 0x01, |
487 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 775 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
488 | 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); | 776 | 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); |
489 | if (ret < 0) | 777 | if (ret < 0) { |
490 | PDEBUG(D_ERR, "write failed"); | 778 | err("write failed %d", ret); |
779 | gspca_dev->usb_err = ret; | ||
780 | } | ||
491 | } | 781 | } |
492 | 782 | ||
493 | static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) | 783 | static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) |
@@ -495,14 +785,18 @@ static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) | |||
495 | struct usb_device *udev = gspca_dev->dev; | 785 | struct usb_device *udev = gspca_dev->dev; |
496 | int ret; | 786 | int ret; |
497 | 787 | ||
788 | if (gspca_dev->usb_err < 0) | ||
789 | return 0; | ||
498 | ret = usb_control_msg(udev, | 790 | ret = usb_control_msg(udev, |
499 | usb_rcvctrlpipe(udev, 0), | 791 | usb_rcvctrlpipe(udev, 0), |
500 | 0x01, | 792 | 0x01, |
501 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 793 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
502 | 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); | 794 | 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]); | 795 | PDEBUG(D_USBI, "GET 01 0000 %04x %02x", reg, gspca_dev->usb_buf[0]); |
504 | if (ret < 0) | 796 | if (ret < 0) { |
505 | PDEBUG(D_ERR, "read failed"); | 797 | err("read failed %d", ret); |
798 | gspca_dev->usb_err = ret; | ||
799 | } | ||
506 | return gspca_dev->usb_buf[0]; | 800 | return gspca_dev->usb_buf[0]; |
507 | } | 801 | } |
508 | 802 | ||
@@ -558,13 +852,15 @@ static int sccb_check_status(struct gspca_dev *gspca_dev) | |||
558 | 852 | ||
559 | static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) | 853 | static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) |
560 | { | 854 | { |
561 | PDEBUG(D_USBO, "reg: 0x%02x, val: 0x%02x", reg, val); | 855 | PDEBUG(D_USBO, "sccb write: %02x %02x", reg, val); |
562 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); | 856 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); |
563 | ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); | 857 | ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); |
564 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); | 858 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); |
565 | 859 | ||
566 | if (!sccb_check_status(gspca_dev)) | 860 | if (!sccb_check_status(gspca_dev)) { |
567 | PDEBUG(D_ERR, "sccb_reg_write failed"); | 861 | err("sccb_reg_write failed"); |
862 | gspca_dev->usb_err = -EIO; | ||
863 | } | ||
568 | } | 864 | } |
569 | 865 | ||
570 | static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) | 866 | static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) |
@@ -572,11 +868,11 @@ static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) | |||
572 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); | 868 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); |
573 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2); | 869 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2); |
574 | if (!sccb_check_status(gspca_dev)) | 870 | if (!sccb_check_status(gspca_dev)) |
575 | PDEBUG(D_ERR, "sccb_reg_read failed 1"); | 871 | err("sccb_reg_read failed 1"); |
576 | 872 | ||
577 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2); | 873 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2); |
578 | if (!sccb_check_status(gspca_dev)) | 874 | if (!sccb_check_status(gspca_dev)) |
579 | PDEBUG(D_ERR, "sccb_reg_read failed 2"); | 875 | err("sccb_reg_read failed 2"); |
580 | 876 | ||
581 | return ov534_reg_read(gspca_dev, OV534_REG_READ); | 877 | return ov534_reg_read(gspca_dev, OV534_REG_READ); |
582 | } | 878 | } |
@@ -635,6 +931,8 @@ static void set_frame_rate(struct gspca_dev *gspca_dev) | |||
635 | {30, 0x04, 0x41, 0x04}, | 931 | {30, 0x04, 0x41, 0x04}, |
636 | }; | 932 | }; |
637 | 933 | ||
934 | if (sd->sensor != SENSOR_OV772x) | ||
935 | return; | ||
638 | if (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv == 0) { | 936 | if (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv == 0) { |
639 | r = rate_0; | 937 | r = rate_0; |
640 | i = ARRAY_SIZE(rate_0); | 938 | i = ARRAY_SIZE(rate_0); |
@@ -658,15 +956,28 @@ static void set_frame_rate(struct gspca_dev *gspca_dev) | |||
658 | static void setbrightness(struct gspca_dev *gspca_dev) | 956 | static void setbrightness(struct gspca_dev *gspca_dev) |
659 | { | 957 | { |
660 | struct sd *sd = (struct sd *) gspca_dev; | 958 | struct sd *sd = (struct sd *) gspca_dev; |
959 | int val; | ||
661 | 960 | ||
662 | sccb_reg_write(gspca_dev, 0x9b, sd->brightness); | 961 | val = sd->ctrls[BRIGHTNESS].val; |
962 | if (sd->sensor == SENSOR_OV767x) { | ||
963 | if (val < 0) | ||
964 | val = 0x80 - val; | ||
965 | sccb_reg_write(gspca_dev, 0x55, val); /* bright */ | ||
966 | } else { | ||
967 | sccb_reg_write(gspca_dev, 0x9b, val); | ||
968 | } | ||
663 | } | 969 | } |
664 | 970 | ||
665 | static void setcontrast(struct gspca_dev *gspca_dev) | 971 | static void setcontrast(struct gspca_dev *gspca_dev) |
666 | { | 972 | { |
667 | struct sd *sd = (struct sd *) gspca_dev; | 973 | struct sd *sd = (struct sd *) gspca_dev; |
974 | u8 val; | ||
668 | 975 | ||
669 | sccb_reg_write(gspca_dev, 0x9c, sd->contrast); | 976 | val = sd->ctrls[CONTRAST].val; |
977 | if (sd->sensor == SENSOR_OV767x) | ||
978 | sccb_reg_write(gspca_dev, 0x56, val); /* contras */ | ||
979 | else | ||
980 | sccb_reg_write(gspca_dev, 0x9c, val); | ||
670 | } | 981 | } |
671 | 982 | ||
672 | static void setgain(struct gspca_dev *gspca_dev) | 983 | static void setgain(struct gspca_dev *gspca_dev) |
@@ -674,10 +985,10 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
674 | struct sd *sd = (struct sd *) gspca_dev; | 985 | struct sd *sd = (struct sd *) gspca_dev; |
675 | u8 val; | 986 | u8 val; |
676 | 987 | ||
677 | if (sd->agc) | 988 | if (sd->ctrls[AGC].val) |
678 | return; | 989 | return; |
679 | 990 | ||
680 | val = sd->gain; | 991 | val = sd->ctrls[GAIN].val; |
681 | switch (val & 0x30) { | 992 | switch (val & 0x30) { |
682 | case 0x00: | 993 | case 0x00: |
683 | val &= 0x0f; | 994 | val &= 0x0f; |
@@ -704,25 +1015,32 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
704 | struct sd *sd = (struct sd *) gspca_dev; | 1015 | struct sd *sd = (struct sd *) gspca_dev; |
705 | u8 val; | 1016 | u8 val; |
706 | 1017 | ||
707 | if (sd->aec) | 1018 | if (sd->ctrls[AEC].val) |
708 | return; | 1019 | return; |
709 | 1020 | ||
710 | /* 'val' is one byte and represents half of the exposure value we are | 1021 | val = sd->ctrls[EXPOSURE].val; |
711 | * going to set into registers, a two bytes value: | 1022 | if (sd->sensor == SENSOR_OV767x) { |
712 | * | 1023 | |
713 | * MSB: ((u16) val << 1) >> 8 == val >> 7 | 1024 | /* set only aec[9:2] */ |
714 | * LSB: ((u16) val << 1) & 0xff == val << 1 | 1025 | sccb_reg_write(gspca_dev, 0x10, val); /* aech */ |
715 | */ | 1026 | } else { |
716 | val = sd->exposure; | 1027 | |
717 | sccb_reg_write(gspca_dev, 0x08, val >> 7); | 1028 | /* 'val' is one byte and represents half of the exposure value |
718 | sccb_reg_write(gspca_dev, 0x10, val << 1); | 1029 | * we are going to set into registers, a two bytes value: |
1030 | * | ||
1031 | * MSB: ((u16) val << 1) >> 8 == val >> 7 | ||
1032 | * LSB: ((u16) val << 1) & 0xff == val << 1 | ||
1033 | */ | ||
1034 | sccb_reg_write(gspca_dev, 0x08, val >> 7); | ||
1035 | sccb_reg_write(gspca_dev, 0x10, val << 1); | ||
1036 | } | ||
719 | } | 1037 | } |
720 | 1038 | ||
721 | static void setagc(struct gspca_dev *gspca_dev) | 1039 | static void setagc(struct gspca_dev *gspca_dev) |
722 | { | 1040 | { |
723 | struct sd *sd = (struct sd *) gspca_dev; | 1041 | struct sd *sd = (struct sd *) gspca_dev; |
724 | 1042 | ||
725 | if (sd->agc) { | 1043 | if (sd->ctrls[AGC].val) { |
726 | sccb_reg_write(gspca_dev, 0x13, | 1044 | sccb_reg_write(gspca_dev, 0x13, |
727 | sccb_reg_read(gspca_dev, 0x13) | 0x04); | 1045 | sccb_reg_read(gspca_dev, 0x13) | 0x04); |
728 | sccb_reg_write(gspca_dev, 0x64, | 1046 | sccb_reg_write(gspca_dev, 0x64, |
@@ -741,15 +1059,17 @@ static void setawb(struct gspca_dev *gspca_dev) | |||
741 | { | 1059 | { |
742 | struct sd *sd = (struct sd *) gspca_dev; | 1060 | struct sd *sd = (struct sd *) gspca_dev; |
743 | 1061 | ||
744 | if (sd->awb) { | 1062 | if (sd->ctrls[AWB].val) { |
745 | sccb_reg_write(gspca_dev, 0x13, | 1063 | sccb_reg_write(gspca_dev, 0x13, |
746 | sccb_reg_read(gspca_dev, 0x13) | 0x02); | 1064 | sccb_reg_read(gspca_dev, 0x13) | 0x02); |
747 | sccb_reg_write(gspca_dev, 0x63, | 1065 | if (sd->sensor == SENSOR_OV772x) |
1066 | sccb_reg_write(gspca_dev, 0x63, | ||
748 | sccb_reg_read(gspca_dev, 0x63) | 0xc0); | 1067 | sccb_reg_read(gspca_dev, 0x63) | 0xc0); |
749 | } else { | 1068 | } else { |
750 | sccb_reg_write(gspca_dev, 0x13, | 1069 | sccb_reg_write(gspca_dev, 0x13, |
751 | sccb_reg_read(gspca_dev, 0x13) & ~0x02); | 1070 | sccb_reg_read(gspca_dev, 0x13) & ~0x02); |
752 | sccb_reg_write(gspca_dev, 0x63, | 1071 | if (sd->sensor == SENSOR_OV772x) |
1072 | sccb_reg_write(gspca_dev, 0x63, | ||
753 | sccb_reg_read(gspca_dev, 0x63) & ~0xc0); | 1073 | sccb_reg_read(gspca_dev, 0x63) & ~0xc0); |
754 | } | 1074 | } |
755 | } | 1075 | } |
@@ -757,14 +1077,22 @@ static void setawb(struct gspca_dev *gspca_dev) | |||
757 | static void setaec(struct gspca_dev *gspca_dev) | 1077 | static void setaec(struct gspca_dev *gspca_dev) |
758 | { | 1078 | { |
759 | struct sd *sd = (struct sd *) gspca_dev; | 1079 | struct sd *sd = (struct sd *) gspca_dev; |
1080 | u8 data; | ||
760 | 1081 | ||
761 | if (sd->aec) | 1082 | data = sd->sensor == SENSOR_OV767x ? |
1083 | 0x05 : /* agc + aec */ | ||
1084 | 0x01; /* agc */ | ||
1085 | if (sd->ctrls[AEC].val) | ||
762 | sccb_reg_write(gspca_dev, 0x13, | 1086 | sccb_reg_write(gspca_dev, 0x13, |
763 | sccb_reg_read(gspca_dev, 0x13) | 0x01); | 1087 | sccb_reg_read(gspca_dev, 0x13) | data); |
764 | else { | 1088 | else { |
765 | sccb_reg_write(gspca_dev, 0x13, | 1089 | sccb_reg_write(gspca_dev, 0x13, |
766 | sccb_reg_read(gspca_dev, 0x13) & ~0x01); | 1090 | sccb_reg_read(gspca_dev, 0x13) & ~data); |
767 | setexposure(gspca_dev); | 1091 | if (sd->sensor == SENSOR_OV767x) |
1092 | sd->ctrls[EXPOSURE].val = | ||
1093 | sccb_reg_read(gspca_dev, 10); /* aech */ | ||
1094 | else | ||
1095 | setexposure(gspca_dev); | ||
768 | } | 1096 | } |
769 | } | 1097 | } |
770 | 1098 | ||
@@ -773,43 +1101,67 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
773 | struct sd *sd = (struct sd *) gspca_dev; | 1101 | struct sd *sd = (struct sd *) gspca_dev; |
774 | u8 val; | 1102 | u8 val; |
775 | 1103 | ||
776 | val = sd->sharpness; | 1104 | val = sd->ctrls[SHARPNESS].val; |
777 | sccb_reg_write(gspca_dev, 0x91, val); /* Auto de-noise threshold */ | 1105 | sccb_reg_write(gspca_dev, 0x91, val); /* Auto de-noise threshold */ |
778 | sccb_reg_write(gspca_dev, 0x8e, val); /* De-noise threshold */ | 1106 | sccb_reg_write(gspca_dev, 0x8e, val); /* De-noise threshold */ |
779 | } | 1107 | } |
780 | 1108 | ||
781 | static void sethflip(struct gspca_dev *gspca_dev) | 1109 | static void sethvflip(struct gspca_dev *gspca_dev) |
782 | { | 1110 | { |
783 | struct sd *sd = (struct sd *) gspca_dev; | 1111 | struct sd *sd = (struct sd *) gspca_dev; |
1112 | u8 val; | ||
784 | 1113 | ||
785 | if (sd->hflip == 0) | 1114 | if (sd->sensor == SENSOR_OV767x) { |
786 | sccb_reg_write(gspca_dev, 0x0c, | 1115 | val = sccb_reg_read(gspca_dev, 0x1e); /* mvfp */ |
787 | sccb_reg_read(gspca_dev, 0x0c) | 0x40); | 1116 | val &= ~0x30; |
788 | else | 1117 | if (sd->ctrls[HFLIP].val) |
789 | sccb_reg_write(gspca_dev, 0x0c, | 1118 | val |= 0x20; |
790 | sccb_reg_read(gspca_dev, 0x0c) & ~0x40); | 1119 | if (sd->ctrls[VFLIP].val) |
1120 | val |= 0x10; | ||
1121 | sccb_reg_write(gspca_dev, 0x1e, val); | ||
1122 | } else { | ||
1123 | val = sccb_reg_read(gspca_dev, 0x0c); | ||
1124 | val &= ~0xc0; | ||
1125 | if (sd->ctrls[HFLIP].val == 0) | ||
1126 | val |= 0x40; | ||
1127 | if (sd->ctrls[VFLIP].val == 0) | ||
1128 | val |= 0x80; | ||
1129 | sccb_reg_write(gspca_dev, 0x0c, val); | ||
1130 | } | ||
791 | } | 1131 | } |
792 | 1132 | ||
793 | static void setvflip(struct gspca_dev *gspca_dev) | 1133 | static void setcolors(struct gspca_dev *gspca_dev) |
794 | { | 1134 | { |
795 | struct sd *sd = (struct sd *) gspca_dev; | 1135 | struct sd *sd = (struct sd *) gspca_dev; |
1136 | u8 val; | ||
1137 | int i; | ||
1138 | static u8 color_tb[][6] = { | ||
1139 | {0x42, 0x42, 0x00, 0x11, 0x30, 0x41}, | ||
1140 | {0x52, 0x52, 0x00, 0x16, 0x3c, 0x52}, | ||
1141 | {0x66, 0x66, 0x00, 0x1b, 0x4b, 0x66}, | ||
1142 | {0x80, 0x80, 0x00, 0x22, 0x5e, 0x80}, | ||
1143 | {0x9a, 0x9a, 0x00, 0x29, 0x71, 0x9a}, | ||
1144 | {0xb8, 0xb8, 0x00, 0x31, 0x87, 0xb8}, | ||
1145 | {0xdd, 0xdd, 0x00, 0x3b, 0xa2, 0xdd}, | ||
1146 | }; | ||
796 | 1147 | ||
797 | if (sd->vflip == 0) | 1148 | val = sd->ctrls[COLORS].val; |
798 | sccb_reg_write(gspca_dev, 0x0c, | 1149 | for (i = 0; i < ARRAY_SIZE(color_tb[0]); i++) |
799 | sccb_reg_read(gspca_dev, 0x0c) | 0x80); | 1150 | sccb_reg_write(gspca_dev, 0x4f + i, color_tb[val][i]); |
800 | else | ||
801 | sccb_reg_write(gspca_dev, 0x0c, | ||
802 | sccb_reg_read(gspca_dev, 0x0c) & ~0x80); | ||
803 | } | 1151 | } |
804 | 1152 | ||
805 | static void setfreqfltr(struct gspca_dev *gspca_dev) | 1153 | static void setlightfreq(struct gspca_dev *gspca_dev) |
806 | { | 1154 | { |
807 | struct sd *sd = (struct sd *) gspca_dev; | 1155 | struct sd *sd = (struct sd *) gspca_dev; |
1156 | u8 val; | ||
808 | 1157 | ||
809 | if (sd->freqfltr == 0) | 1158 | val = sd->ctrls[LIGHTFREQ].val ? 0x9e : 0x00; |
810 | sccb_reg_write(gspca_dev, 0x2b, 0x00); | 1159 | if (sd->sensor == SENSOR_OV767x) { |
811 | else | 1160 | sccb_reg_write(gspca_dev, 0x2a, 0x00); |
812 | sccb_reg_write(gspca_dev, 0x2b, 0x9e); | 1161 | if (val) |
1162 | val = 0x9d; /* insert dummy to 25fps for 50Hz */ | ||
1163 | } | ||
1164 | sccb_reg_write(gspca_dev, 0x2b, val); | ||
813 | } | 1165 | } |
814 | 1166 | ||
815 | 1167 | ||
@@ -822,39 +1174,33 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
822 | 1174 | ||
823 | cam = &gspca_dev->cam; | 1175 | cam = &gspca_dev->cam; |
824 | 1176 | ||
1177 | cam->ctrls = sd->ctrls; | ||
1178 | |||
1179 | /* the auto white balance control works only when auto gain is set */ | ||
1180 | if (sd_ctrls[AGC].qctrl.default_value == 0) | ||
1181 | gspca_dev->ctrl_inac |= (1 << AWB); | ||
1182 | |||
825 | cam->cam_mode = ov772x_mode; | 1183 | cam->cam_mode = ov772x_mode; |
826 | cam->nmodes = ARRAY_SIZE(ov772x_mode); | 1184 | cam->nmodes = ARRAY_SIZE(ov772x_mode); |
827 | cam->mode_framerates = ov772x_framerates; | ||
828 | |||
829 | cam->bulk = 1; | ||
830 | cam->bulk_size = 16384; | ||
831 | cam->bulk_nurbs = 2; | ||
832 | 1185 | ||
833 | sd->frame_rate = 30; | 1186 | sd->frame_rate = 30; |
834 | 1187 | ||
835 | sd->brightness = BRIGHTNESS_DEF; | ||
836 | sd->contrast = CONTRAST_DEF; | ||
837 | sd->gain = GAIN_DEF; | ||
838 | sd->exposure = EXPO_DEF; | ||
839 | #if AGC_DEF != 0 | ||
840 | sd->agc = AGC_DEF; | ||
841 | #else | ||
842 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); | ||
843 | #endif | ||
844 | sd->awb = AWB_DEF; | ||
845 | sd->aec = AEC_DEF; | ||
846 | sd->sharpness = SHARPNESS_DEF; | ||
847 | sd->hflip = HFLIP_DEF; | ||
848 | sd->vflip = VFLIP_DEF; | ||
849 | sd->freqfltr = FREQFLTR_DEF; | ||
850 | |||
851 | return 0; | 1188 | return 0; |
852 | } | 1189 | } |
853 | 1190 | ||
854 | /* this function is called at probe and resume time */ | 1191 | /* this function is called at probe and resume time */ |
855 | static int sd_init(struct gspca_dev *gspca_dev) | 1192 | static int sd_init(struct gspca_dev *gspca_dev) |
856 | { | 1193 | { |
1194 | struct sd *sd = (struct sd *) gspca_dev; | ||
857 | u16 sensor_id; | 1195 | u16 sensor_id; |
1196 | static const struct reg_array bridge_init[NSENSORS] = { | ||
1197 | [SENSOR_OV767x] = {bridge_init_767x, ARRAY_SIZE(bridge_init_767x)}, | ||
1198 | [SENSOR_OV772x] = {bridge_init_772x, ARRAY_SIZE(bridge_init_772x)}, | ||
1199 | }; | ||
1200 | static const struct reg_array sensor_init[NSENSORS] = { | ||
1201 | [SENSOR_OV767x] = {sensor_init_767x, ARRAY_SIZE(sensor_init_767x)}, | ||
1202 | [SENSOR_OV772x] = {sensor_init_772x, ARRAY_SIZE(sensor_init_772x)}, | ||
1203 | }; | ||
858 | 1204 | ||
859 | /* reset bridge */ | 1205 | /* reset bridge */ |
860 | ov534_reg_write(gspca_dev, 0xe7, 0x3a); | 1206 | ov534_reg_write(gspca_dev, 0xe7, 0x3a); |
@@ -875,52 +1221,104 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
875 | sensor_id |= sccb_reg_read(gspca_dev, 0x0b); | 1221 | sensor_id |= sccb_reg_read(gspca_dev, 0x0b); |
876 | PDEBUG(D_PROBE, "Sensor ID: %04x", sensor_id); | 1222 | PDEBUG(D_PROBE, "Sensor ID: %04x", sensor_id); |
877 | 1223 | ||
1224 | if ((sensor_id & 0xfff0) == 0x7670) { | ||
1225 | sd->sensor = SENSOR_OV767x; | ||
1226 | gspca_dev->ctrl_dis = (1 << GAIN) | | ||
1227 | (1 << AGC) | | ||
1228 | (1 << SHARPNESS); /* auto */ | ||
1229 | sd->ctrls[BRIGHTNESS].min = -127; | ||
1230 | sd->ctrls[BRIGHTNESS].max = 127; | ||
1231 | sd->ctrls[BRIGHTNESS].def = 0; | ||
1232 | sd->ctrls[CONTRAST].max = 0x80; | ||
1233 | sd->ctrls[CONTRAST].def = 0x40; | ||
1234 | sd->ctrls[EXPOSURE].min = 0x08; | ||
1235 | sd->ctrls[EXPOSURE].max = 0x60; | ||
1236 | sd->ctrls[EXPOSURE].def = 0x13; | ||
1237 | sd->ctrls[SHARPNESS].max = 9; | ||
1238 | sd->ctrls[SHARPNESS].def = 4; | ||
1239 | sd->ctrls[HFLIP].def = 1; | ||
1240 | gspca_dev->cam.cam_mode = ov767x_mode; | ||
1241 | gspca_dev->cam.nmodes = ARRAY_SIZE(ov767x_mode); | ||
1242 | } else { | ||
1243 | sd->sensor = SENSOR_OV772x; | ||
1244 | gspca_dev->ctrl_dis = (1 << COLORS); | ||
1245 | gspca_dev->cam.bulk = 1; | ||
1246 | gspca_dev->cam.bulk_size = 16384; | ||
1247 | gspca_dev->cam.bulk_nurbs = 2; | ||
1248 | gspca_dev->cam.mode_framerates = ov772x_framerates; | ||
1249 | } | ||
1250 | |||
878 | /* initialize */ | 1251 | /* initialize */ |
879 | reg_w_array(gspca_dev, bridge_init, | 1252 | reg_w_array(gspca_dev, bridge_init[sd->sensor].val, |
880 | ARRAY_SIZE(bridge_init)); | 1253 | bridge_init[sd->sensor].len); |
881 | ov534_set_led(gspca_dev, 1); | 1254 | ov534_set_led(gspca_dev, 1); |
882 | sccb_w_array(gspca_dev, sensor_init, | 1255 | sccb_w_array(gspca_dev, sensor_init[sd->sensor].val, |
883 | ARRAY_SIZE(sensor_init)); | 1256 | sensor_init[sd->sensor].len); |
884 | ov534_reg_write(gspca_dev, 0xe0, 0x09); | 1257 | if (sd->sensor == SENSOR_OV767x) |
885 | ov534_set_led(gspca_dev, 0); | 1258 | sd_start(gspca_dev); |
886 | set_frame_rate(gspca_dev); | 1259 | sd_stopN(gspca_dev); |
887 | 1260 | /* set_frame_rate(gspca_dev); */ | |
888 | return 0; | 1261 | |
1262 | return gspca_dev->usb_err; | ||
889 | } | 1263 | } |
890 | 1264 | ||
891 | static int sd_start(struct gspca_dev *gspca_dev) | 1265 | static int sd_start(struct gspca_dev *gspca_dev) |
892 | { | 1266 | { |
1267 | struct sd *sd = (struct sd *) gspca_dev; | ||
893 | int mode; | 1268 | int mode; |
1269 | static const struct reg_array bridge_start[NSENSORS][2] = { | ||
1270 | [SENSOR_OV767x] = {{bridge_start_qvga_767x, | ||
1271 | ARRAY_SIZE(bridge_start_qvga_767x)}, | ||
1272 | {bridge_start_vga_767x, | ||
1273 | ARRAY_SIZE(bridge_start_vga_767x)}}, | ||
1274 | [SENSOR_OV772x] = {{bridge_start_qvga_772x, | ||
1275 | ARRAY_SIZE(bridge_start_qvga_772x)}, | ||
1276 | {bridge_start_vga_772x, | ||
1277 | ARRAY_SIZE(bridge_start_vga_772x)}}, | ||
1278 | }; | ||
1279 | static const struct reg_array sensor_start[NSENSORS][2] = { | ||
1280 | [SENSOR_OV767x] = {{sensor_start_qvga_767x, | ||
1281 | ARRAY_SIZE(sensor_start_qvga_767x)}, | ||
1282 | {sensor_start_vga_767x, | ||
1283 | ARRAY_SIZE(sensor_start_vga_767x)}}, | ||
1284 | [SENSOR_OV772x] = {{sensor_start_qvga_772x, | ||
1285 | ARRAY_SIZE(sensor_start_qvga_772x)}, | ||
1286 | {sensor_start_vga_772x, | ||
1287 | ARRAY_SIZE(sensor_start_vga_772x)}}, | ||
1288 | }; | ||
1289 | |||
1290 | /* (from ms-win trace) */ | ||
1291 | if (sd->sensor == SENSOR_OV767x) | ||
1292 | sccb_reg_write(gspca_dev, 0x1e, 0x04); | ||
1293 | /* black sun enable ? */ | ||
1294 | |||
1295 | mode = gspca_dev->curr_mode; /* 0: 320x240, 1: 640x480 */ | ||
1296 | reg_w_array(gspca_dev, bridge_start[sd->sensor][mode].val, | ||
1297 | bridge_start[sd->sensor][mode].len); | ||
1298 | sccb_w_array(gspca_dev, sensor_start[sd->sensor][mode].val, | ||
1299 | sensor_start[sd->sensor][mode].len); | ||
894 | 1300 | ||
895 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; | ||
896 | if (mode != 0) { /* 320x240 */ | ||
897 | reg_w_array(gspca_dev, bridge_start_qvga, | ||
898 | ARRAY_SIZE(bridge_start_qvga)); | ||
899 | sccb_w_array(gspca_dev, sensor_start_qvga, | ||
900 | ARRAY_SIZE(sensor_start_qvga)); | ||
901 | } else { /* 640x480 */ | ||
902 | reg_w_array(gspca_dev, bridge_start_vga, | ||
903 | ARRAY_SIZE(bridge_start_vga)); | ||
904 | sccb_w_array(gspca_dev, sensor_start_vga, | ||
905 | ARRAY_SIZE(sensor_start_vga)); | ||
906 | } | ||
907 | set_frame_rate(gspca_dev); | 1301 | set_frame_rate(gspca_dev); |
908 | 1302 | ||
909 | setagc(gspca_dev); | 1303 | if (!(gspca_dev->ctrl_dis & (1 << AGC))) |
1304 | setagc(gspca_dev); | ||
910 | setawb(gspca_dev); | 1305 | setawb(gspca_dev); |
911 | setaec(gspca_dev); | 1306 | setaec(gspca_dev); |
912 | setgain(gspca_dev); | 1307 | if (!(gspca_dev->ctrl_dis & (1 << GAIN))) |
1308 | setgain(gspca_dev); | ||
913 | setexposure(gspca_dev); | 1309 | setexposure(gspca_dev); |
914 | setbrightness(gspca_dev); | 1310 | setbrightness(gspca_dev); |
915 | setcontrast(gspca_dev); | 1311 | setcontrast(gspca_dev); |
916 | setsharpness(gspca_dev); | 1312 | if (!(gspca_dev->ctrl_dis & (1 << SHARPNESS))) |
917 | setvflip(gspca_dev); | 1313 | setsharpness(gspca_dev); |
918 | sethflip(gspca_dev); | 1314 | sethvflip(gspca_dev); |
919 | setfreqfltr(gspca_dev); | 1315 | if (!(gspca_dev->ctrl_dis & (1 << COLORS))) |
1316 | setcolors(gspca_dev); | ||
1317 | setlightfreq(gspca_dev); | ||
920 | 1318 | ||
921 | ov534_set_led(gspca_dev, 1); | 1319 | ov534_set_led(gspca_dev, 1); |
922 | ov534_reg_write(gspca_dev, 0xe0, 0x00); | 1320 | ov534_reg_write(gspca_dev, 0xe0, 0x00); |
923 | return 0; | 1321 | return gspca_dev->usb_err; |
924 | } | 1322 | } |
925 | 1323 | ||
926 | static void sd_stopN(struct gspca_dev *gspca_dev) | 1324 | static void sd_stopN(struct gspca_dev *gspca_dev) |
@@ -946,9 +1344,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
946 | __u32 this_pts; | 1344 | __u32 this_pts; |
947 | u16 this_fid; | 1345 | u16 this_fid; |
948 | int remaining_len = len; | 1346 | int remaining_len = len; |
1347 | int payload_len; | ||
949 | 1348 | ||
1349 | payload_len = gspca_dev->cam.bulk ? 2048 : 2040; | ||
950 | do { | 1350 | do { |
951 | len = min(remaining_len, 2048); | 1351 | len = min(remaining_len, payload_len); |
952 | 1352 | ||
953 | /* Payloads are prefixed with a UVC-style header. We | 1353 | /* Payloads are prefixed with a UVC-style header. We |
954 | consider a frame to start when the FID toggles, or the PTS | 1354 | consider a frame to start when the FID toggles, or the PTS |
@@ -988,8 +1388,9 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
988 | /* If this packet is marked as EOF, end the frame */ | 1388 | /* If this packet is marked as EOF, end the frame */ |
989 | } else if (data[1] & UVC_STREAM_EOF) { | 1389 | } else if (data[1] & UVC_STREAM_EOF) { |
990 | sd->last_pts = 0; | 1390 | sd->last_pts = 0; |
991 | if (gspca_dev->image_len + len - 12 != | 1391 | if (gspca_dev->pixfmt == V4L2_PIX_FMT_YUYV |
992 | gspca_dev->width * gspca_dev->height * 2) { | 1392 | && gspca_dev->image_len + len - 12 != |
1393 | gspca_dev->width * gspca_dev->height * 2) { | ||
993 | PDEBUG(D_PACK, "wrong sized frame"); | 1394 | PDEBUG(D_PACK, "wrong sized frame"); |
994 | goto discard; | 1395 | goto discard; |
995 | } | 1396 | } |
@@ -1015,212 +1416,27 @@ scan_next: | |||
1015 | } while (remaining_len > 0); | 1416 | } while (remaining_len > 0); |
1016 | } | 1417 | } |
1017 | 1418 | ||
1018 | /* controls */ | ||
1019 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | ||
1020 | { | ||
1021 | struct sd *sd = (struct sd *) gspca_dev; | ||
1022 | |||
1023 | sd->gain = val; | ||
1024 | if (gspca_dev->streaming) | ||
1025 | setgain(gspca_dev); | ||
1026 | return 0; | ||
1027 | } | ||
1028 | |||
1029 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | ||
1030 | { | ||
1031 | struct sd *sd = (struct sd *) gspca_dev; | ||
1032 | |||
1033 | *val = sd->gain; | ||
1034 | return 0; | ||
1035 | } | ||
1036 | |||
1037 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val) | ||
1038 | { | ||
1039 | struct sd *sd = (struct sd *) gspca_dev; | ||
1040 | |||
1041 | sd->exposure = val; | ||
1042 | if (gspca_dev->streaming) | ||
1043 | setexposure(gspca_dev); | ||
1044 | return 0; | ||
1045 | } | ||
1046 | |||
1047 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) | ||
1048 | { | ||
1049 | struct sd *sd = (struct sd *) gspca_dev; | ||
1050 | |||
1051 | *val = sd->exposure; | ||
1052 | return 0; | ||
1053 | } | ||
1054 | |||
1055 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
1056 | { | ||
1057 | struct sd *sd = (struct sd *) gspca_dev; | ||
1058 | |||
1059 | sd->brightness = val; | ||
1060 | if (gspca_dev->streaming) | ||
1061 | setbrightness(gspca_dev); | ||
1062 | return 0; | ||
1063 | } | ||
1064 | |||
1065 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
1066 | { | ||
1067 | struct sd *sd = (struct sd *) gspca_dev; | ||
1068 | |||
1069 | *val = sd->brightness; | ||
1070 | return 0; | ||
1071 | } | ||
1072 | |||
1073 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | ||
1074 | { | ||
1075 | struct sd *sd = (struct sd *) gspca_dev; | ||
1076 | |||
1077 | sd->contrast = val; | ||
1078 | if (gspca_dev->streaming) | ||
1079 | setcontrast(gspca_dev); | ||
1080 | return 0; | ||
1081 | } | ||
1082 | |||
1083 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | ||
1084 | { | ||
1085 | struct sd *sd = (struct sd *) gspca_dev; | ||
1086 | |||
1087 | *val = sd->contrast; | ||
1088 | return 0; | ||
1089 | } | ||
1090 | |||
1091 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val) | 1419 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val) |
1092 | { | 1420 | { |
1093 | struct sd *sd = (struct sd *) gspca_dev; | 1421 | struct sd *sd = (struct sd *) gspca_dev; |
1094 | 1422 | ||
1095 | sd->agc = val; | 1423 | sd->ctrls[AGC].val = val; |
1096 | 1424 | ||
1097 | if (gspca_dev->streaming) { | 1425 | /* the auto white balance control works only |
1098 | 1426 | * when auto gain is set */ | |
1099 | /* the auto white balance control works only | 1427 | if (val) { |
1100 | * when auto gain is set */ | 1428 | gspca_dev->ctrl_inac &= ~(1 << AWB); |
1101 | if (val) | 1429 | } else { |
1102 | gspca_dev->ctrl_inac &= ~(1 << AWB_IDX); | 1430 | gspca_dev->ctrl_inac |= (1 << AWB); |
1103 | else | 1431 | if (sd->ctrls[AWB].val) { |
1104 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); | 1432 | sd->ctrls[AWB].val = 0; |
1105 | setagc(gspca_dev); | 1433 | if (gspca_dev->streaming) |
1434 | setawb(gspca_dev); | ||
1435 | } | ||
1106 | } | 1436 | } |
1107 | return 0; | ||
1108 | } | ||
1109 | |||
1110 | static int sd_getagc(struct gspca_dev *gspca_dev, __s32 *val) | ||
1111 | { | ||
1112 | struct sd *sd = (struct sd *) gspca_dev; | ||
1113 | |||
1114 | *val = sd->agc; | ||
1115 | return 0; | ||
1116 | } | ||
1117 | |||
1118 | static int sd_setawb(struct gspca_dev *gspca_dev, __s32 val) | ||
1119 | { | ||
1120 | struct sd *sd = (struct sd *) gspca_dev; | ||
1121 | |||
1122 | sd->awb = val; | ||
1123 | if (gspca_dev->streaming) | ||
1124 | setawb(gspca_dev); | ||
1125 | return 0; | ||
1126 | } | ||
1127 | |||
1128 | static int sd_getawb(struct gspca_dev *gspca_dev, __s32 *val) | ||
1129 | { | ||
1130 | struct sd *sd = (struct sd *) gspca_dev; | ||
1131 | |||
1132 | *val = sd->awb; | ||
1133 | return 0; | ||
1134 | } | ||
1135 | |||
1136 | static int sd_setaec(struct gspca_dev *gspca_dev, __s32 val) | ||
1137 | { | ||
1138 | struct sd *sd = (struct sd *) gspca_dev; | ||
1139 | |||
1140 | sd->aec = val; | ||
1141 | if (gspca_dev->streaming) | 1437 | if (gspca_dev->streaming) |
1142 | setaec(gspca_dev); | 1438 | setagc(gspca_dev); |
1143 | return 0; | 1439 | return gspca_dev->usb_err; |
1144 | } | ||
1145 | |||
1146 | static int sd_getaec(struct gspca_dev *gspca_dev, __s32 *val) | ||
1147 | { | ||
1148 | struct sd *sd = (struct sd *) gspca_dev; | ||
1149 | |||
1150 | *val = sd->aec; | ||
1151 | return 0; | ||
1152 | } | ||
1153 | |||
1154 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val) | ||
1155 | { | ||
1156 | struct sd *sd = (struct sd *) gspca_dev; | ||
1157 | |||
1158 | sd->sharpness = val; | ||
1159 | if (gspca_dev->streaming) | ||
1160 | setsharpness(gspca_dev); | ||
1161 | return 0; | ||
1162 | } | ||
1163 | |||
1164 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) | ||
1165 | { | ||
1166 | struct sd *sd = (struct sd *) gspca_dev; | ||
1167 | |||
1168 | *val = sd->sharpness; | ||
1169 | return 0; | ||
1170 | } | ||
1171 | |||
1172 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) | ||
1173 | { | ||
1174 | struct sd *sd = (struct sd *) gspca_dev; | ||
1175 | |||
1176 | sd->hflip = val; | ||
1177 | if (gspca_dev->streaming) | ||
1178 | sethflip(gspca_dev); | ||
1179 | return 0; | ||
1180 | } | ||
1181 | |||
1182 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
1183 | { | ||
1184 | struct sd *sd = (struct sd *) gspca_dev; | ||
1185 | |||
1186 | *val = sd->hflip; | ||
1187 | return 0; | ||
1188 | } | ||
1189 | |||
1190 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) | ||
1191 | { | ||
1192 | struct sd *sd = (struct sd *) gspca_dev; | ||
1193 | |||
1194 | sd->vflip = val; | ||
1195 | if (gspca_dev->streaming) | ||
1196 | setvflip(gspca_dev); | ||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
1201 | { | ||
1202 | struct sd *sd = (struct sd *) gspca_dev; | ||
1203 | |||
1204 | *val = sd->vflip; | ||
1205 | return 0; | ||
1206 | } | ||
1207 | |||
1208 | static int sd_setfreqfltr(struct gspca_dev *gspca_dev, __s32 val) | ||
1209 | { | ||
1210 | struct sd *sd = (struct sd *) gspca_dev; | ||
1211 | |||
1212 | sd->freqfltr = val; | ||
1213 | if (gspca_dev->streaming) | ||
1214 | setfreqfltr(gspca_dev); | ||
1215 | return 0; | ||
1216 | } | ||
1217 | |||
1218 | static int sd_getfreqfltr(struct gspca_dev *gspca_dev, __s32 *val) | ||
1219 | { | ||
1220 | struct sd *sd = (struct sd *) gspca_dev; | ||
1221 | |||
1222 | *val = sd->freqfltr; | ||
1223 | return 0; | ||
1224 | } | 1440 | } |
1225 | 1441 | ||
1226 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 1442 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
@@ -1243,34 +1459,26 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
1243 | } | 1459 | } |
1244 | 1460 | ||
1245 | /* get stream parameters (framerate) */ | 1461 | /* get stream parameters (framerate) */ |
1246 | static int sd_get_streamparm(struct gspca_dev *gspca_dev, | 1462 | static void sd_get_streamparm(struct gspca_dev *gspca_dev, |
1247 | struct v4l2_streamparm *parm) | 1463 | struct v4l2_streamparm *parm) |
1248 | { | 1464 | { |
1249 | struct v4l2_captureparm *cp = &parm->parm.capture; | 1465 | struct v4l2_captureparm *cp = &parm->parm.capture; |
1250 | struct v4l2_fract *tpf = &cp->timeperframe; | 1466 | struct v4l2_fract *tpf = &cp->timeperframe; |
1251 | struct sd *sd = (struct sd *) gspca_dev; | 1467 | struct sd *sd = (struct sd *) gspca_dev; |
1252 | 1468 | ||
1253 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1254 | return -EINVAL; | ||
1255 | |||
1256 | cp->capability |= V4L2_CAP_TIMEPERFRAME; | 1469 | cp->capability |= V4L2_CAP_TIMEPERFRAME; |
1257 | tpf->numerator = 1; | 1470 | tpf->numerator = 1; |
1258 | tpf->denominator = sd->frame_rate; | 1471 | tpf->denominator = sd->frame_rate; |
1259 | |||
1260 | return 0; | ||
1261 | } | 1472 | } |
1262 | 1473 | ||
1263 | /* set stream parameters (framerate) */ | 1474 | /* set stream parameters (framerate) */ |
1264 | static int sd_set_streamparm(struct gspca_dev *gspca_dev, | 1475 | static void sd_set_streamparm(struct gspca_dev *gspca_dev, |
1265 | struct v4l2_streamparm *parm) | 1476 | struct v4l2_streamparm *parm) |
1266 | { | 1477 | { |
1267 | struct v4l2_captureparm *cp = &parm->parm.capture; | 1478 | struct v4l2_captureparm *cp = &parm->parm.capture; |
1268 | struct v4l2_fract *tpf = &cp->timeperframe; | 1479 | struct v4l2_fract *tpf = &cp->timeperframe; |
1269 | struct sd *sd = (struct sd *) gspca_dev; | 1480 | struct sd *sd = (struct sd *) gspca_dev; |
1270 | 1481 | ||
1271 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1272 | return -EINVAL; | ||
1273 | |||
1274 | /* Set requested framerate */ | 1482 | /* Set requested framerate */ |
1275 | sd->frame_rate = tpf->denominator / tpf->numerator; | 1483 | sd->frame_rate = tpf->denominator / tpf->numerator; |
1276 | if (gspca_dev->streaming) | 1484 | if (gspca_dev->streaming) |
@@ -1279,8 +1487,6 @@ static int sd_set_streamparm(struct gspca_dev *gspca_dev, | |||
1279 | /* Return the actual framerate */ | 1487 | /* Return the actual framerate */ |
1280 | tpf->numerator = 1; | 1488 | tpf->numerator = 1; |
1281 | tpf->denominator = sd->frame_rate; | 1489 | tpf->denominator = sd->frame_rate; |
1282 | |||
1283 | return 0; | ||
1284 | } | 1490 | } |
1285 | 1491 | ||
1286 | /* sub-driver description */ | 1492 | /* sub-driver description */ |
@@ -1299,8 +1505,9 @@ static const struct sd_desc sd_desc = { | |||
1299 | }; | 1505 | }; |
1300 | 1506 | ||
1301 | /* -- module initialisation -- */ | 1507 | /* -- module initialisation -- */ |
1302 | static const __devinitdata struct usb_device_id device_table[] = { | 1508 | static const struct usb_device_id device_table[] = { |
1303 | {USB_DEVICE(0x1415, 0x2000)}, | 1509 | {USB_DEVICE(0x1415, 0x2000)}, |
1510 | {USB_DEVICE(0x06f8, 0x3002)}, | ||
1304 | {} | 1511 | {} |
1305 | }; | 1512 | }; |
1306 | 1513 | ||
@@ -1327,19 +1534,12 @@ static struct usb_driver sd_driver = { | |||
1327 | /* -- module insert / remove -- */ | 1534 | /* -- module insert / remove -- */ |
1328 | static int __init sd_mod_init(void) | 1535 | static int __init sd_mod_init(void) |
1329 | { | 1536 | { |
1330 | int ret; | 1537 | 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 | } | 1538 | } |
1338 | 1539 | ||
1339 | static void __exit sd_mod_exit(void) | 1540 | static void __exit sd_mod_exit(void) |
1340 | { | 1541 | { |
1341 | usb_deregister(&sd_driver); | 1542 | usb_deregister(&sd_driver); |
1342 | PDEBUG(D_PROBE, "deregistered"); | ||
1343 | } | 1543 | } |
1344 | 1544 | ||
1345 | module_init(sd_mod_init); | 1545 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/ov534_9.c b/drivers/media/video/gspca/ov534_9.c index bbe5a030e3b4..aaf5428c57f5 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 | ||
854 | static u8 sccb_read(struct gspca_dev *gspca_dev, u16 reg) | 854 | static 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 | } |
@@ -945,7 +945,6 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
945 | u8 val; | 945 | u8 val; |
946 | 946 | ||
947 | /*fixme: should adjust agc/awb/aec by different controls */ | 947 | /*fixme: should adjust agc/awb/aec by different controls */ |
948 | val = sd->autogain; | ||
949 | val = sccb_read(gspca_dev, 0x13); /* com8 */ | 948 | val = sccb_read(gspca_dev, 0x13); /* com8 */ |
950 | sccb_write(gspca_dev, 0xff, 0x00); | 949 | sccb_write(gspca_dev, 0xff, 0x00); |
951 | if (sd->autogain) | 950 | if (sd->autogain) |
@@ -1430,7 +1429,7 @@ static const struct sd_desc sd_desc = { | |||
1430 | }; | 1429 | }; |
1431 | 1430 | ||
1432 | /* -- module initialisation -- */ | 1431 | /* -- module initialisation -- */ |
1433 | static const __devinitdata struct usb_device_id device_table[] = { | 1432 | static const struct usb_device_id device_table[] = { |
1434 | {USB_DEVICE(0x06f8, 0x3003)}, | 1433 | {USB_DEVICE(0x06f8, 0x3003)}, |
1435 | {} | 1434 | {} |
1436 | }; | 1435 | }; |
@@ -1458,19 +1457,12 @@ static struct usb_driver sd_driver = { | |||
1458 | /* -- module insert / remove -- */ | 1457 | /* -- module insert / remove -- */ |
1459 | static int __init sd_mod_init(void) | 1458 | static int __init sd_mod_init(void) |
1460 | { | 1459 | { |
1461 | int ret; | 1460 | 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 | } | 1461 | } |
1469 | 1462 | ||
1470 | static void __exit sd_mod_exit(void) | 1463 | static void __exit sd_mod_exit(void) |
1471 | { | 1464 | { |
1472 | usb_deregister(&sd_driver); | 1465 | usb_deregister(&sd_driver); |
1473 | PDEBUG(D_PROBE, "deregistered"); | ||
1474 | } | 1466 | } |
1475 | 1467 | ||
1476 | module_init(sd_mod_init); | 1468 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c index a40f8893310d..81739a2f205e 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 | ||
31 | MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); | 31 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
32 | MODULE_DESCRIPTION("Pixart PAC207"); | 32 | MODULE_DESCRIPTION("Pixart PAC207"); |
33 | MODULE_LICENSE("GPL"); | 33 | MODULE_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 |
@@ -162,7 +162,7 @@ static const __u8 pac207_sensor_init[][8] = { | |||
162 | {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84}, | 162 | {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84}, |
163 | {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30}, | 163 | {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30}, |
164 | {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00}, | 164 | {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00}, |
165 | {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00}, | 165 | {0x32, 0x00, 0x96, 0x00, 0xa2, 0x02, 0xaf, 0x00}, |
166 | }; | 166 | }; |
167 | 167 | ||
168 | static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, | 168 | static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, |
@@ -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 | } |
@@ -230,7 +228,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
230 | 228 | ||
231 | idreg[0] = pac207_read_reg(gspca_dev, 0x0000); | 229 | idreg[0] = pac207_read_reg(gspca_dev, 0x0000); |
232 | idreg[1] = pac207_read_reg(gspca_dev, 0x0001); | 230 | idreg[1] = pac207_read_reg(gspca_dev, 0x0001); |
233 | idreg[0] = ((idreg[0] & 0x0F) << 4) | ((idreg[1] & 0xf0) >> 4); | 231 | idreg[0] = ((idreg[0] & 0x0f) << 4) | ((idreg[1] & 0xf0) >> 4); |
234 | idreg[1] = idreg[1] & 0x0f; | 232 | idreg[1] = idreg[1] & 0x0f; |
235 | PDEBUG(D_PROBE, "Pixart Sensor ID 0x%02X Chips ID 0x%02X", | 233 | PDEBUG(D_PROBE, "Pixart Sensor ID 0x%02X Chips ID 0x%02X", |
236 | idreg[0], idreg[1]); | 234 | idreg[0], idreg[1]); |
@@ -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) |
500 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 498 | static 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,13 +524,13 @@ 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 | }; |
533 | 531 | ||
534 | /* -- module initialisation -- */ | 532 | /* -- module initialisation -- */ |
535 | static const __devinitdata struct usb_device_id device_table[] = { | 533 | static const struct usb_device_id device_table[] = { |
536 | {USB_DEVICE(0x041e, 0x4028)}, | 534 | {USB_DEVICE(0x041e, 0x4028)}, |
537 | {USB_DEVICE(0x093a, 0x2460)}, | 535 | {USB_DEVICE(0x093a, 0x2460)}, |
538 | {USB_DEVICE(0x093a, 0x2461)}, | 536 | {USB_DEVICE(0x093a, 0x2461)}, |
@@ -572,17 +570,11 @@ static struct usb_driver sd_driver = { | |||
572 | /* -- module insert / remove -- */ | 570 | /* -- module insert / remove -- */ |
573 | static int __init sd_mod_init(void) | 571 | static 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 | } |
582 | static void __exit sd_mod_exit(void) | 575 | static 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 | ||
588 | module_init(sd_mod_init); | 580 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c index a66df07d7625..5615d7bd8304 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c | |||
@@ -393,7 +393,7 @@ static const __u8 page3_7302[] = { | |||
393 | 393 | ||
394 | static void reg_w_buf(struct gspca_dev *gspca_dev, | 394 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
395 | __u8 index, | 395 | __u8 index, |
396 | const char *buffer, int len) | 396 | const u8 *buffer, int len) |
397 | { | 397 | { |
398 | int ret; | 398 | int ret; |
399 | 399 | ||
@@ -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) |
1139 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 1135 | static 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,13 +1178,13 @@ 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 | }; |
1189 | 1185 | ||
1190 | /* -- module initialisation -- */ | 1186 | /* -- module initialisation -- */ |
1191 | static const struct usb_device_id device_table[] __devinitconst = { | 1187 | static const struct usb_device_id device_table[] = { |
1192 | {USB_DEVICE(0x06f8, 0x3009)}, | 1188 | {USB_DEVICE(0x06f8, 0x3009)}, |
1193 | {USB_DEVICE(0x093a, 0x2620)}, | 1189 | {USB_DEVICE(0x093a, 0x2620)}, |
1194 | {USB_DEVICE(0x093a, 0x2621)}, | 1190 | {USB_DEVICE(0x093a, 0x2621)}, |
@@ -1205,7 +1201,7 @@ static const struct usb_device_id device_table[] __devinitconst = { | |||
1205 | MODULE_DEVICE_TABLE(usb, device_table); | 1201 | MODULE_DEVICE_TABLE(usb, device_table); |
1206 | 1202 | ||
1207 | /* -- device connect -- */ | 1203 | /* -- device connect -- */ |
1208 | static int __devinit sd_probe(struct usb_interface *intf, | 1204 | static int sd_probe(struct usb_interface *intf, |
1209 | const struct usb_device_id *id) | 1205 | const struct usb_device_id *id) |
1210 | { | 1206 | { |
1211 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 1207 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
@@ -1226,17 +1222,11 @@ static struct usb_driver sd_driver = { | |||
1226 | /* -- module insert / remove -- */ | 1222 | /* -- module insert / remove -- */ |
1227 | static int __init sd_mod_init(void) | 1223 | static 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 | } |
1236 | static void __exit sd_mod_exit(void) | 1227 | static 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 | ||
1242 | module_init(sd_mod_init); | 1232 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 1cb7e99e92bd..f8801b50e64f 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -261,7 +261,7 @@ static const __u8 page4_7311[] = { | |||
261 | 261 | ||
262 | static void reg_w_buf(struct gspca_dev *gspca_dev, | 262 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
263 | __u8 index, | 263 | __u8 index, |
264 | const char *buffer, int len) | 264 | const u8 *buffer, int len) |
265 | { | 265 | { |
266 | int ret; | 266 | int ret; |
267 | 267 | ||
@@ -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) |
796 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 792 | static 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,13 +831,13 @@ 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 | }; |
842 | 838 | ||
843 | /* -- module initialisation -- */ | 839 | /* -- module initialisation -- */ |
844 | static const struct usb_device_id device_table[] __devinitconst = { | 840 | static const struct usb_device_id device_table[] = { |
845 | {USB_DEVICE(0x093a, 0x2600)}, | 841 | {USB_DEVICE(0x093a, 0x2600)}, |
846 | {USB_DEVICE(0x093a, 0x2601)}, | 842 | {USB_DEVICE(0x093a, 0x2601)}, |
847 | {USB_DEVICE(0x093a, 0x2603)}, | 843 | {USB_DEVICE(0x093a, 0x2603)}, |
@@ -853,7 +849,7 @@ static const struct usb_device_id device_table[] __devinitconst = { | |||
853 | MODULE_DEVICE_TABLE(usb, device_table); | 849 | MODULE_DEVICE_TABLE(usb, device_table); |
854 | 850 | ||
855 | /* -- device connect -- */ | 851 | /* -- device connect -- */ |
856 | static int __devinit sd_probe(struct usb_interface *intf, | 852 | static int sd_probe(struct usb_interface *intf, |
857 | const struct usb_device_id *id) | 853 | const struct usb_device_id *id) |
858 | { | 854 | { |
859 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 855 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
@@ -874,17 +870,11 @@ static struct usb_driver sd_driver = { | |||
874 | /* -- module insert / remove -- */ | 870 | /* -- module insert / remove -- */ |
875 | static int __init sd_mod_init(void) | 871 | static 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 | } |
884 | static void __exit sd_mod_exit(void) | 875 | static 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 | ||
890 | module_init(sd_mod_init); | 880 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sn9c2028.c b/drivers/media/video/gspca/sn9c2028.c index 71d9447a7986..4271f86dfe01 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 | ||
@@ -703,7 +703,7 @@ static const struct sd_desc sd_desc = { | |||
703 | }; | 703 | }; |
704 | 704 | ||
705 | /* -- module initialisation -- */ | 705 | /* -- module initialisation -- */ |
706 | static const __devinitdata struct usb_device_id device_table[] = { | 706 | static const struct usb_device_id device_table[] = { |
707 | {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */ | 707 | {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */ |
708 | /* The Genius Smart is untested. I can't find an owner ! */ | 708 | /* The Genius Smart is untested. I can't find an owner ! */ |
709 | /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */ | 709 | /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */ |
@@ -738,19 +738,12 @@ static struct usb_driver sd_driver = { | |||
738 | /* -- module insert / remove -- */ | 738 | /* -- module insert / remove -- */ |
739 | static int __init sd_mod_init(void) | 739 | static 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 | ||
750 | static void __exit sd_mod_exit(void) | 744 | static 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 | ||
756 | module_init(sd_mod_init); | 749 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c index 9052d5702556..c431900cd292 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" |
@@ -35,6 +33,14 @@ MODULE_LICENSE("GPL"); | |||
35 | 33 | ||
36 | #define MODULE_NAME "sn9c20x" | 34 | #define MODULE_NAME "sn9c20x" |
37 | 35 | ||
36 | /* | ||
37 | * Pixel format private data | ||
38 | */ | ||
39 | #define SCALE_MASK 0x0f | ||
40 | #define SCALE_160x120 0 | ||
41 | #define SCALE_320x240 1 | ||
42 | #define SCALE_640x480 2 | ||
43 | #define SCALE_1280x1024 3 | ||
38 | #define MODE_RAW 0x10 | 44 | #define MODE_RAW 0x10 |
39 | #define MODE_JPEG 0x20 | 45 | #define MODE_JPEG 0x20 |
40 | #define MODE_SXGA 0x80 | 46 | #define MODE_SXGA 0x80 |
@@ -146,6 +152,13 @@ static const struct dmi_system_id flip_dmi_table[] = { | |||
146 | } | 152 | } |
147 | }, | 153 | }, |
148 | { | 154 | { |
155 | .ident = "MSI MS-1633X", | ||
156 | .matches = { | ||
157 | DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), | ||
158 | DMI_MATCH(DMI_BOARD_NAME, "MS-1633X") | ||
159 | } | ||
160 | }, | ||
161 | { | ||
149 | .ident = "MSI MS-1635X", | 162 | .ident = "MSI MS-1635X", |
150 | .matches = { | 163 | .matches = { |
151 | DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), | 164 | DMI_MATCH(DMI_BOARD_VENDOR, "MSI"), |
@@ -347,103 +360,126 @@ static const struct ctrl sd_ctrls[] = { | |||
347 | 360 | ||
348 | static const struct v4l2_pix_format vga_mode[] = { | 361 | static const struct v4l2_pix_format vga_mode[] = { |
349 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 362 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
350 | .bytesperline = 240, | 363 | .bytesperline = 160, |
351 | .sizeimage = 240 * 120, | 364 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
352 | .colorspace = V4L2_COLORSPACE_JPEG, | 365 | .colorspace = V4L2_COLORSPACE_JPEG, |
353 | .priv = 0 | MODE_JPEG}, | 366 | .priv = SCALE_160x120 | MODE_JPEG}, |
354 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 367 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
355 | .bytesperline = 160, | 368 | .bytesperline = 160, |
356 | .sizeimage = 160 * 120, | 369 | .sizeimage = 160 * 120, |
357 | .colorspace = V4L2_COLORSPACE_SRGB, | 370 | .colorspace = V4L2_COLORSPACE_SRGB, |
358 | .priv = 0 | MODE_RAW}, | 371 | .priv = SCALE_160x120 | MODE_RAW}, |
359 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 372 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
360 | .bytesperline = 240, | 373 | .bytesperline = 160, |
361 | .sizeimage = 240 * 120, | 374 | .sizeimage = 240 * 120, |
362 | .colorspace = V4L2_COLORSPACE_SRGB, | 375 | .colorspace = V4L2_COLORSPACE_SRGB, |
363 | .priv = 0}, | 376 | .priv = SCALE_160x120}, |
364 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 377 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
365 | .bytesperline = 480, | 378 | .bytesperline = 320, |
366 | .sizeimage = 480 * 240 , | 379 | .sizeimage = 320 * 240 * 4 / 8 + 590, |
367 | .colorspace = V4L2_COLORSPACE_JPEG, | 380 | .colorspace = V4L2_COLORSPACE_JPEG, |
368 | .priv = 1 | MODE_JPEG}, | 381 | .priv = SCALE_320x240 | MODE_JPEG}, |
369 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 382 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
370 | .bytesperline = 320, | 383 | .bytesperline = 320, |
371 | .sizeimage = 320 * 240 , | 384 | .sizeimage = 320 * 240 , |
372 | .colorspace = V4L2_COLORSPACE_SRGB, | 385 | .colorspace = V4L2_COLORSPACE_SRGB, |
373 | .priv = 1 | MODE_RAW}, | 386 | .priv = SCALE_320x240 | MODE_RAW}, |
374 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 387 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
375 | .bytesperline = 480, | 388 | .bytesperline = 320, |
376 | .sizeimage = 480 * 240 , | 389 | .sizeimage = 480 * 240 , |
377 | .colorspace = V4L2_COLORSPACE_SRGB, | 390 | .colorspace = V4L2_COLORSPACE_SRGB, |
378 | .priv = 1}, | 391 | .priv = SCALE_320x240}, |
379 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 392 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
380 | .bytesperline = 960, | 393 | .bytesperline = 640, |
381 | .sizeimage = 960 * 480, | 394 | .sizeimage = 640 * 480 * 4 / 8 + 590, |
382 | .colorspace = V4L2_COLORSPACE_JPEG, | 395 | .colorspace = V4L2_COLORSPACE_JPEG, |
383 | .priv = 2 | MODE_JPEG}, | 396 | .priv = SCALE_640x480 | MODE_JPEG}, |
384 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 397 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
385 | .bytesperline = 640, | 398 | .bytesperline = 640, |
386 | .sizeimage = 640 * 480, | 399 | .sizeimage = 640 * 480, |
387 | .colorspace = V4L2_COLORSPACE_SRGB, | 400 | .colorspace = V4L2_COLORSPACE_SRGB, |
388 | .priv = 2 | MODE_RAW}, | 401 | .priv = SCALE_640x480 | MODE_RAW}, |
389 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 402 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
390 | .bytesperline = 960, | 403 | .bytesperline = 640, |
391 | .sizeimage = 960 * 480, | 404 | .sizeimage = 960 * 480, |
392 | .colorspace = V4L2_COLORSPACE_SRGB, | 405 | .colorspace = V4L2_COLORSPACE_SRGB, |
393 | .priv = 2}, | 406 | .priv = SCALE_640x480}, |
394 | }; | 407 | }; |
395 | 408 | ||
396 | static const struct v4l2_pix_format sxga_mode[] = { | 409 | static const struct v4l2_pix_format sxga_mode[] = { |
397 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 410 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
398 | .bytesperline = 240, | 411 | .bytesperline = 160, |
399 | .sizeimage = 240 * 120, | 412 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
400 | .colorspace = V4L2_COLORSPACE_JPEG, | 413 | .colorspace = V4L2_COLORSPACE_JPEG, |
401 | .priv = 0 | MODE_JPEG}, | 414 | .priv = SCALE_160x120 | MODE_JPEG}, |
402 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 415 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
403 | .bytesperline = 160, | 416 | .bytesperline = 160, |
404 | .sizeimage = 160 * 120, | 417 | .sizeimage = 160 * 120, |
405 | .colorspace = V4L2_COLORSPACE_SRGB, | 418 | .colorspace = V4L2_COLORSPACE_SRGB, |
406 | .priv = 0 | MODE_RAW}, | 419 | .priv = SCALE_160x120 | MODE_RAW}, |
407 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 420 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
408 | .bytesperline = 240, | 421 | .bytesperline = 160, |
409 | .sizeimage = 240 * 120, | 422 | .sizeimage = 240 * 120, |
410 | .colorspace = V4L2_COLORSPACE_SRGB, | 423 | .colorspace = V4L2_COLORSPACE_SRGB, |
411 | .priv = 0}, | 424 | .priv = SCALE_160x120}, |
412 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 425 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
413 | .bytesperline = 480, | 426 | .bytesperline = 320, |
414 | .sizeimage = 480 * 240 , | 427 | .sizeimage = 320 * 240 * 4 / 8 + 590, |
415 | .colorspace = V4L2_COLORSPACE_JPEG, | 428 | .colorspace = V4L2_COLORSPACE_JPEG, |
416 | .priv = 1 | MODE_JPEG}, | 429 | .priv = SCALE_320x240 | MODE_JPEG}, |
417 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 430 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
418 | .bytesperline = 320, | 431 | .bytesperline = 320, |
419 | .sizeimage = 320 * 240 , | 432 | .sizeimage = 320 * 240 , |
420 | .colorspace = V4L2_COLORSPACE_SRGB, | 433 | .colorspace = V4L2_COLORSPACE_SRGB, |
421 | .priv = 1 | MODE_RAW}, | 434 | .priv = SCALE_320x240 | MODE_RAW}, |
422 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 435 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
423 | .bytesperline = 480, | 436 | .bytesperline = 320, |
424 | .sizeimage = 480 * 240 , | 437 | .sizeimage = 480 * 240 , |
425 | .colorspace = V4L2_COLORSPACE_SRGB, | 438 | .colorspace = V4L2_COLORSPACE_SRGB, |
426 | .priv = 1}, | 439 | .priv = SCALE_320x240}, |
427 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 440 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
428 | .bytesperline = 960, | 441 | .bytesperline = 640, |
429 | .sizeimage = 960 * 480, | 442 | .sizeimage = 640 * 480 * 4 / 8 + 590, |
430 | .colorspace = V4L2_COLORSPACE_JPEG, | 443 | .colorspace = V4L2_COLORSPACE_JPEG, |
431 | .priv = 2 | MODE_JPEG}, | 444 | .priv = SCALE_640x480 | MODE_JPEG}, |
432 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 445 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
433 | .bytesperline = 640, | 446 | .bytesperline = 640, |
434 | .sizeimage = 640 * 480, | 447 | .sizeimage = 640 * 480, |
435 | .colorspace = V4L2_COLORSPACE_SRGB, | 448 | .colorspace = V4L2_COLORSPACE_SRGB, |
436 | .priv = 2 | MODE_RAW}, | 449 | .priv = SCALE_640x480 | MODE_RAW}, |
437 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 450 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
438 | .bytesperline = 960, | 451 | .bytesperline = 640, |
439 | .sizeimage = 960 * 480, | 452 | .sizeimage = 960 * 480, |
440 | .colorspace = V4L2_COLORSPACE_SRGB, | 453 | .colorspace = V4L2_COLORSPACE_SRGB, |
441 | .priv = 2}, | 454 | .priv = SCALE_640x480}, |
442 | {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 455 | {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
443 | .bytesperline = 1280, | 456 | .bytesperline = 1280, |
444 | .sizeimage = (1280 * 1024) + 64, | 457 | .sizeimage = 1280 * 1024, |
445 | .colorspace = V4L2_COLORSPACE_SRGB, | 458 | .colorspace = V4L2_COLORSPACE_SRGB, |
446 | .priv = 3 | MODE_RAW | MODE_SXGA}, | 459 | .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, |
460 | }; | ||
461 | |||
462 | static const struct v4l2_pix_format mono_mode[] = { | ||
463 | {160, 120, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, | ||
464 | .bytesperline = 160, | ||
465 | .sizeimage = 160 * 120, | ||
466 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
467 | .priv = SCALE_160x120 | MODE_RAW}, | ||
468 | {320, 240, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, | ||
469 | .bytesperline = 320, | ||
470 | .sizeimage = 320 * 240 , | ||
471 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
472 | .priv = SCALE_320x240 | MODE_RAW}, | ||
473 | {640, 480, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, | ||
474 | .bytesperline = 640, | ||
475 | .sizeimage = 640 * 480, | ||
476 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
477 | .priv = SCALE_640x480 | MODE_RAW}, | ||
478 | {1280, 1024, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, | ||
479 | .bytesperline = 1280, | ||
480 | .sizeimage = 1280 * 1024, | ||
481 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
482 | .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, | ||
447 | }; | 483 | }; |
448 | 484 | ||
449 | static const s16 hsv_red_x[] = { | 485 | static const s16 hsv_red_x[] = { |
@@ -855,6 +891,9 @@ static struct i2c_reg_u8 ov7660_init[] = { | |||
855 | {0x0e, 0x80}, {0x0d, 0x08}, {0x0f, 0xc3}, | 891 | {0x0e, 0x80}, {0x0d, 0x08}, {0x0f, 0xc3}, |
856 | {0x04, 0xc3}, {0x10, 0x40}, {0x11, 0x40}, | 892 | {0x04, 0xc3}, {0x10, 0x40}, {0x11, 0x40}, |
857 | {0x12, 0x05}, {0x13, 0xba}, {0x14, 0x2a}, | 893 | {0x12, 0x05}, {0x13, 0xba}, {0x14, 0x2a}, |
894 | /* HDG Set hstart and hstop, datasheet default 0x11, 0x61, using | ||
895 | 0x10, 0x61 and sd->hstart, vstart = 3, fixes ugly colored borders */ | ||
896 | {0x17, 0x10}, {0x18, 0x61}, | ||
858 | {0x37, 0x0f}, {0x38, 0x02}, {0x39, 0x43}, | 897 | {0x37, 0x0f}, {0x38, 0x02}, {0x39, 0x43}, |
859 | {0x3a, 0x00}, {0x69, 0x90}, {0x2d, 0xf6}, | 898 | {0x3a, 0x00}, {0x69, 0x90}, {0x2d, 0xf6}, |
860 | {0x2e, 0x0b}, {0x01, 0x78}, {0x02, 0x50}, | 899 | {0x2e, 0x0b}, {0x01, 0x78}, {0x02, 0x50}, |
@@ -1031,16 +1070,19 @@ static struct i2c_reg_u16 mt9v011_init[] = { | |||
1031 | }; | 1070 | }; |
1032 | 1071 | ||
1033 | static struct i2c_reg_u16 mt9m001_init[] = { | 1072 | static struct i2c_reg_u16 mt9m001_init[] = { |
1034 | {0x0d, 0x0001}, {0x0d, 0x0000}, {0x01, 0x000e}, | 1073 | {0x0d, 0x0001}, |
1035 | {0x02, 0x0014}, {0x03, 0x03c1}, {0x04, 0x0501}, | 1074 | {0x0d, 0x0000}, |
1036 | {0x05, 0x0083}, {0x06, 0x0006}, {0x0d, 0x0002}, | 1075 | {0x04, 0x0500}, /* hres = 1280 */ |
1037 | {0x0a, 0x0000}, {0x0c, 0x0000}, {0x11, 0x0000}, | 1076 | {0x03, 0x0400}, /* vres = 1024 */ |
1038 | {0x1e, 0x8000}, {0x5f, 0x8904}, {0x60, 0x0000}, | 1077 | {0x20, 0x1100}, |
1039 | {0x61, 0x0000}, {0x62, 0x0498}, {0x63, 0x0000}, | 1078 | {0x06, 0x0010}, |
1040 | {0x64, 0x0000}, {0x20, 0x111d}, {0x06, 0x00f2}, | 1079 | {0x2b, 0x0024}, |
1041 | {0x05, 0x0013}, {0x09, 0x10f2}, {0x07, 0x0003}, | 1080 | {0x2e, 0x0024}, |
1042 | {0x2b, 0x002a}, {0x2d, 0x002a}, {0x2c, 0x002a}, | 1081 | {0x35, 0x0024}, |
1043 | {0x2e, 0x0029}, {0x07, 0x0002}, | 1082 | {0x2d, 0x0020}, |
1083 | {0x2c, 0x0020}, | ||
1084 | {0x09, 0x0ad4}, | ||
1085 | {0x35, 0x0057}, | ||
1044 | }; | 1086 | }; |
1045 | 1087 | ||
1046 | static struct i2c_reg_u16 mt9m111_init[] = { | 1088 | static struct i2c_reg_u16 mt9m111_init[] = { |
@@ -1226,8 +1268,17 @@ static int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val) | |||
1226 | static int ov9650_init_sensor(struct gspca_dev *gspca_dev) | 1268 | static int ov9650_init_sensor(struct gspca_dev *gspca_dev) |
1227 | { | 1269 | { |
1228 | int i; | 1270 | int i; |
1271 | u16 id; | ||
1229 | struct sd *sd = (struct sd *) gspca_dev; | 1272 | struct sd *sd = (struct sd *) gspca_dev; |
1230 | 1273 | ||
1274 | if (i2c_r2(gspca_dev, 0x1c, &id) < 0) | ||
1275 | return -EINVAL; | ||
1276 | |||
1277 | if (id != 0x7fa2) { | ||
1278 | err("sensor id for ov9650 doesn't match (0x%04x)", id); | ||
1279 | return -ENODEV; | ||
1280 | } | ||
1281 | |||
1231 | for (i = 0; i < ARRAY_SIZE(ov9650_init); i++) { | 1282 | for (i = 0; i < ARRAY_SIZE(ov9650_init); i++) { |
1232 | if (i2c_w1(gspca_dev, ov9650_init[i].reg, | 1283 | if (i2c_w1(gspca_dev, ov9650_init[i].reg, |
1233 | ov9650_init[i].val) < 0) { | 1284 | ov9650_init[i].val) < 0) { |
@@ -1272,7 +1323,8 @@ static int soi968_init_sensor(struct gspca_dev *gspca_dev) | |||
1272 | } | 1323 | } |
1273 | } | 1324 | } |
1274 | /* disable hflip and vflip */ | 1325 | /* disable hflip and vflip */ |
1275 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << EXPOSURE_IDX); | 1326 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) |
1327 | | (1 << EXPOSURE_IDX); | ||
1276 | sd->hstart = 60; | 1328 | sd->hstart = 60; |
1277 | sd->vstart = 11; | 1329 | sd->vstart = 11; |
1278 | return 0; | 1330 | return 0; |
@@ -1290,10 +1342,8 @@ static int ov7660_init_sensor(struct gspca_dev *gspca_dev) | |||
1290 | return -ENODEV; | 1342 | return -ENODEV; |
1291 | } | 1343 | } |
1292 | } | 1344 | } |
1293 | /* disable hflip and vflip */ | 1345 | sd->hstart = 3; |
1294 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX); | 1346 | sd->vstart = 3; |
1295 | sd->hstart = 1; | ||
1296 | sd->vstart = 1; | ||
1297 | return 0; | 1347 | return 0; |
1298 | } | 1348 | } |
1299 | 1349 | ||
@@ -1351,7 +1401,9 @@ static int mt9v_init_sensor(struct gspca_dev *gspca_dev) | |||
1351 | return -ENODEV; | 1401 | return -ENODEV; |
1352 | } | 1402 | } |
1353 | } | 1403 | } |
1354 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); | 1404 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) |
1405 | | (1 << AUTOGAIN_IDX) | ||
1406 | | (1 << GAIN_IDX); | ||
1355 | sd->hstart = 2; | 1407 | sd->hstart = 2; |
1356 | sd->vstart = 2; | 1408 | sd->vstart = 2; |
1357 | sd->sensor = SENSOR_MT9V111; | 1409 | sd->sensor = SENSOR_MT9V111; |
@@ -1395,7 +1447,8 @@ static int mt9m112_init_sensor(struct gspca_dev *gspca_dev) | |||
1395 | return -ENODEV; | 1447 | return -ENODEV; |
1396 | } | 1448 | } |
1397 | } | 1449 | } |
1398 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); | 1450 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) |
1451 | | (1 << GAIN_IDX); | ||
1399 | sd->hstart = 0; | 1452 | sd->hstart = 0; |
1400 | sd->vstart = 2; | 1453 | sd->vstart = 2; |
1401 | return 0; | 1454 | return 0; |
@@ -1412,7 +1465,8 @@ static int mt9m111_init_sensor(struct gspca_dev *gspca_dev) | |||
1412 | return -ENODEV; | 1465 | return -ENODEV; |
1413 | } | 1466 | } |
1414 | } | 1467 | } |
1415 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX); | 1468 | gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) |
1469 | | (1 << GAIN_IDX); | ||
1416 | sd->hstart = 0; | 1470 | sd->hstart = 0; |
1417 | sd->vstart = 2; | 1471 | sd->vstart = 2; |
1418 | return 0; | 1472 | return 0; |
@@ -1422,6 +1476,25 @@ static int mt9m001_init_sensor(struct gspca_dev *gspca_dev) | |||
1422 | { | 1476 | { |
1423 | struct sd *sd = (struct sd *) gspca_dev; | 1477 | struct sd *sd = (struct sd *) gspca_dev; |
1424 | int i; | 1478 | int i; |
1479 | u16 id; | ||
1480 | |||
1481 | if (i2c_r2(gspca_dev, 0x00, &id) < 0) | ||
1482 | return -EINVAL; | ||
1483 | |||
1484 | /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */ | ||
1485 | switch (id) { | ||
1486 | case 0x8411: | ||
1487 | case 0x8421: | ||
1488 | info("MT9M001 color sensor detected"); | ||
1489 | break; | ||
1490 | case 0x8431: | ||
1491 | info("MT9M001 mono sensor detected"); | ||
1492 | break; | ||
1493 | default: | ||
1494 | err("No MT9M001 chip detected, ID = %x\n", id); | ||
1495 | return -ENODEV; | ||
1496 | } | ||
1497 | |||
1425 | for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) { | 1498 | for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) { |
1426 | if (i2c_w2(gspca_dev, mt9m001_init[i].reg, | 1499 | if (i2c_w2(gspca_dev, mt9m001_init[i].reg, |
1427 | mt9m001_init[i].val) < 0) { | 1500 | mt9m001_init[i].val) < 0) { |
@@ -1431,8 +1504,8 @@ static int mt9m001_init_sensor(struct gspca_dev *gspca_dev) | |||
1431 | } | 1504 | } |
1432 | /* disable hflip and vflip */ | 1505 | /* disable hflip and vflip */ |
1433 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX); | 1506 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX); |
1434 | sd->hstart = 2; | 1507 | sd->hstart = 1; |
1435 | sd->vstart = 2; | 1508 | sd->vstart = 1; |
1436 | return 0; | 1509 | return 0; |
1437 | } | 1510 | } |
1438 | 1511 | ||
@@ -1543,6 +1616,18 @@ static int set_hvflip(struct gspca_dev *gspca_dev) | |||
1543 | } | 1616 | } |
1544 | 1617 | ||
1545 | switch (sd->sensor) { | 1618 | switch (sd->sensor) { |
1619 | case SENSOR_OV7660: | ||
1620 | value = 0x01; | ||
1621 | if (hflip) | ||
1622 | value |= 0x20; | ||
1623 | if (vflip) { | ||
1624 | value |= 0x10; | ||
1625 | sd->vstart = 2; | ||
1626 | } else | ||
1627 | sd->vstart = 3; | ||
1628 | reg_w1(gspca_dev, 0x1182, sd->vstart); | ||
1629 | i2c_w1(gspca_dev, 0x1e, value); | ||
1630 | break; | ||
1546 | case SENSOR_OV9650: | 1631 | case SENSOR_OV9650: |
1547 | i2c_r1(gspca_dev, 0x1e, &value); | 1632 | i2c_r1(gspca_dev, 0x1e, &value); |
1548 | value &= ~0x30; | 1633 | value &= ~0x30; |
@@ -1974,6 +2059,10 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1974 | cam->cam_mode = sxga_mode; | 2059 | cam->cam_mode = sxga_mode; |
1975 | cam->nmodes = ARRAY_SIZE(sxga_mode); | 2060 | cam->nmodes = ARRAY_SIZE(sxga_mode); |
1976 | break; | 2061 | break; |
2062 | case SENSOR_MT9M001: | ||
2063 | cam->cam_mode = mono_mode; | ||
2064 | cam->nmodes = ARRAY_SIZE(mono_mode); | ||
2065 | break; | ||
1977 | default: | 2066 | default: |
1978 | cam->cam_mode = vga_mode; | 2067 | cam->cam_mode = vga_mode; |
1979 | cam->nmodes = ARRAY_SIZE(vga_mode); | 2068 | cam->nmodes = ARRAY_SIZE(vga_mode); |
@@ -2072,7 +2161,6 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
2072 | case SENSOR_MT9M001: | 2161 | case SENSOR_MT9M001: |
2073 | if (mt9m001_init_sensor(gspca_dev) < 0) | 2162 | if (mt9m001_init_sensor(gspca_dev) < 0) |
2074 | return -ENODEV; | 2163 | return -ENODEV; |
2075 | info("MT9M001 sensor detected"); | ||
2076 | break; | 2164 | break; |
2077 | case SENSOR_HV7131R: | 2165 | case SENSOR_HV7131R: |
2078 | if (hv7131r_init_sensor(gspca_dev) < 0) | 2166 | if (hv7131r_init_sensor(gspca_dev) < 0) |
@@ -2170,22 +2258,22 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2170 | else if (mode & MODE_JPEG) | 2258 | else if (mode & MODE_JPEG) |
2171 | fmt = 0x2c; | 2259 | fmt = 0x2c; |
2172 | else | 2260 | else |
2173 | fmt = 0x2f; | 2261 | fmt = 0x2f; /* YUV 420 */ |
2174 | 2262 | ||
2175 | switch (mode & 0x0f) { | 2263 | switch (mode & SCALE_MASK) { |
2176 | case 3: | 2264 | case SCALE_1280x1024: |
2177 | scale = 0xc0; | 2265 | scale = 0xc0; |
2178 | info("Set 1280x1024"); | 2266 | info("Set 1280x1024"); |
2179 | break; | 2267 | break; |
2180 | case 2: | 2268 | case SCALE_640x480: |
2181 | scale = 0x80; | 2269 | scale = 0x80; |
2182 | info("Set 640x480"); | 2270 | info("Set 640x480"); |
2183 | break; | 2271 | break; |
2184 | case 1: | 2272 | case SCALE_320x240: |
2185 | scale = 0x90; | 2273 | scale = 0x90; |
2186 | info("Set 320x240"); | 2274 | info("Set 320x240"); |
2187 | break; | 2275 | break; |
2188 | case 0: | 2276 | case SCALE_160x120: |
2189 | scale = 0xa0; | 2277 | scale = 0xa0; |
2190 | info("Set 160x120"); | 2278 | info("Set 160x120"); |
2191 | break; | 2279 | break; |
@@ -2304,7 +2392,7 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev) | |||
2304 | do_autoexposure(gspca_dev, avg_lum); | 2392 | do_autoexposure(gspca_dev, avg_lum); |
2305 | } | 2393 | } |
2306 | 2394 | ||
2307 | #ifdef CONFIG_INPUT | 2395 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
2308 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 2396 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
2309 | u8 *data, /* interrupt packet */ | 2397 | u8 *data, /* interrupt packet */ |
2310 | int len) /* interrupt packet length */ | 2398 | int len) /* interrupt packet length */ |
@@ -2386,7 +2474,7 @@ static const struct sd_desc sd_desc = { | |||
2386 | .start = sd_start, | 2474 | .start = sd_start, |
2387 | .stopN = sd_stopN, | 2475 | .stopN = sd_stopN, |
2388 | .pkt_scan = sd_pkt_scan, | 2476 | .pkt_scan = sd_pkt_scan, |
2389 | #ifdef CONFIG_INPUT | 2477 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
2390 | .int_pkt_scan = sd_int_pkt_scan, | 2478 | .int_pkt_scan = sd_int_pkt_scan, |
2391 | #endif | 2479 | #endif |
2392 | .dq_callback = sd_dqcallback, | 2480 | .dq_callback = sd_dqcallback, |
@@ -2402,7 +2490,7 @@ static const struct sd_desc sd_desc = { | |||
2402 | | (SENSOR_ ## sensor << 8) \ | 2490 | | (SENSOR_ ## sensor << 8) \ |
2403 | | (i2c_addr) | 2491 | | (i2c_addr) |
2404 | 2492 | ||
2405 | static const __devinitdata struct usb_device_id device_table[] = { | 2493 | static const struct usb_device_id device_table[] = { |
2406 | {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)}, | 2494 | {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)}, |
2407 | {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)}, | 2495 | {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)}, |
2408 | {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)}, | 2496 | {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)}, |
@@ -2414,7 +2502,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
2414 | {USB_DEVICE(0x0c45, 0x6253), SN9C20X(OV9650, 0x30, 0)}, | 2502 | {USB_DEVICE(0x0c45, 0x6253), SN9C20X(OV9650, 0x30, 0)}, |
2415 | {USB_DEVICE(0x0c45, 0x6260), SN9C20X(OV7670, 0x21, 0)}, | 2503 | {USB_DEVICE(0x0c45, 0x6260), SN9C20X(OV7670, 0x21, 0)}, |
2416 | {USB_DEVICE(0x0c45, 0x6270), SN9C20X(MT9VPRB, 0x00, 0)}, | 2504 | {USB_DEVICE(0x0c45, 0x6270), SN9C20X(MT9VPRB, 0x00, 0)}, |
2417 | {USB_DEVICE(0x0c45, 0x627b), SN9C20X(OV7660, 0x21, 0)}, | 2505 | {USB_DEVICE(0x0c45, 0x627b), SN9C20X(OV7660, 0x21, FLIP_DETECT)}, |
2418 | {USB_DEVICE(0x0c45, 0x627c), SN9C20X(HV7131R, 0x11, 0)}, | 2506 | {USB_DEVICE(0x0c45, 0x627c), SN9C20X(HV7131R, 0x11, 0)}, |
2419 | {USB_DEVICE(0x0c45, 0x627f), SN9C20X(OV9650, 0x30, 0)}, | 2507 | {USB_DEVICE(0x0c45, 0x627f), SN9C20X(OV9650, 0x30, 0)}, |
2420 | {USB_DEVICE(0x0c45, 0x6280), SN9C20X(MT9M001, 0x5d, 0)}, | 2508 | {USB_DEVICE(0x0c45, 0x6280), SN9C20X(MT9M001, 0x5d, 0)}, |
@@ -2426,7 +2514,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
2426 | {USB_DEVICE(0x0c45, 0x62a0), SN9C20X(OV7670, 0x21, 0)}, | 2514 | {USB_DEVICE(0x0c45, 0x62a0), SN9C20X(OV7670, 0x21, 0)}, |
2427 | {USB_DEVICE(0x0c45, 0x62b0), SN9C20X(MT9VPRB, 0x00, 0)}, | 2515 | {USB_DEVICE(0x0c45, 0x62b0), SN9C20X(MT9VPRB, 0x00, 0)}, |
2428 | {USB_DEVICE(0x0c45, 0x62b3), SN9C20X(OV9655, 0x30, 0)}, | 2516 | {USB_DEVICE(0x0c45, 0x62b3), SN9C20X(OV9655, 0x30, 0)}, |
2429 | {USB_DEVICE(0x0c45, 0x62bb), SN9C20X(OV7660, 0x21, 0)}, | 2517 | {USB_DEVICE(0x0c45, 0x62bb), SN9C20X(OV7660, 0x21, LED_REVERSE)}, |
2430 | {USB_DEVICE(0x0c45, 0x62bc), SN9C20X(HV7131R, 0x11, 0)}, | 2518 | {USB_DEVICE(0x0c45, 0x62bc), SN9C20X(HV7131R, 0x11, 0)}, |
2431 | {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)}, | 2519 | {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)}, |
2432 | {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)}, | 2520 | {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)}, |
@@ -2467,17 +2555,11 @@ static struct usb_driver sd_driver = { | |||
2467 | /* -- module insert / remove -- */ | 2555 | /* -- module insert / remove -- */ |
2468 | static int __init sd_mod_init(void) | 2556 | static int __init sd_mod_init(void) |
2469 | { | 2557 | { |
2470 | int ret; | 2558 | 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 | } | 2559 | } |
2477 | static void __exit sd_mod_exit(void) | 2560 | static void __exit sd_mod_exit(void) |
2478 | { | 2561 | { |
2479 | usb_deregister(&sd_driver); | 2562 | usb_deregister(&sd_driver); |
2480 | info("deregistered"); | ||
2481 | } | 2563 | } |
2482 | 2564 | ||
2483 | module_init(sd_mod_init); | 2565 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c index 204bb3af4559..146b459b08d5 100644 --- a/drivers/media/video/gspca/sonixb.c +++ b/drivers/media/video/gspca/sonixb.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * sonix sn9c102 (bayer) library | 2 | * sonix sn9c102 (bayer) library |
3 | * Copyright (C) 2003 2004 Michel Xhaard mxhaard@magic.fr | ||
4 | * Add Pas106 Stefano Mozzi (C) 2004 | ||
5 | * | 3 | * |
6 | * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> | 4 | * Copyright (C) 2009-2011 Jean-François Moine <http://moinejf.free.fr> |
5 | * Copyright (C) 2003 2004 Michel Xhaard mxhaard@magic.fr | ||
6 | * Add Pas106 Stefano Mozzi (C) 2004 | ||
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -23,8 +23,15 @@ | |||
23 | /* Some documentation on known sonixb registers: | 23 | /* Some documentation on known sonixb registers: |
24 | 24 | ||
25 | Reg Use | 25 | Reg Use |
26 | sn9c101 / sn9c102: | ||
26 | 0x10 high nibble red gain low nibble blue gain | 27 | 0x10 high nibble red gain low nibble blue gain |
27 | 0x11 low nibble green gain | 28 | 0x11 low nibble green gain |
29 | sn9c103: | ||
30 | 0x05 red gain 0-127 | ||
31 | 0x06 blue gain 0-127 | ||
32 | 0x07 green gain 0-127 | ||
33 | all: | ||
34 | 0x08-0x0f i2c / 3wire registers | ||
28 | 0x12 hstart | 35 | 0x12 hstart |
29 | 0x13 vstart | 36 | 0x13 vstart |
30 | 0x15 hsize (hsize = register-value * 16) | 37 | 0x15 hsize (hsize = register-value * 16) |
@@ -45,25 +52,35 @@ Reg Use | |||
45 | #include <linux/input.h> | 52 | #include <linux/input.h> |
46 | #include "gspca.h" | 53 | #include "gspca.h" |
47 | 54 | ||
48 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 55 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); |
49 | MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver"); | 56 | MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver"); |
50 | MODULE_LICENSE("GPL"); | 57 | MODULE_LICENSE("GPL"); |
51 | 58 | ||
59 | /* controls */ | ||
60 | enum e_ctrl { | ||
61 | BRIGHTNESS, | ||
62 | GAIN, | ||
63 | EXPOSURE, | ||
64 | AUTOGAIN, | ||
65 | FREQ, | ||
66 | NCTRLS /* number of controls */ | ||
67 | }; | ||
68 | |||
52 | /* specific webcam descriptor */ | 69 | /* specific webcam descriptor */ |
53 | struct sd { | 70 | struct sd { |
54 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 71 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
72 | |||
73 | struct gspca_ctrl ctrls[NCTRLS]; | ||
74 | |||
55 | atomic_t avg_lum; | 75 | atomic_t avg_lum; |
56 | int prev_avg_lum; | 76 | int prev_avg_lum; |
57 | int exp_too_low_cnt; | 77 | int exp_too_low_cnt; |
58 | int exp_too_high_cnt; | 78 | int exp_too_high_cnt; |
79 | int header_read; | ||
80 | u8 header[12]; /* Header without sof marker */ | ||
59 | 81 | ||
60 | unsigned short exposure; | ||
61 | unsigned char gain; | ||
62 | unsigned char brightness; | ||
63 | unsigned char autogain; | ||
64 | unsigned char autogain_ignore_frames; | 82 | unsigned char autogain_ignore_frames; |
65 | unsigned char frames_to_drop; | 83 | unsigned char frames_to_drop; |
66 | unsigned char freq; /* light freq filter setting */ | ||
67 | 84 | ||
68 | __u8 bridge; /* Type of bridge */ | 85 | __u8 bridge; /* Type of bridge */ |
69 | #define BRIDGE_101 0 | 86 | #define BRIDGE_101 0 |
@@ -71,26 +88,24 @@ struct sd { | |||
71 | #define BRIDGE_103 1 | 88 | #define BRIDGE_103 1 |
72 | 89 | ||
73 | __u8 sensor; /* Type of image sensor chip */ | 90 | __u8 sensor; /* Type of image sensor chip */ |
74 | #define SENSOR_HV7131R 0 | 91 | #define SENSOR_HV7131D 0 |
75 | #define SENSOR_OV6650 1 | 92 | #define SENSOR_HV7131R 1 |
76 | #define SENSOR_OV7630 2 | 93 | #define SENSOR_OV6650 2 |
77 | #define SENSOR_PAS106 3 | 94 | #define SENSOR_OV7630 3 |
78 | #define SENSOR_PAS202 4 | 95 | #define SENSOR_PAS106 4 |
79 | #define SENSOR_TAS5110C 5 | 96 | #define SENSOR_PAS202 5 |
80 | #define SENSOR_TAS5110D 6 | 97 | #define SENSOR_TAS5110C 6 |
81 | #define SENSOR_TAS5130CXX 7 | 98 | #define SENSOR_TAS5110D 7 |
99 | #define SENSOR_TAS5130CXX 8 | ||
82 | __u8 reg11; | 100 | __u8 reg11; |
83 | }; | 101 | }; |
84 | 102 | ||
85 | typedef const __u8 sensor_init_t[8]; | 103 | typedef const __u8 sensor_init_t[8]; |
86 | 104 | ||
87 | struct sensor_data { | 105 | struct sensor_data { |
88 | const __u8 *bridge_init[2]; | 106 | const __u8 *bridge_init; |
89 | int bridge_init_size[2]; | ||
90 | sensor_init_t *sensor_init; | 107 | sensor_init_t *sensor_init; |
91 | int sensor_init_size; | 108 | int sensor_init_size; |
92 | sensor_init_t *sensor_bridge_init[2]; | ||
93 | int sensor_bridge_init_size[2]; | ||
94 | int flags; | 109 | int flags; |
95 | unsigned ctrl_dis; | 110 | unsigned ctrl_dis; |
96 | __u8 sensor_addr; | 111 | __u8 sensor_addr; |
@@ -106,12 +121,10 @@ struct sensor_data { | |||
106 | #define MODE_REDUCED_SIF 0x20 /* vga mode (320x240 / 160x120) on sif cam */ | 121 | #define MODE_REDUCED_SIF 0x20 /* vga mode (320x240 / 160x120) on sif cam */ |
107 | 122 | ||
108 | /* ctrl_dis helper macros */ | 123 | /* ctrl_dis helper macros */ |
109 | #define NO_EXPO ((1 << EXPOSURE_IDX) | (1 << COARSE_EXPOSURE_IDX) | \ | 124 | #define NO_EXPO ((1 << EXPOSURE) | (1 << AUTOGAIN)) |
110 | (1 << AUTOGAIN_IDX)) | 125 | #define NO_FREQ (1 << FREQ) |
111 | #define NO_FREQ (1 << FREQ_IDX) | 126 | #define NO_BRIGHTNESS (1 << BRIGHTNESS) |
112 | #define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX) | ||
113 | 127 | ||
114 | #define COMP2 0x8f | ||
115 | #define COMP 0xc7 /* 0x87 //0x07 */ | 128 | #define COMP 0xc7 /* 0x87 //0x07 */ |
116 | #define COMP1 0xc9 /* 0x89 //0x09 */ | 129 | #define COMP1 0xc9 /* 0x89 //0x09 */ |
117 | 130 | ||
@@ -120,15 +133,11 @@ struct sensor_data { | |||
120 | 133 | ||
121 | #define SYS_CLK 0x04 | 134 | #define SYS_CLK 0x04 |
122 | 135 | ||
123 | #define SENS(bridge_1, bridge_3, sensor, sensor_1, \ | 136 | #define SENS(bridge, sensor, _flags, _ctrl_dis, _sensor_addr) \ |
124 | sensor_3, _flags, _ctrl_dis, _sensor_addr) \ | ||
125 | { \ | 137 | { \ |
126 | .bridge_init = { bridge_1, bridge_3 }, \ | 138 | .bridge_init = bridge, \ |
127 | .bridge_init_size = { sizeof(bridge_1), sizeof(bridge_3) }, \ | ||
128 | .sensor_init = sensor, \ | 139 | .sensor_init = sensor, \ |
129 | .sensor_init_size = sizeof(sensor), \ | 140 | .sensor_init_size = sizeof(sensor), \ |
130 | .sensor_bridge_init = { sensor_1, sensor_3,}, \ | ||
131 | .sensor_bridge_init_size = { sizeof(sensor_1), sizeof(sensor_3)}, \ | ||
132 | .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \ | 141 | .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \ |
133 | } | 142 | } |
134 | 143 | ||
@@ -139,20 +148,14 @@ struct sensor_data { | |||
139 | #define AUTOGAIN_IGNORE_FRAMES 1 | 148 | #define AUTOGAIN_IGNORE_FRAMES 1 |
140 | 149 | ||
141 | /* V4L2 controls supported by the driver */ | 150 | /* V4L2 controls supported by the driver */ |
142 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 151 | static void setbrightness(struct gspca_dev *gspca_dev); |
143 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 152 | static void setgain(struct gspca_dev *gspca_dev); |
144 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val); | 153 | static void setexposure(struct gspca_dev *gspca_dev); |
145 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); | ||
146 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); | ||
147 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); | ||
148 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 154 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
149 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 155 | static void setfreq(struct gspca_dev *gspca_dev); |
150 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
151 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
152 | 156 | ||
153 | static const struct ctrl sd_ctrls[] = { | 157 | static const struct ctrl sd_ctrls[NCTRLS] = { |
154 | #define BRIGHTNESS_IDX 0 | 158 | [BRIGHTNESS] = { |
155 | { | ||
156 | { | 159 | { |
157 | .id = V4L2_CID_BRIGHTNESS, | 160 | .id = V4L2_CID_BRIGHTNESS, |
158 | .type = V4L2_CTRL_TYPE_INTEGER, | 161 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -160,14 +163,11 @@ static const struct ctrl sd_ctrls[] = { | |||
160 | .minimum = 0, | 163 | .minimum = 0, |
161 | .maximum = 255, | 164 | .maximum = 255, |
162 | .step = 1, | 165 | .step = 1, |
163 | #define BRIGHTNESS_DEF 127 | 166 | .default_value = 127, |
164 | .default_value = BRIGHTNESS_DEF, | ||
165 | }, | 167 | }, |
166 | .set = sd_setbrightness, | 168 | .set_control = setbrightness |
167 | .get = sd_getbrightness, | ||
168 | }, | 169 | }, |
169 | #define GAIN_IDX 1 | 170 | [GAIN] = { |
170 | { | ||
171 | { | 171 | { |
172 | .id = V4L2_CID_GAIN, | 172 | .id = V4L2_CID_GAIN, |
173 | .type = V4L2_CTRL_TYPE_INTEGER, | 173 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -175,48 +175,31 @@ static const struct ctrl sd_ctrls[] = { | |||
175 | .minimum = 0, | 175 | .minimum = 0, |
176 | .maximum = 255, | 176 | .maximum = 255, |
177 | .step = 1, | 177 | .step = 1, |
178 | #define GAIN_DEF 127 | ||
179 | #define GAIN_KNEE 230 | 178 | #define GAIN_KNEE 230 |
180 | .default_value = GAIN_DEF, | 179 | .default_value = 127, |
181 | }, | 180 | }, |
182 | .set = sd_setgain, | 181 | .set_control = setgain |
183 | .get = sd_getgain, | ||
184 | }, | 182 | }, |
185 | #define EXPOSURE_IDX 2 | 183 | [EXPOSURE] = { |
186 | { | ||
187 | { | 184 | { |
188 | .id = V4L2_CID_EXPOSURE, | 185 | .id = V4L2_CID_EXPOSURE, |
189 | .type = V4L2_CTRL_TYPE_INTEGER, | 186 | .type = V4L2_CTRL_TYPE_INTEGER, |
190 | .name = "Exposure", | 187 | .name = "Exposure", |
191 | #define EXPOSURE_DEF 66 /* 33 ms / 30 fps (except on PASXXX) */ | ||
192 | #define EXPOSURE_KNEE 200 /* 100 ms / 10 fps (except on PASXXX) */ | ||
193 | .minimum = 0, | 188 | .minimum = 0, |
194 | .maximum = 1023, | 189 | .maximum = 1023, |
195 | .step = 1, | 190 | .step = 1, |
196 | .default_value = EXPOSURE_DEF, | 191 | .default_value = 66, |
192 | /* 33 ms / 30 fps (except on PASXXX) */ | ||
193 | #define EXPOSURE_KNEE 200 /* 100 ms / 10 fps (except on PASXXX) */ | ||
197 | .flags = 0, | 194 | .flags = 0, |
198 | }, | 195 | }, |
199 | .set = sd_setexposure, | 196 | .set_control = setexposure |
200 | .get = sd_getexposure, | ||
201 | }, | 197 | }, |
202 | #define COARSE_EXPOSURE_IDX 3 | 198 | /* for coarse exposure */ |
203 | { | 199 | #define COARSE_EXPOSURE_MIN 2 |
204 | { | 200 | #define COARSE_EXPOSURE_MAX 15 |
205 | .id = V4L2_CID_EXPOSURE, | ||
206 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
207 | .name = "Exposure", | ||
208 | #define COARSE_EXPOSURE_DEF 2 /* 30 fps */ | 201 | #define COARSE_EXPOSURE_DEF 2 /* 30 fps */ |
209 | .minimum = 2, | 202 | [AUTOGAIN] = { |
210 | .maximum = 15, | ||
211 | .step = 1, | ||
212 | .default_value = COARSE_EXPOSURE_DEF, | ||
213 | .flags = 0, | ||
214 | }, | ||
215 | .set = sd_setexposure, | ||
216 | .get = sd_getexposure, | ||
217 | }, | ||
218 | #define AUTOGAIN_IDX 4 | ||
219 | { | ||
220 | { | 203 | { |
221 | .id = V4L2_CID_AUTOGAIN, | 204 | .id = V4L2_CID_AUTOGAIN, |
222 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 205 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -226,13 +209,11 @@ static const struct ctrl sd_ctrls[] = { | |||
226 | .step = 1, | 209 | .step = 1, |
227 | #define AUTOGAIN_DEF 1 | 210 | #define AUTOGAIN_DEF 1 |
228 | .default_value = AUTOGAIN_DEF, | 211 | .default_value = AUTOGAIN_DEF, |
229 | .flags = 0, | 212 | .flags = V4L2_CTRL_FLAG_UPDATE |
230 | }, | 213 | }, |
231 | .set = sd_setautogain, | 214 | .set = sd_setautogain, |
232 | .get = sd_getautogain, | ||
233 | }, | 215 | }, |
234 | #define FREQ_IDX 5 | 216 | [FREQ] = { |
235 | { | ||
236 | { | 217 | { |
237 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 218 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
238 | .type = V4L2_CTRL_TYPE_MENU, | 219 | .type = V4L2_CTRL_TYPE_MENU, |
@@ -243,8 +224,7 @@ static const struct ctrl sd_ctrls[] = { | |||
243 | #define FREQ_DEF 0 | 224 | #define FREQ_DEF 0 |
244 | .default_value = FREQ_DEF, | 225 | .default_value = FREQ_DEF, |
245 | }, | 226 | }, |
246 | .set = sd_setfreq, | 227 | .set_control = setfreq |
247 | .get = sd_getfreq, | ||
248 | }, | 228 | }, |
249 | }; | 229 | }; |
250 | 230 | ||
@@ -303,14 +283,27 @@ static const struct v4l2_pix_format sif_mode[] = { | |||
303 | .priv = 0}, | 283 | .priv = 0}, |
304 | }; | 284 | }; |
305 | 285 | ||
306 | static const __u8 initHv7131[] = { | 286 | static const __u8 initHv7131d[] = { |
287 | 0x04, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, | ||
288 | 0x00, 0x00, | ||
289 | 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, | ||
290 | 0x28, 0x1e, 0x60, 0x8e, 0x42, | ||
291 | }; | ||
292 | static const __u8 hv7131d_sensor_init[][8] = { | ||
293 | {0xa0, 0x11, 0x01, 0x04, 0x00, 0x00, 0x00, 0x17}, | ||
294 | {0xa0, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x17}, | ||
295 | {0xa0, 0x11, 0x28, 0x00, 0x00, 0x00, 0x00, 0x17}, | ||
296 | {0xa0, 0x11, 0x30, 0x30, 0x00, 0x00, 0x00, 0x17}, /* reset level */ | ||
297 | {0xa0, 0x11, 0x34, 0x02, 0x00, 0x00, 0x00, 0x17}, /* pixel bias volt */ | ||
298 | }; | ||
299 | |||
300 | static const __u8 initHv7131r[] = { | ||
307 | 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, | 301 | 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, |
308 | 0x00, 0x00, | 302 | 0x00, 0x00, |
309 | 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, | 303 | 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, |
310 | 0x28, 0x1e, 0x60, 0x8a, 0x20, | 304 | 0x28, 0x1e, 0x60, 0x8a, 0x20, |
311 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c | ||
312 | }; | 305 | }; |
313 | static const __u8 hv7131_sensor_init[][8] = { | 306 | static const __u8 hv7131r_sensor_init[][8] = { |
314 | {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10}, | 307 | {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10}, |
315 | {0xa0, 0x11, 0x01, 0x08, 0x2a, 0x2e, 0x00, 0x10}, | 308 | {0xa0, 0x11, 0x01, 0x08, 0x2a, 0x2e, 0x00, 0x10}, |
316 | {0xb0, 0x11, 0x20, 0x00, 0xd0, 0x2e, 0x00, 0x10}, | 309 | {0xb0, 0x11, 0x20, 0x00, 0xd0, 0x2e, 0x00, 0x10}, |
@@ -321,12 +314,11 @@ static const __u8 initOv6650[] = { | |||
321 | 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 314 | 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
322 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 315 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
323 | 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, | 316 | 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, |
324 | 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07 | 317 | 0x10, |
325 | }; | 318 | }; |
326 | static const __u8 ov6650_sensor_init[][8] = | 319 | static const __u8 ov6650_sensor_init[][8] = { |
327 | { | ||
328 | /* Bright, contrast, etc are set through SCBB interface. | 320 | /* Bright, contrast, etc are set through SCBB interface. |
329 | * AVCAP on win2 do not send any data on this controls. */ | 321 | * AVCAP on win2 do not send any data on this controls. */ |
330 | /* Anyway, some registers appears to alter bright and constrat */ | 322 | /* Anyway, some registers appears to alter bright and constrat */ |
331 | 323 | ||
332 | /* Reset sensor */ | 324 | /* Reset sensor */ |
@@ -341,7 +333,7 @@ static const __u8 ov6650_sensor_init[][8] = | |||
341 | * but blue wont be there. Avoid this data ... */ | 333 | * but blue wont be there. Avoid this data ... */ |
342 | {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10}, /* format out? */ | 334 | {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10}, /* format out? */ |
343 | {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10}, | 335 | {0xd0, 0x60, 0x26, 0x01, 0x14, 0xd8, 0xa4, 0x10}, |
344 | {0xa0, 0x60, 0x30, 0x3d, 0x0A, 0xd8, 0xa4, 0x10}, | 336 | {0xa0, 0x60, 0x30, 0x3d, 0x0a, 0xd8, 0xa4, 0x10}, |
345 | /* Enable rgb brightness control */ | 337 | /* Enable rgb brightness control */ |
346 | {0xa0, 0x60, 0x61, 0x08, 0x00, 0x00, 0x00, 0x10}, | 338 | {0xa0, 0x60, 0x61, 0x08, 0x00, 0x00, 0x00, 0x10}, |
347 | /* HDG: Note windows uses the line below, which sets both register 0x60 | 339 | /* HDG: Note windows uses the line below, which sets both register 0x60 |
@@ -361,24 +353,13 @@ static const __u8 initOv7630[] = { | |||
361 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ | 353 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ |
362 | 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ | 354 | 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ |
363 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ | 355 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ |
364 | 0x68, COMP2, MCK_INIT1, /* r17 .. r19 */ | ||
365 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */ | ||
366 | }; | ||
367 | static const __u8 initOv7630_3[] = { | ||
368 | 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */ | ||
369 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ | ||
370 | 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */ | ||
371 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ | ||
372 | 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ | 356 | 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ |
373 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */ | ||
374 | 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */ | ||
375 | 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */ | ||
376 | }; | 357 | }; |
377 | static const __u8 ov7630_sensor_init[][8] = { | 358 | static const __u8 ov7630_sensor_init[][8] = { |
378 | {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, | 359 | {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, |
379 | {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10}, | 360 | {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10}, |
380 | /* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */ | 361 | /* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */ |
381 | {0xd0, 0x21, 0x12, 0x1c, 0x00, 0x80, 0x34, 0x10}, /* jfm */ | 362 | {0xd0, 0x21, 0x12, 0x5c, 0x00, 0x80, 0x34, 0x10}, /* jfm */ |
382 | {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10}, | 363 | {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10}, |
383 | {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10}, | 364 | {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10}, |
384 | {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10}, | 365 | {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10}, |
@@ -396,16 +377,11 @@ static const __u8 ov7630_sensor_init[][8] = { | |||
396 | {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, | 377 | {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, |
397 | }; | 378 | }; |
398 | 379 | ||
399 | static const __u8 ov7630_sensor_init_3[][8] = { | ||
400 | {0xa0, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
401 | }; | ||
402 | |||
403 | static const __u8 initPas106[] = { | 380 | static const __u8 initPas106[] = { |
404 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, | 381 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, |
405 | 0x00, 0x00, | 382 | 0x00, 0x00, |
406 | 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, | 383 | 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, |
407 | 0x16, 0x12, 0x24, COMP1, MCK_INIT1, | 384 | 0x16, 0x12, 0x24, COMP1, MCK_INIT1, |
408 | 0x18, 0x10, 0x02, 0x02, 0x09, 0x07 | ||
409 | }; | 385 | }; |
410 | /* compression 0x86 mckinit1 0x2b */ | 386 | /* compression 0x86 mckinit1 0x2b */ |
411 | 387 | ||
@@ -479,7 +455,6 @@ static const __u8 initPas202[] = { | |||
479 | 0x00, 0x00, | 455 | 0x00, 0x00, |
480 | 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a, | 456 | 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a, |
481 | 0x28, 0x1e, 0x20, 0x89, 0x20, | 457 | 0x28, 0x1e, 0x20, 0x89, 0x20, |
482 | 0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c | ||
483 | }; | 458 | }; |
484 | 459 | ||
485 | /* "Known" PAS202BCB registers: | 460 | /* "Known" PAS202BCB registers: |
@@ -506,7 +481,7 @@ static const __u8 pas202_sensor_init[][8] = { | |||
506 | {0xa0, 0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x10}, | 481 | {0xa0, 0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x10}, |
507 | {0xd0, 0x40, 0x04, 0x07, 0x34, 0x00, 0x09, 0x10}, | 482 | {0xd0, 0x40, 0x04, 0x07, 0x34, 0x00, 0x09, 0x10}, |
508 | {0xd0, 0x40, 0x08, 0x01, 0x00, 0x00, 0x01, 0x10}, | 483 | {0xd0, 0x40, 0x08, 0x01, 0x00, 0x00, 0x01, 0x10}, |
509 | {0xd0, 0x40, 0x0C, 0x00, 0x0C, 0x01, 0x32, 0x10}, | 484 | {0xd0, 0x40, 0x0c, 0x00, 0x0c, 0x01, 0x32, 0x10}, |
510 | {0xd0, 0x40, 0x10, 0x00, 0x01, 0x00, 0x63, 0x10}, | 485 | {0xd0, 0x40, 0x10, 0x00, 0x01, 0x00, 0x63, 0x10}, |
511 | {0xa0, 0x40, 0x15, 0x70, 0x01, 0x00, 0x63, 0x10}, | 486 | {0xa0, 0x40, 0x15, 0x70, 0x01, 0x00, 0x63, 0x10}, |
512 | {0xa0, 0x40, 0x18, 0x00, 0x01, 0x00, 0x63, 0x10}, | 487 | {0xa0, 0x40, 0x18, 0x00, 0x01, 0x00, 0x63, 0x10}, |
@@ -520,7 +495,6 @@ static const __u8 initTas5110c[] = { | |||
520 | 0x00, 0x00, | 495 | 0x00, 0x00, |
521 | 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a, | 496 | 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a, |
522 | 0x16, 0x12, 0x60, 0x86, 0x2b, | 497 | 0x16, 0x12, 0x60, 0x86, 0x2b, |
523 | 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 | ||
524 | }; | 498 | }; |
525 | /* Same as above, except a different hstart */ | 499 | /* Same as above, except a different hstart */ |
526 | static const __u8 initTas5110d[] = { | 500 | static const __u8 initTas5110d[] = { |
@@ -528,12 +502,19 @@ static const __u8 initTas5110d[] = { | |||
528 | 0x00, 0x00, | 502 | 0x00, 0x00, |
529 | 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a, | 503 | 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a, |
530 | 0x16, 0x12, 0x60, 0x86, 0x2b, | 504 | 0x16, 0x12, 0x60, 0x86, 0x2b, |
531 | 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 | ||
532 | }; | 505 | }; |
533 | static const __u8 tas5110_sensor_init[][8] = { | 506 | /* tas5110c is 3 wire, tas5110d is 2 wire (regular i2c) */ |
507 | static const __u8 tas5110c_sensor_init[][8] = { | ||
534 | {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10}, | 508 | {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10}, |
535 | {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10}, | 509 | {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10}, |
536 | {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, | 510 | }; |
511 | /* Known TAS5110D registers | ||
512 | * reg02: gain, bit order reversed!! 0 == max gain, 255 == min gain | ||
513 | * reg03: bit3: vflip, bit4: ~hflip, bit7: ~gainboost (~ == inverted) | ||
514 | * Note: writing reg03 seems to only work when written together with 02 | ||
515 | */ | ||
516 | static const __u8 tas5110d_sensor_init[][8] = { | ||
517 | {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, /* reset */ | ||
537 | }; | 518 | }; |
538 | 519 | ||
539 | static const __u8 initTas5130[] = { | 520 | static const __u8 initTas5130[] = { |
@@ -541,31 +522,28 @@ static const __u8 initTas5130[] = { | |||
541 | 0x00, 0x00, | 522 | 0x00, 0x00, |
542 | 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a, | 523 | 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a, |
543 | 0x28, 0x1e, 0x60, COMP, MCK_INIT, | 524 | 0x28, 0x1e, 0x60, COMP, MCK_INIT, |
544 | 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c | ||
545 | }; | 525 | }; |
546 | static const __u8 tas5130_sensor_init[][8] = { | 526 | static const __u8 tas5130_sensor_init[][8] = { |
547 | /* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10}, | 527 | /* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10}, |
548 | * shutter 0x47 short exposure? */ | 528 | * shutter 0x47 short exposure? */ |
549 | {0x30, 0x11, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10}, | 529 | {0x30, 0x11, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10}, |
550 | /* shutter 0x01 long exposure */ | 530 | /* shutter 0x01 long exposure */ |
551 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}, | 531 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}, |
552 | }; | 532 | }; |
553 | 533 | ||
554 | static struct sensor_data sensor_data[] = { | 534 | static const struct sensor_data sensor_data[] = { |
555 | SENS(initHv7131, NULL, hv7131_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, 0), | 535 | SENS(initHv7131d, hv7131d_sensor_init, F_GAIN, NO_BRIGHTNESS|NO_FREQ, 0), |
556 | SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF, 0, 0x60), | 536 | SENS(initHv7131r, hv7131r_sensor_init, 0, NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), |
557 | SENS(initOv7630, initOv7630_3, ov7630_sensor_init, NULL, ov7630_sensor_init_3, | 537 | SENS(initOv6650, ov6650_sensor_init, F_GAIN|F_SIF, 0, 0x60), |
558 | F_GAIN, 0, 0x21), | 538 | SENS(initOv7630, ov7630_sensor_init, F_GAIN, 0, 0x21), |
559 | SENS(initPas106, NULL, pas106_sensor_init, NULL, NULL, F_GAIN|F_SIF, NO_FREQ, | 539 | SENS(initPas106, pas106_sensor_init, F_GAIN|F_SIF, NO_FREQ, 0), |
560 | 0), | 540 | SENS(initPas202, pas202_sensor_init, F_GAIN, NO_FREQ, 0), |
561 | SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, F_GAIN, | 541 | SENS(initTas5110c, tas5110c_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, |
562 | NO_FREQ, 0), | 542 | NO_BRIGHTNESS|NO_FREQ, 0), |
563 | SENS(initTas5110c, NULL, tas5110_sensor_init, NULL, NULL, | 543 | SENS(initTas5110d, tas5110d_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, |
564 | F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0), | 544 | NO_BRIGHTNESS|NO_FREQ, 0), |
565 | SENS(initTas5110d, NULL, tas5110_sensor_init, NULL, NULL, | 545 | SENS(initTas5130, tas5130_sensor_init, F_GAIN, |
566 | F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0), | 546 | NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), |
567 | SENS(initTas5130, NULL, tas5130_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, | ||
568 | 0), | ||
569 | }; | 547 | }; |
570 | 548 | ||
571 | /* get one byte in gspca_dev->usb_buf */ | 549 | /* get one byte in gspca_dev->usb_buf */ |
@@ -637,7 +615,6 @@ static void i2c_w_vector(struct gspca_dev *gspca_dev, | |||
637 | static void setbrightness(struct gspca_dev *gspca_dev) | 615 | static void setbrightness(struct gspca_dev *gspca_dev) |
638 | { | 616 | { |
639 | struct sd *sd = (struct sd *) gspca_dev; | 617 | struct sd *sd = (struct sd *) gspca_dev; |
640 | __u8 value; | ||
641 | 618 | ||
642 | switch (sd->sensor) { | 619 | switch (sd->sensor) { |
643 | case SENSOR_OV6650: | 620 | case SENSOR_OV6650: |
@@ -647,7 +624,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
647 | 624 | ||
648 | /* change reg 0x06 */ | 625 | /* change reg 0x06 */ |
649 | i2cOV[1] = sensor_data[sd->sensor].sensor_addr; | 626 | i2cOV[1] = sensor_data[sd->sensor].sensor_addr; |
650 | i2cOV[3] = sd->brightness; | 627 | i2cOV[3] = sd->ctrls[BRIGHTNESS].val; |
651 | if (i2c_w(gspca_dev, i2cOV) < 0) | 628 | if (i2c_w(gspca_dev, i2cOV) < 0) |
652 | goto err; | 629 | goto err; |
653 | break; | 630 | break; |
@@ -665,13 +642,13 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
665 | i2cpdoit[2] = 0x13; | 642 | i2cpdoit[2] = 0x13; |
666 | } | 643 | } |
667 | 644 | ||
668 | if (sd->brightness < 127) { | 645 | if (sd->ctrls[BRIGHTNESS].val < 127) { |
669 | /* change reg 0x0b, signreg */ | 646 | /* change reg 0x0b, signreg */ |
670 | i2cpbright[3] = 0x01; | 647 | i2cpbright[3] = 0x01; |
671 | /* set reg 0x0c, offset */ | 648 | /* set reg 0x0c, offset */ |
672 | i2cpbright[4] = 127 - sd->brightness; | 649 | i2cpbright[4] = 127 - sd->ctrls[BRIGHTNESS].val; |
673 | } else | 650 | } else |
674 | i2cpbright[4] = sd->brightness - 127; | 651 | i2cpbright[4] = sd->ctrls[BRIGHTNESS].val - 127; |
675 | 652 | ||
676 | if (i2c_w(gspca_dev, i2cpbright) < 0) | 653 | if (i2c_w(gspca_dev, i2cpbright) < 0) |
677 | goto err; | 654 | goto err; |
@@ -679,17 +656,6 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
679 | goto err; | 656 | goto err; |
680 | break; | 657 | break; |
681 | } | 658 | } |
682 | case SENSOR_TAS5130CXX: { | ||
683 | __u8 i2c[] = | ||
684 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; | ||
685 | |||
686 | value = 0xff - sd->brightness; | ||
687 | i2c[4] = value; | ||
688 | PDEBUG(D_CONF, "brightness %d : %d", value, i2c[4]); | ||
689 | if (i2c_w(gspca_dev, i2c) < 0) | ||
690 | goto err; | ||
691 | break; | ||
692 | } | ||
693 | } | 659 | } |
694 | return; | 660 | return; |
695 | err: | 661 | err: |
@@ -699,12 +665,23 @@ err: | |||
699 | static void setsensorgain(struct gspca_dev *gspca_dev) | 665 | static void setsensorgain(struct gspca_dev *gspca_dev) |
700 | { | 666 | { |
701 | struct sd *sd = (struct sd *) gspca_dev; | 667 | struct sd *sd = (struct sd *) gspca_dev; |
702 | unsigned char gain = sd->gain; | 668 | u8 gain = sd->ctrls[GAIN].val; |
703 | 669 | ||
704 | switch (sd->sensor) { | 670 | switch (sd->sensor) { |
671 | case SENSOR_HV7131D: { | ||
672 | __u8 i2c[] = | ||
673 | {0xc0, 0x11, 0x31, 0x00, 0x00, 0x00, 0x00, 0x17}; | ||
674 | |||
675 | i2c[3] = 0x3f - (gain / 4); | ||
676 | i2c[4] = 0x3f - (gain / 4); | ||
677 | i2c[5] = 0x3f - (gain / 4); | ||
705 | 678 | ||
679 | if (i2c_w(gspca_dev, i2c) < 0) | ||
680 | goto err; | ||
681 | break; | ||
682 | } | ||
706 | case SENSOR_TAS5110C: | 683 | case SENSOR_TAS5110C: |
707 | case SENSOR_TAS5110D: { | 684 | case SENSOR_TAS5130CXX: { |
708 | __u8 i2c[] = | 685 | __u8 i2c[] = |
709 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; | 686 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; |
710 | 687 | ||
@@ -713,6 +690,23 @@ static void setsensorgain(struct gspca_dev *gspca_dev) | |||
713 | goto err; | 690 | goto err; |
714 | break; | 691 | break; |
715 | } | 692 | } |
693 | case SENSOR_TAS5110D: { | ||
694 | __u8 i2c[] = { | ||
695 | 0xb0, 0x61, 0x02, 0x00, 0x10, 0x00, 0x00, 0x17 }; | ||
696 | gain = 255 - gain; | ||
697 | /* The bits in the register are the wrong way around!! */ | ||
698 | i2c[3] |= (gain & 0x80) >> 7; | ||
699 | i2c[3] |= (gain & 0x40) >> 5; | ||
700 | i2c[3] |= (gain & 0x20) >> 3; | ||
701 | i2c[3] |= (gain & 0x10) >> 1; | ||
702 | i2c[3] |= (gain & 0x08) << 1; | ||
703 | i2c[3] |= (gain & 0x04) << 3; | ||
704 | i2c[3] |= (gain & 0x02) << 5; | ||
705 | i2c[3] |= (gain & 0x01) << 7; | ||
706 | if (i2c_w(gspca_dev, i2c) < 0) | ||
707 | goto err; | ||
708 | break; | ||
709 | } | ||
716 | 710 | ||
717 | case SENSOR_OV6650: | 711 | case SENSOR_OV6650: |
718 | gain >>= 1; | 712 | gain >>= 1; |
@@ -743,11 +737,11 @@ static void setsensorgain(struct gspca_dev *gspca_dev) | |||
743 | i2cpdoit[2] = 0x13; | 737 | i2cpdoit[2] = 0x13; |
744 | } | 738 | } |
745 | 739 | ||
746 | i2cpgain[3] = sd->gain >> 3; | 740 | i2cpgain[3] = gain >> 3; |
747 | i2cpcolorgain[3] = sd->gain >> 4; | 741 | i2cpcolorgain[3] = gain >> 4; |
748 | i2cpcolorgain[4] = sd->gain >> 4; | 742 | i2cpcolorgain[4] = gain >> 4; |
749 | i2cpcolorgain[5] = sd->gain >> 4; | 743 | i2cpcolorgain[5] = gain >> 4; |
750 | i2cpcolorgain[6] = sd->gain >> 4; | 744 | i2cpcolorgain[6] = gain >> 4; |
751 | 745 | ||
752 | if (i2c_w(gspca_dev, i2cpgain) < 0) | 746 | if (i2c_w(gspca_dev, i2cpgain) < 0) |
753 | goto err; | 747 | goto err; |
@@ -767,7 +761,7 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
767 | { | 761 | { |
768 | struct sd *sd = (struct sd *) gspca_dev; | 762 | struct sd *sd = (struct sd *) gspca_dev; |
769 | __u8 gain; | 763 | __u8 gain; |
770 | __u8 buf[2] = { 0, 0 }; | 764 | __u8 buf[3] = { 0, 0, 0 }; |
771 | 765 | ||
772 | if (sensor_data[sd->sensor].flags & F_GAIN) { | 766 | if (sensor_data[sd->sensor].flags & F_GAIN) { |
773 | /* Use the sensor gain to do the actual gain */ | 767 | /* Use the sensor gain to do the actual gain */ |
@@ -775,13 +769,18 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
775 | return; | 769 | return; |
776 | } | 770 | } |
777 | 771 | ||
778 | gain = sd->gain >> 4; | 772 | if (sd->bridge == BRIDGE_103) { |
779 | 773 | gain = sd->ctrls[GAIN].val >> 1; | |
780 | /* red and blue gain */ | 774 | buf[0] = gain; /* Red */ |
781 | buf[0] = gain << 4 | gain; | 775 | buf[1] = gain; /* Green */ |
782 | /* green gain */ | 776 | buf[2] = gain; /* Blue */ |
783 | buf[1] = gain; | 777 | reg_w(gspca_dev, 0x05, buf, 3); |
784 | reg_w(gspca_dev, 0x10, buf, 2); | 778 | } else { |
779 | gain = sd->ctrls[GAIN].val >> 4; | ||
780 | buf[0] = gain << 4 | gain; /* Red and blue */ | ||
781 | buf[1] = gain; /* Green */ | ||
782 | reg_w(gspca_dev, 0x10, buf, 2); | ||
783 | } | ||
785 | } | 784 | } |
786 | 785 | ||
787 | static void setexposure(struct gspca_dev *gspca_dev) | 786 | static void setexposure(struct gspca_dev *gspca_dev) |
@@ -789,12 +788,31 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
789 | struct sd *sd = (struct sd *) gspca_dev; | 788 | struct sd *sd = (struct sd *) gspca_dev; |
790 | 789 | ||
791 | switch (sd->sensor) { | 790 | switch (sd->sensor) { |
791 | case SENSOR_HV7131D: { | ||
792 | /* Note the datasheet wrongly says line mode exposure uses reg | ||
793 | 0x26 and 0x27, testing has shown 0x25 + 0x26 */ | ||
794 | __u8 i2c[] = {0xc0, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x17}; | ||
795 | /* The HV7131D's exposure goes from 0 - 65535, we scale our | ||
796 | exposure of 0-1023 to 0-6138. There are 2 reasons for this: | ||
797 | 1) This puts our exposure knee of 200 at approx the point | ||
798 | where the framerate starts dropping | ||
799 | 2) At 6138 the framerate has already dropped to 2 fps, | ||
800 | going any lower makes little sense */ | ||
801 | u16 reg = sd->ctrls[EXPOSURE].val * 6; | ||
802 | |||
803 | i2c[3] = reg >> 8; | ||
804 | i2c[4] = reg & 0xff; | ||
805 | if (i2c_w(gspca_dev, i2c) != 0) | ||
806 | goto err; | ||
807 | break; | ||
808 | } | ||
792 | case SENSOR_TAS5110C: | 809 | case SENSOR_TAS5110C: |
793 | case SENSOR_TAS5110D: { | 810 | case SENSOR_TAS5110D: { |
794 | /* register 19's high nibble contains the sn9c10x clock divider | 811 | /* register 19's high nibble contains the sn9c10x clock divider |
795 | The high nibble configures the no fps according to the | 812 | The high nibble configures the no fps according to the |
796 | formula: 60 / high_nibble. With a maximum of 30 fps */ | 813 | formula: 60 / high_nibble. With a maximum of 30 fps */ |
797 | __u8 reg = sd->exposure; | 814 | u8 reg = sd->ctrls[EXPOSURE].val; |
815 | |||
798 | reg = (reg << 4) | 0x0b; | 816 | reg = (reg << 4) | 0x0b; |
799 | reg_w(gspca_dev, 0x19, ®, 1); | 817 | reg_w(gspca_dev, 0x19, ®, 1); |
800 | break; | 818 | break; |
@@ -809,7 +827,7 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
809 | possible to use less exposure then what the fps maximum | 827 | possible to use less exposure then what the fps maximum |
810 | allows by setting register 10. register 10 configures the | 828 | allows by setting register 10. register 10 configures the |
811 | actual exposure as quotient of the full exposure, with 0 | 829 | actual exposure as quotient of the full exposure, with 0 |
812 | being no exposure at all (not very usefull) and reg10_max | 830 | being no exposure at all (not very useful) and reg10_max |
813 | being max exposure possible at that framerate. | 831 | being max exposure possible at that framerate. |
814 | 832 | ||
815 | The code maps our 0 - 510 ms exposure ctrl to these 2 | 833 | The code maps our 0 - 510 ms exposure ctrl to these 2 |
@@ -830,7 +848,7 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
830 | } else | 848 | } else |
831 | reg10_max = 0x41; | 849 | reg10_max = 0x41; |
832 | 850 | ||
833 | reg11 = (15 * sd->exposure + 999) / 1000; | 851 | reg11 = (15 * sd->ctrls[EXPOSURE].val + 999) / 1000; |
834 | if (reg11 < 1) | 852 | if (reg11 < 1) |
835 | reg11 = 1; | 853 | reg11 = 1; |
836 | else if (reg11 > 16) | 854 | else if (reg11 > 16) |
@@ -843,14 +861,16 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
843 | reg11 = 4; | 861 | reg11 = 4; |
844 | 862 | ||
845 | /* frame exposure time in ms = 1000 * reg11 / 30 -> | 863 | /* frame exposure time in ms = 1000 * reg11 / 30 -> |
846 | reg10 = (sd->exposure / 2) * reg10_max / (1000 * reg11 / 30) */ | 864 | reg10 = (sd->ctrls[EXPOSURE].val / 2) * reg10_max |
847 | reg10 = (sd->exposure * 15 * reg10_max) / (1000 * reg11); | 865 | / (1000 * reg11 / 30) */ |
866 | reg10 = (sd->ctrls[EXPOSURE].val * 15 * reg10_max) | ||
867 | / (1000 * reg11); | ||
848 | 868 | ||
849 | /* Don't allow this to get below 10 when using autogain, the | 869 | /* Don't allow this to get below 10 when using autogain, the |
850 | steps become very large (relatively) when below 10 causing | 870 | steps become very large (relatively) when below 10 causing |
851 | the image to oscilate from much too dark, to much too bright | 871 | the image to oscilate from much too dark, to much too bright |
852 | and back again. */ | 872 | and back again. */ |
853 | if (sd->autogain && reg10 < 10) | 873 | if (sd->ctrls[AUTOGAIN].val && reg10 < 10) |
854 | reg10 = 10; | 874 | reg10 = 10; |
855 | else if (reg10 > reg10_max) | 875 | else if (reg10 > reg10_max) |
856 | reg10 = reg10_max; | 876 | reg10 = reg10_max; |
@@ -861,7 +881,7 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
861 | i2c[4] |= reg11 - 1; | 881 | i2c[4] |= reg11 - 1; |
862 | 882 | ||
863 | /* If register 11 didn't change, don't change it */ | 883 | /* If register 11 didn't change, don't change it */ |
864 | if (sd->reg11 == reg11 ) | 884 | if (sd->reg11 == reg11) |
865 | i2c[0] = 0xa0; | 885 | i2c[0] = 0xa0; |
866 | 886 | ||
867 | if (i2c_w(gspca_dev, i2c) == 0) | 887 | if (i2c_w(gspca_dev, i2c) == 0) |
@@ -889,15 +909,16 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
889 | frame exposure times (like we are doing with the ov chips), | 909 | frame exposure times (like we are doing with the ov chips), |
890 | as that sometimes leads to jumps in the exposure control, | 910 | as that sometimes leads to jumps in the exposure control, |
891 | which are bad for auto exposure. */ | 911 | which are bad for auto exposure. */ |
892 | if (sd->exposure < 200) { | 912 | if (sd->ctrls[EXPOSURE].val < 200) { |
893 | i2cpexpo[3] = 255 - (sd->exposure * 255) / 200; | 913 | i2cpexpo[3] = 255 - (sd->ctrls[EXPOSURE].val * 255) |
914 | / 200; | ||
894 | framerate_ctrl = 500; | 915 | framerate_ctrl = 500; |
895 | } else { | 916 | } else { |
896 | /* The PAS202's exposure control goes from 0 - 4095, | 917 | /* The PAS202's exposure control goes from 0 - 4095, |
897 | but anything below 500 causes vsync issues, so scale | 918 | but anything below 500 causes vsync issues, so scale |
898 | our 200-1023 to 500-4095 */ | 919 | our 200-1023 to 500-4095 */ |
899 | framerate_ctrl = (sd->exposure - 200) * 1000 / 229 + | 920 | framerate_ctrl = (sd->ctrls[EXPOSURE].val - 200) |
900 | 500; | 921 | * 1000 / 229 + 500; |
901 | } | 922 | } |
902 | 923 | ||
903 | i2cpframerate[3] = framerate_ctrl >> 6; | 924 | i2cpframerate[3] = framerate_ctrl >> 6; |
@@ -921,15 +942,15 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
921 | 942 | ||
922 | /* For values below 150 use partial frame exposure, above | 943 | /* For values below 150 use partial frame exposure, above |
923 | that use framerate ctrl */ | 944 | that use framerate ctrl */ |
924 | if (sd->exposure < 150) { | 945 | if (sd->ctrls[EXPOSURE].val < 150) { |
925 | i2cpexpo[3] = 150 - sd->exposure; | 946 | i2cpexpo[3] = 150 - sd->ctrls[EXPOSURE].val; |
926 | framerate_ctrl = 300; | 947 | framerate_ctrl = 300; |
927 | } else { | 948 | } else { |
928 | /* The PAS106's exposure control goes from 0 - 4095, | 949 | /* The PAS106's exposure control goes from 0 - 4095, |
929 | but anything below 300 causes vsync issues, so scale | 950 | but anything below 300 causes vsync issues, so scale |
930 | our 150-1023 to 300-4095 */ | 951 | our 150-1023 to 300-4095 */ |
931 | framerate_ctrl = (sd->exposure - 150) * 1000 / 230 + | 952 | framerate_ctrl = (sd->ctrls[EXPOSURE].val - 150) |
932 | 300; | 953 | * 1000 / 230 + 300; |
933 | } | 954 | } |
934 | 955 | ||
935 | i2cpframerate[3] = framerate_ctrl >> 4; | 956 | i2cpframerate[3] = framerate_ctrl >> 4; |
@@ -960,7 +981,7 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
960 | 0x2b register, see ov6630 datasheet. | 981 | 0x2b register, see ov6630 datasheet. |
961 | 0x4f / 0x8a -> (30 fps -> 25 fps), 0x00 -> no adjustment */ | 982 | 0x4f / 0x8a -> (30 fps -> 25 fps), 0x00 -> no adjustment */ |
962 | __u8 i2c[] = {0xa0, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}; | 983 | __u8 i2c[] = {0xa0, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}; |
963 | switch (sd->freq) { | 984 | switch (sd->ctrls[FREQ].val) { |
964 | default: | 985 | default: |
965 | /* case 0: * no filter*/ | 986 | /* case 0: * no filter*/ |
966 | /* case 2: * 60 hz */ | 987 | /* case 2: * 60 hz */ |
@@ -979,7 +1000,7 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
979 | } | 1000 | } |
980 | } | 1001 | } |
981 | 1002 | ||
982 | #include "coarse_expo_autogain.h" | 1003 | #include "autogain_functions.h" |
983 | 1004 | ||
984 | static void do_autogain(struct gspca_dev *gspca_dev) | 1005 | static void do_autogain(struct gspca_dev *gspca_dev) |
985 | { | 1006 | { |
@@ -987,7 +1008,8 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
987 | struct sd *sd = (struct sd *) gspca_dev; | 1008 | struct sd *sd = (struct sd *) gspca_dev; |
988 | int avg_lum = atomic_read(&sd->avg_lum); | 1009 | int avg_lum = atomic_read(&sd->avg_lum); |
989 | 1010 | ||
990 | if (avg_lum == -1 || !sd->autogain) | 1011 | if ((gspca_dev->ctrl_dis & (1 << AUTOGAIN)) || |
1012 | avg_lum == -1 || !sd->ctrls[AUTOGAIN].val) | ||
991 | return; | 1013 | return; |
992 | 1014 | ||
993 | if (sd->autogain_ignore_frames > 0) { | 1015 | if (sd->autogain_ignore_frames > 0) { |
@@ -1003,21 +1025,24 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
1003 | desired_avg_lum = 5000; | 1025 | desired_avg_lum = 5000; |
1004 | } else { | 1026 | } else { |
1005 | deadzone = 1500; | 1027 | deadzone = 1500; |
1006 | desired_avg_lum = 18000; | 1028 | desired_avg_lum = 13000; |
1007 | } | 1029 | } |
1008 | 1030 | ||
1009 | if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) | 1031 | if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) |
1010 | result = gspca_coarse_grained_expo_autogain(gspca_dev, avg_lum, | 1032 | result = coarse_grained_expo_autogain(gspca_dev, avg_lum, |
1011 | sd->brightness * desired_avg_lum / 127, | 1033 | sd->ctrls[BRIGHTNESS].val |
1034 | * desired_avg_lum / 127, | ||
1012 | deadzone); | 1035 | deadzone); |
1013 | else | 1036 | else |
1014 | result = gspca_auto_gain_n_exposure(gspca_dev, avg_lum, | 1037 | result = auto_gain_n_exposure(gspca_dev, avg_lum, |
1015 | sd->brightness * desired_avg_lum / 127, | 1038 | sd->ctrls[BRIGHTNESS].val |
1039 | * desired_avg_lum / 127, | ||
1016 | deadzone, GAIN_KNEE, EXPOSURE_KNEE); | 1040 | deadzone, GAIN_KNEE, EXPOSURE_KNEE); |
1017 | 1041 | ||
1018 | if (result) { | 1042 | if (result) { |
1019 | PDEBUG(D_FRAM, "autogain: gain changed: gain: %d expo: %d", | 1043 | PDEBUG(D_FRAM, "autogain: gain changed: gain: %d expo: %d", |
1020 | (int)sd->gain, (int)sd->exposure); | 1044 | (int) sd->ctrls[GAIN].val, |
1045 | (int) sd->ctrls[EXPOSURE].val); | ||
1021 | sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; | 1046 | sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; |
1022 | } | 1047 | } |
1023 | } | 1048 | } |
@@ -1036,9 +1061,15 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1036 | /* copy the webcam info from the device id */ | 1061 | /* copy the webcam info from the device id */ |
1037 | sd->sensor = id->driver_info >> 8; | 1062 | sd->sensor = id->driver_info >> 8; |
1038 | sd->bridge = id->driver_info & 0xff; | 1063 | sd->bridge = id->driver_info & 0xff; |
1064 | |||
1039 | gspca_dev->ctrl_dis = sensor_data[sd->sensor].ctrl_dis; | 1065 | gspca_dev->ctrl_dis = sensor_data[sd->sensor].ctrl_dis; |
1066 | #if AUTOGAIN_DEF | ||
1067 | if (!(gspca_dev->ctrl_dis & (1 << AUTOGAIN))) | ||
1068 | gspca_dev->ctrl_inac = (1 << GAIN) | (1 << EXPOSURE); | ||
1069 | #endif | ||
1040 | 1070 | ||
1041 | cam = &gspca_dev->cam; | 1071 | cam = &gspca_dev->cam; |
1072 | cam->ctrls = sd->ctrls; | ||
1042 | if (!(sensor_data[sd->sensor].flags & F_SIF)) { | 1073 | if (!(sensor_data[sd->sensor].flags & F_SIF)) { |
1043 | cam->cam_mode = vga_mode; | 1074 | cam->cam_mode = vga_mode; |
1044 | cam->nmodes = ARRAY_SIZE(vga_mode); | 1075 | cam->nmodes = ARRAY_SIZE(vga_mode); |
@@ -1048,20 +1079,11 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1048 | } | 1079 | } |
1049 | cam->npkt = 36; /* 36 packets per ISOC message */ | 1080 | cam->npkt = 36; /* 36 packets per ISOC message */ |
1050 | 1081 | ||
1051 | sd->brightness = BRIGHTNESS_DEF; | ||
1052 | sd->gain = GAIN_DEF; | ||
1053 | if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) { | 1082 | if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) { |
1054 | sd->exposure = COARSE_EXPOSURE_DEF; | 1083 | sd->ctrls[EXPOSURE].min = COARSE_EXPOSURE_MIN; |
1055 | gspca_dev->ctrl_dis |= (1 << EXPOSURE_IDX); | 1084 | sd->ctrls[EXPOSURE].max = COARSE_EXPOSURE_MAX; |
1056 | } else { | 1085 | sd->ctrls[EXPOSURE].def = COARSE_EXPOSURE_DEF; |
1057 | sd->exposure = EXPOSURE_DEF; | ||
1058 | gspca_dev->ctrl_dis |= (1 << COARSE_EXPOSURE_IDX); | ||
1059 | } | 1086 | } |
1060 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) | ||
1061 | sd->autogain = 0; /* Disable do_autogain callback */ | ||
1062 | else | ||
1063 | sd->autogain = AUTOGAIN_DEF; | ||
1064 | sd->freq = FREQ_DEF; | ||
1065 | 1087 | ||
1066 | return 0; | 1088 | return 0; |
1067 | } | 1089 | } |
@@ -1081,53 +1103,91 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1081 | { | 1103 | { |
1082 | struct sd *sd = (struct sd *) gspca_dev; | 1104 | struct sd *sd = (struct sd *) gspca_dev; |
1083 | struct cam *cam = &gspca_dev->cam; | 1105 | struct cam *cam = &gspca_dev->cam; |
1084 | int mode, l; | 1106 | int i, mode; |
1085 | const __u8 *sn9c10x; | 1107 | __u8 regs[0x31]; |
1086 | __u8 reg12_19[8]; | ||
1087 | 1108 | ||
1088 | mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; | 1109 | mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; |
1089 | sn9c10x = sensor_data[sd->sensor].bridge_init[sd->bridge]; | 1110 | /* Copy registers 0x01 - 0x19 from the template */ |
1090 | l = sensor_data[sd->sensor].bridge_init_size[sd->bridge]; | 1111 | memcpy(®s[0x01], sensor_data[sd->sensor].bridge_init, 0x19); |
1091 | memcpy(reg12_19, &sn9c10x[0x12 - 1], 8); | 1112 | /* Set the mode */ |
1092 | reg12_19[6] = sn9c10x[0x18 - 1] | (mode << 4); | 1113 | regs[0x18] |= mode << 4; |
1093 | /* Special cases where reg 17 and or 19 value depends on mode */ | 1114 | |
1115 | /* Set bridge gain to 1.0 */ | ||
1116 | if (sd->bridge == BRIDGE_103) { | ||
1117 | regs[0x05] = 0x20; /* Red */ | ||
1118 | regs[0x06] = 0x20; /* Green */ | ||
1119 | regs[0x07] = 0x20; /* Blue */ | ||
1120 | } else { | ||
1121 | regs[0x10] = 0x00; /* Red and blue */ | ||
1122 | regs[0x11] = 0x00; /* Green */ | ||
1123 | } | ||
1124 | |||
1125 | /* Setup pixel numbers and auto exposure window */ | ||
1126 | if (sensor_data[sd->sensor].flags & F_SIF) { | ||
1127 | regs[0x1a] = 0x14; /* HO_SIZE 640, makes no sense */ | ||
1128 | regs[0x1b] = 0x0a; /* VO_SIZE 320, makes no sense */ | ||
1129 | regs[0x1c] = 0x02; /* AE H-start 64 */ | ||
1130 | regs[0x1d] = 0x02; /* AE V-start 64 */ | ||
1131 | regs[0x1e] = 0x09; /* AE H-end 288 */ | ||
1132 | regs[0x1f] = 0x07; /* AE V-end 224 */ | ||
1133 | } else { | ||
1134 | regs[0x1a] = 0x1d; /* HO_SIZE 960, makes no sense */ | ||
1135 | regs[0x1b] = 0x10; /* VO_SIZE 512, makes no sense */ | ||
1136 | regs[0x1c] = 0x05; /* AE H-start 160 */ | ||
1137 | regs[0x1d] = 0x03; /* AE V-start 96 */ | ||
1138 | regs[0x1e] = 0x0f; /* AE H-end 480 */ | ||
1139 | regs[0x1f] = 0x0c; /* AE V-end 384 */ | ||
1140 | } | ||
1141 | |||
1142 | /* Setup the gamma table (only used with the sn9c103 bridge) */ | ||
1143 | for (i = 0; i < 16; i++) | ||
1144 | regs[0x20 + i] = i * 16; | ||
1145 | regs[0x20 + i] = 255; | ||
1146 | |||
1147 | /* Special cases where some regs depend on mode or bridge */ | ||
1094 | switch (sd->sensor) { | 1148 | switch (sd->sensor) { |
1095 | case SENSOR_TAS5130CXX: | 1149 | case SENSOR_TAS5130CXX: |
1096 | /* probably not mode specific at all most likely the upper | 1150 | /* FIXME / TESTME |
1151 | probably not mode specific at all most likely the upper | ||
1097 | nibble of 0x19 is exposure (clock divider) just as with | 1152 | nibble of 0x19 is exposure (clock divider) just as with |
1098 | the tas5110, we need someone to test this. */ | 1153 | the tas5110, we need someone to test this. */ |
1099 | reg12_19[7] = mode ? 0x23 : 0x43; | 1154 | regs[0x19] = mode ? 0x23 : 0x43; |
1100 | break; | 1155 | break; |
1156 | case SENSOR_OV7630: | ||
1157 | /* FIXME / TESTME for some reason with the 101/102 bridge the | ||
1158 | clock is set to 12 Mhz (reg1 == 0x04), rather then 24. | ||
1159 | Also the hstart needs to go from 1 to 2 when using a 103, | ||
1160 | which is likely related. This does not seem right. */ | ||
1161 | if (sd->bridge == BRIDGE_103) { | ||
1162 | regs[0x01] = 0x44; /* Select 24 Mhz clock */ | ||
1163 | regs[0x12] = 0x02; /* Set hstart to 2 */ | ||
1164 | } | ||
1101 | } | 1165 | } |
1102 | /* Disable compression when the raw bayer format has been selected */ | 1166 | /* Disable compression when the raw bayer format has been selected */ |
1103 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) | 1167 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) |
1104 | reg12_19[6] &= ~0x80; | 1168 | regs[0x18] &= ~0x80; |
1105 | 1169 | ||
1106 | /* Vga mode emulation on SIF sensor? */ | 1170 | /* Vga mode emulation on SIF sensor? */ |
1107 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { | 1171 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { |
1108 | reg12_19[0] += 16; /* 0x12: hstart adjust */ | 1172 | regs[0x12] += 16; /* hstart adjust */ |
1109 | reg12_19[1] += 24; /* 0x13: vstart adjust */ | 1173 | regs[0x13] += 24; /* vstart adjust */ |
1110 | reg12_19[3] = 320 / 16; /* 0x15: hsize */ | 1174 | regs[0x15] = 320 / 16; /* hsize */ |
1111 | reg12_19[4] = 240 / 16; /* 0x16: vsize */ | 1175 | regs[0x16] = 240 / 16; /* vsize */ |
1112 | } | 1176 | } |
1113 | 1177 | ||
1114 | /* reg 0x01 bit 2 video transfert on */ | 1178 | /* reg 0x01 bit 2 video transfert on */ |
1115 | reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1); | 1179 | reg_w(gspca_dev, 0x01, ®s[0x01], 1); |
1116 | /* reg 0x17 SensorClk enable inv Clk 0x60 */ | 1180 | /* reg 0x17 SensorClk enable inv Clk 0x60 */ |
1117 | reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); | 1181 | reg_w(gspca_dev, 0x17, ®s[0x17], 1); |
1118 | /* Set the registers from the template */ | 1182 | /* Set the registers from the template */ |
1119 | reg_w(gspca_dev, 0x01, sn9c10x, l); | 1183 | reg_w(gspca_dev, 0x01, ®s[0x01], |
1184 | (sd->bridge == BRIDGE_103) ? 0x30 : 0x1f); | ||
1120 | 1185 | ||
1121 | /* Init the sensor */ | 1186 | /* Init the sensor */ |
1122 | i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, | 1187 | i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, |
1123 | sensor_data[sd->sensor].sensor_init_size); | 1188 | sensor_data[sd->sensor].sensor_init_size); |
1124 | if (sensor_data[sd->sensor].sensor_bridge_init[sd->bridge]) | ||
1125 | i2c_w_vector(gspca_dev, | ||
1126 | sensor_data[sd->sensor].sensor_bridge_init[sd->bridge], | ||
1127 | sensor_data[sd->sensor].sensor_bridge_init_size[ | ||
1128 | sd->bridge]); | ||
1129 | 1189 | ||
1130 | /* Mode specific sensor setup */ | 1190 | /* Mode / bridge specific sensor setup */ |
1131 | switch (sd->sensor) { | 1191 | switch (sd->sensor) { |
1132 | case SENSOR_PAS202: { | 1192 | case SENSOR_PAS202: { |
1133 | const __u8 i2cpclockdiv[] = | 1193 | const __u8 i2cpclockdiv[] = |
@@ -1135,27 +1195,37 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1135 | /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */ | 1195 | /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */ |
1136 | if (mode) | 1196 | if (mode) |
1137 | i2c_w(gspca_dev, i2cpclockdiv); | 1197 | i2c_w(gspca_dev, i2cpclockdiv); |
1198 | break; | ||
1138 | } | 1199 | } |
1200 | case SENSOR_OV7630: | ||
1201 | /* FIXME / TESTME We should be able to handle this identical | ||
1202 | for the 101/102 and the 103 case */ | ||
1203 | if (sd->bridge == BRIDGE_103) { | ||
1204 | const __u8 i2c[] = { 0xa0, 0x21, 0x13, | ||
1205 | 0x80, 0x00, 0x00, 0x00, 0x10 }; | ||
1206 | i2c_w(gspca_dev, i2c); | ||
1207 | } | ||
1208 | break; | ||
1139 | } | 1209 | } |
1140 | /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ | 1210 | /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ |
1141 | reg_w(gspca_dev, 0x15, ®12_19[3], 2); | 1211 | reg_w(gspca_dev, 0x15, ®s[0x15], 2); |
1142 | /* compression register */ | 1212 | /* compression register */ |
1143 | reg_w(gspca_dev, 0x18, ®12_19[6], 1); | 1213 | reg_w(gspca_dev, 0x18, ®s[0x18], 1); |
1144 | /* H_start */ | 1214 | /* H_start */ |
1145 | reg_w(gspca_dev, 0x12, ®12_19[0], 1); | 1215 | reg_w(gspca_dev, 0x12, ®s[0x12], 1); |
1146 | /* V_START */ | 1216 | /* V_START */ |
1147 | reg_w(gspca_dev, 0x13, ®12_19[1], 1); | 1217 | reg_w(gspca_dev, 0x13, ®s[0x13], 1); |
1148 | /* reset 0x17 SensorClk enable inv Clk 0x60 */ | 1218 | /* reset 0x17 SensorClk enable inv Clk 0x60 */ |
1149 | /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ | 1219 | /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ |
1150 | reg_w(gspca_dev, 0x17, ®12_19[5], 1); | 1220 | reg_w(gspca_dev, 0x17, ®s[0x17], 1); |
1151 | /*MCKSIZE ->3 */ /*fixme: not ov7630*/ | 1221 | /*MCKSIZE ->3 */ /*fixme: not ov7630*/ |
1152 | reg_w(gspca_dev, 0x19, ®12_19[7], 1); | 1222 | reg_w(gspca_dev, 0x19, ®s[0x19], 1); |
1153 | /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ | 1223 | /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ |
1154 | reg_w(gspca_dev, 0x1c, &sn9c10x[0x1c - 1], 4); | 1224 | reg_w(gspca_dev, 0x1c, ®s[0x1c], 4); |
1155 | /* Enable video transfert */ | 1225 | /* Enable video transfert */ |
1156 | reg_w(gspca_dev, 0x01, &sn9c10x[0], 1); | 1226 | reg_w(gspca_dev, 0x01, ®s[0x01], 1); |
1157 | /* Compression */ | 1227 | /* Compression */ |
1158 | reg_w(gspca_dev, 0x18, ®12_19[6], 2); | 1228 | reg_w(gspca_dev, 0x18, ®s[0x18], 2); |
1159 | msleep(20); | 1229 | msleep(20); |
1160 | 1230 | ||
1161 | sd->reg11 = -1; | 1231 | sd->reg11 = -1; |
@@ -1178,13 +1248,10 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1178 | sd_init(gspca_dev); | 1248 | sd_init(gspca_dev); |
1179 | } | 1249 | } |
1180 | 1250 | ||
1181 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1251 | static u8* find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) |
1182 | u8 *data, /* isoc packet */ | ||
1183 | int len) /* iso packet length */ | ||
1184 | { | 1252 | { |
1185 | int i; | ||
1186 | struct sd *sd = (struct sd *) gspca_dev; | 1253 | struct sd *sd = (struct sd *) gspca_dev; |
1187 | struct cam *cam = &gspca_dev->cam; | 1254 | int i, header_size = (sd->bridge == BRIDGE_103) ? 18 : 12; |
1188 | 1255 | ||
1189 | /* frames start with: | 1256 | /* frames start with: |
1190 | * ff ff 00 c4 c4 96 synchro | 1257 | * ff ff 00 c4 c4 96 synchro |
@@ -1195,58 +1262,84 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1195 | * ll mm brightness sum outside auto exposure | 1262 | * ll mm brightness sum outside auto exposure |
1196 | * (xx xx xx xx xx) audio values for snc103 | 1263 | * (xx xx xx xx xx) audio values for snc103 |
1197 | */ | 1264 | */ |
1198 | if (len > 6 && len < 24) { | 1265 | for (i = 0; i < len; i++) { |
1199 | for (i = 0; i < len - 6; i++) { | 1266 | switch (sd->header_read) { |
1200 | if (data[0 + i] == 0xff | 1267 | case 0: |
1201 | && data[1 + i] == 0xff | 1268 | if (data[i] == 0xff) |
1202 | && data[2 + i] == 0x00 | 1269 | sd->header_read++; |
1203 | && data[3 + i] == 0xc4 | 1270 | break; |
1204 | && data[4 + i] == 0xc4 | 1271 | case 1: |
1205 | && data[5 + i] == 0x96) { /* start of frame */ | 1272 | if (data[i] == 0xff) |
1206 | int lum = -1; | 1273 | sd->header_read++; |
1207 | int pkt_type = LAST_PACKET; | 1274 | else |
1208 | int fr_h_sz = (sd->bridge == BRIDGE_103) ? | 1275 | sd->header_read = 0; |
1209 | 18 : 12; | 1276 | break; |
1210 | 1277 | case 2: | |
1211 | if (len - i < fr_h_sz) { | 1278 | if (data[i] == 0x00) |
1212 | PDEBUG(D_STREAM, "packet too short to" | 1279 | sd->header_read++; |
1213 | " get avg brightness"); | 1280 | else if (data[i] != 0xff) |
1214 | } else if (sd->bridge == BRIDGE_103) { | 1281 | sd->header_read = 0; |
1215 | lum = data[i + 9] + | 1282 | break; |
1216 | (data[i + 10] << 8); | 1283 | case 3: |
1217 | } else { | 1284 | if (data[i] == 0xc4) |
1218 | lum = data[i + 8] + (data[i + 9] << 8); | 1285 | sd->header_read++; |
1219 | } | 1286 | else if (data[i] == 0xff) |
1220 | /* When exposure changes midway a frame we | 1287 | sd->header_read = 1; |
1221 | get a lum of 0 in this case drop 2 frames | 1288 | else |
1222 | as the frames directly after an exposure | 1289 | sd->header_read = 0; |
1223 | change have an unstable image. Sometimes lum | 1290 | break; |
1224 | *really* is 0 (cam used in low light with | 1291 | case 4: |
1225 | low exposure setting), so do not drop frames | 1292 | if (data[i] == 0xc4) |
1226 | if the previous lum was 0 too. */ | 1293 | sd->header_read++; |
1227 | if (lum == 0 && sd->prev_avg_lum != 0) { | 1294 | else if (data[i] == 0xff) |
1228 | lum = -1; | 1295 | sd->header_read = 1; |
1229 | sd->frames_to_drop = 2; | 1296 | else |
1230 | sd->prev_avg_lum = 0; | 1297 | sd->header_read = 0; |
1231 | } else | 1298 | break; |
1232 | sd->prev_avg_lum = lum; | 1299 | case 5: |
1233 | atomic_set(&sd->avg_lum, lum); | 1300 | if (data[i] == 0x96) |
1234 | 1301 | sd->header_read++; | |
1235 | if (sd->frames_to_drop) { | 1302 | else if (data[i] == 0xff) |
1236 | sd->frames_to_drop--; | 1303 | sd->header_read = 1; |
1237 | pkt_type = DISCARD_PACKET; | 1304 | else |
1238 | } | 1305 | sd->header_read = 0; |
1239 | 1306 | break; | |
1240 | gspca_frame_add(gspca_dev, pkt_type, | 1307 | default: |
1241 | NULL, 0); | 1308 | sd->header[sd->header_read - 6] = data[i]; |
1242 | data += i + fr_h_sz; | 1309 | sd->header_read++; |
1243 | len -= i + fr_h_sz; | 1310 | if (sd->header_read == header_size) { |
1244 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 1311 | sd->header_read = 0; |
1245 | data, len); | 1312 | return data + i + 1; |
1246 | return; | ||
1247 | } | 1313 | } |
1248 | } | 1314 | } |
1249 | } | 1315 | } |
1316 | return NULL; | ||
1317 | } | ||
1318 | |||
1319 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
1320 | u8 *data, /* isoc packet */ | ||
1321 | int len) /* iso packet length */ | ||
1322 | { | ||
1323 | int fr_h_sz = 0, lum_offset = 0, len_after_sof = 0; | ||
1324 | struct sd *sd = (struct sd *) gspca_dev; | ||
1325 | struct cam *cam = &gspca_dev->cam; | ||
1326 | u8 *sof; | ||
1327 | |||
1328 | sof = find_sof(gspca_dev, data, len); | ||
1329 | if (sof) { | ||
1330 | if (sd->bridge == BRIDGE_103) { | ||
1331 | fr_h_sz = 18; | ||
1332 | lum_offset = 3; | ||
1333 | } else { | ||
1334 | fr_h_sz = 12; | ||
1335 | lum_offset = 2; | ||
1336 | } | ||
1337 | |||
1338 | len_after_sof = len - (sof - data); | ||
1339 | len = (sof - data) - fr_h_sz; | ||
1340 | if (len < 0) | ||
1341 | len = 0; | ||
1342 | } | ||
1250 | 1343 | ||
1251 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) { | 1344 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) { |
1252 | /* In raw mode we sometimes get some garbage after the frame | 1345 | /* In raw mode we sometimes get some garbage after the frame |
@@ -1260,67 +1353,40 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1260 | } | 1353 | } |
1261 | 1354 | ||
1262 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 1355 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
1263 | } | ||
1264 | |||
1265 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
1266 | { | ||
1267 | struct sd *sd = (struct sd *) gspca_dev; | ||
1268 | |||
1269 | sd->brightness = val; | ||
1270 | if (gspca_dev->streaming) | ||
1271 | setbrightness(gspca_dev); | ||
1272 | return 0; | ||
1273 | } | ||
1274 | |||
1275 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
1276 | { | ||
1277 | struct sd *sd = (struct sd *) gspca_dev; | ||
1278 | |||
1279 | *val = sd->brightness; | ||
1280 | return 0; | ||
1281 | } | ||
1282 | |||
1283 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | ||
1284 | { | ||
1285 | struct sd *sd = (struct sd *) gspca_dev; | ||
1286 | |||
1287 | sd->gain = val; | ||
1288 | if (gspca_dev->streaming) | ||
1289 | setgain(gspca_dev); | ||
1290 | return 0; | ||
1291 | } | ||
1292 | |||
1293 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | ||
1294 | { | ||
1295 | struct sd *sd = (struct sd *) gspca_dev; | ||
1296 | 1356 | ||
1297 | *val = sd->gain; | 1357 | if (sof) { |
1298 | return 0; | 1358 | int lum = sd->header[lum_offset] + |
1299 | } | 1359 | (sd->header[lum_offset + 1] << 8); |
1300 | 1360 | ||
1301 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val) | 1361 | /* When exposure changes midway a frame we |
1302 | { | 1362 | get a lum of 0 in this case drop 2 frames |
1303 | struct sd *sd = (struct sd *) gspca_dev; | 1363 | as the frames directly after an exposure |
1304 | 1364 | change have an unstable image. Sometimes lum | |
1305 | sd->exposure = val; | 1365 | *really* is 0 (cam used in low light with |
1306 | if (gspca_dev->streaming) | 1366 | low exposure setting), so do not drop frames |
1307 | setexposure(gspca_dev); | 1367 | if the previous lum was 0 too. */ |
1308 | return 0; | 1368 | if (lum == 0 && sd->prev_avg_lum != 0) { |
1309 | } | 1369 | lum = -1; |
1370 | sd->frames_to_drop = 2; | ||
1371 | sd->prev_avg_lum = 0; | ||
1372 | } else | ||
1373 | sd->prev_avg_lum = lum; | ||
1374 | atomic_set(&sd->avg_lum, lum); | ||
1310 | 1375 | ||
1311 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) | 1376 | if (sd->frames_to_drop) |
1312 | { | 1377 | sd->frames_to_drop--; |
1313 | struct sd *sd = (struct sd *) gspca_dev; | 1378 | else |
1379 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); | ||
1314 | 1380 | ||
1315 | *val = sd->exposure; | 1381 | gspca_frame_add(gspca_dev, FIRST_PACKET, sof, len_after_sof); |
1316 | return 0; | 1382 | } |
1317 | } | 1383 | } |
1318 | 1384 | ||
1319 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | 1385 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
1320 | { | 1386 | { |
1321 | struct sd *sd = (struct sd *) gspca_dev; | 1387 | struct sd *sd = (struct sd *) gspca_dev; |
1322 | 1388 | ||
1323 | sd->autogain = val; | 1389 | sd->ctrls[AUTOGAIN].val = val; |
1324 | sd->exp_too_high_cnt = 0; | 1390 | sd->exp_too_high_cnt = 0; |
1325 | sd->exp_too_low_cnt = 0; | 1391 | sd->exp_too_low_cnt = 0; |
1326 | 1392 | ||
@@ -1328,9 +1394,10 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | |||
1328 | we are on a valid point of the autogain gain / | 1394 | we are on a valid point of the autogain gain / |
1329 | exposure knee graph, and give this change time to | 1395 | exposure knee graph, and give this change time to |
1330 | take effect before doing autogain. */ | 1396 | take effect before doing autogain. */ |
1331 | if (sd->autogain && !(sensor_data[sd->sensor].flags & F_COARSE_EXPO)) { | 1397 | if (sd->ctrls[AUTOGAIN].val |
1332 | sd->exposure = EXPOSURE_DEF; | 1398 | && !(sensor_data[sd->sensor].flags & F_COARSE_EXPO)) { |
1333 | sd->gain = GAIN_DEF; | 1399 | sd->ctrls[EXPOSURE].val = sd->ctrls[EXPOSURE].def; |
1400 | sd->ctrls[GAIN].val = sd->ctrls[GAIN].def; | ||
1334 | if (gspca_dev->streaming) { | 1401 | if (gspca_dev->streaming) { |
1335 | sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; | 1402 | sd->autogain_ignore_frames = AUTOGAIN_IGNORE_FRAMES; |
1336 | setexposure(gspca_dev); | 1403 | setexposure(gspca_dev); |
@@ -1338,32 +1405,11 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | |||
1338 | } | 1405 | } |
1339 | } | 1406 | } |
1340 | 1407 | ||
1341 | return 0; | 1408 | if (sd->ctrls[AUTOGAIN].val) |
1342 | } | 1409 | gspca_dev->ctrl_inac = (1 << GAIN) | (1 << EXPOSURE); |
1343 | 1410 | else | |
1344 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | 1411 | gspca_dev->ctrl_inac = 0; |
1345 | { | ||
1346 | struct sd *sd = (struct sd *) gspca_dev; | ||
1347 | |||
1348 | *val = sd->autogain; | ||
1349 | return 0; | ||
1350 | } | ||
1351 | |||
1352 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
1353 | { | ||
1354 | struct sd *sd = (struct sd *) gspca_dev; | ||
1355 | |||
1356 | sd->freq = val; | ||
1357 | if (gspca_dev->streaming) | ||
1358 | setfreq(gspca_dev); | ||
1359 | return 0; | ||
1360 | } | ||
1361 | |||
1362 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
1363 | { | ||
1364 | struct sd *sd = (struct sd *) gspca_dev; | ||
1365 | 1412 | ||
1366 | *val = sd->freq; | ||
1367 | return 0; | 1413 | return 0; |
1368 | } | 1414 | } |
1369 | 1415 | ||
@@ -1388,7 +1434,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
1388 | return -EINVAL; | 1434 | return -EINVAL; |
1389 | } | 1435 | } |
1390 | 1436 | ||
1391 | #ifdef CONFIG_INPUT | 1437 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
1392 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 1438 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
1393 | u8 *data, /* interrupt packet data */ | 1439 | u8 *data, /* interrupt packet data */ |
1394 | int len) /* interrupt packet length */ | 1440 | int len) /* interrupt packet length */ |
@@ -1419,7 +1465,7 @@ static const struct sd_desc sd_desc = { | |||
1419 | .pkt_scan = sd_pkt_scan, | 1465 | .pkt_scan = sd_pkt_scan, |
1420 | .querymenu = sd_querymenu, | 1466 | .querymenu = sd_querymenu, |
1421 | .dq_callback = do_autogain, | 1467 | .dq_callback = do_autogain, |
1422 | #ifdef CONFIG_INPUT | 1468 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
1423 | .int_pkt_scan = sd_int_pkt_scan, | 1469 | .int_pkt_scan = sd_int_pkt_scan, |
1424 | #endif | 1470 | #endif |
1425 | }; | 1471 | }; |
@@ -1429,36 +1475,41 @@ static const struct sd_desc sd_desc = { | |||
1429 | .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge | 1475 | .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge |
1430 | 1476 | ||
1431 | 1477 | ||
1432 | static const struct usb_device_id device_table[] __devinitconst = { | 1478 | static const struct usb_device_id device_table[] = { |
1433 | {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */ | 1479 | {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */ |
1434 | {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */ | 1480 | {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */ |
1435 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1436 | {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */ | 1481 | {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */ |
1437 | #endif | ||
1438 | {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)}, | 1482 | {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)}, |
1439 | {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, | 1483 | {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, |
1440 | {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, | 1484 | {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, |
1441 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1442 | {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, | 1485 | {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, |
1486 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1443 | {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, | 1487 | {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, |
1444 | {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, | 1488 | {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, |
1445 | #endif | 1489 | #endif |
1446 | {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, | 1490 | {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, |
1447 | {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)}, | 1491 | {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)}, |
1492 | {USB_DEVICE(0x0c45, 0x602a), SB(HV7131D, 102)}, | ||
1493 | /* {USB_DEVICE(0x0c45, 0x602b), SB(MI0343, 102)}, */ | ||
1448 | {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)}, | 1494 | {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)}, |
1449 | {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)}, | 1495 | {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)}, |
1450 | {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)}, | 1496 | {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)}, |
1497 | /* {USB_DEVICE(0x0c45, 0x6030), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */ | ||
1498 | /* {USB_DEVICE(0x0c45, 0x6082), SB(MI03XX, 103)}, */ /* MI0343 MI0360 */ | ||
1499 | {USB_DEVICE(0x0c45, 0x6083), SB(HV7131D, 103)}, | ||
1500 | {USB_DEVICE(0x0c45, 0x608c), SB(HV7131R, 103)}, | ||
1501 | /* {USB_DEVICE(0x0c45, 0x608e), SB(CISVF10, 103)}, */ | ||
1451 | {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)}, | 1502 | {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)}, |
1452 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | 1503 | {USB_DEVICE(0x0c45, 0x60a8), SB(PAS106, 103)}, |
1504 | {USB_DEVICE(0x0c45, 0x60aa), SB(TAS5130CXX, 103)}, | ||
1453 | {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)}, | 1505 | {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)}, |
1454 | #endif | ||
1455 | {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)}, | 1506 | {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)}, |
1456 | {} | 1507 | {} |
1457 | }; | 1508 | }; |
1458 | MODULE_DEVICE_TABLE(usb, device_table); | 1509 | MODULE_DEVICE_TABLE(usb, device_table); |
1459 | 1510 | ||
1460 | /* -- device connect -- */ | 1511 | /* -- device connect -- */ |
1461 | static int __devinit sd_probe(struct usb_interface *intf, | 1512 | static int sd_probe(struct usb_interface *intf, |
1462 | const struct usb_device_id *id) | 1513 | const struct usb_device_id *id) |
1463 | { | 1514 | { |
1464 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 1515 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
@@ -1479,17 +1530,11 @@ static struct usb_driver sd_driver = { | |||
1479 | /* -- module insert / remove -- */ | 1530 | /* -- module insert / remove -- */ |
1480 | static int __init sd_mod_init(void) | 1531 | static int __init sd_mod_init(void) |
1481 | { | 1532 | { |
1482 | int ret; | 1533 | 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 | } | 1534 | } |
1489 | static void __exit sd_mod_exit(void) | 1535 | static void __exit sd_mod_exit(void) |
1490 | { | 1536 | { |
1491 | usb_deregister(&sd_driver); | 1537 | usb_deregister(&sd_driver); |
1492 | PDEBUG(D_PROBE, "deregistered"); | ||
1493 | } | 1538 | } |
1494 | 1539 | ||
1495 | module_init(sd_mod_init); | 1540 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 370544361be2..81b8a600783b 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -25,37 +25,53 @@ | |||
25 | #include "gspca.h" | 25 | #include "gspca.h" |
26 | #include "jpeg.h" | 26 | #include "jpeg.h" |
27 | 27 | ||
28 | #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) | ||
29 | |||
30 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); | 28 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); |
31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); | 29 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
32 | MODULE_LICENSE("GPL"); | 30 | MODULE_LICENSE("GPL"); |
33 | 31 | ||
32 | /* controls */ | ||
33 | enum e_ctrl { | ||
34 | BRIGHTNESS, | ||
35 | CONTRAST, | ||
36 | COLORS, | ||
37 | BLUE, | ||
38 | RED, | ||
39 | GAMMA, | ||
40 | AUTOGAIN, | ||
41 | HFLIP, | ||
42 | VFLIP, | ||
43 | SHARPNESS, | ||
44 | ILLUM, | ||
45 | FREQ, | ||
46 | NCTRLS /* number of controls */ | ||
47 | }; | ||
48 | |||
34 | /* specific webcam descriptor */ | 49 | /* specific webcam descriptor */ |
35 | struct sd { | 50 | struct sd { |
36 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 51 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
37 | 52 | ||
53 | struct gspca_ctrl ctrls[NCTRLS]; | ||
54 | |||
38 | atomic_t avg_lum; | 55 | atomic_t avg_lum; |
39 | u32 exposure; | 56 | u32 exposure; |
40 | 57 | ||
41 | u16 brightness; | 58 | struct work_struct work; |
42 | u8 contrast; | 59 | struct workqueue_struct *work_thread; |
43 | u8 colors; | 60 | |
44 | u8 autogain; | 61 | u32 pktsz; /* (used by pkt_scan) */ |
45 | u8 blue; | 62 | u16 npkt; |
46 | u8 red; | 63 | s8 nchg; |
47 | u8 gamma; | 64 | s8 short_mark; |
48 | u8 vflip; /* ov7630/ov7648 only */ | 65 | |
49 | u8 sharpness; | ||
50 | u8 infrared; /* mt9v111 only */ | ||
51 | u8 freq; /* ov76xx only */ | ||
52 | u8 quality; /* image quality */ | 66 | u8 quality; /* image quality */ |
53 | #define QUALITY_MIN 60 | 67 | #define QUALITY_MIN 25 |
54 | #define QUALITY_MAX 95 | 68 | #define QUALITY_MAX 90 |
55 | #define QUALITY_DEF 80 | 69 | #define QUALITY_DEF 70 |
56 | u8 jpegqual; /* webcam quality */ | ||
57 | 70 | ||
71 | u8 reg01; | ||
72 | u8 reg17; | ||
58 | u8 reg18; | 73 | u8 reg18; |
74 | u8 flags; | ||
59 | 75 | ||
60 | s8 ag_cnt; | 76 | s8 ag_cnt; |
61 | #define AG_CNT_START 13 | 77 | #define AG_CNT_START 13 |
@@ -75,6 +91,7 @@ enum sensors { | |||
75 | SENSOR_GC0307, | 91 | SENSOR_GC0307, |
76 | SENSOR_HV7131R, | 92 | SENSOR_HV7131R, |
77 | SENSOR_MI0360, | 93 | SENSOR_MI0360, |
94 | SENSOR_MI0360B, | ||
78 | SENSOR_MO4000, | 95 | SENSOR_MO4000, |
79 | SENSOR_MT9V111, | 96 | SENSOR_MT9V111, |
80 | SENSOR_OM6802, | 97 | SENSOR_OM6802, |
@@ -87,49 +104,51 @@ enum sensors { | |||
87 | SENSOR_SP80708, | 104 | SENSOR_SP80708, |
88 | }; | 105 | }; |
89 | 106 | ||
107 | static void qual_upd(struct work_struct *work); | ||
108 | |||
109 | /* device flags */ | ||
110 | #define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */ | ||
111 | #define F_ILLUM 0x02 /* presence of illuminator */ | ||
112 | |||
113 | /* sn9c1xx definitions */ | ||
114 | /* register 0x01 */ | ||
115 | #define S_PWR_DN 0x01 /* sensor power down */ | ||
116 | #define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */ | ||
117 | #define V_TX_EN 0x04 /* video transfer enable */ | ||
118 | #define LED 0x08 /* output to pin LED */ | ||
119 | #define SCL_SEL_OD 0x20 /* open-drain mode */ | ||
120 | #define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */ | ||
121 | /* register 0x17 */ | ||
122 | #define MCK_SIZE_MASK 0x1f /* sensor master clock */ | ||
123 | #define SEN_CLK_EN 0x20 /* enable sensor clock */ | ||
124 | #define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */ | ||
125 | |||
90 | /* V4L2 controls supported by the driver */ | 126 | /* V4L2 controls supported by the driver */ |
91 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 127 | static void setbrightness(struct gspca_dev *gspca_dev); |
92 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 128 | static void setcontrast(struct gspca_dev *gspca_dev); |
93 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | 129 | static void setcolors(struct gspca_dev *gspca_dev); |
94 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | 130 | static void setredblue(struct gspca_dev *gspca_dev); |
95 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | 131 | static void setgamma(struct gspca_dev *gspca_dev); |
96 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 132 | static void setautogain(struct gspca_dev *gspca_dev); |
97 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); | 133 | static void sethvflip(struct gspca_dev *gspca_dev); |
98 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); | 134 | static void setsharpness(struct gspca_dev *gspca_dev); |
99 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); | 135 | static void setillum(struct gspca_dev *gspca_dev); |
100 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); | 136 | static void setfreq(struct gspca_dev *gspca_dev); |
101 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); | 137 | |
102 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); | 138 | static const struct ctrl sd_ctrls[NCTRLS] = { |
103 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 139 | [BRIGHTNESS] = { |
104 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | ||
105 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | ||
106 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
107 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | ||
108 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | ||
109 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); | ||
110 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); | ||
111 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
112 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
113 | |||
114 | static const struct ctrl sd_ctrls[] = { | ||
115 | #define BRIGHTNESS_IDX 0 | ||
116 | { | ||
117 | { | 140 | { |
118 | .id = V4L2_CID_BRIGHTNESS, | 141 | .id = V4L2_CID_BRIGHTNESS, |
119 | .type = V4L2_CTRL_TYPE_INTEGER, | 142 | .type = V4L2_CTRL_TYPE_INTEGER, |
120 | .name = "Brightness", | 143 | .name = "Brightness", |
121 | .minimum = 0, | 144 | .minimum = 0, |
122 | #define BRIGHTNESS_MAX 0xffff | 145 | .maximum = 0xff, |
123 | .maximum = BRIGHTNESS_MAX, | ||
124 | .step = 1, | 146 | .step = 1, |
125 | #define BRIGHTNESS_DEF 0x8000 | 147 | .default_value = 0x80, |
126 | .default_value = BRIGHTNESS_DEF, | ||
127 | }, | 148 | }, |
128 | .set = sd_setbrightness, | 149 | .set_control = setbrightness |
129 | .get = sd_getbrightness, | ||
130 | }, | 150 | }, |
131 | #define CONTRAST_IDX 1 | 151 | [CONTRAST] = { |
132 | { | ||
133 | { | 152 | { |
134 | .id = V4L2_CID_CONTRAST, | 153 | .id = V4L2_CID_CONTRAST, |
135 | .type = V4L2_CTRL_TYPE_INTEGER, | 154 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -138,14 +157,11 @@ static const struct ctrl sd_ctrls[] = { | |||
138 | #define CONTRAST_MAX 127 | 157 | #define CONTRAST_MAX 127 |
139 | .maximum = CONTRAST_MAX, | 158 | .maximum = CONTRAST_MAX, |
140 | .step = 1, | 159 | .step = 1, |
141 | #define CONTRAST_DEF 63 | 160 | .default_value = 63, |
142 | .default_value = CONTRAST_DEF, | ||
143 | }, | 161 | }, |
144 | .set = sd_setcontrast, | 162 | .set_control = setcontrast |
145 | .get = sd_getcontrast, | ||
146 | }, | 163 | }, |
147 | #define COLOR_IDX 2 | 164 | [COLORS] = { |
148 | { | ||
149 | { | 165 | { |
150 | .id = V4L2_CID_SATURATION, | 166 | .id = V4L2_CID_SATURATION, |
151 | .type = V4L2_CTRL_TYPE_INTEGER, | 167 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -153,14 +169,12 @@ static const struct ctrl sd_ctrls[] = { | |||
153 | .minimum = 0, | 169 | .minimum = 0, |
154 | .maximum = 40, | 170 | .maximum = 40, |
155 | .step = 1, | 171 | .step = 1, |
156 | #define COLOR_DEF 25 | 172 | #define COLORS_DEF 25 |
157 | .default_value = COLOR_DEF, | 173 | .default_value = COLORS_DEF, |
158 | }, | 174 | }, |
159 | .set = sd_setcolors, | 175 | .set_control = setcolors |
160 | .get = sd_getcolors, | ||
161 | }, | 176 | }, |
162 | #define BLUE_BALANCE_IDX 3 | 177 | [BLUE] = { |
163 | { | ||
164 | { | 178 | { |
165 | .id = V4L2_CID_BLUE_BALANCE, | 179 | .id = V4L2_CID_BLUE_BALANCE, |
166 | .type = V4L2_CTRL_TYPE_INTEGER, | 180 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -168,14 +182,11 @@ static const struct ctrl sd_ctrls[] = { | |||
168 | .minimum = 24, | 182 | .minimum = 24, |
169 | .maximum = 40, | 183 | .maximum = 40, |
170 | .step = 1, | 184 | .step = 1, |
171 | #define BLUE_BALANCE_DEF 32 | 185 | .default_value = 32, |
172 | .default_value = BLUE_BALANCE_DEF, | ||
173 | }, | 186 | }, |
174 | .set = sd_setblue_balance, | 187 | .set_control = setredblue |
175 | .get = sd_getblue_balance, | ||
176 | }, | 188 | }, |
177 | #define RED_BALANCE_IDX 4 | 189 | [RED] = { |
178 | { | ||
179 | { | 190 | { |
180 | .id = V4L2_CID_RED_BALANCE, | 191 | .id = V4L2_CID_RED_BALANCE, |
181 | .type = V4L2_CTRL_TYPE_INTEGER, | 192 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -183,14 +194,11 @@ static const struct ctrl sd_ctrls[] = { | |||
183 | .minimum = 24, | 194 | .minimum = 24, |
184 | .maximum = 40, | 195 | .maximum = 40, |
185 | .step = 1, | 196 | .step = 1, |
186 | #define RED_BALANCE_DEF 32 | 197 | .default_value = 32, |
187 | .default_value = RED_BALANCE_DEF, | ||
188 | }, | 198 | }, |
189 | .set = sd_setred_balance, | 199 | .set_control = setredblue |
190 | .get = sd_getred_balance, | ||
191 | }, | 200 | }, |
192 | #define GAMMA_IDX 5 | 201 | [GAMMA] = { |
193 | { | ||
194 | { | 202 | { |
195 | .id = V4L2_CID_GAMMA, | 203 | .id = V4L2_CID_GAMMA, |
196 | .type = V4L2_CTRL_TYPE_INTEGER, | 204 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -201,11 +209,9 @@ static const struct ctrl sd_ctrls[] = { | |||
201 | #define GAMMA_DEF 20 | 209 | #define GAMMA_DEF 20 |
202 | .default_value = GAMMA_DEF, | 210 | .default_value = GAMMA_DEF, |
203 | }, | 211 | }, |
204 | .set = sd_setgamma, | 212 | .set_control = setgamma |
205 | .get = sd_getgamma, | ||
206 | }, | 213 | }, |
207 | #define AUTOGAIN_IDX 6 | 214 | [AUTOGAIN] = { |
208 | { | ||
209 | { | 215 | { |
210 | .id = V4L2_CID_AUTOGAIN, | 216 | .id = V4L2_CID_AUTOGAIN, |
211 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 217 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -213,15 +219,23 @@ static const struct ctrl sd_ctrls[] = { | |||
213 | .minimum = 0, | 219 | .minimum = 0, |
214 | .maximum = 1, | 220 | .maximum = 1, |
215 | .step = 1, | 221 | .step = 1, |
216 | #define AUTOGAIN_DEF 1 | 222 | .default_value = 1 |
217 | .default_value = AUTOGAIN_DEF, | 223 | }, |
224 | .set_control = setautogain | ||
225 | }, | ||
226 | [HFLIP] = { | ||
227 | { | ||
228 | .id = V4L2_CID_HFLIP, | ||
229 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
230 | .name = "Mirror", | ||
231 | .minimum = 0, | ||
232 | .maximum = 1, | ||
233 | .step = 1, | ||
234 | .default_value = 0, | ||
218 | }, | 235 | }, |
219 | .set = sd_setautogain, | 236 | .set_control = sethvflip |
220 | .get = sd_getautogain, | ||
221 | }, | 237 | }, |
222 | /* ov7630/ov7648 only */ | 238 | [VFLIP] = { |
223 | #define VFLIP_IDX 7 | ||
224 | { | ||
225 | { | 239 | { |
226 | .id = V4L2_CID_VFLIP, | 240 | .id = V4L2_CID_VFLIP, |
227 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 241 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -229,14 +243,11 @@ static const struct ctrl sd_ctrls[] = { | |||
229 | .minimum = 0, | 243 | .minimum = 0, |
230 | .maximum = 1, | 244 | .maximum = 1, |
231 | .step = 1, | 245 | .step = 1, |
232 | #define VFLIP_DEF 0 | 246 | .default_value = 0, |
233 | .default_value = VFLIP_DEF, | ||
234 | }, | 247 | }, |
235 | .set = sd_setvflip, | 248 | .set_control = sethvflip |
236 | .get = sd_getvflip, | ||
237 | }, | 249 | }, |
238 | #define SHARPNESS_IDX 8 | 250 | [SHARPNESS] = { |
239 | { | ||
240 | { | 251 | { |
241 | .id = V4L2_CID_SHARPNESS, | 252 | .id = V4L2_CID_SHARPNESS, |
242 | .type = V4L2_CTRL_TYPE_INTEGER, | 253 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -244,31 +255,24 @@ static const struct ctrl sd_ctrls[] = { | |||
244 | .minimum = 0, | 255 | .minimum = 0, |
245 | .maximum = 255, | 256 | .maximum = 255, |
246 | .step = 1, | 257 | .step = 1, |
247 | #define SHARPNESS_DEF 90 | 258 | .default_value = 90, |
248 | .default_value = SHARPNESS_DEF, | ||
249 | }, | 259 | }, |
250 | .set = sd_setsharpness, | 260 | .set_control = setsharpness |
251 | .get = sd_getsharpness, | ||
252 | }, | 261 | }, |
253 | /* mt9v111 only */ | 262 | [ILLUM] = { |
254 | #define INFRARED_IDX 9 | ||
255 | { | ||
256 | { | 263 | { |
257 | .id = V4L2_CID_INFRARED, | 264 | .id = V4L2_CID_ILLUMINATORS_1, |
258 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 265 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
259 | .name = "Infrared", | 266 | .name = "Illuminator / infrared", |
260 | .minimum = 0, | 267 | .minimum = 0, |
261 | .maximum = 1, | 268 | .maximum = 1, |
262 | .step = 1, | 269 | .step = 1, |
263 | #define INFRARED_DEF 0 | 270 | .default_value = 0, |
264 | .default_value = INFRARED_DEF, | ||
265 | }, | 271 | }, |
266 | .set = sd_setinfrared, | 272 | .set_control = setillum |
267 | .get = sd_getinfrared, | ||
268 | }, | 273 | }, |
269 | /* ov7630/ov7648/ov7660 only */ | 274 | /* ov7630/ov7648/ov7660 only */ |
270 | #define FREQ_IDX 10 | 275 | [FREQ] = { |
271 | { | ||
272 | { | 276 | { |
273 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 277 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
274 | .type = V4L2_CTRL_TYPE_MENU, | 278 | .type = V4L2_CTRL_TYPE_MENU, |
@@ -276,69 +280,71 @@ static const struct ctrl sd_ctrls[] = { | |||
276 | .minimum = 0, | 280 | .minimum = 0, |
277 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | 281 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ |
278 | .step = 1, | 282 | .step = 1, |
279 | #define FREQ_DEF 1 | 283 | .default_value = 1, |
280 | .default_value = FREQ_DEF, | ||
281 | }, | 284 | }, |
282 | .set = sd_setfreq, | 285 | .set_control = setfreq |
283 | .get = sd_getfreq, | ||
284 | }, | 286 | }, |
285 | }; | 287 | }; |
286 | 288 | ||
287 | /* table of the disabled controls */ | 289 | /* table of the disabled controls */ |
288 | static const __u32 ctrl_dis[] = { | 290 | static const __u32 ctrl_dis[] = { |
289 | [SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) | | 291 | [SENSOR_ADCM1700] = (1 << AUTOGAIN) | |
290 | (1 << INFRARED_IDX) | | 292 | (1 << HFLIP) | |
291 | (1 << VFLIP_IDX) | | 293 | (1 << VFLIP) | |
292 | (1 << FREQ_IDX), | 294 | (1 << FREQ), |
293 | 295 | ||
294 | [SENSOR_GC0307] = (1 << INFRARED_IDX) | | 296 | [SENSOR_GC0307] = (1 << HFLIP) | |
295 | (1 << VFLIP_IDX) | | 297 | (1 << VFLIP) | |
296 | (1 << FREQ_IDX), | 298 | (1 << FREQ), |
297 | 299 | ||
298 | [SENSOR_HV7131R] = (1 << INFRARED_IDX) | | 300 | [SENSOR_HV7131R] = (1 << HFLIP) | |
299 | (1 << FREQ_IDX), | 301 | (1 << FREQ), |
300 | 302 | ||
301 | [SENSOR_MI0360] = (1 << INFRARED_IDX) | | 303 | [SENSOR_MI0360] = (1 << HFLIP) | |
302 | (1 << VFLIP_IDX) | | 304 | (1 << VFLIP) | |
303 | (1 << FREQ_IDX), | 305 | (1 << FREQ), |
304 | 306 | ||
305 | [SENSOR_MO4000] = (1 << INFRARED_IDX) | | 307 | [SENSOR_MI0360B] = (1 << HFLIP) | |
306 | (1 << VFLIP_IDX) | | 308 | (1 << VFLIP) | |
307 | (1 << FREQ_IDX), | 309 | (1 << FREQ), |
308 | 310 | ||
309 | [SENSOR_MT9V111] = (1 << VFLIP_IDX) | | 311 | [SENSOR_MO4000] = (1 << HFLIP) | |
310 | (1 << FREQ_IDX), | 312 | (1 << VFLIP) | |
311 | 313 | (1 << FREQ), | |
312 | [SENSOR_OM6802] = (1 << INFRARED_IDX) | | 314 | |
313 | (1 << VFLIP_IDX) | | 315 | [SENSOR_MT9V111] = (1 << HFLIP) | |
314 | (1 << FREQ_IDX), | 316 | (1 << VFLIP) | |
315 | 317 | (1 << FREQ), | |
316 | [SENSOR_OV7630] = (1 << INFRARED_IDX), | 318 | |
317 | 319 | [SENSOR_OM6802] = (1 << HFLIP) | | |
318 | [SENSOR_OV7648] = (1 << INFRARED_IDX), | 320 | (1 << VFLIP) | |
319 | 321 | (1 << FREQ), | |
320 | [SENSOR_OV7660] = (1 << AUTOGAIN_IDX) | | 322 | |
321 | (1 << INFRARED_IDX) | | 323 | [SENSOR_OV7630] = (1 << HFLIP), |
322 | (1 << VFLIP_IDX), | 324 | |
323 | 325 | [SENSOR_OV7648] = (1 << HFLIP), | |
324 | [SENSOR_PO1030] = (1 << AUTOGAIN_IDX) | | 326 | |
325 | (1 << INFRARED_IDX) | | 327 | [SENSOR_OV7660] = (1 << AUTOGAIN) | |
326 | (1 << VFLIP_IDX) | | 328 | (1 << HFLIP) | |
327 | (1 << FREQ_IDX), | 329 | (1 << VFLIP), |
328 | 330 | ||
329 | [SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) | | 331 | [SENSOR_PO1030] = (1 << AUTOGAIN) | |
330 | (1 << INFRARED_IDX) | | 332 | (1 << HFLIP) | |
331 | (1 << VFLIP_IDX) | | 333 | (1 << VFLIP) | |
332 | (1 << FREQ_IDX), | 334 | (1 << FREQ), |
333 | [SENSOR_SOI768] = (1 << AUTOGAIN_IDX) | | 335 | |
334 | (1 << INFRARED_IDX) | | 336 | [SENSOR_PO2030N] = (1 << AUTOGAIN) | |
335 | (1 << VFLIP_IDX) | | 337 | (1 << FREQ), |
336 | (1 << FREQ_IDX), | 338 | |
337 | 339 | [SENSOR_SOI768] = (1 << AUTOGAIN) | | |
338 | [SENSOR_SP80708] = (1 << AUTOGAIN_IDX) | | 340 | (1 << HFLIP) | |
339 | (1 << INFRARED_IDX) | | 341 | (1 << VFLIP) | |
340 | (1 << VFLIP_IDX) | | 342 | (1 << FREQ), |
341 | (1 << FREQ_IDX), | 343 | |
344 | [SENSOR_SP80708] = (1 << AUTOGAIN) | | ||
345 | (1 << HFLIP) | | ||
346 | (1 << VFLIP) | | ||
347 | (1 << FREQ), | ||
342 | }; | 348 | }; |
343 | 349 | ||
344 | static const struct v4l2_pix_format cif_mode[] = { | 350 | static const struct v4l2_pix_format cif_mode[] = { |
@@ -402,7 +408,7 @@ static const u8 sn_hv7131[0x1c] = { | |||
402 | 408 | ||
403 | static const u8 sn_mi0360[0x1c] = { | 409 | static const u8 sn_mi0360[0x1c] = { |
404 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 410 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
405 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, | 411 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
406 | /* reg8 reg9 rega regb regc regd rege regf */ | 412 | /* reg8 reg9 rega regb regc regd rege regf */ |
407 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 413 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
408 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 414 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
@@ -411,6 +417,17 @@ static const u8 sn_mi0360[0x1c] = { | |||
411 | 0x06, 0x00, 0x00, 0x00 | 417 | 0x06, 0x00, 0x00, 0x00 |
412 | }; | 418 | }; |
413 | 419 | ||
420 | static const u8 sn_mi0360b[0x1c] = { | ||
421 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
422 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, | ||
423 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
424 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
425 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
426 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40, | ||
427 | /* reg18 reg19 reg1a reg1b */ | ||
428 | 0x06, 0x00, 0x00, 0x00 | ||
429 | }; | ||
430 | |||
414 | static const u8 sn_mo4000[0x1c] = { | 431 | static const u8 sn_mo4000[0x1c] = { |
415 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 432 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
416 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, | 433 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, |
@@ -527,6 +544,7 @@ static const u8 *sn_tb[] = { | |||
527 | [SENSOR_GC0307] = sn_gc0307, | 544 | [SENSOR_GC0307] = sn_gc0307, |
528 | [SENSOR_HV7131R] = sn_hv7131, | 545 | [SENSOR_HV7131R] = sn_hv7131, |
529 | [SENSOR_MI0360] = sn_mi0360, | 546 | [SENSOR_MI0360] = sn_mi0360, |
547 | [SENSOR_MI0360B] = sn_mi0360b, | ||
530 | [SENSOR_MO4000] = sn_mo4000, | 548 | [SENSOR_MO4000] = sn_mo4000, |
531 | [SENSOR_MT9V111] = sn_mt9v111, | 549 | [SENSOR_MT9V111] = sn_mt9v111, |
532 | [SENSOR_OM6802] = sn_om6802, | 550 | [SENSOR_OM6802] = sn_om6802, |
@@ -572,20 +590,23 @@ static const u8 reg84[] = { | |||
572 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ | 590 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ |
573 | 0x00, 0x00, 0x00 /* YUV offsets */ | 591 | 0x00, 0x00, 0x00 /* YUV offsets */ |
574 | }; | 592 | }; |
593 | |||
594 | #define DELAY 0xdd | ||
595 | |||
575 | static const u8 adcm1700_sensor_init[][8] = { | 596 | static const u8 adcm1700_sensor_init[][8] = { |
576 | {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, | 597 | {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, |
577 | {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ | 598 | {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
578 | {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | 599 | {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
579 | {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, | 600 | {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, |
580 | {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | 601 | {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
581 | {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, | 602 | {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, |
582 | {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, | 603 | {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, |
583 | {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, | 604 | {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, |
584 | {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, | 605 | {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, |
585 | {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, | 606 | {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, |
586 | {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | 607 | {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
587 | {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, | 608 | {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, |
588 | {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, | 609 | {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
589 | {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, | 610 | {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, |
590 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, | 611 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, |
591 | {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, | 612 | {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, |
@@ -629,7 +650,7 @@ static const u8 gc0307_sensor_init[][8] = { | |||
629 | {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, | 650 | {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, |
630 | {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, | 651 | {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, |
631 | {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, | 652 | {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, |
632 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ | 653 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ |
633 | {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, | 654 | {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, |
634 | {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, | 655 | {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, |
635 | {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, | 656 | {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, |
@@ -747,6 +768,62 @@ static const u8 mi0360_sensor_init[][8] = { | |||
747 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ | 768 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
748 | {} | 769 | {} |
749 | }; | 770 | }; |
771 | static const u8 mi0360b_sensor_init[][8] = { | ||
772 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, | ||
773 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, | ||
774 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/ | ||
775 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
776 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/ | ||
777 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, | ||
778 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, | ||
779 | {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
780 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, | ||
781 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
782 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
783 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
784 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
785 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
786 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
787 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
788 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
789 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
790 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
791 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
792 | {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, | ||
793 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
794 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
795 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, | ||
796 | {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10}, | ||
797 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
798 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, | ||
799 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, | ||
800 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, | ||
801 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, | ||
802 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, | ||
803 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
804 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
805 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, | ||
806 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, | ||
807 | |||
808 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, | ||
809 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, | ||
810 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, | ||
811 | {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, | ||
812 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, | ||
813 | {} | ||
814 | }; | ||
815 | static const u8 mi0360b_sensor_param1[][8] = { | ||
816 | {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
817 | {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10}, | ||
818 | {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10}, | ||
819 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ | ||
820 | |||
821 | {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10}, | ||
822 | {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10}, | ||
823 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ | ||
824 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ | ||
825 | {} | ||
826 | }; | ||
750 | static const u8 mo4000_sensor_init[][8] = { | 827 | static const u8 mo4000_sensor_init[][8] = { |
751 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, | 828 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
752 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, | 829 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, |
@@ -772,23 +849,13 @@ static const u8 mo4000_sensor_init[][8] = { | |||
772 | }; | 849 | }; |
773 | static const u8 mt9v111_sensor_init[][8] = { | 850 | static const u8 mt9v111_sensor_init[][8] = { |
774 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ | 851 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ |
775 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 852 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
776 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, | 853 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
777 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ | 854 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ |
778 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ | 855 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ |
779 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ | 856 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ |
780 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, | ||
781 | {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10}, | ||
782 | {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10}, | ||
783 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | ||
784 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ | 857 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ |
785 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, | ||
786 | {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10}, | ||
787 | {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10}, | ||
788 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | ||
789 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
790 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ | 858 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ |
791 | {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10}, | ||
792 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ | 859 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ |
793 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ | 860 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ |
794 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ | 861 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ |
@@ -802,15 +869,10 @@ static const u8 mt9v111_sensor_init[][8] = { | |||
802 | {} | 869 | {} |
803 | }; | 870 | }; |
804 | static const u8 mt9v111_sensor_param1[][8] = { | 871 | static const u8 mt9v111_sensor_param1[][8] = { |
805 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | 872 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xad, 0x10}, /* G1 and B gains */ |
806 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | 873 | {0xd1, 0x5c, 0x2d, 0x00, 0xad, 0x00, 0x33, 0x10}, /* R and G2 gains */ |
807 | {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10}, | 874 | {0xb1, 0x5c, 0x06, 0x00, 0x40, 0x00, 0x00, 0x10}, /* vert blanking */ |
808 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */ | 875 | {0xb1, 0x5c, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10}, /* horiz blanking */ |
809 | {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */ | ||
810 | /*******/ | ||
811 | {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */ | ||
812 | {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */ | ||
813 | {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */ | ||
814 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ | 876 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ |
815 | {} | 877 | {} |
816 | }; | 878 | }; |
@@ -860,10 +922,10 @@ static const u8 om6802_sensor_param1[][8] = { | |||
860 | static const u8 ov7630_sensor_init[][8] = { | 922 | static const u8 ov7630_sensor_init[][8] = { |
861 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, | 923 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, |
862 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | 924 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
863 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 925 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
864 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | 926 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
865 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | 927 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
866 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 928 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
867 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | 929 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
868 | /* win: i2c_r from 00 to 80 */ | 930 | /* win: i2c_r from 00 to 80 */ |
869 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, | 931 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, |
@@ -917,7 +979,7 @@ static const u8 ov7630_sensor_param1[][8] = { | |||
917 | static const u8 ov7648_sensor_init[][8] = { | 979 | static const u8 ov7648_sensor_init[][8] = { |
918 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, | 980 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, |
919 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ | 981 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
920 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 982 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
921 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | 983 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
922 | {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, | 984 | {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, |
923 | {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, | 985 | {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, |
@@ -966,7 +1028,7 @@ static const u8 ov7648_sensor_param1[][8] = { | |||
966 | 1028 | ||
967 | static const u8 ov7660_sensor_init[][8] = { | 1029 | static const u8 ov7660_sensor_init[][8] = { |
968 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ | 1030 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
969 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 1031 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
970 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, | 1032 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
971 | /* Outformat = rawRGB */ | 1033 | /* Outformat = rawRGB */ |
972 | {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ | 1034 | {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ |
@@ -1062,7 +1124,7 @@ static const u8 ov7660_sensor_param1[][8] = { | |||
1062 | static const u8 po1030_sensor_init[][8] = { | 1124 | static const u8 po1030_sensor_init[][8] = { |
1063 | /* the sensor registers are described in m5602/m5602_po1030.h */ | 1125 | /* the sensor registers are described in m5602/m5602_po1030.h */ |
1064 | {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ | 1126 | {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ |
1065 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ | 1127 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
1066 | {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, | 1128 | {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, |
1067 | {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, | 1129 | {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
1068 | {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, | 1130 | {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, |
@@ -1116,10 +1178,10 @@ static const u8 po1030_sensor_param1[][8] = { | |||
1116 | static const u8 po2030n_sensor_init[][8] = { | 1178 | static const u8 po2030n_sensor_init[][8] = { |
1117 | {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, | 1179 | {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, |
1118 | {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, | 1180 | {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, |
1119 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ | 1181 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ |
1120 | {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, | 1182 | {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, |
1121 | {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, | 1183 | {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, |
1122 | {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ | 1184 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ |
1123 | {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, | 1185 | {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, |
1124 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, | 1186 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, |
1125 | {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, | 1187 | {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, |
@@ -1168,7 +1230,7 @@ static const u8 po2030n_sensor_init[][8] = { | |||
1168 | }; | 1230 | }; |
1169 | static const u8 po2030n_sensor_param1[][8] = { | 1231 | static const u8 po2030n_sensor_param1[][8] = { |
1170 | {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, | 1232 | {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, |
1171 | {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ | 1233 | {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ |
1172 | {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, | 1234 | {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, |
1173 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, | 1235 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, |
1174 | {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10}, | 1236 | {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10}, |
@@ -1182,16 +1244,16 @@ static const u8 po2030n_sensor_param1[][8] = { | |||
1182 | {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10}, | 1244 | {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10}, |
1183 | /*after start*/ | 1245 | /*after start*/ |
1184 | {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10}, | 1246 | {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
1185 | {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ | 1247 | {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ |
1186 | {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10}, | 1248 | {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10}, |
1187 | {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ | 1249 | {DELAY, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */ |
1188 | {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10}, | 1250 | {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10}, |
1189 | {} | 1251 | {} |
1190 | }; | 1252 | }; |
1191 | 1253 | ||
1192 | static const u8 soi768_sensor_init[][8] = { | 1254 | static const u8 soi768_sensor_init[][8] = { |
1193 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ | 1255 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
1194 | {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ | 1256 | {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ |
1195 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | 1257 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
1196 | {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, | 1258 | {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, |
1197 | {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, | 1259 | {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, |
@@ -1310,6 +1372,7 @@ static const u8 (*sensor_init[])[8] = { | |||
1310 | [SENSOR_GC0307] = gc0307_sensor_init, | 1372 | [SENSOR_GC0307] = gc0307_sensor_init, |
1311 | [SENSOR_HV7131R] = hv7131r_sensor_init, | 1373 | [SENSOR_HV7131R] = hv7131r_sensor_init, |
1312 | [SENSOR_MI0360] = mi0360_sensor_init, | 1374 | [SENSOR_MI0360] = mi0360_sensor_init, |
1375 | [SENSOR_MI0360B] = mi0360b_sensor_init, | ||
1313 | [SENSOR_MO4000] = mo4000_sensor_init, | 1376 | [SENSOR_MO4000] = mo4000_sensor_init, |
1314 | [SENSOR_MT9V111] = mt9v111_sensor_init, | 1377 | [SENSOR_MT9V111] = mt9v111_sensor_init, |
1315 | [SENSOR_OM6802] = om6802_sensor_init, | 1378 | [SENSOR_OM6802] = om6802_sensor_init, |
@@ -1326,13 +1389,17 @@ static const u8 (*sensor_init[])[8] = { | |||
1326 | static void reg_r(struct gspca_dev *gspca_dev, | 1389 | static void reg_r(struct gspca_dev *gspca_dev, |
1327 | u16 value, int len) | 1390 | u16 value, int len) |
1328 | { | 1391 | { |
1392 | int ret; | ||
1393 | |||
1394 | if (gspca_dev->usb_err < 0) | ||
1395 | return; | ||
1329 | #ifdef GSPCA_DEBUG | 1396 | #ifdef GSPCA_DEBUG |
1330 | if (len > USB_BUF_SZ) { | 1397 | if (len > USB_BUF_SZ) { |
1331 | err("reg_r: buffer overflow"); | 1398 | err("reg_r: buffer overflow"); |
1332 | return; | 1399 | return; |
1333 | } | 1400 | } |
1334 | #endif | 1401 | #endif |
1335 | usb_control_msg(gspca_dev->dev, | 1402 | ret = usb_control_msg(gspca_dev->dev, |
1336 | usb_rcvctrlpipe(gspca_dev->dev, 0), | 1403 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
1337 | 0, | 1404 | 0, |
1338 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 1405 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
@@ -1340,15 +1407,23 @@ static void reg_r(struct gspca_dev *gspca_dev, | |||
1340 | gspca_dev->usb_buf, len, | 1407 | gspca_dev->usb_buf, len, |
1341 | 500); | 1408 | 500); |
1342 | PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); | 1409 | PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); |
1410 | if (ret < 0) { | ||
1411 | err("reg_r err %d", ret); | ||
1412 | gspca_dev->usb_err = ret; | ||
1413 | } | ||
1343 | } | 1414 | } |
1344 | 1415 | ||
1345 | static void reg_w1(struct gspca_dev *gspca_dev, | 1416 | static void reg_w1(struct gspca_dev *gspca_dev, |
1346 | u16 value, | 1417 | u16 value, |
1347 | u8 data) | 1418 | u8 data) |
1348 | { | 1419 | { |
1420 | int ret; | ||
1421 | |||
1422 | if (gspca_dev->usb_err < 0) | ||
1423 | return; | ||
1349 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); | 1424 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); |
1350 | gspca_dev->usb_buf[0] = data; | 1425 | gspca_dev->usb_buf[0] = data; |
1351 | usb_control_msg(gspca_dev->dev, | 1426 | ret = usb_control_msg(gspca_dev->dev, |
1352 | usb_sndctrlpipe(gspca_dev->dev, 0), | 1427 | usb_sndctrlpipe(gspca_dev->dev, 0), |
1353 | 0x08, | 1428 | 0x08, |
1354 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 1429 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
@@ -1356,12 +1431,20 @@ static void reg_w1(struct gspca_dev *gspca_dev, | |||
1356 | 0, | 1431 | 0, |
1357 | gspca_dev->usb_buf, 1, | 1432 | gspca_dev->usb_buf, 1, |
1358 | 500); | 1433 | 500); |
1434 | if (ret < 0) { | ||
1435 | err("reg_w1 err %d", ret); | ||
1436 | gspca_dev->usb_err = ret; | ||
1437 | } | ||
1359 | } | 1438 | } |
1360 | static void reg_w(struct gspca_dev *gspca_dev, | 1439 | static void reg_w(struct gspca_dev *gspca_dev, |
1361 | u16 value, | 1440 | u16 value, |
1362 | const u8 *buffer, | 1441 | const u8 *buffer, |
1363 | int len) | 1442 | int len) |
1364 | { | 1443 | { |
1444 | int ret; | ||
1445 | |||
1446 | if (gspca_dev->usb_err < 0) | ||
1447 | return; | ||
1365 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", | 1448 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", |
1366 | value, buffer[0], buffer[1]); | 1449 | value, buffer[0], buffer[1]); |
1367 | #ifdef GSPCA_DEBUG | 1450 | #ifdef GSPCA_DEBUG |
@@ -1371,20 +1454,27 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
1371 | } | 1454 | } |
1372 | #endif | 1455 | #endif |
1373 | memcpy(gspca_dev->usb_buf, buffer, len); | 1456 | memcpy(gspca_dev->usb_buf, buffer, len); |
1374 | usb_control_msg(gspca_dev->dev, | 1457 | ret = usb_control_msg(gspca_dev->dev, |
1375 | usb_sndctrlpipe(gspca_dev->dev, 0), | 1458 | usb_sndctrlpipe(gspca_dev->dev, 0), |
1376 | 0x08, | 1459 | 0x08, |
1377 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 1460 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
1378 | value, 0, | 1461 | value, 0, |
1379 | gspca_dev->usb_buf, len, | 1462 | gspca_dev->usb_buf, len, |
1380 | 500); | 1463 | 500); |
1464 | if (ret < 0) { | ||
1465 | err("reg_w err %d", ret); | ||
1466 | gspca_dev->usb_err = ret; | ||
1467 | } | ||
1381 | } | 1468 | } |
1382 | 1469 | ||
1383 | /* I2C write 1 byte */ | 1470 | /* I2C write 1 byte */ |
1384 | static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) | 1471 | static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) |
1385 | { | 1472 | { |
1386 | struct sd *sd = (struct sd *) gspca_dev; | 1473 | struct sd *sd = (struct sd *) gspca_dev; |
1474 | int ret; | ||
1387 | 1475 | ||
1476 | if (gspca_dev->usb_err < 0) | ||
1477 | return; | ||
1388 | PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); | 1478 | PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); |
1389 | switch (sd->sensor) { | 1479 | switch (sd->sensor) { |
1390 | case SENSOR_ADCM1700: | 1480 | case SENSOR_ADCM1700: |
@@ -1403,7 +1493,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) | |||
1403 | gspca_dev->usb_buf[5] = 0; | 1493 | gspca_dev->usb_buf[5] = 0; |
1404 | gspca_dev->usb_buf[6] = 0; | 1494 | gspca_dev->usb_buf[6] = 0; |
1405 | gspca_dev->usb_buf[7] = 0x10; | 1495 | gspca_dev->usb_buf[7] = 0x10; |
1406 | usb_control_msg(gspca_dev->dev, | 1496 | ret = usb_control_msg(gspca_dev->dev, |
1407 | usb_sndctrlpipe(gspca_dev->dev, 0), | 1497 | usb_sndctrlpipe(gspca_dev->dev, 0), |
1408 | 0x08, | 1498 | 0x08, |
1409 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 1499 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
@@ -1411,16 +1501,24 @@ static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) | |||
1411 | 0, | 1501 | 0, |
1412 | gspca_dev->usb_buf, 8, | 1502 | gspca_dev->usb_buf, 8, |
1413 | 500); | 1503 | 500); |
1504 | if (ret < 0) { | ||
1505 | err("i2c_w1 err %d", ret); | ||
1506 | gspca_dev->usb_err = ret; | ||
1507 | } | ||
1414 | } | 1508 | } |
1415 | 1509 | ||
1416 | /* I2C write 8 bytes */ | 1510 | /* I2C write 8 bytes */ |
1417 | static void i2c_w8(struct gspca_dev *gspca_dev, | 1511 | static void i2c_w8(struct gspca_dev *gspca_dev, |
1418 | const u8 *buffer) | 1512 | const u8 *buffer) |
1419 | { | 1513 | { |
1514 | int ret; | ||
1515 | |||
1516 | if (gspca_dev->usb_err < 0) | ||
1517 | return; | ||
1420 | PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", | 1518 | PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", |
1421 | buffer[2], buffer[3]); | 1519 | buffer[2], buffer[3]); |
1422 | memcpy(gspca_dev->usb_buf, buffer, 8); | 1520 | memcpy(gspca_dev->usb_buf, buffer, 8); |
1423 | usb_control_msg(gspca_dev->dev, | 1521 | ret = usb_control_msg(gspca_dev->dev, |
1424 | usb_sndctrlpipe(gspca_dev->dev, 0), | 1522 | usb_sndctrlpipe(gspca_dev->dev, 0), |
1425 | 0x08, | 1523 | 0x08, |
1426 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 1524 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
@@ -1428,6 +1526,10 @@ static void i2c_w8(struct gspca_dev *gspca_dev, | |||
1428 | gspca_dev->usb_buf, 8, | 1526 | gspca_dev->usb_buf, 8, |
1429 | 500); | 1527 | 500); |
1430 | msleep(2); | 1528 | msleep(2); |
1529 | if (ret < 0) { | ||
1530 | err("i2c_w8 err %d", ret); | ||
1531 | gspca_dev->usb_err = ret; | ||
1532 | } | ||
1431 | } | 1533 | } |
1432 | 1534 | ||
1433 | /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ | 1535 | /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ |
@@ -1466,7 +1568,7 @@ static void i2c_w_seq(struct gspca_dev *gspca_dev, | |||
1466 | const u8 (*data)[8]) | 1568 | const u8 (*data)[8]) |
1467 | { | 1569 | { |
1468 | while ((*data)[0] != 0) { | 1570 | while ((*data)[0] != 0) { |
1469 | if ((*data)[0] != 0xdd) | 1571 | if ((*data)[0] != DELAY) |
1470 | i2c_w8(gspca_dev, *data); | 1572 | i2c_w8(gspca_dev, *data); |
1471 | else | 1573 | else |
1472 | msleep((*data)[1]); | 1574 | msleep((*data)[1]); |
@@ -1474,22 +1576,22 @@ static void i2c_w_seq(struct gspca_dev *gspca_dev, | |||
1474 | } | 1576 | } |
1475 | } | 1577 | } |
1476 | 1578 | ||
1579 | /* check the ID of the hv7131 sensor */ | ||
1580 | /* this sequence is needed because it activates the sensor */ | ||
1477 | static void hv7131r_probe(struct gspca_dev *gspca_dev) | 1581 | static void hv7131r_probe(struct gspca_dev *gspca_dev) |
1478 | { | 1582 | { |
1479 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ | 1583 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ |
1480 | msleep(10); | 1584 | msleep(10); |
1481 | reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ | 1585 | reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ |
1482 | msleep(10); | 1586 | msleep(10); |
1483 | i2c_r(gspca_dev, 0, 5); /* read sensor id */ | 1587 | i2c_r(gspca_dev, 0, 5); /* read sensor id */ |
1484 | if (gspca_dev->usb_buf[0] == 0x02 | 1588 | if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */ |
1485 | && gspca_dev->usb_buf[1] == 0x09 | 1589 | && gspca_dev->usb_buf[1] == 0x09 |
1486 | && gspca_dev->usb_buf[2] == 0x01 | 1590 | && gspca_dev->usb_buf[2] == 0x01) { |
1487 | && gspca_dev->usb_buf[3] == 0x00 | 1591 | PDEBUG(D_PROBE, "Sensor HV7131R found"); |
1488 | && gspca_dev->usb_buf[4] == 0x00) { | ||
1489 | PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found"); | ||
1490 | return; | 1592 | return; |
1491 | } | 1593 | } |
1492 | PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found", | 1594 | warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x", |
1493 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], | 1595 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], |
1494 | gspca_dev->usb_buf[2]); | 1596 | gspca_dev->usb_buf[2]); |
1495 | } | 1597 | } |
@@ -1529,7 +1631,13 @@ static void mi0360_probe(struct gspca_dev *gspca_dev) | |||
1529 | if (val != 0xffff) | 1631 | if (val != 0xffff) |
1530 | break; | 1632 | break; |
1531 | } | 1633 | } |
1634 | if (gspca_dev->usb_err < 0) | ||
1635 | return; | ||
1532 | switch (val) { | 1636 | switch (val) { |
1637 | case 0x8221: | ||
1638 | PDEBUG(D_PROBE, "Sensor mi0360b"); | ||
1639 | sd->sensor = SENSOR_MI0360B; | ||
1640 | break; | ||
1533 | case 0x823a: | 1641 | case 0x823a: |
1534 | PDEBUG(D_PROBE, "Sensor mt9v111"); | 1642 | PDEBUG(D_PROBE, "Sensor mt9v111"); |
1535 | sd->sensor = SENSOR_MT9V111; | 1643 | sd->sensor = SENSOR_MT9V111; |
@@ -1556,6 +1664,8 @@ static void ov7630_probe(struct gspca_dev *gspca_dev) | |||
1556 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | 1664 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
1557 | reg_w1(gspca_dev, 0x01, 0x29); | 1665 | reg_w1(gspca_dev, 0x01, 0x29); |
1558 | reg_w1(gspca_dev, 0x17, 0x42); | 1666 | reg_w1(gspca_dev, 0x17, 0x42); |
1667 | if (gspca_dev->usb_err < 0) | ||
1668 | return; | ||
1559 | if (val == 0x7628) { /* soi768 */ | 1669 | if (val == 0x7628) { /* soi768 */ |
1560 | sd->sensor = SENSOR_SOI768; | 1670 | sd->sensor = SENSOR_SOI768; |
1561 | /*fixme: only valid for 0c45:613e?*/ | 1671 | /*fixme: only valid for 0c45:613e?*/ |
@@ -1593,13 +1703,14 @@ static void ov7648_probe(struct gspca_dev *gspca_dev) | |||
1593 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | 1703 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
1594 | reg_w1(gspca_dev, 0x01, 0x29); | 1704 | reg_w1(gspca_dev, 0x01, 0x29); |
1595 | reg_w1(gspca_dev, 0x17, 0x42); | 1705 | reg_w1(gspca_dev, 0x17, 0x42); |
1706 | if (gspca_dev->usb_err < 0) | ||
1707 | return; | ||
1596 | if (val == 0x1030) { /* po1030 */ | 1708 | if (val == 0x1030) { /* po1030 */ |
1597 | PDEBUG(D_PROBE, "Sensor po1030"); | 1709 | PDEBUG(D_PROBE, "Sensor po1030"); |
1598 | sd->sensor = SENSOR_PO1030; | 1710 | sd->sensor = SENSOR_PO1030; |
1599 | return; | 1711 | return; |
1600 | } | 1712 | } |
1601 | 1713 | err("Unknown sensor %04x", val); | |
1602 | PDEBUG(D_PROBE, "Unknown sensor %04x", val); | ||
1603 | } | 1714 | } |
1604 | 1715 | ||
1605 | /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ | 1716 | /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ |
@@ -1631,141 +1742,13 @@ static void po2030n_probe(struct gspca_dev *gspca_dev) | |||
1631 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | 1742 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
1632 | reg_w1(gspca_dev, 0x01, 0x29); | 1743 | reg_w1(gspca_dev, 0x01, 0x29); |
1633 | reg_w1(gspca_dev, 0x17, 0x42); | 1744 | reg_w1(gspca_dev, 0x17, 0x42); |
1745 | if (gspca_dev->usb_err < 0) | ||
1746 | return; | ||
1634 | if (val == 0x2030) { | 1747 | if (val == 0x2030) { |
1635 | PDEBUG(D_PROBE, "Sensor po2030n"); | 1748 | PDEBUG(D_PROBE, "Sensor po2030n"); |
1636 | /* sd->sensor = SENSOR_PO2030N; */ | 1749 | /* sd->sensor = SENSOR_PO2030N; */ |
1637 | } else { | 1750 | } else { |
1638 | PDEBUG(D_PROBE, "Unknown sensor ID %04x", val); | 1751 | err("Unknown sensor ID %04x", val); |
1639 | } | ||
1640 | } | ||
1641 | |||
1642 | static void bridge_init(struct gspca_dev *gspca_dev, | ||
1643 | const u8 *sn9c1xx) | ||
1644 | { | ||
1645 | struct sd *sd = (struct sd *) gspca_dev; | ||
1646 | u8 reg0102[2]; | ||
1647 | const u8 *reg9a; | ||
1648 | static const u8 reg9a_def[] = | ||
1649 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; | ||
1650 | static const u8 reg9a_spec[] = | ||
1651 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | ||
1652 | static const u8 regd4[] = {0x60, 0x00, 0x00}; | ||
1653 | |||
1654 | /* sensor clock already enabled in sd_init */ | ||
1655 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | ||
1656 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | ||
1657 | |||
1658 | /* configure gpio */ | ||
1659 | reg0102[0] = sn9c1xx[1]; | ||
1660 | reg0102[1] = sn9c1xx[2]; | ||
1661 | if (gspca_dev->audio) | ||
1662 | reg0102[1] |= 0x04; /* keep the audio connection */ | ||
1663 | reg_w(gspca_dev, 0x01, reg0102, 2); | ||
1664 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); | ||
1665 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); | ||
1666 | switch (sd->sensor) { | ||
1667 | case SENSOR_GC0307: | ||
1668 | case SENSOR_OV7660: | ||
1669 | case SENSOR_PO1030: | ||
1670 | case SENSOR_PO2030N: | ||
1671 | case SENSOR_SOI768: | ||
1672 | case SENSOR_SP80708: | ||
1673 | reg9a = reg9a_spec; | ||
1674 | break; | ||
1675 | default: | ||
1676 | reg9a = reg9a_def; | ||
1677 | break; | ||
1678 | } | ||
1679 | reg_w(gspca_dev, 0x9a, reg9a, 6); | ||
1680 | |||
1681 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); | ||
1682 | |||
1683 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | ||
1684 | |||
1685 | switch (sd->sensor) { | ||
1686 | case SENSOR_ADCM1700: | ||
1687 | reg_w1(gspca_dev, 0x01, 0x43); | ||
1688 | reg_w1(gspca_dev, 0x17, 0x62); | ||
1689 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1690 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1691 | break; | ||
1692 | case SENSOR_GC0307: | ||
1693 | msleep(50); | ||
1694 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1695 | reg_w1(gspca_dev, 0x17, 0x22); | ||
1696 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1697 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1698 | msleep(50); | ||
1699 | break; | ||
1700 | case SENSOR_MT9V111: | ||
1701 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1702 | reg_w1(gspca_dev, 0x17, 0x61); | ||
1703 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1704 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1705 | break; | ||
1706 | case SENSOR_OM6802: | ||
1707 | msleep(10); | ||
1708 | reg_w1(gspca_dev, 0x02, 0x73); | ||
1709 | reg_w1(gspca_dev, 0x17, 0x60); | ||
1710 | reg_w1(gspca_dev, 0x01, 0x22); | ||
1711 | msleep(100); | ||
1712 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1713 | reg_w1(gspca_dev, 0x17, 0x64); | ||
1714 | reg_w1(gspca_dev, 0x17, 0x64); | ||
1715 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1716 | msleep(10); | ||
1717 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1718 | i2c_w8(gspca_dev, om6802_init0[0]); | ||
1719 | i2c_w8(gspca_dev, om6802_init0[1]); | ||
1720 | msleep(15); | ||
1721 | reg_w1(gspca_dev, 0x02, 0x71); | ||
1722 | msleep(150); | ||
1723 | break; | ||
1724 | case SENSOR_OV7630: | ||
1725 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1726 | reg_w1(gspca_dev, 0x17, 0xe2); | ||
1727 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1728 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1729 | break; | ||
1730 | case SENSOR_OV7648: | ||
1731 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1732 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1733 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1734 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1735 | break; | ||
1736 | case SENSOR_PO1030: | ||
1737 | case SENSOR_SOI768: | ||
1738 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1739 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1740 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1741 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1742 | break; | ||
1743 | case SENSOR_PO2030N: | ||
1744 | case SENSOR_OV7660: | ||
1745 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1746 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1747 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1748 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1749 | break; | ||
1750 | case SENSOR_SP80708: | ||
1751 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1752 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1753 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1754 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1755 | msleep(100); | ||
1756 | reg_w1(gspca_dev, 0x02, 0x62); | ||
1757 | break; | ||
1758 | default: | ||
1759 | /* case SENSOR_HV7131R: */ | ||
1760 | /* case SENSOR_MI0360: */ | ||
1761 | /* case SENSOR_MO4000: */ | ||
1762 | reg_w1(gspca_dev, 0x01, 0x43); | ||
1763 | reg_w1(gspca_dev, 0x17, 0x61); | ||
1764 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1765 | if (sd->sensor == SENSOR_HV7131R | ||
1766 | && sd->bridge == BRIDGE_SN9C102P) | ||
1767 | hv7131r_probe(gspca_dev); | ||
1768 | break; | ||
1769 | } | 1752 | } |
1770 | } | 1753 | } |
1771 | 1754 | ||
@@ -1777,7 +1760,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1777 | struct cam *cam; | 1760 | struct cam *cam; |
1778 | 1761 | ||
1779 | sd->bridge = id->driver_info >> 16; | 1762 | sd->bridge = id->driver_info >> 16; |
1780 | sd->sensor = id->driver_info; | 1763 | sd->sensor = id->driver_info >> 8; |
1764 | sd->flags = id->driver_info; | ||
1781 | 1765 | ||
1782 | cam = &gspca_dev->cam; | 1766 | cam = &gspca_dev->cam; |
1783 | if (sd->sensor == SENSOR_ADCM1700) { | 1767 | if (sd->sensor == SENSOR_ADCM1700) { |
@@ -1788,28 +1772,16 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1788 | cam->nmodes = ARRAY_SIZE(vga_mode); | 1772 | cam->nmodes = ARRAY_SIZE(vga_mode); |
1789 | } | 1773 | } |
1790 | cam->npkt = 24; /* 24 packets per ISOC message */ | 1774 | cam->npkt = 24; /* 24 packets per ISOC message */ |
1775 | cam->ctrls = sd->ctrls; | ||
1791 | 1776 | ||
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; | 1777 | 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; | 1778 | sd->quality = QUALITY_DEF; |
1812 | sd->jpegqual = 80; | 1779 | |
1780 | /* if USB 1.1, let some bandwidth for the audio device */ | ||
1781 | if (gspca_dev->audio && gspca_dev->dev->speed < USB_SPEED_HIGH) | ||
1782 | gspca_dev->nbalt--; | ||
1783 | |||
1784 | INIT_WORK(&sd->work, qual_upd); | ||
1813 | 1785 | ||
1814 | return 0; | 1786 | return 0; |
1815 | } | 1787 | } |
@@ -1819,58 +1791,60 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1819 | { | 1791 | { |
1820 | struct sd *sd = (struct sd *) gspca_dev; | 1792 | struct sd *sd = (struct sd *) gspca_dev; |
1821 | const u8 *sn9c1xx; | 1793 | const u8 *sn9c1xx; |
1822 | u8 regGpio[] = { 0x29, 0x74 }; /* with audio */ | 1794 | u8 regGpio[] = { 0x29, 0x70 }; /* no audio */ |
1823 | u8 regF1; | 1795 | u8 regF1; |
1824 | 1796 | ||
1825 | /* setup a selector by bridge */ | 1797 | /* setup a selector by bridge */ |
1826 | reg_w1(gspca_dev, 0xf1, 0x01); | 1798 | reg_w1(gspca_dev, 0xf1, 0x01); |
1827 | reg_r(gspca_dev, 0x00, 1); | 1799 | reg_r(gspca_dev, 0x00, 1); |
1828 | reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); | 1800 | reg_w1(gspca_dev, 0xf1, 0x00); |
1829 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ | 1801 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ |
1830 | regF1 = gspca_dev->usb_buf[0]; | 1802 | regF1 = gspca_dev->usb_buf[0]; |
1803 | if (gspca_dev->usb_err < 0) | ||
1804 | return gspca_dev->usb_err; | ||
1831 | PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); | 1805 | PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); |
1806 | if (gspca_dev->audio) | ||
1807 | regGpio[1] |= 0x04; /* with audio */ | ||
1832 | switch (sd->bridge) { | 1808 | switch (sd->bridge) { |
1833 | case BRIDGE_SN9C102P: | 1809 | case BRIDGE_SN9C102P: |
1834 | if (regF1 != 0x11) | ||
1835 | return -ENODEV; | ||
1836 | reg_w1(gspca_dev, 0x02, regGpio[1]); | ||
1837 | break; | ||
1838 | case BRIDGE_SN9C105: | 1810 | case BRIDGE_SN9C105: |
1839 | if (regF1 != 0x11) | 1811 | if (regF1 != 0x11) |
1840 | return -ENODEV; | 1812 | return -ENODEV; |
1841 | if (sd->sensor == SENSOR_MI0360) | ||
1842 | mi0360_probe(gspca_dev); | ||
1843 | reg_w(gspca_dev, 0x01, regGpio, 2); | ||
1844 | break; | ||
1845 | case BRIDGE_SN9C120: | ||
1846 | if (regF1 != 0x12) | ||
1847 | return -ENODEV; | ||
1848 | switch (sd->sensor) { | ||
1849 | case SENSOR_MI0360: | ||
1850 | mi0360_probe(gspca_dev); | ||
1851 | break; | ||
1852 | case SENSOR_OV7630: | ||
1853 | ov7630_probe(gspca_dev); | ||
1854 | break; | ||
1855 | case SENSOR_OV7648: | ||
1856 | ov7648_probe(gspca_dev); | ||
1857 | break; | ||
1858 | case SENSOR_PO2030N: | ||
1859 | po2030n_probe(gspca_dev); | ||
1860 | break; | ||
1861 | } | ||
1862 | regGpio[1] = 0x70; /* no audio */ | ||
1863 | reg_w(gspca_dev, 0x01, regGpio, 2); | ||
1864 | break; | 1813 | break; |
1865 | default: | 1814 | default: |
1866 | /* case BRIDGE_SN9C110: */ | 1815 | /* case BRIDGE_SN9C110: */ |
1867 | /* case BRIDGE_SN9C325: */ | 1816 | /* case BRIDGE_SN9C120: */ |
1868 | if (regF1 != 0x12) | 1817 | if (regF1 != 0x12) |
1869 | return -ENODEV; | 1818 | return -ENODEV; |
1870 | reg_w1(gspca_dev, 0x02, 0x62); | 1819 | } |
1820 | |||
1821 | switch (sd->sensor) { | ||
1822 | case SENSOR_MI0360: | ||
1823 | mi0360_probe(gspca_dev); | ||
1824 | break; | ||
1825 | case SENSOR_OV7630: | ||
1826 | ov7630_probe(gspca_dev); | ||
1827 | break; | ||
1828 | case SENSOR_OV7648: | ||
1829 | ov7648_probe(gspca_dev); | ||
1830 | break; | ||
1831 | case SENSOR_PO2030N: | ||
1832 | po2030n_probe(gspca_dev); | ||
1871 | break; | 1833 | break; |
1872 | } | 1834 | } |
1873 | 1835 | ||
1836 | switch (sd->bridge) { | ||
1837 | case BRIDGE_SN9C102P: | ||
1838 | reg_w1(gspca_dev, 0x02, regGpio[1]); | ||
1839 | break; | ||
1840 | default: | ||
1841 | reg_w(gspca_dev, 0x01, regGpio, 2); | ||
1842 | break; | ||
1843 | } | ||
1844 | |||
1845 | if (sd->sensor == SENSOR_OM6802) | ||
1846 | sd->ctrls[SHARPNESS].def = 0x10; | ||
1847 | |||
1874 | /* Note we do not disable the sensor clock here (power saving mode), | 1848 | /* Note we do not disable the sensor clock here (power saving mode), |
1875 | as that also disables the button on the cam. */ | 1849 | as that also disables the button on the cam. */ |
1876 | reg_w1(gspca_dev, 0xf1, 0x00); | 1850 | reg_w1(gspca_dev, 0xf1, 0x00); |
@@ -1880,8 +1854,10 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1880 | sd->i2c_addr = sn9c1xx[9]; | 1854 | sd->i2c_addr = sn9c1xx[9]; |
1881 | 1855 | ||
1882 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; | 1856 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
1857 | if (!(sd->flags & F_ILLUM)) | ||
1858 | gspca_dev->ctrl_dis |= (1 << ILLUM); | ||
1883 | 1859 | ||
1884 | return 0; | 1860 | return gspca_dev->usb_err; |
1885 | } | 1861 | } |
1886 | 1862 | ||
1887 | static u32 setexposure(struct gspca_dev *gspca_dev, | 1863 | static u32 setexposure(struct gspca_dev *gspca_dev, |
@@ -1912,7 +1888,8 @@ static u32 setexposure(struct gspca_dev *gspca_dev, | |||
1912 | i2c_w8(gspca_dev, Expodoit); | 1888 | i2c_w8(gspca_dev, Expodoit); |
1913 | break; | 1889 | break; |
1914 | } | 1890 | } |
1915 | case SENSOR_MI0360: { | 1891 | case SENSOR_MI0360: |
1892 | case SENSOR_MI0360B: { | ||
1916 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ | 1893 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ |
1917 | { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; | 1894 | { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; |
1918 | static const u8 doit[] = /* update sensor */ | 1895 | static const u8 doit[] = /* update sensor */ |
@@ -1959,10 +1936,10 @@ static u32 setexposure(struct gspca_dev *gspca_dev, | |||
1959 | u8 expo_c1[] = | 1936 | u8 expo_c1[] = |
1960 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; | 1937 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
1961 | 1938 | ||
1962 | if (expo > 0x0280) | 1939 | if (expo > 0x0390) |
1963 | expo = 0x0280; | 1940 | expo = 0x0390; |
1964 | else if (expo < 0x0040) | 1941 | else if (expo < 0x0060) |
1965 | expo = 0x0040; | 1942 | expo = 0x0060; |
1966 | expo_c1[3] = expo >> 8; | 1943 | expo_c1[3] = expo >> 8; |
1967 | expo_c1[4] = expo; | 1944 | expo_c1[4] = expo; |
1968 | i2c_w8(gspca_dev, expo_c1); | 1945 | i2c_w8(gspca_dev, expo_c1); |
@@ -1991,16 +1968,18 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1991 | { | 1968 | { |
1992 | struct sd *sd = (struct sd *) gspca_dev; | 1969 | struct sd *sd = (struct sd *) gspca_dev; |
1993 | unsigned int expo; | 1970 | unsigned int expo; |
1971 | int brightness; | ||
1994 | u8 k2; | 1972 | u8 k2; |
1995 | 1973 | ||
1996 | k2 = ((int) sd->brightness - 0x8000) >> 10; | 1974 | brightness = sd->ctrls[BRIGHTNESS].val; |
1975 | k2 = (brightness - 0x80) >> 2; | ||
1997 | switch (sd->sensor) { | 1976 | switch (sd->sensor) { |
1998 | case SENSOR_ADCM1700: | 1977 | case SENSOR_ADCM1700: |
1999 | if (k2 > 0x1f) | 1978 | if (k2 > 0x1f) |
2000 | k2 = 0; /* only positive Y offset */ | 1979 | k2 = 0; /* only positive Y offset */ |
2001 | break; | 1980 | break; |
2002 | case SENSOR_HV7131R: | 1981 | case SENSOR_HV7131R: |
2003 | expo = sd->brightness << 4; | 1982 | expo = brightness << 12; |
2004 | if (expo > 0x002dc6c0) | 1983 | if (expo > 0x002dc6c0) |
2005 | expo = 0x002dc6c0; | 1984 | expo = 0x002dc6c0; |
2006 | else if (expo < 0x02a0) | 1985 | else if (expo < 0x02a0) |
@@ -2009,18 +1988,25 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
2009 | break; | 1988 | break; |
2010 | case SENSOR_MI0360: | 1989 | case SENSOR_MI0360: |
2011 | case SENSOR_MO4000: | 1990 | case SENSOR_MO4000: |
2012 | expo = sd->brightness >> 4; | 1991 | expo = brightness << 4; |
1992 | sd->exposure = setexposure(gspca_dev, expo); | ||
1993 | break; | ||
1994 | case SENSOR_MI0360B: | ||
1995 | expo = brightness << 2; | ||
2013 | sd->exposure = setexposure(gspca_dev, expo); | 1996 | sd->exposure = setexposure(gspca_dev, expo); |
2014 | break; | 1997 | break; |
2015 | case SENSOR_GC0307: | 1998 | case SENSOR_GC0307: |
1999 | expo = brightness; | ||
2000 | sd->exposure = setexposure(gspca_dev, expo); | ||
2001 | return; /* don't set the Y offset */ | ||
2016 | case SENSOR_MT9V111: | 2002 | case SENSOR_MT9V111: |
2017 | expo = sd->brightness >> 8; | 2003 | expo = brightness << 2; |
2018 | sd->exposure = setexposure(gspca_dev, expo); | 2004 | sd->exposure = setexposure(gspca_dev, expo); |
2019 | return; /* don't set the Y offset */ | 2005 | return; /* don't set the Y offset */ |
2020 | case SENSOR_OM6802: | 2006 | case SENSOR_OM6802: |
2021 | expo = sd->brightness >> 6; | 2007 | expo = brightness << 2; |
2022 | sd->exposure = setexposure(gspca_dev, expo); | 2008 | sd->exposure = setexposure(gspca_dev, expo); |
2023 | k2 = sd->brightness >> 11; | 2009 | k2 = brightness >> 3; |
2024 | break; | 2010 | break; |
2025 | } | 2011 | } |
2026 | 2012 | ||
@@ -2033,7 +2019,8 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
2033 | u8 k2; | 2019 | u8 k2; |
2034 | u8 contrast[6]; | 2020 | u8 contrast[6]; |
2035 | 2021 | ||
2036 | k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ | 2022 | k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1) |
2023 | + 0x10; /* 10..40 */ | ||
2037 | contrast[0] = (k2 + 1) / 2; /* red */ | 2024 | contrast[0] = (k2 + 1) / 2; /* red */ |
2038 | contrast[1] = 0; | 2025 | contrast[1] = 0; |
2039 | contrast[2] = k2; /* green */ | 2026 | contrast[2] = k2; /* green */ |
@@ -2046,15 +2033,25 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
2046 | static void setcolors(struct gspca_dev *gspca_dev) | 2033 | static void setcolors(struct gspca_dev *gspca_dev) |
2047 | { | 2034 | { |
2048 | struct sd *sd = (struct sd *) gspca_dev; | 2035 | struct sd *sd = (struct sd *) gspca_dev; |
2049 | int i, v; | 2036 | int i, v, colors; |
2037 | const s16 *uv; | ||
2050 | u8 reg8a[12]; /* U & V gains */ | 2038 | u8 reg8a[12]; /* U & V gains */ |
2051 | static const s16 uv[6] = { /* same as reg84 in signed decimal */ | 2039 | static const s16 uv_com[6] = { /* same as reg84 in signed decimal */ |
2052 | -24, -38, 64, /* UR UG UB */ | 2040 | -24, -38, 64, /* UR UG UB */ |
2053 | 62, -51, -9 /* VR VG VB */ | 2041 | 62, -51, -9 /* VR VG VB */ |
2054 | }; | 2042 | }; |
2043 | static const s16 uv_mi0360b[6] = { | ||
2044 | -20, -38, 64, /* UR UG UB */ | ||
2045 | 60, -51, -9 /* VR VG VB */ | ||
2046 | }; | ||
2055 | 2047 | ||
2048 | colors = sd->ctrls[COLORS].val; | ||
2049 | if (sd->sensor == SENSOR_MI0360B) | ||
2050 | uv = uv_mi0360b; | ||
2051 | else | ||
2052 | uv = uv_com; | ||
2056 | for (i = 0; i < 6; i++) { | 2053 | for (i = 0; i < 6; i++) { |
2057 | v = uv[i] * sd->colors / COLOR_DEF; | 2054 | v = uv[i] * colors / COLORS_DEF; |
2058 | reg8a[i * 2] = v; | 2055 | reg8a[i * 2] = v; |
2059 | reg8a[i * 2 + 1] = (v >> 8) & 0x0f; | 2056 | reg8a[i * 2 + 1] = (v >> 8) & 0x0f; |
2060 | } | 2057 | } |
@@ -2065,15 +2062,15 @@ static void setredblue(struct gspca_dev *gspca_dev) | |||
2065 | { | 2062 | { |
2066 | struct sd *sd = (struct sd *) gspca_dev; | 2063 | struct sd *sd = (struct sd *) gspca_dev; |
2067 | 2064 | ||
2068 | reg_w1(gspca_dev, 0x05, sd->red); | 2065 | reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val); |
2069 | /* reg_w1(gspca_dev, 0x07, 32); */ | 2066 | /* reg_w1(gspca_dev, 0x07, 32); */ |
2070 | reg_w1(gspca_dev, 0x06, sd->blue); | 2067 | reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val); |
2071 | } | 2068 | } |
2072 | 2069 | ||
2073 | static void setgamma(struct gspca_dev *gspca_dev) | 2070 | static void setgamma(struct gspca_dev *gspca_dev) |
2074 | { | 2071 | { |
2075 | struct sd *sd = (struct sd *) gspca_dev; | 2072 | struct sd *sd = (struct sd *) gspca_dev; |
2076 | int i; | 2073 | int i, val; |
2077 | u8 gamma[17]; | 2074 | u8 gamma[17]; |
2078 | const u8 *gamma_base; | 2075 | const u8 *gamma_base; |
2079 | static const u8 delta[17] = { | 2076 | static const u8 delta[17] = { |
@@ -2086,6 +2083,7 @@ static void setgamma(struct gspca_dev *gspca_dev) | |||
2086 | gamma_base = gamma_spec_0; | 2083 | gamma_base = gamma_spec_0; |
2087 | break; | 2084 | break; |
2088 | case SENSOR_HV7131R: | 2085 | case SENSOR_HV7131R: |
2086 | case SENSOR_MI0360B: | ||
2089 | case SENSOR_MT9V111: | 2087 | case SENSOR_MT9V111: |
2090 | gamma_base = gamma_spec_1; | 2088 | gamma_base = gamma_spec_1; |
2091 | break; | 2089 | break; |
@@ -2100,9 +2098,10 @@ static void setgamma(struct gspca_dev *gspca_dev) | |||
2100 | break; | 2098 | break; |
2101 | } | 2099 | } |
2102 | 2100 | ||
2101 | val = sd->ctrls[GAMMA].val; | ||
2103 | for (i = 0; i < sizeof gamma; i++) | 2102 | for (i = 0; i < sizeof gamma; i++) |
2104 | gamma[i] = gamma_base[i] | 2103 | gamma[i] = gamma_base[i] |
2105 | + delta[i] * (sd->gamma - GAMMA_DEF) / 32; | 2104 | + delta[i] * (val - GAMMA_DEF) / 32; |
2106 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); | 2105 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); |
2107 | } | 2106 | } |
2108 | 2107 | ||
@@ -2110,7 +2109,7 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
2110 | { | 2109 | { |
2111 | struct sd *sd = (struct sd *) gspca_dev; | 2110 | struct sd *sd = (struct sd *) gspca_dev; |
2112 | 2111 | ||
2113 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) | 2112 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN)) |
2114 | return; | 2113 | return; |
2115 | switch (sd->sensor) { | 2114 | switch (sd->sensor) { |
2116 | case SENSOR_OV7630: | 2115 | case SENSOR_OV7630: |
@@ -2121,74 +2120,100 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
2121 | comb = 0xc0; | 2120 | comb = 0xc0; |
2122 | else | 2121 | else |
2123 | comb = 0xa0; | 2122 | comb = 0xa0; |
2124 | if (sd->autogain) | 2123 | if (sd->ctrls[AUTOGAIN].val) |
2125 | comb |= 0x03; | 2124 | comb |= 0x03; |
2126 | i2c_w1(&sd->gspca_dev, 0x13, comb); | 2125 | i2c_w1(&sd->gspca_dev, 0x13, comb); |
2127 | return; | 2126 | return; |
2128 | } | 2127 | } |
2129 | } | 2128 | } |
2130 | if (sd->autogain) | 2129 | if (sd->ctrls[AUTOGAIN].val) |
2131 | sd->ag_cnt = AG_CNT_START; | 2130 | sd->ag_cnt = AG_CNT_START; |
2132 | else | 2131 | else |
2133 | sd->ag_cnt = -1; | 2132 | sd->ag_cnt = -1; |
2134 | } | 2133 | } |
2135 | 2134 | ||
2136 | /* hv7131r/ov7630/ov7648 only */ | 2135 | static void sethvflip(struct gspca_dev *gspca_dev) |
2137 | static void setvflip(struct sd *sd) | ||
2138 | { | 2136 | { |
2137 | struct sd *sd = (struct sd *) gspca_dev; | ||
2139 | u8 comn; | 2138 | u8 comn; |
2140 | 2139 | ||
2141 | if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX)) | ||
2142 | return; | ||
2143 | switch (sd->sensor) { | 2140 | switch (sd->sensor) { |
2144 | case SENSOR_HV7131R: | 2141 | case SENSOR_HV7131R: |
2145 | comn = 0x18; /* clkdiv = 1, ablcen = 1 */ | 2142 | comn = 0x18; /* clkdiv = 1, ablcen = 1 */ |
2146 | if (sd->vflip) | 2143 | if (sd->ctrls[VFLIP].val) |
2147 | comn |= 0x01; | 2144 | comn |= 0x01; |
2148 | i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */ | 2145 | i2c_w1(gspca_dev, 0x01, comn); /* sctra */ |
2149 | break; | 2146 | break; |
2150 | case SENSOR_OV7630: | 2147 | case SENSOR_OV7630: |
2151 | comn = 0x02; | 2148 | comn = 0x02; |
2152 | if (!sd->vflip) | 2149 | if (!sd->ctrls[VFLIP].val) |
2153 | comn |= 0x80; | 2150 | comn |= 0x80; |
2154 | i2c_w1(&sd->gspca_dev, 0x75, comn); | 2151 | i2c_w1(gspca_dev, 0x75, comn); |
2155 | break; | 2152 | break; |
2156 | default: | 2153 | case SENSOR_OV7648: |
2157 | /* case SENSOR_OV7648: */ | ||
2158 | comn = 0x06; | 2154 | comn = 0x06; |
2159 | if (sd->vflip) | 2155 | if (sd->ctrls[VFLIP].val) |
2156 | comn |= 0x80; | ||
2157 | i2c_w1(gspca_dev, 0x75, comn); | ||
2158 | break; | ||
2159 | case SENSOR_PO2030N: | ||
2160 | /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2) | ||
2161 | * (reset value: 0x0A) | ||
2162 | * bit7: HM: Horizontal Mirror: 0: disable, 1: enable | ||
2163 | * bit6: VM: Vertical Mirror: 0: disable, 1: enable | ||
2164 | * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical | ||
2165 | * bit4: FT: Single Frame Transfer: 0: disable, 1: enable | ||
2166 | * bit3-0: X | ||
2167 | */ | ||
2168 | comn = 0x0a; | ||
2169 | if (sd->ctrls[HFLIP].val) | ||
2160 | comn |= 0x80; | 2170 | comn |= 0x80; |
2161 | i2c_w1(&sd->gspca_dev, 0x75, comn); | 2171 | if (sd->ctrls[VFLIP].val) |
2172 | comn |= 0x40; | ||
2173 | i2c_w1(&sd->gspca_dev, 0x1e, comn); | ||
2162 | break; | 2174 | break; |
2163 | } | 2175 | } |
2164 | } | 2176 | } |
2165 | 2177 | ||
2166 | static void setsharpness(struct sd *sd) | 2178 | static void setsharpness(struct gspca_dev *gspca_dev) |
2167 | { | 2179 | { |
2168 | reg_w1(&sd->gspca_dev, 0x99, sd->sharpness); | 2180 | struct sd *sd = (struct sd *) gspca_dev; |
2181 | |||
2182 | reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val); | ||
2169 | } | 2183 | } |
2170 | 2184 | ||
2171 | static void setinfrared(struct sd *sd) | 2185 | static void setillum(struct gspca_dev *gspca_dev) |
2172 | { | 2186 | { |
2173 | if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) | 2187 | struct sd *sd = (struct sd *) gspca_dev; |
2188 | |||
2189 | if (gspca_dev->ctrl_dis & (1 << ILLUM)) | ||
2174 | return; | 2190 | return; |
2175 | /*fixme: different sequence for StarCam Clip and StarCam 370i */ | 2191 | switch (sd->sensor) { |
2176 | /* Clip */ | 2192 | case SENSOR_ADCM1700: |
2177 | i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ | 2193 | reg_w1(gspca_dev, 0x02, /* gpio */ |
2178 | sd->infrared ? 0x66 : 0x64); | 2194 | sd->ctrls[ILLUM].val ? 0x64 : 0x60); |
2195 | break; | ||
2196 | case SENSOR_MT9V111: | ||
2197 | reg_w1(gspca_dev, 0x02, | ||
2198 | sd->ctrls[ILLUM].val ? 0x77 : 0x74); | ||
2199 | /* should have been: */ | ||
2200 | /* 0x55 : 0x54); * 370i */ | ||
2201 | /* 0x66 : 0x64); * Clip */ | ||
2202 | break; | ||
2203 | } | ||
2179 | } | 2204 | } |
2180 | 2205 | ||
2181 | static void setfreq(struct gspca_dev *gspca_dev) | 2206 | static void setfreq(struct gspca_dev *gspca_dev) |
2182 | { | 2207 | { |
2183 | struct sd *sd = (struct sd *) gspca_dev; | 2208 | struct sd *sd = (struct sd *) gspca_dev; |
2184 | 2209 | ||
2185 | if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) | 2210 | if (gspca_dev->ctrl_dis & (1 << FREQ)) |
2186 | return; | 2211 | return; |
2187 | if (sd->sensor == SENSOR_OV7660) { | 2212 | if (sd->sensor == SENSOR_OV7660) { |
2188 | u8 com8; | 2213 | u8 com8; |
2189 | 2214 | ||
2190 | com8 = 0xdf; /* auto gain/wb/expo */ | 2215 | com8 = 0xdf; /* auto gain/wb/expo */ |
2191 | switch (sd->freq) { | 2216 | switch (sd->ctrls[FREQ].val) { |
2192 | case 0: /* Banding filter disabled */ | 2217 | case 0: /* Banding filter disabled */ |
2193 | i2c_w1(gspca_dev, 0x13, com8 | 0x20); | 2218 | i2c_w1(gspca_dev, 0x13, com8 | 0x20); |
2194 | break; | 2219 | break; |
@@ -2216,7 +2241,7 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
2216 | break; | 2241 | break; |
2217 | } | 2242 | } |
2218 | 2243 | ||
2219 | switch (sd->freq) { | 2244 | switch (sd->ctrls[FREQ].val) { |
2220 | case 0: /* Banding filter disabled */ | 2245 | case 0: /* Banding filter disabled */ |
2221 | break; | 2246 | break; |
2222 | case 1: /* 50 hz (filter on and framerate adj) */ | 2247 | case 1: /* 50 hz (filter on and framerate adj) */ |
@@ -2238,18 +2263,12 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
2238 | static void setjpegqual(struct gspca_dev *gspca_dev) | 2263 | static void setjpegqual(struct gspca_dev *gspca_dev) |
2239 | { | 2264 | { |
2240 | struct sd *sd = (struct sd *) gspca_dev; | 2265 | struct sd *sd = (struct sd *) gspca_dev; |
2241 | int i, sc; | ||
2242 | 2266 | ||
2243 | if (sd->jpegqual < 50) | 2267 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
2244 | sc = 5000 / sd->jpegqual; | ||
2245 | else | ||
2246 | sc = 200 - sd->jpegqual * 2; | ||
2247 | #if USB_BUF_SZ < 64 | 2268 | #if USB_BUF_SZ < 64 |
2248 | #error "No room enough in usb_buf for quantization table" | 2269 | #error "No room enough in usb_buf for quantization table" |
2249 | #endif | 2270 | #endif |
2250 | for (i = 0; i < 64; i++) | 2271 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64); |
2251 | gspca_dev->usb_buf[i] = | ||
2252 | (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100; | ||
2253 | usb_control_msg(gspca_dev->dev, | 2272 | usb_control_msg(gspca_dev->dev, |
2254 | usb_sndctrlpipe(gspca_dev->dev, 0), | 2273 | usb_sndctrlpipe(gspca_dev->dev, 0), |
2255 | 0x08, | 2274 | 0x08, |
@@ -2257,9 +2276,7 @@ static void setjpegqual(struct gspca_dev *gspca_dev) | |||
2257 | 0x0100, 0, | 2276 | 0x0100, 0, |
2258 | gspca_dev->usb_buf, 64, | 2277 | gspca_dev->usb_buf, 64, |
2259 | 500); | 2278 | 500); |
2260 | for (i = 0; i < 64; i++) | 2279 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64); |
2261 | gspca_dev->usb_buf[i] = | ||
2262 | (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100; | ||
2263 | usb_control_msg(gspca_dev->dev, | 2280 | usb_control_msg(gspca_dev->dev, |
2264 | usb_sndctrlpipe(gspca_dev->dev, 0), | 2281 | usb_sndctrlpipe(gspca_dev->dev, 0), |
2265 | 0x08, | 2282 | 0x08, |
@@ -2272,15 +2289,35 @@ static void setjpegqual(struct gspca_dev *gspca_dev) | |||
2272 | reg_w1(gspca_dev, 0x18, sd->reg18); | 2289 | reg_w1(gspca_dev, 0x18, sd->reg18); |
2273 | } | 2290 | } |
2274 | 2291 | ||
2292 | /* JPEG quality update */ | ||
2293 | /* This function is executed from a work queue. */ | ||
2294 | static void qual_upd(struct work_struct *work) | ||
2295 | { | ||
2296 | struct sd *sd = container_of(work, struct sd, work); | ||
2297 | struct gspca_dev *gspca_dev = &sd->gspca_dev; | ||
2298 | |||
2299 | mutex_lock(&gspca_dev->usb_lock); | ||
2300 | PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality); | ||
2301 | setjpegqual(gspca_dev); | ||
2302 | mutex_unlock(&gspca_dev->usb_lock); | ||
2303 | } | ||
2304 | |||
2275 | /* -- start the camera -- */ | 2305 | /* -- start the camera -- */ |
2276 | static int sd_start(struct gspca_dev *gspca_dev) | 2306 | static int sd_start(struct gspca_dev *gspca_dev) |
2277 | { | 2307 | { |
2278 | struct sd *sd = (struct sd *) gspca_dev; | 2308 | struct sd *sd = (struct sd *) gspca_dev; |
2279 | int i; | 2309 | int i; |
2280 | u8 reg1, reg17; | 2310 | u8 reg01, reg17; |
2311 | u8 reg0102[2]; | ||
2281 | const u8 *sn9c1xx; | 2312 | const u8 *sn9c1xx; |
2282 | const u8 (*init)[8]; | 2313 | const u8 (*init)[8]; |
2314 | const u8 *reg9a; | ||
2283 | int mode; | 2315 | int mode; |
2316 | static const u8 reg9a_def[] = | ||
2317 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; | ||
2318 | static const u8 reg9a_spec[] = | ||
2319 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | ||
2320 | static const u8 regd4[] = {0x60, 0x00, 0x00}; | ||
2284 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 2321 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
2285 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 2322 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
2286 | static const u8 CA_adcm1700[] = | 2323 | static const u8 CA_adcm1700[] = |
@@ -2298,11 +2335,88 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2298 | /* create the JPEG header */ | 2335 | /* create the JPEG header */ |
2299 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, | 2336 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
2300 | 0x21); /* JPEG 422 */ | 2337 | 0x21); /* JPEG 422 */ |
2301 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | ||
2302 | 2338 | ||
2303 | /* initialize the bridge */ | 2339 | /* initialize the bridge */ |
2304 | sn9c1xx = sn_tb[sd->sensor]; | 2340 | sn9c1xx = sn_tb[sd->sensor]; |
2305 | bridge_init(gspca_dev, sn9c1xx); | 2341 | |
2342 | /* sensor clock already enabled in sd_init */ | ||
2343 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ | ||
2344 | reg01 = sn9c1xx[1]; | ||
2345 | if (sd->flags & F_PDN_INV) | ||
2346 | reg01 ^= S_PDN_INV; /* power down inverted */ | ||
2347 | reg_w1(gspca_dev, 0x01, reg01); | ||
2348 | |||
2349 | /* configure gpio */ | ||
2350 | reg0102[0] = reg01; | ||
2351 | reg0102[1] = sn9c1xx[2]; | ||
2352 | if (gspca_dev->audio) | ||
2353 | reg0102[1] |= 0x04; /* keep the audio connection */ | ||
2354 | reg_w(gspca_dev, 0x01, reg0102, 2); | ||
2355 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); | ||
2356 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); | ||
2357 | switch (sd->sensor) { | ||
2358 | case SENSOR_GC0307: | ||
2359 | case SENSOR_OV7660: | ||
2360 | case SENSOR_PO1030: | ||
2361 | case SENSOR_PO2030N: | ||
2362 | case SENSOR_SOI768: | ||
2363 | case SENSOR_SP80708: | ||
2364 | reg9a = reg9a_spec; | ||
2365 | break; | ||
2366 | default: | ||
2367 | reg9a = reg9a_def; | ||
2368 | break; | ||
2369 | } | ||
2370 | reg_w(gspca_dev, 0x9a, reg9a, 6); | ||
2371 | |||
2372 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); | ||
2373 | |||
2374 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | ||
2375 | |||
2376 | reg17 = sn9c1xx[0x17]; | ||
2377 | switch (sd->sensor) { | ||
2378 | case SENSOR_GC0307: | ||
2379 | msleep(50); /*fixme: is it useful? */ | ||
2380 | break; | ||
2381 | case SENSOR_OM6802: | ||
2382 | msleep(10); | ||
2383 | reg_w1(gspca_dev, 0x02, 0x73); | ||
2384 | reg17 |= SEN_CLK_EN; | ||
2385 | reg_w1(gspca_dev, 0x17, reg17); | ||
2386 | reg_w1(gspca_dev, 0x01, 0x22); | ||
2387 | msleep(100); | ||
2388 | reg01 = SCL_SEL_OD | S_PDN_INV; | ||
2389 | reg17 &= MCK_SIZE_MASK; | ||
2390 | reg17 |= 0x04; /* clock / 4 */ | ||
2391 | break; | ||
2392 | } | ||
2393 | reg01 |= SYS_SEL_48M; | ||
2394 | reg_w1(gspca_dev, 0x01, reg01); | ||
2395 | reg17 |= SEN_CLK_EN; | ||
2396 | reg_w1(gspca_dev, 0x17, reg17); | ||
2397 | reg01 &= ~S_PWR_DN; /* sensor power on */ | ||
2398 | reg_w1(gspca_dev, 0x01, reg01); | ||
2399 | reg01 &= ~SYS_SEL_48M; | ||
2400 | reg_w1(gspca_dev, 0x01, reg01); | ||
2401 | |||
2402 | switch (sd->sensor) { | ||
2403 | case SENSOR_HV7131R: | ||
2404 | hv7131r_probe(gspca_dev); /*fixme: is it useful? */ | ||
2405 | break; | ||
2406 | case SENSOR_OM6802: | ||
2407 | msleep(10); | ||
2408 | reg_w1(gspca_dev, 0x01, reg01); | ||
2409 | i2c_w8(gspca_dev, om6802_init0[0]); | ||
2410 | i2c_w8(gspca_dev, om6802_init0[1]); | ||
2411 | msleep(15); | ||
2412 | reg_w1(gspca_dev, 0x02, 0x71); | ||
2413 | msleep(150); | ||
2414 | break; | ||
2415 | case SENSOR_SP80708: | ||
2416 | msleep(100); | ||
2417 | reg_w1(gspca_dev, 0x02, 0x62); | ||
2418 | break; | ||
2419 | } | ||
2306 | 2420 | ||
2307 | /* initialize the sensor */ | 2421 | /* initialize the sensor */ |
2308 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); | 2422 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); |
@@ -2330,29 +2444,11 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2330 | } | 2444 | } |
2331 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | 2445 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
2332 | switch (sd->sensor) { | 2446 | switch (sd->sensor) { |
2333 | case SENSOR_GC0307: | 2447 | case SENSOR_OM6802: |
2334 | reg17 = 0xa2; | 2448 | /* case SENSOR_OV7648: * fixme: sometimes */ |
2335 | break; | ||
2336 | case SENSOR_MT9V111: | ||
2337 | reg17 = 0xe0; | ||
2338 | break; | ||
2339 | case SENSOR_ADCM1700: | ||
2340 | case SENSOR_OV7630: | ||
2341 | reg17 = 0xe2; | ||
2342 | break; | ||
2343 | case SENSOR_OV7648: | ||
2344 | reg17 = 0x20; | ||
2345 | break; | ||
2346 | case SENSOR_OV7660: | ||
2347 | case SENSOR_SOI768: | ||
2348 | reg17 = 0xa0; | ||
2349 | break; | ||
2350 | case SENSOR_PO1030: | ||
2351 | case SENSOR_PO2030N: | ||
2352 | reg17 = 0xa0; | ||
2353 | break; | 2449 | break; |
2354 | default: | 2450 | default: |
2355 | reg17 = 0x60; | 2451 | reg17 |= DEF_EN; |
2356 | break; | 2452 | break; |
2357 | } | 2453 | } |
2358 | reg_w1(gspca_dev, 0x17, reg17); | 2454 | reg_w1(gspca_dev, 0x17, reg17); |
@@ -2375,6 +2471,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2375 | break; | 2471 | break; |
2376 | case SENSOR_GC0307: | 2472 | case SENSOR_GC0307: |
2377 | case SENSOR_MT9V111: | 2473 | case SENSOR_MT9V111: |
2474 | case SENSOR_MI0360B: | ||
2378 | reg_w1(gspca_dev, 0x9a, 0x07); | 2475 | reg_w1(gspca_dev, 0x9a, 0x07); |
2379 | break; | 2476 | break; |
2380 | case SENSOR_OV7630: | 2477 | case SENSOR_OV7630: |
@@ -2389,7 +2486,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2389 | reg_w1(gspca_dev, 0x9a, 0x08); | 2486 | reg_w1(gspca_dev, 0x9a, 0x08); |
2390 | break; | 2487 | break; |
2391 | } | 2488 | } |
2392 | setsharpness(sd); | 2489 | setsharpness(gspca_dev); |
2393 | 2490 | ||
2394 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); | 2491 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
2395 | reg_w1(gspca_dev, 0x05, 0x20); /* red */ | 2492 | reg_w1(gspca_dev, 0x05, 0x20); /* red */ |
@@ -2398,91 +2495,67 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2398 | 2495 | ||
2399 | init = NULL; | 2496 | init = NULL; |
2400 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; | 2497 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
2401 | if (mode) | 2498 | reg01 |= SYS_SEL_48M | V_TX_EN; |
2402 | reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */ | 2499 | reg17 &= ~MCK_SIZE_MASK; |
2403 | else | 2500 | reg17 |= 0x02; /* clock / 2 */ |
2404 | reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */ | ||
2405 | reg17 = 0x61; /* 0x:20: enable sensor clock */ | ||
2406 | switch (sd->sensor) { | 2501 | switch (sd->sensor) { |
2407 | case SENSOR_ADCM1700: | 2502 | case SENSOR_ADCM1700: |
2408 | init = adcm1700_sensor_param1; | 2503 | init = adcm1700_sensor_param1; |
2409 | reg1 = 0x46; | ||
2410 | reg17 = 0xe2; | ||
2411 | break; | 2504 | break; |
2412 | case SENSOR_GC0307: | 2505 | case SENSOR_GC0307: |
2413 | init = gc0307_sensor_param1; | 2506 | init = gc0307_sensor_param1; |
2414 | reg17 = 0xa2; | 2507 | break; |
2415 | reg1 = 0x44; | 2508 | case SENSOR_HV7131R: |
2509 | case SENSOR_MI0360: | ||
2510 | if (mode) | ||
2511 | reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */ | ||
2512 | else | ||
2513 | reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */ | ||
2514 | reg17 &= ~MCK_SIZE_MASK; | ||
2515 | reg17 |= 0x01; /* clock / 1 */ | ||
2516 | break; | ||
2517 | case SENSOR_MI0360B: | ||
2518 | init = mi0360b_sensor_param1; | ||
2416 | break; | 2519 | break; |
2417 | case SENSOR_MO4000: | 2520 | case SENSOR_MO4000: |
2418 | if (mode) { | 2521 | if (mode) { /* if 320x240 */ |
2419 | /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ | 2522 | reg01 &= ~SYS_SEL_48M; /* clk 24Mz */ |
2420 | reg1 = 0x06; /* clk 24Mz */ | 2523 | reg17 &= ~MCK_SIZE_MASK; |
2421 | } else { | 2524 | reg17 |= 0x01; /* clock / 1 */ |
2422 | reg17 = 0x22; /* 640 MCKSIZE */ | ||
2423 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | ||
2424 | } | 2525 | } |
2425 | break; | 2526 | break; |
2426 | case SENSOR_MT9V111: | 2527 | case SENSOR_MT9V111: |
2427 | init = mt9v111_sensor_param1; | 2528 | init = mt9v111_sensor_param1; |
2428 | if (mode) { | ||
2429 | reg1 = 0x04; /* 320 clk 48Mhz */ | ||
2430 | } else { | ||
2431 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | ||
2432 | reg17 = 0xc2; | ||
2433 | } | ||
2434 | break; | 2529 | break; |
2435 | case SENSOR_OM6802: | 2530 | case SENSOR_OM6802: |
2436 | init = om6802_sensor_param1; | 2531 | init = om6802_sensor_param1; |
2437 | reg17 = 0x64; /* 640 MCKSIZE */ | 2532 | if (!mode) { /* if 640x480 */ |
2533 | reg17 &= ~MCK_SIZE_MASK; | ||
2534 | reg17 |= 0x04; /* clock / 4 */ | ||
2535 | } | ||
2438 | break; | 2536 | break; |
2439 | case SENSOR_OV7630: | 2537 | case SENSOR_OV7630: |
2440 | init = ov7630_sensor_param1; | 2538 | init = ov7630_sensor_param1; |
2441 | reg17 = 0xe2; | ||
2442 | reg1 = 0x44; | ||
2443 | break; | 2539 | break; |
2444 | case SENSOR_OV7648: | 2540 | case SENSOR_OV7648: |
2445 | init = ov7648_sensor_param1; | 2541 | init = ov7648_sensor_param1; |
2446 | reg17 = 0x21; | 2542 | reg17 &= ~MCK_SIZE_MASK; |
2447 | /* reg1 = 0x42; * 42 - 46? */ | 2543 | reg17 |= 0x01; /* clock / 1 */ |
2448 | break; | 2544 | break; |
2449 | case SENSOR_OV7660: | 2545 | case SENSOR_OV7660: |
2450 | init = ov7660_sensor_param1; | 2546 | init = ov7660_sensor_param1; |
2451 | if (sd->bridge == BRIDGE_SN9C120) { | ||
2452 | if (mode) { /* 320x240 - 160x120 */ | ||
2453 | reg17 = 0xa2; | ||
2454 | reg1 = 0x44; /* 48 Mhz, video trf eneble */ | ||
2455 | } | ||
2456 | } else { | ||
2457 | reg17 = 0x22; | ||
2458 | reg1 = 0x06; /* 24 Mhz, video trf eneble | ||
2459 | * inverse power down */ | ||
2460 | } | ||
2461 | break; | 2547 | break; |
2462 | case SENSOR_PO1030: | 2548 | case SENSOR_PO1030: |
2463 | init = po1030_sensor_param1; | 2549 | init = po1030_sensor_param1; |
2464 | reg17 = 0xa2; | ||
2465 | reg1 = 0x44; | ||
2466 | break; | 2550 | break; |
2467 | case SENSOR_PO2030N: | 2551 | case SENSOR_PO2030N: |
2468 | init = po2030n_sensor_param1; | 2552 | init = po2030n_sensor_param1; |
2469 | reg1 = 0x46; | ||
2470 | reg17 = 0xa2; | ||
2471 | break; | 2553 | break; |
2472 | case SENSOR_SOI768: | 2554 | case SENSOR_SOI768: |
2473 | init = soi768_sensor_param1; | 2555 | init = soi768_sensor_param1; |
2474 | reg1 = 0x44; | ||
2475 | reg17 = 0xa2; | ||
2476 | break; | 2556 | break; |
2477 | default: | 2557 | case SENSOR_SP80708: |
2478 | /* case SENSOR_SP80708: */ | ||
2479 | init = sp80708_sensor_param1; | 2558 | init = sp80708_sensor_param1; |
2480 | if (mode) { | ||
2481 | /*?? reg1 = 0x04; * 320 clk 48Mhz */ | ||
2482 | } else { | ||
2483 | reg1 = 0x46; /* 640 clk 48Mz */ | ||
2484 | reg17 = 0xa2; | ||
2485 | } | ||
2486 | break; | 2559 | break; |
2487 | } | 2560 | } |
2488 | 2561 | ||
@@ -2526,22 +2599,28 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2526 | break; | 2599 | break; |
2527 | } | 2600 | } |
2528 | 2601 | ||
2529 | |||
2530 | /* here change size mode 0 -> VGA; 1 -> CIF */ | 2602 | /* here change size mode 0 -> VGA; 1 -> CIF */ |
2531 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; | 2603 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; |
2532 | reg_w1(gspca_dev, 0x18, sd->reg18); | 2604 | reg_w1(gspca_dev, 0x18, sd->reg18); |
2533 | setjpegqual(gspca_dev); | 2605 | setjpegqual(gspca_dev); |
2534 | 2606 | ||
2535 | reg_w1(gspca_dev, 0x17, reg17); | 2607 | reg_w1(gspca_dev, 0x17, reg17); |
2536 | reg_w1(gspca_dev, 0x01, reg1); | 2608 | reg_w1(gspca_dev, 0x01, reg01); |
2609 | sd->reg01 = reg01; | ||
2610 | sd->reg17 = reg17; | ||
2537 | 2611 | ||
2538 | setvflip(sd); | 2612 | sethvflip(gspca_dev); |
2539 | setbrightness(gspca_dev); | 2613 | setbrightness(gspca_dev); |
2540 | setcontrast(gspca_dev); | 2614 | setcontrast(gspca_dev); |
2541 | setcolors(gspca_dev); | 2615 | setcolors(gspca_dev); |
2542 | setautogain(gspca_dev); | 2616 | setautogain(gspca_dev); |
2543 | setfreq(gspca_dev); | 2617 | setfreq(gspca_dev); |
2544 | return 0; | 2618 | |
2619 | sd->pktsz = sd->npkt = 0; | ||
2620 | sd->nchg = sd->short_mark = 0; | ||
2621 | sd->work_thread = create_singlethread_workqueue(MODULE_NAME); | ||
2622 | |||
2623 | return gspca_dev->usb_err; | ||
2545 | } | 2624 | } |
2546 | 2625 | ||
2547 | static void sd_stopN(struct gspca_dev *gspca_dev) | 2626 | static void sd_stopN(struct gspca_dev *gspca_dev) |
@@ -2555,44 +2634,82 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
2555 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; | 2634 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
2556 | static const u8 stopsoi768[] = | 2635 | static const u8 stopsoi768[] = |
2557 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; | 2636 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; |
2558 | u8 data; | 2637 | u8 reg01; |
2559 | const u8 *sn9c1xx; | 2638 | u8 reg17; |
2560 | 2639 | ||
2561 | data = 0x0b; | 2640 | reg01 = sd->reg01; |
2641 | reg17 = sd->reg17 & ~SEN_CLK_EN; | ||
2562 | switch (sd->sensor) { | 2642 | switch (sd->sensor) { |
2643 | case SENSOR_ADCM1700: | ||
2563 | case SENSOR_GC0307: | 2644 | case SENSOR_GC0307: |
2564 | data = 0x29; | 2645 | case SENSOR_PO2030N: |
2646 | case SENSOR_SP80708: | ||
2647 | reg01 |= LED; | ||
2648 | reg_w1(gspca_dev, 0x01, reg01); | ||
2649 | reg01 &= ~(LED | V_TX_EN); | ||
2650 | reg_w1(gspca_dev, 0x01, reg01); | ||
2651 | /* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */ | ||
2565 | break; | 2652 | break; |
2566 | case SENSOR_HV7131R: | 2653 | case SENSOR_HV7131R: |
2654 | reg01 &= ~V_TX_EN; | ||
2655 | reg_w1(gspca_dev, 0x01, reg01); | ||
2567 | i2c_w8(gspca_dev, stophv7131); | 2656 | i2c_w8(gspca_dev, stophv7131); |
2568 | data = 0x2b; | ||
2569 | break; | 2657 | break; |
2570 | case SENSOR_MI0360: | 2658 | case SENSOR_MI0360: |
2659 | case SENSOR_MI0360B: | ||
2660 | reg01 &= ~V_TX_EN; | ||
2661 | reg_w1(gspca_dev, 0x01, reg01); | ||
2662 | /* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */ | ||
2571 | i2c_w8(gspca_dev, stopmi0360); | 2663 | i2c_w8(gspca_dev, stopmi0360); |
2572 | data = 0x29; | ||
2573 | break; | 2664 | break; |
2574 | case SENSOR_OV7648: | ||
2575 | i2c_w8(gspca_dev, stopov7648); | ||
2576 | /* fall thru */ | ||
2577 | case SENSOR_MT9V111: | 2665 | case SENSOR_MT9V111: |
2578 | case SENSOR_OV7630: | 2666 | case SENSOR_OM6802: |
2579 | case SENSOR_PO1030: | 2667 | case SENSOR_PO1030: |
2580 | data = 0x29; | 2668 | reg01 &= ~V_TX_EN; |
2669 | reg_w1(gspca_dev, 0x01, reg01); | ||
2670 | break; | ||
2671 | case SENSOR_OV7630: | ||
2672 | case SENSOR_OV7648: | ||
2673 | reg01 &= ~V_TX_EN; | ||
2674 | reg_w1(gspca_dev, 0x01, reg01); | ||
2675 | i2c_w8(gspca_dev, stopov7648); | ||
2676 | break; | ||
2677 | case SENSOR_OV7660: | ||
2678 | reg01 &= ~V_TX_EN; | ||
2679 | reg_w1(gspca_dev, 0x01, reg01); | ||
2581 | break; | 2680 | break; |
2582 | case SENSOR_SOI768: | 2681 | case SENSOR_SOI768: |
2583 | i2c_w8(gspca_dev, stopsoi768); | 2682 | i2c_w8(gspca_dev, stopsoi768); |
2584 | data = 0x29; | ||
2585 | break; | 2683 | break; |
2586 | } | 2684 | } |
2587 | sn9c1xx = sn_tb[sd->sensor]; | 2685 | |
2588 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 2686 | reg01 |= SCL_SEL_OD; |
2589 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); | 2687 | reg_w1(gspca_dev, 0x01, reg01); |
2590 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 2688 | reg01 |= S_PWR_DN; /* sensor power down */ |
2591 | reg_w1(gspca_dev, 0x01, data); | 2689 | reg_w1(gspca_dev, 0x01, reg01); |
2690 | reg_w1(gspca_dev, 0x17, reg17); | ||
2691 | reg01 &= ~SYS_SEL_48M; /* clock 24MHz */ | ||
2692 | reg_w1(gspca_dev, 0x01, reg01); | ||
2693 | reg01 |= LED; | ||
2694 | reg_w1(gspca_dev, 0x01, reg01); | ||
2592 | /* Don't disable sensor clock as that disables the button on the cam */ | 2695 | /* Don't disable sensor clock as that disables the button on the cam */ |
2593 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ | 2696 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ |
2594 | } | 2697 | } |
2595 | 2698 | ||
2699 | /* called on streamoff with alt==0 and on disconnect */ | ||
2700 | /* the usb_lock is held at entry - restore on exit */ | ||
2701 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
2702 | { | ||
2703 | struct sd *sd = (struct sd *) gspca_dev; | ||
2704 | |||
2705 | if (sd->work_thread != NULL) { | ||
2706 | mutex_unlock(&gspca_dev->usb_lock); | ||
2707 | destroy_workqueue(sd->work_thread); | ||
2708 | mutex_lock(&gspca_dev->usb_lock); | ||
2709 | sd->work_thread = NULL; | ||
2710 | } | ||
2711 | } | ||
2712 | |||
2596 | static void do_autogain(struct gspca_dev *gspca_dev) | 2713 | static void do_autogain(struct gspca_dev *gspca_dev) |
2597 | { | 2714 | { |
2598 | struct sd *sd = (struct sd *) gspca_dev; | 2715 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -2630,6 +2747,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
2630 | (unsigned int) (expotimes << 8)); | 2747 | (unsigned int) (expotimes << 8)); |
2631 | break; | 2748 | break; |
2632 | case SENSOR_OM6802: | 2749 | case SENSOR_OM6802: |
2750 | case SENSOR_MT9V111: | ||
2633 | expotimes = sd->exposure; | 2751 | expotimes = sd->exposure; |
2634 | expotimes += (luma_mean - delta) >> 2; | 2752 | expotimes += (luma_mean - delta) >> 2; |
2635 | if (expotimes < 0) | 2753 | if (expotimes < 0) |
@@ -2641,7 +2759,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
2641 | default: | 2759 | default: |
2642 | /* case SENSOR_MO4000: */ | 2760 | /* case SENSOR_MO4000: */ |
2643 | /* case SENSOR_MI0360: */ | 2761 | /* case SENSOR_MI0360: */ |
2644 | /* case SENSOR_MT9V111: */ | 2762 | /* case SENSOR_MI0360B: */ |
2645 | expotimes = sd->exposure; | 2763 | expotimes = sd->exposure; |
2646 | expotimes += (luma_mean - delta) >> 6; | 2764 | expotimes += (luma_mean - delta) >> 6; |
2647 | if (expotimes < 0) | 2765 | if (expotimes < 0) |
@@ -2654,261 +2772,171 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
2654 | } | 2772 | } |
2655 | } | 2773 | } |
2656 | 2774 | ||
2657 | /* scan the URB packets */ | 2775 | /* set the average luminosity from an isoc marker */ |
2658 | /* This function is run at interrupt level. */ | 2776 | static void set_lum(struct sd *sd, |
2659 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 2777 | u8 *data) |
2660 | u8 *data, /* isoc packet */ | ||
2661 | int len) /* iso packet length */ | ||
2662 | { | ||
2663 | struct sd *sd = (struct sd *) gspca_dev; | ||
2664 | int sof, avg_lum; | ||
2665 | |||
2666 | sof = len - 64; | ||
2667 | if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) { | ||
2668 | |||
2669 | /* end of frame */ | ||
2670 | gspca_frame_add(gspca_dev, LAST_PACKET, | ||
2671 | data, sof + 2); | ||
2672 | if (sd->ag_cnt < 0) | ||
2673 | return; | ||
2674 | /* w1 w2 w3 */ | ||
2675 | /* w4 w5 w6 */ | ||
2676 | /* w7 w8 */ | ||
2677 | /* w4 */ | ||
2678 | avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6; | ||
2679 | /* w6 */ | ||
2680 | avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6; | ||
2681 | /* w2 */ | ||
2682 | avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6; | ||
2683 | /* w8 */ | ||
2684 | avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6; | ||
2685 | /* w5 */ | ||
2686 | avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4; | ||
2687 | avg_lum >>= 4; | ||
2688 | 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 | |||
2700 | static 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 | |||
2710 | static 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 | |||
2718 | static 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 | |||
2728 | static 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 | |||
2736 | static 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 | |||
2746 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | ||
2747 | { | 2778 | { |
2748 | struct sd *sd = (struct sd *) gspca_dev; | 2779 | int avg_lum; |
2749 | |||
2750 | *val = sd->colors; | ||
2751 | return 0; | ||
2752 | } | ||
2753 | 2780 | ||
2754 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val) | 2781 | /* w0 w1 w2 |
2755 | { | 2782 | * w3 w4 w5 |
2756 | struct sd *sd = (struct sd *) gspca_dev; | 2783 | * w6 w7 w8 |
2757 | 2784 | */ | |
2758 | sd->blue = val; | 2785 | avg_lum = (data[27] << 8) + data[28] /* w3 */ |
2759 | if (gspca_dev->streaming) | ||
2760 | setredblue(gspca_dev); | ||
2761 | return 0; | ||
2762 | } | ||
2763 | 2786 | ||
2764 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val) | 2787 | + (data[31] << 8) + data[32] /* w5 */ |
2765 | { | ||
2766 | struct sd *sd = (struct sd *) gspca_dev; | ||
2767 | 2788 | ||
2768 | *val = sd->blue; | 2789 | + (data[23] << 8) + data[24] /* w1 */ |
2769 | return 0; | ||
2770 | } | ||
2771 | 2790 | ||
2772 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val) | 2791 | + (data[35] << 8) + data[36] /* w7 */ |
2773 | { | ||
2774 | struct sd *sd = (struct sd *) gspca_dev; | ||
2775 | 2792 | ||
2776 | sd->red = val; | 2793 | + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */ |
2777 | if (gspca_dev->streaming) | 2794 | avg_lum >>= 10; |
2778 | setredblue(gspca_dev); | 2795 | atomic_set(&sd->avg_lum, avg_lum); |
2779 | return 0; | ||
2780 | } | ||
2781 | |||
2782 | static 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 | |||
2790 | static 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 | |||
2800 | static 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 | |||
2808 | static 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 | |||
2818 | static 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 | |||
2826 | static 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 | } | 2796 | } |
2835 | 2797 | ||
2836 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) | 2798 | /* scan the URB packets */ |
2837 | { | 2799 | /* This function is run at interrupt level. */ |
2838 | struct sd *sd = (struct sd *) gspca_dev; | 2800 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
2839 | 2801 | u8 *data, /* isoc packet */ | |
2840 | *val = sd->sharpness; | 2802 | int len) /* iso packet length */ |
2841 | return 0; | ||
2842 | } | ||
2843 | |||
2844 | static 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 | |||
2854 | static 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 | |||
2862 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val) | ||
2863 | { | 2803 | { |
2864 | struct sd *sd = (struct sd *) gspca_dev; | 2804 | struct sd *sd = (struct sd *) gspca_dev; |
2805 | int i, new_qual; | ||
2806 | |||
2807 | /* | ||
2808 | * A frame ends on the marker | ||
2809 | * ff ff 00 c4 c4 96 .. | ||
2810 | * which is 62 bytes long and is followed by various information | ||
2811 | * including statuses and luminosity. | ||
2812 | * | ||
2813 | * A marker may be splitted on two packets. | ||
2814 | * | ||
2815 | * The 6th byte of a marker contains the bits: | ||
2816 | * 0x08: USB full | ||
2817 | * 0xc0: frame sequence | ||
2818 | * When the bit 'USB full' is set, the frame must be discarded; | ||
2819 | * this is also the case when the 2 bytes before the marker are | ||
2820 | * not the JPEG end of frame ('ff d9'). | ||
2821 | */ | ||
2822 | |||
2823 | /*fixme: assumption about the following code: | ||
2824 | * - there can be only one marker in a packet | ||
2825 | */ | ||
2865 | 2826 | ||
2866 | sd->infrared = val; | 2827 | /* skip the remaining bytes of a short marker */ |
2867 | if (gspca_dev->streaming) | 2828 | i = sd->short_mark; |
2868 | setinfrared(sd); | 2829 | if (i != 0) { |
2869 | return 0; | 2830 | sd->short_mark = 0; |
2870 | } | 2831 | if (i < 0 /* if 'ff' at end of previous packet */ |
2832 | && data[0] == 0xff | ||
2833 | && data[1] == 0x00) | ||
2834 | goto marker_found; | ||
2835 | if (data[0] == 0xff && data[1] == 0xff) { | ||
2836 | i = 0; | ||
2837 | goto marker_found; | ||
2838 | } | ||
2839 | len -= i; | ||
2840 | if (len <= 0) | ||
2841 | return; | ||
2842 | data += i; | ||
2843 | } | ||
2871 | 2844 | ||
2872 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) | 2845 | /* count the packets and their size */ |
2873 | { | 2846 | sd->npkt++; |
2874 | struct sd *sd = (struct sd *) gspca_dev; | 2847 | sd->pktsz += len; |
2875 | 2848 | ||
2876 | *val = sd->infrared; | 2849 | /* search backwards if there is a marker in the packet */ |
2877 | return 0; | 2850 | for (i = len - 1; --i >= 0; ) { |
2878 | } | 2851 | if (data[i] != 0xff) { |
2852 | i--; | ||
2853 | continue; | ||
2854 | } | ||
2855 | if (data[i + 1] == 0xff) { | ||
2879 | 2856 | ||
2880 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | 2857 | /* (there may be 'ff ff' inside a marker) */ |
2881 | { | 2858 | if (i + 2 >= len || data[i + 2] == 0x00) |
2882 | struct sd *sd = (struct sd *) gspca_dev; | 2859 | goto marker_found; |
2860 | } | ||
2861 | } | ||
2883 | 2862 | ||
2884 | sd->freq = val; | 2863 | /* no marker found */ |
2885 | if (gspca_dev->streaming) | 2864 | /* add the JPEG header if first fragment */ |
2886 | setfreq(gspca_dev); | 2865 | if (data[len - 1] == 0xff) |
2887 | return 0; | 2866 | sd->short_mark = -1; |
2888 | } | 2867 | if (gspca_dev->last_packet_type == LAST_PACKET) |
2868 | gspca_frame_add(gspca_dev, FIRST_PACKET, | ||
2869 | sd->jpeg_hdr, JPEG_HDR_SZ); | ||
2870 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | ||
2871 | return; | ||
2872 | |||
2873 | /* marker found */ | ||
2874 | /* if some error, discard the frame and decrease the quality */ | ||
2875 | marker_found: | ||
2876 | new_qual = 0; | ||
2877 | if (i > 2) { | ||
2878 | if (data[i - 2] != 0xff || data[i - 1] != 0xd9) { | ||
2879 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
2880 | new_qual = -3; | ||
2881 | } | ||
2882 | } else if (i + 6 < len) { | ||
2883 | if (data[i + 6] & 0x08) { | ||
2884 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
2885 | new_qual = -5; | ||
2886 | } | ||
2887 | } | ||
2889 | 2888 | ||
2890 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | 2889 | gspca_frame_add(gspca_dev, LAST_PACKET, data, i); |
2891 | { | ||
2892 | struct sd *sd = (struct sd *) gspca_dev; | ||
2893 | 2890 | ||
2894 | *val = sd->freq; | 2891 | /* compute the filling rate and a new JPEG quality */ |
2895 | return 0; | 2892 | if (new_qual == 0) { |
2896 | } | 2893 | int r; |
2897 | 2894 | ||
2898 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | 2895 | r = (sd->pktsz * 100) / |
2899 | struct v4l2_jpegcompression *jcomp) | 2896 | (sd->npkt * |
2900 | { | 2897 | gspca_dev->urb[0]->iso_frame_desc[0].length); |
2901 | struct sd *sd = (struct sd *) gspca_dev; | 2898 | if (r >= 85) |
2899 | new_qual = -3; | ||
2900 | else if (r < 75) | ||
2901 | new_qual = 2; | ||
2902 | } | ||
2903 | if (new_qual != 0) { | ||
2904 | sd->nchg += new_qual; | ||
2905 | if (sd->nchg < -6 || sd->nchg >= 12) { | ||
2906 | sd->nchg = 0; | ||
2907 | new_qual += sd->quality; | ||
2908 | if (new_qual < QUALITY_MIN) | ||
2909 | new_qual = QUALITY_MIN; | ||
2910 | else if (new_qual > QUALITY_MAX) | ||
2911 | new_qual = QUALITY_MAX; | ||
2912 | if (new_qual != sd->quality) { | ||
2913 | sd->quality = new_qual; | ||
2914 | queue_work(sd->work_thread, &sd->work); | ||
2915 | } | ||
2916 | } | ||
2917 | } else { | ||
2918 | sd->nchg = 0; | ||
2919 | } | ||
2920 | sd->pktsz = sd->npkt = 0; | ||
2902 | 2921 | ||
2903 | if (jcomp->quality < QUALITY_MIN) | 2922 | /* if the marker is smaller than 62 bytes, |
2904 | sd->quality = QUALITY_MIN; | 2923 | * memorize the number of bytes to skip in the next packet */ |
2905 | else if (jcomp->quality > QUALITY_MAX) | 2924 | if (i + 62 > len) { /* no more usable data */ |
2906 | sd->quality = QUALITY_MAX; | 2925 | sd->short_mark = i + 62 - len; |
2907 | else | 2926 | return; |
2908 | sd->quality = jcomp->quality; | 2927 | } |
2909 | if (gspca_dev->streaming) | 2928 | if (sd->ag_cnt >= 0) |
2910 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | 2929 | set_lum(sd, data + i); |
2911 | return 0; | 2930 | |
2931 | /* if more data, start a new frame */ | ||
2932 | i += 62; | ||
2933 | if (i < len) { | ||
2934 | data += i; | ||
2935 | len -= i; | ||
2936 | gspca_frame_add(gspca_dev, FIRST_PACKET, | ||
2937 | sd->jpeg_hdr, JPEG_HDR_SZ); | ||
2938 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | ||
2939 | } | ||
2912 | } | 2940 | } |
2913 | 2941 | ||
2914 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, | 2942 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, |
@@ -2944,7 +2972,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
2944 | return -EINVAL; | 2972 | return -EINVAL; |
2945 | } | 2973 | } |
2946 | 2974 | ||
2947 | #ifdef CONFIG_INPUT | 2975 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
2948 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 2976 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
2949 | u8 *data, /* interrupt packet data */ | 2977 | u8 *data, /* interrupt packet data */ |
2950 | int len) /* interrupt packet length */ | 2978 | int len) /* interrupt packet length */ |
@@ -2967,17 +2995,17 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | |||
2967 | static const struct sd_desc sd_desc = { | 2995 | static const struct sd_desc sd_desc = { |
2968 | .name = MODULE_NAME, | 2996 | .name = MODULE_NAME, |
2969 | .ctrls = sd_ctrls, | 2997 | .ctrls = sd_ctrls, |
2970 | .nctrls = ARRAY_SIZE(sd_ctrls), | 2998 | .nctrls = NCTRLS, |
2971 | .config = sd_config, | 2999 | .config = sd_config, |
2972 | .init = sd_init, | 3000 | .init = sd_init, |
2973 | .start = sd_start, | 3001 | .start = sd_start, |
2974 | .stopN = sd_stopN, | 3002 | .stopN = sd_stopN, |
3003 | .stop0 = sd_stop0, | ||
2975 | .pkt_scan = sd_pkt_scan, | 3004 | .pkt_scan = sd_pkt_scan, |
2976 | .dq_callback = do_autogain, | 3005 | .dq_callback = do_autogain, |
2977 | .get_jcomp = sd_get_jcomp, | 3006 | .get_jcomp = sd_get_jcomp, |
2978 | .set_jcomp = sd_set_jcomp, | ||
2979 | .querymenu = sd_querymenu, | 3007 | .querymenu = sd_querymenu, |
2980 | #ifdef CONFIG_INPUT | 3008 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
2981 | .int_pkt_scan = sd_int_pkt_scan, | 3009 | .int_pkt_scan = sd_int_pkt_scan, |
2982 | #endif | 3010 | #endif |
2983 | }; | 3011 | }; |
@@ -2985,14 +3013,16 @@ static const struct sd_desc sd_desc = { | |||
2985 | /* -- module initialisation -- */ | 3013 | /* -- module initialisation -- */ |
2986 | #define BS(bridge, sensor) \ | 3014 | #define BS(bridge, sensor) \ |
2987 | .driver_info = (BRIDGE_ ## bridge << 16) \ | 3015 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
2988 | | SENSOR_ ## sensor | 3016 | | (SENSOR_ ## sensor << 8) |
2989 | static const __devinitdata struct usb_device_id device_table[] = { | 3017 | #define BSF(bridge, sensor, flags) \ |
2990 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | 3018 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
3019 | | (SENSOR_ ## sensor << 8) \ | ||
3020 | | (flags) | ||
3021 | static const struct usb_device_id device_table[] = { | ||
2991 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, | 3022 | {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, |
2992 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, | 3023 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, |
2993 | #endif | 3024 | {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)}, |
2994 | {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)}, | 3025 | {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)}, |
2995 | {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)}, | ||
2996 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, | 3026 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, |
2997 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, | 3027 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, |
2998 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, | 3028 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, |
@@ -3004,7 +3034,8 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
3004 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ | 3034 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ |
3005 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, | 3035 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, |
3006 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ | 3036 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ |
3007 | {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, | 3037 | {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)}, |
3038 | /* or MT9V111 */ | ||
3008 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ | 3039 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ |
3009 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ | 3040 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ |
3010 | /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ | 3041 | /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ |
@@ -3014,12 +3045,10 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
3014 | /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ | 3045 | /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ |
3015 | /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ | 3046 | /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ |
3016 | {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, | 3047 | {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, |
3017 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
3018 | {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, | 3048 | {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, |
3019 | {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, | 3049 | {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, |
3020 | #endif | ||
3021 | {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ | 3050 | {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ |
3022 | /* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, * / GC0305*/ | 3051 | {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/ |
3023 | /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ | 3052 | /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ |
3024 | {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ | 3053 | {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ |
3025 | {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ | 3054 | {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ |
@@ -3031,25 +3060,24 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
3031 | {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ | 3060 | {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ |
3032 | /*bw600.inf:*/ | 3061 | /*bw600.inf:*/ |
3033 | {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ | 3062 | {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ |
3063 | {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)}, | ||
3034 | {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, | 3064 | {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, |
3035 | {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, | 3065 | {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, |
3036 | /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ | 3066 | /* {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)}, | 3067 | {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, |
3039 | #endif | 3068 | /* or MT9V111 / MI0360B */ |
3040 | /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ | 3069 | /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ |
3041 | {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, | 3070 | {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, |
3042 | {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, | 3071 | {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, |
3043 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
3044 | {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, | 3072 | {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, |
3045 | #endif | ||
3046 | {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, | 3073 | {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, |
3047 | {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, | 3074 | {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, |
3048 | {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ | 3075 | {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ |
3049 | /* or GC0305 / GC0307 */ | 3076 | /* or GC0305 / GC0307 */ |
3050 | {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ | 3077 | {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ |
3051 | {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ | 3078 | {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ |
3052 | {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/ | 3079 | {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)}, |
3080 | /* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/ | ||
3053 | {} | 3081 | {} |
3054 | }; | 3082 | }; |
3055 | MODULE_DEVICE_TABLE(usb, device_table); | 3083 | MODULE_DEVICE_TABLE(usb, device_table); |
@@ -3076,17 +3104,11 @@ static struct usb_driver sd_driver = { | |||
3076 | /* -- module insert / remove -- */ | 3104 | /* -- module insert / remove -- */ |
3077 | static int __init sd_mod_init(void) | 3105 | static int __init sd_mod_init(void) |
3078 | { | 3106 | { |
3079 | int ret; | 3107 | 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 | } | 3108 | } |
3086 | static void __exit sd_mod_exit(void) | 3109 | static void __exit sd_mod_exit(void) |
3087 | { | 3110 | { |
3088 | usb_deregister(&sd_driver); | 3111 | usb_deregister(&sd_driver); |
3089 | info("deregistered"); | ||
3090 | } | 3112 | } |
3091 | 3113 | ||
3092 | module_init(sd_mod_init); | 3114 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca1528.c b/drivers/media/video/gspca/spca1528.c index 3f514eb1d99d..76c006b2bc83 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 | } |
@@ -555,7 +555,7 @@ static const struct sd_desc sd_desc = { | |||
555 | }; | 555 | }; |
556 | 556 | ||
557 | /* -- module initialisation -- */ | 557 | /* -- module initialisation -- */ |
558 | static const __devinitdata struct usb_device_id device_table[] = { | 558 | static const struct usb_device_id device_table[] = { |
559 | {USB_DEVICE(0x04fc, 0x1528)}, | 559 | {USB_DEVICE(0x04fc, 0x1528)}, |
560 | {} | 560 | {} |
561 | }; | 561 | }; |
@@ -587,18 +587,11 @@ static struct usb_driver sd_driver = { | |||
587 | /* -- module insert / remove -- */ | 587 | /* -- module insert / remove -- */ |
588 | static int __init sd_mod_init(void) | 588 | static 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 | } |
598 | static void __exit sd_mod_exit(void) | 592 | static 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 | ||
604 | module_init(sd_mod_init); | 597 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index c02beb6c1e93..3e76951e3c19 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 | } |
@@ -607,7 +607,7 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) | |||
607 | reg_w(gspca_dev, 0x00, 0x8880, 2); | 607 | reg_w(gspca_dev, 0x00, 0x8880, 2); |
608 | /* family cam Quicksmart stuff */ | 608 | /* family cam Quicksmart stuff */ |
609 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); | 609 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); |
610 | /* Set agc transfer: synced inbetween frames */ | 610 | /* Set agc transfer: synced between frames */ |
611 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); | 611 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); |
612 | /* Init SDRAM - needed for SDRAM access */ | 612 | /* Init SDRAM - needed for SDRAM access */ |
613 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); | 613 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
@@ -831,7 +831,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
831 | 831 | ||
832 | /* familycam Quicksmart pocketDV stuff */ | 832 | /* familycam Quicksmart pocketDV stuff */ |
833 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); | 833 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); |
834 | /* Set agc transfer: synced inbetween frames */ | 834 | /* Set agc transfer: synced between frames */ |
835 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); | 835 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); |
836 | /* Init SDRAM - needed for SDRAM access */ | 836 | /* Init SDRAM - needed for SDRAM access */ |
837 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); | 837 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
@@ -1051,7 +1051,7 @@ static const struct sd_desc sd_desc = { | |||
1051 | }; | 1051 | }; |
1052 | 1052 | ||
1053 | /* -- module initialisation -- */ | 1053 | /* -- module initialisation -- */ |
1054 | static const __devinitdata struct usb_device_id device_table[] = { | 1054 | static const struct usb_device_id device_table[] = { |
1055 | {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200}, | 1055 | {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200}, |
1056 | {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300}, | 1056 | {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300}, |
1057 | {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler}, | 1057 | {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler}, |
@@ -1093,17 +1093,11 @@ static struct usb_driver sd_driver = { | |||
1093 | /* -- module insert / remove -- */ | 1093 | /* -- module insert / remove -- */ |
1094 | static int __init sd_mod_init(void) | 1094 | static 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 | } |
1103 | static void __exit sd_mod_exit(void) | 1098 | static 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 | ||
1109 | module_init(sd_mod_init); | 1103 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c index c99333933e32..f7ef282cc600 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 | ||
@@ -2155,7 +2155,7 @@ static const struct sd_desc sd_desc = { | |||
2155 | }; | 2155 | }; |
2156 | 2156 | ||
2157 | /* -- module initialisation -- */ | 2157 | /* -- module initialisation -- */ |
2158 | static const __devinitdata struct usb_device_id device_table[] = { | 2158 | static const struct usb_device_id device_table[] = { |
2159 | {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325}, | 2159 | {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325}, |
2160 | {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera}, | 2160 | {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera}, |
2161 | {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite}, | 2161 | {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite}, |
@@ -2189,17 +2189,11 @@ static struct usb_driver sd_driver = { | |||
2189 | /* -- module insert / remove -- */ | 2189 | /* -- module insert / remove -- */ |
2190 | static int __init sd_mod_init(void) | 2190 | static 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 | } |
2199 | static void __exit sd_mod_exit(void) | 2194 | static 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 | ||
2205 | module_init(sd_mod_init); | 2199 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c index c576eed73abe..e5bf865147d7 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 | ||
@@ -791,7 +786,7 @@ static const struct sd_desc sd_desc = { | |||
791 | }; | 786 | }; |
792 | 787 | ||
793 | /* -- module initialisation -- */ | 788 | /* -- module initialisation -- */ |
794 | static const __devinitdata struct usb_device_id device_table[] = { | 789 | static const struct usb_device_id device_table[] = { |
795 | {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, | 790 | {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, |
796 | {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, | 791 | {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, |
797 | /*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */ | 792 | /*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */ |
@@ -821,18 +816,11 @@ static struct usb_driver sd_driver = { | |||
821 | /* -- module insert / remove -- */ | 816 | /* -- module insert / remove -- */ |
822 | static int __init sd_mod_init(void) | 817 | static 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 | } |
832 | static void __exit sd_mod_exit(void) | 821 | static 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 | ||
838 | module_init(sd_mod_init); | 826 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c index edf0fe157501..9d0b46027b93 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 | */ |
95 | static const u16 spca508_init_data[][2] = | 95 | static 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 */ |
@@ -593,7 +592,7 @@ static const u16 spca508_sightcam_init_data[][2] = { | |||
593 | /* This line seems to setup the frame/canvas */ | 592 | /* This line seems to setup the frame/canvas */ |
594 | {0x000f, 0x8402}, | 593 | {0x000f, 0x8402}, |
595 | 594 | ||
596 | /* Theese 6 lines are needed to startup the webcam */ | 595 | /* These 6 lines are needed to startup the webcam */ |
597 | {0x0090, 0x8110}, | 596 | {0x0090, 0x8110}, |
598 | {0x0001, 0x8114}, | 597 | {0x0001, 0x8114}, |
599 | {0x0001, 0x8114}, | 598 | {0x0001, 0x8114}, |
@@ -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]; |
@@ -1376,7 +1375,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1376 | { | 1375 | { |
1377 | struct sd *sd = (struct sd *) gspca_dev; | 1376 | struct sd *sd = (struct sd *) gspca_dev; |
1378 | struct cam *cam; | 1377 | struct cam *cam; |
1379 | int data1, data2; | ||
1380 | const u16 (*init_data)[2]; | 1378 | const u16 (*init_data)[2]; |
1381 | static const u16 (*(init_data_tb[]))[2] = { | 1379 | static const u16 (*(init_data_tb[]))[2] = { |
1382 | spca508_vista_init_data, /* CreativeVista 0 */ | 1380 | spca508_vista_init_data, /* CreativeVista 0 */ |
@@ -1387,6 +1385,9 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1387 | spca508_init_data, /* ViewQuestVQ110 5 */ | 1385 | spca508_init_data, /* ViewQuestVQ110 5 */ |
1388 | }; | 1386 | }; |
1389 | 1387 | ||
1388 | #ifdef GSPCA_DEBUG | ||
1389 | int data1, data2; | ||
1390 | |||
1390 | /* Read from global register the USB product and vendor IDs, just to | 1391 | /* Read from global register the USB product and vendor IDs, just to |
1391 | * prove that we can communicate with the device. This works, which | 1392 | * prove that we can communicate with the device. This works, which |
1392 | * confirms at we are communicating properly and that the device | 1393 | * confirms at we are communicating properly and that the device |
@@ -1401,6 +1402,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1401 | 1402 | ||
1402 | data1 = reg_read(gspca_dev, 0x8621); | 1403 | data1 = reg_read(gspca_dev, 0x8621); |
1403 | PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); | 1404 | PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); |
1405 | #endif | ||
1404 | 1406 | ||
1405 | cam = &gspca_dev->cam; | 1407 | cam = &gspca_dev->cam; |
1406 | cam->cam_mode = sif_mode; | 1408 | cam->cam_mode = sif_mode; |
@@ -1510,7 +1512,7 @@ static const struct sd_desc sd_desc = { | |||
1510 | }; | 1512 | }; |
1511 | 1513 | ||
1512 | /* -- module initialisation -- */ | 1514 | /* -- module initialisation -- */ |
1513 | static const __devinitdata struct usb_device_id device_table[] = { | 1515 | static const struct usb_device_id device_table[] = { |
1514 | {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam}, | 1516 | {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam}, |
1515 | {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista}, | 1517 | {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista}, |
1516 | {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110}, | 1518 | {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110}, |
@@ -1543,18 +1545,11 @@ static struct usb_driver sd_driver = { | |||
1543 | /* -- module insert / remove -- */ | 1545 | /* -- module insert / remove -- */ |
1544 | static int __init sd_mod_init(void) | 1546 | static int __init sd_mod_init(void) |
1545 | { | 1547 | { |
1546 | int ret; | 1548 | 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 | } | 1549 | } |
1554 | static void __exit sd_mod_exit(void) | 1550 | static void __exit sd_mod_exit(void) |
1555 | { | 1551 | { |
1556 | usb_deregister(&sd_driver); | 1552 | usb_deregister(&sd_driver); |
1557 | PDEBUG(D_PROBE, "deregistered"); | ||
1558 | } | 1553 | } |
1559 | 1554 | ||
1560 | module_init(sd_mod_init); | 1555 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c index 7bb2355005dc..e836e778dfb6 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 | ||
321 | static void write_vector(struct gspca_dev *gspca_dev, | 321 | static void write_vector(struct gspca_dev *gspca_dev, |
@@ -597,7 +597,7 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
597 | else if (sd->gain < 128) | 597 | else if (sd->gain < 128) |
598 | gspca_dev->usb_buf[0] = (sd->gain / 2) | 0x40; | 598 | gspca_dev->usb_buf[0] = (sd->gain / 2) | 0x40; |
599 | else | 599 | else |
600 | gspca_dev->usb_buf[0] = (sd->gain / 4) | 0xC0; | 600 | gspca_dev->usb_buf[0] = (sd->gain / 4) | 0xc0; |
601 | 601 | ||
602 | gspca_dev->usb_buf[1] = 0; | 602 | gspca_dev->usb_buf[1] = 0; |
603 | reg_w_buf(gspca_dev, 0x8335, 2); | 603 | reg_w_buf(gspca_dev, 0x8335, 2); |
@@ -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 | }; |
@@ -1061,7 +1061,7 @@ static const struct sd_desc *sd_desc[2] = { | |||
1061 | }; | 1061 | }; |
1062 | 1062 | ||
1063 | /* -- module initialisation -- */ | 1063 | /* -- module initialisation -- */ |
1064 | static const __devinitdata struct usb_device_id device_table[] = { | 1064 | static const struct usb_device_id device_table[] = { |
1065 | {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, | 1065 | {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, |
1066 | {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, | 1066 | {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, |
1067 | {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A}, | 1067 | {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A}, |
@@ -1107,17 +1107,11 @@ static struct usb_driver sd_driver = { | |||
1107 | /* -- module insert / remove -- */ | 1107 | /* -- module insert / remove -- */ |
1108 | static int __init sd_mod_init(void) | 1108 | static 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 | } |
1117 | static void __exit sd_mod_exit(void) | 1112 | static 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 | ||
1123 | module_init(sd_mod_init); | 1117 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c index 09b3f93fa4d6..5ba96aff2252 100644 --- a/drivers/media/video/gspca/sq905.c +++ b/drivers/media/video/gspca/sq905.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * History and Acknowledgments | 22 | * History and Acknowledgments |
23 | * | 23 | * |
24 | * The original Linux driver for SQ905 based cameras was written by | 24 | * The original Linux driver for SQ905 based cameras was written by |
25 | * Marcell Lengyel and furter developed by many other contributers | 25 | * Marcell Lengyel and furter developed by many other contributors |
26 | * and is available from http://sourceforge.net/projects/sqcam/ | 26 | * and is available from http://sourceforge.net/projects/sqcam/ |
27 | * | 27 | * |
28 | * This driver takes advantage of the reverse engineering work done for | 28 | * This driver takes advantage of the reverse engineering work done for |
@@ -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 | ||
@@ -396,7 +396,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
396 | } | 396 | } |
397 | 397 | ||
398 | /* Table of supported USB devices */ | 398 | /* Table of supported USB devices */ |
399 | static const __devinitdata struct usb_device_id device_table[] = { | 399 | static const struct usb_device_id device_table[] = { |
400 | {USB_DEVICE(0x2770, 0x9120)}, | 400 | {USB_DEVICE(0x2770, 0x9120)}, |
401 | {} | 401 | {} |
402 | }; | 402 | }; |
@@ -436,19 +436,12 @@ static struct usb_driver sd_driver = { | |||
436 | /* -- module insert / remove -- */ | 436 | /* -- module insert / remove -- */ |
437 | static int __init sd_mod_init(void) | 437 | static 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 | ||
448 | static void __exit sd_mod_exit(void) | 442 | static 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 | ||
454 | module_init(sd_mod_init); | 447 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c index 4c70628ca615..457563b7a71b 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 | ||
@@ -298,9 +298,10 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
298 | } | 298 | } |
299 | 299 | ||
300 | /* Table of supported USB devices */ | 300 | /* Table of supported USB devices */ |
301 | static const __devinitdata struct usb_device_id device_table[] = { | 301 | static const struct usb_device_id device_table[] = { |
302 | {USB_DEVICE(0x2770, 0x905c)}, | 302 | {USB_DEVICE(0x2770, 0x905c)}, |
303 | {USB_DEVICE(0x2770, 0x9050)}, | 303 | {USB_DEVICE(0x2770, 0x9050)}, |
304 | {USB_DEVICE(0x2770, 0x9051)}, | ||
304 | {USB_DEVICE(0x2770, 0x9052)}, | 305 | {USB_DEVICE(0x2770, 0x9052)}, |
305 | {USB_DEVICE(0x2770, 0x913d)}, | 306 | {USB_DEVICE(0x2770, 0x913d)}, |
306 | {} | 307 | {} |
@@ -341,19 +342,12 @@ static struct usb_driver sd_driver = { | |||
341 | /* -- module insert / remove -- */ | 342 | /* -- module insert / remove -- */ |
342 | static int __init sd_mod_init(void) | 343 | static int __init sd_mod_init(void) |
343 | { | 344 | { |
344 | int ret; | 345 | 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 | } | 346 | } |
352 | 347 | ||
353 | static void __exit sd_mod_exit(void) | 348 | static void __exit sd_mod_exit(void) |
354 | { | 349 | { |
355 | usb_deregister(&sd_driver); | 350 | usb_deregister(&sd_driver); |
356 | PDEBUG(D_PROBE, "deregistered"); | ||
357 | } | 351 | } |
358 | 352 | ||
359 | module_init(sd_mod_init); | 353 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/sq930x.c b/drivers/media/video/gspca/sq930x.c index 7ae6522d4edf..8215d5dcd456 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 | } |
@@ -687,10 +687,19 @@ static void cmos_probe(struct gspca_dev *gspca_dev) | |||
687 | if (gspca_dev->usb_buf[0] != 0) | 687 | if (gspca_dev->usb_buf[0] != 0) |
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 | gspca_dev->usb_err = -EINVAL; |
693 | sd->sensor = probe_order[i]; | 693 | return; |
694 | } | ||
695 | sd->sensor = probe_order[i]; | ||
696 | switch (sd->sensor) { | ||
697 | case SENSOR_OV7660: | ||
698 | case SENSOR_OV9630: | ||
699 | err("Sensor %s not yet treated", sensor_tb[sd->sensor].name); | ||
700 | gspca_dev->usb_err = -EINVAL; | ||
701 | break; | ||
702 | } | ||
694 | } | 703 | } |
695 | 704 | ||
696 | static void mt9v111_init(struct gspca_dev *gspca_dev) | 705 | static void mt9v111_init(struct gspca_dev *gspca_dev) |
@@ -867,6 +876,9 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
867 | */ | 876 | */ |
868 | 877 | ||
869 | reg_r(gspca_dev, SQ930_CTRL_GET_DEV_INFO, 8); | 878 | reg_r(gspca_dev, SQ930_CTRL_GET_DEV_INFO, 8); |
879 | if (gspca_dev->usb_err < 0) | ||
880 | return gspca_dev->usb_err; | ||
881 | |||
870 | /* it returns: | 882 | /* it returns: |
871 | * 03 00 12 93 0b f6 c9 00 live! ultra | 883 | * 03 00 12 93 0b f6 c9 00 live! ultra |
872 | * 03 00 07 93 0b f6 ca 00 live! ultra for notebook | 884 | * 03 00 07 93 0b f6 ca 00 live! ultra for notebook |
@@ -900,15 +912,15 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
900 | if (sd->sensor == SENSOR_MI0360) { | 912 | if (sd->sensor == SENSOR_MI0360) { |
901 | 913 | ||
902 | /* no sensor probe for icam tracer */ | 914 | /* no sensor probe for icam tracer */ |
903 | if (gspca_dev->usb_buf[5] == 0xf6) /* if CMOS */ | 915 | if (gspca_dev->usb_buf[5] == 0xf6) /* if ccd */ |
904 | sd->sensor = SENSOR_ICX098BQ; | 916 | sd->sensor = SENSOR_ICX098BQ; |
905 | else | 917 | else |
906 | cmos_probe(gspca_dev); | 918 | cmos_probe(gspca_dev); |
907 | } | 919 | } |
908 | 920 | if (gspca_dev->usb_err >= 0) { | |
909 | PDEBUG(D_PROBE, "Sensor %s", sensor_tb[sd->sensor].name); | 921 | PDEBUG(D_PROBE, "Sensor %s", sensor_tb[sd->sensor].name); |
910 | 922 | global_init(sd, 1); | |
911 | global_init(sd, 1); | 923 | } |
912 | return gspca_dev->usb_err; | 924 | return gspca_dev->usb_err; |
913 | } | 925 | } |
914 | 926 | ||
@@ -1079,7 +1091,7 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev) | |||
1079 | gspca_dev->cam.bulk_nurbs = 1; | 1091 | gspca_dev->cam.bulk_nurbs = 1; |
1080 | ret = usb_submit_urb(gspca_dev->urb[0], GFP_ATOMIC); | 1092 | ret = usb_submit_urb(gspca_dev->urb[0], GFP_ATOMIC); |
1081 | if (ret < 0) | 1093 | if (ret < 0) |
1082 | PDEBUG(D_ERR|D_PACK, "sd_dq_callback() err %d", ret); | 1094 | err("sd_dq_callback() err %d", ret); |
1083 | 1095 | ||
1084 | /* wait a little time, otherwise the webcam crashes */ | 1096 | /* wait a little time, otherwise the webcam crashes */ |
1085 | msleep(100); | 1097 | msleep(100); |
@@ -1151,7 +1163,7 @@ static const struct sd_desc sd_desc = { | |||
1151 | #define ST(sensor, type) \ | 1163 | #define ST(sensor, type) \ |
1152 | .driver_info = (SENSOR_ ## sensor << 8) \ | 1164 | .driver_info = (SENSOR_ ## sensor << 8) \ |
1153 | | (type) | 1165 | | (type) |
1154 | static const __devinitdata struct usb_device_id device_table[] = { | 1166 | static const struct usb_device_id device_table[] = { |
1155 | {USB_DEVICE(0x041e, 0x4038), ST(MI0360, 0)}, | 1167 | {USB_DEVICE(0x041e, 0x4038), ST(MI0360, 0)}, |
1156 | {USB_DEVICE(0x041e, 0x403c), ST(LZ24BP, 0)}, | 1168 | {USB_DEVICE(0x041e, 0x403c), ST(LZ24BP, 0)}, |
1157 | {USB_DEVICE(0x041e, 0x403d), ST(LZ24BP, 0)}, | 1169 | {USB_DEVICE(0x041e, 0x403d), ST(LZ24BP, 0)}, |
@@ -1185,18 +1197,11 @@ static struct usb_driver sd_driver = { | |||
1185 | /* -- module insert / remove -- */ | 1197 | /* -- module insert / remove -- */ |
1186 | static int __init sd_mod_init(void) | 1198 | static int __init sd_mod_init(void) |
1187 | { | 1199 | { |
1188 | int ret; | 1200 | 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 | } | 1201 | } |
1196 | static void __exit sd_mod_exit(void) | 1202 | static void __exit sd_mod_exit(void) |
1197 | { | 1203 | { |
1198 | usb_deregister(&sd_driver); | 1204 | usb_deregister(&sd_driver); |
1199 | info("deregistered"); | ||
1200 | } | 1205 | } |
1201 | 1206 | ||
1202 | module_init(sd_mod_init); | 1207 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c index 2aedf4b1bfa3..763747700f10 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>"); | |||
27 | MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); | 27 | MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); |
28 | MODULE_LICENSE("GPL"); | 28 | MODULE_LICENSE("GPL"); |
29 | 29 | ||
30 | /* controls */ | ||
31 | enum 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 */ |
31 | struct sd { | 40 | struct 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 */ |
47 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 54 | static void setbrightness(struct gspca_dev *gspca_dev); |
48 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 55 | static void setcontrast(struct gspca_dev *gspca_dev); |
49 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | 56 | static void setcolors(struct gspca_dev *gspca_dev); |
50 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | 57 | static void setlightfreq(struct gspca_dev *gspca_dev); |
51 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | 58 | |
52 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 59 | static const struct ctrl sd_ctrls[NCTRLS] = { |
53 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | 60 | [BRIGHTNESS] = { |
54 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
55 | |||
56 | static 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 | ||
291 | static void setfreq(struct gspca_dev *gspca_dev) | 286 | static 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,92 +433,17 @@ 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 | ||
444 | static 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 | |||
454 | static 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 | |||
462 | static 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 | |||
472 | static 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 | |||
480 | static 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 | |||
490 | static 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 | |||
498 | static 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 | |||
508 | static 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 | |||
516 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 436 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
517 | struct v4l2_querymenu *menu) | 437 | struct v4l2_querymenu *menu) |
518 | { | 438 | { |
439 | static const char *freq_nm[3] = {"NoFliker", "50 Hz", "60 Hz"}; | ||
440 | |||
519 | switch (menu->id) { | 441 | switch (menu->id) { |
520 | case V4L2_CID_POWER_LINE_FREQUENCY: | 442 | case V4L2_CID_POWER_LINE_FREQUENCY: |
521 | switch (menu->index) { | 443 | if ((unsigned) menu->index >= ARRAY_SIZE(freq_nm)) |
522 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | 444 | break; |
523 | strcpy((char *) menu->name, "50 Hz"); | 445 | strcpy((char *) menu->name, freq_nm[menu->index]); |
524 | return 0; | 446 | return 0; |
525 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | ||
526 | strcpy((char *) menu->name, "60 Hz"); | ||
527 | return 0; | ||
528 | } | ||
529 | break; | ||
530 | } | 447 | } |
531 | return -EINVAL; | 448 | return -EINVAL; |
532 | } | 449 | } |
@@ -563,7 +480,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
563 | static const struct sd_desc sd_desc = { | 480 | static const struct sd_desc sd_desc = { |
564 | .name = MODULE_NAME, | 481 | .name = MODULE_NAME, |
565 | .ctrls = sd_ctrls, | 482 | .ctrls = sd_ctrls, |
566 | .nctrls = ARRAY_SIZE(sd_ctrls), | 483 | .nctrls = NCTRLS, |
567 | .config = sd_config, | 484 | .config = sd_config, |
568 | .init = sd_init, | 485 | .init = sd_init, |
569 | .start = sd_start, | 486 | .start = sd_start, |
@@ -575,7 +492,7 @@ static const struct sd_desc sd_desc = { | |||
575 | }; | 492 | }; |
576 | 493 | ||
577 | /* -- module initialisation -- */ | 494 | /* -- module initialisation -- */ |
578 | static const __devinitdata struct usb_device_id device_table[] = { | 495 | static const struct usb_device_id device_table[] = { |
579 | {USB_DEVICE(0x05e1, 0x0893)}, | 496 | {USB_DEVICE(0x05e1, 0x0893)}, |
580 | {} | 497 | {} |
581 | }; | 498 | }; |
@@ -603,17 +520,11 @@ static struct usb_driver sd_driver = { | |||
603 | /* -- module insert / remove -- */ | 520 | /* -- module insert / remove -- */ |
604 | static int __init sd_mod_init(void) | 521 | static int __init sd_mod_init(void) |
605 | { | 522 | { |
606 | int ret; | 523 | 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 | } | 524 | } |
613 | static void __exit sd_mod_exit(void) | 525 | static void __exit sd_mod_exit(void) |
614 | { | 526 | { |
615 | usb_deregister(&sd_driver); | 527 | usb_deregister(&sd_driver); |
616 | info("deregistered"); | ||
617 | } | 528 | } |
618 | 529 | ||
619 | module_init(sd_mod_init); | 530 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/stv0680.c b/drivers/media/video/gspca/stv0680.c index e50dd7693f74..e2ef41cf72d7 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 | ||
34 | MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>"); | 34 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
35 | MODULE_DESCRIPTION("STV0680 USB Camera Driver"); | 35 | MODULE_DESCRIPTION("STV0680 USB Camera Driver"); |
36 | MODULE_LICENSE("GPL"); | 36 | MODULE_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 | ||
@@ -328,7 +327,7 @@ static const struct sd_desc sd_desc = { | |||
328 | }; | 327 | }; |
329 | 328 | ||
330 | /* -- module initialisation -- */ | 329 | /* -- module initialisation -- */ |
331 | static const __devinitdata struct usb_device_id device_table[] = { | 330 | static const struct usb_device_id device_table[] = { |
332 | {USB_DEVICE(0x0553, 0x0202)}, | 331 | {USB_DEVICE(0x0553, 0x0202)}, |
333 | {USB_DEVICE(0x041e, 0x4007)}, | 332 | {USB_DEVICE(0x041e, 0x4007)}, |
334 | {} | 333 | {} |
@@ -357,17 +356,11 @@ static struct usb_driver sd_driver = { | |||
357 | /* -- module insert / remove -- */ | 356 | /* -- module insert / remove -- */ |
358 | static int __init sd_mod_init(void) | 357 | static 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 | } |
367 | static void __exit sd_mod_exit(void) | 361 | static 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 | ||
373 | module_init(sd_mod_init); | 366 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c index 14f179a19485..abf1658fa33e 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 | ||
@@ -263,7 +263,21 @@ static int stv06xx_init(struct gspca_dev *gspca_dev) | |||
263 | static int stv06xx_start(struct gspca_dev *gspca_dev) | 263 | static int stv06xx_start(struct gspca_dev *gspca_dev) |
264 | { | 264 | { |
265 | struct sd *sd = (struct sd *) gspca_dev; | 265 | struct sd *sd = (struct sd *) gspca_dev; |
266 | int err; | 266 | struct usb_host_interface *alt; |
267 | struct usb_interface *intf; | ||
268 | int err, packet_size; | ||
269 | |||
270 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | ||
271 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | ||
272 | if (!alt) { | ||
273 | PDEBUG(D_ERR, "Couldn't get altsetting"); | ||
274 | return -EIO; | ||
275 | } | ||
276 | |||
277 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
278 | err = stv06xx_write_bridge(sd, STV_ISO_SIZE_L, packet_size); | ||
279 | if (err < 0) | ||
280 | return err; | ||
267 | 281 | ||
268 | /* Prepare the sensor for start */ | 282 | /* Prepare the sensor for start */ |
269 | err = sd->sensor->start(sd); | 283 | err = sd->sensor->start(sd); |
@@ -282,6 +296,43 @@ out: | |||
282 | return (err < 0) ? err : 0; | 296 | return (err < 0) ? err : 0; |
283 | } | 297 | } |
284 | 298 | ||
299 | static int stv06xx_isoc_init(struct gspca_dev *gspca_dev) | ||
300 | { | ||
301 | struct usb_host_interface *alt; | ||
302 | struct sd *sd = (struct sd *) gspca_dev; | ||
303 | |||
304 | /* Start isoc bandwidth "negotiation" at max isoc bandwidth */ | ||
305 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | ||
306 | alt->endpoint[0].desc.wMaxPacketSize = | ||
307 | cpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev) | ||
313 | { | ||
314 | int ret, packet_size, min_packet_size; | ||
315 | struct usb_host_interface *alt; | ||
316 | struct sd *sd = (struct sd *) gspca_dev; | ||
317 | |||
318 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | ||
319 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
320 | min_packet_size = sd->sensor->min_packet_size[gspca_dev->curr_mode]; | ||
321 | if (packet_size <= min_packet_size) | ||
322 | return -EIO; | ||
323 | |||
324 | packet_size -= 100; | ||
325 | if (packet_size < min_packet_size) | ||
326 | packet_size = min_packet_size; | ||
327 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size); | ||
328 | |||
329 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); | ||
330 | if (ret < 0) | ||
331 | PDEBUG(D_ERR|D_STREAM, "set alt 1 err %d", ret); | ||
332 | |||
333 | return ret; | ||
334 | } | ||
335 | |||
285 | static void stv06xx_stopN(struct gspca_dev *gspca_dev) | 336 | static void stv06xx_stopN(struct gspca_dev *gspca_dev) |
286 | { | 337 | { |
287 | int err; | 338 | int err; |
@@ -349,7 +400,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, | |||
349 | } | 400 | } |
350 | 401 | ||
351 | /* First byte seem to be 02=data 2nd byte is unknown??? */ | 402 | /* First byte seem to be 02=data 2nd byte is unknown??? */ |
352 | if (sd->bridge == BRIDGE_ST6422 && (id & 0xFF00) == 0x0200) | 403 | if (sd->bridge == BRIDGE_ST6422 && (id & 0xff00) == 0x0200) |
353 | goto frame_data; | 404 | goto frame_data; |
354 | 405 | ||
355 | switch (id) { | 406 | switch (id) { |
@@ -428,7 +479,7 @@ frame_data: | |||
428 | } | 479 | } |
429 | } | 480 | } |
430 | 481 | ||
431 | #ifdef CONFIG_INPUT | 482 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
432 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 483 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
433 | u8 *data, /* interrupt packet data */ | 484 | u8 *data, /* interrupt packet data */ |
434 | int len) /* interrupt packet length */ | 485 | int len) /* interrupt packet length */ |
@@ -462,7 +513,9 @@ static const struct sd_desc sd_desc = { | |||
462 | .start = stv06xx_start, | 513 | .start = stv06xx_start, |
463 | .stopN = stv06xx_stopN, | 514 | .stopN = stv06xx_stopN, |
464 | .pkt_scan = stv06xx_pkt_scan, | 515 | .pkt_scan = stv06xx_pkt_scan, |
465 | #ifdef CONFIG_INPUT | 516 | .isoc_init = stv06xx_isoc_init, |
517 | .isoc_nego = stv06xx_isoc_nego, | ||
518 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
466 | .int_pkt_scan = sd_int_pkt_scan, | 519 | .int_pkt_scan = sd_int_pkt_scan, |
467 | #endif | 520 | #endif |
468 | }; | 521 | }; |
@@ -472,11 +525,9 @@ static int stv06xx_config(struct gspca_dev *gspca_dev, | |||
472 | const struct usb_device_id *id) | 525 | const struct usb_device_id *id) |
473 | { | 526 | { |
474 | struct sd *sd = (struct sd *) gspca_dev; | 527 | struct sd *sd = (struct sd *) gspca_dev; |
475 | struct cam *cam; | ||
476 | 528 | ||
477 | PDEBUG(D_PROBE, "Configuring camera"); | 529 | PDEBUG(D_PROBE, "Configuring camera"); |
478 | 530 | ||
479 | cam = &gspca_dev->cam; | ||
480 | sd->desc = sd_desc; | 531 | sd->desc = sd_desc; |
481 | sd->bridge = id->driver_info; | 532 | sd->bridge = id->driver_info; |
482 | gspca_dev->sd_desc = &sd->desc; | 533 | gspca_dev->sd_desc = &sd->desc; |
@@ -511,7 +562,7 @@ static int stv06xx_config(struct gspca_dev *gspca_dev, | |||
511 | 562 | ||
512 | 563 | ||
513 | /* -- module initialisation -- */ | 564 | /* -- module initialisation -- */ |
514 | static const __devinitdata struct usb_device_id device_table[] = { | 565 | static const struct usb_device_id device_table[] = { |
515 | /* QuickCam Express */ | 566 | /* QuickCam Express */ |
516 | {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, | 567 | {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, |
517 | /* LEGO cam / QuickCam Web */ | 568 | /* LEGO cam / QuickCam Web */ |
@@ -562,17 +613,11 @@ static struct usb_driver sd_driver = { | |||
562 | /* -- module insert / remove -- */ | 613 | /* -- module insert / remove -- */ |
563 | static int __init sd_mod_init(void) | 614 | static int __init sd_mod_init(void) |
564 | { | 615 | { |
565 | int ret; | 616 | 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 | } | 617 | } |
572 | static void __exit sd_mod_exit(void) | 618 | static void __exit sd_mod_exit(void) |
573 | { | 619 | { |
574 | usb_deregister(&sd_driver); | 620 | usb_deregister(&sd_driver); |
575 | PDEBUG(D_PROBE, "deregistered"); | ||
576 | } | 621 | } |
577 | 622 | ||
578 | module_init(sd_mod_init); | 623 | module_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..b8156855f2b7 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 | ||
@@ -568,7 +569,7 @@ static int hdcs_init(struct sd *sd) | |||
568 | if (err < 0) | 569 | if (err < 0) |
569 | return err; | 570 | return err; |
570 | 571 | ||
571 | /* Enable continous frame capture, bit 2: stop when frame complete */ | 572 | /* Enable continuous frame capture, bit 2: stop when frame complete */ |
572 | err = stv06xx_write_sensor(sd, HDCS_REG_CONFIG(sd), BIT(3)); | 573 | err = stv06xx_write_sensor(sd, HDCS_REG_CONFIG(sd), BIT(3)); |
573 | if (err < 0) | 574 | if (err < 0) |
574 | return err; | 575 | return err; |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.h index 37b31c99d956..a14a84a5079b 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 |
@@ -125,7 +125,7 @@ | |||
125 | #define HDCS_SLEEP_MODE (1 << 1) | 125 | #define HDCS_SLEEP_MODE (1 << 1) |
126 | 126 | ||
127 | #define HDCS_DEFAULT_EXPOSURE 48 | 127 | #define HDCS_DEFAULT_EXPOSURE 48 |
128 | #define HDCS_DEFAULT_GAIN 128 | 128 | #define HDCS_DEFAULT_GAIN 50 |
129 | 129 | ||
130 | static int hdcs_probe_1x00(struct sd *sd); | 130 | static int hdcs_probe_1x00(struct sd *sd); |
131 | static int hdcs_probe_1020(struct sd *sd); | 131 | static int hdcs_probe_1020(struct sd *sd); |
@@ -146,6 +146,11 @@ const struct stv06xx_sensor stv06xx_sensor_hdcs1x00 = { | |||
146 | .i2c_addr = (0x55 << 1), | 146 | .i2c_addr = (0x55 << 1), |
147 | .i2c_len = 1, | 147 | .i2c_len = 1, |
148 | 148 | ||
149 | /* FIXME (see if we can lower min_packet_size, needs testing, and also | ||
150 | adjusting framerate when the bandwidth gets lower) */ | ||
151 | .min_packet_size = { 847 }, | ||
152 | .max_packet_size = { 847 }, | ||
153 | |||
149 | .init = hdcs_init, | 154 | .init = hdcs_init, |
150 | .probe = hdcs_probe_1x00, | 155 | .probe = hdcs_probe_1x00, |
151 | .start = hdcs_start, | 156 | .start = hdcs_start, |
@@ -160,6 +165,11 @@ const struct stv06xx_sensor stv06xx_sensor_hdcs1020 = { | |||
160 | .i2c_addr = (0x55 << 1), | 165 | .i2c_addr = (0x55 << 1), |
161 | .i2c_len = 1, | 166 | .i2c_len = 1, |
162 | 167 | ||
168 | /* FIXME (see if we can lower min_packet_size, needs testing, and also | ||
169 | adjusting framerate when the bandwidthm gets lower) */ | ||
170 | .min_packet_size = { 847 }, | ||
171 | .max_packet_size = { 847 }, | ||
172 | |||
163 | .init = hdcs_init, | 173 | .init = hdcs_init, |
164 | .probe = hdcs_probe_1020, | 174 | .probe = hdcs_probe_1020, |
165 | .start = hdcs_start, | 175 | .start = hdcs_start, |
@@ -177,7 +187,6 @@ static const u16 stv_bridge_init[][2] = { | |||
177 | {STV_REG04, 0x07}, | 187 | {STV_REG04, 0x07}, |
178 | 188 | ||
179 | {STV_SCAN_RATE, 0x20}, | 189 | {STV_SCAN_RATE, 0x20}, |
180 | {STV_ISO_SIZE_L, 847}, | ||
181 | {STV_Y_CTRL, 0x01}, | 190 | {STV_Y_CTRL, 0x01}, |
182 | {STV_X_CTRL, 0x0a} | 191 | {STV_X_CTRL, 0x0a} |
183 | }; | 192 | }; |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c index 285221e6b390..75a5b9c2f15f 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c +++ b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c | |||
@@ -208,11 +208,26 @@ static int pb0100_probe(struct sd *sd) | |||
208 | 208 | ||
209 | static int pb0100_start(struct sd *sd) | 209 | static int pb0100_start(struct sd *sd) |
210 | { | 210 | { |
211 | int err; | 211 | int err, packet_size, max_packet_size; |
212 | struct usb_host_interface *alt; | ||
213 | struct usb_interface *intf; | ||
212 | struct cam *cam = &sd->gspca_dev.cam; | 214 | struct cam *cam = &sd->gspca_dev.cam; |
213 | s32 *sensor_settings = sd->sensor_priv; | 215 | s32 *sensor_settings = sd->sensor_priv; |
214 | u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv; | 216 | u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv; |
215 | 217 | ||
218 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | ||
219 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | ||
220 | if (!alt) | ||
221 | return -ENODEV; | ||
222 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
223 | |||
224 | /* If we don't have enough bandwidth use a lower framerate */ | ||
225 | max_packet_size = sd->sensor->max_packet_size[sd->gspca_dev.curr_mode]; | ||
226 | if (packet_size < max_packet_size) | ||
227 | stv06xx_write_sensor(sd, PB_ROWSPEED, BIT(4)|BIT(3)|BIT(1)); | ||
228 | else | ||
229 | stv06xx_write_sensor(sd, PB_ROWSPEED, BIT(5)|BIT(3)|BIT(1)); | ||
230 | |||
216 | /* Setup sensor window */ | 231 | /* Setup sensor window */ |
217 | if (mode & PB0100_CROP_TO_VGA) { | 232 | if (mode & PB0100_CROP_TO_VGA) { |
218 | stv06xx_write_sensor(sd, PB_RSTART, 30); | 233 | stv06xx_write_sensor(sd, PB_RSTART, 30); |
@@ -328,9 +343,6 @@ static int pb0100_init(struct sd *sd) | |||
328 | stv06xx_write_bridge(sd, STV_REG03, 0x45); | 343 | stv06xx_write_bridge(sd, STV_REG03, 0x45); |
329 | stv06xx_write_bridge(sd, STV_REG04, 0x07); | 344 | stv06xx_write_bridge(sd, STV_REG04, 0x07); |
330 | 345 | ||
331 | /* ISO-Size (0x27b: 635... why? - HDCS uses 847) */ | ||
332 | stv06xx_write_bridge(sd, STV_ISO_SIZE_L, 847); | ||
333 | |||
334 | /* Scan/timing for the sensor */ | 346 | /* Scan/timing for the sensor */ |
335 | stv06xx_write_sensor(sd, PB_ROWSPEED, BIT(4)|BIT(3)|BIT(1)); | 347 | stv06xx_write_sensor(sd, PB_ROWSPEED, BIT(4)|BIT(3)|BIT(1)); |
336 | stv06xx_write_sensor(sd, PB_CFILLIN, 14); | 348 | stv06xx_write_sensor(sd, PB_CFILLIN, 14); |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.h b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.h index 4de4fa5ebc57..757de246dc75 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.h +++ b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.h | |||
@@ -138,6 +138,9 @@ const struct stv06xx_sensor stv06xx_sensor_pb0100 = { | |||
138 | .i2c_addr = 0xba, | 138 | .i2c_addr = 0xba, |
139 | .i2c_len = 2, | 139 | .i2c_len = 2, |
140 | 140 | ||
141 | .min_packet_size = { 635, 847 }, | ||
142 | .max_packet_size = { 847, 923 }, | ||
143 | |||
141 | .init = pb0100_init, | 144 | .init = pb0100_init, |
142 | .probe = pb0100_probe, | 145 | .probe = pb0100_probe, |
143 | .start = pb0100_start, | 146 | .start = pb0100_start, |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h b/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h index 934b9cebc1ab..fb229d8ded58 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h +++ b/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h | |||
@@ -53,6 +53,10 @@ struct stv06xx_sensor { | |||
53 | /* length of an i2c word */ | 53 | /* length of an i2c word */ |
54 | u8 i2c_len; | 54 | u8 i2c_len; |
55 | 55 | ||
56 | /* Isoc packet size (per mode) */ | ||
57 | int min_packet_size[4]; | ||
58 | int max_packet_size[4]; | ||
59 | |||
56 | /* Probes if the sensor is connected */ | 60 | /* Probes if the sensor is connected */ |
57 | int (*probe)(struct sd *sd); | 61 | int (*probe)(struct sd *sd); |
58 | 62 | ||
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c index c11f06e4ae76..8a456de4970a 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c +++ b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c | |||
@@ -28,6 +28,20 @@ | |||
28 | 28 | ||
29 | #include "stv06xx_st6422.h" | 29 | #include "stv06xx_st6422.h" |
30 | 30 | ||
31 | /* controls */ | ||
32 | enum e_ctrl { | ||
33 | BRIGHTNESS, | ||
34 | CONTRAST, | ||
35 | GAIN, | ||
36 | EXPOSURE, | ||
37 | NCTRLS /* number of controls */ | ||
38 | }; | ||
39 | |||
40 | /* sensor settings */ | ||
41 | struct st6422_settings { | ||
42 | struct gspca_ctrl ctrls[NCTRLS]; | ||
43 | }; | ||
44 | |||
31 | static struct v4l2_pix_format st6422_mode[] = { | 45 | static struct v4l2_pix_format st6422_mode[] = { |
32 | /* Note we actually get 124 lines of data, of which we skip the 4st | 46 | /* Note we actually get 124 lines of data, of which we skip the 4st |
33 | 4 as they are garbage */ | 47 | 4 as they are garbage */ |
@@ -57,9 +71,14 @@ static struct v4l2_pix_format st6422_mode[] = { | |||
57 | }, | 71 | }, |
58 | }; | 72 | }; |
59 | 73 | ||
60 | static const struct ctrl st6422_ctrl[] = { | 74 | /* V4L2 controls supported by the driver */ |
61 | #define BRIGHTNESS_IDX 0 | 75 | static void st6422_set_brightness(struct gspca_dev *gspca_dev); |
62 | { | 76 | static void st6422_set_contrast(struct gspca_dev *gspca_dev); |
77 | static void st6422_set_gain(struct gspca_dev *gspca_dev); | ||
78 | static void st6422_set_exposure(struct gspca_dev *gspca_dev); | ||
79 | |||
80 | static const struct ctrl st6422_ctrl[NCTRLS] = { | ||
81 | [BRIGHTNESS] = { | ||
63 | { | 82 | { |
64 | .id = V4L2_CID_BRIGHTNESS, | 83 | .id = V4L2_CID_BRIGHTNESS, |
65 | .type = V4L2_CTRL_TYPE_INTEGER, | 84 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -69,11 +88,9 @@ static const struct ctrl st6422_ctrl[] = { | |||
69 | .step = 1, | 88 | .step = 1, |
70 | .default_value = 3 | 89 | .default_value = 3 |
71 | }, | 90 | }, |
72 | .set = st6422_set_brightness, | 91 | .set_control = st6422_set_brightness |
73 | .get = st6422_get_brightness | ||
74 | }, | 92 | }, |
75 | #define CONTRAST_IDX 1 | 93 | [CONTRAST] = { |
76 | { | ||
77 | { | 94 | { |
78 | .id = V4L2_CID_CONTRAST, | 95 | .id = V4L2_CID_CONTRAST, |
79 | .type = V4L2_CTRL_TYPE_INTEGER, | 96 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -83,11 +100,9 @@ static const struct ctrl st6422_ctrl[] = { | |||
83 | .step = 1, | 100 | .step = 1, |
84 | .default_value = 11 | 101 | .default_value = 11 |
85 | }, | 102 | }, |
86 | .set = st6422_set_contrast, | 103 | .set_control = st6422_set_contrast |
87 | .get = st6422_get_contrast | ||
88 | }, | 104 | }, |
89 | #define GAIN_IDX 2 | 105 | [GAIN] = { |
90 | { | ||
91 | { | 106 | { |
92 | .id = V4L2_CID_GAIN, | 107 | .id = V4L2_CID_GAIN, |
93 | .type = V4L2_CTRL_TYPE_INTEGER, | 108 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -97,49 +112,43 @@ static const struct ctrl st6422_ctrl[] = { | |||
97 | .step = 1, | 112 | .step = 1, |
98 | .default_value = 64 | 113 | .default_value = 64 |
99 | }, | 114 | }, |
100 | .set = st6422_set_gain, | 115 | .set_control = st6422_set_gain |
101 | .get = st6422_get_gain | ||
102 | }, | 116 | }, |
103 | #define EXPOSURE_IDX 3 | 117 | [EXPOSURE] = { |
104 | { | ||
105 | { | 118 | { |
106 | .id = V4L2_CID_EXPOSURE, | 119 | .id = V4L2_CID_EXPOSURE, |
107 | .type = V4L2_CTRL_TYPE_INTEGER, | 120 | .type = V4L2_CTRL_TYPE_INTEGER, |
108 | .name = "Exposure", | 121 | .name = "Exposure", |
109 | .minimum = 0, | 122 | .minimum = 0, |
110 | .maximum = 1023, | 123 | #define EXPOSURE_MAX 1023 |
124 | .maximum = EXPOSURE_MAX, | ||
111 | .step = 1, | 125 | .step = 1, |
112 | .default_value = 256 | 126 | .default_value = 256 |
113 | }, | 127 | }, |
114 | .set = st6422_set_exposure, | 128 | .set_control = st6422_set_exposure |
115 | .get = st6422_get_exposure | ||
116 | }, | 129 | }, |
117 | }; | 130 | }; |
118 | 131 | ||
119 | static int st6422_probe(struct sd *sd) | 132 | static int st6422_probe(struct sd *sd) |
120 | { | 133 | { |
121 | int i; | 134 | struct st6422_settings *sensor_settings; |
122 | s32 *sensor_settings; | ||
123 | 135 | ||
124 | if (sd->bridge != BRIDGE_ST6422) | 136 | if (sd->bridge != BRIDGE_ST6422) |
125 | return -ENODEV; | 137 | return -ENODEV; |
126 | 138 | ||
127 | info("st6422 sensor detected"); | 139 | info("st6422 sensor detected"); |
128 | 140 | ||
129 | sensor_settings = kmalloc(ARRAY_SIZE(st6422_ctrl) * sizeof(s32), | 141 | sensor_settings = kmalloc(sizeof *sensor_settings, GFP_KERNEL); |
130 | GFP_KERNEL); | ||
131 | if (!sensor_settings) | 142 | if (!sensor_settings) |
132 | return -ENOMEM; | 143 | return -ENOMEM; |
133 | 144 | ||
134 | sd->gspca_dev.cam.cam_mode = st6422_mode; | 145 | sd->gspca_dev.cam.cam_mode = st6422_mode; |
135 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(st6422_mode); | 146 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(st6422_mode); |
147 | sd->gspca_dev.cam.ctrls = sensor_settings->ctrls; | ||
136 | sd->desc.ctrls = st6422_ctrl; | 148 | sd->desc.ctrls = st6422_ctrl; |
137 | sd->desc.nctrls = ARRAY_SIZE(st6422_ctrl); | 149 | sd->desc.nctrls = ARRAY_SIZE(st6422_ctrl); |
138 | sd->sensor_priv = sensor_settings; | 150 | sd->sensor_priv = sensor_settings; |
139 | 151 | ||
140 | for (i = 0; i < sd->desc.nctrls; i++) | ||
141 | sensor_settings[i] = st6422_ctrl[i].qctrl.default_value; | ||
142 | |||
143 | return 0; | 152 | return 0; |
144 | } | 153 | } |
145 | 154 | ||
@@ -151,11 +160,11 @@ static int st6422_init(struct sd *sd) | |||
151 | { STV_ISO_ENABLE, 0x00 }, /* disable capture */ | 160 | { STV_ISO_ENABLE, 0x00 }, /* disable capture */ |
152 | { 0x1436, 0x00 }, | 161 | { 0x1436, 0x00 }, |
153 | { 0x1432, 0x03 }, /* 0x00-0x1F brightness */ | 162 | { 0x1432, 0x03 }, /* 0x00-0x1F brightness */ |
154 | { 0x143a, 0xF9 }, /* 0x00-0x0F contrast */ | 163 | { 0x143a, 0xf9 }, /* 0x00-0x0F contrast */ |
155 | { 0x0509, 0x38 }, /* R */ | 164 | { 0x0509, 0x38 }, /* R */ |
156 | { 0x050a, 0x38 }, /* G */ | 165 | { 0x050a, 0x38 }, /* G */ |
157 | { 0x050b, 0x38 }, /* B */ | 166 | { 0x050b, 0x38 }, /* B */ |
158 | { 0x050c, 0x2A }, | 167 | { 0x050c, 0x2a }, |
159 | { 0x050d, 0x01 }, | 168 | { 0x050d, 0x01 }, |
160 | 169 | ||
161 | 170 | ||
@@ -213,7 +222,6 @@ static int st6422_init(struct sd *sd) | |||
213 | { 0x150e, 0x8e }, | 222 | { 0x150e, 0x8e }, |
214 | { 0x150f, 0x37 }, | 223 | { 0x150f, 0x37 }, |
215 | { 0x15c0, 0x00 }, | 224 | { 0x15c0, 0x00 }, |
216 | { 0x15c1, 1023 }, /* 160x120, ISOC_PACKET_SIZE */ | ||
217 | { 0x15c3, 0x08 }, /* 0x04/0x14 ... test pictures ??? */ | 225 | { 0x15c3, 0x08 }, /* 0x04/0x14 ... test pictures ??? */ |
218 | 226 | ||
219 | 227 | ||
@@ -235,91 +243,92 @@ static void st6422_disconnect(struct sd *sd) | |||
235 | kfree(sd->sensor_priv); | 243 | kfree(sd->sensor_priv); |
236 | } | 244 | } |
237 | 245 | ||
238 | static int st6422_start(struct sd *sd) | 246 | static int setbrightness(struct sd *sd) |
239 | { | 247 | { |
240 | int err, packet_size; | 248 | struct st6422_settings *sensor_settings = sd->sensor_priv; |
241 | struct cam *cam = &sd->gspca_dev.cam; | ||
242 | s32 *sensor_settings = sd->sensor_priv; | ||
243 | struct usb_host_interface *alt; | ||
244 | struct usb_interface *intf; | ||
245 | |||
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); | ||
248 | if (!alt) { | ||
249 | PDEBUG(D_ERR, "Couldn't get altsetting"); | ||
250 | return -EIO; | ||
251 | } | ||
252 | 249 | ||
253 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 250 | /* val goes from 0 -> 31 */ |
254 | err = stv06xx_write_bridge(sd, 0x15c1, packet_size); | 251 | return stv06xx_write_bridge(sd, 0x1432, |
255 | if (err < 0) | 252 | sensor_settings->ctrls[BRIGHTNESS].val); |
256 | return err; | 253 | } |
257 | 254 | ||
258 | if (cam->cam_mode[sd->gspca_dev.curr_mode].priv) | 255 | static int setcontrast(struct sd *sd) |
259 | err = stv06xx_write_bridge(sd, 0x1505, 0x0f); | 256 | { |
260 | else | 257 | struct st6422_settings *sensor_settings = sd->sensor_priv; |
261 | err = stv06xx_write_bridge(sd, 0x1505, 0x02); | 258 | |
262 | if (err < 0) | 259 | /* Val goes from 0 -> 15 */ |
263 | return err; | 260 | return stv06xx_write_bridge(sd, 0x143a, |
261 | sensor_settings->ctrls[CONTRAST].val | 0xf0); | ||
262 | } | ||
263 | |||
264 | static int setgain(struct sd *sd) | ||
265 | { | ||
266 | struct st6422_settings *sensor_settings = sd->sensor_priv; | ||
267 | u8 gain; | ||
268 | int err; | ||
269 | |||
270 | gain = sensor_settings->ctrls[GAIN].val; | ||
264 | 271 | ||
265 | err = st6422_set_brightness(&sd->gspca_dev, | 272 | /* Set red, green, blue, gain */ |
266 | sensor_settings[BRIGHTNESS_IDX]); | 273 | err = stv06xx_write_bridge(sd, 0x0509, gain); |
267 | if (err < 0) | 274 | if (err < 0) |
268 | return err; | 275 | return err; |
269 | 276 | ||
270 | err = st6422_set_contrast(&sd->gspca_dev, | 277 | err = stv06xx_write_bridge(sd, 0x050a, gain); |
271 | sensor_settings[CONTRAST_IDX]); | ||
272 | if (err < 0) | 278 | if (err < 0) |
273 | return err; | 279 | return err; |
274 | 280 | ||
275 | err = st6422_set_exposure(&sd->gspca_dev, | 281 | err = stv06xx_write_bridge(sd, 0x050b, gain); |
276 | sensor_settings[EXPOSURE_IDX]); | ||
277 | if (err < 0) | 282 | if (err < 0) |
278 | return err; | 283 | return err; |
279 | 284 | ||
280 | err = st6422_set_gain(&sd->gspca_dev, | 285 | /* 2 mystery writes */ |
281 | sensor_settings[GAIN_IDX]); | 286 | err = stv06xx_write_bridge(sd, 0x050c, 0x2a); |
282 | if (err < 0) | 287 | if (err < 0) |
283 | return err; | 288 | return err; |
284 | 289 | ||
285 | PDEBUG(D_STREAM, "Starting stream"); | 290 | return stv06xx_write_bridge(sd, 0x050d, 0x01); |
286 | |||
287 | return 0; | ||
288 | } | 291 | } |
289 | 292 | ||
290 | static int st6422_stop(struct sd *sd) | 293 | static int setexposure(struct sd *sd) |
291 | { | 294 | { |
292 | PDEBUG(D_STREAM, "Halting stream"); | 295 | struct st6422_settings *sensor_settings = sd->sensor_priv; |
293 | 296 | u16 expo; | |
294 | return 0; | 297 | int err; |
295 | } | ||
296 | |||
297 | static int st6422_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
298 | { | ||
299 | struct sd *sd = (struct sd *) gspca_dev; | ||
300 | s32 *sensor_settings = sd->sensor_priv; | ||
301 | |||
302 | *val = sensor_settings[BRIGHTNESS_IDX]; | ||
303 | 298 | ||
304 | PDEBUG(D_V4L2, "Read brightness %d", *val); | 299 | expo = sensor_settings->ctrls[EXPOSURE].val; |
300 | err = stv06xx_write_bridge(sd, 0x143d, expo & 0xff); | ||
301 | if (err < 0) | ||
302 | return err; | ||
305 | 303 | ||
306 | return 0; | 304 | return stv06xx_write_bridge(sd, 0x143e, expo >> 8); |
307 | } | 305 | } |
308 | 306 | ||
309 | static int st6422_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | 307 | static int st6422_start(struct sd *sd) |
310 | { | 308 | { |
311 | int err; | 309 | int err; |
312 | struct sd *sd = (struct sd *) gspca_dev; | 310 | struct cam *cam = &sd->gspca_dev.cam; |
313 | s32 *sensor_settings = sd->sensor_priv; | ||
314 | 311 | ||
315 | sensor_settings[BRIGHTNESS_IDX] = val; | 312 | if (cam->cam_mode[sd->gspca_dev.curr_mode].priv) |
313 | err = stv06xx_write_bridge(sd, 0x1505, 0x0f); | ||
314 | else | ||
315 | err = stv06xx_write_bridge(sd, 0x1505, 0x02); | ||
316 | if (err < 0) | ||
317 | return err; | ||
316 | 318 | ||
317 | if (!gspca_dev->streaming) | 319 | err = setbrightness(sd); |
318 | return 0; | 320 | if (err < 0) |
321 | return err; | ||
319 | 322 | ||
320 | /* val goes from 0 -> 31 */ | 323 | err = setcontrast(sd); |
321 | PDEBUG(D_V4L2, "Set brightness to %d", val); | 324 | if (err < 0) |
322 | err = stv06xx_write_bridge(sd, 0x1432, val); | 325 | return err; |
326 | |||
327 | err = setexposure(sd); | ||
328 | if (err < 0) | ||
329 | return err; | ||
330 | |||
331 | err = setgain(sd); | ||
323 | if (err < 0) | 332 | if (err < 0) |
324 | return err; | 333 | return err; |
325 | 334 | ||
@@ -328,125 +337,65 @@ static int st6422_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | |||
328 | return (err < 0) ? err : 0; | 337 | return (err < 0) ? err : 0; |
329 | } | 338 | } |
330 | 339 | ||
331 | static int st6422_get_contrast(struct gspca_dev *gspca_dev, __s32 *val) | 340 | static int st6422_stop(struct sd *sd) |
332 | { | 341 | { |
333 | struct sd *sd = (struct sd *) gspca_dev; | 342 | PDEBUG(D_STREAM, "Halting stream"); |
334 | s32 *sensor_settings = sd->sensor_priv; | ||
335 | |||
336 | *val = sensor_settings[CONTRAST_IDX]; | ||
337 | |||
338 | PDEBUG(D_V4L2, "Read contrast %d", *val); | ||
339 | 343 | ||
340 | return 0; | 344 | return 0; |
341 | } | 345 | } |
342 | 346 | ||
343 | static int st6422_set_contrast(struct gspca_dev *gspca_dev, __s32 val) | 347 | static void st6422_set_brightness(struct gspca_dev *gspca_dev) |
344 | { | 348 | { |
345 | int err; | 349 | int err; |
346 | struct sd *sd = (struct sd *) gspca_dev; | 350 | struct sd *sd = (struct sd *) gspca_dev; |
347 | s32 *sensor_settings = sd->sensor_priv; | ||
348 | |||
349 | sensor_settings[CONTRAST_IDX] = val; | ||
350 | 351 | ||
351 | if (!gspca_dev->streaming) | 352 | err = setbrightness(sd); |
352 | return 0; | ||
353 | |||
354 | /* Val goes from 0 -> 15 */ | ||
355 | PDEBUG(D_V4L2, "Set contrast to %d\n", val); | ||
356 | err = stv06xx_write_bridge(sd, 0x143a, 0xf0 | val); | ||
357 | if (err < 0) | ||
358 | return err; | ||
359 | 353 | ||
360 | /* commit settings */ | 354 | /* commit settings */ |
361 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | 355 | if (err >= 0) |
362 | return (err < 0) ? err : 0; | 356 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); |
363 | } | ||
364 | |||
365 | static int st6422_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | ||
366 | { | ||
367 | struct sd *sd = (struct sd *) gspca_dev; | ||
368 | s32 *sensor_settings = sd->sensor_priv; | ||
369 | |||
370 | *val = sensor_settings[GAIN_IDX]; | ||
371 | |||
372 | PDEBUG(D_V4L2, "Read gain %d", *val); | ||
373 | 357 | ||
374 | return 0; | 358 | gspca_dev->usb_err = err; |
375 | } | 359 | } |
376 | 360 | ||
377 | static int st6422_set_gain(struct gspca_dev *gspca_dev, __s32 val) | 361 | static void st6422_set_contrast(struct gspca_dev *gspca_dev) |
378 | { | 362 | { |
379 | int err; | 363 | int err; |
380 | struct sd *sd = (struct sd *) gspca_dev; | 364 | struct sd *sd = (struct sd *) gspca_dev; |
381 | s32 *sensor_settings = sd->sensor_priv; | ||
382 | |||
383 | sensor_settings[GAIN_IDX] = val; | ||
384 | |||
385 | if (!gspca_dev->streaming) | ||
386 | return 0; | ||
387 | |||
388 | PDEBUG(D_V4L2, "Set gain to %d", val); | ||
389 | 365 | ||
390 | /* Set red, green, blue, gain */ | 366 | err = setcontrast(sd); |
391 | err = stv06xx_write_bridge(sd, 0x0509, val); | ||
392 | if (err < 0) | ||
393 | return err; | ||
394 | |||
395 | err = stv06xx_write_bridge(sd, 0x050a, val); | ||
396 | if (err < 0) | ||
397 | return err; | ||
398 | |||
399 | err = stv06xx_write_bridge(sd, 0x050b, val); | ||
400 | if (err < 0) | ||
401 | return err; | ||
402 | |||
403 | /* 2 mystery writes */ | ||
404 | err = stv06xx_write_bridge(sd, 0x050c, 0x2a); | ||
405 | if (err < 0) | ||
406 | return err; | ||
407 | |||
408 | err = stv06xx_write_bridge(sd, 0x050d, 0x01); | ||
409 | if (err < 0) | ||
410 | return err; | ||
411 | 367 | ||
412 | /* commit settings */ | 368 | /* commit settings */ |
413 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | 369 | if (err >= 0) |
414 | return (err < 0) ? err : 0; | 370 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); |
371 | |||
372 | gspca_dev->usb_err = err; | ||
415 | } | 373 | } |
416 | 374 | ||
417 | static int st6422_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | 375 | static void st6422_set_gain(struct gspca_dev *gspca_dev) |
418 | { | 376 | { |
377 | int err; | ||
419 | struct sd *sd = (struct sd *) gspca_dev; | 378 | struct sd *sd = (struct sd *) gspca_dev; |
420 | s32 *sensor_settings = sd->sensor_priv; | ||
421 | 379 | ||
422 | *val = sensor_settings[EXPOSURE_IDX]; | 380 | err = setgain(sd); |
423 | 381 | ||
424 | PDEBUG(D_V4L2, "Read exposure %d", *val); | 382 | /* commit settings */ |
383 | if (err >= 0) | ||
384 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | ||
425 | 385 | ||
426 | return 0; | 386 | gspca_dev->usb_err = err; |
427 | } | 387 | } |
428 | 388 | ||
429 | static int st6422_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | 389 | static void st6422_set_exposure(struct gspca_dev *gspca_dev) |
430 | { | 390 | { |
431 | int err; | 391 | int err; |
432 | struct sd *sd = (struct sd *) gspca_dev; | 392 | struct sd *sd = (struct sd *) gspca_dev; |
433 | s32 *sensor_settings = sd->sensor_priv; | ||
434 | |||
435 | sensor_settings[EXPOSURE_IDX] = val; | ||
436 | 393 | ||
437 | if (!gspca_dev->streaming) | 394 | err = setexposure(sd); |
438 | return 0; | ||
439 | |||
440 | PDEBUG(D_V4L2, "Set exposure to %d\n", val); | ||
441 | err = stv06xx_write_bridge(sd, 0x143d, val & 0xff); | ||
442 | if (err < 0) | ||
443 | return err; | ||
444 | |||
445 | err = stv06xx_write_bridge(sd, 0x143e, val >> 8); | ||
446 | if (err < 0) | ||
447 | return err; | ||
448 | 395 | ||
449 | /* commit settings */ | 396 | /* commit settings */ |
450 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | 397 | if (err >= 0) |
451 | return (err < 0) ? err : 0; | 398 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); |
399 | |||
400 | gspca_dev->usb_err = err; | ||
452 | } | 401 | } |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h index b2d45fe50522..d7498e06432b 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h +++ b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h | |||
@@ -37,18 +37,11 @@ static int st6422_init(struct sd *sd); | |||
37 | static int st6422_stop(struct sd *sd); | 37 | static int st6422_stop(struct sd *sd); |
38 | static void st6422_disconnect(struct sd *sd); | 38 | static void st6422_disconnect(struct sd *sd); |
39 | 39 | ||
40 | /* V4L2 controls supported by the driver */ | ||
41 | static int st6422_get_brightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
42 | static int st6422_set_brightness(struct gspca_dev *gspca_dev, __s32 val); | ||
43 | static int st6422_get_contrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
44 | static int st6422_set_contrast(struct gspca_dev *gspca_dev, __s32 val); | ||
45 | static int st6422_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | ||
46 | static int st6422_set_gain(struct gspca_dev *gspca_dev, __s32 val); | ||
47 | static int st6422_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); | ||
48 | static int st6422_set_exposure(struct gspca_dev *gspca_dev, __s32 val); | ||
49 | |||
50 | const struct stv06xx_sensor stv06xx_sensor_st6422 = { | 40 | const struct stv06xx_sensor stv06xx_sensor_st6422 = { |
51 | .name = "ST6422", | 41 | .name = "ST6422", |
42 | /* No known way to lower framerate in case of less bandwidth */ | ||
43 | .min_packet_size = { 300, 847 }, | ||
44 | .max_packet_size = { 300, 847 }, | ||
52 | .init = st6422_init, | 45 | .init = st6422_init, |
53 | .probe = st6422_probe, | 46 | .probe = st6422_probe, |
54 | .start = st6422_start, | 47 | .start = st6422_start, |
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..7fe3587f5f71 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) |
@@ -197,6 +197,10 @@ const struct stv06xx_sensor stv06xx_sensor_vv6410 = { | |||
197 | .i2c_flush = 5, | 197 | .i2c_flush = 5, |
198 | .i2c_addr = 0x20, | 198 | .i2c_addr = 0x20, |
199 | .i2c_len = 1, | 199 | .i2c_len = 1, |
200 | /* FIXME (see if we can lower packet_size-s, needs testing, and also | ||
201 | adjusting framerate when the bandwidth gets lower) */ | ||
202 | .min_packet_size = { 1023 }, | ||
203 | .max_packet_size = { 1023 }, | ||
200 | .init = vv6410_init, | 204 | .init = vv6410_init, |
201 | .probe = vv6410_probe, | 205 | .probe = vv6410_probe, |
202 | .start = vv6410_start, | 206 | .start = vv6410_start, |
@@ -220,10 +224,6 @@ static const u8 x1536[] = { /* 0x1536 - 0x153b */ | |||
220 | 0x02, 0x00, 0x60, 0x01, 0x20, 0x01 | 224 | 0x02, 0x00, 0x60, 0x01, 0x20, 0x01 |
221 | }; | 225 | }; |
222 | 226 | ||
223 | static const u8 x15c1[] = { /* 0x15c1 - 0x15c2 */ | ||
224 | 0xff, 0x03 /* Output word 0x03ff = 1023 (ISO size) */ | ||
225 | }; | ||
226 | |||
227 | static const struct stv_init stv_bridge_init[] = { | 227 | static const struct stv_init stv_bridge_init[] = { |
228 | /* This reg is written twice. Some kind of reset? */ | 228 | /* This reg is written twice. Some kind of reset? */ |
229 | {NULL, 0x1620, 0x80}, | 229 | {NULL, 0x1620, 0x80}, |
@@ -232,7 +232,6 @@ static const struct stv_init stv_bridge_init[] = { | |||
232 | {NULL, 0x1423, 0x04}, | 232 | {NULL, 0x1423, 0x04}, |
233 | {x1500, 0x1500, ARRAY_SIZE(x1500)}, | 233 | {x1500, 0x1500, ARRAY_SIZE(x1500)}, |
234 | {x1536, 0x1536, ARRAY_SIZE(x1536)}, | 234 | {x1536, 0x1536, ARRAY_SIZE(x1536)}, |
235 | {x15c1, 0x15c1, ARRAY_SIZE(x15c1)} | ||
236 | }; | 235 | }; |
237 | 236 | ||
238 | static const u8 vv6410_sensor_init[][2] = { | 237 | static const u8 vv6410_sensor_init[][2] = { |
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c index 9494f86b9a85..b089c0d3ee9f 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 | } |
@@ -396,57 +396,6 @@ static void reg_w_riv(struct gspca_dev *gspca_dev, | |||
396 | req, index, value); | 396 | req, index, value); |
397 | } | 397 | } |
398 | 398 | ||
399 | /* read 1 byte */ | ||
400 | static u8 reg_r_1(struct gspca_dev *gspca_dev, | ||
401 | u16 value) /* wValue */ | ||
402 | { | ||
403 | int ret; | ||
404 | |||
405 | if (gspca_dev->usb_err < 0) | ||
406 | return 0; | ||
407 | ret = usb_control_msg(gspca_dev->dev, | ||
408 | usb_rcvctrlpipe(gspca_dev->dev, 0), | ||
409 | 0x20, /* request */ | ||
410 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
411 | value, | ||
412 | 0, /* index */ | ||
413 | gspca_dev->usb_buf, 1, | ||
414 | 500); /* timeout */ | ||
415 | if (ret < 0) { | ||
416 | PDEBUG(D_ERR, "reg_r_1 err %d", ret); | ||
417 | gspca_dev->usb_err = ret; | ||
418 | return 0; | ||
419 | } | ||
420 | return gspca_dev->usb_buf[0]; | ||
421 | } | ||
422 | |||
423 | /* read 1 or 2 bytes */ | ||
424 | static u16 reg_r_12(struct gspca_dev *gspca_dev, | ||
425 | u8 req, /* bRequest */ | ||
426 | u16 index, /* wIndex */ | ||
427 | u16 length) /* wLength (1 or 2 only) */ | ||
428 | { | ||
429 | int ret; | ||
430 | |||
431 | if (gspca_dev->usb_err < 0) | ||
432 | return 0; | ||
433 | gspca_dev->usb_buf[1] = 0; | ||
434 | ret = usb_control_msg(gspca_dev->dev, | ||
435 | usb_rcvctrlpipe(gspca_dev->dev, 0), | ||
436 | req, | ||
437 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
438 | 0, /* value */ | ||
439 | index, | ||
440 | gspca_dev->usb_buf, length, | ||
441 | 500); | ||
442 | if (ret < 0) { | ||
443 | PDEBUG(D_ERR, "reg_r_12 err %d", ret); | ||
444 | gspca_dev->usb_err = ret; | ||
445 | return 0; | ||
446 | } | ||
447 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; | ||
448 | } | ||
449 | |||
450 | static void write_vector(struct gspca_dev *gspca_dev, | 399 | static void write_vector(struct gspca_dev *gspca_dev, |
451 | const struct cmd *data, int ncmds) | 400 | const struct cmd *data, int ncmds) |
452 | { | 401 | { |
@@ -463,7 +412,7 @@ static void setup_qtable(struct gspca_dev *gspca_dev, | |||
463 | 412 | ||
464 | /* loop over y components */ | 413 | /* loop over y components */ |
465 | for (i = 0; i < 64; i++) | 414 | for (i = 0; i < 64; i++) |
466 | reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]); | 415 | reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]); |
467 | 416 | ||
468 | /* loop over c components */ | 417 | /* loop over c components */ |
469 | for (i = 0; i < 64; i++) | 418 | for (i = 0; i < 64; i++) |
@@ -473,44 +422,46 @@ static void setup_qtable(struct gspca_dev *gspca_dev, | |||
473 | static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, | 422 | static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, |
474 | u8 req, u16 idx, u16 val) | 423 | u8 req, u16 idx, u16 val) |
475 | { | 424 | { |
476 | u16 notdone; | ||
477 | |||
478 | reg_w_riv(gspca_dev, req, idx, val); | 425 | reg_w_riv(gspca_dev, req, idx, val); |
479 | notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); | 426 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
427 | PDEBUG(D_FRAM, "before wait 0x%04x", gspca_dev->usb_buf[0]); | ||
480 | reg_w_riv(gspca_dev, req, idx, val); | 428 | reg_w_riv(gspca_dev, req, idx, val); |
481 | 429 | ||
482 | PDEBUG(D_FRAM, "before wait 0x%04x", notdone); | ||
483 | |||
484 | msleep(200); | 430 | msleep(200); |
485 | notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); | 431 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
486 | PDEBUG(D_FRAM, "after wait 0x%04x", notdone); | 432 | PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]); |
487 | } | 433 | } |
488 | 434 | ||
435 | #ifdef GSPCA_DEBUG | ||
489 | static void spca504_read_info(struct gspca_dev *gspca_dev) | 436 | static void spca504_read_info(struct gspca_dev *gspca_dev) |
490 | { | 437 | { |
491 | int i; | 438 | int i; |
492 | u8 info[6]; | 439 | u8 info[6]; |
493 | 440 | ||
494 | for (i = 0; i < 6; i++) | 441 | for (i = 0; i < 6; i++) { |
495 | info[i] = reg_r_1(gspca_dev, i); | 442 | reg_r(gspca_dev, 0, i, 1); |
443 | info[i] = gspca_dev->usb_buf[0]; | ||
444 | } | ||
496 | PDEBUG(D_STREAM, | 445 | PDEBUG(D_STREAM, |
497 | "Read info: %d %d %d %d %d %d." | 446 | "Read info: %d %d %d %d %d %d." |
498 | " Should be 1,0,2,2,0,0", | 447 | " Should be 1,0,2,2,0,0", |
499 | info[0], info[1], info[2], | 448 | info[0], info[1], info[2], |
500 | info[3], info[4], info[5]); | 449 | info[3], info[4], info[5]); |
501 | } | 450 | } |
451 | #endif | ||
502 | 452 | ||
503 | static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, | 453 | static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, |
504 | u8 req, | 454 | u8 req, |
505 | u16 idx, u16 val, u16 endcode, u8 count) | 455 | u16 idx, u16 val, u8 endcode, u8 count) |
506 | { | 456 | { |
507 | u16 status; | 457 | u16 status; |
508 | 458 | ||
509 | reg_w_riv(gspca_dev, req, idx, val); | 459 | reg_w_riv(gspca_dev, req, idx, val); |
510 | status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); | 460 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
511 | if (gspca_dev->usb_err < 0) | 461 | if (gspca_dev->usb_err < 0) |
512 | return; | 462 | return; |
513 | PDEBUG(D_FRAM, "Status 0x%04x Need 0x%04x", status, endcode); | 463 | PDEBUG(D_FRAM, "Status 0x%02x Need 0x%02x", |
464 | gspca_dev->usb_buf[0], endcode); | ||
514 | if (!count) | 465 | if (!count) |
515 | return; | 466 | return; |
516 | count = 200; | 467 | count = 200; |
@@ -518,7 +469,8 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, | |||
518 | msleep(10); | 469 | msleep(10); |
519 | /* gsmart mini2 write a each wait setting 1 ms is enough */ | 470 | /* gsmart mini2 write a each wait setting 1 ms is enough */ |
520 | /* reg_w_riv(gspca_dev, req, idx, val); */ | 471 | /* reg_w_riv(gspca_dev, req, idx, val); */ |
521 | status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); | 472 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
473 | status = gspca_dev->usb_buf[0]; | ||
522 | if (status == endcode) { | 474 | if (status == endcode) { |
523 | PDEBUG(D_FRAM, "status 0x%04x after wait %d", | 475 | PDEBUG(D_FRAM, "status 0x%04x after wait %d", |
524 | status, 200 - count); | 476 | status, 200 - count); |
@@ -555,17 +507,19 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) | |||
555 | } | 507 | } |
556 | } | 508 | } |
557 | 509 | ||
510 | #ifdef GSPCA_DEBUG | ||
558 | static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) | 511 | static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) |
559 | { | 512 | { |
560 | u8 *data; | 513 | u8 *data; |
561 | 514 | ||
562 | data = gspca_dev->usb_buf; | 515 | data = gspca_dev->usb_buf; |
563 | reg_r(gspca_dev, 0x20, 0, 5); | 516 | reg_r(gspca_dev, 0x20, 0, 5); |
564 | PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ", | 517 | PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d", |
565 | data[0], data[1], data[2], data[3], data[4]); | 518 | data[0], data[1], data[2], data[3], data[4]); |
566 | reg_r(gspca_dev, 0x23, 0, 64); | 519 | reg_r(gspca_dev, 0x23, 0, 64); |
567 | reg_r(gspca_dev, 0x23, 1, 64); | 520 | reg_r(gspca_dev, 0x23, 1, 64); |
568 | } | 521 | } |
522 | #endif | ||
569 | 523 | ||
570 | static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) | 524 | static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) |
571 | { | 525 | { |
@@ -578,7 +532,9 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) | |||
578 | reg_w_riv(gspca_dev, 0x31, 0, 0); | 532 | reg_w_riv(gspca_dev, 0x31, 0, 0); |
579 | spca504B_WaitCmdStatus(gspca_dev); | 533 | spca504B_WaitCmdStatus(gspca_dev); |
580 | spca504B_PollingDataReady(gspca_dev); | 534 | spca504B_PollingDataReady(gspca_dev); |
535 | #ifdef GSPCA_DEBUG | ||
581 | spca50x_GetFirmware(gspca_dev); | 536 | spca50x_GetFirmware(gspca_dev); |
537 | #endif | ||
582 | reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */ | 538 | reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */ |
583 | reg_r(gspca_dev, 0x24, 8, 1); | 539 | reg_r(gspca_dev, 0x24, 8, 1); |
584 | 540 | ||
@@ -628,7 +584,8 @@ static void spca504_wait_status(struct gspca_dev *gspca_dev) | |||
628 | cnt = 256; | 584 | cnt = 256; |
629 | while (--cnt > 0) { | 585 | while (--cnt > 0) { |
630 | /* With this we get the status, when return 0 it's all ok */ | 586 | /* With this we get the status, when return 0 it's all ok */ |
631 | if (reg_r_12(gspca_dev, 0x06, 0x00, 1) == 0) | 587 | reg_r(gspca_dev, 0x06, 0x00, 1); |
588 | if (gspca_dev->usb_buf[0] == 0) | ||
632 | return; | 589 | return; |
633 | msleep(10); | 590 | msleep(10); |
634 | } | 591 | } |
@@ -712,8 +669,9 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
712 | sd->subtype = id->driver_info; | 669 | sd->subtype = id->driver_info; |
713 | 670 | ||
714 | if (sd->subtype == AiptekMiniPenCam13) { | 671 | if (sd->subtype == AiptekMiniPenCam13) { |
715 | /* try to get the firmware as some cam answer 2.0.1.2.2 | 672 | |
716 | * and should be a spca504b then overwrite that setting */ | 673 | /* try to get the firmware as some cam answer 2.0.1.2.2 |
674 | * and should be a spca504b then overwrite that setting */ | ||
717 | reg_r(gspca_dev, 0x20, 0, 1); | 675 | reg_r(gspca_dev, 0x20, 0, 1); |
718 | switch (gspca_dev->usb_buf[0]) { | 676 | switch (gspca_dev->usb_buf[0]) { |
719 | case 1: | 677 | case 1: |
@@ -733,7 +691,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
733 | /* case BRIDGE_SPCA504: */ | 691 | /* case BRIDGE_SPCA504: */ |
734 | /* case BRIDGE_SPCA536: */ | 692 | /* case BRIDGE_SPCA536: */ |
735 | cam->cam_mode = vga_mode; | 693 | cam->cam_mode = vga_mode; |
736 | cam->nmodes =ARRAY_SIZE(vga_mode); | 694 | cam->nmodes = ARRAY_SIZE(vga_mode); |
737 | break; | 695 | break; |
738 | case BRIDGE_SPCA533: | 696 | case BRIDGE_SPCA533: |
739 | cam->cam_mode = custom_mode; | 697 | cam->cam_mode = custom_mode; |
@@ -771,10 +729,14 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
771 | /* fall thru */ | 729 | /* fall thru */ |
772 | case BRIDGE_SPCA533: | 730 | case BRIDGE_SPCA533: |
773 | spca504B_PollingDataReady(gspca_dev); | 731 | spca504B_PollingDataReady(gspca_dev); |
732 | #ifdef GSPCA_DEBUG | ||
774 | spca50x_GetFirmware(gspca_dev); | 733 | spca50x_GetFirmware(gspca_dev); |
734 | #endif | ||
775 | break; | 735 | break; |
776 | case BRIDGE_SPCA536: | 736 | case BRIDGE_SPCA536: |
737 | #ifdef GSPCA_DEBUG | ||
777 | spca50x_GetFirmware(gspca_dev); | 738 | spca50x_GetFirmware(gspca_dev); |
739 | #endif | ||
778 | reg_r(gspca_dev, 0x00, 0x5002, 1); | 740 | reg_r(gspca_dev, 0x00, 0x5002, 1); |
779 | reg_w_1(gspca_dev, 0x24, 0, 0, 0); | 741 | reg_w_1(gspca_dev, 0x24, 0, 0, 0); |
780 | reg_r(gspca_dev, 0x24, 0, 1); | 742 | reg_r(gspca_dev, 0x24, 0, 1); |
@@ -800,7 +762,9 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
800 | /* case BRIDGE_SPCA504: */ | 762 | /* case BRIDGE_SPCA504: */ |
801 | PDEBUG(D_STREAM, "Opening SPCA504"); | 763 | PDEBUG(D_STREAM, "Opening SPCA504"); |
802 | if (sd->subtype == AiptekMiniPenCam13) { | 764 | if (sd->subtype == AiptekMiniPenCam13) { |
765 | #ifdef GSPCA_DEBUG | ||
803 | spca504_read_info(gspca_dev); | 766 | spca504_read_info(gspca_dev); |
767 | #endif | ||
804 | 768 | ||
805 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ | 769 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ |
806 | spca504A_acknowledged_command(gspca_dev, 0x24, | 770 | spca504A_acknowledged_command(gspca_dev, 0x24, |
@@ -872,7 +836,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
872 | break; | 836 | break; |
873 | case BRIDGE_SPCA504: | 837 | case BRIDGE_SPCA504: |
874 | if (sd->subtype == AiptekMiniPenCam13) { | 838 | if (sd->subtype == AiptekMiniPenCam13) { |
839 | #ifdef GSPCA_DEBUG | ||
875 | spca504_read_info(gspca_dev); | 840 | spca504_read_info(gspca_dev); |
841 | #endif | ||
876 | 842 | ||
877 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ | 843 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ |
878 | spca504A_acknowledged_command(gspca_dev, 0x24, | 844 | spca504A_acknowledged_command(gspca_dev, 0x24, |
@@ -884,7 +850,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
884 | 0, 0, 0x9d, 1); | 850 | 0, 0, 0x9d, 1); |
885 | } else { | 851 | } else { |
886 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); | 852 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); |
853 | #ifdef GSPCA_DEBUG | ||
887 | spca504_read_info(gspca_dev); | 854 | spca504_read_info(gspca_dev); |
855 | #endif | ||
888 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); | 856 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); |
889 | spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); | 857 | spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); |
890 | } | 858 | } |
@@ -1161,7 +1129,7 @@ static const struct sd_desc sd_desc = { | |||
1161 | #define BS(bridge, subtype) \ | 1129 | #define BS(bridge, subtype) \ |
1162 | .driver_info = (BRIDGE_ ## bridge << 8) \ | 1130 | .driver_info = (BRIDGE_ ## bridge << 8) \ |
1163 | | (subtype) | 1131 | | (subtype) |
1164 | static const __devinitdata struct usb_device_id device_table[] = { | 1132 | static const struct usb_device_id device_table[] = { |
1165 | {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)}, | 1133 | {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)}, |
1166 | {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)}, | 1134 | {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)}, |
1167 | {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)}, | 1135 | {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)}, |
@@ -1247,17 +1215,11 @@ static struct usb_driver sd_driver = { | |||
1247 | /* -- module insert / remove -- */ | 1215 | /* -- module insert / remove -- */ |
1248 | static int __init sd_mod_init(void) | 1216 | static int __init sd_mod_init(void) |
1249 | { | 1217 | { |
1250 | int ret; | 1218 | 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 | } | 1219 | } |
1257 | static void __exit sd_mod_exit(void) | 1220 | static void __exit sd_mod_exit(void) |
1258 | { | 1221 | { |
1259 | usb_deregister(&sd_driver); | 1222 | usb_deregister(&sd_driver); |
1260 | PDEBUG(D_PROBE, "deregistered"); | ||
1261 | } | 1223 | } |
1262 | 1224 | ||
1263 | module_init(sd_mod_init); | 1225 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index 3b3b983f2b9d..7e762d551099 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c | |||
@@ -92,8 +92,6 @@ static int sd_setmirror(struct gspca_dev *gspca_dev, __s32 val); | |||
92 | static int sd_getmirror(struct gspca_dev *gspca_dev, __s32 *val); | 92 | static int sd_getmirror(struct gspca_dev *gspca_dev, __s32 *val); |
93 | static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val); | 93 | static int sd_seteffect(struct gspca_dev *gspca_dev, __s32 val); |
94 | static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val); | 94 | static int sd_geteffect(struct gspca_dev *gspca_dev, __s32 *val); |
95 | static int sd_querymenu(struct gspca_dev *gspca_dev, | ||
96 | struct v4l2_querymenu *menu); | ||
97 | 95 | ||
98 | static const struct ctrl sd_ctrls[] = { | 96 | static const struct ctrl sd_ctrls[] = { |
99 | { | 97 | { |
@@ -487,7 +485,7 @@ static const u8 gamma_table[GAMMA_MAX][17] = { | |||
487 | {0x00, 0x02, 0x07, 0x0f, 0x18, 0x24, 0x30, 0x3f, /* 3 */ | 485 | {0x00, 0x02, 0x07, 0x0f, 0x18, 0x24, 0x30, 0x3f, /* 3 */ |
488 | 0x4f, 0x61, 0x73, 0x88, 0x9d, 0xb4, 0xcd, 0xe6, | 486 | 0x4f, 0x61, 0x73, 0x88, 0x9d, 0xb4, 0xcd, 0xe6, |
489 | 0xff}, | 487 | 0xff}, |
490 | {0x00, 0x04, 0x0B, 0x15, 0x20, 0x2d, 0x3b, 0x4a, /* 4 */ | 488 | {0x00, 0x04, 0x0b, 0x15, 0x20, 0x2d, 0x3b, 0x4a, /* 4 */ |
491 | 0x5b, 0x6c, 0x7f, 0x92, 0xa7, 0xbc, 0xd2, 0xe9, | 489 | 0x5b, 0x6c, 0x7f, 0x92, 0xa7, 0xbc, 0xd2, 0xe9, |
492 | 0xff}, | 490 | 0xff}, |
493 | {0x00, 0x07, 0x11, 0x15, 0x20, 0x2d, 0x48, 0x58, /* 5 */ | 491 | {0x00, 0x07, 0x11, 0x15, 0x20, 0x2d, 0x48, 0x58, /* 5 */ |
@@ -892,7 +890,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
892 | sd->sensor = SENSOR_OM6802; | 890 | sd->sensor = SENSOR_OM6802; |
893 | break; | 891 | break; |
894 | default: | 892 | default: |
895 | PDEBUG(D_ERR|D_PROBE, "unknown sensor %04x", sensor_id); | 893 | err("unknown sensor %04x", sensor_id); |
896 | return -EINVAL; | 894 | return -EINVAL; |
897 | } | 895 | } |
898 | 896 | ||
@@ -1379,17 +1377,14 @@ static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val) | |||
1379 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 1377 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
1380 | struct v4l2_querymenu *menu) | 1378 | struct v4l2_querymenu *menu) |
1381 | { | 1379 | { |
1380 | static const char *freq_nm[3] = {"NoFliker", "50 Hz", "60 Hz"}; | ||
1381 | |||
1382 | switch (menu->id) { | 1382 | switch (menu->id) { |
1383 | case V4L2_CID_POWER_LINE_FREQUENCY: | 1383 | case V4L2_CID_POWER_LINE_FREQUENCY: |
1384 | switch (menu->index) { | 1384 | if ((unsigned) menu->index >= ARRAY_SIZE(freq_nm)) |
1385 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | 1385 | break; |
1386 | strcpy((char *) menu->name, "50 Hz"); | 1386 | strcpy((char *) menu->name, freq_nm[menu->index]); |
1387 | return 0; | 1387 | return 0; |
1388 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | ||
1389 | strcpy((char *) menu->name, "60 Hz"); | ||
1390 | return 0; | ||
1391 | } | ||
1392 | break; | ||
1393 | case V4L2_CID_EFFECTS: | 1388 | case V4L2_CID_EFFECTS: |
1394 | if ((unsigned) menu->index < ARRAY_SIZE(effects_control)) { | 1389 | if ((unsigned) menu->index < ARRAY_SIZE(effects_control)) { |
1395 | strncpy((char *) menu->name, | 1390 | strncpy((char *) menu->name, |
@@ -1416,7 +1411,7 @@ static const struct sd_desc sd_desc = { | |||
1416 | }; | 1411 | }; |
1417 | 1412 | ||
1418 | /* -- module initialisation -- */ | 1413 | /* -- module initialisation -- */ |
1419 | static const __devinitdata struct usb_device_id device_table[] = { | 1414 | static const struct usb_device_id device_table[] = { |
1420 | {USB_DEVICE(0x17a1, 0x0128)}, | 1415 | {USB_DEVICE(0x17a1, 0x0128)}, |
1421 | {} | 1416 | {} |
1422 | }; | 1417 | }; |
@@ -1444,17 +1439,11 @@ static struct usb_driver sd_driver = { | |||
1444 | /* -- module insert / remove -- */ | 1439 | /* -- module insert / remove -- */ |
1445 | static int __init sd_mod_init(void) | 1440 | static int __init sd_mod_init(void) |
1446 | { | 1441 | { |
1447 | int ret; | 1442 | 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 | } | 1443 | } |
1454 | static void __exit sd_mod_exit(void) | 1444 | static void __exit sd_mod_exit(void) |
1455 | { | 1445 | { |
1456 | usb_deregister(&sd_driver); | 1446 | usb_deregister(&sd_driver); |
1457 | PDEBUG(D_PROBE, "deregistered"); | ||
1458 | } | 1447 | } |
1459 | 1448 | ||
1460 | module_init(sd_mod_init); | 1449 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c index d9c5bf3449d4..933ef2ca658c 100644 --- a/drivers/media/video/gspca/tv8532.c +++ b/drivers/media/video/gspca/tv8532.c | |||
@@ -132,7 +132,7 @@ static const struct v4l2_pix_format sif_mode[] = { | |||
132 | #define R36_PID 0x36 | 132 | #define R36_PID 0x36 |
133 | #define R37_PIDH 0x37 | 133 | #define R37_PIDH 0x37 |
134 | #define R39_Test1 0x39 /* GPIO */ | 134 | #define R39_Test1 0x39 /* GPIO */ |
135 | #define R3B_Test3 0x3B /* GPIO */ | 135 | #define R3B_Test3 0x3b /* GPIO */ |
136 | #define R83_AD_IDH 0x83 | 136 | #define R83_AD_IDH 0x83 |
137 | #define R91_AD_SLOPEREG 0x91 | 137 | #define R91_AD_SLOPEREG 0x91 |
138 | #define R94_AD_BITCONTROL 0x94 | 138 | #define R94_AD_BITCONTROL 0x94 |
@@ -388,7 +388,7 @@ static const struct sd_desc sd_desc = { | |||
388 | }; | 388 | }; |
389 | 389 | ||
390 | /* -- module initialisation -- */ | 390 | /* -- module initialisation -- */ |
391 | static const __devinitdata struct usb_device_id device_table[] = { | 391 | static const struct usb_device_id device_table[] = { |
392 | {USB_DEVICE(0x046d, 0x0920)}, | 392 | {USB_DEVICE(0x046d, 0x0920)}, |
393 | {USB_DEVICE(0x046d, 0x0921)}, | 393 | {USB_DEVICE(0x046d, 0x0921)}, |
394 | {USB_DEVICE(0x0545, 0x808b)}, | 394 | {USB_DEVICE(0x0545, 0x808b)}, |
@@ -421,18 +421,12 @@ static struct usb_driver sd_driver = { | |||
421 | /* -- module insert / remove -- */ | 421 | /* -- module insert / remove -- */ |
422 | static int __init sd_mod_init(void) | 422 | static 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 | ||
432 | static void __exit sd_mod_exit(void) | 427 | static 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 | ||
438 | module_init(sd_mod_init); | 432 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index b16fd47e8ced..6caed734a06a 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c | |||
@@ -47,24 +47,29 @@ struct sd { | |||
47 | u8 image_offset; | 47 | u8 image_offset; |
48 | 48 | ||
49 | u8 bridge; | 49 | u8 bridge; |
50 | #define BRIDGE_VC0321 0 | ||
51 | #define BRIDGE_VC0323 1 | ||
52 | u8 sensor; | 50 | u8 sensor; |
53 | #define SENSOR_HV7131R 0 | ||
54 | #define SENSOR_MI0360 1 | ||
55 | #define SENSOR_MI1310_SOC 2 | ||
56 | #define SENSOR_MI1320 3 | ||
57 | #define SENSOR_MI1320_SOC 4 | ||
58 | #define SENSOR_OV7660 5 | ||
59 | #define SENSOR_OV7670 6 | ||
60 | #define SENSOR_PO1200 7 | ||
61 | #define SENSOR_PO3130NC 8 | ||
62 | #define SENSOR_POxxxx 9 | ||
63 | u8 flags; | 51 | u8 flags; |
64 | #define FL_SAMSUNG 0x01 /* SamsungQ1 (2 sensors) */ | 52 | #define FL_SAMSUNG 0x01 /* SamsungQ1 (2 sensors) */ |
65 | #define FL_HFLIP 0x02 /* mirrored by default */ | 53 | #define FL_HFLIP 0x02 /* mirrored by default */ |
66 | #define FL_VFLIP 0x04 /* vertical flipped by default */ | 54 | #define FL_VFLIP 0x04 /* vertical flipped by default */ |
67 | }; | 55 | }; |
56 | enum bridges { | ||
57 | BRIDGE_VC0321, | ||
58 | BRIDGE_VC0323, | ||
59 | }; | ||
60 | enum sensors { | ||
61 | SENSOR_HV7131R, | ||
62 | SENSOR_MI0360, | ||
63 | SENSOR_MI1310_SOC, | ||
64 | SENSOR_MI1320, | ||
65 | SENSOR_MI1320_SOC, | ||
66 | SENSOR_OV7660, | ||
67 | SENSOR_OV7670, | ||
68 | SENSOR_PO1200, | ||
69 | SENSOR_PO3130NC, | ||
70 | SENSOR_POxxxx, | ||
71 | NSENSORS | ||
72 | }; | ||
68 | 73 | ||
69 | /* V4L2 controls supported by the driver */ | 74 | /* V4L2 controls supported by the driver */ |
70 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 75 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); |
@@ -260,56 +265,56 @@ static const struct ctrl sd_ctrls[] = { | |||
260 | }; | 265 | }; |
261 | 266 | ||
262 | /* table of the disabled controls */ | 267 | /* table of the disabled controls */ |
263 | static u32 ctrl_dis[] = { | 268 | static u32 ctrl_dis[NSENSORS] = { |
264 | /* SENSOR_HV7131R 0 */ | 269 | [SENSOR_HV7131R] = |
265 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 270 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
266 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) | 271 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) |
267 | | (1 << SHARPNESS_IDX) | 272 | | (1 << SHARPNESS_IDX) |
268 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 273 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
269 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 274 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
270 | /* SENSOR_MI0360 1 */ | 275 | [SENSOR_MI0360] = |
271 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 276 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
272 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) | 277 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) |
273 | | (1 << SHARPNESS_IDX) | 278 | | (1 << SHARPNESS_IDX) |
274 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 279 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
275 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 280 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
276 | /* SENSOR_MI1310_SOC 2 */ | 281 | [SENSOR_MI1310_SOC] = |
277 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 282 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
278 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) | 283 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) |
279 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 284 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
280 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 285 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
281 | /* SENSOR_MI1320 3 */ | 286 | [SENSOR_MI1320] = |
282 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 287 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
283 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) | 288 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) |
284 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 289 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
285 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 290 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
286 | /* SENSOR_MI1320_SOC 4 */ | 291 | [SENSOR_MI1320_SOC] = |
287 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 292 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
288 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) | 293 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) |
289 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 294 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
290 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 295 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
291 | /* SENSOR_OV7660 5 */ | 296 | [SENSOR_OV7660] = |
292 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 297 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
293 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) | 298 | | (1 << LIGHTFREQ_IDX) | (1 << SHARPNESS_IDX) |
294 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 299 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
295 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 300 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
296 | /* SENSOR_OV7670 6 */ | 301 | [SENSOR_OV7670] = |
297 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 302 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
298 | | (1 << SHARPNESS_IDX) | 303 | | (1 << SHARPNESS_IDX) |
299 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 304 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
300 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 305 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
301 | /* SENSOR_PO1200 7 */ | 306 | [SENSOR_PO1200] = |
302 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 307 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
303 | | (1 << LIGHTFREQ_IDX) | 308 | | (1 << LIGHTFREQ_IDX) |
304 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 309 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
305 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 310 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
306 | /* SENSOR_PO3130NC 8 */ | 311 | [SENSOR_PO3130NC] = |
307 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) | 312 | (1 << BRIGHTNESS_IDX) | (1 << CONTRAST_IDX) | (1 << COLORS_IDX) |
308 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) | 313 | | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX) |
309 | | (1 << SHARPNESS_IDX) | 314 | | (1 << SHARPNESS_IDX) |
310 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) | 315 | | (1 << GAIN_IDX) | (1 << EXPOSURE_IDX) |
311 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), | 316 | | (1 << AUTOGAIN_IDX) | (1 << BACKLIGHT_IDX), |
312 | /* SENSOR_POxxxx 9 */ | 317 | [SENSOR_POxxxx] = |
313 | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX), | 318 | (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << LIGHTFREQ_IDX), |
314 | }; | 319 | }; |
315 | 320 | ||
@@ -3164,7 +3169,7 @@ static void reg_r_i(struct gspca_dev *gspca_dev, | |||
3164 | index, gspca_dev->usb_buf, len, | 3169 | index, gspca_dev->usb_buf, len, |
3165 | 500); | 3170 | 500); |
3166 | if (ret < 0) { | 3171 | if (ret < 0) { |
3167 | PDEBUG(D_ERR, "reg_r err %d", ret); | 3172 | err("reg_r err %d", ret); |
3168 | gspca_dev->usb_err = ret; | 3173 | gspca_dev->usb_err = ret; |
3169 | } | 3174 | } |
3170 | } | 3175 | } |
@@ -3205,7 +3210,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev, | |||
3205 | value, index, NULL, 0, | 3210 | value, index, NULL, 0, |
3206 | 500); | 3211 | 500); |
3207 | if (ret < 0) { | 3212 | if (ret < 0) { |
3208 | PDEBUG(D_ERR, "reg_w err %d", ret); | 3213 | err("reg_w err %d", ret); |
3209 | gspca_dev->usb_err = ret; | 3214 | gspca_dev->usb_err = ret; |
3210 | } | 3215 | } |
3211 | } | 3216 | } |
@@ -3230,7 +3235,7 @@ static u16 read_sensor_register(struct gspca_dev *gspca_dev, | |||
3230 | 3235 | ||
3231 | reg_r(gspca_dev, 0xa1, 0xb33f, 1); | 3236 | reg_r(gspca_dev, 0xa1, 0xb33f, 1); |
3232 | if (!(gspca_dev->usb_buf[0] & 0x02)) { | 3237 | if (!(gspca_dev->usb_buf[0] & 0x02)) { |
3233 | PDEBUG(D_ERR, "I2c Bus Busy Wait %02x", | 3238 | err("I2c Bus Busy Wait %02x", |
3234 | gspca_dev->usb_buf[0]); | 3239 | gspca_dev->usb_buf[0]); |
3235 | return 0; | 3240 | return 0; |
3236 | } | 3241 | } |
@@ -3344,7 +3349,7 @@ static void i2c_write(struct gspca_dev *gspca_dev, | |||
3344 | msleep(20); | 3349 | msleep(20); |
3345 | } while (--retry > 0); | 3350 | } while (--retry > 0); |
3346 | if (retry <= 0) | 3351 | if (retry <= 0) |
3347 | PDEBUG(D_ERR, "i2c_write timeout"); | 3352 | err("i2c_write timeout"); |
3348 | } | 3353 | } |
3349 | 3354 | ||
3350 | static void put_tab_to_reg(struct gspca_dev *gspca_dev, | 3355 | static void put_tab_to_reg(struct gspca_dev *gspca_dev, |
@@ -3420,17 +3425,18 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3420 | struct sd *sd = (struct sd *) gspca_dev; | 3425 | struct sd *sd = (struct sd *) gspca_dev; |
3421 | struct cam *cam; | 3426 | struct cam *cam; |
3422 | int sensor; | 3427 | int sensor; |
3423 | static u8 npkt[] = { /* number of packets per ISOC message */ | 3428 | /* number of packets per ISOC message */ |
3424 | 64, /* HV7131R 0 */ | 3429 | static u8 npkt[NSENSORS] = { |
3425 | 32, /* MI0360 1 */ | 3430 | [SENSOR_HV7131R] = 64, |
3426 | 32, /* MI1310_SOC 2 */ | 3431 | [SENSOR_MI0360] = 32, |
3427 | 64, /* MI1320 3 */ | 3432 | [SENSOR_MI1310_SOC] = 32, |
3428 | 128, /* MI1320_SOC 4 */ | 3433 | [SENSOR_MI1320] = 64, |
3429 | 32, /* OV7660 5 */ | 3434 | [SENSOR_MI1320_SOC] = 128, |
3430 | 64, /* OV7670 6 */ | 3435 | [SENSOR_OV7660] = 32, |
3431 | 128, /* PO1200 7 */ | 3436 | [SENSOR_OV7670] = 64, |
3432 | 128, /* PO3130NC 8 */ | 3437 | [SENSOR_PO1200] = 128, |
3433 | 128, /* POxxxx 9 */ | 3438 | [SENSOR_PO3130NC] = 128, |
3439 | [SENSOR_POxxxx] = 128, | ||
3434 | }; | 3440 | }; |
3435 | 3441 | ||
3436 | if (sd->sensor != SENSOR_POxxxx) | 3442 | if (sd->sensor != SENSOR_POxxxx) |
@@ -3440,7 +3446,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3440 | 3446 | ||
3441 | switch (sensor) { | 3447 | switch (sensor) { |
3442 | case -1: | 3448 | case -1: |
3443 | PDEBUG(D_PROBE, "Unknown sensor..."); | 3449 | err("Unknown sensor..."); |
3444 | return -EINVAL; | 3450 | return -EINVAL; |
3445 | case SENSOR_HV7131R: | 3451 | case SENSOR_HV7131R: |
3446 | PDEBUG(D_PROBE, "Find Sensor HV7131R"); | 3452 | PDEBUG(D_PROBE, "Find Sensor HV7131R"); |
@@ -4186,7 +4192,7 @@ static const struct sd_desc sd_desc = { | |||
4186 | #define BF(bridge, flags) \ | 4192 | #define BF(bridge, flags) \ |
4187 | .driver_info = (BRIDGE_ ## bridge << 8) \ | 4193 | .driver_info = (BRIDGE_ ## bridge << 8) \ |
4188 | | (flags) | 4194 | | (flags) |
4189 | static const __devinitdata struct usb_device_id device_table[] = { | 4195 | static const struct usb_device_id device_table[] = { |
4190 | {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)}, | 4196 | {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)}, |
4191 | {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)}, | 4197 | {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)}, |
4192 | {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)}, | 4198 | {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)}, |
@@ -4226,18 +4232,11 @@ static struct usb_driver sd_driver = { | |||
4226 | /* -- module insert / remove -- */ | 4232 | /* -- module insert / remove -- */ |
4227 | static int __init sd_mod_init(void) | 4233 | static int __init sd_mod_init(void) |
4228 | { | 4234 | { |
4229 | int ret; | 4235 | 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 | } | 4236 | } |
4237 | static void __exit sd_mod_exit(void) | 4237 | static void __exit sd_mod_exit(void) |
4238 | { | 4238 | { |
4239 | usb_deregister(&sd_driver); | 4239 | usb_deregister(&sd_driver); |
4240 | PDEBUG(D_PROBE, "deregistered"); | ||
4241 | } | 4240 | } |
4242 | 4241 | ||
4243 | module_init(sd_mod_init); | 4242 | module_init(sd_mod_init); |
diff --git a/drivers/media/video/gspca/vicam.c b/drivers/media/video/gspca/vicam.c new file mode 100644 index 000000000000..84dfbab923b5 --- /dev/null +++ b/drivers/media/video/gspca/vicam.c | |||
@@ -0,0 +1,381 @@ | |||
1 | /* | ||
2 | * gspca ViCam subdriver | ||
3 | * | ||
4 | * Copyright (C) 2011 Hans de Goede <hdegoede@redhat.com> | ||
5 | * | ||
6 | * Based on the usbvideo vicam driver, which is: | ||
7 | * | ||
8 | * Copyright (c) 2002 Joe Burks (jburks@wavicle.org), | ||
9 | * Christopher L Cheney (ccheney@cheney.cx), | ||
10 | * Pavel Machek (pavel@ucw.cz), | ||
11 | * John Tyner (jtyner@cs.ucr.edu), | ||
12 | * Monroe Williams (monroe@pobox.com) | ||
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 | * 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 | #define MODULE_NAME "vicam" | ||
30 | #define HEADER_SIZE 64 | ||
31 | |||
32 | #include <linux/workqueue.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/firmware.h> | ||
35 | #include <linux/ihex.h> | ||
36 | #include "gspca.h" | ||
37 | |||
38 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | ||
39 | MODULE_DESCRIPTION("GSPCA ViCam USB Camera Driver"); | ||
40 | MODULE_LICENSE("GPL"); | ||
41 | |||
42 | enum e_ctrl { | ||
43 | GAIN, | ||
44 | EXPOSURE, | ||
45 | NCTRL /* number of controls */ | ||
46 | }; | ||
47 | |||
48 | struct sd { | ||
49 | struct gspca_dev gspca_dev; /* !! must be the first item */ | ||
50 | struct work_struct work_struct; | ||
51 | struct workqueue_struct *work_thread; | ||
52 | struct gspca_ctrl ctrls[NCTRL]; | ||
53 | }; | ||
54 | |||
55 | /* The vicam sensor has a resolution of 512 x 244, with I believe square | ||
56 | pixels, but this is forced to a 4:3 ratio by optics. So it has | ||
57 | non square pixels :( */ | ||
58 | static struct v4l2_pix_format vicam_mode[] = { | ||
59 | { 256, 122, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
60 | .bytesperline = 256, | ||
61 | .sizeimage = 256 * 122, | ||
62 | .colorspace = V4L2_COLORSPACE_SRGB,}, | ||
63 | /* 2 modes with somewhat more square pixels */ | ||
64 | { 256, 200, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
65 | .bytesperline = 256, | ||
66 | .sizeimage = 256 * 200, | ||
67 | .colorspace = V4L2_COLORSPACE_SRGB,}, | ||
68 | { 256, 240, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
69 | .bytesperline = 256, | ||
70 | .sizeimage = 256 * 240, | ||
71 | .colorspace = V4L2_COLORSPACE_SRGB,}, | ||
72 | #if 0 /* This mode has extremely non square pixels, testing use only */ | ||
73 | { 512, 122, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
74 | .bytesperline = 512, | ||
75 | .sizeimage = 512 * 122, | ||
76 | .colorspace = V4L2_COLORSPACE_SRGB,}, | ||
77 | #endif | ||
78 | { 512, 244, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
79 | .bytesperline = 512, | ||
80 | .sizeimage = 512 * 244, | ||
81 | .colorspace = V4L2_COLORSPACE_SRGB,}, | ||
82 | }; | ||
83 | |||
84 | static const struct ctrl sd_ctrls[] = { | ||
85 | [GAIN] = { | ||
86 | { | ||
87 | .id = V4L2_CID_GAIN, | ||
88 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
89 | .name = "Gain", | ||
90 | .minimum = 0, | ||
91 | .maximum = 255, | ||
92 | .step = 1, | ||
93 | .default_value = 200, | ||
94 | }, | ||
95 | }, | ||
96 | [EXPOSURE] = { | ||
97 | { | ||
98 | .id = V4L2_CID_EXPOSURE, | ||
99 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
100 | .name = "Exposure", | ||
101 | .minimum = 0, | ||
102 | .maximum = 2047, | ||
103 | .step = 1, | ||
104 | .default_value = 256, | ||
105 | }, | ||
106 | }, | ||
107 | }; | ||
108 | |||
109 | static int vicam_control_msg(struct gspca_dev *gspca_dev, u8 request, | ||
110 | u16 value, u16 index, u8 *data, u16 len) | ||
111 | { | ||
112 | int ret; | ||
113 | |||
114 | ret = usb_control_msg(gspca_dev->dev, | ||
115 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
116 | request, | ||
117 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
118 | value, index, data, len, 1000); | ||
119 | if (ret < 0) | ||
120 | err("control msg req %02X error %d", request, ret); | ||
121 | |||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | static int vicam_set_camera_power(struct gspca_dev *gspca_dev, int state) | ||
126 | { | ||
127 | int ret; | ||
128 | |||
129 | ret = vicam_control_msg(gspca_dev, 0x50, state, 0, NULL, 0); | ||
130 | if (ret < 0) | ||
131 | return ret; | ||
132 | |||
133 | if (state) | ||
134 | ret = vicam_control_msg(gspca_dev, 0x55, 1, 0, NULL, 0); | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * request and read a block of data - see warning on vicam_command. | ||
141 | */ | ||
142 | static int vicam_read_frame(struct gspca_dev *gspca_dev, u8 *data, int size) | ||
143 | { | ||
144 | struct sd *sd = (struct sd *)gspca_dev; | ||
145 | int ret, unscaled_height, act_len = 0; | ||
146 | u8 *req_data = gspca_dev->usb_buf; | ||
147 | |||
148 | memset(req_data, 0, 16); | ||
149 | req_data[0] = sd->ctrls[GAIN].val; | ||
150 | if (gspca_dev->width == 256) | ||
151 | req_data[1] |= 0x01; /* low nibble x-scale */ | ||
152 | if (gspca_dev->height <= 122) { | ||
153 | req_data[1] |= 0x10; /* high nibble y-scale */ | ||
154 | unscaled_height = gspca_dev->height * 2; | ||
155 | } else | ||
156 | unscaled_height = gspca_dev->height; | ||
157 | req_data[2] = 0x90; /* unknown, does not seem to do anything */ | ||
158 | if (unscaled_height <= 200) | ||
159 | req_data[3] = 0x06; /* vend? */ | ||
160 | else if (unscaled_height <= 242) /* Yes 242 not 240 */ | ||
161 | req_data[3] = 0x07; /* vend? */ | ||
162 | else /* Up to 244 lines with req_data[3] == 0x08 */ | ||
163 | req_data[3] = 0x08; /* vend? */ | ||
164 | |||
165 | if (sd->ctrls[EXPOSURE].val < 256) { | ||
166 | /* Frame rate maxed out, use partial frame expo time */ | ||
167 | req_data[4] = 255 - sd->ctrls[EXPOSURE].val; | ||
168 | req_data[5] = 0x00; | ||
169 | req_data[6] = 0x00; | ||
170 | req_data[7] = 0x01; | ||
171 | } else { | ||
172 | /* Modify frame rate */ | ||
173 | req_data[4] = 0x00; | ||
174 | req_data[5] = 0x00; | ||
175 | req_data[6] = sd->ctrls[EXPOSURE].val & 0xFF; | ||
176 | req_data[7] = sd->ctrls[EXPOSURE].val >> 8; | ||
177 | } | ||
178 | req_data[8] = ((244 - unscaled_height) / 2) & ~0x01; /* vstart */ | ||
179 | /* bytes 9-15 do not seem to affect exposure or image quality */ | ||
180 | |||
181 | mutex_lock(&gspca_dev->usb_lock); | ||
182 | ret = vicam_control_msg(gspca_dev, 0x51, 0x80, 0, req_data, 16); | ||
183 | mutex_unlock(&gspca_dev->usb_lock); | ||
184 | if (ret < 0) | ||
185 | return ret; | ||
186 | |||
187 | ret = usb_bulk_msg(gspca_dev->dev, | ||
188 | usb_rcvbulkpipe(gspca_dev->dev, 0x81), | ||
189 | data, size, &act_len, 10000); | ||
190 | /* successful, it returns 0, otherwise negative */ | ||
191 | if (ret < 0 || act_len != size) { | ||
192 | err("bulk read fail (%d) len %d/%d", | ||
193 | ret, act_len, size); | ||
194 | return -EIO; | ||
195 | } | ||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | /* This function is called as a workqueue function and runs whenever the camera | ||
200 | * is streaming data. Because it is a workqueue function it is allowed to sleep | ||
201 | * so we can use synchronous USB calls. To avoid possible collisions with other | ||
202 | * threads attempting to use the camera's USB interface we take the gspca | ||
203 | * usb_lock when performing USB operations. In practice the only thing we need | ||
204 | * to protect against is the usb_set_interface call that gspca makes during | ||
205 | * stream_off as the camera doesn't provide any controls that the user could try | ||
206 | * to change. | ||
207 | */ | ||
208 | static void vicam_dostream(struct work_struct *work) | ||
209 | { | ||
210 | struct sd *sd = container_of(work, struct sd, work_struct); | ||
211 | struct gspca_dev *gspca_dev = &sd->gspca_dev; | ||
212 | int ret, frame_sz; | ||
213 | u8 *buffer; | ||
214 | |||
215 | frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage + | ||
216 | HEADER_SIZE; | ||
217 | buffer = kmalloc(frame_sz, GFP_KERNEL | GFP_DMA); | ||
218 | if (!buffer) { | ||
219 | err("Couldn't allocate USB buffer"); | ||
220 | goto exit; | ||
221 | } | ||
222 | |||
223 | while (gspca_dev->present && gspca_dev->streaming) { | ||
224 | ret = vicam_read_frame(gspca_dev, buffer, frame_sz); | ||
225 | if (ret < 0) | ||
226 | break; | ||
227 | |||
228 | /* Note the frame header contents seem to be completely | ||
229 | constant, they do not change with either image, or | ||
230 | settings. So we simply discard it. The frames have | ||
231 | a very similar 64 byte footer, which we don't even | ||
232 | bother reading from the cam */ | ||
233 | gspca_frame_add(gspca_dev, FIRST_PACKET, | ||
234 | buffer + HEADER_SIZE, | ||
235 | frame_sz - HEADER_SIZE); | ||
236 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); | ||
237 | } | ||
238 | exit: | ||
239 | kfree(buffer); | ||
240 | } | ||
241 | |||
242 | /* This function is called at probe time just before sd_init */ | ||
243 | static int sd_config(struct gspca_dev *gspca_dev, | ||
244 | const struct usb_device_id *id) | ||
245 | { | ||
246 | struct cam *cam = &gspca_dev->cam; | ||
247 | struct sd *sd = (struct sd *)gspca_dev; | ||
248 | |||
249 | /* We don't use the buffer gspca allocates so make it small. */ | ||
250 | cam->bulk = 1; | ||
251 | cam->bulk_size = 64; | ||
252 | cam->cam_mode = vicam_mode; | ||
253 | cam->nmodes = ARRAY_SIZE(vicam_mode); | ||
254 | cam->ctrls = sd->ctrls; | ||
255 | |||
256 | INIT_WORK(&sd->work_struct, vicam_dostream); | ||
257 | |||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | /* this function is called at probe and resume time */ | ||
262 | static int sd_init(struct gspca_dev *gspca_dev) | ||
263 | { | ||
264 | int ret; | ||
265 | const struct ihex_binrec *rec; | ||
266 | const struct firmware *uninitialized_var(fw); | ||
267 | u8 *firmware_buf; | ||
268 | |||
269 | ret = request_ihex_firmware(&fw, "vicam/firmware.fw", | ||
270 | &gspca_dev->dev->dev); | ||
271 | if (ret) { | ||
272 | err("Failed to load \"vicam/firmware.fw\": %d\n", ret); | ||
273 | return ret; | ||
274 | } | ||
275 | |||
276 | firmware_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
277 | if (!firmware_buf) { | ||
278 | ret = -ENOMEM; | ||
279 | goto exit; | ||
280 | } | ||
281 | for (rec = (void *)fw->data; rec; rec = ihex_next_binrec(rec)) { | ||
282 | memcpy(firmware_buf, rec->data, be16_to_cpu(rec->len)); | ||
283 | ret = vicam_control_msg(gspca_dev, 0xff, 0, 0, firmware_buf, | ||
284 | be16_to_cpu(rec->len)); | ||
285 | if (ret < 0) | ||
286 | break; | ||
287 | } | ||
288 | |||
289 | kfree(firmware_buf); | ||
290 | exit: | ||
291 | release_firmware(fw); | ||
292 | return ret; | ||
293 | } | ||
294 | |||
295 | /* Set up for getting frames. */ | ||
296 | static int sd_start(struct gspca_dev *gspca_dev) | ||
297 | { | ||
298 | struct sd *sd = (struct sd *)gspca_dev; | ||
299 | int ret; | ||
300 | |||
301 | ret = vicam_set_camera_power(gspca_dev, 1); | ||
302 | if (ret < 0) | ||
303 | return ret; | ||
304 | |||
305 | /* Start the workqueue function to do the streaming */ | ||
306 | sd->work_thread = create_singlethread_workqueue(MODULE_NAME); | ||
307 | queue_work(sd->work_thread, &sd->work_struct); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | /* called on streamoff with alt==0 and on disconnect */ | ||
313 | /* the usb_lock is held at entry - restore on exit */ | ||
314 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
315 | { | ||
316 | struct sd *dev = (struct sd *)gspca_dev; | ||
317 | |||
318 | /* wait for the work queue to terminate */ | ||
319 | mutex_unlock(&gspca_dev->usb_lock); | ||
320 | /* This waits for vicam_dostream to finish */ | ||
321 | destroy_workqueue(dev->work_thread); | ||
322 | dev->work_thread = NULL; | ||
323 | mutex_lock(&gspca_dev->usb_lock); | ||
324 | |||
325 | vicam_set_camera_power(gspca_dev, 0); | ||
326 | } | ||
327 | |||
328 | /* Table of supported USB devices */ | ||
329 | static const struct usb_device_id device_table[] = { | ||
330 | {USB_DEVICE(0x04c1, 0x009d)}, | ||
331 | {USB_DEVICE(0x0602, 0x1001)}, | ||
332 | {} | ||
333 | }; | ||
334 | |||
335 | MODULE_DEVICE_TABLE(usb, device_table); | ||
336 | |||
337 | /* sub-driver description */ | ||
338 | static const struct sd_desc sd_desc = { | ||
339 | .name = MODULE_NAME, | ||
340 | .ctrls = sd_ctrls, | ||
341 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
342 | .config = sd_config, | ||
343 | .init = sd_init, | ||
344 | .start = sd_start, | ||
345 | .stop0 = sd_stop0, | ||
346 | }; | ||
347 | |||
348 | /* -- device connect -- */ | ||
349 | static int sd_probe(struct usb_interface *intf, | ||
350 | const struct usb_device_id *id) | ||
351 | { | ||
352 | return gspca_dev_probe(intf, id, | ||
353 | &sd_desc, | ||
354 | sizeof(struct sd), | ||
355 | THIS_MODULE); | ||
356 | } | ||
357 | |||
358 | static struct usb_driver sd_driver = { | ||
359 | .name = MODULE_NAME, | ||
360 | .id_table = device_table, | ||
361 | .probe = sd_probe, | ||
362 | .disconnect = gspca_disconnect, | ||
363 | #ifdef CONFIG_PM | ||
364 | .suspend = gspca_suspend, | ||
365 | .resume = gspca_resume, | ||
366 | #endif | ||
367 | }; | ||
368 | |||
369 | /* -- module insert / remove -- */ | ||
370 | static int __init sd_mod_init(void) | ||
371 | { | ||
372 | return usb_register(&sd_driver); | ||
373 | } | ||
374 | |||
375 | static void __exit sd_mod_exit(void) | ||
376 | { | ||
377 | usb_deregister(&sd_driver); | ||
378 | } | ||
379 | |||
380 | module_init(sd_mod_init); | ||
381 | module_exit(sd_mod_exit); | ||
diff --git a/drivers/media/video/gspca/w996Xcf.c b/drivers/media/video/gspca/w996Xcf.c index 38a68591ce48..4a9e622e5e1b 100644 --- a/drivers/media/video/gspca/w996Xcf.c +++ b/drivers/media/video/gspca/w996Xcf.c | |||
@@ -59,18 +59,21 @@ static const struct v4l2_pix_format w9968cf_vga_mode[] = { | |||
59 | .colorspace = V4L2_COLORSPACE_JPEG}, | 59 | .colorspace = V4L2_COLORSPACE_JPEG}, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static int reg_w(struct sd *sd, __u16 index, __u16 value); | 62 | static void reg_w(struct sd *sd, u16 index, u16 value); |
63 | 63 | ||
64 | /*-------------------------------------------------------------------------- | 64 | /*-------------------------------------------------------------------------- |
65 | Write 64-bit data to the fast serial bus registers. | 65 | Write 64-bit data to the fast serial bus registers. |
66 | Return 0 on success, -1 otherwise. | 66 | Return 0 on success, -1 otherwise. |
67 | --------------------------------------------------------------------------*/ | 67 | --------------------------------------------------------------------------*/ |
68 | static int w9968cf_write_fsb(struct sd *sd, u16* data) | 68 | static void 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 | ||
74 | if (sd->gspca_dev.usb_err < 0) | ||
75 | return; | ||
76 | |||
74 | value = *data++; | 77 | value = *data++; |
75 | memcpy(sd->gspca_dev.usb_buf, data, 6); | 78 | memcpy(sd->gspca_dev.usb_buf, data, 6); |
76 | 79 | ||
@@ -78,21 +81,22 @@ static int w9968cf_write_fsb(struct sd *sd, u16* data) | |||
78 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, | 81 | USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, |
79 | value, 0x06, sd->gspca_dev.usb_buf, 6, 500); | 82 | value, 0x06, sd->gspca_dev.usb_buf, 6, 500); |
80 | if (ret < 0) { | 83 | if (ret < 0) { |
81 | PDEBUG(D_ERR, "Write FSB registers failed (%d)", ret); | 84 | err("Write FSB registers failed (%d)", ret); |
82 | return ret; | 85 | sd->gspca_dev.usb_err = ret; |
83 | } | 86 | } |
84 | |||
85 | return 0; | ||
86 | } | 87 | } |
87 | 88 | ||
88 | /*-------------------------------------------------------------------------- | 89 | /*-------------------------------------------------------------------------- |
89 | Write data to the serial bus control register. | 90 | Write data to the serial bus control register. |
90 | Return 0 on success, a negative number otherwise. | 91 | Return 0 on success, a negative number otherwise. |
91 | --------------------------------------------------------------------------*/ | 92 | --------------------------------------------------------------------------*/ |
92 | static int w9968cf_write_sb(struct sd *sd, u16 value) | 93 | static void w9968cf_write_sb(struct sd *sd, u16 value) |
93 | { | 94 | { |
94 | int ret; | 95 | int ret; |
95 | 96 | ||
97 | if (sd->gspca_dev.usb_err < 0) | ||
98 | return; | ||
99 | |||
96 | /* We don't use reg_w here, as that would cause all writes when | 100 | /* We don't use reg_w here, as that would cause all writes when |
97 | bitbanging i2c to be logged, making the logs impossible to read */ | 101 | bitbanging i2c to be logged, making the logs impossible to read */ |
98 | ret = usb_control_msg(sd->gspca_dev.dev, | 102 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -104,11 +108,9 @@ static int w9968cf_write_sb(struct sd *sd, u16 value) | |||
104 | udelay(W9968CF_I2C_BUS_DELAY); | 108 | udelay(W9968CF_I2C_BUS_DELAY); |
105 | 109 | ||
106 | if (ret < 0) { | 110 | if (ret < 0) { |
107 | PDEBUG(D_ERR, "Write SB reg [01] %04x failed", value); | 111 | err("Write SB reg [01] %04x failed", value); |
108 | return ret; | 112 | sd->gspca_dev.usb_err = ret; |
109 | } | 113 | } |
110 | |||
111 | return 0; | ||
112 | } | 114 | } |
113 | 115 | ||
114 | /*-------------------------------------------------------------------------- | 116 | /*-------------------------------------------------------------------------- |
@@ -119,6 +121,9 @@ static int w9968cf_read_sb(struct sd *sd) | |||
119 | { | 121 | { |
120 | int ret; | 122 | int ret; |
121 | 123 | ||
124 | if (sd->gspca_dev.usb_err < 0) | ||
125 | return -1; | ||
126 | |||
122 | /* We don't use reg_r here, as the w9968cf is special and has 16 | 127 | /* We don't use reg_r here, as the w9968cf is special and has 16 |
123 | bit registers instead of 8 bit */ | 128 | bit registers instead of 8 bit */ |
124 | ret = usb_control_msg(sd->gspca_dev.dev, | 129 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -126,11 +131,13 @@ static int w9968cf_read_sb(struct sd *sd) | |||
126 | 1, | 131 | 1, |
127 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 132 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
128 | 0, 0x01, sd->gspca_dev.usb_buf, 2, 500); | 133 | 0, 0x01, sd->gspca_dev.usb_buf, 2, 500); |
129 | if (ret >= 0) | 134 | if (ret >= 0) { |
130 | ret = sd->gspca_dev.usb_buf[0] | | 135 | ret = sd->gspca_dev.usb_buf[0] | |
131 | (sd->gspca_dev.usb_buf[1] << 8); | 136 | (sd->gspca_dev.usb_buf[1] << 8); |
132 | else | 137 | } else { |
133 | PDEBUG(D_ERR, "Read SB reg [01] failed"); | 138 | err("Read SB reg [01] failed"); |
139 | sd->gspca_dev.usb_err = ret; | ||
140 | } | ||
134 | 141 | ||
135 | udelay(W9968CF_I2C_BUS_DELAY); | 142 | udelay(W9968CF_I2C_BUS_DELAY); |
136 | 143 | ||
@@ -142,22 +149,20 @@ static int w9968cf_read_sb(struct sd *sd) | |||
142 | This function is called by w9968cf_start_transfer(). | 149 | This function is called by w9968cf_start_transfer(). |
143 | Return 0 on success, a negative number otherwise. | 150 | Return 0 on success, a negative number otherwise. |
144 | --------------------------------------------------------------------------*/ | 151 | --------------------------------------------------------------------------*/ |
145 | static int w9968cf_upload_quantizationtables(struct sd *sd) | 152 | static void w9968cf_upload_quantizationtables(struct sd *sd) |
146 | { | 153 | { |
147 | u16 a, b; | 154 | u16 a, b; |
148 | int ret = 0, i, j; | 155 | int i, j; |
149 | 156 | ||
150 | ret += reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */ | 157 | reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */ |
151 | 158 | ||
152 | for (i = 0, j = 0; i < 32; i++, j += 2) { | 159 | for (i = 0, j = 0; i < 32; i++, j += 2) { |
153 | a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j+1]) << 8); | 160 | a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j + 1]) << 8); |
154 | b = UV_QUANTABLE[j] | ((unsigned)(UV_QUANTABLE[j+1]) << 8); | 161 | b = UV_QUANTABLE[j] | ((unsigned)(UV_QUANTABLE[j + 1]) << 8); |
155 | ret += reg_w(sd, 0x40+i, a); | 162 | reg_w(sd, 0x40 + i, a); |
156 | ret += reg_w(sd, 0x60+i, b); | 163 | reg_w(sd, 0x60 + i, b); |
157 | } | 164 | } |
158 | ret += reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */ | 165 | reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */ |
159 | |||
160 | return ret; | ||
161 | } | 166 | } |
162 | 167 | ||
163 | /**************************************************************************** | 168 | /**************************************************************************** |
@@ -168,50 +173,39 @@ static int w9968cf_upload_quantizationtables(struct sd *sd) | |||
168 | * i2c_adap_read_byte() * | 173 | * i2c_adap_read_byte() * |
169 | ****************************************************************************/ | 174 | ****************************************************************************/ |
170 | 175 | ||
171 | static int w9968cf_smbus_start(struct sd *sd) | 176 | static void w9968cf_smbus_start(struct sd *sd) |
172 | { | 177 | { |
173 | int ret = 0; | 178 | w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ |
174 | 179 | w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | |
175 | ret += w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | ||
176 | ret += w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | ||
177 | |||
178 | return ret; | ||
179 | } | 180 | } |
180 | 181 | ||
181 | static int w9968cf_smbus_stop(struct sd *sd) | 182 | static void w9968cf_smbus_stop(struct sd *sd) |
182 | { | 183 | { |
183 | int ret = 0; | 184 | w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ |
184 | 185 | w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | |
185 | ret += w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | 186 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
186 | ret += w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | ||
187 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | ||
188 | |||
189 | return ret; | ||
190 | } | 187 | } |
191 | 188 | ||
192 | static int w9968cf_smbus_write_byte(struct sd *sd, u8 v) | 189 | static void w9968cf_smbus_write_byte(struct sd *sd, u8 v) |
193 | { | 190 | { |
194 | u8 bit; | 191 | u8 bit; |
195 | int ret = 0, sda; | 192 | int sda; |
196 | 193 | ||
197 | for (bit = 0 ; bit < 8 ; bit++) { | 194 | for (bit = 0 ; bit < 8 ; bit++) { |
198 | sda = (v & 0x80) ? 2 : 0; | 195 | sda = (v & 0x80) ? 2 : 0; |
199 | v <<= 1; | 196 | v <<= 1; |
200 | /* SDE=1, SDA=sda, SCL=0 */ | 197 | /* SDE=1, SDA=sda, SCL=0 */ |
201 | ret += w9968cf_write_sb(sd, 0x10 | sda); | 198 | w9968cf_write_sb(sd, 0x10 | sda); |
202 | /* SDE=1, SDA=sda, SCL=1 */ | 199 | /* SDE=1, SDA=sda, SCL=1 */ |
203 | ret += w9968cf_write_sb(sd, 0x11 | sda); | 200 | w9968cf_write_sb(sd, 0x11 | sda); |
204 | /* SDE=1, SDA=sda, SCL=0 */ | 201 | /* SDE=1, SDA=sda, SCL=0 */ |
205 | ret += w9968cf_write_sb(sd, 0x10 | sda); | 202 | w9968cf_write_sb(sd, 0x10 | sda); |
206 | } | 203 | } |
207 | |||
208 | return ret; | ||
209 | } | 204 | } |
210 | 205 | ||
211 | static int w9968cf_smbus_read_byte(struct sd *sd, u8* v) | 206 | static void w9968cf_smbus_read_byte(struct sd *sd, u8 *v) |
212 | { | 207 | { |
213 | u8 bit; | 208 | u8 bit; |
214 | int ret = 0; | ||
215 | 209 | ||
216 | /* No need to ensure SDA is high as we are always called after | 210 | /* No need to ensure SDA is high as we are always called after |
217 | read_ack which ends with SDA high */ | 211 | read_ack which ends with SDA high */ |
@@ -219,51 +213,40 @@ static int w9968cf_smbus_read_byte(struct sd *sd, u8* v) | |||
219 | for (bit = 0 ; bit < 8 ; bit++) { | 213 | for (bit = 0 ; bit < 8 ; bit++) { |
220 | *v <<= 1; | 214 | *v <<= 1; |
221 | /* SDE=1, SDA=1, SCL=1 */ | 215 | /* SDE=1, SDA=1, SCL=1 */ |
222 | ret += w9968cf_write_sb(sd, 0x0013); | 216 | w9968cf_write_sb(sd, 0x0013); |
223 | *v |= (w9968cf_read_sb(sd) & 0x0008) ? 1 : 0; | 217 | *v |= (w9968cf_read_sb(sd) & 0x0008) ? 1 : 0; |
224 | /* SDE=1, SDA=1, SCL=0 */ | 218 | /* SDE=1, SDA=1, SCL=0 */ |
225 | ret += w9968cf_write_sb(sd, 0x0012); | 219 | w9968cf_write_sb(sd, 0x0012); |
226 | } | 220 | } |
227 | |||
228 | return ret; | ||
229 | } | 221 | } |
230 | 222 | ||
231 | static int w9968cf_smbus_write_nack(struct sd *sd) | 223 | static void w9968cf_smbus_write_nack(struct sd *sd) |
232 | { | 224 | { |
233 | int ret = 0; | ||
234 | |||
235 | /* No need to ensure SDA is high as we are always called after | 225 | /* No need to ensure SDA is high as we are always called after |
236 | read_byte which ends with SDA high */ | 226 | read_byte which ends with SDA high */ |
237 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | 227 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
238 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 228 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
239 | |||
240 | return ret; | ||
241 | } | 229 | } |
242 | 230 | ||
243 | static int w9968cf_smbus_read_ack(struct sd *sd) | 231 | static void w9968cf_smbus_read_ack(struct sd *sd) |
244 | { | 232 | { |
245 | int ret = 0, sda; | 233 | int sda; |
246 | 234 | ||
247 | /* Ensure SDA is high before raising clock to avoid a spurious stop */ | 235 | /* Ensure SDA is high before raising clock to avoid a spurious stop */ |
248 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 236 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
249 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | 237 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
250 | sda = w9968cf_read_sb(sd); | 238 | sda = w9968cf_read_sb(sd); |
251 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 239 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
252 | if (sda < 0) | 240 | if (sda >= 0 && (sda & 0x08)) { |
253 | ret += sda; | ||
254 | else if (sda & 0x08) { | ||
255 | PDEBUG(D_USBI, "Did not receive i2c ACK"); | 241 | PDEBUG(D_USBI, "Did not receive i2c ACK"); |
256 | ret += -1; | 242 | sd->gspca_dev.usb_err = -EIO; |
257 | } | 243 | } |
258 | |||
259 | return ret; | ||
260 | } | 244 | } |
261 | 245 | ||
262 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ | 246 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ |
263 | static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | 247 | static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) |
264 | { | 248 | { |
265 | u16* data = (u16 *)sd->gspca_dev.usb_buf; | 249 | u16* data = (u16 *)sd->gspca_dev.usb_buf; |
266 | int ret = 0; | ||
267 | 250 | ||
268 | data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0); | 251 | data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0); |
269 | data[0] |= (sd->sensor_addr & 0x40) ? 0x4000 : 0x0; | 252 | data[0] |= (sd->sensor_addr & 0x40) ? 0x4000 : 0x0; |
@@ -276,7 +259,7 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
276 | data[3] = 0x1d20 | ((sd->sensor_addr & 0x02) ? 0x0001 : 0x0); | 259 | data[3] = 0x1d20 | ((sd->sensor_addr & 0x02) ? 0x0001 : 0x0); |
277 | data[3] |= (sd->sensor_addr & 0x01) ? 0x0054 : 0x0; | 260 | data[3] |= (sd->sensor_addr & 0x01) ? 0x0054 : 0x0; |
278 | 261 | ||
279 | ret += w9968cf_write_fsb(sd, data); | 262 | w9968cf_write_fsb(sd, data); |
280 | 263 | ||
281 | data[0] = 0x8208 | ((reg & 0x80) ? 0x0015 : 0x0); | 264 | data[0] = 0x8208 | ((reg & 0x80) ? 0x0015 : 0x0); |
282 | data[0] |= (reg & 0x40) ? 0x0540 : 0x0; | 265 | data[0] |= (reg & 0x40) ? 0x0540 : 0x0; |
@@ -290,7 +273,7 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
290 | data[2] |= (reg & 0x01) ? 0x5400 : 0x0; | 273 | data[2] |= (reg & 0x01) ? 0x5400 : 0x0; |
291 | data[3] = 0x001d; | 274 | data[3] = 0x001d; |
292 | 275 | ||
293 | ret += w9968cf_write_fsb(sd, data); | 276 | w9968cf_write_fsb(sd, data); |
294 | 277 | ||
295 | data[0] = 0x8208 | ((value & 0x80) ? 0x0015 : 0x0); | 278 | data[0] = 0x8208 | ((value & 0x80) ? 0x0015 : 0x0); |
296 | data[0] |= (value & 0x40) ? 0x0540 : 0x0; | 279 | data[0] |= (value & 0x40) ? 0x0540 : 0x0; |
@@ -304,14 +287,9 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
304 | data[2] |= (value & 0x01) ? 0x5400 : 0x0; | 287 | data[2] |= (value & 0x01) ? 0x5400 : 0x0; |
305 | data[3] = 0xfe1d; | 288 | data[3] = 0xfe1d; |
306 | 289 | ||
307 | ret += w9968cf_write_fsb(sd, data); | 290 | w9968cf_write_fsb(sd, data); |
308 | 291 | ||
309 | if (!ret) | 292 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); |
310 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | ||
311 | else | ||
312 | PDEBUG(D_ERR, "i2c 0x%02x -> [0x%02x] failed", value, reg); | ||
313 | |||
314 | return ret; | ||
315 | } | 293 | } |
316 | 294 | ||
317 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ | 295 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ |
@@ -321,28 +299,28 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) | |||
321 | u8 value; | 299 | u8 value; |
322 | 300 | ||
323 | /* Fast serial bus data control disable */ | 301 | /* Fast serial bus data control disable */ |
324 | ret += w9968cf_write_sb(sd, 0x0013); /* don't change ! */ | 302 | w9968cf_write_sb(sd, 0x0013); /* don't change ! */ |
325 | 303 | ||
326 | ret += w9968cf_smbus_start(sd); | 304 | w9968cf_smbus_start(sd); |
327 | ret += w9968cf_smbus_write_byte(sd, sd->sensor_addr); | 305 | w9968cf_smbus_write_byte(sd, sd->sensor_addr); |
328 | ret += w9968cf_smbus_read_ack(sd); | 306 | w9968cf_smbus_read_ack(sd); |
329 | ret += w9968cf_smbus_write_byte(sd, reg); | 307 | w9968cf_smbus_write_byte(sd, reg); |
330 | ret += w9968cf_smbus_read_ack(sd); | 308 | w9968cf_smbus_read_ack(sd); |
331 | ret += w9968cf_smbus_stop(sd); | 309 | w9968cf_smbus_stop(sd); |
332 | ret += w9968cf_smbus_start(sd); | 310 | w9968cf_smbus_start(sd); |
333 | ret += w9968cf_smbus_write_byte(sd, sd->sensor_addr + 1); | 311 | w9968cf_smbus_write_byte(sd, sd->sensor_addr + 1); |
334 | ret += w9968cf_smbus_read_ack(sd); | 312 | w9968cf_smbus_read_ack(sd); |
335 | ret += w9968cf_smbus_read_byte(sd, &value); | 313 | w9968cf_smbus_read_byte(sd, &value); |
336 | /* signal we don't want to read anymore, the v4l1 driver used to | 314 | /* signal we don't want to read anymore, the v4l1 driver used to |
337 | send an ack here which is very wrong! (and then fixed | 315 | send an ack here which is very wrong! (and then fixed |
338 | the issues this gave by retrying reads) */ | 316 | the issues this gave by retrying reads) */ |
339 | ret += w9968cf_smbus_write_nack(sd); | 317 | w9968cf_smbus_write_nack(sd); |
340 | ret += w9968cf_smbus_stop(sd); | 318 | w9968cf_smbus_stop(sd); |
341 | 319 | ||
342 | /* Fast serial bus data control re-enable */ | 320 | /* Fast serial bus data control re-enable */ |
343 | ret += w9968cf_write_sb(sd, 0x0030); | 321 | w9968cf_write_sb(sd, 0x0030); |
344 | 322 | ||
345 | if (!ret) { | 323 | if (sd->gspca_dev.usb_err >= 0) { |
346 | ret = value; | 324 | ret = value; |
347 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 325 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); |
348 | } else | 326 | } else |
@@ -351,79 +329,68 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) | |||
351 | return ret; | 329 | return ret; |
352 | } | 330 | } |
353 | 331 | ||
354 | |||
355 | /*-------------------------------------------------------------------------- | 332 | /*-------------------------------------------------------------------------- |
356 | Turn on the LED on some webcams. A beep should be heard too. | 333 | Turn on the LED on some webcams. A beep should be heard too. |
357 | Return 0 on success, a negative number otherwise. | 334 | Return 0 on success, a negative number otherwise. |
358 | --------------------------------------------------------------------------*/ | 335 | --------------------------------------------------------------------------*/ |
359 | static int w9968cf_configure(struct sd *sd) | 336 | static void w9968cf_configure(struct sd *sd) |
360 | { | 337 | { |
361 | int ret = 0; | 338 | reg_w(sd, 0x00, 0xff00); /* power-down */ |
362 | 339 | reg_w(sd, 0x00, 0xbf17); /* reset everything */ | |
363 | ret += reg_w(sd, 0x00, 0xff00); /* power-down */ | 340 | reg_w(sd, 0x00, 0xbf10); /* normal operation */ |
364 | ret += reg_w(sd, 0x00, 0xbf17); /* reset everything */ | 341 | reg_w(sd, 0x01, 0x0010); /* serial bus, SDS high */ |
365 | ret += reg_w(sd, 0x00, 0xbf10); /* normal operation */ | 342 | reg_w(sd, 0x01, 0x0000); /* serial bus, SDS low */ |
366 | ret += reg_w(sd, 0x01, 0x0010); /* serial bus, SDS high */ | 343 | reg_w(sd, 0x01, 0x0010); /* ..high 'beep-beep' */ |
367 | ret += reg_w(sd, 0x01, 0x0000); /* serial bus, SDS low */ | 344 | reg_w(sd, 0x01, 0x0030); /* Set sda scl to FSB mode */ |
368 | ret += reg_w(sd, 0x01, 0x0010); /* ..high 'beep-beep' */ | ||
369 | ret += reg_w(sd, 0x01, 0x0030); /* Set sda scl to FSB mode */ | ||
370 | |||
371 | if (ret) | ||
372 | PDEBUG(D_ERR, "Couldn't turn on the LED"); | ||
373 | 345 | ||
374 | sd->stopped = 1; | 346 | sd->stopped = 1; |
375 | |||
376 | return ret; | ||
377 | } | 347 | } |
378 | 348 | ||
379 | static int w9968cf_init(struct sd *sd) | 349 | static void w9968cf_init(struct sd *sd) |
380 | { | 350 | { |
381 | int ret = 0; | ||
382 | unsigned long hw_bufsize = sd->sif ? (352 * 288 * 2) : (640 * 480 * 2), | 351 | unsigned long hw_bufsize = sd->sif ? (352 * 288 * 2) : (640 * 480 * 2), |
383 | y0 = 0x0000, | 352 | y0 = 0x0000, |
384 | u0 = y0 + hw_bufsize/2, | 353 | u0 = y0 + hw_bufsize / 2, |
385 | v0 = u0 + hw_bufsize/4, | 354 | v0 = u0 + hw_bufsize / 4, |
386 | y1 = v0 + hw_bufsize/4, | 355 | y1 = v0 + hw_bufsize / 4, |
387 | u1 = y1 + hw_bufsize/2, | 356 | u1 = y1 + hw_bufsize / 2, |
388 | v1 = u1 + hw_bufsize/4; | 357 | v1 = u1 + hw_bufsize / 4; |
389 | 358 | ||
390 | ret += reg_w(sd, 0x00, 0xff00); /* power off */ | 359 | reg_w(sd, 0x00, 0xff00); /* power off */ |
391 | ret += reg_w(sd, 0x00, 0xbf10); /* power on */ | 360 | reg_w(sd, 0x00, 0xbf10); /* power on */ |
392 | 361 | ||
393 | ret += reg_w(sd, 0x03, 0x405d); /* DRAM timings */ | 362 | reg_w(sd, 0x03, 0x405d); /* DRAM timings */ |
394 | ret += reg_w(sd, 0x04, 0x0030); /* SDRAM timings */ | 363 | reg_w(sd, 0x04, 0x0030); /* SDRAM timings */ |
395 | 364 | ||
396 | ret += reg_w(sd, 0x20, y0 & 0xffff); /* Y buf.0, low */ | 365 | reg_w(sd, 0x20, y0 & 0xffff); /* Y buf.0, low */ |
397 | ret += reg_w(sd, 0x21, y0 >> 16); /* Y buf.0, high */ | 366 | reg_w(sd, 0x21, y0 >> 16); /* Y buf.0, high */ |
398 | ret += reg_w(sd, 0x24, u0 & 0xffff); /* U buf.0, low */ | 367 | reg_w(sd, 0x24, u0 & 0xffff); /* U buf.0, low */ |
399 | ret += reg_w(sd, 0x25, u0 >> 16); /* U buf.0, high */ | 368 | reg_w(sd, 0x25, u0 >> 16); /* U buf.0, high */ |
400 | ret += reg_w(sd, 0x28, v0 & 0xffff); /* V buf.0, low */ | 369 | reg_w(sd, 0x28, v0 & 0xffff); /* V buf.0, low */ |
401 | ret += reg_w(sd, 0x29, v0 >> 16); /* V buf.0, high */ | 370 | reg_w(sd, 0x29, v0 >> 16); /* V buf.0, high */ |
402 | 371 | ||
403 | ret += reg_w(sd, 0x22, y1 & 0xffff); /* Y buf.1, low */ | 372 | reg_w(sd, 0x22, y1 & 0xffff); /* Y buf.1, low */ |
404 | ret += reg_w(sd, 0x23, y1 >> 16); /* Y buf.1, high */ | 373 | reg_w(sd, 0x23, y1 >> 16); /* Y buf.1, high */ |
405 | ret += reg_w(sd, 0x26, u1 & 0xffff); /* U buf.1, low */ | 374 | reg_w(sd, 0x26, u1 & 0xffff); /* U buf.1, low */ |
406 | ret += reg_w(sd, 0x27, u1 >> 16); /* U buf.1, high */ | 375 | reg_w(sd, 0x27, u1 >> 16); /* U buf.1, high */ |
407 | ret += reg_w(sd, 0x2a, v1 & 0xffff); /* V buf.1, low */ | 376 | reg_w(sd, 0x2a, v1 & 0xffff); /* V buf.1, low */ |
408 | ret += reg_w(sd, 0x2b, v1 >> 16); /* V buf.1, high */ | 377 | reg_w(sd, 0x2b, v1 >> 16); /* V buf.1, high */ |
409 | 378 | ||
410 | ret += reg_w(sd, 0x32, y1 & 0xffff); /* JPEG buf 0 low */ | 379 | reg_w(sd, 0x32, y1 & 0xffff); /* JPEG buf 0 low */ |
411 | ret += reg_w(sd, 0x33, y1 >> 16); /* JPEG buf 0 high */ | 380 | reg_w(sd, 0x33, y1 >> 16); /* JPEG buf 0 high */ |
412 | 381 | ||
413 | ret += reg_w(sd, 0x34, y1 & 0xffff); /* JPEG buf 1 low */ | 382 | reg_w(sd, 0x34, y1 & 0xffff); /* JPEG buf 1 low */ |
414 | ret += reg_w(sd, 0x35, y1 >> 16); /* JPEG bug 1 high */ | 383 | reg_w(sd, 0x35, y1 >> 16); /* JPEG bug 1 high */ |
415 | 384 | ||
416 | ret += reg_w(sd, 0x36, 0x0000);/* JPEG restart interval */ | 385 | reg_w(sd, 0x36, 0x0000);/* JPEG restart interval */ |
417 | ret += reg_w(sd, 0x37, 0x0804);/*JPEG VLE FIFO threshold*/ | 386 | reg_w(sd, 0x37, 0x0804);/*JPEG VLE FIFO threshold*/ |
418 | ret += reg_w(sd, 0x38, 0x0000);/* disable hw up-scaling */ | 387 | reg_w(sd, 0x38, 0x0000);/* disable hw up-scaling */ |
419 | ret += reg_w(sd, 0x3f, 0x0000); /* JPEG/MCTL test data */ | 388 | reg_w(sd, 0x3f, 0x0000); /* JPEG/MCTL test data */ |
420 | |||
421 | return ret; | ||
422 | } | 389 | } |
423 | 390 | ||
424 | static int w9968cf_set_crop_window(struct sd *sd) | 391 | static void w9968cf_set_crop_window(struct sd *sd) |
425 | { | 392 | { |
426 | int ret = 0, start_cropx, start_cropy, x, y, fw, fh, cw, ch, | 393 | int start_cropx, start_cropy, x, y, fw, fh, cw, ch, |
427 | max_width, max_height; | 394 | max_width, max_height; |
428 | 395 | ||
429 | if (sd->sif) { | 396 | if (sd->sif) { |
@@ -437,7 +404,7 @@ static int w9968cf_set_crop_window(struct sd *sd) | |||
437 | if (sd->sensor == SEN_OV7620) { | 404 | if (sd->sensor == SEN_OV7620) { |
438 | /* Sigh, this is dependend on the clock / framerate changes | 405 | /* Sigh, this is dependend on the clock / framerate changes |
439 | made by the frequency control, sick. */ | 406 | made by the frequency control, sick. */ |
440 | if (sd->freq == 1) { | 407 | if (sd->ctrls[FREQ].val == 1) { |
441 | start_cropx = 277; | 408 | start_cropx = 277; |
442 | start_cropy = 37; | 409 | start_cropy = 37; |
443 | } else { | 410 | } else { |
@@ -456,8 +423,8 @@ static int w9968cf_set_crop_window(struct sd *sd) | |||
456 | fw = SC(sd->gspca_dev.width) / max_width; | 423 | fw = SC(sd->gspca_dev.width) / max_width; |
457 | fh = SC(sd->gspca_dev.height) / max_height; | 424 | fh = SC(sd->gspca_dev.height) / max_height; |
458 | 425 | ||
459 | cw = (fw >= fh) ? max_width : SC(sd->gspca_dev.width)/fh; | 426 | cw = (fw >= fh) ? max_width : SC(sd->gspca_dev.width) / fh; |
460 | ch = (fw >= fh) ? SC(sd->gspca_dev.height)/fw : max_height; | 427 | ch = (fw >= fh) ? SC(sd->gspca_dev.height) / fw : max_height; |
461 | 428 | ||
462 | sd->sensor_width = max_width; | 429 | sd->sensor_width = max_width; |
463 | sd->sensor_height = max_height; | 430 | sd->sensor_height = max_height; |
@@ -465,42 +432,40 @@ static int w9968cf_set_crop_window(struct sd *sd) | |||
465 | x = (max_width - cw) / 2; | 432 | x = (max_width - cw) / 2; |
466 | y = (max_height - ch) / 2; | 433 | y = (max_height - ch) / 2; |
467 | 434 | ||
468 | ret += reg_w(sd, 0x10, start_cropx + x); | 435 | reg_w(sd, 0x10, start_cropx + x); |
469 | ret += reg_w(sd, 0x11, start_cropy + y); | 436 | reg_w(sd, 0x11, start_cropy + y); |
470 | ret += reg_w(sd, 0x12, start_cropx + x + cw); | 437 | reg_w(sd, 0x12, start_cropx + x + cw); |
471 | ret += reg_w(sd, 0x13, start_cropy + y + ch); | 438 | reg_w(sd, 0x13, start_cropy + y + ch); |
472 | |||
473 | return ret; | ||
474 | } | 439 | } |
475 | 440 | ||
476 | static int w9968cf_mode_init_regs(struct sd *sd) | 441 | static void w9968cf_mode_init_regs(struct sd *sd) |
477 | { | 442 | { |
478 | int ret = 0, val, vs_polarity, hs_polarity; | 443 | int val, vs_polarity, hs_polarity; |
479 | 444 | ||
480 | ret += w9968cf_set_crop_window(sd); | 445 | w9968cf_set_crop_window(sd); |
481 | 446 | ||
482 | ret += reg_w(sd, 0x14, sd->gspca_dev.width); | 447 | reg_w(sd, 0x14, sd->gspca_dev.width); |
483 | ret += reg_w(sd, 0x15, sd->gspca_dev.height); | 448 | reg_w(sd, 0x15, sd->gspca_dev.height); |
484 | 449 | ||
485 | /* JPEG width & height */ | 450 | /* JPEG width & height */ |
486 | ret += reg_w(sd, 0x30, sd->gspca_dev.width); | 451 | reg_w(sd, 0x30, sd->gspca_dev.width); |
487 | ret += reg_w(sd, 0x31, sd->gspca_dev.height); | 452 | reg_w(sd, 0x31, sd->gspca_dev.height); |
488 | 453 | ||
489 | /* Y & UV frame buffer strides (in WORD) */ | 454 | /* Y & UV frame buffer strides (in WORD) */ |
490 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == | 455 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == |
491 | V4L2_PIX_FMT_JPEG) { | 456 | V4L2_PIX_FMT_JPEG) { |
492 | ret += reg_w(sd, 0x2c, sd->gspca_dev.width/2); | 457 | reg_w(sd, 0x2c, sd->gspca_dev.width / 2); |
493 | ret += reg_w(sd, 0x2d, sd->gspca_dev.width/4); | 458 | reg_w(sd, 0x2d, sd->gspca_dev.width / 4); |
494 | } else | 459 | } else |
495 | ret += reg_w(sd, 0x2c, sd->gspca_dev.width); | 460 | reg_w(sd, 0x2c, sd->gspca_dev.width); |
496 | 461 | ||
497 | ret += reg_w(sd, 0x00, 0xbf17); /* reset everything */ | 462 | reg_w(sd, 0x00, 0xbf17); /* reset everything */ |
498 | ret += reg_w(sd, 0x00, 0xbf10); /* normal operation */ | 463 | reg_w(sd, 0x00, 0xbf10); /* normal operation */ |
499 | 464 | ||
500 | /* Transfer size in WORDS (for UYVY format only) */ | 465 | /* Transfer size in WORDS (for UYVY format only) */ |
501 | val = sd->gspca_dev.width * sd->gspca_dev.height; | 466 | val = sd->gspca_dev.width * sd->gspca_dev.height; |
502 | ret += reg_w(sd, 0x3d, val & 0xffff); /* low bits */ | 467 | reg_w(sd, 0x3d, val & 0xffff); /* low bits */ |
503 | ret += reg_w(sd, 0x3e, val >> 16); /* high bits */ | 468 | reg_w(sd, 0x3e, val >> 16); /* high bits */ |
504 | 469 | ||
505 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == | 470 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == |
506 | V4L2_PIX_FMT_JPEG) { | 471 | V4L2_PIX_FMT_JPEG) { |
@@ -508,7 +473,7 @@ static int w9968cf_mode_init_regs(struct sd *sd) | |||
508 | jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, | 473 | jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, |
509 | sd->gspca_dev.width, 0x22); /* JPEG 420 */ | 474 | sd->gspca_dev.width, 0x22); /* JPEG 420 */ |
510 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | 475 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
511 | ret += w9968cf_upload_quantizationtables(sd); | 476 | w9968cf_upload_quantizationtables(sd); |
512 | } | 477 | } |
513 | 478 | ||
514 | /* Video Capture Control Register */ | 479 | /* Video Capture Control Register */ |
@@ -540,19 +505,15 @@ static int w9968cf_mode_init_regs(struct sd *sd) | |||
540 | 505 | ||
541 | val |= 0x8000; /* capt. enable */ | 506 | val |= 0x8000; /* capt. enable */ |
542 | 507 | ||
543 | ret += reg_w(sd, 0x16, val); | 508 | reg_w(sd, 0x16, val); |
544 | 509 | ||
545 | sd->gspca_dev.empty_packet = 0; | 510 | sd->gspca_dev.empty_packet = 0; |
546 | |||
547 | return ret; | ||
548 | } | 511 | } |
549 | 512 | ||
550 | static void w9968cf_stop0(struct sd *sd) | 513 | static void w9968cf_stop0(struct sd *sd) |
551 | { | 514 | { |
552 | if (sd->gspca_dev.present) { | 515 | reg_w(sd, 0x39, 0x0000); /* disable JPEG encoder */ |
553 | reg_w(sd, 0x39, 0x0000); /* disable JPEG encoder */ | 516 | reg_w(sd, 0x16, 0x0000); /* stop video capture */ |
554 | reg_w(sd, 0x16, 0x0000); /* stop video capture */ | ||
555 | } | ||
556 | } | 517 | } |
557 | 518 | ||
558 | /* The w9968cf docs say that a 0 sized packet means EOF (and also SOF | 519 | /* The w9968cf docs say that a 0 sized packet means EOF (and also SOF |
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c new file mode 100644 index 000000000000..c089a0f6f1d0 --- /dev/null +++ b/drivers/media/video/gspca/xirlink_cit.c | |||
@@ -0,0 +1,3337 @@ | |||
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 <linux/input.h> | ||
33 | #include "gspca.h" | ||
34 | |||
35 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | ||
36 | MODULE_DESCRIPTION("Xirlink C-IT"); | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | |||
39 | /* FIXME we should autodetect this */ | ||
40 | static int ibm_netcam_pro; | ||
41 | module_param(ibm_netcam_pro, int, 0); | ||
42 | MODULE_PARM_DESC(ibm_netcam_pro, | ||
43 | "Use IBM Netcamera Pro init sequences for Model 3 cams"); | ||
44 | |||
45 | /* FIXME this should be handled through the V4L2 input selection API */ | ||
46 | static int rca_input; | ||
47 | module_param(rca_input, int, 0644); | ||
48 | MODULE_PARM_DESC(rca_input, | ||
49 | "Use rca input instead of ccd sensor on Model 3 cams"); | ||
50 | |||
51 | /* specific webcam descriptor */ | ||
52 | struct sd { | ||
53 | struct gspca_dev gspca_dev; /* !! must be the first item */ | ||
54 | u8 model; | ||
55 | #define CIT_MODEL0 0 /* bcd version 0.01 cams ie the xvp-500 */ | ||
56 | #define CIT_MODEL1 1 /* The model 1 - 4 nomenclature comes from the old */ | ||
57 | #define CIT_MODEL2 2 /* ibmcam driver */ | ||
58 | #define CIT_MODEL3 3 | ||
59 | #define CIT_MODEL4 4 | ||
60 | #define CIT_IBM_NETCAM_PRO 5 | ||
61 | u8 input_index; | ||
62 | u8 button_state; | ||
63 | u8 stop_on_control_change; | ||
64 | u8 sof_read; | ||
65 | u8 sof_len; | ||
66 | u8 contrast; | ||
67 | u8 brightness; | ||
68 | u8 hue; | ||
69 | u8 sharpness; | ||
70 | u8 lighting; | ||
71 | u8 hflip; | ||
72 | }; | ||
73 | |||
74 | /* V4L2 controls supported by the driver */ | ||
75 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
76 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
77 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
78 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
79 | static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val); | ||
80 | static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val); | ||
81 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | ||
82 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | ||
83 | static int sd_setlighting(struct gspca_dev *gspca_dev, __s32 val); | ||
84 | static int sd_getlighting(struct gspca_dev *gspca_dev, __s32 *val); | ||
85 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | ||
86 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
87 | static void sd_stop0(struct gspca_dev *gspca_dev); | ||
88 | |||
89 | static const struct ctrl sd_ctrls[] = { | ||
90 | #define SD_BRIGHTNESS 0 | ||
91 | { | ||
92 | { | ||
93 | .id = V4L2_CID_BRIGHTNESS, | ||
94 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
95 | .name = "Brightness", | ||
96 | .minimum = 0, | ||
97 | .maximum = 63, | ||
98 | .step = 1, | ||
99 | #define BRIGHTNESS_DEFAULT 32 | ||
100 | .default_value = BRIGHTNESS_DEFAULT, | ||
101 | .flags = 0, | ||
102 | }, | ||
103 | .set = sd_setbrightness, | ||
104 | .get = sd_getbrightness, | ||
105 | }, | ||
106 | #define SD_CONTRAST 1 | ||
107 | { | ||
108 | { | ||
109 | .id = V4L2_CID_CONTRAST, | ||
110 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
111 | .name = "contrast", | ||
112 | .minimum = 0, | ||
113 | .maximum = 20, | ||
114 | .step = 1, | ||
115 | #define CONTRAST_DEFAULT 10 | ||
116 | .default_value = CONTRAST_DEFAULT, | ||
117 | .flags = 0, | ||
118 | }, | ||
119 | .set = sd_setcontrast, | ||
120 | .get = sd_getcontrast, | ||
121 | }, | ||
122 | #define SD_HUE 2 | ||
123 | { | ||
124 | { | ||
125 | .id = V4L2_CID_HUE, | ||
126 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
127 | .name = "Hue", | ||
128 | .minimum = 0, | ||
129 | .maximum = 127, | ||
130 | .step = 1, | ||
131 | #define HUE_DEFAULT 63 | ||
132 | .default_value = HUE_DEFAULT, | ||
133 | .flags = 0, | ||
134 | }, | ||
135 | .set = sd_sethue, | ||
136 | .get = sd_gethue, | ||
137 | }, | ||
138 | #define SD_SHARPNESS 3 | ||
139 | { | ||
140 | { | ||
141 | .id = V4L2_CID_SHARPNESS, | ||
142 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
143 | .name = "Sharpness", | ||
144 | .minimum = 0, | ||
145 | .maximum = 6, | ||
146 | .step = 1, | ||
147 | #define SHARPNESS_DEFAULT 3 | ||
148 | .default_value = SHARPNESS_DEFAULT, | ||
149 | .flags = 0, | ||
150 | }, | ||
151 | .set = sd_setsharpness, | ||
152 | .get = sd_getsharpness, | ||
153 | }, | ||
154 | #define SD_LIGHTING 4 | ||
155 | { | ||
156 | { | ||
157 | .id = V4L2_CID_BACKLIGHT_COMPENSATION, | ||
158 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
159 | .name = "Lighting", | ||
160 | .minimum = 0, | ||
161 | .maximum = 2, | ||
162 | .step = 1, | ||
163 | #define LIGHTING_DEFAULT 1 | ||
164 | .default_value = LIGHTING_DEFAULT, | ||
165 | .flags = 0, | ||
166 | }, | ||
167 | .set = sd_setlighting, | ||
168 | .get = sd_getlighting, | ||
169 | }, | ||
170 | #define SD_HFLIP 5 | ||
171 | { | ||
172 | { | ||
173 | .id = V4L2_CID_HFLIP, | ||
174 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
175 | .name = "Mirror", | ||
176 | .minimum = 0, | ||
177 | .maximum = 1, | ||
178 | .step = 1, | ||
179 | #define HFLIP_DEFAULT 0 | ||
180 | .default_value = HFLIP_DEFAULT, | ||
181 | }, | ||
182 | .set = sd_sethflip, | ||
183 | .get = sd_gethflip, | ||
184 | }, | ||
185 | }; | ||
186 | |||
187 | static const struct v4l2_pix_format cif_yuv_mode[] = { | ||
188 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
189 | .bytesperline = 176, | ||
190 | .sizeimage = 176 * 144 * 3 / 2 + 4, | ||
191 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
192 | {352, 288, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
193 | .bytesperline = 352, | ||
194 | .sizeimage = 352 * 288 * 3 / 2 + 4, | ||
195 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
196 | }; | ||
197 | |||
198 | static const struct v4l2_pix_format vga_yuv_mode[] = { | ||
199 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
200 | .bytesperline = 160, | ||
201 | .sizeimage = 160 * 120 * 3 / 2 + 4, | ||
202 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
203 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
204 | .bytesperline = 320, | ||
205 | .sizeimage = 320 * 240 * 3 / 2 + 4, | ||
206 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
207 | {640, 480, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
208 | .bytesperline = 640, | ||
209 | .sizeimage = 640 * 480 * 3 / 2 + 4, | ||
210 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
211 | }; | ||
212 | |||
213 | static const struct v4l2_pix_format model0_mode[] = { | ||
214 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
215 | .bytesperline = 160, | ||
216 | .sizeimage = 160 * 120 * 3 / 2 + 4, | ||
217 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
218 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
219 | .bytesperline = 176, | ||
220 | .sizeimage = 176 * 144 * 3 / 2 + 4, | ||
221 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
222 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
223 | .bytesperline = 320, | ||
224 | .sizeimage = 320 * 240 * 3 / 2 + 4, | ||
225 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
226 | }; | ||
227 | |||
228 | static const struct v4l2_pix_format model2_mode[] = { | ||
229 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
230 | .bytesperline = 160, | ||
231 | .sizeimage = 160 * 120 * 3 / 2 + 4, | ||
232 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
233 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | ||
234 | .bytesperline = 176, | ||
235 | .sizeimage = 176 * 144 * 3 / 2 + 4, | ||
236 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
237 | {320, 240, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
238 | .bytesperline = 320, | ||
239 | .sizeimage = 320 * 240 + 4, | ||
240 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
241 | {352, 288, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | ||
242 | .bytesperline = 352, | ||
243 | .sizeimage = 352 * 288 + 4, | ||
244 | .colorspace = V4L2_COLORSPACE_SRGB}, | ||
245 | }; | ||
246 | |||
247 | /* | ||
248 | * 01.01.08 - Added for RCA video in support -LO | ||
249 | * This struct is used to init the Model3 cam to use the RCA video in port | ||
250 | * instead of the CCD sensor. | ||
251 | */ | ||
252 | static const u16 rca_initdata[][3] = { | ||
253 | {0, 0x0000, 0x010c}, | ||
254 | {0, 0x0006, 0x012c}, | ||
255 | {0, 0x0078, 0x012d}, | ||
256 | {0, 0x0046, 0x012f}, | ||
257 | {0, 0xd141, 0x0124}, | ||
258 | {0, 0x0000, 0x0127}, | ||
259 | {0, 0xfea8, 0x0124}, | ||
260 | {1, 0x0000, 0x0116}, | ||
261 | {0, 0x0064, 0x0116}, | ||
262 | {1, 0x0000, 0x0115}, | ||
263 | {0, 0x0003, 0x0115}, | ||
264 | {0, 0x0008, 0x0123}, | ||
265 | {0, 0x0000, 0x0117}, | ||
266 | {0, 0x0000, 0x0112}, | ||
267 | {0, 0x0080, 0x0100}, | ||
268 | {0, 0x0000, 0x0100}, | ||
269 | {1, 0x0000, 0x0116}, | ||
270 | {0, 0x0060, 0x0116}, | ||
271 | {0, 0x0002, 0x0112}, | ||
272 | {0, 0x0000, 0x0123}, | ||
273 | {0, 0x0001, 0x0117}, | ||
274 | {0, 0x0040, 0x0108}, | ||
275 | {0, 0x0019, 0x012c}, | ||
276 | {0, 0x0040, 0x0116}, | ||
277 | {0, 0x000a, 0x0115}, | ||
278 | {0, 0x000b, 0x0115}, | ||
279 | {0, 0x0078, 0x012d}, | ||
280 | {0, 0x0046, 0x012f}, | ||
281 | {0, 0xd141, 0x0124}, | ||
282 | {0, 0x0000, 0x0127}, | ||
283 | {0, 0xfea8, 0x0124}, | ||
284 | {0, 0x0064, 0x0116}, | ||
285 | {0, 0x0000, 0x0115}, | ||
286 | {0, 0x0001, 0x0115}, | ||
287 | {0, 0xffff, 0x0124}, | ||
288 | {0, 0xfff9, 0x0124}, | ||
289 | {0, 0x0086, 0x0127}, | ||
290 | {0, 0xfff8, 0x0124}, | ||
291 | {0, 0xfffd, 0x0124}, | ||
292 | {0, 0x00aa, 0x0127}, | ||
293 | {0, 0xfff8, 0x0124}, | ||
294 | {0, 0xfffd, 0x0124}, | ||
295 | {0, 0x0000, 0x0127}, | ||
296 | {0, 0xfff8, 0x0124}, | ||
297 | {0, 0xfffd, 0x0124}, | ||
298 | {0, 0xfffa, 0x0124}, | ||
299 | {0, 0xffff, 0x0124}, | ||
300 | {0, 0xfff9, 0x0124}, | ||
301 | {0, 0x0086, 0x0127}, | ||
302 | {0, 0xfff8, 0x0124}, | ||
303 | {0, 0xfffd, 0x0124}, | ||
304 | {0, 0x00f2, 0x0127}, | ||
305 | {0, 0xfff8, 0x0124}, | ||
306 | {0, 0xfffd, 0x0124}, | ||
307 | {0, 0x000f, 0x0127}, | ||
308 | {0, 0xfff8, 0x0124}, | ||
309 | {0, 0xfffd, 0x0124}, | ||
310 | {0, 0xfffa, 0x0124}, | ||
311 | {0, 0xffff, 0x0124}, | ||
312 | {0, 0xfff9, 0x0124}, | ||
313 | {0, 0x0086, 0x0127}, | ||
314 | {0, 0xfff8, 0x0124}, | ||
315 | {0, 0xfffd, 0x0124}, | ||
316 | {0, 0x00f8, 0x0127}, | ||
317 | {0, 0xfff8, 0x0124}, | ||
318 | {0, 0xfffd, 0x0124}, | ||
319 | {0, 0x00fc, 0x0127}, | ||
320 | {0, 0xfff8, 0x0124}, | ||
321 | {0, 0xfffd, 0x0124}, | ||
322 | {0, 0xfffa, 0x0124}, | ||
323 | {0, 0xffff, 0x0124}, | ||
324 | {0, 0xfff9, 0x0124}, | ||
325 | {0, 0x0086, 0x0127}, | ||
326 | {0, 0xfff8, 0x0124}, | ||
327 | {0, 0xfffd, 0x0124}, | ||
328 | {0, 0x00f9, 0x0127}, | ||
329 | {0, 0xfff8, 0x0124}, | ||
330 | {0, 0xfffd, 0x0124}, | ||
331 | {0, 0x003c, 0x0127}, | ||
332 | {0, 0xfff8, 0x0124}, | ||
333 | {0, 0xfffd, 0x0124}, | ||
334 | {0, 0xfffa, 0x0124}, | ||
335 | {0, 0xffff, 0x0124}, | ||
336 | {0, 0xfff9, 0x0124}, | ||
337 | {0, 0x0086, 0x0127}, | ||
338 | {0, 0xfff8, 0x0124}, | ||
339 | {0, 0xfffd, 0x0124}, | ||
340 | {0, 0x0027, 0x0127}, | ||
341 | {0, 0xfff8, 0x0124}, | ||
342 | {0, 0xfffd, 0x0124}, | ||
343 | {0, 0x0019, 0x0127}, | ||
344 | {0, 0xfff8, 0x0124}, | ||
345 | {0, 0xfffd, 0x0124}, | ||
346 | {0, 0xfffa, 0x0124}, | ||
347 | {0, 0xfff9, 0x0124}, | ||
348 | {0, 0x0086, 0x0127}, | ||
349 | {0, 0xfff8, 0x0124}, | ||
350 | {0, 0xfffd, 0x0124}, | ||
351 | {0, 0x0037, 0x0127}, | ||
352 | {0, 0xfff8, 0x0124}, | ||
353 | {0, 0xfffd, 0x0124}, | ||
354 | {0, 0x0000, 0x0127}, | ||
355 | {0, 0xfff8, 0x0124}, | ||
356 | {0, 0xfffd, 0x0124}, | ||
357 | {0, 0x0021, 0x0127}, | ||
358 | {0, 0xfff8, 0x0124}, | ||
359 | {0, 0xfffd, 0x0124}, | ||
360 | {0, 0xfffa, 0x0124}, | ||
361 | {0, 0xfff9, 0x0124}, | ||
362 | {0, 0x0086, 0x0127}, | ||
363 | {0, 0xfff8, 0x0124}, | ||
364 | {0, 0xfffd, 0x0124}, | ||
365 | {0, 0x0038, 0x0127}, | ||
366 | {0, 0xfff8, 0x0124}, | ||
367 | {0, 0xfffd, 0x0124}, | ||
368 | {0, 0x0006, 0x0127}, | ||
369 | {0, 0xfff8, 0x0124}, | ||
370 | {0, 0xfffd, 0x0124}, | ||
371 | {0, 0x0045, 0x0127}, | ||
372 | {0, 0xfff8, 0x0124}, | ||
373 | {0, 0xfffd, 0x0124}, | ||
374 | {0, 0xfffa, 0x0124}, | ||
375 | {0, 0xfff9, 0x0124}, | ||
376 | {0, 0x0086, 0x0127}, | ||
377 | {0, 0xfff8, 0x0124}, | ||
378 | {0, 0xfffd, 0x0124}, | ||
379 | {0, 0x0037, 0x0127}, | ||
380 | {0, 0xfff8, 0x0124}, | ||
381 | {0, 0xfffd, 0x0124}, | ||
382 | {0, 0x0001, 0x0127}, | ||
383 | {0, 0xfff8, 0x0124}, | ||
384 | {0, 0xfffd, 0x0124}, | ||
385 | {0, 0x002a, 0x0127}, | ||
386 | {0, 0xfff8, 0x0124}, | ||
387 | {0, 0xfffd, 0x0124}, | ||
388 | {0, 0xfffa, 0x0124}, | ||
389 | {0, 0xfff9, 0x0124}, | ||
390 | {0, 0x0086, 0x0127}, | ||
391 | {0, 0xfff8, 0x0124}, | ||
392 | {0, 0xfffd, 0x0124}, | ||
393 | {0, 0x0038, 0x0127}, | ||
394 | {0, 0xfff8, 0x0124}, | ||
395 | {0, 0xfffd, 0x0124}, | ||
396 | {0, 0x0000, 0x0127}, | ||
397 | {0, 0xfff8, 0x0124}, | ||
398 | {0, 0xfffd, 0x0124}, | ||
399 | {0, 0x000e, 0x0127}, | ||
400 | {0, 0xfff8, 0x0124}, | ||
401 | {0, 0xfffd, 0x0124}, | ||
402 | {0, 0xfffa, 0x0124}, | ||
403 | {0, 0xfff9, 0x0124}, | ||
404 | {0, 0x0086, 0x0127}, | ||
405 | {0, 0xfff8, 0x0124}, | ||
406 | {0, 0xfffd, 0x0124}, | ||
407 | {0, 0x0037, 0x0127}, | ||
408 | {0, 0xfff8, 0x0124}, | ||
409 | {0, 0xfffd, 0x0124}, | ||
410 | {0, 0x0001, 0x0127}, | ||
411 | {0, 0xfff8, 0x0124}, | ||
412 | {0, 0xfffd, 0x0124}, | ||
413 | {0, 0x002b, 0x0127}, | ||
414 | {0, 0xfff8, 0x0124}, | ||
415 | {0, 0xfffd, 0x0124}, | ||
416 | {0, 0xfffa, 0x0124}, | ||
417 | {0, 0xfff9, 0x0124}, | ||
418 | {0, 0x0086, 0x0127}, | ||
419 | {0, 0xfff8, 0x0124}, | ||
420 | {0, 0xfffd, 0x0124}, | ||
421 | {0, 0x0038, 0x0127}, | ||
422 | {0, 0xfff8, 0x0124}, | ||
423 | {0, 0xfffd, 0x0124}, | ||
424 | {0, 0x0001, 0x0127}, | ||
425 | {0, 0xfff8, 0x0124}, | ||
426 | {0, 0xfffd, 0x0124}, | ||
427 | {0, 0x00f4, 0x0127}, | ||
428 | {0, 0xfff8, 0x0124}, | ||
429 | {0, 0xfffd, 0x0124}, | ||
430 | {0, 0xfffa, 0x0124}, | ||
431 | {0, 0xfff9, 0x0124}, | ||
432 | {0, 0x0086, 0x0127}, | ||
433 | {0, 0xfff8, 0x0124}, | ||
434 | {0, 0xfffd, 0x0124}, | ||
435 | {0, 0x0037, 0x0127}, | ||
436 | {0, 0xfff8, 0x0124}, | ||
437 | {0, 0xfffd, 0x0124}, | ||
438 | {0, 0x0001, 0x0127}, | ||
439 | {0, 0xfff8, 0x0124}, | ||
440 | {0, 0xfffd, 0x0124}, | ||
441 | {0, 0x002c, 0x0127}, | ||
442 | {0, 0xfff8, 0x0124}, | ||
443 | {0, 0xfffd, 0x0124}, | ||
444 | {0, 0xfffa, 0x0124}, | ||
445 | {0, 0xfff9, 0x0124}, | ||
446 | {0, 0x0086, 0x0127}, | ||
447 | {0, 0xfff8, 0x0124}, | ||
448 | {0, 0xfffd, 0x0124}, | ||
449 | {0, 0x0038, 0x0127}, | ||
450 | {0, 0xfff8, 0x0124}, | ||
451 | {0, 0xfffd, 0x0124}, | ||
452 | {0, 0x0001, 0x0127}, | ||
453 | {0, 0xfff8, 0x0124}, | ||
454 | {0, 0xfffd, 0x0124}, | ||
455 | {0, 0x0004, 0x0127}, | ||
456 | {0, 0xfff8, 0x0124}, | ||
457 | {0, 0xfffd, 0x0124}, | ||
458 | {0, 0xfffa, 0x0124}, | ||
459 | {0, 0xfff9, 0x0124}, | ||
460 | {0, 0x0086, 0x0127}, | ||
461 | {0, 0xfff8, 0x0124}, | ||
462 | {0, 0xfffd, 0x0124}, | ||
463 | {0, 0x0037, 0x0127}, | ||
464 | {0, 0xfff8, 0x0124}, | ||
465 | {0, 0xfffd, 0x0124}, | ||
466 | {0, 0x0001, 0x0127}, | ||
467 | {0, 0xfff8, 0x0124}, | ||
468 | {0, 0xfffd, 0x0124}, | ||
469 | {0, 0x002d, 0x0127}, | ||
470 | {0, 0xfff8, 0x0124}, | ||
471 | {0, 0xfffd, 0x0124}, | ||
472 | {0, 0xfffa, 0x0124}, | ||
473 | {0, 0xfff9, 0x0124}, | ||
474 | {0, 0x0086, 0x0127}, | ||
475 | {0, 0xfff8, 0x0124}, | ||
476 | {0, 0xfffd, 0x0124}, | ||
477 | {0, 0x0038, 0x0127}, | ||
478 | {0, 0xfff8, 0x0124}, | ||
479 | {0, 0xfffd, 0x0124}, | ||
480 | {0, 0x0000, 0x0127}, | ||
481 | {0, 0xfff8, 0x0124}, | ||
482 | {0, 0xfffd, 0x0124}, | ||
483 | {0, 0x0014, 0x0127}, | ||
484 | {0, 0xfff8, 0x0124}, | ||
485 | {0, 0xfffd, 0x0124}, | ||
486 | {0, 0xfffa, 0x0124}, | ||
487 | {0, 0xfff9, 0x0124}, | ||
488 | {0, 0x0086, 0x0127}, | ||
489 | {0, 0xfff8, 0x0124}, | ||
490 | {0, 0xfffd, 0x0124}, | ||
491 | {0, 0x0037, 0x0127}, | ||
492 | {0, 0xfff8, 0x0124}, | ||
493 | {0, 0xfffd, 0x0124}, | ||
494 | {0, 0x0001, 0x0127}, | ||
495 | {0, 0xfff8, 0x0124}, | ||
496 | {0, 0xfffd, 0x0124}, | ||
497 | {0, 0x002e, 0x0127}, | ||
498 | {0, 0xfff8, 0x0124}, | ||
499 | {0, 0xfffd, 0x0124}, | ||
500 | {0, 0xfffa, 0x0124}, | ||
501 | {0, 0xfff9, 0x0124}, | ||
502 | {0, 0x0086, 0x0127}, | ||
503 | {0, 0xfff8, 0x0124}, | ||
504 | {0, 0xfffd, 0x0124}, | ||
505 | {0, 0x0038, 0x0127}, | ||
506 | {0, 0xfff8, 0x0124}, | ||
507 | {0, 0xfffd, 0x0124}, | ||
508 | {0, 0x0003, 0x0127}, | ||
509 | {0, 0xfff8, 0x0124}, | ||
510 | {0, 0xfffd, 0x0124}, | ||
511 | {0, 0x0000, 0x0127}, | ||
512 | {0, 0xfff8, 0x0124}, | ||
513 | {0, 0xfffd, 0x0124}, | ||
514 | {0, 0xfffa, 0x0124}, | ||
515 | {0, 0xfff9, 0x0124}, | ||
516 | {0, 0x0086, 0x0127}, | ||
517 | {0, 0xfff8, 0x0124}, | ||
518 | {0, 0xfffd, 0x0124}, | ||
519 | {0, 0x0037, 0x0127}, | ||
520 | {0, 0xfff8, 0x0124}, | ||
521 | {0, 0xfffd, 0x0124}, | ||
522 | {0, 0x0001, 0x0127}, | ||
523 | {0, 0xfff8, 0x0124}, | ||
524 | {0, 0xfffd, 0x0124}, | ||
525 | {0, 0x002f, 0x0127}, | ||
526 | {0, 0xfff8, 0x0124}, | ||
527 | {0, 0xfffd, 0x0124}, | ||
528 | {0, 0xfffa, 0x0124}, | ||
529 | {0, 0xfff9, 0x0124}, | ||
530 | {0, 0x0086, 0x0127}, | ||
531 | {0, 0xfff8, 0x0124}, | ||
532 | {0, 0xfffd, 0x0124}, | ||
533 | {0, 0x0038, 0x0127}, | ||
534 | {0, 0xfff8, 0x0124}, | ||
535 | {0, 0xfffd, 0x0124}, | ||
536 | {0, 0x0003, 0x0127}, | ||
537 | {0, 0xfff8, 0x0124}, | ||
538 | {0, 0xfffd, 0x0124}, | ||
539 | {0, 0x0014, 0x0127}, | ||
540 | {0, 0xfff8, 0x0124}, | ||
541 | {0, 0xfffd, 0x0124}, | ||
542 | {0, 0xfffa, 0x0124}, | ||
543 | {0, 0xfff9, 0x0124}, | ||
544 | {0, 0x0086, 0x0127}, | ||
545 | {0, 0xfff8, 0x0124}, | ||
546 | {0, 0xfffd, 0x0124}, | ||
547 | {0, 0x0037, 0x0127}, | ||
548 | {0, 0xfff8, 0x0124}, | ||
549 | {0, 0xfffd, 0x0124}, | ||
550 | {0, 0x0001, 0x0127}, | ||
551 | {0, 0xfff8, 0x0124}, | ||
552 | {0, 0xfffd, 0x0124}, | ||
553 | {0, 0x0040, 0x0127}, | ||
554 | {0, 0xfff8, 0x0124}, | ||
555 | {0, 0xfffd, 0x0124}, | ||
556 | {0, 0xfffa, 0x0124}, | ||
557 | {0, 0xfff9, 0x0124}, | ||
558 | {0, 0x0086, 0x0127}, | ||
559 | {0, 0xfff8, 0x0124}, | ||
560 | {0, 0xfffd, 0x0124}, | ||
561 | {0, 0x0038, 0x0127}, | ||
562 | {0, 0xfff8, 0x0124}, | ||
563 | {0, 0xfffd, 0x0124}, | ||
564 | {0, 0x0000, 0x0127}, | ||
565 | {0, 0xfff8, 0x0124}, | ||
566 | {0, 0xfffd, 0x0124}, | ||
567 | {0, 0x0040, 0x0127}, | ||
568 | {0, 0xfff8, 0x0124}, | ||
569 | {0, 0xfffd, 0x0124}, | ||
570 | {0, 0xfffa, 0x0124}, | ||
571 | {0, 0xfff9, 0x0124}, | ||
572 | {0, 0x0086, 0x0127}, | ||
573 | {0, 0xfff8, 0x0124}, | ||
574 | {0, 0xfffd, 0x0124}, | ||
575 | {0, 0x0037, 0x0127}, | ||
576 | {0, 0xfff8, 0x0124}, | ||
577 | {0, 0xfffd, 0x0124}, | ||
578 | {0, 0x0001, 0x0127}, | ||
579 | {0, 0xfff8, 0x0124}, | ||
580 | {0, 0xfffd, 0x0124}, | ||
581 | {0, 0x0053, 0x0127}, | ||
582 | {0, 0xfff8, 0x0124}, | ||
583 | {0, 0xfffd, 0x0124}, | ||
584 | {0, 0xfffa, 0x0124}, | ||
585 | {0, 0xfff9, 0x0124}, | ||
586 | {0, 0x0086, 0x0127}, | ||
587 | {0, 0xfff8, 0x0124}, | ||
588 | {0, 0xfffd, 0x0124}, | ||
589 | {0, 0x0038, 0x0127}, | ||
590 | {0, 0xfff8, 0x0124}, | ||
591 | {0, 0xfffd, 0x0124}, | ||
592 | {0, 0x0000, 0x0127}, | ||
593 | {0, 0xfff8, 0x0124}, | ||
594 | {0, 0xfffd, 0x0124}, | ||
595 | {0, 0x0038, 0x0127}, | ||
596 | {0, 0xfff8, 0x0124}, | ||
597 | {0, 0xfffd, 0x0124}, | ||
598 | {0, 0xfffa, 0x0124}, | ||
599 | {0, 0x0000, 0x0101}, | ||
600 | {0, 0x00a0, 0x0103}, | ||
601 | {0, 0x0078, 0x0105}, | ||
602 | {0, 0x0000, 0x010a}, | ||
603 | {0, 0x0024, 0x010b}, | ||
604 | {0, 0x0028, 0x0119}, | ||
605 | {0, 0x0088, 0x011b}, | ||
606 | {0, 0x0002, 0x011d}, | ||
607 | {0, 0x0003, 0x011e}, | ||
608 | {0, 0x0000, 0x0129}, | ||
609 | {0, 0x00fc, 0x012b}, | ||
610 | {0, 0x0008, 0x0102}, | ||
611 | {0, 0x0000, 0x0104}, | ||
612 | {0, 0x0008, 0x011a}, | ||
613 | {0, 0x0028, 0x011c}, | ||
614 | {0, 0x0021, 0x012a}, | ||
615 | {0, 0x0000, 0x0118}, | ||
616 | {0, 0x0000, 0x0132}, | ||
617 | {0, 0x0000, 0x0109}, | ||
618 | {0, 0xfff9, 0x0124}, | ||
619 | {0, 0x0086, 0x0127}, | ||
620 | {0, 0xfff8, 0x0124}, | ||
621 | {0, 0xfffd, 0x0124}, | ||
622 | {0, 0x0037, 0x0127}, | ||
623 | {0, 0xfff8, 0x0124}, | ||
624 | {0, 0xfffd, 0x0124}, | ||
625 | {0, 0x0001, 0x0127}, | ||
626 | {0, 0xfff8, 0x0124}, | ||
627 | {0, 0xfffd, 0x0124}, | ||
628 | {0, 0x0031, 0x0127}, | ||
629 | {0, 0xfff8, 0x0124}, | ||
630 | {0, 0xfffd, 0x0124}, | ||
631 | {0, 0xfffa, 0x0124}, | ||
632 | {0, 0xfff9, 0x0124}, | ||
633 | {0, 0x0086, 0x0127}, | ||
634 | {0, 0xfff8, 0x0124}, | ||
635 | {0, 0xfffd, 0x0124}, | ||
636 | {0, 0x0038, 0x0127}, | ||
637 | {0, 0xfff8, 0x0124}, | ||
638 | {0, 0xfffd, 0x0124}, | ||
639 | {0, 0x0000, 0x0127}, | ||
640 | {0, 0xfff8, 0x0124}, | ||
641 | {0, 0xfffd, 0x0124}, | ||
642 | {0, 0x0000, 0x0127}, | ||
643 | {0, 0xfff8, 0x0124}, | ||
644 | {0, 0xfffd, 0x0124}, | ||
645 | {0, 0xfffa, 0x0124}, | ||
646 | {0, 0xfff9, 0x0124}, | ||
647 | {0, 0x0086, 0x0127}, | ||
648 | {0, 0xfff8, 0x0124}, | ||
649 | {0, 0xfffd, 0x0124}, | ||
650 | {0, 0x0037, 0x0127}, | ||
651 | {0, 0xfff8, 0x0124}, | ||
652 | {0, 0xfffd, 0x0124}, | ||
653 | {0, 0x0001, 0x0127}, | ||
654 | {0, 0xfff8, 0x0124}, | ||
655 | {0, 0xfffd, 0x0124}, | ||
656 | {0, 0x0040, 0x0127}, | ||
657 | {0, 0xfff8, 0x0124}, | ||
658 | {0, 0xfffd, 0x0124}, | ||
659 | {0, 0xfffa, 0x0124}, | ||
660 | {0, 0xfff9, 0x0124}, | ||
661 | {0, 0x0086, 0x0127}, | ||
662 | {0, 0xfff8, 0x0124}, | ||
663 | {0, 0xfffd, 0x0124}, | ||
664 | {0, 0x0038, 0x0127}, | ||
665 | {0, 0xfff8, 0x0124}, | ||
666 | {0, 0xfffd, 0x0124}, | ||
667 | {0, 0x0000, 0x0127}, | ||
668 | {0, 0xfff8, 0x0124}, | ||
669 | {0, 0xfffd, 0x0124}, | ||
670 | {0, 0x0040, 0x0127}, | ||
671 | {0, 0xfff8, 0x0124}, | ||
672 | {0, 0xfffd, 0x0124}, | ||
673 | {0, 0xfffa, 0x0124}, | ||
674 | {0, 0xfff9, 0x0124}, | ||
675 | {0, 0x0086, 0x0127}, | ||
676 | {0, 0xfff8, 0x0124}, | ||
677 | {0, 0xfffd, 0x0124}, | ||
678 | {0, 0x0037, 0x0127}, | ||
679 | {0, 0xfff8, 0x0124}, | ||
680 | {0, 0xfffd, 0x0124}, | ||
681 | {0, 0x0000, 0x0127}, | ||
682 | {0, 0xfff8, 0x0124}, | ||
683 | {0, 0xfffd, 0x0124}, | ||
684 | {0, 0x00dc, 0x0127}, | ||
685 | {0, 0xfff8, 0x0124}, | ||
686 | {0, 0xfffd, 0x0124}, | ||
687 | {0, 0xfffa, 0x0124}, | ||
688 | {0, 0xfff9, 0x0124}, | ||
689 | {0, 0x0086, 0x0127}, | ||
690 | {0, 0xfff8, 0x0124}, | ||
691 | {0, 0xfffd, 0x0124}, | ||
692 | {0, 0x0038, 0x0127}, | ||
693 | {0, 0xfff8, 0x0124}, | ||
694 | {0, 0xfffd, 0x0124}, | ||
695 | {0, 0x0000, 0x0127}, | ||
696 | {0, 0xfff8, 0x0124}, | ||
697 | {0, 0xfffd, 0x0124}, | ||
698 | {0, 0x0000, 0x0127}, | ||
699 | {0, 0xfff8, 0x0124}, | ||
700 | {0, 0xfffd, 0x0124}, | ||
701 | {0, 0xfffa, 0x0124}, | ||
702 | {0, 0xfff9, 0x0124}, | ||
703 | {0, 0x0086, 0x0127}, | ||
704 | {0, 0xfff8, 0x0124}, | ||
705 | {0, 0xfffd, 0x0124}, | ||
706 | {0, 0x0037, 0x0127}, | ||
707 | {0, 0xfff8, 0x0124}, | ||
708 | {0, 0xfffd, 0x0124}, | ||
709 | {0, 0x0001, 0x0127}, | ||
710 | {0, 0xfff8, 0x0124}, | ||
711 | {0, 0xfffd, 0x0124}, | ||
712 | {0, 0x0032, 0x0127}, | ||
713 | {0, 0xfff8, 0x0124}, | ||
714 | {0, 0xfffd, 0x0124}, | ||
715 | {0, 0xfffa, 0x0124}, | ||
716 | {0, 0xfff9, 0x0124}, | ||
717 | {0, 0x0086, 0x0127}, | ||
718 | {0, 0xfff8, 0x0124}, | ||
719 | {0, 0xfffd, 0x0124}, | ||
720 | {0, 0x0038, 0x0127}, | ||
721 | {0, 0xfff8, 0x0124}, | ||
722 | {0, 0xfffd, 0x0124}, | ||
723 | {0, 0x0001, 0x0127}, | ||
724 | {0, 0xfff8, 0x0124}, | ||
725 | {0, 0xfffd, 0x0124}, | ||
726 | {0, 0x0020, 0x0127}, | ||
727 | {0, 0xfff8, 0x0124}, | ||
728 | {0, 0xfffd, 0x0124}, | ||
729 | {0, 0xfffa, 0x0124}, | ||
730 | {0, 0xfff9, 0x0124}, | ||
731 | {0, 0x0086, 0x0127}, | ||
732 | {0, 0xfff8, 0x0124}, | ||
733 | {0, 0xfffd, 0x0124}, | ||
734 | {0, 0x0037, 0x0127}, | ||
735 | {0, 0xfff8, 0x0124}, | ||
736 | {0, 0xfffd, 0x0124}, | ||
737 | {0, 0x0001, 0x0127}, | ||
738 | {0, 0xfff8, 0x0124}, | ||
739 | {0, 0xfffd, 0x0124}, | ||
740 | {0, 0x0040, 0x0127}, | ||
741 | {0, 0xfff8, 0x0124}, | ||
742 | {0, 0xfffd, 0x0124}, | ||
743 | {0, 0xfffa, 0x0124}, | ||
744 | {0, 0xfff9, 0x0124}, | ||
745 | {0, 0x0086, 0x0127}, | ||
746 | {0, 0xfff8, 0x0124}, | ||
747 | {0, 0xfffd, 0x0124}, | ||
748 | {0, 0x0038, 0x0127}, | ||
749 | {0, 0xfff8, 0x0124}, | ||
750 | {0, 0xfffd, 0x0124}, | ||
751 | {0, 0x0000, 0x0127}, | ||
752 | {0, 0xfff8, 0x0124}, | ||
753 | {0, 0xfffd, 0x0124}, | ||
754 | {0, 0x0040, 0x0127}, | ||
755 | {0, 0xfff8, 0x0124}, | ||
756 | {0, 0xfffd, 0x0124}, | ||
757 | {0, 0xfffa, 0x0124}, | ||
758 | {0, 0xfff9, 0x0124}, | ||
759 | {0, 0x0086, 0x0127}, | ||
760 | {0, 0xfff8, 0x0124}, | ||
761 | {0, 0xfffd, 0x0124}, | ||
762 | {0, 0x0037, 0x0127}, | ||
763 | {0, 0xfff8, 0x0124}, | ||
764 | {0, 0xfffd, 0x0124}, | ||
765 | {0, 0x0000, 0x0127}, | ||
766 | {0, 0xfff8, 0x0124}, | ||
767 | {0, 0xfffd, 0x0124}, | ||
768 | {0, 0x0030, 0x0127}, | ||
769 | {0, 0xfff8, 0x0124}, | ||
770 | {0, 0xfffd, 0x0124}, | ||
771 | {0, 0xfffa, 0x0124}, | ||
772 | {0, 0xfff9, 0x0124}, | ||
773 | {0, 0x0086, 0x0127}, | ||
774 | {0, 0xfff8, 0x0124}, | ||
775 | {0, 0xfffd, 0x0124}, | ||
776 | {0, 0x0038, 0x0127}, | ||
777 | {0, 0xfff8, 0x0124}, | ||
778 | {0, 0xfffd, 0x0124}, | ||
779 | {0, 0x0008, 0x0127}, | ||
780 | {0, 0xfff8, 0x0124}, | ||
781 | {0, 0xfffd, 0x0124}, | ||
782 | {0, 0x0000, 0x0127}, | ||
783 | {0, 0xfff8, 0x0124}, | ||
784 | {0, 0xfffd, 0x0124}, | ||
785 | {0, 0xfffa, 0x0124}, | ||
786 | {0, 0x0003, 0x0111}, | ||
787 | }; | ||
788 | |||
789 | /* TESTME the old ibmcam driver repeats certain commands to Model1 cameras, we | ||
790 | do the same for now (testing needed to see if this is really necessary) */ | ||
791 | static const int cit_model1_ntries = 5; | ||
792 | static const int cit_model1_ntries2 = 2; | ||
793 | |||
794 | static int cit_write_reg(struct gspca_dev *gspca_dev, u16 value, u16 index) | ||
795 | { | ||
796 | struct usb_device *udev = gspca_dev->dev; | ||
797 | int err; | ||
798 | |||
799 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, | ||
800 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, | ||
801 | value, index, NULL, 0, 1000); | ||
802 | if (err < 0) | ||
803 | err("Failed to write a register (index 0x%04X," | ||
804 | " value 0x%02X, error %d)", index, value, err); | ||
805 | |||
806 | return 0; | ||
807 | } | ||
808 | |||
809 | static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index, int verbose) | ||
810 | { | ||
811 | struct usb_device *udev = gspca_dev->dev; | ||
812 | __u8 *buf = gspca_dev->usb_buf; | ||
813 | int res; | ||
814 | |||
815 | res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x01, | ||
816 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, | ||
817 | 0x00, index, buf, 8, 1000); | ||
818 | if (res < 0) { | ||
819 | err("Failed to read a register (index 0x%04X, error %d)", | ||
820 | index, res); | ||
821 | return res; | ||
822 | } | ||
823 | |||
824 | if (verbose) | ||
825 | PDEBUG(D_PROBE, "Register %04x value: %02x", index, buf[0]); | ||
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 | */ | ||
839 | static 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 | |||
846 | static 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 | |||
853 | static 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 | |||
859 | static 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 | |||
865 | static 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 | |||
873 | static 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 | |||
881 | static 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 | |||
890 | static 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 | |||
900 | static 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, 0); | ||
911 | cit_send_FF_04_02(gspca_dev); | ||
912 | } | ||
913 | |||
914 | static 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 | |||
921 | static 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 | |||
927 | static 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 | */ | ||
948 | static 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 | |||
957 | static 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 | |||
966 | static 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 */ | ||
981 | static 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 | |||
1051 | static 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 | |||
1075 | static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev) | ||
1076 | { | ||
1077 | cit_read_reg(gspca_dev, 0x128, 1); | ||
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, 0); | ||
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, 1); | ||
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 */ | ||
1268 | static 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 | |||
1290 | static 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 | |||
1330 | static 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 | |||
1393 | static 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 | |||
1445 | static 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 | */ | ||
1513 | static 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 | |||
1533 | static 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 | |||
1553 | static 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 | cit_write_reg(gspca_dev, 0x0001, 0x0114); | ||
1561 | /* Fall through */ | ||
1562 | case CIT_MODEL2: | ||
1563 | case CIT_MODEL4: | ||
1564 | cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */ | ||
1565 | usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe); | ||
1566 | break; | ||
1567 | case CIT_MODEL3: | ||
1568 | case CIT_IBM_NETCAM_PRO: | ||
1569 | cit_write_reg(gspca_dev, 0x0001, 0x0114); | ||
1570 | cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */ | ||
1571 | usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe); | ||
1572 | /* Clear button events from while we were not streaming */ | ||
1573 | cit_write_reg(gspca_dev, 0x0001, 0x0113); | ||
1574 | break; | ||
1575 | } | ||
1576 | |||
1577 | sd->sof_read = 0; | ||
1578 | |||
1579 | return 0; | ||
1580 | } | ||
1581 | |||
1582 | static int cit_get_packet_size(struct gspca_dev *gspca_dev) | ||
1583 | { | ||
1584 | struct usb_host_interface *alt; | ||
1585 | struct usb_interface *intf; | ||
1586 | |||
1587 | intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); | ||
1588 | alt = usb_altnum_to_altsetting(intf, gspca_dev->alt); | ||
1589 | if (!alt) { | ||
1590 | err("Couldn't get altsetting"); | ||
1591 | return -EIO; | ||
1592 | } | ||
1593 | |||
1594 | return le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
1595 | } | ||
1596 | |||
1597 | /* Calculate the clockdiv giving us max fps given the available bandwidth */ | ||
1598 | static int cit_get_clock_div(struct gspca_dev *gspca_dev) | ||
1599 | { | ||
1600 | int clock_div = 7; /* 0=30 1=25 2=20 3=15 4=12 5=7.5 6=6 7=3fps ?? */ | ||
1601 | int fps[8] = { 30, 25, 20, 15, 12, 8, 6, 3 }; | ||
1602 | int packet_size; | ||
1603 | |||
1604 | packet_size = cit_get_packet_size(gspca_dev); | ||
1605 | if (packet_size < 0) | ||
1606 | return packet_size; | ||
1607 | |||
1608 | while (clock_div > 3 && | ||
1609 | 1000 * packet_size > | ||
1610 | gspca_dev->width * gspca_dev->height * | ||
1611 | fps[clock_div - 1] * 3 / 2) | ||
1612 | clock_div--; | ||
1613 | |||
1614 | PDEBUG(D_PROBE, | ||
1615 | "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)", | ||
1616 | packet_size, gspca_dev->width, gspca_dev->height, clock_div, | ||
1617 | fps[clock_div]); | ||
1618 | |||
1619 | return clock_div; | ||
1620 | } | ||
1621 | |||
1622 | static int cit_start_model0(struct gspca_dev *gspca_dev) | ||
1623 | { | ||
1624 | const unsigned short compression = 0; /* 0=none, 7=best frame rate */ | ||
1625 | int clock_div; | ||
1626 | |||
1627 | clock_div = cit_get_clock_div(gspca_dev); | ||
1628 | if (clock_div < 0) | ||
1629 | return clock_div; | ||
1630 | |||
1631 | cit_write_reg(gspca_dev, 0x0000, 0x0100); /* turn on led */ | ||
1632 | cit_write_reg(gspca_dev, 0x0003, 0x0438); | ||
1633 | cit_write_reg(gspca_dev, 0x001e, 0x042b); | ||
1634 | cit_write_reg(gspca_dev, 0x0041, 0x042c); | ||
1635 | cit_write_reg(gspca_dev, 0x0008, 0x0436); | ||
1636 | cit_write_reg(gspca_dev, 0x0024, 0x0403); | ||
1637 | cit_write_reg(gspca_dev, 0x002c, 0x0404); | ||
1638 | cit_write_reg(gspca_dev, 0x0002, 0x0426); | ||
1639 | cit_write_reg(gspca_dev, 0x0014, 0x0427); | ||
1640 | |||
1641 | switch (gspca_dev->width) { | ||
1642 | case 160: /* 160x120 */ | ||
1643 | cit_write_reg(gspca_dev, 0x0004, 0x010b); | ||
1644 | cit_write_reg(gspca_dev, 0x0001, 0x010a); | ||
1645 | cit_write_reg(gspca_dev, 0x0010, 0x0102); | ||
1646 | cit_write_reg(gspca_dev, 0x00a0, 0x0103); | ||
1647 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
1648 | cit_write_reg(gspca_dev, 0x0078, 0x0105); | ||
1649 | break; | ||
1650 | |||
1651 | case 176: /* 176x144 */ | ||
1652 | cit_write_reg(gspca_dev, 0x0006, 0x010b); | ||
1653 | cit_write_reg(gspca_dev, 0x0000, 0x010a); | ||
1654 | cit_write_reg(gspca_dev, 0x0005, 0x0102); | ||
1655 | cit_write_reg(gspca_dev, 0x00b0, 0x0103); | ||
1656 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
1657 | cit_write_reg(gspca_dev, 0x0090, 0x0105); | ||
1658 | break; | ||
1659 | |||
1660 | case 320: /* 320x240 */ | ||
1661 | cit_write_reg(gspca_dev, 0x0008, 0x010b); | ||
1662 | cit_write_reg(gspca_dev, 0x0004, 0x010a); | ||
1663 | cit_write_reg(gspca_dev, 0x0005, 0x0102); | ||
1664 | cit_write_reg(gspca_dev, 0x00a0, 0x0103); | ||
1665 | cit_write_reg(gspca_dev, 0x0010, 0x0104); | ||
1666 | cit_write_reg(gspca_dev, 0x0078, 0x0105); | ||
1667 | break; | ||
1668 | } | ||
1669 | |||
1670 | cit_write_reg(gspca_dev, compression, 0x0109); | ||
1671 | cit_write_reg(gspca_dev, clock_div, 0x0111); | ||
1672 | |||
1673 | return 0; | ||
1674 | } | ||
1675 | |||
1676 | static int cit_start_model1(struct gspca_dev *gspca_dev) | ||
1677 | { | ||
1678 | struct sd *sd = (struct sd *) gspca_dev; | ||
1679 | int i, clock_div; | ||
1680 | |||
1681 | clock_div = cit_get_clock_div(gspca_dev); | ||
1682 | if (clock_div < 0) | ||
1683 | return clock_div; | ||
1684 | |||
1685 | cit_read_reg(gspca_dev, 0x0128, 1); | ||
1686 | cit_read_reg(gspca_dev, 0x0100, 0); | ||
1687 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ | ||
1688 | cit_read_reg(gspca_dev, 0x0100, 0); | ||
1689 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ | ||
1690 | cit_read_reg(gspca_dev, 0x0100, 0); | ||
1691 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ | ||
1692 | cit_write_reg(gspca_dev, 0x01, 0x0108); | ||
1693 | |||
1694 | cit_write_reg(gspca_dev, 0x03, 0x0112); | ||
1695 | cit_read_reg(gspca_dev, 0x0115, 0); | ||
1696 | cit_write_reg(gspca_dev, 0x06, 0x0115); | ||
1697 | cit_read_reg(gspca_dev, 0x0116, 0); | ||
1698 | cit_write_reg(gspca_dev, 0x44, 0x0116); | ||
1699 | cit_read_reg(gspca_dev, 0x0116, 0); | ||
1700 | cit_write_reg(gspca_dev, 0x40, 0x0116); | ||
1701 | cit_read_reg(gspca_dev, 0x0115, 0); | ||
1702 | cit_write_reg(gspca_dev, 0x0e, 0x0115); | ||
1703 | cit_write_reg(gspca_dev, 0x19, 0x012c); | ||
1704 | |||
1705 | cit_Packet_Format1(gspca_dev, 0x00, 0x1e); | ||
1706 | cit_Packet_Format1(gspca_dev, 0x39, 0x0d); | ||
1707 | cit_Packet_Format1(gspca_dev, 0x39, 0x09); | ||
1708 | cit_Packet_Format1(gspca_dev, 0x3b, 0x00); | ||
1709 | cit_Packet_Format1(gspca_dev, 0x28, 0x22); | ||
1710 | cit_Packet_Format1(gspca_dev, 0x27, 0x00); | ||
1711 | cit_Packet_Format1(gspca_dev, 0x2b, 0x1f); | ||
1712 | cit_Packet_Format1(gspca_dev, 0x39, 0x08); | ||
1713 | |||
1714 | for (i = 0; i < cit_model1_ntries; i++) | ||
1715 | cit_Packet_Format1(gspca_dev, 0x2c, 0x00); | ||
1716 | |||
1717 | for (i = 0; i < cit_model1_ntries; i++) | ||
1718 | cit_Packet_Format1(gspca_dev, 0x30, 0x14); | ||
1719 | |||
1720 | cit_PacketFormat2(gspca_dev, 0x39, 0x02); | ||
1721 | cit_PacketFormat2(gspca_dev, 0x01, 0xe1); | ||
1722 | cit_PacketFormat2(gspca_dev, 0x02, 0xcd); | ||
1723 | cit_PacketFormat2(gspca_dev, 0x03, 0xcd); | ||
1724 | cit_PacketFormat2(gspca_dev, 0x04, 0xfa); | ||
1725 | cit_PacketFormat2(gspca_dev, 0x3f, 0xff); | ||
1726 | cit_PacketFormat2(gspca_dev, 0x39, 0x00); | ||
1727 | |||
1728 | cit_PacketFormat2(gspca_dev, 0x39, 0x02); | ||
1729 | cit_PacketFormat2(gspca_dev, 0x0a, 0x37); | ||
1730 | cit_PacketFormat2(gspca_dev, 0x0b, 0xb8); | ||
1731 | cit_PacketFormat2(gspca_dev, 0x0c, 0xf3); | ||
1732 | cit_PacketFormat2(gspca_dev, 0x0d, 0xe3); | ||
1733 | cit_PacketFormat2(gspca_dev, 0x0e, 0x0d); | ||
1734 | cit_PacketFormat2(gspca_dev, 0x0f, 0xf2); | ||
1735 | cit_PacketFormat2(gspca_dev, 0x10, 0xd5); | ||
1736 | cit_PacketFormat2(gspca_dev, 0x11, 0xba); | ||
1737 | cit_PacketFormat2(gspca_dev, 0x12, 0x53); | ||
1738 | cit_PacketFormat2(gspca_dev, 0x3f, 0xff); | ||
1739 | cit_PacketFormat2(gspca_dev, 0x39, 0x00); | ||
1740 | |||
1741 | cit_PacketFormat2(gspca_dev, 0x39, 0x02); | ||
1742 | cit_PacketFormat2(gspca_dev, 0x16, 0x00); | ||
1743 | cit_PacketFormat2(gspca_dev, 0x17, 0x28); | ||
1744 | cit_PacketFormat2(gspca_dev, 0x18, 0x7d); | ||
1745 | cit_PacketFormat2(gspca_dev, 0x19, 0xbe); | ||
1746 | cit_PacketFormat2(gspca_dev, 0x3f, 0xff); | ||
1747 | cit_PacketFormat2(gspca_dev, 0x39, 0x00); | ||
1748 | |||
1749 | for (i = 0; i < cit_model1_ntries; i++) | ||
1750 | cit_Packet_Format1(gspca_dev, 0x00, 0x18); | ||
1751 | for (i = 0; i < cit_model1_ntries; i++) | ||
1752 | cit_Packet_Format1(gspca_dev, 0x13, 0x18); | ||
1753 | for (i = 0; i < cit_model1_ntries; i++) | ||
1754 | cit_Packet_Format1(gspca_dev, 0x14, 0x06); | ||
1755 | |||
1756 | /* TESTME These are handled through controls | ||
1757 | KEEP until someone can test leaving this out is ok */ | ||
1758 | if (0) { | ||
1759 | /* This is default brightness */ | ||
1760 | for (i = 0; i < cit_model1_ntries; i++) | ||
1761 | cit_Packet_Format1(gspca_dev, 0x31, 0x37); | ||
1762 | for (i = 0; i < cit_model1_ntries; i++) | ||
1763 | cit_Packet_Format1(gspca_dev, 0x32, 0x46); | ||
1764 | for (i = 0; i < cit_model1_ntries; i++) | ||
1765 | cit_Packet_Format1(gspca_dev, 0x33, 0x55); | ||
1766 | } | ||
1767 | |||
1768 | cit_Packet_Format1(gspca_dev, 0x2e, 0x04); | ||
1769 | for (i = 0; i < cit_model1_ntries; i++) | ||
1770 | cit_Packet_Format1(gspca_dev, 0x2d, 0x04); | ||
1771 | for (i = 0; i < cit_model1_ntries; i++) | ||
1772 | cit_Packet_Format1(gspca_dev, 0x29, 0x80); | ||
1773 | cit_Packet_Format1(gspca_dev, 0x2c, 0x01); | ||
1774 | cit_Packet_Format1(gspca_dev, 0x30, 0x17); | ||
1775 | cit_Packet_Format1(gspca_dev, 0x39, 0x08); | ||
1776 | for (i = 0; i < cit_model1_ntries; i++) | ||
1777 | cit_Packet_Format1(gspca_dev, 0x34, 0x00); | ||
1778 | |||
1779 | cit_write_reg(gspca_dev, 0x00, 0x0101); | ||
1780 | cit_write_reg(gspca_dev, 0x00, 0x010a); | ||
1781 | |||
1782 | switch (gspca_dev->width) { | ||
1783 | case 128: /* 128x96 */ | ||
1784 | cit_write_reg(gspca_dev, 0x80, 0x0103); | ||
1785 | cit_write_reg(gspca_dev, 0x60, 0x0105); | ||
1786 | cit_write_reg(gspca_dev, 0x0c, 0x010b); | ||
1787 | cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */ | ||
1788 | cit_write_reg(gspca_dev, 0x0b, 0x011d); | ||
1789 | cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */ | ||
1790 | cit_write_reg(gspca_dev, 0x00, 0x0129); | ||
1791 | break; | ||
1792 | case 176: /* 176x144 */ | ||
1793 | cit_write_reg(gspca_dev, 0xb0, 0x0103); | ||
1794 | cit_write_reg(gspca_dev, 0x8f, 0x0105); | ||
1795 | cit_write_reg(gspca_dev, 0x06, 0x010b); | ||
1796 | cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */ | ||
1797 | cit_write_reg(gspca_dev, 0x0d, 0x011d); | ||
1798 | cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */ | ||
1799 | cit_write_reg(gspca_dev, 0x03, 0x0129); | ||
1800 | break; | ||
1801 | case 352: /* 352x288 */ | ||
1802 | cit_write_reg(gspca_dev, 0xb0, 0x0103); | ||
1803 | cit_write_reg(gspca_dev, 0x90, 0x0105); | ||
1804 | cit_write_reg(gspca_dev, 0x02, 0x010b); | ||
1805 | cit_write_reg(gspca_dev, 0x04, 0x011b); /* Same everywhere */ | ||
1806 | cit_write_reg(gspca_dev, 0x05, 0x011d); | ||
1807 | cit_write_reg(gspca_dev, 0x00, 0x011e); /* Same everywhere */ | ||
1808 | cit_write_reg(gspca_dev, 0x00, 0x0129); | ||
1809 | break; | ||
1810 | } | ||
1811 | |||
1812 | cit_write_reg(gspca_dev, 0xff, 0x012b); | ||
1813 | |||
1814 | /* TESTME These are handled through controls | ||
1815 | KEEP until someone can test leaving this out is ok */ | ||
1816 | if (0) { | ||
1817 | /* This is another brightness - don't know why */ | ||
1818 | for (i = 0; i < cit_model1_ntries; i++) | ||
1819 | cit_Packet_Format1(gspca_dev, 0x31, 0xc3); | ||
1820 | for (i = 0; i < cit_model1_ntries; i++) | ||
1821 | cit_Packet_Format1(gspca_dev, 0x32, 0xd2); | ||
1822 | for (i = 0; i < cit_model1_ntries; i++) | ||
1823 | cit_Packet_Format1(gspca_dev, 0x33, 0xe1); | ||
1824 | |||
1825 | /* Default contrast */ | ||
1826 | for (i = 0; i < cit_model1_ntries; i++) | ||
1827 | cit_Packet_Format1(gspca_dev, 0x14, 0x0a); | ||
1828 | |||
1829 | /* Default sharpness */ | ||
1830 | for (i = 0; i < cit_model1_ntries2; i++) | ||
1831 | cit_PacketFormat2(gspca_dev, 0x13, 0x1a); | ||
1832 | |||
1833 | /* Default lighting conditions */ | ||
1834 | cit_Packet_Format1(gspca_dev, 0x0027, sd->lighting); | ||
1835 | } | ||
1836 | |||
1837 | /* Assorted init */ | ||
1838 | switch (gspca_dev->width) { | ||
1839 | case 128: /* 128x96 */ | ||
1840 | cit_Packet_Format1(gspca_dev, 0x2b, 0x1e); | ||
1841 | cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */ | ||
1842 | cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */ | ||
1843 | cit_write_reg(gspca_dev, 0x36, 0x0102); | ||
1844 | cit_write_reg(gspca_dev, 0x1a, 0x0104); | ||
1845 | cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */ | ||
1846 | cit_write_reg(gspca_dev, 0x2b, 0x011c); | ||
1847 | cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */ | ||
1848 | break; | ||
1849 | case 176: /* 176x144 */ | ||
1850 | cit_Packet_Format1(gspca_dev, 0x2b, 0x1e); | ||
1851 | cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */ | ||
1852 | cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */ | ||
1853 | cit_write_reg(gspca_dev, 0x04, 0x0102); | ||
1854 | cit_write_reg(gspca_dev, 0x02, 0x0104); | ||
1855 | cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */ | ||
1856 | cit_write_reg(gspca_dev, 0x2b, 0x011c); | ||
1857 | cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */ | ||
1858 | break; | ||
1859 | case 352: /* 352x288 */ | ||
1860 | cit_Packet_Format1(gspca_dev, 0x2b, 0x1f); | ||
1861 | cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */ | ||
1862 | cit_write_reg(gspca_dev, 0x80, 0x0109); /* Same everywhere */ | ||
1863 | cit_write_reg(gspca_dev, 0x08, 0x0102); | ||
1864 | cit_write_reg(gspca_dev, 0x01, 0x0104); | ||
1865 | cit_write_reg(gspca_dev, 0x04, 0x011a); /* Same everywhere */ | ||
1866 | cit_write_reg(gspca_dev, 0x2f, 0x011c); | ||
1867 | cit_write_reg(gspca_dev, 0x23, 0x012a); /* Same everywhere */ | ||
1868 | break; | ||
1869 | } | ||
1870 | |||
1871 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ | ||
1872 | cit_write_reg(gspca_dev, clock_div, 0x0111); | ||
1873 | |||
1874 | return 0; | ||
1875 | } | ||
1876 | |||
1877 | static int cit_start_model2(struct gspca_dev *gspca_dev) | ||
1878 | { | ||
1879 | struct sd *sd = (struct sd *) gspca_dev; | ||
1880 | int clock_div = 0; | ||
1881 | |||
1882 | cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ | ||
1883 | cit_read_reg(gspca_dev, 0x0116, 0); | ||
1884 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | ||
1885 | cit_write_reg(gspca_dev, 0x0002, 0x0112); | ||
1886 | cit_write_reg(gspca_dev, 0x00bc, 0x012c); | ||
1887 | cit_write_reg(gspca_dev, 0x0008, 0x012b); | ||
1888 | cit_write_reg(gspca_dev, 0x0000, 0x0108); | ||
1889 | cit_write_reg(gspca_dev, 0x0001, 0x0133); | ||
1890 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
1891 | switch (gspca_dev->width) { | ||
1892 | case 176: /* 176x144 */ | ||
1893 | cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */ | ||
1894 | cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */ | ||
1895 | cit_write_reg(gspca_dev, 0x0024, 0x0105); /* 176x144, 352x288 */ | ||
1896 | cit_write_reg(gspca_dev, 0x00b9, 0x010a); /* Unique to this mode */ | ||
1897 | cit_write_reg(gspca_dev, 0x0038, 0x0119); /* Unique to this mode */ | ||
1898 | /* TESTME HDG: this does not seem right | ||
1899 | (it is 2 for all other resolutions) */ | ||
1900 | sd->sof_len = 10; | ||
1901 | break; | ||
1902 | case 320: /* 320x240 */ | ||
1903 | cit_write_reg(gspca_dev, 0x0028, 0x0103); /* Unique to this mode */ | ||
1904 | cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */ | ||
1905 | cit_write_reg(gspca_dev, 0x001e, 0x0105); /* 320x240, 352x240 */ | ||
1906 | cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */ | ||
1907 | cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */ | ||
1908 | sd->sof_len = 2; | ||
1909 | break; | ||
1910 | /* case VIDEOSIZE_352x240: */ | ||
1911 | cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */ | ||
1912 | cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */ | ||
1913 | cit_write_reg(gspca_dev, 0x001e, 0x0105); /* 320x240, 352x240 */ | ||
1914 | cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */ | ||
1915 | cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */ | ||
1916 | sd->sof_len = 2; | ||
1917 | break; | ||
1918 | case 352: /* 352x288 */ | ||
1919 | cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */ | ||
1920 | cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */ | ||
1921 | cit_write_reg(gspca_dev, 0x0024, 0x0105); /* 176x144, 352x288 */ | ||
1922 | cit_write_reg(gspca_dev, 0x0039, 0x010a); /* All except 176x144 */ | ||
1923 | cit_write_reg(gspca_dev, 0x0070, 0x0119); /* All except 176x144 */ | ||
1924 | sd->sof_len = 2; | ||
1925 | break; | ||
1926 | } | ||
1927 | |||
1928 | cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ | ||
1929 | |||
1930 | switch (gspca_dev->width) { | ||
1931 | case 176: /* 176x144 */ | ||
1932 | cit_write_reg(gspca_dev, 0x0050, 0x0111); | ||
1933 | cit_write_reg(gspca_dev, 0x00d0, 0x0111); | ||
1934 | break; | ||
1935 | case 320: /* 320x240 */ | ||
1936 | case 352: /* 352x288 */ | ||
1937 | cit_write_reg(gspca_dev, 0x0040, 0x0111); | ||
1938 | cit_write_reg(gspca_dev, 0x00c0, 0x0111); | ||
1939 | break; | ||
1940 | } | ||
1941 | cit_write_reg(gspca_dev, 0x009b, 0x010f); | ||
1942 | cit_write_reg(gspca_dev, 0x00bb, 0x010f); | ||
1943 | |||
1944 | /* | ||
1945 | * Hardware settings, may affect CMOS sensor; not user controls! | ||
1946 | * ------------------------------------------------------------- | ||
1947 | * 0x0004: no effect | ||
1948 | * 0x0006: hardware effect | ||
1949 | * 0x0008: no effect | ||
1950 | * 0x000a: stops video stream, probably important h/w setting | ||
1951 | * 0x000c: changes color in hardware manner (not user setting) | ||
1952 | * 0x0012: changes number of colors (does not affect speed) | ||
1953 | * 0x002a: no effect | ||
1954 | * 0x002c: hardware setting (related to scan lines) | ||
1955 | * 0x002e: stops video stream, probably important h/w setting | ||
1956 | */ | ||
1957 | cit_model2_Packet1(gspca_dev, 0x000a, 0x005c); | ||
1958 | cit_model2_Packet1(gspca_dev, 0x0004, 0x0000); | ||
1959 | cit_model2_Packet1(gspca_dev, 0x0006, 0x00fb); | ||
1960 | cit_model2_Packet1(gspca_dev, 0x0008, 0x0000); | ||
1961 | cit_model2_Packet1(gspca_dev, 0x000c, 0x0009); | ||
1962 | cit_model2_Packet1(gspca_dev, 0x0012, 0x000a); | ||
1963 | cit_model2_Packet1(gspca_dev, 0x002a, 0x0000); | ||
1964 | cit_model2_Packet1(gspca_dev, 0x002c, 0x0000); | ||
1965 | cit_model2_Packet1(gspca_dev, 0x002e, 0x0008); | ||
1966 | |||
1967 | /* | ||
1968 | * Function 0x0030 pops up all over the place. Apparently | ||
1969 | * it is a hardware control register, with every bit assigned to | ||
1970 | * do something. | ||
1971 | */ | ||
1972 | cit_model2_Packet1(gspca_dev, 0x0030, 0x0000); | ||
1973 | |||
1974 | /* | ||
1975 | * Magic control of CMOS sensor. Only lower values like | ||
1976 | * 0-3 work, and picture shifts left or right. Don't change. | ||
1977 | */ | ||
1978 | switch (gspca_dev->width) { | ||
1979 | case 176: /* 176x144 */ | ||
1980 | cit_model2_Packet1(gspca_dev, 0x0014, 0x0002); | ||
1981 | cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */ | ||
1982 | cit_model2_Packet1(gspca_dev, 0x0018, 0x004a); /* Another hardware setting */ | ||
1983 | clock_div = 6; | ||
1984 | break; | ||
1985 | case 320: /* 320x240 */ | ||
1986 | cit_model2_Packet1(gspca_dev, 0x0014, 0x0009); | ||
1987 | cit_model2_Packet1(gspca_dev, 0x0016, 0x0005); /* Horizontal shift */ | ||
1988 | cit_model2_Packet1(gspca_dev, 0x0018, 0x0044); /* Another hardware setting */ | ||
1989 | clock_div = 8; | ||
1990 | break; | ||
1991 | /* case VIDEOSIZE_352x240: */ | ||
1992 | /* This mode doesn't work as Windows programs it; changed to work */ | ||
1993 | cit_model2_Packet1(gspca_dev, 0x0014, 0x0009); /* Windows sets this to 8 */ | ||
1994 | cit_model2_Packet1(gspca_dev, 0x0016, 0x0003); /* Horizontal shift */ | ||
1995 | cit_model2_Packet1(gspca_dev, 0x0018, 0x0044); /* Windows sets this to 0x0045 */ | ||
1996 | clock_div = 10; | ||
1997 | break; | ||
1998 | case 352: /* 352x288 */ | ||
1999 | cit_model2_Packet1(gspca_dev, 0x0014, 0x0003); | ||
2000 | cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */ | ||
2001 | cit_model2_Packet1(gspca_dev, 0x0018, 0x004a); /* Another hardware setting */ | ||
2002 | clock_div = 16; | ||
2003 | break; | ||
2004 | } | ||
2005 | |||
2006 | /* TESTME These are handled through controls | ||
2007 | KEEP until someone can test leaving this out is ok */ | ||
2008 | if (0) | ||
2009 | cit_model2_Packet1(gspca_dev, 0x001a, 0x005a); | ||
2010 | |||
2011 | /* | ||
2012 | * We have our own frame rate setting varying from 0 (slowest) to 6 | ||
2013 | * (fastest). The camera model 2 allows frame rate in range [0..0x1F] | ||
2014 | # where 0 is also the slowest setting. However for all practical | ||
2015 | # reasons high settings make no sense because USB is not fast enough | ||
2016 | # to support high FPS. Be aware that the picture datastream will be | ||
2017 | # severely disrupted if you ask for frame rate faster than allowed | ||
2018 | # for the video size - see below: | ||
2019 | * | ||
2020 | * Allowable ranges (obtained experimentally on OHCI, K6-3, 450 MHz): | ||
2021 | * ----------------------------------------------------------------- | ||
2022 | * 176x144: [6..31] | ||
2023 | * 320x240: [8..31] | ||
2024 | * 352x240: [10..31] | ||
2025 | * 352x288: [16..31] I have to raise lower threshold for stability... | ||
2026 | * | ||
2027 | * As usual, slower FPS provides better sensitivity. | ||
2028 | */ | ||
2029 | cit_model2_Packet1(gspca_dev, 0x001c, clock_div); | ||
2030 | |||
2031 | /* | ||
2032 | * This setting does not visibly affect pictures; left it here | ||
2033 | * because it was present in Windows USB data stream. This function | ||
2034 | * does not allow arbitrary values and apparently is a bit mask, to | ||
2035 | * be activated only at appropriate time. Don't change it randomly! | ||
2036 | */ | ||
2037 | switch (gspca_dev->width) { | ||
2038 | case 176: /* 176x144 */ | ||
2039 | cit_model2_Packet1(gspca_dev, 0x0026, 0x00c2); | ||
2040 | break; | ||
2041 | case 320: /* 320x240 */ | ||
2042 | cit_model2_Packet1(gspca_dev, 0x0026, 0x0044); | ||
2043 | break; | ||
2044 | /* case VIDEOSIZE_352x240: */ | ||
2045 | cit_model2_Packet1(gspca_dev, 0x0026, 0x0046); | ||
2046 | break; | ||
2047 | case 352: /* 352x288 */ | ||
2048 | cit_model2_Packet1(gspca_dev, 0x0026, 0x0048); | ||
2049 | break; | ||
2050 | } | ||
2051 | |||
2052 | /* FIXME this cannot be changed while streaming, so we | ||
2053 | should report a grabbed flag for this control. */ | ||
2054 | cit_model2_Packet1(gspca_dev, 0x0028, sd->lighting); | ||
2055 | /* color balance rg2 */ | ||
2056 | cit_model2_Packet1(gspca_dev, 0x001e, 0x002f); | ||
2057 | /* saturation */ | ||
2058 | cit_model2_Packet1(gspca_dev, 0x0020, 0x0034); | ||
2059 | /* color balance yb */ | ||
2060 | cit_model2_Packet1(gspca_dev, 0x0022, 0x00a0); | ||
2061 | |||
2062 | /* Hardware control command */ | ||
2063 | cit_model2_Packet1(gspca_dev, 0x0030, 0x0004); | ||
2064 | |||
2065 | return 0; | ||
2066 | } | ||
2067 | |||
2068 | static int cit_start_model3(struct gspca_dev *gspca_dev) | ||
2069 | { | ||
2070 | const unsigned short compression = 0; /* 0=none, 7=best frame rate */ | ||
2071 | int i, clock_div = 0; | ||
2072 | |||
2073 | /* HDG not in ibmcam driver, added to see if it helps with | ||
2074 | auto-detecting between model3 and ibm netcamera pro */ | ||
2075 | cit_read_reg(gspca_dev, 0x128, 1); | ||
2076 | |||
2077 | cit_write_reg(gspca_dev, 0x0000, 0x0100); | ||
2078 | cit_read_reg(gspca_dev, 0x0116, 0); | ||
2079 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | ||
2080 | cit_write_reg(gspca_dev, 0x0002, 0x0112); | ||
2081 | cit_write_reg(gspca_dev, 0x0000, 0x0123); | ||
2082 | cit_write_reg(gspca_dev, 0x0001, 0x0117); | ||
2083 | cit_write_reg(gspca_dev, 0x0040, 0x0108); | ||
2084 | cit_write_reg(gspca_dev, 0x0019, 0x012c); | ||
2085 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | ||
2086 | cit_write_reg(gspca_dev, 0x0002, 0x0115); | ||
2087 | cit_write_reg(gspca_dev, 0x0003, 0x0115); | ||
2088 | cit_read_reg(gspca_dev, 0x0115, 0); | ||
2089 | cit_write_reg(gspca_dev, 0x000b, 0x0115); | ||
2090 | |||
2091 | /* TESTME HDG not in ibmcam driver, added to see if it helps with | ||
2092 | auto-detecting between model3 and ibm netcamera pro */ | ||
2093 | if (0) { | ||
2094 | cit_write_reg(gspca_dev, 0x0078, 0x012d); | ||
2095 | cit_write_reg(gspca_dev, 0x0001, 0x012f); | ||
2096 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2097 | cit_write_reg(gspca_dev, 0x0079, 0x012d); | ||
2098 | cit_write_reg(gspca_dev, 0x00ff, 0x0130); | ||
2099 | cit_write_reg(gspca_dev, 0xcd41, 0x0124); | ||
2100 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2101 | cit_read_reg(gspca_dev, 0x0126, 1); | ||
2102 | } | ||
2103 | |||
2104 | cit_model3_Packet1(gspca_dev, 0x000a, 0x0040); | ||
2105 | cit_model3_Packet1(gspca_dev, 0x000b, 0x00f6); | ||
2106 | cit_model3_Packet1(gspca_dev, 0x000c, 0x0002); | ||
2107 | cit_model3_Packet1(gspca_dev, 0x000d, 0x0020); | ||
2108 | cit_model3_Packet1(gspca_dev, 0x000e, 0x0033); | ||
2109 | cit_model3_Packet1(gspca_dev, 0x000f, 0x0007); | ||
2110 | cit_model3_Packet1(gspca_dev, 0x0010, 0x0000); | ||
2111 | cit_model3_Packet1(gspca_dev, 0x0011, 0x0070); | ||
2112 | cit_model3_Packet1(gspca_dev, 0x0012, 0x0030); | ||
2113 | cit_model3_Packet1(gspca_dev, 0x0013, 0x0000); | ||
2114 | cit_model3_Packet1(gspca_dev, 0x0014, 0x0001); | ||
2115 | cit_model3_Packet1(gspca_dev, 0x0015, 0x0001); | ||
2116 | cit_model3_Packet1(gspca_dev, 0x0016, 0x0001); | ||
2117 | cit_model3_Packet1(gspca_dev, 0x0017, 0x0001); | ||
2118 | cit_model3_Packet1(gspca_dev, 0x0018, 0x0000); | ||
2119 | cit_model3_Packet1(gspca_dev, 0x001e, 0x00c3); | ||
2120 | cit_model3_Packet1(gspca_dev, 0x0020, 0x0000); | ||
2121 | cit_model3_Packet1(gspca_dev, 0x0028, 0x0010); | ||
2122 | cit_model3_Packet1(gspca_dev, 0x0029, 0x0054); | ||
2123 | cit_model3_Packet1(gspca_dev, 0x002a, 0x0013); | ||
2124 | cit_model3_Packet1(gspca_dev, 0x002b, 0x0007); | ||
2125 | cit_model3_Packet1(gspca_dev, 0x002d, 0x0028); | ||
2126 | cit_model3_Packet1(gspca_dev, 0x002e, 0x0000); | ||
2127 | cit_model3_Packet1(gspca_dev, 0x0031, 0x0000); | ||
2128 | cit_model3_Packet1(gspca_dev, 0x0032, 0x0000); | ||
2129 | cit_model3_Packet1(gspca_dev, 0x0033, 0x0000); | ||
2130 | cit_model3_Packet1(gspca_dev, 0x0034, 0x0000); | ||
2131 | cit_model3_Packet1(gspca_dev, 0x0035, 0x0038); | ||
2132 | cit_model3_Packet1(gspca_dev, 0x003a, 0x0001); | ||
2133 | cit_model3_Packet1(gspca_dev, 0x003c, 0x001e); | ||
2134 | cit_model3_Packet1(gspca_dev, 0x003f, 0x000a); | ||
2135 | cit_model3_Packet1(gspca_dev, 0x0041, 0x0000); | ||
2136 | cit_model3_Packet1(gspca_dev, 0x0046, 0x003f); | ||
2137 | cit_model3_Packet1(gspca_dev, 0x0047, 0x0000); | ||
2138 | cit_model3_Packet1(gspca_dev, 0x0050, 0x0005); | ||
2139 | cit_model3_Packet1(gspca_dev, 0x0052, 0x001a); | ||
2140 | cit_model3_Packet1(gspca_dev, 0x0053, 0x0003); | ||
2141 | cit_model3_Packet1(gspca_dev, 0x005a, 0x006b); | ||
2142 | cit_model3_Packet1(gspca_dev, 0x005d, 0x001e); | ||
2143 | cit_model3_Packet1(gspca_dev, 0x005e, 0x0030); | ||
2144 | cit_model3_Packet1(gspca_dev, 0x005f, 0x0041); | ||
2145 | cit_model3_Packet1(gspca_dev, 0x0064, 0x0008); | ||
2146 | cit_model3_Packet1(gspca_dev, 0x0065, 0x0015); | ||
2147 | cit_model3_Packet1(gspca_dev, 0x0068, 0x000f); | ||
2148 | cit_model3_Packet1(gspca_dev, 0x0079, 0x0000); | ||
2149 | cit_model3_Packet1(gspca_dev, 0x007a, 0x0000); | ||
2150 | cit_model3_Packet1(gspca_dev, 0x007c, 0x003f); | ||
2151 | cit_model3_Packet1(gspca_dev, 0x0082, 0x000f); | ||
2152 | cit_model3_Packet1(gspca_dev, 0x0085, 0x0000); | ||
2153 | cit_model3_Packet1(gspca_dev, 0x0099, 0x0000); | ||
2154 | cit_model3_Packet1(gspca_dev, 0x009b, 0x0023); | ||
2155 | cit_model3_Packet1(gspca_dev, 0x009c, 0x0022); | ||
2156 | cit_model3_Packet1(gspca_dev, 0x009d, 0x0096); | ||
2157 | cit_model3_Packet1(gspca_dev, 0x009e, 0x0096); | ||
2158 | cit_model3_Packet1(gspca_dev, 0x009f, 0x000a); | ||
2159 | |||
2160 | switch (gspca_dev->width) { | ||
2161 | case 160: | ||
2162 | cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */ | ||
2163 | cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */ | ||
2164 | cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */ | ||
2165 | cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */ | ||
2166 | cit_write_reg(gspca_dev, 0x0024, 0x010b); /* Differs everywhere */ | ||
2167 | cit_write_reg(gspca_dev, 0x00a9, 0x0119); | ||
2168 | cit_write_reg(gspca_dev, 0x0016, 0x011b); | ||
2169 | cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */ | ||
2170 | cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */ | ||
2171 | cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */ | ||
2172 | cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */ | ||
2173 | cit_write_reg(gspca_dev, 0x0018, 0x0102); | ||
2174 | cit_write_reg(gspca_dev, 0x0004, 0x0104); | ||
2175 | cit_write_reg(gspca_dev, 0x0004, 0x011a); | ||
2176 | cit_write_reg(gspca_dev, 0x0028, 0x011c); | ||
2177 | cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */ | ||
2178 | cit_write_reg(gspca_dev, 0x0000, 0x0118); | ||
2179 | cit_write_reg(gspca_dev, 0x0000, 0x0132); | ||
2180 | cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */ | ||
2181 | cit_write_reg(gspca_dev, compression, 0x0109); | ||
2182 | clock_div = 3; | ||
2183 | break; | ||
2184 | case 320: | ||
2185 | cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */ | ||
2186 | cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */ | ||
2187 | cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */ | ||
2188 | cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */ | ||
2189 | cit_write_reg(gspca_dev, 0x0028, 0x010b); /* Differs everywhere */ | ||
2190 | cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same */ | ||
2191 | cit_write_reg(gspca_dev, 0x0000, 0x011e); | ||
2192 | cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */ | ||
2193 | cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */ | ||
2194 | /* 4 commands from 160x120 skipped */ | ||
2195 | cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */ | ||
2196 | cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */ | ||
2197 | cit_write_reg(gspca_dev, compression, 0x0109); | ||
2198 | cit_write_reg(gspca_dev, 0x00d9, 0x0119); | ||
2199 | cit_write_reg(gspca_dev, 0x0006, 0x011b); | ||
2200 | cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */ | ||
2201 | cit_write_reg(gspca_dev, 0x0010, 0x0104); | ||
2202 | cit_write_reg(gspca_dev, 0x0004, 0x011a); | ||
2203 | cit_write_reg(gspca_dev, 0x003f, 0x011c); | ||
2204 | cit_write_reg(gspca_dev, 0x001c, 0x0118); | ||
2205 | cit_write_reg(gspca_dev, 0x0000, 0x0132); | ||
2206 | clock_div = 5; | ||
2207 | break; | ||
2208 | case 640: | ||
2209 | cit_write_reg(gspca_dev, 0x00f0, 0x0105); | ||
2210 | cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */ | ||
2211 | cit_write_reg(gspca_dev, 0x0038, 0x010b); /* Differs everywhere */ | ||
2212 | cit_write_reg(gspca_dev, 0x00d9, 0x0119); /* Same on 320x240, 640x480 */ | ||
2213 | cit_write_reg(gspca_dev, 0x0006, 0x011b); /* Same on 320x240, 640x480 */ | ||
2214 | cit_write_reg(gspca_dev, 0x0004, 0x011d); /* NC */ | ||
2215 | cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */ | ||
2216 | cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */ | ||
2217 | cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */ | ||
2218 | cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */ | ||
2219 | cit_write_reg(gspca_dev, 0x0016, 0x0104); /* NC */ | ||
2220 | cit_write_reg(gspca_dev, 0x0004, 0x011a); /* Same on 320x240, 640x480 */ | ||
2221 | cit_write_reg(gspca_dev, 0x003f, 0x011c); /* Same on 320x240, 640x480 */ | ||
2222 | cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */ | ||
2223 | cit_write_reg(gspca_dev, 0x001c, 0x0118); /* Same on 320x240, 640x480 */ | ||
2224 | cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */ | ||
2225 | cit_write_reg(gspca_dev, compression, 0x0109); | ||
2226 | cit_write_reg(gspca_dev, 0x0040, 0x0101); | ||
2227 | cit_write_reg(gspca_dev, 0x0040, 0x0103); | ||
2228 | cit_write_reg(gspca_dev, 0x0000, 0x0132); /* Same on 320x240, 640x480 */ | ||
2229 | clock_div = 7; | ||
2230 | break; | ||
2231 | } | ||
2232 | |||
2233 | cit_model3_Packet1(gspca_dev, 0x007e, 0x000e); /* Hue */ | ||
2234 | cit_model3_Packet1(gspca_dev, 0x0036, 0x0011); /* Brightness */ | ||
2235 | cit_model3_Packet1(gspca_dev, 0x0060, 0x0002); /* Sharpness */ | ||
2236 | cit_model3_Packet1(gspca_dev, 0x0061, 0x0004); /* Sharpness */ | ||
2237 | cit_model3_Packet1(gspca_dev, 0x0062, 0x0005); /* Sharpness */ | ||
2238 | cit_model3_Packet1(gspca_dev, 0x0063, 0x0014); /* Sharpness */ | ||
2239 | cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */ | ||
2240 | cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */ | ||
2241 | cit_model3_Packet1(gspca_dev, 0x0067, 0x0001); /* Contrast */ | ||
2242 | cit_model3_Packet1(gspca_dev, 0x005b, 0x000c); /* Contrast */ | ||
2243 | cit_model3_Packet1(gspca_dev, 0x005c, 0x0016); /* Contrast */ | ||
2244 | cit_model3_Packet1(gspca_dev, 0x0098, 0x000b); | ||
2245 | cit_model3_Packet1(gspca_dev, 0x002c, 0x0003); /* Was 1, broke 640x480 */ | ||
2246 | cit_model3_Packet1(gspca_dev, 0x002f, 0x002a); | ||
2247 | cit_model3_Packet1(gspca_dev, 0x0030, 0x0029); | ||
2248 | cit_model3_Packet1(gspca_dev, 0x0037, 0x0002); | ||
2249 | cit_model3_Packet1(gspca_dev, 0x0038, 0x0059); | ||
2250 | cit_model3_Packet1(gspca_dev, 0x003d, 0x002e); | ||
2251 | cit_model3_Packet1(gspca_dev, 0x003e, 0x0028); | ||
2252 | cit_model3_Packet1(gspca_dev, 0x0078, 0x0005); | ||
2253 | cit_model3_Packet1(gspca_dev, 0x007b, 0x0011); | ||
2254 | cit_model3_Packet1(gspca_dev, 0x007d, 0x004b); | ||
2255 | cit_model3_Packet1(gspca_dev, 0x007f, 0x0022); | ||
2256 | cit_model3_Packet1(gspca_dev, 0x0080, 0x000c); | ||
2257 | cit_model3_Packet1(gspca_dev, 0x0081, 0x000b); | ||
2258 | cit_model3_Packet1(gspca_dev, 0x0083, 0x00fd); | ||
2259 | cit_model3_Packet1(gspca_dev, 0x0086, 0x000b); | ||
2260 | cit_model3_Packet1(gspca_dev, 0x0087, 0x000b); | ||
2261 | cit_model3_Packet1(gspca_dev, 0x007e, 0x000e); | ||
2262 | cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */ | ||
2263 | cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */ | ||
2264 | cit_model3_Packet1(gspca_dev, 0x0098, 0x000b); | ||
2265 | |||
2266 | /* FIXME we should probably use cit_get_clock_div() here (in | ||
2267 | combination with isoc negotiation using the programmable isoc size) | ||
2268 | like with the IBM netcam pro). */ | ||
2269 | cit_write_reg(gspca_dev, clock_div, 0x0111); /* Clock Divider */ | ||
2270 | |||
2271 | switch (gspca_dev->width) { | ||
2272 | case 160: | ||
2273 | cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */ | ||
2274 | cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */ | ||
2275 | cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */ | ||
2276 | cit_model3_Packet1(gspca_dev, 0x0040, 0x000a); | ||
2277 | cit_model3_Packet1(gspca_dev, 0x0051, 0x000a); | ||
2278 | break; | ||
2279 | case 320: | ||
2280 | cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */ | ||
2281 | cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */ | ||
2282 | cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */ | ||
2283 | cit_model3_Packet1(gspca_dev, 0x0040, 0x0008); | ||
2284 | cit_model3_Packet1(gspca_dev, 0x0051, 0x000b); | ||
2285 | break; | ||
2286 | case 640: | ||
2287 | cit_model3_Packet1(gspca_dev, 0x001f, 0x0002); /* !Same */ | ||
2288 | cit_model3_Packet1(gspca_dev, 0x0039, 0x003e); /* !Same */ | ||
2289 | cit_model3_Packet1(gspca_dev, 0x0040, 0x0008); | ||
2290 | cit_model3_Packet1(gspca_dev, 0x0051, 0x000a); | ||
2291 | break; | ||
2292 | } | ||
2293 | |||
2294 | /* if (sd->input_index) { */ | ||
2295 | if (rca_input) { | ||
2296 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { | ||
2297 | if (rca_initdata[i][0]) | ||
2298 | cit_read_reg(gspca_dev, rca_initdata[i][2], 0); | ||
2299 | else | ||
2300 | cit_write_reg(gspca_dev, rca_initdata[i][1], | ||
2301 | rca_initdata[i][2]); | ||
2302 | } | ||
2303 | } | ||
2304 | |||
2305 | return 0; | ||
2306 | } | ||
2307 | |||
2308 | static int cit_start_model4(struct gspca_dev *gspca_dev) | ||
2309 | { | ||
2310 | struct sd *sd = (struct sd *) gspca_dev; | ||
2311 | |||
2312 | cit_write_reg(gspca_dev, 0x0000, 0x0100); | ||
2313 | cit_write_reg(gspca_dev, 0x00c0, 0x0111); | ||
2314 | cit_write_reg(gspca_dev, 0x00bc, 0x012c); | ||
2315 | cit_write_reg(gspca_dev, 0x0080, 0x012b); | ||
2316 | cit_write_reg(gspca_dev, 0x0000, 0x0108); | ||
2317 | cit_write_reg(gspca_dev, 0x0001, 0x0133); | ||
2318 | cit_write_reg(gspca_dev, 0x009b, 0x010f); | ||
2319 | cit_write_reg(gspca_dev, 0x00bb, 0x010f); | ||
2320 | cit_model4_Packet1(gspca_dev, 0x0038, 0x0000); | ||
2321 | cit_model4_Packet1(gspca_dev, 0x000a, 0x005c); | ||
2322 | |||
2323 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2324 | cit_write_reg(gspca_dev, 0x0004, 0x012f); | ||
2325 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2326 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2327 | cit_write_reg(gspca_dev, 0x00fb, 0x012e); | ||
2328 | cit_write_reg(gspca_dev, 0x0000, 0x0130); | ||
2329 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2330 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2331 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2332 | cit_write_reg(gspca_dev, 0x000c, 0x0127); | ||
2333 | cit_write_reg(gspca_dev, 0x0009, 0x012e); | ||
2334 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2335 | |||
2336 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2337 | cit_write_reg(gspca_dev, 0x0012, 0x012f); | ||
2338 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2339 | cit_write_reg(gspca_dev, 0x0008, 0x0127); | ||
2340 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2341 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2342 | cit_write_reg(gspca_dev, 0x002a, 0x012d); | ||
2343 | cit_write_reg(gspca_dev, 0x0000, 0x012f); | ||
2344 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2345 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2346 | cit_model4_Packet1(gspca_dev, 0x0034, 0x0000); | ||
2347 | |||
2348 | switch (gspca_dev->width) { | ||
2349 | case 128: /* 128x96 */ | ||
2350 | cit_write_reg(gspca_dev, 0x0070, 0x0119); | ||
2351 | cit_write_reg(gspca_dev, 0x00d0, 0x0111); | ||
2352 | cit_write_reg(gspca_dev, 0x0039, 0x010a); | ||
2353 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
2354 | cit_write_reg(gspca_dev, 0x0028, 0x0103); | ||
2355 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
2356 | cit_write_reg(gspca_dev, 0x001e, 0x0105); | ||
2357 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2358 | cit_write_reg(gspca_dev, 0x0016, 0x012f); | ||
2359 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2360 | cit_write_reg(gspca_dev, 0x000a, 0x0127); | ||
2361 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2362 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2363 | cit_write_reg(gspca_dev, 0x0014, 0x012d); | ||
2364 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2365 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2366 | cit_write_reg(gspca_dev, 0x00aa, 0x012e); | ||
2367 | cit_write_reg(gspca_dev, 0x001a, 0x0130); | ||
2368 | cit_write_reg(gspca_dev, 0x8a0a, 0x0124); | ||
2369 | cit_write_reg(gspca_dev, 0x005a, 0x012d); | ||
2370 | cit_write_reg(gspca_dev, 0x9545, 0x0124); | ||
2371 | cit_write_reg(gspca_dev, 0x00aa, 0x0127); | ||
2372 | cit_write_reg(gspca_dev, 0x0018, 0x012e); | ||
2373 | cit_write_reg(gspca_dev, 0x0043, 0x0130); | ||
2374 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2375 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2376 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2377 | cit_write_reg(gspca_dev, 0x001c, 0x0127); | ||
2378 | cit_write_reg(gspca_dev, 0x00eb, 0x012e); | ||
2379 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2380 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2381 | cit_write_reg(gspca_dev, 0x0032, 0x012f); | ||
2382 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2383 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2384 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2385 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2386 | cit_write_reg(gspca_dev, 0x0036, 0x012d); | ||
2387 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2388 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2389 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2390 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2391 | cit_write_reg(gspca_dev, 0x001e, 0x012f); | ||
2392 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2393 | cit_write_reg(gspca_dev, 0x0017, 0x0127); | ||
2394 | cit_write_reg(gspca_dev, 0x0013, 0x012e); | ||
2395 | cit_write_reg(gspca_dev, 0x0031, 0x0130); | ||
2396 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2397 | cit_write_reg(gspca_dev, 0x0017, 0x012d); | ||
2398 | cit_write_reg(gspca_dev, 0x0078, 0x012f); | ||
2399 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2400 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2401 | cit_write_reg(gspca_dev, 0xfea8, 0x0124); | ||
2402 | sd->sof_len = 2; | ||
2403 | break; | ||
2404 | case 160: /* 160x120 */ | ||
2405 | cit_write_reg(gspca_dev, 0x0038, 0x0119); | ||
2406 | cit_write_reg(gspca_dev, 0x00d0, 0x0111); | ||
2407 | cit_write_reg(gspca_dev, 0x00b9, 0x010a); | ||
2408 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
2409 | cit_write_reg(gspca_dev, 0x0028, 0x0103); | ||
2410 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
2411 | cit_write_reg(gspca_dev, 0x001e, 0x0105); | ||
2412 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2413 | cit_write_reg(gspca_dev, 0x0016, 0x012f); | ||
2414 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2415 | cit_write_reg(gspca_dev, 0x000b, 0x0127); | ||
2416 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2417 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2418 | cit_write_reg(gspca_dev, 0x0014, 0x012d); | ||
2419 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2420 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2421 | cit_write_reg(gspca_dev, 0x00aa, 0x012e); | ||
2422 | cit_write_reg(gspca_dev, 0x001a, 0x0130); | ||
2423 | cit_write_reg(gspca_dev, 0x8a0a, 0x0124); | ||
2424 | cit_write_reg(gspca_dev, 0x005a, 0x012d); | ||
2425 | cit_write_reg(gspca_dev, 0x9545, 0x0124); | ||
2426 | cit_write_reg(gspca_dev, 0x00aa, 0x0127); | ||
2427 | cit_write_reg(gspca_dev, 0x0018, 0x012e); | ||
2428 | cit_write_reg(gspca_dev, 0x0043, 0x0130); | ||
2429 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2430 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2431 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2432 | cit_write_reg(gspca_dev, 0x001c, 0x0127); | ||
2433 | cit_write_reg(gspca_dev, 0x00c7, 0x012e); | ||
2434 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2435 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2436 | cit_write_reg(gspca_dev, 0x0032, 0x012f); | ||
2437 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2438 | cit_write_reg(gspca_dev, 0x0025, 0x0127); | ||
2439 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2440 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2441 | cit_write_reg(gspca_dev, 0x0036, 0x012d); | ||
2442 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2443 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2444 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2445 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2446 | cit_write_reg(gspca_dev, 0x001e, 0x012f); | ||
2447 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2448 | cit_write_reg(gspca_dev, 0x0048, 0x0127); | ||
2449 | cit_write_reg(gspca_dev, 0x0035, 0x012e); | ||
2450 | cit_write_reg(gspca_dev, 0x00d0, 0x0130); | ||
2451 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2452 | cit_write_reg(gspca_dev, 0x0048, 0x012d); | ||
2453 | cit_write_reg(gspca_dev, 0x0090, 0x012f); | ||
2454 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2455 | cit_write_reg(gspca_dev, 0x0001, 0x0127); | ||
2456 | cit_write_reg(gspca_dev, 0xfea8, 0x0124); | ||
2457 | sd->sof_len = 2; | ||
2458 | break; | ||
2459 | case 176: /* 176x144 */ | ||
2460 | cit_write_reg(gspca_dev, 0x0038, 0x0119); | ||
2461 | cit_write_reg(gspca_dev, 0x00d0, 0x0111); | ||
2462 | cit_write_reg(gspca_dev, 0x00b9, 0x010a); | ||
2463 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
2464 | cit_write_reg(gspca_dev, 0x002c, 0x0103); | ||
2465 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
2466 | cit_write_reg(gspca_dev, 0x0024, 0x0105); | ||
2467 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2468 | cit_write_reg(gspca_dev, 0x0016, 0x012f); | ||
2469 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2470 | cit_write_reg(gspca_dev, 0x0007, 0x0127); | ||
2471 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2472 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2473 | cit_write_reg(gspca_dev, 0x0014, 0x012d); | ||
2474 | cit_write_reg(gspca_dev, 0x0001, 0x012f); | ||
2475 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2476 | cit_write_reg(gspca_dev, 0x00aa, 0x012e); | ||
2477 | cit_write_reg(gspca_dev, 0x001a, 0x0130); | ||
2478 | cit_write_reg(gspca_dev, 0x8a0a, 0x0124); | ||
2479 | cit_write_reg(gspca_dev, 0x005e, 0x012d); | ||
2480 | cit_write_reg(gspca_dev, 0x9545, 0x0124); | ||
2481 | cit_write_reg(gspca_dev, 0x00aa, 0x0127); | ||
2482 | cit_write_reg(gspca_dev, 0x0018, 0x012e); | ||
2483 | cit_write_reg(gspca_dev, 0x0049, 0x0130); | ||
2484 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2485 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2486 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2487 | cit_write_reg(gspca_dev, 0x001c, 0x0127); | ||
2488 | cit_write_reg(gspca_dev, 0x00c7, 0x012e); | ||
2489 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2490 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2491 | cit_write_reg(gspca_dev, 0x0032, 0x012f); | ||
2492 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2493 | cit_write_reg(gspca_dev, 0x0028, 0x0127); | ||
2494 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2495 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2496 | cit_write_reg(gspca_dev, 0x0036, 0x012d); | ||
2497 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2498 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2499 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2500 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2501 | cit_write_reg(gspca_dev, 0x001e, 0x012f); | ||
2502 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2503 | cit_write_reg(gspca_dev, 0x0010, 0x0127); | ||
2504 | cit_write_reg(gspca_dev, 0x0013, 0x012e); | ||
2505 | cit_write_reg(gspca_dev, 0x002a, 0x0130); | ||
2506 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2507 | cit_write_reg(gspca_dev, 0x0010, 0x012d); | ||
2508 | cit_write_reg(gspca_dev, 0x006d, 0x012f); | ||
2509 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2510 | cit_write_reg(gspca_dev, 0x0001, 0x0127); | ||
2511 | cit_write_reg(gspca_dev, 0xfea8, 0x0124); | ||
2512 | /* TESTME HDG: this does not seem right | ||
2513 | (it is 2 for all other resolutions) */ | ||
2514 | sd->sof_len = 10; | ||
2515 | break; | ||
2516 | case 320: /* 320x240 */ | ||
2517 | cit_write_reg(gspca_dev, 0x0070, 0x0119); | ||
2518 | cit_write_reg(gspca_dev, 0x00d0, 0x0111); | ||
2519 | cit_write_reg(gspca_dev, 0x0039, 0x010a); | ||
2520 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
2521 | cit_write_reg(gspca_dev, 0x0028, 0x0103); | ||
2522 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
2523 | cit_write_reg(gspca_dev, 0x001e, 0x0105); | ||
2524 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2525 | cit_write_reg(gspca_dev, 0x0016, 0x012f); | ||
2526 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2527 | cit_write_reg(gspca_dev, 0x000a, 0x0127); | ||
2528 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2529 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2530 | cit_write_reg(gspca_dev, 0x0014, 0x012d); | ||
2531 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2532 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2533 | cit_write_reg(gspca_dev, 0x00aa, 0x012e); | ||
2534 | cit_write_reg(gspca_dev, 0x001a, 0x0130); | ||
2535 | cit_write_reg(gspca_dev, 0x8a0a, 0x0124); | ||
2536 | cit_write_reg(gspca_dev, 0x005a, 0x012d); | ||
2537 | cit_write_reg(gspca_dev, 0x9545, 0x0124); | ||
2538 | cit_write_reg(gspca_dev, 0x00aa, 0x0127); | ||
2539 | cit_write_reg(gspca_dev, 0x0018, 0x012e); | ||
2540 | cit_write_reg(gspca_dev, 0x0043, 0x0130); | ||
2541 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2542 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2543 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2544 | cit_write_reg(gspca_dev, 0x001c, 0x0127); | ||
2545 | cit_write_reg(gspca_dev, 0x00eb, 0x012e); | ||
2546 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2547 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2548 | cit_write_reg(gspca_dev, 0x0032, 0x012f); | ||
2549 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2550 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2551 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2552 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2553 | cit_write_reg(gspca_dev, 0x0036, 0x012d); | ||
2554 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2555 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2556 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2557 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2558 | cit_write_reg(gspca_dev, 0x001e, 0x012f); | ||
2559 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2560 | cit_write_reg(gspca_dev, 0x0017, 0x0127); | ||
2561 | cit_write_reg(gspca_dev, 0x0013, 0x012e); | ||
2562 | cit_write_reg(gspca_dev, 0x0031, 0x0130); | ||
2563 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2564 | cit_write_reg(gspca_dev, 0x0017, 0x012d); | ||
2565 | cit_write_reg(gspca_dev, 0x0078, 0x012f); | ||
2566 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2567 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2568 | cit_write_reg(gspca_dev, 0xfea8, 0x0124); | ||
2569 | sd->sof_len = 2; | ||
2570 | break; | ||
2571 | case 352: /* 352x288 */ | ||
2572 | cit_write_reg(gspca_dev, 0x0070, 0x0119); | ||
2573 | cit_write_reg(gspca_dev, 0x00c0, 0x0111); | ||
2574 | cit_write_reg(gspca_dev, 0x0039, 0x010a); | ||
2575 | cit_write_reg(gspca_dev, 0x0001, 0x0102); | ||
2576 | cit_write_reg(gspca_dev, 0x002c, 0x0103); | ||
2577 | cit_write_reg(gspca_dev, 0x0000, 0x0104); | ||
2578 | cit_write_reg(gspca_dev, 0x0024, 0x0105); | ||
2579 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2580 | cit_write_reg(gspca_dev, 0x0016, 0x012f); | ||
2581 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2582 | cit_write_reg(gspca_dev, 0x0006, 0x0127); | ||
2583 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2584 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2585 | cit_write_reg(gspca_dev, 0x0014, 0x012d); | ||
2586 | cit_write_reg(gspca_dev, 0x0002, 0x012f); | ||
2587 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2588 | cit_write_reg(gspca_dev, 0x00aa, 0x012e); | ||
2589 | cit_write_reg(gspca_dev, 0x001a, 0x0130); | ||
2590 | cit_write_reg(gspca_dev, 0x8a0a, 0x0124); | ||
2591 | cit_write_reg(gspca_dev, 0x005e, 0x012d); | ||
2592 | cit_write_reg(gspca_dev, 0x9545, 0x0124); | ||
2593 | cit_write_reg(gspca_dev, 0x00aa, 0x0127); | ||
2594 | cit_write_reg(gspca_dev, 0x0018, 0x012e); | ||
2595 | cit_write_reg(gspca_dev, 0x0049, 0x0130); | ||
2596 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2597 | cit_write_reg(gspca_dev, 0x00aa, 0x012f); | ||
2598 | cit_write_reg(gspca_dev, 0xd055, 0x0124); | ||
2599 | cit_write_reg(gspca_dev, 0x001c, 0x0127); | ||
2600 | cit_write_reg(gspca_dev, 0x00cf, 0x012e); | ||
2601 | cit_write_reg(gspca_dev, 0xaa28, 0x0124); | ||
2602 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2603 | cit_write_reg(gspca_dev, 0x0032, 0x012f); | ||
2604 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2605 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2606 | cit_write_reg(gspca_dev, 0x00aa, 0x0130); | ||
2607 | cit_write_reg(gspca_dev, 0x82a8, 0x0124); | ||
2608 | cit_write_reg(gspca_dev, 0x0036, 0x012d); | ||
2609 | cit_write_reg(gspca_dev, 0x0008, 0x012f); | ||
2610 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2611 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | ||
2612 | cit_write_reg(gspca_dev, 0x00aa, 0x012d); | ||
2613 | cit_write_reg(gspca_dev, 0x001e, 0x012f); | ||
2614 | cit_write_reg(gspca_dev, 0xd141, 0x0124); | ||
2615 | cit_write_reg(gspca_dev, 0x0010, 0x0127); | ||
2616 | cit_write_reg(gspca_dev, 0x0013, 0x012e); | ||
2617 | cit_write_reg(gspca_dev, 0x0025, 0x0130); | ||
2618 | cit_write_reg(gspca_dev, 0x8a28, 0x0124); | ||
2619 | cit_write_reg(gspca_dev, 0x0010, 0x012d); | ||
2620 | cit_write_reg(gspca_dev, 0x0048, 0x012f); | ||
2621 | cit_write_reg(gspca_dev, 0xd145, 0x0124); | ||
2622 | cit_write_reg(gspca_dev, 0x0000, 0x0127); | ||
2623 | cit_write_reg(gspca_dev, 0xfea8, 0x0124); | ||
2624 | sd->sof_len = 2; | ||
2625 | break; | ||
2626 | } | ||
2627 | |||
2628 | cit_model4_Packet1(gspca_dev, 0x0038, 0x0004); | ||
2629 | |||
2630 | return 0; | ||
2631 | } | ||
2632 | |||
2633 | static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev) | ||
2634 | { | ||
2635 | const unsigned short compression = 0; /* 0=none, 7=best frame rate */ | ||
2636 | int i, clock_div; | ||
2637 | |||
2638 | clock_div = cit_get_clock_div(gspca_dev); | ||
2639 | if (clock_div < 0) | ||
2640 | return clock_div; | ||
2641 | |||
2642 | cit_write_reg(gspca_dev, 0x0003, 0x0133); | ||
2643 | cit_write_reg(gspca_dev, 0x0000, 0x0117); | ||
2644 | cit_write_reg(gspca_dev, 0x0008, 0x0123); | ||
2645 | cit_write_reg(gspca_dev, 0x0000, 0x0100); | ||
2646 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | ||
2647 | /* cit_write_reg(gspca_dev, 0x0002, 0x0112); see sd_stop0 */ | ||
2648 | cit_write_reg(gspca_dev, 0x0000, 0x0133); | ||
2649 | cit_write_reg(gspca_dev, 0x0000, 0x0123); | ||
2650 | cit_write_reg(gspca_dev, 0x0001, 0x0117); | ||
2651 | cit_write_reg(gspca_dev, 0x0040, 0x0108); | ||
2652 | cit_write_reg(gspca_dev, 0x0019, 0x012c); | ||
2653 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | ||
2654 | /* cit_write_reg(gspca_dev, 0x000b, 0x0115); see sd_stop0 */ | ||
2655 | |||
2656 | cit_model3_Packet1(gspca_dev, 0x0049, 0x0000); | ||
2657 | |||
2658 | cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */ | ||
2659 | cit_write_reg(gspca_dev, 0x003a, 0x0102); /* Hstart */ | ||
2660 | cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */ | ||
2661 | cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */ | ||
2662 | cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */ | ||
2663 | cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */ | ||
2664 | cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */ | ||
2665 | cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */ | ||
2666 | cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */ | ||
2667 | |||
2668 | switch (gspca_dev->width) { | ||
2669 | case 160: /* 160x120 */ | ||
2670 | cit_write_reg(gspca_dev, 0x0024, 0x010b); | ||
2671 | cit_write_reg(gspca_dev, 0x0089, 0x0119); | ||
2672 | cit_write_reg(gspca_dev, 0x000a, 0x011b); | ||
2673 | cit_write_reg(gspca_dev, 0x0003, 0x011e); | ||
2674 | cit_write_reg(gspca_dev, 0x0007, 0x0104); | ||
2675 | cit_write_reg(gspca_dev, 0x0009, 0x011a); | ||
2676 | cit_write_reg(gspca_dev, 0x008b, 0x011c); | ||
2677 | cit_write_reg(gspca_dev, 0x0008, 0x0118); | ||
2678 | cit_write_reg(gspca_dev, 0x0000, 0x0132); | ||
2679 | break; | ||
2680 | case 320: /* 320x240 */ | ||
2681 | cit_write_reg(gspca_dev, 0x0028, 0x010b); | ||
2682 | cit_write_reg(gspca_dev, 0x00d9, 0x0119); | ||
2683 | cit_write_reg(gspca_dev, 0x0006, 0x011b); | ||
2684 | cit_write_reg(gspca_dev, 0x0000, 0x011e); | ||
2685 | cit_write_reg(gspca_dev, 0x000e, 0x0104); | ||
2686 | cit_write_reg(gspca_dev, 0x0004, 0x011a); | ||
2687 | cit_write_reg(gspca_dev, 0x003f, 0x011c); | ||
2688 | cit_write_reg(gspca_dev, 0x000c, 0x0118); | ||
2689 | cit_write_reg(gspca_dev, 0x0000, 0x0132); | ||
2690 | break; | ||
2691 | } | ||
2692 | |||
2693 | cit_model3_Packet1(gspca_dev, 0x0019, 0x0031); | ||
2694 | cit_model3_Packet1(gspca_dev, 0x001a, 0x0003); | ||
2695 | cit_model3_Packet1(gspca_dev, 0x001b, 0x0038); | ||
2696 | cit_model3_Packet1(gspca_dev, 0x001c, 0x0000); | ||
2697 | cit_model3_Packet1(gspca_dev, 0x0024, 0x0001); | ||
2698 | cit_model3_Packet1(gspca_dev, 0x0027, 0x0001); | ||
2699 | cit_model3_Packet1(gspca_dev, 0x002a, 0x0004); | ||
2700 | cit_model3_Packet1(gspca_dev, 0x0035, 0x000b); | ||
2701 | cit_model3_Packet1(gspca_dev, 0x003f, 0x0001); | ||
2702 | cit_model3_Packet1(gspca_dev, 0x0044, 0x0000); | ||
2703 | cit_model3_Packet1(gspca_dev, 0x0054, 0x0000); | ||
2704 | cit_model3_Packet1(gspca_dev, 0x00c4, 0x0000); | ||
2705 | cit_model3_Packet1(gspca_dev, 0x00e7, 0x0001); | ||
2706 | cit_model3_Packet1(gspca_dev, 0x00e9, 0x0001); | ||
2707 | cit_model3_Packet1(gspca_dev, 0x00ee, 0x0000); | ||
2708 | cit_model3_Packet1(gspca_dev, 0x00f3, 0x00c0); | ||
2709 | |||
2710 | cit_write_reg(gspca_dev, compression, 0x0109); | ||
2711 | cit_write_reg(gspca_dev, clock_div, 0x0111); | ||
2712 | |||
2713 | /* if (sd->input_index) { */ | ||
2714 | if (rca_input) { | ||
2715 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { | ||
2716 | if (rca_initdata[i][0]) | ||
2717 | cit_read_reg(gspca_dev, rca_initdata[i][2], 0); | ||
2718 | else | ||
2719 | cit_write_reg(gspca_dev, rca_initdata[i][1], | ||
2720 | rca_initdata[i][2]); | ||
2721 | } | ||
2722 | } | ||
2723 | |||
2724 | return 0; | ||
2725 | } | ||
2726 | |||
2727 | /* -- start the camera -- */ | ||
2728 | static int sd_start(struct gspca_dev *gspca_dev) | ||
2729 | { | ||
2730 | struct sd *sd = (struct sd *) gspca_dev; | ||
2731 | int packet_size; | ||
2732 | |||
2733 | packet_size = cit_get_packet_size(gspca_dev); | ||
2734 | if (packet_size < 0) | ||
2735 | return packet_size; | ||
2736 | |||
2737 | switch (sd->model) { | ||
2738 | case CIT_MODEL0: | ||
2739 | cit_start_model0(gspca_dev); | ||
2740 | break; | ||
2741 | case CIT_MODEL1: | ||
2742 | cit_start_model1(gspca_dev); | ||
2743 | break; | ||
2744 | case CIT_MODEL2: | ||
2745 | cit_start_model2(gspca_dev); | ||
2746 | break; | ||
2747 | case CIT_MODEL3: | ||
2748 | cit_start_model3(gspca_dev); | ||
2749 | break; | ||
2750 | case CIT_MODEL4: | ||
2751 | cit_start_model4(gspca_dev); | ||
2752 | break; | ||
2753 | case CIT_IBM_NETCAM_PRO: | ||
2754 | cit_start_ibm_netcam_pro(gspca_dev); | ||
2755 | break; | ||
2756 | } | ||
2757 | |||
2758 | cit_set_brightness(gspca_dev); | ||
2759 | cit_set_contrast(gspca_dev); | ||
2760 | cit_set_hue(gspca_dev); | ||
2761 | cit_set_sharpness(gspca_dev); | ||
2762 | cit_set_lighting(gspca_dev); | ||
2763 | cit_set_hflip(gspca_dev); | ||
2764 | |||
2765 | /* Program max isoc packet size */ | ||
2766 | cit_write_reg(gspca_dev, packet_size >> 8, 0x0106); | ||
2767 | cit_write_reg(gspca_dev, packet_size & 0xff, 0x0107); | ||
2768 | |||
2769 | cit_restart_stream(gspca_dev); | ||
2770 | |||
2771 | return 0; | ||
2772 | } | ||
2773 | |||
2774 | static int sd_isoc_init(struct gspca_dev *gspca_dev) | ||
2775 | { | ||
2776 | struct usb_host_interface *alt; | ||
2777 | int max_packet_size; | ||
2778 | |||
2779 | switch (gspca_dev->width) { | ||
2780 | case 160: | ||
2781 | max_packet_size = 450; | ||
2782 | break; | ||
2783 | case 176: | ||
2784 | max_packet_size = 600; | ||
2785 | break; | ||
2786 | default: | ||
2787 | max_packet_size = 1022; | ||
2788 | break; | ||
2789 | } | ||
2790 | |||
2791 | /* Start isoc bandwidth "negotiation" at max isoc bandwidth */ | ||
2792 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | ||
2793 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(max_packet_size); | ||
2794 | |||
2795 | return 0; | ||
2796 | } | ||
2797 | |||
2798 | static int sd_isoc_nego(struct gspca_dev *gspca_dev) | ||
2799 | { | ||
2800 | int ret, packet_size, min_packet_size; | ||
2801 | struct usb_host_interface *alt; | ||
2802 | |||
2803 | switch (gspca_dev->width) { | ||
2804 | case 160: | ||
2805 | min_packet_size = 200; | ||
2806 | break; | ||
2807 | case 176: | ||
2808 | min_packet_size = 266; | ||
2809 | break; | ||
2810 | default: | ||
2811 | min_packet_size = 400; | ||
2812 | break; | ||
2813 | } | ||
2814 | |||
2815 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | ||
2816 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
2817 | if (packet_size <= min_packet_size) | ||
2818 | return -EIO; | ||
2819 | |||
2820 | packet_size -= 100; | ||
2821 | if (packet_size < min_packet_size) | ||
2822 | packet_size = min_packet_size; | ||
2823 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size); | ||
2824 | |||
2825 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); | ||
2826 | if (ret < 0) | ||
2827 | err("set alt 1 err %d", ret); | ||
2828 | |||
2829 | return ret; | ||
2830 | } | ||
2831 | |||
2832 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
2833 | { | ||
2834 | cit_write_reg(gspca_dev, 0x0000, 0x010c); | ||
2835 | } | ||
2836 | |||
2837 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
2838 | { | ||
2839 | struct sd *sd = (struct sd *) gspca_dev; | ||
2840 | |||
2841 | /* We cannot use gspca_dev->present here as that is not set when | ||
2842 | sd_init gets called and we get called from sd_init */ | ||
2843 | if (!gspca_dev->dev) | ||
2844 | return; | ||
2845 | |||
2846 | switch (sd->model) { | ||
2847 | case CIT_MODEL0: | ||
2848 | /* HDG windows does this, but it causes the cams autogain to | ||
2849 | restart from a gain of 0, which does not look good when | ||
2850 | changing resolutions. */ | ||
2851 | /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */ | ||
2852 | cit_write_reg(gspca_dev, 0x00c0, 0x0100); /* LED Off */ | ||
2853 | break; | ||
2854 | case CIT_MODEL1: | ||
2855 | cit_send_FF_04_02(gspca_dev); | ||
2856 | cit_read_reg(gspca_dev, 0x0100, 0); | ||
2857 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ | ||
2858 | break; | ||
2859 | case CIT_MODEL2: | ||
2860 | case CIT_MODEL4: | ||
2861 | cit_model2_Packet1(gspca_dev, 0x0030, 0x0004); | ||
2862 | |||
2863 | cit_write_reg(gspca_dev, 0x0080, 0x0100); /* LED Off */ | ||
2864 | cit_write_reg(gspca_dev, 0x0020, 0x0111); | ||
2865 | cit_write_reg(gspca_dev, 0x00a0, 0x0111); | ||
2866 | |||
2867 | cit_model2_Packet1(gspca_dev, 0x0030, 0x0002); | ||
2868 | |||
2869 | cit_write_reg(gspca_dev, 0x0020, 0x0111); | ||
2870 | cit_write_reg(gspca_dev, 0x0000, 0x0112); | ||
2871 | break; | ||
2872 | case CIT_MODEL3: | ||
2873 | cit_write_reg(gspca_dev, 0x0006, 0x012c); | ||
2874 | cit_model3_Packet1(gspca_dev, 0x0046, 0x0000); | ||
2875 | cit_read_reg(gspca_dev, 0x0116, 0); | ||
2876 | cit_write_reg(gspca_dev, 0x0064, 0x0116); | ||
2877 | cit_read_reg(gspca_dev, 0x0115, 0); | ||
2878 | cit_write_reg(gspca_dev, 0x0003, 0x0115); | ||
2879 | cit_write_reg(gspca_dev, 0x0008, 0x0123); | ||
2880 | cit_write_reg(gspca_dev, 0x0000, 0x0117); | ||
2881 | cit_write_reg(gspca_dev, 0x0000, 0x0112); | ||
2882 | cit_write_reg(gspca_dev, 0x0080, 0x0100); | ||
2883 | break; | ||
2884 | case CIT_IBM_NETCAM_PRO: | ||
2885 | cit_model3_Packet1(gspca_dev, 0x0049, 0x00ff); | ||
2886 | cit_write_reg(gspca_dev, 0x0006, 0x012c); | ||
2887 | cit_write_reg(gspca_dev, 0x0000, 0x0116); | ||
2888 | /* HDG windows does this, but I cannot get the camera | ||
2889 | to restart with this without redoing the entire init | ||
2890 | sequence which makes switching modes really slow */ | ||
2891 | /* cit_write_reg(gspca_dev, 0x0006, 0x0115); */ | ||
2892 | cit_write_reg(gspca_dev, 0x0008, 0x0123); | ||
2893 | cit_write_reg(gspca_dev, 0x0000, 0x0117); | ||
2894 | cit_write_reg(gspca_dev, 0x0003, 0x0133); | ||
2895 | cit_write_reg(gspca_dev, 0x0000, 0x0111); | ||
2896 | /* HDG windows does this, but I get a green picture when | ||
2897 | restarting the stream after this */ | ||
2898 | /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */ | ||
2899 | cit_write_reg(gspca_dev, 0x00c0, 0x0100); | ||
2900 | break; | ||
2901 | } | ||
2902 | |||
2903 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
2904 | /* If the last button state is pressed, release it now! */ | ||
2905 | if (sd->button_state) { | ||
2906 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | ||
2907 | input_sync(gspca_dev->input_dev); | ||
2908 | sd->button_state = 0; | ||
2909 | } | ||
2910 | #endif | ||
2911 | } | ||
2912 | |||
2913 | static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) | ||
2914 | { | ||
2915 | struct sd *sd = (struct sd *) gspca_dev; | ||
2916 | u8 byte3 = 0, byte4 = 0; | ||
2917 | int i; | ||
2918 | |||
2919 | switch (sd->model) { | ||
2920 | case CIT_MODEL0: | ||
2921 | case CIT_MODEL1: | ||
2922 | case CIT_MODEL3: | ||
2923 | case CIT_IBM_NETCAM_PRO: | ||
2924 | switch (gspca_dev->width) { | ||
2925 | case 160: /* 160x120 */ | ||
2926 | byte3 = 0x02; | ||
2927 | byte4 = 0x0a; | ||
2928 | break; | ||
2929 | case 176: /* 176x144 */ | ||
2930 | byte3 = 0x02; | ||
2931 | byte4 = 0x0e; | ||
2932 | break; | ||
2933 | case 320: /* 320x240 */ | ||
2934 | byte3 = 0x02; | ||
2935 | byte4 = 0x08; | ||
2936 | break; | ||
2937 | case 352: /* 352x288 */ | ||
2938 | byte3 = 0x02; | ||
2939 | byte4 = 0x00; | ||
2940 | break; | ||
2941 | case 640: | ||
2942 | byte3 = 0x03; | ||
2943 | byte4 = 0x08; | ||
2944 | break; | ||
2945 | } | ||
2946 | |||
2947 | /* These have a different byte3 */ | ||
2948 | if (sd->model <= CIT_MODEL1) | ||
2949 | byte3 = 0x00; | ||
2950 | |||
2951 | for (i = 0; i < len; i++) { | ||
2952 | /* For this model the SOF always starts at offset 0 | ||
2953 | so no need to search the entire frame */ | ||
2954 | if (sd->model == CIT_MODEL0 && sd->sof_read != i) | ||
2955 | break; | ||
2956 | |||
2957 | switch (sd->sof_read) { | ||
2958 | case 0: | ||
2959 | if (data[i] == 0x00) | ||
2960 | sd->sof_read++; | ||
2961 | break; | ||
2962 | case 1: | ||
2963 | if (data[i] == 0xff) | ||
2964 | sd->sof_read++; | ||
2965 | else if (data[i] == 0x00) | ||
2966 | sd->sof_read = 1; | ||
2967 | else | ||
2968 | sd->sof_read = 0; | ||
2969 | break; | ||
2970 | case 2: | ||
2971 | if (data[i] == byte3) | ||
2972 | sd->sof_read++; | ||
2973 | else if (data[i] == 0x00) | ||
2974 | sd->sof_read = 1; | ||
2975 | else | ||
2976 | sd->sof_read = 0; | ||
2977 | break; | ||
2978 | case 3: | ||
2979 | if (data[i] == byte4) { | ||
2980 | sd->sof_read = 0; | ||
2981 | return data + i + (sd->sof_len - 3); | ||
2982 | } | ||
2983 | if (byte3 == 0x00 && data[i] == 0xff) | ||
2984 | sd->sof_read = 2; | ||
2985 | else if (data[i] == 0x00) | ||
2986 | sd->sof_read = 1; | ||
2987 | else | ||
2988 | sd->sof_read = 0; | ||
2989 | break; | ||
2990 | } | ||
2991 | } | ||
2992 | break; | ||
2993 | case CIT_MODEL2: | ||
2994 | case CIT_MODEL4: | ||
2995 | /* TESTME we need to find a longer sof signature to avoid | ||
2996 | false positives */ | ||
2997 | for (i = 0; i < len; i++) { | ||
2998 | switch (sd->sof_read) { | ||
2999 | case 0: | ||
3000 | if (data[i] == 0x00) | ||
3001 | sd->sof_read++; | ||
3002 | break; | ||
3003 | case 1: | ||
3004 | sd->sof_read = 0; | ||
3005 | if (data[i] == 0xff) { | ||
3006 | if (i >= 4) | ||
3007 | PDEBUG(D_FRAM, | ||
3008 | "header found at offset: %d: %02x %02x 00 %02x %02x %02x\n", | ||
3009 | i - 1, | ||
3010 | data[i - 4], | ||
3011 | data[i - 3], | ||
3012 | data[i], | ||
3013 | data[i + 1], | ||
3014 | data[i + 2]); | ||
3015 | else | ||
3016 | PDEBUG(D_FRAM, | ||
3017 | "header found at offset: %d: 00 %02x %02x %02x\n", | ||
3018 | i - 1, | ||
3019 | data[i], | ||
3020 | data[i + 1], | ||
3021 | data[i + 2]); | ||
3022 | return data + i + (sd->sof_len - 1); | ||
3023 | } | ||
3024 | break; | ||
3025 | } | ||
3026 | } | ||
3027 | break; | ||
3028 | } | ||
3029 | return NULL; | ||
3030 | } | ||
3031 | |||
3032 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
3033 | u8 *data, int len) | ||
3034 | { | ||
3035 | struct sd *sd = (struct sd *) gspca_dev; | ||
3036 | unsigned char *sof; | ||
3037 | |||
3038 | sof = cit_find_sof(gspca_dev, data, len); | ||
3039 | if (sof) { | ||
3040 | int n; | ||
3041 | |||
3042 | /* finish decoding current frame */ | ||
3043 | n = sof - data; | ||
3044 | if (n > sd->sof_len) | ||
3045 | n -= sd->sof_len; | ||
3046 | else | ||
3047 | n = 0; | ||
3048 | gspca_frame_add(gspca_dev, LAST_PACKET, | ||
3049 | data, n); | ||
3050 | gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0); | ||
3051 | len -= sof - data; | ||
3052 | data = sof; | ||
3053 | } | ||
3054 | |||
3055 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | ||
3056 | } | ||
3057 | |||
3058 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
3059 | { | ||
3060 | struct sd *sd = (struct sd *) gspca_dev; | ||
3061 | |||
3062 | sd->brightness = val; | ||
3063 | if (gspca_dev->streaming) { | ||
3064 | if (sd->stop_on_control_change) | ||
3065 | sd_stopN(gspca_dev); | ||
3066 | cit_set_brightness(gspca_dev); | ||
3067 | if (sd->stop_on_control_change) | ||
3068 | cit_restart_stream(gspca_dev); | ||
3069 | } | ||
3070 | |||
3071 | return 0; | ||
3072 | } | ||
3073 | |||
3074 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
3075 | { | ||
3076 | struct sd *sd = (struct sd *) gspca_dev; | ||
3077 | |||
3078 | *val = sd->brightness; | ||
3079 | |||
3080 | return 0; | ||
3081 | } | ||
3082 | |||
3083 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | ||
3084 | { | ||
3085 | struct sd *sd = (struct sd *) gspca_dev; | ||
3086 | |||
3087 | sd->contrast = val; | ||
3088 | if (gspca_dev->streaming) { | ||
3089 | if (sd->stop_on_control_change) | ||
3090 | sd_stopN(gspca_dev); | ||
3091 | cit_set_contrast(gspca_dev); | ||
3092 | if (sd->stop_on_control_change) | ||
3093 | cit_restart_stream(gspca_dev); | ||
3094 | } | ||
3095 | |||
3096 | return 0; | ||
3097 | } | ||
3098 | |||
3099 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | ||
3100 | { | ||
3101 | struct sd *sd = (struct sd *) gspca_dev; | ||
3102 | |||
3103 | *val = sd->contrast; | ||
3104 | |||
3105 | return 0; | ||
3106 | } | ||
3107 | |||
3108 | static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val) | ||
3109 | { | ||
3110 | struct sd *sd = (struct sd *) gspca_dev; | ||
3111 | |||
3112 | sd->hue = val; | ||
3113 | if (gspca_dev->streaming) { | ||
3114 | if (sd->stop_on_control_change) | ||
3115 | sd_stopN(gspca_dev); | ||
3116 | cit_set_hue(gspca_dev); | ||
3117 | if (sd->stop_on_control_change) | ||
3118 | cit_restart_stream(gspca_dev); | ||
3119 | } | ||
3120 | return 0; | ||
3121 | } | ||
3122 | |||
3123 | static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val) | ||
3124 | { | ||
3125 | struct sd *sd = (struct sd *) gspca_dev; | ||
3126 | |||
3127 | *val = sd->hue; | ||
3128 | |||
3129 | return 0; | ||
3130 | } | ||
3131 | |||
3132 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val) | ||
3133 | { | ||
3134 | struct sd *sd = (struct sd *) gspca_dev; | ||
3135 | |||
3136 | sd->sharpness = val; | ||
3137 | if (gspca_dev->streaming) { | ||
3138 | if (sd->stop_on_control_change) | ||
3139 | sd_stopN(gspca_dev); | ||
3140 | cit_set_sharpness(gspca_dev); | ||
3141 | if (sd->stop_on_control_change) | ||
3142 | cit_restart_stream(gspca_dev); | ||
3143 | } | ||
3144 | return 0; | ||
3145 | } | ||
3146 | |||
3147 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) | ||
3148 | { | ||
3149 | struct sd *sd = (struct sd *) gspca_dev; | ||
3150 | |||
3151 | *val = sd->sharpness; | ||
3152 | |||
3153 | return 0; | ||
3154 | } | ||
3155 | |||
3156 | static int sd_setlighting(struct gspca_dev *gspca_dev, __s32 val) | ||
3157 | { | ||
3158 | struct sd *sd = (struct sd *) gspca_dev; | ||
3159 | |||
3160 | sd->lighting = val; | ||
3161 | if (gspca_dev->streaming) { | ||
3162 | if (sd->stop_on_control_change) | ||
3163 | sd_stopN(gspca_dev); | ||
3164 | cit_set_lighting(gspca_dev); | ||
3165 | if (sd->stop_on_control_change) | ||
3166 | cit_restart_stream(gspca_dev); | ||
3167 | } | ||
3168 | return 0; | ||
3169 | } | ||
3170 | |||
3171 | static int sd_getlighting(struct gspca_dev *gspca_dev, __s32 *val) | ||
3172 | { | ||
3173 | struct sd *sd = (struct sd *) gspca_dev; | ||
3174 | |||
3175 | *val = sd->lighting; | ||
3176 | |||
3177 | return 0; | ||
3178 | } | ||
3179 | |||
3180 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) | ||
3181 | { | ||
3182 | struct sd *sd = (struct sd *) gspca_dev; | ||
3183 | |||
3184 | sd->hflip = val; | ||
3185 | if (gspca_dev->streaming) { | ||
3186 | if (sd->stop_on_control_change) | ||
3187 | sd_stopN(gspca_dev); | ||
3188 | cit_set_hflip(gspca_dev); | ||
3189 | if (sd->stop_on_control_change) | ||
3190 | cit_restart_stream(gspca_dev); | ||
3191 | } | ||
3192 | return 0; | ||
3193 | } | ||
3194 | |||
3195 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
3196 | { | ||
3197 | struct sd *sd = (struct sd *) gspca_dev; | ||
3198 | |||
3199 | *val = sd->hflip; | ||
3200 | |||
3201 | return 0; | ||
3202 | } | ||
3203 | |||
3204 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3205 | static void cit_check_button(struct gspca_dev *gspca_dev) | ||
3206 | { | ||
3207 | int new_button_state; | ||
3208 | struct sd *sd = (struct sd *)gspca_dev; | ||
3209 | |||
3210 | switch (sd->model) { | ||
3211 | case CIT_MODEL3: | ||
3212 | case CIT_IBM_NETCAM_PRO: | ||
3213 | break; | ||
3214 | default: /* TEST ME unknown if this works on other models too */ | ||
3215 | return; | ||
3216 | } | ||
3217 | |||
3218 | /* Read the button state */ | ||
3219 | cit_read_reg(gspca_dev, 0x0113, 0); | ||
3220 | new_button_state = !gspca_dev->usb_buf[0]; | ||
3221 | |||
3222 | /* Tell the cam we've seen the button press, notice that this | ||
3223 | is a nop (iow the cam keeps reporting pressed) until the | ||
3224 | button is actually released. */ | ||
3225 | if (new_button_state) | ||
3226 | cit_write_reg(gspca_dev, 0x01, 0x0113); | ||
3227 | |||
3228 | if (sd->button_state != new_button_state) { | ||
3229 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, | ||
3230 | new_button_state); | ||
3231 | input_sync(gspca_dev->input_dev); | ||
3232 | sd->button_state = new_button_state; | ||
3233 | } | ||
3234 | } | ||
3235 | #endif | ||
3236 | |||
3237 | /* sub-driver description */ | ||
3238 | static const struct sd_desc sd_desc = { | ||
3239 | .name = MODULE_NAME, | ||
3240 | .ctrls = sd_ctrls, | ||
3241 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
3242 | .config = sd_config, | ||
3243 | .init = sd_init, | ||
3244 | .start = sd_start, | ||
3245 | .stopN = sd_stopN, | ||
3246 | .stop0 = sd_stop0, | ||
3247 | .pkt_scan = sd_pkt_scan, | ||
3248 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3249 | .dq_callback = cit_check_button, | ||
3250 | .other_input = 1, | ||
3251 | #endif | ||
3252 | }; | ||
3253 | |||
3254 | static const struct sd_desc sd_desc_isoc_nego = { | ||
3255 | .name = MODULE_NAME, | ||
3256 | .ctrls = sd_ctrls, | ||
3257 | .nctrls = ARRAY_SIZE(sd_ctrls), | ||
3258 | .config = sd_config, | ||
3259 | .init = sd_init, | ||
3260 | .start = sd_start, | ||
3261 | .isoc_init = sd_isoc_init, | ||
3262 | .isoc_nego = sd_isoc_nego, | ||
3263 | .stopN = sd_stopN, | ||
3264 | .stop0 = sd_stop0, | ||
3265 | .pkt_scan = sd_pkt_scan, | ||
3266 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3267 | .dq_callback = cit_check_button, | ||
3268 | .other_input = 1, | ||
3269 | #endif | ||
3270 | }; | ||
3271 | |||
3272 | /* -- module initialisation -- */ | ||
3273 | static const struct usb_device_id device_table[] = { | ||
3274 | { USB_DEVICE_VER(0x0545, 0x8080, 0x0001, 0x0001), .driver_info = CIT_MODEL0 }, | ||
3275 | { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info = CIT_MODEL1 }, | ||
3276 | { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info = CIT_MODEL2 }, | ||
3277 | { USB_DEVICE_VER(0x0545, 0x8080, 0x0301, 0x0301), .driver_info = CIT_MODEL3 }, | ||
3278 | { USB_DEVICE_VER(0x0545, 0x8002, 0x030a, 0x030a), .driver_info = CIT_MODEL4 }, | ||
3279 | { USB_DEVICE_VER(0x0545, 0x800c, 0x030a, 0x030a), .driver_info = CIT_MODEL2 }, | ||
3280 | { USB_DEVICE_VER(0x0545, 0x800d, 0x030a, 0x030a), .driver_info = CIT_MODEL4 }, | ||
3281 | {} | ||
3282 | }; | ||
3283 | MODULE_DEVICE_TABLE(usb, device_table); | ||
3284 | |||
3285 | /* -- device connect -- */ | ||
3286 | static int sd_probe(struct usb_interface *intf, | ||
3287 | const struct usb_device_id *id) | ||
3288 | { | ||
3289 | const struct sd_desc *desc = &sd_desc; | ||
3290 | |||
3291 | switch (id->driver_info) { | ||
3292 | case CIT_MODEL0: | ||
3293 | case CIT_MODEL1: | ||
3294 | if (intf->cur_altsetting->desc.bInterfaceNumber != 2) | ||
3295 | return -ENODEV; | ||
3296 | break; | ||
3297 | case CIT_MODEL2: | ||
3298 | case CIT_MODEL4: | ||
3299 | if (intf->cur_altsetting->desc.bInterfaceNumber != 0) | ||
3300 | return -ENODEV; | ||
3301 | break; | ||
3302 | case CIT_MODEL3: | ||
3303 | if (intf->cur_altsetting->desc.bInterfaceNumber != 0) | ||
3304 | return -ENODEV; | ||
3305 | /* FIXME this likely applies to all model3 cams and probably | ||
3306 | to other models too. */ | ||
3307 | if (ibm_netcam_pro) | ||
3308 | desc = &sd_desc_isoc_nego; | ||
3309 | break; | ||
3310 | } | ||
3311 | |||
3312 | return gspca_dev_probe2(intf, id, desc, sizeof(struct sd), THIS_MODULE); | ||
3313 | } | ||
3314 | |||
3315 | static struct usb_driver sd_driver = { | ||
3316 | .name = MODULE_NAME, | ||
3317 | .id_table = device_table, | ||
3318 | .probe = sd_probe, | ||
3319 | .disconnect = gspca_disconnect, | ||
3320 | #ifdef CONFIG_PM | ||
3321 | .suspend = gspca_suspend, | ||
3322 | .resume = gspca_resume, | ||
3323 | #endif | ||
3324 | }; | ||
3325 | |||
3326 | /* -- module insert / remove -- */ | ||
3327 | static int __init sd_mod_init(void) | ||
3328 | { | ||
3329 | return usb_register(&sd_driver); | ||
3330 | } | ||
3331 | static void __exit sd_mod_exit(void) | ||
3332 | { | ||
3333 | usb_deregister(&sd_driver); | ||
3334 | } | ||
3335 | |||
3336 | module_init(sd_mod_init); | ||
3337 | module_exit(sd_mod_exit); | ||
diff --git a/drivers/media/video/gspca/zc3xx-reg.h b/drivers/media/video/gspca/zc3xx-reg.h index bfb559c3b713..a1bd94e8ce52 100644 --- a/drivers/media/video/gspca/zc3xx-reg.h +++ b/drivers/media/video/gspca/zc3xx-reg.h | |||
@@ -160,8 +160,6 @@ | |||
160 | #define ZC3XX_R1A6_YMEANAFTERAE 0x01a6 | 160 | #define ZC3XX_R1A6_YMEANAFTERAE 0x01a6 |
161 | #define ZC3XX_R1A7_CALCGLOBALMEAN 0x01a7 | 161 | #define ZC3XX_R1A7_CALCGLOBALMEAN 0x01a7 |
162 | 162 | ||
163 | #define ZC3XX_R1A2_BLUEMEANAFTERAGC 0x01a2 | ||
164 | |||
165 | /* Matrixes */ | 163 | /* Matrixes */ |
166 | 164 | ||
167 | /* Color matrix is like : | 165 | /* Color matrix is like : |
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index 0666038a51b0..61cdd56a74a9 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Z-Star/Vimicro zc301/zc302p/vc30x library | 2 | * Z-Star/Vimicro zc301/zc302p/vc30x library |
3 | * | 3 | * |
4 | * Copyright (C) 2009-2010 Jean-Francois Moine <http://moinejf.free.fr> | 4 | * Copyright (C) 2009-2011 Jean-Francois Moine <http://moinejf.free.fr> |
5 | * Copyright (C) 2004 2005 2006 Michel Xhaard mxhaard@magic.fr | 5 | * Copyright (C) 2004 2005 2006 Michel Xhaard mxhaard@magic.fr |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -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 | ||
@@ -37,16 +35,26 @@ static int force_sensor = -1; | |||
37 | #define QUANT_VAL 1 /* quantization table */ | 35 | #define QUANT_VAL 1 /* quantization table */ |
38 | #include "zc3xx-reg.h" | 36 | #include "zc3xx-reg.h" |
39 | 37 | ||
38 | /* controls */ | ||
39 | enum e_ctrl { | ||
40 | BRIGHTNESS, | ||
41 | CONTRAST, | ||
42 | EXPOSURE, | ||
43 | GAMMA, | ||
44 | AUTOGAIN, | ||
45 | LIGHTFREQ, | ||
46 | SHARPNESS, | ||
47 | NCTRLS /* number of controls */ | ||
48 | }; | ||
49 | |||
50 | #define AUTOGAIN_DEF 1 | ||
51 | |||
40 | /* specific webcam descriptor */ | 52 | /* specific webcam descriptor */ |
41 | struct sd { | 53 | struct sd { |
42 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 54 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
43 | 55 | ||
44 | u8 brightness; | 56 | struct gspca_ctrl ctrls[NCTRLS]; |
45 | u8 contrast; | 57 | |
46 | u8 gamma; | ||
47 | u8 autogain; | ||
48 | u8 lightfreq; | ||
49 | u8 sharpness; | ||
50 | u8 quality; /* image quality */ | 58 | u8 quality; /* image quality */ |
51 | #define QUALITY_MIN 50 | 59 | #define QUALITY_MIN 50 |
52 | #define QUALITY_MAX 80 | 60 | #define QUALITY_MAX 80 |
@@ -66,8 +74,9 @@ enum sensors { | |||
66 | SENSOR_ADCM2700, | 74 | SENSOR_ADCM2700, |
67 | SENSOR_CS2102, | 75 | SENSOR_CS2102, |
68 | SENSOR_CS2102K, | 76 | SENSOR_CS2102K, |
77 | SENSOR_GC0303, | ||
69 | SENSOR_GC0305, | 78 | SENSOR_GC0305, |
70 | SENSOR_HDCS2020b, | 79 | SENSOR_HDCS2020, |
71 | SENSOR_HV7131B, | 80 | SENSOR_HV7131B, |
72 | SENSOR_HV7131R, | 81 | SENSOR_HV7131R, |
73 | SENSOR_ICM105A, | 82 | SENSOR_ICM105A, |
@@ -81,26 +90,18 @@ enum sensors { | |||
81 | SENSOR_PB0330, | 90 | SENSOR_PB0330, |
82 | SENSOR_PO2030, | 91 | SENSOR_PO2030, |
83 | SENSOR_TAS5130C, | 92 | SENSOR_TAS5130C, |
84 | SENSOR_TAS5130C_VF0250, | ||
85 | SENSOR_MAX | 93 | SENSOR_MAX |
86 | }; | 94 | }; |
87 | 95 | ||
88 | /* V4L2 controls supported by the driver */ | 96 | /* V4L2 controls supported by the driver */ |
89 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 97 | static void setcontrast(struct gspca_dev *gspca_dev); |
90 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 98 | static void setexposure(struct gspca_dev *gspca_dev); |
91 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
92 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
93 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 99 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
94 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 100 | static void setlightfreq(struct gspca_dev *gspca_dev); |
95 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); | 101 | static void setsharpness(struct gspca_dev *gspca_dev); |
96 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); | 102 | |
97 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | 103 | static const struct ctrl sd_ctrls[NCTRLS] = { |
98 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | 104 | [BRIGHTNESS] = { |
99 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | ||
100 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | ||
101 | |||
102 | static const struct ctrl sd_ctrls[] = { | ||
103 | { | ||
104 | { | 105 | { |
105 | .id = V4L2_CID_BRIGHTNESS, | 106 | .id = V4L2_CID_BRIGHTNESS, |
106 | .type = V4L2_CTRL_TYPE_INTEGER, | 107 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -108,13 +109,11 @@ static const struct ctrl sd_ctrls[] = { | |||
108 | .minimum = 0, | 109 | .minimum = 0, |
109 | .maximum = 255, | 110 | .maximum = 255, |
110 | .step = 1, | 111 | .step = 1, |
111 | #define BRIGHTNESS_DEF 128 | 112 | .default_value = 128, |
112 | .default_value = BRIGHTNESS_DEF, | ||
113 | }, | 113 | }, |
114 | .set = sd_setbrightness, | 114 | .set_control = setcontrast |
115 | .get = sd_getbrightness, | ||
116 | }, | 115 | }, |
117 | { | 116 | [CONTRAST] = { |
118 | { | 117 | { |
119 | .id = V4L2_CID_CONTRAST, | 118 | .id = V4L2_CID_CONTRAST, |
120 | .type = V4L2_CTRL_TYPE_INTEGER, | 119 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -122,13 +121,23 @@ static const struct ctrl sd_ctrls[] = { | |||
122 | .minimum = 0, | 121 | .minimum = 0, |
123 | .maximum = 255, | 122 | .maximum = 255, |
124 | .step = 1, | 123 | .step = 1, |
125 | #define CONTRAST_DEF 128 | 124 | .default_value = 128, |
126 | .default_value = CONTRAST_DEF, | 125 | }, |
126 | .set_control = setcontrast | ||
127 | }, | ||
128 | [EXPOSURE] = { | ||
129 | { | ||
130 | .id = V4L2_CID_EXPOSURE, | ||
131 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
132 | .name = "Exposure", | ||
133 | .minimum = 0x30d, | ||
134 | .maximum = 0x493e, | ||
135 | .step = 1, | ||
136 | .default_value = 0x927 | ||
127 | }, | 137 | }, |
128 | .set = sd_setcontrast, | 138 | .set_control = setexposure |
129 | .get = sd_getcontrast, | ||
130 | }, | 139 | }, |
131 | { | 140 | [GAMMA] = { |
132 | { | 141 | { |
133 | .id = V4L2_CID_GAMMA, | 142 | .id = V4L2_CID_GAMMA, |
134 | .type = V4L2_CTRL_TYPE_INTEGER, | 143 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -138,10 +147,9 @@ static const struct ctrl sd_ctrls[] = { | |||
138 | .step = 1, | 147 | .step = 1, |
139 | .default_value = 4, | 148 | .default_value = 4, |
140 | }, | 149 | }, |
141 | .set = sd_setgamma, | 150 | .set_control = setcontrast |
142 | .get = sd_getgamma, | ||
143 | }, | 151 | }, |
144 | { | 152 | [AUTOGAIN] = { |
145 | { | 153 | { |
146 | .id = V4L2_CID_AUTOGAIN, | 154 | .id = V4L2_CID_AUTOGAIN, |
147 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 155 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -149,14 +157,12 @@ static const struct ctrl sd_ctrls[] = { | |||
149 | .minimum = 0, | 157 | .minimum = 0, |
150 | .maximum = 1, | 158 | .maximum = 1, |
151 | .step = 1, | 159 | .step = 1, |
152 | #define AUTOGAIN_DEF 1 | ||
153 | .default_value = AUTOGAIN_DEF, | 160 | .default_value = AUTOGAIN_DEF, |
161 | .flags = V4L2_CTRL_FLAG_UPDATE | ||
154 | }, | 162 | }, |
155 | .set = sd_setautogain, | 163 | .set = sd_setautogain |
156 | .get = sd_getautogain, | ||
157 | }, | 164 | }, |
158 | #define LIGHTFREQ_IDX 4 | 165 | [LIGHTFREQ] = { |
159 | { | ||
160 | { | 166 | { |
161 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 167 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
162 | .type = V4L2_CTRL_TYPE_MENU, | 168 | .type = V4L2_CTRL_TYPE_MENU, |
@@ -164,13 +170,11 @@ static const struct ctrl sd_ctrls[] = { | |||
164 | .minimum = 0, | 170 | .minimum = 0, |
165 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | 171 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ |
166 | .step = 1, | 172 | .step = 1, |
167 | #define FREQ_DEF 0 | 173 | .default_value = 0, |
168 | .default_value = FREQ_DEF, | ||
169 | }, | 174 | }, |
170 | .set = sd_setfreq, | 175 | .set_control = setlightfreq |
171 | .get = sd_getfreq, | ||
172 | }, | 176 | }, |
173 | { | 177 | [SHARPNESS] = { |
174 | { | 178 | { |
175 | .id = V4L2_CID_SHARPNESS, | 179 | .id = V4L2_CID_SHARPNESS, |
176 | .type = V4L2_CTRL_TYPE_INTEGER, | 180 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -178,11 +182,9 @@ static const struct ctrl sd_ctrls[] = { | |||
178 | .minimum = 0, | 182 | .minimum = 0, |
179 | .maximum = 3, | 183 | .maximum = 3, |
180 | .step = 1, | 184 | .step = 1, |
181 | #define SHARPNESS_DEF 2 | 185 | .default_value = 2, |
182 | .default_value = SHARPNESS_DEF, | ||
183 | }, | 186 | }, |
184 | .set = sd_setsharpness, | 187 | .set_control = setsharpness |
185 | .get = sd_getsharpness, | ||
186 | }, | 188 | }, |
187 | }; | 189 | }; |
188 | 190 | ||
@@ -1513,7 +1515,7 @@ static const struct usb_action gc0305_NoFliker[] = { | |||
1513 | {} | 1515 | {} |
1514 | }; | 1516 | }; |
1515 | 1517 | ||
1516 | static const struct usb_action hdcs2020b_InitialScale[] = { | 1518 | static const struct usb_action hdcs2020_InitialScale[] = { |
1517 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, | 1519 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, |
1518 | {0xa0, 0x11, ZC3XX_R002_CLOCKSELECT}, | 1520 | {0xa0, 0x11, ZC3XX_R002_CLOCKSELECT}, |
1519 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* qtable 0x05 */ | 1521 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* qtable 0x05 */ |
@@ -1645,7 +1647,7 @@ static const struct usb_action hdcs2020b_InitialScale[] = { | |||
1645 | {0xa0, 0x40, ZC3XX_R118_BGAIN}, | 1647 | {0xa0, 0x40, ZC3XX_R118_BGAIN}, |
1646 | {} | 1648 | {} |
1647 | }; | 1649 | }; |
1648 | static const struct usb_action hdcs2020b_Initial[] = { | 1650 | static const struct usb_action hdcs2020_Initial[] = { |
1649 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, | 1651 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, |
1650 | {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT}, | 1652 | {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT}, |
1651 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, | 1653 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, |
@@ -1773,7 +1775,7 @@ static const struct usb_action hdcs2020b_Initial[] = { | |||
1773 | {0xa0, 0x40, ZC3XX_R118_BGAIN}, | 1775 | {0xa0, 0x40, ZC3XX_R118_BGAIN}, |
1774 | {} | 1776 | {} |
1775 | }; | 1777 | }; |
1776 | static const struct usb_action hdcs2020b_50HZ[] = { | 1778 | static const struct usb_action hdcs2020_50HZ[] = { |
1777 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ | 1779 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ |
1778 | {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */ | 1780 | {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */ |
1779 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ | 1781 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ |
@@ -1794,7 +1796,7 @@ static const struct usb_action hdcs2020b_50HZ[] = { | |||
1794 | {0xa0, 0x2f, ZC3XX_R01F_HSYNC_2}, /* 00,1f,2f,cc */ | 1796 | {0xa0, 0x2f, ZC3XX_R01F_HSYNC_2}, /* 00,1f,2f,cc */ |
1795 | {} | 1797 | {} |
1796 | }; | 1798 | }; |
1797 | static const struct usb_action hdcs2020b_60HZ[] = { | 1799 | static const struct usb_action hdcs2020_60HZ[] = { |
1798 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ | 1800 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ |
1799 | {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */ | 1801 | {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */ |
1800 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ | 1802 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ |
@@ -1815,7 +1817,7 @@ static const struct usb_action hdcs2020b_60HZ[] = { | |||
1815 | {0xa0, 0x2c, ZC3XX_R01F_HSYNC_2}, /* 00,1f,2c,cc */ | 1817 | {0xa0, 0x2c, ZC3XX_R01F_HSYNC_2}, /* 00,1f,2c,cc */ |
1816 | {} | 1818 | {} |
1817 | }; | 1819 | }; |
1818 | static const struct usb_action hdcs2020b_NoFliker[] = { | 1820 | static const struct usb_action hdcs2020_NoFliker[] = { |
1819 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ | 1821 | {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ |
1820 | {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */ | 1822 | {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */ |
1821 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ | 1823 | {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ |
@@ -2141,7 +2143,6 @@ static const struct usb_action hv7131r_Initial[] = { | |||
2141 | {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW}, | 2143 | {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW}, |
2142 | {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, | 2144 | {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, |
2143 | {0xa0, 0xe0, ZC3XX_R006_FRAMEHEIGHTLOW}, | 2145 | {0xa0, 0xe0, ZC3XX_R006_FRAMEHEIGHTLOW}, |
2144 | |||
2145 | {0xa0, 0x00, ZC3XX_R098_WINYSTARTLOW}, | 2146 | {0xa0, 0x00, ZC3XX_R098_WINYSTARTLOW}, |
2146 | {0xa0, 0x00, ZC3XX_R09A_WINXSTARTLOW}, | 2147 | {0xa0, 0x00, ZC3XX_R09A_WINXSTARTLOW}, |
2147 | {0xa0, 0x01, ZC3XX_R09B_WINHEIGHTHIGH}, | 2148 | {0xa0, 0x01, ZC3XX_R09B_WINHEIGHTHIGH}, |
@@ -2893,7 +2894,7 @@ static const struct usb_action mc501cb_Initial[] = { | |||
2893 | {0xaa, 0x11, 0x0001}, /* 00,11,01,aa */ | 2894 | {0xaa, 0x11, 0x0001}, /* 00,11,01,aa */ |
2894 | {0xaa, 0x30, 0x0000}, /* 00,30,00,aa */ | 2895 | {0xaa, 0x30, 0x0000}, /* 00,30,00,aa */ |
2895 | {0xaa, 0x60, 0x0000}, /* 00,60,00,aa */ | 2896 | {0xaa, 0x60, 0x0000}, /* 00,60,00,aa */ |
2896 | {0xaa, 0xa0, ZC3XX_R01A_LASTFRAMESTATE}, /* 00,a0,1a,aa */ | 2897 | {0xaa, 0xa0, 0x001a}, /* 00,a0,1a,aa */ |
2897 | {0xaa, 0xa1, 0x0000}, /* 00,a1,00,aa */ | 2898 | {0xaa, 0xa1, 0x0000}, /* 00,a1,00,aa */ |
2898 | {0xaa, 0xa2, 0x003f}, /* 00,a2,3f,aa */ | 2899 | {0xaa, 0xa2, 0x003f}, /* 00,a2,3f,aa */ |
2899 | {0xaa, 0xa3, 0x0028}, /* 00,a3,28,aa */ | 2900 | {0xaa, 0xa3, 0x0028}, /* 00,a3,28,aa */ |
@@ -2953,7 +2954,7 @@ static const struct usb_action mc501cb_Initial[] = { | |||
2953 | {} | 2954 | {} |
2954 | }; | 2955 | }; |
2955 | 2956 | ||
2956 | static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */ | 2957 | static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */ |
2957 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */ | 2958 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc */ |
2958 | {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */ | 2959 | {0xa0, 0x10, ZC3XX_R002_CLOCKSELECT}, /* 00,02,10,cc */ |
2959 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */ | 2960 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc */ |
@@ -3013,7 +3014,7 @@ static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */ | |||
3013 | {0xaa, 0x11, 0x0001}, /* 00,11,01,aa */ | 3014 | {0xaa, 0x11, 0x0001}, /* 00,11,01,aa */ |
3014 | {0xaa, 0x30, 0x0000}, /* 00,30,00,aa */ | 3015 | {0xaa, 0x30, 0x0000}, /* 00,30,00,aa */ |
3015 | {0xaa, 0x60, 0x0000}, /* 00,60,00,aa */ | 3016 | {0xaa, 0x60, 0x0000}, /* 00,60,00,aa */ |
3016 | {0xaa, 0xa0, ZC3XX_R01A_LASTFRAMESTATE}, /* 00,a0,1a,aa */ | 3017 | {0xaa, 0xa0, 0x001a}, /* 00,a0,1a,aa */ |
3017 | {0xaa, 0xa1, 0x0000}, /* 00,a1,00,aa */ | 3018 | {0xaa, 0xa1, 0x0000}, /* 00,a1,00,aa */ |
3018 | {0xaa, 0xa2, 0x003f}, /* 00,a2,3f,aa */ | 3019 | {0xaa, 0xa2, 0x003f}, /* 00,a2,3f,aa */ |
3019 | {0xaa, 0xa3, 0x0028}, /* 00,a3,28,aa */ | 3020 | {0xaa, 0xa3, 0x0028}, /* 00,a3,28,aa */ |
@@ -3064,15 +3065,10 @@ static const struct usb_action mc501cb_InitialScale[] = { /* 320x240 */ | |||
3064 | {0xaa, 0x55, 0x0010}, /* 00,55,10,aa */ | 3065 | {0xaa, 0x55, 0x0010}, /* 00,55,10,aa */ |
3065 | {0xa0, 0xf0, 0x0199}, /* 01,99,F0,cc */ | 3066 | {0xa0, 0xf0, 0x0199}, /* 01,99,F0,cc */ |
3066 | {0xa0, 0x80, 0x019a}, /* 01,9A,80,cc */ | 3067 | {0xa0, 0x80, 0x019a}, /* 01,9A,80,cc */ |
3067 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3068 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3069 | {0xaa, 0x36, 0x001d}, /* 00,36,1D,aa */ | ||
3070 | {0xaa, 0x37, 0x004c}, /* 00,37,4C,aa */ | ||
3071 | {0xaa, 0x3b, 0x001d}, /* 00,3B,1D,aa */ | ||
3072 | {} | 3068 | {} |
3073 | }; | 3069 | }; |
3074 | 3070 | ||
3075 | static const struct usb_action mc501cb_50HZScale[] = { | 3071 | static const struct usb_action mc501cb_50HZ[] = { |
3076 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3072 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3077 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3073 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3078 | {0xaa, 0x36, 0x001d}, /* 00,36,1D,aa */ | 3074 | {0xaa, 0x36, 0x001d}, /* 00,36,1D,aa */ |
@@ -3081,15 +3077,10 @@ static const struct usb_action mc501cb_50HZScale[] = { | |||
3081 | {0xaa, 0x3c, 0x004c}, /* 00,3C,4C,aa */ | 3077 | {0xaa, 0x3c, 0x004c}, /* 00,3C,4C,aa */ |
3082 | {0xaa, 0x3d, 0x001d}, /* 00,3D,1D,aa */ | 3078 | {0xaa, 0x3d, 0x001d}, /* 00,3D,1D,aa */ |
3083 | {0xaa, 0x3e, 0x004c}, /* 00,3E,4C,aa */ | 3079 | {0xaa, 0x3e, 0x004c}, /* 00,3E,4C,aa */ |
3084 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3085 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3086 | {0xaa, 0x36, 0x003a}, /* 00,36,3A,aa */ | ||
3087 | {0xaa, 0x37, 0x0098}, /* 00,37,98,aa */ | ||
3088 | {0xaa, 0x3b, 0x003a}, /* 00,3B,3A,aa */ | ||
3089 | {} | 3080 | {} |
3090 | }; | 3081 | }; |
3091 | 3082 | ||
3092 | static const struct usb_action mc501cb_50HZ[] = { | 3083 | static const struct usb_action mc501cb_50HZScale[] = { |
3093 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3084 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3094 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3085 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3095 | {0xaa, 0x36, 0x003a}, /* 00,36,3A,aa */ | 3086 | {0xaa, 0x36, 0x003a}, /* 00,36,3A,aa */ |
@@ -3098,15 +3089,10 @@ static const struct usb_action mc501cb_50HZ[] = { | |||
3098 | {0xaa, 0x3c, 0x0098}, /* 00,3C,98,aa */ | 3089 | {0xaa, 0x3c, 0x0098}, /* 00,3C,98,aa */ |
3099 | {0xaa, 0x3d, 0x003a}, /* 00,3D,3A,aa */ | 3090 | {0xaa, 0x3d, 0x003a}, /* 00,3D,3A,aa */ |
3100 | {0xaa, 0x3e, 0x0098}, /* 00,3E,98,aa */ | 3091 | {0xaa, 0x3e, 0x0098}, /* 00,3E,98,aa */ |
3101 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3102 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3103 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ | ||
3104 | {0xaa, 0x37, 0x006a}, /* 00,37,6A,aa */ | ||
3105 | {0xaa, 0x3d, 0x0018}, /* 00,3D,18,aa */ | ||
3106 | {} | 3092 | {} |
3107 | }; | 3093 | }; |
3108 | 3094 | ||
3109 | static const struct usb_action mc501cb_60HZScale[] = { | 3095 | static const struct usb_action mc501cb_60HZ[] = { |
3110 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3096 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3111 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3097 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3112 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ | 3098 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ |
@@ -3115,15 +3101,10 @@ static const struct usb_action mc501cb_60HZScale[] = { | |||
3115 | {0xaa, 0x3e, 0x006a}, /* 00,3E,6A,aa */ | 3101 | {0xaa, 0x3e, 0x006a}, /* 00,3E,6A,aa */ |
3116 | {0xaa, 0x3b, 0x0018}, /* 00,3B,18,aa */ | 3102 | {0xaa, 0x3b, 0x0018}, /* 00,3B,18,aa */ |
3117 | {0xaa, 0x3c, 0x006a}, /* 00,3C,6A,aa */ | 3103 | {0xaa, 0x3c, 0x006a}, /* 00,3C,6A,aa */ |
3118 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3119 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3120 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ | ||
3121 | {0xaa, 0x37, 0x00d4}, /* 00,37,D4,aa */ | ||
3122 | {0xaa, 0x3d, 0x0030}, /* 00,3D,30,aa */ | ||
3123 | {} | 3104 | {} |
3124 | }; | 3105 | }; |
3125 | 3106 | ||
3126 | static const struct usb_action mc501cb_60HZ[] = { | 3107 | static const struct usb_action mc501cb_60HZScale[] = { |
3127 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3108 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3128 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3109 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3129 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ | 3110 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ |
@@ -3132,15 +3113,10 @@ static const struct usb_action mc501cb_60HZ[] = { | |||
3132 | {0xaa, 0x3e, 0x00d4}, /* 00,3E,D4,aa */ | 3113 | {0xaa, 0x3e, 0x00d4}, /* 00,3E,D4,aa */ |
3133 | {0xaa, 0x3b, 0x0030}, /* 00,3B,30,aa */ | 3114 | {0xaa, 0x3b, 0x0030}, /* 00,3B,30,aa */ |
3134 | {0xaa, 0x3c, 0x00d4}, /* 00,3C,D4,aa */ | 3115 | {0xaa, 0x3c, 0x00d4}, /* 00,3C,D4,aa */ |
3135 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3136 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3137 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ | ||
3138 | {0xaa, 0x37, 0x006a}, /* 00,37,6A,aa */ | ||
3139 | {0xaa, 0x3d, 0x0018}, /* 00,3D,18,aa */ | ||
3140 | {} | 3116 | {} |
3141 | }; | 3117 | }; |
3142 | 3118 | ||
3143 | static const struct usb_action mc501cb_NoFlikerScale[] = { | 3119 | static const struct usb_action mc501cb_NoFliker[] = { |
3144 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3120 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3145 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3121 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3146 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ | 3122 | {0xaa, 0x36, 0x0018}, /* 00,36,18,aa */ |
@@ -3149,15 +3125,10 @@ static const struct usb_action mc501cb_NoFlikerScale[] = { | |||
3149 | {0xaa, 0x3e, 0x006a}, /* 00,3E,6A,aa */ | 3125 | {0xaa, 0x3e, 0x006a}, /* 00,3E,6A,aa */ |
3150 | {0xaa, 0x3b, 0x0018}, /* 00,3B,18,aa */ | 3126 | {0xaa, 0x3b, 0x0018}, /* 00,3B,18,aa */ |
3151 | {0xaa, 0x3c, 0x006a}, /* 00,3C,6A,aa */ | 3127 | {0xaa, 0x3c, 0x006a}, /* 00,3C,6A,aa */ |
3152 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | ||
3153 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | ||
3154 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ | ||
3155 | {0xaa, 0x37, 0x00d4}, /* 00,37,D4,aa */ | ||
3156 | {0xaa, 0x3d, 0x0030}, /* 00,3D,30,aa */ | ||
3157 | {} | 3128 | {} |
3158 | }; | 3129 | }; |
3159 | 3130 | ||
3160 | static const struct usb_action mc501cb_NoFliker[] = { | 3131 | static const struct usb_action mc501cb_NoFlikerScale[] = { |
3161 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ | 3132 | {0xaa, 0x03, 0x0003}, /* 00,03,03,aa */ |
3162 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ | 3133 | {0xaa, 0x10, 0x00fc}, /* 00,10,fc,aa */ |
3163 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ | 3134 | {0xaa, 0x36, 0x0030}, /* 00,36,30,aa */ |
@@ -3325,7 +3296,7 @@ static const struct usb_action ov7620_50HZ[] = { | |||
3325 | {0xaa, 0x10, 0x0082}, /* 00,10,82,aa */ | 3296 | {0xaa, 0x10, 0x0082}, /* 00,10,82,aa */ |
3326 | {0xaa, 0x76, 0x0003}, /* 00,76,03,aa */ | 3297 | {0xaa, 0x76, 0x0003}, /* 00,76,03,aa */ |
3327 | /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT}, * 00,02,40,cc | 3298 | /* {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT}, * 00,02,40,cc |
3328 | if mode0 (640x480) */ | 3299 | * if mode0 (640x480) */ |
3329 | {} | 3300 | {} |
3330 | }; | 3301 | }; |
3331 | static const struct usb_action ov7620_60HZ[] = { | 3302 | static const struct usb_action ov7620_60HZ[] = { |
@@ -3731,7 +3702,6 @@ static const struct usb_action pas106b_InitialScale[] = { /* 176x144 */ | |||
3731 | {0xaa, 0x0d, 0x0000}, | 3702 | {0xaa, 0x0d, 0x0000}, |
3732 | {0xaa, 0x0e, 0x0002}, | 3703 | {0xaa, 0x0e, 0x0002}, |
3733 | {0xaa, 0x14, 0x0081}, | 3704 | {0xaa, 0x14, 0x0081}, |
3734 | |||
3735 | /* Other registers */ | 3705 | /* Other registers */ |
3736 | {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, | 3706 | {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, |
3737 | /* Frame retreiving */ | 3707 | /* Frame retreiving */ |
@@ -3785,7 +3755,6 @@ static const struct usb_action pas106b_InitialScale[] = { /* 176x144 */ | |||
3785 | {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, | 3755 | {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, |
3786 | {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, | 3756 | {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, |
3787 | {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, | 3757 | {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, |
3788 | |||
3789 | /* Auto exposure and white balance */ | 3758 | /* Auto exposure and white balance */ |
3790 | {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, | 3759 | {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, |
3791 | {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, | 3760 | {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, |
@@ -3849,7 +3818,6 @@ static const struct usb_action pas106b_Initial[] = { /* 352x288 */ | |||
3849 | {0xaa, 0x0d, 0x0000}, | 3818 | {0xaa, 0x0d, 0x0000}, |
3850 | {0xaa, 0x0e, 0x0002}, | 3819 | {0xaa, 0x0e, 0x0002}, |
3851 | {0xaa, 0x14, 0x0081}, | 3820 | {0xaa, 0x14, 0x0081}, |
3852 | |||
3853 | /* Other registers */ | 3821 | /* Other registers */ |
3854 | {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, | 3822 | {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, |
3855 | /* Frame retreiving */ | 3823 | /* Frame retreiving */ |
@@ -4504,7 +4472,7 @@ static const struct usb_action mt9v111_3_Initial[] = { | |||
4504 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, | 4472 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, |
4505 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, | 4473 | {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, |
4506 | {0xa0, 0x0a, ZC3XX_R010_CMOSSENSORSELECT}, | 4474 | {0xa0, 0x0a, ZC3XX_R010_CMOSSENSORSELECT}, |
4507 | {0xa0, 0x04, ZC3XX_R002_CLOCKSELECT}, | 4475 | {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT}, |
4508 | {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH}, | 4476 | {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH}, |
4509 | {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW}, | 4477 | {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW}, |
4510 | {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, | 4478 | {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, |
@@ -5411,7 +5379,7 @@ static const struct usb_action tas5130c_NoFlikerScale[] = { | |||
5411 | {} | 5379 | {} |
5412 | }; | 5380 | }; |
5413 | 5381 | ||
5414 | static const struct usb_action tas5130c_vf0250_InitialScale[] = { | 5382 | static const struct usb_action gc0303_InitialScale[] = { |
5415 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ | 5383 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ |
5416 | {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ | 5384 | {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ |
5417 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ | 5385 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ |
@@ -5478,7 +5446,7 @@ static const struct usb_action tas5130c_vf0250_InitialScale[] = { | |||
5478 | {} | 5446 | {} |
5479 | }; | 5447 | }; |
5480 | 5448 | ||
5481 | static const struct usb_action tas5130c_vf0250_Initial[] = { | 5449 | static const struct usb_action gc0303_Initial[] = { |
5482 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ | 5450 | {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ |
5483 | {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ | 5451 | {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ |
5484 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ | 5452 | {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ |
@@ -5543,7 +5511,7 @@ static const struct usb_action tas5130c_vf0250_Initial[] = { | |||
5543 | {0xa0, 0x65, ZC3XX_R118_BGAIN}, /* 01,18,65,cc */ | 5511 | {0xa0, 0x65, ZC3XX_R118_BGAIN}, /* 01,18,65,cc */ |
5544 | {} | 5512 | {} |
5545 | }; | 5513 | }; |
5546 | static const struct usb_action tas5130c_vf0250_50HZScale[] = { | 5514 | static const struct usb_action gc0303_50HZScale[] = { |
5547 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5515 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5548 | {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ | 5516 | {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ |
5549 | {0xaa, 0x84, 0x00aa}, /* 00,84,aa,aa */ | 5517 | {0xaa, 0x84, 0x00aa}, /* 00,84,aa,aa */ |
@@ -5567,7 +5535,7 @@ static const struct usb_action tas5130c_vf0250_50HZScale[] = { | |||
5567 | {} | 5535 | {} |
5568 | }; | 5536 | }; |
5569 | 5537 | ||
5570 | static const struct usb_action tas5130c_vf0250_50HZ[] = { | 5538 | static const struct usb_action gc0303_50HZ[] = { |
5571 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5539 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5572 | {0xaa, 0x83, 0x0003}, /* 00,83,03,aa */ | 5540 | {0xaa, 0x83, 0x0003}, /* 00,83,03,aa */ |
5573 | {0xaa, 0x84, 0x0054}, /* 00,84,54,aa */ | 5541 | {0xaa, 0x84, 0x0054}, /* 00,84,54,aa */ |
@@ -5591,7 +5559,7 @@ static const struct usb_action tas5130c_vf0250_50HZ[] = { | |||
5591 | {} | 5559 | {} |
5592 | }; | 5560 | }; |
5593 | 5561 | ||
5594 | static const struct usb_action tas5130c_vf0250_60HZScale[] = { | 5562 | static const struct usb_action gc0303_60HZScale[] = { |
5595 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5563 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5596 | {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ | 5564 | {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ |
5597 | {0xaa, 0x84, 0x0062}, /* 00,84,62,aa */ | 5565 | {0xaa, 0x84, 0x0062}, /* 00,84,62,aa */ |
@@ -5615,7 +5583,7 @@ static const struct usb_action tas5130c_vf0250_60HZScale[] = { | |||
5615 | {} | 5583 | {} |
5616 | }; | 5584 | }; |
5617 | 5585 | ||
5618 | static const struct usb_action tas5130c_vf0250_60HZ[] = { | 5586 | static const struct usb_action gc0303_60HZ[] = { |
5619 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5587 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5620 | {0xaa, 0x83, 0x0002}, /* 00,83,02,aa */ | 5588 | {0xaa, 0x83, 0x0002}, /* 00,83,02,aa */ |
5621 | {0xaa, 0x84, 0x00c4}, /* 00,84,c4,aa */ | 5589 | {0xaa, 0x84, 0x00c4}, /* 00,84,c4,aa */ |
@@ -5639,7 +5607,7 @@ static const struct usb_action tas5130c_vf0250_60HZ[] = { | |||
5639 | {} | 5607 | {} |
5640 | }; | 5608 | }; |
5641 | 5609 | ||
5642 | static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = { | 5610 | static const struct usb_action gc0303_NoFlikerScale[] = { |
5643 | {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ | 5611 | {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ |
5644 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5612 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5645 | {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ | 5613 | {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ |
@@ -5661,7 +5629,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = { | |||
5661 | {} | 5629 | {} |
5662 | }; | 5630 | }; |
5663 | 5631 | ||
5664 | static const struct usb_action tas5130c_vf0250_NoFliker[] = { | 5632 | static const struct usb_action gc0303_NoFliker[] = { |
5665 | {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ | 5633 | {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ |
5666 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ | 5634 | {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ |
5667 | {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ | 5635 | {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ |
@@ -5698,7 +5666,7 @@ static u8 reg_r_i(struct gspca_dev *gspca_dev, | |||
5698 | index, gspca_dev->usb_buf, 1, | 5666 | index, gspca_dev->usb_buf, 1, |
5699 | 500); | 5667 | 500); |
5700 | if (ret < 0) { | 5668 | if (ret < 0) { |
5701 | PDEBUG(D_ERR, "reg_r_i err %d", ret); | 5669 | err("reg_r_i err %d", ret); |
5702 | gspca_dev->usb_err = ret; | 5670 | gspca_dev->usb_err = ret; |
5703 | return 0; | 5671 | return 0; |
5704 | } | 5672 | } |
@@ -5730,7 +5698,7 @@ static void reg_w_i(struct gspca_dev *gspca_dev, | |||
5730 | value, index, NULL, 0, | 5698 | value, index, NULL, 0, |
5731 | 500); | 5699 | 500); |
5732 | if (ret < 0) { | 5700 | if (ret < 0) { |
5733 | PDEBUG(D_ERR, "reg_w_i err %d", ret); | 5701 | err("reg_w_i err %d", ret); |
5734 | gspca_dev->usb_err = ret; | 5702 | gspca_dev->usb_err = ret; |
5735 | } | 5703 | } |
5736 | } | 5704 | } |
@@ -5811,7 +5779,7 @@ static void usb_exchange(struct gspca_dev *gspca_dev, | |||
5811 | break; | 5779 | break; |
5812 | default: | 5780 | default: |
5813 | /* case 0xdd: * delay */ | 5781 | /* case 0xdd: * delay */ |
5814 | msleep(action->val / 64 + 10); | 5782 | msleep(action->idx); |
5815 | break; | 5783 | break; |
5816 | } | 5784 | } |
5817 | action++; | 5785 | action++; |
@@ -5838,16 +5806,17 @@ static void setmatrix(struct gspca_dev *gspca_dev) | |||
5838 | {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60}; | 5806 | {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60}; |
5839 | static const u8 tas5130c_matrix[9] = | 5807 | static const u8 tas5130c_matrix[9] = |
5840 | {0x68, 0xec, 0xec, 0xec, 0x68, 0xec, 0xec, 0xec, 0x68}; | 5808 | {0x68, 0xec, 0xec, 0xec, 0x68, 0xec, 0xec, 0xec, 0x68}; |
5841 | static const u8 vf0250_matrix[9] = | 5809 | static const u8 gc0303_matrix[9] = |
5842 | {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b}; | 5810 | {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b}; |
5843 | static const u8 *matrix_tb[SENSOR_MAX] = { | 5811 | static const u8 *matrix_tb[SENSOR_MAX] = { |
5844 | [SENSOR_ADCM2700] = adcm2700_matrix, | 5812 | [SENSOR_ADCM2700] = adcm2700_matrix, |
5845 | [SENSOR_CS2102] = ov7620_matrix, | 5813 | [SENSOR_CS2102] = ov7620_matrix, |
5846 | [SENSOR_CS2102K] = NULL, | 5814 | [SENSOR_CS2102K] = NULL, |
5815 | [SENSOR_GC0303] = gc0303_matrix, | ||
5847 | [SENSOR_GC0305] = gc0305_matrix, | 5816 | [SENSOR_GC0305] = gc0305_matrix, |
5848 | [SENSOR_HDCS2020b] = NULL, | 5817 | [SENSOR_HDCS2020] = NULL, |
5849 | [SENSOR_HV7131B] = NULL, | 5818 | [SENSOR_HV7131B] = NULL, |
5850 | [SENSOR_HV7131R] = NULL, | 5819 | [SENSOR_HV7131R] = po2030_matrix, |
5851 | [SENSOR_ICM105A] = po2030_matrix, | 5820 | [SENSOR_ICM105A] = po2030_matrix, |
5852 | [SENSOR_MC501CB] = NULL, | 5821 | [SENSOR_MC501CB] = NULL, |
5853 | [SENSOR_MT9V111_1] = gc0305_matrix, | 5822 | [SENSOR_MT9V111_1] = gc0305_matrix, |
@@ -5859,7 +5828,6 @@ static void setmatrix(struct gspca_dev *gspca_dev) | |||
5859 | [SENSOR_PB0330] = gc0305_matrix, | 5828 | [SENSOR_PB0330] = gc0305_matrix, |
5860 | [SENSOR_PO2030] = po2030_matrix, | 5829 | [SENSOR_PO2030] = po2030_matrix, |
5861 | [SENSOR_TAS5130C] = tas5130c_matrix, | 5830 | [SENSOR_TAS5130C] = tas5130c_matrix, |
5862 | [SENSOR_TAS5130C_VF0250] = vf0250_matrix, | ||
5863 | }; | 5831 | }; |
5864 | 5832 | ||
5865 | matrix = matrix_tb[sd->sensor]; | 5833 | matrix = matrix_tb[sd->sensor]; |
@@ -5880,7 +5848,7 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
5880 | {0x10, 0x1e} | 5848 | {0x10, 0x1e} |
5881 | }; | 5849 | }; |
5882 | 5850 | ||
5883 | sharpness = sd->sharpness; | 5851 | sharpness = sd->ctrls[SHARPNESS].val; |
5884 | reg_w(gspca_dev, sharpness_tb[sharpness][0], 0x01c6); | 5852 | reg_w(gspca_dev, sharpness_tb[sharpness][0], 0x01c6); |
5885 | reg_r(gspca_dev, 0x01c8); | 5853 | reg_r(gspca_dev, 0x01c8); |
5886 | reg_r(gspca_dev, 0x01c9); | 5854 | reg_r(gspca_dev, 0x01c9); |
@@ -5915,10 +5883,10 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
5915 | 0xe0, 0xeb, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff}, | 5883 | 0xe0, 0xeb, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff}, |
5916 | }; | 5884 | }; |
5917 | 5885 | ||
5918 | Tgamma = gamma_tb[sd->gamma - 1]; | 5886 | Tgamma = gamma_tb[sd->ctrls[GAMMA].val - 1]; |
5919 | 5887 | ||
5920 | contrast = ((int) sd->contrast - 128); /* -128 / 127 */ | 5888 | contrast = ((int) sd->ctrls[CONTRAST].val - 128); /* -128 / 127 */ |
5921 | brightness = ((int) sd->brightness - 128); /* -128 / 92 */ | 5889 | brightness = ((int) sd->ctrls[BRIGHTNESS].val - 128); /* -128 / 92 */ |
5922 | adj = 0; | 5890 | adj = 0; |
5923 | gp1 = gp2 = 0; | 5891 | gp1 = gp2 = 0; |
5924 | for (i = 0; i < 16; i++) { | 5892 | for (i = 0; i < 16; i++) { |
@@ -5945,6 +5913,26 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
5945 | reg_w(gspca_dev, gr[i], 0x0130 + i); /* gradient */ | 5913 | reg_w(gspca_dev, gr[i], 0x0130 + i); /* gradient */ |
5946 | } | 5914 | } |
5947 | 5915 | ||
5916 | static void getexposure(struct gspca_dev *gspca_dev) | ||
5917 | { | ||
5918 | struct sd *sd = (struct sd *) gspca_dev; | ||
5919 | |||
5920 | sd->ctrls[EXPOSURE].val = (i2c_read(gspca_dev, 0x25) << 9) | ||
5921 | | (i2c_read(gspca_dev, 0x26) << 1) | ||
5922 | | (i2c_read(gspca_dev, 0x27) >> 7); | ||
5923 | } | ||
5924 | |||
5925 | static void setexposure(struct gspca_dev *gspca_dev) | ||
5926 | { | ||
5927 | struct sd *sd = (struct sd *) gspca_dev; | ||
5928 | int val; | ||
5929 | |||
5930 | val = sd->ctrls[EXPOSURE].val; | ||
5931 | i2c_write(gspca_dev, 0x25, val >> 9, 0x00); | ||
5932 | i2c_write(gspca_dev, 0x26, val >> 1, 0x00); | ||
5933 | i2c_write(gspca_dev, 0x27, val << 7, 0x00); | ||
5934 | } | ||
5935 | |||
5948 | static void setquality(struct gspca_dev *gspca_dev) | 5936 | static void setquality(struct gspca_dev *gspca_dev) |
5949 | { | 5937 | { |
5950 | struct sd *sd = (struct sd *) gspca_dev; | 5938 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -5954,6 +5942,7 @@ static void setquality(struct gspca_dev *gspca_dev) | |||
5954 | case SENSOR_ADCM2700: | 5942 | case SENSOR_ADCM2700: |
5955 | case SENSOR_GC0305: | 5943 | case SENSOR_GC0305: |
5956 | case SENSOR_HV7131B: | 5944 | case SENSOR_HV7131B: |
5945 | case SENSOR_HV7131R: | ||
5957 | case SENSOR_OV7620: | 5946 | case SENSOR_OV7620: |
5958 | case SENSOR_PAS202B: | 5947 | case SENSOR_PAS202B: |
5959 | case SENSOR_PO2030: | 5948 | case SENSOR_PO2030: |
@@ -5999,14 +5988,18 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
5999 | {cs2102_NoFliker, cs2102_NoFlikerScale, | 5988 | {cs2102_NoFliker, cs2102_NoFlikerScale, |
6000 | NULL, NULL, /* currently disabled */ | 5989 | NULL, NULL, /* currently disabled */ |
6001 | NULL, NULL}, | 5990 | NULL, NULL}, |
5991 | [SENSOR_GC0303] = | ||
5992 | {gc0303_NoFliker, gc0303_NoFlikerScale, | ||
5993 | gc0303_50HZ, gc0303_50HZScale, | ||
5994 | gc0303_60HZ, gc0303_60HZScale}, | ||
6002 | [SENSOR_GC0305] = | 5995 | [SENSOR_GC0305] = |
6003 | {gc0305_NoFliker, gc0305_NoFliker, | 5996 | {gc0305_NoFliker, gc0305_NoFliker, |
6004 | gc0305_50HZ, gc0305_50HZ, | 5997 | gc0305_50HZ, gc0305_50HZ, |
6005 | gc0305_60HZ, gc0305_60HZ}, | 5998 | gc0305_60HZ, gc0305_60HZ}, |
6006 | [SENSOR_HDCS2020b] = | 5999 | [SENSOR_HDCS2020] = |
6007 | {hdcs2020b_NoFliker, hdcs2020b_NoFliker, | 6000 | {hdcs2020_NoFliker, hdcs2020_NoFliker, |
6008 | hdcs2020b_50HZ, hdcs2020b_50HZ, | 6001 | hdcs2020_50HZ, hdcs2020_50HZ, |
6009 | hdcs2020b_60HZ, hdcs2020b_60HZ}, | 6002 | hdcs2020_60HZ, hdcs2020_60HZ}, |
6010 | [SENSOR_HV7131B] = | 6003 | [SENSOR_HV7131B] = |
6011 | {hv7131b_NoFliker, hv7131b_NoFlikerScale, | 6004 | {hv7131b_NoFliker, hv7131b_NoFlikerScale, |
6012 | hv7131b_50HZ, hv7131b_50HZScale, | 6005 | hv7131b_50HZ, hv7131b_50HZScale, |
@@ -6059,14 +6052,10 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
6059 | {tas5130c_NoFliker, tas5130c_NoFlikerScale, | 6052 | {tas5130c_NoFliker, tas5130c_NoFlikerScale, |
6060 | tas5130c_50HZ, tas5130c_50HZScale, | 6053 | tas5130c_50HZ, tas5130c_50HZScale, |
6061 | tas5130c_60HZ, tas5130c_60HZScale}, | 6054 | tas5130c_60HZ, tas5130c_60HZScale}, |
6062 | [SENSOR_TAS5130C_VF0250] = | ||
6063 | {tas5130c_vf0250_NoFliker, tas5130c_vf0250_NoFlikerScale, | ||
6064 | tas5130c_vf0250_50HZ, tas5130c_vf0250_50HZScale, | ||
6065 | tas5130c_vf0250_60HZ, tas5130c_vf0250_60HZScale}, | ||
6066 | }; | 6055 | }; |
6067 | 6056 | ||
6068 | i = sd->lightfreq * 2; | 6057 | i = sd->ctrls[LIGHTFREQ].val * 2; |
6069 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 6058 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
6070 | if (mode) | 6059 | if (mode) |
6071 | i++; /* 320x240 */ | 6060 | i++; /* 320x240 */ |
6072 | zc3_freq = freq_tb[sd->sensor][i]; | 6061 | zc3_freq = freq_tb[sd->sensor][i]; |
@@ -6075,14 +6064,14 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
6075 | usb_exchange(gspca_dev, zc3_freq); | 6064 | usb_exchange(gspca_dev, zc3_freq); |
6076 | switch (sd->sensor) { | 6065 | switch (sd->sensor) { |
6077 | case SENSOR_GC0305: | 6066 | case SENSOR_GC0305: |
6078 | if (mode /* if 320x240 */ | 6067 | if (mode /* if 320x240 */ |
6079 | && sd->lightfreq == 1) /* and 50Hz */ | 6068 | && sd->ctrls[LIGHTFREQ].val == 1) /* and 50Hz */ |
6080 | reg_w(gspca_dev, 0x85, 0x018d); | 6069 | reg_w(gspca_dev, 0x85, 0x018d); |
6081 | /* win: 0x80, 0x018d */ | 6070 | /* win: 0x80, 0x018d */ |
6082 | break; | 6071 | break; |
6083 | case SENSOR_OV7620: | 6072 | case SENSOR_OV7620: |
6084 | if (!mode) { /* if 640x480 */ | 6073 | if (!mode) { /* if 640x480 */ |
6085 | if (sd->lightfreq != 0) /* and 50 or 60 Hz */ | 6074 | if (sd->ctrls[LIGHTFREQ].val != 0) /* and filter */ |
6086 | reg_w(gspca_dev, 0x40, 0x0002); | 6075 | reg_w(gspca_dev, 0x40, 0x0002); |
6087 | else | 6076 | else |
6088 | reg_w(gspca_dev, 0x44, 0x0002); | 6077 | reg_w(gspca_dev, 0x44, 0x0002); |
@@ -6099,7 +6088,7 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
6099 | struct sd *sd = (struct sd *) gspca_dev; | 6088 | struct sd *sd = (struct sd *) gspca_dev; |
6100 | u8 autoval; | 6089 | u8 autoval; |
6101 | 6090 | ||
6102 | if (sd->autogain) | 6091 | if (sd->ctrls[AUTOGAIN].val) |
6103 | autoval = 0x42; | 6092 | autoval = 0x42; |
6104 | else | 6093 | else |
6105 | autoval = 0x02; | 6094 | autoval = 0x02; |
@@ -6108,7 +6097,7 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
6108 | 6097 | ||
6109 | static void send_unknown(struct gspca_dev *gspca_dev, int sensor) | 6098 | static void send_unknown(struct gspca_dev *gspca_dev, int sensor) |
6110 | { | 6099 | { |
6111 | reg_w(gspca_dev, 0x01, 0x0000); /* led off */ | 6100 | reg_w(gspca_dev, 0x01, 0x0000); /* bridge reset */ |
6112 | switch (sensor) { | 6101 | switch (sensor) { |
6113 | case SENSOR_PAS106: | 6102 | case SENSOR_PAS106: |
6114 | reg_w(gspca_dev, 0x03, 0x003a); | 6103 | reg_w(gspca_dev, 0x03, 0x003a); |
@@ -6126,11 +6115,13 @@ static void send_unknown(struct gspca_dev *gspca_dev, int sensor) | |||
6126 | reg_w(gspca_dev, 0x02, 0x003b); | 6115 | reg_w(gspca_dev, 0x02, 0x003b); |
6127 | reg_w(gspca_dev, 0x00, 0x0038); | 6116 | reg_w(gspca_dev, 0x00, 0x0038); |
6128 | break; | 6117 | break; |
6118 | case SENSOR_HV7131R: | ||
6129 | case SENSOR_PAS202B: | 6119 | case SENSOR_PAS202B: |
6130 | reg_w(gspca_dev, 0x03, 0x003b); | 6120 | reg_w(gspca_dev, 0x03, 0x003b); |
6131 | reg_w(gspca_dev, 0x0c, 0x003a); | 6121 | reg_w(gspca_dev, 0x0c, 0x003a); |
6132 | reg_w(gspca_dev, 0x0b, 0x0039); | 6122 | reg_w(gspca_dev, 0x0b, 0x0039); |
6133 | reg_w(gspca_dev, 0x0b, 0x0038); | 6123 | if (sensor == SENSOR_PAS202B) |
6124 | reg_w(gspca_dev, 0x0b, 0x0038); | ||
6134 | break; | 6125 | break; |
6135 | } | 6126 | } |
6136 | } | 6127 | } |
@@ -6275,7 +6266,6 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6275 | { | 6266 | { |
6276 | struct sd *sd = (struct sd *) gspca_dev; | 6267 | struct sd *sd = (struct sd *) gspca_dev; |
6277 | int i; | 6268 | int i; |
6278 | u8 retbyte; | ||
6279 | u16 retword; | 6269 | u16 retword; |
6280 | 6270 | ||
6281 | /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ | 6271 | /*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ |
@@ -6309,8 +6299,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6309 | if (chipset_revision_sensor[i].revision == retword) { | 6299 | if (chipset_revision_sensor[i].revision == retword) { |
6310 | sd->chip_revision = retword; | 6300 | sd->chip_revision = retword; |
6311 | send_unknown(gspca_dev, SENSOR_PB0330); | 6301 | send_unknown(gspca_dev, SENSOR_PB0330); |
6312 | return chipset_revision_sensor[i] | 6302 | return chipset_revision_sensor[i].internal_sensor_id; |
6313 | .internal_sensor_id; | ||
6314 | } | 6303 | } |
6315 | } | 6304 | } |
6316 | 6305 | ||
@@ -6326,6 +6315,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6326 | return 0x0a; /* PB0330 */ | 6315 | return 0x0a; /* PB0330 */ |
6327 | } | 6316 | } |
6328 | 6317 | ||
6318 | /* probe gc0303 / gc0305 */ | ||
6329 | reg_w(gspca_dev, 0x01, 0x0000); | 6319 | reg_w(gspca_dev, 0x01, 0x0000); |
6330 | reg_w(gspca_dev, 0x01, 0x0001); | 6320 | reg_w(gspca_dev, 0x01, 0x0001); |
6331 | reg_w(gspca_dev, 0x98, 0x008b); | 6321 | reg_w(gspca_dev, 0x98, 0x008b); |
@@ -6336,8 +6326,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6336 | retword = i2c_read(gspca_dev, 0x00); | 6326 | retword = i2c_read(gspca_dev, 0x00); |
6337 | if (retword != 0) { | 6327 | if (retword != 0) { |
6338 | PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); | 6328 | PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); |
6339 | if (retword == 0x0011) /* VF0250 */ | 6329 | if (retword == 0x0011) /* gc0303 */ |
6340 | return 0x0250; | 6330 | return 0x0303; |
6341 | if (retword == 0x0029) /* gc0305 */ | 6331 | if (retword == 0x0029) /* gc0305 */ |
6342 | send_unknown(gspca_dev, SENSOR_GC0305); | 6332 | send_unknown(gspca_dev, SENSOR_GC0305); |
6343 | return retword; | 6333 | return retword; |
@@ -6368,8 +6358,12 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev) | |||
6368 | retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ | 6358 | retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ |
6369 | PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); | 6359 | PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); |
6370 | if (retword == 0x2030) { | 6360 | if (retword == 0x2030) { |
6361 | #ifdef GSPCA_DEBUG | ||
6362 | u8 retbyte; | ||
6363 | |||
6371 | retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ | 6364 | retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ |
6372 | PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); | 6365 | PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); |
6366 | #endif | ||
6373 | send_unknown(gspca_dev, SENSOR_PO2030); | 6367 | send_unknown(gspca_dev, SENSOR_PO2030); |
6374 | return retword; | 6368 | return retword; |
6375 | } | 6369 | } |
@@ -6398,7 +6392,7 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | |||
6398 | switch (sd->sensor) { | 6392 | switch (sd->sensor) { |
6399 | case SENSOR_MC501CB: | 6393 | case SENSOR_MC501CB: |
6400 | return -1; /* don't probe */ | 6394 | return -1; /* don't probe */ |
6401 | case SENSOR_TAS5130C_VF0250: | 6395 | case SENSOR_GC0303: |
6402 | /* may probe but with no write in reg 0x0010 */ | 6396 | /* may probe but with no write in reg 0x0010 */ |
6403 | return -1; /* don't probe */ | 6397 | return -1; /* don't probe */ |
6404 | case SENSOR_PAS106: | 6398 | case SENSOR_PAS106: |
@@ -6427,13 +6421,13 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
6427 | /* define some sensors from the vendor/product */ | 6421 | /* define some sensors from the vendor/product */ |
6428 | sd->sensor = id->driver_info; | 6422 | sd->sensor = id->driver_info; |
6429 | 6423 | ||
6430 | sd->sharpness = SHARPNESS_DEF; | 6424 | gspca_dev->cam.ctrls = sd->ctrls; |
6431 | sd->brightness = BRIGHTNESS_DEF; | ||
6432 | sd->contrast = CONTRAST_DEF; | ||
6433 | sd->autogain = AUTOGAIN_DEF; | ||
6434 | sd->lightfreq = FREQ_DEF; | ||
6435 | sd->quality = QUALITY_DEF; | 6425 | sd->quality = QUALITY_DEF; |
6436 | 6426 | ||
6427 | /* if USB 1.1, let some bandwidth for the audio device */ | ||
6428 | if (gspca_dev->audio && gspca_dev->dev->speed < USB_SPEED_HIGH) | ||
6429 | gspca_dev->nbalt--; | ||
6430 | |||
6437 | return 0; | 6431 | return 0; |
6438 | } | 6432 | } |
6439 | 6433 | ||
@@ -6447,8 +6441,9 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6447 | [SENSOR_ADCM2700] = 4, | 6441 | [SENSOR_ADCM2700] = 4, |
6448 | [SENSOR_CS2102] = 4, | 6442 | [SENSOR_CS2102] = 4, |
6449 | [SENSOR_CS2102K] = 5, | 6443 | [SENSOR_CS2102K] = 5, |
6444 | [SENSOR_GC0303] = 3, | ||
6450 | [SENSOR_GC0305] = 4, | 6445 | [SENSOR_GC0305] = 4, |
6451 | [SENSOR_HDCS2020b] = 4, | 6446 | [SENSOR_HDCS2020] = 4, |
6452 | [SENSOR_HV7131B] = 4, | 6447 | [SENSOR_HV7131B] = 4, |
6453 | [SENSOR_HV7131R] = 4, | 6448 | [SENSOR_HV7131R] = 4, |
6454 | [SENSOR_ICM105A] = 4, | 6449 | [SENSOR_ICM105A] = 4, |
@@ -6462,14 +6457,14 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6462 | [SENSOR_PB0330] = 4, | 6457 | [SENSOR_PB0330] = 4, |
6463 | [SENSOR_PO2030] = 4, | 6458 | [SENSOR_PO2030] = 4, |
6464 | [SENSOR_TAS5130C] = 3, | 6459 | [SENSOR_TAS5130C] = 3, |
6465 | [SENSOR_TAS5130C_VF0250] = 3, | ||
6466 | }; | 6460 | }; |
6467 | static const u8 mode_tb[SENSOR_MAX] = { | 6461 | static const u8 mode_tb[SENSOR_MAX] = { |
6468 | [SENSOR_ADCM2700] = 2, | 6462 | [SENSOR_ADCM2700] = 2, |
6469 | [SENSOR_CS2102] = 1, | 6463 | [SENSOR_CS2102] = 1, |
6470 | [SENSOR_CS2102K] = 1, | 6464 | [SENSOR_CS2102K] = 1, |
6465 | [SENSOR_GC0303] = 1, | ||
6471 | [SENSOR_GC0305] = 1, | 6466 | [SENSOR_GC0305] = 1, |
6472 | [SENSOR_HDCS2020b] = 1, | 6467 | [SENSOR_HDCS2020] = 1, |
6473 | [SENSOR_HV7131B] = 1, | 6468 | [SENSOR_HV7131B] = 1, |
6474 | [SENSOR_HV7131R] = 1, | 6469 | [SENSOR_HV7131R] = 1, |
6475 | [SENSOR_ICM105A] = 1, | 6470 | [SENSOR_ICM105A] = 1, |
@@ -6483,7 +6478,6 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6483 | [SENSOR_PB0330] = 1, | 6478 | [SENSOR_PB0330] = 1, |
6484 | [SENSOR_PO2030] = 1, | 6479 | [SENSOR_PO2030] = 1, |
6485 | [SENSOR_TAS5130C] = 1, | 6480 | [SENSOR_TAS5130C] = 1, |
6486 | [SENSOR_TAS5130C_VF0250] = 1, | ||
6487 | }; | 6481 | }; |
6488 | 6482 | ||
6489 | sensor = zcxx_probeSensor(gspca_dev); | 6483 | sensor = zcxx_probeSensor(gspca_dev); |
@@ -6499,12 +6493,11 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6499 | case SENSOR_MC501CB: | 6493 | case SENSOR_MC501CB: |
6500 | PDEBUG(D_PROBE, "Sensor MC501CB"); | 6494 | PDEBUG(D_PROBE, "Sensor MC501CB"); |
6501 | break; | 6495 | break; |
6502 | case SENSOR_TAS5130C_VF0250: | 6496 | case SENSOR_GC0303: |
6503 | PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)"); | 6497 | PDEBUG(D_PROBE, "Sensor GC0303"); |
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; |
@@ -6534,8 +6527,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6534 | sd->sensor = SENSOR_CS2102; | 6527 | sd->sensor = SENSOR_CS2102; |
6535 | break; | 6528 | break; |
6536 | case 0x08: | 6529 | case 0x08: |
6537 | PDEBUG(D_PROBE, "Find Sensor HDCS2020(b)"); | 6530 | PDEBUG(D_PROBE, "Find Sensor HDCS2020"); |
6538 | sd->sensor = SENSOR_HDCS2020b; | 6531 | sd->sensor = SENSOR_HDCS2020; |
6539 | break; | 6532 | break; |
6540 | case 0x0a: | 6533 | case 0x0a: |
6541 | PDEBUG(D_PROBE, | 6534 | PDEBUG(D_PROBE, |
@@ -6588,14 +6581,14 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6588 | PDEBUG(D_PROBE, "Find Sensor GC0305"); | 6581 | PDEBUG(D_PROBE, "Find Sensor GC0305"); |
6589 | sd->sensor = SENSOR_GC0305; | 6582 | sd->sensor = SENSOR_GC0305; |
6590 | break; | 6583 | break; |
6591 | case 0x0250: | 6584 | case 0x0303: |
6592 | PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)"); | 6585 | PDEBUG(D_PROBE, "Sensor GC0303"); |
6593 | sd->sensor = SENSOR_TAS5130C_VF0250; | 6586 | sd->sensor = SENSOR_GC0303; |
6594 | break; | 6587 | break; |
6595 | case 0x2030: | 6588 | case 0x2030: |
6596 | PDEBUG(D_PROBE, "Find Sensor PO2030"); | 6589 | PDEBUG(D_PROBE, "Find Sensor PO2030"); |
6597 | sd->sensor = SENSOR_PO2030; | 6590 | sd->sensor = SENSOR_PO2030; |
6598 | sd->sharpness = 0; /* from win traces */ | 6591 | sd->ctrls[SHARPNESS].def = 0; /* from win traces */ |
6599 | break; | 6592 | break; |
6600 | case 0x7620: | 6593 | case 0x7620: |
6601 | PDEBUG(D_PROBE, "Find Sensor OV7620"); | 6594 | PDEBUG(D_PROBE, "Find Sensor OV7620"); |
@@ -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 | } |
@@ -6636,13 +6629,23 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6636 | cam->nmodes = ARRAY_SIZE(broken_vga_mode); | 6629 | cam->nmodes = ARRAY_SIZE(broken_vga_mode); |
6637 | break; | 6630 | break; |
6638 | } | 6631 | } |
6639 | sd->gamma = gamma[sd->sensor]; | 6632 | |
6633 | sd->ctrls[GAMMA].def = gamma[sd->sensor]; | ||
6640 | 6634 | ||
6641 | switch (sd->sensor) { | 6635 | switch (sd->sensor) { |
6636 | case SENSOR_HV7131R: | ||
6637 | break; | ||
6642 | case SENSOR_OV7630C: | 6638 | case SENSOR_OV7630C: |
6643 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); | 6639 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ) | (1 << EXPOSURE); |
6640 | break; | ||
6641 | default: | ||
6642 | gspca_dev->ctrl_dis = (1 << EXPOSURE); | ||
6644 | break; | 6643 | break; |
6645 | } | 6644 | } |
6645 | #if AUTOGAIN_DEF | ||
6646 | if (sd->ctrls[AUTOGAIN].val) | ||
6647 | gspca_dev->ctrl_inac = (1 << EXPOSURE); | ||
6648 | #endif | ||
6646 | 6649 | ||
6647 | /* switch off the led */ | 6650 | /* switch off the led */ |
6648 | reg_w(gspca_dev, 0x01, 0x0000); | 6651 | reg_w(gspca_dev, 0x01, 0x0000); |
@@ -6660,10 +6663,12 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6660 | {cs2102_Initial, cs2102_InitialScale}, | 6663 | {cs2102_Initial, cs2102_InitialScale}, |
6661 | [SENSOR_CS2102K] = | 6664 | [SENSOR_CS2102K] = |
6662 | {cs2102K_Initial, cs2102K_InitialScale}, | 6665 | {cs2102K_Initial, cs2102K_InitialScale}, |
6666 | [SENSOR_GC0303] = | ||
6667 | {gc0303_Initial, gc0303_InitialScale}, | ||
6663 | [SENSOR_GC0305] = | 6668 | [SENSOR_GC0305] = |
6664 | {gc0305_Initial, gc0305_InitialScale}, | 6669 | {gc0305_Initial, gc0305_InitialScale}, |
6665 | [SENSOR_HDCS2020b] = | 6670 | [SENSOR_HDCS2020] = |
6666 | {hdcs2020b_Initial, hdcs2020b_InitialScale}, | 6671 | {hdcs2020_Initial, hdcs2020_InitialScale}, |
6667 | [SENSOR_HV7131B] = | 6672 | [SENSOR_HV7131B] = |
6668 | {hv7131b_Initial, hv7131b_InitialScale}, | 6673 | {hv7131b_Initial, hv7131b_InitialScale}, |
6669 | [SENSOR_HV7131R] = | 6674 | [SENSOR_HV7131R] = |
@@ -6690,8 +6695,6 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6690 | {po2030_Initial, po2030_InitialScale}, | 6695 | {po2030_Initial, po2030_InitialScale}, |
6691 | [SENSOR_TAS5130C] = | 6696 | [SENSOR_TAS5130C] = |
6692 | {tas5130c_Initial, tas5130c_InitialScale}, | 6697 | {tas5130c_Initial, tas5130c_InitialScale}, |
6693 | [SENSOR_TAS5130C_VF0250] = | ||
6694 | {tas5130c_vf0250_Initial, tas5130c_vf0250_InitialScale}, | ||
6695 | }; | 6698 | }; |
6696 | 6699 | ||
6697 | /* create the JPEG header */ | 6700 | /* create the JPEG header */ |
@@ -6716,7 +6719,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6716 | case SENSOR_OV7620: | 6719 | case SENSOR_OV7620: |
6717 | case SENSOR_PO2030: | 6720 | case SENSOR_PO2030: |
6718 | case SENSOR_TAS5130C: | 6721 | case SENSOR_TAS5130C: |
6719 | case SENSOR_TAS5130C_VF0250: | 6722 | case SENSOR_GC0303: |
6720 | /* msleep(100); * ?? */ | 6723 | /* msleep(100); * ?? */ |
6721 | reg_r(gspca_dev, 0x0002); /* --> 0x40 */ | 6724 | reg_r(gspca_dev, 0x0002); /* --> 0x40 */ |
6722 | reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ | 6725 | reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ |
@@ -6727,10 +6730,13 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6727 | reg_w(gspca_dev, 0x02, 0x003b); | 6730 | reg_w(gspca_dev, 0x02, 0x003b); |
6728 | reg_w(gspca_dev, 0x00, 0x0038); | 6731 | reg_w(gspca_dev, 0x00, 0x0038); |
6729 | break; | 6732 | break; |
6733 | case SENSOR_HV7131R: | ||
6730 | case SENSOR_PAS202B: | 6734 | case SENSOR_PAS202B: |
6731 | reg_w(gspca_dev, 0x03, 0x003b); | 6735 | reg_w(gspca_dev, 0x03, 0x003b); |
6732 | reg_w(gspca_dev, 0x0c, 0x003a); | 6736 | reg_w(gspca_dev, 0x0c, 0x003a); |
6733 | reg_w(gspca_dev, 0x0b, 0x0039); | 6737 | reg_w(gspca_dev, 0x0b, 0x0039); |
6738 | if (sd->sensor == SENSOR_HV7131R) | ||
6739 | reg_w(gspca_dev, 0x50, ZC3XX_R11D_GLOBALGAIN); | ||
6734 | break; | 6740 | break; |
6735 | } | 6741 | } |
6736 | 6742 | ||
@@ -6743,6 +6749,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6743 | break; | 6749 | break; |
6744 | case SENSOR_PAS202B: | 6750 | case SENSOR_PAS202B: |
6745 | case SENSOR_GC0305: | 6751 | case SENSOR_GC0305: |
6752 | case SENSOR_HV7131R: | ||
6746 | case SENSOR_TAS5130C: | 6753 | case SENSOR_TAS5130C: |
6747 | reg_r(gspca_dev, 0x0008); | 6754 | reg_r(gspca_dev, 0x0008); |
6748 | /* fall thru */ | 6755 | /* fall thru */ |
@@ -6755,7 +6762,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6755 | /* set the gamma tables when not set */ | 6762 | /* set the gamma tables when not set */ |
6756 | switch (sd->sensor) { | 6763 | switch (sd->sensor) { |
6757 | case SENSOR_CS2102K: /* gamma set in xxx_Initial */ | 6764 | case SENSOR_CS2102K: /* gamma set in xxx_Initial */ |
6758 | case SENSOR_HDCS2020b: | 6765 | case SENSOR_HDCS2020: |
6759 | case SENSOR_OV7630C: | 6766 | case SENSOR_OV7630C: |
6760 | break; | 6767 | break; |
6761 | default: | 6768 | default: |
@@ -6783,6 +6790,11 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6783 | /* ms-win + */ | 6790 | /* ms-win + */ |
6784 | reg_w(gspca_dev, 0x40, 0x0117); | 6791 | reg_w(gspca_dev, 0x40, 0x0117); |
6785 | break; | 6792 | break; |
6793 | case SENSOR_HV7131R: | ||
6794 | if (!sd->ctrls[AUTOGAIN].val) | ||
6795 | setexposure(gspca_dev); | ||
6796 | reg_w(gspca_dev, 0x00, ZC3XX_R1A7_CALCGLOBALMEAN); | ||
6797 | break; | ||
6786 | case SENSOR_GC0305: | 6798 | case SENSOR_GC0305: |
6787 | case SENSOR_TAS5130C: | 6799 | case SENSOR_TAS5130C: |
6788 | reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ | 6800 | reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ |
@@ -6790,7 +6802,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6790 | /* fall thru */ | 6802 | /* fall thru */ |
6791 | case SENSOR_PAS202B: | 6803 | case SENSOR_PAS202B: |
6792 | case SENSOR_PO2030: | 6804 | case SENSOR_PO2030: |
6793 | /* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); * (from win traces) */ | 6805 | /* reg_w(gspca_dev, 0x40, ZC3XX_R117_GGAIN); in win traces */ |
6794 | reg_r(gspca_dev, 0x0180); | 6806 | reg_r(gspca_dev, 0x0180); |
6795 | break; | 6807 | break; |
6796 | case SENSOR_OV7620: | 6808 | case SENSOR_OV7620: |
@@ -6798,7 +6810,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
6798 | reg_w(gspca_dev, 0x15, 0x01ae); | 6810 | reg_w(gspca_dev, 0x15, 0x01ae); |
6799 | i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */ | 6811 | i2c_read(gspca_dev, 0x13); /*fixme: returns 0xa3 */ |
6800 | i2c_write(gspca_dev, 0x13, 0xa3, 0x00); | 6812 | i2c_write(gspca_dev, 0x13, 0xa3, 0x00); |
6801 | /*fixme: returned value to send? */ | 6813 | /*fixme: returned value to send? */ |
6802 | reg_w(gspca_dev, 0x40, 0x0117); | 6814 | reg_w(gspca_dev, 0x40, 0x0117); |
6803 | reg_r(gspca_dev, 0x0180); | 6815 | reg_r(gspca_dev, 0x0180); |
6804 | break; | 6816 | break; |
@@ -6831,9 +6843,17 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
6831 | { | 6843 | { |
6832 | struct sd *sd = (struct sd *) gspca_dev; | 6844 | struct sd *sd = (struct sd *) gspca_dev; |
6833 | 6845 | ||
6834 | if (data[0] == 0xff && data[1] == 0xd8) { /* start of frame */ | 6846 | /* check the JPEG end of frame */ |
6847 | if (len >= 3 | ||
6848 | && data[len - 3] == 0xff && data[len - 2] == 0xd9) { | ||
6849 | /*fixme: what does the last byte mean?*/ | ||
6835 | gspca_frame_add(gspca_dev, LAST_PACKET, | 6850 | gspca_frame_add(gspca_dev, LAST_PACKET, |
6836 | NULL, 0); | 6851 | data, len - 1); |
6852 | return; | ||
6853 | } | ||
6854 | |||
6855 | /* check the JPEG start of a frame */ | ||
6856 | if (data[0] == 0xff && data[1] == 0xd8) { | ||
6837 | /* put the JPEG header in the new frame */ | 6857 | /* put the JPEG header in the new frame */ |
6838 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 6858 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
6839 | sd->jpeg_hdr, JPEG_HDR_SZ); | 6859 | sd->jpeg_hdr, JPEG_HDR_SZ); |
@@ -6841,7 +6861,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
6841 | /* remove the webcam's header: | 6861 | /* remove the webcam's header: |
6842 | * ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp | 6862 | * 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) | 6863 | * - 'ss ss' is the frame sequence number (BE) |
6844 | * - 'ww ww' and 'hh hh' are the window dimensions (BE) | 6864 | * - 'ww ww' and 'hh hh' are the window dimensions (BE) |
6845 | * - 'pp pp' is the packet sequence number (BE) | 6865 | * - 'pp pp' is the packet sequence number (BE) |
6846 | */ | 6866 | */ |
6847 | data += 18; | 6867 | data += 18; |
@@ -6850,114 +6870,23 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
6850 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 6870 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
6851 | } | 6871 | } |
6852 | 6872 | ||
6853 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
6854 | { | ||
6855 | struct sd *sd = (struct sd *) gspca_dev; | ||
6856 | |||
6857 | sd->brightness = val; | ||
6858 | if (gspca_dev->streaming) | ||
6859 | setcontrast(gspca_dev); | ||
6860 | return gspca_dev->usb_err; | ||
6861 | } | ||
6862 | |||
6863 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
6864 | { | ||
6865 | struct sd *sd = (struct sd *) gspca_dev; | ||
6866 | |||
6867 | *val = sd->brightness; | ||
6868 | return 0; | ||
6869 | } | ||
6870 | |||
6871 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | ||
6872 | { | ||
6873 | struct sd *sd = (struct sd *) gspca_dev; | ||
6874 | |||
6875 | sd->contrast = val; | ||
6876 | if (gspca_dev->streaming) | ||
6877 | setcontrast(gspca_dev); | ||
6878 | return gspca_dev->usb_err; | ||
6879 | } | ||
6880 | |||
6881 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | ||
6882 | { | ||
6883 | struct sd *sd = (struct sd *) gspca_dev; | ||
6884 | |||
6885 | *val = sd->contrast; | ||
6886 | return 0; | ||
6887 | } | ||
6888 | |||
6889 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | 6873 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
6890 | { | 6874 | { |
6891 | struct sd *sd = (struct sd *) gspca_dev; | 6875 | struct sd *sd = (struct sd *) gspca_dev; |
6892 | 6876 | ||
6893 | sd->autogain = val; | 6877 | sd->ctrls[AUTOGAIN].val = val; |
6878 | if (val) { | ||
6879 | gspca_dev->ctrl_inac |= (1 << EXPOSURE); | ||
6880 | } else { | ||
6881 | gspca_dev->ctrl_inac &= ~(1 << EXPOSURE); | ||
6882 | if (gspca_dev->streaming) | ||
6883 | getexposure(gspca_dev); | ||
6884 | } | ||
6894 | if (gspca_dev->streaming) | 6885 | if (gspca_dev->streaming) |
6895 | setautogain(gspca_dev); | 6886 | setautogain(gspca_dev); |
6896 | return gspca_dev->usb_err; | 6887 | return gspca_dev->usb_err; |
6897 | } | 6888 | } |
6898 | 6889 | ||
6899 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | ||
6900 | { | ||
6901 | struct sd *sd = (struct sd *) gspca_dev; | ||
6902 | |||
6903 | *val = sd->autogain; | ||
6904 | return 0; | ||
6905 | } | ||
6906 | |||
6907 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val) | ||
6908 | { | ||
6909 | struct sd *sd = (struct sd *) gspca_dev; | ||
6910 | |||
6911 | sd->gamma = val; | ||
6912 | if (gspca_dev->streaming) | ||
6913 | setcontrast(gspca_dev); | ||
6914 | return gspca_dev->usb_err; | ||
6915 | } | ||
6916 | |||
6917 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) | ||
6918 | { | ||
6919 | struct sd *sd = (struct sd *) gspca_dev; | ||
6920 | |||
6921 | *val = sd->gamma; | ||
6922 | return 0; | ||
6923 | } | ||
6924 | |||
6925 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
6926 | { | ||
6927 | struct sd *sd = (struct sd *) gspca_dev; | ||
6928 | |||
6929 | sd->lightfreq = val; | ||
6930 | if (gspca_dev->streaming) | ||
6931 | setlightfreq(gspca_dev); | ||
6932 | return gspca_dev->usb_err; | ||
6933 | } | ||
6934 | |||
6935 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
6936 | { | ||
6937 | struct sd *sd = (struct sd *) gspca_dev; | ||
6938 | |||
6939 | *val = sd->lightfreq; | ||
6940 | return 0; | ||
6941 | } | ||
6942 | |||
6943 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val) | ||
6944 | { | ||
6945 | struct sd *sd = (struct sd *) gspca_dev; | ||
6946 | |||
6947 | sd->sharpness = val; | ||
6948 | if (gspca_dev->streaming) | ||
6949 | setsharpness(gspca_dev); | ||
6950 | return gspca_dev->usb_err; | ||
6951 | } | ||
6952 | |||
6953 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) | ||
6954 | { | ||
6955 | struct sd *sd = (struct sd *) gspca_dev; | ||
6956 | |||
6957 | *val = sd->sharpness; | ||
6958 | return 0; | ||
6959 | } | ||
6960 | |||
6961 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 6890 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
6962 | struct v4l2_querymenu *menu) | 6891 | struct v4l2_querymenu *menu) |
6963 | { | 6892 | { |
@@ -7007,7 +6936,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
7007 | return 0; | 6936 | return 0; |
7008 | } | 6937 | } |
7009 | 6938 | ||
7010 | #ifdef CONFIG_INPUT | 6939 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
7011 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 6940 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
7012 | u8 *data, /* interrupt packet data */ | 6941 | u8 *data, /* interrupt packet data */ |
7013 | int len) /* interrput packet length */ | 6942 | int len) /* interrput packet length */ |
@@ -7035,12 +6964,12 @@ static const struct sd_desc sd_desc = { | |||
7035 | .querymenu = sd_querymenu, | 6964 | .querymenu = sd_querymenu, |
7036 | .get_jcomp = sd_get_jcomp, | 6965 | .get_jcomp = sd_get_jcomp, |
7037 | .set_jcomp = sd_set_jcomp, | 6966 | .set_jcomp = sd_set_jcomp, |
7038 | #ifdef CONFIG_INPUT | 6967 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) |
7039 | .int_pkt_scan = sd_int_pkt_scan, | 6968 | .int_pkt_scan = sd_int_pkt_scan, |
7040 | #endif | 6969 | #endif |
7041 | }; | 6970 | }; |
7042 | 6971 | ||
7043 | static const __devinitdata struct usb_device_id device_table[] = { | 6972 | static const struct usb_device_id device_table[] = { |
7044 | {USB_DEVICE(0x041e, 0x041e)}, | 6973 | {USB_DEVICE(0x041e, 0x041e)}, |
7045 | {USB_DEVICE(0x041e, 0x4017)}, | 6974 | {USB_DEVICE(0x041e, 0x4017)}, |
7046 | {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106}, | 6975 | {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106}, |
@@ -7052,8 +6981,8 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
7052 | {USB_DEVICE(0x041e, 0x4035), .driver_info = SENSOR_PAS106}, | 6981 | {USB_DEVICE(0x041e, 0x4035), .driver_info = SENSOR_PAS106}, |
7053 | {USB_DEVICE(0x041e, 0x4036)}, | 6982 | {USB_DEVICE(0x041e, 0x4036)}, |
7054 | {USB_DEVICE(0x041e, 0x403a)}, | 6983 | {USB_DEVICE(0x041e, 0x403a)}, |
7055 | {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_TAS5130C_VF0250}, | 6984 | {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_GC0303}, |
7056 | {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_TAS5130C_VF0250}, | 6985 | {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_GC0303}, |
7057 | {USB_DEVICE(0x0458, 0x7007)}, | 6986 | {USB_DEVICE(0x0458, 0x7007)}, |
7058 | {USB_DEVICE(0x0458, 0x700c)}, | 6987 | {USB_DEVICE(0x0458, 0x700c)}, |
7059 | {USB_DEVICE(0x0458, 0x700f)}, | 6988 | {USB_DEVICE(0x0458, 0x700f)}, |
@@ -7073,8 +7002,8 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
7073 | {USB_DEVICE(0x046d, 0x08af)}, | 7002 | {USB_DEVICE(0x046d, 0x08af)}, |
7074 | {USB_DEVICE(0x046d, 0x08b9)}, | 7003 | {USB_DEVICE(0x046d, 0x08b9)}, |
7075 | {USB_DEVICE(0x046d, 0x08d7)}, | 7004 | {USB_DEVICE(0x046d, 0x08d7)}, |
7076 | {USB_DEVICE(0x046d, 0x08d9)}, | ||
7077 | {USB_DEVICE(0x046d, 0x08d8)}, | 7005 | {USB_DEVICE(0x046d, 0x08d8)}, |
7006 | {USB_DEVICE(0x046d, 0x08d9)}, | ||
7078 | {USB_DEVICE(0x046d, 0x08da)}, | 7007 | {USB_DEVICE(0x046d, 0x08da)}, |
7079 | {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB}, | 7008 | {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB}, |
7080 | {USB_DEVICE(0x0471, 0x0325), .driver_info = SENSOR_PAS106}, | 7009 | {USB_DEVICE(0x0471, 0x0325), .driver_info = SENSOR_PAS106}, |
@@ -7120,18 +7049,12 @@ static struct usb_driver sd_driver = { | |||
7120 | 7049 | ||
7121 | static int __init sd_mod_init(void) | 7050 | static int __init sd_mod_init(void) |
7122 | { | 7051 | { |
7123 | int ret; | 7052 | 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 | } | 7053 | } |
7130 | 7054 | ||
7131 | static void __exit sd_mod_exit(void) | 7055 | static void __exit sd_mod_exit(void) |
7132 | { | 7056 | { |
7133 | usb_deregister(&sd_driver); | 7057 | usb_deregister(&sd_driver); |
7134 | PDEBUG(D_PROBE, "deregistered"); | ||
7135 | } | 7058 | } |
7136 | 7059 | ||
7137 | module_init(sd_mod_init); | 7060 | module_init(sd_mod_init); |