This source file includes following definitions.
- writeEEProm
- readEEProm
- signCard
- check_for_i2c_devices
- locate_tuner_address
- locate_eeprom_address
- probeCard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 #include <sys/param.h>
52 #include <sys/systm.h>
53 #include <sys/vnode.h>
54
55 #include <dev/ic/bt8xx.h>
56 #include <dev/pci/bktr/bktr_reg.h>
57 #include <dev/pci/bktr/bktr_core.h>
58 #include <dev/pci/bktr/bktr_tuner.h>
59 #include <dev/pci/bktr/bktr_card.h>
60 #include <dev/pci/bktr/bktr_audio.h>
61
62
63 #include <dev/pci/pcidevs.h>
64 #include <dev/pci/pcireg.h>
65
66
67 #define HAUP_REMOTE_INT_WADDR 0x30
68 #define HAUP_REMOTE_INT_RADDR 0x31
69
70 #define HAUP_REMOTE_EXT_WADDR 0x34
71 #define HAUP_REMOTE_EXT_RADDR 0x35
72
73
74 #define TDA9850_WADDR 0xb6
75 #define TDA9850_RADDR 0xb7
76
77
78 #define MSP3400C_WADDR 0x80
79 #define MSP3400C_RADDR 0x81
80
81
82 #define DPL3518A_WADDR 0x84
83 #define DPL3518A_RADDR 0x85
84
85
86 #define X24C01_WADDR 0xae
87 #define X24C01_RADDR 0xaf
88
89
90
91 #define PFC8582_WADDR 0xa0
92 #define PFC8582_RADDR 0xa1
93
94 #if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
95 #define DEFAULT_TUNER PHILIPS_PALI
96 #else
97 #define DEFAULT_TUNER PHILIPS_NTSC
98 #endif
99
100
101
102
103
104
105
106
107
108
109 static const struct CARDTYPE cards[] = {
110
111 { CARD_UNKNOWN,
112 "Unknown",
113 NULL,
114 0,
115 0,
116 0,
117 0,
118 0,
119 0,
120 { 0, 0, 0, 0, 0 },
121 0 },
122
123 { CARD_MIRO,
124 "Pinnacle/Miro TV",
125 NULL,
126 0,
127 0,
128 0,
129 0,
130 0,
131 0,
132 { 0x02, 0x01, 0x00, 0x0a, 1 },
133 0x0f },
134
135 { CARD_HAUPPAUGE,
136 "Hauppauge WinCast/TV",
137 NULL,
138 0,
139 0,
140 0,
141 0,
142 PFC8582_WADDR,
143 (u_char)(256 / EEPROMBLOCKSIZE),
144 { 0x00, 0x02, 0x01, 0x04, 1 },
145 0x0f },
146
147 { CARD_STB,
148 "STB TV/PCI",
149 NULL,
150 0,
151 0,
152 0,
153 0,
154 X24C01_WADDR,
155 (u_char)(128 / EEPROMBLOCKSIZE),
156 { 0x00, 0x01, 0x02, 0x02, 1 },
157 0x0f },
158
159 { CARD_INTEL,
160 "Intel Smart Video III/VideoLogic Captivator PCI",
161 NULL,
162 0,
163 0,
164 0,
165 0,
166 0,
167 0,
168 { 0, 0, 0, 0, 0 },
169 0x00 },
170
171 { CARD_IMS_TURBO,
172 "IMS TV Turbo",
173 NULL,
174 0,
175 0,
176 0,
177 0,
178 PFC8582_WADDR,
179 (u_char)(256 / EEPROMBLOCKSIZE),
180 { 0x01, 0x02, 0x01, 0x00, 1 },
181 0x0f },
182
183 { CARD_AVER_MEDIA,
184 "AVer Media TV/FM",
185 NULL,
186 0,
187 0,
188 0,
189 0,
190 0,
191 0,
192 { 0x0c, 0x08, 0x04, 0x00, 1 },
193 0x1f },
194
195 { CARD_OSPREY,
196 "MMAC Osprey",
197 NULL,
198 0,
199 0,
200 0,
201 0,
202 PFC8582_WADDR,
203 (u_char)(256 / EEPROMBLOCKSIZE),
204 { 0x00, 0x00, 0x00, 0x00, 0 },
205 0 },
206
207 { CARD_NEC_PK,
208 "NEC PK-UG-X017",
209 NULL,
210 0,
211 0,
212 0,
213 0,
214 0,
215 0,
216 { 0x01, 0x02, 0x01, 0x00, 1 },
217 0x0f },
218
219 { CARD_IO_GV,
220 "I/O DATA GV-BCTV2/PCI",
221 NULL,
222 0,
223 0,
224 0,
225 0,
226 0,
227 0,
228 { 0x00, 0x00, 0x00, 0x00, 1 },
229 0x0f },
230
231 { CARD_FLYVIDEO,
232 "FlyVideo",
233 NULL,
234 0,
235 0,
236 0,
237 0,
238 0xac,
239 (u_char)(256 / EEPROMBLOCKSIZE),
240 { 0x000, 0x800, 0x400, 0x8dff00, 1 },
241 0x8dff00 },
242
243 { CARD_ZOLTRIX,
244 "Zoltrix",
245 NULL,
246 0,
247 0,
248 0,
249 0,
250 0,
251 0,
252 { 0x04, 0x01, 0x00, 0x0a, 1 },
253 0x0f },
254
255 { CARD_KISS,
256 "KISS TV/FM PCI",
257 NULL,
258 0,
259 0,
260 0,
261 0,
262 0,
263 0,
264 { 0x0c, 0x00, 0x0b, 0x0b, 1 },
265 0x0f },
266
267 { CARD_VIDEO_HIGHWAY_XTREME,
268 "Video Highway Xtreme",
269 NULL,
270 0,
271 0,
272 0,
273 0,
274 0,
275 0,
276 { 0x00, 0x02, 0x01, 0x04, 1 },
277 0x0f },
278
279 { CARD_ASKEY_DYNALINK_MAGIC_TVIEW,
280 "Askey/Dynalink Magic TView",
281 NULL,
282 0,
283 0,
284 0,
285 0,
286 0,
287 0,
288 { 0x400, 0xE00, 0x400, 0xC00, 1 },
289 0xE00 },
290
291 { CARD_LEADTEK,
292 "Leadtek WinFast TV 2000",
293 NULL,
294 0,
295 0,
296 0,
297 0,
298 0,
299 0,
300
301 { 0x621000, 0x621000, 0x621000, 0xE21000, 1 },
302 0xfff000 },
303
304 { CARD_TERRATVPLUS,
305 "TerraTVplus",
306 NULL,
307 0,
308 0,
309 0,
310 0,
311 0,
312 0,
313 { 0x20000, 0x00000, 0x30000, 0x40000, 1 },
314 0x70000 },
315
316 { CARD_TVWONDER,
317 "ATI TV-Wonder/VE",
318 NULL,
319 0,
320 0,
321 0,
322 0,
323 0,
324 0,
325 { 0x1002, 0x1002, 0x3003, 0x3003, 0x3003 },
326 0x300f },
327
328 { CARD_IO_BCTV3,
329 "I/O DATA GV-BCTV3/PCI",
330 NULL,
331 0,
332 0,
333 0,
334 0,
335 0,
336 0,
337
338 { 0x10000, 0, 0x10000, 0, 1 },
339 0x10f00 },
340
341 { CARD_AOPEN_VA1000,
342 "AOpen VA1000",
343 NULL,
344 0,
345 0,
346 0,
347 0,
348 0,
349 0,
350 { 0x02, 0x00, 0x00, 0x00, 1 },
351 0x18e0 },
352
353 { CARD_ZOLTRIX_GENIE_FM,
354 "Zoltrix Genie TV/FM",
355 NULL,
356 0,
357 0,
358 0,
359 0,
360 0,
361 0,
362 { 0xbc803f, 0xbcb03f, 0xbc903f, 0x0, 1 },
363 0xbcf03f },
364
365 { CARD_LEADTEK_XP,
366 "Leadtek WinFast TV 2000 XP",
367 NULL,
368 0,
369 0,
370 0,
371 0,
372 0,
373 0,
374 { 0x122000, 0x1000, 0x620000, 0x0, 1 },
375 0xb3300 },
376 };
377
378 struct bt848_card_sig bt848_card_signature[1]= {
379
380 { 5,9, {00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 02, 00, 00, 00}}
381 };
382
383
384
385
386
387
388
389 int
390 writeEEProm( bktr_ptr_t bktr, int offset, int count, u_char *data )
391 {
392 return( -1 );
393 }
394
395
396
397
398
399
400 int
401 readEEProm(bktr_ptr_t bktr, int offset, int count, u_char *data)
402 {
403 int x;
404 int addr;
405 int max;
406 int byte;
407
408
409 addr = (int)(bktr->card.eepromAddr & 0xff);
410 if ( addr == 0 )
411 return( -1 );
412
413 max = (int)(bktr->card.eepromSize * EEPROMBLOCKSIZE);
414 if ( (offset + count) > max )
415 return( -1 );
416
417
418 if ( i2cWrite( bktr, addr, offset, -1 ) == -1 )
419 return( -1 );
420
421
422 for ( x = 0; x < count; ++x ) {
423 if ( (byte = i2cRead( bktr, (addr | 1) )) == -1 )
424 return( -1 );
425 data[ x ] = byte;
426 }
427
428 return( 0 );
429 }
430
431
432 #define ABSENT (-1)
433
434
435
436
437
438
439
440
441 int
442 signCard( bktr_ptr_t bktr, int offset, int count, u_char *sig )
443 {
444 int x;
445
446 for ( x = 0; x < 16; ++x )
447 sig[ x ] = 0;
448
449 for ( x = 0; x < count; ++x ) {
450 if ( i2cRead( bktr, (2 * x) + 1 ) != ABSENT ) {
451 sig[ x / 8 ] |= (1 << (x % 8) );
452 }
453 }
454
455 return( 0 );
456 }
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471 static int check_for_i2c_devices( bktr_ptr_t bktr ){
472 int x, temp_read;
473 int i2c_all_0 = 1;
474 int i2c_all_absent = 1;
475 for ( x = 0; x < 128; ++x ) {
476 temp_read = i2cRead( bktr, (2 * x) + 1 );
477 if (temp_read != 0) i2c_all_0 = 0;
478 if (temp_read != ABSENT) i2c_all_absent = 0;
479 }
480
481 if ((i2c_all_0) || (i2c_all_absent)) return 0;
482 else return 1;
483 }
484
485
486
487
488
489
490
491 static int locate_tuner_address( bktr_ptr_t bktr) {
492 if (i2cRead( bktr, 0xc1) != ABSENT) return 0xc0;
493 if (i2cRead( bktr, 0xc3) != ABSENT) return 0xc2;
494 if (i2cRead( bktr, 0xc5) != ABSENT) return 0xc4;
495 if (i2cRead( bktr, 0xc7) != ABSENT) return 0xc6;
496 return -1;
497 }
498
499
500
501
502
503
504
505
506 static int locate_eeprom_address( bktr_ptr_t bktr) {
507 if (i2cRead(bktr, 0xa0) != ABSENT) return 0xa0;
508 if (i2cRead(bktr, 0xac) != ABSENT) return 0xac;
509 if (i2cRead(bktr, 0xae) != ABSENT) return 0xae;
510 return -1;
511 }
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562 #define PCI_VENDOR_LEADTEK_ALT 0x6606
563 #define PCI_VENDOR_LEADTEK_ALT_2 0x6607
564 #define PCI_VENDOR_LEADTEK_ALT_3 0x107d
565 #define PCI_VENDOR_FLYVIDEO 0x1851
566 #define PCI_VENDOR_FLYVIDEO_2 0x1852
567 #define PCI_VENDOR_PINNACLE_ALT 0xBD11
568
569 void
570 probeCard( bktr_ptr_t bktr, int verbose, int unit )
571 {
572 int card, i,j, card_found;
573 int status;
574 u_char probe_signature[128], *probe_temp;
575 int any_i2c_devices;
576 u_char eeprom[256];
577 int tuner_i2c_address = -1;
578 int eeprom_i2c_address = -1;
579
580
581 OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
582 if (bootverbose)
583 printf("%s: GPIO is 0x%08x\n", bktr_name(bktr),
584 INL(bktr, BKTR_GPIO_DATA));
585
586 #ifdef HAUPPAUGE_MSP_RESET
587
588
589
590
591 OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) | (1<<5));
592 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5));
593 DELAY(2500);
594 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) & ~(1<<5));
595 DELAY(2500);
596 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5));
597 DELAY(2500);
598 #endif
599
600
601 any_i2c_devices = check_for_i2c_devices( bktr );
602
603
604
605 #if defined( BKTR_OVERRIDE_CARD )
606 bktr->card = cards[ (card = BKTR_OVERRIDE_CARD) ];
607 goto checkEEPROM;
608 #endif
609 if (bktr->bt848_card != -1 ) {
610 bktr->card = cards[ (card = bktr->bt848_card) ];
611 goto checkEEPROM;
612 }
613
614
615
616
617
618
619
620
621
622
623
624
625 if ((bktr->id==BROOKTREE_878) || (bktr->id==BROOKTREE_879)) {
626
627 eeprom_i2c_address = locate_eeprom_address( bktr );
628 if (eeprom_i2c_address != -1) {
629
630 unsigned int subsystem_vendor_id;
631 unsigned int subsystem_id;
632 unsigned int byte_252, byte_253, byte_254, byte_255;
633
634 bktr->card = cards[ (card = CARD_UNKNOWN) ];
635 bktr->card.eepromAddr = eeprom_i2c_address;
636 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
637
638 if (readEEProm(bktr, 0, 256, eeprom) && bootverbose)
639 printf("%s: error reading EEPROM\n", bktr_name(bktr));
640 byte_252 = (unsigned int)eeprom[252];
641 byte_253 = (unsigned int)eeprom[253];
642 byte_254 = (unsigned int)eeprom[254];
643 byte_255 = (unsigned int)eeprom[255];
644
645 subsystem_id = (byte_252 << 8) | byte_253;
646 subsystem_vendor_id = (byte_254 << 8) | byte_255;
647
648 if (bootverbose)
649 printf("%s: subsystem 0x%04x 0x%04x\n", bktr_name(bktr),
650 subsystem_vendor_id, subsystem_id);
651
652 if (subsystem_vendor_id == PCI_VENDOR_AVERMEDIA) {
653 bktr->card = cards[ (card = CARD_AVER_MEDIA) ];
654 bktr->card.eepromAddr = eeprom_i2c_address;
655 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
656 goto checkTuner;
657 }
658
659 if (subsystem_vendor_id == PCI_VENDOR_HAUPPAUGE) {
660 bktr->card = cards[ (card = CARD_HAUPPAUGE) ];
661 bktr->card.eepromAddr = eeprom_i2c_address;
662 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
663 goto checkTuner;
664 }
665
666 if ((subsystem_vendor_id == PCI_VENDOR_FLYVIDEO) ||
667 (subsystem_vendor_id == PCI_VENDOR_FLYVIDEO_2) ) {
668 bktr->card = cards[ (card = CARD_FLYVIDEO) ];
669 bktr->card.eepromAddr = eeprom_i2c_address;
670 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
671 goto checkTuner;
672 }
673
674 if (subsystem_vendor_id == PCI_VENDOR_STB) {
675 bktr->card = cards[ (card = CARD_STB) ];
676 bktr->card.eepromAddr = eeprom_i2c_address;
677 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
678 goto checkTuner;
679 }
680
681 if (subsystem_vendor_id == PCI_VENDOR_ASKEY) {
682 bktr->card = cards[ (card = CARD_ASKEY_DYNALINK_MAGIC_TVIEW) ];
683 bktr->card.eepromAddr = eeprom_i2c_address;
684 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
685 goto checkTuner;
686 }
687
688 if ((subsystem_vendor_id == PCI_VENDOR_LEADTEK)
689 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT)
690 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT_2)
691 || (subsystem_vendor_id == PCI_VENDOR_LEADTEK_ALT_3)) {
692 if (subsystem_id == PCI_PRODUCT_LEADTEK_WINFAST_XP)
693 bktr->card = cards[ (card = CARD_LEADTEK_XP) ];
694 else
695 bktr->card = cards[ (card = CARD_LEADTEK) ];
696 bktr->card.eepromAddr = eeprom_i2c_address;
697 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
698 goto checkTuner;
699 }
700
701 if (subsystem_vendor_id == PCI_VENDOR_PINNACLE_ALT) {
702 bktr->card = cards[ (card = CARD_MIRO) ];
703 bktr->card.eepromAddr = eeprom_i2c_address;
704 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
705 goto checkTuner;
706 }
707
708 if (subsystem_vendor_id == PCI_VENDOR_TERRATEC) {
709 bktr->card = cards[ (card = CARD_TERRATVPLUS) ];
710 bktr->card.eepromAddr = eeprom_i2c_address;
711 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
712 goto checkTuner;
713 }
714
715 if (subsystem_vendor_id == PCI_VENDOR_ATI) {
716 bktr->card = cards[ (card = CARD_TVWONDER) ];
717 bktr->card.eepromAddr = eeprom_i2c_address;
718 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
719 goto checkTuner;
720 }
721
722
723
724
725
726
727 if (subsystem_vendor_id == PCI_VENDOR_IODATA &&
728 subsystem_id == PCI_PRODUCT_IODATA_GV_BCTV3) {
729 bktr->card = cards[ (card = CARD_IO_BCTV3) ];
730 bktr->card.eepromAddr = eeprom_i2c_address;
731 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
732 goto checkTuner;
733 }
734
735 if (subsystem_vendor_id == PCI_VENDOR_ZOLTRIX) {
736 if (subsystem_id == PCI_PRODUCT_ZOLTRIX_GENIE_TV_FM) {
737 bktr->card = cards[ (card = CARD_ZOLTRIX_GENIE_FM) ];
738 } else {
739 bktr->card = cards[ (card = CARD_ZOLTRIX) ];
740 }
741 bktr->card.eepromAddr = eeprom_i2c_address;
742 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
743 goto checkTuner;
744 }
745
746
747
748 printf("%s: Warning "
749 "- card vendor 0x%04x (model 0x%04x) unknown.\n",
750 bktr_name(bktr), subsystem_vendor_id, subsystem_id);
751 } else
752 printf("%s: Card has no configuration EEPROM. "
753 "Cannot determine card make.\n", bktr_name(bktr));
754 }
755
756
757
758
759
760
761 if (!any_i2c_devices) {
762 bktr->card = cards[ (card = CARD_INTEL) ];
763 bktr->card.eepromAddr = 0;
764 bktr->card.eepromSize = 0;
765 goto checkTuner;
766 }
767
768
769
770
771
772 if ((bktr->id==BROOKTREE_848) ||
773 (bktr->id==BROOKTREE_848A) ||
774 (bktr->id==BROOKTREE_849A)) {
775
776
777 if ( (status = i2cRead( bktr, PFC8582_RADDR )) != ABSENT ) {
778
779
780 bktr->card = cards[ (card = CARD_UNKNOWN) ];
781 bktr->card.eepromAddr = PFC8582_WADDR;
782 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
783 readEEProm(bktr, 0, 128, eeprom );
784
785
786 if (eeprom[0] == 0x84) {
787 bktr->card = cards[ (card = CARD_HAUPPAUGE) ];
788 bktr->card.eepromAddr = PFC8582_WADDR;
789 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
790 goto checkTuner;
791 }
792
793
794 if ( (eeprom[0] == 'M') &&(eeprom[1] == 'M')
795 &&(eeprom[2] == 'A') &&(eeprom[3] == 'C')) {
796 bktr->card = cards[ (card = CARD_OSPREY) ];
797 bktr->card.eepromAddr = PFC8582_WADDR;
798 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
799 goto checkTuner;
800 }
801 printf("%s: Warning: Unknown card type. EEPROM data not recognised\n",
802 bktr_name(bktr));
803 printf("%s: %x %x %x %x\n", bktr_name(bktr),
804 eeprom[0],eeprom[1],eeprom[2],eeprom[3]);
805 }
806
807
808 if ( (status = i2cRead( bktr, X24C01_RADDR )) != ABSENT ) {
809 bktr->card = cards[ (card = CARD_STB) ];
810 bktr->card.eepromAddr = X24C01_WADDR;
811 bktr->card.eepromSize = (u_char)(128 / EEPROMBLOCKSIZE);
812 goto checkTuner;
813 }
814
815 }
816
817 signCard( bktr, 1, 128, (u_char *) &probe_signature );
818
819 if (bootverbose) {
820 printf("%s: card signature: ", bktr_name(bktr));
821 for (j = 0; j < Bt848_MAX_SIGN; j++) {
822 printf(" %02x ", probe_signature[j]);
823 }
824 printf("\n\n");
825 }
826 for (i = 0;
827 i < (sizeof bt848_card_signature)/ sizeof (struct bt848_card_sig);
828 i++ ) {
829
830 card_found = 1;
831 probe_temp = (u_char *) &bt848_card_signature[i].signature;
832
833 for (j = 0; j < Bt848_MAX_SIGN; j++) {
834 if ((probe_temp[j] & 0xf) != (probe_signature[j] & 0xf)) {
835 card_found = 0;
836 break;
837 }
838
839 }
840 if (card_found) {
841 bktr->card = cards[ card = bt848_card_signature[i].card];
842 eeprom_i2c_address = locate_eeprom_address( bktr );
843 if (eeprom_i2c_address != -1) {
844 bktr->card.eepromAddr = eeprom_i2c_address;
845 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
846 } else {
847 bktr->card.eepromAddr = 0;
848 bktr->card.eepromSize = 0;
849 }
850 tuner_i2c_address = locate_tuner_address( bktr );
851 select_tuner( bktr, bt848_card_signature[i].tuner );
852 goto checkDBX;
853 }
854 }
855
856
857 bktr->card = cards[ (card = CARD_MIRO) ];
858
859
860 checkEEPROM:
861
862 eeprom_i2c_address = locate_eeprom_address( bktr );
863 if (eeprom_i2c_address != -1) {
864 bktr->card.eepromAddr = eeprom_i2c_address;
865 bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
866 } else {
867 bktr->card.eepromAddr = 0;
868 bktr->card.eepromSize = 0;
869 }
870
871
872 checkTuner:
873
874
875 tuner_i2c_address = locate_tuner_address( bktr );
876 if ( tuner_i2c_address == -1 ) {
877 select_tuner( bktr, NO_TUNER );
878 goto checkDBX;
879 }
880
881 #if defined( BKTR_OVERRIDE_TUNER )
882 select_tuner( bktr, BKTR_OVERRIDE_TUNER );
883 goto checkDBX;
884 #endif
885 if (bktr->bt848_tuner != -1 ) {
886 select_tuner( bktr, bktr->bt848_tuner & 0xff );
887 goto checkDBX;
888 }
889
890
891 if (!any_i2c_devices) {
892 select_tuner( bktr, NO_TUNER );
893 goto checkDBX;
894 }
895
896
897
898 switch (card) {
899 case CARD_MIRO:
900 switch (((INL(bktr, BKTR_GPIO_DATA) >> 10)-1)&7) {
901 case 0: select_tuner( bktr, TEMIC_PAL ); break;
902 case 1: select_tuner( bktr, PHILIPS_PAL ); break;
903 case 2: select_tuner( bktr, PHILIPS_NTSC ); break;
904 case 3: select_tuner( bktr, PHILIPS_SECAM ); break;
905 case 4: select_tuner( bktr, NO_TUNER ); break;
906 case 5: select_tuner( bktr, PHILIPS_PALI ); break;
907 case 6: select_tuner( bktr, TEMIC_NTSC ); break;
908 case 7: select_tuner( bktr, TEMIC_PALI ); break;
909 }
910 goto checkDBX;
911 break;
912
913 case CARD_HAUPPAUGE:
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971 if (bktr->card.eepromAddr != 0) {
972
973 unsigned char *block_1, *block_2, *block_3, *block_4;
974 int block_1_data_size, block_2_data_size, block_3_data_size;
975 int block_1_total_size, block_2_total_size, block_3_total_size;
976 int block_4_header_size;
977
978 unsigned int model,revision;
979 unsigned char tuner_code;
980 unsigned char no_audio_mux;
981
982 readEEProm(bktr, 0, 128, eeprom);
983
984
985 block_1 = &eeprom[0];
986 block_1_data_size = (block_1[2] << 8 | block_1[1]);
987 block_1_total_size = block_1_data_size + 3;
988
989 block_2 = &eeprom[block_1_total_size];
990 block_2_data_size = (block_2[2] << 8 | block_2[1]);
991 block_2_total_size = block_2_data_size + 3;
992
993 block_3 = &eeprom[block_1_total_size + block_2_total_size];
994 block_3_data_size = (block_3[0] &0x07);
995 block_3_total_size = block_3_data_size + 1;
996
997 block_4 = &eeprom[block_1_total_size +block_2_total_size +block_3_total_size];
998 block_4_header_size = 1;
999
1000 model = (block_1[12] << 8 | block_1[11]);
1001 revision = (block_1[15] << 16 | block_1[14] << 8 | block_1[13]);
1002
1003 tuner_code = block_1[9];
1004
1005 no_audio_mux = ((block_3[3] >> 7) &0x01);
1006
1007 if (no_audio_mux) bktr->audio_mux_present = 0;
1008
1009 if (verbose)
1010 printf("%s: Hauppauge Model %d %c%c%c%c\n",
1011 bktr_name(bktr),
1012 model,
1013 ((revision >> 18) & 0x3f) + 32,
1014 ((revision >> 12) & 0x3f) + 32,
1015 ((revision >> 6) & 0x3f) + 32,
1016 ((revision >> 0) & 0x3f) + 32 );
1017
1018
1019
1020 switch (tuner_code) {
1021
1022 case 0x5:
1023 case 0x0a:
1024 case 0x1a:
1025 select_tuner( bktr, PHILIPS_NTSC );
1026 goto checkDBX;
1027
1028 case 0x4:
1029 case 0x9:
1030 select_tuner( bktr, PHILIPS_SECAM );
1031 goto checkDBX;
1032
1033 case 0x11:
1034 case 0x16:
1035 select_tuner( bktr, PHILIPS_FR1236_SECAM );
1036 goto checkDBX;
1037
1038 case 0x12:
1039 case 0x17:
1040 case 0x21:
1041 select_tuner( bktr, PHILIPS_FR1236_NTSC );
1042 goto checkDBX;
1043
1044 case 0x6:
1045 case 0x8:
1046 case 0xb:
1047 case 0x1d:
1048 case 0x23:
1049 select_tuner( bktr, PHILIPS_PALI );
1050 goto checkDBX;
1051
1052 case 0xd:
1053 select_tuner( bktr, TEMIC_NTSC );
1054 goto checkDBX;
1055
1056 case 0xe:
1057 select_tuner( bktr, TEMIC_PAL );
1058 goto checkDBX;
1059
1060 case 0xf:
1061 select_tuner( bktr, TEMIC_PALI );
1062 goto checkDBX;
1063
1064 case 0x15:
1065 select_tuner( bktr, PHILIPS_FR1216_PAL );
1066 goto checkDBX;
1067
1068 case 0x2a:
1069 bktr->msp_use_mono_source = 1;
1070 select_tuner( bktr, PHILIPS_FR1216_PAL );
1071 goto checkDBX;
1072
1073 default :
1074 printf("%s: Warning - Unknown Hauppauge Tuner 0x%x\n",
1075 bktr_name(bktr), tuner_code);
1076 }
1077 }
1078 break;
1079
1080
1081 case CARD_AVER_MEDIA:
1082
1083
1084
1085
1086 if (bktr->card.eepromAddr != 0) {
1087
1088 u_char tuner_make;
1089 u_char tuner_tv_fm;
1090 u_char tuner_format;
1091 int tuner;
1092
1093 int tuner_0_table[] = {
1094 PHILIPS_NTSC, PHILIPS_PAL,
1095 PHILIPS_PAL, PHILIPS_PAL,
1096 PHILIPS_PAL, PHILIPS_PAL,
1097 PHILIPS_SECAM, PHILIPS_SECAM,
1098 PHILIPS_SECAM, PHILIPS_PAL};
1099
1100 int tuner_0_fm_table[] = {
1101 PHILIPS_FR1236_NTSC, PHILIPS_FR1216_PAL,
1102 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
1103 PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
1104 PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
1105 PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
1106
1107 int tuner_1_table[] = {
1108 TEMIC_NTSC, TEMIC_PAL, TEMIC_PAL,
1109 TEMIC_PAL, TEMIC_PAL, TEMIC_PAL,
1110 TEMIC_SECAM, TEMIC_SECAM, TEMIC_SECAM,
1111 TEMIC_PAL};
1112
1113
1114
1115 readEEProm(bktr, 0, 128, eeprom);
1116
1117 tuner_make = (eeprom[0x41] & 0x7);
1118 tuner_tv_fm = (eeprom[0x41] & 0x18) >> 3;
1119 tuner_format = (eeprom[0x42] & 0xf0) >> 4;
1120
1121
1122 if ( ((tuner_make == 0) || (tuner_make == 2))
1123 && (tuner_format <= 9) && (tuner_tv_fm == 0) ) {
1124 tuner = tuner_0_table[tuner_format];
1125 select_tuner( bktr, tuner );
1126 goto checkDBX;
1127 }
1128
1129 if ( ((tuner_make == 0) || (tuner_make == 2))
1130 && (tuner_format <= 9) && (tuner_tv_fm == 1) ) {
1131 tuner = tuner_0_fm_table[tuner_format];
1132 select_tuner( bktr, tuner );
1133 goto checkDBX;
1134 }
1135
1136 if ( (tuner_make == 1) && (tuner_format <= 9) ) {
1137 tuner = tuner_1_table[tuner_format];
1138 select_tuner( bktr, tuner );
1139 goto checkDBX;
1140 }
1141
1142 printf("%s: Warning - Unknown AVerMedia Tuner Make %d Format %d\n",
1143 bktr_name(bktr), tuner_make, tuner_format);
1144 }
1145 break;
1146
1147 case CARD_LEADTEK:
1148 #if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
1149 select_tuner( bktr, PHILIPS_FR1216_PAL );
1150 #else
1151 select_tuner( bktr, PHILIPS_FR1236_NTSC );
1152 #endif
1153 goto checkDBX;
1154 break;
1155
1156 case CARD_TVWONDER:
1157 select_tuner( bktr, PHILIPS_NTSC );
1158 goto checkDBX;
1159 break;
1160
1161 case CARD_ZOLTRIX_GENIE_FM:
1162 select_tuner( bktr, PHILIPS_FR1236_NTSC );
1163 goto checkDBX;
1164 break;
1165
1166 case CARD_IO_BCTV3:
1167 select_tuner( bktr, ALPS_TSCH5 );
1168 goto checkDBX;
1169 break;
1170
1171 case CARD_LEADTEK_XP:
1172 select_tuner( bktr, TIVISION_TVF5533 );
1173 goto checkDBX;
1174 break;
1175
1176 }
1177
1178
1179
1180
1181
1182
1183
1184
1185 if ( i2cRead( bktr, 0xc1 ) != ABSENT ) {
1186 select_tuner( bktr, TEMIC_NTSC );
1187 goto checkDBX;
1188 }
1189
1190
1191 if ( i2cRead( bktr, 0xc7 ) != ABSENT ) {
1192 select_tuner( bktr, PHILIPS_NTSC );
1193 goto checkDBX;
1194 }
1195
1196
1197
1198
1199 select_tuner( bktr, DEFAULT_TUNER );
1200
1201
1202 checkDBX:
1203 #if defined( BKTR_OVERRIDE_DBX )
1204 bktr->card.dbx = BKTR_OVERRIDE_DBX;
1205 goto checkMSP;
1206 #endif
1207
1208 if (!any_i2c_devices) {
1209 goto checkMSP;
1210 }
1211
1212
1213 if ( i2cRead( bktr, TDA9850_RADDR ) != ABSENT )
1214 bktr->card.dbx = 1;
1215
1216 checkMSP:
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229 #ifndef BKTR_NO_MSP_RESET
1230 if (card == CARD_HAUPPAUGE) {
1231 OUTL(bktr, BKTR_GPIO_OUT_EN, INL(bktr, BKTR_GPIO_OUT_EN) | (1<<5));
1232 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5));
1233 DELAY(2500);
1234 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) & ~(1<<5));
1235 DELAY(2500);
1236 OUTL(bktr, BKTR_GPIO_DATA, INL(bktr, BKTR_GPIO_DATA) | (1<<5));
1237 DELAY(2500);
1238 }
1239 #endif
1240
1241 #if defined( BKTR_OVERRIDE_MSP )
1242 bktr->card.msp3400c = BKTR_OVERRIDE_MSP;
1243 goto checkMSPEnd;
1244 #endif
1245
1246
1247 if (!any_i2c_devices) {
1248 goto checkMSPEnd;
1249 }
1250
1251 if ( i2cRead( bktr, MSP3400C_RADDR ) != ABSENT ) {
1252 bktr->card.msp3400c = 1;
1253 }
1254
1255 checkMSPEnd:
1256
1257 if (bktr->card.msp3400c) {
1258 bktr->msp_addr = MSP3400C_WADDR;
1259 msp_read_id( bktr );
1260 printf("%s: Detected a MSP%s at 0x%x\n", bktr_name(bktr),
1261 bktr->msp_version_string,
1262 bktr->msp_addr);
1263
1264 }
1265
1266
1267 if ( i2cRead( bktr, DPL3518A_RADDR ) != ABSENT ) {
1268 bktr->card.dpl3518a = 1;
1269 }
1270
1271 if (bktr->card.dpl3518a) {
1272 bktr->dpl_addr = DPL3518A_WADDR;
1273 dpl_read_id( bktr );
1274 printf("%s: Detected a DPL%s at 0x%x\n", bktr_name(bktr),
1275 bktr->dpl_version_string,
1276 bktr->dpl_addr);
1277 }
1278
1279
1280
1281
1282
1283 bktr->remote_control = 0;
1284
1285 if (any_i2c_devices) {
1286 if (i2cRead( bktr, HAUP_REMOTE_EXT_RADDR ) != ABSENT ) {
1287 bktr->remote_control = 1;
1288 bktr->remote_control_addr = HAUP_REMOTE_EXT_RADDR;
1289 } else if (i2cRead( bktr, HAUP_REMOTE_INT_RADDR ) != ABSENT ) {
1290 bktr->remote_control = 1;
1291 bktr->remote_control_addr = HAUP_REMOTE_INT_RADDR;
1292 }
1293 }
1294
1295
1296 if (bktr->remote_control) {
1297 int i;
1298 for (i=0; i<5; i++)
1299 i2cRead( bktr, bktr->remote_control_addr );
1300 }
1301
1302
1303 #if defined( BKTR_USE_PLL )
1304 bktr->xtal_pll_mode = BT848_USE_PLL;
1305 goto checkPLLEnd;
1306 #endif
1307
1308 bktr->xtal_pll_mode = BT848_USE_XTALS;
1309
1310
1311 if (card == CARD_OSPREY)
1312 bktr->xtal_pll_mode = BT848_USE_PLL;
1313
1314
1315 if (card == CARD_VIDEO_HIGHWAY_XTREME)
1316 bktr->xtal_pll_mode = BT848_USE_PLL;
1317
1318
1319 if (card == CARD_TVWONDER)
1320 bktr->xtal_pll_mode = BT848_USE_PLL;
1321
1322
1323
1324
1325
1326
1327 if ((bktr->id==BROOKTREE_878 || bktr->id==BROOKTREE_879) )
1328 bktr->xtal_pll_mode = BT848_USE_PLL;
1329
1330
1331 #if defined( BKTR_USE_PLL )
1332 checkPLLEnd:
1333 #endif
1334
1335
1336 bktr->card.tuner_pllAddr = tuner_i2c_address;
1337
1338 if ( verbose ) {
1339 printf( "%s: %s", bktr_name(bktr), bktr->card.name );
1340 if ( bktr->card.tuner )
1341 printf( ", %s tuner", bktr->card.tuner->name );
1342 if ( bktr->card.dbx )
1343 printf( ", dbx stereo" );
1344 if ( bktr->card.msp3400c )
1345 printf( ", msp3400c stereo" );
1346 if ( bktr->card.dpl3518a )
1347 printf( ", dpl3518a dolby" );
1348 if ( bktr->remote_control )
1349 printf( ", remote control" );
1350 printf( ".\n" );
1351 }
1352 }
1353
1354 #undef ABSENT