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