Home | History | Annotate | Line # | Download | only in isa
pas.c revision 1.28
      1  1.28  augustss /*	$NetBSD: pas.c,v 1.28 1997/07/25 01:42:20 augustss 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.28  augustss  * 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.1    brezak  * 	- look at other PAS drivers (for PAS native suport)
     46   1.1    brezak  * 	- use common sb.c once emulation is setup
     47   1.1    brezak  */
     48   1.1    brezak 
     49   1.1    brezak #include <sys/param.h>
     50   1.1    brezak #include <sys/systm.h>
     51   1.1    brezak #include <sys/errno.h>
     52   1.1    brezak #include <sys/ioctl.h>
     53   1.1    brezak #include <sys/syslog.h>
     54   1.1    brezak #include <sys/device.h>
     55   1.1    brezak #include <sys/proc.h>
     56   1.1    brezak 
     57   1.1    brezak #include <machine/cpu.h>
     58  1.17   mycroft #include <machine/intr.h>
     59  1.27   thorpej #include <machine/bus.h>
     60   1.1    brezak #include <machine/pio.h>
     61   1.1    brezak 
     62   1.1    brezak #include <sys/audioio.h>
     63   1.1    brezak #include <dev/audio_if.h>
     64   1.1    brezak 
     65   1.5       cgd #include <dev/isa/isavar.h>
     66   1.5       cgd #include <dev/isa/isadmavar.h>
     67   1.1    brezak 
     68   1.6       cgd #include <dev/isa/sbdspvar.h>
     69   1.6       cgd #include <dev/isa/sbreg.h>
     70   1.1    brezak 
     71   1.1    brezak #define DEFINE_TRANSLATIONS
     72   1.6       cgd #include <dev/isa/pasreg.h>
     73   1.1    brezak 
     74   1.8    brezak #ifdef AUDIO_DEBUG
     75  1.19  christos #define DPRINTF(x)	if (pasdebug) printf x
     76   1.1    brezak int	pasdebug = 0;
     77   1.1    brezak #else
     78   1.1    brezak #define DPRINTF(x)
     79   1.1    brezak #endif
     80   1.1    brezak 
     81   1.1    brezak /*
     82   1.1    brezak  * Software state, per SoundBlaster card.
     83   1.1    brezak  * The soundblaster has multiple functionality, which we must demultiplex.
     84   1.1    brezak  * One approach is to have one major device number for the soundblaster card,
     85   1.1    brezak  * and use different minor numbers to indicate which hardware function
     86   1.1    brezak  * we want.  This would make for one large driver.  Instead our approach
     87   1.1    brezak  * is to partition the design into a set of drivers that share an underlying
     88   1.1    brezak  * piece of hardware.  Most things are hard to share, for example, the audio
     89   1.1    brezak  * and midi ports.  For audio, we might want to mix two processes' signals,
     90   1.1    brezak  * and for midi we might want to merge streams (this is hard due to
     91   1.1    brezak  * running status).  Moreover, we should be able to re-use the high-level
     92   1.1    brezak  * modules with other kinds of hardware.  In this module, we only handle the
     93   1.1    brezak  * most basic communications with the sb card.
     94   1.1    brezak  */
     95   1.1    brezak struct pas_softc {
     96  1.20     mikel 	struct sbdsp_softc sc_sbdsp;	/* base device, &c. */
     97   1.1    brezak 
     98   1.1    brezak 	int model;
     99   1.1    brezak 	int rev;
    100   1.1    brezak };
    101   1.1    brezak 
    102   1.1    brezak int	pasopen __P((dev_t, int));
    103   1.4   mycroft int	pas_getdev __P((void *, struct audio_device *));
    104  1.16  christos void	pasconf __P((int, int, int, int));
    105   1.1    brezak 
    106   1.1    brezak 
    107   1.1    brezak /*
    108   1.1    brezak  * Define our interface to the higher level audio driver.
    109   1.1    brezak  */
    110   1.1    brezak 
    111   1.1    brezak struct audio_hw_if pas_hw_if = {
    112   1.1    brezak 	pasopen,
    113   1.1    brezak 	sbdsp_close,
    114   1.1    brezak 	NULL,
    115   1.1    brezak 	sbdsp_query_encoding,
    116  1.26  augustss 	sbdsp_set_params,
    117   1.1    brezak 	sbdsp_round_blocksize,
    118   1.1    brezak 	sbdsp_set_out_port,
    119   1.1    brezak 	sbdsp_get_out_port,
    120   1.1    brezak 	sbdsp_set_in_port,
    121   1.1    brezak 	sbdsp_get_in_port,
    122   1.1    brezak 	sbdsp_commit_settings,
    123   1.1    brezak 	sbdsp_dma_output,
    124   1.1    brezak 	sbdsp_dma_input,
    125   1.1    brezak 	sbdsp_haltdma,
    126   1.1    brezak 	sbdsp_haltdma,
    127   1.1    brezak 	sbdsp_contdma,
    128   1.1    brezak 	sbdsp_contdma,
    129   1.1    brezak 	sbdsp_speaker_ctl,
    130   1.1    brezak 	pas_getdev,
    131   1.1    brezak 	sbdsp_setfd,
    132   1.1    brezak 	sbdsp_mixer_set_port,
    133   1.1    brezak 	sbdsp_mixer_get_port,
    134   1.1    brezak 	sbdsp_mixer_query_devinfo,
    135   1.1    brezak 	0,	/* not full-duplex */
    136   1.1    brezak 	0
    137   1.1    brezak };
    138   1.1    brezak 
    139   1.1    brezak /* The Address Translation code is used to convert I/O register addresses to
    140   1.1    brezak    be relative to the given base -register */
    141   1.1    brezak 
    142   1.1    brezak static char *pasnames[] = {
    143   1.1    brezak 	"",
    144   1.1    brezak 	"Plus",
    145   1.1    brezak 	"CDPC",
    146   1.3    brezak 	"16",
    147   1.3    brezak 	"16Basic"
    148   1.1    brezak };
    149   1.1    brezak 
    150   1.1    brezak static struct audio_device pas_device = {
    151   1.1    brezak 	"PAS,??",
    152   1.1    brezak 	"",
    153   1.1    brezak 	"pas"
    154   1.1    brezak };
    155   1.1    brezak 
    156   1.1    brezak /*XXX assume default I/O base address */
    157   1.1    brezak #define pasread(p) inb(p)
    158   1.1    brezak #define paswrite(d, p) outb(p, d)
    159   1.1    brezak 
    160   1.1    brezak void
    161  1.16  christos pasconf(model, sbbase, sbirq, sbdrq)
    162  1.16  christos 	int model;
    163  1.16  christos 	int sbbase;
    164  1.16  christos 	int sbirq;
    165  1.16  christos 	int sbdrq;
    166   1.1    brezak {
    167   1.1    brezak 	paswrite(0x00, INTERRUPT_MASK);
    168   1.1    brezak 	/* Local timer control register */
    169   1.1    brezak 	paswrite(0x36, SAMPLE_COUNTER_CONTROL);
    170   1.1    brezak 	/* Sample rate timer (16 bit) */
    171   1.1    brezak 	paswrite(0x36, SAMPLE_RATE_TIMER);
    172   1.1    brezak 	paswrite(0, SAMPLE_RATE_TIMER);
    173   1.1    brezak 	/* Local timer control register */
    174   1.1    brezak 	paswrite(0x74, SAMPLE_COUNTER_CONTROL);
    175   1.1    brezak 	/* Sample count register (16 bit) */
    176   1.1    brezak 	paswrite(0x74, SAMPLE_BUFFER_COUNTER);
    177   1.1    brezak 	paswrite(0, SAMPLE_BUFFER_COUNTER);
    178   1.1    brezak 
    179   1.1    brezak 	paswrite(P_C_PCM_MONO | P_C_PCM_DAC_MODE |
    180   1.1    brezak 		  P_C_MIXER_CROSS_L_TO_L | P_C_MIXER_CROSS_R_TO_R,
    181   1.1    brezak 		  PCM_CONTROL);
    182   1.1    brezak 	paswrite(S_M_PCM_RESET | S_M_FM_RESET |
    183   1.1    brezak 		  S_M_SB_RESET | S_M_MIXER_RESET, SERIAL_MIXER);
    184   1.1    brezak 
    185   1.1    brezak /*XXX*/
    186   1.1    brezak 	paswrite(I_C_1_BOOT_RESET_ENABLE|1, IO_CONFIGURATION_1);
    187   1.1    brezak 
    188   1.1    brezak 	paswrite(I_C_2_PCM_DMA_DISABLED, IO_CONFIGURATION_2);
    189   1.1    brezak 	paswrite(I_C_3_PCM_IRQ_DISABLED, IO_CONFIGURATION_3);
    190   1.1    brezak 
    191   1.1    brezak #ifdef BROKEN_BUS_CLOCK
    192   1.1    brezak 	paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND |
    193   1.1    brezak 		  S_C_1_FM_EMULATE_CLOCK, SYSTEM_CONFIGURATION_1);
    194   1.1    brezak #else
    195   1.1    brezak 	paswrite(S_C_1_PCS_ENABLE | S_C_1_PCS_STEREO | S_C_1_PCS_REALSOUND,
    196   1.1    brezak 		  SYSTEM_CONFIGURATION_1);
    197   1.1    brezak #endif
    198   1.1    brezak 
    199   1.1    brezak 	/*XXX*/
    200   1.1    brezak 	paswrite(0, SYSTEM_CONFIGURATION_2);
    201   1.1    brezak 	paswrite(0, SYSTEM_CONFIGURATION_3);
    202   1.1    brezak 
    203   1.1    brezak 	/* Sets mute off and selects filter rate of 17.897 kHz */
    204   1.1    brezak 	paswrite(F_F_MIXER_UNMUTE | 0x01, FILTER_FREQUENCY);
    205   1.1    brezak 
    206   1.3    brezak 	if (model == PAS_16 || model == PAS_16BASIC)
    207   1.1    brezak 		paswrite(8, PRESCALE_DIVIDER);
    208   1.1    brezak 	else
    209   1.1    brezak 		paswrite(0, PRESCALE_DIVIDER);
    210   1.1    brezak 
    211   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_PCM, PARALLEL_MIXER);
    212   1.1    brezak 	paswrite(5, PARALLEL_MIXER);
    213   1.1    brezak 
    214   1.1    brezak 	/*
    215   1.1    brezak 	 * Setup SoundBlaster emulation.
    216   1.1    brezak 	 */
    217   1.1    brezak 	paswrite((sbbase >> 4) & 0xf, EMULATION_ADDRESS);
    218   1.1    brezak 	paswrite(E_C_SB_IRQ_translate[sbirq] | E_C_SB_DMA_translate[sbdrq],
    219   1.1    brezak 		 EMULATION_CONFIGURATION);
    220   1.1    brezak 	paswrite(C_E_SB_ENABLE, COMPATIBILITY_ENABLE);
    221   1.1    brezak 
    222   1.1    brezak 	/*
    223   1.1    brezak 	 * Set mid-range levels.
    224   1.1    brezak 	 */
    225   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MODE, PARALLEL_MIXER);
    226   1.1    brezak 	paswrite(P_M_MV508_LOUDNESS | P_M_MV508_ENHANCE_NONE, PARALLEL_MIXER);
    227   1.1    brezak 
    228   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_A, PARALLEL_MIXER);
    229   1.1    brezak 	paswrite(50, PARALLEL_MIXER);
    230   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MASTER_B, PARALLEL_MIXER);
    231   1.1    brezak 	paswrite(50, PARALLEL_MIXER);
    232   1.1    brezak 
    233   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_SB, PARALLEL_MIXER);
    234   1.1    brezak 	paswrite(P_M_MV508_OUTPUTMIX | 30, PARALLEL_MIXER);
    235   1.1    brezak 
    236   1.1    brezak 	paswrite(P_M_MV508_ADDRESS | P_M_MV508_MIXER | P_M_MV508_MIC, PARALLEL_MIXER);
    237   1.1    brezak 	paswrite(P_M_MV508_INPUTMIX | 30, PARALLEL_MIXER);
    238   1.1    brezak }
    239   1.1    brezak 
    240  1.12   mycroft int	pasprobe __P((struct device *, void *, void *));
    241  1.12   mycroft void	pasattach __P((struct device *, struct device *, void *));
    242  1.12   mycroft 
    243  1.14   thorpej struct cfattach pas_ca = {
    244  1.14   thorpej 	sizeof(struct pas_softc), pasprobe, pasattach
    245  1.14   thorpej };
    246  1.14   thorpej 
    247  1.14   thorpej struct cfdriver pas_cd = {
    248  1.14   thorpej 	NULL, "pas", DV_DULL
    249   1.1    brezak };
    250   1.1    brezak 
    251   1.1    brezak /*
    252   1.1    brezak  * Probe / attach routines.
    253   1.1    brezak  */
    254   1.1    brezak 
    255   1.1    brezak /*
    256   1.1    brezak  * Probe for the soundblaster hardware.
    257   1.1    brezak  */
    258   1.1    brezak int
    259  1.12   mycroft pasprobe(parent, match, aux)
    260  1.12   mycroft 	struct device *parent;
    261  1.12   mycroft 	void *match, *aux;
    262   1.1    brezak {
    263  1.12   mycroft 	register struct pas_softc *sc = match;
    264   1.1    brezak 	register struct isa_attach_args *ia = aux;
    265  1.10   mycroft 	register int iobase;
    266   1.1    brezak 	u_char id, t;
    267   1.1    brezak 
    268  1.28  augustss         /* ensure we can set this up as a sound blaster */
    269  1.28  augustss        	if (!SB_BASE_VALID(ia->ia_iobase)) {
    270  1.28  augustss 		printf("pas: configured SB iobase 0x%x invalid\n", ia->ia_iobase);
    271  1.28  augustss 		return 0;
    272  1.28  augustss 	}
    273  1.28  augustss 
    274   1.1    brezak 	/*
    275   1.1    brezak 	 * WARNING: Setting an option like W:1 or so that disables
    276   1.1    brezak 	 * warm boot reset of the card will screw up this detect code
    277   1.1    brezak 	 * something fierce.  Adding code to handle this means possibly
    278   1.1    brezak 	 * interfering with other cards on the bus if you have something
    279   1.1    brezak 	 * on base port 0x388.  SO be forewarned.
    280   1.1    brezak 	 */
    281   1.1    brezak 	/* Talk to first board */
    282   1.1    brezak 	outb(MASTER_DECODE, 0xbc);
    283   1.1    brezak 	/* Set base address */
    284   1.1    brezak 
    285   1.1    brezak #if 0
    286   1.1    brezak 	/* XXX Need to setup pseudo device */
    287   1.1    brezak 	/* XXX What are good io addrs ? */
    288   1.1    brezak 	if (iobase != PAS_DEFAULT_BASE) {
    289  1.19  christos 		printf("pas: configured iobase %d invalid\n", iobase);
    290   1.1    brezak 		return 0;
    291   1.1    brezak 	}
    292   1.1    brezak #else
    293   1.1    brezak 	/* Start out talking to native PAS */
    294   1.1    brezak 	iobase = PAS_DEFAULT_BASE;
    295   1.1    brezak #endif
    296   1.1    brezak 
    297   1.1    brezak 	outb(MASTER_DECODE, iobase >> 2);
    298   1.1    brezak 	/* One wait-state */
    299   1.1    brezak 	paswrite(1, WAIT_STATE);
    300   1.1    brezak 
    301   1.1    brezak 	id = pasread(INTERRUPT_MASK);
    302   1.1    brezak 	if (id == 0xff || id == 0xfe) {
    303   1.1    brezak 		/* sanity */
    304   1.1    brezak 		DPRINTF(("pas: bogus card id\n"));
    305   1.1    brezak 		return 0;
    306   1.1    brezak 	}
    307   1.1    brezak 	/*
    308   1.1    brezak 	 * We probably have a PAS-series board, now check for a
    309   1.1    brezak 	 * PAS2-series board by trying to change the board revision
    310   1.1    brezak 	 * bits.  PAS2-series hardware won't let you do this because
    311   1.1    brezak 	 * the bits are read-only.
    312   1.1    brezak 	 */
    313   1.1    brezak 	t = id ^ 0xe0;
    314   1.1    brezak 	paswrite(t, INTERRUPT_MASK);
    315   1.1    brezak 	t = inb(INTERRUPT_MASK);
    316   1.1    brezak 	paswrite(id, INTERRUPT_MASK);
    317   1.1    brezak 
    318   1.1    brezak 	if (t != id) {
    319   1.1    brezak 		/* Not a PAS2 */
    320  1.19  christos 		printf("pas: detected card but PAS2 test failed\n");
    321   1.1    brezak 		return 0;
    322   1.1    brezak 	}
    323   1.1    brezak 	/*XXX*/
    324   1.1    brezak 	t = pasread(OPERATION_MODE_1) & 0xf;
    325   1.1    brezak 	sc->model = O_M_1_to_card[t];
    326   1.1    brezak 	if (sc->model != 0) {
    327   1.1    brezak 		sc->rev = pasread(BOARD_REV_ID);
    328   1.1    brezak 	}
    329   1.1    brezak 	else {
    330   1.1    brezak 		DPRINTF(("pas: bogus model id\n"));
    331   1.1    brezak 		return 0;
    332   1.1    brezak 	}
    333   1.1    brezak 
    334   1.1    brezak         if (sc->model >= 0) {
    335  1.10   mycroft                 if (ia->ia_irq == IRQUNK) {
    336  1.19  christos                         printf("pas: sb emulation requires known irq\n");
    337   1.1    brezak                         return (0);
    338   1.1    brezak                 }
    339  1.10   mycroft                 pasconf(sc->model, ia->ia_iobase, ia->ia_irq, 1);
    340   1.1    brezak         } else {
    341   1.2    brezak                 DPRINTF(("pas: could not probe pas\n"));
    342   1.1    brezak                 return (0);
    343   1.1    brezak         }
    344   1.1    brezak 
    345  1.28  augustss 	/* Now a SoundBlaster, so set up proper bus-space hooks
    346  1.28  augustss          * appropriately
    347  1.28  augustss          */
    348  1.28  augustss 
    349   1.1    brezak 	sc->sc_sbdsp.sc_iobase = ia->ia_iobase;
    350  1.24  augustss 	sc->sc_sbdsp.sc_iot = ia->ia_iot;
    351  1.28  augustss 
    352  1.28  augustss 	/* Map i/o space [we map 24 ports which is the max of the sb and pro */
    353  1.28  augustss 	if (bus_space_map(sc->sc_sbdsp.sc_iot, ia->ia_iobase, SBP_NPORT, 0,
    354  1.28  augustss 	    &sc->sc_sbdsp.sc_ioh)) {
    355  1.28  augustss 		printf("pas: can't map i/o space 0x%x/%d in probe\n",
    356  1.28  augustss 		    ia->ia_iobase, SBP_NPORT);
    357  1.28  augustss 		return 0;
    358  1.28  augustss 	}
    359  1.28  augustss 
    360   1.1    brezak 	if (sbdsp_reset(&sc->sc_sbdsp) < 0) {
    361   1.1    brezak 		DPRINTF(("pas: couldn't reset card\n"));
    362  1.28  augustss 		goto unmap;
    363   1.1    brezak 	}
    364   1.1    brezak 
    365   1.1    brezak 	/*
    366   1.1    brezak 	 * Cannot auto-discover DMA channel.
    367   1.1    brezak 	 */
    368   1.1    brezak 	if (!SB_DRQ_VALID(ia->ia_drq)) {
    369  1.19  christos 		printf("pas: configured dma chan %d invalid\n", ia->ia_drq);
    370  1.28  augustss 		goto unmap;
    371   1.1    brezak 	}
    372   1.1    brezak #ifdef NEWCONFIG
    373   1.1    brezak 	/*
    374   1.1    brezak 	 * If the IRQ wasn't compiled in, auto-detect it.
    375   1.1    brezak 	 */
    376   1.1    brezak 	if (ia->ia_irq == IRQUNK) {
    377   1.1    brezak 		ia->ia_irq = isa_discoverintr(pasforceintr, aux);
    378   1.1    brezak 		sbdsp_reset(&sc->sc_sbdsp);
    379   1.1    brezak 		if (!SB_IRQ_VALID(ia->ia_irq)) {
    380  1.19  christos 			printf("pas: couldn't auto-detect interrupt");
    381  1.28  augustss 			goto unmap;
    382   1.1    brezak 		}
    383   1.1    brezak 	} else
    384   1.1    brezak #endif
    385   1.1    brezak 	if (!SB_IRQ_VALID(ia->ia_irq)) {
    386  1.19  christos 		printf("pas: configured irq chan %d invalid\n", ia->ia_irq);
    387  1.28  augustss 		goto unmap;
    388   1.1    brezak 	}
    389   1.1    brezak 
    390   1.2    brezak 	sc->sc_sbdsp.sc_irq = ia->ia_irq;
    391  1.23       jtk 	sc->sc_sbdsp.sc_drq8 = ia->ia_drq;
    392  1.23       jtk 	sc->sc_sbdsp.sc_drq16 = -1; /* XXX */
    393   1.1    brezak 
    394   1.1    brezak 	if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
    395   1.1    brezak 		DPRINTF(("pas: sbdsp probe failed\n"));
    396  1.28  augustss 		goto unmap;
    397   1.1    brezak 	}
    398   1.1    brezak 
    399   1.1    brezak 	ia->ia_iosize = SB_NPORT;
    400   1.1    brezak 	return 1;
    401  1.28  augustss 
    402  1.28  augustss  unmap:
    403  1.28  augustss 	bus_space_unmap(sc->sc_sbdsp.sc_iot, sc->sc_sbdsp.sc_ioh, SBP_NPORT);
    404  1.28  augustss 	return 0;
    405   1.1    brezak }
    406   1.1    brezak 
    407   1.1    brezak #ifdef NEWCONFIG
    408   1.1    brezak void
    409   1.1    brezak pasforceintr(aux)
    410   1.1    brezak 	void *aux;
    411   1.1    brezak {
    412   1.1    brezak 	static char dmabuf;
    413   1.1    brezak 	struct isa_attach_args *ia = aux;
    414  1.10   mycroft 	int iobase = ia->ia_iobase;
    415   1.1    brezak 
    416   1.1    brezak 	/*
    417   1.1    brezak 	 * Set up a DMA read of one byte.
    418   1.1    brezak 	 * XXX Note that at this point we haven't called
    419   1.1    brezak 	 * at_setup_dmachan().  This is okay because it just
    420   1.1    brezak 	 * allocates a buffer in case it needs to make a copy,
    421   1.1    brezak 	 * and it won't need to make a copy for a 1 byte buffer.
    422   1.1    brezak 	 * (I think that calling at_setup_dmachan() should be optional;
    423   1.1    brezak 	 * if you don't call it, it will be called the first time
    424   1.1    brezak 	 * it is needed (and you pay the latency).  Also, you might
    425   1.1    brezak 	 * never need the buffer anyway.)
    426   1.1    brezak 	 */
    427  1.13   mycroft 	at_dma(DMAMODE_READ, &dmabuf, 1, ia->ia_drq);
    428   1.1    brezak 	if (pas_wdsp(iobase, SB_DSP_RDMA) == 0) {
    429   1.1    brezak 		(void)pas_wdsp(iobase, 0);
    430   1.1    brezak 		(void)pas_wdsp(iobase, 0);
    431   1.1    brezak 	}
    432   1.1    brezak }
    433   1.1    brezak #endif
    434   1.1    brezak 
    435   1.1    brezak /*
    436   1.1    brezak  * Attach hardware to driver, attach hardware driver to audio
    437   1.1    brezak  * pseudo-device driver .
    438   1.1    brezak  */
    439   1.1    brezak void
    440   1.1    brezak pasattach(parent, self, aux)
    441   1.1    brezak 	struct device *parent, *self;
    442   1.1    brezak 	void *aux;
    443   1.1    brezak {
    444   1.1    brezak 	register struct pas_softc *sc = (struct pas_softc *)self;
    445   1.1    brezak 	struct isa_attach_args *ia = (struct isa_attach_args *)aux;
    446  1.10   mycroft 	register int iobase = ia->ia_iobase;
    447   1.8    brezak 	int err;
    448   1.8    brezak 
    449  1.20     mikel 	sc->sc_sbdsp.sc_iobase = iobase;
    450  1.20     mikel 	sc->sc_sbdsp.sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
    451  1.20     mikel 	    IST_EDGE, IPL_AUDIO, sbdsp_intr, &sc->sc_sbdsp);
    452  1.27   thorpej 
    453  1.27   thorpej 	sc->sc_sbdsp.sc_isa = parent;
    454   1.1    brezak 
    455  1.20     mikel 	printf(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model],
    456  1.20     mikel 	    sc->rev);
    457   1.1    brezak 
    458   1.1    brezak 	sbdsp_attach(&sc->sc_sbdsp);
    459   1.1    brezak 
    460  1.19  christos 	sprintf(pas_device.name, "pas,%s", pasnames[sc->model]);
    461  1.19  christos 	sprintf(pas_device.version, "%d", sc->rev);
    462   1.1    brezak 
    463   1.8    brezak 	if ((err = audio_hardware_attach(&pas_hw_if, &sc->sc_sbdsp)) != 0)
    464  1.19  christos 		printf("pas: could not attach to audio pseudo-device driver (%d)\n", err);
    465   1.1    brezak }
    466   1.1    brezak 
    467   1.1    brezak int
    468   1.1    brezak pasopen(dev, flags)
    469   1.1    brezak     dev_t dev;
    470   1.1    brezak     int flags;
    471   1.1    brezak {
    472   1.1    brezak     struct pas_softc *sc;
    473   1.1    brezak     int unit = AUDIOUNIT(dev);
    474   1.1    brezak 
    475  1.14   thorpej     if (unit >= pas_cd.cd_ndevs)
    476   1.1    brezak 	return ENODEV;
    477   1.1    brezak 
    478  1.14   thorpej     sc = pas_cd.cd_devs[unit];
    479   1.1    brezak     if (!sc)
    480   1.1    brezak 	return ENXIO;
    481   1.1    brezak 
    482   1.1    brezak     return sbdsp_open(&sc->sc_sbdsp, dev, flags);
    483   1.1    brezak }
    484   1.1    brezak 
    485   1.1    brezak int
    486   1.1    brezak pas_getdev(addr, retp)
    487   1.4   mycroft 	void *addr;
    488   1.1    brezak 	struct audio_device *retp;
    489   1.1    brezak {
    490   1.1    brezak 	*retp = pas_device;
    491   1.1    brezak 	return 0;
    492   1.1    brezak }
    493