summaryrefslogtreecommitdiffstats
path: root/sys/dev/audio.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Refactor klist insertion and removalvisa2020-12-251-5/+5
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* Implement kqueue(2) support.mpi2020-05-191-2/+179
| | | | | | | Assert that the KERNEL_LOCK() has to be held before grabbing `audio_lock' to prevent lock ordering issues inside selwakeup(). ok visa@, ratchov@
* Use softintr to call selwakeup() in the mixer code code-pathratchov2020-05-161-6/+26
| | | | ok mpi
* Remove support for unused /dev/mixer device nodes.ratchov2020-04-181-17/+1
| | | | ok deraadt
* Wake up processes reading the mixer when the device is detached.ratchov2020-03-081-1/+5
|
* Fix missing locking during calls to selwakeup().ratchov2020-02-131-12/+40
| | | | | | | | | | selwakeup() was called in the interrupt handler, i.e. with the audio_lock held. We can't just grab the KERNEL_LOCK needed by selwakeup(), because locks would be taken in the wrong order. Solve this by defering selwakeup() calls to a softintr, called with the KERNEL_LOCK held. Mostly from mpi@, ok mpi@.
* Add support for notifications about audio(4) controls changes.ratchov2020-01-291-3/+158
| | | | | | Whenever a "mixer" control is changed by a program or with volume keys, its index may be read from the /dev/audioctlN device using the read(2) syscall. Only one reader at a time is allowed.
* Rename audio_mixer_{read,write} to audio_mixer_{get,set}.ratchov2020-01-241-5/+5
| | | | | The audio_mixer_{read,write} names are misleading: these functions are not the methods of the read and write syscalls. No object change.
* audio(4): msleep(9) -> msleep_nsec(9)cheloha2019-12-181-7/+7
| | | | ok ratchov@
* Convert infinite tsleep(9) to tsleep_nsec(9).mpi2019-10-071-5/+5
| | | | ok ratchov@
* If the requensted block size is too large, then use half theratchov2019-09-101-1/+16
| | | | | buffer size instead of failing. Problem found and fix tested by Joe Davis <me at jo.ie>, thanks!
* Add the set_blksz() and set_nblks() audio driver functions.ratchov2019-09-051-5/+50
| | | | | | | | | | | | | | | | The first sets the block size in frames, which is necessarily common to play and recording directions no matter the number of channels. The second sets the number of blocks per buffer for the given direction. Together, these two functions allow audio drivers to easily set the block size, matching both playback and recording constraints. The round_blocksize() didn't allow to do so because it returns the block size in *bytes*. Since the driver doesn't know if it's called for the play or for the record block size, it's impossible to calculate the block size in all cases if play and record number of channels are different. ok mpi@
* Move play blocks count from the audio_softc to the audio_buf structure.ratchov2019-08-171-20/+22
| | | | | As the audio_buf structure is per-direction, this makes play and recording code similar. No behavior change.
* Move block size and block count calculations in their own routines.ratchov2019-08-171-80/+108
| | | | Makes the code easier to read, no behabior change.
* Try to start playback after play buffer pointers are advanced.ratchov2019-04-051-4/+6
| | | | | | Allows playback to start automatically as soon as there's enough data, even if the AUDIO_START ioctl is not called. This is mainly useful to quickly test & debug low level drivers with simple shell commands.
* Don't try to recover when DMA pointers wrap if the driver isratchov2019-03-311-3/+3
| | | | | using bounce buffers. In this case, hardware underruns are managed by the driver on the bounce buffers, not the audio ring buffer.
* Add new copy_output() and underrun() methods to support driversratchov2019-03-121-4/+12
| | | | | | using bounce buffers, like the uaudio(4) driver. ok mpi
* Use the return value of task_add(9) to determine whether the task waskettenis2018-12-311-20/+7
| | | | | | already scheduled and whether we have to unref the device ourselves. ok tedu@, ratchov@
* must remember to unref device if setting the task isn't done.tedu2018-12-271-1/+5
| | | | ok anton
* sc argument of start_output, start_input, trigger_output and trigger_inputmiko2018-10-311-7/+7
| | | | is void* so no need to cast; ok ratchov@
* Save all mixer elements in the suspend/resume array instead of onlyratchov2018-06-241-10/+3
| | | | | | | | enum, sets, and values. This is simpler and less error prone. This fixes the record.enable elements replacing the last few hardware mixer controls. Help from Laurence Tratt, tested by landry@
* In addition to "on" and "off", allow the audio "record.enable" mixerratchov2018-05-261-4/+17
| | | | | | | | knob to take the new "sysctl" value, which is the default. In this case, the device behavior is determined by the new "kern.audio.record" sysctl(2), which defaults to zero. ok florian
* Add a "record.enable" mixer knob to control recording. When recordingratchov2018-05-261-12/+106
| | | | | | | | is disabled, the device records silence. The control may be modified only by root and defaults to "off", ie. recording is disabled by default. ok florian, deraadt
* Add mixer save/restore capability to the audio(4) driver andratchov2018-04-111-1/+64
| | | | | | | | use it during suspend/resume. Remove driver-specific mixer save/restore bits that don't need to be duplicated in every low-lever driver. ok mpi
* Fix the way we detect xrun on the recording end, which may prevent theratchov2018-03-211-2/+2
| | | | | | | ring read pointer from wrapping, in turn allowing the process to read past the ring boundaries. ok deraadt@
* Remove assignement of sc->round to itself that makes no sense. Fromratchov2018-01-101-2/+1
| | | | Michael W. Bombardieri, thanks.
* No need to grab the audio lock to call audio_canstart() as it checksratchov2017-11-231-4/+3
| | | | | whether the device is started before using structures shared with the interrupt handler. From Michael W. Bombardieri, tested by me.
* Factor a variable assignment in audiopoll().ratchov2017-06-261-3/+2
| | | | From Michael Bombardieri, thanks.
* Remove references to /dev/soundN, which was removed last year.ratchov2017-05-161-10/+2
| | | | From Jan Stary <hans at stare.cz>, thanks.
* style improvement from Michael W. Bombardieri <mb at ii.net>ratchov2017-05-031-5/+4
|
* Simplify rate/channels/bits bounds checking code. Fromratchov2017-03-281-8/+8
| | | | Michael W. Bombardieri <mb at ii.net>. Thanks.
* AUDIO_ENCODING_{S,U}LINEAR constants are neither used by low levelratchov2017-03-111-20/+1
| | | | | drivers nor exposed to user-land. Remove definitions and code to handle convertions.
* If gain is above MAX, no need to check whether it's below MIN.ratchov2017-01-031-2/+2
| | | | From Michael W. Bombardieri. Thanks.
* Fix many typos. From Michael W. Bombardieri <mb at ii.net>. Thanksratchov2016-12-201-8/+8
|
* Remove few useless #ifdef AUDIO_DEBUG, spotted byratchov2016-12-121-14/+4
| | | | Michael W. Bombardieri <mb at ii.net>. Thanks
* Log start/stop of DMA if AUDIO_DEBUG is defined and be less verboseratchov2016-11-081-11/+3
| | | | about buffer parameters. No behaviour change.
* Don't allocate struct mixer_devinfo instances on the stack. It is a fairlykettenis2016-10-091-25/+37
| | | | | | | large data structure and if the compiler gets clever and inlines some code we hit the stack size compiler warning. This makes things compile with clang. ok ratchov@
* Fix the condition used to decide whether to automatically start theratchov2016-10-061-4/+15
| | | | | | device, and factor it into a single function. Without this fix, if the device is open in full-duplex mode, it could start with empty play buffer.
* At acpithinkpad attach time determine the value of the mute, and deferderaadt2016-10-041-4/+36
| | | | | | | telling the audio subsystem about this later on in boot. (Mute state is maintained by the BIOS over a suspend, hibernate, reboot, etc -- this may be last missing piece of the puzzle we tore our hair out in Brisbane) diagnosis and code by Anton Lindqvist, ok ratchov
* Remove unused getdev() audio driver functions.ratchov2016-09-191-2/+1
|
* Remove drain(), query_encoding(), mappage() and get_default_params()ratchov2016-09-141-2/+1
| | | | | methods from all audio drivers and from the audio_if structure as they are never called.
* Delete unused ioctls and associated macros. Move macros that are stillratchov2016-08-311-226/+2
| | | | | used internally by low-level drivers from sys/audioio.h to dev/audio_if.h instead of deleting them.
* fix typos in comments and spacingratchov2016-06-211-4/+4
|
* Add a new AUDIO_GETSTATUS ioctl to get various audio driver variables.ratchov2016-06-181-1/+13
| | | | | It's intended for use with diagnostic tools (like audioctl) and is of no use to audio programs.
* New USB device driver for Audio/Video capture devices based on themglocker2016-06-011-2/+10
| | | | | | | | | | | | Fushicai USBTV007 chip. The chip specific code has been written by Lubomir Rintel and Federico Simoncelli. Patrick Keshishian has ported it to OpenBSD and wrote the remaining code based on uvideo(4). Input and help also from mpi@ and ratchov@. ok mpi
* Use round_blocksize() to determine the maximum hardware block size (inratchov2016-05-111-4/+12
| | | | | | bytes) then, adjust the block size accordingly. Fixes zaudio(4) not starting when large blocks are requested. Found and reported by Andre Smagin <as at smagin.com>, thanks.
* Dont reuse "mult" local variable. Use separate variable for hardwareratchov2016-05-111-8/+9
| | | | | block size multiplier (in bytes) and for the driver block size multiplier (in frames). No behaviour change.
* Expose new audio ioctls that do one thing only: start and stop DMA,ratchov2016-03-161-1/+148
| | | | | | set and get parameters. This is much simpler. ok semarie, armani, tweaks from jmc
* Move the AUDIO_GETDEV ioctl in its own routine.ratchov2016-01-291-6/+12
|
* make AUDIO_GETDEV ioctl return the device name (ex "azalia0") ratherratchov2016-01-201-2/+6
| | | | | | than driver specific strings. ok kettenis