Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/bktr Import of (finally busspaced) bktr-driver f...



details:   https://anonhg.NetBSD.org/src/rev/895006eb6ad2
branches:  trunk
changeset: 485829:895006eb6ad2
user:      wiz <wiz%NetBSD.org@localhost>
date:      Sun May 07 00:16:17 2000 +0000

description:
Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.

diffstat:

 sys/dev/pci/bktr/README       |    28 +
 sys/dev/pci/bktr/bktr_audio.c |   573 +++++
 sys/dev/pci/bktr/bktr_audio.h |    86 +
 sys/dev/pci/bktr/bktr_card.c  |  1190 +++++++++++
 sys/dev/pci/bktr/bktr_card.h  |    89 +
 sys/dev/pci/bktr/bktr_core.c  |  4155 +++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/bktr/bktr_core.h  |    95 +
 sys/dev/pci/bktr/bktr_os.c    |  1706 ++++++++++++++++
 sys/dev/pci/bktr/bktr_os.h    |    74 +
 sys/dev/pci/bktr/bktr_reg.h   |   676 ++++++
 sys/dev/pci/bktr/bktr_tuner.c |  1011 +++++++++
 sys/dev/pci/bktr/bktr_tuner.h |   105 +
 12 files changed, 9788 insertions(+), 0 deletions(-)

diffs (truncated from 9836 to 300 lines):

diff -r 49de33da57d0 -r 895006eb6ad2 sys/dev/pci/bktr/README
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/bktr/README   Sun May 07 00:16:17 2000 +0000
@@ -0,0 +1,28 @@
+README FOR BT848/BT878 DRIVER
+Updated 20th March 2000
+
+  Roger Hardiman
+  roger%cs.strath.ac.uk@localhost
+  roger%freebsd.org@localhost
+  http://www.telepresence.strath.ac.uk/bt848
+  http://www.freebsd.org/~roger
+
+Introduction
+------------
+
+The BKTR driver is a driver for Bt848 and Bt878 based Video Capture
+cards and TV Tuner Cards.
+The driver was written by Amancio Hasty for FreeBSD but is now
+maintained by Roger Hardiman.
+
+The driver has been ported from FreeBSD to NetBSD, OpenBSD and BSD/OS.
+There is also a Linux version on an old version.
+
+
+Please read the README file for your specific Operating System for
+more information.
+
+Thanks
+Roger
+--
+Roger Hardiman
diff -r 49de33da57d0 -r 895006eb6ad2 sys/dev/pci/bktr/bktr_audio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/bktr/bktr_audio.c     Sun May 07 00:16:17 2000 +0000
@@ -0,0 +1,573 @@
+/*     $NetBSD: bktr_audio.c,v 1.1.1.1 2000/05/07 00:16:17 wiz Exp $   */
+
+/* FreeBSD: src/sys/dev/bktr/bktr_audio.c,v 1.2 1999/10/28 13:58:14 roger Exp */
+/*
+ * This is part 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 and Amancio Hasty.
+ *
+ * bktr_audio : This deals with controlling the audio on TV cards,
+ *                controlling the Audio Multiplexer (audio source selector).
+ *                controlling any MSP34xx stereo audio decoders.
+ *                controlling any DPL35xx dolby surroud sound audio decoders.    
+ *                initialising TDA98xx audio devices.
+ *
+ */
+
+/*
+ * 1. Redistributions of source code must retain the
+ * Copyright (c) 1997 Amancio Hasty, 1999 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 Amancio Hasty and
+ *      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/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
+
+#ifdef __NetBSD__
+#include <dev/ic/ioctl_meteor.h>       /* NetBSD location of .h files */
+#include <dev/ic/ioctl_bt848.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>
+
+
+/*
+ * Prototypes for the GV_BCTV specific functions.
+ */
+void    set_bctv_audio( bktr_ptr_t bktr );
+void    bctv_gpio_write( bktr_ptr_t bktr, int port, int val );
+/*int   bctv_gpio_read( bktr_ptr_t bktr, int port );*/ /* Not used */
+
+
+
+/*
+ * init_audio_devices
+ * Reset any MSP34xx or TDA98xx audio devices.
+ */
+void init_audio_devices( bktr_ptr_t bktr ) {
+
+        /* enable stereo if appropriate on TDA audio chip */
+        if ( bktr->card.dbx )
+                init_BTSC( bktr );
+ 
+        /* reset the MSP34xx stereo audio chip */
+        if ( bktr->card.msp3400c )
+                msp_dpl_reset( bktr, bktr->msp_addr );
+
+        /* reset the DPL35xx dolby audio chip */
+        if ( bktr->card.dpl3518a )
+                msp_dpl_reset( bktr, bktr->dpl_addr );
+
+}
+
+
+/*
+ * 
+ */
+#define AUDIOMUX_DISCOVER_NOT
+int
+set_audio( bktr_ptr_t bktr, int cmd )
+{
+       u_long          temp;
+       volatile u_char idx;
+
+#if defined( AUDIOMUX_DISCOVER )
+       if ( cmd >= 200 )
+               cmd -= 200;
+       else
+#endif /* AUDIOMUX_DISCOVER */
+
+       /* check for existance of audio MUXes */
+       if ( !bktr->card.audiomuxs[ 4 ] )
+               return( -1 );
+
+       switch (cmd) {
+       case AUDIO_TUNER:
+#ifdef BKTR_REVERSEMUTE
+               bktr->audio_mux_select = 3;
+#else
+               bktr->audio_mux_select = 0;
+#endif
+
+               if (bktr->reverse_mute ) 
+                     bktr->audio_mux_select = 0;
+               else    
+                   bktr->audio_mux_select = 3;
+
+               break;
+       case AUDIO_EXTERN:
+               bktr->audio_mux_select = 1;
+               break;
+       case AUDIO_INTERN:
+               bktr->audio_mux_select = 2;
+               break;
+       case AUDIO_MUTE:
+               bktr->audio_mute_state = TRUE;  /* set mute */
+               break;
+       case AUDIO_UNMUTE:
+               bktr->audio_mute_state = FALSE; /* clear mute */
+               break;
+       default:
+               printf("bktr: audio cmd error %02x\n", cmd);
+               return( -1 );
+       }
+
+
+       /* Most cards have a simple audio multiplexer to select the
+        * audio source. The I/O_GV card has a more advanced multiplexer
+        * and requires special handling.
+        */
+        if ( bktr->bt848_card == CARD_IO_GV ) {
+                set_bctv_audio( bktr );
+                return( 0 );
+       }
+
+       /* Proceed with the simpler audio multiplexer code for the majority
+        * of Bt848 cards.
+        */
+
+       /*
+        * Leave the upper bits of the GPIO port alone in case they control
+        * something like the dbx or teletext chips.  This doesn't guarantee
+        * success, but follows the rule of least astonishment.
+        */
+
+       if ( bktr->audio_mute_state == TRUE ) {
+#ifdef BKTR_REVERSEMUTE
+               idx = 0;
+#else
+               idx = 3;
+#endif
+
+               if (bktr->reverse_mute )
+                 idx  = 3;
+               else    
+                 idx  = 0;
+
+       }
+       else
+               idx = bktr->audio_mux_select;
+
+       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 );
+#else
+       OUTL(bktr, BKTR_GPIO_DATA, temp | bktr->card.audiomuxs[ idx ]);
+#endif /* AUDIOMUX_DISCOVER */
+
+       return( 0 );
+}
+
+
+/*
+ * 
+ */
+void
+temp_mute( bktr_ptr_t bktr, int flag )
+{
+       static int      muteState = FALSE;
+
+       if ( flag == TRUE ) {
+               muteState = bktr->audio_mute_state;
+               set_audio( bktr, AUDIO_MUTE );          /* prevent 'click' */
+       }
+       else {
+               tsleep( BKTR_SLEEP, PZERO, "tuning", hz/8 );
+               if ( muteState == FALSE )
+                       set_audio( bktr, AUDIO_UNMUTE );
+       }
+}
+
+/* address of BTSC/SAP decoder chip */
+#define TDA9850_WADDR           0xb6
+#define TDA9850_RADDR           0xb7
+
+
+/* registers in the TDA9850 BTSC/dbx chip */
+#define CON1ADDR                0x04
+#define CON2ADDR                0x05
+#define CON3ADDR                0x06 
+#define CON4ADDR                0x07
+#define ALI1ADDR                0x08 
+#define ALI2ADDR                0x09
+#define ALI3ADDR                0x0a
+
+/*
+ * initialise the dbx chip
+ * taken from the Linux bttv driver TDA9850 initialisation code
+ */
+void 
+init_BTSC( bktr_ptr_t bktr )
+{
+    i2cWrite(bktr, TDA9850_WADDR, CON1ADDR, 0x08); /* noise threshold st */
+    i2cWrite(bktr, TDA9850_WADDR, CON2ADDR, 0x08); /* noise threshold sap */
+    i2cWrite(bktr, TDA9850_WADDR, CON3ADDR, 0x40); /* stereo mode */
+    i2cWrite(bktr, TDA9850_WADDR, CON4ADDR, 0x07); /* 0 dB input gain? */
+    i2cWrite(bktr, TDA9850_WADDR, ALI1ADDR, 0x10); /* wideband alignment? */
+    i2cWrite(bktr, TDA9850_WADDR, ALI2ADDR, 0x10); /* spectral alignment? */
+    i2cWrite(bktr, TDA9850_WADDR, ALI3ADDR, 0x03);
+}
+
+/*
+ * setup the dbx chip



Home | Main Index | Thread Index | Old Index