summaryrefslogtreecommitdiff
path: root/sys/dev/sound/midi/midi.c
Commit message (Collapse)AuthorAgeFilesLines
* sound: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-12/+0
| | | | Notes: svn path=/head/; revision=365085
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-2/+4
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Use a sleepable lock for midistat functions.Mark Johnston2019-08-201-72/+58
| | | | | | | | | | | | Otherwise the mutex needs to be dropped when copying out the midistat sbuf, leading to a race which allows one to read kernel memory beyond the end of the sbuf buffer. Reported and tested by: pho Security: CVE-2019-5612 Notes: svn path=/head/; revision=351262
* Revert r338423, reapplying r338422, which did get approval butGlen Barber2018-09-011-4/+0
| | | | | | | | | | | | communication lines got crossed. Apologies to avatar@ for the confusion. Approved by: re (implicit) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=338424
* Revert r338422, which was did not get official approval from re@.Glen Barber2018-09-011-0/+4
| | | | | | | | Approved by: re (implicit) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=338423
* Adding support for CS46xx MIDI output. With this patch, users canTai-hwa Liang2018-09-011-4/+0
| | | | | | | | | | | | | | play the MIDI files through /dev/sequencer device with tools like playmidi. The audio output will go through the external MIDI device such like wavetable synthesis card. Reviewed by: matk (a long time ago), kib Approved by: re (kib) Tested with: Terratec SiXPack 5.1+ + Yamaha DB50XG MFC after: 4 weeks Notes: svn path=/head/; revision=338422
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-211-3/+2
| | | | | | | | | | | | | | | | | | Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197 Notes: svn path=/head/; revision=328218
* dev: make some use of mallocarray(9).Pedro F. Giffuni2018-01-131-2/+3
| | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these is likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. Notes: svn path=/head/; revision=327949
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* sound(4): Don't use-after-free in midi module unloadConrad Meyer2016-04-201-4/+4
| | | | | | | | | | | Also, use ANSI function parameter definitions (void) while here. Reported by: Coverity CID: 1006107 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=298339
* Replace 0 with NULL for pointers in misc. device drivers.Pedro F. Giffuni2016-04-121-1/+1
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297862
* Cleanup unnecessary semicolons from the kernel.Pedro F. Giffuni2016-04-101-2/+2
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297793
* - Plugging a memory leak when malloc() failed during initialisation;Tai-hwa Liang2015-10-241-4/+8
| | | | | | | | | | - Plugging another memory leak inside the destructor. Reviewed by: matk MFC after: 3 weeks Notes: svn path=/head/; revision=289888
* Using the error return code documented in the comment.Tai-hwa Liang2015-08-181-1/+1
| | | | | | | | | | | | | Though there is no direct midi_uninit() caller amongst existing drivers at this moment, a quick experiment indicates that EBUSY gives users more precise error message once drivers start to honour this result. For example, emu_midi_detach() should check the result of mpu401_uninit() and block module unloading if there is any MIDI I/O in progress. MFC after: 2 weeks Notes: svn path=/head/; revision=286887
* Fixing typo as well as improving readability of a few comments.Tai-hwa Liang2015-08-181-6/+11
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=286886
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* In order to maximize the re-usability of kernel code in user space thisKip Macy2011-09-161-2/+2
| | | | | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz) Notes: svn path=/head/; revision=225617
* Change the type of uio_resid member of struct uio from int to ssize_t.Konstantin Belousov2009-06-251-1/+1
| | | | | | | | | | | Note that this does not actually enable full-range i/o requests for 64 architectures, and is done now to update KBI only. Tested by: pho Reviewed by: jhb, bde (as part of the review of the bigger patch) Notes: svn path=/head/; revision=194990
* Remove custom KOBJMETHOD(), CHANNEL_DECLARE() and MIXER_DECLARE()Ariff Abdullah2009-06-111-11/+3
| | | | | | | | (enabled with SND_DEBUG) that was intended to provoke build failure due to inconsistencies. Notes: svn path=/head/; revision=193979
* Sound Mega-commit. Expect further cleanup until code freeze.Ariff Abdullah2009-06-071-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a slightly thorough explaination, please refer to [1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html . Summary of changes includes: 1 Volume Per-Channel (vpc). Provides private / standalone volume control unique per-stream pcm channel without touching master volume / pcm. Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for backwards compatibility, SOUND_MIXER_PCM through the opened dsp device instead of /dev/mixer. Special "bypass" mode is enabled through /dev/mixer which will automatically detect if the adjustment is made through /dev/mixer and forward its request to this private volume controller. Changes to this volume object will not interfere with other channels. Requirements: - SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which require specific application modifications (preferred). - No modifications required for using bypass mode, so applications like mplayer or xmms should work out of the box. Kernel hints: - hint.pcm.%d.vpc (0 = disable vpc). Kernel sysctls: - hw.snd.vpc_mixer_bypass (default: 1). Enable or disable /dev/mixer bypass mode. - hw.snd.vpc_autoreset (default: 1). By default, closing/opening /dev/dsp will reset the volume back to 0 db gain/attenuation. Setting this to 0 will preserve its settings across device closing/opening. - hw.snd.vpc_reset (default: 0). Panic/reset button to reset all volume settings back to 0 db. - hw.snd.vpc_0db (default: 45). 0 db relative to linear mixer value. 2 High quality fixed-point Bandlimited SINC sampling rate converter, based on Julius O'Smith's Digital Audio Resampling - http://ccrma.stanford.edu/~jos/resample/. It includes a filter design script written in awk (the clumsiest joke I've ever written) - 100% 32bit fixed-point, 64bit accumulator. - Possibly among the fastest (if not fastest) of its kind. - Resampling quality is tunable, either runtime or during kernel compilation (FEEDER_RATE_PRESETS). - Quality can be further customized during kernel compilation by defining FEEDER_RATE_PRESETS in /etc/make.conf. Kernel sysctls: - hw.snd.feeder_rate_quality. 0 - Zero-order Hold (ZOH). Fastest, bad quality. 1 - Linear Interpolation (LINEAR). Slightly slower than ZOH, better quality but still does not eliminate aliasing. 2 - (and above) - Sinc Interpolation(SINC). Best quality. SINC quality always start from 2 and above. Rough quality comparisons: - http://people.freebsd.org/~ariff/z_comparison/ 3 Bit-perfect mode. Bypasses all feeder/dsp effects. Pure sound will be directly fed into the hardware. 4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf. 5 Transparent/Adaptive Virtual Channel. Now you don't have to disable vchans in order to make digital format pass through. It also makes vchans more dynamic by choosing a better format/rate among all the concurrent streams, which means that dev.pcm.X.play.vchanformat/rate becomes sort of optional. 6 Exclusive Stream, with special open() mode O_EXCL. This will "mute" other concurrent vchan streams and only allow a single channel with O_EXCL set to keep producing sound. Other Changes: * most feeder_* stuffs are compilable in userland. Let's not speculate whether we should go all out for it (save that for FreeBSD 16.0-RELEASE). * kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org> * pull out channel mixing logic out of vchan.c and create its own feeder_mixer for world justice. * various refactoring here and there, for good or bad. * activation of few more OSSv4 ioctls() (see [1] above). * opt_snd.h for possible compile time configuration: (mostly for debugging purposes, don't try these at home) SND_DEBUG SND_DIAGNOSTIC SND_FEEDER_MULTIFORMAT SND_FEEDER_FULL_MULTIFORMAT SND_FEEDER_RATE_HP SND_PCM_64 SND_OLDSTEREO Manual page updates are on the way. Tested by: joel, Olivier SMEDTS <olivier at gid0 d org>, too many unsung / unnamed heroes. Notes: svn path=/head/; revision=193640
* Remove license clauses 3 and 4 as per rev. 1.65 of midi.c in NetBSD.Joel Dahl2009-05-201-7/+0
| | | | | | | Approved by: matk Notes: svn path=/head/; revision=192458
* Disable seq_modevent(). The implementation is incomplete, and causingAriff Abdullah2007-04-021-0/+4
| | | | | | | memory leak during unload. Notes: svn path=/head/; revision=168253
* NULL instead of 0 in mtx_init() .Ariff Abdullah2007-03-151-3/+3
| | | | Notes: svn path=/head/; revision=167604
* semi-automatic style(9)Alexander Leidinger2007-02-251-524/+533
| | | | Notes: svn path=/head/; revision=166971
* Clean up the BSD license to match the preferred license inJoel Dahl2007-01-281-2/+1
| | | | | | | | | | | /usr/share/examples/etc/bsd-style-copyright. I've fixed a few minor wording and formatting differences. Approved by: matk, Hannu Savolainen <hannu@opensound.com> Reviewed by: imp Notes: svn path=/head/; revision=166322
* Rearrange locking order to avoid LOR (cat /dev/midistat).Ariff Abdullah2007-01-271-3/+9
| | | | | | | Reported by: rodrigc Notes: svn path=/head/; revision=166280
* - Rename hw.snd.unit to hw.snd.default_unit to make the purpose more obvious.Alexander Leidinger2006-06-181-0/+1
| | | | | | | | | | - Enable 4 automatic vchan's by default. - Add some comments which provide ides/questions for improvement. - Prefix some temporary sysctl's with an underscore to denote that it is not an official API but a workaround until the real solution is implemented. Notes: svn path=/head/; revision=159732
* Fix build with -Wundef.Ruslan Ermilov2006-05-291-2/+2
| | | | Notes: svn path=/head/; revision=159042
* Use a more appropriate printf format for size_t.Alexander Leidinger2006-05-281-1/+1
| | | | | | | This should unbreak the tinderbox build (64bit architectures). Notes: svn path=/head/; revision=159009
* Commit the new (old) midi framework. It's based in parts on the NetBSD code,Alexander Leidinger2006-05-271-0/+1509
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | but large parts are rewritten by matk and tanimura. This is old code, it's not maintained since 2003. We also don't have a maintainer for this! Yuriy Tsibizov took it and uses it in his emu10kx driver. Since the emu10kx driver will enter the tree "soon" (some bugs have to be fixed after Yuriy return from his holidays), I add it here already. This also contains some changes to emu10k1 and cmi, so if you're lucky, you can now make some kind of use of midi with those soundcards. To all those poor souls which don't have such a card: feel free to send patches, we don't have a maintainer for this. To those which miss a specific feature in the midi code: feel free to submit patches, we don't have a maintainer for this. Oh, did I already told that it would be nice if someone would take care of it? Maintainer with midi equipment wanted! :-) If you get LOR's, submit a PR and notify multimedia@ please. If you get panics, submit a PR with a backtrace (compile the sound system into your kernel instead of using modules in this case) and notify multimedia@ please. Written by: matk, tanimura Submitted by: "Yuriy Tsibizov" <Yuriy.Tsibizov@gfk.ru> Based upon: code from NetBSD Notes: svn path=/head/; revision=158979
* Axe the old midi drivers and framework. matk has developed a newSeigo Tanimura2004-06-011-1054/+0
| | | | | | | module-friendly midi subsystem to be merged soon. Notes: svn path=/head/; revision=129925
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-0/+2
| | | | | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags. Notes: svn path=/head/; revision=126080
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-13/+8
| | | | | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl) Notes: svn path=/head/; revision=111815
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-3/+3
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-3/+3
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Change callers of mtx_init() to pass in an appropriate lock type name. InJohn Baldwin2002-04-041-7/+7
| | | | | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64 Notes: svn path=/head/; revision=93818
* - Provide toggles to show debug messages. Set new sysctl variablesSeigo Tanimura2002-01-041-28/+180
| | | | | | | | | | | | | | | | | hw.midi.debug and hw.midi.seq.debug to 1 to enable debug log. - Make debug messages human-frendly. - Implement /dev/music. - Add a timer engine required by /dev/music. - Fix nonblocking I/O. - Fix the numbering of midi and synth devices. Notes: svn path=/head/; revision=88869
* - Do not uiomove with a mutex locked.Seigo Tanimura2002-01-011-25/+46
| | | | | | | | | | | | - Move from msleep/wakeup to condvar. - Return either zero or a positive errno value from a function. Return additional result via references. - Unify the typedef of callback functions. Notes: svn path=/head/; revision=88773
* KSE Milestone 2Julian Elischer2001-09-121-21/+21
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Send the remains (such as I have located) of "block major numbers" toPoul-Henning Kamp2001-03-261-1/+0
| | | | | | | the bit-bucket. Notes: svn path=/head/; revision=74810
* - Do not touch the Giant.Seigo Tanimura2001-03-141-84/+0
| | | | | | | | | | | Requested by: jhb - Initialize a mutex prior to locking it. Spotted by: dcs Notes: svn path=/head/; revision=74239
* - Mutexify midi(4). The driver runs under the giant lock by default.Seigo Tanimura2001-02-261-95/+327
| | | | | | | | | | | | | | | | | If you ever want to run midi(4) out of the giant lock, uncomment MIDI_OUTOFGIANT in midi.h. Confirmed to work for csamidi with WITNESS and INVARIANTS. - midi_info, midi_open and seq_info are now tailqs, allowing arbitrary numbers of devices to be configured. - Do not send an active sensing message to reset midi modules. - Clone /dev/sequencer*. /dev/sequencer0 and /dev/sequencer are generated upon initialization. Notes: svn path=/head/; revision=73072
* Encapselate midi_info, nmidi and nsynth into midi.c.Seigo Tanimura2001-02-181-8/+45
| | | | Notes: svn path=/head/; revision=72661
* Avoid the modules madness I inadvertently introduced by making thePoul-Henning Kamp2000-09-021-2/+0
| | | | | | | | | | | | | | | | | | | | | cloning infrastructure standard in kern_conf. Modules are now the same with or without devfs support. If you need to detect if devfs is present, in modules or elsewhere, check the integer variable "devfs_present". This happily removes an ugly hack from kern/vfs_conf.c. This forces a rename of the eventhandler and the standard clone helper function. Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include like <sys/queue.h> Remove all #includes of opt_devfs.h they no longer matter. Notes: svn path=/head/; revision=65374
* Finally merge newmidi.Seigo Tanimura2000-07-111-0/+702
(I had been busy for my own research activity until the last weekend) Supported devices: SB Midi Port (sbc + midi) SB OPL3 (sbc + midi) 16550 UART (midi, needs a trick in your hint) CS461x Midi Port (csa + midi) OSS-compatible sequencer (seq) Supported playing software: playmidi (We definitely need more) Notes: /dev/midistat now reports installed midi drivers. /dev/sndstat reports only pcm drivers. We need the new name(pcmstat?). EMU8000(SB AWE) does not sound yet but does get probed so that the OPL3 synth on an AWE card works. TODO: MSS/PCI bridge drivers Midi-tty interface to support general serial devices Modules Notes: svn path=/head/; revision=62947