diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-01-29 06:28:00 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-01-29 06:28:00 +0000 |
commit | 3e69d06600d67479fe28260f374456ba5edb721f (patch) | |
tree | 32a27b22c7fb3e591c25472d6b2c7ea3ecd33540 /sys/dev/isa/ess.c | |
parent | 272fb308d299aaa40f31254b14fe752eee6cef70 (diff) |
new timeouts; spaces
Diffstat (limited to 'sys/dev/isa/ess.c')
-rw-r--r-- | sys/dev/isa/ess.c | 116 |
1 files changed, 60 insertions, 56 deletions
diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index 54c8e89c94e..89f257f1875 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.2 1999/09/30 22:13:52 kstailey Exp $ */ +/* $OpenBSD: ess.c,v 1.3 2001/01/29 06:27:59 mickey Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -45,8 +45,8 @@ ** ** MODULE DESCRIPTION: ** -** This module contains the device driver for the ESS -** Technologies 1888/1887/888 sound chip. The code in sbdsp.c was +** This module contains the device driver for the ESS +** Technologies 1888/1887/888 sound chip. The code in sbdsp.c was ** used as a reference point when implementing this driver. ** ** AUTHORS: @@ -54,7 +54,7 @@ ** Blair Fidler Software Engineering Australia ** Gold Coast, Australia. ** -** CREATION DATE: +** CREATION DATE: ** ** March 10, 1997. ** @@ -74,6 +74,7 @@ #include <sys/device.h> #include <sys/proc.h> #include <sys/kernel.h> +#include <sys/timeout.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -119,10 +120,10 @@ void ess_1788_close __P((void *)); void ess_1888_close __P((void *)); int ess_getdev __P((void *, struct audio_device *)); int ess_drain __P((void *)); - + int ess_query_encoding __P((void *, struct audio_encoding *)); -int ess_set_params __P((void *, int, int, struct audio_params *, +int ess_set_params __P((void *, int, int, struct audio_params *, struct audio_params *)); int ess_round_blocksize __P((void *, int)); @@ -143,7 +144,7 @@ void ess_audio2_poll __P((void *)); int ess_speaker_ctl __P((void *, int)); int ess_getdev __P((void *, struct audio_device *)); - + int ess_set_port __P((void *, mixer_ctrl_t *)); int ess_get_port __P((void *, mixer_ctrl_t *)); @@ -276,7 +277,7 @@ ess_printsc(sc) struct ess_softc *sc; { int i; - + printf("open %d iobase 0x%x outport %u inport %u speaker %s\n", (int)sc->sc_open, sc->sc_iobase, sc->out_port, sc->in_port, sc->spkr_state ? "on" : "off"); @@ -415,7 +416,7 @@ ess_config_addr(sc) /* Write the base address information into SCR[0]. */ EWRITE1(iot, scr_ioh, ESS_SCR_INDEX, 0); EWRITE1(iot, scr_ioh, ESS_SCR_DATA, scr_value); - + /* Lock the SCR. */ EWRITE1(iot, scr_access_ioh, ESS_SCR_LOCK, 0); @@ -473,7 +474,7 @@ ess_config_irq(sc) break; #ifdef DIAGNOSTIC default: - printf("ess_config_irq: configured irq %d not supported for Audio 1\n", + printf("ess_config_irq: configured irq %d not supported for Audio 1\n", sc->sc_audio1.irq); return; #endif @@ -509,7 +510,7 @@ ess_config_irq(sc) break; #ifdef DIAGNOSTIC default: - printf("ess: configured irq %d not supported for Audio 1\n", + printf("ess: configured irq %d not supported for Audio 1\n", sc->sc_audio1.irq); return; #endif @@ -522,11 +523,11 @@ ess_config_irq(sc) if (sc->sc_audio2.polled) { /* Turn off Audio2 interrupts. */ - ess_clear_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, + ess_clear_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, ESS_AUDIO2_CTRL2_IRQ2_ENABLE); } else { /* Audio2 is hardwired to INTRE in this mode. */ - ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, + ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, ESS_AUDIO2_CTRL2_IRQ2_ENABLE); } } @@ -554,7 +555,7 @@ ess_config_drq(sc) break; #ifdef DIAGNOSTIC default: - printf("ess_config_drq: configured dma chan %d not supported for Audio 1\n", + printf("ess_config_drq: configured dma chan %d not supported for Audio 1\n", sc->sc_audio1.drq); return; #endif @@ -582,19 +583,19 @@ ess_config_drq(sc) break; #ifdef DIAGNOSTIC default: - printf("ess_config_drq: configured dma chan %d not supported for Audio 2\n", + printf("ess_config_drq: configured dma chan %d not supported for Audio 2\n", sc->sc_audio2.drq); return; #endif } ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL3, v); /* Enable DMA 2 */ - ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, + ess_set_mreg_bits(sc, ESS_MREG_AUDIO2_CTRL2, ESS_AUDIO2_CTRL2_DMA_ENABLE); } -/* - * Set up registers after a reset. +/* + * Set up registers after a reset. */ void ess_setup(sc) @@ -611,7 +612,7 @@ ess_setup(sc) * Determine the model of ESS chip we are talking to. Currently we * only support ES1888, ES1887 and ES888. The method of determining * the chip is based on the information on page 27 of the ES1887 data - * sheet. + * sheet. * * This routine sets the values of sc->sc_model and sc->sc_version. */ @@ -660,9 +661,9 @@ ess_identify(sc) */ reg1 = ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL); reg2 = reg1 ^ 0x04; /* toggle bit 2 */ - + ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg2); - + if (ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL) != reg2) { printf("ess: Hardware error (unable to toggle bit 2 of mixer register 0x64)\n"); return 1; @@ -675,7 +676,7 @@ ess_identify(sc) /* - * 3. Verify we can change the value of mixer register + * 3. Verify we can change the value of mixer register * ESS_MREG_SAMPLE_RATE. * This is possible on the 1888/1887/888, but not on the 1788. * It is not necessary to restore the value of this mixer register. @@ -684,7 +685,7 @@ ess_identify(sc) reg2 = reg1 ^ 0xff; /* toggle all bits */ ess_write_mix_reg(sc, ESS_MREG_SAMPLE_RATE, reg2); - + if (ess_read_mix_reg(sc, ESS_MREG_SAMPLE_RATE) != reg2) { /* If we got this far before failing, it's a 1788. */ sc->sc_model = ESS_1788; @@ -713,9 +714,9 @@ ess_identify(sc) */ reg1 = ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL); reg2 = reg1 ^ 0x20; /* toggle bit 5 */ - + ess_write_mix_reg(sc, ESS_MREG_VOLUME_CTRL, reg2); - + if (ess_read_mix_reg(sc, ESS_MREG_VOLUME_CTRL) == reg2) { sc->sc_model = ESS_1887; @@ -762,7 +763,7 @@ ess_identify(sc) sc->sc_model = ESS_888; else sc->sc_model = ESS_1888; - + /* * Restore the original value of the registers. */ @@ -811,7 +812,7 @@ essmatch(sc) if (ess_config_addr(sc)) return (0); - if (ess_setup_sc(sc, 1)) + if (ess_setup_sc(sc, 1)) return (0); if (sc->sc_model == ESS_UNSUPPORTED) { @@ -839,8 +840,8 @@ essmatch(sc) if (!isa_drq_isfree(sc->sc_isa, sc->sc_audio2.drq)) return (0); } - - /* + + /* * The 1887 has an additional IRQ mode where both channels are mapped * to the same IRQ. */ @@ -895,7 +896,7 @@ essattach(sc) return; } - printf(": ESS Technology ES%s [version 0x%04x]\n", + printf(": ESS Technology ES%s [version 0x%04x]\n", essmodel[sc->sc_model], sc->sc_version); sc->sc_audio1.polled = sc->sc_audio1.irq == -1; @@ -932,7 +933,10 @@ essattach(sc) } } - /* + timeout_set(&sc->sc_tmo1, ess_audio1_poll, sc); + timeout_set(&sc->sc_tmo2, ess_audio2_poll, sc); + + /* * Set record and play parameters to default values defined in * generic audio driver. */ @@ -1032,7 +1036,7 @@ ess_open(addr, flags) struct ess_softc *sc = addr; DPRINTF(("ess_open: sc=%p\n", sc)); - + if (sc->sc_open != 0 || ess_reset(sc) != 0) return ENXIO; @@ -1214,7 +1218,7 @@ ess_set_params(addr, setmode, usemode, play, rec) return (EINVAL); } - for (mode = AUMODE_RECORD; mode != -1; + for (mode = AUMODE_RECORD; mode != -1; mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) { if ((setmode & mode) == 0) continue; @@ -1299,7 +1303,7 @@ ess_audio1_trigger_output(addr, start, end, blksize, intr, arg, param) sc->sc_audio1.buffersize = (char *)end - (char *)start; sc->sc_audio1.dmacount = 0; sc->sc_audio1.blksize = blksize; - timeout(ess_audio1_poll, sc, hz/30); + timeout_add(&sc->sc_tmo1, hz/30); } reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL); @@ -1329,7 +1333,7 @@ ess_audio1_trigger_output(addr, start, end, blksize, intr, arg, param) reg |= ESS_AUDIO1_CTRL1_FIFO_CONNECT; ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1, reg); - isa_dmastart(sc->sc_isa, sc->sc_audio1.drq, start, + isa_dmastart(sc->sc_isa, sc->sc_audio1.drq, start, (char *)end - (char *)start, NULL, DMAMODE_WRITE | DMAMODE_LOOP, BUS_DMA_NOWAIT); @@ -1342,7 +1346,7 @@ ess_audio1_trigger_output(addr, start, end, blksize, intr, arg, param) ess_set_xreg_bits(sc, ESS_XCMD_DEMAND_CTRL, ESS_DEMAND_CTRL_DEMAND_4); /* Start auto-init DMA */ - ess_wdsp(sc, ESS_ACMD_ENABLE_SPKR); + ess_wdsp(sc, ESS_ACMD_ENABLE_SPKR); reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2); reg &= ~(ESS_AUDIO1_CTRL2_DMA_READ | ESS_AUDIO1_CTRL2_ADC_ENABLE); reg |= ESS_AUDIO1_CTRL2_FIFO_ENABLE | ESS_AUDIO1_CTRL2_AUTO_INIT; @@ -1377,7 +1381,7 @@ ess_audio2_trigger_output(addr, start, end, blksize, intr, arg, param) sc->sc_audio2.buffersize = (char *)end - (char *)start; sc->sc_audio2.dmacount = 0; sc->sc_audio2.blksize = blksize; - timeout(ess_audio2_poll, sc, hz/30); + timeout_add(&sc->sc_tmo2, hz/30); } reg = ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2); @@ -1396,7 +1400,7 @@ ess_audio2_trigger_output(addr, start, end, blksize, intr, arg, param) reg &= ~ESS_AUDIO2_CTRL2_FIFO_SIGNED; ess_write_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2, reg); - isa_dmastart(sc->sc_isa, sc->sc_audio2.drq, start, + isa_dmastart(sc->sc_isa, sc->sc_audio2.drq, start, (char *)end - (char *)start, NULL, DMAMODE_WRITE | DMAMODE_LOOP, BUS_DMA_NOWAIT); @@ -1446,7 +1450,7 @@ ess_audio1_trigger_input(addr, start, end, blksize, intr, arg, param) sc->sc_audio1.buffersize = (char *)end - (char *)start; sc->sc_audio1.dmacount = 0; sc->sc_audio1.blksize = blksize; - timeout(ess_audio1_poll, sc, hz/30); + timeout_add(&sc->sc_tmo1, hz/30); } reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL); @@ -1476,7 +1480,7 @@ ess_audio1_trigger_input(addr, start, end, blksize, intr, arg, param) reg |= ESS_AUDIO1_CTRL1_FIFO_CONNECT; ess_write_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1, reg); - isa_dmastart(sc->sc_isa, sc->sc_audio1.drq, start, + isa_dmastart(sc->sc_isa, sc->sc_audio1.drq, start, (char *)end - (char *)start, NULL, DMAMODE_READ | DMAMODE_LOOP, BUS_DMA_NOWAIT); @@ -1489,7 +1493,7 @@ ess_audio1_trigger_input(addr, start, end, blksize, intr, arg, param) ess_set_xreg_bits(sc, ESS_XCMD_DEMAND_CTRL, ESS_DEMAND_CTRL_DEMAND_4); /* Start auto-init DMA */ - ess_wdsp(sc, ESS_ACMD_DISABLE_SPKR); + ess_wdsp(sc, ESS_ACMD_DISABLE_SPKR); reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL2); reg |= ESS_AUDIO1_CTRL2_DMA_READ | ESS_AUDIO1_CTRL2_ADC_ENABLE; reg |= ESS_AUDIO1_CTRL2_FIFO_ENABLE | ESS_AUDIO1_CTRL2_AUTO_INIT; @@ -1511,7 +1515,7 @@ ess_audio1_halt(addr) ESS_AUDIO1_CTRL2_FIFO_ENABLE); isa_dmaabort(sc->sc_isa, sc->sc_audio1.drq); if (sc->sc_audio1.polled) - untimeout(ess_audio1_poll, sc); + timeout_del(&sc->sc_tmo1); sc->sc_audio1.active = 0; } @@ -1532,7 +1536,7 @@ ess_audio2_halt(addr) ESS_AUDIO2_CTRL1_FIFO_ENABLE); isa_dmaabort(sc->sc_isa, sc->sc_audio2.drq); if (sc->sc_audio2.polled) - untimeout(ess_audio2_poll, sc); + timeout_del(&sc->sc_tmo2); sc->sc_audio2.active = 0; } @@ -1616,7 +1620,7 @@ ess_audio1_poll(addr) (*sc->sc_audio1.intr)(sc->sc_audio1.arg, dmacount); #endif - timeout(ess_audio1_poll, sc, hz/30); + timeout_add(&sc->sc_tmo1, hz/30); } void @@ -1647,7 +1651,7 @@ ess_audio2_poll(addr) (*sc->sc_audio2.intr)(sc->sc_audio2.arg, dmacount); #endif - timeout(ess_audio2_poll, sc, hz/30); + timeout_add(&sc->sc_tmo2, hz/30); } int @@ -1665,7 +1669,7 @@ ess_set_port(addr, cp) { struct ess_softc *sc = addr; int lgain, rgain; - + DPRINTFN(5,("ess_set_port: port=%d num_channels=%d\n", cp->dev, cp->un.value.num_channels)); @@ -1805,7 +1809,7 @@ ess_get_port(addr, cp) mixer_ctrl_t *cp; { struct ess_softc *sc = addr; - + DPRINTFN(5,("ess_get_port: port=%d\n", cp->dev)); switch (cp->dev) { @@ -1819,13 +1823,13 @@ ess_get_port(addr, cp) case ESS_RECORD_VOL: switch (cp->un.value.num_channels) { case 1: - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = + cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->gain[cp->dev][ESS_LEFT]; break; case 2: - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->gain[cp->dev][ESS_LEFT]; - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->gain[cp->dev][ESS_RIGHT]; break; default: @@ -1837,7 +1841,7 @@ ess_get_port(addr, cp) if (cp->un.value.num_channels != 1) return EINVAL; - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = + cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->gain[cp->dev][ESS_LEFT]; return (0); @@ -1866,13 +1870,13 @@ ess_get_port(addr, cp) case ESS_AUXB_REC_VOL: switch (cp->un.value.num_channels) { case 1: - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = + cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->gain[cp->dev][ESS_LEFT]; break; case 2: - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->gain[cp->dev][ESS_LEFT]; - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->gain[cp->dev][ESS_RIGHT]; break; default: @@ -1896,7 +1900,7 @@ ess_query_devinfo(addr, dip) { struct ess_softc *sc = addr; - DPRINTFN(5,("ess_query_devinfo: model=%d index=%d\n", + DPRINTFN(5,("ess_query_devinfo: model=%d index=%d\n", sc->sc_model, dip->index)); /* @@ -2016,7 +2020,7 @@ ess_query_devinfo(addr, dip) /* * The 1788 doesn't use the input mixer control that * the 1888 uses, because it's a pain when you only - * have one mixer. + * have one mixer. * Perhaps it could be emulated by keeping both sets of * gain values, and doing a `context switch' of the * mixer registers when shifting from playing to |