Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/midisyn.c
RevisionDateAuthorComments
 1.25  08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.24  09-Apr-2012  plunky branches: 1.24.40; 1.24.44;
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.23  23-Nov-2011  jmcneill branches: 1.23.2;
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  28-Apr-2008  martin branches: 1.22.12; 1.22.34; 1.22.36;
Remove clause 3 and 4 from TNF licenses
 1.21  04-Mar-2007  christos branches: 1.21.36; 1.21.38; 1.21.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20  16-Nov-2006  christos branches: 1.20.4;
__unused removal on arguments; approved by core.
 1.19  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18  30-Jun-2006  chap branches: 1.18.4; 1.18.6;
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  14-Apr-2006  christos branches: 1.17.2; 1.17.4;
Coveriry CID 565: Remove bogus test.
 1.16  11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
merge ktrace-lwp.
 1.15  27-Feb-2005  perry branches: 1.15.4;
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  13-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.9  13-Nov-2001  lukem add RCSIDs
 1.8  02-Oct-2001  augustss ANSIfy.
 1.7  18-Jan-2001  jdolecek branches: 1.7.2; 1.7.4; 1.7.6;
constify
 1.6  29-Mar-2000  simonb Don't need to include <sys/conf.h> here.
 1.5  25-Nov-1998  augustss branches: 1.5.10;
Make the copyright header conform to the NetBSD template.
 1.4  13-Sep-1998  mycroft Make sure all voices are deallocated on close.
 1.3  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.2  13-Aug-1998  augustss Remove some leftover fluff.
Make sure there is no outstanding timeout when the sequencer is closed.
 1.1  12-Aug-1998  augustss Add a layer to handle emulation of MIDI for synthesizers.
It handles decoding of MIDI commands, voice allocation, and translation
it notes to frequencies.
 1.5.10.2  11-Feb-2001  bouyer Sync with HEAD.
 1.5.10.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.7.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.7.4.2  11-Feb-2002  jdolecek Sync w/ -current.
 1.7.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.3  28-Feb-2002  nathanw Catch up to -current.
 1.7.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.7.2.1  08-Oct-2001  nathanw Catch up to -current.
 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.15.4.3  03-Sep-2007  yamt sync with head.
 1.15.4.2  30-Dec-2006  yamt sync with head.
 1.15.4.1  21-Jun-2006  yamt sync with head.
 1.16.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.10.1  19-Apr-2006  elad sync with head.
 1.16.8.2  11-Aug-2006  yamt sync with head
 1.16.8.1  24-May-2006  yamt sync with head.
 1.16.6.1  22-Apr-2006  simonb Sync with head.
 1.16.4.1  09-Sep-2006  rpaulo sync with head
 1.17.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.17.2.18  10-Jun-2006  chap Now with support for the following MIDI controls -

Channel Volume
Expression

- the following heretofore unimplemented message -

Pitch Bend

- and the following registered parameters -

Pitch Bend Range
Channel Fine Tuning
Channel Coarse Tuning

Volume and Expression are handled by all synth chip drivers but pcppi
(which has a fixed volume). All of the pitch controls will be effective
(at least for new notes struck after a change) for all current synth
drivers but cms (that driver discards all the fractional pitch bits and
calculates its own frequency by a table lookup; it should be possible to
do better with knowledge of the formula behind the table, but I have
found no cms docs). If a driver provides repitchv and relevelv methods
for changing the pitch/level of a sounding voice, then changes to these
parameters will take effect in real time and not just for subsequent notes.
The effect can be heard (for repitchv) over pcppi.

Heads up: if you build with libprop earlier than 2006.05.28, you can enjoy
the exhilarating experience of seeing kernel memory stomped. ;)
 1.17.2.17  09-Jun-2006  chap Bit of housecleaning.

"miditune" wasn't a good name for the pitch representation (even if it
did come from the MIDI Tuning Specification) because for too many people
a 'tune' is a little ditty, not a single pitch. Changed the name to
midipitch and added a typedef midipitch_t; renamed the associated macros
consistently.

The type and operations on it are now in <sys/midiio.h> because they could
show up in userland for manipulation of the MIDI Tuning messages that
RP-012 defines. The macro MIDIPITCH_TO_HZ18 expands in userland to
ordinary libm calls, and in-kernel to the no-floating-point version in
midisyn. A few more operations are defined in userland where libm is
available.

At the same time, made midipitch_t signed. It has the bits to spare,
and such manipulations as adding several corrections and clamping the
result will be simpler with it signed.
 1.17.2.16  09-Jun-2006  chap Missed a couple details for opl on the first try.

The opl device I tested plays slightly but noticeably sharp. I double-
checked the coefficients in the manual and also compared to a kernel
from before my changes: also sharp. So I don't think I did it. I don't
know what the usual tolerances are for inexpensive soundcards. There
will at any rate be a general workaround as soon as midisyn groks
master-tuning.

This leaves only cms untested with the midisyn changes; I don't have
access to a cms device, but confidence is high.
 1.17.2.15  08-Jun-2006  chap Rototill of midisyn <-> synth driver i/f.

The DOALLOC and FREQXLATE flags are on the way out. Whether a driver wants
allocation service is deducible from whether it provides an allocv method, and
anyway none does. As for freq, they all get a miditune and can convert it
whichever way they want.

Controller handling with midictl is hooked in but few controllers watched yet.

Some macros for manipulating the miditune type are currently in midisynvar.h
but should perhaps be exported in midiio.h.

opl no longer has its own master volume state (there was no setter for it
anyway, it never changed); soon that will be handled centrally in midisyn.

Builds a kernel. Not all functionality tested yet.
 1.17.2.14  08-Jun-2006  chap Now with some conversions allowing relatively standard units to be used in
the i/f to synth drivers so everybody means the same thing. For volume
levels, centibels should be ample resolution, and the MIDI Tuning format
specified in RP-012 is a good way to pass around pitches. A nice thing
about both of these formats is that they're manipulated additively.

Next up: redefine the appropriate methods to use these parameter formats.
 1.17.2.13  07-Jun-2006  chap Done pruning unused and ill-defined methods. Several bits of code that
actually did nothing have been replaced with comments explaining what
ought to be done there someday. This is actually progress. Everything
should still work, save PAN for opl, the only preexisting functionality
that's actually gone at this point, but it will be back soon.
 1.17.2.12  07-Jun-2006  chap midisyn now uses midictl instead of punting every ctl_change message
uninterpreted down to the MD synth driver (most of which don't even
try to field it). Right now that means no control change has any effect
right now, but that is a loss of functionality only for OPL, which handled
the following extensive set of control messages: { PAN }

Now to do some tillage of the midisyn <-> md synth interface with the goal
of adding a method for communicating /cooked/ control messages down. Won't
be much tillage because there are only 3 children in the tree and the two
that aren't opl have no ctl logic at all. Start by making them all use
designated initializers for their method structures, so the set of methods
can evolve without a versioning nightmare. Then probably prune a number of
methods that NOBODY implements, where it's not clear they're defined the
best way to begin with, and they can easily re-evolve (possibly in better
form) when there is actual interest in implementing them.
 1.17.2.11  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.2.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.2.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.2.8  20-May-2006  chap Spotted a bug in a buffer condition. Never saw any symptom, but it's a
bug nonetheless.
 1.17.2.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.2.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.2.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.2.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.2.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.2.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.2.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.18.6.2  10-Dec-2006  yamt sync with head.
 1.18.6.1  22-Oct-2006  yamt sync with head
 1.18.4.1  18-Nov-2006  ad Sync with head.
 1.20.4.1  12-Mar-2007  rmind Sync with HEAD.
 1.21.40.1  16-May-2008  yamt sync with head.
 1.21.38.1  18-May-2008  yamt sync with head.
 1.21.36.1  02-Jun-2008  mjf Sync with HEAD.
 1.22.36.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.34.1  17-Apr-2012  yamt sync with head
 1.22.12.1  09-Dec-2008  ad Checkpoint work on MIDI.
 1.23.2.1  29-Apr-2012  mrg sync to latest -current.
 1.24.44.1  04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.24.40.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed