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