From owner-freebsd-multimedia Mon Oct 27 14:57:02 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA03304 for multimedia-outgoing; Mon, 27 Oct 1997 14:57:02 -0800 (PST) (envelope-from owner-freebsd-multimedia) Received: from ns1.yes.no (ns1.yes.no [195.119.24.10]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA03292 for ; Mon, 27 Oct 1997 14:56:49 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [194.198.43.36]) by ns1.yes.no (8.8.7/8.8.7) with ESMTP id WAA03104; Mon, 27 Oct 1997 22:56:42 GMT Received: (from eivind@localhost) by bitbox.follo.net (8.8.6/8.8.6) id XAA03407; Mon, 27 Oct 1997 23:56:39 +0100 (MET) Message-ID: <19971027235639.09278@bitbox.follo.net> Date: Mon, 27 Oct 1997 23:56:39 +0100 From: Eivind Eklund To: tomppa@fidata.fi, Joao Carlos Mendes Luis Cc: freebsd-multimedia@FreeBSD.ORG Subject: Re: Bt848 driver patches References: <199710270202.DAA00345@bitbox.follo.net> <199710272216.AAA07436@zeta.fidata.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.69e In-Reply-To: <199710272216.AAA07436@zeta.fidata.fi>; from Tomi Vainio on Tue, Oct 28, 1997 at 12:16:33AM +0200 Sender: owner-freebsd-multimedia@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Tue, Oct 28, 1997 at 12:16:33AM +0200, Tomi Vainio wrote: > Eivind Eklund writes: > > The following patches add PAL support, and make some more of the code > > table-driven than before. Beware that I don't know the correct magic > > for RSVD - heck, I don't even know what it means :-) > > > Your patch broke my tuner mode with Hauppauge model 406 PAL/BDGHI. Ouch - serious typo, NTSC-based instead of PAL-based. Try these two modelines, instead: /* # define BT848_IFORM_F_PALBDGHI (0x3) */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 }, OR /* # define BT848_IFORM_F_PALBDGHI (0x3) */ { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT0 }, XT0 matches what we had before; XT1 matches what the Linux driver has for PAL/BGDHI. Given that we only used XT0 before, while bttv distinush between them, I'd guess it is doing closer to 'the right thing'. Eivind. Here is a patch that include the upper of these ones, as well as adding som missing break statements and modifying the PAL/M entry to (hopefully) be correct. Please test (and sorry for the previous broken patch). Index: brktree_reg.h =================================================================== RCS file: /home/ncvs/src/sys/pci/brktree_reg.h,v retrieving revision 1.8 diff -u -r1.8 brktree_reg.h --- brktree_reg.h 1997/10/07 06:30:00 1.8 +++ brktree_reg.h 1997/10/27 01:23:02 @@ -337,6 +337,10 @@ int horizontal, vertical; /* frame rate . for ntsc is 30 frames per second */ int frame_rate; +/* A-delay and B-delay */ + u_char adelay, bdelay; +/* Iform XTSEL value */ + int iform_xtsel; }; Index: brooktree848.c =================================================================== RCS file: /home/ncvs/src/sys/pci/brooktree848.c,v retrieving revision 1.16 diff -u -r1.16 brooktree848.c --- brooktree848.c 1997/10/08 06:54:43 1.16 +++ brooktree848.c 1997/10/27 22:31:03 @@ -406,10 +406,23 @@ */ static struct format_params format_params[] = { -#define FORMAT_PARAMS_NTSC525 0 - { 525, 22, 480, 910, 135, 754, 640, 780, 30 }, -#define FORMAT_PARAMS_PAL625 1 - { 625, 32, 576, 1135, 186, 922, 768, 944, 25 } +/* # define BT848_IFORM_F_AUTO (0x0) - don't matter. */ + { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, 0 }, +/* # define BT848_IFORM_F_NTSCM (0x1) */ + { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, +/* # define BT848_IFORM_F_NTSCJ (0x2) */ + { 525, 22, 480, 910, 135, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, +/* # define BT848_IFORM_F_PALBDGHI (0x3) */ + { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 }, +/* # define BT848_IFORM_F_PALM (0x4) */ + { 525, 22, 480, 910, 186, 754, 640, 780, 30, 0x68, 0x5d, BT848_IFORM_X_XT0 }, +/*{ 625, 32, 576, 910, 186, 922, 640, 780, 25, 0x68, 0x5d, BT848_IFORM_X_XT0 }, */ +/* # define BT848_IFORM_F_PALN (0x5) */ + { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT1 }, +/* # define BT848_IFORM_F_SECAM (0x6) */ + { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x00, BT848_IFORM_X_XT1 }, +/* # define BT848_IFORM_F_RSVD (0x7) - ???? */ + { 625, 32, 576, 1135, 186, 922, 768, 944, 25, 0x7f, 0x72, BT848_IFORM_X_XT0 }, }; /* @@ -1070,7 +1083,7 @@ BT848_IFORM_X_XT0 | BT848_IFORM_F_NTSCM; bktr->flags = (bktr->flags & ~METEOR_DEV_MASK) | METEOR_DEV0; - bktr->format_params = FORMAT_PARAMS_NTSC525; + bktr->format_params = BT848_IFORM_F_NTSCM; bktr->max_clip_node = 0; @@ -1130,7 +1143,7 @@ /* enable drivers on the GPIO port that control the MUXes */ bktr->base->gpio_out_en = GPIO_AUDIOMUX_BITS; - /* unmure the audio stream */ + /* unmute the audio stream */ set_audio( bktr, AUDIO_UNMUTE ); /* enable stereo if appropriate */ @@ -1399,7 +1412,7 @@ case BT848SFMT: /* set input format */ temp = *(unsigned long*)arg & BT848_IFORM_FORMAT; bt848->iform &= ~BT848_IFORM_FORMAT; - bt848->iform |= temp; + bt848->iform |= (temp | format_params[temp].iform_xtsel); switch( temp ) { case BT848_IFORM_F_AUTO: bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | @@ -1408,23 +1421,25 @@ case BT848_IFORM_F_NTSCM: case BT848_IFORM_F_NTSCJ: - case BT848_IFORM_F_PALM: bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | - METEOR_NTSC; - bt848->adelay = 0x68; - bt848->bdelay = 0x5d; - bktr->format_params = FORMAT_PARAMS_NTSC525; + METEOR_NTSC; + bt848->adelay = format_params[temp].adelay; + bt848->bdelay = format_params[temp].bdelay; + bktr->format_params = temp; break; case BT848_IFORM_F_PALBDGHI: case BT848_IFORM_F_PALN: case BT848_IFORM_F_SECAM: case BT848_IFORM_F_RSVD: + case BT848_IFORM_F_PALM: bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | METEOR_PAL; - bt848->adelay = 0x7f; - bt848->bdelay = 0x72; - bktr->format_params = FORMAT_PARAMS_PAL625; + bt848->adelay = format_params[temp].adelay; + bt848->bdelay = format_params[temp].bdelay; + bktr->format_params = temp; + break; + } break; @@ -1438,7 +1453,7 @@ bt848->iform |= BT848_IFORM_F_NTSCM; bt848->adelay = 0x68; bt848->bdelay = 0x5d; - bktr->format_params = FORMAT_PARAMS_NTSC525; + bktr->format_params = BT848_IFORM_F_NTSCM; break; case METEOR_FMT_PAL: @@ -1448,7 +1463,7 @@ bt848->iform |= BT848_IFORM_F_PALBDGHI; bt848->adelay = 0x7f; bt848->bdelay = 0x72; - bktr->format_params = FORMAT_PARAMS_PAL625; + bktr->format_params = BT848_IFORM_F_PALBDGHI; break; case METEOR_FMT_AUTOMODE: @@ -3410,6 +3425,8 @@ #define PHILIPS_NTSC 4 #define PHILIPS_PAL 5 #define PHILIPS_SECAM 6 +#define TEMIC_PALI 7 +#define PHILIPS_PALI 8 /* XXX FIXME: this list is incomplete */ /* input types */ @@ -3487,7 +3504,23 @@ 0x00, /* PLL write address */ TSA552x_SCONTROL, /* control byte for PLL */ { 0x00, 0x00 }, /* band-switch crosspoints */ - { 0xa0, 0x90, 0x30 } } /* the band-switch values */ + { 0xa0, 0x90, 0x30 } }, /* the band-switch values */ + + /* TEMIC_PAL I */ + { "Temic PAL I", /* the 'name' */ + TTYPE_PAL, /* input type */ + TEMIC_PALI_WADDR, /* PLL write address */ + TSA552x_SCONTROL, /* control byte for PLL */ + { 0x00, 0x00 }, /* band-switch crosspoints */ + { 0x02, 0x04, 0x01 } }, /* the band-switch values */ + + /* PHILIPS_PAL */ + { "Philips PAL I", /* the 'name' */ + TTYPE_PAL, /* input type */ + 0x00, /* PLL write address */ + TSA552x_SCONTROL, /* control byte for PLL */ + { 0x00, 0x00 }, /* band-switch crosspoints */ + { 0xa0, 0x90, 0x30 } }, /* the band-switch values */ }; @@ -3527,12 +3560,19 @@ { int card; int status; + bt848_ptr_t bt848; + + bt848 = bktr->base; #if defined( OVERRIDE_CARD ) bktr->card = cards[ (card = OVERRIDE_CARD) ]; goto checkTuner; #endif + bt848->gpio_out_en = 0; + if (bootverbose) + printf("bktr: GPIO is 0x%08x\n", bt848->gpio_data); + /* look for a tuner */ if ( i2cRead( bktr, TSA552x_RADDR ) == ABSENT ) { bktr->card = cards[ (card = CARD_INTEL) ]; @@ -3562,26 +3602,40 @@ #endif /* differentiate type of tuner */ - if ( i2cRead( bktr, TEMIC_NTSC_RADDR ) != ABSENT ) { + switch (card) { + case CARD_MIRO: + switch (((bt848->gpio_data >> 10)-1)&7) { + case 0: bktr->card.tuner = &tuners[ TEMIC_PAL ]; break; + case 1: bktr->card.tuner = &tuners[ PHILIPS_PAL ]; break; + case 2: bktr->card.tuner = &tuners[ PHILIPS_NTSC ]; break; + case 3: bktr->card.tuner = &tuners[ PHILIPS_SECAM ]; break; + case 4: bktr->card.tuner = &tuners[ NO_TUNER ]; break; + case 5: bktr->card.tuner = &tuners[ PHILIPS_PALI ]; break; + case 6: bktr->card.tuner = &tuners[ TEMIC_NTSC ]; break; + case 7: bktr->card.tuner = &tuners[ TEMIC_PALI ]; break; + } + break; + default: + if ( i2cRead( bktr, TEMIC_NTSC_RADDR ) != ABSENT ) { bktr->card.tuner = &tuners[ TEMIC_NTSC ]; goto checkDBX; - } + } - if ( i2cRead( bktr, PHILIPS_NTSC_RADDR ) != ABSENT ) { + if ( i2cRead( bktr, PHILIPS_NTSC_RADDR ) != ABSENT ) { bktr->card.tuner = &tuners[ PHILIPS_NTSC ]; goto checkDBX; - } + } - if ( card == CARD_HAUPPAUGE ) { + if ( card == CARD_HAUPPAUGE ) { if ( i2cRead( bktr, TEMIC_PALI_RADDR ) != ABSENT ) { - bktr->card.tuner = &tuners[ TEMIC_PAL ]; - goto checkDBX; + bktr->card.tuner = &tuners[ TEMIC_PAL ]; + goto checkDBX; } + } + /* no tuner found */ + bktr->card.tuner = &tuners[ NO_TUNER ]; } - /* no tuner found */ - bktr->card.tuner = &tuners[ NO_TUNER ]; - checkDBX: #if defined( OVERRIDE_DBX ) bktr->card.dbx = OVERRIDE_DBX; @@ -4230,4 +4284,5 @@ /* c-label-offset: -8 */ /* c-continued-statement-offset: 8 */ /* c-tab-always-indent: nil */ +/* tab-width: 8 */ /* End: */