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