summaryrefslogtreecommitdiff
path: root/sys/dev/pci/brooktree848.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-05-19 22:02:32 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-05-19 22:02:32 +0000
commit9be4087c3d281c023bde5e2b725d757df9c87bcf (patch)
tree1815790a41f95f7feff6f426864b3922b6a113ad /sys/dev/pci/brooktree848.c
parentf20c27e4f0b47089a51022e6fe9536f12f33f29e (diff)
merge with freebsd 1.64, for real
Diffstat (limited to 'sys/dev/pci/brooktree848.c')
-rw-r--r--sys/dev/pci/brooktree848.c124
1 files changed, 51 insertions, 73 deletions
diff --git a/sys/dev/pci/brooktree848.c b/sys/dev/pci/brooktree848.c
index b0080d46008..fc451b813f4 100644
--- a/sys/dev/pci/brooktree848.c
+++ b/sys/dev/pci/brooktree848.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: brooktree848.c,v 1.7 1999/02/19 02:54:38 deraadt Exp $ */
+/* $OpenBSD: brooktree848.c,v 1.8 1999/05/19 22:02:31 niklas Exp $ */
/* $FreeBSD: brooktree848.c,v 1.64 1999/01/28 17:47:47 roger Exp $ */
/* BT848 Driver for Brooktree's Bt848, Bt849, Bt878 and Bt 879 based cards.
The Brooktree BT848 Driver driver is based upon Mark Tinguely and
@@ -795,39 +795,6 @@ static struct {
* i2c things:
*/
-/* PLL on a Temic NTSC tuner: 4032FY5 */
-#define TEMIC_NTSC_WADDR 0xc0
-#define TEMIC_NTSC_RADDR 0xc1
-
-/* PLL on a Temic PAL I tuner: 4062FY5 */
-#define TEMIC_PALI_WADDR 0xc2
-#define TEMIC_PALI_RADDR 0xc3
-
-/* PLL on a Philips tuner */
-#define PHILIPS_NTSC_WADDR 0xc6
-#define PHILIPS_NTSC_RADDR 0xc7
-
-/* PLL on a the Philips FR1236MK2 tuner */
-#define PHILIPS_FR1236_NTSC_WADDR 0xc2
-#define PHILIPS_FR1236_NTSC_RADDR 0xc3
-
-/* PLL on a the Philips FR1236MK2 tuner */
-#define PHILIPS_FR1236_SECAM_WADDR 0xc0
-#define PHILIPS_FR1236_SECAM_RADDR 0xc1
-
-/* PLL on a the Philips FR1216MK2 tuner,
- yes, the european version of the tuner is 1216 */
-#define PHILIPS_FR1216_PAL_WADDR 0xc2
-#define PHILIPS_FR1216_PAL_RADDR 0xc3
-
-/* guaranteed address for any TSA5522/3 (PLL on all(?) tuners) */
-#define TSA552x_WADDR 0xc2
-#define TSA552x_RADDR 0xc3
-
-#define PHILIPS_PAL_WADDR 0xc2
-#define PHILIPS_PAL_RADDR 0xc3
-
-
#define TSA552x_CB_MSB (0x80)
#define TSA552x_CB_CP (1<<6)
#define TSA552x_CB_T2 (1<<5)
@@ -945,7 +912,6 @@ static struct {
struct TUNER {
char* name;
u_char type;
- u_char pllAddr;
u_char pllControl;
u_char bandLimits[ 2 ];
u_char bandAddrs[ 3 ];
@@ -1095,7 +1061,7 @@ static const struct TUNER tuners[] = {
#define CARD_STB 3
#define CARD_INTEL 4
#define CARD_IMS_TURBO 5
-#define CARD_AVER_MEDIA 6
+#define CARD_AVER_MEDIA 6
#define Bt848_MAX_CARD 7
/*
@@ -1175,6 +1141,7 @@ static const struct CARDTYPE cards[] = {
0, /* EEProm type */
0, /* EEProm size */
{ 0x0c, 0x00, 0x0b, 0x0b, 1 } }, /* audio MUX values */
+
};
struct bt848_card_sig bt848_card_signature[1]= {
@@ -2053,12 +2020,13 @@ video_open( bktr_ptr_t bktr )
bt848->bdelay = format_params[bktr->format_params].bdelay;
frame_rate = format_params[bktr->format_params].frame_rate;
-#ifdef BKTR_USE_PLL
- bt848->tgctrl=0;
- bt848->pll_f_lo=0xf9;
- bt848->pll_f_hi=0xdc;
- bt848->pll_f_xci=0x8e;
-#endif
+ /* enable PLL mode using 28Mhz crystal for PAL/SECAM users */
+ if (bktr->xtal_pll_mode == BT848_USE_PLL) {
+ bt848->tgctrl=0;
+ bt848->pll_f_lo=0xf9;
+ bt848->pll_f_hi=0xdc;
+ bt848->pll_f_xci=0x8e;
+ }
bktr->flags = (bktr->flags & ~METEOR_DEV_MASK) | METEOR_DEV0;
@@ -2999,7 +2967,7 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr )
break;
case TVTUNER_GETSTATUS:
- temp = i2cRead( bktr, TSA552x_RADDR );
+ temp = i2cRead( bktr, bktr->card.tuner_pllAddr + 1 );
*(unsigned long *)arg = temp & 0xff;
break;
@@ -4337,13 +4305,12 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
/* end of video params */
-#ifdef BKTR_USE_PLL
- if (fp->iform_xtsel==BT848_IFORM_X_XT1) {
+ if ((bktr->xtal_pll_mode == BT848_USE_PLL)
+ && (fp->iform_xtsel==BT848_IFORM_X_XT1)) {
bt848->tgctrl=8; /* Select PLL mode */
} else {
bt848->tgctrl=0; /* Select Normal xtal 0/xtal 1 mode */
}
-#endif
/* capture control */
switch (i_flag) {
@@ -5257,6 +5224,19 @@ static int check_for_i2c_devices( bktr_ptr_t bktr ){
}
/*
+ * Temic/Philips datasheets say tuners can be at i2c addresses 0xc0, 0xc2,
+ * 0xc4 or 0xc6, settable by links on the tuner
+ * Determine the actual address used on the TV card by probing read addresses
+ */
+static int locate_tuner_address( bktr_ptr_t bktr) {
+ if (i2cRead( bktr, 0xc1) != ABSENT) return 0xc0;
+ if (i2cRead( bktr, 0xc3) != ABSENT) return 0xc2;
+ if (i2cRead( bktr, 0xc5) != ABSENT) return 0xc4;
+ if (i2cRead( bktr, 0xc7) != ABSENT) return 0xc6;
+ return -1; /* no tuner found */
+}
+
+/*
* determine the card brand/model
* OVERRIDE_CARD, OVERRIDE_TUNER, OVERRIDE_DBX and OVERRIDE_MSP
* can be used to select a specific device, regardless of the
@@ -5299,7 +5279,6 @@ static int check_for_i2c_devices( bktr_ptr_t bktr ){
#define VENDOR_AVER_MEDIA 0x1431
#define VENDOR_HAUPPAUGE 0x0070
-
static void
probeCard( bktr_ptr_t bktr, int verbose )
{
@@ -5382,12 +5361,6 @@ probeCard( bktr_ptr_t bktr, int verbose )
goto checkTuner;
}
- /* look for a tuner */
- if ( i2cRead( bktr, TSA552x_RADDR ) == ABSENT ) {
- bktr->card = cards[ (card = CARD_INTEL) ];
- bktr->card.tuner = &tuners[ NO_TUNER ];
- goto checkDBX;
- }
/* Look for Hauppauge and STB cards by the presence of an EEPROM */
/* Note: Bt878 based cards also use EEPROMs so we can only do this */
@@ -5440,6 +5413,15 @@ probeCard( bktr_ptr_t bktr, int verbose )
bktr->card = cards[ (card = CARD_MIRO) ];
checkTuner:
+
+ /* look for a tuner */
+ tuner_i2c_address = locate_tuner_address( bktr );
+ if ( tuner_i2c_address == -1 ) {
+ bktr->card = cards[ (card = CARD_INTEL) ];
+ bktr->card.tuner = &tuners[ NO_TUNER ];
+ goto checkDBX;
+ }
+
#if defined( OVERRIDE_TUNER )
bktr->card.tuner = &tuners[ OVERRIDE_TUNER ];
goto checkDBX;
@@ -5536,6 +5518,10 @@ checkTuner:
bktr->card.tuner = &tuners[ PHILIPS_PALI ];
goto checkDBX;
+ case 0xd:
+ bktr->card.tuner = &tuners[ TEMIC_NTSC ];
+ goto checkDBX;
+
case 0xe:
bktr->card.tuner = &tuners[ TEMIC_PAL];
goto checkDBX;
@@ -5557,34 +5543,25 @@ checkTuner:
/* At this point, a goto checkDBX has not occured */
/* We have not been able to select a Tuner */
- /* We could simply go for No Tuner, but by some guesswork */
- /* we can try and select a suitable tuner */
+ /* Some cards make use of the tuner address to */
+ /* identify the make/model of tuner */
-
- /* At address 0xc0/0xc1 is TEMIC NTSC and PHILIPS_FR1236_SECAM tuner*/
- /* If we find a tuner at this address, assume it is TEMIC NTSC */
- /* Sorry SECAM users */
-
- if ( i2cRead( bktr, TEMIC_NTSC_RADDR ) != ABSENT ) {
+ /* At address 0xc0/0xc1 we often find a TEMIC NTSC */
+ if ( i2cRead( bktr, 0xc1 ) != ABSENT ) {
bktr->card.tuner = &tuners[ TEMIC_NTSC ];
goto checkDBX;
}
-
- /* At address 0xc6/0xc7 is the PHILIPS NTSC Tuner */
- /* If we find a tuner at this address, assume it is PHILIPS NTSC */
- /* PHILIPS NTSC Tuner is at address 0xc6 / 0xc7 */
-
- if ( i2cRead( bktr, PHILIPS_NTSC_RADDR ) != ABSENT ) {
+
+ /* At address 0xc6/0xc7 we often find a PHILIPS NTSC Tuner */
+ if ( i2cRead( bktr, 0xc7 ) != ABSENT ) {
bktr->card.tuner = &tuners[ PHILIPS_NTSC ];
goto checkDBX;
}
- /* At address 0xc2/0xc3 is the TEMIC_PALI, PHILIPS_PAL, */
- /* PHILIPS_FR_NTSC and PHILIPS_FR_PAL Tuners */
- /* and we cannot tell which is which. */
+ /* Address 0xc2/0xc3 is default (or common address) for several */
+ /* tuners and we cannot tell which is which. */
/* Default to No Tuner */
-
/* no tuner found */
bktr->card.tuner = &tuners[ NO_TUNER ];
@@ -5656,8 +5633,8 @@ checkMSPEnd:
}
/* If a remote control is found, poll it 5 times to turn off the LED */
if (bktr->remote_control) {
- int i;
- for (i=0; i<5; i++)
+ int i;
+ for (i=0; i<5; i++)
i2cRead( bktr, bktr->remote_control_addr );
}
/* End of Check Remote */
@@ -6497,3 +6474,4 @@ vm_page_alloc_contig(size, low, high, alignment)
/* c-tab-always-indent: nil */
/* tab-width: 8 */
/* End: */
+