summaryrefslogtreecommitdiffstats
path: root/sys/dev/audio.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* when setting the block size, use the scale factor only once inratchov2008-03-221-6/+6
| | | | | | | audiosetinfo(), so the block size don't get scaled twice. Also fix the formula used in audiosetinfo(). ok jakemsr
* Set the default high water mark to the buffer size, instead of the bufferratchov2008-03-121-2/+2
| | | | | | size minus one block. Otherwise, recording cannot work with 32kB blocks. ok jakemsr@
* from audio(4):jakemsr2008-02-281-5/+8
| | | | | | | | | | | | | | | | | | 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@
* use tables to determine the best control to use for play.gain, record.gainratchov2007-11-171-37/+73
| | | | | | | 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@
* prepare audio(4) for addition of the envy(4) driver: enable 32bit samplesratchov2007-10-281-35/+24
| | | | | | | (basically only audio_fill_silence() must be updated) and bump max channel number to 12 ok jakemsr@
* the pointer we give to audio_fill_silence() may point in the middle of aratchov2007-10-281-13/+23
| | | | | | | | 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@
* fix: when a block is captured audio_rint() is called, we mustratchov2007-10-271-2/+2
| | | | | | | | 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@
* sc->sc_pr.usedlow must be multiple of the block size, fixratchov2007-10-251-5/+9
| | | | | | audio_calcwater() to do so ok jakemsr@
* return POLLOUT as long as (lowat + 1) isn't reached. without this audio(4)ratchov2007-10-251-2/+2
| | | | | | is unusable with lowat = 1 ok jakemsr@
* add a new audio_set_blksize() function that sets (and adjusts) the blockratchov2007-10-231-36/+47
| | | | | | | | 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
* fix audio_calc_blksize() not to return larger block sizes thanratchov2007-10-191-5/+8
| | | | | | the buffer size ok jakemsr
* add two new audio ioctls, AUDIO_GETPRINFO and AUDIO_GETRRINFO, and thejakemsr2007-10-031-2/+43
| | | | | | | | | | | | | | 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
* accept values > 1 for "output_muted". That's what SunOS do. Suggestedratchov2007-09-241-2/+2
| | | | | | by deanna@ ok jakemsr@
* fix audioctl(1) returning bugus values of 'output_muted' because ofratchov2007-09-241-1/+3
| | | | | | uninitialized variable. found by deanna@, ok jackmsr@
* implement the output_muted member of audio_info_t as found in originaljakemsr2007-09-171-1/+9
| | | | | | Sun audio. input from and ok ratchov
* use au_get_gain()/au_set_gain() and the new au_get_mute()/au_set_mute()jakemsr2007-09-171-114/+28
| | | | | | | | | | 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
* add functions to mute/unmute outputjakemsr2007-09-171-1/+71
| | | | ok ratchov
* fix uninitialized linked list headratchov2007-09-101-1/+2
| | | | ok jakemsr@
* initialize sc_outports->master and sc_inports->master. Fixes "set failed"ratchov2007-09-101-1/+3
| | | | | | errors when running audioctl(1) on devices without master controls ok jakemsr@
* don't try to set the recording gain or balance through /dev/audio[ctl]jakemsr2007-09-091-3/+3
| | | | | | | if the selected recording port is not a port the limited /dev/audio[ctl] interface to mixer controls supports. ok ratchov@
* revert the change in rev 1.60 of audio.c and the correspondingjakemsr2007-08-081-2/+4
| | | | | | | | | | documentation change the audio layer is still too "imperfect" for this change fixes problems reported aanriot, matthieu and dtucker requested by deraadt
* for consistency, keep the count of dropped data in HW sample size, andjakemsr2007-08-021-11/+25
| | | | | | | convert to userland sample size when needed. why this subsystem wasn't written with samples as the basic unit of measure is beyond me.
* the MI audio layer never really knows what encoding the hardware uses;jakemsr2007-08-021-8/+33
| | | | | | | | | | 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.
* always ignore attempts to set the record or play port to 0.jakemsr2007-07-311-3/+3
| | | | | | | | | | | | | 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.
* - when traversing mixer fields in the attach routine and connectingjakemsr2007-07-181-4/+10
| | | | | | | | | | | | | | | | | | | | | | 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
* move the processing of the pause attribute to the end of audiosetinfo(),jakemsr2007-07-181-22/+22
| | | | | | | | | | | | 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@
* more places where the difference between the hardware sample sizejakemsr2007-07-171-10/+14
| | | | | | | | | | | | | | 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.
* - the data in the read buffer, that was put there by the hardware,jakemsr2007-07-171-4/+5
| | | | | | | | | | | | | | | | | | 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
* - ANSI function declarationsjakemsr2007-07-141-215/+73
| | | | | | - remove argument names from function prototypes OK jasper@, ray@, "Didn't notice any errors" marc@
* fix the bug rev 1.56 uncovered and rev 1.62 worked around.jakemsr2007-07-101-3/+3
| | | | | | | | data is expanded before it goes in the buffer. all sizes and offsets used internally are of this expanded data. there's no need to compensate for this fact except when showing information to the user in case their actions depend on how many bytes are in the buffer.
* take into account possible expansion and be more careful not tojakemsr2007-07-091-2/+2
| | | | | | | | | | try to go past the end of the buffer. this and the last commit allow ffplay and gnash to work properly on devices that may need to do mono to stereo conversion, like auich(4). problem reported by and much debugging deanna@
* give the user what they expect instead of what we're working withjakemsr2007-07-091-2/+2
| | | | | | by taking into account expansion we may have done in cases such as playing monoaural media on a device that only plays stereo, like auich(4).
* - enable full-duplex mode by default if a device is openedjakemsr2007-07-061-4/+2
| | | | | | | | | | read-write and it supports full-duplex operation. - update documentation to match this behaviour. see http://marc.info/?l=openbsd-tech&m=118310788926431&w=2 for more background on this change "patches look correct to me" marc@
* the AUDIO_WSEEK ioctl should return the number of bytes in the playjakemsr2007-07-061-2/+2
| | | | | | | | buffer, not the record buffer. inspired by recent similar change in NetBSD. "patches look correct to me" marc@
* be sure to respect the pause attributejakemsr2007-07-061-6/+6
| | | | | | originally from Alexandre Ratchov "patches look correct to me" marco@
* - there is no need for audio_init_ringbuffer() to always set the "pause"jakemsr2007-07-061-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | attribute to '0'. this function may be called when executing an AUDIO_SETINFO ioctl where the pause attribute was set to '1', and setting it to '0' in this function will cause unexpected bahaviour. - according to audio(4), the AUDIO_FLUSH ioctl "restarts recording and playback". therefor, it should set the pause attributes to '0'. this was previously accomplished indirectly, because it calls audio_init_ringbuffer(), which was setting pause to '0'. - the pause attribute must be set to '0' in audio_open() so that recording and playback buffers can be "activated" when the device is opened. this was apparently forgotten when audiosetinfo() was split off of audio_open() and the logic in audiosetinfo() was changed to accomodate being run at times other than open(). also, this only really affects read() with poll(), which may explain why the problem was not noticed for some time. originally part of a patch Alexandre Ratchov sent to tech@ a while back fixes PR 3813 "patches look correct to me" marco@
* The poll(2) syscall doesn't work correctly on audio(4) devices.jakemsr2007-07-061-4/+8
| | | | | | | | | | | | For instance, it may not set POLLIN when samples become available, or may set POLLOUT when write(2) will block. Fix this by making conditions used by poll (FILTREAD and FILTWRITE macros) match the blocking conditions in audio_read() and audio_write(). originally from Alexandre Ratchov, with a small tweak by me. "patches look correct to me" marco@
* switch wskbd hotkeys over to workq. this eliminates quite a bit of code,tedu2007-05-311-7/+7
| | | | | so remove the option too. if you have audio and wskbd, you have hotkeys. ok dlg
* Protect against zero blocksize (causing a divide by zero) in audiogetinfo().miod2007-01-071-4/+7
|
* Compile the mixer tuning via keyboard code if NWSKBD_HOTKEY if nonzeromiod2006-11-291-5/+5
| | | | rather than NWSKBD being nonzero.
* poll errors should be POLLERR, not some random E valuetedu2006-11-011-3/+3
| | | | from alexandre ratchov. ok claudio
* In a drivers activate() entry point, if on DVACT_DEACTIVATE it doesmiod2006-06-231-2/+1
| | | | | | something, then it MUST return zero on DVACT_ACTIVATE, not EOPNOTSUPP; this very popular bug has been cut and pasted a lot of times... ok deraadt@ mickey@
* Add support for the audio volume keys found on many laptops' builtinmiod2006-05-291-1/+168
| | | | | | | keyboard. These specific keys are posted to a kernel thread which will issue mixer commands if an audio device exists. Written by Alexey Vatchenko <avv , mail zp ua> with tweaks by deraadt@ and I.
* explicitly initialize a couple variablesjakemsr2006-03-121-1/+3
| | | | OK brad@
* remove last traces of __BROKEN_INDIRECT_CONFIG.brad2006-01-021-10/+1
| | | | | Thanks to aanriot@ and Michael Knudsen for checking that alpha/i386/macppc kernels still compile.
* Move contents of sys/select.h to sys/selinfo.h in preparation for amillert2005-11-211-2/+2
| | | | | userland-visible sys/select.h. Consistent with what Net and Free do. OK deraadt@, tested with full ports build by naddy@.
* correctly close the audio device in audio_open() if one of thejoris2005-06-021-2/+3
| | | | | | precision parameters is zero. ok tedu@
* Make sure recording is started before we return EWOULDBLOCK in a read().brad2005-04-141-7/+7
| | | | | | From NetBSD ok mickey@
* replace strange cpp magic by straight codevincent2004-07-101-7/+5
| | | | ok deraadt@
* remove uvm_extern.hbrad2004-01-091-3/+1
| | | | | | tested on alpha, i386, powerpc, sparc64, m68k. ok miod@