Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/midi_if.h
RevisionDateAuthorComments
 1.27  01-Mar-2015  mrg fix some comments about MP midi.
 1.26  21-Dec-2014  mrg fix the midi_if documentation to properly describe the locks that will
be held during various operations.
 1.25  09-Apr-2012  plunky branches: 1.25.14; 1.25.16;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.24  24-Nov-2011  mrg branches: 1.24.2;
begin to document the per-midi call backs and locking.

XXX: lots more to do.
 1.23  23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.22  07-Apr-2009  dyoung branches: 1.22.12; 1.22.14;
Declare mididetach() for use by midi0 at pcppi0.
 1.21  28-Apr-2008  martin branches: 1.21.8; 1.21.12; 1.21.14;
Remove clause 3 and 4 from TNF licenses
 1.20  04-Mar-2008  cube branches: 1.20.2; 1.20.4;
Split device_t/softc for midi(4), and other related cosmetic changes.
 1.19  04-Mar-2007  christos branches: 1.19.16; 1.19.32; 1.19.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18  30-Jun-2006  chap branches: 1.18.10; 1.18.12;
Ankh-Morpork, we have a MIDI driver....

Merge from chap-midi branch, after
~month for review
Comments by thorpej@ drochner@ and Alexandre Ratchov

Incorporated: points by thorpej@ drochner@; preliminary support for
a stats-collecting ioctl suggested by martin@ from comments by A.R.

PR kern/32441 kern/32442 kern/32567 kern/32588 kern/32694 kern/33590
kern/33614 and one instance of kern/32651

ok martin@
 1.17  11-Dec-2005  christos branches: 1.17.4; 1.17.8; 1.17.14; 1.17.16;
merge ktrace-lwp.
 1.16  29-May-2005  christos branches: 1.16.2;
- add const
- avoid variable shadowing.
 1.15  27-Feb-2005  perry nuke trailing whitespace
 1.14  29-Oct-2004  yamt branches: 1.14.4; 1.14.6;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.13  04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.12  29-Jun-2003  fvdl branches: 1.12.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.11  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.10  02-Oct-2001  augustss ANSIfy.
 1.9  07-Jul-2000  wrstuden branches: 1.9.2; 1.9.4; 1.9.6;
Define splaudio as splbio and IPL_AUDIO as IPL_BIO only if IPL_AUDIO
is not defined. Previously tested for specific system architectures (i386,
etc.) rather than just looking for IPL_AUDIO.
 1.8  21-Mar-2000  garbled branches: 1.8.4;
Fix this again. This time only for prep, and not all of powerpc, which
broke macppc.
 1.7  21-Mar-2000  garbled Back this out and rethink..
 1.6  21-Mar-2000  garbled Allow kernels to compile again for prep. Patch supplied by nonaka.
 1.5  09-Sep-1999  augustss branches: 1.5.2;
Add support for detaching audio devices.
 1.4  22-Mar-1999  mycroft Do the splaudio()/IPL_AUDIO hack here, too, so that MPU attachments can see
it.
 1.3  25-Nov-1998  augustss Make the copyright header conform to the NetBSD template.
 1.2  24-Aug-1998  augustss Write MIDI data from the sequencer to the device in a more sane way.
 1.1  17-Aug-1998  augustss * Redo the way the way the MIDI driver attaches to audio devices.
* Improve the midisyn layer a little.
* Add a driver for the Yamaha OPL[23] FM synths.
The opl driver is not finished yet; it sounds pretty awful.

For some strange reason I cannot get any FM sound from my SB64 cards,
but a regular SB16 works fine.
 1.5.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.4.1  24-Jul-2000  wrstuden Pull in rev 1.8 -> 1.9. Rather than special case ports which have
an IPL_AUDIO, test for it. Approved by thorpej.
 1.9.6.1  11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.9.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.1  08-Oct-2001  nathanw Catch up to -current.
 1.12.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.2.5  02-Nov-2004  skrll Sync with HEAD.
 1.12.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.12.2.2  03-Aug-2004  skrll Sync with HEAD
 1.12.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.14.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.4.1  29-Apr-2005  kent sync with -current
 1.16.2.4  17-Mar-2008  yamt sync with head.
 1.16.2.3  03-Sep-2007  yamt sync with head.
 1.16.2.2  30-Dec-2006  yamt sync with head.
 1.16.2.1  21-Jun-2006  yamt sync with head.
 1.17.16.1  13-Jul-2006  gdamore Merge from HEAD.
 1.17.14.13  31-May-2006  chap Allow getinfo (and therefore midiplay -l) to reveal something useful for
umidi devices.

Annotate devices that lack output interrupts in the dmesg with (cpu-
intensive output) so users can easily tell which ones to prefer for
bulk output.
 1.17.14.12  30-May-2006  chap A flag is added to the midi_hw_if_ext struct for the hardware to specify
that it would like compression of data to be transmitted. It will still
receive a message at a time, with the status and channel passed as
arguments, but the message buffer will omit the status byte when possible.
umidi now uses this flag when talking to Midiman devices, which do not do
their own compression, so as to make best use of the MIDI 1.0 bandwidth on
the far side.
 1.17.14.11  26-May-2006  chap Guard against having to invent /another/ interface-extension hack at some
future time....
 1.17.14.10  20-May-2006  chap Now for Phase Two. The patched files have been rolled forward again, with
a naive mechanical resolution of conflicts. Now to compare the diffs and
make sure the resolutions made sense. Sleep first.
 1.17.14.9  20-May-2006  chap Learned of two ugly corners in MIDI protocol that made the state machine
overly pedantic. Both have to do with the End SysEx byte, 0xf7. First, it
is allowed not only at the end of a SysEx message, but anywhere else any
status byte can appear (and in that case has no meaning). Second, it is
not even required at the end of a SysEx message - any subsequent status
byte implicitly ends the SysEx, and this is not considered an error.

I don't like these provisions because they make it even harder to detect
errors in a corrupted MIDI stream, but as MIDI gets sent increasingly over
error-correcting transports I suppose that is less of a concern. In any
case, though midi(4) will accept data (input from device or data from
write(2)) with stray or dropped End SysEx bytes, it will always ensure
that output to the device, and data for read(2), has End SysEx only and
always at the ends of SysEx messages.
 1.17.14.8  20-May-2006  chap Spotted a bug in a buffer condition. Never saw any symptom, but it's a
bug nonetheless.
 1.17.14.7  20-May-2006  chap The two choices CN_SEQ_GLOBAL and CN_SEQ_PER_EP cannot cover all devices,
some are wired arbitrarily oddly and need a CN_FIXED quirk to specify
the cable number mappings explicitly. But then as a result of those
mappings, the automatically bound mididevice unit numbers might not match
the order of the device's physical jacks or blinkenlights, so an MD_FIXED
quirk is needed to specify that order as well. It turns out the cn_base
field added earlier was neither necessary (at the time) nor sufficient
(to handle CN_FIXED), so it's gone now.

Q: How do you tell when you've got the cable number associations wrong on
a Midisport 2x4?
A: Everything works right except data-rate throttling - you'll be able to
send data to certain ports at rates far in excess of the MIDI data rate
(and lose most of it). If you never transmit that fast, you'll never
notice.

So testing for a sane data transfer rate (use dd to blast a stream of MIDI
data at the rmidi device, it'll report the rate on completion) is probably
a wise testing step when adding support for a new umidi device.
 1.17.14.6  20-May-2006  chap Patch to account explicitly for the prior inconsistency in the treatment of
cable numbers. Also contains a (functionally insignificant) change to the
declaration of endpoint buffers introduced in kern/32441, which will be
useful in a forthcoming patch. This patch should be fuzz-free on 2.0
source after the 32441 and 32442 patches.
 1.17.14.5  20-May-2006  chap Active Sense now handled for receive as well as for transmit. Following the
spec, if no Active Sense is seen on receive, no special behavior applies,
but if an Active Sense is seen then any absence of received data exceeding
300ms thereafter will be signalled as a read EOF on the rmidi device.
Receipt of any further data will clear the EOF condition, and operation
resumes as if no Active Sense has been seen.

Also moved some selnotify's out of locks so they don't deadlock against
the corresponding kevent filters.

This concludes this round of midi hacking (except for possibly improving
the safety of how pending callouts and interrupts are canceled on device
detach. Other fixes/enhancements to the midi subsystems will get their
own patches.
 1.17.14.4  20-May-2006  chap The FST now handles the equivalence between NoteOn (velocity 0) and a
NoteOff with velocity 64, both for canonicalizing (always produce NoteOff)
and compressing (produce whichever allows a current running status to be
exploited). The code from sequencer that attempted to model this behavior
and running status has been superseded and removed. Also removed the
EBADF checks I added to sequencer earlier, as they're handled in a layer
above.
 1.17.14.3  20-May-2006  chap umidi now uses hw_if_ext and no longer has its own approximate midi state
machine. This patch is relative to umidi.c and umidivar.h already patched
by midiman.pat (kern/32441).
 1.17.14.2  20-May-2006  chap Added hw_if_ext for hw drivers that want their messages intact rather than
byte by byte. Works with midisyn - must still integrate and test with
umidi.
 1.17.14.1  20-May-2006  chap Now for Phase One. The patches to be applied in sequence were created
and tested against 2.0 sources. To begin, let CVS roll the affected files
back to that historic state. The reverse operation will be used (and
will involve some manual merging) after the patches have been applied.
Naturally, intermediate stages on this branch will not be directly
compilable (unless merged into a 2.0 checkout).
 1.17.8.1  11-Aug-2006  yamt sync with head
 1.17.4.1  09-Sep-2006  rpaulo sync with head
 1.18.12.1  27-Feb-2007  ad Add MP locking for audio drivers.
 1.18.10.1  12-Mar-2007  rmind Sync with HEAD.
 1.19.36.2  02-Jun-2008  mjf Sync with HEAD.
 1.19.36.1  03-Apr-2008  mjf Sync with HEAD.
 1.19.32.1  24-Mar-2008  keiichi sync with head.
 1.19.16.1  23-Mar-2008  matt sync with HEAD
 1.20.4.2  04-May-2009  yamt sync with head.
 1.20.4.1  16-May-2008  yamt sync with head.
 1.20.2.1  18-May-2008  yamt sync with head.
 1.21.14.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.12.1  09-Dec-2008  ad Checkpoint work on MIDI.
 1.21.8.1  28-Apr-2009  skrll Sync with HEAD.
 1.22.14.1  19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.22.12.1  17-Apr-2012  yamt sync with head
 1.24.2.1  29-Apr-2012  mrg sync to latest -current.
 1.25.16.1  06-Apr-2015  skrll Sync with HEAD
 1.25.14.1  11-Jan-2015  martin Pull up following revision(s) (requested by mrg in ticket #407):
sys/dev/midivar.h: revision 1.20
sys/dev/usb/umidivar.h: file removal
sys/dev/midi.c: revision 1.82
sys/dev/midi.c: revision 1.83
sys/dev/usb/FILES: revision 1.13
sys/dev/midi_if.h: revision 1.26
sys/dev/sequencer.c: revision 1.60
sys/dev/sequencer.c: revision 1.61
sys/dev/sequencer.c: revision 1.62
sys/dev/sequencer.c: revision 1.63
sys/dev/usb/umidi_quirks.c: revision 1.19
sys/dev/usb/umidi.c: revision 1.66
sys/dev/usb/umidi.c: revision 1.67
sys/dev/usb/umidi.c: revision 1.68
sys/dev/usb/umidireg.h: file removal
sys/dev/sequencervar.h: revision 1.17
fix the midi_if documentation to properly describe the locks that will
be held during various operations.
various umidi clean ups:
- move the contents of umidi{reg,var}.h into umidi.c directly as they
are not referenced by any other file.
- remove the useless include of umidi{reg,var}.h from umidi_quirks.c.
- add reference counting and wait/broadcast support to the IO paths.
- fix the error handling in midi_attach() and midi_open().
- sprinkle KASSERT() in several places.
- drop the local interrupt lock before calling into various parts of
the USB code. fixes lockdebug issues, and likely hangs.
- rename "binded" member as "bound".
with these most of the panics and problems i've seen are gone. there
is still one lockdebug panic to deal with that happens when unplugging
umidi while midiplay(1) is running.
various clean ups for midi and sequencer:
midi specific:
- add reference counting for midi operations, and ensure that
detach waits for other threads to complete before tearing
down the device completely.
- in detach, halt midi callouts before destroying them
- re-check sc->dying after sleeping in midiread()
- in real_writebytes(), make sure we're open and not dying
- make sure we drop the interrupt lock before calling any code
that may want to check thread locks. this is now safe due to
the above changes.
sequencer specific:
- avoid caching the midi softc in the sequencer softc. instead,
every time we want to use it, look it up again and make sure
it still exists.
this fixes various crashes i've seen in the usb midi code when
detaching the umidi while it is active.
use __func__ in some debug messages.
- check sc->dying after sleeping in several more places, and
convert it into EIO error where necessary.
- remove a wrong additional mutex_exit() call.
- make sure to check sc->dying under the device lock.
- fix a confusion between midi(4) unit and connected to sequencer
devices.
- minor comment/debug clean ups.
fixes problems attempting to read or write from the right midi(4)
device using the sequencer(4) device when one or more of the
non-final devices fails to open with midiseq_open().
fix !AUDIO_DEBUG build.
CID/1261465: Dereference after NULL check.
CID/1261467: Unreachable code
actually fix one of the previous: don't test for NULL after deref.

RSS XML Feed