diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index 6753f864ba9c..eed7ce89a919 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -1,888 +1,884 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Mathew Kanner * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Lennart Augustsson (augustss@netbsd.org). * * Redistribution and use in source and binary forms, with or without * 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. * 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. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_snd.h" #endif #include #include "mpu_if.h" #include MALLOC_DEFINE(M_MIDI, "midi buffers", "Midi data allocation area"); -#ifndef KOBJMETHOD_END -#define KOBJMETHOD_END { NULL, NULL } -#endif - #define MIDI_DEV_MIDICTL 12 enum midi_states { MIDI_IN_START, MIDI_IN_SYSEX, MIDI_IN_DATA }; #define MIDI_NAMELEN 16 struct snd_midi { KOBJ_FIELDS; struct mtx lock; /* Protects all but queues */ void *cookie; int unit; /* Should only be used in midistat */ int channel; /* Should only be used in midistat */ int busy; int flags; /* File flags */ char name[MIDI_NAMELEN]; struct mtx qlock; /* Protects inq, outq and flags */ MIDIQ_HEAD(, char) inq, outq; int rchan, wchan; struct selinfo rsel, wsel; int hiwat; /* QLEN(outq)>High-water -> disable * writes from userland */ enum midi_states inq_state; int inq_status, inq_left; /* Variables for the state machine in * Midi_in, this is to provide that * signals only get issued only * complete command packets. */ struct proc *async; struct cdev *dev; TAILQ_ENTRY(snd_midi) link; }; TAILQ_HEAD(, snd_midi) midi_devs; struct sx mstat_lock; static d_open_t midi_open; static d_close_t midi_close; static d_ioctl_t midi_ioctl; static d_read_t midi_read; static d_write_t midi_write; static d_poll_t midi_poll; static struct cdevsw midi_cdevsw = { .d_version = D_VERSION, .d_open = midi_open, .d_close = midi_close, .d_read = midi_read, .d_write = midi_write, .d_ioctl = midi_ioctl, .d_poll = midi_poll, .d_name = "rmidi", }; static int midi_destroy(struct snd_midi *, int); static int midi_load(void); static int midi_unload(void); SYSCTL_NODE(_hw, OID_AUTO, midi, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Midi driver"); int midi_debug; /* XXX: should this be moved into debug.midi? */ SYSCTL_INT(_hw_midi, OID_AUTO, debug, CTLFLAG_RW, &midi_debug, 0, ""); #define MIDI_DEBUG(l,a) if(midi_debug>=l) a void midistat_lock(void) { sx_xlock(&mstat_lock); } void midistat_unlock(void) { sx_xunlock(&mstat_lock); } void midistat_lockassert(void) { sx_assert(&mstat_lock, SA_XLOCKED); } /* * Register a new rmidi device. cls midi_if interface unit == 0 means * auto-assign new unit number unit != 0 already assigned a unit number, eg. * not the first channel provided by this device. channel, sub-unit * cookie is passed back on MPU calls Typical device drivers will call with * unit=0, channel=1..(number of channels) and cookie=soft_c and won't care * what unit number is used. * * It is an error to call midi_init with an already used unit/channel combo. */ struct snd_midi * midi_init(kobj_class_t cls, int unit, int channel, void *cookie) { struct snd_midi *m; int i; int inqsize, outqsize; uint8_t *buf; MIDI_DEBUG(1, printf("midiinit: unit %d/%d.\n", unit, channel)); midistat_lock(); /* * Protect against call with existing unit/channel or auto-allocate a * new unit number. */ i = -1; TAILQ_FOREACH(m, &midi_devs, link) { mtx_lock(&m->lock); if (unit != 0) { if (m->unit == unit && m->channel == channel) { mtx_unlock(&m->lock); goto err0; } } else { /* * Find a better unit number */ if (m->unit > i) i = m->unit; } mtx_unlock(&m->lock); } if (unit == 0) unit = i + 1; MIDI_DEBUG(1, printf("midiinit #2: unit %d/%d.\n", unit, channel)); m = malloc(sizeof(*m), M_MIDI, M_WAITOK | M_ZERO); kobj_init((kobj_t)m, cls); inqsize = MPU_INQSIZE(m, cookie); outqsize = MPU_OUTQSIZE(m, cookie); MIDI_DEBUG(1, printf("midiinit queues %d/%d.\n", inqsize, outqsize)); if (!inqsize && !outqsize) goto err1; mtx_init(&m->lock, "raw midi", NULL, 0); mtx_init(&m->qlock, "q raw midi", NULL, 0); mtx_lock(&m->lock); mtx_lock(&m->qlock); if (inqsize) buf = malloc(sizeof(uint8_t) * inqsize, M_MIDI, M_NOWAIT); else buf = NULL; MIDIQ_INIT(m->inq, buf, inqsize); if (outqsize) buf = malloc(sizeof(uint8_t) * outqsize, M_MIDI, M_NOWAIT); else buf = NULL; m->hiwat = outqsize / 2; MIDIQ_INIT(m->outq, buf, outqsize); if ((inqsize && !MIDIQ_BUF(m->inq)) || (outqsize && !MIDIQ_BUF(m->outq))) goto err2; m->busy = 0; m->flags = 0; m->unit = unit; m->channel = channel; m->cookie = cookie; if (MPU_INIT(m, cookie)) goto err2; mtx_unlock(&m->lock); mtx_unlock(&m->qlock); TAILQ_INSERT_TAIL(&midi_devs, m, link); midistat_unlock(); m->dev = make_dev(&midi_cdevsw, unit, UID_ROOT, GID_WHEEL, 0666, "midi%d.%d", unit, channel); m->dev->si_drv1 = m; return m; err2: mtx_destroy(&m->qlock); mtx_destroy(&m->lock); if (MIDIQ_BUF(m->inq)) free(MIDIQ_BUF(m->inq), M_MIDI); if (MIDIQ_BUF(m->outq)) free(MIDIQ_BUF(m->outq), M_MIDI); err1: free(m, M_MIDI); err0: midistat_unlock(); MIDI_DEBUG(1, printf("midi_init ended in error\n")); return NULL; } /* * midi_uninit does not call MIDI_UNINIT, as since this is the implementors * entry point. midi_uninit if fact, does not send any methods. A call to * midi_uninit is a defacto promise that you won't manipulate ch anymore */ int midi_uninit(struct snd_midi *m) { int err; err = EBUSY; midistat_lock(); mtx_lock(&m->lock); if (m->busy) { if (!(m->rchan || m->wchan)) goto err; if (m->rchan) { wakeup(&m->rchan); m->rchan = 0; } if (m->wchan) { wakeup(&m->wchan); m->wchan = 0; } } err = midi_destroy(m, 0); if (!err) goto exit; err: mtx_unlock(&m->lock); exit: midistat_unlock(); return err; } #ifdef notdef static int midi_lengths[] = {2, 2, 2, 2, 1, 1, 2, 0}; #endif /* notdef */ /* Number of bytes in a MIDI command */ #define MIDI_LENGTH(d) (midi_lengths[((d) >> 4) & 7]) #define MIDI_ACK 0xfe #define MIDI_IS_STATUS(d) ((d) >= 0x80) #define MIDI_IS_COMMON(d) ((d) >= 0xf0) #define MIDI_SYSEX_START 0xF0 #define MIDI_SYSEX_END 0xF7 /* * midi_in: process all data until the queue is full, then discards the rest. * Since midi_in is a state machine, data discards can cause it to get out of * whack. Process as much as possible. It calls, wakeup, selnotify and * psignal at most once. */ int midi_in(struct snd_midi *m, uint8_t *buf, int size) { /* int i, sig, enq; */ int used; /* uint8_t data; */ MIDI_DEBUG(5, printf("midi_in: m=%p size=%d\n", m, size)); /* * XXX: locking flub */ if (!(m->flags & M_RX)) return size; used = 0; mtx_lock(&m->qlock); #if 0 /* * Don't bother queuing if not in read mode. Discard everything and * return size so the caller doesn't freak out. */ if (!(m->flags & M_RX)) return size; for (i = sig = 0; i < size; i++) { data = buf[i]; enq = 0; if (data == MIDI_ACK) continue; switch (m->inq_state) { case MIDI_IN_START: if (MIDI_IS_STATUS(data)) { switch (data) { case 0xf0: /* Sysex */ m->inq_state = MIDI_IN_SYSEX; break; case 0xf1: /* MTC quarter frame */ case 0xf3: /* Song select */ m->inq_state = MIDI_IN_DATA; enq = 1; m->inq_left = 1; break; case 0xf2: /* Song position pointer */ m->inq_state = MIDI_IN_DATA; enq = 1; m->inq_left = 2; break; default: if (MIDI_IS_COMMON(data)) { enq = 1; sig = 1; } else { m->inq_state = MIDI_IN_DATA; enq = 1; m->inq_status = data; m->inq_left = MIDI_LENGTH(data); } break; } } else if (MIDI_IS_STATUS(m->inq_status)) { m->inq_state = MIDI_IN_DATA; if (!MIDIQ_FULL(m->inq)) { used++; MIDIQ_ENQ(m->inq, &m->inq_status, 1); } enq = 1; m->inq_left = MIDI_LENGTH(m->inq_status) - 1; } break; /* * End of case MIDI_IN_START: */ case MIDI_IN_DATA: enq = 1; if (--m->inq_left <= 0) sig = 1;/* deliver data */ break; case MIDI_IN_SYSEX: if (data == MIDI_SYSEX_END) m->inq_state = MIDI_IN_START; break; } if (enq) if (!MIDIQ_FULL(m->inq)) { MIDIQ_ENQ(m->inq, &data, 1); used++; } /* * End of the state machines main "for loop" */ } if (sig) { #endif MIDI_DEBUG(6, printf("midi_in: len %jd avail %jd\n", (intmax_t)MIDIQ_LEN(m->inq), (intmax_t)MIDIQ_AVAIL(m->inq))); if (MIDIQ_AVAIL(m->inq) > size) { used = size; MIDIQ_ENQ(m->inq, buf, size); } else { MIDI_DEBUG(4, printf("midi_in: Discarding data qu\n")); mtx_unlock(&m->qlock); return 0; } if (m->rchan) { wakeup(&m->rchan); m->rchan = 0; } selwakeup(&m->rsel); if (m->async) { PROC_LOCK(m->async); kern_psignal(m->async, SIGIO); PROC_UNLOCK(m->async); } #if 0 } #endif mtx_unlock(&m->qlock); return used; } /* * midi_out: The only clearer of the M_TXEN flag. */ int midi_out(struct snd_midi *m, uint8_t *buf, int size) { int used; /* * XXX: locking flub */ if (!(m->flags & M_TXEN)) return 0; MIDI_DEBUG(2, printf("midi_out: %p\n", m)); mtx_lock(&m->qlock); used = MIN(size, MIDIQ_LEN(m->outq)); MIDI_DEBUG(3, printf("midi_out: used %d\n", used)); if (used) MIDIQ_DEQ(m->outq, buf, used); if (MIDIQ_EMPTY(m->outq)) { m->flags &= ~M_TXEN; MPU_CALLBACKP(m, m->cookie, m->flags); } if (used && MIDIQ_AVAIL(m->outq) > m->hiwat) { if (m->wchan) { wakeup(&m->wchan); m->wchan = 0; } selwakeup(&m->wsel); if (m->async) { PROC_LOCK(m->async); kern_psignal(m->async, SIGIO); PROC_UNLOCK(m->async); } } mtx_unlock(&m->qlock); return used; } int midi_open(struct cdev *i_dev, int flags, int mode, struct thread *td) { struct snd_midi *m = i_dev->si_drv1; int retval; MIDI_DEBUG(1, printf("midiopen %p %s %s\n", td, flags & FREAD ? "M_RX" : "", flags & FWRITE ? "M_TX" : "")); if (m == NULL) return ENXIO; mtx_lock(&m->lock); mtx_lock(&m->qlock); retval = 0; if (flags & FREAD) { if (MIDIQ_SIZE(m->inq) == 0) retval = ENXIO; else if (m->flags & M_RX) retval = EBUSY; if (retval) goto err; } if (flags & FWRITE) { if (MIDIQ_SIZE(m->outq) == 0) retval = ENXIO; else if (m->flags & M_TX) retval = EBUSY; if (retval) goto err; } m->busy++; m->rchan = 0; m->wchan = 0; m->async = 0; if (flags & FREAD) { m->flags |= M_RX | M_RXEN; /* * Only clear the inq, the outq might still have data to drain * from a previous session */ MIDIQ_CLEAR(m->inq); } if (flags & FWRITE) m->flags |= M_TX; MPU_CALLBACK(m, m->cookie, m->flags); MIDI_DEBUG(2, printf("midi_open: opened.\n")); err: mtx_unlock(&m->qlock); mtx_unlock(&m->lock); return retval; } int midi_close(struct cdev *i_dev, int flags, int mode, struct thread *td) { struct snd_midi *m = i_dev->si_drv1; int retval; int oldflags; MIDI_DEBUG(1, printf("midi_close %p %s %s\n", td, flags & FREAD ? "M_RX" : "", flags & FWRITE ? "M_TX" : "")); if (m == NULL) return ENXIO; mtx_lock(&m->lock); mtx_lock(&m->qlock); if ((flags & FREAD && !(m->flags & M_RX)) || (flags & FWRITE && !(m->flags & M_TX))) { retval = ENXIO; goto err; } m->busy--; oldflags = m->flags; if (flags & FREAD) m->flags &= ~(M_RX | M_RXEN); if (flags & FWRITE) m->flags &= ~M_TX; if ((m->flags & (M_TXEN | M_RXEN)) != (oldflags & (M_RXEN | M_TXEN))) MPU_CALLBACK(m, m->cookie, m->flags); MIDI_DEBUG(1, printf("midi_close: closed, busy = %d.\n", m->busy)); mtx_unlock(&m->qlock); mtx_unlock(&m->lock); retval = 0; err: return retval; } /* * TODO: midi_read, per oss programmer's guide pg. 42 should return as soon * as data is available. */ int midi_read(struct cdev *i_dev, struct uio *uio, int ioflag) { #define MIDI_RSIZE 32 struct snd_midi *m = i_dev->si_drv1; int retval; int used; char buf[MIDI_RSIZE]; MIDI_DEBUG(5, printf("midiread: count=%lu\n", (unsigned long)uio->uio_resid)); retval = EIO; if (m == NULL) goto err0; mtx_lock(&m->lock); mtx_lock(&m->qlock); if (!(m->flags & M_RX)) goto err1; while (uio->uio_resid > 0) { while (MIDIQ_EMPTY(m->inq)) { retval = EWOULDBLOCK; if (ioflag & O_NONBLOCK) goto err1; mtx_unlock(&m->lock); m->rchan = 1; retval = msleep(&m->rchan, &m->qlock, PCATCH | PDROP, "midi RX", 0); /* * We slept, maybe things have changed since last * dying check */ if (retval == EINTR) goto err0; if (m != i_dev->si_drv1) retval = ENXIO; /* if (retval && retval != ERESTART) */ if (retval) goto err0; mtx_lock(&m->lock); mtx_lock(&m->qlock); m->rchan = 0; if (!m->busy) goto err1; } MIDI_DEBUG(6, printf("midi_read start\n")); /* * At this point, it is certain that m->inq has data */ used = MIN(MIDIQ_LEN(m->inq), uio->uio_resid); used = MIN(used, MIDI_RSIZE); MIDI_DEBUG(6, printf("midiread: uiomove cc=%d\n", used)); MIDIQ_DEQ(m->inq, buf, used); retval = uiomove(buf, used, uio); if (retval) goto err1; } /* * If we Made it here then transfer is good */ retval = 0; err1: mtx_unlock(&m->qlock); mtx_unlock(&m->lock); err0: MIDI_DEBUG(4, printf("midi_read: ret %d\n", retval)); return retval; } /* * midi_write: The only setter of M_TXEN */ int midi_write(struct cdev *i_dev, struct uio *uio, int ioflag) { #define MIDI_WSIZE 32 struct snd_midi *m = i_dev->si_drv1; int retval; int used; char buf[MIDI_WSIZE]; MIDI_DEBUG(4, printf("midi_write\n")); retval = 0; if (m == NULL) goto err0; mtx_lock(&m->lock); mtx_lock(&m->qlock); if (!(m->flags & M_TX)) goto err1; while (uio->uio_resid > 0) { while (MIDIQ_AVAIL(m->outq) == 0) { retval = EWOULDBLOCK; if (ioflag & O_NONBLOCK) goto err1; mtx_unlock(&m->lock); m->wchan = 1; MIDI_DEBUG(3, printf("midi_write msleep\n")); retval = msleep(&m->wchan, &m->qlock, PCATCH | PDROP, "midi TX", 0); /* * We slept, maybe things have changed since last * dying check */ if (retval == EINTR) goto err0; if (m != i_dev->si_drv1) retval = ENXIO; if (retval) goto err0; mtx_lock(&m->lock); mtx_lock(&m->qlock); m->wchan = 0; if (!m->busy) goto err1; } /* * We are certain than data can be placed on the queue */ used = MIN(MIDIQ_AVAIL(m->outq), uio->uio_resid); used = MIN(used, MIDI_WSIZE); MIDI_DEBUG(5, printf("midiout: resid %zd len %jd avail %jd\n", uio->uio_resid, (intmax_t)MIDIQ_LEN(m->outq), (intmax_t)MIDIQ_AVAIL(m->outq))); MIDI_DEBUG(5, printf("midi_write: uiomove cc=%d\n", used)); retval = uiomove(buf, used, uio); if (retval) goto err1; MIDIQ_ENQ(m->outq, buf, used); /* * Inform the bottom half that data can be written */ if (!(m->flags & M_TXEN)) { m->flags |= M_TXEN; MPU_CALLBACK(m, m->cookie, m->flags); } } /* * If we Made it here then transfer is good */ retval = 0; err1: mtx_unlock(&m->qlock); mtx_unlock(&m->lock); err0: return retval; } int midi_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) { return ENXIO; } int midi_poll(struct cdev *i_dev, int events, struct thread *td) { struct snd_midi *m = i_dev->si_drv1; int revents; if (m == NULL) return 0; revents = 0; mtx_lock(&m->lock); mtx_lock(&m->qlock); if (events & (POLLIN | POLLRDNORM)) if (!MIDIQ_EMPTY(m->inq)) events |= events & (POLLIN | POLLRDNORM); if (events & (POLLOUT | POLLWRNORM)) if (MIDIQ_AVAIL(m->outq) < m->hiwat) events |= events & (POLLOUT | POLLWRNORM); if (revents == 0) { if (events & (POLLIN | POLLRDNORM)) selrecord(td, &m->rsel); if (events & (POLLOUT | POLLWRNORM)) selrecord(td, &m->wsel); } mtx_unlock(&m->lock); mtx_unlock(&m->qlock); return (revents); } /* * Single point of midi destructions. */ static int midi_destroy(struct snd_midi *m, int midiuninit) { midistat_lockassert(); mtx_assert(&m->lock, MA_OWNED); MIDI_DEBUG(3, printf("midi_destroy\n")); m->dev->si_drv1 = NULL; mtx_unlock(&m->lock); /* XXX */ destroy_dev(m->dev); TAILQ_REMOVE(&midi_devs, m, link); if (midiuninit) MPU_UNINIT(m, m->cookie); free(MIDIQ_BUF(m->inq), M_MIDI); free(MIDIQ_BUF(m->outq), M_MIDI); mtx_destroy(&m->qlock); mtx_destroy(&m->lock); free(m, M_MIDI); return 0; } static int midi_load(void) { sx_init(&mstat_lock, "midistat lock"); TAILQ_INIT(&midi_devs); return 0; } static int midi_unload(void) { struct snd_midi *m, *tmp; int retval; MIDI_DEBUG(1, printf("midi_unload()\n")); retval = EBUSY; midistat_lock(); TAILQ_FOREACH_SAFE(m, &midi_devs, link, tmp) { mtx_lock(&m->lock); if (m->busy) retval = EBUSY; else retval = midi_destroy(m, 1); if (retval) goto exit; } midistat_unlock(); sx_destroy(&mstat_lock); return 0; exit: mtx_unlock(&m->lock); midistat_unlock(); if (retval) MIDI_DEBUG(2, printf("midi_unload: failed\n")); return retval; } static int midi_modevent(module_t mod, int type, void *data) { int retval; retval = 0; switch (type) { case MOD_LOAD: retval = midi_load(); break; case MOD_UNLOAD: retval = midi_unload(); break; default: break; } return retval; } DEV_MODULE(midi, midi_modevent, NULL); MODULE_VERSION(midi, 1); diff --git a/sys/dev/sound/midi/mpu401.c b/sys/dev/sound/midi/mpu401.c index 224ebb1b01f4..af3149ec8180 100644 --- a/sys/dev/sound/midi/mpu401.c +++ b/sys/dev/sound/midi/mpu401.c @@ -1,254 +1,250 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Mathew Kanner * All rights reserved. * * Redistribution and use in source and binary forms, with or without * 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. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include /* to get driver_intr_t */ #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_snd.h" #endif #include #include #include "mpu_if.h" #include "mpufoi_if.h" -#ifndef KOBJMETHOD_END -#define KOBJMETHOD_END { NULL, NULL } -#endif - #define MPU_DATAPORT 0 #define MPU_CMDPORT 1 #define MPU_STATPORT 1 #define MPU_RESET 0xff #define MPU_UART 0x3f #define MPU_ACK 0xfe #define MPU_STATMASK 0xc0 #define MPU_OUTPUTBUSY 0x40 #define MPU_INPUTBUSY 0x80 #define MPU_TRYDATA 50 #define MPU_DELAY 2500 #define CMD(m,d) MPUFOI_WRITE(m, m->cookie, MPU_CMDPORT,d) #define STATUS(m) MPUFOI_READ(m, m->cookie, MPU_STATPORT) #define READ(m) MPUFOI_READ(m, m->cookie, MPU_DATAPORT) #define WRITE(m,d) MPUFOI_WRITE(m, m->cookie, MPU_DATAPORT,d) struct mpu401 { KOBJ_FIELDS; struct snd_midi *mid; int flags; driver_intr_t *si; void *cookie; struct callout timer; }; static void mpu401_timeout(void *m); static mpu401_intr_t mpu401_intr; static int mpu401_minit(struct snd_midi *, void *); static int mpu401_muninit(struct snd_midi *, void *); static int mpu401_minqsize(struct snd_midi *, void *); static int mpu401_moutqsize(struct snd_midi *, void *); static void mpu401_mcallback(struct snd_midi *, void *, int); static void mpu401_mcallbackp(struct snd_midi *, void *, int); static kobj_method_t mpu401_methods[] = { KOBJMETHOD(mpu_init, mpu401_minit), KOBJMETHOD(mpu_uninit, mpu401_muninit), KOBJMETHOD(mpu_inqsize, mpu401_minqsize), KOBJMETHOD(mpu_outqsize, mpu401_moutqsize), KOBJMETHOD(mpu_callback, mpu401_mcallback), KOBJMETHOD(mpu_callbackp, mpu401_mcallbackp), KOBJMETHOD_END }; DEFINE_CLASS(mpu401, mpu401_methods, 0); void mpu401_timeout(void *a) { struct mpu401 *m = (struct mpu401 *)a; if (m->si) (m->si)(m->cookie); } static int mpu401_intr(struct mpu401 *m) { #define MPU_INTR_BUF 16 uint8_t b[MPU_INTR_BUF]; int i; int s; #define RXRDY(m) ( (STATUS(m) & MPU_INPUTBUSY) == 0) #define TXRDY(m) ( (STATUS(m) & MPU_OUTPUTBUSY) == 0) i = 0; s = STATUS(m); while ((s & MPU_INPUTBUSY) == 0 && i < MPU_INTR_BUF) { b[i] = READ(m); i++; s = STATUS(m); } if (i) midi_in(m->mid, b, i); i = 0; while (!(s & MPU_OUTPUTBUSY) && i < MPU_INTR_BUF) { if (midi_out(m->mid, b, 1)) { WRITE(m, *b); } else { return 0; } i++; /* DELAY(100); */ s = STATUS(m); } if ((m->flags & M_TXEN) && (m->si)) { callout_reset(&m->timer, 1, mpu401_timeout, m); } return (m->flags & M_TXEN) == M_TXEN; } struct mpu401 * mpu401_init(kobj_class_t cls, void *cookie, driver_intr_t softintr, mpu401_intr_t ** cb) { struct mpu401 *m; *cb = NULL; m = malloc(sizeof(*m), M_MIDI, M_NOWAIT | M_ZERO); if (!m) return NULL; kobj_init((kobj_t)m, cls); callout_init(&m->timer, 1); m->si = softintr; m->cookie = cookie; m->flags = 0; m->mid = midi_init(&mpu401_class, 0, 0, m); if (!m->mid) goto err; *cb = mpu401_intr; return m; err: printf("mpu401_init error\n"); free(m, M_MIDI); return NULL; } int mpu401_uninit(struct mpu401 *m) { int retval; CMD(m, MPU_RESET); retval = midi_uninit(m->mid); if (retval) return retval; free(m, M_MIDI); return 0; } static int mpu401_minit(struct snd_midi *sm, void *arg) { struct mpu401 *m = arg; int i; CMD(m, MPU_RESET); CMD(m, MPU_UART); return 0; i = 0; while (++i < 2000) { if (RXRDY(m)) if (READ(m) == MPU_ACK) break; } if (i < 2000) { CMD(m, MPU_UART); return 0; } printf("mpu401_minit failed active sensing\n"); return 1; } int mpu401_muninit(struct snd_midi *sm, void *arg) { struct mpu401 *m = arg; return MPUFOI_UNINIT(m, m->cookie); } int mpu401_minqsize(struct snd_midi *sm, void *arg) { return 128; } int mpu401_moutqsize(struct snd_midi *sm, void *arg) { return 128; } static void mpu401_mcallback(struct snd_midi *sm, void *arg, int flags) { struct mpu401 *m = arg; if (flags & M_TXEN && m->si) { callout_reset(&m->timer, 1, mpu401_timeout, m); } m->flags = flags; } static void mpu401_mcallbackp(struct snd_midi *sm, void *arg, int flags) { mpu401_mcallback(sm, arg, flags); } diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index 75fb57e33733..c5107d5fba1c 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -1,504 +1,500 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005-2009 Ariff Abdullah * Copyright (c) 1999 Cameron Grant * Copyright (c) 1995 Hannu Savolainen * All rights reserved. * Copyright (c) 2024-2025 The FreeBSD Foundation * * Portions of this software were developed by Christos Margiolis * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * 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. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * first, include kernel header files. */ #ifndef _OS_H_ #define _OS_H_ #ifdef _KERNEL #include #include #include #include #include #include #include #include #include #include /* for DATA_SET */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#ifndef KOBJMETHOD_END -#define KOBJMETHOD_END { NULL, NULL } -#endif - struct pcm_channel; struct pcm_feeder; struct snd_dbuf; struct snd_mixer; #include #include #include #include #include #include #define PCM_SOFTC_SIZE (sizeof(struct snddev_info)) #define SND_STATUSLEN 64 #define SOUND_MODVER 5 #define SOUND_MINVER SOUND_MODVER #define SOUND_PREFVER SOUND_MODVER #define SOUND_MAXVER SOUND_MODVER #define SD_F_SIMPLEX 0x00000001 /* unused 0x00000002 */ #define SD_F_SOFTPCMVOL 0x00000004 #define SD_F_BUSY 0x00000008 #define SD_F_MPSAFE 0x00000010 #define SD_F_REGISTERED 0x00000020 #define SD_F_BITPERFECT 0x00000040 #define SD_F_VPC 0x00000080 /* volume-per-channel */ #define SD_F_EQ 0x00000100 /* EQ */ #define SD_F_EQ_ENABLED 0x00000200 /* EQ enabled */ #define SD_F_EQ_BYPASSED 0x00000400 /* EQ bypassed */ #define SD_F_EQ_PC 0x00000800 /* EQ per-channel */ #define SD_F_PVCHANS 0x00001000 /* Playback vchans enabled */ #define SD_F_RVCHANS 0x00002000 /* Recording vchans enabled */ #define SD_F_EQ_DEFAULT (SD_F_EQ | SD_F_EQ_ENABLED) #define SD_F_EQ_MASK (SD_F_EQ | SD_F_EQ_ENABLED | \ SD_F_EQ_BYPASSED | SD_F_EQ_PC) #define SD_F_BITS "\020" \ "\001SIMPLEX" \ /* "\002 */ \ "\003SOFTPCMVOL" \ "\004BUSY" \ "\005MPSAFE" \ "\006REGISTERED" \ "\007BITPERFECT" \ "\010VPC" \ "\011EQ" \ "\012EQ_ENABLED" \ "\013EQ_BYPASSED" \ "\014EQ_PC" \ "\015PVCHANS" \ "\016RVCHANS" #define PCM_ALIVE(x) ((x) != NULL && (x)->lock != NULL) #define PCM_REGISTERED(x) (PCM_ALIVE(x) && ((x)->flags & SD_F_REGISTERED)) #define PCM_MAXCHANS 10000 #define PCM_CHANCOUNT(d) \ (d->playcount + d->pvchancount + d->reccount + d->rvchancount) /* many variables should be reduced to a range. Here define a macro */ #define RANGE(var, low, high) (var) = \ (((var)<(low))? (low) : ((var)>(high))? (high) : (var)) extern int snd_unit; extern int snd_verbose; extern devclass_t pcm_devclass; extern struct unrhdr *pcmsg_unrhdr; #ifndef DEB #define DEB(x) #endif SYSCTL_DECL(_hw_snd); int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo); unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz); void pcm_init(device_t dev, void *devinfo); int pcm_register(device_t dev, char *str); int pcm_unregister(device_t dev); u_int32_t pcm_getflags(device_t dev); void pcm_setflags(device_t dev, u_int32_t val); void *pcm_getdevinfo(device_t dev); int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep); void *snd_mtxcreate(const char *desc, const char *type); void snd_mtxfree(void *m); void snd_mtxassert(void *m); #define snd_mtxlock(m) mtx_lock(m) #define snd_mtxunlock(m) mtx_unlock(m) int sndstat_register(device_t dev, char *str); int sndstat_unregister(device_t dev); /* These are the function codes assigned to the children of sound cards. */ enum { SCF_PCM, SCF_MIDI, }; /* * This is the device information struct, used by a bridge device to pass the * device function code to the children. */ struct sndcard_func { int func; /* The function code. */ void *varinfo; /* Bridge-specific information. */ }; /* * this is rather kludgey- we need to duplicate these struct def'ns from sound.c * so that the macro versions of pcm_{,un}lock can dereference them. * we also have to do this now makedev() has gone away. */ struct snddev_info { struct { struct { SLIST_HEAD(, pcm_channel) head; struct { SLIST_HEAD(, pcm_channel) head; } busy; struct { SLIST_HEAD(, pcm_channel) head; } opened; struct { SLIST_HEAD(, pcm_channel) head; } primary; } pcm; } channels; unsigned playcount, reccount, pvchancount, rvchancount; unsigned flags; unsigned int bufsz; void *devinfo; device_t dev; char status[SND_STATUSLEN]; struct mtx *lock; struct cdev *mixer_dev; struct cdev *dsp_dev; uint32_t pvchanrate, pvchanformat, pvchanmode; uint32_t rvchanrate, rvchanformat, rvchanmode; int32_t eqpreamp; struct sysctl_ctx_list play_sysctl_ctx, rec_sysctl_ctx; struct sysctl_oid *play_sysctl_tree, *rec_sysctl_tree; struct cv cv; struct unrhdr *p_unr; struct unrhdr *vp_unr; struct unrhdr *r_unr; struct unrhdr *vr_unr; }; void sound_oss_sysinfo(oss_sysinfo *); int sound_oss_card_info(oss_card_info *); #define PCM_MODE_MIXER 0x01 #define PCM_MODE_PLAY 0x02 #define PCM_MODE_REC 0x04 #define PCM_LOCKOWNED(d) mtx_owned((d)->lock) #define PCM_LOCK(d) mtx_lock((d)->lock) #define PCM_UNLOCK(d) mtx_unlock((d)->lock) #define PCM_TRYLOCK(d) mtx_trylock((d)->lock) #define PCM_LOCKASSERT(d) mtx_assert((d)->lock, MA_OWNED) #define PCM_UNLOCKASSERT(d) mtx_assert((d)->lock, MA_NOTOWNED) /* * For PCM_[WAIT | ACQUIRE | RELEASE], be sure to surround these * with PCM_LOCK/UNLOCK() sequence, or I'll come to gnaw upon you! */ #ifdef SND_DIAGNOSTIC #define PCM_WAIT(x) do { \ if (!PCM_LOCKOWNED(x)) \ panic("%s(%d): [PCM WAIT] Mutex not owned!", \ __func__, __LINE__); \ while ((x)->flags & SD_F_BUSY) { \ if (snd_verbose > 3) \ device_printf((x)->dev, \ "%s(%d): [PCM WAIT] calling cv_wait().\n", \ __func__, __LINE__); \ cv_wait(&(x)->cv, (x)->lock); \ } \ } while (0) #define PCM_ACQUIRE(x) do { \ if (!PCM_LOCKOWNED(x)) \ panic("%s(%d): [PCM ACQUIRE] Mutex not owned!", \ __func__, __LINE__); \ if ((x)->flags & SD_F_BUSY) \ panic("%s(%d): [PCM ACQUIRE] " \ "Trying to acquire BUSY cv!", __func__, __LINE__); \ (x)->flags |= SD_F_BUSY; \ } while (0) #define PCM_RELEASE(x) do { \ if (!PCM_LOCKOWNED(x)) \ panic("%s(%d): [PCM RELEASE] Mutex not owned!", \ __func__, __LINE__); \ if ((x)->flags & SD_F_BUSY) { \ (x)->flags &= ~SD_F_BUSY; \ cv_broadcast(&(x)->cv); \ } else \ panic("%s(%d): [PCM RELEASE] Releasing non-BUSY cv!", \ __func__, __LINE__); \ } while (0) /* Quick version, for shorter path. */ #define PCM_ACQUIRE_QUICK(x) do { \ if (PCM_LOCKOWNED(x)) \ panic("%s(%d): [PCM ACQUIRE QUICK] Mutex owned!", \ __func__, __LINE__); \ PCM_LOCK(x); \ PCM_WAIT(x); \ PCM_ACQUIRE(x); \ PCM_UNLOCK(x); \ } while (0) #define PCM_RELEASE_QUICK(x) do { \ if (PCM_LOCKOWNED(x)) \ panic("%s(%d): [PCM RELEASE QUICK] Mutex owned!", \ __func__, __LINE__); \ PCM_LOCK(x); \ PCM_RELEASE(x); \ PCM_UNLOCK(x); \ } while (0) #define PCM_BUSYASSERT(x) do { \ if (!((x) != NULL && ((x)->flags & SD_F_BUSY))) \ panic("%s(%d): [PCM BUSYASSERT] " \ "Failed, snddev_info=%p", __func__, __LINE__, x); \ } while (0) #define PCM_GIANT_ENTER(x) do { \ int _pcm_giant = 0; \ if (PCM_LOCKOWNED(x)) \ panic("%s(%d): [GIANT ENTER] PCM lock owned!", \ __func__, __LINE__); \ if (mtx_owned(&Giant) != 0 && snd_verbose > 3) \ device_printf((x)->dev, \ "%s(%d): [GIANT ENTER] Giant owned!\n", \ __func__, __LINE__); \ if (!((x)->flags & SD_F_MPSAFE) && mtx_owned(&Giant) == 0) \ do { \ mtx_lock(&Giant); \ _pcm_giant = 1; \ } while (0) #define PCM_GIANT_EXIT(x) do { \ if (PCM_LOCKOWNED(x)) \ panic("%s(%d): [GIANT EXIT] PCM lock owned!", \ __func__, __LINE__); \ if (!(_pcm_giant == 0 || _pcm_giant == 1)) \ panic("%s(%d): [GIANT EXIT] _pcm_giant screwed!", \ __func__, __LINE__); \ if ((x)->flags & SD_F_MPSAFE) { \ if (_pcm_giant == 1) \ panic("%s(%d): [GIANT EXIT] MPSAFE Giant?", \ __func__, __LINE__); \ if (mtx_owned(&Giant) != 0 && snd_verbose > 3) \ device_printf((x)->dev, \ "%s(%d): [GIANT EXIT] Giant owned!\n", \ __func__, __LINE__); \ } \ if (_pcm_giant != 0) { \ if (mtx_owned(&Giant) == 0) \ panic("%s(%d): [GIANT EXIT] Giant not owned!", \ __func__, __LINE__); \ _pcm_giant = 0; \ mtx_unlock(&Giant); \ } \ } while (0) #else /* !SND_DIAGNOSTIC */ #define PCM_WAIT(x) do { \ PCM_LOCKASSERT(x); \ while ((x)->flags & SD_F_BUSY) \ cv_wait(&(x)->cv, (x)->lock); \ } while (0) #define PCM_ACQUIRE(x) do { \ PCM_LOCKASSERT(x); \ KASSERT(!((x)->flags & SD_F_BUSY), \ ("%s(%d): [PCM ACQUIRE] Trying to acquire BUSY cv!", \ __func__, __LINE__)); \ (x)->flags |= SD_F_BUSY; \ } while (0) #define PCM_RELEASE(x) do { \ PCM_LOCKASSERT(x); \ KASSERT((x)->flags & SD_F_BUSY, \ ("%s(%d): [PCM RELEASE] Releasing non-BUSY cv!", \ __func__, __LINE__)); \ (x)->flags &= ~SD_F_BUSY; \ cv_broadcast(&(x)->cv); \ } while (0) /* Quick version, for shorter path. */ #define PCM_ACQUIRE_QUICK(x) do { \ PCM_UNLOCKASSERT(x); \ PCM_LOCK(x); \ PCM_WAIT(x); \ PCM_ACQUIRE(x); \ PCM_UNLOCK(x); \ } while (0) #define PCM_RELEASE_QUICK(x) do { \ PCM_UNLOCKASSERT(x); \ PCM_LOCK(x); \ PCM_RELEASE(x); \ PCM_UNLOCK(x); \ } while (0) #define PCM_BUSYASSERT(x) KASSERT(x != NULL && \ ((x)->flags & SD_F_BUSY), \ ("%s(%d): [PCM BUSYASSERT] " \ "Failed, snddev_info=%p", \ __func__, __LINE__, x)) #define PCM_GIANT_ENTER(x) do { \ int _pcm_giant = 0; \ PCM_UNLOCKASSERT(x); \ if (!((x)->flags & SD_F_MPSAFE) && mtx_owned(&Giant) == 0) \ do { \ mtx_lock(&Giant); \ _pcm_giant = 1; \ } while (0) #define PCM_GIANT_EXIT(x) do { \ PCM_UNLOCKASSERT(x); \ KASSERT(_pcm_giant == 0 || _pcm_giant == 1, \ ("%s(%d): [GIANT EXIT] _pcm_giant screwed!", \ __func__, __LINE__)); \ KASSERT(!((x)->flags & SD_F_MPSAFE) || \ (((x)->flags & SD_F_MPSAFE) && _pcm_giant == 0), \ ("%s(%d): [GIANT EXIT] MPSAFE Giant?", \ __func__, __LINE__)); \ if (_pcm_giant != 0) { \ mtx_assert(&Giant, MA_OWNED); \ _pcm_giant = 0; \ mtx_unlock(&Giant); \ } \ } while (0) #endif /* SND_DIAGNOSTIC */ #define PCM_GIANT_LEAVE(x) \ PCM_GIANT_EXIT(x); \ } while (0) #endif /* _KERNEL */ /* make figuring out what a format is easier. got AFMT_STEREO already */ #define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE | \ AFMT_F32_LE | AFMT_F32_BE) #define AFMT_24BIT (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE) #define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE) #define AFMT_G711 (AFMT_MU_LAW | AFMT_A_LAW) #define AFMT_8BIT (AFMT_G711 | AFMT_U8 | AFMT_S8) #define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_F32_LE | AFMT_F32_BE | \ AFMT_S24_LE | AFMT_S24_BE | \ AFMT_S16_LE | AFMT_S16_BE | AFMT_S8) #define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_F32_BE | \ AFMT_S24_BE | AFMT_U24_BE | AFMT_S16_BE | AFMT_U16_BE) #define AFMT_CONVERTIBLE (AFMT_8BIT | AFMT_16BIT | AFMT_24BIT | \ AFMT_32BIT) /* Supported vchan mixing formats */ #define AFMT_VCHAN (AFMT_CONVERTIBLE & ~AFMT_G711) #define AFMT_PASSTHROUGH AFMT_AC3 #define AFMT_PASSTHROUGH_RATE 48000 #define AFMT_PASSTHROUGH_CHANNEL 2 #define AFMT_PASSTHROUGH_EXTCHANNEL 0 /* * We're simply using unused, contiguous bits from various AFMT_ definitions. * ~(0xb00ff7ff) */ #define AFMT_ENCODING_MASK 0xf00fffff #define AFMT_CHANNEL_MASK 0x07f00000 #define AFMT_CHANNEL_SHIFT 20 #define AFMT_CHANNEL_MAX 0x7f #define AFMT_EXTCHANNEL_MASK 0x08000000 #define AFMT_EXTCHANNEL_SHIFT 27 #define AFMT_EXTCHANNEL_MAX 1 #define AFMT_ENCODING(v) ((v) & AFMT_ENCODING_MASK) #define AFMT_EXTCHANNEL(v) (((v) & AFMT_EXTCHANNEL_MASK) >> \ AFMT_EXTCHANNEL_SHIFT) #define AFMT_CHANNEL(v) (((v) & AFMT_CHANNEL_MASK) >> \ AFMT_CHANNEL_SHIFT) #define AFMT_BIT(v) (((v) & AFMT_32BIT) ? 32 : \ (((v) & AFMT_24BIT) ? 24 : \ ((((v) & AFMT_16BIT) || \ ((v) & AFMT_PASSTHROUGH)) ? 16 : 8))) #define AFMT_BPS(v) (AFMT_BIT(v) >> 3) #define AFMT_ALIGN(v) (AFMT_BPS(v) * AFMT_CHANNEL(v)) #define SND_FORMAT(f, c, e) (AFMT_ENCODING(f) | \ (((c) << AFMT_CHANNEL_SHIFT) & \ AFMT_CHANNEL_MASK) | \ (((e) << AFMT_EXTCHANNEL_SHIFT) & \ AFMT_EXTCHANNEL_MASK)) #define AFMT_U8_NE AFMT_U8 #define AFMT_S8_NE AFMT_S8 #define AFMT_SIGNED_NE (AFMT_S8_NE | AFMT_S16_NE | AFMT_S24_NE | \ AFMT_S32_NE | AFMT_F32_NE) #define AFMT_NE (AFMT_SIGNED_NE | AFMT_U8_NE | AFMT_U16_NE | \ AFMT_U24_NE | AFMT_U32_NE) #endif /* _OS_H_ */