aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-09-05 15:05:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:04:44 -0400
commit1f33de0f8b91b70ccadb44958f09aa5bee7c1a44 (patch)
tree3af617c6e9672536c153f9674c4eb6095784155b /drivers/media/video/gspca
parentf1edeea6c2ec6f2a1362fe53b2f4e8b1c50c4216 (diff)
V4L/DVB: gspca_xirlink_cit: New gspca subdriver replacing v4l1 usbvideo/ibmcam.c
The old usbvideo ibmcam driver needs to be replaced with a v4l2 driver preferably using the gspca webcam framework rather then the old usbvideo framework. This new gspca sub driver sets a first step in that direction. The ibmcam driver supports 4 different model webcams. This new driver (for now) only supports Model 3 cameras, as my test cam is a Model 3 cam, or so I thought. Upon reading: http://www.linux-usb.org/ibmcam/ I learned that the IBM Netcamera Pro I have even though having the same usb id and the same bcd version is different from the Model 3 cameras supported by the ibmcam driver. So this new gscpa subdriver supports Model 3 cameras (untested), and the IBM Netcamera Pro. Currently use with the IBM Netcamera Pro requires a module parameter. I hope to be able to autodetect which is which in the future. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/Kconfig9
-rw-r--r--drivers/media/video/gspca/Makefile2
-rw-r--r--drivers/media/video/gspca/xirlink_cit.c1765
3 files changed, 1776 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig
index 23db0c29f68c..cab7be7eb638 100644
--- a/drivers/media/video/gspca/Kconfig
+++ b/drivers/media/video/gspca/Kconfig
@@ -337,6 +337,15 @@ config USB_GSPCA_VC032X
337 To compile this driver as a module, choose M here: the 337 To compile this driver as a module, choose M here: the
338 module will be called gspca_vc032x. 338 module will be called gspca_vc032x.
339 339
340config USB_GSPCA_XIRLINK_CIT
341 tristate "Xirlink C-It USB Camera Driver"
342 depends on VIDEO_V4L2 && USB_GSPCA
343 help
344 Say Y here if you want support for Xirlink C-It bases cameras.
345
346 To compile this driver as a module, choose M here: the
347 module will be called gspca_xirlink_cit.
348
340config USB_GSPCA_ZC3XX 349config USB_GSPCA_ZC3XX
341 tristate "ZC3XX USB Camera Driver" 350 tristate "ZC3XX USB Camera Driver"
342 depends on VIDEO_V4L2 && USB_GSPCA 351 depends on VIDEO_V4L2 && USB_GSPCA
diff --git a/drivers/media/video/gspca/Makefile b/drivers/media/video/gspca/Makefile
index f6616db0b7f8..ea89ac1bd547 100644
--- a/drivers/media/video/gspca/Makefile
+++ b/drivers/media/video/gspca/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_USB_GSPCA_STV0680) += gspca_stv0680.o
33obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o 33obj-$(CONFIG_USB_GSPCA_T613) += gspca_t613.o
34obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o 34obj-$(CONFIG_USB_GSPCA_TV8532) += gspca_tv8532.o
35obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o 35obj-$(CONFIG_USB_GSPCA_VC032X) += gspca_vc032x.o
36obj-$(CONFIG_USB_GSPCA_XIRLINK_CIT) += gspca_xirlink_cit.o
36obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o 37obj-$(CONFIG_USB_GSPCA_ZC3XX) += gspca_zc3xx.o
37 38
38gspca_main-objs := gspca.o 39gspca_main-objs := gspca.o
@@ -70,6 +71,7 @@ gspca_sunplus-objs := sunplus.o
70gspca_t613-objs := t613.o 71gspca_t613-objs := t613.o
71gspca_tv8532-objs := tv8532.o 72gspca_tv8532-objs := tv8532.o
72gspca_vc032x-objs := vc032x.o 73gspca_vc032x-objs := vc032x.o
74gspca_xirlink_cit-objs := xirlink_cit.o
73gspca_zc3xx-objs := zc3xx.o 75gspca_zc3xx-objs := zc3xx.o
74 76
75obj-$(CONFIG_USB_M5602) += m5602/ 77obj-$(CONFIG_USB_M5602) += m5602/
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c
new file mode 100644
index 000000000000..3525e783f7a2
--- /dev/null
+++ b/drivers/media/video/gspca/xirlink_cit.c
@@ -0,0 +1,1765 @@
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 <hdgoede@redhat.com>
8 *
9 * This driver is based on earlier work of:
10 *
11 * (C) Copyright 1999 Johannes Erdfelt
12 * (C) Copyright 1999 Randy Dunlap
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */
29
30#define MODULE_NAME "xirlink-cit"
31
32#include "gspca.h"
33
34MODULE_AUTHOR("Hans de Goede <hdgoede@redhat.com>");
35MODULE_DESCRIPTION("Xirlink C-IT");
36MODULE_LICENSE("GPL");
37
38/* FIXME we should autodetect this */
39static int ibm_netcam_pro;
40module_param(ibm_netcam_pro, int, 0);
41MODULE_PARM_DESC(ibm_netcam_pro,
42 "Use IBM Netcamera Pro init sequences for Model 3 cams");
43
44/* FIXME this should be handled through the V4L2 input selection API */
45static int rca_input;
46module_param(rca_input, int, 0644);
47MODULE_PARM_DESC(rca_input,
48 "Use rca input instead of ccd sensor on Model 3 cams");
49
50/* specific webcam descriptor */
51struct sd {
52 struct gspca_dev gspca_dev; /* !! must be the first item */
53 u8 model;
54#define CIT_MODEL1 0 /* The model 1 - 4 nomenclature comes from the old */
55#define CIT_MODEL2 1 /* ibmcam driver */
56#define CIT_MODEL3 2
57#define CIT_MODEL4 3
58#define CIT_IBM_NETCAM_PRO 4
59 u8 input_index;
60 u8 sof_read;
61 u8 contrast;
62 u8 brightness;
63 u8 hue;
64 u8 sharpness;
65};
66
67/* V4L2 controls supported by the driver */
68static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
69static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
70static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
71static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
72static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val);
73static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val);
74static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
75static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
76static void sd_stop0(struct gspca_dev *gspca_dev);
77
78static const struct ctrl sd_ctrls[] = {
79#define SD_BRIGHTNESS 0
80 {
81 {
82 .id = V4L2_CID_BRIGHTNESS,
83 .type = V4L2_CTRL_TYPE_INTEGER,
84 .name = "Brightness",
85 .minimum = 0x0c,
86 .maximum = 0x3f,
87 .step = 1,
88#define BRIGHTNESS_DEFAULT 0x20
89 .default_value = BRIGHTNESS_DEFAULT,
90 .flags = 0,
91 },
92 .set = sd_setbrightness,
93 .get = sd_getbrightness,
94 },
95#define SD_CONTRAST 1
96 {
97 {
98 .id = V4L2_CID_CONTRAST,
99 .type = V4L2_CTRL_TYPE_INTEGER,
100 .name = "contrast",
101 .minimum = 0,
102 .maximum = 20,
103 .step = 1,
104#define CONTRAST_DEFAULT 10
105 .default_value = CONTRAST_DEFAULT,
106 .flags = 0,
107 },
108 .set = sd_setcontrast,
109 .get = sd_getcontrast,
110 },
111#define SD_HUE 2
112 {
113 {
114 .id = V4L2_CID_HUE,
115 .type = V4L2_CTRL_TYPE_INTEGER,
116 .name = "Hue",
117 .minimum = 0x05,
118 .maximum = 0x37,
119 .step = 1,
120#define HUE_DEFAULT 0x20
121 .default_value = HUE_DEFAULT,
122 .flags = 0,
123 },
124 .set = sd_sethue,
125 .get = sd_gethue,
126 },
127#define SD_SHARPNESS 3
128 {
129 {
130 .id = V4L2_CID_SHARPNESS,
131 .type = V4L2_CTRL_TYPE_INTEGER,
132 .name = "Sharpness",
133 .minimum = 0,
134 .maximum = 6,
135 .step = 1,
136#define SHARPNESS_DEFAULT 3
137 .default_value = SHARPNESS_DEFAULT,
138 .flags = 0,
139 },
140 .set = sd_setsharpness,
141 .get = sd_getsharpness,
142 },
143};
144
145static const struct v4l2_pix_format vga_yuv_mode[] = {
146 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
147 .bytesperline = 160,
148 .sizeimage = 160 * 120 * 3 / 2,
149 .colorspace = V4L2_COLORSPACE_SRGB},
150 {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
151 .bytesperline = 320,
152 .sizeimage = 320 * 240 * 3 / 2,
153 .colorspace = V4L2_COLORSPACE_SRGB},
154 {640, 480, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE,
155 .bytesperline = 640,
156 .sizeimage = 640 * 480 * 3 / 2,
157 .colorspace = V4L2_COLORSPACE_SRGB},
158};
159
160/*
161 * 01.01.08 - Added for RCA video in support -LO
162 * This struct is used to init the Model3 cam to use the RCA video in port
163 * instead of the CCD sensor.
164 */
165static const u16 rca_initdata[][3] = {
166 {0, 0x0000, 0x010c},
167 {0, 0x0006, 0x012c},
168 {0, 0x0078, 0x012d},
169 {0, 0x0046, 0x012f},
170 {0, 0xd141, 0x0124},
171 {0, 0x0000, 0x0127},
172 {0, 0xfea8, 0x0124},
173 {1, 0x0000, 0x0116},
174 {0, 0x0064, 0x0116},
175 {1, 0x0000, 0x0115},
176 {0, 0x0003, 0x0115},
177 {0, 0x0008, 0x0123},
178 {0, 0x0000, 0x0117},
179 {0, 0x0000, 0x0112},
180 {0, 0x0080, 0x0100},
181 {0, 0x0000, 0x0100},
182 {1, 0x0000, 0x0116},
183 {0, 0x0060, 0x0116},
184 {0, 0x0002, 0x0112},
185 {0, 0x0000, 0x0123},
186 {0, 0x0001, 0x0117},
187 {0, 0x0040, 0x0108},
188 {0, 0x0019, 0x012c},
189 {0, 0x0040, 0x0116},
190 {0, 0x000a, 0x0115},
191 {0, 0x000b, 0x0115},
192 {0, 0x0078, 0x012d},
193 {0, 0x0046, 0x012f},
194 {0, 0xd141, 0x0124},
195 {0, 0x0000, 0x0127},
196 {0, 0xfea8, 0x0124},
197 {0, 0x0064, 0x0116},
198 {0, 0x0000, 0x0115},
199 {0, 0x0001, 0x0115},
200 {0, 0xffff, 0x0124},
201 {0, 0xfff9, 0x0124},
202 {0, 0x0086, 0x0127},
203 {0, 0xfff8, 0x0124},
204 {0, 0xfffd, 0x0124},
205 {0, 0x00aa, 0x0127},
206 {0, 0xfff8, 0x0124},
207 {0, 0xfffd, 0x0124},
208 {0, 0x0000, 0x0127},
209 {0, 0xfff8, 0x0124},
210 {0, 0xfffd, 0x0124},
211 {0, 0xfffa, 0x0124},
212 {0, 0xffff, 0x0124},
213 {0, 0xfff9, 0x0124},
214 {0, 0x0086, 0x0127},
215 {0, 0xfff8, 0x0124},
216 {0, 0xfffd, 0x0124},
217 {0, 0x00f2, 0x0127},
218 {0, 0xfff8, 0x0124},
219 {0, 0xfffd, 0x0124},
220 {0, 0x000f, 0x0127},
221 {0, 0xfff8, 0x0124},
222 {0, 0xfffd, 0x0124},
223 {0, 0xfffa, 0x0124},
224 {0, 0xffff, 0x0124},
225 {0, 0xfff9, 0x0124},
226 {0, 0x0086, 0x0127},
227 {0, 0xfff8, 0x0124},
228 {0, 0xfffd, 0x0124},
229 {0, 0x00f8, 0x0127},
230 {0, 0xfff8, 0x0124},
231 {0, 0xfffd, 0x0124},
232 {0, 0x00fc, 0x0127},
233 {0, 0xfff8, 0x0124},
234 {0, 0xfffd, 0x0124},
235 {0, 0xfffa, 0x0124},
236 {0, 0xffff, 0x0124},
237 {0, 0xfff9, 0x0124},
238 {0, 0x0086, 0x0127},
239 {0, 0xfff8, 0x0124},
240 {0, 0xfffd, 0x0124},
241 {0, 0x00f9, 0x0127},
242 {0, 0xfff8, 0x0124},
243 {0, 0xfffd, 0x0124},
244 {0, 0x003c, 0x0127},
245 {0, 0xfff8, 0x0124},
246 {0, 0xfffd, 0x0124},
247 {0, 0xfffa, 0x0124},
248 {0, 0xffff, 0x0124},
249 {0, 0xfff9, 0x0124},
250 {0, 0x0086, 0x0127},
251 {0, 0xfff8, 0x0124},
252 {0, 0xfffd, 0x0124},
253 {0, 0x0027, 0x0127},
254 {0, 0xfff8, 0x0124},
255 {0, 0xfffd, 0x0124},
256 {0, 0x0019, 0x0127},
257 {0, 0xfff8, 0x0124},
258 {0, 0xfffd, 0x0124},
259 {0, 0xfffa, 0x0124},
260 {0, 0xfff9, 0x0124},
261 {0, 0x0086, 0x0127},
262 {0, 0xfff8, 0x0124},
263 {0, 0xfffd, 0x0124},
264 {0, 0x0037, 0x0127},
265 {0, 0xfff8, 0x0124},
266 {0, 0xfffd, 0x0124},
267 {0, 0x0000, 0x0127},
268 {0, 0xfff8, 0x0124},
269 {0, 0xfffd, 0x0124},
270 {0, 0x0021, 0x0127},
271 {0, 0xfff8, 0x0124},
272 {0, 0xfffd, 0x0124},
273 {0, 0xfffa, 0x0124},
274 {0, 0xfff9, 0x0124},
275 {0, 0x0086, 0x0127},
276 {0, 0xfff8, 0x0124},
277 {0, 0xfffd, 0x0124},
278 {0, 0x0038, 0x0127},
279 {0, 0xfff8, 0x0124},
280 {0, 0xfffd, 0x0124},
281 {0, 0x0006, 0x0127},
282 {0, 0xfff8, 0x0124},
283 {0, 0xfffd, 0x0124},
284 {0, 0x0045, 0x0127},
285 {0, 0xfff8, 0x0124},
286 {0, 0xfffd, 0x0124},
287 {0, 0xfffa, 0x0124},
288 {0, 0xfff9, 0x0124},
289 {0, 0x0086, 0x0127},
290 {0, 0xfff8, 0x0124},
291 {0, 0xfffd, 0x0124},
292 {0, 0x0037, 0x0127},
293 {0, 0xfff8, 0x0124},
294 {0, 0xfffd, 0x0124},
295 {0, 0x0001, 0x0127},
296 {0, 0xfff8, 0x0124},
297 {0, 0xfffd, 0x0124},
298 {0, 0x002a, 0x0127},
299 {0, 0xfff8, 0x0124},
300 {0, 0xfffd, 0x0124},
301 {0, 0xfffa, 0x0124},
302 {0, 0xfff9, 0x0124},
303 {0, 0x0086, 0x0127},
304 {0, 0xfff8, 0x0124},
305 {0, 0xfffd, 0x0124},
306 {0, 0x0038, 0x0127},
307 {0, 0xfff8, 0x0124},
308 {0, 0xfffd, 0x0124},
309 {0, 0x0000, 0x0127},
310 {0, 0xfff8, 0x0124},
311 {0, 0xfffd, 0x0124},
312 {0, 0x000e, 0x0127},
313 {0, 0xfff8, 0x0124},
314 {0, 0xfffd, 0x0124},
315 {0, 0xfffa, 0x0124},
316 {0, 0xfff9, 0x0124},
317 {0, 0x0086, 0x0127},
318 {0, 0xfff8, 0x0124},
319 {0, 0xfffd, 0x0124},
320 {0, 0x0037, 0x0127},
321 {0, 0xfff8, 0x0124},
322 {0, 0xfffd, 0x0124},
323 {0, 0x0001, 0x0127},
324 {0, 0xfff8, 0x0124},
325 {0, 0xfffd, 0x0124},
326 {0, 0x002b, 0x0127},
327 {0, 0xfff8, 0x0124},
328 {0, 0xfffd, 0x0124},
329 {0, 0xfffa, 0x0124},
330 {0, 0xfff9, 0x0124},
331 {0, 0x0086, 0x0127},
332 {0, 0xfff8, 0x0124},
333 {0, 0xfffd, 0x0124},
334 {0, 0x0038, 0x0127},
335 {0, 0xfff8, 0x0124},
336 {0, 0xfffd, 0x0124},
337 {0, 0x0001, 0x0127},
338 {0, 0xfff8, 0x0124},
339 {0, 0xfffd, 0x0124},
340 {0, 0x00f4, 0x0127},
341 {0, 0xfff8, 0x0124},
342 {0, 0xfffd, 0x0124},
343 {0, 0xfffa, 0x0124},
344 {0, 0xfff9, 0x0124},
345 {0, 0x0086, 0x0127},
346 {0, 0xfff8, 0x0124},
347 {0, 0xfffd, 0x0124},
348 {0, 0x0037, 0x0127},
349 {0, 0xfff8, 0x0124},
350 {0, 0xfffd, 0x0124},
351 {0, 0x0001, 0x0127},
352 {0, 0xfff8, 0x0124},
353 {0, 0xfffd, 0x0124},
354 {0, 0x002c, 0x0127},
355 {0, 0xfff8, 0x0124},
356 {0, 0xfffd, 0x0124},
357 {0, 0xfffa, 0x0124},
358 {0, 0xfff9, 0x0124},
359 {0, 0x0086, 0x0127},
360 {0, 0xfff8, 0x0124},
361 {0, 0xfffd, 0x0124},
362 {0, 0x0038, 0x0127},
363 {0, 0xfff8, 0x0124},
364 {0, 0xfffd, 0x0124},
365 {0, 0x0001, 0x0127},
366 {0, 0xfff8, 0x0124},
367 {0, 0xfffd, 0x0124},
368 {0, 0x0004, 0x0127},
369 {0, 0xfff8, 0x0124},
370 {0, 0xfffd, 0x0124},
371 {0, 0xfffa, 0x0124},
372 {0, 0xfff9, 0x0124},
373 {0, 0x0086, 0x0127},
374 {0, 0xfff8, 0x0124},
375 {0, 0xfffd, 0x0124},
376 {0, 0x0037, 0x0127},
377 {0, 0xfff8, 0x0124},
378 {0, 0xfffd, 0x0124},
379 {0, 0x0001, 0x0127},
380 {0, 0xfff8, 0x0124},
381 {0, 0xfffd, 0x0124},
382 {0, 0x002d, 0x0127},
383 {0, 0xfff8, 0x0124},
384 {0, 0xfffd, 0x0124},
385 {0, 0xfffa, 0x0124},
386 {0, 0xfff9, 0x0124},
387 {0, 0x0086, 0x0127},
388 {0, 0xfff8, 0x0124},
389 {0, 0xfffd, 0x0124},
390 {0, 0x0038, 0x0127},
391 {0, 0xfff8, 0x0124},
392 {0, 0xfffd, 0x0124},
393 {0, 0x0000, 0x0127},
394 {0, 0xfff8, 0x0124},
395 {0, 0xfffd, 0x0124},
396 {0, 0x0014, 0x0127},
397 {0, 0xfff8, 0x0124},
398 {0, 0xfffd, 0x0124},
399 {0, 0xfffa, 0x0124},
400 {0, 0xfff9, 0x0124},
401 {0, 0x0086, 0x0127},
402 {0, 0xfff8, 0x0124},
403 {0, 0xfffd, 0x0124},
404 {0, 0x0037, 0x0127},
405 {0, 0xfff8, 0x0124},
406 {0, 0xfffd, 0x0124},
407 {0, 0x0001, 0x0127},
408 {0, 0xfff8, 0x0124},
409 {0, 0xfffd, 0x0124},
410 {0, 0x002e, 0x0127},
411 {0, 0xfff8, 0x0124},
412 {0, 0xfffd, 0x0124},
413 {0, 0xfffa, 0x0124},
414 {0, 0xfff9, 0x0124},
415 {0, 0x0086, 0x0127},
416 {0, 0xfff8, 0x0124},
417 {0, 0xfffd, 0x0124},
418 {0, 0x0038, 0x0127},
419 {0, 0xfff8, 0x0124},
420 {0, 0xfffd, 0x0124},
421 {0, 0x0003, 0x0127},
422 {0, 0xfff8, 0x0124},
423 {0, 0xfffd, 0x0124},
424 {0, 0x0000, 0x0127},
425 {0, 0xfff8, 0x0124},
426 {0, 0xfffd, 0x0124},
427 {0, 0xfffa, 0x0124},
428 {0, 0xfff9, 0x0124},
429 {0, 0x0086, 0x0127},
430 {0, 0xfff8, 0x0124},
431 {0, 0xfffd, 0x0124},
432 {0, 0x0037, 0x0127},
433 {0, 0xfff8, 0x0124},
434 {0, 0xfffd, 0x0124},
435 {0, 0x0001, 0x0127},
436 {0, 0xfff8, 0x0124},
437 {0, 0xfffd, 0x0124},
438 {0, 0x002f, 0x0127},
439 {0, 0xfff8, 0x0124},
440 {0, 0xfffd, 0x0124},
441 {0, 0xfffa, 0x0124},
442 {0, 0xfff9, 0x0124},
443 {0, 0x0086, 0x0127},
444 {0, 0xfff8, 0x0124},
445 {0, 0xfffd, 0x0124},
446 {0, 0x0038, 0x0127},
447 {0, 0xfff8, 0x0124},
448 {0, 0xfffd, 0x0124},
449 {0, 0x0003, 0x0127},
450 {0, 0xfff8, 0x0124},
451 {0, 0xfffd, 0x0124},
452 {0, 0x0014, 0x0127},
453 {0, 0xfff8, 0x0124},
454 {0, 0xfffd, 0x0124},
455 {0, 0xfffa, 0x0124},
456 {0, 0xfff9, 0x0124},
457 {0, 0x0086, 0x0127},
458 {0, 0xfff8, 0x0124},
459 {0, 0xfffd, 0x0124},
460 {0, 0x0037, 0x0127},
461 {0, 0xfff8, 0x0124},
462 {0, 0xfffd, 0x0124},
463 {0, 0x0001, 0x0127},
464 {0, 0xfff8, 0x0124},
465 {0, 0xfffd, 0x0124},
466 {0, 0x0040, 0x0127},
467 {0, 0xfff8, 0x0124},
468 {0, 0xfffd, 0x0124},
469 {0, 0xfffa, 0x0124},
470 {0, 0xfff9, 0x0124},
471 {0, 0x0086, 0x0127},
472 {0, 0xfff8, 0x0124},
473 {0, 0xfffd, 0x0124},
474 {0, 0x0038, 0x0127},
475 {0, 0xfff8, 0x0124},
476 {0, 0xfffd, 0x0124},
477 {0, 0x0000, 0x0127},
478 {0, 0xfff8, 0x0124},
479 {0, 0xfffd, 0x0124},
480 {0, 0x0040, 0x0127},
481 {0, 0xfff8, 0x0124},
482 {0, 0xfffd, 0x0124},
483 {0, 0xfffa, 0x0124},
484 {0, 0xfff9, 0x0124},
485 {0, 0x0086, 0x0127},
486 {0, 0xfff8, 0x0124},
487 {0, 0xfffd, 0x0124},
488 {0, 0x0037, 0x0127},
489 {0, 0xfff8, 0x0124},
490 {0, 0xfffd, 0x0124},
491 {0, 0x0001, 0x0127},
492 {0, 0xfff8, 0x0124},
493 {0, 0xfffd, 0x0124},
494 {0, 0x0053, 0x0127},
495 {0, 0xfff8, 0x0124},
496 {0, 0xfffd, 0x0124},
497 {0, 0xfffa, 0x0124},
498 {0, 0xfff9, 0x0124},
499 {0, 0x0086, 0x0127},
500 {0, 0xfff8, 0x0124},
501 {0, 0xfffd, 0x0124},
502 {0, 0x0038, 0x0127},
503 {0, 0xfff8, 0x0124},
504 {0, 0xfffd, 0x0124},
505 {0, 0x0000, 0x0127},
506 {0, 0xfff8, 0x0124},
507 {0, 0xfffd, 0x0124},
508 {0, 0x0038, 0x0127},
509 {0, 0xfff8, 0x0124},
510 {0, 0xfffd, 0x0124},
511 {0, 0xfffa, 0x0124},
512 {0, 0x0000, 0x0101},
513 {0, 0x00a0, 0x0103},
514 {0, 0x0078, 0x0105},
515 {0, 0x0000, 0x010a},
516 {0, 0x0024, 0x010b},
517 {0, 0x0028, 0x0119},
518 {0, 0x0088, 0x011b},
519 {0, 0x0002, 0x011d},
520 {0, 0x0003, 0x011e},
521 {0, 0x0000, 0x0129},
522 {0, 0x00fc, 0x012b},
523 {0, 0x0008, 0x0102},
524 {0, 0x0000, 0x0104},
525 {0, 0x0008, 0x011a},
526 {0, 0x0028, 0x011c},
527 {0, 0x0021, 0x012a},
528 {0, 0x0000, 0x0118},
529 {0, 0x0000, 0x0132},
530 {0, 0x0000, 0x0109},
531 {0, 0xfff9, 0x0124},
532 {0, 0x0086, 0x0127},
533 {0, 0xfff8, 0x0124},
534 {0, 0xfffd, 0x0124},
535 {0, 0x0037, 0x0127},
536 {0, 0xfff8, 0x0124},
537 {0, 0xfffd, 0x0124},
538 {0, 0x0001, 0x0127},
539 {0, 0xfff8, 0x0124},
540 {0, 0xfffd, 0x0124},
541 {0, 0x0031, 0x0127},
542 {0, 0xfff8, 0x0124},
543 {0, 0xfffd, 0x0124},
544 {0, 0xfffa, 0x0124},
545 {0, 0xfff9, 0x0124},
546 {0, 0x0086, 0x0127},
547 {0, 0xfff8, 0x0124},
548 {0, 0xfffd, 0x0124},
549 {0, 0x0038, 0x0127},
550 {0, 0xfff8, 0x0124},
551 {0, 0xfffd, 0x0124},
552 {0, 0x0000, 0x0127},
553 {0, 0xfff8, 0x0124},
554 {0, 0xfffd, 0x0124},
555 {0, 0x0000, 0x0127},
556 {0, 0xfff8, 0x0124},
557 {0, 0xfffd, 0x0124},
558 {0, 0xfffa, 0x0124},
559 {0, 0xfff9, 0x0124},
560 {0, 0x0086, 0x0127},
561 {0, 0xfff8, 0x0124},
562 {0, 0xfffd, 0x0124},
563 {0, 0x0037, 0x0127},
564 {0, 0xfff8, 0x0124},
565 {0, 0xfffd, 0x0124},
566 {0, 0x0001, 0x0127},
567 {0, 0xfff8, 0x0124},
568 {0, 0xfffd, 0x0124},
569 {0, 0x0040, 0x0127},
570 {0, 0xfff8, 0x0124},
571 {0, 0xfffd, 0x0124},
572 {0, 0xfffa, 0x0124},
573 {0, 0xfff9, 0x0124},
574 {0, 0x0086, 0x0127},
575 {0, 0xfff8, 0x0124},
576 {0, 0xfffd, 0x0124},
577 {0, 0x0038, 0x0127},
578 {0, 0xfff8, 0x0124},
579 {0, 0xfffd, 0x0124},
580 {0, 0x0000, 0x0127},
581 {0, 0xfff8, 0x0124},
582 {0, 0xfffd, 0x0124},
583 {0, 0x0040, 0x0127},
584 {0, 0xfff8, 0x0124},
585 {0, 0xfffd, 0x0124},
586 {0, 0xfffa, 0x0124},
587 {0, 0xfff9, 0x0124},
588 {0, 0x0086, 0x0127},
589 {0, 0xfff8, 0x0124},
590 {0, 0xfffd, 0x0124},
591 {0, 0x0037, 0x0127},
592 {0, 0xfff8, 0x0124},
593 {0, 0xfffd, 0x0124},
594 {0, 0x0000, 0x0127},
595 {0, 0xfff8, 0x0124},
596 {0, 0xfffd, 0x0124},
597 {0, 0x00dc, 0x0127},
598 {0, 0xfff8, 0x0124},
599 {0, 0xfffd, 0x0124},
600 {0, 0xfffa, 0x0124},
601 {0, 0xfff9, 0x0124},
602 {0, 0x0086, 0x0127},
603 {0, 0xfff8, 0x0124},
604 {0, 0xfffd, 0x0124},
605 {0, 0x0038, 0x0127},
606 {0, 0xfff8, 0x0124},
607 {0, 0xfffd, 0x0124},
608 {0, 0x0000, 0x0127},
609 {0, 0xfff8, 0x0124},
610 {0, 0xfffd, 0x0124},
611 {0, 0x0000, 0x0127},
612 {0, 0xfff8, 0x0124},
613 {0, 0xfffd, 0x0124},
614 {0, 0xfffa, 0x0124},
615 {0, 0xfff9, 0x0124},
616 {0, 0x0086, 0x0127},
617 {0, 0xfff8, 0x0124},
618 {0, 0xfffd, 0x0124},
619 {0, 0x0037, 0x0127},
620 {0, 0xfff8, 0x0124},
621 {0, 0xfffd, 0x0124},
622 {0, 0x0001, 0x0127},
623 {0, 0xfff8, 0x0124},
624 {0, 0xfffd, 0x0124},
625 {0, 0x0032, 0x0127},
626 {0, 0xfff8, 0x0124},
627 {0, 0xfffd, 0x0124},
628 {0, 0xfffa, 0x0124},
629 {0, 0xfff9, 0x0124},
630 {0, 0x0086, 0x0127},
631 {0, 0xfff8, 0x0124},
632 {0, 0xfffd, 0x0124},
633 {0, 0x0038, 0x0127},
634 {0, 0xfff8, 0x0124},
635 {0, 0xfffd, 0x0124},
636 {0, 0x0001, 0x0127},
637 {0, 0xfff8, 0x0124},
638 {0, 0xfffd, 0x0124},
639 {0, 0x0020, 0x0127},
640 {0, 0xfff8, 0x0124},
641 {0, 0xfffd, 0x0124},
642 {0, 0xfffa, 0x0124},
643 {0, 0xfff9, 0x0124},
644 {0, 0x0086, 0x0127},
645 {0, 0xfff8, 0x0124},
646 {0, 0xfffd, 0x0124},
647 {0, 0x0037, 0x0127},
648 {0, 0xfff8, 0x0124},
649 {0, 0xfffd, 0x0124},
650 {0, 0x0001, 0x0127},
651 {0, 0xfff8, 0x0124},
652 {0, 0xfffd, 0x0124},
653 {0, 0x0040, 0x0127},
654 {0, 0xfff8, 0x0124},
655 {0, 0xfffd, 0x0124},
656 {0, 0xfffa, 0x0124},
657 {0, 0xfff9, 0x0124},
658 {0, 0x0086, 0x0127},
659 {0, 0xfff8, 0x0124},
660 {0, 0xfffd, 0x0124},
661 {0, 0x0038, 0x0127},
662 {0, 0xfff8, 0x0124},
663 {0, 0xfffd, 0x0124},
664 {0, 0x0000, 0x0127},
665 {0, 0xfff8, 0x0124},
666 {0, 0xfffd, 0x0124},
667 {0, 0x0040, 0x0127},
668 {0, 0xfff8, 0x0124},
669 {0, 0xfffd, 0x0124},
670 {0, 0xfffa, 0x0124},
671 {0, 0xfff9, 0x0124},
672 {0, 0x0086, 0x0127},
673 {0, 0xfff8, 0x0124},
674 {0, 0xfffd, 0x0124},
675 {0, 0x0037, 0x0127},
676 {0, 0xfff8, 0x0124},
677 {0, 0xfffd, 0x0124},
678 {0, 0x0000, 0x0127},
679 {0, 0xfff8, 0x0124},
680 {0, 0xfffd, 0x0124},
681 {0, 0x0030, 0x0127},
682 {0, 0xfff8, 0x0124},
683 {0, 0xfffd, 0x0124},
684 {0, 0xfffa, 0x0124},
685 {0, 0xfff9, 0x0124},
686 {0, 0x0086, 0x0127},
687 {0, 0xfff8, 0x0124},
688 {0, 0xfffd, 0x0124},
689 {0, 0x0038, 0x0127},
690 {0, 0xfff8, 0x0124},
691 {0, 0xfffd, 0x0124},
692 {0, 0x0008, 0x0127},
693 {0, 0xfff8, 0x0124},
694 {0, 0xfffd, 0x0124},
695 {0, 0x0000, 0x0127},
696 {0, 0xfff8, 0x0124},
697 {0, 0xfffd, 0x0124},
698 {0, 0xfffa, 0x0124},
699 {0, 0x0003, 0x0111},
700};
701
702static int cit_write_reg(struct gspca_dev *gspca_dev, u16 value, u16 index)
703{
704 struct usb_device *udev = gspca_dev->dev;
705 int err;
706
707 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00,
708 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
709 value, index, NULL, 0, 1000);
710 if (err < 0)
711 PDEBUG(D_ERR, "Failed to write a register (index 0x%04X,"
712 " value 0x%02X, error %d)", index, value, err);
713
714 return 0;
715}
716
717static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index)
718{
719 struct usb_device *udev = gspca_dev->dev;
720 __u8 *buf = gspca_dev->usb_buf;
721 int res;
722
723 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x01,
724 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
725 0x00, index, buf, 8, 1000);
726 if (res < 0) {
727 PDEBUG(D_ERR,
728 "Failed to read a register (index 0x%04X, error %d)",
729 index, res);
730 return res;
731 }
732
733 PDEBUG(D_PROBE,
734 "Register %04x value: %02x %02x %02x %02x %02x %02x %02x %02x",
735 index,
736 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
737
738 return 0;
739}
740
741/*
742 * ibmcam_model3_Packet1()
743 *
744 * 00_0078_012d
745 * 00_0097_012f
746 * 00_d141_0124
747 * 00_0096_0127
748 * 00_fea8_0124
749*/
750static void cit_model3_Packet1(struct gspca_dev *gspca_dev, u16 v1, u16 v2)
751{
752 cit_write_reg(gspca_dev, 0x0078, 0x012d);
753 cit_write_reg(gspca_dev, v1, 0x012f);
754 cit_write_reg(gspca_dev, 0xd141, 0x0124);
755 cit_write_reg(gspca_dev, v2, 0x0127);
756 cit_write_reg(gspca_dev, 0xfea8, 0x0124);
757}
758
759/* this function is called at probe time */
760static int sd_config(struct gspca_dev *gspca_dev,
761 const struct usb_device_id *id)
762{
763 struct sd *sd = (struct sd *) gspca_dev;
764 struct cam *cam;
765
766 sd->model = id->driver_info;
767 if (sd->model == CIT_MODEL3 && ibm_netcam_pro)
768 sd->model = CIT_IBM_NETCAM_PRO;
769
770 cam = &gspca_dev->cam;
771 switch (sd->model) {
772 case CIT_MODEL3:
773 cam->cam_mode = vga_yuv_mode;
774 cam->nmodes = ARRAY_SIZE(vga_yuv_mode);
775 gspca_dev->ctrl_dis = (1 << SD_HUE);
776 break;
777 case CIT_IBM_NETCAM_PRO:
778 cam->cam_mode = vga_yuv_mode;
779 cam->nmodes = 2; /* no 640 x 480 */
780 cam->input_flags = V4L2_IN_ST_VFLIP;
781 gspca_dev->ctrl_dis = ~(1 << SD_CONTRAST);
782 break;
783 }
784
785 sd->brightness = BRIGHTNESS_DEFAULT;
786 sd->contrast = CONTRAST_DEFAULT;
787 sd->hue = HUE_DEFAULT;
788 sd->sharpness = SHARPNESS_DEFAULT;
789
790 return 0;
791}
792
793static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev)
794{
795 cit_read_reg(gspca_dev, 0x128);
796 cit_write_reg(gspca_dev, 0x0003, 0x0133);
797 cit_write_reg(gspca_dev, 0x0000, 0x0117);
798 cit_write_reg(gspca_dev, 0x0008, 0x0123);
799 cit_write_reg(gspca_dev, 0x0000, 0x0100);
800 cit_read_reg(gspca_dev, 0x0116);
801 cit_write_reg(gspca_dev, 0x0060, 0x0116);
802 cit_write_reg(gspca_dev, 0x0002, 0x0112);
803 cit_write_reg(gspca_dev, 0x0000, 0x0133);
804 cit_write_reg(gspca_dev, 0x0000, 0x0123);
805 cit_write_reg(gspca_dev, 0x0001, 0x0117);
806 cit_write_reg(gspca_dev, 0x0040, 0x0108);
807 cit_write_reg(gspca_dev, 0x0019, 0x012c);
808 cit_write_reg(gspca_dev, 0x0060, 0x0116);
809 cit_write_reg(gspca_dev, 0x0002, 0x0115);
810 cit_write_reg(gspca_dev, 0x000b, 0x0115);
811
812 cit_write_reg(gspca_dev, 0x0078, 0x012d);
813 cit_write_reg(gspca_dev, 0x0001, 0x012f);
814 cit_write_reg(gspca_dev, 0xd141, 0x0124);
815 cit_write_reg(gspca_dev, 0x0079, 0x012d);
816 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
817 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
818 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
819 cit_read_reg(gspca_dev, 0x0126);
820
821 cit_model3_Packet1(gspca_dev, 0x0000, 0x0000);
822 cit_model3_Packet1(gspca_dev, 0x0000, 0x0001);
823 cit_model3_Packet1(gspca_dev, 0x000b, 0x0000);
824 cit_model3_Packet1(gspca_dev, 0x000c, 0x0008);
825 cit_model3_Packet1(gspca_dev, 0x000d, 0x003a);
826 cit_model3_Packet1(gspca_dev, 0x000e, 0x0060);
827 cit_model3_Packet1(gspca_dev, 0x000f, 0x0060);
828 cit_model3_Packet1(gspca_dev, 0x0010, 0x0008);
829 cit_model3_Packet1(gspca_dev, 0x0011, 0x0004);
830 cit_model3_Packet1(gspca_dev, 0x0012, 0x0028);
831 cit_model3_Packet1(gspca_dev, 0x0013, 0x0002);
832 cit_model3_Packet1(gspca_dev, 0x0014, 0x0000);
833 cit_model3_Packet1(gspca_dev, 0x0015, 0x00fb);
834 cit_model3_Packet1(gspca_dev, 0x0016, 0x0002);
835 cit_model3_Packet1(gspca_dev, 0x0017, 0x0037);
836 cit_model3_Packet1(gspca_dev, 0x0018, 0x0036);
837 cit_model3_Packet1(gspca_dev, 0x001e, 0x0000);
838 cit_model3_Packet1(gspca_dev, 0x001f, 0x0008);
839 cit_model3_Packet1(gspca_dev, 0x0020, 0x00c1);
840 cit_model3_Packet1(gspca_dev, 0x0021, 0x0034);
841 cit_model3_Packet1(gspca_dev, 0x0022, 0x0034);
842 cit_model3_Packet1(gspca_dev, 0x0025, 0x0002);
843 cit_model3_Packet1(gspca_dev, 0x0028, 0x0022);
844 cit_model3_Packet1(gspca_dev, 0x0029, 0x000a);
845 cit_model3_Packet1(gspca_dev, 0x002b, 0x0000);
846 cit_model3_Packet1(gspca_dev, 0x002c, 0x0000);
847 cit_model3_Packet1(gspca_dev, 0x002d, 0x00ff);
848 cit_model3_Packet1(gspca_dev, 0x002e, 0x00ff);
849 cit_model3_Packet1(gspca_dev, 0x002f, 0x00ff);
850 cit_model3_Packet1(gspca_dev, 0x0030, 0x00ff);
851 cit_model3_Packet1(gspca_dev, 0x0031, 0x00ff);
852 cit_model3_Packet1(gspca_dev, 0x0032, 0x0007);
853 cit_model3_Packet1(gspca_dev, 0x0033, 0x0005);
854 cit_model3_Packet1(gspca_dev, 0x0037, 0x0040);
855 cit_model3_Packet1(gspca_dev, 0x0039, 0x0000);
856 cit_model3_Packet1(gspca_dev, 0x003a, 0x0000);
857 cit_model3_Packet1(gspca_dev, 0x003b, 0x0001);
858 cit_model3_Packet1(gspca_dev, 0x003c, 0x0000);
859 cit_model3_Packet1(gspca_dev, 0x0040, 0x000c);
860 cit_model3_Packet1(gspca_dev, 0x0041, 0x00fb);
861 cit_model3_Packet1(gspca_dev, 0x0042, 0x0002);
862 cit_model3_Packet1(gspca_dev, 0x0043, 0x0000);
863 cit_model3_Packet1(gspca_dev, 0x0045, 0x0000);
864 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000);
865 cit_model3_Packet1(gspca_dev, 0x0047, 0x0000);
866 cit_model3_Packet1(gspca_dev, 0x0048, 0x0000);
867 cit_model3_Packet1(gspca_dev, 0x0049, 0x0000);
868 cit_model3_Packet1(gspca_dev, 0x004a, 0x00ff);
869 cit_model3_Packet1(gspca_dev, 0x004b, 0x00ff);
870 cit_model3_Packet1(gspca_dev, 0x004c, 0x00ff);
871 cit_model3_Packet1(gspca_dev, 0x004f, 0x0000);
872 cit_model3_Packet1(gspca_dev, 0x0050, 0x0000);
873 cit_model3_Packet1(gspca_dev, 0x0051, 0x0002);
874 cit_model3_Packet1(gspca_dev, 0x0055, 0x0000);
875 cit_model3_Packet1(gspca_dev, 0x0056, 0x0000);
876 cit_model3_Packet1(gspca_dev, 0x0057, 0x0000);
877 cit_model3_Packet1(gspca_dev, 0x0058, 0x0002);
878 cit_model3_Packet1(gspca_dev, 0x0059, 0x0000);
879 cit_model3_Packet1(gspca_dev, 0x005c, 0x0016);
880 cit_model3_Packet1(gspca_dev, 0x005d, 0x0022);
881 cit_model3_Packet1(gspca_dev, 0x005e, 0x003c);
882 cit_model3_Packet1(gspca_dev, 0x005f, 0x0050);
883 cit_model3_Packet1(gspca_dev, 0x0060, 0x0044);
884 cit_model3_Packet1(gspca_dev, 0x0061, 0x0005);
885 cit_model3_Packet1(gspca_dev, 0x006a, 0x007e);
886 cit_model3_Packet1(gspca_dev, 0x006f, 0x0000);
887 cit_model3_Packet1(gspca_dev, 0x0072, 0x001b);
888 cit_model3_Packet1(gspca_dev, 0x0073, 0x0005);
889 cit_model3_Packet1(gspca_dev, 0x0074, 0x000a);
890 cit_model3_Packet1(gspca_dev, 0x0075, 0x001b);
891 cit_model3_Packet1(gspca_dev, 0x0076, 0x002a);
892 cit_model3_Packet1(gspca_dev, 0x0077, 0x003c);
893 cit_model3_Packet1(gspca_dev, 0x0078, 0x0050);
894 cit_model3_Packet1(gspca_dev, 0x007b, 0x0000);
895 cit_model3_Packet1(gspca_dev, 0x007c, 0x0011);
896 cit_model3_Packet1(gspca_dev, 0x007d, 0x0024);
897 cit_model3_Packet1(gspca_dev, 0x007e, 0x0043);
898 cit_model3_Packet1(gspca_dev, 0x007f, 0x005a);
899 cit_model3_Packet1(gspca_dev, 0x0084, 0x0020);
900 cit_model3_Packet1(gspca_dev, 0x0085, 0x0033);
901 cit_model3_Packet1(gspca_dev, 0x0086, 0x000a);
902 cit_model3_Packet1(gspca_dev, 0x0087, 0x0030);
903 cit_model3_Packet1(gspca_dev, 0x0088, 0x0070);
904 cit_model3_Packet1(gspca_dev, 0x008b, 0x0008);
905 cit_model3_Packet1(gspca_dev, 0x008f, 0x0000);
906 cit_model3_Packet1(gspca_dev, 0x0090, 0x0006);
907 cit_model3_Packet1(gspca_dev, 0x0091, 0x0028);
908 cit_model3_Packet1(gspca_dev, 0x0092, 0x005a);
909 cit_model3_Packet1(gspca_dev, 0x0093, 0x0082);
910 cit_model3_Packet1(gspca_dev, 0x0096, 0x0014);
911 cit_model3_Packet1(gspca_dev, 0x0097, 0x0020);
912 cit_model3_Packet1(gspca_dev, 0x0098, 0x0000);
913 cit_model3_Packet1(gspca_dev, 0x00b0, 0x0046);
914 cit_model3_Packet1(gspca_dev, 0x00b1, 0x0000);
915 cit_model3_Packet1(gspca_dev, 0x00b2, 0x0000);
916 cit_model3_Packet1(gspca_dev, 0x00b3, 0x0004);
917 cit_model3_Packet1(gspca_dev, 0x00b4, 0x0007);
918 cit_model3_Packet1(gspca_dev, 0x00b6, 0x0002);
919 cit_model3_Packet1(gspca_dev, 0x00b7, 0x0004);
920 cit_model3_Packet1(gspca_dev, 0x00bb, 0x0000);
921 cit_model3_Packet1(gspca_dev, 0x00bc, 0x0001);
922 cit_model3_Packet1(gspca_dev, 0x00bd, 0x0000);
923 cit_model3_Packet1(gspca_dev, 0x00bf, 0x0000);
924 cit_model3_Packet1(gspca_dev, 0x00c0, 0x00c8);
925 cit_model3_Packet1(gspca_dev, 0x00c1, 0x0014);
926 cit_model3_Packet1(gspca_dev, 0x00c2, 0x0001);
927 cit_model3_Packet1(gspca_dev, 0x00c3, 0x0000);
928 cit_model3_Packet1(gspca_dev, 0x00c4, 0x0004);
929 cit_model3_Packet1(gspca_dev, 0x00cb, 0x00bf);
930 cit_model3_Packet1(gspca_dev, 0x00cc, 0x00bf);
931 cit_model3_Packet1(gspca_dev, 0x00cd, 0x00bf);
932 cit_model3_Packet1(gspca_dev, 0x00ce, 0x0000);
933 cit_model3_Packet1(gspca_dev, 0x00cf, 0x0020);
934 cit_model3_Packet1(gspca_dev, 0x00d0, 0x0040);
935 cit_model3_Packet1(gspca_dev, 0x00d1, 0x00bf);
936 cit_model3_Packet1(gspca_dev, 0x00d1, 0x00bf);
937 cit_model3_Packet1(gspca_dev, 0x00d2, 0x00bf);
938 cit_model3_Packet1(gspca_dev, 0x00d3, 0x00bf);
939 cit_model3_Packet1(gspca_dev, 0x00ea, 0x0008);
940 cit_model3_Packet1(gspca_dev, 0x00eb, 0x0000);
941 cit_model3_Packet1(gspca_dev, 0x00ec, 0x00e8);
942 cit_model3_Packet1(gspca_dev, 0x00ed, 0x0001);
943 cit_model3_Packet1(gspca_dev, 0x00ef, 0x0022);
944 cit_model3_Packet1(gspca_dev, 0x00f0, 0x0000);
945 cit_model3_Packet1(gspca_dev, 0x00f2, 0x0028);
946 cit_model3_Packet1(gspca_dev, 0x00f4, 0x0002);
947 cit_model3_Packet1(gspca_dev, 0x00f5, 0x0000);
948 cit_model3_Packet1(gspca_dev, 0x00fa, 0x0000);
949 cit_model3_Packet1(gspca_dev, 0x00fb, 0x0001);
950 cit_model3_Packet1(gspca_dev, 0x00fc, 0x0000);
951 cit_model3_Packet1(gspca_dev, 0x00fd, 0x0000);
952 cit_model3_Packet1(gspca_dev, 0x00fe, 0x0000);
953 cit_model3_Packet1(gspca_dev, 0x00ff, 0x0000);
954
955 cit_model3_Packet1(gspca_dev, 0x00be, 0x0003);
956 cit_model3_Packet1(gspca_dev, 0x00c8, 0x0000);
957 cit_model3_Packet1(gspca_dev, 0x00c9, 0x0020);
958 cit_model3_Packet1(gspca_dev, 0x00ca, 0x0040);
959 cit_model3_Packet1(gspca_dev, 0x0053, 0x0001);
960 cit_model3_Packet1(gspca_dev, 0x0082, 0x000e);
961 cit_model3_Packet1(gspca_dev, 0x0083, 0x0020);
962 cit_model3_Packet1(gspca_dev, 0x0034, 0x003c);
963 cit_model3_Packet1(gspca_dev, 0x006e, 0x0055);
964 cit_model3_Packet1(gspca_dev, 0x0062, 0x0005);
965 cit_model3_Packet1(gspca_dev, 0x0063, 0x0008);
966 cit_model3_Packet1(gspca_dev, 0x0066, 0x000a);
967 cit_model3_Packet1(gspca_dev, 0x0067, 0x0006);
968 cit_model3_Packet1(gspca_dev, 0x006b, 0x0010);
969 cit_model3_Packet1(gspca_dev, 0x005a, 0x0001);
970 cit_model3_Packet1(gspca_dev, 0x005b, 0x000a);
971 cit_model3_Packet1(gspca_dev, 0x0023, 0x0006);
972 cit_model3_Packet1(gspca_dev, 0x0026, 0x0004);
973 cit_model3_Packet1(gspca_dev, 0x0036, 0x0069);
974 cit_model3_Packet1(gspca_dev, 0x0038, 0x0064);
975 cit_model3_Packet1(gspca_dev, 0x003d, 0x0003);
976 cit_model3_Packet1(gspca_dev, 0x003e, 0x0001);
977 cit_model3_Packet1(gspca_dev, 0x00b8, 0x0014);
978 cit_model3_Packet1(gspca_dev, 0x00b9, 0x0014);
979 cit_model3_Packet1(gspca_dev, 0x00e6, 0x0004);
980 cit_model3_Packet1(gspca_dev, 0x00e8, 0x0001);
981
982 return 0;
983}
984
985/* this function is called at probe and resume time */
986static int sd_init(struct gspca_dev *gspca_dev)
987{
988 struct sd *sd = (struct sd *) gspca_dev;
989
990 switch (sd->model) {
991 case CIT_MODEL3:
992 break; /* All is done in sd_start */
993 case CIT_IBM_NETCAM_PRO:
994 cit_init_ibm_netcam_pro(gspca_dev);
995 sd_stop0(gspca_dev);
996 break;
997 }
998 return 0;
999}
1000
1001static int cit_set_brightness(struct gspca_dev *gspca_dev)
1002{
1003 struct sd *sd = (struct sd *) gspca_dev;
1004
1005 switch (sd->model) {
1006 case CIT_MODEL3:
1007 /* Model 3: Brightness range 'i' in [0x0C..0x3F] */
1008 cit_model3_Packet1(gspca_dev, 0x0036, sd->brightness);
1009 break;
1010 case CIT_IBM_NETCAM_PRO:
1011 /* No (known) brightness control for ibm netcam pro */
1012 break;
1013 }
1014
1015 return 0;
1016}
1017
1018static int cit_set_contrast(struct gspca_dev *gspca_dev)
1019{
1020 struct sd *sd = (struct sd *) gspca_dev;
1021
1022 switch (sd->model) {
1023 case CIT_MODEL3:
1024 { /* Preset hardware values */
1025 static const struct {
1026 unsigned short cv1;
1027 unsigned short cv2;
1028 unsigned short cv3;
1029 } cv[7] = {
1030 { 0x05, 0x05, 0x0f }, /* Minimum */
1031 { 0x04, 0x04, 0x16 },
1032 { 0x02, 0x03, 0x16 },
1033 { 0x02, 0x08, 0x16 },
1034 { 0x01, 0x0c, 0x16 },
1035 { 0x01, 0x0e, 0x16 },
1036 { 0x01, 0x10, 0x16 } /* Maximum */
1037 };
1038 int i = sd->contrast / 3;
1039 cit_model3_Packet1(gspca_dev, 0x0067, cv[i].cv1);
1040 cit_model3_Packet1(gspca_dev, 0x005b, cv[i].cv2);
1041 cit_model3_Packet1(gspca_dev, 0x005c, cv[i].cv3);
1042 break;
1043 }
1044 case CIT_IBM_NETCAM_PRO:
1045 cit_model3_Packet1(gspca_dev, 0x005b, sd->contrast + 1);
1046 break;
1047 }
1048 return 0;
1049}
1050
1051static int cit_set_hue(struct gspca_dev *gspca_dev)
1052{
1053 struct sd *sd = (struct sd *) gspca_dev;
1054
1055 switch (sd->model) {
1056 case CIT_MODEL3:
1057 /* according to the ibmcam driver this does not work 8/
1058 /* cit_model3_Packet1(gspca_dev, 0x007e, sd->hue); */
1059 break;
1060 case CIT_IBM_NETCAM_PRO:
1061 /* No hue control for ibm netcam pro */
1062 break;
1063 }
1064 return 0;
1065}
1066
1067static int cit_set_sharpness(struct gspca_dev *gspca_dev)
1068{
1069 struct sd *sd = (struct sd *) gspca_dev;
1070
1071 switch (sd->model) {
1072 case CIT_MODEL3:
1073 { /*
1074 * "Use a table of magic numbers.
1075 * This setting doesn't really change much.
1076 * But that's how Windows does it."
1077 */
1078 static const struct {
1079 unsigned short sv1;
1080 unsigned short sv2;
1081 unsigned short sv3;
1082 unsigned short sv4;
1083 } sv[7] = {
1084 { 0x00, 0x00, 0x05, 0x14 }, /* Smoothest */
1085 { 0x01, 0x04, 0x05, 0x14 },
1086 { 0x02, 0x04, 0x05, 0x14 },
1087 { 0x03, 0x04, 0x05, 0x14 },
1088 { 0x03, 0x05, 0x05, 0x14 },
1089 { 0x03, 0x06, 0x05, 0x14 },
1090 { 0x03, 0x07, 0x05, 0x14 } /* Sharpest */
1091 };
1092 cit_model3_Packet1(gspca_dev, 0x0060, sv[sd->sharpness].sv1);
1093 cit_model3_Packet1(gspca_dev, 0x0061, sv[sd->sharpness].sv2);
1094 cit_model3_Packet1(gspca_dev, 0x0062, sv[sd->sharpness].sv3);
1095 cit_model3_Packet1(gspca_dev, 0x0063, sv[sd->sharpness].sv4);
1096 break;
1097 }
1098 case CIT_IBM_NETCAM_PRO:
1099 /* No sharpness setting on ibm netcamera pro */
1100 break;
1101 }
1102 return 0;
1103}
1104
1105static int cit_restart_stream(struct gspca_dev *gspca_dev)
1106{
1107 struct sd *sd = (struct sd *) gspca_dev;
1108
1109 switch (sd->model) {
1110 case CIT_MODEL3:
1111 case CIT_IBM_NETCAM_PRO:
1112 cit_write_reg(gspca_dev, 0x0001, 0x0114);
1113 cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */
1114 usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe);
1115 cit_write_reg(gspca_dev, 0x0001, 0x0113);
1116 }
1117
1118 sd->sof_read = 0;
1119
1120 return 0;
1121}
1122
1123static int cit_start_model3(struct gspca_dev *gspca_dev)
1124{
1125 const unsigned short compression = 0; /* 0=none, 7=best frame rate */
1126 int i, clock_div = 0;
1127
1128 /* HDG not in ibmcam driver, added to see if it helps with
1129 auto-detecting between model3 and ibm netcamera pro */
1130 cit_read_reg(gspca_dev, 0x128);
1131
1132 cit_write_reg(gspca_dev, 0x0000, 0x0100);
1133 cit_read_reg(gspca_dev, 0x0116);
1134 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1135 cit_write_reg(gspca_dev, 0x0002, 0x0112);
1136 cit_write_reg(gspca_dev, 0x0000, 0x0123);
1137 cit_write_reg(gspca_dev, 0x0001, 0x0117);
1138 cit_write_reg(gspca_dev, 0x0040, 0x0108);
1139 cit_write_reg(gspca_dev, 0x0019, 0x012c);
1140 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1141 cit_write_reg(gspca_dev, 0x0002, 0x0115);
1142 cit_write_reg(gspca_dev, 0x0003, 0x0115);
1143 cit_read_reg(gspca_dev, 0x0115);
1144 cit_write_reg(gspca_dev, 0x000b, 0x0115);
1145
1146 /* HDG not in ibmcam driver, added to see if it helps with
1147 auto-detecting between model3 and ibm netcamera pro */
1148 if (0) {
1149 cit_write_reg(gspca_dev, 0x0078, 0x012d);
1150 cit_write_reg(gspca_dev, 0x0001, 0x012f);
1151 cit_write_reg(gspca_dev, 0xd141, 0x0124);
1152 cit_write_reg(gspca_dev, 0x0079, 0x012d);
1153 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
1154 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
1155 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
1156 cit_read_reg(gspca_dev, 0x0126);
1157 }
1158
1159 cit_model3_Packet1(gspca_dev, 0x000a, 0x0040);
1160 cit_model3_Packet1(gspca_dev, 0x000b, 0x00f6);
1161 cit_model3_Packet1(gspca_dev, 0x000c, 0x0002);
1162 cit_model3_Packet1(gspca_dev, 0x000d, 0x0020);
1163 cit_model3_Packet1(gspca_dev, 0x000e, 0x0033);
1164 cit_model3_Packet1(gspca_dev, 0x000f, 0x0007);
1165 cit_model3_Packet1(gspca_dev, 0x0010, 0x0000);
1166 cit_model3_Packet1(gspca_dev, 0x0011, 0x0070);
1167 cit_model3_Packet1(gspca_dev, 0x0012, 0x0030);
1168 cit_model3_Packet1(gspca_dev, 0x0013, 0x0000);
1169 cit_model3_Packet1(gspca_dev, 0x0014, 0x0001);
1170 cit_model3_Packet1(gspca_dev, 0x0015, 0x0001);
1171 cit_model3_Packet1(gspca_dev, 0x0016, 0x0001);
1172 cit_model3_Packet1(gspca_dev, 0x0017, 0x0001);
1173 cit_model3_Packet1(gspca_dev, 0x0018, 0x0000);
1174 cit_model3_Packet1(gspca_dev, 0x001e, 0x00c3);
1175 cit_model3_Packet1(gspca_dev, 0x0020, 0x0000);
1176 cit_model3_Packet1(gspca_dev, 0x0028, 0x0010);
1177 cit_model3_Packet1(gspca_dev, 0x0029, 0x0054);
1178 cit_model3_Packet1(gspca_dev, 0x002a, 0x0013);
1179 cit_model3_Packet1(gspca_dev, 0x002b, 0x0007);
1180 cit_model3_Packet1(gspca_dev, 0x002d, 0x0028);
1181 cit_model3_Packet1(gspca_dev, 0x002e, 0x0000);
1182 cit_model3_Packet1(gspca_dev, 0x0031, 0x0000);
1183 cit_model3_Packet1(gspca_dev, 0x0032, 0x0000);
1184 cit_model3_Packet1(gspca_dev, 0x0033, 0x0000);
1185 cit_model3_Packet1(gspca_dev, 0x0034, 0x0000);
1186 cit_model3_Packet1(gspca_dev, 0x0035, 0x0038);
1187 cit_model3_Packet1(gspca_dev, 0x003a, 0x0001);
1188 cit_model3_Packet1(gspca_dev, 0x003c, 0x001e);
1189 cit_model3_Packet1(gspca_dev, 0x003f, 0x000a);
1190 cit_model3_Packet1(gspca_dev, 0x0041, 0x0000);
1191 cit_model3_Packet1(gspca_dev, 0x0046, 0x003f);
1192 cit_model3_Packet1(gspca_dev, 0x0047, 0x0000);
1193 cit_model3_Packet1(gspca_dev, 0x0050, 0x0005);
1194 cit_model3_Packet1(gspca_dev, 0x0052, 0x001a);
1195 cit_model3_Packet1(gspca_dev, 0x0053, 0x0003);
1196 cit_model3_Packet1(gspca_dev, 0x005a, 0x006b);
1197 cit_model3_Packet1(gspca_dev, 0x005d, 0x001e);
1198 cit_model3_Packet1(gspca_dev, 0x005e, 0x0030);
1199 cit_model3_Packet1(gspca_dev, 0x005f, 0x0041);
1200 cit_model3_Packet1(gspca_dev, 0x0064, 0x0008);
1201 cit_model3_Packet1(gspca_dev, 0x0065, 0x0015);
1202 cit_model3_Packet1(gspca_dev, 0x0068, 0x000f);
1203 cit_model3_Packet1(gspca_dev, 0x0079, 0x0000);
1204 cit_model3_Packet1(gspca_dev, 0x007a, 0x0000);
1205 cit_model3_Packet1(gspca_dev, 0x007c, 0x003f);
1206 cit_model3_Packet1(gspca_dev, 0x0082, 0x000f);
1207 cit_model3_Packet1(gspca_dev, 0x0085, 0x0000);
1208 cit_model3_Packet1(gspca_dev, 0x0099, 0x0000);
1209 cit_model3_Packet1(gspca_dev, 0x009b, 0x0023);
1210 cit_model3_Packet1(gspca_dev, 0x009c, 0x0022);
1211 cit_model3_Packet1(gspca_dev, 0x009d, 0x0096);
1212 cit_model3_Packet1(gspca_dev, 0x009e, 0x0096);
1213 cit_model3_Packet1(gspca_dev, 0x009f, 0x000a);
1214
1215 switch (gspca_dev->width) {
1216 case 160:
1217 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
1218 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
1219 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
1220 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
1221 cit_write_reg(gspca_dev, 0x0024, 0x010b); /* Differs everywhere */
1222 cit_write_reg(gspca_dev, 0x00a9, 0x0119);
1223 cit_write_reg(gspca_dev, 0x0016, 0x011b);
1224 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
1225 cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
1226 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
1227 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
1228 cit_write_reg(gspca_dev, 0x0018, 0x0102);
1229 cit_write_reg(gspca_dev, 0x0004, 0x0104);
1230 cit_write_reg(gspca_dev, 0x0004, 0x011a);
1231 cit_write_reg(gspca_dev, 0x0028, 0x011c);
1232 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
1233 cit_write_reg(gspca_dev, 0x0000, 0x0118);
1234 cit_write_reg(gspca_dev, 0x0000, 0x0132);
1235 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
1236 cit_write_reg(gspca_dev, compression, 0x0109);
1237 clock_div = 3;
1238 break;
1239 case 320:
1240 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
1241 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
1242 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
1243 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
1244 cit_write_reg(gspca_dev, 0x0028, 0x010b); /* Differs everywhere */
1245 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same */
1246 cit_write_reg(gspca_dev, 0x0000, 0x011e);
1247 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
1248 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
1249 /* 4 commands from 160x120 skipped */
1250 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
1251 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
1252 cit_write_reg(gspca_dev, compression, 0x0109);
1253 cit_write_reg(gspca_dev, 0x00d9, 0x0119);
1254 cit_write_reg(gspca_dev, 0x0006, 0x011b);
1255 cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
1256 cit_write_reg(gspca_dev, 0x0010, 0x0104);
1257 cit_write_reg(gspca_dev, 0x0004, 0x011a);
1258 cit_write_reg(gspca_dev, 0x003f, 0x011c);
1259 cit_write_reg(gspca_dev, 0x001c, 0x0118);
1260 cit_write_reg(gspca_dev, 0x0000, 0x0132);
1261 clock_div = 5;
1262 break;
1263 case 640:
1264 cit_write_reg(gspca_dev, 0x00f0, 0x0105);
1265 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
1266 cit_write_reg(gspca_dev, 0x0038, 0x010b); /* Differs everywhere */
1267 cit_write_reg(gspca_dev, 0x00d9, 0x0119); /* Same on 320x240, 640x480 */
1268 cit_write_reg(gspca_dev, 0x0006, 0x011b); /* Same on 320x240, 640x480 */
1269 cit_write_reg(gspca_dev, 0x0004, 0x011d); /* NC */
1270 cit_write_reg(gspca_dev, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
1271 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
1272 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
1273 cit_write_reg(gspca_dev, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
1274 cit_write_reg(gspca_dev, 0x0016, 0x0104); /* NC */
1275 cit_write_reg(gspca_dev, 0x0004, 0x011a); /* Same on 320x240, 640x480 */
1276 cit_write_reg(gspca_dev, 0x003f, 0x011c); /* Same on 320x240, 640x480 */
1277 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
1278 cit_write_reg(gspca_dev, 0x001c, 0x0118); /* Same on 320x240, 640x480 */
1279 cit_model3_Packet1(gspca_dev, 0x0021, 0x0001); /* Same */
1280 cit_write_reg(gspca_dev, compression, 0x0109);
1281 cit_write_reg(gspca_dev, 0x0040, 0x0101);
1282 cit_write_reg(gspca_dev, 0x0040, 0x0103);
1283 cit_write_reg(gspca_dev, 0x0000, 0x0132); /* Same on 320x240, 640x480 */
1284 clock_div = 7;
1285 break;
1286 }
1287
1288 cit_model3_Packet1(gspca_dev, 0x007e, 0x000e); /* Hue */
1289 cit_model3_Packet1(gspca_dev, 0x0036, 0x0011); /* Brightness */
1290 cit_model3_Packet1(gspca_dev, 0x0060, 0x0002); /* Sharpness */
1291 cit_model3_Packet1(gspca_dev, 0x0061, 0x0004); /* Sharpness */
1292 cit_model3_Packet1(gspca_dev, 0x0062, 0x0005); /* Sharpness */
1293 cit_model3_Packet1(gspca_dev, 0x0063, 0x0014); /* Sharpness */
1294 cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */
1295 cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */
1296 cit_model3_Packet1(gspca_dev, 0x0067, 0x0001); /* Contrast */
1297 cit_model3_Packet1(gspca_dev, 0x005b, 0x000c); /* Contrast */
1298 cit_model3_Packet1(gspca_dev, 0x005c, 0x0016); /* Contrast */
1299 cit_model3_Packet1(gspca_dev, 0x0098, 0x000b);
1300 cit_model3_Packet1(gspca_dev, 0x002c, 0x0003); /* Was 1, broke 640x480 */
1301 cit_model3_Packet1(gspca_dev, 0x002f, 0x002a);
1302 cit_model3_Packet1(gspca_dev, 0x0030, 0x0029);
1303 cit_model3_Packet1(gspca_dev, 0x0037, 0x0002);
1304 cit_model3_Packet1(gspca_dev, 0x0038, 0x0059);
1305 cit_model3_Packet1(gspca_dev, 0x003d, 0x002e);
1306 cit_model3_Packet1(gspca_dev, 0x003e, 0x0028);
1307 cit_model3_Packet1(gspca_dev, 0x0078, 0x0005);
1308 cit_model3_Packet1(gspca_dev, 0x007b, 0x0011);
1309 cit_model3_Packet1(gspca_dev, 0x007d, 0x004b);
1310 cit_model3_Packet1(gspca_dev, 0x007f, 0x0022);
1311 cit_model3_Packet1(gspca_dev, 0x0080, 0x000c);
1312 cit_model3_Packet1(gspca_dev, 0x0081, 0x000b);
1313 cit_model3_Packet1(gspca_dev, 0x0083, 0x00fd);
1314 cit_model3_Packet1(gspca_dev, 0x0086, 0x000b);
1315 cit_model3_Packet1(gspca_dev, 0x0087, 0x000b);
1316 cit_model3_Packet1(gspca_dev, 0x007e, 0x000e);
1317 cit_model3_Packet1(gspca_dev, 0x0096, 0x00a0); /* Red sharpness */
1318 cit_model3_Packet1(gspca_dev, 0x0097, 0x0096); /* Blue sharpness */
1319 cit_model3_Packet1(gspca_dev, 0x0098, 0x000b);
1320
1321 cit_write_reg(gspca_dev, clock_div, 0x0111); /* Clock Divider */
1322
1323 switch (gspca_dev->width) {
1324 case 160:
1325 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */
1326 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */
1327 cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */
1328 cit_model3_Packet1(gspca_dev, 0x0040, 0x000a);
1329 cit_model3_Packet1(gspca_dev, 0x0051, 0x000a);
1330 break;
1331 case 320:
1332 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */
1333 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */
1334 cit_model3_Packet1(gspca_dev, 0x003b, 0x003c); /* Same */
1335 cit_model3_Packet1(gspca_dev, 0x0040, 0x0008);
1336 cit_model3_Packet1(gspca_dev, 0x0051, 0x000b);
1337 break;
1338 case 640:
1339 cit_model3_Packet1(gspca_dev, 0x001f, 0x0002); /* !Same */
1340 cit_model3_Packet1(gspca_dev, 0x0039, 0x003e); /* !Same */
1341 cit_model3_Packet1(gspca_dev, 0x0040, 0x0008);
1342 cit_model3_Packet1(gspca_dev, 0x0051, 0x000a);
1343 break;
1344 }
1345
1346/* if (sd->input_index) { */
1347 if (rca_input) {
1348 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
1349 if (rca_initdata[i][0])
1350 cit_read_reg(gspca_dev, rca_initdata[i][2]);
1351 else
1352 cit_write_reg(gspca_dev, rca_initdata[i][1],
1353 rca_initdata[i][2]);
1354 }
1355 }
1356
1357 return 0;
1358}
1359
1360static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev)
1361{
1362 const unsigned short compression = 0; /* 0=none, 7=best frame rate */
1363 int i, clock_div = 0;
1364
1365 cit_write_reg(gspca_dev, 0x0003, 0x0133);
1366 cit_write_reg(gspca_dev, 0x0000, 0x0117);
1367 cit_write_reg(gspca_dev, 0x0008, 0x0123);
1368 cit_write_reg(gspca_dev, 0x0000, 0x0100);
1369 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1370 /* cit_write_reg(gspca_dev, 0x0002, 0x0112); see sd_stop0 */
1371 cit_write_reg(gspca_dev, 0x0000, 0x0133);
1372 cit_write_reg(gspca_dev, 0x0000, 0x0123);
1373 cit_write_reg(gspca_dev, 0x0001, 0x0117);
1374 cit_write_reg(gspca_dev, 0x0040, 0x0108);
1375 cit_write_reg(gspca_dev, 0x0019, 0x012c);
1376 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1377 /* cit_write_reg(gspca_dev, 0x000b, 0x0115); see sd_stop0 */
1378
1379 cit_model3_Packet1(gspca_dev, 0x0049, 0x0000);
1380
1381 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
1382 cit_write_reg(gspca_dev, 0x003a, 0x0102); /* Hstart */
1383 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
1384 cit_write_reg(gspca_dev, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
1385 cit_write_reg(gspca_dev, 0x0000, 0x010a); /* Same */
1386 cit_write_reg(gspca_dev, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
1387 cit_write_reg(gspca_dev, 0x0000, 0x0129); /* Same */
1388 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
1389 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
1390
1391 switch (gspca_dev->width) {
1392 case 160:
1393 cit_write_reg(gspca_dev, 0x0024, 0x010b);
1394 cit_write_reg(gspca_dev, 0x0089, 0x0119);
1395 cit_write_reg(gspca_dev, 0x000a, 0x011b);
1396 cit_write_reg(gspca_dev, 0x0003, 0x011e);
1397 cit_write_reg(gspca_dev, 0x0007, 0x0104);
1398 cit_write_reg(gspca_dev, 0x0009, 0x011a);
1399 cit_write_reg(gspca_dev, 0x008b, 0x011c);
1400 cit_write_reg(gspca_dev, 0x0008, 0x0118);
1401 cit_write_reg(gspca_dev, 0x0000, 0x0132);
1402 clock_div = 3;
1403 break;
1404 case 320:
1405 cit_write_reg(gspca_dev, 0x0028, 0x010b);
1406 cit_write_reg(gspca_dev, 0x00d9, 0x0119);
1407 cit_write_reg(gspca_dev, 0x0006, 0x011b);
1408 cit_write_reg(gspca_dev, 0x0000, 0x011e);
1409 cit_write_reg(gspca_dev, 0x000e, 0x0104);
1410 cit_write_reg(gspca_dev, 0x0004, 0x011a);
1411 cit_write_reg(gspca_dev, 0x003f, 0x011c);
1412 cit_write_reg(gspca_dev, 0x000c, 0x0118);
1413 cit_write_reg(gspca_dev, 0x0000, 0x0132);
1414 clock_div = 5;
1415 break;
1416 }
1417
1418 cit_model3_Packet1(gspca_dev, 0x0019, 0x0031);
1419 cit_model3_Packet1(gspca_dev, 0x001a, 0x0003);
1420 cit_model3_Packet1(gspca_dev, 0x001b, 0x0038);
1421 cit_model3_Packet1(gspca_dev, 0x001c, 0x0000);
1422 cit_model3_Packet1(gspca_dev, 0x0024, 0x0001);
1423 cit_model3_Packet1(gspca_dev, 0x0027, 0x0001);
1424 cit_model3_Packet1(gspca_dev, 0x002a, 0x0004);
1425 cit_model3_Packet1(gspca_dev, 0x0035, 0x000b);
1426 cit_model3_Packet1(gspca_dev, 0x003f, 0x0001);
1427 cit_model3_Packet1(gspca_dev, 0x0044, 0x0000);
1428 cit_model3_Packet1(gspca_dev, 0x0054, 0x0000);
1429 cit_model3_Packet1(gspca_dev, 0x00c4, 0x0000);
1430 cit_model3_Packet1(gspca_dev, 0x00e7, 0x0001);
1431 cit_model3_Packet1(gspca_dev, 0x00e9, 0x0001);
1432 cit_model3_Packet1(gspca_dev, 0x00ee, 0x0000);
1433 cit_model3_Packet1(gspca_dev, 0x00f3, 0x00c0);
1434
1435 cit_write_reg(gspca_dev, compression, 0x0109);
1436 cit_write_reg(gspca_dev, clock_div, 0x0111);
1437
1438/* if (sd->input_index) { */
1439 if (rca_input) {
1440 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
1441 if (rca_initdata[i][0])
1442 cit_read_reg(gspca_dev, rca_initdata[i][2]);
1443 else
1444 cit_write_reg(gspca_dev, rca_initdata[i][1],
1445 rca_initdata[i][2]);
1446 }
1447 }
1448
1449 return 0;
1450}
1451
1452/* -- start the camera -- */
1453static int sd_start(struct gspca_dev *gspca_dev)
1454{
1455 struct sd *sd = (struct sd *) gspca_dev;
1456 struct usb_host_interface *alt;
1457 struct usb_interface *intf;
1458 int packet_size;
1459
1460 switch (sd->model) {
1461 case CIT_MODEL3:
1462 cit_start_model3(gspca_dev);
1463 break;
1464 case CIT_IBM_NETCAM_PRO:
1465 cit_start_ibm_netcam_pro(gspca_dev);
1466 break;
1467 }
1468
1469 cit_set_brightness(gspca_dev);
1470 cit_set_contrast(gspca_dev);
1471 cit_set_hue(gspca_dev);
1472 cit_set_sharpness(gspca_dev);
1473
1474 /* Program max isoc packet size, one day we should use this to
1475 allow us to work together with other isoc devices on the same
1476 root hub. */
1477 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
1478 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
1479 if (!alt) {
1480 PDEBUG(D_ERR, "Couldn't get altsetting");
1481 return -EIO;
1482 }
1483
1484 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
1485 cit_write_reg(gspca_dev, packet_size >> 8, 0x0106);
1486 cit_write_reg(gspca_dev, packet_size & 0xff, 0x0107);
1487
1488 cit_restart_stream(gspca_dev);
1489
1490 return 0;
1491}
1492
1493static void sd_stopN(struct gspca_dev *gspca_dev)
1494{
1495 struct sd *sd = (struct sd *) gspca_dev;
1496
1497 switch (sd->model) {
1498 case CIT_MODEL3:
1499 case CIT_IBM_NETCAM_PRO:
1500 cit_write_reg(gspca_dev, 0x0000, 0x010c);
1501 break;
1502 }
1503}
1504
1505static void sd_stop0(struct gspca_dev *gspca_dev)
1506{
1507 struct sd *sd = (struct sd *) gspca_dev;
1508
1509 /* We cannot use gspca_dev->present here as that is not set when
1510 sd_init gets called and we get called from sd_init */
1511 if (!gspca_dev->dev)
1512 return;
1513
1514 switch (sd->model) {
1515 case CIT_MODEL3:
1516 cit_write_reg(gspca_dev, 0x0006, 0x012c);
1517 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000);
1518 cit_read_reg(gspca_dev, 0x0116);
1519 cit_write_reg(gspca_dev, 0x0064, 0x0116);
1520 cit_read_reg(gspca_dev, 0x0115);
1521 cit_write_reg(gspca_dev, 0x0003, 0x0115);
1522 cit_write_reg(gspca_dev, 0x0008, 0x0123);
1523 cit_write_reg(gspca_dev, 0x0000, 0x0117);
1524 cit_write_reg(gspca_dev, 0x0000, 0x0112);
1525 cit_write_reg(gspca_dev, 0x0080, 0x0100);
1526 break;
1527 case CIT_IBM_NETCAM_PRO:
1528 cit_model3_Packet1(gspca_dev, 0x0049, 0x00ff);
1529 cit_write_reg(gspca_dev, 0x0006, 0x012c);
1530 cit_write_reg(gspca_dev, 0x0000, 0x0116);
1531 /* HDG windows does this, but I cannot get the camera
1532 to restart with this without redoing the entire init
1533 sequence which makes switching modes really slow */
1534 /* cit_write_reg(gspca_dev, 0x0006, 0x0115); */
1535 cit_write_reg(gspca_dev, 0x0008, 0x0123);
1536 cit_write_reg(gspca_dev, 0x0000, 0x0117);
1537 cit_write_reg(gspca_dev, 0x0003, 0x0133);
1538 cit_write_reg(gspca_dev, 0x0000, 0x0111);
1539 /* HDG windows does this, but I get a green picture when
1540 restarting the stream after this */
1541 /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */
1542 cit_write_reg(gspca_dev, 0x00c0, 0x0100);
1543 break;
1544 }
1545}
1546
1547static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len)
1548{
1549 struct sd *sd = (struct sd *) gspca_dev;
1550 int i;
1551
1552 switch (sd->model) {
1553 case CIT_MODEL3:
1554 case CIT_IBM_NETCAM_PRO:
1555 for (i = 0; i < len; i++) {
1556 switch (sd->sof_read) {
1557 case 0:
1558 if (data[i] == 0x00)
1559 sd->sof_read++;
1560 break;
1561 case 1:
1562 if (data[i] == 0xff)
1563 sd->sof_read++;
1564 else
1565 sd->sof_read = 0;
1566 break;
1567 case 2:
1568 sd->sof_read = 0;
1569 if (data[i] != 0xff) {
1570 if (i >= 4)
1571 PDEBUG(D_FRAM,
1572 "header found at offset: %d: %02x %02x 00 ff %02x %02x\n",
1573 i - 2,
1574 data[i - 4],
1575 data[i - 3],
1576 data[i],
1577 data[i + 1]);
1578 return data + i + 2;
1579 }
1580 break;
1581 }
1582 }
1583 break;
1584 }
1585 return NULL;
1586}
1587
1588static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1589 u8 *data, int len)
1590{
1591 unsigned char *sof;
1592
1593 sof = cit_find_sof(gspca_dev, data, len);
1594 if (sof) {
1595 int n;
1596
1597 /* finish decoding current frame */
1598 n = sof - data;
1599 if (n > 4)
1600 n -= 4;
1601 else
1602 n = 0;
1603 gspca_frame_add(gspca_dev, LAST_PACKET,
1604 data, n);
1605 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
1606 len -= sof - data;
1607 data = sof;
1608 }
1609
1610 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1611}
1612
1613static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1614{
1615 struct sd *sd = (struct sd *) gspca_dev;
1616
1617 sd->brightness = val;
1618 if (gspca_dev->streaming) {
1619 sd_stopN(gspca_dev);
1620 cit_set_brightness(gspca_dev);
1621 cit_restart_stream(gspca_dev);
1622 }
1623
1624 return 0;
1625}
1626
1627static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1628{
1629 struct sd *sd = (struct sd *) gspca_dev;
1630
1631 *val = sd->brightness;
1632
1633 return 0;
1634}
1635
1636static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1637{
1638 struct sd *sd = (struct sd *) gspca_dev;
1639
1640 sd->contrast = val;
1641 if (gspca_dev->streaming) {
1642 sd_stopN(gspca_dev);
1643 cit_set_contrast(gspca_dev);
1644 cit_restart_stream(gspca_dev);
1645 }
1646
1647 return 0;
1648}
1649
1650static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
1651{
1652 struct sd *sd = (struct sd *) gspca_dev;
1653
1654 *val = sd->contrast;
1655
1656 return 0;
1657}
1658
1659static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val)
1660{
1661 struct sd *sd = (struct sd *) gspca_dev;
1662
1663 sd->hue = val;
1664 if (gspca_dev->streaming) {
1665 sd_stopN(gspca_dev);
1666 cit_set_hue(gspca_dev);
1667 cit_restart_stream(gspca_dev);
1668 }
1669 return 0;
1670}
1671
1672static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val)
1673{
1674 struct sd *sd = (struct sd *) gspca_dev;
1675
1676 *val = sd->hue;
1677
1678 return 0;
1679}
1680
1681static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
1682{
1683 struct sd *sd = (struct sd *) gspca_dev;
1684
1685 sd->sharpness = val;
1686 if (gspca_dev->streaming) {
1687 sd_stopN(gspca_dev);
1688 cit_set_sharpness(gspca_dev);
1689 cit_restart_stream(gspca_dev);
1690 }
1691 return 0;
1692}
1693
1694static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
1695{
1696 struct sd *sd = (struct sd *) gspca_dev;
1697
1698 *val = sd->sharpness;
1699
1700 return 0;
1701}
1702
1703
1704/* sub-driver description */
1705static const struct sd_desc sd_desc = {
1706 .name = MODULE_NAME,
1707 .ctrls = sd_ctrls,
1708 .nctrls = ARRAY_SIZE(sd_ctrls),
1709 .config = sd_config,
1710 .init = sd_init,
1711 .start = sd_start,
1712 .stopN = sd_stopN,
1713 .stop0 = sd_stop0,
1714 .pkt_scan = sd_pkt_scan,
1715};
1716
1717/* -- module initialisation -- */
1718static const __devinitdata struct usb_device_id device_table[] = {
1719 { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info = CIT_MODEL1 },
1720 { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info = CIT_MODEL2 },
1721 { USB_DEVICE_VER(0x0545, 0x8080, 0x0301, 0x0301), .driver_info = CIT_MODEL3 },
1722 { USB_DEVICE_VER(0x0545, 0x8002, 0x030a, 0x030a), .driver_info = CIT_MODEL4 },
1723 { USB_DEVICE_VER(0x0545, 0x800c, 0x030a, 0x030a), .driver_info = CIT_MODEL2 },
1724 { USB_DEVICE_VER(0x0545, 0x800d, 0x030a, 0x030a), .driver_info = CIT_MODEL4 },
1725 {}
1726};
1727MODULE_DEVICE_TABLE(usb, device_table);
1728
1729/* -- device connect -- */
1730static int sd_probe(struct usb_interface *intf,
1731 const struct usb_device_id *id)
1732{
1733 return gspca_dev_probe2(intf, id, &sd_desc, sizeof(struct sd),
1734 THIS_MODULE);
1735}
1736
1737static struct usb_driver sd_driver = {
1738 .name = MODULE_NAME,
1739 .id_table = device_table,
1740 .probe = sd_probe,
1741 .disconnect = gspca_disconnect,
1742#ifdef CONFIG_PM
1743 .suspend = gspca_suspend,
1744 .resume = gspca_resume,
1745#endif
1746};
1747
1748/* -- module insert / remove -- */
1749static int __init sd_mod_init(void)
1750{
1751 int ret;
1752 ret = usb_register(&sd_driver);
1753 if (ret < 0)
1754 return ret;
1755 PDEBUG(D_PROBE, "registered");
1756 return 0;
1757}
1758static void __exit sd_mod_exit(void)
1759{
1760 usb_deregister(&sd_driver);
1761 PDEBUG(D_PROBE, "deregistered");
1762}
1763
1764module_init(sd_mod_init);
1765module_exit(sd_mod_exit);