diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index ac6ae4917ad6..608988488569 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $NetBSD: gus.c,v 1.42 1997/08/26 19:27:21 augustss Exp $ */ +/* $NetBSD: gus.c,v 1.43 1997/09/06 14:23:13 augustss Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -181,7 +181,10 @@ struct gus_softc { struct isadev sc_id; /* ISA device */ void *sc_ih; /* interrupt vector */ bus_space_tag_t sc_iot; /* tag */ - bus_space_handle_t sc_ioh; /* handle */ + bus_space_handle_t sc_ioh1; /* handle */ + bus_space_handle_t sc_ioh2; /* handle */ + bus_space_handle_t sc_ioh3; /* ICS2101 handle */ + bus_space_handle_t sc_ioh4; /* MIDI handle */ int sc_iobase; /* I/O base address */ int sc_irq; /* IRQ used */ @@ -392,8 +395,8 @@ STATIC void gus_deinterleave __P((struct gus_softc *, void *, int)); STATIC int gus_mic_ctl __P((void *, int)); STATIC int gus_linein_ctl __P((void *, int)); -STATIC int gus_test_iobase __P((int)); -STATIC void guspoke __P((int, long, u_char)); +STATIC int gus_test_iobase __P((struct gus_softc *, int)); +STATIC void guspoke __P((bus_space_tag_t, bus_space_handle_t, long, u_char)); STATIC void gusdmaout __P((struct gus_softc *, int, u_long, caddr_t, int)); STATIC void gus_init_cs4231 __P((struct gus_softc *)); STATIC void gus_init_ics2101 __P((struct gus_softc *)); @@ -418,7 +421,7 @@ STATIC int gus_dmain_intr __P((struct gus_softc *)); STATIC int gus_voice_intr __P((struct gus_softc *)); STATIC void gus_start_playing __P((struct gus_softc *, int)); STATIC int gus_continue_playing __P((struct gus_softc *, int)); -STATIC u_char guspeek __P((int, u_long)); +STATIC u_char guspeek __P((bus_space_tag_t, bus_space_handle_t, u_long)); STATIC u_long convert_to_16bit __P((u_long)); STATIC int gus_mixer_set_port __P((void *, mixer_ctrl_t *)); STATIC int gus_mixer_get_port __P((void *, mixer_ctrl_t *)); @@ -571,8 +574,7 @@ static unsigned short gus_log_volumes[512] = { 0x0ff0, 0x0ff1, 0x0ff2, 0x0ff3, 0x0ff4, 0x0ff5, 0x0ff6, 0x0ff7, 0x0ff8, 0x0ff9, 0x0ffa, 0x0ffb, 0x0ffc, 0x0ffd, 0x0ffe, 0x0fff}; -#define SELECT_GUS_REG(port,x) outb(port+GUS_REG_SELECT,x) -#define WHICH_GUS_REG(port) inb(port+GUS_REG_SELECT) +#define SELECT_GUS_REG(iot,ioh1,x) bus_space_write_1(iot,ioh1,GUS_REG_SELECT,x) #define ADDR_HIGH(x) (unsigned int) ((x >> 7L) & 0x1fffL) #define ADDR_LOW(x) (unsigned int) ((x & 0x7fL) << 9L) @@ -637,6 +639,47 @@ struct audio_hw_if gus_hw_if = { gus_get_props, }; +static struct audio_hw_if gusmax_hw_if = { + gusmaxopen, + gusmax_close, + NULL, /* drain */ + + gus_query_encoding, /* query encoding */ + + gusmax_set_params, + + gusmax_round_blocksize, + + gusmax_set_out_port, + gusmax_get_out_port, + gusmax_set_in_port, + gusmax_get_in_port, + + gusmax_commit_settings, + + NULL, + NULL, + + gusmax_dma_output, + gusmax_dma_input, + gusmax_halt_out_dma, + gusmax_halt_in_dma, + gusmax_cont_out_dma, + gusmax_cont_in_dma, + + gusmax_speaker_ctl, + + gus_getdev, + NULL, + gusmax_mixer_set_port, + gusmax_mixer_get_port, + gusmax_mixer_query_devinfo, + NULL, + NULL, + NULL, + NULL, + gusmax_get_props, +}; /* * Some info about the current audio device @@ -667,20 +710,21 @@ gusprobe(parent, match, aux) * valid for this card. */ + /* XXX range check before indexing!! */ if (ia->ia_irq == IRQUNK || gus_irq_map[ia->ia_irq] == IRQUNK) { printf("gus: invalid irq %d, card not probed\n", ia->ia_irq); - return(0); + return 0; } if (ia->ia_drq == DRQUNK || gus_drq_map[ia->ia_drq] == DRQUNK) { printf("gus: invalid drq %d, card not probed\n", ia->ia_drq); - return(0); + return 0; } if (recdrq != DRQUNK) { if (recdrq > 7 || gus_drq_map[recdrq] == DRQUNK) { printf("gus: invalid second DMA channel (%d), card not probed\n", recdrq); - return(0); + return 0; } } else recdrq = ia->ia_drq; @@ -688,12 +732,12 @@ gusprobe(parent, match, aux) if (iobase == IOBASEUNK) { int i; for(i = 0; i < gus_addrs; i++) - if (gus_test_iobase(gus_base_addrs[i])) { + if (gus_test_iobase(sc, gus_base_addrs[i])) { iobase = gus_base_addrs[i]; goto done; } return 0; - } else if (! gus_test_iobase(iobase)) + } else if (!gus_test_iobase(sc, iobase)) return 0; done: @@ -702,9 +746,9 @@ done: sc->sc_drq = ia->ia_drq; sc->sc_recdrq = recdrq; - ia->ia_iobase = sc->sc_iobase; - ia->ia_iosize = 16; /* XXX */ - return(1); + ia->ia_iobase = iobase; + ia->ia_iosize = GUS_NPORT1; + return 1; } /* @@ -713,47 +757,79 @@ done: */ STATIC int -gus_test_iobase (int iobase) +gus_test_iobase (sc, iobase) + struct gus_softc *sc; + int iobase; { - int i = splgus(); + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1, ioh2, ioh3, ioh4; u_char s1, s2; + int s; + + /* Map i/o space */ + if (bus_space_map(iot, iobase, GUS_NPORT1, 0, &ioh1)) + return 0; + sc->sc_ioh1 = ioh1; + if (bus_space_map(iot, iobase+GUS_IOH2_OFFSET, GUS_NPORT2, 0, &ioh2)) + goto bad1; + sc->sc_ioh2 = ioh2; + + /* XXX Maybe we shouldn't fail on mapping this, but just assume + * the card is of revision 0? */ + if (bus_space_map(iot, iobase+GUS_IOH3_OFFSET, GUS_NPORT3, 0, &ioh3)) + goto bad2; + sc->sc_ioh3 = ioh3; + + if (bus_space_map(iot, iobase+GUS_IOH4_OFFSET, GUS_NPORT4, 0, &ioh4)) + goto bad3; + sc->sc_ioh4 = ioh4; /* * Reset GUS to an initial state before we do anything. */ + s = splgus(); delay(500); - SELECT_GUS_REG(iobase, GUSREG_RESET); - outb(iobase+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); delay(500); - SELECT_GUS_REG(iobase, GUSREG_RESET); - outb(iobase+GUS_DATA_HIGH, GUSMASK_MASTER_RESET); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, GUSMASK_MASTER_RESET); delay(500); - splx(i); + splx(s); /* * See if we can write to the board's memory */ - s1 = guspeek(iobase, 0L); - s2 = guspeek(iobase, 1L); + s1 = guspeek(iot, ioh2, 0L); + s2 = guspeek(iot, ioh2, 1L); - guspoke(iobase, 0L, 0xaa); - guspoke(iobase, 1L, 0x55); + guspoke(iot, ioh2, 0L, 0xaa); + guspoke(iot, ioh2, 1L, 0x55); - if ((i=(int)guspeek(iobase, 0L)) != 0xaa) { - return(0); - } + if (guspeek(iot, ioh2, 0L) != 0xaa) + goto bad; - guspoke(iobase, 0L, s1); - guspoke(iobase, 1L, s2); + guspoke(iot, ioh2, 0L, s1); + guspoke(iot, ioh2, 1L, s2); return 1; + +bad: + bus_space_unmap(sc->sc_iot, sc->sc_ioh4, GUS_NPORT4); +bad3: + bus_space_unmap(sc->sc_iot, sc->sc_ioh3, GUS_NPORT3); +bad2: + bus_space_unmap(sc->sc_iot, sc->sc_ioh2, GUS_NPORT2); +bad1: + bus_space_unmap(sc->sc_iot, sc->sc_ioh1, GUS_NPORT1); + return 0; } /* @@ -767,8 +843,11 @@ gusattach(parent, self, aux) { struct gus_softc *sc = (void *) self; struct isa_attach_args *ia = aux; - int port = ia->ia_iobase; - int i; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; + bus_space_handle_t ioh2 = sc->sc_ioh2; + bus_space_handle_t ioh3 = sc->sc_ioh3; + int i; unsigned char c,d,m; /* @@ -778,15 +857,15 @@ gusattach(parent, self, aux) delay(500); - c = inb(port+GUS_BOARD_REV); + c = bus_space_read_1(iot, ioh3, GUS_BOARD_REV); if (c != 0xff) sc->sc_revision = c; else sc->sc_revision = 0; - SELECT_GUS_REG(port, GUSREG_RESET); - outb(port+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); gusreset(sc, GUS_MAX_VOICES); /* initialize all voices */ gusreset(sc, GUS_MIN_VOICES); /* then set to just the ones we use */ @@ -817,31 +896,31 @@ gusattach(parent, self, aux) * The order of these operations is very magical. */ - disable_intr(); + disable_intr(); /* XXX needed? */ - outb(port+GUS_REG_CONTROL, GUS_REG_IRQCTL); - outb(port+GUS_MIX_CONTROL, m); - outb(port+GUS_IRQCTL_CONTROL, 0x00); - outb(port+0x0f, 0x00); + bus_space_write_1(iot, ioh1, GUS_REG_CONTROL, GUS_REG_IRQCTL); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, m); + bus_space_write_1(iot, ioh1, GUS_IRQCTL_CONTROL, 0x00); + bus_space_write_1(iot, ioh1, 0x0f, 0x00); - outb(port+GUS_MIX_CONTROL, m); - outb(port+GUS_DMA_CONTROL, d | 0x80); /* magic reset? */ + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, m); + bus_space_write_1(iot, ioh1, GUS_DMA_CONTROL, d | 0x80); /* magic reset? */ - outb(port+GUS_MIX_CONTROL, m | GUSMASK_CONTROL_SEL); - outb(port+GUS_IRQ_CONTROL, c); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, m | GUSMASK_CONTROL_SEL); + bus_space_write_1(iot, ioh1, GUS_IRQ_CONTROL, c); - outb(port+GUS_MIX_CONTROL, m); - outb(port+GUS_DMA_CONTROL, d); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, m); + bus_space_write_1(iot, ioh1, GUS_DMA_CONTROL, d); - outb(port+GUS_MIX_CONTROL, m | GUSMASK_CONTROL_SEL); - outb(port+GUS_IRQ_CONTROL, c); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, m | GUSMASK_CONTROL_SEL); + bus_space_write_1(iot, ioh1, GUS_IRQ_CONTROL, c); - outb(port+GUS_VOICE_SELECT, 0x00); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, 0x00); /* enable line in, line out. leave mic disabled. */ - outb(port+GUS_MIX_CONTROL, + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, (m | GUSMASK_LATCHES) & ~(GUSMASK_LINE_OUT|GUSMASK_LINE_IN)); - outb(port+GUS_VOICE_SELECT, 0x00); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, 0x00); enable_intr(); @@ -859,14 +938,14 @@ gusattach(parent, self, aux) gus_init_cs4231(sc); } - SELECT_GUS_REG(port, GUSREG_RESET); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); /* * Check to see how much memory we have on this card; see if any * "mirroring" occurs. We're assuming at least 256K already exists * on the card; otherwise the initial probe would have failed */ - guspoke(port, 0L, 0x00); + guspoke(iot, ioh2, 0L, 0x00); for(i = 1; i < 1024; i++) { u_long loc; @@ -874,13 +953,13 @@ gusattach(parent, self, aux) * See if we've run into mirroring yet */ - if (guspeek(port, 0L) != 0) + if (guspeek(iot, ioh2, 0L) != 0) break; loc = i << 10; - guspoke(port, loc, 0xaa); - if (guspeek(port, loc) != 0xaa) + guspoke(iot, ioh2, loc, 0xaa); + if (guspeek(iot, ioh2, loc) != 0xaa) break; } @@ -913,6 +992,7 @@ gusattach(parent, self, aux) /* * Set some default values + * XXX others start with 8kHz mono mulaw */ sc->sc_irate = sc->sc_orate = 44100; @@ -929,13 +1009,13 @@ gusattach(parent, self, aux) * full right. * For mono playback, we set up both voices playing the same buffer. */ - outb(sc->sc_iobase+GUS_VOICE_SELECT, (unsigned char) GUS_VOICE_LEFT); - SELECT_GUS_REG(sc->sc_iobase, GUSREG_PAN_POS); - outb(sc->sc_iobase+GUS_DATA_HIGH, GUS_PAN_FULL_LEFT); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) GUS_VOICE_LEFT); + SELECT_GUS_REG(iot, ioh2, GUSREG_PAN_POS); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, GUS_PAN_FULL_LEFT); - outb(sc->sc_iobase+GUS_VOICE_SELECT, (unsigned char) GUS_VOICE_RIGHT); - SELECT_GUS_REG(sc->sc_iobase, GUSREG_PAN_POS); - outb(sc->sc_iobase+GUS_DATA_HIGH, GUS_PAN_FULL_RIGHT); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) GUS_VOICE_RIGHT); + SELECT_GUS_REG(iot, ioh2, GUSREG_PAN_POS); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, GUS_PAN_FULL_RIGHT); /* * Attach to the generic audio layer @@ -1255,8 +1335,11 @@ gusintr(arg) void *arg; { struct gus_softc *sc = arg; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; + bus_space_handle_t ioh2 = sc->sc_ioh2; unsigned char intr; - int port = sc->sc_iobase; + int retval = 0; DPRINTF(("gusintr\n")); @@ -1265,15 +1348,15 @@ gusintr(arg) #endif if (HAS_CODEC(sc)) retval = ad1848_intr(&sc->sc_codec); - if ((intr = inb(port+GUS_IRQ_STATUS)) & GUSMASK_IRQ_DMATC) { + if ((intr = bus_space_read_1(iot, ioh1, GUS_IRQ_STATUS)) & GUSMASK_IRQ_DMATC) { DMAPRINTF(("gusintr dma flags=%x\n", sc->sc_flags)); #ifdef DIAGNOSTIC gusdmaintrcnt++; #endif retval += gus_dmaout_intr(sc); if (sc->sc_flags & GUS_DMAIN_ACTIVE) { - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - intr = inb(port+GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + intr = bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); if (intr & GUSMASK_SAMPLE_DMATC) { retval += gus_dmain_intr(sc); } @@ -1313,28 +1396,29 @@ int playcntr; STATIC void gus_dmaout_timeout(arg) - void *arg; + void *arg; { - struct gus_softc *sc = arg; - int port = sc->sc_iobase; - int s; + struct gus_softc *sc = arg; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; + int s; - printf("%s: dmaout timeout\n", sc->sc_dev.dv_xname); - /* - * Stop any DMA. - */ - - s = splgus(); - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - outb(sc->sc_iobase+GUS_DATA_HIGH, 0); + printf("%s: dmaout timeout\n", sc->sc_dev.dv_xname); + /* + * Stop any DMA. + */ + s = splgus(); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0); + #if 0 - /* XXX we will dmadone below? */ - isa_dmaabort(sc->sc_dev.dv_parent, sc->sc_drq); + /* XXX we will dmadone below? */ + isa_dmaabort(sc->sc_dev.dv_parent, sc->sc_drq); #endif - - gus_dmaout_dointr(sc); - splx(s); + + gus_dmaout_dointr(sc); + splx(s); } @@ -1347,15 +1431,16 @@ STATIC int gus_dmaout_intr(sc) struct gus_softc *sc; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; /* * If we got a DMA transfer complete from the GUS DRAM, then deal * with it. */ - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - if (inb(port+GUS_DATA_HIGH) & GUSMASK_DMA_IRQPEND) { + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + if (bus_space_read_1(iot, ioh2, GUS_DATA_HIGH) & GUSMASK_DMA_IRQPEND) { untimeout(gus_dmaout_timeout, sc); gus_dmaout_dointr(sc); return 1; @@ -1367,7 +1452,8 @@ STATIC void gus_dmaout_dointr(sc) struct gus_softc *sc; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; /* sc->sc_dmaoutcnt - 1 because DMA controller counts from zero?. */ isa_dmadone(sc->sc_dev.dv_parent, sc->sc_drq); @@ -1391,23 +1477,23 @@ gus_dmaout_dointr(sc) goto byte; /* we have the native format */ for (i = 1; i <= 2; i++) - guspoke(port, sc->sc_gusaddr - + guspoke(iot, ioh2, sc->sc_gusaddr - (sc->sc_nbufs - 1) * sc->sc_chanblocksize - i, sc->sc_dmaoutaddr[sc->sc_dmaoutcnt-i]); break; case AUDIO_ENCODING_ULINEAR_LE: case AUDIO_ENCODING_ULINEAR_BE: - guspoke(port, sc->sc_gusaddr - + guspoke(iot, ioh2, sc->sc_gusaddr - (sc->sc_nbufs - 1) * sc->sc_chanblocksize - 2, - guspeek(port, + guspeek(iot, ioh2, sc->sc_gusaddr + sc->sc_chanblocksize - 2)); case AUDIO_ENCODING_ALAW: case AUDIO_ENCODING_ULAW: byte: /* we need to fetch the translated byte, then stuff it. */ - guspoke(port, sc->sc_gusaddr - + guspoke(iot, ioh2, sc->sc_gusaddr - (sc->sc_nbufs - 1) * sc->sc_chanblocksize - 1, - guspeek(port, + guspeek(iot, ioh2, sc->sc_gusaddr + sc->sc_chanblocksize - 1)); break; } @@ -1483,11 +1569,11 @@ gus_dmaout_dointr(sc) playcntr = ++playcntr % NDMARECS; } #endif - outb(port+GUS_VOICE_SELECT, GUS_VOICE_LEFT); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].volcntl); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, GUS_VOICE_LEFT); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].volcntl); } } gus_bufcnt[sc->sc_bufcnt-1]++; @@ -1520,7 +1606,8 @@ STATIC int gus_voice_intr(sc) struct gus_softc *sc; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; int ignore = 0, voice, rval = 0; unsigned char intr, status; @@ -1531,8 +1618,8 @@ gus_voice_intr(sc) */ while(1) { - SELECT_GUS_REG(port, GUSREG_IRQ_STATUS); - intr = inb(port+GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_IRQ_STATUS); + intr = bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); if ((intr & (GUSMASK_WIRQ_VOLUME | GUSMASK_WIRQ_VOICE)) == (GUSMASK_WIRQ_VOLUME | GUSMASK_WIRQ_VOICE)) @@ -1561,8 +1648,8 @@ gus_voice_intr(sc) * (this stops it from continuously generating IRQs) */ - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL+0x80); - status = inb(port+GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL+0x80); + status = bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); if (status & GUSMASK_VOICE_STOPPED) { if (voice != GUS_VOICE_LEFT) { DMAPRINTF(("%s: spurious voice %d stop?\n", @@ -1666,177 +1753,179 @@ gus_voice_intr(sc) STATIC void gus_start_playing(sc, bufno) -struct gus_softc *sc; -int bufno; + struct gus_softc *sc; + int bufno; { - int port = sc->sc_iobase; - /* - * Start the voices playing, with buffer BUFNO. - */ + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; + /* + * Start the voices playing, with buffer BUFNO. + */ - /* - * Loop or roll if we have buffers ready. - */ + /* + * Loop or roll if we have buffers ready. + */ - if (sc->sc_bufcnt == 1) { - sc->sc_voc[GUS_VOICE_LEFT].voccntl &= ~(GUSMASK_LOOP_ENABLE); - sc->sc_voc[GUS_VOICE_LEFT].volcntl &= ~(GUSMASK_VOICE_ROLL); - } else { - if (bufno == sc->sc_nbufs - 1) { - sc->sc_voc[GUS_VOICE_LEFT].voccntl |= GUSMASK_LOOP_ENABLE; - sc->sc_voc[GUS_VOICE_LEFT].volcntl &= ~(GUSMASK_VOICE_ROLL); + if (sc->sc_bufcnt == 1) { + sc->sc_voc[GUS_VOICE_LEFT].voccntl &= ~(GUSMASK_LOOP_ENABLE); + sc->sc_voc[GUS_VOICE_LEFT].volcntl &= ~(GUSMASK_VOICE_ROLL); } else { - sc->sc_voc[GUS_VOICE_LEFT].voccntl &= ~GUSMASK_LOOP_ENABLE; - sc->sc_voc[GUS_VOICE_LEFT].volcntl |= GUSMASK_VOICE_ROLL; + if (bufno == sc->sc_nbufs - 1) { + sc->sc_voc[GUS_VOICE_LEFT].voccntl |= GUSMASK_LOOP_ENABLE; + sc->sc_voc[GUS_VOICE_LEFT].volcntl &= ~(GUSMASK_VOICE_ROLL); + } else { + sc->sc_voc[GUS_VOICE_LEFT].voccntl &= ~GUSMASK_LOOP_ENABLE; + sc->sc_voc[GUS_VOICE_LEFT].volcntl |= GUSMASK_VOICE_ROLL; + } } - } - outb(port+GUS_VOICE_SELECT, GUS_VOICE_LEFT); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, GUS_VOICE_LEFT); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].volcntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_LEFT].volcntl); - sc->sc_voc[GUS_VOICE_LEFT].current_addr = - GUS_MEM_OFFSET + sc->sc_chanblocksize * bufno; - sc->sc_voc[GUS_VOICE_LEFT].end_addr = - sc->sc_voc[GUS_VOICE_LEFT].current_addr + sc->sc_chanblocksize - 1; - sc->sc_voc[GUS_VOICE_RIGHT].current_addr = - sc->sc_voc[GUS_VOICE_LEFT].current_addr + - (gus_dostereo && sc->sc_channels == 2 ? GUS_LEFT_RIGHT_OFFSET : 0); - /* - * set up right channel to just loop forever, no interrupts, - * starting at the buffer we just filled. We'll feed it data - * at the same time as left channel. - */ - sc->sc_voc[GUS_VOICE_RIGHT].voccntl |= GUSMASK_LOOP_ENABLE; - sc->sc_voc[GUS_VOICE_RIGHT].volcntl &= ~(GUSMASK_VOICE_ROLL); + sc->sc_voc[GUS_VOICE_LEFT].current_addr = + GUS_MEM_OFFSET + sc->sc_chanblocksize * bufno; + sc->sc_voc[GUS_VOICE_LEFT].end_addr = + sc->sc_voc[GUS_VOICE_LEFT].current_addr + sc->sc_chanblocksize - 1; + sc->sc_voc[GUS_VOICE_RIGHT].current_addr = + sc->sc_voc[GUS_VOICE_LEFT].current_addr + + (gus_dostereo && sc->sc_channels == 2 ? GUS_LEFT_RIGHT_OFFSET : 0); + /* + * set up right channel to just loop forever, no interrupts, + * starting at the buffer we just filled. We'll feed it data + * at the same time as left channel. + */ + sc->sc_voc[GUS_VOICE_RIGHT].voccntl |= GUSMASK_LOOP_ENABLE; + sc->sc_voc[GUS_VOICE_RIGHT].volcntl &= ~(GUSMASK_VOICE_ROLL); #ifdef GUSPLAYDEBUG - if (gusstats) { - microtime(&playstats[playcntr].tv); - playstats[playcntr].curaddr = sc->sc_voc[GUS_VOICE_LEFT].current_addr; + if (gusstats) { + microtime(&playstats[playcntr].tv); + playstats[playcntr].curaddr = sc->sc_voc[GUS_VOICE_LEFT].current_addr; - playstats[playcntr].voccntl = sc->sc_voc[GUS_VOICE_LEFT].voccntl; - playstats[playcntr].volcntl = sc->sc_voc[GUS_VOICE_LEFT].volcntl; - playstats[playcntr].endaddr = sc->sc_voc[GUS_VOICE_LEFT].end_addr; - playstats[playcntr].playbuf = bufno; - playstats[playcntr].dmabuf = sc->sc_dmabuf; - playstats[playcntr].bufcnt = sc->sc_bufcnt; - playstats[playcntr].vaction = 5; - playcntr = ++playcntr % NDMARECS; - } + playstats[playcntr].voccntl = sc->sc_voc[GUS_VOICE_LEFT].voccntl; + playstats[playcntr].volcntl = sc->sc_voc[GUS_VOICE_LEFT].volcntl; + playstats[playcntr].endaddr = sc->sc_voc[GUS_VOICE_LEFT].end_addr; + playstats[playcntr].playbuf = bufno; + playstats[playcntr].dmabuf = sc->sc_dmabuf; + playstats[playcntr].bufcnt = sc->sc_bufcnt; + playstats[playcntr].vaction = 5; + playcntr = ++playcntr % NDMARECS; + } #endif - outb(port+GUS_VOICE_SELECT, GUS_VOICE_RIGHT); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_RIGHT].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_RIGHT].volcntl); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, GUS_VOICE_RIGHT); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_RIGHT].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[GUS_VOICE_RIGHT].volcntl); - gus_start_voice(sc, GUS_VOICE_RIGHT, 0); - gus_start_voice(sc, GUS_VOICE_LEFT, 1); - if (sc->sc_playbuf == -1) - /* mark start of playing */ - sc->sc_playbuf = bufno; + gus_start_voice(sc, GUS_VOICE_RIGHT, 0); + gus_start_voice(sc, GUS_VOICE_LEFT, 1); + if (sc->sc_playbuf == -1) + /* mark start of playing */ + sc->sc_playbuf = bufno; } STATIC int gus_continue_playing(sc, voice) -struct gus_softc *sc; -int voice; + struct gus_softc *sc; + int voice; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; - /* - * stop this voice from interrupting while we work. - */ + /* + * stop this voice from interrupting while we work. + */ - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl & ~(GUSMASK_VOICE_IRQ)); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl & ~(GUSMASK_VOICE_IRQ)); - /* - * update playbuf to point to the buffer the hardware just started - * playing - */ - sc->sc_playbuf = ++sc->sc_playbuf % sc->sc_nbufs; + /* + * update playbuf to point to the buffer the hardware just started + * playing + */ + sc->sc_playbuf = ++sc->sc_playbuf % sc->sc_nbufs; - /* - * account for buffer just finished - */ - if (--sc->sc_bufcnt == 0) { - DPRINTF(("gus: bufcnt 0 on continuing voice?\n")); - } - if (sc->sc_playbuf == sc->sc_dmabuf && (sc->sc_flags & GUS_LOCKED)) { - printf("%s: continue into active dmabuf?\n", sc->sc_dev.dv_xname); - return 1; - } - - /* - * Select the end of the buffer based on the currently active - * buffer, [plus extra contiguous buffers (if ready)]. - */ - - /* - * set endpoint at end of buffer we just started playing. - * - * The total gets -1 because end addrs are one less than you might - * think (the end_addr is the address of the last sample to play) - */ - gus_set_endaddr(sc, voice, GUS_MEM_OFFSET + - sc->sc_chanblocksize * (sc->sc_playbuf + 1) - 1); - - if (sc->sc_bufcnt < 2) { /* - * Clear out the loop and roll flags, and rotate the currently - * playing buffer. That way, if we don't manage to get more - * data before this buffer finishes, we'll just stop. + * account for buffer just finished */ - sc->sc_voc[voice].voccntl &= ~GUSMASK_LOOP_ENABLE; - sc->sc_voc[voice].volcntl &= ~GUSMASK_VOICE_ROLL; - playstats[playcntr].vaction = 0; - } else { - /* - * We have some buffers to play. set LOOP if we're on the - * last buffer in the ring, otherwise set ROLL. - */ - if (sc->sc_playbuf == sc->sc_nbufs - 1) { - sc->sc_voc[voice].voccntl |= GUSMASK_LOOP_ENABLE; - sc->sc_voc[voice].volcntl &= ~GUSMASK_VOICE_ROLL; - playstats[playcntr].vaction = 1; - } else { - sc->sc_voc[voice].voccntl &= ~GUSMASK_LOOP_ENABLE; - sc->sc_voc[voice].volcntl |= GUSMASK_VOICE_ROLL; - playstats[playcntr].vaction = 2; + if (--sc->sc_bufcnt == 0) { + DPRINTF(("gus: bufcnt 0 on continuing voice?\n")); + } + if (sc->sc_playbuf == sc->sc_dmabuf && (sc->sc_flags & GUS_LOCKED)) { + printf("%s: continue into active dmabuf?\n", sc->sc_dev.dv_xname); + return 1; } - } -#ifdef GUSPLAYDEBUG - if (gusstats) { - microtime(&playstats[playcntr].tv); - playstats[playcntr].curaddr = gus_get_curaddr(sc, voice); - playstats[playcntr].voccntl = sc->sc_voc[voice].voccntl; - playstats[playcntr].volcntl = sc->sc_voc[voice].volcntl; - playstats[playcntr].endaddr = sc->sc_voc[voice].end_addr; - playstats[playcntr].playbuf = sc->sc_playbuf; - playstats[playcntr].dmabuf = sc->sc_dmabuf; - playstats[playcntr].bufcnt = sc->sc_bufcnt; - playcntr = ++playcntr % NDMARECS; - } + /* + * Select the end of the buffer based on the currently active + * buffer, [plus extra contiguous buffers (if ready)]. + */ + + /* + * set endpoint at end of buffer we just started playing. + * + * The total gets -1 because end addrs are one less than you might + * think (the end_addr is the address of the last sample to play) + */ + gus_set_endaddr(sc, voice, GUS_MEM_OFFSET + + sc->sc_chanblocksize * (sc->sc_playbuf + 1) - 1); + + if (sc->sc_bufcnt < 2) { + /* + * Clear out the loop and roll flags, and rotate the currently + * playing buffer. That way, if we don't manage to get more + * data before this buffer finishes, we'll just stop. + */ + sc->sc_voc[voice].voccntl &= ~GUSMASK_LOOP_ENABLE; + sc->sc_voc[voice].volcntl &= ~GUSMASK_VOICE_ROLL; + playstats[playcntr].vaction = 0; + } else { + /* + * We have some buffers to play. set LOOP if we're on the + * last buffer in the ring, otherwise set ROLL. + */ + if (sc->sc_playbuf == sc->sc_nbufs - 1) { + sc->sc_voc[voice].voccntl |= GUSMASK_LOOP_ENABLE; + sc->sc_voc[voice].volcntl &= ~GUSMASK_VOICE_ROLL; + playstats[playcntr].vaction = 1; + } else { + sc->sc_voc[voice].voccntl &= ~GUSMASK_LOOP_ENABLE; + sc->sc_voc[voice].volcntl |= GUSMASK_VOICE_ROLL; + playstats[playcntr].vaction = 2; + } + } +#ifdef GUSPLAYDEBUG + if (gusstats) { + microtime(&playstats[playcntr].tv); + playstats[playcntr].curaddr = gus_get_curaddr(sc, voice); + + playstats[playcntr].voccntl = sc->sc_voc[voice].voccntl; + playstats[playcntr].volcntl = sc->sc_voc[voice].volcntl; + playstats[playcntr].endaddr = sc->sc_voc[voice].end_addr; + playstats[playcntr].playbuf = sc->sc_playbuf; + playstats[playcntr].dmabuf = sc->sc_dmabuf; + playstats[playcntr].bufcnt = sc->sc_bufcnt; + playcntr = ++playcntr % NDMARECS; + } #endif - /* - * (re-)set voice parameters. This will reenable interrupts from this - * voice. - */ + /* + * (re-)set voice parameters. This will reenable interrupts from this + * voice. + */ - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].volcntl); - return 0; + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].volcntl); + return 0; } /* @@ -1851,7 +1940,8 @@ gusdmaout(sc, flags, gusaddr, buffaddr, length) caddr_t buffaddr; { unsigned char c = (unsigned char) flags; - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; DMAPRINTF(("gusdmaout flags=%x scflags=%x\n", flags, sc->sc_flags)); @@ -1877,8 +1967,8 @@ gusdmaout(sc, flags, gusaddr, buffaddr, length) * Make sure the GUS _isn't_ setup for DMA */ - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - outb(port+GUS_DATA_HIGH, 0); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0); /* * Tell the PC DMA controller to start doing DMA @@ -1895,15 +1985,15 @@ gusdmaout(sc, flags, gusaddr, buffaddr, length) sc->sc_flags |= GUS_DMAOUT_ACTIVE; - SELECT_GUS_REG(port, GUSREG_DMA_START); - outw(port+GUS_DATA_LOW, (int) (gusaddr >> 4)); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_START); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, (int) (gusaddr >> 4)); /* * Tell the GUS to start doing DMA */ - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - outb(port+GUS_DATA_HIGH, c); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, c); /* * XXX If we don't finish in one second, give up... @@ -1923,7 +2013,8 @@ gus_start_voice(sc, voice, intrs) int voice; int intrs; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; u_long start; u_long current; u_long end; @@ -1953,22 +2044,22 @@ gus_start_voice(sc, voice, intrs) * Select the voice we want to use, and program the data addresses */ - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_START_ADDR_HIGH); - outw(port+GUS_DATA_LOW, ADDR_HIGH(start)); - SELECT_GUS_REG(port, GUSREG_START_ADDR_LOW); - outw(port+GUS_DATA_LOW, ADDR_LOW(start)); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_HIGH(start)); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_LOW(start)); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_HIGH); - outw(port+GUS_DATA_LOW, ADDR_HIGH(current)); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_LOW); - outw(port+GUS_DATA_LOW, ADDR_LOW(current)); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_HIGH(current)); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_LOW(current)); - SELECT_GUS_REG(port, GUSREG_END_ADDR_HIGH); - outw(port+GUS_DATA_LOW, ADDR_HIGH(end)); - SELECT_GUS_REG(port, GUSREG_END_ADDR_LOW); - outw(port+GUS_DATA_LOW, ADDR_LOW(end)); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_HIGH(end)); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_LOW(end)); /* * (maybe) enable interrupts, disable voice stopping @@ -1988,24 +2079,24 @@ gus_start_voice(sc, voice, intrs) * from 0 up to the set volume to help reduce clicks. */ - SELECT_GUS_REG(port, GUSREG_START_VOLUME); - outb(port+GUS_DATA_HIGH, 0x00); - SELECT_GUS_REG(port, GUSREG_END_VOLUME); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].current_volume >> 4); - SELECT_GUS_REG(port, GUSREG_CUR_VOLUME); - outw(port+GUS_DATA_LOW, 0x00); - SELECT_GUS_REG(port, GUSREG_VOLUME_RATE); - outb(port+GUS_DATA_HIGH, 63); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].current_volume >> 4); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_VOLUME); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_RATE); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 63); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); delay(50); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); } @@ -2019,7 +2110,8 @@ gus_stop_voice(sc, voice, intrs_too) int voice; int intrs_too; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; sc->sc_voc[voice].voccntl |= GUSMASK_VOICE_STOPPED | GUSMASK_STOP_VOICE; @@ -2030,24 +2122,24 @@ gus_stop_voice(sc, voice, intrs_too) } DMAPRINTF(("gusintr voice notplaying=%x\n", sc->sc_flags)); - guspoke(port, 0L, 0); + guspoke(iot, ioh2, 0L, 0); - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_CUR_VOLUME); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_VOLUME); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); delay(100); - SELECT_GUS_REG(port, GUSREG_CUR_VOLUME); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_VOLUME); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[voice].voccntl); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_HIGH); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_LOW); - outw(port+GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); } @@ -2060,25 +2152,26 @@ gus_set_volume(sc, voice, volume) struct gus_softc *sc; int voice, volume; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; unsigned int gusvol; gusvol = gus_log_volumes[volume < 512 ? volume : 511]; sc->sc_voc[voice].current_volume = gusvol; - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_START_VOLUME); - outb(port+GUS_DATA_HIGH, (unsigned char) (gusvol >> 4)); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, (unsigned char) (gusvol >> 4)); - SELECT_GUS_REG(port, GUSREG_END_VOLUME); - outb(port+GUS_DATA_HIGH, (unsigned char) (gusvol >> 4)); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, (unsigned char) (gusvol >> 4)); - SELECT_GUS_REG(port, GUSREG_CUR_VOLUME); - outw(port+GUS_DATA_LOW, gusvol << 4); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_VOLUME); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, gusvol << 4); delay(500); - outw(port+GUS_DATA_LOW, gusvol << 4); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, gusvol << 4); } @@ -2232,13 +2325,14 @@ STATIC inline void gus_set_voices(sc, voices) struct gus_softc *sc; int voices; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; /* * Select the active number of voices */ - SELECT_GUS_REG(port, GUSREG_ACTIVE_VOICES); - outb(port+GUS_DATA_HIGH, (voices-1) | 0xc0); + SELECT_GUS_REG(iot, ioh2, GUSREG_ACTIVE_VOICES); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, (voices-1) | 0xc0); sc->sc_voices = voices; } @@ -2330,7 +2424,8 @@ gus_set_samprate(sc, voice, freq) struct gus_softc *sc; int voice, freq; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; unsigned int fc; u_long temp, f = (u_long) freq; @@ -2350,9 +2445,9 @@ gus_set_samprate(sc, voice, freq) * Program the voice frequency, and set it in the voice data record */ - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_FREQ_CONTROL); - outw(port+GUS_DATA_LOW, fc); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); + SELECT_GUS_REG(iot, ioh2, GUSREG_FREQ_CONTROL); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, fc); sc->sc_voc[voice].rate = freq; @@ -2368,7 +2463,8 @@ gus_set_recrate(sc, rate) struct gus_softc *sc; u_long rate; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; u_char realrate; DPRINTF(("gus_set_recrate %lu\n", rate)); @@ -2377,8 +2473,8 @@ gus_set_recrate(sc, rate) #endif realrate = (9878400 >> 4)/rate - 2; /* formula from code, sigh. */ - SELECT_GUS_REG(port, GUSREG_SAMPLE_FREQ); - outb(port+GUS_DATA_HIGH, realrate); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_FREQ); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, realrate); } /* @@ -2401,17 +2497,19 @@ gus_speaker_ctl(addr, newstate) int newstate; { struct gus_softc *sc = (struct gus_softc *) addr; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; /* Line out bit is flipped: 0 enables, 1 disables */ if ((newstate == SPKR_ON) && (sc->sc_mixcontrol & GUSMASK_LINE_OUT)) { sc->sc_mixcontrol &= ~GUSMASK_LINE_OUT; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } if ((newstate == SPKR_OFF) && (sc->sc_mixcontrol & GUSMASK_LINE_OUT) == 0) { sc->sc_mixcontrol |= GUSMASK_LINE_OUT; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } return 0; @@ -2423,17 +2521,19 @@ gus_linein_ctl(addr, newstate) int newstate; { struct gus_softc *sc = (struct gus_softc *) addr; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; /* Line in bit is flipped: 0 enables, 1 disables */ if ((newstate == SPKR_ON) && (sc->sc_mixcontrol & GUSMASK_LINE_IN)) { sc->sc_mixcontrol &= ~GUSMASK_LINE_IN; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } if ((newstate == SPKR_OFF) && (sc->sc_mixcontrol & GUSMASK_LINE_IN) == 0) { sc->sc_mixcontrol |= GUSMASK_LINE_IN; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } return 0; @@ -2445,17 +2545,19 @@ gus_mic_ctl(addr, newstate) int newstate; { struct gus_softc *sc = (struct gus_softc *) addr; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; /* Mic bit is normal: 1 enables, 0 disables */ if ((newstate == SPKR_ON) && (sc->sc_mixcontrol & GUSMASK_MIC_IN) == 0) { sc->sc_mixcontrol |= GUSMASK_MIC_IN; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } if ((newstate == SPKR_OFF) && (sc->sc_mixcontrol & GUSMASK_MIC_IN)) { sc->sc_mixcontrol &= ~GUSMASK_MIC_IN; - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); } return 0; @@ -2471,17 +2573,18 @@ gus_set_endaddr(sc, voice, addr) int voice; u_long addr; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; sc->sc_voc[voice].end_addr = addr; if (sc->sc_voc[voice].voccntl & GUSMASK_DATA_SIZE16) addr = convert_to_16bit(addr); - SELECT_GUS_REG(port, GUSREG_END_ADDR_HIGH); - outw(port+GUS_DATA_LOW, ADDR_HIGH(addr)); - SELECT_GUS_REG(port, GUSREG_END_ADDR_LOW); - outw(port+GUS_DATA_LOW, ADDR_LOW(addr)); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_HIGH(addr)); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_LOW(addr)); } @@ -2495,19 +2598,20 @@ gus_set_curaddr(sc, voice, addr) int voice; u_long addr; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; sc->sc_voc[voice].current_addr = addr; if (sc->sc_voc[voice].voccntl & GUSMASK_DATA_SIZE16) addr = convert_to_16bit(addr); - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_HIGH); - outw(port+GUS_DATA_LOW, ADDR_HIGH(addr)); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_LOW); - outw(port+GUS_DATA_LOW, ADDR_LOW(addr)); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_HIGH(addr)); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, ADDR_LOW(addr)); } @@ -2519,14 +2623,15 @@ gus_get_curaddr(sc, voice) struct gus_softc *sc; int voice; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; u_long addr; - outb(port+GUS_VOICE_SELECT, (unsigned char) voice); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_HIGH|GUSREG_READ); - addr = (inw(port+GUS_DATA_LOW) & 0x1fff) << 7; - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_LOW|GUSREG_READ); - addr |= (inw(port+GUS_DATA_LOW) >> 9L) & 0x7f; + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) voice); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_HIGH|GUSREG_READ); + addr = (bus_space_read_2(iot, ioh2, GUS_DATA_LOW) & 0x1fff) << 7; + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_LOW|GUSREG_READ); + addr |= (bus_space_read_2(iot, ioh2, GUS_DATA_LOW) >> 9L) & 0x7f; if (sc->sc_voc[voice].voccntl & GUSMASK_DATA_SIZE16) addr = (addr & 0xc0000) | ((addr & 0x1ffff) << 1); /* undo 16-bit change */ @@ -2562,8 +2667,9 @@ convert_to_16bit(address) */ STATIC void -guspoke(port, address, value) - int port; +guspoke(iot, ioh2, address, value) + bus_space_tag_t iot; + bus_space_handle_t ioh2; long address; unsigned char value; { @@ -2572,16 +2678,16 @@ guspoke(port, address, value) * Select the DRAM address */ - SELECT_GUS_REG(port, GUSREG_DRAM_ADDR_LOW); - outw(port+GUS_DATA_LOW, (unsigned int) (address & 0xffff)); - SELECT_GUS_REG(port, GUSREG_DRAM_ADDR_HIGH); - outb(port+GUS_DATA_HIGH, (unsigned char) ((address >> 16) & 0xff)); + SELECT_GUS_REG(iot, ioh2, GUSREG_DRAM_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, (unsigned int) (address & 0xffff)); + SELECT_GUS_REG(iot, ioh2, GUSREG_DRAM_ADDR_HIGH); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, (unsigned char) ((address >> 16) & 0xff)); /* * Actually write the data */ - outb(port+GUS_DRAM_DATA, value); + bus_space_write_1(iot, ioh2, GUS_DRAM_DATA, value); } /* @@ -2589,8 +2695,9 @@ guspoke(port, address, value) */ STATIC unsigned char -guspeek(port, address) - int port; +guspeek(iot, ioh2, address) + bus_space_tag_t iot; + bus_space_handle_t ioh2; u_long address; { @@ -2598,16 +2705,16 @@ guspeek(port, address) * Select the DRAM address */ - SELECT_GUS_REG(port, GUSREG_DRAM_ADDR_LOW); - outw(port+GUS_DATA_LOW, (unsigned int) (address & 0xffff)); - SELECT_GUS_REG(port, GUSREG_DRAM_ADDR_HIGH); - outb(port+GUS_DATA_HIGH, (unsigned char) ((address >> 16) & 0xff)); + SELECT_GUS_REG(iot, ioh2, GUSREG_DRAM_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, (unsigned int) (address & 0xffff)); + SELECT_GUS_REG(iot, ioh2, GUSREG_DRAM_ADDR_HIGH); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, (unsigned char) ((address >> 16) & 0xff)); /* * Read in the data from the board */ - return (unsigned char) inb(port+GUS_DRAM_DATA); + return (unsigned char) bus_space_read_1(iot, ioh2, GUS_DRAM_DATA); } /* @@ -2619,7 +2726,10 @@ gusreset(sc, voices) struct gus_softc *sc; int voices; { - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; + bus_space_handle_t ioh2 = sc->sc_ioh2; + bus_space_handle_t ioh4 = sc->sc_ioh4; int i,s; s = splgus(); @@ -2628,8 +2738,8 @@ gusreset(sc, voices) * Reset the GF1 chip */ - SELECT_GUS_REG(port, GUSREG_RESET); - outb(port+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); delay(500); @@ -2637,8 +2747,8 @@ gusreset(sc, voices) * Release reset */ - SELECT_GUS_REG(port, GUSREG_RESET); - outb(port+GUS_DATA_HIGH, GUSMASK_MASTER_RESET); + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, GUSMASK_MASTER_RESET); delay(500); @@ -2646,95 +2756,95 @@ gusreset(sc, voices) * Reset MIDI port as well */ - outb(GUS_MIDI_CONTROL,MIDI_RESET); + bus_space_write_1(iot, ioh4, GUS_MIDI_CONTROL, MIDI_RESET); delay(500); - outb(GUS_MIDI_CONTROL,0x00); + bus_space_write_1(iot, ioh4, GUS_MIDI_CONTROL, 0x00); /* * Clear interrupts */ - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - outb(port+GUS_DATA_HIGH, 0x00); - SELECT_GUS_REG(port, GUSREG_TIMER_CONTROL); - outb(port+GUS_DATA_HIGH, 0x00); - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - outb(port+GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_TIMER_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x00); gus_set_voices(sc, voices); - inb(port+GUS_IRQ_STATUS); - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - inb(port+GUS_DATA_HIGH); - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - inb(port+GUS_DATA_HIGH); - SELECT_GUS_REG(port, GUSREG_IRQ_STATUS); - inb(port+GUS_DATA_HIGH); + bus_space_read_1(iot, ioh1, GUS_IRQ_STATUS); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_IRQ_STATUS); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); /* * Reset voice specific information */ for(i = 0; i < voices; i++) { - outb(port+GUS_VOICE_SELECT, (unsigned char) i); + bus_space_write_1(iot, ioh2, GUS_VOICE_SELECT, (unsigned char) i); - SELECT_GUS_REG(port, GUSREG_VOICE_CNTL); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOICE_CNTL); sc->sc_voc[i].voccntl = GUSMASK_VOICE_STOPPED | GUSMASK_STOP_VOICE; - outb(port+GUS_DATA_HIGH, sc->sc_voc[i].voccntl); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[i].voccntl); sc->sc_voc[i].volcntl = GUSMASK_VOLUME_STOPPED | GUSMASK_STOP_VOLUME; - SELECT_GUS_REG(port, GUSREG_VOLUME_CONTROL); - outb(port+GUS_DATA_HIGH, sc->sc_voc[i].volcntl); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, sc->sc_voc[i].volcntl); delay(100); gus_set_samprate(sc, i, 8000); - SELECT_GUS_REG(port, GUSREG_START_ADDR_HIGH); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_START_ADDR_LOW); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_END_ADDR_HIGH); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_END_ADDR_LOW); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_VOLUME_RATE); - outb(port+GUS_DATA_HIGH, 0x01); - SELECT_GUS_REG(port, GUSREG_START_VOLUME); - outb(port+GUS_DATA_HIGH, 0x10); - SELECT_GUS_REG(port, GUSREG_END_VOLUME); - outb(port+GUS_DATA_HIGH, 0xe0); - SELECT_GUS_REG(port, GUSREG_CUR_VOLUME); - outw(port+GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_VOLUME_RATE); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x01); + SELECT_GUS_REG(iot, ioh2, GUSREG_START_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x10); + SELECT_GUS_REG(iot, ioh2, GUSREG_END_VOLUME); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0xe0); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_VOLUME); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_HIGH); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_CUR_ADDR_LOW); - outw(port+GUS_DATA_LOW, 0x0000); - SELECT_GUS_REG(port, GUSREG_PAN_POS); - outb(port+GUS_DATA_HIGH, 0x07); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_HIGH); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_CUR_ADDR_LOW); + bus_space_write_2(iot, ioh2, GUS_DATA_LOW, 0x0000); + SELECT_GUS_REG(iot, ioh2, GUSREG_PAN_POS); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0x07); } /* * Clear out any pending IRQs */ - inb(port+GUS_IRQ_STATUS); - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - inb(port+GUS_DATA_HIGH); - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - inb(port+GUS_DATA_HIGH); - SELECT_GUS_REG(port, GUSREG_IRQ_STATUS); - inb(port+GUS_DATA_HIGH); + bus_space_read_1(iot, ioh1, GUS_IRQ_STATUS); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); + SELECT_GUS_REG(iot, ioh2, GUSREG_IRQ_STATUS); + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH); - SELECT_GUS_REG(port, GUSREG_RESET); - outb(port+GUS_DATA_HIGH, GUSMASK_MASTER_RESET | GUSMASK_DAC_ENABLE | + SELECT_GUS_REG(iot, ioh2, GUSREG_RESET); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, GUSMASK_MASTER_RESET | GUSMASK_DAC_ENABLE | GUSMASK_IRQ_ENABLE); splx(s); @@ -2745,6 +2855,8 @@ STATIC void gus_init_cs4231(sc) struct gus_softc *sc; { + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh1 = sc->sc_ioh1; int port = sc->sc_iobase; u_char ctrl; @@ -2758,7 +2870,7 @@ gus_init_cs4231(sc) if (sc->sc_recdrq >= 4) ctrl |= GUS_MAX_PLAYCHAN16; - outb(port+GUS_MAX_CTRL, ctrl); + bus_space_write_1(iot, ioh1, GUS_MAX_CTRL, ctrl); sc->sc_codec.sc_iot = sc->sc_iot; sc->sc_codec.sc_iobase = port+GUS_MAX_CODEC_BASE; @@ -2767,47 +2879,6 @@ gus_init_cs4231(sc) sc->sc_flags &= ~GUS_CODEC_INSTALLED; } else { struct ad1848_volume vol = {AUDIO_MAX_GAIN, AUDIO_MAX_GAIN}; - static struct audio_hw_if gusmax_hw_if = { - gusmaxopen, - gusmax_close, - NULL, /* drain */ - - gus_query_encoding, /* query encoding */ - - gusmax_set_params, - - gusmax_round_blocksize, - - gusmax_set_out_port, - gusmax_get_out_port, - gusmax_set_in_port, - gusmax_get_in_port, - - gusmax_commit_settings, - - NULL, - NULL, - - gusmax_dma_output, - gusmax_dma_input, - gusmax_halt_out_dma, - gusmax_halt_in_dma, - gusmax_cont_out_dma, - gusmax_cont_in_dma, - - gusmax_speaker_ctl, - - gus_getdev, - NULL, - gusmax_mixer_set_port, - gusmax_mixer_get_port, - gusmax_mixer_query_devinfo, - NULL, - NULL, - NULL, - NULL, - gusmax_get_props, - }; sc->sc_flags |= GUS_CODEC_INSTALLED; sc->sc_codec.parent = sc; sc->sc_codec.sc_drq = sc->sc_recdrq; @@ -2817,7 +2888,7 @@ gus_init_cs4231(sc) will do the real mixing for them. */ sc->sc_mixcontrol &= ~GUSMASK_LINE_IN; /* 0 enables. */ sc->sc_mixcontrol |= GUSMASK_MIC_IN; /* 1 enables. */ - outb(sc->sc_iobase+GUS_MIX_CONTROL, sc->sc_mixcontrol); + bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol); ad1848_attach(&sc->sc_codec); /* turn on pre-MUX microphone gain. */ @@ -2987,7 +3058,8 @@ gus_dma_input(addr, buf, size, callback, arg) void *arg; { struct gus_softc *sc = addr; - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; u_char dmac; DMAPRINTF(("gus_dma_input called\n")); @@ -3019,8 +3091,8 @@ gus_dma_input(addr, buf, size, callback, arg) sc->sc_dmaincnt = size; sc->sc_dmainaddr = buf; - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - outb(port+GUS_DATA_HIGH, dmac); /* Go! */ + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, dmac); /* Go! */ DMAPRINTF(("gus_dma_input returning\n")); @@ -3097,15 +3169,16 @@ gus_halt_out_dma(addr) void * addr; { struct gus_softc *sc = addr; - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; DMAPRINTF(("gus_halt_out_dma called\n")); /* * Make sure the GUS _isn't_ setup for DMA */ - SELECT_GUS_REG(port, GUSREG_DMA_CONTROL); - outb(sc->sc_iobase+GUS_DATA_HIGH, 0); + SELECT_GUS_REG(iot, ioh2, GUSREG_DMA_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, 0); untimeout(gus_dmaout_timeout, sc); isa_dmaabort(sc->sc_dev.dv_parent, sc->sc_drq); @@ -3132,16 +3205,17 @@ gus_halt_in_dma(addr) void * addr; { struct gus_softc *sc = addr; - int port = sc->sc_iobase; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh2 = sc->sc_ioh2; DMAPRINTF(("gus_halt_in_dma called\n")); /* * Make sure the GUS _isn't_ setup for DMA */ - SELECT_GUS_REG(port, GUSREG_SAMPLE_CONTROL); - outb(port+GUS_DATA_HIGH, - inb(port+GUS_DATA_HIGH) & ~(GUSMASK_SAMPLE_START|GUSMASK_SAMPLE_IRQ)); + SELECT_GUS_REG(iot, ioh2, GUSREG_SAMPLE_CONTROL); + bus_space_write_1(iot, ioh2, GUS_DATA_HIGH, + bus_space_read_1(iot, ioh2, GUS_DATA_HIGH) & ~(GUSMASK_SAMPLE_START|GUSMASK_SAMPLE_IRQ)); isa_dmaabort(sc->sc_dev.dv_parent, sc->sc_recdrq); sc->sc_flags &= ~GUS_DMAIN_ACTIVE; @@ -4273,10 +4347,12 @@ STATIC void gus_init_ics2101(sc) struct gus_softc *sc; { - int port = sc->sc_iobase; struct ics2101_softc *ic = &sc->sc_mixer; - sc->sc_mixer.sc_selio = port+GUS_MIXER_SELECT; - sc->sc_mixer.sc_dataio = port+GUS_MIXER_DATA; + sc->sc_mixer.sc_iot = sc->sc_iot; + sc->sc_mixer.sc_selio = GUS_MIXER_SELECT; + sc->sc_mixer.sc_selio_ioh = sc->sc_ioh3; + sc->sc_mixer.sc_dataio = GUS_MIXER_DATA; + sc->sc_mixer.sc_dataio_ioh = sc->sc_ioh2; sc->sc_mixer.sc_flags = (sc->sc_revision == 5) ? ICS_FLIP : 0; ics2101_mix_attenuate(ic, diff --git a/sys/dev/isa/gusreg.h b/sys/dev/isa/gusreg.h index f201a92e635d..ce192a7e4602 100644 --- a/sys/dev/isa/gusreg.h +++ b/sys/dev/isa/gusreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: gusreg.h,v 1.4 1997/03/19 06:45:23 mikel Exp $ */ +/* $NetBSD: gusreg.h,v 1.5 1997/09/06 14:23:14 augustss Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -46,10 +46,13 @@ * address. */ -#define GUS_MIDI_CONTROL 0x100 -#define GUS_MIDI_STATUS 0x100 -#define GUS_MIDI_READ 0x101 -#define GUS_MIDI_WRITE 0x101 +#define GUS_IOH4_OFFSET 0x100 +#define GUS_NPORT4 2 + +#define GUS_MIDI_CONTROL (0x100-GUS_IOH4_OFFSET) +#define GUS_MIDI_STATUS (0x100-GUS_IOH4_OFFSET) +#define GUS_MIDI_READ (0x101-GUS_IOH4_OFFSET) +#define GUS_MIDI_WRITE (0x101-GUS_IOH4_OFFSET) /* * Joystick interface - note this is an absolute address, NOT an offset from @@ -78,11 +81,18 @@ #define GUS_DMA_CONTROL 0x00b #define GUS_IRQCTL_CONTROL 0x00b #define GUS_JUMPER_CONTROL 0x00b -#define GUS_VOICE_SELECT 0x102 -#define GUS_REG_SELECT 0x103 -#define GUS_DATA_LOW 0x104 -#define GUS_DATA_HIGH 0x105 -#define GUS_DRAM_DATA 0x107 + +#define GUS_NPORT1 16 + +#define GUS_IOH2_OFFSET 0x102 +#define GUS_VOICE_SELECT (0x102-GUS_IOH2_OFFSET) +#define GUS_REG_SELECT (0x103-GUS_IOH2_OFFSET) +#define GUS_DATA_LOW (0x104-GUS_IOH2_OFFSET) +#define GUS_DATA_HIGH (0x105-GUS_IOH2_OFFSET) +/* GUS_MIXER_SELECT 106 */ +#define GUS_DRAM_DATA (0x107-GUS_IOH2_OFFSET) + +#define GUS_NPORT2 6 /* * GUS on-board global registers @@ -228,9 +238,12 @@ * ICS Mixer registers */ -#define GUS_MIXER_SELECT 0x506 /* read=board rev, wr=mixer */ -#define GUS_BOARD_REV 0x506 -#define GUS_MIXER_DATA 0x106 /* data for mixer control */ +#define GUS_IOH3_OFFSET 0x506 +#define GUS_NPORT3 1 + +#define GUS_MIXER_SELECT (0x506-GUS_IOH3_OFFSET) /* read=board rev, wr=mixer */ +#define GUS_BOARD_REV (0x506-GUS_IOH3_OFFSET) +#define GUS_MIXER_DATA (0x106-GUS_IOH2_OFFSET) /* data for mixer control */ #define GUSMIX_CHAN_MIC ICSMIX_CHAN_0 #define GUSMIX_CHAN_LINE ICSMIX_CHAN_1