Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/midi.c
RevisionDateAuthorComments
 1.101  23-Oct-2022  riastradh midi(4): No need to take lock just for callout_halt.

Lock is relevant only if we're doing something _else_ under the lock
that must be serialized with the callout's own action.
 1.100  23-Oct-2022  riastradh midi(4): Explain what's about to happen when refcnt drain fails.

This should really be an unconditional cv_wait loop, but for now
let's just give fair warning when the driver is about to puke its
guts out in case the I/O paths I haven't audited yet are buggy.
 1.99  23-Oct-2022  riastradh midi(4): Wake waiters _before_ waiting for them.

Otherwise we may deadlock waiting for them to give up while they're
waiting for I/O, not knowing they need to give up.
 1.98  04-Jun-2022  pgoyette Combine the midi and sequencer modules into a single midi_seq module
to avoid a circular dependency as noted in kern/56772. Retain minimal
modules of the original names to accomodate auto-loading upon access
to the /dev/xxx nodes.
 1.97  22-May-2022  andvar fix various small typos, mainly in comments.
 1.96  31-Mar-2022  pgoyette For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence. This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

devsw_attach()
config_init_component() or config_cf*_attach()
...
config_fini_component() or config_cf*_detach()
devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
1. compile without build break
2. no related test failures from atf
3. modload/modunload work as well as
before.

No functional device testing done, since I don't have any
of these devices. Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken; see kern/56772. This commit does not break
any additional modules (as far as I know).
 1.95  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.94  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.93  26-Apr-2021  thorpej branches: 1.93.6;
midi_attach_mi(): Be explicit about using the "midibus" interface attribute,
as the caller may be a device that carries more than one.
 1.92  24-Apr-2021  thorpej branches: 1.92.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.91  19-Dec-2020  thorpej branches: 1.91.2;
Use sel{record,remove}_knote().
 1.90  23-May-2020  ad branches: 1.90.2;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.89  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.88  28-Oct-2017  riastradh branches: 1.88.4; 1.88.8;
Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h".
 1.87  25-Oct-2017  maya Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.86  01-Jun-2017  pgoyette Add infrastructure for modularization of audio, midi, and sequencer
 1.85  14-Jul-2016  msaitoh branches: 1.85.2; 1.85.8;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.84  07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.83  30-Dec-2014  mrg - 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.
 1.82  22-Dec-2014  mrg 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.
 1.81  25-Jul-2014  dholland branches: 1.81.2; 1.81.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.80  16-Mar-2014  dholland branches: 1.80.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.79  14-Sep-2013  martin Quell a few "unused variable" warnings (where the variables are generated
by macros)
 1.78  09-Apr-2012  plunky branches: 1.78.2; 1.78.4;
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.77  05-Apr-2012  plunky midi_attach() does not actually ever use the parent device
pointer, so no need to store it in sc_dev. Further, remove
the sc_dev field entirely since it is easily confused with
the dev field, which is the 'self' device pointer. Fix the
comment.
 1.76  05-Apr-2012  plunky move the pmf_device_register() for midi.c and midi_pcppi.c to midi_attach()
for symmetry, since it is removed in midi detach code

and don't need to call device_pmf_is_registered() before registering it
 1.75  10-Jan-2012  njoly Call aprint_naive for quiet boot message.
 1.74  24-Nov-2011  mrg branches: 1.74.2;
set hwif_softc around midi_attach()s call to ->getinfo(), like the old
code, so that midi_register_hw_if_ext() works. add a mutex for this
to avoid multiple midi_attach()s fighting over it.

XXX: this is an ugly interface
 1.73  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.72  27-Jul-2010  jakllsch branches: 1.72.8; 1.72.10;
printf() size_t with 'z' format modifier in debug code.
 1.71  06-Dec-2009  dyoung branches: 1.71.2; 1.71.4;
Simplify these device-activation hooks using the following semantic
patch.

XXX sc_dying must die.

@@
type device_t;

identifier act, midi_softc, midiactivate, sc, self;
@@

int
midiactivate(device_t self, enum devact act)
{
(
struct midi_softc *sc = device_private(self);
|
- struct midi_softc *sc;
+ struct midi_softc *sc = device_private(self);
...
- sc = device_private(self);
)
...
switch (act) {
- case DVACT_ACTIVATE:
- return (EOPNOTSUPP);
-
case DVACT_DEACTIVATE:
(
sc->dying
|
sc->sc_dying
)
=
(
1
|
true
)
;
- break;
+ return 0;
+ default:
+ return EOPNOTSUPP;
}
- return (0);
}
 1.70  23-Aug-2009  jmcneill I'm not so sure this is actually CPU-intensive in 2009, so don't print it.
 1.69  07-Apr-2009  dyoung Cosmetic: in a debug statement, use "%s", __func__ instead of a
misspelling of the detach routine's name.
 1.68  12-Jun-2008  cegger branches: 1.68.4; 1.68.8; 1.68.10;
use device_lookup to get device_t
 1.67  10-Jun-2008  cegger device_private(device_lookup()) -> device_lookup_private()
ok cube@
 1.66  30-Apr-2008  ad branches: 1.66.2; 1.66.4;
Make various bits of debug code compile again.
 1.65  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.64  24-Apr-2008  ad branches: 1.64.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.63  05-Mar-2008  cube branches: 1.63.2;
Fix fallout from midi(4)'s softc split.
 1.62  05-Mar-2008  tnn Include sys/device.h for device_t
 1.61  04-Mar-2008  cube Split device_t/softc for midi(4), and other related cosmetic changes.
 1.60  01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.59  16-Dec-2007  christos branches: 1.59.2; 1.59.6;
add null pmf handlers.
 1.58  05-Dec-2007  pooka branches: 1.58.4;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.57  01-Dec-2007  jmcneill branches: 1.57.2;
aprintify, on behalf of xtraeme
 1.56  08-Oct-2007  ad branches: 1.56.4;
Use the softint API.
 1.55  09-Jul-2007  ad branches: 1.55.6; 1.55.8; 1.55.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.54  16-Jun-2007  pavel Correct format strings for ptrdiff_t and size_t arguments in DPRINTFs,
so that a kernel with AUDIO_DEBUG builds.
 1.53  04-Mar-2007  christos branches: 1.53.2; 1.53.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.52  15-Feb-2007  ad branches: 1.52.2; 1.52.4;
Defer wakeup() to the soft interrupt also.
 1.51  09-Feb-2007  ad Merge newlock2 to head.
 1.50  16-Nov-2006  christos branches: 1.50.2; 1.50.4;
__unused removal on arguments; approved by core.
 1.49  12-Oct-2006  thorpej Add __unused as necessary.
 1.48  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.47  02-Sep-2006  christos branches: 1.47.2; 1.47.4;
add missing initializer
 1.46  02-Jul-2006  wiz Uppercase CPU.
 1.45  01-Jul-2006  chap Correct build failures when MIDI is not enabled (the idea!).

Specifically eap but no midi, which makes sense if you want sound,
and umidi but no midi, which makes little sense but shouldn't fail the
build.

Suggest changing the evbarm conf files containing umidi but #midi
to comment out umidi as well (even though this fix should let them build).
 1.44  30-Jun-2006  chap 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.43  28-Mar-2006  thorpej branches: 1.43.2; 1.43.4;
Use device_unit().
 1.42  11-Dec-2005  christos branches: 1.42.4; 1.42.6; 1.42.8; 1.42.10; 1.42.12;
merge ktrace-lwp.
 1.41  21-Jun-2005  ws branches: 1.41.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.40  29-May-2005  christos - add const
- avoid variable shadowing.
 1.39  27-Feb-2005  perry nuke trailing whitespace
 1.38  29-Oct-2004  yamt branches: 1.38.4; 1.38.6;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.37  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.36  23-Nov-2003  gson Make the raw midi device pass through received system exclusive
messages rather than discard them.
 1.35  02-Nov-2003  gson Some possible MIDI input byte streams could cause sc->in_msg[]
to be overrun, causing a crash.
 1.34  29-Jun-2003  fvdl branches: 1.34.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.33  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.32  31-Jan-2003  thorpej Use aprint_*().
 1.31  26-Nov-2002  christos si_ -> sel_
 1.30  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.29  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.28  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.27  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.26  23-Sep-2002  simonb Remove breaks after returns, unreachable returns and returns after
returns(!).
 1.25  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.24  01-Jun-2002  gson spl botch in midipoll() when sc->dying
 1.23  13-Nov-2001  lukem branches: 1.23.8;
add RCSIDs
 1.22  02-Oct-2001  augustss ANSIfy.
 1.21  31-Jan-2001  tshiozak branches: 1.21.2; 1.21.4; 1.21.6;
solve the race condition while output for umidi.
 1.20  30-Jan-2001  tshiozak some changes for midi_start_output() under PROP_OUT_INTR devices.
- protect the buffer even though ointr occur until exiting
from hw_if->output().
- allow this function to send multiple bytes to hw_if->output()
at the same time. it's necessary for umidi.
 1.19  13-Jan-2001  tshiozak add missing sc->dying initializer at midiattach.
 1.18  13-Jan-2001  tshiozak add detaching/deactivation code to midi driver.
 1.17  06-Jul-2000  thorpej Use device_lookup().
 1.16  06-May-2000  augustss Simplify an expression.
 1.15  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.14  18-Jan-2000  augustss Add a little more debug printing.
 1.13  19-Oct-1999  soren '<Device>' usually means the string comes from outside the kernel.
 1.12  09-Sep-1999  augustss branches: 1.12.2; 1.12.4; 1.12.6;
Add support for detaching audio devices.
 1.11  26-Feb-1999  nathanw Make these compile on the alpha when AUDIO_DEBUG is defined.
 1.10  20-Dec-1998  drochner Make midi_attach_mi() and audioprint() available also if MIDIBUS
(but not necessarily MIDI) is defined.
Fixes PR port-i386/6615 (Krister Walfridsson <cato@ulysses.df.lth.se>).
(XXX this should probably go into a separate file to get rid of
the #ifdef mess)
 1.9  15-Dec-1998  augustss Fix a MIDI buffer overflow problem. Fixes PR 6583.
Patch from Ales Krenek <ljocha@ics.muni.cz>
 1.8  25-Nov-1998  augustss Make the copyright header conform to the NetBSD template.
 1.7  05-Oct-1998  augustss Make MIDI input work again.
Fix from Torsten Duwe <duwe@ns.lst.de>.
 1.6  13-Sep-1998  mycroft Make sure the buffers are synchronized on open.
 1.5  24-Aug-1998  augustss Write MIDI data from the sequencer to the device in a more sane way.
 1.4  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.3  13-Aug-1998  augustss Remove some leftover fluff.
Make sure there is no outstanding timeout when the sequencer is closed.
 1.2  12-Aug-1998  augustss Tidy up and rename some functions in the MIDI driver.
 1.1  07-Aug-1998  augustss Add MIDI support. The MIDI devices can be accessed as ``raw'' through
the /dev/rmidiN devices, or with a sequencer interface via /dev/music.
So far the only supported MIDI device is the MPU401 port on SoundBlaster
(and only on SB on isapnp, since we do not have locators with multiple
values yet).
 1.12.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.4.1  15-Nov-1999  fvdl Sync with -current
 1.12.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.12.2.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.12.2.2  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.12.2.1  20-Oct-1999  thorpej Sync w/ trunk.
 1.21.6.3  11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.21.6.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.21.6.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.21.4.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.21.4.5  02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.21.4.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.21.4.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.4.2  08-Sep-2001  thorpej Oops, selwakeup -> selnotify
 1.21.4.1  08-Sep-2001  thorpej Add kqueue support (someone who understands the midi code should
make sure this is correct).
 1.21.2.7  11-Dec-2002  thorpej Sync with HEAD.
 1.21.2.6  11-Nov-2002  nathanw Catch up to -current
 1.21.2.5  18-Oct-2002  nathanw Catch up to -current.
 1.21.2.4  17-Sep-2002  nathanw Catch up to -current.
 1.21.2.3  20-Jun-2002  nathanw Catch up to -current.
 1.21.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.21.2.1  08-Oct-2001  nathanw Catch up to -current.
 1.23.8.2  20-Jun-2002  gehenna catch up with -current.
 1.23.8.1  16-May-2002  gehenna Add the character device switch.
Replace the direct-access to devsw table with calling devsw API.
 1.34.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.34.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.34.2.5  02-Nov-2004  skrll Sync with HEAD.
 1.34.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.34.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.34.2.2  03-Aug-2004  skrll Sync with HEAD
 1.34.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.38.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.38.4.1  29-Apr-2005  kent sync with -current
 1.41.2.8  17-Mar-2008  yamt sync with head.
 1.41.2.7  21-Jan-2008  yamt sync with head
 1.41.2.6  07-Dec-2007  yamt sync with head
 1.41.2.5  27-Oct-2007  yamt sync with head.
 1.41.2.4  03-Sep-2007  yamt sync with head.
 1.41.2.3  26-Feb-2007  yamt sync with head.
 1.41.2.2  30-Dec-2006  yamt sync with head.
 1.41.2.1  21-Jun-2006  yamt sync with head.
 1.42.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.42.10.1  19-Apr-2006  elad sync with head.
 1.42.8.3  03-Sep-2006  yamt sync with head.
 1.42.8.2  11-Aug-2006  yamt sync with head
 1.42.8.1  01-Apr-2006  yamt sync with head.
 1.42.6.1  22-Apr-2006  simonb Sync with head.
 1.42.4.1  09-Sep-2006  rpaulo sync with head
 1.43.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.43.2.20  28-Jun-2006  chap Handle error counters for devices with no output capability symmetrically
w.r.t. those with no input. Some preparation for a stats-returning ioctl
TBD.
 1.43.2.19  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.43.2.18  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.43.2.17  21-May-2006  chap @.n.o e-mail address, and a couple of corrections to the mechanical
merge, found by eyeball. Now to see how many gcc will catch....
 1.43.2.16  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.43.2.15  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.43.2.14  20-May-2006  chap Spotted a bug in a buffer condition. Never saw any symptom, but it's a
bug nonetheless.
 1.43.2.13  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.43.2.12  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.43.2.11  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.43.2.10  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.43.2.9  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.43.2.8  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.43.2.7  20-May-2006  chap The DFA (well, technically it's really a FST - a DFA with output) is now
used for transmit as well as receive; it's run at the upstream end of
each pipe (the receive interrupt for receive, the write call for transmit)
so that protocol errors can be detected as soon as possible, and erroneous
data won't fill the buffer. Implemented a guarantee that read(2) on the
raw device returns as many complete messages as will fit in the read
request, so the user program does not have to parse around read boundaries
(except for SysEx). Required a new buffer scheme that preserves message
boundaries. (A little like reinventing STREAMS, hmm...) Implemented
FIONREAD. New approach to sharing the cpu during output to interrupt-
challenged devices.

umidi happens to work now even in the presence of Active Sense, as the
transmit FST ensures the Active Sense doesn't appear in the midst of
another message, and right now the FST is always in canonicalizing mode
so there is no running status to disturb. That's half accident though, and
doesn't work for midisyn (which treats any System Common message as SysEx,
argh). The right solution will be to allow message-based drivers like umidi
and midisyn to get their data via a message-at-a-time interface, rather
than splitting the messages into bytes for lower drivers to reassemble
wrong.
 1.43.2.6  20-May-2006  chap Receive dfa factored out and made usable for both receive and transmit.
So far so good. Now to rewire transmit to use it.
 1.43.2.5  20-May-2006  chap Implement Active Sense on transmit. The same callout used by
midi_start_output for brief delays in output is now also scheduled
for 285 ms if there is nothing to transmit, and will send an Active Sense
at that time if there is nothing else to go; this will keep the receiving
equipment expecting our Active Sense and ensure that notes will stop
sounding when it ceases (either because we close normally, or we hang,
or someone trips over a cable). Sounds simple enough but involved a new
locking strategy, because we used to block out user_incurred start_output
whenever the device interrupt or callout was pending, but in the case of
the 285ms callout we /want/ to let a user write through and cancel the
callout (and avoid races, etc). Also moved the callout_init into
midi_attach because midiattach was not called in all cases, and added
a callout_stop in detach (though it is not yet quite up to all cases where
the callout may have been fired but not yet run at the time of detach -
nothing is easy.)

Surprisingly, the Active Sense works almost right over umidi: umidi's
state machine isn't smart enough to pass it through a packet being built,
and makes garbage instead, but a Yamaha keyboard at least is happy to
accept a bit of garbage within 300 ms as a sign we're still alive. :)

Now to go do a better state machine for output. :/ It shouldn't be in
umidi; it should be in midi, done once and done right; there should be
no need to have slightly different replicas of the midi state machine
all over the kernel ... I think there's one in sequencer too.
 1.43.2.4  20-May-2006  chap Take open modes seriously: do not write if not open for writing, or read
if not open for reading, or if the midi device cannot read. In sequencer,
open only the midi devices that support at least one of the open modes
wanted; so, if the sequencer is opened for reading only, do not bother
opening midi devices that cannot input. Do not write anything to the
midi devices if opened for reading only; seq_reset previously wrote a
bunch of initial settings, which could lead to long timeouts in seq_drain
on close because of data in the output buffer that could not go anywhere.

TODO: sending initial settings is the less important thing for seq_reset
to do; the most important is to reset the buffers so the playing stops!
At present, it doesn't do that at all.
 1.43.2.3  20-May-2006  chap Fixes a bug in midi_unit_count.

Dropped byte and message counters now use evcnt.

My state machine could treat an invalid SystemCommon message or out-of-
sequence EndSysex (all protocol errors anyway) as /mishandled/ protocol
errors if encountered in certain states. Fixed.
 1.43.2.2  20-May-2006  chap Replaces the state machine in midi.c with a full, pedantically correct,
error detecting one. Rearranges some DPRINTFN debug levels to make it
easier to get the level of debug information wanted. Applies to 2.0.
 1.43.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.47.4.2  10-Dec-2006  yamt sync with head.
 1.47.4.1  22-Oct-2006  yamt sync with head
 1.47.2.5  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.47.2.4  27-Jan-2007  ad Don't call selnotify() or psignal() while above IPL_VM: defer them to a
soft interrupt.
 1.47.2.3  19-Jan-2007  ad Put back arg to preempt() for nwo.
 1.47.2.2  19-Jan-2007  ad Acquire proclist_mutex before sending signals.
 1.47.2.1  18-Nov-2006  ad Sync with head.
 1.50.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.50.2.1  18-Jun-2007  liamjfoy Pull up following revision(s) (requested by pavel in ticket #726):
sys/dev/midi.c: revision 1.54
Correct format strings for ptrdiff_t and size_t arguments in DPRINTFs,
so that a kernel with AUDIO_DEBUG builds.
 1.52.4.1  27-Feb-2007  ad Add MP locking for audio drivers.
 1.52.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.53.4.1  11-Jul-2007  mjf Sync with head.
 1.53.2.3  15-Jul-2007  ad Sync with head.
 1.53.2.2  01-Jul-2007  ad Adapt to callout API change.
 1.53.2.1  17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.55.10.1  14-Oct-2007  yamt sync with head.
 1.55.8.3  23-Mar-2008  matt sync with HEAD
 1.55.8.2  09-Jan-2008  matt sync with HEAD
 1.55.8.1  06-Nov-2007  matt sync with HEAD
 1.55.6.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.55.6.2  03-Dec-2007  joerg Sync with HEAD.
 1.55.6.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.56.4.2  27-Dec-2007  mjf Sync with HEAD.
 1.56.4.1  08-Dec-2007  mjf Sync with HEAD.
 1.57.2.2  26-Dec-2007  ad Sync with head.
 1.57.2.1  08-Dec-2007  ad Sync with head.
 1.58.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.59.6.5  29-Jun-2008  mjf Sync with HEAD.
 1.59.6.4  02-Jun-2008  mjf Sync with HEAD.
 1.59.6.3  06-Apr-2008  mjf - after some discussion with agc@ i agreed it would be a good idea to move
device_unregister_* to device_deregister_* to be more like the pmf(9)
functions, especially since a lot of the time the function calls are next
to each other.

- add device_register_name() support for dk(4).
 1.59.6.2  05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.59.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.59.2.1  24-Mar-2008  keiichi sync with head.
 1.63.2.2  17-Jun-2008  yamt sync with head.
 1.63.2.1  18-May-2008  yamt sync with head.
 1.64.2.5  11-Aug-2010  yamt sync with head.
 1.64.2.4  11-Mar-2010  yamt sync with head
 1.64.2.3  16-Sep-2009  yamt sync with head
 1.64.2.2  04-May-2009  yamt sync with head.
 1.64.2.1  16-May-2008  yamt sync with head.
 1.66.4.1  18-Jun-2008  simonb Sync with head.
 1.66.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.68.10.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.68.8.2  12-Dec-2008  ad Checkpoint work in progress.
 1.68.8.1  09-Dec-2008  ad Checkpoint work on MIDI.
 1.68.4.1  28-Apr-2009  skrll Sync with HEAD.
 1.71.4.1  05-Mar-2011  rmind sync with head
 1.71.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.72.10.2  22-Nov-2011  mrg adjust some DPRINTF*() calls so that they compile now.
 1.72.10.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.72.8.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.72.8.1  17-Apr-2012  yamt sync with head
 1.74.2.3  29-Apr-2012  mrg sync to latest -current.
 1.74.2.2  05-Apr-2012  mrg sync to latest -current.
 1.74.2.1  18-Feb-2012  mrg merge to -current.
 1.78.4.1  18-May-2014  rmind sync with head
 1.78.2.2  03-Dec-2017  jdolecek update from HEAD
 1.78.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.80.2.1  10-Aug-2014  tls Rebase.
 1.81.4.4  28-Aug-2017  skrll Sync with HEAD
 1.81.4.3  05-Oct-2016  skrll Sync with HEAD
 1.81.4.2  09-Jul-2016  skrll Sync with HEAD
 1.81.4.1  06-Apr-2015  skrll Sync with HEAD
 1.81.2.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.
 1.85.8.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.85.2.2  26-Jul-2016  pgoyette Fix botched edit.
 1.85.2.1  26-Jul-2016  pgoyette Sync with HEAD
 1.88.8.1  04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.88.4.1  10-Jun-2019  christos Sync with HEAD
 1.90.2.1  03-Jan-2021  thorpej Sync w/ HEAD.
 1.91.2.1  21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.92.2.1  13-May-2021  thorpej Sync with HEAD.
 1.93.6.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed