diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-01-01 17:36:26 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-01-01 17:36:26 +0000 |
commit | a46d1d7f893729bbd95a207f15da7cf72690209c (patch) | |
tree | 2bf9e44e75f8effab6b654ff7122f77f882aeee0 /sys/dev/sound/isa | |
parent | cfe419eb213db0b2937a261122224454d75db7a4 (diff) | |
download | FreeBSD-src-a46d1d7f893729bbd95a207f15da7cf72690209c.zip FreeBSD-src-a46d1d7f893729bbd95a207f15da7cf72690209c.tar.gz |
- Do not uiomove with a mutex locked.
- Move from msleep/wakeup to condvar.
- Return either zero or a positive errno value from a function.
Return additional result via references.
- Unify the typedef of callback functions.
Diffstat (limited to 'sys/dev/sound/isa')
-rw-r--r-- | sys/dev/sound/isa/emu8000.c | 20 | ||||
-rw-r--r-- | sys/dev/sound/isa/gusmidi.c | 14 | ||||
-rw-r--r-- | sys/dev/sound/isa/mpu.c | 34 | ||||
-rw-r--r-- | sys/dev/sound/isa/opl.c | 19 | ||||
-rw-r--r-- | sys/dev/sound/isa/uartsio.c | 13 |
5 files changed, 72 insertions, 28 deletions
diff --git a/sys/dev/sound/isa/emu8000.c b/sys/dev/sound/isa/emu8000.c index ea434e6..af9e3b2 100644 --- a/sys/dev/sound/isa/emu8000.c +++ b/sys/dev/sound/isa/emu8000.c @@ -803,21 +803,28 @@ emu_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) } static int -emu_callback(mididev_info *devinfo, int reason) +emu_callback(void *d, int reason) { + mididev_info *devinfo; + + devinfo = (mididev_info *)d; + mtx_assert(&devinfo->flagqueue_mtx, MA_OWNED); return (0); } static int -emu_readraw(mididev_info *md, u_char *buf, int len, int nonblock) +emu_readraw(mididev_info *md, u_char *buf, int len, int *lenr, int nonblock) { sc_p scp; int unit; if (md == NULL) return (ENXIO); + if (lenr == NULL) + return (EINVAL); + unit = md->unit; scp = md->softc; if ((md->fflags & FREAD) == 0) { @@ -826,17 +833,22 @@ emu_readraw(mididev_info *md, u_char *buf, int len, int nonblock) } /* NOP. */ + *lenr = 0; + return (0); } static int -emu_writeraw(mididev_info *md, u_char *buf, int len, int nonblock) +emu_writeraw(mididev_info *md, u_char *buf, int len, int *lenw, int nonblock) { sc_p scp; int unit; if (md == NULL) return (ENXIO); + if (lenw == NULL) + return (EINVAL); + unit = md->unit; scp = md->softc; if ((md->fflags & FWRITE) == 0) { @@ -845,6 +857,8 @@ emu_writeraw(mididev_info *md, u_char *buf, int len, int nonblock) } /* NOP. */ + *lenw = 0; + return (0); } diff --git a/sys/dev/sound/isa/gusmidi.c b/sys/dev/sound/isa/gusmidi.c index 797d168..e5ff9cf 100644 --- a/sys/dev/sound/isa/gusmidi.c +++ b/sys/dev/sound/isa/gusmidi.c @@ -289,7 +289,7 @@ gusmidi_intr(void *arg) sc_p scp; u_char c; mididev_info *devinfo; - int stat, did_something; + int stat, did_something, leni; scp = (sc_p)arg; devinfo = scp->devinfo; @@ -308,13 +308,13 @@ gusmidi_intr(void *arg) (!(devinfo->flags & MIDI_F_BUSY) || !(devinfo->fflags & FWRITE))) { midibuf_input_intr(&devinfo->midi_dbuf_passthru, - &c, sizeof c); + &c, sizeof c, &leni); devinfo->callback(devinfo, MIDI_CB_START | MIDI_CB_WR); } if ((devinfo->flags & MIDI_F_READING) && c != 0xfe) { midibuf_input_intr(&devinfo->midi_dbuf_in, - &c, sizeof c); + &c, sizeof c, &leni); } did_something = 1; } else @@ -342,10 +342,13 @@ gusmidi_intr(void *arg) } static int -gusmidi_callback(mididev_info *d, int reason) +gusmidi_callback(void *di, int reason) { int unit; sc_p scp; + mididev_info *d; + + d = (mididev_info *)di; mtx_assert(&d->flagqueue_mtx, MA_OWNED); @@ -424,6 +427,7 @@ gusmidi_xmit(sc_p scp) register mididev_info *devinfo; register midi_dbuf *dbuf; u_char c; + int leno; devinfo = scp->devinfo; @@ -450,7 +454,7 @@ gusmidi_xmit(sc_p scp) mtx_lock(&scp->mtx); if (gusmidi_readport(scp, PORT_ST) & MIDIST_TXDONE) { /* Send the data. */ - midibuf_output_intr(dbuf, &c, sizeof(c)); + midibuf_output_intr(dbuf, &c, sizeof(c), &leno); gusmidi_writeport(scp, PORT_TX, c); /* We are playing now. */ } else { diff --git a/sys/dev/sound/isa/mpu.c b/sys/dev/sound/isa/mpu.c index ed9b746..b79a3dd 100644 --- a/sys/dev/sound/isa/mpu.c +++ b/sys/dev/sound/isa/mpu.c @@ -148,7 +148,7 @@ static int mpu_uartmode(sc_p scp); static int mpu_waitack(sc_p scp); static int mpu_status(sc_p scp); static int mpu_command(sc_p scp, u_int8_t value); -static int mpu_readdata(sc_p scp); +static int mpu_readdata(sc_p scp, u_int8_t *value); static int mpu_writedata(sc_p scp, u_int8_t value); static u_int mpu_readport(sc_p scp, int off); static void mpu_writeport(sc_p scp, int off, u_int8_t value); @@ -454,6 +454,7 @@ mpu_intr(void *arg) sc_p scp; u_char c; mididev_info *devinfo; + int leni; scp = (sc_p)arg; devinfo = scp->devinfo; @@ -464,16 +465,16 @@ mpu_intr(void *arg) /* Read the received data. */ while ((mpu_status(scp) & MPU_INPUTBUSY) == 0) { /* Receive the data. */ - c = mpu_readdata(scp); + mpu_readdata(scp, &c); mtx_unlock(&scp->mtx); /* Queue into the passthru buffer and start transmitting if we can. */ if ((devinfo->flags & MIDI_F_PASSTHRU) != 0 && ((devinfo->flags & MIDI_F_BUSY) == 0 || (devinfo->fflags & FWRITE) == 0)) { - midibuf_input_intr(&devinfo->midi_dbuf_passthru, &c, sizeof(c)); + midibuf_input_intr(&devinfo->midi_dbuf_passthru, &c, sizeof(c), &leni); devinfo->callback(devinfo, MIDI_CB_START | MIDI_CB_WR); } /* Queue if we are reading. Discard an active sensing. */ if ((devinfo->flags & MIDI_F_READING) != 0 && c != 0xfe) { - midibuf_input_intr(&devinfo->midi_dbuf_in, &c, sizeof(c)); + midibuf_input_intr(&devinfo->midi_dbuf_in, &c, sizeof(c), &leni); } mtx_lock(&scp->mtx); } @@ -485,10 +486,13 @@ mpu_intr(void *arg) } static int -mpu_callback(mididev_info *d, int reason) +mpu_callback(void *di, int reason) { int unit; sc_p scp; + mididev_info *d; + + d = (mididev_info *)di; mtx_assert(&d->flagqueue_mtx, MA_OWNED); @@ -553,6 +557,7 @@ mpu_xmit(sc_p scp) register mididev_info *devinfo; register midi_dbuf *dbuf; u_char c; + int leno; devinfo = scp->devinfo; @@ -573,7 +578,7 @@ mpu_xmit(sc_p scp) /* XXX Wait until we can write the data. */ if ((mpu_status(scp) & MPU_OUTPUTBUSY) == 0) { /* Send the data. */ - midibuf_output_intr(dbuf, &c, sizeof(c)); + midibuf_output_intr(dbuf, &c, sizeof(c), &leno); mpu_writedata(scp, c); /* We are playing now. */ devinfo->flags |= MIDI_F_WRITING; @@ -639,12 +644,12 @@ mpu_uartmode(sc_p scp) static int mpu_waitack(sc_p scp) { - int i, resp; + int i; + u_int8_t resp; resp = 0; for (i = 0 ; i < MPU_TRYDATA ; i++) { - resp = mpu_readdata(scp); - if (resp >= 0) + if (mpu_readdata(scp, &resp) == 0) break; } if (resp != MPU_ACK) @@ -680,17 +685,22 @@ mpu_command(sc_p scp, u_int8_t value) /* Reads a byte of data. */ static int -mpu_readdata(sc_p scp) +mpu_readdata(sc_p scp, u_int8_t *value) { u_int status; + if (value == NULL) + return (EINVAL); + /* Is the interface ready to write? */ status = mpu_status(scp); if ((status & MPU_INPUTBUSY) != 0) /* The interface is busy. */ - return (-EAGAIN); + return (EAGAIN); + + *value = (u_int8_t)(mpu_readport(scp, MPU_DATAPORT) & 0xff); - return (int)mpu_readport(scp, MPU_DATAPORT) & 0xff; + return (0); } /* Writes a byte of data. */ diff --git a/sys/dev/sound/isa/opl.c b/sys/dev/sound/isa/opl.c index 5ebf974..345bebb 100644 --- a/sys/dev/sound/isa/opl.c +++ b/sys/dev/sound/isa/opl.c @@ -907,10 +907,13 @@ opl_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) } static int -opl_callback(mididev_info *devinfo, int reason) +opl_callback(void *d, int reason) { int unit; sc_p scp; + mididev_info *devinfo; + + devinfo = (mididev_info *)d; mtx_assert(&devinfo->flagqueue_mtx, MA_OWNED); @@ -948,13 +951,16 @@ opl_callback(mididev_info *devinfo, int reason) } static int -opl_readraw(mididev_info *md, u_char *buf, int len, int nonblock) +opl_readraw(mididev_info *md, u_char *buf, int len, int *lenr, int nonblock) { sc_p scp; int unit; if (md == NULL) return (ENXIO); + if (lenr == NULL) + return (EINVAL); + unit = md->unit; scp = md->softc; if ((md->fflags & FREAD) == 0) { @@ -963,17 +969,22 @@ opl_readraw(mididev_info *md, u_char *buf, int len, int nonblock) } /* NOP. */ + *lenr = 0; + return (0); } static int -opl_writeraw(mididev_info *md, u_char *buf, int len, int nonblock) +opl_writeraw(mididev_info *md, u_char *buf, int len, int *lenw, int nonblock) { sc_p scp; int unit; if (md == NULL) return (ENXIO); + if (lenw == NULL) + return (EINVAL); + unit = md->unit; scp = md->softc; if ((md->fflags & FWRITE) == 0) { @@ -982,6 +993,8 @@ opl_writeraw(mididev_info *md, u_char *buf, int len, int nonblock) } /* NOP. */ + *lenw = 0; + return (0); } diff --git a/sys/dev/sound/isa/uartsio.c b/sys/dev/sound/isa/uartsio.c index 07c9be3..f81f787 100644 --- a/sys/dev/sound/isa/uartsio.c +++ b/sys/dev/sound/isa/uartsio.c @@ -320,10 +320,13 @@ uartsio_intr(void *arg) } static int -uartsio_callback(mididev_info *d, int reason) +uartsio_callback(void *di, int reason) { int unit; sc_p scp; + mididev_info *d; + + d = (mididev_info *)di; mtx_assert(&d->flagqueue_mtx, MA_OWNED); @@ -386,7 +389,7 @@ uartsio_xmit(sc_p scp) { mididev_info *devinfo; midi_dbuf *dbuf; - int lsr, msr, iir, i, txsize; + int lsr, msr, iir, i, txsize, leni, leno; u_char c[TX_FIFO_SIZE]; devinfo = scp->devinfo; @@ -406,12 +409,12 @@ uartsio_xmit(sc_p scp) mtx_unlock(&scp->mtx); /* Queue into the passthru buffer and start transmitting if we can. */ if ((devinfo->flags & MIDI_F_PASSTHRU) != 0 && ((devinfo->flags & MIDI_F_BUSY) == 0 || (devinfo->fflags & FWRITE) == 0)) { - midibuf_input_intr(&devinfo->midi_dbuf_passthru, &c[0], sizeof(c[0])); + midibuf_input_intr(&devinfo->midi_dbuf_passthru, &c[0], sizeof(c[0]), &leni); devinfo->flags |= MIDI_F_WRITING; } /* Queue if we are reading. Discard an active sensing. */ if ((devinfo->flags & MIDI_F_READING) != 0 && c[0] != 0xfe) - midibuf_input_intr(&devinfo->midi_dbuf_in, &c[0], sizeof(c[0])); + midibuf_input_intr(&devinfo->midi_dbuf_in, &c[0], sizeof(c[0]), &leni); mtx_lock(&scp->mtx); } } @@ -440,7 +443,7 @@ uartsio_xmit(sc_p scp) txsize = scp->tx_size; if (dbuf->rl < txsize) txsize = dbuf->rl; - midibuf_output_intr(dbuf, c, txsize); + midibuf_output_intr(dbuf, c, txsize, &leno); for (i = 0 ; i < txsize ; i++) uartsio_writeport(scp, com_data, c[i]); /* We are playing now. */ |