summaryrefslogtreecommitdiff
path: root/sys/dev/audio.c
AgeCommit message (Collapse)Author
2021-05-16panic does not require a \n at the end. When one is provided, it looks wrong.Theo de Raadt
2020-12-25Refactor klist insertion and removalVisa Hankala
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@
2020-05-19Implement kqueue(2) support.Martin Pieuchot
Assert that the KERNEL_LOCK() has to be held before grabbing `audio_lock' to prevent lock ordering issues inside selwakeup(). ok visa@, ratchov@
2020-05-16Use softintr to call selwakeup() in the mixer code code-pathAlexandre Ratchov
ok mpi
2020-04-18Remove support for unused /dev/mixer device nodes.Alexandre Ratchov
ok deraadt
2020-03-08Wake up processes reading the mixer when the device is detached.Alexandre Ratchov
2020-02-13Fix missing locking during calls to selwakeup().Alexandre Ratchov
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@.
2020-01-29Add support for notifications about audio(4) controls changes.Alexandre Ratchov
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.
2020-01-24Rename audio_mixer_{read,write} to audio_mixer_{get,set}.Alexandre Ratchov
The audio_mixer_{read,write} names are misleading: these functions are not the methods of the read and write syscalls. No object change.
2019-12-18audio(4): msleep(9) -> msleep_nsec(9)cheloha
ok ratchov@
2019-10-07Convert infinite tsleep(9) to tsleep_nsec(9).Martin Pieuchot
ok ratchov@
2019-09-10If the requensted block size is too large, then use half theAlexandre Ratchov
buffer size instead of failing. Problem found and fix tested by Joe Davis <me at jo.ie>, thanks!
2019-09-05Add the set_blksz() and set_nblks() audio driver functions.Alexandre Ratchov
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@
2019-08-17Move play blocks count from the audio_softc to the audio_buf structure.Alexandre Ratchov
As the audio_buf structure is per-direction, this makes play and recording code similar. No behavior change.
2019-08-17Move block size and block count calculations in their own routines.Alexandre Ratchov
Makes the code easier to read, no behabior change.
2019-04-05Try to start playback after play buffer pointers are advanced.Alexandre Ratchov
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.
2019-03-31Don't try to recover when DMA pointers wrap if the driver isAlexandre Ratchov
using bounce buffers. In this case, hardware underruns are managed by the driver on the bounce buffers, not the audio ring buffer.
2019-03-12Add new copy_output() and underrun() methods to support driversAlexandre Ratchov
using bounce buffers, like the uaudio(4) driver. ok mpi
2018-12-31Use the return value of task_add(9) to determine whether the task wasMark Kettenis
already scheduled and whether we have to unref the device ourselves. ok tedu@, ratchov@
2018-12-27must remember to unref device if setting the task isn't done.Ted Unangst
ok anton
2018-10-31sc argument of start_output, start_input, trigger_output and trigger_inputmiko
is void* so no need to cast; ok ratchov@
2018-06-24Save all mixer elements in the suspend/resume array instead of onlyAlexandre Ratchov
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@
2018-05-26In addition to "on" and "off", allow the audio "record.enable" mixerAlexandre Ratchov
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
2018-05-26Add a "record.enable" mixer knob to control recording. When recordingAlexandre Ratchov
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
2018-04-11Add mixer save/restore capability to the audio(4) driver andAlexandre Ratchov
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
2018-03-21Fix the way we detect xrun on the recording end, which may prevent theAlexandre Ratchov
ring read pointer from wrapping, in turn allowing the process to read past the ring boundaries. ok deraadt@
2018-01-10Remove assignement of sc->round to itself that makes no sense. FromAlexandre Ratchov
Michael W. Bombardieri, thanks.
2017-11-23No need to grab the audio lock to call audio_canstart() as it checksAlexandre Ratchov
whether the device is started before using structures shared with the interrupt handler. From Michael W. Bombardieri, tested by me.
2017-06-26Factor a variable assignment in audiopoll().Alexandre Ratchov
From Michael Bombardieri, thanks.
2017-05-16Remove references to /dev/soundN, which was removed last year.Alexandre Ratchov
From Jan Stary <hans at stare.cz>, thanks.
2017-05-03style improvement from Michael W. Bombardieri <mb at ii.net>Alexandre Ratchov
2017-03-28Simplify rate/channels/bits bounds checking code. FromAlexandre Ratchov
Michael W. Bombardieri <mb at ii.net>. Thanks.
2017-03-11AUDIO_ENCODING_{S,U}LINEAR constants are neither used by low levelAlexandre Ratchov
drivers nor exposed to user-land. Remove definitions and code to handle convertions.
2017-01-03If gain is above MAX, no need to check whether it's below MIN.Alexandre Ratchov
From Michael W. Bombardieri. Thanks.
2016-12-20Fix many typos. From Michael W. Bombardieri <mb at ii.net>. ThanksAlexandre Ratchov
2016-12-12Remove few useless #ifdef AUDIO_DEBUG, spotted byAlexandre Ratchov
Michael W. Bombardieri <mb at ii.net>. Thanks
2016-11-08Log start/stop of DMA if AUDIO_DEBUG is defined and be less verboseAlexandre Ratchov
about buffer parameters. No behaviour change.
2016-10-09Don't allocate struct mixer_devinfo instances on the stack. It is a fairlyMark Kettenis
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@
2016-10-06Fix the condition used to decide whether to automatically start theAlexandre Ratchov
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.
2016-10-04At acpithinkpad attach time determine the value of the mute, and deferTheo de Raadt
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
2016-09-19Remove unused getdev() audio driver functions.Alexandre Ratchov
2016-09-14Remove drain(), query_encoding(), mappage() and get_default_params()Alexandre Ratchov
methods from all audio drivers and from the audio_if structure as they are never called.
2016-08-31Delete unused ioctls and associated macros. Move macros that are stillAlexandre Ratchov
used internally by low-level drivers from sys/audioio.h to dev/audio_if.h instead of deleting them.
2016-06-21fix typos in comments and spacingAlexandre Ratchov
2016-06-18Add a new AUDIO_GETSTATUS ioctl to get various audio driver variables.Alexandre Ratchov
It's intended for use with diagnostic tools (like audioctl) and is of no use to audio programs.
2016-06-01New USB device driver for Audio/Video capture devices based on theMarcus Glocker
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
2016-05-11Use round_blocksize() to determine the maximum hardware block size (inAlexandre Ratchov
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.
2016-05-11Dont reuse "mult" local variable. Use separate variable for hardwareAlexandre Ratchov
block size multiplier (in bytes) and for the driver block size multiplier (in frames). No behaviour change.
2016-03-16Expose new audio ioctls that do one thing only: start and stop DMA,Alexandre Ratchov
set and get parameters. This is much simpler. ok semarie, armani, tweaks from jmc
2016-01-29Move the AUDIO_GETDEV ioctl in its own routine.Alexandre Ratchov