Commit Graph

801 Commits

Author SHA1 Message Date
Robert Watson
6a113b3de7 Merge the dev_clone and dev_clone_cred event handlers into a single
event handler, dev_clone, which accepts a credential argument.
Implementors of the event can ignore it if they're not interested,
and most do.  This avoids having multiple event handler types and
fall-back/precedence logic in devfs.

This changes the kernel API for /dev cloning, and may affect third
party packages containg cloning kernel modules.

Requested by:	phk
MFC after:	3 days
2005-08-08 19:55:32 +00:00
Alexander Leidinger
4442c32be7 Style fix.
Noticed by:	njl
2005-07-31 18:59:47 +00:00
Alexander Leidinger
87506547d2 Whats New:
1. Support wide range sampling rate, as low as 1hz up to int32 max
   (which is, insane) through new feeder_rate, multiple precisions
   choice (32/64 bit converter). This is indeed, quite insane, but it
   does give us more room and flexibility. Plenty sysctl options to
   adjust resampling characteristics.
2. Support 24/32 bit pcm format conversion through new, much improved,
   simplified and optimized feeder_fmt.

Changes:
1. buffer.c / dsp.c / sound.h
   * Support for 24/32 AFMT.
2. feeder_rate.c
   * New implementation of sampling rate conversion with 32/64 bit
     precision, 1 - int32max hz (which is, ridiculous, yet very
     addictive).  Much improved / smarter buffer management to not
     cause any missing samples at the end of conversion process
   * Tunable sysctls for various aspect:
       hw.snd.feeder_rate_ratemin - minimum allowable sampling rate
       (default to 4000)
       hw.snd.feeder_rate_ratemax - maximum allowable sampling rate
       (default to 1102500)
       hw.snd.feeder_rate_buffersize - conversion buffer size
       (default to 8192)
       hw.snd.feeder_rate_scaling - scaling / conversion method
       (please refer to the source for explaination). Default to
       previous implementation type.
3. feeder_fmt.c / sound.h
   * New implementation, support for 24/32bit conversion, optimized,
     and simplified. Few routines has been removed (8 to xlaw, 16 to
     8). It just doesn't make sense.
4. channel.c
   * Support for 24/32 AFMT
   * Fix wrong xruns increment, causing incorrect underruns statistic
     while using vchans.
5. vchan.c
   * Support for 24/32 AFMT
   * Proper speed / rate detection especially for fixed rate ac97.
     User can override it using kernel hint:
     hint.pcm.<unit>.vchanrate="xxxx".

Notes / Issues:
        * Virtual Channels (vchans)
          Enabling vchans can really, really help to solve overrun
          issues.  This is quite understandable, because it operates
          entirely within its own buffering system without relying on
          hardware interrupt / state. Even if you don't need vchan,
          just enable single channel can help much. Few soundcards
          (notably via8233x, sblive, possibly others) have their own
          hardware multi channel, and this is unfortunately beyond
          vchan reachability.
        * The arrival of 24/32 also come with a price. Applications
          that can do 24/32bit playback need to be recompiled (notably
          mplayer).  Use (recompiled) mplayer to experiment / test /
          debug this various format using -af format=fmt. Note that
          24bit seeking in mplayer is a little bit broken, sometimes
          can cause silence or loud static noise. Pausing / seeking
          few times can solve this problem.
          You don't have to rebuild world entirely for this. Simply
          copy /usr/src/sys/sys/soundcard.h to
          /usr/include/sys/soundcard.h would suffice. Few drivers also
          need recompilation, and this can be done via
          /usr/src/sys/modules/sound/.
          Support for 24bit hardware playback is beyond the scope of
          this changes. That would require spessific hardware driver
          changes.
        * Don't expect playing 9999999999hz is a wise decision. Be
          reasonable. The new feeder_rate implemention provide
          flexibility, not insanity. You can easily chew up your CPU
          with this kind of mind instability. Please use proper
          mosquito repellent device for this obvious cracked brain
          attempt. As for testing purposes, you can use (again)
          mplayer to generate / play with different sampling rate. Use
          something like "mplayer -af resample=192000:0:0 <files>".

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by:	multimedia@
2005-07-31 16:16:22 +00:00
Alexander Leidinger
fe435202da * Slightly new method to detect mixer capabilities and resolution.
This mostly to help CT4730, but apparently it does help other
  cards too (especially via8233x). This probably need further test
  and confirmation from other people with ac97 cards other than via
  / es137x.
* Aggresive dac power wake up call, again, to help CT4730 (and
  probably others).

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by:	multimedia@
2005-07-31 14:28:31 +00:00
Alexander Leidinger
c249345405 - Fixup the locking.
- Don't mark MPSAFE (yet).
- DSP_CMD_DMAEXIT_8 doesn't work on old cards, use sb_reset_dsp() instead.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:53:53 +00:00
Alexander Leidinger
7a7689dea4 - Fixup the locking.
- Don't mark MPSAFE (yet).

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:51:04 +00:00
Alexander Leidinger
205d75821e Add another ID.
Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:49:47 +00:00
Alexander Leidinger
01bec79c11 * Add locking / MPSAFE
* Add kernel hint option to disable DXS channels entirely. Report
  from several skype users / Pav Lucistnik indicate that disabling
  DXS may fix lots of pop / crackling noise. To disable DXS add
  hint.pcm.<unit>.via_dxs_disabled="1" to /boot/device.hints.
  Further investigation of the issues regarding DXS showed, that
  the problem is in another (more generic) place, but until the
  right fix is tested/reviewed this may help a little bit.

Added sysctl's to aid testing/debugging:
hint.pcm.<unit>.via_dxs_disabled=X - Disable / Enable DXS channels entirely
hint.pcm.<unit>.via_dxs_channels=X - Limit DXS channels up to X
hint.pcm.<unit>.via_sgd_channels=X - Limit SGD channels up to X
hint.pcm.<unit>.via_dxs_src=X      - Enable / Disable DXS sample rate
                                     converter.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by:	multimedia@
2005-07-31 13:43:42 +00:00
Alexander Leidinger
cc730bdd4a Fix a LOR introduced with the last commit (some hours ago), I had the
wrong version of the patch.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Pointy hat to:	netchild
2005-07-31 13:24:47 +00:00
Alexander Leidinger
69e10e5a1b Fix a LOR introduced in the last commit (some hours ago), I had the wrong
version of the patch...

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Pointy hat to:	netchild
2005-07-31 13:22:48 +00:00
Alexander Leidinger
ae93e580dd * Register programming error during device initialization
especially for CT4730 / EV1938 chip, causing misconfigured mixer
  (David Xu), crippled after power cycle (Kevin Oberman). Fixed.
* Incorporate locking/spdif patches from Jon Noack / matk. Not all
  es137x can really do spdif, clean it up a bit to only let few capable
  chip. This adds a "hw.snd.pcm<unit>.spdif_enabled" sysctl until
  a more generic way of handling this from userland (by an ordinary
  user) is designed/implemented.
* Convert all bus_space_(read|write) to use es_rd/es_wr, simmilar
  with other drivers.
* Add tunable hw.snd.pcm<unit>.latency_timer sysctl to toggle pci
  latency timer value on the fly. Much noise / pop / crackling
  issues can be solved by increasing its value. Other people have
  pointed out to use pciconf instead, but this is just an added
  value specific for CT4730/EV1938.
* Remove es137x specific debug sysctl/code.

Several PRs can now be closed.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Submitted by:	Jon Noack <noackjr@alumni.rice.edu> (implicit)
Submitted by:	matk (implicit)
PR:		59349, 68594, 73498
Tested by:	multimedia@
2005-07-31 13:19:38 +00:00
Alexander Leidinger
f769fa83d5 This driver is already MPSAFE, remove busdma_lock_mutex and Giant from
bus_dma_tag_create.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 12:38:22 +00:00
Alexander Leidinger
2b379e8d35 * Add locking / MPSAFE.
Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by:	netchild
2005-07-31 11:04:36 +00:00
Alexander Leidinger
1adf8286e7 * als4000 can't do 48k properly (perhaps it really can't at all!).
Set maxspeed to 44.1k instead.
* Add locking / MPSAFE
* Fix recording

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 11:01:13 +00:00
Alexander Leidinger
7233abab86 * Fix panic during driver unload on second attempt after failure on
first (device busy).
* Fix module unloading for sound.ko itself.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by:	multimedia@
2005-07-31 10:55:24 +00:00
John Baldwin
dfa9ef3d99 Don't attach the non-PnP mss pcm(4) driver to acpi busses as ACPI only
enumerates PnP ISA-like devices.

Reported by:	Harry Coin harrycoin at qconline dot com
MFC after:	3 days
2005-07-13 15:17:54 +00:00
Gleb Smirnoff
961478afd1 Implement suspend/resume operation for snd_csa(4)
PR:		kern/82243
Submitted by:	Serge Semenenko
Approved by:	re (scottl)
MFC after:	1 month
2005-06-27 07:43:57 +00:00
Marius Strobl
169d14035a Wrap the calls to the ISA DMA specific sndbuf_dma*() functions of
sys/dev/sound/isa/sndbuf_dma.c (compilation depending on device isa)
in #ifdef DEV_ISA so sound(4) can be compiled without isa(4).

MFC after:	1 month
2005-06-10 21:33:14 +00:00
Seigo Tanimura
7b7c2c20d4 s/-1000/BUS_PROBE_LOW_PRIORITY/
Pointed out by:	nyan
2005-05-29 23:22:23 +00:00
Seigo Tanimura
db051dad5f Add 6300ESB, which should be treated as ICH4.
PR:		kern/81573
Submitted by:	OOTOMO Hiroyuki <ootomo@za.wakwak.com>
MFC after:	1 week
2005-05-28 09:32:43 +00:00
Pyun YongHyeon
c21880a7df Make snd_maestro3(4) mpsafe
- Let m3_pchan_trigger()/m3_rchan_trigger() acquire lock and call
   m3_pchan_trigger_locked()/m3_rchan_trigger_locked() respectivly.
 - Mark interrupt handler INTR_MPSAFE.
 - Add locks in sound/channel interface.

Tested by:	nork
2005-05-23 06:27:07 +00:00
Marius Strobl
437bc968c0 Take advantage of ebus(4) having switched to SYS_RES_MEMORY for the
memory resources in ebus.c rev. 1.22 and treat both the EBus and SBus
variants alike in this regard.

Ok'ed by:	yongari
2005-05-19 18:13:49 +00:00
Julian Elischer
7f05203a38 Add code from Kazuhito HONDA that allows the user to see
the available modes in /dev/sndstat.
e.g.
pcm1: <USB Audio> at addr ? (0p/1r/0v channels duplex)
        mode 1:(input) 1ch, 16/16bit, pcm, 44100Hz
	mode 2:(input) 1ch, 16/16bit, pcm, 22050Hz
	mode 3:(input) 1ch, 16/16bit, pcm, 11025Hz
	mode 4:(input) 1ch, 16/16bit, pcm, 8000Hz
2005-04-27 17:16:27 +00:00
Mathew Kanner
fe862a9b36 Fix a bug where we call pcm_getbuffersize twice.
Pointed out by:	Kazuhito HONDA <kazuhito at ph dot noda dot tus dot ac dot jp>
2005-04-17 16:26:08 +00:00
Mathew Kanner
ece089c054 De-dma the uaudio <-> pcm bridge. We were not capable of doing DMA from
this buffer anyway so the constraint that it had to be DMA capable only
caused pain when devices failed to aquire the memory.  Use a regular
malloc instead with sndbuf_setup.

Approved by:    tanimura (mentor)
2005-04-17 15:26:51 +00:00
Julian Elischer
0224b85a14 On record only devices, don't fail if we don't have a play channel.
MFC after: 3 days
2005-04-17 07:42:28 +00:00
Julian Elischer
b7fd00d97c The maximum allowable alloc is 16K not (16K-1).
This whole section is actually overly restrictive and
another patch is in the works.
2005-04-13 16:39:22 +00:00
Matthew N. Dodd
8f6a80b791 Make it clear that the statement following the conditional is a NOP. 2005-04-13 06:42:43 +00:00
Scott Long
c5cb8d604c Fix the output ports on the AD1988 codec. From the submitter:
Affects to people WITH an AD1888 codec, the system will output to the port
labeled "speaker" instead of microphone.  System will work the same in
multiple operating systems.

If people are currently using their systems with this codec they will need
to swap their output ports.

I have _not_ checked audio input or line input (basically, I have checked
nothing other than line-out).

I believe this is an appropriate change, it makes us consistent with
documentation, and other operating systems.  Furthermore, this feature
(playing) is the vast majority of sound activities, so if this makes is
right for playback and wrong for recording... playback is more important,
and we can fix recoding in the future without worries of screwing people
again in the future (since we'll be "right" on the playback).

Submitted by: David Cross
2005-04-10 14:45:27 +00:00
Poul-Henning Kamp
f4f6abcb4e Explicitly hold a reference to the cdev we have just cloned. This
closes the race where the cdev was reclaimed before it ever made it
back to devfs lookup.
2005-03-31 12:19:44 +00:00
Murray Stokely
ddc5ac8b73 Return BUS_PROBE_DEFAULT in preference to 0.
Pointed out by:	Nate Lawson <nate@root.org>
2005-03-20 20:13:21 +00:00
Murray Stokely
a52010a036 Add device id for nForce 4 audio controller.
PR:		kern/78482
Submitted by:	Markus Niemistö <markus.niemisto@iki.fi>
MFC after:	1 week
2005-03-19 01:39:13 +00:00
Warner Losh
d2b677bb1a Use BUS_PROBE_DEFAULT in preference to 0 and BUS_PROBE_LOW_PRIORITY in
preference to some random negative number to allow other drivers a
bite at the apple.
2005-03-01 08:58:06 +00:00
Matthew N. Dodd
c58d5e62ad Use mss_{format,speed}() rather than chn_set{format,speed}() and hold
mss lock across call.

This allows my Thinkpad 600E to resume with the sound driver loaded and
vchans enabled.
2005-02-27 23:32:21 +00:00
Poul-Henning Kamp
e70377df79 Use dynamic major number allocation. 2005-02-27 22:16:30 +00:00
Warner Losh
7c61c21042 BUS_SPACE_UNRESTRICTED shouldn't be used with the bus_alloc_resource
interface.  Instead, move to the convenience _any interface.
2005-02-01 07:43:34 +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
Julian Elischer
587161d920 Allow selection of a recording source on USB audio devices.
PR:		75316
Submitted by:	Kazuhito HONDA <kazuhito at ph dot noda dot tus dot ac dot jp>
Obtained from:	NetBSD plus changes
MFC after:	2 weeks
2004-12-25 08:55:52 +00:00
Julian Elischer
65046f8612 Allow recording on at least some USB audio devices.
PR:		75311
Submitted by:	Kazuhito HONDA <kazuhito at ph dot noda dot tus dot ac dot jp>
Obtained from:	NetBSD plus changes
MFC after:	2 weeks
2004-12-25 08:51:47 +00:00
Julian Elischer
2baaf9c206 Allow volume control on more channels/inputs
PR:		75276
Submitted by:	Kazuhito HONDA <kazuhito at ph dot noda dot tus dot ac dot jp>
Obtained from:	NetBSD  with changes
MFC after:	2 weeks
2004-12-25 08:46:03 +00:00
Julian Elischer
d28a81455e MFNetBSD:
One of a set of patches submitted by  Kazuhito HONDA
	to make the usb audio driver a lot more capable.

PR:	75274
Submitted by:	Kazuhito HONDA (kazuhito at ph dot noda dot tus dot ac dot jp)
Obtained from:	NetBSD (indirectly)
MFC after:	2 weeks
2004-12-25 06:20:49 +00:00
Poul-Henning Kamp
ba7cd7b68a Don't include vnode.h 2004-12-22 17:31:10 +00:00
Warner Losh
993fd0c509 PNP BIOS devices are fundamentally different than ISA PNP devices.
These devices should be probed first because they are at fixed
locations and cannot be turned off.  ISA PNP devices, on the other
hand, can be turned off and often can be flexible in the resources
they use.  Probe them last, as always.
2004-12-07 05:30:02 +00:00
Ruslan Ermilov
cf7190f2ea Fix build.
Submitted by:	Taku YAMAMOTO
2004-11-11 13:01:13 +00:00
Julian Elischer
15b0a9c8f7 Add record capability.
Submitted by:	Taku Yamamoto  (original author)
2004-11-10 04:29:09 +00:00
Pyun YongHyeon
7a7386a3e2 Device driver for onboard CS4231 audio controller which is found
on UltraSPARC workstations. The driver is based on OpenBSD's SBus
cs4231 driver and heavily modified to incorporate into sound(4)
infrastructure. Due to the lack of APCDMA documentation, the DMA
code of SBus cs4231 came from OpenBSD's driver.
The driver runs without Giant lock and supports both SBus and EBus
based CS4231 audio controller. Special thanks to marius for providing
feedbacks during the driver writing. His feedback made it possible
to write hiccup free playback code under high system loads.

Approved by:	jake (mentor)
Reviewed by:	marius (initial version)
Tested by:	marius, kwm, Julian C. Dunn(jdunn AT opentrend DOT net)
2004-10-25 10:29:57 +00:00
Nate Lawson
ecb7c87d1c Re-add an acpi attachment for the legacy probe that was inadvertently
removed.
2004-10-15 05:13:25 +00:00
Pyun YongHyeon
cea54ee291 Plug possible memory leak in sound DMA buffer handling. It also
changes return code to ENOMEM in case of allocation failure.

Approved by:	jake (mentor), scottl (co-mentor)
Reviewed by:	truckman, matk
2004-10-15 03:50:04 +00:00
Pyun YongHyeon
a2f4d2f5b0 Limit DMA address space to 1GB since the trident audio cards can't
handle DMA addresses located above 1GB. The LBA(loop begin address)
register which holds DMA base address is 32bits register. But the
MSB 2bits are used for other purposes. This effectivly limits the
DMA address space up to 1GB.

Approved by:	jake (mentor)
Reviewed by:	truckman, matk
2004-10-13 06:04:01 +00:00
Pyun YongHyeon
eba1cb6e3e Audio drivers failed to detect failure condition and attempted to
assign DMA address to the wrong address. It can cause system lockup
or other mysterious errors. Since most sound cards requires low DMA
address(BUS_SPACE_MAXADDR_24BIT) sndbuf_alloc() would fail when the
audio driver is loaded after long running of operations.

Approved by:	jake (mentor)
Reviewed by:	truckman, matk
2004-10-13 05:45:16 +00:00