summaryrefslogtreecommitdiff
path: root/sys/dev/audio.c
AgeCommit message (Collapse)Author
2011-07-03Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingMatthew Dempsky
that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago
2011-07-02kqueue attach functions should return an errno or 0, not a plain 1. FixNicholas Marriott
the obvious cases to return EINVAL and ENXIO. ok tedu deraadt
2011-06-06Microphone mute button support from acpithinkpad (or elsewhere).Theo de Raadt
The audio side is a bit lacking; it does not yet mute all types of devices. from Alexander Polakov ok jakemsr
2010-11-18Don'tMiod Vallat
#include "foo.h" #if NFOO > 0 (whole file) #endif since config(8) file inclusion rules already do it for you. ok deraadt@
2010-09-21change quiescing to not call the audio_hw_if halt method in interruptJacob Meuser
context, because drivers (like eso(4) and envy(4)) might want to sleep in their halt method.
2010-09-12DVACT_{QUIESCE,RESUME} for audio(4)Jacob Meuser
DVACT_QUIESCE: 1) waits until ringbuffer current position wraps back to the start of the buffer 2) stops playback and/or recording by way of the hardware drivers' "halt" audio_hw_if method 3) blocks userland access to audio device 4) saves the current state of the master mute, then mutes it DVACT_RESUME: 1) reprogram hardware stream parameters for playback or recording if they were active at DVACT_QUIESCE by way of hardware drivers' "set_params" audio_hw_if method 2) start playback or recording if they were active at DVACT_QUIESCE by way of hardware drivers' "trigger" or "start" audio_hw_if method 3) restores master mute state as it was at DVACT_QUIESCE 4) wakes up blocked userland processes accessing the hardware
2010-07-15add two new members to structs audio_encoding and audio_prinfo.Jacob Meuser
for both structs, the new members are 'bps' and 'msb', which describe the number of bytes per sample and data alignment in the sample, respectively. drivers must properly set these fields in the 'query_encoding', 'set_parameters' and 'get_default_params' hardware interface methods. discussed with ratchov, deraadt
2009-11-09Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tNicholas Marriott
supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
2009-10-27in the get_default_parameters method, give the low level drivers aJacob Meuser
pointer to the low level driver's softc, not audio's softc. nothing is actually using this yet. ok ratchov
2009-10-13Get rid of devact enum, substitute it with an int and coresponding defines.Paul Irofti
This is needed for the addition of further suspend/resume actions. Okay deraadt@, marco@.
2009-06-18fix previous: start playback when at least one block of data hasJacob Meuser
been written to the device, instead of waiting for a write(2) when the buffer is or will be over the high water mark. ok ratchov@
2009-03-21don't call uiomove(9) at IPL_AUDIO, slightly simplify the codeAlexandre Ratchov
help from and ok jakemsr
2009-03-16first stage of removing ``copying & needfeel'' flags thatAlexandre Ratchov
make the audio driver missing blocks and, thus, breaking full-duplex apps. help and ok jakemsr
2009-01-16deal with sample precisions that are not a power of 2.Jacob Meuser
discussed with and ok ratchov; manpage tweak from naddy, thanks
2008-10-30for devices that do not allow independent setting of recording andJacob Meuser
playback parameters (like the macppc i2s devices), be sure to synchronise recording parameters to playback parameters when configuring for full-duplex operation, as audio(4) dictates. ok ratchov
2008-10-25audio(9) says low level drivers are allowed to change the requestedJacob Meuser
values of the audio_params structure during AUDIO_SETINFO if the hardware cannot be set to exactly the requested mode. some drivers do this sometimes. others always return EINVAL if there isn't an exact match. be more consistent. only return EINVAL if an absurd parameter was requested, otherwise return a supported set of parameters, as close as possible to what was requested. with/ok ratchov@
2008-09-29account for data expansion due to emulation in AUDIO_GET{I,O}OFFSJacob Meuser
ioctls. ok ratchov@
2008-08-10'flus' -> 'flush', 'waitinf' -> 'waiting'. From Dawe via tech@.Kenneth R Westerback
2008-07-29When paused (or overrun), the record ring pointers are not incrementedAlexandre Ratchov
properly in audio_rint(), the periodic boundary conditions aren't met. This causes, later read(2) to return EFAULT while trying to access unmapped regions of the kernel address space. Fix this by using the correct pointer arithmetic. ok jakemsr@
2008-04-21allow low level audio drivers to specify a default sample format,Jacob Meuser
instead of 8-bit mono mulaw @ 8kHz. this is just the infrastructure; no drivers are specifying a default yet. ok ratchov@, deanna@
2008-04-04if full-duplex is being turned on, also set the oprtational mode toJacob Meuser
for both recording and playback. ok ratchov
2008-03-22add audio(4) driver the ability to use different block sizes for play andAlexandre Ratchov
record modes. This makes possible to have blocks of the same duration if the play and record formats are different. The API change is backward compatible, so it shouldn't be noticed by current audio ports. ok jakemsr
2008-03-22when setting the block size, use the scale factor only once inAlexandre Ratchov
audiosetinfo(), so the block size don't get scaled twice. Also fix the formula used in audiosetinfo(). ok jakemsr
2008-03-12Set the default high water mark to the buffer size, instead of the bufferAlexandre Ratchov
size minus one block. Otherwise, recording cannot work with 32kB blocks. ok jakemsr@
2008-02-28from audio(4):Jacob Meuser
blocksize sets the current audio blocksize. The generic audio driver layer and the hardware driver have the opportunity to ad- just this block size to get it within implementation-required limits. Upon return from an AUDIO_SETINFO call, the actual blocksize set is returned in this field. Normally the blocksize is calculated to correspond to 50ms of sound and it is recalcu- lated when the encoding parameter changes, but if the blocksize is set explicitly this value becomes sticky, i.e., it remains even when the encoding is changed. The stickiness can be cleared by reopening the device or setting the blocksize to 0. however, there were insufficient checks to make the blocksize is actually sticky once it is set by the user. this adds them. ok ratchov@
2007-11-17use tables to determine the best control to use for play.gain, record.gainAlexandre Ratchov
and monitor_gain; this makes play.gain always usable as general purpose volume knob even on devices that don't have outputs.master. ok jakemsr@, deanna@
2007-10-28prepare audio(4) for addition of the envy(4) driver: enable 32bit samplesAlexandre Ratchov
(basically only audio_fill_silence() must be updated) and bump max channel number to 12 ok jakemsr@
2007-10-28the pointer we give to audio_fill_silence() may point in the middle of aAlexandre Ratchov
sample (eg. if write(2) have written an odd number of bytes and 16bit encoding is used), so we'll not properly write silence. To fix this, round start pointer to fill with silence uncomplete samples too. ok jakemsr@
2007-10-27fix: when a block is captured audio_rint() is called, we mustAlexandre Ratchov
consider that the ring buffer has overrrun if (used >= usedhigh) and not if (used >= usedhigh + blksize), otherwise recording doesn't work when large enough blocks are used ok jakemsr@
2007-10-25sc->sc_pr.usedlow must be multiple of the block size, fixAlexandre Ratchov
audio_calcwater() to do so ok jakemsr@
2007-10-25return POLLOUT as long as (lowat + 1) isn't reached. without this audio(4)Alexandre Ratchov
is unusable with lowat = 1 ok jakemsr@
2007-10-23add a new audio_set_blksize() function that sets (and adjusts) the blockAlexandre Ratchov
size to the given number of frames per second, all changes pass through it. If parameters are changed or the user requested a new block size (or both), the block size is recalculated. ok jakemsr
2007-10-19fix audio_calc_blksize() not to return larger block sizes thanAlexandre Ratchov
the buffer size ok jakemsr
2007-10-03add two new audio ioctls, AUDIO_GETPRINFO and AUDIO_GETRRINFO, and theJacob Meuser
data structure these ioctls use, audio_bufinfo. these ioctls return information about the play and record buffers into the audio_bufinfo structure. these are being added to aid in porting non-native audio applications and libraries, and to fix issues in our OSS audio emulation. these ioctls exist only on OpenBSD and should not be used in code intended for distribution. ok ratchov
2007-09-24accept values > 1 for "output_muted". That's what SunOS do. SuggestedAlexandre Ratchov
by deanna@ ok jakemsr@
2007-09-24fix audioctl(1) returning bugus values of 'output_muted' because ofAlexandre Ratchov
uninitialized variable. found by deanna@, ok jackmsr@
2007-09-17implement the output_muted member of audio_info_t as found in originalJacob Meuser
Sun audio. input from and ok ratchov
2007-09-17use au_get_gain()/au_set_gain() and the new au_get_mute()/au_set_mute()Jacob Meuser
functions instead of doing things the hard way. also add some bits to au_set_gain() so it sets a gain that is within limits. its possible to pass in an out-of-range value through audioctl(1) as well. ok ratchov
2007-09-17add functions to mute/unmute outputJacob Meuser
ok ratchov
2007-09-10fix uninitialized linked list headAlexandre Ratchov
ok jakemsr@
2007-09-10initialize sc_outports->master and sc_inports->master. Fixes "set failed"Alexandre Ratchov
errors when running audioctl(1) on devices without master controls ok jakemsr@
2007-09-09don't try to set the recording gain or balance through /dev/audio[ctl]Jacob Meuser
if the selected recording port is not a port the limited /dev/audio[ctl] interface to mixer controls supports. ok ratchov@
2007-08-08revert the change in rev 1.60 of audio.c and the correspondingJacob Meuser
documentation change the audio layer is still too "imperfect" for this change fixes problems reported aanriot, matthieu and dtucker requested by deraadt
2007-08-02for consistency, keep the count of dropped data in HW sample size, andJacob Meuser
convert to userland sample size when needed. why this subsystem wasn't written with samples as the basic unit of measure is beyond me.
2007-08-02the MI audio layer never really knows what encoding the hardware uses;Jacob Meuser
the hardware drivers just set a conversion function. when the MI audio layer needs to add silence, it adds silence in the userland format, but the amount added is for the hardware sample size. this diff fixes both record mode by sending the right amount, and play mode by converting the silence to the right format.
2007-07-31always ignore attempts to set the record or play port to 0.Jacob Meuser
this interface to mixer functionality is very limited, and is only used for recording. it only recognizes 'mic', 'cd', and 'line' as valid recording inputs. many devices have other inputs. because of the way AUDIO_INITINFO works, it is impossible to expand this API to include all devices. this fixes another common cause of audioctl(1) problems. AUDIO_GETINFO returns 0 for record.port when the recording port is something other than 'mic', 'cd', or 'line', and the subsequent AUDIO_SETINFO would fail on this.
2007-07-18- when traversing mixer fields in the attach routine and connectingJacob Meuser
the mixer layer to the audio layer, differentiate between the 'monitor' class and the 'outputs' class instead of lumping them together. not all mixers have a monitor class entry which was causing the outputs class to be ignored. - look for monitor port in the monitor class, but if the monitor port is not found in the monitor class look in the outputs class as well. the code was effectively looking in both the monitor and outputs classes before, so this is no real change. sets up audio_info.play.[gain|balance] correctly on at least emu(4), auich(4), auvia(4) and snapper(4) ... probably most other AC'97 devices as well. as a result, audioctl(1) works much better and the overall volume can be set with /dev/audio instead of needing to go through /dev/mixer. from deanna@ thanks again to those who tested this change
2007-07-18move the processing of the pause attribute to the end of audiosetinfo(),Jacob Meuser
to allow buffer sizes and pointer to the buffer to be set to reasonable values for the sample size of the data to be read/written. fixes kernel corruption seen with azalia and probably other drivers that are using something other than 8kHz monaural mulaw as the default encoding when doing 'dd if=/dev/audio of=foo' as the first audio operation after boot. problem reported by deanna@
2007-07-17more places where the difference between the hardware sample sizeJacob Meuser
and the userland sample size matters. there may be different sample size factors for play and record, so use the appropriate factor when userland sets the blocksize. the reported blocksize, hiwat and lowat are only for the play buffer. IMO, it would be good to report the record blocksize, hiwat and lowat as well, but that is another issue. tested with emu(4) and an auvia(4) modified to only do stereo in hardware.
2007-07-17- the data in the read buffer, that was put there by the hardware,Jacob Meuser
may not be the same sample size as what userland is to receive. account for the discrepency between the sample sizes when comparing how much to copy out with what userland expects. - only copy out the part of the buffer that is in the format userland expects. emu(4) can now record with all encodings it claims to be able to. that is, dd if=/dev/audio of=foo does as audio(4) says (monaural mu-law) and does it correctly. AFAIKS, the only other driver that sets a read factor is uaudio(4), and that depends on what the hardware supports. tested on i386, amd64 and sgi with 3 different emu(4) cards