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