Commit Graph

191 Commits

Author SHA1 Message Date
fredb fec463c4fe Comment as to why we run through the devinfo list twice, in audioattach(). 2005-02-13 23:50:22 +00:00
kent 68559dd1d9 fix a typo in audiogetinfo().
No behaviour changes though the code was wrong.
2005-02-13 17:05:15 +00:00
kent 373214b329 * audiosetinfo()
call audio_clear() only when blocksizes are actually changed.
  This fixes a problem on some audio devices and applications which
use ossaudio and call SNDCTL_DSP_GETOSPACE repeatedly while playing.

* audiostartp()
  add some debug prints.
2005-01-29 18:16:49 +00:00
minoura c2a6ed3b7b Fix panic when precision < 8.
From kent@.
2005-01-17 14:13:19 +00:00
kent ba29617639 minor KNF 2005-01-15 16:23:03 +00:00
kent 14eae77d98 fix a typo in audiostartp(). This change fixes a problem introduced by
kent-audio1 merger with some audio hardware such as emuxki.
2005-01-15 04:57:18 +00:00
kent 23b5d91433 merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
  - remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels.  Conversion information
is conveyed by stream_filter_list_t.
  - change the type of sample_rate: u_long -> u_int
  - add `validbits,' which represents the valid data size in
precision bits.  It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
 - add two parameters to set_params()
	stream_filter_list_t *pfil, stream_filter_list *rfil
   A HW driver should set filter recipes for requested formats
 - constify audio_params parameters of trigger_output() and
trigger_input().  They represent audio formats for the hardware.
 - make open() and close() optional
 - add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
 to round_blocksize()

* sw_code is replaced with stream_filter_t.
  stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
  converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
 - audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
 - audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
 - audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
 - ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-10 22:01:36 +00:00
yamt 18f717bb90 constify audio_hw_if, midi_hw_if, and radio_hw_if. 2004-10-29 12:57:15 +00:00
mycroft 77bfa3ce71 If we're short-circuiting audiostartp() because there isn't enough data
present, do an extra wakeup() on the write channel.  This happens when we
change parameters during playback, at which point we flush the buffer, and
would stall.
2004-07-07 22:30:22 +00:00
fredb 7f674884ad Fix a couple of long-standing bugs in the volume control(s) part of the
audio device interface:

1) When attempting to match the appropriate mixer control, we weren't
checking the class label, but only the second level label, so for
devices that had both an "inputs.cd" and a "record.cd", for example,
we could never do the right thing except by chance. For this reason,
evidently, all the record masters were labeled (by the underlying
drivers) either "record.record" or "record.volume", to distinguish
from "outputs.master". We'll now accept "record.master", and document
that as the the new preferred way.

2) More importantly, the model was deficient. Selecting a port on many
chips completely disables most of the level controls, which doesn't play
nice with other applications which are trying to use the interface. Now,
selecting a port simply sets which mixer input control shall be changed,
setting state in the audio layer. In other words, the "mixerout" port
is really selected all the time, enabling the final stage mixer, and
setting "gain" sets the level of the appropriate input. It should be
possible for separate applications to each control the mic, dac, and cd
inputs at the same time using this interface, simply by reiterating their
port selections with each change, but applications that don't bother to
do that aren't any worse off than they were before.

The user is expected to set the master output with another application,
dedicated to that task. Though it is now meaningful to select "no port"
with the audio device interface, to manipulate the master output, there's
no particular reason for an audio device consumer to do that. (I added
the capability in order to restore the initial state of the audio device,
for testing purposes. It might also be useful to users of broken binary-
only applications.)

Observe that the mixer device interface (and so, "mixerctl") still
retains all capabilities, including the ability to set the actual input
port on the chip, overriding the level controls. No change is being made
to the mixer device interface. The mixer device simply presents all the
controls on the chip, with no attempt at abstraction, so there are no
bugs there.

The upshot is, that applications that have been trying to use the audio
device interface to change the volume, such as mplayer, now "just work".

I've tested these changes extensively with "eso" and "eap" since first
proposing them on tech-kern last January, and somewhat with "esm" and a
few others. This closes both PR kern/10221, and PR kern/17159.
2004-01-31 00:07:56 +00:00
mycroft fc3c7930e6 A bit of cleanup:
* Separate the code to set the default parameters into a new function,
  audio_set_defaults().  Make it use audiosetinfo(), which properly initializes
  the block size and whatnot.  Use this in both audioattach() and the
  /dev/audio case of audio_open().
* Do not force a reinitialization when /dev/sound is opened.
* Do all of the block size sanity checks in auto_init_ringbuffer(), not in
  both audio_calc_blksize() and audiosetinfo().
* Fix a bug in audiosetinfo() that caused the block size to not be recalculated
  immediately if we set it to 0.
* For AUDIO_GET[IO]OFFS, modify the deltablks calculation so that it gives us
  the number of block boundaries crossed.
2003-10-02 07:15:20 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
augustss 4cc039d469 Add FIONREAD ioctl(). 2003-05-26 12:43:35 +00:00
wiz 1ffa7b76c4 DMA, not dma nor Dma. 2003-05-03 18:10:37 +00:00
gmcgarry 2bdf9ba1f2 Fix full-duplex mode (again).
Back-out revision 1.170 and and 1.166.  Revision 1.170 fixes some problems
introduced in revision 1.166.  It isn't clear what problem revision 1.166
was attempting to address.  It seems bogus anyway, since we later check
the modes in audio_check_params().
2003-04-25 03:02:11 +00:00
wiz 68caa698b2 Respect the law: Use A-law and mu-law as spellings as far as easily possible.
Inspired by Igor Sobrado in PR 19680.
2003-04-06 18:20:07 +00:00
jdolecek cd8e491e95 sprinkle const qualifiers to const stuff 2003-03-31 18:47:58 +00:00
thorpej e354490475 Use aprint_*(). 2003-01-31 02:15:57 +00:00
thorpej 72a7af27b0 Use aprint_normal() in cfprint routines. 2003-01-01 00:10:15 +00:00
augustss 185623c571 Use correct values to compute record high water mark. From kern/19614 by
Ron Roskens.
2002-12-31 00:33:10 +00:00
fredette 9d97e92d89 If the user is providing a mode value in AUDIO_SETINFO, that value
cannot change the recording or playback mode of the device, it can
only change other mode-like values (like AUMODE_PLAY_ALL).  Be very
explicit about fixing up the user's mode value based on the mode of
the device.  Before, giving AUMODE_PLAY_ALL could cause AUMODE_PLAY
to become set on the device, and once AUMODE_PLAY_ALL was set it
was impossible to clear.
2002-12-20 18:30:01 +00:00
christos 514f7047e4 si_ -> sel_ 2002-11-26 18:49:40 +00:00
kent 48dbdc6afe Fix LR contrary problem of play.balance and record.balance. The
change is based on PR kern/18901 by SUNAKAWA Hirokatsu.
2002-11-08 05:02:07 +00:00
jdolecek e0cc03a09b merge kqueue branch into -current
kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
2002-10-23 09:10:23 +00:00
jdolecek cafbd6033f for AUDIO_SETINFO, silently enforce same mode as the currently used one;
this value is supposed to be read-only for this ioctl
2002-10-16 21:07:08 +00:00
thorpej c9b3657ce9 Add trailing ; to CFATTACH_DECL. 2002-10-02 16:33:28 +00:00
thorpej e9d707fbd5 Use CFATTACH_DECL(). 2002-09-30 21:17:57 +00:00
thorpej f818766afe Declare all cfattach structures const. 2002-09-27 20:31:45 +00:00
simonb 4e3613273b Remove breaks after returns, unreachable returns and returns after
returns(!).
2002-09-23 05:51:10 +00:00
christos 6079632012 fix unitialized variable. from simonb. OI 2002-09-23 03:44:56 +00:00
gehenna 77a6b82b27 Merge the gehenna-devsw branch into the trunk.
This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

	device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
  by using this grammer.

- Added the new naming convention.
  The name of the device switch must be <prefix>_[bc]devsw for auto-generation
  of device switch tables.

- The backward compatibility of loading block/character device
  switch by LKM framework is broken. This is necessary to convert
  from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
  We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
  the LKM framework will refer it to assign device major number dynamically.
2002-09-06 13:18:43 +00:00
gson 94addcb364 When a recording interrupt happened in the middle of audio_read(),
changes to cb->used by audio_rint() could be overwritten by audio_read().
2002-07-10 02:25:49 +00:00
gmcgarry 5a74b0b2f5 Back out revision 1.132. This revision broke binary compatibility with
binaries which were working fine on NetBSD 1.5.  We defer this change
until a longer-term fix is found as explain in the commit message in
revision 1.132.

Further details can be found in PR17159.
2002-06-23 01:36:07 +00:00
gson a257b81df8 The logic in audio_poll() was incorrect in full duplex mode;
among other things, it behaved as if full-duplex audio devices
were always ready for writing.  Also commented the code in case.
This fixes PRs kern/11179 and kern/13829.
2002-06-02 02:00:30 +00:00
gson 910011f658 When audio recording was paused or dropping samples, the "outp" of the
recording ring buffer could overrun the end of the buffer.  When
recording resumed, memory after the end of the buffer would be read,
sometimes causing a system crash.
2002-05-27 17:13:14 +00:00
kent a37082a494 whitespace and folding fix. 2002-03-23 17:17:10 +00:00
isaki fa9ce0dedb Fix previous commit. modifying cc is only when factor_denom > 1.
reviewed by kent@netbsd.org
2002-03-21 05:22:24 +00:00
isaki ec23c6650c Fix infinate loop in recoding on vs0. 2002-03-17 03:20:40 +00:00
isaki ae997346b5 Add factor_denom, a denominator of factor,
in 'struct audio_param' for vs0 on x68k.

{hw,user}_bytes_per_sample is changed to {hw,user}_bits_per_sample
to handle 4bit/sampling.
2002-03-16 08:58:49 +00:00
kent 569fb75aef audio.c: revert a part of previous change.
auconv.c: correct handling of size parameter.
2002-03-15 14:55:03 +00:00
kent a5bad132ba Fix a bug of audio_read() in a case that params->factor is not 1. 2002-03-15 14:35:32 +00:00
kent a1f23f2a90 Move sampling rate conversion functions to aurateconv.c.
Introduce "aurateconv" attribute for audio devices.
Add aurateconv to uaudio and auich.
(due to kern/15845 and kern/15848)
2002-03-09 20:30:42 +00:00
toshii f9d3d32c2e Fix splaudio/splx botch. 2002-03-09 07:25:41 +00:00
thorpej 4c3cc0bfe3 Fix printf format on LP64. 2002-03-08 02:30:54 +00:00
kent c329c38eef Sampling rate and mono-stereo conversion described in
http://mail-index.netbsd.org/tech-kern/2002/03/04/0005.html

auconv.c: Add conversion functions

audio.c: Sample alignment, calling conversion functions, etc.

audio_if.h: Add four hw_* members to "struct audio_params"

audiovar.h: Add conversion buffers, etc.

auich and uaudio: Add conversion request code to *_set_params().
2002-03-07 14:37:02 +00:00
jdolecek 74c54977ea drop completely superfluous PRINT() macro 2002-01-18 21:59:41 +00:00
perry 4c7e639df1 fix a trivial lint warning 2001-11-17 05:31:27 +00:00
lukem 2bbe2de647 add RCSIDs 2001-11-13 05:32:49 +00:00
augustss 3d2be4cf9b Fix pasto in type of dev_ioctl method. 2001-10-03 20:48:41 +00:00