Home | History | Annotate | Line # | Download | only in isa
pas.c revision 1.57.2.5
      1  1.57.2.5     skrll /*	$NetBSD: pas.c,v 1.57.2.5 2005/01/17 19:31:11 skrll Exp $	*/
      2       1.1    brezak 
      3       1.1    brezak /*
      4       1.1    brezak  * Copyright (c) 1991-1993 Regents of the University of California.
      5       1.1    brezak  * All rights reserved.
      6       1.1    brezak  *
      7       1.1    brezak  * Redistribution and use in source and binary forms, with or without
      8       1.1    brezak  * modification, are permitted provided that the following conditions
      9       1.1    brezak  * are met:
     10       1.1    brezak  * 1. Redistributions of source code must retain the above copyright
     11       1.1    brezak  *    notice, this list of conditions and the following disclaimer.
     12       1.1    brezak  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1    brezak  *    notice, this list of conditions and the following disclaimer in the
     14       1.1    brezak  *    documentation and/or other materials provided with the distribution.
     15       1.1    brezak  * 3. All advertising materials mentioning features or use of this software
     16       1.1    brezak  *    must display the following acknowledgement:
     17       1.1    brezak  *	This product includes software developed by the Computer Systems
     18       1.1    brezak  *	Engineering Group at Lawrence Berkeley Laboratory.
     19       1.1    brezak  * 4. Neither the name of the University nor of the Laboratory may be used
     20       1.1    brezak  *    to endorse or promote products derived from this software without
     21       1.1    brezak  *    specific prior written permission.
     22       1.1    brezak  *
     23       1.1    brezak  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24       1.1    brezak  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25       1.1    brezak  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26       1.1    brezak  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27       1.1    brezak  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28       1.1    brezak  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29       1.1    brezak  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30       1.1    brezak  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31       1.1    brezak  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32       1.1    brezak  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33       1.1    brezak  * SUCH DAMAGE.
     34       1.1    brezak  *
     35       1.1    brezak  */
     36       1.1    brezak /*
     37  1.57.2.5     skrll  * jfw 7/13/97 - The soundblaster code requires the generic bus-space
     38      1.28  augustss  * structures to be set up properly.  Rather than go to the effort of making
     39      1.28  augustss  * code for a dead line fully generic, properly set up the SB structures and
     40      1.28  augustss  * leave the rest x86/ISA/default-configuration specific.  If you have a
     41      1.28  augustss  * REAL computer, go buy a REAL sound card.
     42      1.28  augustss  */
     43      1.28  augustss /*
     44       1.1    brezak  * Todo:
     45  1.57.2.5     skrll  *	- look at other PAS drivers (for PAS native suport)
     46  1.57.2.5     skrll  *	- use common sb.c once emulation is setup
     47       1.1    brezak  */
     48      1.42  augustss /*
     49      1.42  augustss  * jfw 6/21/98 - WARNING:  the PAS native IO ports are scattered all around
     50      1.42  augustss  * IO port space (0x0388, 0x738B, 0xBF88, 0x2789, ...) which will make proper
     51      1.42  augustss  * reservation a real pain, so I'm not going to do it (while fixing the
     52      1.42  augustss  * current reservation code to "work").  As a sanity check, I reserve the
     53      1.42  augustss  * 0x0388 base address, but you probably shouldn't even think of trying this
     54      1.42  augustss  * driver unless you're certain you have the hardware installed and it doesn't
     55      1.42  augustss  * conflict with other hardware...
     56      1.42  augustss  */
     57      1.42  augustss 
     58      1.51     lukem 
     59      1.51     lukem #include <sys/cdefs.h>
     60  1.57.2.5     skrll __KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.57.2.5 2005/01/17 19:31:11 skrll Exp $");
     61       1.1    brezak 
     62       1.1    brezak #include <sys/param.h>
     63       1.1    brezak #include <sys/systm.h>
     64       1.1    brezak #include <sys/errno.h>
     65       1.1    brezak #include <sys/ioctl.h>
     66       1.1    brezak #include <sys/syslog.h>
     67       1.1    brezak #include <sys/device.h>
     68       1.1    brezak #include <sys/proc.h>
     69       1.1    brezak 
     70       1.1    brezak #include <machine/cpu.h>
     71      1.17   mycroft #include <machine/intr.h>
     72      1.27   thorpej #include <machine/bus.h>
     73       1.1    brezak #include <machine/pio.h>
     74       1.1    brezak 
     75       1.1    brezak #include <sys/audioio.h>
     76       1.1    brezak #include <dev/audio_if.h>
     77      1.44  augustss #include <dev/midi_if.h>
     78       1.1    brezak 
     79       1.5       cgd #include <dev/isa/isavar.h>
     80       1.5       cgd #include <dev/isa/isadmavar.h>
     81       1.1    brezak 
     82       1.6       cgd #include <dev/isa/sbdspvar.h>
     83       1.6       cgd #include <dev/isa/sbreg.h>
     84       1.1    brezak 
     85       1.1    brezak #define DEFINE_TRANSLATIONS
     86       1.6       cgd #include <dev/isa/pasreg.h>
     87       1.1    brezak 
     88       1.8    brezak #ifdef AUDIO_DEBUG
     89      1.19  christos #define DPRINTF(x)	if (pasdebug) printf x
     90       1.1    brezak int	pasdebug = 0;
     91       1.1    brezak #else
     92       1.1    brezak #define DPRINTF(x)
     93       1.1    brezak #endif
     94       1.1    brezak 
     95       1.1    brezak /*
     96       1.1    brezak  * Software state, per SoundBlaster card.
     97       1.1    brezak  * The soundblaster has multiple functionality, which we must demultiplex.
     98       1.1    brezak  * One approach is to have one major device number for the soundblaster card,
     99       1.1    brezak  * and use different minor numbers to indicate which hardware function
    100       1.1    brezak  * we want.  This would make for one large driver.  Instead our approach
    101       1.1    brezak  * is to partition the design into a set of drivers that share an underlying
    102       1.1    brezak  * piece of hardware.  Most things are hard to share, for example, the audio
    103       1.1    brezak  * and midi ports.  For audio, we might want to mix two processes' signals,
    104       1.1    brezak  * and for midi we might want to merge streams (this is hard due to
    105       1.1    brezak  * running status).  Moreover, we should be able to re-use the high-level
    106       1.1    brezak  * modules with other kinds of hardware.  In this module, we only handle the
    107       1.1    brezak  * most basic communications with the sb card.
    108       1.1    brezak  */
    109       1.1    brezak struct pas_softc {
    110      1.20     mikel 	struct sbdsp_softc sc_sbdsp;	/* base device, &c. */
    111  1.57.2.5     skrll 	bus_space_handle_t pas_port_handle;    /* the pas-specific port */
    112       1.1    brezak 
    113       1.1    brezak 	int model;
    114       1.1    brezak 	int rev;
    115       1.1    brezak };
    116       1.1    brezak 
    117  1.57.2.5     skrll int	pas_getdev(void *, struct audio_device *);
    118  1.57.2.5     skrll void	pasconf(int, int, int, int);
    119       1.1    brezak 
    120       1.1    brezak 
    121       1.1    brezak /*
    122       1.1    brezak  * Define our interface to the higher level audio driver.
    123       1.1    brezak  */
    124       1.1    brezak 
    125  1.57.2.4     skrll const struct audio_hw_if pas_hw_if = {
    126      1.33  augustss 	sbdsp_open,
    127       1.1    brezak 	sbdsp_close,
    128      1.30  augustss 	0,
    129       1.1    brezak 	sbdsp_query_encoding,
    130      1.26  augustss 	sbdsp_set_params,
    131       1.1    brezak 	sbdsp_round_blocksize,
    132      1.30  augustss 	0,
    133      1.43   mycroft 	0,
    134      1.43   mycroft 	0,
    135      1.43   mycroft 	0,
    136      1.43   mycroft 	0,
    137      1.46   mycroft 	sbdsp_halt_output,
    138      1.46   mycroft 	sbdsp_halt_input,
    139       1.1    brezak 	sbdsp_speaker_ctl,
    140       1.1    brezak 	pas_getdev,
    141      1.30  augustss 	0,
    142       1.1    brezak 	sbdsp_mixer_set_port,
    143       1.1    brezak 	sbdsp_mixer_get_port,
    144       1.1    brezak 	sbdsp_mixer_query_devinfo,
    145      1.29  augustss 	sb_malloc,
    146      1.29  augustss 	sb_free,
    147      1.45   mycroft 	sb_round_buffersize,
    148  1.57.2.5     skrll 	sb_mappage,
    149      1.33  augustss 	sbdsp_get_props,
    150      1.43   mycroft 	sbdsp_trigger_output,
    151      1.43   mycroft 	sbdsp_trigger_input,
    152      1.50  augustss 	0,
    153       1.1    brezak };
    154       1.1    brezak 
    155       1.1    brezak /* The Address Translation code is used to convert I/O register addresses to
    156       1.1    brezak    be relative to the given base -register */
    157       1.1    brezak 
    158  1.57.2.5     skrll static const char *pasnames[] = {
    159       1.1    brezak 	"",
    160       1.1    brezak 	"Plus",
    161       1.1    brezak 	"CDPC",
    162       1.3    brezak 	"16",
    163       1.3    brezak 	"16Basic"
    164       1.1    brezak };
    165       1.1    brezak 
    166       1.1    brezak static struct audio_device pas_device = {
    167       1.1    brezak 	"PAS,??",
    168       1.1    brezak 	"",
    169       1.1    brezak 	"pas"
    170       1.1    brezak };
    171       1.1    brezak 
    172       1.1    brezak /*XXX assume default I/O base address */
    173      1.48     lukem #define pasread(p) inb((p))
    174      1.48     lukem #define paswrite(d, p) outb((p), (d))
    175       1.1    brezak 
    176       1.1    brezak void
    177  1.57.2.5     skrll pasconf(int model, int sbbase, int sbirq, int sbdrq)
    178       1.1    brezak {
    179  1.57.2.5     skrll 
    180       1.1    brezak 	paswrite(0x00, INTERRUPT_MASK);
    181       1.1    brezak 	/* Local timer control register */
    182       1.1    brezak 	paswrite(0x36, SAMPLE_COUNTER_CONTROL);
    183       1.1    brezak 	/* Sample rate timer (16 bit) */
    184       1.1    brezak 	paswrite(0x36, SAMPLE_RATE_TIMER);
    185       1.1    brezak 	paswrite(0, SAMPLE_RATE_TIMER);
    186       1.1    brezak 	/* Local timer control register */
    187       1.1    brezak 	paswrite(0x74, SAMPLE_COUNTER_CONTROL);
    188       1.1    brezak 	/* Sample count register (16 bit) */
    189       1.1    brezak 	paswrite(0x74, SAMPLE_BUFFER_COUNTER);
    190       1.1    brezak 	paswrite(0, SAMPLE_BUFFER_COUNTER);
    191       1.1    brezak 
    192       1.1    brezak 	paswrite(P_C_PCM_MONO | P_C_PCM_DAC_MODE |
    193  1.57.2.5     skrll 	    P_C_MIXER_CROSS_L_TO_L | P_C_MIXER_CROSS_R_TO_R,
    194  1.57.2.5     skrll 	    PCM_CONTROL);
    195       1.1    brezak 	paswrite(S_M_PCM_RESET | S_M_FM_RESET |
    196  1.57.2.5     skrll 	    S_M_SB_RESET | S_M_MIXER_RESET, SERIAL_MIXER);
    197       1.1    brezak 
    198       1.1    brezak /*XXX*/
    199       1.1    brezak 	paswrite(I_C_1_BOOT_RESET_ENABLE|1, IO_CONFIGURATION_1);
    200       1.1    brezak 
    201       1.1    brezak 	paswrite(I_C_2_PCM_DMA_DISABLED, IO_CONFIGURATION_2);
    202       1.1    brezak 	paswrite(I_C_3_PCM_IRQ_DISABLED, IO_CONFIGURATION_3);
    203  1.57.2.5     skrll 
    204  1.57.2.5     skrll #ifdef BROKEN_BUS_CLOCK
    205       1.1    brezak 	paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND |
    206  1.57.2.5     skrll 	    S_C_1_FM_EMULATE_CLOCK, SYSTEM_CONFIGURATION_1);
    207       1.1    brezak #else
    208       1.1    brezak 	paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND,
    209  1.57.2.5     skrll 	    SYSTEM_CONFIGURATION_1);
    210       1.1    brezak #endif
    211       1.1    brezak 
    212       1.1    brezak 	/*XXX*/
    213       1.1    brezak 	paswrite(0, SYSTEM_CONFIGURATION_2);
    214       1.1    brezak 	paswrite(0, SYSTEM_CONFIGURATION_3);
    215       1.1    brezak 
    216       1.1    brezak 	/* Sets mute off and selects filter rate of 17.897 kHz */
    217       1.1    brezak 	paswrite(F_F_MIXER_UNMUTE | 0x01, FILTER_FREQUENCY);
    218       1.1    brezak 
    219       1.3    brezak 	if (model == PAS_16 || model == PAS_16BASIC)
    220       1.1    brezak 		paswrite(8, PRESCALE_DIVIDER);
    221       1.1    brezak 	else
    222       1.1    brezak 		paswrite(0, PRESCALE_DIVIDER);
    223       1.1    brezak 
    224       1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_PCM, PARALLEL_MIXER);
    225       1.1    brezak 	paswrite(5, PARALLEL_MIXER);
    226  1.57.2.5     skrll 
    227       1.1    brezak 	/*
    228       1.1    brezak 	 * Setup SoundBlaster emulation.
    229       1.1    brezak 	 */
    230       1.1    brezak 	paswrite((sbbase >> 4) & 0xf, EMULATION_ADDRESS);
    231       1.1    brezak 	paswrite(E_C_SB_IRQ_translate[sbirq] | E_C_SB_DMA_translate[sbdrq],
    232  1.57.2.5     skrll 	    EMULATION_CONFIGURATION);
    233       1.1    brezak 	paswrite(C_E_SB_ENABLE, COMPATIBILITY_ENABLE);
    234       1.1    brezak 
    235       1.1    brezak 	/*
    236       1.1    brezak 	 * Set mid-range levels.
    237       1.1    brezak 	 */
    238       1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MODE, PARALLEL_MIXER);
    239  1.57.2.5     skrll 	paswrite(P_M_MV508_LOUDNESS | P_M_MV508_ENHANCE_NONE, PARALLEL_MIXER);
    240       1.1    brezak 
    241       1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_A, PARALLEL_MIXER);
    242       1.1    brezak 	paswrite(50, PARALLEL_MIXER);
    243       1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_B, PARALLEL_MIXER);
    244       1.1    brezak 	paswrite(50, PARALLEL_MIXER);
    245       1.1    brezak 
    246  1.57.2.5     skrll 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_SB,
    247  1.57.2.5     skrll 	    PARALLEL_MIXER);
    248       1.1    brezak 	paswrite(P_M_MV508_OUTPUTMIX | 30, PARALLEL_MIXER);
    249       1.1    brezak 
    250  1.57.2.5     skrll 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_MIC,
    251  1.57.2.5     skrll 	    PARALLEL_MIXER);
    252       1.1    brezak 	paswrite(P_M_MV508_INPUTMIX | 30, PARALLEL_MIXER);
    253       1.1    brezak }
    254       1.1    brezak 
    255  1.57.2.5     skrll int	pasprobe(struct device *, struct cfdata *, void *);
    256  1.57.2.5     skrll void	pasattach(struct device *, struct device *, void *);
    257  1.57.2.5     skrll static	int pasfind(struct device *, struct pas_softc *,
    258  1.57.2.5     skrll     struct isa_attach_args *, int);
    259      1.42  augustss /* argument to pasfind */
    260      1.42  augustss #define PASPROBE  1
    261      1.42  augustss #define PASATTACH 0
    262      1.12   mycroft 
    263      1.55   thorpej CFATTACH_DECL(pas, sizeof(struct pas_softc),
    264      1.56   thorpej     pasprobe, pasattach, NULL, NULL);
    265       1.1    brezak 
    266       1.1    brezak /*
    267       1.1    brezak  * Probe / attach routines.
    268       1.1    brezak  */
    269       1.1    brezak 
    270       1.1    brezak int
    271  1.57.2.5     skrll pasprobe(struct device *parent, struct cfdata *match, void *aux)
    272       1.1    brezak {
    273  1.57.2.5     skrll 	struct isa_attach_args *ia;
    274  1.57.2.5     skrll 	struct pas_softc probesc, *sc;
    275      1.39  augustss 
    276  1.57.2.5     skrll 	ia = aux;
    277  1.57.2.5     skrll 	sc = &probesc;
    278      1.52   thorpej 	if (ia->ia_nio < 1)
    279  1.57.2.5     skrll 		return 0;
    280      1.52   thorpej 	if (ia->ia_nirq < 1)
    281  1.57.2.5     skrll 		return 0;
    282      1.52   thorpej 	if (ia->ia_ndrq < 1)
    283  1.57.2.5     skrll 		return 0;
    284      1.52   thorpej 
    285      1.52   thorpej 	if (ISA_DIRECT_CONFIG(ia))
    286  1.57.2.5     skrll 		return 0;
    287      1.52   thorpej 
    288      1.49   thorpej 	memset(sc, 0, sizeof *sc);
    289      1.53  jdolecek 	sc->sc_sbdsp.sc_dev.dv_cfdata = match;
    290      1.39  augustss 	strcpy(sc->sc_sbdsp.sc_dev.dv_xname, "pas");
    291      1.42  augustss 	return pasfind(parent, sc, aux, PASPROBE);
    292      1.39  augustss }
    293      1.39  augustss 
    294      1.39  augustss /*
    295      1.39  augustss  * Probe for the soundblaster hardware.
    296      1.39  augustss  */
    297      1.39  augustss static int
    298  1.57.2.5     skrll pasfind(struct device *parent, struct pas_softc *sc,
    299  1.57.2.5     skrll     struct isa_attach_args *ia, int probing)
    300      1.39  augustss {
    301      1.35  augustss 	int iobase;
    302       1.1    brezak 	u_char id, t;
    303  1.57.2.5     skrll 	int rc;
    304       1.1    brezak 
    305  1.57.2.5     skrll 	rc = 0;			/* failure */
    306  1.57.2.5     skrll 	/* ensure we can set this up as a sound blaster */
    307  1.57.2.5     skrll 	if (!SB_BASE_VALID(ia->ia_io[0].ir_addr)) {
    308      1.52   thorpej 		printf("pas: configured SB iobase 0x%x invalid\n",
    309      1.52   thorpej 		    ia->ia_io[0].ir_addr);
    310      1.28  augustss 		return 0;
    311      1.28  augustss 	}
    312      1.28  augustss 
    313      1.42  augustss 	if (bus_space_map(sc->sc_sbdsp.sc_iot, PAS_DEFAULT_BASE, 1, 0,
    314  1.57.2.5     skrll 	    &sc->pas_port_handle)) {
    315      1.42  augustss 		printf("pas: can't map base register %x in probe\n",
    316  1.57.2.5     skrll 		    PAS_DEFAULT_BASE);
    317      1.42  augustss 		return 0;
    318      1.42  augustss 	}
    319      1.42  augustss 
    320       1.1    brezak 	/*
    321       1.1    brezak 	 * WARNING: Setting an option like W:1 or so that disables
    322       1.1    brezak 	 * warm boot reset of the card will screw up this detect code
    323       1.1    brezak 	 * something fierce.  Adding code to handle this means possibly
    324       1.1    brezak 	 * interfering with other cards on the bus if you have something
    325  1.57.2.5     skrll 	 * on base port 0x388.  SO be forewarned.
    326       1.1    brezak 	 */
    327       1.1    brezak 	/* Talk to first board */
    328       1.1    brezak 	outb(MASTER_DECODE, 0xbc);
    329       1.1    brezak 	/* Set base address */
    330       1.1    brezak 
    331       1.1    brezak #if 0
    332       1.1    brezak 	/* XXX Need to setup pseudo device */
    333       1.1    brezak 	/* XXX What are good io addrs ? */
    334       1.1    brezak 	if (iobase != PAS_DEFAULT_BASE) {
    335      1.19  christos 		printf("pas: configured iobase %d invalid\n", iobase);
    336       1.1    brezak 		return 0;
    337       1.1    brezak 	}
    338       1.1    brezak #else
    339       1.1    brezak 	/* Start out talking to native PAS */
    340       1.1    brezak 	iobase = PAS_DEFAULT_BASE;
    341       1.1    brezak #endif
    342       1.1    brezak 
    343       1.1    brezak 	outb(MASTER_DECODE, iobase >> 2);
    344       1.1    brezak 	/* One wait-state */
    345       1.1    brezak 	paswrite(1, WAIT_STATE);
    346       1.1    brezak 
    347       1.1    brezak 	id = pasread(INTERRUPT_MASK);
    348       1.1    brezak 	if (id == 0xff || id == 0xfe) {
    349       1.1    brezak 		/* sanity */
    350       1.1    brezak 		DPRINTF(("pas: bogus card id\n"));
    351      1.42  augustss 		goto unmap1;
    352       1.1    brezak 	}
    353       1.1    brezak 	/*
    354       1.1    brezak 	 * We probably have a PAS-series board, now check for a
    355       1.1    brezak 	 * PAS2-series board by trying to change the board revision
    356       1.1    brezak 	 * bits.  PAS2-series hardware won't let you do this because
    357       1.1    brezak 	 * the bits are read-only.
    358       1.1    brezak 	 */
    359       1.1    brezak 	t = id ^ 0xe0;
    360       1.1    brezak 	paswrite(t, INTERRUPT_MASK);
    361       1.1    brezak 	t = inb(INTERRUPT_MASK);
    362       1.1    brezak 	paswrite(id, INTERRUPT_MASK);
    363       1.1    brezak 
    364       1.1    brezak 	if (t != id) {
    365       1.1    brezak 		/* Not a PAS2 */
    366      1.19  christos 		printf("pas: detected card but PAS2 test failed\n");
    367      1.42  augustss 		goto unmap1;
    368       1.1    brezak 	}
    369       1.1    brezak 	/*XXX*/
    370       1.1    brezak 	t = pasread(OPERATION_MODE_1) & 0xf;
    371       1.1    brezak 	sc->model = O_M_1_to_card[t];
    372       1.1    brezak 	if (sc->model != 0) {
    373       1.1    brezak 		sc->rev = pasread(BOARD_REV_ID);
    374  1.57.2.5     skrll 	} else {
    375       1.1    brezak 		DPRINTF(("pas: bogus model id\n"));
    376      1.42  augustss 		goto unmap1;
    377       1.1    brezak 	}
    378       1.1    brezak 
    379  1.57.2.5     skrll 	if (sc->model >= 0) {
    380  1.57.2.5     skrll 		if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ) {
    381  1.57.2.5     skrll 			printf("pas: sb emulation requires known irq\n");
    382      1.42  augustss 			goto unmap1;
    383  1.57.2.5     skrll 		}
    384  1.57.2.5     skrll 		pasconf(sc->model, ia->ia_io[0].ir_addr,
    385  1.57.2.5     skrll 		    ia->ia_irq[0].ir_irq, 1);
    386  1.57.2.5     skrll 	} else {
    387  1.57.2.5     skrll 		DPRINTF(("pas: could not probe pas\n"));
    388      1.42  augustss 		goto unmap1;
    389  1.57.2.5     skrll 	}
    390       1.1    brezak 
    391      1.28  augustss 	/* Now a SoundBlaster, so set up proper bus-space hooks
    392      1.28  augustss          * appropriately
    393      1.28  augustss          */
    394      1.28  augustss 
    395      1.52   thorpej 	sc->sc_sbdsp.sc_iobase = ia->ia_io[0].ir_addr;
    396      1.24  augustss 	sc->sc_sbdsp.sc_iot = ia->ia_iot;
    397      1.28  augustss 
    398      1.28  augustss 	/* Map i/o space [we map 24 ports which is the max of the sb and pro */
    399      1.52   thorpej 	if (bus_space_map(sc->sc_sbdsp.sc_iot, ia->ia_io[0].ir_addr,
    400      1.52   thorpej 	    SBP_NPORT, 0, &sc->sc_sbdsp.sc_ioh)) {
    401      1.28  augustss 		printf("pas: can't map i/o space 0x%x/%d in probe\n",
    402      1.52   thorpej 		    ia->ia_io[0].ir_addr, SBP_NPORT);
    403      1.47  jdolecek 		goto unmap1;
    404      1.28  augustss 	}
    405      1.28  augustss 
    406       1.1    brezak 	if (sbdsp_reset(&sc->sc_sbdsp) < 0) {
    407       1.1    brezak 		DPRINTF(("pas: couldn't reset card\n"));
    408      1.28  augustss 		goto unmap;
    409       1.1    brezak 	}
    410       1.1    brezak 
    411       1.1    brezak 	/*
    412       1.1    brezak 	 * Cannot auto-discover DMA channel.
    413       1.1    brezak 	 */
    414      1.52   thorpej 	if (!SB_DRQ_VALID(ia->ia_drq[0].ir_drq)) {
    415      1.57       wiz 		printf("pas: configured DMA chan %d invalid\n",
    416      1.52   thorpej 		    ia->ia_drq[0].ir_drq);
    417      1.28  augustss 		goto unmap;
    418       1.1    brezak 	}
    419      1.52   thorpej 	if (!SB_IRQ_VALID(ia->ia_irq[0].ir_irq)) {
    420      1.52   thorpej 		printf("pas: configured irq chan %d invalid\n",
    421      1.52   thorpej 		    ia->ia_drq[0].ir_drq);
    422      1.28  augustss 		goto unmap;
    423       1.1    brezak 	}
    424       1.1    brezak 
    425      1.52   thorpej 	sc->sc_sbdsp.sc_irq = ia->ia_irq[0].ir_irq;
    426      1.52   thorpej 	sc->sc_sbdsp.sc_drq8 = ia->ia_drq[0].ir_drq;
    427      1.23       jtk 	sc->sc_sbdsp.sc_drq16 = -1; /* XXX */
    428  1.57.2.5     skrll 
    429       1.1    brezak 	if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
    430       1.1    brezak 		DPRINTF(("pas: sbdsp probe failed\n"));
    431      1.28  augustss 		goto unmap;
    432       1.1    brezak 	}
    433       1.1    brezak 
    434      1.42  augustss 	rc = 1;
    435      1.52   thorpej 
    436      1.52   thorpej 	if (probing) {
    437      1.52   thorpej 		ia->ia_nio = 1;
    438      1.52   thorpej 		ia->ia_io[0].ir_size = SBP_NPORT;
    439      1.52   thorpej 
    440      1.52   thorpej 		ia->ia_nirq = 1;
    441      1.52   thorpej 		ia->ia_ndrq = 1;
    442      1.52   thorpej 
    443      1.52   thorpej 		ia->ia_niomem = 0;
    444      1.52   thorpej 	}
    445      1.28  augustss 
    446      1.28  augustss  unmap:
    447      1.42  augustss 	if (rc == 0 || probing)
    448  1.57.2.5     skrll 		bus_space_unmap(sc->sc_sbdsp.sc_iot, sc->sc_sbdsp.sc_ioh,
    449  1.57.2.5     skrll 		    SBP_NPORT);
    450      1.42  augustss  unmap1:
    451      1.42  augustss 	if (rc == 0 || probing)
    452  1.57.2.5     skrll 		bus_space_unmap(sc->sc_sbdsp.sc_iot, PAS_DEFAULT_BASE, 1);
    453      1.42  augustss 	return rc;
    454       1.1    brezak }
    455       1.1    brezak 
    456       1.1    brezak /*
    457       1.1    brezak  * Attach hardware to driver, attach hardware driver to audio
    458       1.1    brezak  * pseudo-device driver .
    459       1.1    brezak  */
    460       1.1    brezak void
    461  1.57.2.5     skrll pasattach(struct device *parent, struct device *self, void *aux)
    462       1.1    brezak {
    463  1.57.2.5     skrll 	struct pas_softc *sc;
    464  1.57.2.5     skrll 	struct isa_attach_args *ia;
    465  1.57.2.5     skrll 	int iobase;
    466  1.57.2.5     skrll 
    467  1.57.2.5     skrll 	sc = (struct pas_softc *)self;
    468  1.57.2.5     skrll 	ia = (struct isa_attach_args *)aux;
    469  1.57.2.5     skrll 	iobase = ia->ia_io[0].ir_addr;
    470      1.42  augustss 	if (!pasfind(parent, sc, ia, PASATTACH)) {
    471      1.39  augustss 		printf("%s: pasfind failed\n", sc->sc_sbdsp.sc_dev.dv_xname);
    472      1.39  augustss 		return;
    473      1.39  augustss 	}
    474      1.39  augustss 
    475      1.40   thorpej 	sc->sc_sbdsp.sc_ic = ia->ia_ic;
    476      1.20     mikel 	sc->sc_sbdsp.sc_iobase = iobase;
    477      1.52   thorpej 	sc->sc_sbdsp.sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
    478      1.20     mikel 	    IST_EDGE, IPL_AUDIO, sbdsp_intr, &sc->sc_sbdsp);
    479       1.1    brezak 
    480      1.20     mikel 	printf(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model],
    481      1.20     mikel 	    sc->rev);
    482  1.57.2.5     skrll 
    483       1.1    brezak 	sbdsp_attach(&sc->sc_sbdsp);
    484       1.1    brezak 
    485  1.57.2.1     skrll 	snprintf(pas_device.name, sizeof(pas_device.name), "pas,%s",
    486  1.57.2.1     skrll 	    pasnames[sc->model]);
    487  1.57.2.1     skrll 	snprintf(pas_device.version, sizeof(pas_device.version), "%d",
    488  1.57.2.1     skrll 	    sc->rev);
    489       1.1    brezak 
    490      1.44  augustss 	audio_attach_mi(&pas_hw_if, &sc->sc_sbdsp, &sc->sc_sbdsp.sc_dev);
    491       1.1    brezak }
    492       1.1    brezak 
    493       1.1    brezak int
    494  1.57.2.5     skrll pas_getdev(void *addr, struct audio_device *retp)
    495       1.1    brezak {
    496  1.57.2.5     skrll 
    497       1.1    brezak 	*retp = pas_device;
    498       1.1    brezak 	return 0;
    499       1.1    brezak }
    500