2005-01-14 06:41:45 +03:00
|
|
|
/* $NetBSD: pas.c,v 1.61 2005/01/14 03:41:45 kent Exp $ */
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1991-1993 Regents of the University of California.
|
|
|
|
* 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 the Computer Systems
|
|
|
|
* Engineering Group at Lawrence Berkeley Laboratory.
|
|
|
|
* 4. Neither the name of the University nor of the Laboratory may be used
|
|
|
|
* to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
|
|
|
*
|
|
|
|
*/
|
1997-07-25 05:42:20 +04:00
|
|
|
/*
|
2005-01-14 06:41:45 +03:00
|
|
|
* jfw 7/13/97 - The soundblaster code requires the generic bus-space
|
1997-07-25 05:42:20 +04:00
|
|
|
* structures to be set up properly. Rather than go to the effort of making
|
|
|
|
* code for a dead line fully generic, properly set up the SB structures and
|
|
|
|
* leave the rest x86/ISA/default-configuration specific. If you have a
|
|
|
|
* REAL computer, go buy a REAL sound card.
|
|
|
|
*/
|
1995-02-21 05:27:18 +03:00
|
|
|
/*
|
|
|
|
* Todo:
|
2005-01-14 06:41:45 +03:00
|
|
|
* - look at other PAS drivers (for PAS native suport)
|
|
|
|
* - use common sb.c once emulation is setup
|
1995-02-21 05:27:18 +03:00
|
|
|
*/
|
1998-06-22 21:21:34 +04:00
|
|
|
/*
|
|
|
|
* jfw 6/21/98 - WARNING: the PAS native IO ports are scattered all around
|
|
|
|
* IO port space (0x0388, 0x738B, 0xBF88, 0x2789, ...) which will make proper
|
|
|
|
* reservation a real pain, so I'm not going to do it (while fixing the
|
|
|
|
* current reservation code to "work"). As a sanity check, I reserve the
|
|
|
|
* 0x0388 base address, but you probably shouldn't even think of trying this
|
|
|
|
* driver unless you're certain you have the hardware installed and it doesn't
|
|
|
|
* conflict with other hardware...
|
|
|
|
*/
|
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
|
2001-11-13 11:01:09 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-01-14 06:41:45 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.61 2005/01/14 03:41:45 kent Exp $");
|
2001-11-13 11:01:09 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
1996-05-13 03:51:23 +04:00
|
|
|
#include <machine/intr.h>
|
1997-06-07 03:43:45 +04:00
|
|
|
#include <machine/bus.h>
|
1995-02-21 05:27:18 +03:00
|
|
|
#include <machine/pio.h>
|
|
|
|
|
|
|
|
#include <sys/audioio.h>
|
|
|
|
#include <dev/audio_if.h>
|
1998-08-18 01:16:09 +04:00
|
|
|
#include <dev/midi_if.h>
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/isa/isadmavar.h>
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1995-04-17 19:48:20 +04:00
|
|
|
#include <dev/isa/sbdspvar.h>
|
|
|
|
#include <dev/isa/sbreg.h>
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
#define DEFINE_TRANSLATIONS
|
1995-04-17 19:48:20 +04:00
|
|
|
#include <dev/isa/pasreg.h>
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1995-07-07 06:19:48 +04:00
|
|
|
#ifdef AUDIO_DEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
#define DPRINTF(x) if (pasdebug) printf x
|
1995-02-21 05:27:18 +03:00
|
|
|
int pasdebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Software state, per SoundBlaster card.
|
|
|
|
* The soundblaster has multiple functionality, which we must demultiplex.
|
|
|
|
* One approach is to have one major device number for the soundblaster card,
|
|
|
|
* and use different minor numbers to indicate which hardware function
|
|
|
|
* we want. This would make for one large driver. Instead our approach
|
|
|
|
* is to partition the design into a set of drivers that share an underlying
|
|
|
|
* piece of hardware. Most things are hard to share, for example, the audio
|
|
|
|
* and midi ports. For audio, we might want to mix two processes' signals,
|
|
|
|
* and for midi we might want to merge streams (this is hard due to
|
|
|
|
* running status). Moreover, we should be able to re-use the high-level
|
|
|
|
* modules with other kinds of hardware. In this module, we only handle the
|
|
|
|
* most basic communications with the sb card.
|
|
|
|
*/
|
|
|
|
struct pas_softc {
|
1996-11-12 10:39:56 +03:00
|
|
|
struct sbdsp_softc sc_sbdsp; /* base device, &c. */
|
2005-01-14 06:41:45 +03:00
|
|
|
bus_space_handle_t pas_port_handle; /* the pas-specific port */
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
int model;
|
|
|
|
int rev;
|
|
|
|
};
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
int pas_getdev(void *, struct audio_device *);
|
|
|
|
void pasconf(int, int, int, int);
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define our interface to the higher level audio driver.
|
|
|
|
*/
|
|
|
|
|
2004-10-29 16:57:15 +04:00
|
|
|
const struct audio_hw_if pas_hw_if = {
|
1997-08-01 02:33:08 +04:00
|
|
|
sbdsp_open,
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_close,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_query_encoding,
|
1997-05-10 02:16:27 +04:00
|
|
|
sbdsp_set_params,
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_round_blocksize,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1998-08-10 04:20:39 +04:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
1999-02-18 10:08:35 +03:00
|
|
|
sbdsp_halt_output,
|
|
|
|
sbdsp_halt_input,
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_speaker_ctl,
|
|
|
|
pas_getdev,
|
1997-07-28 03:51:48 +04:00
|
|
|
0,
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_mixer_set_port,
|
|
|
|
sbdsp_mixer_get_port,
|
|
|
|
sbdsp_mixer_query_devinfo,
|
1997-07-27 05:16:32 +04:00
|
|
|
sb_malloc,
|
|
|
|
sb_free,
|
1999-02-17 05:37:38 +03:00
|
|
|
sb_round_buffersize,
|
2005-01-14 06:41:45 +03:00
|
|
|
sb_mappage,
|
1997-08-01 02:33:08 +04:00
|
|
|
sbdsp_get_props,
|
1998-08-10 04:20:39 +04:00
|
|
|
sbdsp_trigger_output,
|
|
|
|
sbdsp_trigger_input,
|
2001-10-03 04:04:47 +04:00
|
|
|
0,
|
1995-02-21 05:27:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The Address Translation code is used to convert I/O register addresses to
|
|
|
|
be relative to the given base -register */
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
static const char *pasnames[] = {
|
1995-02-21 05:27:18 +03:00
|
|
|
"",
|
|
|
|
"Plus",
|
|
|
|
"CDPC",
|
1995-03-14 21:41:36 +03:00
|
|
|
"16",
|
|
|
|
"16Basic"
|
1995-02-21 05:27:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct audio_device pas_device = {
|
|
|
|
"PAS,??",
|
|
|
|
"",
|
|
|
|
"pas"
|
|
|
|
};
|
|
|
|
|
|
|
|
/*XXX assume default I/O base address */
|
2001-05-15 19:00:04 +04:00
|
|
|
#define pasread(p) inb((p))
|
|
|
|
#define paswrite(d, p) outb((p), (d))
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
void
|
2005-01-14 06:41:45 +03:00
|
|
|
pasconf(int model, int sbbase, int sbirq, int sbdrq)
|
1995-02-21 05:27:18 +03:00
|
|
|
{
|
2005-01-14 06:41:45 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(0x00, INTERRUPT_MASK);
|
|
|
|
/* Local timer control register */
|
|
|
|
paswrite(0x36, SAMPLE_COUNTER_CONTROL);
|
|
|
|
/* Sample rate timer (16 bit) */
|
|
|
|
paswrite(0x36, SAMPLE_RATE_TIMER);
|
|
|
|
paswrite(0, SAMPLE_RATE_TIMER);
|
|
|
|
/* Local timer control register */
|
|
|
|
paswrite(0x74, SAMPLE_COUNTER_CONTROL);
|
|
|
|
/* Sample count register (16 bit) */
|
|
|
|
paswrite(0x74, SAMPLE_BUFFER_COUNTER);
|
|
|
|
paswrite(0, SAMPLE_BUFFER_COUNTER);
|
|
|
|
|
|
|
|
paswrite(P_C_PCM_MONO | P_C_PCM_DAC_MODE |
|
2005-01-14 06:41:45 +03:00
|
|
|
P_C_MIXER_CROSS_L_TO_L | P_C_MIXER_CROSS_R_TO_R,
|
|
|
|
PCM_CONTROL);
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(S_M_PCM_RESET | S_M_FM_RESET |
|
2005-01-14 06:41:45 +03:00
|
|
|
S_M_SB_RESET | S_M_MIXER_RESET, SERIAL_MIXER);
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
/*XXX*/
|
|
|
|
paswrite(I_C_1_BOOT_RESET_ENABLE|1, IO_CONFIGURATION_1);
|
|
|
|
|
|
|
|
paswrite(I_C_2_PCM_DMA_DISABLED, IO_CONFIGURATION_2);
|
|
|
|
paswrite(I_C_3_PCM_IRQ_DISABLED, IO_CONFIGURATION_3);
|
2005-01-14 06:41:45 +03:00
|
|
|
|
|
|
|
#ifdef BROKEN_BUS_CLOCK
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND |
|
2005-01-14 06:41:45 +03:00
|
|
|
S_C_1_FM_EMULATE_CLOCK, SYSTEM_CONFIGURATION_1);
|
1995-02-21 05:27:18 +03:00
|
|
|
#else
|
|
|
|
paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND,
|
2005-01-14 06:41:45 +03:00
|
|
|
SYSTEM_CONFIGURATION_1);
|
1995-02-21 05:27:18 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*XXX*/
|
|
|
|
paswrite(0, SYSTEM_CONFIGURATION_2);
|
|
|
|
paswrite(0, SYSTEM_CONFIGURATION_3);
|
|
|
|
|
|
|
|
/* Sets mute off and selects filter rate of 17.897 kHz */
|
|
|
|
paswrite(F_F_MIXER_UNMUTE | 0x01, FILTER_FREQUENCY);
|
|
|
|
|
1995-03-14 21:41:36 +03:00
|
|
|
if (model == PAS_16 || model == PAS_16BASIC)
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(8, PRESCALE_DIVIDER);
|
|
|
|
else
|
|
|
|
paswrite(0, PRESCALE_DIVIDER);
|
|
|
|
|
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_PCM, PARALLEL_MIXER);
|
|
|
|
paswrite(5, PARALLEL_MIXER);
|
2005-01-14 06:41:45 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
/*
|
|
|
|
* Setup SoundBlaster emulation.
|
|
|
|
*/
|
|
|
|
paswrite((sbbase >> 4) & 0xf, EMULATION_ADDRESS);
|
|
|
|
paswrite(E_C_SB_IRQ_translate[sbirq] | E_C_SB_DMA_translate[sbdrq],
|
2005-01-14 06:41:45 +03:00
|
|
|
EMULATION_CONFIGURATION);
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(C_E_SB_ENABLE, COMPATIBILITY_ENABLE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set mid-range levels.
|
|
|
|
*/
|
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_MODE, PARALLEL_MIXER);
|
2005-01-14 06:41:45 +03:00
|
|
|
paswrite(P_M_MV508_LOUDNESS | P_M_MV508_ENHANCE_NONE, PARALLEL_MIXER);
|
1995-02-21 05:27:18 +03:00
|
|
|
|
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_A, PARALLEL_MIXER);
|
|
|
|
paswrite(50, PARALLEL_MIXER);
|
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_B, PARALLEL_MIXER);
|
|
|
|
paswrite(50, PARALLEL_MIXER);
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_SB,
|
|
|
|
PARALLEL_MIXER);
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(P_M_MV508_OUTPUTMIX | 30, PARALLEL_MIXER);
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_MIC,
|
|
|
|
PARALLEL_MIXER);
|
1995-02-21 05:27:18 +03:00
|
|
|
paswrite(P_M_MV508_INPUTMIX | 30, PARALLEL_MIXER);
|
|
|
|
}
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
int pasprobe(struct device *, struct cfdata *, void *);
|
|
|
|
void pasattach(struct device *, struct device *, void *);
|
|
|
|
static int pasfind(struct device *, struct pas_softc *,
|
|
|
|
struct isa_attach_args *, int);
|
1998-06-22 21:21:34 +04:00
|
|
|
/* argument to pasfind */
|
|
|
|
#define PASPROBE 1
|
|
|
|
#define PASATTACH 0
|
1996-02-16 11:18:32 +03:00
|
|
|
|
2002-10-02 06:00:07 +04:00
|
|
|
CFATTACH_DECL(pas, sizeof(struct pas_softc),
|
2002-10-02 07:10:45 +04:00
|
|
|
pasprobe, pasattach, NULL, NULL);
|
1996-03-17 03:43:52 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
/*
|
|
|
|
* Probe / attach routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2005-01-14 06:41:45 +03:00
|
|
|
pasprobe(struct device *parent, struct cfdata *match, void *aux)
|
1995-02-21 05:27:18 +03:00
|
|
|
{
|
2005-01-14 06:41:45 +03:00
|
|
|
struct isa_attach_args *ia;
|
|
|
|
struct pas_softc probesc, *sc;
|
1998-03-23 04:00:21 +03:00
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
ia = aux;
|
|
|
|
sc = &probesc;
|
2002-01-08 00:46:56 +03:00
|
|
|
if (ia->ia_nio < 1)
|
2005-01-14 06:41:45 +03:00
|
|
|
return 0;
|
2002-01-08 00:46:56 +03:00
|
|
|
if (ia->ia_nirq < 1)
|
2005-01-14 06:41:45 +03:00
|
|
|
return 0;
|
2002-01-08 00:46:56 +03:00
|
|
|
if (ia->ia_ndrq < 1)
|
2005-01-14 06:41:45 +03:00
|
|
|
return 0;
|
2002-01-08 00:46:56 +03:00
|
|
|
|
|
|
|
if (ISA_DIRECT_CONFIG(ia))
|
2005-01-14 06:41:45 +03:00
|
|
|
return 0;
|
2002-01-08 00:46:56 +03:00
|
|
|
|
2001-07-19 00:39:53 +04:00
|
|
|
memset(sc, 0, sizeof *sc);
|
2002-01-11 20:45:10 +03:00
|
|
|
sc->sc_sbdsp.sc_dev.dv_cfdata = match;
|
1998-03-23 04:00:21 +03:00
|
|
|
strcpy(sc->sc_sbdsp.sc_dev.dv_xname, "pas");
|
1998-06-22 21:21:34 +04:00
|
|
|
return pasfind(parent, sc, aux, PASPROBE);
|
1998-03-23 04:00:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe for the soundblaster hardware.
|
|
|
|
*/
|
|
|
|
static int
|
2005-01-14 06:41:45 +03:00
|
|
|
pasfind(struct device *parent, struct pas_softc *sc,
|
|
|
|
struct isa_attach_args *ia, int probing)
|
1998-03-23 04:00:21 +03:00
|
|
|
{
|
1997-09-14 13:03:33 +04:00
|
|
|
int iobase;
|
1995-02-21 05:27:18 +03:00
|
|
|
u_char id, t;
|
2005-01-14 06:41:45 +03:00
|
|
|
int rc;
|
1995-02-21 05:27:18 +03:00
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
rc = 0; /* failure */
|
|
|
|
/* ensure we can set this up as a sound blaster */
|
|
|
|
if (!SB_BASE_VALID(ia->ia_io[0].ir_addr)) {
|
2002-01-08 00:46:56 +03:00
|
|
|
printf("pas: configured SB iobase 0x%x invalid\n",
|
|
|
|
ia->ia_io[0].ir_addr);
|
1997-07-25 05:42:20 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-06-22 21:21:34 +04:00
|
|
|
if (bus_space_map(sc->sc_sbdsp.sc_iot, PAS_DEFAULT_BASE, 1, 0,
|
2005-01-14 06:41:45 +03:00
|
|
|
&sc->pas_port_handle)) {
|
1998-06-22 21:21:34 +04:00
|
|
|
printf("pas: can't map base register %x in probe\n",
|
2005-01-14 06:41:45 +03:00
|
|
|
PAS_DEFAULT_BASE);
|
1998-06-22 21:21:34 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
/*
|
|
|
|
* WARNING: Setting an option like W:1 or so that disables
|
|
|
|
* warm boot reset of the card will screw up this detect code
|
|
|
|
* something fierce. Adding code to handle this means possibly
|
|
|
|
* interfering with other cards on the bus if you have something
|
2005-01-14 06:41:45 +03:00
|
|
|
* on base port 0x388. SO be forewarned.
|
1995-02-21 05:27:18 +03:00
|
|
|
*/
|
|
|
|
/* Talk to first board */
|
|
|
|
outb(MASTER_DECODE, 0xbc);
|
|
|
|
/* Set base address */
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* XXX Need to setup pseudo device */
|
|
|
|
/* XXX What are good io addrs ? */
|
|
|
|
if (iobase != PAS_DEFAULT_BASE) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("pas: configured iobase %d invalid\n", iobase);
|
1995-02-21 05:27:18 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* Start out talking to native PAS */
|
|
|
|
iobase = PAS_DEFAULT_BASE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
outb(MASTER_DECODE, iobase >> 2);
|
|
|
|
/* One wait-state */
|
|
|
|
paswrite(1, WAIT_STATE);
|
|
|
|
|
|
|
|
id = pasread(INTERRUPT_MASK);
|
|
|
|
if (id == 0xff || id == 0xfe) {
|
|
|
|
/* sanity */
|
|
|
|
DPRINTF(("pas: bogus card id\n"));
|
1998-06-22 21:21:34 +04:00
|
|
|
goto unmap1;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* We probably have a PAS-series board, now check for a
|
|
|
|
* PAS2-series board by trying to change the board revision
|
|
|
|
* bits. PAS2-series hardware won't let you do this because
|
|
|
|
* the bits are read-only.
|
|
|
|
*/
|
|
|
|
t = id ^ 0xe0;
|
|
|
|
paswrite(t, INTERRUPT_MASK);
|
|
|
|
t = inb(INTERRUPT_MASK);
|
|
|
|
paswrite(id, INTERRUPT_MASK);
|
|
|
|
|
|
|
|
if (t != id) {
|
|
|
|
/* Not a PAS2 */
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("pas: detected card but PAS2 test failed\n");
|
1998-06-22 21:21:34 +04:00
|
|
|
goto unmap1;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
/*XXX*/
|
|
|
|
t = pasread(OPERATION_MODE_1) & 0xf;
|
|
|
|
sc->model = O_M_1_to_card[t];
|
|
|
|
if (sc->model != 0) {
|
|
|
|
sc->rev = pasread(BOARD_REV_ID);
|
2005-01-14 06:41:45 +03:00
|
|
|
} else {
|
1995-02-21 05:27:18 +03:00
|
|
|
DPRINTF(("pas: bogus model id\n"));
|
1998-06-22 21:21:34 +04:00
|
|
|
goto unmap1;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
2005-01-14 06:41:45 +03:00
|
|
|
if (sc->model >= 0) {
|
|
|
|
if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ) {
|
|
|
|
printf("pas: sb emulation requires known irq\n");
|
1998-06-22 21:21:34 +04:00
|
|
|
goto unmap1;
|
2005-01-14 06:41:45 +03:00
|
|
|
}
|
|
|
|
pasconf(sc->model, ia->ia_io[0].ir_addr,
|
|
|
|
ia->ia_irq[0].ir_irq, 1);
|
|
|
|
} else {
|
|
|
|
DPRINTF(("pas: could not probe pas\n"));
|
1998-06-22 21:21:34 +04:00
|
|
|
goto unmap1;
|
2005-01-14 06:41:45 +03:00
|
|
|
}
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1997-07-25 05:42:20 +04:00
|
|
|
/* Now a SoundBlaster, so set up proper bus-space hooks
|
|
|
|
* appropriately
|
|
|
|
*/
|
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
sc->sc_sbdsp.sc_iobase = ia->ia_io[0].ir_addr;
|
1997-04-06 04:54:22 +04:00
|
|
|
sc->sc_sbdsp.sc_iot = ia->ia_iot;
|
1997-07-25 05:42:20 +04:00
|
|
|
|
|
|
|
/* Map i/o space [we map 24 ports which is the max of the sb and pro */
|
2002-01-08 00:46:56 +03:00
|
|
|
if (bus_space_map(sc->sc_sbdsp.sc_iot, ia->ia_io[0].ir_addr,
|
|
|
|
SBP_NPORT, 0, &sc->sc_sbdsp.sc_ioh)) {
|
1997-07-25 05:42:20 +04:00
|
|
|
printf("pas: can't map i/o space 0x%x/%d in probe\n",
|
2002-01-08 00:46:56 +03:00
|
|
|
ia->ia_io[0].ir_addr, SBP_NPORT);
|
2000-04-28 12:51:42 +04:00
|
|
|
goto unmap1;
|
1997-07-25 05:42:20 +04:00
|
|
|
}
|
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
if (sbdsp_reset(&sc->sc_sbdsp) < 0) {
|
|
|
|
DPRINTF(("pas: couldn't reset card\n"));
|
1997-07-25 05:42:20 +04:00
|
|
|
goto unmap;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cannot auto-discover DMA channel.
|
|
|
|
*/
|
2002-01-08 00:46:56 +03:00
|
|
|
if (!SB_DRQ_VALID(ia->ia_drq[0].ir_drq)) {
|
2003-05-03 22:10:37 +04:00
|
|
|
printf("pas: configured DMA chan %d invalid\n",
|
2002-01-08 00:46:56 +03:00
|
|
|
ia->ia_drq[0].ir_drq);
|
1997-07-25 05:42:20 +04:00
|
|
|
goto unmap;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
2002-01-08 00:46:56 +03:00
|
|
|
if (!SB_IRQ_VALID(ia->ia_irq[0].ir_irq)) {
|
|
|
|
printf("pas: configured irq chan %d invalid\n",
|
|
|
|
ia->ia_drq[0].ir_drq);
|
1997-07-25 05:42:20 +04:00
|
|
|
goto unmap;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
sc->sc_sbdsp.sc_irq = ia->ia_irq[0].ir_irq;
|
|
|
|
sc->sc_sbdsp.sc_drq8 = ia->ia_drq[0].ir_drq;
|
1997-03-24 08:30:28 +03:00
|
|
|
sc->sc_sbdsp.sc_drq16 = -1; /* XXX */
|
2005-01-14 06:41:45 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
|
|
|
|
DPRINTF(("pas: sbdsp probe failed\n"));
|
1997-07-25 05:42:20 +04:00
|
|
|
goto unmap;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
1998-06-22 21:21:34 +04:00
|
|
|
rc = 1;
|
2002-01-08 00:46:56 +03:00
|
|
|
|
|
|
|
if (probing) {
|
|
|
|
ia->ia_nio = 1;
|
|
|
|
ia->ia_io[0].ir_size = SBP_NPORT;
|
|
|
|
|
|
|
|
ia->ia_nirq = 1;
|
|
|
|
ia->ia_ndrq = 1;
|
|
|
|
|
|
|
|
ia->ia_niomem = 0;
|
|
|
|
}
|
1997-07-25 05:42:20 +04:00
|
|
|
|
|
|
|
unmap:
|
1998-06-22 21:21:34 +04:00
|
|
|
if (rc == 0 || probing)
|
2005-01-14 06:41:45 +03:00
|
|
|
bus_space_unmap(sc->sc_sbdsp.sc_iot, sc->sc_sbdsp.sc_ioh,
|
|
|
|
SBP_NPORT);
|
1998-06-22 21:21:34 +04:00
|
|
|
unmap1:
|
|
|
|
if (rc == 0 || probing)
|
2005-01-14 06:41:45 +03:00
|
|
|
bus_space_unmap(sc->sc_sbdsp.sc_iot, PAS_DEFAULT_BASE, 1);
|
1998-06-22 21:21:34 +04:00
|
|
|
return rc;
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach hardware to driver, attach hardware driver to audio
|
|
|
|
* pseudo-device driver .
|
|
|
|
*/
|
|
|
|
void
|
2005-01-14 06:41:45 +03:00
|
|
|
pasattach(struct device *parent, struct device *self, void *aux)
|
1995-02-21 05:27:18 +03:00
|
|
|
{
|
2005-01-14 06:41:45 +03:00
|
|
|
struct pas_softc *sc;
|
|
|
|
struct isa_attach_args *ia;
|
|
|
|
int iobase;
|
|
|
|
|
|
|
|
sc = (struct pas_softc *)self;
|
|
|
|
ia = (struct isa_attach_args *)aux;
|
|
|
|
iobase = ia->ia_io[0].ir_addr;
|
1998-06-22 21:21:34 +04:00
|
|
|
if (!pasfind(parent, sc, ia, PASATTACH)) {
|
1998-03-23 04:00:21 +03:00
|
|
|
printf("%s: pasfind failed\n", sc->sc_sbdsp.sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-06-09 04:05:44 +04:00
|
|
|
sc->sc_sbdsp.sc_ic = ia->ia_ic;
|
1996-11-12 10:39:56 +03:00
|
|
|
sc->sc_sbdsp.sc_iobase = iobase;
|
2002-01-08 00:46:56 +03:00
|
|
|
sc->sc_sbdsp.sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
|
1996-11-12 10:39:56 +03:00
|
|
|
IST_EDGE, IPL_AUDIO, sbdsp_intr, &sc->sc_sbdsp);
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1996-11-12 10:39:56 +03:00
|
|
|
printf(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model],
|
|
|
|
sc->rev);
|
2005-01-14 06:41:45 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
sbdsp_attach(&sc->sc_sbdsp);
|
|
|
|
|
2004-04-22 04:17:10 +04:00
|
|
|
snprintf(pas_device.name, sizeof(pas_device.name), "pas,%s",
|
|
|
|
pasnames[sc->model]);
|
|
|
|
snprintf(pas_device.version, sizeof(pas_device.version), "%d",
|
|
|
|
sc->rev);
|
1995-02-21 05:27:18 +03:00
|
|
|
|
1998-08-18 01:16:09 +04:00
|
|
|
audio_attach_mi(&pas_hw_if, &sc->sc_sbdsp, &sc->sc_sbdsp.sc_dev);
|
1995-02-21 05:27:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-01-14 06:41:45 +03:00
|
|
|
pas_getdev(void *addr, struct audio_device *retp)
|
1995-02-21 05:27:18 +03:00
|
|
|
{
|
2005-01-14 06:41:45 +03:00
|
|
|
|
1995-02-21 05:27:18 +03:00
|
|
|
*retp = pas_device;
|
|
|
|
return 0;
|
|
|
|
}
|