diff options
author | Niels Provos <provos@cvs.openbsd.org> | 1997-07-10 23:06:41 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 1997-07-10 23:06:41 +0000 |
commit | 0826c0a0161aae0be113fb06ba0a48642830c9b9 (patch) | |
tree | 8b607d05b561823151e23638d77fd97f8baeb591 /sys/dev/isa/pss.c | |
parent | 2ec8c7489d9ac4f6eb544112b10bfae5a1f06913 (diff) |
sync with NETBSD 30/3/97 + adapating aria.c
Diffstat (limited to 'sys/dev/isa/pss.c')
-rw-r--r-- | sys/dev/isa/pss.c | 227 |
1 files changed, 112 insertions, 115 deletions
diff --git a/sys/dev/isa/pss.c b/sys/dev/isa/pss.c index 3c7e94ef2c7..651a644c097 100644 --- a/sys/dev/isa/pss.c +++ b/sys/dev/isa/pss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pss.c,v 1.10 1996/05/26 00:27:27 deraadt Exp $ */ +/* $OpenBSD: pss.c,v 1.11 1997/07/10 23:06:36 provos Exp $ */ /* $NetBSD: pss.c,v 1.15 1996/05/12 23:53:23 mycroft Exp $ */ /* @@ -74,6 +74,9 @@ #include <dev/isa/wssreg.h> #include <dev/isa/pssreg.h> +/* XXX Default WSS base */ +#define WSS_BASE_ADDRESS 0x0530 + /* * Mixer devices */ @@ -106,7 +109,9 @@ struct pss_softc { struct device sc_dev; /* base device */ +#ifdef NEWCONFIG struct isadev sc_id; /* ISA device */ +#endif void *sc_ih; /* interrupt vectoring */ int sc_iobase; /* I/O port base address */ @@ -125,23 +130,29 @@ struct pss_softc { int mic_mute, cd_mute, dac_mute; }; +#ifdef notyet struct mpu_softc { struct device sc_dev; /* base device */ +#ifdef NEWCONFIG struct isadev sc_id; /* ISA device */ +#endif void *sc_ih; /* interrupt vectoring */ int sc_iobase; /* MIDI I/O port base address */ int sc_irq; /* MIDI interrupt */ }; -struct cd_softc { +struct pcd_softc { struct device sc_dev; /* base device */ +#ifdef NEWCONFIG struct isadev sc_id; /* ISA device */ +#endif void *sc_ih; /* interrupt vectoring */ int sc_iobase; /* CD I/O port base address */ int sc_irq; /* CD interrupt */ }; +#endif #ifdef AUDIO_DEBUG extern void Dprintf __P((const char *, ...)); @@ -157,16 +168,20 @@ void pssattach __P((struct device *, struct device *, void *)); int spprobe __P((struct device *, void *, void *)); void spattach __P((struct device *, struct device *, void *)); +#ifdef notyet int mpuprobe __P((struct device *, void *, void *)); void mpuattach __P((struct device *, struct device *, void *)); int pcdprobe __P((struct device *, void *, void *)); void pcdattach __P((struct device *, struct device *, void *)); +#endif int spopen __P((dev_t, int)); int pssintr __P((void *)); +#ifdef notyet int mpuintr __P((void *)); +#endif int pss_speaker_ctl __P((void *, int)); @@ -181,14 +196,21 @@ int pss_mixer_set_port __P((void *, mixer_ctrl_t *)); int pss_mixer_get_port __P((void *, mixer_ctrl_t *)); int pss_query_devinfo __P((void *, mixer_devinfo_t *)); +#ifdef PSS_DSP void pss_dspwrite __P((struct pss_softc *, int)); +#endif void pss_setaddr __P((int, int)); int pss_setint __P((int, int)); int pss_setdma __P((int, int)); +int pss_testirq __P((struct pss_softc *, int)); int pss_testdma __P((struct pss_softc *, int)); +#ifdef notyet int pss_reset_dsp __P((struct pss_softc *)); int pss_download_dsp __P((struct pss_softc *, u_char *, int)); +#endif +#ifdef AUDIO_DEBUG void pss_dump_regs __P((struct pss_softc *)); +#endif int pss_set_master_gain __P((struct pss_softc *, struct ad1848_volume *)); int pss_set_master_mode __P((struct pss_softc *, int)); int pss_set_treble __P((struct pss_softc *, u_int)); @@ -201,7 +223,9 @@ int pss_get_bass __P((struct pss_softc *, u_char *)); static int pss_to_vol __P((mixer_ctrl_t *, struct ad1848_volume *)); static int pss_from_vol __P((mixer_ctrl_t *, struct ad1848_volume *)); +#ifdef AUDIO_DEBUG void wss_dump_regs __P((struct ad1848_softc *)); +#endif /* * Define our interface to the higher level audio driver. @@ -216,9 +240,8 @@ struct audio_hw_if pss_audio_if = { ad1848_set_out_sr, ad1848_get_out_sr, ad1848_query_encoding, - ad1848_set_encoding, + ad1848_set_format, ad1848_get_encoding, - ad1848_set_precision, ad1848_get_precision, ad1848_set_channels, ad1848_get_channels, @@ -228,7 +251,6 @@ struct audio_hw_if pss_audio_if = { pss_set_in_port, pss_get_in_port, ad1848_commit_settings, - ad1848_get_silence, NULL, NULL, ad1848_dma_output, @@ -249,18 +271,15 @@ struct audio_hw_if pss_audio_if = { /* Interrupt translation for WSS config */ -static u_char wss_interrupt_bits[12] = { +static u_char wss_interrupt_bits[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, - 0xff, 0x10, 0x18, 0x20 + 0xff, 0x10, 0x18, 0x20, + 0xff, 0xff, 0xff, 0xff }; /* ditto for WSS DMA channel */ static u_char wss_dma_bits[4] = {1, 2, 0, 3}; -#ifndef NEWCONFIG -#define at_dma(flags, ptr, cc, chan) isa_dmastart(flags, ptr, cc, chan) -#endif - struct cfattach pss_ca = { sizeof(struct pss_softc), pssprobe, pssattach }; @@ -277,6 +296,7 @@ struct cfdriver sp_cd = { NULL, "sp", DV_DULL }; +#ifdef notyet struct cfattach mpu_ca = { sizeof(struct mpu_softc), mpuprobe, mpuattach }; @@ -286,12 +306,13 @@ struct cfdriver mpu_cd = { }; struct cfattach pcd_ca = { - sizeof(struct cd_softc), pcdprobe, pcdattach + sizeof(struct pcd_softc), pcdprobe, pcdattach }; struct cfdriver pcd_cd = { NULL, "pcd", DV_DULL }; +#endif struct audio_device pss_device = { "pss,ad1848", @@ -299,6 +320,7 @@ struct audio_device pss_device = { "PSS" }; +#ifdef PSS_DSP void pss_dspwrite(sc, data) struct pss_softc *sc; @@ -322,6 +344,7 @@ pss_dspwrite(sc, data) } printf ("pss: DSP Command (%04x) Timeout.\n", data); } +#endif /* PSS_DSP */ void pss_setaddr(addr, configAddr) @@ -347,58 +370,48 @@ pss_setint(intNum, configAddress) int configAddress; { int val; + switch(intNum) { - case 0: - val = inw(configAddress); - val &= INT_MASK; - outw(configAddress,val); - break; case 3: val = inw(configAddress); val &= INT_MASK; val |= INT_3_BITS; - outw(configAddress,val); break; case 5: val = inw(configAddress); val &= INT_MASK; val |= INT_5_BITS; - outw(configAddress,val); break; case 7: val = inw(configAddress); val &= INT_MASK; val |= INT_7_BITS; - outw(configAddress,val); break; case 9: val = inw(configAddress); val &= INT_MASK; val |= INT_9_BITS; - outw(configAddress,val); break; case 10: val = inw(configAddress); val &= INT_MASK; val |= INT_10_BITS; - outw(configAddress,val); break; case 11: val = inw(configAddress); val &= INT_MASK; val |= INT_11_BITS; - outw(configAddress,val); break; case 12: val = inw(configAddress); val &= INT_MASK; val |= INT_12_BITS; - outw(configAddress,val); break; default: - printf("pss_setint unkown int\n"); + DPRINTF(("pss_setint: invalid irq (%d)\n", intNum)); return 1; } + outw(configAddress,val); return 0; } @@ -414,55 +427,50 @@ pss_setdma(dmaNum, configAddress) val = inw(configAddress); val &= DMA_MASK; val |= DMA_0_BITS; - outw(configAddress,val); break; case 1: val = inw(configAddress); val &= DMA_MASK; val |= DMA_1_BITS; - outw(configAddress,val); break; case 3: val = inw(configAddress); val &= DMA_MASK; val |= DMA_3_BITS; - outw(configAddress,val); break; case 5: val = inw(configAddress); val &= DMA_MASK; val |= DMA_5_BITS; - outw(configAddress,val); break; case 6: val = inw(configAddress); val &= DMA_MASK; val |= DMA_6_BITS; - outw(configAddress,val); break; case 7: val = inw(configAddress); val &= DMA_MASK; val |= DMA_7_BITS; - outw(configAddress,val); break; default: - printf("PSS ERROR! pss_setdma: unknown_dma\n"); + DPRINTF(("pss_setdma: invalid drq (%d)\n", dmaNum)); return 1; } + outw(configAddress, val); return 0; } /* * This function tests an interrupt number to see if - * it is availible. It takes the interrupt button - * as it's argument and returns TRUE if the interrupt + * it is available. It takes the interrupt button + * as its argument and returns TRUE if the interrupt * is ok. */ -static int +int pss_testirq(struct pss_softc *sc, int intNum) { - int iobase = sc->sc_iobase; + int config = sc->sc_iobase + PSS_CONFIG; int val; int ret; int i; @@ -470,61 +478,50 @@ pss_testirq(struct pss_softc *sc, int intNum) /* Set the interrupt bits */ switch(intNum) { case 3: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; /* Special: 0 */ - outw(iobase+PSS_CONFIG, val); break; case 5: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_5_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_5_BITS; break; case 7: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_7_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_7_BITS; break; case 9: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_9_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_9_BITS; break; case 10: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_10_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_10_BITS; break; case 11: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_11_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_11_BITS; break; case 12: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= INT_MASK; - val |= INT_12_BITS; - outw(iobase+PSS_CONFIG,val); + val |= INT_TEST_BIT | INT_12_BITS; break; default: - DPRINTF(("pss: unknown IRQ (%d)\n", intNum)); + DPRINTF(("pss_testirq: invalid irq (%d)\n", intNum)); return 0; } - - /* Set the interrupt test bit */ - val = inw(iobase+PSS_CONFIG); - val |= INT_TEST_BIT; - outw(iobase+PSS_CONFIG,val); + outw(config, val); /* Check if the interrupt is in use */ /* Do it a few times in case there is a delay */ ret = 0; for (i = 0; i < 5; i++) { - val = inw(iobase+PSS_CONFIG); + val = inw(config); if (val & INT_TEST_PASS) { ret = 1; break; @@ -532,17 +529,16 @@ pss_testirq(struct pss_softc *sc, int intNum) } /* Clear the Test bit and the interrupt bits */ - val = inw(iobase+PSS_CONFIG); - val &= INT_TEST_BIT_MASK; - val &= INT_MASK; - outw(iobase+PSS_CONFIG,val); + val = inw(config); + val &= INT_TEST_BIT_MASK & INT_MASK; + outw(config, val); return(ret); } /* * This function tests a dma channel to see if - * it is availible. It takes the DMA channel button - * as it's argument and returns TRUE if the channel + * it is available. It takes the DMA channel button + * as its argument and returns TRUE if the channel * is ok. */ int @@ -550,62 +546,52 @@ pss_testdma(sc, dmaNum) struct pss_softc *sc; int dmaNum; { - int iobase = sc->sc_iobase; + int config = sc->sc_iobase + PSS_CONFIG; int val; - int i,ret; + int i, ret; switch (dmaNum) { case 0: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_0_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_0_BITS; break; case 1: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_1_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_1_BITS; break; case 3: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_3_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_3_BITS; break; case 5: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_5_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_5_BITS; break; case 6: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_6_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_6_BITS; break; case 7: - val = inw(iobase+PSS_CONFIG); + val = inw(config); val &= DMA_MASK; - val |= DMA_7_BITS; - outw(iobase+PSS_CONFIG,val); + val |= DMA_TEST_BIT | DMA_7_BITS; break; default: - DPRINTF(("pss: unknown DMA channel (%d)\n", dmaNum)); + DPRINTF(("pss_testdma: invalid drq (%d)\n", dmaNum)); return 0; } - - /* Set the DMA test bit */ - val = inw(iobase+PSS_CONFIG); - val |= DMA_TEST_BIT; - outw(iobase+PSS_CONFIG,val); + outw(config, val); /* Check if the DMA channel is in use */ /* Do it a few times in case there is a delay */ ret = 0; for (i = 0; i < 3; i++) { - val = inw(iobase+PSS_CONFIG); + val = inw(config); if (val & DMA_TEST_PASS) { ret = 1; break; @@ -613,13 +599,13 @@ pss_testdma(sc, dmaNum) } /* Clear the Test bit and the DMA bits */ - val = inw(iobase+PSS_CONFIG); - val &= DMA_TEST_BIT_MASK; - val &= DMA_MASK; - outw(iobase+PSS_CONFIG,val); + val = inw(config); + val &= DMA_TEST_BIT_MASK & DMA_MASK; + outw(config, val); return(ret); } +#ifdef notyet int pss_reset_dsp(sc) struct pss_softc *sc; @@ -639,8 +625,8 @@ pss_reset_dsp(sc) /* * This function loads an image into the PSS - * card. The function loads the file by putting - * reseting the dsp and feeding it the boot bytes. + * card. The function loads the file by + * resetting the dsp and feeding it the boot bytes. * First you feed the ASIC the first byte of * the boot sequence. The ASIC waits until it * detects a BMS and RD and asserts BR @@ -720,28 +706,32 @@ pss_download_dsp(sc, block, size) return 1; } +#endif /* notyet */ +#ifdef AUDIO_DEBUG void wss_dump_regs(sc) struct ad1848_softc *sc; { - printf("WSS regs: config=%x version=%x\n", - (u_char)inb(sc->sc_iobase+WSS_CONFIG), - (u_char)inb(sc->sc_iobase+WSS_STATUS)); + + printf("WSS reg: status=%02x\n", + (u_char)inb(sc->sc_iobase-WSS_CODEC+WSS_STATUS)); } void pss_dump_regs(sc) struct pss_softc *sc; { - printf("PSS regs: status=%x vers=%x ", + + printf("PSS regs: status=%04x vers=%04x ", (u_short)inw(sc->sc_iobase+PSS_STATUS), (u_short)inw(sc->sc_iobase+PSS_ID_VERS)); - printf("config=%x wss_config=%x\n", + printf("config=%04x wss_config=%04x\n", (u_short)inw(sc->sc_iobase+PSS_CONFIG), (u_short)inw(sc->sc_iobase+PSS_WSS_CONFIG)); } +#endif /* * Probe for the PSS hardware. @@ -784,7 +774,7 @@ pss_found: sc->sc_iobase = iobase; /* Clear WSS config */ - pss_setaddr(WSS_BASE_ADDRESS, sc->sc_iobase+PSS_WSS_CONFIG); + pss_setaddr(WSS_BASE_ADDRESS, sc->sc_iobase+PSS_WSS_CONFIG); /* XXX! */ outb(WSS_BASE_ADDRESS+WSS_CONFIG, 0); /* Clear config registers (POR reset state) */ @@ -828,7 +818,7 @@ pss_found: pss_setint(ia->ia_irq, sc->sc_iobase+PSS_CONFIG); pss_setdma(sc->sc_drq, sc->sc_iobase+PSS_CONFIG); - +#ifdef notyet /* Setup the Game port */ #ifdef PSS_GAMEPORT DPRINTF(("Turning Game Port On.\n")); @@ -839,6 +829,7 @@ pss_found: /* Reset DSP */ pss_reset_dsp(sc); +#endif /* notyet */ return 1; } @@ -857,10 +848,10 @@ spprobe(parent, match, aux) u_char bits; int i; - sc->sc_iobase = cf->cf_iobase; + sc->sc_iobase = cf->cf_iobase + WSS_CODEC; /* Set WSS io address */ - pss_setaddr(sc->sc_iobase, pc->sc_iobase+PSS_WSS_CONFIG); + pss_setaddr(cf->cf_iobase, pc->sc_iobase+PSS_WSS_CONFIG); /* Is there an ad1848 chip at the WSS iobase ? */ if (ad1848_probe(sc) == 0) { @@ -940,6 +931,7 @@ spprobe(parent, match, aux) return 1; } +#ifdef notyet int mpuprobe(parent, match, aux) struct device *parent; @@ -990,7 +982,7 @@ pcdprobe(parent, match, aux) struct device *parent; void *match, *aux; { - struct cd_softc *sc = match; + struct pcd_softc *sc = match; struct pss_softc *pc = (void *) parent; struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata; u_short val; @@ -1035,6 +1027,7 @@ pcdprobe(parent, match, aux) return 1; } +#endif /* notyet */ /* * Attach hardware to driver, attach hardware driver to audio @@ -1097,7 +1090,7 @@ spattach(parent, self, aux) #endif sc->sc_ih = isa_intr_establish(ic, cf->cf_irq, IST_EDGE, IPL_AUDIO, - ad1848_intr, sc, sc->sc_dev.dv_xname); + ad1848_intr, sc); /* XXX might use pssprint func ?? */ printf(" port 0x%x-0x%x irq %d drq %d", @@ -1109,6 +1102,7 @@ spattach(parent, self, aux) printf("\n"); } +#ifdef notyet void mpuattach(parent, self, aux) struct device *parent, *self; @@ -1126,7 +1120,7 @@ mpuattach(parent, self, aux) #endif sc->sc_ih = isa_intr_establish(ic, cf->cf_irq, IST_EDGE, IPL_AUDIO, - mpuintr, sc, sc->sc_dev.dv_xname); + mpuintr, sc); /* XXX might use pssprint func ?? */ printf(" port 0x%x-0x%x irq %d\n", @@ -1139,7 +1133,7 @@ pcdattach(parent, self, aux) struct device *parent, *self; void *aux; { - struct cd_softc *sc = (struct cd_softc *)self; + struct pcd_softc *sc = (struct pcd_softc *)self; struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata; int iobase = cf->cf_iobase; @@ -1159,6 +1153,7 @@ pcdattach(parent, self, aux) sc->sc_iobase, sc->sc_iobase+2, cf->cf_irq); } +#endif /* notyet */ static int pss_to_vol(cp, vol) @@ -1378,6 +1373,7 @@ pssintr(arg) return 0; } +#ifdef notyet int mpuintr(arg) void *arg; @@ -1392,6 +1388,7 @@ mpuintr(arg) /* XXX Need to clear intr */ return 1; } +#endif int pss_getdev(addr, retp) |