aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorRoger Hardiman <roger@FreeBSD.org>2000-09-10 14:34:08 +0000
committerRoger Hardiman <roger@FreeBSD.org>2000-09-10 14:34:08 +0000
commitdd11af663730660c9485a30adce19ef8d4b31ee7 (patch)
treefc576b808fef21222887397a350041b27f4aed37 /sys
parent452d07c1ce31c128e5bf4b42fe862bd7b8b9f4e1 (diff)
Notes
Diffstat (limited to 'sys')
-rwxr-xr-xsys/dev/bktr/CHANGELOG.TXT11
-rw-r--r--sys/dev/bktr/bktr_card.c7
-rw-r--r--sys/dev/bktr/bktr_core.c65
-rw-r--r--sys/dev/bktr/bktr_mem.c173
-rw-r--r--sys/dev/bktr/bktr_mem.h63
-rw-r--r--sys/dev/bktr/bktr_os.c6
-rw-r--r--sys/dev/bktr/bktr_reg.h8
7 files changed, 307 insertions, 26 deletions
diff --git a/sys/dev/bktr/CHANGELOG.TXT b/sys/dev/bktr/CHANGELOG.TXT
index aaf845560ee2..d542093166cd 100755
--- a/sys/dev/bktr/CHANGELOG.TXT
+++ b/sys/dev/bktr/CHANGELOG.TXT
@@ -491,3 +491,14 @@
required for Josef Karthauser <joe@pavilion.net>
Change the structure of some of the #include files and
merge in more NetBSD changes.
+
+2.15 10 Sep 2000 Add support for bktr_mem, a module to hold onto the bktr
+ drives's contiguous memory buffers even when it is unloaded
+ and reloaded.
+ Simplify the use of the optional SMBUS i2c code by using a new
+ #define called BKTR_USE_FREEBSD_SMBUS.
+ Poul-Henning Kamp <phk@freebsd.org> changed the DEVFS code.
+ Peter Wemm <peter@freebsd.org> fixed an SMBUS warning.
+ Alexander Langer <alex@cichlids.com> fixed some FreeBSD newbus
+ resource allocation problems (FreeBSD PR kern/18744).
+
diff --git a/sys/dev/bktr/bktr_card.c b/sys/dev/bktr/bktr_card.c
index 979c8d4c1099..8702f57a8984 100644
--- a/sys/dev/bktr/bktr_card.c
+++ b/sys/dev/bktr/bktr_card.c
@@ -521,6 +521,7 @@ static int locate_eeprom_address( bktr_ptr_t bktr) {
#define VENDOR_AVER_MEDIA 0x1461
#define VENDOR_HAUPPAUGE 0x0070
#define VENDOR_FLYVIDEO 0x1851
+#define VENDOR_FLYVIDEO_2 0x1852
#define VENDOR_STB 0x10B4
#define VENDOR_ASKEY_COMP 0x144F
#define VENDOR_LEADTEK 0x6606
@@ -623,7 +624,8 @@ probeCard( bktr_ptr_t bktr, int verbose, int unit )
goto checkTuner;
}
- if (subsystem_vendor_id == VENDOR_FLYVIDEO) {
+ if ((subsystem_vendor_id == VENDOR_FLYVIDEO)
+ || (subsystem_vendor_id == VENDOR_FLYVIDEO_2) ) {
bktr->card = cards[ (card = CARD_FLYVIDEO) ];
bktr->card.eepromAddr = eeprom_i2c_address;
bktr->card.eepromSize = (u_char)(256 / EEPROMBLOCKSIZE);
@@ -872,7 +874,7 @@ checkTuner:
0x29 Temic 4006FN5 BG/I/DK
0x2a Temic 4009FR5 BG FM
0x2b Temic 4046FM5 B/G, I, D/K, L/L'
- 0x2c Temic 4009FN5 B/G, I, D/K, FM (no demod)
+ 0x2c Temic 4009FN5 B/G, I, D/K, FM (no demod) PHILIPS_PALI
0x2d Philips TD1536D_FH_44 MN/ATSCDigital DUAL INPUT
*/
@@ -926,6 +928,7 @@ checkTuner:
case 0xb:
case 0x1d:
case 0x23:
+ case 0x2c:
select_tuner( bktr, PHILIPS_PALI );
goto checkDBX;
diff --git a/sys/dev/bktr/bktr_core.c b/sys/dev/bktr/bktr_core.c
index 3a50b03f9c68..e6e0da74fd4c 100644
--- a/sys/dev/bktr/bktr_core.c
+++ b/sys/dev/bktr/bktr_core.c
@@ -145,8 +145,11 @@
#include <dev/bktr/bktr_audio.h>
#include <dev/bktr/bktr_os.h>
#include <dev/bktr/bktr_core.h>
+#if defined(BKTR_FREEBSD_MODULE)
+#include <dev/bktr/bktr_mem.h>
+#endif
-#if (NSMBUS > 0)
+#if defined(BKTR_USE_FREEBSD_SMBUS)
#include <dev/bktr/bktr_i2c.h>
#include <dev/smbus/smbconf.h>
#include <dev/iicbus/iiconf.h>
@@ -442,7 +445,7 @@ static void remote_read(bktr_ptr_t bktr, struct bktr_remote *remote);
static int common_ioctl( bktr_ptr_t bktr, ioctl_cmd_t cmd, caddr_t arg );
-#if ((!defined(__FreeBSD__)) || (NSMBUS == 0) )
+#if !defined(BKTR_USE_FREEBSD_SMBUS)
/*
* i2c primitives for low level control of i2c bus. Added for MSP34xx control
*/
@@ -460,7 +463,8 @@ static int i2c_read_byte( bktr_ptr_t bktr, unsigned char *data, int last );
void
common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev )
{
- vm_offset_t buf;
+ vm_offset_t buf = 0;
+ int need_to_allocate_memory = 1;
/***************************************/
/* *** OS Specific memory routines *** */
@@ -486,21 +490,48 @@ common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev )
#endif
#if defined(__FreeBSD__) || defined(__bsdi__)
- /* allocate space for dma program */
- bktr->dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC);
- bktr->odd_dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC);
- /* allocte space for the VBI buffer */
- bktr->vbidata = get_bktr_mem(unit, VBI_DATA_SIZE);
- bktr->vbibuffer = get_bktr_mem(unit, VBI_BUFFER_SIZE);
+/* If this is a module, check if there is any currently saved contiguous memory */
+#if defined(BKTR_FREEBSD_MODULE)
+ if (bktr_has_stored_addresses(unit) == 1) {
+ /* recover the addresses */
+ bktr->dma_prog = bktr_retrieve_address(unit, BKTR_MEM_DMA_PROG);
+ bktr->odd_dma_prog = bktr_retrieve_address(unit, BKTR_MEM_ODD_DMA_PROG);
+ bktr->vbidata = bktr_retrieve_address(unit, BKTR_MEM_VBIDATA);
+ bktr->vbibuffer = bktr_retrieve_address(unit, BKTR_MEM_VBIBUFFER);
+ buf = bktr_retrieve_address(unit, BKTR_MEM_BUF);
+ need_to_allocate_memory = 0;
+ }
+#endif
+
+ if (need_to_allocate_memory == 1) {
+ /* allocate space for dma program */
+ bktr->dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC);
+ bktr->odd_dma_prog = get_bktr_mem(unit, DMA_PROG_ALLOC);
- /* allocate space for pixel buffer */
- if ( BROOKTREE_ALLOC )
- buf = get_bktr_mem(unit, BROOKTREE_ALLOC);
- else
- buf = 0;
+ /* allocte space for the VBI buffer */
+ bktr->vbidata = get_bktr_mem(unit, VBI_DATA_SIZE);
+ bktr->vbibuffer = get_bktr_mem(unit, VBI_BUFFER_SIZE);
+
+ /* allocate space for pixel buffer */
+ if ( BROOKTREE_ALLOC )
+ buf = get_bktr_mem(unit, BROOKTREE_ALLOC);
+ else
+ buf = 0;
+ }
+#endif /* FreeBSD or BSDi */
+
+
+/* If this is a module, save the current contiguous memory */
+#if defined(BKTR_FREEBSD_MODULE)
+bktr_store_address(unit, BKTR_MEM_DMA_PROG, bktr->dma_prog);
+bktr_store_address(unit, BKTR_MEM_ODD_DMA_PROG, bktr->odd_dma_prog);
+bktr_store_address(unit, BKTR_MEM_VBIDATA, bktr->vbidata);
+bktr_store_address(unit, BKTR_MEM_VBIBUFFER, bktr->vbibuffer);
+bktr_store_address(unit, BKTR_MEM_BUF, buf);
#endif
+
if ( bootverbose ) {
printf("%s: buffer size %d, addr 0x%x\n",
bktr_name(bktr), BROOKTREE_ALLOC, vtophys(buf));
@@ -3708,7 +3739,7 @@ static int oformat_meteor_to_bt( u_long format )
BT848_DATA_CTL_I2CSDA)
/* Select between old i2c code and new iicbus / smbus code */
-#if (defined(__FreeBSD__) && (NSMBUS > 0))
+#if defined(BKTR_USE_FREEBSD_SMBUS)
/*
* The hardware interface is actually SMB commands
@@ -3854,7 +3885,7 @@ static void remote_read(bktr_ptr_t bktr, struct bktr_remote *remote) {
return;
}
-#else /* defined(__FreeBSD__) && (NSMBUS > 0) */
+#else /* defined(BKTR_USE_FREEBSD_SMBUS) */
/*
* Program the i2c bus directly
@@ -4110,7 +4141,7 @@ static void remote_read(bktr_ptr_t bktr, struct bktr_remote *remote) {
return;
}
-#endif /* defined(__FreeBSD__) && (NSMBUS > 0) */
+#endif /* defined(BKTR_USE_FREEBSD_SMBUS) */
#if defined( I2C_SOFTWARE_PROBE )
diff --git a/sys/dev/bktr/bktr_mem.c b/sys/dev/bktr/bktr_mem.c
new file mode 100644
index 000000000000..370670664d4a
--- /dev/null
+++ b/sys/dev/bktr/bktr_mem.c
@@ -0,0 +1,173 @@
+/* $FreeBSD$ */
+
+/*
+ * This is prt of the Driver for Video Capture Cards (Frame grabbers)
+ * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
+ * chipset.
+ * Copyright Roger Hardiman.
+ *
+ * bktr_mem : This kernel module allows us to keep our allocated
+ * contiguous memory for the video buffer, DMA programs and VBI data
+ * while the main bktr driver is unloaded and reloaded.
+ * This avoids the problem of trying to allocate contiguous each
+ * time the bktr driver is loaded.
+ */
+
+/*
+ * 1. Redistributions of source code must retain the
+ * Copyright (c) 2000 Roger Hardiman
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Roger Hardiman
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <stdio.h>
+#include <string.h>
+#include <dev/bktr/bktr_mem.h>
+
+struct memory_pointers {
+ int addresses_stored;
+ vm_offset_t dma_prog;
+ vm_offset_t odd_dma_prog;
+ vm_offset_t vbidata;
+ vm_offset_t vbibuffer;
+ vm_offset_t buf;
+} memory_pointers;
+
+static struct memory_pointers memory_list[BKTR_MEM_MAX_DEVICES];
+
+/*************************************************************/
+
+static int
+bktr_mem_modevent(module_t mod, int type, void *unused){
+
+ switch (type) {
+ case MOD_LOAD:
+ {
+ printf("bktr_mem: memory holder loaded\n");
+/*
+ * bzero causes a panic.
+ bzero((caddr_t)memory_list, sizeof(memory_list));
+ * So use a simple for loop for now.
+*/
+ {int x;
+ unsigned char *d = (unsigned char *)memory_list;
+ for (x=0; x< sizeof(memory_list); x++) {
+ d[x]=0;
+ }
+ }
+ return 0;
+ }
+ case MOD_UNLOAD:
+ {
+ printf("bktr_mem: memory holder unloaded\n");
+ return 0;
+ }
+ default:
+ break;
+ }
+ return 0;
+};
+
+/*************************************************************/
+
+int
+bktr_has_stored_addresses(int unit) {
+
+ if ((unit < 0) || (unit >= BKTR_MEM_MAX_DEVICES)) {
+ printf("bktr_mem: Unit number %d invalid\n",unit);
+ return 0;
+ }
+
+ return memory_list[unit].addresses_stored;
+}
+
+/*************************************************************/
+
+void
+bktr_store_address(int unit, int type, vm_offset_t addr) {
+
+ if ((unit < 0) || (unit >= BKTR_MEM_MAX_DEVICES)) {
+ printf("bktr_mem: Unit number %d invalid for memory type %d, address 0x%x\n"
+ ,unit,type,addr);
+ return;
+ }
+
+ switch (type) {
+ case BKTR_MEM_DMA_PROG: memory_list[unit].dma_prog = addr;
+ memory_list[unit].addresses_stored = 1;
+ break;
+ case BKTR_MEM_ODD_DMA_PROG: memory_list[unit].odd_dma_prog = addr;
+ memory_list[unit].addresses_stored = 1;
+ break;
+ case BKTR_MEM_VBIDATA: memory_list[unit].vbidata = addr;
+ memory_list[unit].addresses_stored = 1;
+ break;
+ case BKTR_MEM_VBIBUFFER: memory_list[unit].vbibuffer = addr;
+ memory_list[unit].addresses_stored = 1;
+ break;
+ case BKTR_MEM_BUF: memory_list[unit].buf = addr;
+ memory_list[unit].addresses_stored = 1;
+ break;
+ default: printf("bktr_mem: Invalid memory type %d for bktr%d, address 0x%xn",
+ type,unit,addr);
+ break;
+ }
+}
+
+/*************************************************************/
+
+vm_offset_t
+bktr_retrieve_address(int unit, int type) {
+
+ if ((unit < 0) || (unit >= BKTR_MEM_MAX_DEVICES)) {
+ printf("bktr_mem: Unit number %d too large for memory type %d\n",unit,type);
+ return NULL;
+ }
+ switch (type) {
+ case BKTR_MEM_DMA_PROG: return memory_list[unit].dma_prog;
+ case BKTR_MEM_ODD_DMA_PROG: return memory_list[unit].odd_dma_prog;
+ case BKTR_MEM_VBIDATA: return memory_list[unit].vbidata;
+ case BKTR_MEM_VBIBUFFER: return memory_list[unit].vbibuffer;
+ case BKTR_MEM_BUF: return memory_list[unit].buf;
+ default: printf("bktr_mem: Invalid memory type %d for bktr%d",type,unit);
+ return NULL;
+ }
+}
+
+/*************************************************************/
+
+static moduledata_t bktr_mem_mod = {
+ "bktr_mem",
+ bktr_mem_modevent,
+ 0
+};
+DECLARE_MODULE(bktr_mem, bktr_mem_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+
diff --git a/sys/dev/bktr/bktr_mem.h b/sys/dev/bktr/bktr_mem.h
new file mode 100644
index 000000000000..4c6d7a508ac7
--- /dev/null
+++ b/sys/dev/bktr/bktr_mem.h
@@ -0,0 +1,63 @@
+/* $FreeBSD$ */
+
+/*
+ * This is prt of the Driver for Video Capture Cards (Frame grabbers)
+ * and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
+ * chipset.
+ * Copyright Roger Hardiman.
+ *
+ * bktr_mem : This kernel module allows us to keep our allocated
+ * contiguous memory for the video buffer, DMA programs and VBI data
+ * while the main bktr driver is unloaded and reloaded.
+ * This avoids the problem of trying to allocate contiguous each
+ * time the bktr driver is loaded.
+ */
+
+/*
+ * 1. Redistributions of source code must retain the
+ * Copyright (c) 2000 Roger Hardiman
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Roger Hardiman
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/* Support this number of devices */
+#define BKTR_MEM_MAX_DEVICES 8
+
+/* Define a name for each block of memory we need to keep hold of */
+#define BKTR_MEM_DMA_PROG 1
+#define BKTR_MEM_ODD_DMA_PROG 2
+#define BKTR_MEM_VBIDATA 3
+#define BKTR_MEM_VBIBUFFER 4
+#define BKTR_MEM_BUF 5
+
+/* Prototypes */
+int bktr_has_stored_addresses(int unit);
+void bktr_store_address(int unit, int type, vm_offset_t addr);
+vm_offset_t bktr_retrieve_address(int unit, int type);
+
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c
index eecc94903d17..10df9c8d4145 100644
--- a/sys/dev/bktr/bktr_os.c
+++ b/sys/dev/bktr/bktr_os.c
@@ -184,7 +184,7 @@ int bktr_debug = 0;
#include <dev/bktr/bktr_audio.h>
#include <dev/bktr/bktr_core.h>
#include <dev/bktr/bktr_os.h>
-#if (NSMBUS > 0)
+#if defined(BKTR_USE_FREEBSD_SMBUS)
#include <dev/bktr/bktr_i2c.h>
#endif
#endif
@@ -380,7 +380,7 @@ bktr_attach( device_t dev )
/* XXX call bt848_i2c dependent attach() routine */
-#if (NSMBUS > 0)
+#if defined(BKTR_USE_FREEBSD_SMBUS)
if (bt848_i2c_attach(unit, bktr, &bktr->i2c_sc))
printf("bktr%d: i2c_attach: can't attach\n", unit);
#endif
@@ -931,7 +931,7 @@ bktr_attach( pcici_t tag, int unit )
/* XXX call bt848_i2c dependent attach() routine */
-#if (NSMBUS > 0)
+#if defined(BKTR_USE_FREEBSD_SMBUS)
if (bt848_i2c_attach(unit, bktr, &bktr->i2c_sc))
printf("bktr%d: i2c_attach: can't attach\n", unit);
#endif
diff --git a/sys/dev/bktr/bktr_reg.h b/sys/dev/bktr/bktr_reg.h
index 038af09ed273..8d2bd0e1e4fc 100644
--- a/sys/dev/bktr/bktr_reg.h
+++ b/sys/dev/bktr/bktr_reg.h
@@ -36,13 +36,13 @@
#ifdef __FreeBSD__
# if (__FreeBSD_version >= 310000)
-# include <sys/bus.h>
# include "smbus.h"
# else
# define NSMBUS 0 /* FreeBSD before 3.1 does not have SMBUS */
# endif
-#else
-# define NSMBUS 0 /* Non FreeBSD systems do not have SMBUS */
+# if (NSMBUS > 0)
+# define BKTR_USE_FREEBSD_SMBUS
+# endif
#endif
#ifdef __NetBSD__
@@ -436,7 +436,7 @@ struct format_params {
int vbi_num_lines, vbi_num_samples;
};
-#if ((defined(__FreeBSD__)) && (NSMBUS > 0))
+#if defined(BKTR_USE_FREEBSD_SMBUS)
struct bktr_i2c_softc {
device_t iicbus;
device_t smbus;