From d32591560a05bb509787de6a756d24d9719523c9 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Tue, 7 Oct 1997 06:30:01 +0000 Subject: [PATCH] Latest round of patches from the author. This driver includes the following patches submitted by: 1.0 Hideyuki Suzuki Japanese Cable support 2.0 Keith Sklower Minor update to the BSDI section so it compiles cleanly on BSDI 3.0 Joao Carlos Mendes Luis ioctl interface to select video format , NTSC, PAL, etc... --- sys/dev/bktr/bktr_core.c | 86 +++++++++++++++++++++++++++++++--- sys/dev/bktr/bktr_reg.h | 9 ---- sys/dev/bktr/ioctl_bt848.h | 25 ++++++++-- sys/i386/include/ioctl_bt848.h | 25 ++++++++-- sys/pci/brktree_reg.h | 9 ---- sys/pci/brooktree848.c | 86 +++++++++++++++++++++++++++++++--- sys/sys/ioctl_bt848.h | 25 ++++++++-- 7 files changed, 226 insertions(+), 39 deletions(-) diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c index 58e5e84f59b..50e4ae00911 100644 --- a/sys/dev/bktr/bktr_core.c +++ b/sys/dev/bktr/bktr_core.c @@ -1,4 +1,4 @@ -/* BT848 1.3-ALPHA Driver for Brooktree's Bt848 based cards. +/* BT848 1.20 Driver for Brooktree's Bt848 based cards. The Brooktree BT848 Driver driver is based upon Mark Tinguely and Jim Lowe's driver for the Matrox Meteor PCI card . The Philips SAA 7116 and SAA 7196 are very different chipsets than @@ -182,6 +182,15 @@ interrupts from a PCI device by default, Added Luigi's, ioctl's BT848_SLNOTCH, BT848_GLNOTCH (set luma notch and get luma not) +1.20 10/5/97 Keith Sklower submitted + a patch to fix compilation of the BSDI's PCI + interface. + Hideyuki Suzuki + Submitted a patch for Japanese cable channels + Joao Carlos Mendes Luis jonny@gta.ufrj.br + Submitted general ioctl to set video broadcast + formats (PAL, NTSC, etc..) previously we depended + on the Bt848 auto video detect feature. */ #define DDB(x) x @@ -251,7 +260,7 @@ typedef u_long ioctl_cmd_t; typedef u_char bool_t; -#define BKTPRI (PZERO+8)|PCATCH +#define BKTRPRI (PZERO+8)|PCATCH static void bktr_intr __P((void *arg)); @@ -285,7 +294,6 @@ static void bktr_intr __P((void *arg)); static bktr_reg_t brooktree[ NBKTR ]; #define BROOKTRE_NUM(mtr) ((bktr - &brooktree[0])/sizeof(bktr_reg_t)) -#define BKTRPRI (PZERO+8)|PCATCH #define UNIT(x) ((x) & 0x0f) #define MINOR(x) ((x >> 4) & 0x0f) #define ATTACH_ARGS pcici_t tag, int unit @@ -327,6 +335,8 @@ static struct cdevsw bktr_cdevsw = #define ATTACH_ARGS \ struct device * const parent, struct device * const self, void * const aux +#define PCI_COMMAND_STATUS_REG PCI_COMMAND + static void bktr_attach( ATTACH_ARGS ); #define NBKTR bktrcd.cd_ndevs #define brooktree *((bktr_ptr_t *)bktrcd.cd_devs) @@ -335,7 +345,6 @@ static int bktr_spl; static int bktr_intr_returning_1(void *arg) { bktr_intr(arg); return (1);} #define disable_intr() { bktr_spl = splhigh(); } #define enable_intr() { splx(bktr_spl); } -static int bktr_intr_returning_1(void *arg) { bktr_intr(arg); return (1);} static int bktr_pci_match(pci_devaddr_t *pa) @@ -872,7 +881,7 @@ bktr_intr( void *arg ) #endif /* STATUS_SUM */ /* printf( " STATUS %x %x %x \n", dstatus, bktr_status, bt848->risc_count ); - */ + */ /* if risc was disabled re-start process again */ if ( !(bktr_status & BT848_INT_RISC_EN) || ((bktr_status & (BT848_INT_FBUS | @@ -1396,6 +1405,38 @@ video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) *(u_short *)arg = temp; break; + case BT848SFMT: /* set input format */ + temp = *(unsigned long*)arg & BT848_IFORM_FORMAT; + bt848->iform &= ~BT848_IFORM_FORMAT; + bt848->iform |= temp; + switch( temp ) { + case BT848_IFORM_F_AUTO: + bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | + METEOR_AUTOMODE; + break; + + 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; + break; + + case BT848_IFORM_F_PALBDGHI: + case BT848_IFORM_F_PALN: + case BT848_IFORM_F_SECAM: + case BT848_IFORM_F_RSVD: + bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | + METEOR_PAL; + bt848->adelay = 0x7f; + bt848->bdelay = 0x72; + bktr->format_params = FORMAT_PARAMS_PAL625; + } + break; + case METEORSFMT: /* set input format */ switch(*(unsigned long *)arg & METEOR_FORM_MASK ) { case 0: /* default */ @@ -1434,6 +1475,11 @@ video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) *(u_long *)arg = bktr->flags & METEOR_FORM_MASK; break; + + case BT848GFMT: /* get input format */ + *(u_long *)arg = bt848->iform & BT848_IFORM_FORMAT; + break; + case METEORSCOUNT: /* (re)set error counts */ cnt = (struct meteor_counts *) arg; bktr->fifo_errors = cnt->fifo_errors; @@ -3790,6 +3836,32 @@ int jpnbcst[] = { #undef IF_FREQ #undef OFFSET +/* + * Japanese Cable Channels: + * + * 1: 91.25MHz - 3: 103.25MHz + * 4: 171.25MHz - 7: 189.25MHz + * 8: 193.25MHz - 12: 217.25MHz + * 13: 109.25MHz - 21: 157.25MHz + * 22: 165.25MHz + * 23: 223.25MHz - 63: 463.25MHz + * + * IF freq: 45.75 mHz + */ +#define OFFSET 6.00 +#define IF_FREQ 45.75 +int jpncable[] = { + 63, (int)(IF_FREQ * FREQFACTOR), 0, + 23, (int)(223.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 22, (int)(165.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 13, (int)(109.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 8, (int)(193.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 4, (int)(171.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 1, (int)( 91.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 0 +}; +#undef IF_FREQ +#undef OFFSET int* freqTable[] = { NULL, @@ -3797,7 +3869,9 @@ int* freqTable[] = { irccable, hrccable, weurope, - jpnbcst + jpnbcst, + jpncable + }; diff --git a/sys/dev/bktr/bktr_reg.h b/sys/dev/bktr/bktr_reg.h index 7d5e230281e..2fb8b3d223d 100644 --- a/sys/dev/bktr/bktr_reg.h +++ b/sys/dev/bktr/bktr_reg.h @@ -67,15 +67,6 @@ struct bt848_registers { # define BT848_IFORM_X_XT1 (0x02<<3) # define BT848_IFORM_X_XT0 (0x01<<3) # define BT848_IFORM_X_RSVD (0x00<<3) -#define BT848_IFORM_FORMAT (0x7<<0) -# define BT848_IFORM_F_RSVD (0x7) -# define BT848_IFORM_F_SECAM (0x6) -# define BT848_IFORM_F_PALN (0x5) -# define BT848_IFORM_F_PALM (0x4) -# define BT848_IFORM_F_PALBDGHI (0x3) -# define BT848_IFORM_F_NTSCJ (0x2) -# define BT848_IFORM_F_NTSCM (0x1) -# define BT848_IFORM_F_AUTO (0x0) BTBYTE (tdec); /* 8, 9,a,b */ BTBYTE (e_crop); /* c, d,e,f */ BTBYTE (e_vdelay_lo); /* 10, 11,12,13 */ diff --git a/sys/dev/bktr/ioctl_bt848.h b/sys/dev/bktr/ioctl_bt848.h index 02febcd62aa..94382aaa8d9 100644 --- a/sys/dev/bktr/ioctl_bt848.h +++ b/sys/dev/bktr/ioctl_bt848.h @@ -9,9 +9,10 @@ #define CHNLSET_CABLEIRC 2 #define CHNLSET_CABLEHRC 3 #define CHNLSET_WEUROPE 4 -#define CHNLSET_JPNBCST 5 -#define CHNLSET_MIN CHNLSET_NABCST -#define CHNLSET_MAX CHNLSET_JPNBCST +#define CHNLSET_JPNBCST 5 +#define CHNLSET_JPNCABLE 6 +#define CHNLSET_MIN CHNLSET_NABCST +#define CHNLSET_MAX CHNLSET_JPNCABLE /* @@ -184,3 +185,21 @@ struct _bktr_clip { /* set clip list */ #define BT848SCLIP _IOW('x', 66, struct _bktr_clip ) #define BT848GCLIP _IOR('x', 66, struct _bktr_clip ) + + +/* set input format */ +#define BT848SFMT _IOW('x', 67, unsigned long ) +#define BT848GFMT _IOR('x', 67, unsigned long ) + +/* XXX - Copied from /sys/pci/brktree_reg.h */ +#define BT848_IFORM_FORMAT (0x7<<0) +# define BT848_IFORM_F_RSVD (0x7) +# define BT848_IFORM_F_SECAM (0x6) +# define BT848_IFORM_F_PALN (0x5) +# define BT848_IFORM_F_PALM (0x4) +# define BT848_IFORM_F_PALBDGHI (0x3) +# define BT848_IFORM_F_NTSCJ (0x2) +# define BT848_IFORM_F_NTSCM (0x1) +# define BT848_IFORM_F_AUTO (0x0) + + diff --git a/sys/i386/include/ioctl_bt848.h b/sys/i386/include/ioctl_bt848.h index 02febcd62aa..94382aaa8d9 100644 --- a/sys/i386/include/ioctl_bt848.h +++ b/sys/i386/include/ioctl_bt848.h @@ -9,9 +9,10 @@ #define CHNLSET_CABLEIRC 2 #define CHNLSET_CABLEHRC 3 #define CHNLSET_WEUROPE 4 -#define CHNLSET_JPNBCST 5 -#define CHNLSET_MIN CHNLSET_NABCST -#define CHNLSET_MAX CHNLSET_JPNBCST +#define CHNLSET_JPNBCST 5 +#define CHNLSET_JPNCABLE 6 +#define CHNLSET_MIN CHNLSET_NABCST +#define CHNLSET_MAX CHNLSET_JPNCABLE /* @@ -184,3 +185,21 @@ struct _bktr_clip { /* set clip list */ #define BT848SCLIP _IOW('x', 66, struct _bktr_clip ) #define BT848GCLIP _IOR('x', 66, struct _bktr_clip ) + + +/* set input format */ +#define BT848SFMT _IOW('x', 67, unsigned long ) +#define BT848GFMT _IOR('x', 67, unsigned long ) + +/* XXX - Copied from /sys/pci/brktree_reg.h */ +#define BT848_IFORM_FORMAT (0x7<<0) +# define BT848_IFORM_F_RSVD (0x7) +# define BT848_IFORM_F_SECAM (0x6) +# define BT848_IFORM_F_PALN (0x5) +# define BT848_IFORM_F_PALM (0x4) +# define BT848_IFORM_F_PALBDGHI (0x3) +# define BT848_IFORM_F_NTSCJ (0x2) +# define BT848_IFORM_F_NTSCM (0x1) +# define BT848_IFORM_F_AUTO (0x0) + + diff --git a/sys/pci/brktree_reg.h b/sys/pci/brktree_reg.h index 7d5e230281e..2fb8b3d223d 100644 --- a/sys/pci/brktree_reg.h +++ b/sys/pci/brktree_reg.h @@ -67,15 +67,6 @@ struct bt848_registers { # define BT848_IFORM_X_XT1 (0x02<<3) # define BT848_IFORM_X_XT0 (0x01<<3) # define BT848_IFORM_X_RSVD (0x00<<3) -#define BT848_IFORM_FORMAT (0x7<<0) -# define BT848_IFORM_F_RSVD (0x7) -# define BT848_IFORM_F_SECAM (0x6) -# define BT848_IFORM_F_PALN (0x5) -# define BT848_IFORM_F_PALM (0x4) -# define BT848_IFORM_F_PALBDGHI (0x3) -# define BT848_IFORM_F_NTSCJ (0x2) -# define BT848_IFORM_F_NTSCM (0x1) -# define BT848_IFORM_F_AUTO (0x0) BTBYTE (tdec); /* 8, 9,a,b */ BTBYTE (e_crop); /* c, d,e,f */ BTBYTE (e_vdelay_lo); /* 10, 11,12,13 */ diff --git a/sys/pci/brooktree848.c b/sys/pci/brooktree848.c index 58e5e84f59b..50e4ae00911 100644 --- a/sys/pci/brooktree848.c +++ b/sys/pci/brooktree848.c @@ -1,4 +1,4 @@ -/* BT848 1.3-ALPHA Driver for Brooktree's Bt848 based cards. +/* BT848 1.20 Driver for Brooktree's Bt848 based cards. The Brooktree BT848 Driver driver is based upon Mark Tinguely and Jim Lowe's driver for the Matrox Meteor PCI card . The Philips SAA 7116 and SAA 7196 are very different chipsets than @@ -182,6 +182,15 @@ interrupts from a PCI device by default, Added Luigi's, ioctl's BT848_SLNOTCH, BT848_GLNOTCH (set luma notch and get luma not) +1.20 10/5/97 Keith Sklower submitted + a patch to fix compilation of the BSDI's PCI + interface. + Hideyuki Suzuki + Submitted a patch for Japanese cable channels + Joao Carlos Mendes Luis jonny@gta.ufrj.br + Submitted general ioctl to set video broadcast + formats (PAL, NTSC, etc..) previously we depended + on the Bt848 auto video detect feature. */ #define DDB(x) x @@ -251,7 +260,7 @@ typedef u_long ioctl_cmd_t; typedef u_char bool_t; -#define BKTPRI (PZERO+8)|PCATCH +#define BKTRPRI (PZERO+8)|PCATCH static void bktr_intr __P((void *arg)); @@ -285,7 +294,6 @@ static void bktr_intr __P((void *arg)); static bktr_reg_t brooktree[ NBKTR ]; #define BROOKTRE_NUM(mtr) ((bktr - &brooktree[0])/sizeof(bktr_reg_t)) -#define BKTRPRI (PZERO+8)|PCATCH #define UNIT(x) ((x) & 0x0f) #define MINOR(x) ((x >> 4) & 0x0f) #define ATTACH_ARGS pcici_t tag, int unit @@ -327,6 +335,8 @@ static struct cdevsw bktr_cdevsw = #define ATTACH_ARGS \ struct device * const parent, struct device * const self, void * const aux +#define PCI_COMMAND_STATUS_REG PCI_COMMAND + static void bktr_attach( ATTACH_ARGS ); #define NBKTR bktrcd.cd_ndevs #define brooktree *((bktr_ptr_t *)bktrcd.cd_devs) @@ -335,7 +345,6 @@ static int bktr_spl; static int bktr_intr_returning_1(void *arg) { bktr_intr(arg); return (1);} #define disable_intr() { bktr_spl = splhigh(); } #define enable_intr() { splx(bktr_spl); } -static int bktr_intr_returning_1(void *arg) { bktr_intr(arg); return (1);} static int bktr_pci_match(pci_devaddr_t *pa) @@ -872,7 +881,7 @@ bktr_intr( void *arg ) #endif /* STATUS_SUM */ /* printf( " STATUS %x %x %x \n", dstatus, bktr_status, bt848->risc_count ); - */ + */ /* if risc was disabled re-start process again */ if ( !(bktr_status & BT848_INT_RISC_EN) || ((bktr_status & (BT848_INT_FBUS | @@ -1396,6 +1405,38 @@ video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) *(u_short *)arg = temp; break; + case BT848SFMT: /* set input format */ + temp = *(unsigned long*)arg & BT848_IFORM_FORMAT; + bt848->iform &= ~BT848_IFORM_FORMAT; + bt848->iform |= temp; + switch( temp ) { + case BT848_IFORM_F_AUTO: + bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | + METEOR_AUTOMODE; + break; + + 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; + break; + + case BT848_IFORM_F_PALBDGHI: + case BT848_IFORM_F_PALN: + case BT848_IFORM_F_SECAM: + case BT848_IFORM_F_RSVD: + bktr->flags = (bktr->flags & ~METEOR_FORM_MASK) | + METEOR_PAL; + bt848->adelay = 0x7f; + bt848->bdelay = 0x72; + bktr->format_params = FORMAT_PARAMS_PAL625; + } + break; + case METEORSFMT: /* set input format */ switch(*(unsigned long *)arg & METEOR_FORM_MASK ) { case 0: /* default */ @@ -1434,6 +1475,11 @@ video_ioctl( bktr_ptr_t bktr, int unit, int cmd, caddr_t arg, struct proc* pr ) *(u_long *)arg = bktr->flags & METEOR_FORM_MASK; break; + + case BT848GFMT: /* get input format */ + *(u_long *)arg = bt848->iform & BT848_IFORM_FORMAT; + break; + case METEORSCOUNT: /* (re)set error counts */ cnt = (struct meteor_counts *) arg; bktr->fifo_errors = cnt->fifo_errors; @@ -3790,6 +3836,32 @@ int jpnbcst[] = { #undef IF_FREQ #undef OFFSET +/* + * Japanese Cable Channels: + * + * 1: 91.25MHz - 3: 103.25MHz + * 4: 171.25MHz - 7: 189.25MHz + * 8: 193.25MHz - 12: 217.25MHz + * 13: 109.25MHz - 21: 157.25MHz + * 22: 165.25MHz + * 23: 223.25MHz - 63: 463.25MHz + * + * IF freq: 45.75 mHz + */ +#define OFFSET 6.00 +#define IF_FREQ 45.75 +int jpncable[] = { + 63, (int)(IF_FREQ * FREQFACTOR), 0, + 23, (int)(223.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 22, (int)(165.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 13, (int)(109.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 8, (int)(193.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 4, (int)(171.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 1, (int)( 91.25 * FREQFACTOR), (int)(OFFSET * FREQFACTOR), + 0 +}; +#undef IF_FREQ +#undef OFFSET int* freqTable[] = { NULL, @@ -3797,7 +3869,9 @@ int* freqTable[] = { irccable, hrccable, weurope, - jpnbcst + jpnbcst, + jpncable + }; diff --git a/sys/sys/ioctl_bt848.h b/sys/sys/ioctl_bt848.h index 02febcd62aa..94382aaa8d9 100644 --- a/sys/sys/ioctl_bt848.h +++ b/sys/sys/ioctl_bt848.h @@ -9,9 +9,10 @@ #define CHNLSET_CABLEIRC 2 #define CHNLSET_CABLEHRC 3 #define CHNLSET_WEUROPE 4 -#define CHNLSET_JPNBCST 5 -#define CHNLSET_MIN CHNLSET_NABCST -#define CHNLSET_MAX CHNLSET_JPNBCST +#define CHNLSET_JPNBCST 5 +#define CHNLSET_JPNCABLE 6 +#define CHNLSET_MIN CHNLSET_NABCST +#define CHNLSET_MAX CHNLSET_JPNCABLE /* @@ -184,3 +185,21 @@ struct _bktr_clip { /* set clip list */ #define BT848SCLIP _IOW('x', 66, struct _bktr_clip ) #define BT848GCLIP _IOR('x', 66, struct _bktr_clip ) + + +/* set input format */ +#define BT848SFMT _IOW('x', 67, unsigned long ) +#define BT848GFMT _IOR('x', 67, unsigned long ) + +/* XXX - Copied from /sys/pci/brktree_reg.h */ +#define BT848_IFORM_FORMAT (0x7<<0) +# define BT848_IFORM_F_RSVD (0x7) +# define BT848_IFORM_F_SECAM (0x6) +# define BT848_IFORM_F_PALN (0x5) +# define BT848_IFORM_F_PALM (0x4) +# define BT848_IFORM_F_PALBDGHI (0x3) +# define BT848_IFORM_F_NTSCJ (0x2) +# define BT848_IFORM_F_NTSCM (0x1) +# define BT848_IFORM_F_AUTO (0x0) + +