1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define MODULE_NAME "spca508"
22
23#include "gspca.h"
24
25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
26MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver");
27MODULE_LICENSE("GPL");
28
29
30struct sd {
31 struct gspca_dev gspca_dev;
32
33 u8 brightness;
34
35 u8 subtype;
36#define CreativeVista 0
37#define HamaUSBSightcam 1
38#define HamaUSBSightcam2 2
39#define IntelEasyPCCamera 3
40#define MicroInnovationIC200 4
41#define ViewQuestVQ110 5
42};
43
44
45static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
46static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
47
48static const struct ctrl sd_ctrls[] = {
49 {
50 {
51 .id = V4L2_CID_BRIGHTNESS,
52 .type = V4L2_CTRL_TYPE_INTEGER,
53 .name = "Brightness",
54 .minimum = 0,
55 .maximum = 255,
56 .step = 1,
57#define BRIGHTNESS_DEF 128
58 .default_value = BRIGHTNESS_DEF,
59 },
60 .set = sd_setbrightness,
61 .get = sd_getbrightness,
62 },
63};
64
65static const struct v4l2_pix_format sif_mode[] = {
66 {160, 120, V4L2_PIX_FMT_SPCA508, V4L2_FIELD_NONE,
67 .bytesperline = 160,
68 .sizeimage = 160 * 120 * 3 / 2,
69 .colorspace = V4L2_COLORSPACE_SRGB,
70 .priv = 3},
71 {176, 144, V4L2_PIX_FMT_SPCA508, V4L2_FIELD_NONE,
72 .bytesperline = 176,
73 .sizeimage = 176 * 144 * 3 / 2,
74 .colorspace = V4L2_COLORSPACE_SRGB,
75 .priv = 2},
76 {320, 240, V4L2_PIX_FMT_SPCA508, V4L2_FIELD_NONE,
77 .bytesperline = 320,
78 .sizeimage = 320 * 240 * 3 / 2,
79 .colorspace = V4L2_COLORSPACE_SRGB,
80 .priv = 1},
81 {352, 288, V4L2_PIX_FMT_SPCA508, V4L2_FIELD_NONE,
82 .bytesperline = 352,
83 .sizeimage = 352 * 288 * 3 / 2,
84 .colorspace = V4L2_COLORSPACE_SRGB,
85 .priv = 0},
86};
87
88
89#define SPCA508_OFFSET_DATA 37
90
91
92
93
94
95static const u16 spca508_init_data[][2] = {
96 {0x0000, 0x870b},
97
98 {0x0020, 0x8112},
99 {0x0003, 0x8111},
100 {0x0000, 0x8110},
101
102 {0x0000, 0x8114},
103 {0x0008, 0x8110},
104 {0x0002, 0x8116},
105
106 {0x0003, 0x8111},
107 {0x0000, 0x8111},
108 {0x0098, 0x8110},
109
110 {0x000d, 0x8114},
111 {0x0002, 0x8116},
112 {0x0020, 0x8112},
113
114 {0x000f, 0x8402},
115 {0x0000, 0x8403},
116
117
118
119
120
121
122
123 {0x00c0, 0x8804},
124 {0x0008, 0x8802},
125
126
127 {0x0008, 0x8802},
128 {0x0012, 0x8801},
129 {0x0080, 0x8800},
130
131
132
133 {0x0008, 0x8802},
134 {0x0012, 0x8801},
135 {0x0000, 0x8800},
136
137
138
139 {0x0008, 0x8802},
140 {0x0011, 0x8801},
141 {0x0040, 0x8800},
142
143
144
145 {0x0008, 0x8802},
146 {0x0013, 0x8801},
147 {0x0000, 0x8800},
148
149
150
151 {0x0008, 0x8802},
152 {0x0014, 0x8801},
153 {0x0000, 0x8800},
154
155
156
157 {0x0008, 0x8802},
158 {0x0015, 0x8801},
159 {0x0001, 0x8800},
160
161
162
163 {0x0008, 0x8802},
164 {0x0016, 0x8801},
165 {0x0003, 0x8800},
166
167
168
169 {0x0008, 0x8802},
170 {0x0017, 0x8801},
171 {0x0036, 0x8800},
172
173
174
175 {0x0008, 0x8802},
176 {0x0018, 0x8801},
177 {0x00ec, 0x8800},
178
179
180
181 {0x0008, 0x8802},
182 {0x001a, 0x8801},
183 {0x0094, 0x8800},
184
185
186
187 {0x0008, 0x8802},
188 {0x001b, 0x8801},
189 {0x0000, 0x8800},
190
191
192
193 {0x0008, 0x8802},
194 {0x0027, 0x8801},
195 {0x00a2, 0x8800},
196
197
198
199 {0x0008, 0x8802},
200 {0x0028, 0x8801},
201 {0x0040, 0x8800},
202
203
204
205 {0x0008, 0x8802},
206 {0x002a, 0x8801},
207 {0x0084, 0x8800},
208
209
210
211 {0x0008, 0x8802},
212 {0x002b, 0x8801},
213 {0x00a8, 0x8800},
214
215
216
217 {0x0008, 0x8802},
218 {0x002c, 0x8801},
219 {0x00fe, 0x8800},
220
221
222
223 {0x0008, 0x8802},
224 {0x002d, 0x8801},
225 {0x0003, 0x8800},
226
227
228
229 {0x0008, 0x8802},
230 {0x0038, 0x8801},
231 {0x0083, 0x8800},
232
233
234
235 {0x0008, 0x8802},
236 {0x0033, 0x8801},
237 {0x0081, 0x8800},
238
239
240
241 {0x0008, 0x8802},
242 {0x0034, 0x8801},
243 {0x004a, 0x8800},
244
245
246
247 {0x0008, 0x8802},
248 {0x0039, 0x8801},
249 {0x0000, 0x8800},
250
251
252
253 {0x0008, 0x8802},
254 {0x0010, 0x8801},
255 {0x00a8, 0x8800},
256
257
258
259 {0x0008, 0x8802},
260 {0x0006, 0x8801},
261 {0x0058, 0x8800},
262
263
264
265 {0x0008, 0x8802},
266 {0x0000, 0x8801},
267 {0x0004, 0x8800},
268
269
270
271 {0x0008, 0x8802},
272 {0x0040, 0x8801},
273 {0x0080, 0x8800},
274
275
276
277 {0x0008, 0x8802},
278 {0x0041, 0x8801},
279 {0x000c, 0x8800},
280
281
282
283 {0x0008, 0x8802},
284 {0x0042, 0x8801},
285 {0x000c, 0x8800},
286
287
288
289 {0x0008, 0x8802},
290 {0x0043, 0x8801},
291 {0x0028, 0x8800},
292
293
294
295 {0x0008, 0x8802},
296 {0x0044, 0x8801},
297 {0x0080, 0x8800},
298
299
300
301 {0x0008, 0x8802},
302 {0x0045, 0x8801},
303 {0x0020, 0x8800},
304
305
306
307 {0x0008, 0x8802},
308 {0x0046, 0x8801},
309 {0x0020, 0x8800},
310
311
312
313 {0x0008, 0x8802},
314 {0x0047, 0x8801},
315 {0x0080, 0x8800},
316
317
318
319 {0x0008, 0x8802},
320 {0x0048, 0x8801},
321 {0x004c, 0x8800},
322
323
324
325 {0x0008, 0x8802},
326 {0x0049, 0x8801},
327 {0x0084, 0x8800},
328
329
330
331 {0x0008, 0x8802},
332 {0x004a, 0x8801},
333 {0x0084, 0x8800},
334
335
336
337 {0x0008, 0x8802},
338 {0x004b, 0x8801},
339 {0x0084, 0x8800},
340
341
342 {0x0012, 0x8700},
343 {0x0000, 0x8701},
344 {0x0000, 0x8701},
345 {0x0001, 0x870c},
346
347 {0x0080, 0x8600},
348 {0x0001, 0x8606},
349 {0x0064, 0x8607},
350 {0x002a, 0x8601},
351
352 {0x0000, 0x8602},
353 {0x0080, 0x8600},
354 {0x000a, 0x8603},
355
356 {0x00df, 0x865b},
357 {0x0012, 0x865c},
358
359
360
361
362 {0x0058, 0x865d},
363 {0x0048, 0x865e},
364
365 {0x0015, 0x8608},
366 {0x0030, 0x8609},
367 {0x00fb, 0x860a},
368 {0x003e, 0x860b},
369 {0x00ce, 0x860c},
370 {0x00f4, 0x860d},
371 {0x00eb, 0x860e},
372 {0x00dc, 0x860f},
373 {0x0039, 0x8610},
374 {0x0001, 0x8611},
375 {0x0000, 0x8612},
376 {0x0001, 0x8613},
377 {0x0000, 0x8614},
378 {0x005b, 0x8651},
379 {0x0040, 0x8652},
380 {0x0060, 0x8653},
381 {0x0040, 0x8654},
382 {0x0000, 0x8655},
383 {0x0001, 0x863f},
384
385 {0x00a1, 0x8656},
386
387
388 {0x0018, 0x8657},
389 {0x0020, 0x8658},
390 {0x000a, 0x8659},
391 {0x0005, 0x865a},
392
393 {0x0030, 0x8112},
394
395
396 {0xa908, 0x8802},
397 {0x0034, 0x8801},
398 {0x00ca, 0x8800},
399
400
401
402
403 {0x1f08, 0x8802},
404 {0x0006, 0x8801},
405 {0x0080, 0x8800},
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420 {0xb008, 0x8802},
421 {0x0006, 0x8801},
422 {0x007d, 0x8800},
423
424
425
426
427
428
429
430 {0x0015, 0x8608},
431 {0x0030, 0x8609},
432 {0xfffb, 0x860a},
433 {0x003e, 0x860b},
434 {0xffce, 0x860c},
435 {0xfff4, 0x860d},
436 {0xffeb, 0x860e},
437 {0xffdc, 0x860f},
438 {0x0039, 0x8610},
439 {0x0018, 0x8657},
440
441 {0x0000, 0x8508},
442
443
444 {0x0032, 0x850b},
445 {0x0003, 0x8509},
446 {0x0011, 0x850a},
447 {0x0021, 0x850d},
448 {0x0010, 0x850c},
449 {0x0003, 0x8500},
450 {0x0001, 0x8501},
451 {0x0061, 0x8656},
452
453
454 {0x0018, 0x8617},
455 {0x0008, 0x8618},
456 {0x0061, 0x8656},
457
458
459 {0x0058, 0x8619},
460 {0x0008, 0x861a},
461 {0x00ff, 0x8615},
462 {0x0000, 0x8616},
463 {0x0012, 0x8700},
464 {0x0012, 0x8700},
465
466 {0x0028, 0x8802},
467
468
469 {0x1f28, 0x8802},
470 {0x0010, 0x8801},
471 {0x003e, 0x8800},
472
473 {0x0028, 0x8802},
474
475
476 {0x1f28, 0x8802},
477 {0x0000, 0x8801},
478 {0x001f, 0x8800},
479
480 {0x0001, 0x8602},
481
482
483 {0x0023, 0x8700},
484 {0x000f, 0x8602},
485
486 {0x0028, 0x8802},
487
488
489 {0x1f28, 0x8802},
490 {0x0010, 0x8801},
491 {0x007b, 0x8800},
492
493 {0x002f, 0x8651},
494 {0x0080, 0x8653},
495
496 {0x0000, 0x8655},
497
498 {0x0030, 0x8112},
499 {0x0020, 0x8112},
500
501 {}
502};
503
504
505
506
507static const u16 spca508cs110_init_data[][2] = {
508 {0x0000, 0x870b},
509 {0x0003, 0x8111},
510 {0x0000, 0x8111},
511 {0x0090, 0x8110},
512
513 {0x0020, 0x8112},
514 {0x0000, 0x8114},
515 {0x0001, 0x8114},
516 {0x0001, 0x8114},
517 {0x0001, 0x8114},
518 {0x0003, 0x8114},
519
520
521 {0x000f, 0x8402},
522 {0x0000, 0x8403},
523 {0x00ba, 0x8804},
524 {0x0010, 0x8802},
525 {0x0010, 0x8802},
526
527 {0x0001, 0x8801},
528 {0x000a, 0x8805},
529 {0x0000, 0x8800},
530 {0x0010, 0x8802},
531
532 {0x0002, 0x8801},
533 {0x0000, 0x8805},
534 {0x0000, 0x8800},
535 {0x0010, 0x8802},
536
537 {0x0003, 0x8801},
538 {0x0027, 0x8805},
539 {0x0001, 0x8800},
540 {0x0010, 0x8802},
541
542 {0x0004, 0x8801},
543 {0x0065, 0x8805},
544 {0x0001, 0x8800},
545 {0x0010, 0x8802},
546
547 {0x0005, 0x8801},
548 {0x0003, 0x8805},
549 {0x0000, 0x8800},
550 {0x0010, 0x8802},
551
552 {0x0006, 0x8801},
553 {0x001c, 0x8805},
554 {0x0000, 0x8800},
555 {0x0010, 0x8802},
556
557 {0x0007, 0x8801},
558 {0x002a, 0x8805},
559 {0x0000, 0x8800},
560 {0x0010, 0x8802},
561
562 {0x0002, 0x8704},
563 {0x0001, 0x8606},
564 {0x009a, 0x8600},
565 {0x0001, 0x865b},
566 {0x0003, 0x865c},
567 {0x0058, 0x865d},
568
569 {0x0006, 0x8660},
570
571 {0x000a, 0x8602},
572 {0x0000, 0x8603},
573
574
575
576
577
578
579 {0x0040, 0x8651},
580 {0x0030, 0x8652},
581 {0x0035, 0x8653},
582 {0x0035, 0x8654},
583 {0x0041, 0x863f},
584
585
586 {0x0000, 0x8655},
587
588 {}
589};
590
591static const u16 spca508_sightcam_init_data[][2] = {
592
593 {0x000f, 0x8402},
594
595
596 {0x0090, 0x8110},
597 {0x0001, 0x8114},
598 {0x0001, 0x8114},
599 {0x0001, 0x8114},
600 {0x0003, 0x8114},
601 {0x0080, 0x8804},
602
603
604 {0x0001, 0x8801},
605 {0x0004, 0x8800},
606 {0x0003, 0x8801},
607 {0x00e0, 0x8800},
608 {0x0004, 0x8801},
609 {0x00b4, 0x8800},
610 {0x0005, 0x8801},
611 {0x0000, 0x8800},
612
613 {0x0006, 0x8801},
614 {0x00e0, 0x8800},
615 {0x0007, 0x8801},
616 {0x000c, 0x8800},
617
618
619
620
621
622 {0x0014, 0x8801},
623 {0x0008, 0x8800},
624 {0x0015, 0x8801},
625 {0x0067, 0x8800},
626 {0x0016, 0x8801},
627 {0x0000, 0x8800},
628 {0x0017, 0x8801},
629 {0x0020, 0x8800},
630 {0x0018, 0x8801},
631 {0x0044, 0x8800},
632
633
634
635
636 {0x001e, 0x8801},
637 {0x00ea, 0x8800},
638 {0x001f, 0x8801},
639 {0x0001, 0x8800},
640 {0x0003, 0x8801},
641 {0x00e0, 0x8800},
642
643
644 {0x0006, 0x8704},
645 {0x0001, 0x870c},
646 {0x0016, 0x8600},
647 {0x0002, 0x8606},
648
649
650 {0x0064, 0x8607},
651 {0x003a, 0x8601},
652 {0x0000, 0x8602},
653
654
655 {0x0016, 0x8600},
656 {0x0018, 0x8617},
657 {0x0008, 0x8618},
658 {0x00a1, 0x8656},
659
660
661 {0x0007, 0x865b},
662 {0x0001, 0x865c},
663 {0x0058, 0x865d},
664 {0x0048, 0x865e},
665
666
667 {0x0049, 0x8651},
668 {0x0040, 0x8652},
669 {0x004c, 0x8653},
670 {0x0040, 0x8654},
671 {}
672};
673
674static const u16 spca508_sightcam2_init_data[][2] = {
675 {0x0020, 0x8112},
676
677 {0x000f, 0x8402},
678 {0x0000, 0x8403},
679
680 {0x0008, 0x8201},
681 {0x0008, 0x8200},
682 {0x0001, 0x8200},
683 {0x0009, 0x8201},
684 {0x0008, 0x8200},
685 {0x0001, 0x8200},
686 {0x000a, 0x8201},
687 {0x0008, 0x8200},
688 {0x0001, 0x8200},
689 {0x000b, 0x8201},
690 {0x0008, 0x8200},
691 {0x0001, 0x8200},
692 {0x000c, 0x8201},
693 {0x0008, 0x8200},
694 {0x0001, 0x8200},
695 {0x000d, 0x8201},
696 {0x0008, 0x8200},
697 {0x0001, 0x8200},
698 {0x000e, 0x8201},
699 {0x0008, 0x8200},
700 {0x0001, 0x8200},
701 {0x0007, 0x8201},
702 {0x0008, 0x8200},
703 {0x0001, 0x8200},
704 {0x000f, 0x8201},
705 {0x0008, 0x8200},
706 {0x0001, 0x8200},
707
708 {0x0018, 0x8660},
709 {0x0010, 0x8201},
710
711 {0x0008, 0x8200},
712 {0x0001, 0x8200},
713 {0x0011, 0x8201},
714 {0x0008, 0x8200},
715 {0x0001, 0x8200},
716
717 {0x0000, 0x86b0},
718 {0x0034, 0x86b1},
719 {0x0000, 0x86b2},
720 {0x0049, 0x86b3},
721 {0x0000, 0x86b4},
722 {0x0000, 0x86b4},
723
724 {0x0012, 0x8201},
725 {0x0008, 0x8200},
726 {0x0001, 0x8200},
727 {0x0013, 0x8201},
728 {0x0008, 0x8200},
729 {0x0001, 0x8200},
730
731 {0x0001, 0x86b0},
732 {0x00aa, 0x86b1},
733 {0x0000, 0x86b2},
734 {0x00e4, 0x86b3},
735 {0x0000, 0x86b4},
736 {0x0000, 0x86b4},
737
738 {0x0018, 0x8660},
739
740 {0x0090, 0x8110},
741 {0x0001, 0x8114},
742 {0x0001, 0x8114},
743 {0x0001, 0x8114},
744 {0x0003, 0x8114},
745
746 {0x0080, 0x8804},
747 {0x0003, 0x8801},
748 {0x0012, 0x8800},
749 {0x0004, 0x8801},
750 {0x0005, 0x8800},
751 {0x0005, 0x8801},
752 {0x0000, 0x8800},
753 {0x0006, 0x8801},
754 {0x0000, 0x8800},
755 {0x0007, 0x8801},
756 {0x0000, 0x8800},
757 {0x0008, 0x8801},
758 {0x0005, 0x8800},
759 {0x000a, 0x8700},
760 {0x000e, 0x8801},
761 {0x0004, 0x8800},
762 {0x0005, 0x8801},
763 {0x0047, 0x8800},
764 {0x0006, 0x8801},
765 {0x0000, 0x8800},
766 {0x0007, 0x8801},
767 {0x00c0, 0x8800},
768 {0x0008, 0x8801},
769 {0x0003, 0x8800},
770 {0x0013, 0x8801},
771 {0x0001, 0x8800},
772 {0x0009, 0x8801},
773 {0x0000, 0x8800},
774 {0x000a, 0x8801},
775 {0x0000, 0x8800},
776 {0x000b, 0x8801},
777 {0x0000, 0x8800},
778 {0x000c, 0x8801},
779 {0x0000, 0x8800},
780 {0x000e, 0x8801},
781 {0x0004, 0x8800},
782 {0x000f, 0x8801},
783 {0x0000, 0x8800},
784 {0x0010, 0x8801},
785 {0x0006, 0x8800},
786 {0x0011, 0x8801},
787 {0x0006, 0x8800},
788 {0x0012, 0x8801},
789 {0x0000, 0x8800},
790 {0x0013, 0x8801},
791 {0x0001, 0x8800},
792
793 {0x000a, 0x8700},
794 {0x0000, 0x8702},
795 {0x0000, 0x8703},
796 {0x00c2, 0x8704},
797 {0x0001, 0x870c},
798
799 {0x0044, 0x8600},
800 {0x0002, 0x8606},
801 {0x0064, 0x8607},
802 {0x003a, 0x8601},
803 {0x0008, 0x8602},
804 {0x0044, 0x8600},
805 {0x0018, 0x8617},
806 {0x0008, 0x8618},
807 {0x00a1, 0x8656},
808 {0x0004, 0x865b},
809 {0x0002, 0x865c},
810 {0x0058, 0x865d},
811 {0x0048, 0x865e},
812 {0x0012, 0x8608},
813 {0x002c, 0x8609},
814 {0x0002, 0x860a},
815 {0x002c, 0x860b},
816 {0x00db, 0x860c},
817 {0x00f9, 0x860d},
818 {0x00f1, 0x860e},
819 {0x00e3, 0x860f},
820 {0x002c, 0x8610},
821 {0x006c, 0x8651},
822 {0x0041, 0x8652},
823 {0x0059, 0x8653},
824 {0x0040, 0x8654},
825 {0x00fa, 0x8611},
826 {0x00ff, 0x8612},
827 {0x00f8, 0x8613},
828 {0x0000, 0x8614},
829 {0x0001, 0x863f},
830 {0x0000, 0x8640},
831 {0x0026, 0x8641},
832 {0x0045, 0x8642},
833 {0x0060, 0x8643},
834 {0x0075, 0x8644},
835 {0x0088, 0x8645},
836 {0x009b, 0x8646},
837 {0x00b0, 0x8647},
838 {0x00c5, 0x8648},
839 {0x00d2, 0x8649},
840 {0x00dc, 0x864a},
841 {0x00e5, 0x864b},
842 {0x00eb, 0x864c},
843 {0x00f0, 0x864d},
844 {0x00f6, 0x864e},
845 {0x00fa, 0x864f},
846 {0x00ff, 0x8650},
847 {0x0060, 0x8657},
848 {0x0010, 0x8658},
849 {0x0018, 0x8659},
850 {0x0005, 0x865a},
851 {0x0018, 0x8660},
852 {0x0003, 0x8509},
853 {0x0011, 0x850a},
854 {0x0032, 0x850b},
855 {0x0010, 0x850c},
856 {0x0021, 0x850d},
857 {0x0001, 0x8500},
858 {0x0000, 0x8508},
859 {0x0012, 0x8608},
860 {0x002c, 0x8609},
861 {0x0002, 0x860a},
862 {0x0039, 0x860b},
863 {0x00d0, 0x860c},
864 {0x00f7, 0x860d},
865 {0x00ed, 0x860e},
866 {0x00db, 0x860f},
867 {0x0039, 0x8610},
868 {0x0012, 0x8657},
869 {0x000c, 0x8619},
870 {0x0004, 0x861a},
871 {0x00a1, 0x8656},
872 {0x00c8, 0x8615},
873 {0x0032, 0x8616},
874
875 {0x0030, 0x8112},
876 {0x0020, 0x8112},
877 {0x0020, 0x8112},
878 {0x000f, 0x8402},
879 {0x0000, 0x8403},
880
881 {0x0090, 0x8110},
882 {0x0001, 0x8114},
883 {0x0001, 0x8114},
884 {0x0001, 0x8114},
885 {0x0003, 0x8114},
886 {0x0080, 0x8804},
887
888 {0x0003, 0x8801},
889 {0x0012, 0x8800},
890 {0x0004, 0x8801},
891 {0x0005, 0x8800},
892 {0x0005, 0x8801},
893 {0x0047, 0x8800},
894 {0x0006, 0x8801},
895 {0x0000, 0x8800},
896 {0x0007, 0x8801},
897 {0x00c0, 0x8800},
898 {0x0008, 0x8801},
899 {0x0003, 0x8800},
900 {0x000a, 0x8700},
901 {0x000e, 0x8801},
902 {0x0004, 0x8800},
903 {0x0005, 0x8801},
904 {0x0047, 0x8800},
905 {0x0006, 0x8801},
906 {0x0000, 0x8800},
907 {0x0007, 0x8801},
908 {0x00c0, 0x8800},
909 {0x0008, 0x8801},
910 {0x0003, 0x8800},
911 {0x0013, 0x8801},
912 {0x0001, 0x8800},
913 {0x0009, 0x8801},
914 {0x0000, 0x8800},
915 {0x000a, 0x8801},
916 {0x0000, 0x8800},
917 {0x000b, 0x8801},
918 {0x0000, 0x8800},
919 {0x000c, 0x8801},
920 {0x0000, 0x8800},
921 {0x000e, 0x8801},
922 {0x0004, 0x8800},
923 {0x000f, 0x8801},
924 {0x0000, 0x8800},
925 {0x0010, 0x8801},
926 {0x0006, 0x8800},
927 {0x0011, 0x8801},
928 {0x0006, 0x8800},
929 {0x0012, 0x8801},
930 {0x0000, 0x8800},
931 {0x0013, 0x8801},
932 {0x0001, 0x8800},
933 {0x000a, 0x8700},
934 {0x0000, 0x8702},
935 {0x0000, 0x8703},
936 {0x00c2, 0x8704},
937 {0x0001, 0x870c},
938 {0x0044, 0x8600},
939 {0x0002, 0x8606},
940 {0x0064, 0x8607},
941 {0x003a, 0x8601},
942 {0x0008, 0x8602},
943 {0x0044, 0x8600},
944 {0x0018, 0x8617},
945 {0x0008, 0x8618},
946 {0x00a1, 0x8656},
947 {0x0004, 0x865b},
948 {0x0002, 0x865c},
949 {0x0058, 0x865d},
950 {0x0048, 0x865e},
951 {0x0012, 0x8608},
952 {0x002c, 0x8609},
953 {0x0002, 0x860a},
954 {0x002c, 0x860b},
955 {0x00db, 0x860c},
956 {0x00f9, 0x860d},
957 {0x00f1, 0x860e},
958 {0x00e3, 0x860f},
959 {0x002c, 0x8610},
960 {0x006c, 0x8651},
961 {0x0041, 0x8652},
962 {0x0059, 0x8653},
963 {0x0040, 0x8654},
964 {0x00fa, 0x8611},
965 {0x00ff, 0x8612},
966 {0x00f8, 0x8613},
967 {0x0000, 0x8614},
968 {0x0001, 0x863f},
969 {0x0000, 0x8640},
970 {0x0026, 0x8641},
971 {0x0045, 0x8642},
972 {0x0060, 0x8643},
973 {0x0075, 0x8644},
974 {0x0088, 0x8645},
975 {0x009b, 0x8646},
976 {0x00b0, 0x8647},
977 {0x00c5, 0x8648},
978 {0x00d2, 0x8649},
979 {0x00dc, 0x864a},
980 {0x00e5, 0x864b},
981 {0x00eb, 0x864c},
982 {0x00f0, 0x864d},
983 {0x00f6, 0x864e},
984 {0x00fa, 0x864f},
985 {0x00ff, 0x8650},
986 {0x0060, 0x8657},
987 {0x0010, 0x8658},
988 {0x0018, 0x8659},
989 {0x0005, 0x865a},
990 {0x0018, 0x8660},
991 {0x0003, 0x8509},
992 {0x0011, 0x850a},
993 {0x0032, 0x850b},
994 {0x0010, 0x850c},
995 {0x0021, 0x850d},
996 {0x0001, 0x8500},
997 {0x0000, 0x8508},
998
999 {0x0012, 0x8608},
1000 {0x002c, 0x8609},
1001 {0x0002, 0x860a},
1002 {0x0039, 0x860b},
1003 {0x00d0, 0x860c},
1004 {0x00f7, 0x860d},
1005 {0x00ed, 0x860e},
1006 {0x00db, 0x860f},
1007 {0x0039, 0x8610},
1008 {0x0012, 0x8657},
1009 {0x0064, 0x8619},
1010
1011
1012
1013
1014
1015 {}
1016};
1017
1018
1019
1020
1021static const u16 spca508_vista_init_data[][2] = {
1022 {0x0008, 0x8200},
1023 {0x0000, 0x870b},
1024 {0x0020, 0x8112},
1025 {0x0003, 0x8111},
1026 {0x0000, 0x8110},
1027 {0x0000, 0x8114},
1028 {0x0000, 0x8114},
1029
1030 {0x0003, 0x8111},
1031 {0x0000, 0x8111},
1032 {0x0090, 0x8110},
1033 {0x0020, 0x8112},
1034 {0x0000, 0x8114},
1035 {0x0001, 0x8114},
1036 {0x0001, 0x8114},
1037 {0x0001, 0x8114},
1038 {0x0003, 0x8114},
1039
1040 {0x000f, 0x8402},
1041 {0x0000, 0x8403},
1042 {0x00ba, 0x8804},
1043 {0x0010, 0x8802},
1044
1045
1046
1047 {0x0010, 0x8802},
1048 {0x0020, 0x8801},
1049 {0x0044, 0x8805},
1050 {0x0004, 0x8800},
1051
1052
1053
1054
1055 {0x0010, 0x8802},
1056 {0x0009, 0x8801},
1057 {0x0042, 0x8805},
1058 {0x0001, 0x8800},
1059
1060
1061
1062
1063 {0x0010, 0x8802},
1064 {0x003c, 0x8801},
1065 {0x0001, 0x8805},
1066 {0x0000, 0x8800},
1067
1068
1069
1070
1071 {0x0010, 0x8802},
1072 {0x0001, 0x8801},
1073 {0x000a, 0x8805},
1074 {0x0000, 0x8800},
1075
1076
1077
1078
1079 {0x0010, 0x8802},
1080 {0x0002, 0x8801},
1081 {0x0000, 0x8805},
1082 {0x0000, 0x8800},
1083
1084
1085
1086
1087 {0x0010, 0x8802},
1088 {0x0003, 0x8801},
1089 {0x0027, 0x8805},
1090 {0x0001, 0x8800},
1091
1092
1093
1094
1095 {0x0010, 0x8802},
1096 {0x0004, 0x8801},
1097 {0x0065, 0x8805},
1098 {0x0001, 0x8800},
1099
1100
1101
1102
1103 {0x0010, 0x8802},
1104 {0x0005, 0x8801},
1105 {0x0003, 0x8805},
1106 {0x0000, 0x8800},
1107
1108
1109
1110
1111 {0x0010, 0x8802},
1112 {0x0006, 0x8801},
1113 {0x001c, 0x8805},
1114 {0x0000, 0x8800},
1115
1116
1117
1118
1119 {0x0010, 0x8802},
1120 {0x0007, 0x8801},
1121 {0x002a, 0x8805},
1122 {0x0000, 0x8800},
1123
1124
1125
1126
1127 {0x0010, 0x8802},
1128 {0x000e, 0x8801},
1129 {0x0000, 0x8805},
1130 {0x0000, 0x8800},
1131
1132
1133
1134
1135 {0x0010, 0x8802},
1136 {0x0028, 0x8801},
1137 {0x002e, 0x8805},
1138 {0x0000, 0x8800},
1139
1140
1141
1142
1143 {0x0010, 0x8802},
1144 {0x0039, 0x8801},
1145 {0x0013, 0x8805},
1146 {0x0000, 0x8800},
1147
1148
1149
1150
1151 {0x0010, 0x8802},
1152 {0x003b, 0x8801},
1153 {0x000c, 0x8805},
1154 {0x0000, 0x8800},
1155
1156
1157
1158
1159 {0x0010, 0x8802},
1160 {0x0035, 0x8801},
1161 {0x0028, 0x8805},
1162 {0x0000, 0x8800},
1163
1164
1165
1166
1167 {0x0010, 0x8802},
1168 {0x0009, 0x8801},
1169 {0x0042, 0x8805},
1170 {0x0001, 0x8800},
1171
1172
1173 {0x0050, 0x8703},
1174 {0x0002, 0x8704},
1175 {0x0001, 0x870c},
1176 {0x009a, 0x8600},
1177 {0x0001, 0x8606},
1178 {0x0023, 0x8601},
1179 {0x0010, 0x8602},
1180 {0x000a, 0x8603},
1181 {0x009a, 0x8600},
1182 {0x0001, 0x865b},
1183 {0x0003, 0x865c},
1184 {0x0058, 0x865d},
1185 {0x0048, 0x865e},
1186 {0x0000, 0x865f},
1187
1188 {0x0006, 0x8660},
1189
1190
1191 {0x0013, 0x8608},
1192 {0x0028, 0x8609},
1193
1194 {0x0005, 0x860a},
1195 {0x0025, 0x860b},
1196 {0x00e1, 0x860c},
1197 {0x00fa, 0x860d},
1198 {0x00f4, 0x860e},
1199 {0x00e8, 0x860f},
1200 {0x0025, 0x8610},
1201 {0x00fc, 0x8611},
1202 {0x0001, 0x8612},
1203 {0x00fe, 0x8613},
1204 {0x0000, 0x8614},
1205
1206 {0x0064, 0x8651},
1207 {0x0040, 0x8652},
1208 {0x0066, 0x8653},
1209 {0x0040, 0x8654},
1210 {0x0001, 0x863f},
1211
1212 {0x00a1, 0x8656},
1213
1214
1215 {0x0018, 0x8657},
1216 {0x0020, 0x8658},
1217 {0x000a, 0x8659},
1218 {0x0005, 0x865a},
1219 {0x0064, 0x8607},
1220
1221 {0x0016, 0x8660},
1222 {0x0000, 0x86b0},
1223 {0x00dc, 0x86b1},
1224 {0x0000, 0x86b2},
1225 {0x0009, 0x86b3},
1226 {0x0000, 0x86b4},
1227
1228 {0x0001, 0x86b0},
1229 {0x00f5, 0x86b1},
1230 {0x0000, 0x86b2},
1231 {0x00c6, 0x86b3},
1232 {0x0000, 0x86b4},
1233
1234 {0x0002, 0x86b0},
1235 {0x001c, 0x86b1},
1236 {0x0001, 0x86b2},
1237 {0x00d7, 0x86b3},
1238 {0x0000, 0x86b4},
1239
1240 {0x0003, 0x86b0},
1241 {0x001c, 0x86b1},
1242 {0x0001, 0x86b2},
1243 {0x00d8, 0x86b3},
1244 {0x0000, 0x86b4},
1245
1246 {0x0004, 0x86b0},
1247 {0x001d, 0x86b1},
1248 {0x0001, 0x86b2},
1249 {0x00d8, 0x86b3},
1250 {0x0000, 0x86b4},
1251 {0x001e, 0x8660},
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262 {}
1263};
1264
1265static int reg_write(struct usb_device *dev,
1266 u16 index, u16 value)
1267{
1268 int ret;
1269
1270 ret = usb_control_msg(dev,
1271 usb_sndctrlpipe(dev, 0),
1272 0,
1273 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1274 value, index, NULL, 0, 500);
1275 PDEBUG(D_USBO, "reg write i:0x%04x = 0x%02x",
1276 index, value);
1277 if (ret < 0)
1278 err("reg write: error %d", ret);
1279 return ret;
1280}
1281
1282
1283
1284static int reg_read(struct gspca_dev *gspca_dev,
1285 u16 index)
1286{
1287 int ret;
1288
1289 ret = usb_control_msg(gspca_dev->dev,
1290 usb_rcvctrlpipe(gspca_dev->dev, 0),
1291 0,
1292 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1293 0,
1294 index,
1295 gspca_dev->usb_buf, 1,
1296 500);
1297 PDEBUG(D_USBI, "reg read i:%04x --> %02x",
1298 index, gspca_dev->usb_buf[0]);
1299 if (ret < 0) {
1300 err("reg_read err %d", ret);
1301 return ret;
1302 }
1303 return gspca_dev->usb_buf[0];
1304}
1305
1306
1307static int ssi_w(struct gspca_dev *gspca_dev,
1308 u16 reg, u16 val)
1309{
1310 struct usb_device *dev = gspca_dev->dev;
1311 int ret, retry;
1312
1313 ret = reg_write(dev, 0x8802, reg >> 8);
1314 if (ret < 0)
1315 goto out;
1316 ret = reg_write(dev, 0x8801, reg & 0x00ff);
1317 if (ret < 0)
1318 goto out;
1319 if ((reg & 0xff00) == 0x1000) {
1320 ret = reg_write(dev, 0x8805, val & 0x00ff);
1321 if (ret < 0)
1322 goto out;
1323 val >>= 8;
1324 }
1325 ret = reg_write(dev, 0x8800, val);
1326 if (ret < 0)
1327 goto out;
1328
1329
1330 retry = 10;
1331 for (;;) {
1332 ret = reg_read(gspca_dev, 0x8803);
1333 if (ret < 0)
1334 break;
1335 if (gspca_dev->usb_buf[0] == 0)
1336 break;
1337 if (--retry <= 0) {
1338 PDEBUG(D_ERR, "ssi_w busy %02x",
1339 gspca_dev->usb_buf[0]);
1340 ret = -1;
1341 break;
1342 }
1343 msleep(8);
1344 }
1345
1346out:
1347 return ret;
1348}
1349
1350static int write_vector(struct gspca_dev *gspca_dev,
1351 const u16 (*data)[2])
1352{
1353 struct usb_device *dev = gspca_dev->dev;
1354 int ret = 0;
1355
1356 while ((*data)[1] != 0) {
1357 if ((*data)[1] & 0x8000) {
1358 if ((*data)[1] == 0xdd00)
1359 msleep((*data)[0]);
1360 else
1361 ret = reg_write(dev, (*data)[1], (*data)[0]);
1362 } else {
1363 ret = ssi_w(gspca_dev, (*data)[1], (*data)[0]);
1364 }
1365 if (ret < 0)
1366 break;
1367 data++;
1368 }
1369 return ret;
1370}
1371
1372
1373static int sd_config(struct gspca_dev *gspca_dev,
1374 const struct usb_device_id *id)
1375{
1376 struct sd *sd = (struct sd *) gspca_dev;
1377 struct cam *cam;
1378 int data1, data2;
1379 const u16 (*init_data)[2];
1380 static const u16 (*(init_data_tb[]))[2] = {
1381 spca508_vista_init_data,
1382 spca508_sightcam_init_data,
1383 spca508_sightcam2_init_data,
1384 spca508cs110_init_data,
1385 spca508cs110_init_data,
1386 spca508_init_data,
1387 };
1388
1389
1390
1391
1392
1393 data1 = reg_read(gspca_dev, 0x8104);
1394 data2 = reg_read(gspca_dev, 0x8105);
1395 PDEBUG(D_PROBE, "Webcam Vendor ID: 0x%02x%02x", data2, data1);
1396
1397 data1 = reg_read(gspca_dev, 0x8106);
1398 data2 = reg_read(gspca_dev, 0x8107);
1399 PDEBUG(D_PROBE, "Webcam Product ID: 0x%02x%02x", data2, data1);
1400
1401 data1 = reg_read(gspca_dev, 0x8621);
1402 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1);
1403
1404 cam = &gspca_dev->cam;
1405 cam->cam_mode = sif_mode;
1406 cam->nmodes = ARRAY_SIZE(sif_mode);
1407
1408 sd->subtype = id->driver_info;
1409 sd->brightness = BRIGHTNESS_DEF;
1410
1411 init_data = init_data_tb[sd->subtype];
1412 return write_vector(gspca_dev, init_data);
1413}
1414
1415
1416static int sd_init(struct gspca_dev *gspca_dev)
1417{
1418 return 0;
1419}
1420
1421static int sd_start(struct gspca_dev *gspca_dev)
1422{
1423 int mode;
1424
1425 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
1426 reg_write(gspca_dev->dev, 0x8500, mode);
1427 switch (mode) {
1428 case 0:
1429 case 1:
1430 reg_write(gspca_dev->dev, 0x8700, 0x28);
1431 break;
1432 default:
1433
1434
1435 reg_write(gspca_dev->dev, 0x8700, 0x23);
1436 break;
1437 }
1438 reg_write(gspca_dev->dev, 0x8112, 0x10 | 0x20);
1439 return 0;
1440}
1441
1442static void sd_stopN(struct gspca_dev *gspca_dev)
1443{
1444
1445 reg_write(gspca_dev->dev, 0x8112, 0x20);
1446}
1447
1448static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1449 u8 *data,
1450 int len)
1451{
1452 switch (data[0]) {
1453 case 0:
1454 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
1455 data += SPCA508_OFFSET_DATA;
1456 len -= SPCA508_OFFSET_DATA;
1457 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
1458 break;
1459 case 0xff:
1460 break;
1461 default:
1462 data += 1;
1463 len -= 1;
1464 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1465 break;
1466 }
1467}
1468
1469static void setbrightness(struct gspca_dev *gspca_dev)
1470{
1471 struct sd *sd = (struct sd *) gspca_dev;
1472 u8 brightness = sd->brightness;
1473
1474
1475 reg_write(gspca_dev->dev, 0x8651, brightness);
1476 reg_write(gspca_dev->dev, 0x8652, brightness);
1477 reg_write(gspca_dev->dev, 0x8653, brightness);
1478 reg_write(gspca_dev->dev, 0x8654, brightness);
1479}
1480
1481static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1482{
1483 struct sd *sd = (struct sd *) gspca_dev;
1484
1485 sd->brightness = val;
1486 if (gspca_dev->streaming)
1487 setbrightness(gspca_dev);
1488 return 0;
1489}
1490
1491static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
1492{
1493 struct sd *sd = (struct sd *) gspca_dev;
1494
1495 *val = sd->brightness;
1496 return 0;
1497}
1498
1499
1500static const struct sd_desc sd_desc = {
1501 .name = MODULE_NAME,
1502 .ctrls = sd_ctrls,
1503 .nctrls = ARRAY_SIZE(sd_ctrls),
1504 .config = sd_config,
1505 .init = sd_init,
1506 .start = sd_start,
1507 .stopN = sd_stopN,
1508 .pkt_scan = sd_pkt_scan,
1509};
1510
1511
1512static const struct usb_device_id device_table[] = {
1513 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam},
1514 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista},
1515 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
1516 {USB_DEVICE(0x0af9, 0x0010), .driver_info = HamaUSBSightcam},
1517 {USB_DEVICE(0x0af9, 0x0011), .driver_info = HamaUSBSightcam2},
1518 {USB_DEVICE(0x8086, 0x0110), .driver_info = IntelEasyPCCamera},
1519 {}
1520};
1521MODULE_DEVICE_TABLE(usb, device_table);
1522
1523
1524static int sd_probe(struct usb_interface *intf,
1525 const struct usb_device_id *id)
1526{
1527 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
1528 THIS_MODULE);
1529}
1530
1531static struct usb_driver sd_driver = {
1532 .name = MODULE_NAME,
1533 .id_table = device_table,
1534 .probe = sd_probe,
1535 .disconnect = gspca_disconnect,
1536#ifdef CONFIG_PM
1537 .suspend = gspca_suspend,
1538 .resume = gspca_resume,
1539#endif
1540};
1541
1542
1543static int __init sd_mod_init(void)
1544{
1545 return usb_register(&sd_driver);
1546}
1547static void __exit sd_mod_exit(void)
1548{
1549 usb_deregister(&sd_driver);
1550}
1551
1552module_init(sd_mod_init);
1553module_exit(sd_mod_exit);
1554