Commit Graph

585 Commits

Author SHA1 Message Date
John Baldwin
2c69ba8741 Change snd_mtxcreate() to accept a lock type as an extra argument that is
passed to mtx_init().
2002-04-04 20:54:27 +00:00
Mike Barcroft
08f8120ab2 Include <machine/limits.h> for definition of ULONG_MAX. Remove a
duplicate include.
2002-03-25 09:23:41 +00:00
Alfred Perlstein
85f190e4d1 Fixes to make select/poll mpsafe.
Problem:
  selwakeup required calling pfind which would cause lock order
  reversals with the allproc_lock and the per-process filedesc lock.
Solution:
  Instead of recording the pid of the select()'ing process into the
  selinfo structure, actually record a pointer to the thread.  To
  avoid dereferencing a bad address all the selinfo structures that
  are in use by a thread are kept in a list hung off the thread
  (protected by sellock).  When a selwakeup occurs the selinfo is
  removed from that threads list, it is also removed on the way out
  of select or poll where the thread will traverse its list removing
  all the selinfos from its own list.

Problem:
  Previously the PROC_LOCK was used to provide the mutual exclusion
  needed to ensure proper locking, this couldn't work because there
  was a single condvar used for select and poll and condvars can
  only be used with a single mutex.
Solution:
  Introduce a global mutex 'sellock' which is used to provide mutual
  exclusion when recording events to wait on as well as performing
  notification when an event occurs.

Interesting note:
  schedlock is required to manipulate the per-thread TDF_SELECT
  flag, however if given its own field it would not need schedlock,
  also because TDF_SELECT is only manipulated under sellock one
  doesn't actually use schedlock for syncronization, only to protect
  against corruption.

Proc locks are no longer used in select/poll.

Portions contributed by: davidc
2002-03-14 01:32:30 +00:00
Seigo Tanimura
01d901fff3 Do not call a synthesizer with a sequencer lock held. 2002-03-10 16:56:38 +00:00
Orion Hodson
38c81beede Suspend and resume related patches from Toshikazu Ichinoseki <t.ichinoseki@nifty.com>.
PR's: kern/35484, kern/35230.
2002-03-04 00:36:04 +00:00
Orion Hodson
b3aeda3f1f Add support for VT8233. 2002-03-01 20:30:13 +00:00
Dag-Erling Smørgrav
a0eed7bc1c Add a sysctl, sysctl hw.snd.report_soft_formats, that controls whether the
AIOGCAP ioctl reports software-emulated formats.  It defaults to on.  People
who use performance-sensitive audio software and do not want it to pick a
software-emulated audio format instead of one supported by their hardware
should turn it off.

This unbreaks isdnphone(1) on systems with PCM-only sound cards.

Approved by:	cg
2002-02-24 00:49:43 +00:00
Alfred Perlstein
472cd8b5ef Add play (but not record) support for the Sis 7012.
Submitted by: Mike Meyer <mwm@mired.org>
2002-02-19 00:59:23 +00:00
Thomas Gellekum
cc9f4eb939 Add support for the Aztech 2320 chip.
Reviewed by:	cg
Obtained from:	NetBSD (partly)
2002-02-05 12:09:23 +00:00
Seigo Tanimura
38b968c3a5 - Do not hang if the resource allocation fails.
- Add another quirk entry of SB AWE64.

PR:		kern/32530
Submitted by:	Magnus Backstrom <b@etek.chalmers.se>
2002-02-05 06:52:56 +00:00
Scott Long
60d1d6861b Recent changes to newpcm require that the CHANNEL_SETFORMAT op return 0
for success, non-zero otherwise.  The maestro and maestro3 drivers were
returning the format code, which was being interpreted as a failure code.
Fixed.  No one seems to have noticed that the maestro driver was broken,
but I'll fix it anyways.

MFC after:	2 weeks
2002-01-27 23:09:41 +00:00
Cameron Grant
b8a3639565 * improve error handling
* be more specific in verbose boot messages
* allow the feeder subsystem to veto pcm* attaching if there is an error
  initialising the root feeder
* don't free/malloc a new tmpbuf when resizing a snd_dbuf to the same size as
  it currently is
* store the feeder description in the feeder structure instead of mallocing
  space for it
2002-01-26 22:13:24 +00:00
Scott Long
436c9b651a Fix code that had rotted behind debugging macros.
Approved by:	cg (in principle)
MFC after:	2 weeks
2002-01-25 04:14:12 +00:00
Cameron Grant
be27d718c0 a buffer offset equal to the buffer size is illegal too, fix assertion in
sndbuf_getbufofs()
2002-01-25 02:39:34 +00:00
Cameron Grant
f8db81f347 cosmetic change, free b instead of c->bufhard for consistency within
chn_kill()
2002-01-25 02:36:22 +00:00
Cameron Grant
4c68642adb improve sndstat output of feederchains so it can be understood without
reading the feeder sourcecode
2002-01-23 06:02:15 +00:00
Cameron Grant
4e60be3473 print warnings if a pcm*.buffersize hint is out of range or a non-power-of-2 2002-01-23 05:49:41 +00:00
Cameron Grant
23bc171b29 fix some comments accidentally hit by search/replace several revisions ago 2002-01-23 05:41:35 +00:00
Cameron Grant
0dd4f3508e set the speeds the right way round for recording using the rate feeder 2002-01-23 05:35:12 +00:00
Cameron Grant
1e59d53c22 add more error checking in chn_init() and chn_reset() 2002-01-23 05:21:27 +00:00
Cameron Grant
79e6a82b48 make the feederchain builder work for recording. this has not been tested
extensively as none of my testboxes have speakers or an audio source at
present, but the chains built look correct and reading /dev/audio (ulaw,
translated from signed 16 bit little-endian) gives values within the
expected range for silence.
2002-01-23 05:10:56 +00:00
Cameron Grant
f6126456ef don't bother checking if an unsigned parameter is less than 0 in a KASSERT 2002-01-23 04:50:51 +00:00
Cameron Grant
095159ecd1 add more error checking to open of /dev/dsp* and /dev/audio* - if the
default format for the chosen subdevice cannot be obtained return an error
instead of returning success with an indeteterminate format selected.

note that this should never happen once the feederchain builder works for
recording.
2002-01-23 04:44:03 +00:00
Cameron Grant
1c72c53f4e don't allow mmap beyond the end of the buffer
Submitted by:	Philippe Anel <philippe.anel@noos.fr> (partially)
2002-01-23 04:32:18 +00:00
Orion Hodson
bd8e0aee01 Change ich_calibrate to busy wait on buffer fill level and use a more
likely looking rate calculation.

Install interrupt handler before calling ich_init as the initialization
occasionally generates spurious interrupts.

These changes are derived from cg's work in progress version of this
driver.
2002-01-18 18:44:41 +00:00
Seigo Tanimura
5ddd093d23 Add the system default timer engine. 2002-01-04 01:16:18 +00:00
Seigo Tanimura
995231304d - Provide toggles to show debug messages. Set new sysctl variables
hw.midi.debug and hw.midi.seq.debug to 1 to enable debug log.

- Make debug messages human-frendly.

- Implement /dev/music.

- Add a timer engine required by /dev/music.

- Fix nonblocking I/O.

- Fix the numbering of midi and synth devices.
2002-01-04 01:13:49 +00:00
Seigo Tanimura
05331bc6d4 - Do not uiomove with a mutex locked.
- Move from msleep/wakeup to condvar.

- Return either zero or a positive errno value from a function.
  Return additional result via references.

- Unify the typedef of callback functions.
2002-01-01 17:36:26 +00:00
Cameron Grant
193d571957 make mmapped vchans work 2001-12-23 13:10:29 +00:00
Pierre Beyssac
5a8c4e90b9 Fixes apparent hang at probe time due to an extremely long timeout
(experienced with an Opti931/ISA PnP card).

Approved by:	cg
2001-12-21 23:26:55 +00:00
Cameron Grant
b83a42d36f fix mmapped playback
remove dead debugging code
2001-12-21 22:34:01 +00:00
Orion Hodson
aaa167872e Save and restore state for suspend/resume.
PR:		kern/28692
Obtained from:	SAKIYAMA Nobuo <sakichan@sakichan.org>
2001-12-21 19:20:28 +00:00
Orion Hodson
df6ee7b7a1 Correct unexpected interrupt detection. 2001-12-19 18:26:53 +00:00
Orion Hodson
faee270315 Nitlets. 2001-12-19 18:04:04 +00:00
Orion Hodson
23d2179744 Clear resume interrupts - these can occur during initialization and
must be cleared to prevent machine hanging (presently aflicts -current
and -stable).

Problem reported by Bruce Montague <brucem@cse.iitkgp.ernet.in>

PR:		kern/29769 (probably)
2001-12-19 17:38:38 +00:00
Orion Hodson
0225c5ac86 Add calibration test to determine extent of AC97 overclocking (if any). 2001-12-18 03:29:31 +00:00
John Baldwin
7e1f6dfe9d Modify the critical section API as follows:
- The MD functions critical_enter/exit are renamed to start with a cpu_
  prefix.
- MI wrapper functions critical_enter/exit maintain a per-thread nesting
  count and a per-thread critical section saved state set when entering
  a critical section while at nesting level 0 and restored when exiting
  to nesting level 0.  This moves the saved state out of spin mutexes so
  that interlocking spin mutexes works properly.
- Most low-level MD code that used critical_enter/exit now use
  cpu_critical_enter/exit.  MI code such as device drivers and spin
  mutexes use the MI wrappers.  Note that since the MI wrappers store
  the state in the current thread, they do not have any return values or
  arguments.
- mtx_intr_enable() is replaced with a constant CRITICAL_FORK which is
  assigned to curthread->td_savecrit during fork_exit().

Tested on:	i386, alpha
2001-12-18 00:27:18 +00:00
Orion Hodson
2ae4ee833d Added a sysctl control variable "ac97rate" to allow manual tuning of
the link rate - some ich motherboards overclock ac97 out of the box.

Will hopefully replace this with a callibration loop in time for 4.5R
freeze.

Problem reported by Luigi Rizzo and fix derived from his code (put
diff in ich.c rather than ac97.c).

MFC after:	3 days
2001-12-17 01:57:42 +00:00
Orion Hodson
1abb0234c3 Addition of sysctl variable to enable spdif. By default spdif is disabled.
MFC after:	3 days
2001-12-17 01:39:36 +00:00
Guido van Rooij
b60e55dbd0 Get rid of irritating (bogus) message:
pcm0: ac97 codec failed to reset extended mode (0, got 80)
This was due to not masking off the correct extended function bits
in the read value from the extended status reg.

MFC after:	2 days
2001-12-10 20:27:18 +00:00
David E. O'Brien
6e551fb628 Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.
2001-12-10 08:09:49 +00:00
Guido van Rooij
3068bdba98 Fix resume for HP Omnibook 500's.
MFC after:	1 week
2001-12-05 10:36:32 +00:00
Mitsuru IWASAKI
a02ab1042e Add suspend/resume support.
MFC after:	1 week
2001-11-24 18:00:33 +00:00
Orion Hodson
21f3068887 Fix typo introduced with last commit. 2001-11-22 23:38:26 +00:00
Orion Hodson
eb5b9d0b87 Correct extmode initialization.
MFC after:	3
2001-11-21 04:26:04 +00:00
Orion Hodson
647fbfebc5 Emit a warning if invalid mode passed to ac97_setextmode.
MFC after:	3 days
2001-11-21 04:08:10 +00:00
Orion Hodson
2065c8c619 Set extmode according to extcaps. Fixes codec sample rate failures
that causes noisy playback with rates other than 48k (reported by
Olexander Kunytsa).

MFC after:	3 days
2001-11-21 04:06:52 +00:00
Jeroen Ruigrok van der Werven
41425f4fac Remove clkrun_hack for ThinkPad 570.
PR:		28031
Submitted by:	Tan Koan-Sin <freedom@csie.nctu.edu.tw>
MFC after:	2 weeks
2001-11-15 18:51:08 +00:00
Seigo Tanimura
b9d9d8e74c Avoid crash of minor numbers between /dev/midistat and /dev/dspr*. 2001-11-03 12:47:19 +00:00
Peter Wemm
aaa3add4ea Add Id for 82801CA (ICH3?). The ich driver seems to work fine on the
laptop that had it.
2001-11-03 05:07:59 +00:00
John Baldwin
02185af5a9 Change the module name from 'snd_sonicvibes' to 'snd_vibes' as that is
the filename (thus the "old" module name) and the name used by
snd_driver.ko.
2001-10-24 21:44:07 +00:00
John Baldwin
579f17a038 Change module name from 'snd_als' to 'snd_als4000' to match name in
snd_driver.ko.
2001-10-24 21:42:06 +00:00
John Baldwin
0ff24d06f7 Change the module name from 'via' to 'snd_via82c686' to match the KLD
filename and in snd_driver.ko.
2001-10-24 21:38:08 +00:00
John Baldwin
ee1fbec1bf Change the module name from 'snd_cmipci' to 'snd_cmi' to match the
filename, module name in the loader, the dependency in snd_driver.ko, and
to be consistent with other sound drivers.
2001-10-24 21:35:31 +00:00
Cameron Grant
16a33022e7 fix SNDCTL_DSP_GETISPACE behaviour 2001-10-24 12:40:54 +00:00
Cameron Grant
8309fd9aef improve recording behaviour 2001-10-24 12:33:21 +00:00
Warner Losh
565fcd9dbb These two used sioreg.h as well. This is mildly bogus, but it is harder
to fix right in a hurry.

This (almost) fixes LINT.

Submitted by:	bde
2001-10-22 15:59:49 +00:00
Scott Long
73b9d66d9a Turn on the hardware volume buttons that are present on most laptops with
these chips.  There is a new hint, hint.pcm.N.hwvol_config, that can be set
to 1 or 0 to select which pins the buttons are connected to.  I'm open to
suggestions on where to document this.  Also bump the number of playback
channels up to 4.

MFC after:	3 days
2001-10-14 19:22:51 +00:00
Orion Hodson
9b6a5708db use pcm_getbuffersize() 2001-10-10 17:56:35 +00:00
Scott Long
baadfb4c1e Update to using the pcm_getbuffersize() method.
Fix an off-by-one error in the saving of the dsp memory.
Up the play channels to 2.

MFC after:	3 days
2001-10-09 19:46:09 +00:00
Cameron Grant
a791cfee44 use pcm_getbuffersize()
only creat a mic recording channel if the codec supports it
2001-10-08 06:10:39 +00:00
Cameron Grant
50388172c5 use pcm_getbuffersize()
use seperate dma tags for buffers and control info
2001-10-08 06:01:13 +00:00
Cameron Grant
39dbd126c7 use pcm_getbuffersize() 2001-10-08 05:59:54 +00:00
Cameron Grant
82ab7a3bc2 * register the correct number of channels
* include hw buffer size in sndstat info
2001-10-07 23:31:52 +00:00
Cameron Grant
a9d2ee22ac use mixer channel numbers, not channel masks- this should fix sb/sbpro mixer
problems.
2001-10-07 23:28:34 +00:00
George C A Reid
8c65132c76 Add another pnpid for the AWE64
PR:		30909
Submitted by:	Kinji Itoh <kinji-i@gray.plala.or.jp>
MFC after:	7 days
2001-09-29 12:38:58 +00:00
Cameron Grant
11149a9ac8 release isa dma channels on unload. 2001-09-29 08:01:42 +00:00
Cameron Grant
374e1c5baa allow the hardware buffer size to be controlled with hints
release isa dma channels on unload (ad1816, ess, sb8)
2001-09-29 07:57:07 +00:00
John Baldwin
ed01445d8f Use the passed in thread to selrecord() instead of curthread. 2001-09-21 22:46:54 +00:00
Cameron Grant
a6295c60ae when setting blocksize, fix blockcount to 2 to reduce latency with smaller
block sizes.
2001-09-18 15:19:44 +00:00
Cameron Grant
c2995ba2d4 make buffer size adjustable. 2001-09-18 15:12:35 +00:00
Cameron Grant
fca71897c4 don't enable the mic record channel unless the codec supports it.
allow hardware buffer size to be specified using hints.
2001-09-18 14:53:01 +00:00
Cameron Grant
a67fe5c1d6 change tracking of channel counts.
add method for retrieving "buffersize" hints for pcm devices, adjusted for
specified minimum, maximum and default values.
2001-09-18 14:50:52 +00:00
Cameron Grant
a3a1ce3024 add a tunable/sysctl, hw.snd.targetirqrate, to modify the default target
irq rate for apps that do not set a blocksize.
2001-09-18 14:45:09 +00:00
Cameron Grant
5d91ad679d add a method for retrieving codec capabilities 2001-09-18 14:34:59 +00:00
Seigo Tanimura
4ce6a64b25 Catch up to the last commit of KSE. 2001-09-15 08:14:23 +00:00
George C A Reid
5c25132af5 - Correctly increment the channel refcount in dsp_open() such that it is
no longer possible to unload the driver module while sound is playing
  (which resulted in a panic).
- Fix a similar problem with the sndstat device that I found while looking
  at the above.
- Append a newline character to error messages in pcm_unregister()

Reviewed by:	cg
MFC after:	10 days
2001-09-14 20:26:03 +00:00
Julian Elischer
b40ce4165d KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after:    ha ha ha ha
2001-09-12 08:38:13 +00:00
Brian Feldman
a46252c61f Convert the CMedia driver to using a device mutex and INTR_MPSAFE. 2001-09-08 05:20:52 +00:00
Cameron Grant
506a5308bc add a method for recording of specific channels for devices with more than
one hardware record channel.  new devices, /dev/dsprX.Y where X is unit
number and Y is channel index.
2001-09-05 16:28:41 +00:00
Cameron Grant
c2e6dd76ce don't try to dump nonexistent data when recording 2001-09-05 14:49:44 +00:00
Orion Hodson
bb76bd1180 Return updated blocksize from setblocksize function. 2001-09-03 02:14:55 +00:00
Orion Hodson
61608985c7 Fix return value of cs4281chan_setblocksize. 2001-09-03 01:05:04 +00:00
Orion Hodson
256e749243 Fix return value of svchan_setblocksize.
Expand probing range.
2001-09-03 01:03:50 +00:00
Orion Hodson
167d1bcd19 Fix return value of setblocksize functions. Recording is interspersed
with silent intervals otherwise.
2001-09-03 00:45:00 +00:00
Cameron Grant
edecdda7b9 tweaks to reduce latency/pauses in output 2001-08-29 09:17:43 +00:00
George C A Reid
0a1e38d38a Add support for the Acer Labs M5451 chip.
Submitted by:	Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
2001-08-29 09:04:22 +00:00
Cameron Grant
a32858897e add some extra diagnostic info to sndstat output. 2001-08-29 02:49:54 +00:00
Cameron Grant
9924faf6e7 * change buffering method a bit
* swap record/mic channels
* initialise all channels
* align dma buffers to 8 bytes

Submitted by:	Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp>
(mostly)
2001-08-29 02:31:03 +00:00
Cameron Grant
4f4449e01c now we have the rate feeder, we don't need to constrain the default channel
speed.  however, continue to do so for record channels until the feederchain
builder is fixed.
2001-08-27 01:02:13 +00:00
Cameron Grant
52eb6afd0c MFS rev 1.8.2.8:
release resources on detach

Submitted by:	"Christopher N . Harrell" <cnh@netvmg.com>
2001-08-27 00:54:26 +00:00
George C A Reid
874f2e78b4 Add support for the SiS 7018
PR:		30100
Submitted by:	Ada Lim <adal@cse.unsw.edu.au>
2001-08-26 19:15:28 +00:00
Cameron Grant
4132a3b206 the feederchain builder is currently broken for recording channels. disable
it until it is fixed.  this limits recording to native formats and speeds
only.
2001-08-23 12:27:27 +00:00
Cameron Grant
334326a17f handle bogus values passed to SOUND_PCM_WRITE_CHANNELS/SNDCTL_DSP_CHANNELS
ioctls better- if 0 is passed, return the current setting.  if 1 or 2 are
passed, behave accordingly.  treat values >2 as 2.

PR:		kern/29964
2001-08-23 12:21:12 +00:00
Cameron Grant
48875621e1 make the 4dwave nx chip work
Submitted by:	Philippe Anel <xigh@noos.fr>
2001-08-23 12:02:29 +00:00
Cameron Grant
92f39b2c05 MFS: make SNDCTL_DSP_SETTRIGGER work 2001-08-23 11:58:38 +00:00
Cameron Grant
1662598f0c MFS: allow multiple opens of mixer devices 2001-08-23 11:56:07 +00:00
Cameron Grant
67b1dce3bc many changes:
* add new channels to the end of the list so channels used in order of
addition

* de-globalise definition of struct snddev_info and provide accessor
functions where necessary.

* move the $FreeBSD$ tag in each .c file into a macro and allow the
/dev/sndstat handler to display these when set to maximum verbosity to aid
debugging.

* allow each device to register its own sndstat handler to reduce the amount
of groping sndstat must do in foreign structs.
2001-08-23 11:30:52 +00:00
George C A Reid
1ad86e6dd7 Set up the via_chinfo structures properly so we write to the correct
registers later on; this fixes the VIA82C686 sound problems recently
reported by a number of people.
2001-08-02 22:13:10 +00:00
Scott Long
19f2be11b0 Limit the device to only one playback channel until I can figure out why
a) newpcm insists on using only the highest number channel available, and
b) the maestro3 driver no longer likes anything above channel 0.
2001-07-19 20:53:52 +00:00