diff options
author | sos <sos@FreeBSD.org> | 1994-09-29 08:24:45 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 1994-09-29 08:24:45 +0000 |
commit | d3edb28dc2f03a25970ab71ad2da48a307983394 (patch) | |
tree | adddc141b3e2e77559bd5c17e153282e8520e01a /sys/i386/isa/pcaudio.c | |
parent | e9600855b708ccbf583f1ea559b8b2e58b93c539 (diff) | |
download | FreeBSD-src-d3edb28dc2f03a25970ab71ad2da48a307983394.zip FreeBSD-src-d3edb28dc2f03a25970ab71ad2da48a307983394.tar.gz |
Updated pcaudio.c to latest from 1.1.5.1
Enabled timer reprogramming in clock.c (this could use more work).
Obtained from: FreeBSD-1.1.5.1
Diffstat (limited to 'sys/i386/isa/pcaudio.c')
-rw-r--r-- | sys/i386/isa/pcaudio.c | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/sys/i386/isa/pcaudio.c b/sys/i386/isa/pcaudio.c index f3fb1d5..489b968 100644 --- a/sys/i386/isa/pcaudio.c +++ b/sys/i386/isa/pcaudio.c @@ -6,7 +6,8 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. @@ -24,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pcaudio.c,v 1.6 1994/08/22 11:11:05 sos Exp $ + * $Id: pcaudio.c,v 1.7 1994/09/16 13:33:47 davidg Exp $ */ #include "pca.h" @@ -34,6 +35,8 @@ #include <sys/systm.h> #include <sys/uio.h> #include <sys/ioctl.h> +#include <sys/file.h> +#include <sys/proc.h> #include <machine/pcaudioio.h> #include <i386/isa/isa.h> #include <i386/isa/isa_device.h> @@ -60,6 +63,8 @@ static struct pca_status { char current; /* current buffer */ unsigned char oldval; /* old timer port value */ char timer_on; /* is playback running */ + char coll; /* select collision */ + pid_t wsel; /* pid of select'ing proc */ } pca_status; static char buffer1[BUF_SIZE]; @@ -76,6 +81,7 @@ int pcaclose(dev_t dev, int flag); int pcaopen(dev_t dev, int flag); int pcawrite(dev_t dev, struct uio *uio, int flag); int pcaioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p); +int pcaselect(dev_t dev, int rw, struct proc *p); struct isa_driver pcadriver = { pcaprobe, pcaattach, "pca", @@ -269,6 +275,10 @@ pcawrite(dev_t dev, struct uio *uio, int flag) return ENXIO; while ((count = min(BUF_SIZE, uio->uio_resid)) > 0) { + if (pca_status.in_use[0] && pca_status.in_use[1]) { + pca_sleep = 1; + tsleep((caddr_t)&pca_sleep, PZERO|PCATCH, "pca_wait",0); + } which = pca_status.in_use[0] ? 1 : 0; if (count && !pca_status.in_use[which]) { uiomove(pca_status.buf[which], count, uio); @@ -289,10 +299,6 @@ pcawrite(dev_t dev, struct uio *uio, int flag) if (pca_start()) return EBUSY; } - if (pca_status.in_use[0] && pca_status.in_use[1]) { - pca_sleep = 1; - tsleep((caddr_t)&pca_sleep, PZERO|PCATCH, "pca_wait",0); - } } return 0; } @@ -301,7 +307,7 @@ pcawrite(dev_t dev, struct uio *uio, int flag) int pcaioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { -audio_info_t *auptr; + audio_info_t *auptr; switch(cmd) { @@ -365,7 +371,6 @@ void pcaintr(int regs) { if (pca_status.index < pca_status.in_use[pca_status.current]) { -#if 1 disable_intr(); __asm__("outb %0,$0x61\n" "andb $0xFE,%0\n" @@ -376,18 +381,10 @@ pcaintr(int regs) : : "a" ((char)pca_status.buffer[pca_status.index]), "b" ((long)volume_table) ); enable_intr(); -#else - disable_intr(); - outb(IO_PPI, pca_status.oldval); - outb(IO_PPI, pca_status.oldval & 0xFE); - outb(TIMER_CNTR2, - volume_table[pca_status.buffer[pca_status.index]]); - enable_intr(); -#endif pca_status.counter += pca_status.scale; pca_status.index = (pca_status.counter >> 8); } - else { + if (pca_status.index >= pca_status.in_use[pca_status.current]) { pca_status.index = pca_status.counter = 0; pca_status.in_use[pca_status.current] = 0; pca_status.current ^= 1; @@ -396,7 +393,38 @@ pcaintr(int regs) wakeup((caddr_t)&pca_sleep); pca_sleep = 0; } + if (pca_status.wsel) { + selwakeup(pca_status.wsel, pca_status.coll); + pca_status.wsel = 0; + pca_status.coll = 0; + } } } + +int +pcaselect(dev_t dev, int rw, struct proc *p) +{ + int s = spltty(); + struct proc *p1; + + switch (rw) { + + case FWRITE: + if (!pca_status.in_use[0] || !pca_status.in_use[1]) { + splx(s); + return(1); + } + if (pca_status.wsel && (p1 = pfind(pca_status.wsel)) + && p1->p_wchan == (caddr_t)&selwait) + pca_status.coll = 1; + else + pca_status.wsel = p->p_pid; + splx(s); + return 0; + default: + splx(s); + return(0); + } +} #endif |