Add a overhaul of the soundchip initialization for the MSP34xx chipsets
found only many tv-cards. We currently use more ore less evil hacks (slow_msp_audio sysctl) to configure the various variants of these chips in order to have stereo autodetection work. Nevertheless, this doesn't always work even though it _should_, according to the specs. This is, for example, the case for some popular Hauppauge models sold sold in Germany. However, the Linux driver always worked for me and others. Looking at the sourcecode you will find that the linux-driver uses a very much enhanced approach to program the various msp34xx chipset variants, which is also found in the specs for these chips. This is a port of the Linux MSP34xx code, written by Gerd Knorr <kraxel@bytesex.org>, who agreed to re-release his code under a BSD license for this port. A new config option "BKTR_NEW_MSP34XX_DRIVER" is added, which is required to enable the new driver. Otherwise the old code is used. The msp34xx.c file is diff-reduced to the linux-driver to make later modifications easier, thus it doesn't follow style(9) in most cases. Approved by: roger (committing this, no time to test/review), keichii (code review)
This commit is contained in:
parent
75cf31a016
commit
30e27d9623
@ -1917,6 +1917,10 @@ device nmdm
|
||||
# motherboards and motherboards with bad or incomplete PCI 2.1 support.
|
||||
# As a rough guess, old = before 1998
|
||||
#
|
||||
# options BKTR_NEW_MSP34XX_DRIVER
|
||||
# Use new, more complete initialization scheme for the msp34* soundchip.
|
||||
# Should fix stereo autodetection if the old driver does only output
|
||||
# mono sound.
|
||||
|
||||
device meteor 1
|
||||
|
||||
|
@ -335,6 +335,7 @@ dev/bktr/bktr_core.c optional bktr pci
|
||||
dev/bktr/bktr_i2c.c optional bktr pci smbus
|
||||
dev/bktr/bktr_os.c optional bktr pci
|
||||
dev/bktr/bktr_tuner.c optional bktr pci
|
||||
dev/bktr/msp34xx.c optional bktr pci
|
||||
dev/buslogic/bt.c optional bt
|
||||
dev/buslogic/bt_eisa.c optional bt eisa
|
||||
dev/buslogic/bt_isa.c optional bt isa
|
||||
|
@ -523,6 +523,7 @@ BKTR_NO_MSP_RESET opt_bktr.h
|
||||
BKTR_430_FX_MODE opt_bktr.h
|
||||
BKTR_SIS_VIA_MODE opt_bktr.h
|
||||
BKTR_USE_FREEBSD_SMBUS opt_bktr.h
|
||||
BKTR_NEW_MSP34XX_DRIVER opt_bktr.h
|
||||
|
||||
# meteor opt_meteor.h
|
||||
METEOR_ALLOC_PAGES opt_meteor.h
|
||||
|
@ -46,6 +46,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_bktr.h" /* Include any kernel config options */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -472,6 +474,13 @@ void msp_read_id( bktr_ptr_t bktr ){
|
||||
* the chip and re-programs it if needed.
|
||||
*/
|
||||
void msp_autodetect( bktr_ptr_t bktr ) {
|
||||
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
|
||||
/* Just wake up the (maybe) sleeping thread, it'll do everything for us */
|
||||
msp_wake_thread(bktr);
|
||||
|
||||
#else
|
||||
int auto_detect, loops;
|
||||
int stereo;
|
||||
|
||||
@ -596,6 +605,8 @@ void msp_autodetect( bktr_ptr_t bktr ) {
|
||||
/* uncomment the following line to enable the MSP34xx 1Khz Tone Generator */
|
||||
/* turn your speaker volume down low before trying this */
|
||||
/* msp_dpl_write(bktr, bktr->msp_addr, 0x12, 0x0014, 0x7f40); */
|
||||
|
||||
#endif /* BKTR_NEW_MSP34XX_DRIVER */
|
||||
}
|
||||
|
||||
/* Read the DPL version string */
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* This is part of the Driver for Video Capture Cards (Frame grabbers)
|
||||
* and TV Tuner cards using the Brooktree Bt848, Bt848A, Bt849A, Bt878, Bt879
|
||||
@ -65,6 +64,12 @@ void init_audio_devices( bktr_ptr_t bktr );
|
||||
*/
|
||||
void msp_autodetect( bktr_ptr_t bktr );
|
||||
void msp_read_id( bktr_ptr_t bktr );
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
int msp_attach(bktr_ptr_t bktr);
|
||||
int msp_detach(bktr_ptr_t bktr);
|
||||
void msp_wake_thread(bktr_ptr_t bktr);
|
||||
void msp_halt_thread(bktr_ptr_t bktr);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
@ -471,6 +471,9 @@ common_bktr_attach( bktr_ptr_t bktr, int unit, u_long pci_id, u_int rev )
|
||||
{
|
||||
vm_offset_t buf = 0;
|
||||
int need_to_allocate_memory = 1;
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
int err;
|
||||
#endif
|
||||
|
||||
/***************************************/
|
||||
/* *** OS Specific memory routines *** */
|
||||
@ -612,11 +615,29 @@ bktr_store_address(unit, BKTR_MEM_BUF, buf);
|
||||
bktr->msp_source_selected = -1;
|
||||
bktr->audio_mux_present = 1;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
/* get hint on short programming of the msp34xx, so we know */
|
||||
/* if the decision what thread to start should be overwritten */
|
||||
if ( (err = resource_int_value("bktr", unit, "mspsimple",
|
||||
&(bktr->mspsimple)) ) != 0 )
|
||||
bktr->mspsimple = -1; /* fall back to default */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
probeCard( bktr, TRUE, unit );
|
||||
|
||||
/* Initialise any MSP34xx or TDA98xx audio chips */
|
||||
init_audio_devices( bktr );
|
||||
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
/* setup the kenrel thread */
|
||||
err = msp_attach( bktr );
|
||||
if ( err != 0 ) /* error doing kernel thread stuff, disable msp3400c */
|
||||
bktr->card.msp3400c = 0;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,6 +107,12 @@ int bt848_tuner = -1;
|
||||
int bt848_reverse_mute = -1;
|
||||
int bt848_format = -1;
|
||||
int bt848_slow_msp_audio = -1;
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
int bt848_stereo_once = 0; /* no continuous stereo monitoring */
|
||||
int bt848_amsound = 0; /* hard-wire AM sound at 6.5 Hz (france),
|
||||
the autoscan seems work well only with FM... */
|
||||
int bt848_dolby = 0;
|
||||
#endif
|
||||
|
||||
SYSCTL_NODE(_hw, OID_AUTO, bt848, CTLFLAG_RW, 0, "Bt848 Driver mgmt");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, card, CTLFLAG_RW, &bt848_card, -1, "");
|
||||
@ -114,6 +120,11 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, tuner, CTLFLAG_RW, &bt848_tuner, -1, "");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, reverse_mute, CTLFLAG_RW, &bt848_reverse_mute, -1, "");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, format, CTLFLAG_RW, &bt848_format, -1, "");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audio, -1, "");
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, stereo_once, CTLFLAG_RW, &bt848_stereo_once, 0, "");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, amsound, CTLFLAG_RW, &bt848_amsound, 0, "");
|
||||
SYSCTL_INT(_hw_bt848, OID_AUTO, dolby, CTLFLAG_RW, &bt848_dolby, 0, "");
|
||||
#endif
|
||||
|
||||
#endif /* end freebsd section */
|
||||
|
||||
@ -473,6 +484,12 @@ bktr_detach( device_t dev )
|
||||
{
|
||||
struct bktr_softc *bktr = device_get_softc(dev);
|
||||
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
/* Disable the soundchip and kernel thread */
|
||||
if (bktr->msp3400c_info != NULL)
|
||||
msp_detach(bktr);
|
||||
#endif
|
||||
|
||||
/* Disable the brooktree device */
|
||||
OUTL(bktr, BKTR_INT_MASK, ALL_INTS_DISABLED);
|
||||
OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_RISC_DISABLED);
|
||||
@ -611,6 +628,26 @@ bktr_open( dev_t dev, int flags, int fmt, struct thread *td )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
if (bt848_stereo_once != 0) {
|
||||
if ((bt848_stereo_once >> 8) == unit ) {
|
||||
bktr->stereo_once = (bt848_stereo_once & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
if (bt848_amsound != -1) {
|
||||
if ((bt848_amsound >> 8) == unit ) {
|
||||
bktr->amsound = (bt848_amsound & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
if (bt848_dolby != -1) {
|
||||
if ((bt848_dolby >> 8) == unit ) {
|
||||
bktr->dolby = (bt848_dolby & 0xff);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch ( FUNCTION( minor(dev) ) ) {
|
||||
case VIDEO_DEV:
|
||||
result = video_open( bktr );
|
||||
|
@ -695,6 +695,15 @@ struct bktr_softc {
|
||||
int audio_mux_present; /* 1 = has audio mux on GPIO lines, 0 = no audio mux */
|
||||
int msp_source_selected; /* 0 = TV source, 1 = Line In source, 2 = FM Radio Source */
|
||||
|
||||
#ifdef BKTR_NEW_MSP34XX_DRIVER
|
||||
/* msp3400c related data */
|
||||
void * msp3400c_info;
|
||||
int stereo_once;
|
||||
int amsound;
|
||||
int mspsimple;
|
||||
int dolby;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
typedef struct bktr_softc bktr_reg_t;
|
||||
|
1255
sys/dev/bktr/msp34xx.c
Normal file
1255
sys/dev/bktr/msp34xx.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
.PATH: ${.CURDIR}/../../../dev/bktr
|
||||
|
||||
KMOD= bktr
|
||||
SRCS= bktr_core.c bktr_os.c bktr_audio.c bktr_tuner.c bktr_card.c \
|
||||
SRCS= bktr_core.c bktr_os.c bktr_audio.c bktr_tuner.c bktr_card.c msp34xx.c \
|
||||
opt_devfs.h opt_bktr.h bus_if.h device_if.h \
|
||||
pci_if.h vnode_if.h
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user