2 * Sunplus spca504(abc) spca533 spca536 library
3 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define MODULE_NAME "sunplus"
27 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
28 MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver");
29 MODULE_LICENSE("GPL");
31 /* specific webcam descriptor */
33 struct gspca_dev gspca_dev; /* !! must be the first item */
35 __u8 packet[ISO_MAX_SIZE + 128];
36 /* !! no more than 128 ff in an ISO packet */
38 unsigned char brightness;
39 unsigned char contrast;
41 unsigned char autogain;
45 #define BRIDGE_SPCA504 0
46 #define BRIDGE_SPCA504B 1
47 #define BRIDGE_SPCA504C 2
48 #define BRIDGE_SPCA533 3
49 #define BRIDGE_SPCA536 4
51 #define AiptekMiniPenCam13 1
52 #define LogitechClickSmart420 2
53 #define LogitechClickSmart820 3
57 /* V4L2 controls supported by the driver */
58 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
59 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
60 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
61 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
62 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
63 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
64 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
65 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
67 static struct ctrl sd_ctrls[] = {
68 #define SD_BRIGHTNESS 0
71 .id = V4L2_CID_BRIGHTNESS,
72 .type = V4L2_CTRL_TYPE_INTEGER,
79 .set = sd_setbrightness,
80 .get = sd_getbrightness,
85 .id = V4L2_CID_CONTRAST,
86 .type = V4L2_CTRL_TYPE_INTEGER,
91 .default_value = 0x20,
93 .set = sd_setcontrast,
94 .get = sd_getcontrast,
99 .id = V4L2_CID_SATURATION,
100 .type = V4L2_CTRL_TYPE_INTEGER,
105 .default_value = 0x1a,
110 #define SD_AUTOGAIN 3
113 .id = V4L2_CID_AUTOGAIN,
114 .type = V4L2_CTRL_TYPE_BOOLEAN,
121 .set = sd_setautogain,
122 .get = sd_getautogain,
126 static struct v4l2_pix_format vga_mode[] = {
127 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
129 .sizeimage = 320 * 240 * 3 / 8 + 590,
130 .colorspace = V4L2_COLORSPACE_JPEG,
132 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
134 .sizeimage = 640 * 480 * 3 / 8 + 590,
135 .colorspace = V4L2_COLORSPACE_JPEG,
139 static struct v4l2_pix_format custom_mode[] = {
140 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
142 .sizeimage = 320 * 240 * 3 / 8 + 590,
143 .colorspace = V4L2_COLORSPACE_JPEG,
145 {464, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
147 .sizeimage = 464 * 480 * 3 / 8 + 590,
148 .colorspace = V4L2_COLORSPACE_JPEG,
152 static struct v4l2_pix_format vga_mode2[] = {
153 {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
155 .sizeimage = 176 * 144 * 3 / 8 + 590,
156 .colorspace = V4L2_COLORSPACE_JPEG,
158 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
160 .sizeimage = 320 * 240 * 3 / 8 + 590,
161 .colorspace = V4L2_COLORSPACE_JPEG,
163 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
165 .sizeimage = 352 * 288 * 3 / 8 + 590,
166 .colorspace = V4L2_COLORSPACE_JPEG,
168 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
170 .sizeimage = 640 * 480 * 3 / 8 + 590,
171 .colorspace = V4L2_COLORSPACE_JPEG,
175 #define SPCA50X_OFFSET_DATA 10
176 #define SPCA504_PCCAM600_OFFSET_SNAPSHOT 3
177 #define SPCA504_PCCAM600_OFFSET_COMPRESS 4
178 #define SPCA504_PCCAM600_OFFSET_MODE 5
179 #define SPCA504_PCCAM600_OFFSET_DATA 14
180 /* Frame packet header offsets for the spca533 */
181 #define SPCA533_OFFSET_DATA 16
182 #define SPCA533_OFFSET_FRAMSEQ 15
183 /* Frame packet header offsets for the spca536 */
184 #define SPCA536_OFFSET_DATA 4
185 #define SPCA536_OFFSET_FRAMSEQ 1
187 /* Initialisation data for the Creative PC-CAM 600 */
188 static const __u16 spca504_pccam600_init_data[][3] = {
189 /* {0xa0, 0x0000, 0x0503}, * capture mode */
190 {0x00, 0x0000, 0x2000},
191 {0x00, 0x0013, 0x2301},
192 {0x00, 0x0003, 0x2000},
193 {0x00, 0x0001, 0x21ac},
194 {0x00, 0x0001, 0x21a6},
195 {0x00, 0x0000, 0x21a7}, /* brightness */
196 {0x00, 0x0020, 0x21a8}, /* contrast */
197 {0x00, 0x0001, 0x21ac}, /* sat/hue */
198 {0x00, 0x0000, 0x21ad}, /* hue */
199 {0x00, 0x001a, 0x21ae}, /* saturation */
200 {0x00, 0x0002, 0x21a3}, /* gamma */
201 {0x30, 0x0154, 0x0008},
202 {0x30, 0x0004, 0x0006},
203 {0x30, 0x0258, 0x0009},
204 {0x30, 0x0004, 0x0000},
205 {0x30, 0x0093, 0x0004},
206 {0x30, 0x0066, 0x0005},
207 {0x00, 0x0000, 0x2000},
208 {0x00, 0x0013, 0x2301},
209 {0x00, 0x0003, 0x2000},
210 {0x00, 0x0013, 0x2301},
211 {0x00, 0x0003, 0x2000},
215 /* Creative PC-CAM 600 specific open data, sent before using the
216 * generic initialisation data from spca504_open_data.
218 static const __u16 spca504_pccam600_open_data[][3] = {
219 {0x00, 0x0001, 0x2501},
220 {0x20, 0x0500, 0x0001}, /* snapshot mode */
221 {0x00, 0x0003, 0x2880},
222 {0x00, 0x0001, 0x2881},
226 /* Initialisation data for the logitech clicksmart 420 */
227 static const __u16 spca504A_clicksmart420_init_data[][3] = {
228 /* {0xa0, 0x0000, 0x0503}, * capture mode */
229 {0x00, 0x0000, 0x2000},
230 {0x00, 0x0013, 0x2301},
231 {0x00, 0x0003, 0x2000},
232 {0x00, 0x0001, 0x21ac},
233 {0x00, 0x0001, 0x21a6},
234 {0x00, 0x0000, 0x21a7}, /* brightness */
235 {0x00, 0x0020, 0x21a8}, /* contrast */
236 {0x00, 0x0001, 0x21ac}, /* sat/hue */
237 {0x00, 0x0000, 0x21ad}, /* hue */
238 {0x00, 0x001a, 0x21ae}, /* saturation */
239 {0x00, 0x0002, 0x21a3}, /* gamma */
240 {0x30, 0x0004, 0x000a},
241 {0xb0, 0x0001, 0x0000},
244 {0x0a1, 0x0080, 0x0001},
245 {0x30, 0x0049, 0x0000},
246 {0x30, 0x0060, 0x0005},
247 {0x0c, 0x0004, 0x0000},
248 {0x00, 0x0000, 0x0000},
249 {0x00, 0x0000, 0x2000},
250 {0x00, 0x0013, 0x2301},
251 {0x00, 0x0003, 0x2000},
252 {0x00, 0x0000, 0x2000},
257 /* clicksmart 420 open data ? */
258 static const __u16 spca504A_clicksmart420_open_data[][3] = {
259 {0x00, 0x0001, 0x2501},
260 {0x20, 0x0502, 0x0000},
261 {0x06, 0x0000, 0x0000},
262 {0x00, 0x0004, 0x2880},
263 {0x00, 0x0001, 0x2881},
264 /* look like setting a qTable */
265 {0x00, 0x0006, 0x2800},
266 {0x00, 0x0004, 0x2801},
267 {0x00, 0x0004, 0x2802},
268 {0x00, 0x0006, 0x2803},
269 {0x00, 0x000a, 0x2804},
270 {0x00, 0x0010, 0x2805},
271 {0x00, 0x0014, 0x2806},
272 {0x00, 0x0018, 0x2807},
273 {0x00, 0x0005, 0x2808},
274 {0x00, 0x0005, 0x2809},
275 {0x00, 0x0006, 0x280a},
276 {0x00, 0x0008, 0x280b},
277 {0x00, 0x000a, 0x280c},
278 {0x00, 0x0017, 0x280d},
279 {0x00, 0x0018, 0x280e},
280 {0x00, 0x0016, 0x280f},
282 {0x00, 0x0006, 0x2810},
283 {0x00, 0x0005, 0x2811},
284 {0x00, 0x0006, 0x2812},
285 {0x00, 0x000a, 0x2813},
286 {0x00, 0x0010, 0x2814},
287 {0x00, 0x0017, 0x2815},
288 {0x00, 0x001c, 0x2816},
289 {0x00, 0x0016, 0x2817},
290 {0x00, 0x0006, 0x2818},
291 {0x00, 0x0007, 0x2819},
292 {0x00, 0x0009, 0x281a},
293 {0x00, 0x000c, 0x281b},
294 {0x00, 0x0014, 0x281c},
295 {0x00, 0x0023, 0x281d},
296 {0x00, 0x0020, 0x281e},
297 {0x00, 0x0019, 0x281f},
299 {0x00, 0x0007, 0x2820},
300 {0x00, 0x0009, 0x2821},
301 {0x00, 0x000f, 0x2822},
302 {0x00, 0x0016, 0x2823},
303 {0x00, 0x001b, 0x2824},
304 {0x00, 0x002c, 0x2825},
305 {0x00, 0x0029, 0x2826},
306 {0x00, 0x001f, 0x2827},
307 {0x00, 0x000a, 0x2828},
308 {0x00, 0x000e, 0x2829},
309 {0x00, 0x0016, 0x282a},
310 {0x00, 0x001a, 0x282b},
311 {0x00, 0x0020, 0x282c},
312 {0x00, 0x002a, 0x282d},
313 {0x00, 0x002d, 0x282e},
314 {0x00, 0x0025, 0x282f},
316 {0x00, 0x0014, 0x2830},
317 {0x00, 0x001a, 0x2831},
318 {0x00, 0x001f, 0x2832},
319 {0x00, 0x0023, 0x2833},
320 {0x00, 0x0029, 0x2834},
321 {0x00, 0x0030, 0x2835},
322 {0x00, 0x0030, 0x2836},
323 {0x00, 0x0028, 0x2837},
324 {0x00, 0x001d, 0x2838},
325 {0x00, 0x0025, 0x2839},
326 {0x00, 0x0026, 0x283a},
327 {0x00, 0x0027, 0x283b},
328 {0x00, 0x002d, 0x283c},
329 {0x00, 0x0028, 0x283d},
330 {0x00, 0x0029, 0x283e},
331 {0x00, 0x0028, 0x283f},
333 {0x00, 0x0007, 0x2840},
334 {0x00, 0x0007, 0x2841},
335 {0x00, 0x000a, 0x2842},
336 {0x00, 0x0013, 0x2843},
337 {0x00, 0x0028, 0x2844},
338 {0x00, 0x0028, 0x2845},
339 {0x00, 0x0028, 0x2846},
340 {0x00, 0x0028, 0x2847},
341 {0x00, 0x0007, 0x2848},
342 {0x00, 0x0008, 0x2849},
343 {0x00, 0x000a, 0x284a},
344 {0x00, 0x001a, 0x284b},
345 {0x00, 0x0028, 0x284c},
346 {0x00, 0x0028, 0x284d},
347 {0x00, 0x0028, 0x284e},
348 {0x00, 0x0028, 0x284f},
350 {0x00, 0x000a, 0x2850},
351 {0x00, 0x000a, 0x2851},
352 {0x00, 0x0016, 0x2852},
353 {0x00, 0x0028, 0x2853},
354 {0x00, 0x0028, 0x2854},
355 {0x00, 0x0028, 0x2855},
356 {0x00, 0x0028, 0x2856},
357 {0x00, 0x0028, 0x2857},
358 {0x00, 0x0013, 0x2858},
359 {0x00, 0x001a, 0x2859},
360 {0x00, 0x0028, 0x285a},
361 {0x00, 0x0028, 0x285b},
362 {0x00, 0x0028, 0x285c},
363 {0x00, 0x0028, 0x285d},
364 {0x00, 0x0028, 0x285e},
365 {0x00, 0x0028, 0x285f},
367 {0x00, 0x0028, 0x2860},
368 {0x00, 0x0028, 0x2861},
369 {0x00, 0x0028, 0x2862},
370 {0x00, 0x0028, 0x2863},
371 {0x00, 0x0028, 0x2864},
372 {0x00, 0x0028, 0x2865},
373 {0x00, 0x0028, 0x2866},
374 {0x00, 0x0028, 0x2867},
375 {0x00, 0x0028, 0x2868},
376 {0x00, 0x0028, 0x2869},
377 {0x00, 0x0028, 0x286a},
378 {0x00, 0x0028, 0x286b},
379 {0x00, 0x0028, 0x286c},
380 {0x00, 0x0028, 0x286d},
381 {0x00, 0x0028, 0x286e},
382 {0x00, 0x0028, 0x286f},
384 {0x00, 0x0028, 0x2870},
385 {0x00, 0x0028, 0x2871},
386 {0x00, 0x0028, 0x2872},
387 {0x00, 0x0028, 0x2873},
388 {0x00, 0x0028, 0x2874},
389 {0x00, 0x0028, 0x2875},
390 {0x00, 0x0028, 0x2876},
391 {0x00, 0x0028, 0x2877},
392 {0x00, 0x0028, 0x2878},
393 {0x00, 0x0028, 0x2879},
394 {0x00, 0x0028, 0x287a},
395 {0x00, 0x0028, 0x287b},
396 {0x00, 0x0028, 0x287c},
397 {0x00, 0x0028, 0x287d},
398 {0x00, 0x0028, 0x287e},
399 {0x00, 0x0028, 0x287f},
401 {0xa0, 0x0000, 0x0503},
405 static const __u8 qtable_creative_pccam[2][64] = {
406 { /* Q-table Y-components */
407 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
408 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
409 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
410 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
411 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
412 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
413 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
414 0x16, 0x1c, 0x1d, 0x1d, 0x22, 0x1e, 0x1f, 0x1e},
415 { /* Q-table C-components */
416 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
417 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
418 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
419 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
420 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
421 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
422 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
423 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
426 /* FIXME: This Q-table is identical to the Creative PC-CAM one,
427 * except for one byte. Possibly a typo?
430 static const __u8 qtable_spca504_default[2][64] = {
431 { /* Q-table Y-components */
432 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
433 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
434 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
435 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
436 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
437 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
438 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
439 0x16, 0x1c, 0x1d, 0x1d, 0x1d /* 0x22 */ , 0x1e, 0x1f, 0x1e,
441 { /* Q-table C-components */
442 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
443 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
444 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
445 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
446 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
447 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
448 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
449 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
452 static void reg_r(struct usb_device *dev,
455 __u8 *buffer, __u16 length)
458 usb_rcvctrlpipe(dev, 0),
460 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
462 index, buffer, length,
466 static void reg_w(struct usb_device *dev,
470 __u8 *buffer, __u16 length)
473 usb_sndctrlpipe(dev, 0),
475 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
476 value, index, buffer, length,
480 /* write req / index / value */
481 static int reg_w_riv(struct usb_device *dev,
482 __u16 req, __u16 index, __u16 value)
486 ret = usb_control_msg(dev,
487 usb_sndctrlpipe(dev, 0),
489 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
490 value, index, NULL, 0, 500);
491 PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d",
492 req, index, value, ret);
494 PDEBUG(D_ERR, "reg write: error %d", ret);
499 static int reg_r_1(struct gspca_dev *gspca_dev,
500 __u16 value) /* wValue */
504 ret = usb_control_msg(gspca_dev->dev,
505 usb_rcvctrlpipe(gspca_dev->dev, 0),
507 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
510 gspca_dev->usb_buf, 1,
513 PDEBUG(D_ERR, "reg_r_1 err %d", ret);
516 return gspca_dev->usb_buf[0];
519 /* read 1 or 2 bytes - returns < 0 if error */
520 static int reg_r_12(struct gspca_dev *gspca_dev,
521 __u16 req, /* bRequest */
522 __u16 index, /* wIndex */
523 __u16 length) /* wLength (1 or 2 only) */
527 gspca_dev->usb_buf[1] = 0;
528 ret = usb_control_msg(gspca_dev->dev,
529 usb_rcvctrlpipe(gspca_dev->dev, 0),
531 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
534 gspca_dev->usb_buf, length,
537 PDEBUG(D_ERR, "reg_read err %d", ret);
540 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
543 static int write_vector(struct gspca_dev *gspca_dev,
544 const __u16 data[][3])
546 struct usb_device *dev = gspca_dev->dev;
549 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
550 ret = reg_w_riv(dev, data[i][0], data[i][2], data[i][1]);
553 "Register write failed for 0x%x,0x%x,0x%x",
554 data[i][0], data[i][1], data[i][2]);
562 static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
563 unsigned int request,
566 const __u8 qtable[2][64])
568 struct usb_device *dev = gspca_dev->dev;
571 /* loop over y components */
572 for (i = 0; i < 64; i++) {
573 err = reg_w_riv(dev, request, ybase + i, qtable[0][i]);
578 /* loop over c components */
579 for (i = 0; i < 64; i++) {
580 err = reg_w_riv(dev, request, cbase + i, qtable[1][i]);
587 static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
588 __u16 req, __u16 idx, __u16 val)
590 struct usb_device *dev = gspca_dev->dev;
593 reg_w_riv(dev, req, idx, val);
594 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
595 reg_w_riv(dev, req, idx, val);
597 PDEBUG(D_FRAM, "before wait 0x%x", notdone);
600 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
601 PDEBUG(D_FRAM, "after wait 0x%x", notdone);
604 static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
606 __u16 idx, __u16 val, __u8 stat, __u8 count)
608 struct usb_device *dev = gspca_dev->dev;
612 reg_w_riv(dev, req, idx, val);
613 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
615 PDEBUG(D_FRAM, "Status 0x%x Need 0x%x", status, stat);
619 while (--count > 0) {
621 /* gsmart mini2 write a each wait setting 1 ms is enought */
622 /* reg_w_riv(dev, req, idx, val); */
623 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
624 if (status == endcode) {
625 PDEBUG(D_FRAM, "status 0x%x after wait 0x%x",
626 status, 200 - count);
632 static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
636 while (--count > 0) {
637 reg_r(gspca_dev->dev, 0x21, 0, gspca_dev->usb_buf, 1);
638 if ((gspca_dev->usb_buf[0] & 0x01) == 0)
642 return gspca_dev->usb_buf[0];
645 static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
647 struct usb_device *dev = gspca_dev->dev;
650 while (--count > 0) {
651 reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1);
652 if (gspca_dev->usb_buf[0] != 0) {
653 gspca_dev->usb_buf[0] = 0;
654 reg_w(dev, 0x21, 0, 1, gspca_dev->usb_buf, 1);
655 reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1);
656 spca504B_PollingDataReady(gspca_dev);
663 static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
665 struct usb_device *dev = gspca_dev->dev;
668 data = kmalloc(64, GFP_KERNEL);
669 reg_r(dev, 0x20, 0, data, 5);
670 PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ",
671 data[0], data[1], data[2], data[3], data[4]);
672 reg_r(dev, 0x23, 0, data, 64);
673 reg_r(dev, 0x23, 1, data, 64);
677 static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
679 struct sd *sd = (struct sd *) gspca_dev;
680 struct usb_device *dev = gspca_dev->dev;
685 Size = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
687 switch (sd->bridge) {
689 reg_w(dev, 0x31, 0, 0, NULL, 0);
690 spca504B_WaitCmdStatus(gspca_dev);
691 rc = spca504B_PollingDataReady(gspca_dev);
692 spca50x_GetFirmware(gspca_dev);
693 gspca_dev->usb_buf[0] = 2; /* type */
694 reg_w(dev, 0x24, 0, 8, gspca_dev->usb_buf, 1);
695 reg_r(dev, 0x24, 8, gspca_dev->usb_buf, 1);
697 gspca_dev->usb_buf[0] = Size;
698 reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1);
699 reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */
700 rc = spca504B_PollingDataReady(gspca_dev);
702 /* Init the cam width height with some values get on init ? */
703 reg_w(dev, 0x31, 0, 4, NULL, 0);
704 spca504B_WaitCmdStatus(gspca_dev);
705 rc = spca504B_PollingDataReady(gspca_dev);
708 /* case BRIDGE_SPCA504B: */
709 /* case BRIDGE_SPCA536: */
710 gspca_dev->usb_buf[0] = Size;
711 reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1);
712 reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */
714 gspca_dev->usb_buf[0] = Type;
715 reg_w(dev, 0x27, 0, 0, gspca_dev->usb_buf, 1);
716 reg_r(dev, 0x27, 0, gspca_dev->usb_buf, 1); /* type */
717 rc = spca504B_PollingDataReady(gspca_dev);
721 if (sd->subtype == AiptekMiniPenCam13) {
722 /* spca504a aiptek */
723 spca504A_acknowledged_command(gspca_dev,
725 0x80 | (Size & 0x0f), 1);
726 spca504A_acknowledged_command(gspca_dev,
729 spca504_acknowledged_command(gspca_dev, 0x08, Size, 0);
732 case BRIDGE_SPCA504C:
734 reg_w_riv(dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
735 reg_w_riv(dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
740 static void spca504_wait_status(struct gspca_dev *gspca_dev)
746 /* With this we get the status, when return 0 it's all ok */
747 if (reg_r_12(gspca_dev, 0x06, 0x00, 1) == 0)
753 static void spca504B_setQtable(struct gspca_dev *gspca_dev)
755 struct usb_device *dev = gspca_dev->dev;
757 gspca_dev->usb_buf[0] = 3;
758 reg_w(dev, 0x26, 0, 0, gspca_dev->usb_buf, 1);
759 reg_r(dev, 0x26, 0, gspca_dev->usb_buf, 1);
760 spca504B_PollingDataReady(gspca_dev);
763 static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
765 struct sd *sd = (struct sd *) gspca_dev;
766 struct usb_device *dev = gspca_dev->dev;
769 switch (sd->bridge) {
771 case BRIDGE_SPCA504C:
775 /* case BRIDGE_SPCA533: */
776 /* case BRIDGE_SPCA504B: */
777 reg_w(dev, 0, 0, 0x21a7, NULL, 0); /* brightness */
778 reg_w(dev, 0, 0x20, 0x21a8, NULL, 0); /* contrast */
779 reg_w(dev, 0, 0, 0x21ad, NULL, 0); /* hue */
780 reg_w(dev, 0, 1, 0x21ac, NULL, 0); /* sat/hue */
781 reg_w(dev, 0, 0x20, 0x21ae, NULL, 0); /* saturation */
782 reg_w(dev, 0, 0, 0x21a3, NULL, 0); /* gamma */
785 reg_w(dev, 0, 0, 0x20f0, NULL, 0);
786 reg_w(dev, 0, 0x21, 0x20f1, NULL, 0);
787 reg_w(dev, 0, 0x40, 0x20f5, NULL, 0);
788 reg_w(dev, 0, 1, 0x20f4, NULL, 0);
789 reg_w(dev, 0, 0x40, 0x20f6, NULL, 0);
790 reg_w(dev, 0, 0, 0x2089, NULL, 0);
794 spca504B_PollingDataReady(gspca_dev);
797 /* this function is called at probe time */
798 static int sd_config(struct gspca_dev *gspca_dev,
799 const struct usb_device_id *id)
801 struct sd *sd = (struct sd *) gspca_dev;
802 struct usb_device *dev = gspca_dev->dev;
805 cam = &gspca_dev->cam;
808 sd->bridge = id->driver_info >> 8;
809 sd->subtype = id->driver_info;
811 if (sd->subtype == AiptekMiniPenCam13) {
812 /* try to get the firmware as some cam answer 2.0.1.2.2
813 * and should be a spca504b then overwrite that setting */
814 reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1);
815 switch (gspca_dev->usb_buf[0]) {
817 break; /* (right bridge/subtype) */
819 sd->bridge = BRIDGE_SPCA504B;
827 switch (sd->bridge) {
829 /* case BRIDGE_SPCA504B: */
830 /* case BRIDGE_SPCA504: */
831 /* case BRIDGE_SPCA536: */
832 cam->cam_mode = vga_mode;
833 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
836 cam->cam_mode = custom_mode;
837 cam->nmodes = sizeof custom_mode / sizeof custom_mode[0];
839 case BRIDGE_SPCA504C:
840 cam->cam_mode = vga_mode2;
841 cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0];
844 sd->qindex = 5; /* set the quantization table */
845 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
846 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
847 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
851 /* this function is called at open time */
852 static int sd_open(struct gspca_dev *gspca_dev)
854 struct sd *sd = (struct sd *) gspca_dev;
855 struct usb_device *dev = gspca_dev->dev;
861 switch (sd->bridge) {
862 case BRIDGE_SPCA504B:
863 reg_w(dev, 0x1d, 0, 0, NULL, 0);
864 reg_w(dev, 0, 1, 0x2306, NULL, 0);
865 reg_w(dev, 0, 0, 0x0d04, NULL, 0);
866 reg_w(dev, 0, 0, 0x2000, NULL, 0);
867 reg_w(dev, 0, 0x13, 0x2301, NULL, 0);
868 reg_w(dev, 0, 0, 0x2306, NULL, 0);
871 rc = spca504B_PollingDataReady(gspca_dev);
872 spca50x_GetFirmware(gspca_dev);
875 spca50x_GetFirmware(gspca_dev);
876 reg_r(dev, 0x00, 0x5002, gspca_dev->usb_buf, 1);
877 gspca_dev->usb_buf[0] = 0;
878 reg_w(dev, 0x24, 0, 0, gspca_dev->usb_buf, 1);
879 reg_r(dev, 0x24, 0, gspca_dev->usb_buf, 1);
880 rc = spca504B_PollingDataReady(gspca_dev);
881 reg_w(dev, 0x34, 0, 0, NULL, 0);
882 spca504B_WaitCmdStatus(gspca_dev);
884 case BRIDGE_SPCA504C: /* pccam600 */
885 PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
886 reg_w_riv(dev, 0xe0, 0x0000, 0x0000);
887 reg_w_riv(dev, 0xe0, 0x0000, 0x0001); /* reset */
888 spca504_wait_status(gspca_dev);
889 if (sd->subtype == LogitechClickSmart420)
890 write_vector(gspca_dev,
891 spca504A_clicksmart420_open_data);
893 write_vector(gspca_dev, spca504_pccam600_open_data);
894 err_code = spca50x_setup_qtable(gspca_dev,
896 0x2840, qtable_creative_pccam);
898 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
903 /* case BRIDGE_SPCA504: */
904 PDEBUG(D_STREAM, "Opening SPCA504");
905 if (sd->subtype == AiptekMiniPenCam13) {
906 /*****************************/
907 for (i = 0; i < 6; i++)
908 info[i] = reg_r_1(gspca_dev, i);
910 "Read info: %d %d %d %d %d %d."
911 " Should be 1,0,2,2,0,0",
912 info[0], info[1], info[2],
913 info[3], info[4], info[5]);
914 /* spca504a aiptek */
915 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
916 spca504A_acknowledged_command(gspca_dev, 0x24,
918 /* Twice sequencial need status 0xff->0x9e->0x9d */
919 spca504A_acknowledged_command(gspca_dev, 0x24,
922 spca504A_acknowledged_command(gspca_dev, 0x24,
924 /******************************/
925 /* spca504a aiptek */
926 spca504A_acknowledged_command(gspca_dev, 0x08,
928 /* reg_write (dev, 0, 0x2000, 0); */
929 /* reg_write (dev, 0, 0x2883, 1); */
930 /* spca504A_acknowledged_command (gspca_dev, 0x08,
932 /* spca504A_acknowledged_command (gspca_dev, 0x24,
934 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
935 reg_w_riv(dev, 0x0, 0x2310, 0x05);
936 spca504A_acknowledged_command(gspca_dev, 0x01,
940 reg_w_riv(dev, 0, 0x2000, 0);
941 reg_w_riv(dev, 0, 0x2883, 1);
942 err_code = spca50x_setup_qtable(gspca_dev,
945 qtable_spca504_default);
947 PDEBUG(D_ERR, "spca50x_setup_qtable failed");
955 static void sd_start(struct gspca_dev *gspca_dev)
957 struct sd *sd = (struct sd *) gspca_dev;
958 struct usb_device *dev = gspca_dev->dev;
964 if (sd->bridge == BRIDGE_SPCA504B)
965 spca504B_setQtable(gspca_dev);
966 spca504B_SetSizeType(gspca_dev);
967 switch (sd->bridge) {
969 /* case BRIDGE_SPCA504B: */
970 /* case BRIDGE_SPCA533: */
971 /* case BRIDGE_SPCA536: */
972 if (sd->subtype == MegapixV4 ||
973 sd->subtype == LogitechClickSmart820) {
974 reg_w(dev, 0xf0, 0, 0, NULL, 0);
975 spca504B_WaitCmdStatus(gspca_dev);
976 reg_r(dev, 0xf0, 4, NULL, 0);
977 spca504B_WaitCmdStatus(gspca_dev);
979 reg_w(dev, 0x31, 0, 4, NULL, 0);
980 spca504B_WaitCmdStatus(gspca_dev);
981 rc = spca504B_PollingDataReady(gspca_dev);
985 if (sd->subtype == AiptekMiniPenCam13) {
986 for (i = 0; i < 6; i++)
987 info[i] = reg_r_1(gspca_dev, i);
989 "Read info: %d %d %d %d %d %d."
990 " Should be 1,0,2,2,0,0",
991 info[0], info[1], info[2],
992 info[3], info[4], info[5]);
993 /* spca504a aiptek */
994 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
995 spca504A_acknowledged_command(gspca_dev, 0x24,
997 /* Twice sequencial need status 0xff->0x9e->0x9d */
998 spca504A_acknowledged_command(gspca_dev, 0x24,
1000 spca504A_acknowledged_command(gspca_dev, 0x24,
1003 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
1004 for (i = 0; i < 6; i++)
1005 info[i] = reg_r_1(gspca_dev, i);
1007 "Read info: %d %d %d %d %d %d."
1008 " Should be 1,0,2,2,0,0",
1009 info[0], info[1], info[2],
1010 info[3], info[4], info[5]);
1011 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
1012 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1014 spca504B_SetSizeType(gspca_dev);
1015 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */
1016 reg_w_riv(dev, 0x0, 0x2310, 0x05);
1018 case BRIDGE_SPCA504C:
1019 if (sd->subtype == LogitechClickSmart420) {
1020 write_vector(gspca_dev,
1021 spca504A_clicksmart420_init_data);
1023 write_vector(gspca_dev, spca504_pccam600_init_data);
1025 enable = (sd->autogain ? 0x04 : 0x01);
1026 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */
1027 reg_w_riv(dev, 0xb0, 0x0000, enable); /* auto whiteness */
1029 /* set default exposure compensation and whiteness balance */
1030 reg_w_riv(dev, 0x30, 0x0001, 800); /* ~ 20 fps */
1031 reg_w_riv(dev, 0x30, 0x0002, 1600);
1032 spca504B_SetSizeType(gspca_dev);
1035 sp5xx_initContBrigHueRegisters(gspca_dev);
1038 static void sd_stopN(struct gspca_dev *gspca_dev)
1040 struct sd *sd = (struct sd *) gspca_dev;
1041 struct usb_device *dev = gspca_dev->dev;
1043 switch (sd->bridge) {
1045 /* case BRIDGE_SPCA533: */
1046 /* case BRIDGE_SPCA536: */
1047 /* case BRIDGE_SPCA504B: */
1048 reg_w(dev, 0x31, 0, 0, NULL, 0);
1049 spca504B_WaitCmdStatus(gspca_dev);
1050 spca504B_PollingDataReady(gspca_dev);
1052 case BRIDGE_SPCA504:
1053 case BRIDGE_SPCA504C:
1054 reg_w_riv(dev, 0x00, 0x2000, 0x0000);
1056 if (sd->subtype == AiptekMiniPenCam13) {
1057 /* spca504a aiptek */
1058 /* spca504A_acknowledged_command(gspca_dev, 0x08,
1060 spca504A_acknowledged_command(gspca_dev, 0x24,
1061 0x00, 0x00, 0x9d, 1);
1062 spca504A_acknowledged_command(gspca_dev, 0x01,
1063 0x0f, 0x00, 0xff, 1);
1065 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1066 reg_w_riv(dev, 0x01, 0x000f, 0x00);
1072 static void sd_stop0(struct gspca_dev *gspca_dev)
1076 static void sd_close(struct gspca_dev *gspca_dev)
1080 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1081 struct gspca_frame *frame, /* target */
1082 __u8 *data, /* isoc packet */
1083 int len) /* iso packet length */
1085 struct sd *sd = (struct sd *) gspca_dev;
1087 unsigned char *s, *d;
1088 static unsigned char ffd9[] = {0xff, 0xd9};
1090 /* frames are jpeg 4.1.1 without 0xff escape */
1091 switch (sd->bridge) {
1092 case BRIDGE_SPCA533:
1093 if (data[0] == 0xff) {
1094 if (data[1] != 0x01) { /* drop packet */
1095 /* gspca_dev->last_packet_type = DISCARD_PACKET; */
1099 data += SPCA533_OFFSET_DATA;
1100 len -= SPCA533_OFFSET_DATA;
1106 case BRIDGE_SPCA536:
1107 if (data[0] == 0xff) {
1109 data += SPCA536_OFFSET_DATA;
1110 len -= SPCA536_OFFSET_DATA;
1117 /* case BRIDGE_SPCA504: */
1118 /* case BRIDGE_SPCA504B: */
1120 case 0xfe: /* start of frame */
1122 data += SPCA50X_OFFSET_DATA;
1123 len -= SPCA50X_OFFSET_DATA;
1125 case 0xff: /* drop packet */
1126 /* gspca_dev->last_packet_type = DISCARD_PACKET; */
1134 case BRIDGE_SPCA504C:
1136 case 0xfe: /* start of frame */
1138 data += SPCA504_PCCAM600_OFFSET_DATA;
1139 len -= SPCA504_PCCAM600_OFFSET_DATA;
1141 case 0xff: /* drop packet */
1142 /* gspca_dev->last_packet_type = DISCARD_PACKET; */
1151 if (sof) { /* start of frame */
1152 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
1155 /* put the JPEG header in the new frame */
1156 jpeg_put_header(gspca_dev, frame,
1157 ((struct sd *) gspca_dev)->qindex,
1161 /* add 0x00 after 0xff */
1162 for (i = len; --i >= 0; )
1163 if (data[i] == 0xff)
1165 if (i < 0) { /* no 0xff */
1166 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1171 for (i = 0; i < len; i++) {
1176 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
1177 sd->packet, d - sd->packet);
1180 static void setbrightness(struct gspca_dev *gspca_dev)
1182 struct sd *sd = (struct sd *) gspca_dev;
1183 struct usb_device *dev = gspca_dev->dev;
1185 switch (sd->bridge) {
1187 /* case BRIDGE_SPCA533: */
1188 /* case BRIDGE_SPCA504B: */
1189 /* case BRIDGE_SPCA504: */
1190 /* case BRIDGE_SPCA504C: */
1191 reg_w_riv(dev, 0x0, 0x21a7, sd->brightness);
1193 case BRIDGE_SPCA536:
1194 reg_w_riv(dev, 0x0, 0x20f0, sd->brightness);
1199 static void getbrightness(struct gspca_dev *gspca_dev)
1201 struct sd *sd = (struct sd *) gspca_dev;
1202 __u16 brightness = 0;
1204 switch (sd->bridge) {
1206 /* case BRIDGE_SPCA533: */
1207 /* case BRIDGE_SPCA504B: */
1208 /* case BRIDGE_SPCA504: */
1209 /* case BRIDGE_SPCA504C: */
1210 brightness = reg_r_12(gspca_dev, 0x00, 0x21a7, 2);
1212 case BRIDGE_SPCA536:
1213 brightness = reg_r_12(gspca_dev, 0x00, 0x20f0, 2);
1216 sd->brightness = ((brightness & 0xff) - 128) % 255;
1219 static void setcontrast(struct gspca_dev *gspca_dev)
1221 struct sd *sd = (struct sd *) gspca_dev;
1222 struct usb_device *dev = gspca_dev->dev;
1224 switch (sd->bridge) {
1226 /* case BRIDGE_SPCA533: */
1227 /* case BRIDGE_SPCA504B: */
1228 /* case BRIDGE_SPCA504: */
1229 /* case BRIDGE_SPCA504C: */
1230 reg_w_riv(dev, 0x0, 0x21a8, sd->contrast);
1232 case BRIDGE_SPCA536:
1233 reg_w_riv(dev, 0x0, 0x20f1, sd->contrast);
1238 static void getcontrast(struct gspca_dev *gspca_dev)
1240 struct sd *sd = (struct sd *) gspca_dev;
1242 switch (sd->bridge) {
1244 /* case BRIDGE_SPCA533: */
1245 /* case BRIDGE_SPCA504B: */
1246 /* case BRIDGE_SPCA504: */
1247 /* case BRIDGE_SPCA504C: */
1248 sd->contrast = reg_r_12(gspca_dev, 0x00, 0x21a8, 2);
1250 case BRIDGE_SPCA536:
1251 sd->contrast = reg_r_12(gspca_dev, 0x00, 0x20f1, 2);
1256 static void setcolors(struct gspca_dev *gspca_dev)
1258 struct sd *sd = (struct sd *) gspca_dev;
1259 struct usb_device *dev = gspca_dev->dev;
1261 switch (sd->bridge) {
1263 /* case BRIDGE_SPCA533: */
1264 /* case BRIDGE_SPCA504B: */
1265 /* case BRIDGE_SPCA504: */
1266 /* case BRIDGE_SPCA504C: */
1267 reg_w_riv(dev, 0x0, 0x21ae, sd->colors);
1269 case BRIDGE_SPCA536:
1270 reg_w_riv(dev, 0x0, 0x20f6, sd->colors);
1275 static void getcolors(struct gspca_dev *gspca_dev)
1277 struct sd *sd = (struct sd *) gspca_dev;
1279 switch (sd->bridge) {
1281 /* case BRIDGE_SPCA533: */
1282 /* case BRIDGE_SPCA504B: */
1283 /* case BRIDGE_SPCA504: */
1284 /* case BRIDGE_SPCA504C: */
1285 sd->colors = reg_r_12(gspca_dev, 0x00, 0x21ae, 2) >> 1;
1287 case BRIDGE_SPCA536:
1288 sd->colors = reg_r_12(gspca_dev, 0x00, 0x20f6, 2) >> 1;
1293 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1295 struct sd *sd = (struct sd *) gspca_dev;
1297 sd->brightness = val;
1298 if (gspca_dev->streaming)
1299 setbrightness(gspca_dev);
1303 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1305 struct sd *sd = (struct sd *) gspca_dev;
1307 getbrightness(gspca_dev);
1308 *val = sd->brightness;
1312 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1314 struct sd *sd = (struct sd *) gspca_dev;
1317 if (gspca_dev->streaming)
1318 setcontrast(gspca_dev);
1322 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
1324 struct sd *sd = (struct sd *) gspca_dev;
1326 getcontrast(gspca_dev);
1327 *val = sd->contrast;
1331 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
1333 struct sd *sd = (struct sd *) gspca_dev;
1336 if (gspca_dev->streaming)
1337 setcolors(gspca_dev);
1341 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
1343 struct sd *sd = (struct sd *) gspca_dev;
1345 getcolors(gspca_dev);
1350 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
1352 struct sd *sd = (struct sd *) gspca_dev;
1358 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
1360 struct sd *sd = (struct sd *) gspca_dev;
1362 *val = sd->autogain;
1366 /* sub-driver description */
1367 static const struct sd_desc sd_desc = {
1368 .name = MODULE_NAME,
1370 .nctrls = ARRAY_SIZE(sd_ctrls),
1371 .config = sd_config,
1377 .pkt_scan = sd_pkt_scan,
1380 /* -- module initialisation -- */
1381 #define BS(bridge, subtype) \
1382 .driver_info = (BRIDGE_ ## bridge << 8) \
1384 static const __devinitdata struct usb_device_id device_table[] = {
1385 {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
1386 {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
1387 {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
1388 {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)},
1389 {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)},
1390 {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)},
1391 {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)},
1392 {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)},
1393 {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)},
1394 {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)},
1395 {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)},
1396 {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)},
1397 {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)},
1398 {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)},
1399 {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)},
1400 {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)},
1401 {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
1402 {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
1403 {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
1404 {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
1405 {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
1406 {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
1407 {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)},
1408 {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)},
1409 {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)},
1410 {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)},
1411 {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)},
1412 {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)},
1413 {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)},
1414 {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)},
1415 {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)},
1416 {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)},
1417 {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)},
1418 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
1419 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
1420 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
1421 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
1422 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
1423 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
1424 {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
1425 {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
1426 {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
1427 {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
1428 {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
1429 {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
1430 {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
1431 {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
1432 {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
1433 {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
1434 {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
1435 {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
1436 {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
1437 {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
1438 {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
1439 {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
1440 {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
1441 {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
1444 MODULE_DEVICE_TABLE(usb, device_table);
1446 /* -- device connect -- */
1447 static int sd_probe(struct usb_interface *intf,
1448 const struct usb_device_id *id)
1450 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
1454 static struct usb_driver sd_driver = {
1455 .name = MODULE_NAME,
1456 .id_table = device_table,
1458 .disconnect = gspca_disconnect,
1461 /* -- module insert / remove -- */
1462 static int __init sd_mod_init(void)
1464 if (usb_register(&sd_driver) < 0)
1466 PDEBUG(D_PROBE, "registered");
1469 static void __exit sd_mod_exit(void)
1471 usb_deregister(&sd_driver);
1472 PDEBUG(D_PROBE, "deregistered");
1475 module_init(sd_mod_init);
1476 module_exit(sd_mod_exit);