summaryrefslogtreecommitdiffstats
path: root/sys/dev/bktr
diff options
context:
space:
mode:
authorroger <roger@FreeBSD.org>2000-06-26 09:41:32 +0000
committerroger <roger@FreeBSD.org>2000-06-26 09:41:32 +0000
commit07b15689bbec3d7f5024404fd5b6f0ec09cb0a2c (patch)
tree6c22ab09c4e8940bf214a4421504260a8573e2de /sys/dev/bktr
parent358ae698cb54498b21d5c879f71916c674991551 (diff)
downloadFreeBSD-src-07b15689bbec3d7f5024404fd5b6f0ec09cb0a2c.zip
FreeBSD-src-07b15689bbec3d7f5024404fd5b6f0ec09cb0a2c.tar.gz
Update to driver 2.13.
This merges in changes from NetBSD which ensure bktr0 (actually bktr%d) is printed at the start of any output lines. Submitted by: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
Diffstat (limited to 'sys/dev/bktr')
-rwxr-xr-xsys/dev/bktr/CHANGELOG.TXT5
-rw-r--r--sys/dev/bktr/bktr_audio.c44
-rw-r--r--sys/dev/bktr/bktr_card.c94
-rw-r--r--sys/dev/bktr/bktr_card.h4
-rw-r--r--sys/dev/bktr/bktr_core.c127
-rw-r--r--sys/dev/bktr/bktr_core.h3
-rw-r--r--sys/dev/bktr/bktr_os.c199
-rw-r--r--sys/dev/bktr/bktr_reg.h42
-rw-r--r--sys/dev/bktr/bktr_tuner.c28
9 files changed, 306 insertions, 240 deletions
diff --git a/sys/dev/bktr/CHANGELOG.TXT b/sys/dev/bktr/CHANGELOG.TXT
index a210f83..619baee 100755
--- a/sys/dev/bktr/CHANGELOG.TXT
+++ b/sys/dev/bktr/CHANGELOG.TXT
@@ -481,6 +481,9 @@
Thomas Klausner <wiz@netbsd.org>
Fix typo in the new interrupt code.
+2.12 20 May 2000 Merge in NetBSD changes from Thomas Klausner <wiz@netbsd.org>
+ following the import of driver 2.12 into NetBSD
-
+2.13 26 Jun 2000 Merge in more changes from Thomas Klausner <wiz@netbsd.org>
+ syncing this driver with the NetBSD source at 25th June.
diff --git a/sys/dev/bktr/bktr_audio.c b/sys/dev/bktr/bktr_audio.c
index b38cbb7..4ff8950 100644
--- a/sys/dev/bktr/bktr_audio.c
+++ b/sys/dev/bktr/bktr_audio.c
@@ -50,35 +50,35 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
-#ifdef __NetBSD__
-#include <sys/proc.h>
-static int bootverbose = 1;
-#endif
#ifdef __FreeBSD__
#include <machine/clock.h> /* for DELAY */
#include <pci/pcivar.h>
-#endif
#if (__FreeBSD_version >=300000)
#include <machine/bus_memio.h> /* for bus space */
#include <machine/bus.h>
#include <sys/bus.h>
#endif
+#endif
#ifdef __NetBSD__
-#include <dev/ic/ioctl_meteor.h> /* NetBSD location of .h files */
-#include <dev/ic/ioctl_bt848.h>
+#include <sys/proc.h>
+#include <dev/ic/bt8xx.h> /* NetBSD location of .h files */
+#include <dev/pci/bktr/bktr_reg.h>
+#include <dev/pci/bktr/bktr_core.h>
+#include <dev/pci/bktr/bktr_tuner.h>
+#include <dev/pci/bktr/bktr_card.h>
+#include <dev/pci/bktr/bktr_audio.h>
#else
#include <machine/ioctl_meteor.h> /* Traditional location of .h files */
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
-#endif
#include <dev/bktr/bktr_reg.h>
#include <dev/bktr/bktr_core.h>
#include <dev/bktr/bktr_tuner.h>
#include <dev/bktr/bktr_card.h>
#include <dev/bktr/bktr_audio.h>
-
+#endif
/*
* Prototypes for the GV_BCTV specific functions.
@@ -157,7 +157,8 @@ set_audio( bktr_ptr_t bktr, int cmd )
bktr->audio_mute_state = FALSE; /* clear mute */
break;
default:
- printf("bktr: audio cmd error %02x\n", cmd);
+ printf("%s: audio cmd error %02x\n", bktr_name(bktr),
+ cmd);
return( -1 );
}
@@ -200,7 +201,8 @@ set_audio( bktr_ptr_t bktr, int cmd )
temp = INL(bktr, BKTR_GPIO_DATA) & ~bktr->card.gpio_mux_bits;
#if defined( AUDIOMUX_DISCOVER )
OUTL(bktr, BKTR_GPIO_DATA, temp | (cmd & 0xff));
- printf("cmd: %d audio mux %x temp %x \n", cmd,bktr->card.audiomuxs[ idx ], temp );
+ printf("%s: cmd: %d audio mux %x temp %x \n", bktr_name(bktr),
+ cmd, bktr->card.audiomuxs[ idx ], temp );
#else
OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]);
#endif /* AUDIOMUX_DISCOVER */
@@ -447,7 +449,6 @@ void msp_autodetect( bktr_ptr_t bktr ) {
/* FAST sound scheme */
if ( (strncmp("3430G", bktr->msp_version_string, 5) != 0)
&& (bktr->slow_msp_audio == 0) ){
- if(bootverbose)printf("inside fast MSP autodetect code\n");
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0021,0x0001);/* Auto selection of NICAM/MONO mode */
@@ -458,7 +459,6 @@ void msp_autodetect( bktr_ptr_t bktr ) {
/* SLOW sound scheme */
if ( (strncmp("3430G", bktr->msp_version_string, 5) != 0)
&& (bktr->slow_msp_audio == 1) ){
- if (bootverbose)printf("inside slow MSP autodetect code\n");
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0000,0x7300);/* Set volume to 0db gain */
msp_dpl_write(bktr, bktr->msp_addr, 0x10, 0x0020,0x0001);/* Enable Auto format detection */
@@ -469,7 +469,8 @@ void msp_autodetect( bktr_ptr_t bktr ) {
auto_detect = msp_dpl_read(bktr, bktr->msp_addr, 0x10, 0x007e);
loops++;
} while (auto_detect > 0xff && loops < 50);
- if (bootverbose)printf ("Result of autodetect after %dms: %d\n", loops*10, auto_detect);
+ if (bootverbose)printf ("%s: Result of autodetect after %dms: %d\n",
+ bktr_name(bktr), loops*10, auto_detect);
/* Now set the audio baseband processing */
switch (auto_detect) {
@@ -481,13 +482,16 @@ void msp_autodetect( bktr_ptr_t bktr ) {
/* Read the stereo detection value from DSP reg 0x0018 */
DELAY(20000);
stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
- if (bootverbose)printf ("Stereo reg 0x18 a: %d\n", stereo);
+ if (bootverbose)printf ("%s: Stereo reg 0x18 a: %d\n",
+ bktr_name(bktr), stereo);
DELAY(20000);
stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
- if (bootverbose)printf ("Stereo reg 0x18 b: %d\n", stereo);
+ if (bootverbose)printf ("%s: Stereo reg 0x18 b: %d\n",
+ bktr_name(bktr), stereo);
DELAY(20000);
stereo = msp_dpl_read(bktr, bktr->msp_addr, 0x12, 0x0018);
- if (bootverbose)printf ("Stereo reg 0x18 c: %d\n", stereo);
+ if (bootverbose)printf ("%s: Stereo reg 0x18 c: %d\n",
+ bktr_name(bktr), stereo);
if (stereo > 0x0100 && stereo < 0x8000) { /* Seems to be stereo */
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0020);/* Loudspeaker set stereo*/
/*
@@ -496,7 +500,8 @@ void msp_autodetect( bktr_ptr_t bktr ) {
*/
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x3f28);
} else if (stereo > 0x8000) { /* bilingual mode */
- if (bootverbose) printf ("Bilingual mode detected\n");
+ if (bootverbose) printf ("%s: Bilingual mode detected\n",
+ bktr_name(bktr));
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0008,0x0000);/* Loudspeaker */
msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0005,0x0000);/* all spatial effects off */
} else { /* must be mono */
@@ -527,7 +532,8 @@ void msp_autodetect( bktr_ptr_t bktr ) {
case 10: /* i-FM NICAM */
break;
default:
- if (bootverbose) printf ("Unkown autodetection result value: %d\n", auto_detect);
+ if (bootverbose) printf ("%s: Unknown autodetection result value: %d\n",
+ bktr_name(bktr), auto_detect);
}
}
diff --git a/sys/dev/bktr/bktr_card.c b/sys/dev/bktr/bktr_card.c
index 7b80be0..128658b 100644
--- a/sys/dev/bktr/bktr_card.c
+++ b/sys/dev/bktr/bktr_card.c
@@ -56,29 +56,29 @@
#ifdef __FreeBSD__
#include <machine/clock.h> /* for DELAY */
#include <pci/pcivar.h>
-#endif
#if (__FreeBSD_version >=300000)
#include <machine/bus_memio.h> /* for bus space */
#include <machine/bus.h>
#include <sys/bus.h>
#endif
+#endif
#ifdef __NetBSD__
-#include <dev/ic/ioctl_meteor.h> /* NetBSD location for .h files */
-#include <dev/ic/ioctl_bt848.h>
+#include <dev/ic/bt8xx.h> /* NetBSD location for .h files */
+#include <dev/pci/bktr/bktr_reg.h>
+#include <dev/pci/bktr/bktr_core.h>
+#include <dev/pci/bktr/bktr_tuner.h>
+#include <dev/pci/bktr/bktr_card.h>
+#include <dev/pci/bktr/bktr_audio.h>
#else
#include <machine/ioctl_meteor.h> /* Traditional location for .h files */
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
-#endif
#include <dev/bktr/bktr_reg.h>
#include <dev/bktr/bktr_core.h>
#include <dev/bktr/bktr_tuner.h>
#include <dev/bktr/bktr_card.h>
#include <dev/bktr/bktr_audio.h>
-
-#ifdef __NetBSD__
-static int bootverbose = 1;
#endif
/* Various defines */
@@ -110,7 +110,7 @@ static int bootverbose = 1;
#define PFC8582_WADDR 0xa0
#define PFC8582_RADDR 0xa1
-#if BROOKTREE_SYSTEM_DEFAULT == BROOKTREE_PAL
+#if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
#define DEFAULT_TUNER PHILIPS_PALI
#else
#define DEFAULT_TUNER PHILIPS_NTSC
@@ -474,9 +474,9 @@ static int locate_eeprom_address( bktr_ptr_t bktr) {
/*
* 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
- * autodetection and i2c device checks.
+ * BKTR_OVERRIDE_CARD, BKTR_OVERRIDE_TUNER, BKTR_OVERRIDE_DBX and
+ * BKTR_OVERRIDE_MSP can be used to select a specific device,
+ * regardless of the autodetection and i2c device checks.
*
* The scheme used for probing cards faces these problems:
* It is impossible to work out which type of tuner is actually fitted,
@@ -541,7 +541,8 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
/* Select all GPIO bits as inputs */
OUTL(bktr, BKTR_GPIO_OUT_EN, 0);
if (bootverbose)
- printf("bktr: GPIO is 0x%08x\n", INL(bktr, BKTR_GPIO_DATA));
+ printf("%s: GPIO is 0x%08x\n", bktr_name(bktr),
+ INL(bktr, BKTR_GPIO_DATA));
#ifdef HAUPPAUGE_MSP_RESET
/* Reset the MSP34xx audio chip. This resolves bootup card
@@ -562,8 +563,8 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
/* Check for a user specified override on the card selection */
-#if defined( OVERRIDE_CARD )
- bktr->card = cards[ (card = OVERRIDE_CARD) ];
+#if defined( BKTR_OVERRIDE_CARD )
+ bktr->card = cards[ (card = BKTR_OVERRIDE_CARD) ];
goto checkEEPROM;
#endif
if (bktr->bt848_card != -1 ) {
@@ -605,7 +606,7 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
subsystem_vendor_id = (byte_254 << 8) | byte_255;
if ( bootverbose )
- printf("subsystem 0x%04x 0x%04x\n",
+ printf("%s: subsystem 0x%04x 0x%04x\n", bktr_name(bktr),
subsystem_vendor_id, subsystem_id);
if (subsystem_vendor_id == VENDOR_AVER_MEDIA) {
@@ -652,11 +653,13 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
/* Vendor is unknown. We will use the standard probe code */
/* which may not give best results */
- printf("Warning - card vendor 0x%04x (model 0x%04x) unknown.\n",subsystem_vendor_id,subsystem_id);
+ printf("%s: Warning - card vendor 0x%04x (model 0x%04x) unknown.\n",
+ bktr_name(bktr), subsystem_vendor_id, subsystem_id);
}
else
{
- printf("Card has no configuration EEPROM. Cannot determine card make.\n");
+ printf("%s: Card has no configuration EEPROM. Cannot determine card make.\n",
+ bktr_name(bktr));
}
} /* end of bt878/bt879 card detection code */
@@ -705,8 +708,10 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
goto checkTuner;
}
- printf("Warning: Unknown card type. EEPROM data not recognised\n");
- printf("%x %x %x %x\n",eeprom[0],eeprom[1],eeprom[2],eeprom[3]);
+ printf("%s: Warning: Unknown card type. EEPROM data not recognised\n",
+ bktr_name(bktr));
+ printf("%s: %x %x %x %x\n", bktr_name(bktr),
+ eeprom[0],eeprom[1],eeprom[2],eeprom[3]);
}
/* look for an STB card */
@@ -722,7 +727,7 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
signCard( bktr, 1, 128, (u_char *) &probe_signature );
if (bootverbose) {
- printf("card signature \n");
+ printf("%s: card signature: ", bktr_name(bktr));
for (j = 0; j < Bt848_MAX_SIGN; j++) {
printf(" %02x ", probe_signature[j]);
}
@@ -783,8 +788,8 @@ checkTuner:
goto checkDBX;
}
-#if defined( OVERRIDE_TUNER )
- select_tuner( bktr, OVERRIDE_TUNER );
+#if defined( BKTR_OVERRIDE_TUNER )
+ select_tuner( bktr, BKTR_OVERRIDE_TUNER );
goto checkDBX;
#endif
if (bktr->bt848_tuner != -1 ) {
@@ -870,13 +875,13 @@ checkTuner:
model = (eeprom[12] << 8 | eeprom[11]);
revision = (eeprom[15] << 16 | eeprom[14] << 8 | eeprom[13]);
if (verbose)
- printf("bktr%d: Hauppauge Model %d %c%c%c%c\n",
- unit,
- model,
- ((revision >> 18) & 0x3f) + 32,
- ((revision >> 12) & 0x3f) + 32,
- ((revision >> 6) & 0x3f) + 32,
- ((revision >> 0) & 0x3f) + 32 );
+ printf("%s: Hauppauge Model %d %c%c%c%c\n",
+ bktr_name(bktr),
+ model,
+ ((revision >> 18) & 0x3f) + 32,
+ ((revision >> 12) & 0x3f) + 32,
+ ((revision >> 6) & 0x3f) + 32,
+ ((revision >> 0) & 0x3f) + 32 );
/* Determine the tuner type from the eeprom */
tuner_code = eeprom[9];
@@ -927,7 +932,8 @@ checkTuner:
goto checkDBX;
default :
- printf("Warning - Unknown Hauppauge Tuner 0x%x\n",tuner_code);
+ printf("%s: Warning - Unknown Hauppauge Tuner 0x%x\n",
+ bktr_name(bktr), tuner_code);
}
}
break;
@@ -994,13 +1000,13 @@ checkTuner:
goto checkDBX;
}
- printf("Warning - Unknown AVerMedia Tuner Make %d Format %d\n",
- tuner_make, tuner_format);
+ printf("%s: Warning - Unknown AVerMedia Tuner Make %d Format %d\n",
+ bktr_name(bktr), tuner_make, tuner_format);
}
break;
case CARD_LEADTEK:
-#if BROOKTREE_SYSTEM_DEFAULT == BROOKTREE_PAL
+#if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
select_tuner( bktr, PHILIPS_FR1216_PAL );
#else
select_tuner( bktr, PHILIPS_FR1236_NTSC );
@@ -1035,8 +1041,8 @@ checkTuner:
checkDBX:
-#if defined( OVERRIDE_DBX )
- bktr->card.dbx = OVERRIDE_DBX;
+#if defined( BKTR_OVERRIDE_DBX )
+ bktr->card.dbx = BKTR_OVERRIDE_DBX;
goto checkMSP;
#endif
/* Check for i2c devices */
@@ -1073,8 +1079,8 @@ checkMSP:
}
#endif
-#if defined( OVERRIDE_MSP )
- bktr->card.msp3400c = OVERRIDE_MSP;
+#if defined( BKTR_OVERRIDE_MSP )
+ bktr->card.msp3400c = BKTR_OVERRIDE_MSP;
goto checkMSPEnd;
#endif
@@ -1092,9 +1098,9 @@ checkMSPEnd:
if (bktr->card.msp3400c) {
bktr->msp_addr = MSP3400C_WADDR;
msp_read_id( bktr );
- printf("bktr%d: Detected a MSP%s at 0x%x\n", unit,
- bktr->msp_version_string,
- bktr->msp_addr);
+ printf("%s: Detected a MSP%s at 0x%x\n", bktr_name(bktr),
+ bktr->msp_version_string,
+ bktr->msp_addr);
}
@@ -1106,9 +1112,9 @@ checkMSPEnd:
if (bktr->card.dpl3518a) {
bktr->dpl_addr = DPL3518A_WADDR;
dpl_read_id( bktr );
- printf("bktr%d: Detected a DPL%s at 0x%x\n", unit,
- bktr->dpl_version_string,
- bktr->dpl_addr);
+ printf("%s: Detected a DPL%s at 0x%x\n", bktr_name(bktr),
+ bktr->dpl_version_string,
+ bktr->dpl_addr);
}
/* Start of Check Remote */
@@ -1170,7 +1176,7 @@ checkPLLEnd:
bktr->card.tuner_pllAddr = tuner_i2c_address;
if ( verbose ) {
- printf( "%s", bktr->card.name );
+ printf( "%s: %s", bktr_name(bktr), bktr->card.name );
if ( bktr->card.tuner )
printf( ", %s tuner", bktr->card.tuner->name );
if ( bktr->card.dbx )
diff --git a/sys/dev/bktr/bktr_card.h b/sys/dev/bktr/bktr_card.h
index abebb45..272636f 100644
--- a/sys/dev/bktr/bktr_card.h
+++ b/sys/dev/bktr/bktr_card.h
@@ -50,8 +50,8 @@
/*
* If probeCard() fails to detect the correct card on boot you can
* override it by setting adding the following option to your kernel config
- * options OVERRIDE_CARD <card type>
- * eg options OVERRIDE CARD=1
+ * options BKTR_OVERRIDE_CARD <card type>
+ * eg options BKTR_OVERRIDE CARD=1
*
* or using the sysclt hw.bt848.card
* eg sysctl -w hw.bt848.card=1
diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c
index ae8ac66..8fa5c0a 100644
--- a/sys/dev/bktr/bktr_core.c
+++ b/sys/dev/bktr/bktr_core.c
@@ -154,6 +154,12 @@
#include "iicbus_if.h"
#endif
+const char *
+bktr_name(bktr_ptr_t bktr)
+{
+ return bktr->bktr_xname;
+}
+
#if (__FreeBSD__ == 2)
typedef unsigned int uintptr_t;
@@ -174,19 +180,22 @@ typedef unsigned int uintptr_t;
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/inttypes.h> /* uintptr_t */
-#include <dev/ic/ioctl_meteor.h>
-#include <dev/ic/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
-#include <dev/bktr/bktr_reg.h>
-#include <dev/bktr/bktr_tuner.h>
-#include <dev/bktr/bktr_card.h>
-#include <dev/bktr/bktr_audio.h>
-#include <dev/bktr/bktr_core.h>
-#include <dev/bktr/bktr_os.h>
-
-static int bootverbose = 1;
+#include <dev/ic/bt8xx.h>
+#include <dev/pci/bktr/bktr_reg.h>
+#include <dev/pci/bktr/bktr_tuner.h>
+#include <dev/pci/bktr/bktr_card.h>
+#include <dev/pci/bktr/bktr_audio.h>
+#include <dev/pci/bktr/bktr_core.h>
+#include <dev/pci/bktr/bktr_os.h>
static int bt848_format = -1;
+const char *
+bktr_name(bktr_ptr_t bktr)
+{
+ return (bktr->bktr_dev.dv_xname);
+}
+
#endif /* __NetBSD__ || __OpenBSD__ */
@@ -443,12 +452,16 @@ common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev )
/***************************************/
#if defined(__NetBSD__) || defined(__OpenBSD__)
/* allocate space for dma program */
- bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog, DMA_PROG_ALLOC);
- bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog, DMA_PROG_ALLOC)
-;
- /* allocte space for the VBI buffer */
- bktr->vbidata = get_bktr_mem(bktr, &bktr->dm_vbidata, VBI_DATA_SIZE);
- bktr->vbibuffer = get_bktr_mem(bktr, &bktr->dm_vbibuffer, VBI_BUFFER_SIZE);
+ bktr->dma_prog = get_bktr_mem(bktr, &bktr->dm_prog,
+ DMA_PROG_ALLOC);
+ bktr->odd_dma_prog = get_bktr_mem(bktr, &bktr->dm_oprog,
+ DMA_PROG_ALLOC);
+
+ /* allocate space for the VBI buffer */
+ bktr->vbidata = get_bktr_mem(bktr, &bktr->dm_vbidata,
+ VBI_DATA_SIZE);
+ bktr->vbibuffer = get_bktr_mem(bktr, &bktr->dm_vbibuffer,
+ VBI_BUFFER_SIZE);
/* allocate space for pixel buffer */
if ( BROOKTREE_ALLOC )
@@ -474,8 +487,8 @@ common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev )
#endif
if ( bootverbose ) {
- printf("bktr%d: buffer size %d, addr 0x%x\n",
- unit, BROOKTREE_ALLOC, vtophys(buf));
+ printf("%s: buffer size %d, addr 0x%x\n",
+ bktr_name(bktr), BROOKTREE_ALLOC, vtophys(buf));
}
if ( buf != 0 ) {
@@ -633,7 +646,7 @@ common_bktr_intr( void *arg )
status_sum |= (bktr_status & ~(BT848_INT_RSV0|BT848_INT_RSV1));
status_sum |= ((dstatus & (BT848_DSTATUS_COF|BT848_DSTATUS_LOF)) << 6);
#endif /* STATUS_SUM */
- /* printf( " STATUS %x %x %x \n",
+ /* printf( "%s: STATUS %x %x %x \n", bktr_name(bktr),
dstatus, bktr_status, INL(bktr, BKTR_RISC_COUNT) );
*/
@@ -693,7 +706,7 @@ common_bktr_intr( void *arg )
return 0;
/**
- printf( "intr status %x %x %x\n",
+ printf( "%s: intr status %x %x %x\n", bktr_name(bktr),
bktr_status, dstatus, INL(bktr, BKTR_RISC_COUNT) );
*/
@@ -888,7 +901,7 @@ video_open( bktr_ptr_t bktr )
OUTB(bktr, BKTR_ADC, SYNC_LEVEL);
-#if BROOKTREE_SYSTEM_DEFAULT == BROOKTREE_PAL
+#if BKTR_SYSTEM_DEFAULT == BROOKTREE_PAL
video_format = 0;
#else
video_format = 1;
@@ -1122,7 +1135,8 @@ video_read(bktr_ptr_t bktr, int unit, dev_t dev, struct uio *uio)
if (!status) /* successful capture */
status = uiomove((caddr_t)bktr->bigbuf, count, uio);
else
- printf ("bktr%d: read: tsleep error %d\n", unit, status);
+ printf ("%s: read: tsleep error %d\n",
+ bktr_name(bktr), status);
bktr->flags &= ~(METEOR_SINGLE | METEOR_WANT_MASK);
@@ -1518,8 +1532,9 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
if (error && (error != ERESTART)) {
/* Here if we didn't get complete frame */
#ifdef DIAGNOSTIC
- printf( "bktr%d: ioctl: tsleep error %d %x\n",
- unit, error, INL(bktr, BKTR_RISC_COUNT));
+ printf( "%s: ioctl: tsleep error %d %x\n",
+ bktr_name(bktr), error,
+ INL(bktr, BKTR_RISC_COUNT));
#endif
/* stop dma */
@@ -1584,8 +1599,8 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
/* Either even or odd, if even & odd, then these a zero */
if ((geo->oformat & METEOR_GEO_ODD_ONLY) &&
(geo->oformat & METEOR_GEO_EVEN_ONLY)) {
- printf( "bktr%d: ioctl: Geometry odd or even only.\n",
- unit);
+ printf( "%s: ioctl: Geometry odd or even only.\n",
+ bktr_name(bktr));
return( EINVAL );
}
@@ -1601,34 +1616,35 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
if (geo->columns <= 0) {
printf(
- "bktr%d: ioctl: %d: columns must be greater than zero.\n",
- unit, geo->columns);
+ "%s: ioctl: %d: columns must be greater than zero.\n",
+ bktr_name(bktr), geo->columns);
error = EINVAL;
}
else if ((geo->columns & 0x3fe) != geo->columns) {
printf(
- "bktr%d: ioctl: %d: columns too large or not even.\n",
- unit, geo->columns);
+ "%s: ioctl: %d: columns too large or not even.\n",
+ bktr_name(bktr), geo->columns);
error = EINVAL;
}
if (geo->rows <= 0) {
printf(
- "bktr%d: ioctl: %d: rows must be greater than zero.\n",
- unit, geo->rows);
+ "%s: ioctl: %d: rows must be greater than zero.\n",
+ bktr_name(bktr), geo->rows);
error = EINVAL;
}
else if (((geo->rows & 0x7fe) != geo->rows) ||
((geo->oformat & METEOR_GEO_FIELD_MASK) &&
((geo->rows & 0x3fe) != geo->rows)) ) {
printf(
- "bktr%d: ioctl: %d: rows too large or not even.\n",
- unit, geo->rows);
+ "%s: ioctl: %d: rows too large or not even.\n",
+ bktr_name(bktr), geo->rows);
error = EINVAL;
}
if (geo->frames > 32) {
- printf("bktr%d: ioctl: too many frames.\n", unit);
+ printf("%s: ioctl: too many frames.\n",
+ bktr_name(bktr));
error = EINVAL;
}
@@ -1675,8 +1691,8 @@ video_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
bktr->alloc_pages = temp;
if (bootverbose)
printf(
- "bktr%d: ioctl: Allocating %d bytes\n",
- unit, temp*PAGE_SIZE);
+ "%s: ioctl: Allocating %d bytes\n",
+ bktr_name(bktr), temp*PAGE_SIZE);
}
else
error = ENOMEM;
@@ -2142,14 +2158,15 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
temp=(int)*(unsigned long *)arg;
#ifdef BKTR_RADIO_DEBUG
- printf("bktr%d: arg=%d temp=%d\n",unit,(int)*(unsigned long *)arg,temp);
+ printf("%s: arg=%d temp=%d\n", bktr_name(bktr),
+ (int)*(unsigned long *)arg, temp);
#endif
#ifndef BKTR_RADIO_NOFREQCHECK
/* According to the spec. sheet the band: 87.5MHz-108MHz */
/* is supported. */
if(temp<8750 || temp>10800) {
- printf("bktr%d: Radio frequency out of range\n",unit);
+ printf("%s: Radio frequency out of range\n", bktr_name(bktr));
return(EINVAL);
}
#endif
@@ -2158,7 +2175,7 @@ tuner_ioctl( bktr_ptr_t bktr, int unit, ioctl_cmd_t cmd, caddr_t arg, struct pro
temp_mute( bktr, FALSE );
#ifdef BKTR_RADIO_DEBUG
if(temp)
- printf("bktr%d: tv_freq returned: %d\n",unit,temp);
+ printf("%s: tv_freq returned: %d\n", bktr_name(bktr), temp);
#endif
if ( temp < 0 )
return( EINVAL );
@@ -2376,16 +2393,20 @@ dump_bt848( bktr_ptr_t bktr )
int i;
for (i = 0; i < 40; i+=4) {
- printf(" Reg:value : \t%x:%x \t%x:%x \t %x:%x \t %x:%x\n",
+ printf("%s: Reg:value : \t%x:%x \t%x:%x \t %x:%x \t %x:%x\n",
+ bktr_name(bktr),
r[i], INL(bktr, r[i]),
r[i+1], INL(bktr, r[i+1]),
r[i+2], INL(bktr, r[i+2]),
r[i+3], INL(bktr, r[i+3]]));
}
- printf(" INT STAT %x \n", INL(bktr, BKTR_INT_STAT));
- printf(" Reg INT_MASK %x \n", INL(bktr, BKTR_INT_MASK));
- printf(" Reg GPIO_DMA_CTL %x \n", INW(bktr, BKTR_GPIO_DMA_CTL));
+ printf("%s: INT STAT %x \n", bktr_name(bktr),
+ INL(bktr, BKTR_INT_STAT));
+ printf("%s: Reg INT_MASK %x \n", bktr_name(bktr),
+ INL(bktr, BKTR_INT_MASK));
+ printf("%s: Reg GPIO_DMA_CTL %x \n", bktr_name(bktr),
+ INW(bktr, BKTR_GPIO_DMA_CTL));
return( 0 );
}
@@ -2665,7 +2686,7 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
*dma_prog++ = 0;
for(i = 0; i < vbilines; i++) {
*dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples;
- *dma_prog++ = (u_long) vtophys(bktr->vbidata +
+ *dma_prog++ = (u_long) vtophys((caddr_t)bktr->vbidata +
(i * VBI_LINE_SIZE));
}
@@ -2716,7 +2737,7 @@ rgb_vbi_prog( bktr_ptr_t bktr, char i_flag, int cols, int rows, int interlace )
*dma_prog++ = 0;
for(i = 0; i < vbilines; i++) {
*dma_prog++ = OP_WRITE | OP_SOL | OP_EOL | vbisamples;
- *dma_prog++ = (u_long) vtophys(bktr->vbidata +
+ *dma_prog++ = (u_long) vtophys((caddr_t)bktr->vbidata +
((i+MAX_VBI_LINES) * VBI_LINE_SIZE));
}
@@ -3300,7 +3321,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
temp = ((quad_t ) fp->htotal* (quad_t) fp->scaled_hactive * 4096
/ fp->scaled_htotal / bktr->cols) - 4096;
- /* printf("HSCALE value is %d\n",temp); */
+ /* printf("%s: HSCALE value is %d\n", bktr_name(bktr), temp); */
OUTB(bktr, BKTR_E_HSCALE_LO, temp & 0xff);
OUTB(bktr, BKTR_O_HSCALE_LO, temp & 0xff);
OUTB(bktr, BKTR_E_HSCALE_HI, (temp >> 8) & 0xff);
@@ -3308,7 +3329,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
/* horizontal active */
temp = bktr->cols;
- /* printf("HACTIVE value is %d\n",temp); */
+ /* printf("%s: HACTIVE value is %d\n", bktr_name(bktr), temp); */
OUTB(bktr, BKTR_E_HACTIVE_LO, temp & 0xff);
OUTB(bktr, BKTR_O_HACTIVE_LO, temp & 0xff);
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) & ~0x3);
@@ -3325,7 +3346,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
temp = temp & 0x3fe;
- /* printf("HDELAY value is %d\n",temp); */
+ /* printf("%s: HDELAY value is %d\n", bktr_name(bktr), temp); */
OUTB(bktr, BKTR_E_DELAY_LO, temp & 0xff);
OUTB(bktr, BKTR_O_DELAY_LO, temp & 0xff);
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) & ~0xc);
@@ -3356,7 +3377,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
}
tmp_int &= 0x1fff;
- /* printf("VSCALE value is %d\n",tmp_int); */
+ /* printf("%s: VSCALE value is %d\n", bktr_name(bktr), tmp_int); */
OUTB(bktr, BKTR_E_VSCALE_LO, tmp_int & 0xff);
OUTB(bktr, BKTR_O_VSCALE_LO, tmp_int & 0xff);
OUTB(bktr, BKTR_E_VSCALE_HI, INB(bktr, BKTR_E_VSCALE_HI) & ~0x1f);
@@ -3370,7 +3391,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
temp = bktr->capture_area_y_size;
else
temp = fp->vactive;
- /* printf("VACTIVE is %d\n",temp); */
+ /* printf("%s: VACTIVE is %d\n", bktr_name(bktr), temp); */
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) & ~0x30);
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) | ((temp >> 4) & 0x30));
OUTB(bktr, BKTR_E_VACTIVE_LO, temp & 0xff);
@@ -3383,7 +3404,7 @@ build_dma_prog( bktr_ptr_t bktr, char i_flag )
temp = fp->vdelay + (bktr->capture_area_y_offset);
else
temp = fp->vdelay;
- /* printf("VDELAY is %d\n",temp); */
+ /* printf("%s: VDELAY is %d\n", bktr_name(bktr), temp); */
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) & ~0xC0);
OUTB(bktr, BKTR_E_CROP, INB(bktr, BKTR_E_CROP) | ((temp >> 2) & 0xC0));
OUTB(bktr, BKTR_E_VDELAY_LO, temp & 0xff);
@@ -4118,7 +4139,7 @@ i2cProbe( bktr_ptr_t bktr, int addr )
DELAY( BITD ); /* release clock */
}
else {
- OUTL(bktr, BKTR_I2C_DATA_CTL, 0 ;
+ OUTL(bktr, BKTR_I2C_DATA_CTL, 0);
DELAY( BITD ); /* assert LO data */
OUTL(bktr, BKTR_I2C_DATA_CTL, 2);
DELAY( BITD ); /* strobe clock */
diff --git a/sys/dev/bktr/bktr_core.h b/sys/dev/bktr/bktr_core.h
index 790d718..bf41a99 100644
--- a/sys/dev/bktr/bktr_core.h
+++ b/sys/dev/bktr/bktr_core.h
@@ -68,6 +68,9 @@ void msp_dpl_write( bktr_ptr_t bktr, int i2c_addr, unsigned char dev,
#define VBI_SLEEP ((caddr_t)bktr + 1)
+/* device name for printf */
+const char *bktr_name(bktr_ptr_t bktr);
+
/* Prototypes for attatch and interrupt functions */
void common_bktr_attach( bktr_ptr_t bktr, int unit,
u_long pci_id, u_int rev );
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c
index e66f3e9..7ca82a1 100644
--- a/sys/dev/bktr/bktr_os.c
+++ b/sys/dev/bktr/bktr_os.c
@@ -107,18 +107,23 @@
#endif
#ifdef __NetBSD__
-#include <dev/ic/ioctl_meteor.h> /* NetBSD location for .h files */
-#include <dev/ic/ioctl_bt848.h>
+#include <dev/ic/bt8xx.h> /* NetBSD location for .h files */
+#include <dev/pci/bktr/bktr_reg.h>
+#include <dev/pci/bktr/bktr_tuner.h>
+#include <dev/pci/bktr/bktr_card.h>
+#include <dev/pci/bktr/bktr_audio.h>
+#include <dev/pci/bktr/bktr_core.h>
+#include <dev/pci/bktr/bktr_os.h>
#else /* Traditional location for .h files */
#include <machine/ioctl_meteor.h>
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
-#endif
#include <dev/bktr/bktr_reg.h>
#include <dev/bktr/bktr_tuner.h>
#include <dev/bktr/bktr_card.h>
#include <dev/bktr/bktr_audio.h>
#include <dev/bktr/bktr_core.h>
#include <dev/bktr/bktr_os.h>
+#endif
#if defined(__FreeBSD__)
#if (NSMBUS > 0)
@@ -161,9 +166,6 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audi
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>
-static int bootverbose = 1;
-
-
#define BKTR_DEBUG
#ifdef BKTR_DEBUG
int bktr_debug = 0;
@@ -283,6 +285,9 @@ bktr_attach( device_t dev )
unit = device_get_unit(dev);
+ /* build the device name for bktr_name() */
+ snprintf(bktr->bktr_xname, sizeof(bktr->bktr_xname), "bktr%d",unit);
+
/*
* Enable bus mastering and Memory Mapped device
*/
@@ -845,6 +850,9 @@ bktr_attach( pcici_t tag, int unit )
return;
}
+ /* build the device name for bktr_name() */
+ snprintf(bktr->bktr_xname, sizeof(bktr->bktr_xname), "bktr%d",unit);
+
/* Enable Memory Mapping */
fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG);
pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 2);
@@ -1221,7 +1229,6 @@ int bktr_poll( dev_t dev, int events, struct proc *p)
/*****************************/
#if defined(__NetBSD__) || defined(__OpenBSD__)
-
#define IPL_VIDEO IPL_BIO /* XXX */
static int bktr_intr(void *arg) { return common_bktr_intr(arg); }
@@ -1238,12 +1245,12 @@ int bktr_close __P((dev_t, int, int, struct proc *));
int bktr_read __P((dev_t, struct uio *, int));
int bktr_write __P((dev_t, struct uio *, int));
int bktr_ioctl __P((dev_t, ioctl_cmd_t, caddr_t, int, struct proc*));
-int bktr_mmap __P((dev_t, vm_offset_t, int));
+int bktr_mmap __P((dev_t, int, int));
vm_offset_t vm_page_alloc_contig(vm_offset_t, vm_offset_t,
vm_offset_t, vm_offset_t);
-#if defined(__BROKEN_INDIRECT_CONFIG) || defined(__OpenBSD__)
+#if defined(__OpenBSD__)
static int bktr_probe __P((struct device *, void *, void *));
#else
static int bktr_probe __P((struct device *, struct cfdata *, void *));
@@ -1262,9 +1269,10 @@ struct cfdriver bktr_cd = {
};
#endif
-int bktr_probe(parent, match, aux)
- struct device *parent;
-#if defined(__BROKEN_INDIRECT_CONFIG) || defined(__OpenBSD__)
+int
+bktr_probe(parent, match, aux)
+ struct device *parent;
+#if defined(__OpenBSD__)
void *match;
#else
struct cfdata *match;
@@ -1288,7 +1296,7 @@ int bktr_probe(parent, match, aux)
* the attach routine.
*/
static void
-bktr_attach __P((struct device *parent, struct device *self, void *aux))
+bktr_attach(struct device *parent, struct device *self, void *aux)
{
bktr_ptr_t bktr;
u_long latency;
@@ -1367,14 +1375,14 @@ bktr_attach __P((struct device *parent, struct device *self, void *aux))
* map memory
*/
retval = pci_mapreg_map(pa, PCI_MAPREG_START,
- PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
- &bktr->memt, &bktr->memh, &bktr->phys_base,
- &bktr->obmemsz);
- DPR(("pci_mapreg_map: memt %x, memh %x, base %x, size %x\n",
- bktr->memt, (u_int)bktr->memh,
- (u_int)bktr->phys_base, (u_int)bktr->obmemsz));
+ PCI_MAPREG_TYPE_MEM
+ | PCI_MAPREG_MEM_TYPE_32BIT, 0,
+ &bktr->memt, &bktr->memh, NULL,
+ &bktr->obmemsz);
+ DPR(("pci_mapreg_map: memt %x, memh %x, size %x\n",
+ bktr->memt, (u_int)bktr->memh, (u_int)bktr->obmemsz));
if (retval) {
- printf("%s: couldn't map memory\n", bktr->bktr_dev.dv_xname);
+ printf("%s: couldn't map memory\n", bktr_name(bktr));
return;
}
@@ -1389,7 +1397,8 @@ bktr_attach __P((struct device *parent, struct device *self, void *aux))
*/
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
pa->pa_intrline, &ih)) {
- printf("%s: couldn't map interrupt\n", bktr->bktr_dev.dv_xname);
+ printf("%s: couldn't map interrupt\n",
+ bktr_name(bktr));
return;
}
intrstr = pci_intr_string(pa->pa_pc, ih);
@@ -1397,14 +1406,14 @@ bktr_attach __P((struct device *parent, struct device *self, void *aux))
bktr_intr, bktr);
if (bktr->ih == NULL) {
printf("%s: couldn't establish interrupt",
- bktr->bktr_dev.dv_xname);
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- return;
+ bktr_name(bktr));
+ if (intrstr != NULL)
+ printf(" at %s", intrstr);
+ printf("\n");
+ return;
}
if (intrstr != NULL)
- printf("%s: interrupting at %s\n", bktr->bktr_dev.dv_xname,
+ printf("%s: interrupting at %s\n", bktr_name(bktr),
intrstr);
#endif /* __NetBSD__ */
@@ -1418,11 +1427,10 @@ bktr_attach __P((struct device *parent, struct device *self, void *aux))
latency = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_LATENCY_TIMER);
latency = (latency >> 8) & 0xff;
- if ( !latency ) {
- if ( bootverbose ) {
+ if (!latency) {
+ if (bootverbose) {
printf("%s: PCI bus latency was 0 changing to %d",
- bktr->bktr_dev.dv_xname,
- BROOKTREE_DEF_LATENCY_VALUE);
+ bktr_name(bktr), BROOKTREE_DEF_LATENCY_VALUE);
}
latency = BROOKTREE_DEF_LATENCY_VALUE;
pci_conf_write(pa->pa_pc, pa->pa_tag,
@@ -1430,17 +1438,18 @@ bktr_attach __P((struct device *parent, struct device *self, void *aux))
}
- /* Enabled Bus Master and Memory Mapping */
+ /* Enabled Bus Master
+ XXX: check if all old DMA is stopped first (e.g. after warm
+ boot) */
fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
- pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, fun | 2);
- fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
- pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, fun | 4);
+ pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+ fun | PCI_COMMAND_MASTER_ENABLE);
/* read the pci id and determine the card type */
fun = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ID_REG);
rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0x000000ff;
- common_bktr_attach( bktr, unit, fun, rev );
+ common_bktr_attach(bktr, unit, fun, rev);
}
@@ -1468,15 +1477,15 @@ get_bktr_mem(bktr, dmapp, size)
align = PAGE_SIZE;
if (bus_dmamem_alloc(dmat, size, align, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
- printf("bktr%d: Unable to dmamem_alloc of %d bytes\n",
- bktr->bktr_dev.dv_unit, size);
+ printf("%s: Unable to dmamem_alloc of %d bytes\n",
+ bktr_name(bktr), size);
return 0;
}
}
if (bus_dmamem_map(dmat, &seg, rseg, size,
&kva, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
- printf("bktr%d: Unable to dmamem_map of %d bytes\n",
- bktr->bktr_dev.dv_unit, size);
+ printf("%s: Unable to dmamem_map of %d bytes\n",
+ bktr_name(bktr), size);
bus_dmamem_free(dmat, &seg, rseg);
return 0;
}
@@ -1487,15 +1496,15 @@ get_bktr_mem(bktr, dmapp, size)
* Create and locd the DMA map for the DMA area
*/
if (bus_dmamap_create(dmat, size, 1, size, 0, BUS_DMA_NOWAIT, dmapp)) {
- printf("bktr%d: Unable to dmamap_create of %d bytes\n",
- bktr->bktr_dev.dv_unit, size);
+ printf("%s: Unable to dmamap_create of %d bytes\n",
+ bktr_name(bktr), size);
bus_dmamem_unmap(dmat, kva, size);
bus_dmamem_free(dmat, &seg, rseg);
return 0;
}
if (bus_dmamap_load(dmat, *dmapp, kva, size, NULL, BUS_DMA_NOWAIT)) {
- printf("bktr%d: Unable to dmamap_load of %d bytes\n",
- bktr->bktr_dev.dv_unit, size);
+ printf("%s: Unable to dmamap_load of %d bytes\n",
+ bktr_name(bktr), size);
bus_dmamem_unmap(dmat, kva, size);
bus_dmamem_free(dmat, &seg, rseg);
bus_dmamap_destroy(dmat, *dmapp);
@@ -1534,40 +1543,39 @@ free_bktr_mem(bktr, dmap, kva)
#define TUNER_DEV 0x01
#define VBI_DEV 0x02
-#define UNIT(x) ((x) & 0x0f)
-#define FUNCTION(x) ((x >> 4) & 0x0f)
+#define UNIT(x) (minor((x) & 0x0f))
+#define FUNCTION(x) (minor((x >> 4) & 0x0f))
/*
*
*/
int
-bktr_open( dev_t dev, int flags, int fmt, struct proc *p )
+bktr_open(dev_t dev, int flags, int fmt, struct proc *p)
{
bktr_ptr_t bktr;
int unit;
- unit = UNIT( minor(dev) );
+ unit = UNIT(dev);
/* unit out of range */
if ((unit > bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
- return( ENXIO );
+ return(ENXIO);
bktr = bktr_cd.cd_devs[unit];
-
if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */
- return( ENXIO );
+ return(ENXIO);
- switch ( FUNCTION( minor(dev) ) ) {
+ switch (FUNCTION(dev)) {
case VIDEO_DEV:
- return( video_open( bktr ) );
+ return(video_open(bktr));
case TUNER_DEV:
- return( tuner_open( bktr ) );
+ return(tuner_open(bktr));
case VBI_DEV:
- return( vbi_open( bktr ) );
+ return(vbi_open(bktr));
}
- return( ENXIO );
+ return(ENXIO);
}
@@ -1575,56 +1583,48 @@ bktr_open( dev_t dev, int flags, int fmt, struct proc *p )
*
*/
int
-bktr_close( dev_t dev, int flags, int fmt, struct proc *p )
+bktr_close(dev_t dev, int flags, int fmt, struct proc *p)
{
bktr_ptr_t bktr;
int unit;
- unit = UNIT( minor(dev) );
-
- /* unit out of range */
- if ((unit > bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
- return( ENXIO );
+ unit = UNIT(dev);
bktr = bktr_cd.cd_devs[unit];
- switch ( FUNCTION( minor(dev) ) ) {
+ switch (FUNCTION(dev)) {
case VIDEO_DEV:
- return( video_close( bktr ) );
+ return(video_close(bktr));
case TUNER_DEV:
- return( tuner_close( bktr ) );
+ return(tuner_close(bktr));
case VBI_DEV:
- return( vbi_close( bktr ) );
+ return(vbi_close(bktr));
}
- return( ENXIO );
+ return(ENXIO);
}
/*
*
*/
int
-bktr_read( dev_t dev, struct uio *uio, int ioflag )
+bktr_read(dev_t dev, struct uio *uio, int ioflag)
{
bktr_ptr_t bktr;
int unit;
- unit = UNIT(minor(dev));
-
- /* unit out of range */
- if ((unit > bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
- return( ENXIO );
+ unit = UNIT(dev);
bktr = bktr_cd.cd_devs[unit];
- switch ( FUNCTION( minor(dev) ) ) {
+ switch (FUNCTION(dev)) {
case VIDEO_DEV:
- return( video_read( bktr, unit, dev, uio ) );
+ return(video_read(bktr, unit, dev, uio));
case VBI_DEV:
- return( vbi_read( bktr, uio, ioflag ) );
+ return(vbi_read(bktr, uio, ioflag));
}
- return( ENXIO );
+ return(ENXIO);
}
@@ -1632,72 +1632,65 @@ bktr_read( dev_t dev, struct uio *uio, int ioflag )
*
*/
int
-bktr_write( dev_t dev, struct uio *uio, int ioflag )
+bktr_write(dev_t dev, struct uio *uio, int ioflag)
{
/* operation not supported */
- return( EOPNOTSUPP );
+ return(EOPNOTSUPP);
}
/*
*
*/
int
-bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr )
+bktr_ioctl(dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct proc* pr)
{
bktr_ptr_t bktr;
int unit;
- unit = UNIT(minor(dev));
-
- /* unit out of range */
- if ((unit > bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
- return( ENXIO );
+ unit = UNIT(dev);
bktr = bktr_cd.cd_devs[unit];
if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */
- return( ENOMEM );
+ return(ENOMEM);
- switch ( FUNCTION( minor(dev) ) ) {
+ switch (FUNCTION(dev)) {
case VIDEO_DEV:
- return( video_ioctl( bktr, unit, cmd, arg, pr ) );
+ return(video_ioctl(bktr, unit, cmd, arg, pr));
case TUNER_DEV:
- return( tuner_ioctl( bktr, unit, cmd, arg, pr ) );
+ return(tuner_ioctl(bktr, unit, cmd, arg, pr));
}
- return( ENXIO );
+ return(ENXIO);
}
/*
*
*/
int
-bktr_mmap( dev_t dev, vm_offset_t offset, int nprot )
+bktr_mmap(dev_t dev, int offset, int nprot)
{
int unit;
bktr_ptr_t bktr;
- unit = UNIT(minor(dev));
+ unit = UNIT(dev);
- /* unit out of range */
- if ((unit > bktr_cd.cd_ndevs) || (bktr_cd.cd_devs[unit] == NULL))
- return( -1 );
- if (FUNCTION(minor(dev)) > 0)
- return( -1 );
+ if (FUNCTION(dev) > 0) /* only allow mmap on /dev/bktr[n] */
+ return(-1);
bktr = bktr_cd.cd_devs[unit];
- if (offset < 0)
- return( -1 );
+ if ((vaddr_t)offset < 0)
+ return(-1);
- if (offset >= bktr->alloc_pages * PAGE_SIZE)
- return( -1 );
+ if ((vaddr_t)offset >= bktr->alloc_pages * PAGE_SIZE)
+ return(-1);
#ifdef __NetBSD__
return (bus_dmamem_mmap(bktr->dmat, bktr->dm_mem->dm_segs, 1,
- offset, nprot, BUS_DMA_WAITOK));
+ (vaddr_t)offset, nprot, BUS_DMA_WAITOK));
#else
- return( i386_btop(vtophys(bktr->bigbuf) + offset) );
+ return(i386_btop(vtophys(bktr->bigbuf) + offset));
#endif
}
diff --git a/sys/dev/bktr/bktr_reg.h b/sys/dev/bktr/bktr_reg.h
index 31fd356..81bf8da 100644
--- a/sys/dev/bktr/bktr_reg.h
+++ b/sys/dev/bktr/bktr_reg.h
@@ -49,8 +49,42 @@
#include <machine/bus.h> /* struct device */
#include <sys/device.h>
#include <sys/select.h> /* struct selinfo */
+# ifdef DEBUG
+# define bootverbose 1
+# else
+# define bootverbose 0
+# endif
#endif
+/*
+ * The kernel options for the driver now all begin with BKTR.
+ * Support the older kernel options on FreeBSD and OpenBSD.
+ *
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(BROOKTREE_SYSTEM_DEFAULT)
+#define BKTR_SYSTEM_DEFAULT BROOKTREE_SYSTEM_DEFAULT
+#endif
+
+#if defined(OVERRIDE_CARD)
+#define BKTR_OVERRIDE_CARD OVERRIDE_CARD
+#endif
+
+#if defined(OVERRIDE_TUNER)
+#define BKTR_OVERRIDE_TUNER OVERRIDE_TUNER
+#endif
+
+#if defined(OVERRIDE_DBX)
+#define BKTR_OVERRIDE_DBX OVERRIDE_DBX
+#endif
+
+#if defined(OVERRIDE_MSP)
+#define BKTR_OVERRIDE_MSP OVERRIDE_MSP
+#endif
+
+#endif
+
+
#ifndef PCI_LATENCY_TIMER
#define PCI_LATENCY_TIMER 0x0c /* pci timer register */
#endif
@@ -440,7 +474,7 @@ typedef struct bktr_clip bktr_clip_t;
* NetBSD >= 1.3H uses vaddr_t instead of vm_offset_t
*/
#if defined(__NetBSD__) && __NetBSD_Version__ >= 103080000
-typedef vaddr_t vm_offset_t;
+typedef void * vm_offset_t;
#endif
/*
@@ -467,11 +501,6 @@ struct bktr_softc {
bus_dmamap_t dm_mem;
bus_dmamap_t dm_vbidata;
bus_dmamap_t dm_vbibuffer;
-#if __NetBSD_Version__ >= 103080000
- paddr_t phys_base; /* Bt848 register physical address */
-#else
- vm_offset_t phys_base; /* Bt848 register physical address */
-#endif
#endif
#if defined(__OpenBSD__)
@@ -510,6 +539,7 @@ struct bktr_softc {
#if (NSMBUS > 0)
struct bktr_i2c_softc i2c_sc; /* bt848_i2c device */
#endif
+ char bktr_xname[7]; /* device name and unit number */
#endif
/* the following definitions are common over all platforms */
diff --git a/sys/dev/bktr/bktr_tuner.c b/sys/dev/bktr/bktr_tuner.c
index c63798c..0f16547 100644
--- a/sys/dev/bktr/bktr_tuner.c
+++ b/sys/dev/bktr/bktr_tuner.c
@@ -56,25 +56,28 @@
#ifdef __FreeBSD__
#include <machine/clock.h> /* for DELAY */
#include <pci/pcivar.h>
-#endif
#if (__FreeBSD_version >=300000)
#include <machine/bus_memio.h> /* for bus space */
#include <machine/bus.h>
#include <sys/bus.h>
#endif
+#endif
#ifdef __NetBSD__
-#include <dev/ic/ioctl_meteor.h> /* NetBSD .h file location */
-#include <dev/ic/ioctl_bt848.h>
+#include <dev/ic/bt8xx.h> /* NetBSD .h file location */
+#include <dev/pci/bktr/bktr_reg.h>
+#include <dev/pci/bktr/bktr_tuner.h>
+#include <dev/pci/bktr/bktr_card.h>
+#include <dev/pci/bktr/bktr_core.h>
#else
#include <machine/ioctl_meteor.h> /* Traditional .h file location */
#include <machine/ioctl_bt848.h> /* extensions to ioctl_meteor.h */
-#endif
#include <dev/bktr/bktr_reg.h>
#include <dev/bktr/bktr_tuner.h>
#include <dev/bktr/bktr_card.h>
#include <dev/bktr/bktr_core.h>
+#endif
@@ -835,16 +838,17 @@ tv_freq( bktr_ptr_t bktr, int frequency, int type )
/* AFC failed, restore requested frequency */
N = frequency + TBL_IF;
#if defined( TEST_TUNER_AFC )
- printf("do_afc: failed to lock\n");
+ printf("%s: do_afc: failed to lock\n",
+ bktr_name(bktr));
#endif
i2cWrite( bktr, addr, (N>>8) & 0x7f, N & 0xff );
}
else
frequency = N - TBL_IF;
#if defined( TEST_TUNER_AFC )
- printf("do_afc: returned freq %d (%d %% %d)\n", frequency, frequency / 16, frequency % 16);
+ printf("%s: do_afc: returned freq %d (%d %% %d)\n", bktr_name(bktr), frequency, frequency / 16, frequency % 16);
afcDelta = frequency - oldFrequency;
- printf("changed by: %d clicks (%d mod %d)\n", afcDelta, afcDelta / 16, afcDelta % 16);
+ printf("%s: changed by: %d clicks (%d mod %d)\n", bktr_name(bktr), afcDelta, afcDelta / 16, afcDelta % 16);
#endif
}
#endif /* TUNER_AFC */
@@ -913,14 +917,14 @@ do_afc( bktr_ptr_t bktr, int addr, int frequency )
return( -1 );
#if defined( TEST_TUNER_AFC )
- printf( "\nOriginal freq: %d, status: 0x%02x\n", frequency, status );
+ printf( "%s: Original freq: %d, status: 0x%02x\n", bktr_name(bktr), frequency, status );
#endif
for ( step = 0; step < AFC_MAX_STEP; ++step ) {
if ( (status = i2cRead( bktr, addr + 1 )) < 0 )
goto fubar;
if ( !(status & 0x40) ) {
#if defined( TEST_TUNER_AFC )
- printf( "no lock!\n" );
+ printf( "%s: no lock!\n", bktr_name(bktr) );
#endif
goto fubar;
}
@@ -928,14 +932,14 @@ do_afc( bktr_ptr_t bktr, int addr, int frequency )
switch( status & AFC_BITS ) {
case AFC_FREQ_CENTERED:
#if defined( TEST_TUNER_AFC )
- printf( "Centered, freq: %d, status: 0x%02x\n", frequency, status );
+ printf( "%s: Centered, freq: %d, status: 0x%02x\n", bktr_name(bktr), frequency, status );
#endif
return( frequency );
case AFC_FREQ_MINUS_125:
case AFC_FREQ_MINUS_62:
#if defined( TEST_TUNER_AFC )
- printf( "Low, freq: %d, status: 0x%02x\n", frequency, status );
+ printf( "%s: Low, freq: %d, status: 0x%02x\n", bktr_name(bktr), frequency, status );
#endif
--frequency;
break;
@@ -943,7 +947,7 @@ do_afc( bktr_ptr_t bktr, int addr, int frequency )
case AFC_FREQ_PLUS_62:
case AFC_FREQ_PLUS_125:
#if defined( TEST_TUNER_AFC )
- printf( "Hi, freq: %d, status: 0x%02x\n", frequency, status );
+ printf( "%s: Hi, freq: %d, status: 0x%02x\n", bktr_name(bktr), frequency, status );
#endif
++frequency;
break;
OpenPOWER on IntegriCloud