Commit Graph

63 Commits

Author SHA1 Message Date
Poul-Henning Kamp
e70377df79 Use dynamic major number allocation. 2005-02-27 22:16:30 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Seigo Tanimura
0739ea1de2 Rename the sound device drivers:
- `sound'
  The generic sound driver, always required.

- `snd_*'
  Device-dependent drivers, named after the sound module names.
  Configure accordingly to your hardware.

In addition, rename the `snd_pcm' module to `sound' in order to sync
with the driver names.

Suggested by:	cg
2004-07-16 04:00:08 +00:00
Marcel Moolenaar
b8c48216b1 Remove DDB. The one user of this macro has been changed to use BVDDB.
Yes, DDB is unrelated to the debugger with the same acronym. Hence,
the change.
2004-07-10 21:13:28 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Brian Feldman
8fb9a995cf The newpcm headers currently #define away INTR_MPSAFE and INTR_TYPE_AV
because they bogusly check for defined(INTR_MPSAFE) -- something which
never was a #define.  Correct the definitions.

This make INTR_TYPE_AV finally get used instead of the lower-priority
INTR_TYPE_TTY, so it's quite possible some improvement will be had
on sound driver performance.  It would also make all the drivers
marked INTR_MPSAFE actually run without Giant (which does seem to
work for me), but:
	INTR_MPSAFE HAS BEEN REMOVED FROM EVERY SOUND DRIVER!
It needs to be re-added on a case-by-case basis since there is no one
who will vouch for which sound drivers, if any, willy actually operate
correctly without Giant, since there hasn't been testing because of
this bug disabling INTR_MPSAFE.

Found by:	"Yuriy Tsibizov" <Yuriy.Tsibizov@gfk.ru>
2004-04-14 14:57:49 +00:00
Mathew Kanner
0d8ed52ea5 Augment /dev/sndstat with the module names, if applicable.
Approved by:	  tanimura (mentor)
2004-03-06 15:52:42 +00:00
Don Lewis
a3193a9ca3 Create a new mutex type for virtual channels. This allows us to get
rid of the MTX_DUPOK flag on channel mutexes, which allows witness to
do a better job of lock order checking.  Nuke snd_chnmtxcreate() since
it is no longer needed.

Tested by:	matk
2004-02-28 19:47:02 +00:00
Don Lewis
12e524a290 Change KASSERT() in feed_vchan16() into an explicit test and call to
panic() so that the buffer overflow just beyond this point is always
caught, even when the code is not compiled with INVARIANTS.

Change chn_setblocksize() buffer reallocation code to attempt to avoid
the feed_vchan16() buffer overflow by attempting to always keep the
bufsoft buffer at least as large as the bufhard buffer.

Print a diagnositic message
	Danger! %s bufsoft size increasing from %d to %d after CHANNEL_SETBLOCKSIZE()
if our best attempts fail.  If feed_vchan16() were to be called by
the interrupt handler while locks are dropped in chn_setblocksize()
to increase the size bufsoft to match the size of bufhard, the panic()
code in feed_vchan16() will be triggered.  If the diagnostic message
is printed, it is a warning that a panic is possible if the system
were to see events in an "unlucky" order.

Change the locking code to avoid the need for MTX_RECURSIVE mutexes.

Add the MTX_DUPOK option to the channel mutexes and change the locking
sequence to always lock the parent channel before its children to avoid
the possibility of deadlock.

Actually implement locking assertions for the channel mutexes and fix
the problems found by the resulting assertion violations.

Clean up the locking code in dsp_ioctl().

Allocate the channel buffers using the malloc() M_WAITOK option instead
of M_NOWAIT so that buffer allocation won't fail.  Drop locks across
the malloc() calls.

Add/modify KASSERTS() in attempt to detect problems early.

Abuse layering by adding a pointer to the snd_dbuf structure that points
back to the pcm_channel that owns it.  This allows sndbuf_resize() to do
proper locking without having to change the its API, which is used by
the hardware drivers.

Don't dereference a NULL pointer when setting hw.snd.maxautovchans
if a hardware driver is not loaded.  Noticed by Ryan Sommers
<ryans at gamersimpact.com>.

Tested by:	Stefan Ehmann <shoesoft AT gmx.net>
Tested by:	matk (Mathew Kanner)
Tested by:	Gordon Bergling <gbergling AT 0xfce3.net>
2004-01-28 08:02:15 +00:00
Mathew Kanner
5ee30e277a Fix a panic when kldloading a sound driver. Do this by replacing the
link-list of dev_t's with named variables.  Remove used code.

Approved by:		tanimura (mentor)
2004-01-20 03:58:57 +00:00
Poul-Henning Kamp
4555065861 As previously announced: discontinue use of makedev() call in soundcode.
This takes us a lot closer to refcounting dev_t.

This patch originally by cg@ with a few minor changes by me.

It is largely untested, but has been HEADSUP'ed twice, so presumably
people have not found any issues with it.

Submitted by:	cg@
2004-01-17 10:37:11 +00:00
Cameron Grant
3f22597838 update my email address. 2003-09-07 16:28:03 +00:00
Cameron Grant
a527dbc77c handle locking when creating or destroying vchans better 2003-08-18 23:20:39 +00:00
Yoshihiro Takahashi
3febcc57ec - Clean up ISA DMA supports.
- Rename all sndbuf_isadma* functions to sndbuf_dma* and move them into
  sys/dev/sound/isa/sndbuf_dma.c.

No response from:	sound
2003-02-07 14:05:34 +00:00
Cameron Grant
67beb5a5c8 various fixes to eliminate locking warnings
Approved by:	re
Reviewed by:	orion
2002-11-25 17:17:43 +00:00
Bruce Evans
ab85003bf5 Fixed breakage from removing the used include of <sys/buf.h> in the
previous commit:
Include <sys/mutex.h> and its prerequisite <sys/lock.h> instead of
depending on namespace pollution in <sys/buf.h>.  Only do this in the
__FreeBSD_version > 500000 case although the __FreeBSD_version < 500000
case has already rotted.
2002-09-15 08:21:14 +00:00
Poul-Henning Kamp
296bbb4cfb FreeBSD -current doesn't need <sys/buf.h> or <sys/bio.h>. 2002-09-14 18:58:36 +00:00
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
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
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
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
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
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
Cameron Grant
cbe7d6a3ed remove obsolete typedefs.
only define INTR_TYPE_AV if it is not already defined.
2001-07-03 12:53:09 +00:00
Brian Feldman
bc0e6469ff Correct obviously wrong mistakes. 2001-07-02 23:47:23 +00:00
Brian Feldman
0cfa4761f7 Make all this compile on 4.3, modulus sbuf. 2001-07-02 15:27:28 +00:00
Cameron Grant
f637a36cfd don't flag the playback hardchan as busy on devices with only one of them.
if a device has vchans already but they are all busy, allocate another one
at open() time, up to a maximum of hw.snd.maxvchans.

when creating/destroying vchans, don't make/remove a devnode for the
first/last one as it replaces a hardchan.
2001-06-27 19:59:45 +00:00
Cameron Grant
cd9766c5f8 add a tunable/sysctl, hw.snd.autovchans. if this is set to a value n where
n > 0, n vchans will be assigned to any devices that subsequently register
with a single playback channel.
2001-06-26 21:54:55 +00:00
Cameron Grant
f00f162a5f add defines and ifdefs so this code will compile on 4.x
add spls so this code will work on 4.x
2001-06-23 17:36:51 +00:00
Cameron Grant
faeebea2b8 revise dsp_clone() to return the first nonbusy channel instead of simply
cycling channel numbers.

remove unused fields from struct snddev_info.
2001-06-17 23:23:06 +00:00
Cameron Grant
d95502a838 use a global devclass for all drivers - i'm not entirely sure why this
worked before.

mixer, dsp and sndstat are seperate devices - give them their own cdevsws
instead of demuxing requests sent to a single cdevsw.

use the si_drv1/si_drv2 fields in dev_t structures for holding information
specific to an open instance of mixer/dsp.

nuke /dev/{dsp,dspW,audio}[0-9]* links - this functionality is now provided
using cloning.

various locking fixes.
2001-06-16 21:25:10 +00:00
Cameron Grant
b8f0d9e0b2 various locking fixes, rework open logic and channel registration
PR:             kern/28084
2001-06-14 13:31:30 +00:00
Cameron Grant
49c5e6e20a lock sound device when adding/removing channels
implement setblocksize for vchans
don't panic when doing certain ioctls or aborting on a vchan
xmms now works with vchans
2001-06-07 20:06:22 +00:00
Cameron Grant
285648f9d2 beginnings of virtual playback channel support
instead of using two malloced arrays for storing channel lists, use an
slist.  convert the sndstat device to use sbufs and optionally provide more
detail about channel state.

vchans are software mixed playback channels.  they are not enabled by this
commit.  they use the feeder infrastructure to emulate normal playback
channels in a manner transparent to applications, whilst providing as many
channels are desired, especially suitable for devices with only one hardware
playback channel.  in the future they will provide additional features.

those wishing to test this functionality will need to add vchan.c to
sys/conf/files and use 'sysctl -w hw.snd.pcm0.vchans' to enable it.

blocksize and auto-rate selection are not yet supported.
2001-05-27 17:22:00 +00:00
Cameron Grant
66ef8af5b0 mega-commit.
this introduces a new buffering mechanism which results in dramatic
simplification of the channel manager.

as several structures have changed, we take the opportunity to move their
definitions into the source files where they are used, make them private and
de-typedef them.

the sound drivers are updated to use snd_setup_intr instead of
bus_setup_intr, and to comply with the de-typedefed structures.

the ac97, mixer and channel layers have been updated with finegrained
locking, as have some drivers- not all though.  the rest will follow soon.
2001-03-24 23:10:29 +00:00
Cameron Grant
a0585a78aa MFS: add kobj.h to reduce diffs from -stable 2001-03-05 16:47:35 +00:00
Cameron Grant
dec507e8f7 enable per-device sysctls unconditionally 2001-03-05 15:58:05 +00:00
Cameron Grant
37209180a5 add functions for sound drivers to use for locking and setting up interrupt
handlers.  these are not yet used, but will allow compatibility for driver
modules from 5.x to 4.x.
2001-02-27 07:45:09 +00:00
Cameron Grant
041e207dec MFS: 4.x/5.x compatibility #defines 2001-02-27 06:58:55 +00:00
John Baldwin
b3b7ccfe38 Create a new sysctl node 'hw.snd' and move 'hw.sndunit' to
'hw.snd.unit'.

Reviewed by:	cg
2001-01-03 01:25:26 +00:00
Cameron Grant
350a5fafb1 update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use.  it will aim for a power of two size small
enough to generate block sizes of at most 20ms.  it will also set the
hard-blocksize taking into account rate/format conversions in use.

update drivers to implement setblocksize  correctly:
updated, tested: 	sb16, emu10k1, maestro, solo
updated, untested: 	ad1816, ess, mss, sb8, csa
not updated: 		ds1, es137x, fm801, neomagic, t4dwave, via82c686

i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
Cameron Grant
0f55ac6c1a kobjify.
this gives us several benefits, including:

* easier extensibility- new optional methods can be added to
  ac97/mixer/channel classes without having to fixup every driver.

* forward compatibility for drivers, provided no new mandatory methods are
  added.
2000-12-18 01:36:41 +00:00
Cameron Grant
4e2e565cbd add AFMT_8BIT for easier determination of formats 2000-11-06 22:22:52 +00:00
Cameron Grant
37ab02c0ed tidy up a little, add a mask for 32bit formats 2000-09-05 20:56:31 +00:00
Cameron Grant
33dbf14a17 change mixer api slightly
change channel interface - kobj implementation coming soonish
make pcm_makelinks not panic if modular
add pcm_unregister()

these changes support newpcm kld unloading, but this is only implemented
by ds1.c
2000-09-01 20:09:24 +00:00
Cameron Grant
513693be6c rework feeder sytem to allow feeders in klds
modify driver capability reporting format to list every audio format
seperately- required for above and because we could not previously indicate
that mono was unsupported.

there should be no functional impact.
2000-08-20 22:18:56 +00:00
Cameron Grant
071280d442 MFS: module macro changes 2000-08-09 18:46:48 +00:00
Cameron Grant
1874ec255c MFS: sync with peter's isadma fixup 2000-08-09 01:22:09 +00:00
Cameron Grant
d98c7b9a99 make this file suitable for 4-stable as well as 5-current 2000-07-18 21:23:48 +00:00
Cameron Grant
f314f3dad2 add module metadata. this is a hack, sound drivers will eventually present a
bus to which pcm, mixer, etc will attach.
2000-07-03 20:52:27 +00:00