Commit Graph

659 Commits

Author SHA1 Message Date
Orion Hodson
cb4458e030 Disable DRA to fix problems with recording. 2003-01-26 04:23:23 +00:00
Orion Hodson
f9eb140935 Add ac97_patch.[ch] that provide space for ac97 codec specific patches. 2003-01-25 16:54:05 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Orion Hodson
4a532ff091 Re-implemention of the interpolation code used for sample rate
conversion.  The new version has improved interpolation accuracy and
maintains the timing relationship between the input and output signals
exactly.

Approved by:	cg
2003-01-20 00:54:24 +00:00
Matthew N. Dodd
6dc61b5ae5 - GC a few more hand-rolled 'abs' macros.
- GC a few hand-rolled min()/max() macros while I'm here.
2003-01-15 02:15:57 +00:00
Olivier Houchard
e550089d43 Don't call destroy_dev it a channel has children.
vchan creation doesn't lead to /dev entry creation if the new vchan is the
first child of a channel,
This fix a panic that happens when loading a sound driver module, creating
vchans and unloading the driver.

Approved by:	cg
MFC after:	3 days
2003-01-14 17:13:52 +00:00
Orion Hodson
916aaded05 Add Realtek ALC650 id.
Submitted by:	"Mikko S. Hyvarinen" <morphy@morphy.iki.fi>
MFC after:	5 days
2003-01-13 17:43:49 +00:00
Orion Hodson
a7697e5514 Add nForce2 device id.
Submitted by:	"Mikko S. Hyvarinen" <morphy@morphy.iki.fi>
MFC after:	5 days
2003-01-13 17:42:13 +00:00
Matthew N. Dodd
dd815daba5 - Add acpi module binding.
- Restore speed and format settings on resume for CS423x and
  CS423x-PCI devices.
2003-01-08 06:24:25 +00:00
Brian Feldman
a8be3e63ce Fix the duplicate unlock of the pcm read channel in certain cases.
Reviewed by:	cg
2003-01-05 07:32:33 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Semen Ustimenko
83190e29d3 Do not return(foo()) in void function.
Submitted by:	marius@alchemy.franken.de
MFC after:	3 days
2002-12-18 22:53:24 +00:00
Cameron Grant
00acb1337e (hopefully) fix build breakage some people are seeing
Approved by:	re
2002-11-26 18:16:27 +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
Cameron Grant
68f4e7f1d3 various fixes to eliminate locking warnings
Approved by:	re
Reviewed by:	orion
2002-11-25 17:07:33 +00:00
Cameron Grant
0586ff0d84 if the list of supported formats is empty, fail the attach instead of
panicing later.  this is a band-aid pending further investigation.

MFC After:	7 days
Approved by:	re
2002-11-25 17:03:39 +00:00
Josef Karthauser
8ecdcb3ff3 Packed structures are defined differently in older gcc's, like the one
currently in -stable.  Put the exception into usb.h instead of having it
hard coded in the sound code.
2002-11-06 21:37:21 +00:00
Olivier Houchard
e33bee0756 Call pcm_chn_destroy() in pcm_killchan() so that channel mutexes are destroyed and struct pcm_channel freed.
Reviewed by:	cg
MFC after:	3 days
2002-11-04 19:12:02 +00:00
Marcel Moolenaar
e9be79d69c Suppress the uninitialized variable warning on ia64 introduced by
the previous commit by initializing i and j. These initializations
will normally be eliminated by the compiler.
2002-10-17 03:45:34 +00:00
Olivier Houchard
89ca562efb Fix support for the ALi M5451 (rev 0.2) chip.
Reviewed by:	orion, mux
Approved by:	mux (mentor)
MFC after:	1 week
2002-10-14 11:47:37 +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
Scott Long
5ffa65f9ab Sigh. The fix to the suspend code wasn't complete, since the resume
code was broken in the same way.

Submitted by:	co9@xs4all.nl
MFC after:	3 days
2002-09-04 08:13:36 +00:00
Maxim Sobolev
5cfa81a801 - Improve AC97 presence check and move it from fm801_attach() to fm801_probe();
- add bus capabilities into the driver, so that it is possible for a radio
  driver to attach to it to use shared resources of fm801 chip. The radio
  driver itself will be committed later.

MFC after:	1 week
2002-09-03 08:58:15 +00:00
Maxim Sobolev
d8afaeb24b Whitespace-only: don't mix tabs and spaces for doing identation. 2002-08-30 14:21:01 +00:00
Scott Long
c02a39a15d Fix a silly off my one error that caused crashes on resume in certain
circumstances.  The problem was only reported with -stable, but it's
obviously wrong in -current also.  MFC is forthcoming.

Submitted by:	doconnor@dsoft.com.au
2002-08-29 15:06:26 +00:00
Orion Hodson
47d5a0f3e5 Marginally simplify dsp_open error handling by adding an early test to
determine liklihood of opening device in requested directions.  Makes for
simpler error handling and change should close kern/35004.

PR: kern/35004.
2002-08-28 15:19:30 +00:00
Orion Hodson
933ce6fa4b Add suspend and resume support.
Contributed by:	Takanori Watanabe <takawata@FreeBSD.org>
PR:		kern/41809
2002-08-25 02:00:49 +00:00
Bruce Evans
760e2cb04a Fixed editing errors in rev.1.4 which manifested as printf format errors
at compile time and probably as panics at runtime.
2002-08-25 01:32:22 +00:00
Nick Sayer
47172de8a2 Be sure to unregister from sndstat on unregister. Gets rid of phantom
sndstat output after removing uaudio.
2002-08-24 19:13:11 +00:00
Orion Hodson
4408eb15b0 Make sure channel buffer start is associated with channel, otherwise
getptr is broken.  Noise reported by Thomas Draney <tmdraney@yahoo.com> who
also tested the patch.
2002-08-23 20:54:32 +00:00
Orion Hodson
108082c42e s/AC97_MIX_PHONES/AC97_MIX_AUXOUT/ to match ac97r2.{2,3}.
Attempt to determine what function of AUX_OUT is: "True line level
out", "Headphone out", or "4-Channel out" and frig OSS mixer label
accordingly.

Addresses problem raised by Randy Bush on -multimedia of not being
able to hear audio on ich2 m/b which was eventually found to be
because the mixer monitor value was 0.  On this h/w the label
"monitor" should now be presented as the marginally more intuitive
"ogain".
2002-08-23 06:19:28 +00:00
Archie Cobbs
4a6a94d8d8 Replace (ab)uses of "NULL" where "0" is really meant. 2002-08-22 21:24:01 +00:00
Orion Hodson
2296709020 Back out last commit. Needs slightly more subtle handling. 2002-08-20 08:02:56 +00:00
Orion Hodson
14213e7d3e Cater for ich4 quirks.
Reported by: Jacob Rhoden
Tested by: Jacob Rhoden, mp
2002-08-19 16:03:56 +00:00
Orion Hodson
42e67fd3e7 Apply reference counting patch. Fixes problem of two applications
opening the device, eg one read only and one write only, and the
reference count being non-zero when both exit rendering device
permanently busy.

PR:		kern/35004
Submitted by:	Bill Wells
MFC after:	3 days
2002-08-18 14:17:06 +00:00
Orion Hodson
b383a8478c Fix VRA configuration.
Reported and fixed by: Grzybowski Rafal <grzybek@inferno.mikrus.pw.edu.pl>
2002-08-18 00:29:08 +00:00
Orion Hodson
ae83180158 Support for VIA VT8233 audio controller. 2002-08-17 16:23:44 +00:00
Orion Hodson
67a97e1522 Remove support for the vt8233. Specs for chipset changed mid-revision
so this code was not working for the newer VIA chipsets.
2002-08-17 16:13:29 +00:00
Mark Peek
eabc182e02 Add PCI ID for the ICH4 AC97 controller. 2002-08-12 15:45:12 +00:00
Josef Karthauser
3b7efc56d0 Use the hw.usb sysctl tree instead of debug.usb.
Requested by:	imp
2002-08-08 12:05:51 +00:00
Josef Karthauser
528d1a7fbc Replace the FOO_DEBUG definitions with USB_DEBUG, and switch the
debugging levels to off by default.  Now that debug levels can be
tweaked by sysctl we don't need to go through hoops to get the
different usb parts to produce debug data.
2002-07-31 14:34:36 +00:00
Josef Karthauser
6ada40b009 Make this compile with the debugging options switched on. 2002-07-31 14:27:40 +00:00
Josef Karthauser
0e6b196686 Get bored with hard coded debug level variables and introduce a debug.usb
sysctl tree for tweaking them real-time.

Reviewed by:	iedowse
2002-07-31 13:33:55 +00:00
Maxim Sobolev
47c7de587b Add support for controlling line1 mixer device, which on some cards represents
onboard FM tuner.

MFC after:	2 weeks
2002-07-30 16:24:00 +00:00
Maxim Sobolev
b047aa218b Add a quick check that device actually has sound capabilities. The problem
is that some cards built around fm801 chip have the same device ID, only
have radio tuner onboard, but no sound capabilities. Therefore, with such
card inserted and `device pcm' in kernel the user has a big problem, as
the fm801 driver effectively hangs the machine when trying to initialise
nonexistent ac97 codecs (it does 500 retries with 1 second interval!).
It would be better if MediaForte's engeneers were smart enough to put
different device ID into such cards, but it isn't an option.

MFC after:	2 weeks
2002-07-30 10:54:19 +00:00
Brian Feldman
ca33ae2367 Fix some of the places where sound(4) can sleep with a lock held. (Help
courtesy of fenner).
2002-07-25 04:49:45 +00:00
Doug Ambrisko
fed38951fd Fake a resume method for this chip via calling detach/attach. This lets
ThinkPads using this chip to have sound after a suspend/resume sequence
without resorting to kldunload/kldload.

MFC after:	1 week
2002-07-24 21:27:22 +00:00
Alexander Kabaev
61698e0ca1 Fix the sound driver vchan support to work when hw.snd.maxautovchans
has been specified through /boot/loader.conf as opposed to setting it
in /etc/sysctl.conf. Only PCMDIR_PLAY channel can be used as a parent
of virtual channel. Do not initialize a new vchan for a given physical
channel if other physical channel already has one created.

PR:	31597
Approved by:	obrien (mentor)
2002-07-23 14:50:51 +00:00
Orion Hodson
7cf0e77a00 Move lock in pcm_chn_add() to after malloc.
PR:             kern/40157
Submitted by:   Dan Lukes <dan@obluda.cz>
2002-07-22 02:38:20 +00:00
Peter Wemm
7c65416558 Make this compile.
uaudio.c:1822: warning: `uaudio_ctl_get' defined but not used
2002-07-22 00:11:35 +00:00
Nick Sayer
d807a231a2 Add uaudio -- a USB audio device driver.
This driver actually works slightly better on -stable than on -current
(the system locks on detach on -current), so it should be MFC'd somewhat
sooner.

This driver currently points out a difficulty in the sound device framework.
The PCM unregister routine is allowed to refuse the detach if the device is
in use. In the case of a USB device, however, this unregistration is much more
mandatory in nature, since the device is *actually* gone when this call is
made. The sound subsystem really should not refuse an unregistration and
should take its own steps to reject further I/O. As a result, if you detach
a USB sound device while it is in use, you can expect a panic shortly
thereafter.

This device cannot currently record audio. Some routines are unwritten as
of yet in uaudio.c to support recording.

This device hangs my -current box on detach. I don't know why. This does
not happen on my -stable machine.

Obtained from:	Hiroyuki Aizu
MFC after:	2 weeks
2002-07-21 17:28:50 +00:00
Mark Murray
64d85ef750 Use semicolons at the end of function-like macros for the sake of
consistency, style and future cleanliness.
2002-07-15 13:03:10 +00:00
Robert Drehmel
0a17f47b92 Reenable the m3 interrupts in m3_pci_resume() and do not
enable them in m3_pci_attach().
2002-07-08 11:41:53 +00:00
Scott Long
63393eea99 Fix a botched flag clear operation. Rumor has it that this also fixes
the funky-volume-settings-on-startup problem.

Reviewed by:	the channel that shall not be named
MFC after:	7 days
2002-06-28 06:11:26 +00:00
Scott Long
f4df40b218 Delay the AC97 calibration until after the system clock has been
calibrated.  This fixes the problem where playback and recording do
not run at the correct speed.  It probably also eliminates the
need for the hacks/workarounds/sysctl's that were previously
devised to deal with this, but I will leave that for a different
time.

Reviewed by:	orion
2002-06-27 22:36:01 +00:00
Robert Drehmel
9ce4f54341 Enable mixer interrupts after the mixer is initialized,
otherwise we might get interrupts and are unable to
handle them properly, which results in a page fault.

PR:		kern/39549
Submitted by:	Gil Kloepfer <gil@arlut.utexas.edu>
2002-06-24 15:28:47 +00:00
Hellmuth Michaelis
30d12b5c86 Fix driver to re-enable sound output on AD1816 based cards caused by an
obviously bogous return value of ad1816chan_setformat().
PR:             37932
Submitted by:   Martin Kaeske <Martin.Kaeske@Stud.TU-Ilmenau.DE>
Reviewed by:    hm
MFC after:      10 days
2002-06-09 14:20:17 +00:00
Bruce Evans
e788f79698 Fixed printf format errors which apparently crept in while -Wformat was
disabled for gcc-3.
2002-05-25 11:18:03 +00:00
Peter Wemm
9cfd8eb371 Try and solve some cases of labels at end of compound statements that gcc
now objects to (as it should, it is not legal C).
2002-05-19 06:31:56 +00:00
Orion Hodson
7dace039d8 No longer attempt to power off the ACLINK during suspend - luigi
reports this causes his ich machine to hang.
2002-05-05 15:37:09 +00:00
David E. O'Brien
90a78bd0ba makeobjops.awk is stricter on syntax than the perl version. 2002-05-01 03:52:40 +00:00
David E. O'Brien
82303b6b14 Remove the trailing ^M's. makeobjops.awk does not like them. 2002-05-01 03:07:40 +00:00
Cameron Grant
21ed9908a2 add a missing \n to an unregister failure message 2002-04-28 22:59:45 +00:00
Cameron Grant
9dbee70d4a recognise ct5880-e
Submitted by:	SONODA Yoshihide <yshd@na.rim.or.jp>
2002-04-28 22:38:23 +00:00
Orion Hodson
c6d4b83ad1 Add ac97_reset function that polls ready bits in power register. One
component in tweaks required for the ICH3 controller in the thinkpad
x22 reported by Colin Perkins on -multimedia.
2002-04-26 15:27:56 +00:00
John Baldwin
0654f06291 Cast another bus_addr_t to long long for a printf to quiet a warning on
alpha.
2002-04-16 01:58:13 +00:00
John Baldwin
77b6db948d Recognize the AC97 interface to the onboard sound controller on the Nvidia
nForce chipset.  Playback at least seems to work fine with the ich driver
out of the box.

Sponsored by:	The Weather Channel
Help from:	cg
2002-04-15 20:42:40 +00:00
John Baldwin
e789153cfc Use bus_addr_t instead of u_int for local variables that are derived from
the per-channel bus_addr_t offset.  Also, cast the offset to (long long)
and use %#llx instead of %#x to fix printf warnings on architectures where
sizeof(bus_addr_t) != sizeof(int).
2002-04-15 19:16:37 +00:00
Ollivier Robert
a8851d32b1 Remove a spurious warning as x is always initialised before use.
es137x.c: In function `es1371_rdcd':
es137x.c:598: warning: `x' might be used uninitialized in this function

PR:		kern/35408
Submitted by:	Thomas Quinot <thomas@cuivre.fr.eu.org>
2002-04-15 14:43:23 +00:00
John Hay
fcd478479d Fix the play / record rate setting so that it actually works.
The extra microphone channel capability is part of the "normal" ac97
capabilities and not an extended ac97 capability. Now recording on
codecs without a seperate mic channel works.

MFC after:	1 week
2002-04-14 10:39:59 +00:00
John Baldwin
2c823989e1 Fix a warning due to the code assuming sizeof(int) == sizeof(void *) which
is not true on the alpha.  I think that other parts of this code also make
this implicit assumption as well.
2002-04-11 15:31:01 +00:00
John Baldwin
6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
John Baldwin
489c22ebb8 Add lock type arguments to callers of snd_mtxcreate(). 2002-04-04 20:56:47 +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
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