Commit Graph

680 Commits

Author SHA1 Message Date
Alexander Motin
8f740c4b03 Enable MSI support by default. Still can be disabled using device.hints. 2009-02-15 21:17:21 +00:00
Alexander Motin
c7a5ac775b s/succeded/succeeded/ in comments. 2009-02-12 09:37:45 +00:00
Alexander Leidinger
3141a8dcd1 All open fixes and improvements from Konstantin for which users had to
use patches so far:
 + Envy24:
   - fix: broken init data for M Audio Delta DiO 2496
   - add: support for M Audio Delta 44
   - add: support for M Audio Delta 1010LT
     Tested by:	Dominique Goncalves, dominique.goncalves at gmail.com
   - add: support for Terratec EWX 2496
     Tested by:	Stefan Sperling, stsp at stsp.name
   - add: support for M Audio Delta 66
     Tested by:	Richard Bown, richard.bown at blueyonder.co.uk
   - add: support for M Audio Delta 1010
     Tested by:	Andrew Reilly, areilly at bigpond.net.au
 + Envy24HT:
   - add: support for Terrasoniq TS22PCI
   - fix: M-Audio Revolution 5.1 sound volume is very low
     Reported by:	Oliver Hartmann, ohartman at zedat.fu-berlin.de
                 	Andrey Slusar, anrays at gmail.com
     Tested by:		Andrey Slusar, anrays at gmail.com
               		Rusu Silviu, arol.the at gmail.com
   - fix: M-Audio Revolution 7.1 sound is distorted and very quiet
     Reported by:	Olev Hannula, hannula at gmail.com
     Tested by:		Olev Hannula, hannula at gmail.com
               		Stanislav Belansky, stanislav at icmail.ru
   - fix: Terratec PHASE 22 codec is power-off due to wrong init data
     Reported by:	Philipp Ost, pj at smo.de
     Tested by:		Philipp Ost, pj at smo.de
 + SpicDS:
   - fix: AK4381 produce hiss sound on 192kHz sample rate
   - fix: stupid bug with volume control for AK4396

Submitted by:	 	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
2009-02-11 10:29:45 +00:00
Olivier Houchard
cd5c163926 Hmm... "base? base : 0" and "base" should be equivalent.
Pointy hat to:	cognet

MFC after:	3 days
2009-02-09 22:59:22 +00:00
Alexander Motin
a05a433984 Fix bug in hint.hdac.X.config parsing. 2009-01-31 08:24:09 +00:00
Alexander Motin
18141fb27d Specify analog beep pin widget for several AD codecs.
It gives working speaker control for that systems.
2009-01-26 15:55:15 +00:00
Alexander Motin
8e097e5b32 Add two more nVidia HDMI codec IDs. 2009-01-19 19:16:50 +00:00
Giorgos Keramidas
7efe59806b Add support for CMedia CMI120.
PR:		kern/123640
Approved by:	ariff
MFC after:	2 weeks
2009-01-18 04:29:42 +00:00
Alexander Motin
a1cfce010b Correct spelling in comment. 2009-01-13 23:03:07 +00:00
Alexander Motin
12f2031fd5 Improve AD1983 codec support:
- force playback via mixer to get PCM volume control,
 - make cleanup on recoring source selection.
2009-01-13 22:10:01 +00:00
Alexander Motin
01dd74a1ed Change configuration order to enable output only after codec is configured.
Mute all mixer controllable amplifiers initially to let mixer to unmute
only some of them later. This should reduce clicks and noises during boot.
2009-01-13 16:27:04 +00:00
Alexander Motin
56035520b7 Fix unwanted crosschannel mixing, possible on some codecs like
VIA VT1708B and Realtek ALC268.
2009-01-11 12:04:18 +00:00
Alexander Motin
7f7de27152 Add one more bunch of controller and codec IDs. 2009-01-10 14:14:00 +00:00
Alexander Motin
78bb0fa358 Add external connector jack color into widget names.
It should help users to identify them while reading verbose messages.
2009-01-08 19:43:47 +00:00
Rong-En Fan
fb898a2cc2 - Remove snd_au88x0 which seems never got compiled into kernel nor as a kernel
module. These files cause manual interaction when building
  ports/audio/aureal-kmod which provides a usable i386-only driver (it requires
  linking against some linux object files distributed by vendor which bankrupted
  back in 2000).

MFC after:	1 week
2009-01-07 03:15:22 +00:00
Alexander Motin
f496eee7e3 Add some found NVidia MCP7x HDA controller IDs. 2008-12-27 11:00:20 +00:00
Alexander Motin
3f4f72bf2b Add some special handling for AD1986A codec:
Disable some unneeded pathes in overcomplicated input mixer to help parser
to handle the rest better. This gives mic input boost control in some
configurations and just more predictable operation in others.
2008-12-26 22:47:11 +00:00
Alexander Motin
51a8e5f0c3 Organize Conexant codecs.
Add CX20561 (Hermosa) codec ID.
2008-12-23 14:58:08 +00:00
Alexander Motin
fd9c95bdab Add 9 more Analog Devices codec names. 2008-12-22 22:40:17 +00:00
Alexander Motin
9678919ba4 Add ULI M5461 chipset and vendor ID. 2008-12-18 22:04:13 +00:00
Alexander Motin
1bc133fee9 Add some HDMI codec IDs. 2008-12-16 00:08:51 +00:00
Alexander Motin
13cf3e1bbe Add VIA VT1708B codec IDs. 2008-12-15 23:49:09 +00:00
Alexander Motin
b6562075bb Remove DELAY() on hdac_audio_commit().
I don't see the reason why it is needed.
2008-11-23 23:19:31 +00:00
Alexander Motin
1f925d9161 Do not use soft PCM volume for digital outputs to allow SPDIF AC3 bypass
to work. Soft PCM volume (and vchans) unable to bypass AC3 stream now.
2008-11-23 20:19:35 +00:00
Alexander Motin
3a7a3fc203 Strictly differentiate digital and analog PCM devices according to codec
nodes capabilities. Add "Analog"/"Digital" marks to the pcm device names.

I hope it will help new users easier accept concept of several PCM devices
and understand exact purposes of that devices.
2008-11-23 20:03:58 +00:00
Alexander Motin
f4088192d4 Whitespace cleanup for previous commit. 2008-11-22 15:38:24 +00:00
Alexander Motin
e3ae9f65c2 Handle device_get_children() errors in more correct way.
We shouldn't detach until all children are surely destroyed.

Found with:     Coverity Prevent(tm)
CID:            2137
2008-11-22 15:35:21 +00:00
Alexander Motin
d7b96565f5 Change check order to avoid array overrun.
Found with:	Coverity Prevent(tm)
CID:		2497
2008-11-22 14:48:40 +00:00
Alexander Motin
316f941e96 Correct association 0 handling.
as=0 means unused pin, so disable it explicitly, this is mostly cosmetics.
2008-11-15 09:39:00 +00:00
Alexander Motin
9fccea878a Add quirk to set GPIO2 to enable internal speaker on Dell Vostro 1400.
Tested by:	Sergio Veloso
2008-10-30 17:54:20 +00:00
Alexander Motin
6b3a1c6a08 Fix spelling in comment. 2008-10-25 08:31:20 +00:00
Alexander Motin
6f6487c338 Bump the revision after the latest commits. 2008-10-24 19:36:28 +00:00
Alexander Motin
e1a5654741 Add some special handeling for AD1981HD codec. It has very unusual design
with several points unappropriate for the present parser. This patch
disables input-to-output analog monitoring but instead fixes recording.

Tested by Tobias Grosser on ThinkPad T61p.
2008-10-24 19:29:07 +00:00
Alexander Motin
16c8eda0bd Add Intel ICH10 and SCH HDA controllers PCI IDs. 2008-10-23 18:30:06 +00:00
Alexander Motin
5ce33ccf10 Make HDA PCM device boot and sndstat messages more alike to PCI device ones.
Move codec # out of the device name as it is a device address and not part of
device type name.
2008-10-20 18:37:10 +00:00
Alexander Motin
2ba3710257 Tune boot messages a bit.
Use <> brackets only at device name line.
2008-10-20 17:24:25 +00:00
Alexander Motin
7be3ed1dfe Add all Sigmatel/IDT codecs I could find.
Add IDT and Intel unknown codecs.

PR:		kern/125822
2008-10-14 19:58:26 +00:00
Alexander Motin
f5803010bb Bump driver revision after the previous commit. 2008-10-12 21:46:11 +00:00
Alexander Motin
bbbf908dad Fix bug in a second call of the channel allocation function.
This should fix crash on systems where two audio codecs connected
to the same HDA bus.
2008-10-12 21:42:21 +00:00
Ed Schouten
d3ce832719 Remove unit2minor() use from kernel code.
When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by:	kib
2008-09-26 14:19:52 +00:00
Alexander Motin
4d423c805b Hide some of driver's internal debugging.
Left only parts surely required for basic troubleshooting and configuration
purposes. There is still very long output, but further shrinking makes it
less informative.

Original debugging can be enabled with hw.snd.verbose=4.
2008-09-16 20:03:34 +00:00
Alexander Motin
a6371849d1 Small addition to the previous commit. Sorry. 2008-09-14 17:40:53 +00:00
Alexander Motin
ac14b5ee5c Add some missing Realtek codec IDs. Just for reference.
Fix small typo in error message.
2008-09-14 17:37:34 +00:00
Alexander Motin
c7edbd9d92 Remove one unneeded printf from non-verbose output.
Submitted by:	Artem Naluzhnyy
2008-09-14 15:10:53 +00:00
Alexander Motin
859159d164 My massive snd_hda driver update.
Because of using more clear and same time more functional codec parser
new driver is able to handle more codecs, use them better then before and
without most of previous quirks. All of tested codecs itself manage playback,
record, input mixing and monitoring quite fine. In all of investigated
trouble cases problem was found or in nonstandard codec usage or incorrect
codec configuration made by BIOS. Most of that cases could be fixed using
device hints, some of which are already included to the driver.

New driver supports multiple codecs per HDA bus, multiple audio function
groups per codec and multiple logical sound devices per audio function group.
So don't worry when you get several PCM devices instead of one, it is normal.
It is usual situation with powerful codecs to provide, for example, 3 PCM
devices: one for 7.1 playback and main recording, one for headset and one
for digital SPDIF I/O.

New driver implements Universal Audio Architecture (UAA) much better then
previous one. Most information about recommended codec usage now taken from
the codec configuration registers initialized by BIOS. User may alter that
configuration using device hints to reconfigure logical audio devices to
his needs in a very broad range up to the limits of the codec functionality.

New driver supports digital PCM playback and AC3 pass-through. I am not sure
about completeness of this implementation, but I have several success stories
including my own. Vchans subsystem does not support AC3 pass-through so it
had to be disabled for that devices at this moment.

New driver is ready for multichannel playback, but until our OSS is unable
to use this it will just duplicate same stereo stream into all channel
pairs.

New driver supports suspend/resume. I am unable to really test this part
myself, but I have got several success stories.

Driver has very informative verbose boot messages. So if you have any
questions or problems - enable and read them first.

Discussed on:	freebsd-multimedia@
Tested by:	many
2008-09-13 16:56:03 +00:00
Joel Dahl
bbe9d8cba9 Fix deactivation of speakers while plugging in headphones on Fujitsu
U1010, Lenovo 3k N200 and Acer Aspire 4715Z.

Reviewed by:	attilio
PR:		126216, 126244, 127034
Submitted by:	Anton E. Kartashev <amokk@mirahost.ru>,
		Ganael Laplanche <ganael.laplanche@martymac.com>,
		Dennis Generaloff <giantlock@gmail.com>
2008-09-07 20:25:19 +00:00
Warner Losh
a4e1d2d2cf Make sure that we handle errors in device_get_children correctly. 2008-08-23 18:27:10 +00:00
Xin LI
ff7b31cb8f Add quirk for Dell D630 laptops.
Tested by:	Quake Lee <quakelee geekcn org>,
		Robert Noland <rnoland 2hip net>
MFC after:	1 week
Approved by:	ariff
2008-07-15 02:34:44 +00:00
Xin LI
f8635870a4 Correct SB600 AC97 Audio PCI ID, otherwise we will attach to the
SBx00 PCI to PCI Bridge which causes problems.
2008-06-30 05:14:44 +00:00
Kevin Lo
c730aefff3 Add codec id for Sigmatel STAC9872AK
Reviewed by:	ariff
2008-05-22 09:14:12 +00:00
Ariff Abdullah
42018dcf7b Fix no sound issues for ASUS W6F (ALC861) laptops (buggy BIOS config that
deserves its own internet memes). The trick is to force all available,
unused pins (that being advertised as "speaker") to behave as microphone
pins instead.

Reported / Tested by:	Dmitry Kutsenko <kutsenko.truebsd.org>
MFC after:		3 days
2008-04-19 22:32:23 +00:00
Ariff Abdullah
3cc4ca2ab8 - Add codec id for Sigmatel STAC9205
- Fix speaker issues with Dell Vostro 1500 (GPIO0)

Tested by:	John Wright <jwright.gmail.com>

- Apply ridiculous quirk on Asus A8X series (A8JC, A8M, A8xx, etc). These
  different laptop series share simmilar pci id, hardware codecs, etc.
  but works differently. A slight difference in connection type for
  widget #26 is used to differentiate it.

Tested by:	eric baumbach <embaumbach.gmail.com>

- Apply GPIO0 quirk for ASUS G2K laptop
- Sort ASUS ids accordingly.

Submitted by:	jkim

MFC after:	3 days
2008-04-12 15:07:32 +00:00
Ariff Abdullah
667aaea554 Limit total hardware playback channels to just 1. The reliability of
it's multi DAC / playback channels is not that good. Enabling vchans
make the bug more visible since playback allocation will look for
possible free hardware channels first (i.e: the next DAC, the very first
has been consumed by vchan mixer) which in this case has been proven faulty.

Tested by:	Dominic Fandrey <LoN_Kamikaze at gmx dot de>
URL:		http://lists.freebsd.org/pipermail/freebsd-stable/2007-December/039022.html
2007-12-14 02:16:26 +00:00
Ariff Abdullah
d155e640d8 Add speaker/headphone controls for HP Compaq DC7700 Small Form Factor PC
@ ALC262.

Submitted by:	Carlos A. M. dos Santos <unixmania at gmail dot com>
2007-12-13 15:48:45 +00:00
Ariff Abdullah
c8d361d42d nid 28 for Acer @ ALC268 should be identified as analog CD input pin,
though it doesn't provides proper (sane, valid, usable, etc) analog CD
playback due to its stripped down nature.
2007-12-13 15:44:53 +00:00
Ariff Abdullah
909f7f7f4e Disable AC97 microphone channel. Due to the channel allocation priority
that favours true hardware channel, the first instance of recording
request will grab this channel (the first channel is being used as
vchan master). In many cases, it is not really work as intended and give
false impression of broken recording.

PR:		kern/118546
MFC after:	3 days
2007-12-12 18:21:05 +00:00
Ariff Abdullah
229acba1d0 Headphone / speakers automute fixup for Acer Aspire 4710 @ ALC268 laptop.
Tested by:	Liyu, She
2007-12-02 16:38:28 +00:00
Ariff Abdullah
1cb55600a0 - Add Analog Devices AD1984 codec id.
- Enable pcbeep control for Acer + ALC268 (nid 29). Give enough (fake)
  hints so the parser will grab it and allocate "speaker" control.
- Fix regression while preparing DAC and ADC for multichannel
  format. Since playback policy is to output to every possible path,
  ensure that each DAC is started.

Reported / Tested by:	Guy Brand
2007-11-28 15:27:22 +00:00
Ariff Abdullah
fcdde99a89 Add missing MCP65 id which was accidentally removed in previous commit. 2007-11-28 02:13:20 +00:00
Ariff Abdullah
46e5fdd5af * Fix support for followings:
o Acer Aspire 4520 laptop
    - jack sensing / automute
  o Toshiba Satellite A135-S4527 laptop
    - jack sensing / automute
      Tested by: lioux
  o Apple Macbook 3 (is it?)
    - require gpio0 (for speakers) and ovref50 (for headphone)
      to make it works
    - jack sensing / automute
      Tested by: Ed Schouten
* Add Nvidia MCP67 controller ids.
* Be sensible about simmilar controller with multiple pci ids.
* Connect unused DAC/ADC to stream#0 rather than forcing each of them
  managing their own stream.

MFC after:	3 days
2007-11-21 11:39:27 +00:00
Ariff Abdullah
8b18769048 Limit total playback channels to just 1, for ALi M5451.
The reliability of it's multi DAC / playback channels is
not that good. Enabling vchans make the bug more visible
since playback allocation will look for possible free
hardware channels first (i.e: the next DAC, the very first
has been consumed by vchan mixer) which in this case has
been proven faulty.

Reported / Tested by:	Sascha Klauder
MFC after:		3 days
2007-11-10 04:32:50 +00:00
Ariff Abdullah
ee2b7497ea Add support for trimmed down version of ATI SB600 AC97 audio
controller.

URL:		http://www.ipc2u.de/catalog/P/PE/36486.html
PR:		kern/117813
Submitted by:	Klaus Mayr
MFC after:	1 day
2007-11-04 16:03:10 +00:00
Ariff Abdullah
fd0a47907c - Gigabyte G33-S2H fixup, due to the present of multiple competing
codecs. Codec at address 0 seems purely digital, or perhaps an HDMI
  interface. Let the driver skip it and continue scanning the codecs
  starting with address 2 (Realtek ALC885).
  * Due to possibilities of future similar cases, put enough logic
    in hdac_scan_codecs() to force codec scanning starting from
    XX address via tunable "hint.pcm.%d.codec_index".

  Reported / Tested by:	Toomas Pelberg <toomasp@gmx.net>

- Trivial headphone / speaker automute fixup for Fujitsu-Siemens
  AMILO Si 1848 laptop.

  Reported / Tested by:	Ed <ed@bsd.it>

- Trivial headphone / speaker automute fixup for Fujitsu-Siemens
  Lifebook S7020D laptop.

  Reported / Tested by: Jaromir Dvoracek <jarek@ataxo.com>

- Some smart vendor trying to create interplanetary wormhole by
  screwing pci config space during their BIOS update. The side effects
  of their failure attempt includes mutilated hardware id, broken
  speaker automuting and loosing the entire analog CD connectivity,
  thus causing enough collateral damages to collapse the entire
  universe.  Move along with it.

  Please exercise extra cautious when applying BIOS updates.

  Reported / Tested by:	Pietro Cerutti <gahr@gahr.ch>
                       	- assembled laptop, based on the MSI-1034
                          (662) which is now becoming MSI-034A.

- Fix no sound issues (on headphones) for Lenovo ThinkCentre A55 due
  to global automute table entry which is not applicable for
  non-laptops.

  Reported / Tested by:	Piotr Smyrak <piotr.smyrak@heron.pl>

- Speaker mute control for HP DC7700 since the front headphone jack
  does not generate any interesting unsolicited signal/response.

  Reported / Tested by:	tyop @ irc.freenode.net

Approved by:	re (kensmith)
MFC after:	3 days
2007-10-19 15:49:39 +00:00
Kevin Lo
976b010645 Spelling fix for interupt -> interrupt 2007-10-12 06:03:46 +00:00
Ariff Abdullah
b28624fde6 Update snd_emu10kx driver with recent perforce changes (and few
other changes too).

(without any real order)

1. Use device_get_nameunit for mutex naming
2. Add timer for low-latency playback
3. Move most mixer controls from sysctls to mixer(8) controls.
   This is a largest part of this patch.
4. Add analog/digital switch (as a temporary sysctl)
5. Get back support for low-bitrate playback (with help of (2))
6. Change locking for exclusive I/O. Writing to non-PTR register
   is almost safe and does not need to be ordered with PTR operations.
7. Disable MIDI until we get it to detach properly and fix memory
   managment problems.
8. Enable multichannel playback by default. It is as stable as
   single-channel mode. Multichannel recording is still an
   experimental feature.
9. Multichannel options can be changed by loader tunables.
10. Add a way to disable card from a loader tunable.
11. Add new PCI IDs.
12. Debugger settings are loader tunables now.
14. Remove some unused variables.
15. Mark pcm sub-devices MPSAFE.
16. Partially revert (bus_setup_intr -> snd_setup_intr) since it need
    to be done independently

Submitted by:	Yuriy Tsibizov (driver maintainer)
Approved by:	re (bmah)
2007-09-12 07:43:43 +00:00
Ariff Abdullah
05cba74005 Protect against divide by zero while calculating bus speed due to
possible broken kernel timecounter.

Reported/Tested by:	silby
Approved by:		re (hrs)
MFC after:		1 day
2007-07-11 14:27:45 +00:00
Ariff Abdullah
0937dd1ec0 - Add codec id for Realtek ALC268.
- Add controller id for Intel 82801I (ICH9).
  PR:			kern/114399
  Submitted by:		Michael Fuckner <michael@fuckner.net>

- MSI support. Disable by default due to various issues with too many
  broken hardwares. MSI can be enabled through device.hints(5) or
  kenv(8) by setting "hint.pcm.%d.msi=1".
  Partially submitted by:	kevlo
                         	YAMAMOTO Taku <taku@tackymt.homeip.net>
  Tested by:			joel, kevlo, YAMAMOTO Taku

Approved by:	re (hrs)
MFC after:	3 days
2007-07-09 20:42:11 +00:00
Ariff Abdullah
8a7c4d36cb Fix stream suspend/resume activity due to its states being
clobbered by pcm channel start/stop trigger operation.

Approved by:	re (hrs)
2007-07-09 20:41:23 +00:00
Ariff Abdullah
36bc8661bf Properly unlock mutex before returning. There was a slight mishap
during last major locking cleanup.

Reported by:	Thierry Herbelot <thierry@herbelot.com>
Approved by:	re (mux)
2007-07-05 10:22:37 +00:00
Ariff Abdullah
e5ad83a7e3 - Fix input/microphone support for ASUS A8N-VMCSM series.
Submitted by:	Simon Schubert <corecode@fs.ei.tum.de>

- Defer flushing unsolicited response into taskqueue thread rather
  than handle it directly in interrupt handler, since few of its
  operations (like measuring/calibrating jack impedance) are quite
  expensive.
- Misc. debugging cleanups.

Tested by:	joel
Approved by:	re (hrs)
MFC after:	3 days
2007-07-01 17:31:20 +00:00
Ariff Abdullah
715ed548ab Fix headphone jack sensing support for Olivetti Olibook 610-430 XPSE.
Tested by:	Gonzalo Lionel Rodriguez
2007-06-18 22:39:27 +00:00
Ariff Abdullah
082f63835c Flush remaining malloc() cleanups (M_NOWAIT -> M_WAITOK). 2007-06-17 06:10:43 +00:00
Ariff Abdullah
e4e61333ff Last (again ?!?) major commit for RELENG_7, featuring total Giant
eradication in/from userland path, countless locking fixes, etc.

- General sleep call through msleep(9) has been converted to condvar(9)
  with better consistencies.
- Heavily guard every possible "slow path" entries (open(), close(),
  few ioctl()s, sysctls), but once it entering "fast path" (io, interrupt
  started), they are free to fly on their own.
- Rearrange locking sequences, resulting better concurrency and
  serialization. Large part doesn't even need locking at all, and will be
  removed in future. Less clutter, except in few places due to lock
  ordering.
- Anonymous mixer object creation/deletion to simplify mixer handling
  beyond typical mixer ioctls.
  Submitted by:		chibis (with modifications)
- Add few mix_[get|set|..] functions to avoid calling mixer_ioctl()
  directly using cryptic arguments.
- Locking fixes to avoid possible deadlock with (still under Giant) USB.
- Better simplex/duplex device handling.
- Recover mmap() functionality for recording, which has been lost
  since 2.2.x - 3.x (the introduction of newpcm). Full-duplex mmap still
  doesn't work (due to VM/page design), but people still can mmap
  both by opening each direction separately. mmaped playback is guarantee
  to work either way.
- New sysctl: "hw.snd.compat_linux_mmap" to allow PROT_EXEC page
  mapping, due to recent changes in linux compatibility layer which
  require it. All linux applications that using sound + mmap() (mostly games)
  require this to be enabled. Disabled by default.
- Other goodies.. too many, that will increase releng7 shareholder value
  and make users of releng6 (and below) cry ;)

* This commit should be atomic. If anything goes wrong (not counting problem
  originated from elsewhere), I will not hesitate to revert everything back
  within 12 hours. This substantial changes itself not a rocket science
  and the process has begun for almost 2 years, and lots of incremental
  changes are already in place during that period of time.
* Some issues does occur in snd_emu10kx (note the 'x') due to various
  internal locking issues and it is currently being worked on by chibis.

Tested by:	chibis (Yuriy Tsibizov), joel, Alexandre Vieira,
          	many innocent souls...
2007-06-16 03:37:28 +00:00
Ariff Abdullah
5d75db4f00 Drain all callout handlers during driver detach appropriately. 2007-06-14 11:13:38 +00:00
Ariff Abdullah
79b783c721 Don't push too hard waiting/looping for codec detection interrupt.
Let the interrupt do the job waking us up.
2007-06-14 11:11:06 +00:00
Ariff Abdullah
bdfbdcec6a Filter/compress the amount of channel trigger. This should reduce
much of lock/unlock contentions within the interrupt handler. Most
of these drivers only need PCMTRIG_START or STOP (ABORT).

Discussed with:		scottl
2007-06-11 00:49:46 +00:00
Ariff Abdullah
f6cdab92db - Add codec id for ALC660 [1]
- Add codec id for AD1988B, along with fixing its line-in and other
  issues (with proper quirks). [2]

Submitted by:	[1] barbara.xxx1975@libero.it
             	[2] Oliver Brandmueller ob@e-Gitt.NET
MFC after:	3 days
2007-06-10 23:01:40 +00:00
David Malone
041b706b2f Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported.  In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.
2007-06-04 18:25:08 +00:00
Ariff Abdullah
e510f52136 Use standard pcm_get/setflags() rather than dereferencing softc while
enabling SD_F_SOFTPCMVOL or any flags.
2007-06-02 17:28:26 +00:00
Ariff Abdullah
4257f25c06 Don't rely on pcm_channel index numbering while doing sequential channel
allocation.
2007-05-30 16:15:01 +00:00
Ariff Abdullah
2ba5e1edcc - Enable soft pcm volume flag early to ensure it not being clobbered
by the subsequent mix_setdevs() and friends.
- Minor style(9) declaration arrangement nit.

Requested by:	joeld
Submitted by:	pluknet <pluknet@gmail.com>
2007-05-28 16:22:07 +00:00
Ariff Abdullah
79462204f1 Fix broken binary issues with latest gcc 4.x due to bitfield signess
mishaps for emu10k1 [1] and few other places.

Reported/Submitted/Tested by:	Ed Schouten <ed@fxq.nl> [1]
2007-05-27 20:12:51 +00:00
Joel Dahl
ccb43d8d2c Bring in a bunch of bug fixes and some code to support more chipsets.
Neither me nor Ariff have access to any of this hardware, so all tests
have been made by Konstantin and Artem.  Commit message mostly written
by Konstantin.

envy24:
- Add test code to support rear line-in input on 'Terratec DMX 6fire'
  audio card.  This code is also intended to be used in the future for
  support of cards, that have I2C-to-GPIO expanders wired between the
  control line of the audio codec and the Envy24, however such cards
  are too complex and i can't add that support without hardware sample
  of such board, i've already tried and failed.

envy24ht:
- Add support for 'AudioTrak Prodigy HD2'.
- Add support for 'AudioTrak Prodigy 7.1 XT'.
- Add support for 'ESI Juli@' (Works ok, DAC volume is hard-coded for
  the time being, so 'mixer vol ...' doesn't work, only 'mixer pcm
  ...' works). [1]
- Fix bug in the init data for M-Audio Revolution 5.1, that
  results in distorted sound.
- Add software volume control (now 'mixer pcm' works, thanks to Ariff).
- Add support for more samples rates - 176.4kHz and 192kHz.
- Fix problem with the 192kHz samples rate playback when 24.576MHz
  crystal is used on the board instead of 49.152MHz crystal.

spicds:
- Add support for Asahi Kasei flagship DAC - AK4396 (used in AudioTrak
  Prodigy HD2).

Submitted by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
Tested by:	Artem Antonov [1]
Reviewed by:	ariff
2007-05-27 19:58:39 +00:00
Joel Dahl
ea18b1d925 Fix randomly broken playback with Fortemedia FM801 XWave PCI soundcard.
PR:		kern/98898
Submitted by:	Johannes Weiner <hnazfoo@googlemail.com>
Approved by:	ariff
2007-05-19 13:19:32 +00:00
Joel Dahl
03756ceff7 Turn off the AK452X De-emphasis filter for 44.1KHz. This should fix some
sound quality problems.

PR:		kern/112688
Submitted by:	Stefan Ehmann <shoesoft@gmx.net>
Reviewed by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
Approved by:	ariff
2007-05-19 11:06:43 +00:00
Ariff Abdullah
a6f9c6fb5f Don't hold mutex while releasing bus resources. 2007-05-10 01:46:51 +00:00
Ariff Abdullah
3419bf5a7d Fix (or rather workaround) Intel 440MX Errata #36
- http://www.intel.com/design/chipsets/specupdt/245051.htm

AC97 Soft Audio and Soft Modem Master Abort Errata

Issue:
  Use of either soft audio or soft modem on an Intel® 82443MX PCISet
  based platform running a 100 MHz Processor System Bus and an AC97 codec
  may result in failures. The system continues to function normally while
  the AC97 hardware may not resume and may require a cold-boot to
  recover. As a result of the failure, the Master Abort Status bit will
  be set in the audio or modem function PCI header space.

Workaround:
  Force uncacheable DMA on both BDL and pcm buffers.

Tested by:	Emil Holmstr|m <emil@linux.se>
2007-05-05 09:18:05 +00:00
Ariff Abdullah
71e3af015d Miscellaneous changes and fix:
- Remove explicit call to pmap_change_attr(), since we now have proper
  and functional definition of BUS_DMA_NOCACHE.
- Enable PCI(e) bus snooping for non i386/amd64 as an alternative for
  uncacheable DMA.
- Codecs changes:
  * Analag Device -> Analog Devices, AD1988.
  * New codec: VIA VT1708 and VT1709, Realtek ALC262, ALC861-VD and
    ALC885.
  * Various fixups for Conexant Waikiki, fix recording (read: microphone)
    on various Analog Devices codecs due to vendor BIOS mess, various
    quirks for several ASUS laptops/boards.
- Fix connection list handling, closely following the specification to
  handle range of nids.
- Basic Jack sense polling infrastructure for possible hardwares with
  broken unsolicited response interrupt.

Ideas/Submitted/Tested by:	Andriy Gapon <avg@icyb.net.ua>,
                          	#freebsd-azalia, many.
2007-05-05 09:17:36 +00:00
Ariff Abdullah
53bc1d83c0 Fix use-after-free for DMA tag. Destroy DMA tag later.
Submitted by:	Yuriy Tsibizov
2007-05-04 12:38:46 +00:00
Ariff Abdullah
9d2d90cb79 Unbreak module / driver attach breakage. Both snd_envy24 and snd_envy24ht
mistakenly rely on wrong snd_spicds version.
2007-04-20 01:28:51 +00:00
Ariff Abdullah
2e334adf6a sndbuf_alloc() now accept dmaflags argument which will be forwarded to
internal bus_dmammem_alloc() for greater flexibility on setting up DMA /
page attributes.
2007-04-18 18:26:41 +00:00
Ariff Abdullah
319276aac0 Disable cmi_midiattach(). The implementation is incomplete, and causing
various interesting memory leak issues.
2007-04-08 07:52:27 +00:00
Ariff Abdullah
703c934a48 Memory leak killing spree, mostly bus_dma(9) related. 2007-03-21 18:17:03 +00:00
Ariff Abdullah
94d36aa276 Put a temporary bandaid to set/reset uncacheable DMA region (affected
on amd64 and i386) until we gain proper BUS_DMA_NOCACHE support.
(in progress).

Tested by:	rafan, infofarmer, Nguyen Tam Chinh <unixvn@gmail.com>
Tested on:	amd64, i386
2007-03-20 11:24:29 +00:00
Ariff Abdullah
19f018fb83 Destroy channel DMA tag during resource cleanup. 2007-03-19 16:06:26 +00:00
Ariff Abdullah
d2ea76fe8f Fix (another, more to come) ivar memory leak during driver detach. 2007-03-17 19:37:09 +00:00
Ariff Abdullah
1042342ad8 [stage: 8/9]
Implement CHANNEL_SETFRAGMENTS() for snd_atiixp, snd_es137x, snd_hda
and snd_via8233. CHANNEL_SETBLOCKSIZE() will basically call
CHANNEL_SETFRAGMENTS() internally using conservative blocksize /
blockcount hints. Other drivers will be converted later.
2007-03-16 17:18:17 +00:00
Ariff Abdullah
d90a1cd318 Fix support for ASUS A7T ALC882 laptop (gpio0 quirk).
Reported/Tested by:	cognet
2007-03-16 01:44:21 +00:00
Ariff Abdullah
12828031ac - Put some sanity break statement in few missing places.
- Remove NULL checking on snd_mtxcreate() (M_WAITOK) .
2007-03-15 17:35:04 +00:00
Ariff Abdullah
82199c9255 NOOP (for now) for hdac_dma_nocache(). It is a wrong way to enforce
cache coherency, besides of causing train wreck in other places
(especially on amd64, possibly on i386).

Discussed with:	kib@, rafan@
Tested by:	rafan@
2007-03-15 17:23:38 +00:00
Ariff Abdullah
4582b3a100 Fix severe out-of-bound mtx "type" pointer, causing WITNESS refcount
confusions and panic provided that the following conditions are met:

  1) WITNESS is enabled (watch/trace).
  2) Using modules, instead of statically linked (Not a strict
     requirement, but easier to reproduce this way).
  3) 2 or more modules share the same mtx type ("sound softc").
     - They might share the same name (strcmp() == 0), but it always
       point to different address.
  4) Repetitive kldunload/load on any module that shares the same mtx
     type (Not a strict requirement, but easier to reproduce this way).

     Consider module A and module B:
     - From enroll() - subr_witness.c:
       * Load module A. Everything seems fine right now.
         wA-w_refcount == 1 ; wA-w_name = "sound softc"
       * Load module B.
       * w->w_name == description will always fail.
         ("sound softc" from A and B point to different address).
       * wA->w_refcount > 0 && strcmp(description, wA->w_name) == 0
       * enroll() will return wA instead of returning (possibly unique)
         wB.
         wA->w_refcount++ , == 2.
       * Unload module A, mtx_destroy(), wA->w_name become invalid,
         but wA->w_refcount-- become 1 instead of 0. wA will not be
         removed from witness list.
       * Some other places call mtx_init(), iterating witness list,
         found wA, failed on wA->w_name == description
       * wA->w_refcount > 0 && strcmp(description, wA->w_name)
       * Panic on strcmp() since wA->w_name no longer point to valid
         address.

Note that this could happened in other places as well, not just sound
(eg. consider lots of drivers that share simmilar MTX_NETWORK_LOCK).

Solutions (for sound case):
  1) Provide unique mtx type string for each mutex creation (chosen)
  or
  2) Put "sound softc" global variable somewhere and use it.
2007-03-15 16:41:27 +00:00
Ariff Abdullah
0585c315b7 Add AC97 inverted external amplifier quirk for ASUS A6R laptop.
PR:		kern/110244
MFC after:	3 days
2007-03-13 15:20:33 +00:00
Ariff Abdullah
c0dc2ab241 Fix analog CD connectivity. HP decided to screw pinconfig settings in
their latest Compaq V3000 BIOS (revision F.22). As a result, analog CD
connectivity is gone to the oblivion. Even if they decide to fix it in
future revisions, the damage has been done.
2007-03-11 15:26:49 +00:00
Ariff Abdullah
018b991e1d Fix long standing multi playback/recording issues, caused by
excessive interrupt clock timer reset, screwing interrupt generation
for already active channels. Track moving DMA pointer and call buffer
interrupt on each blocksize boundary.

PR:		kern/109791
MFC after:	3 days
2007-03-09 05:35:20 +00:00
Kevin Lo
32d6c6993c Use M_NOWAIT instead of M_WAITOK to cause malloc() to return NULL. 2007-03-07 05:28:42 +00:00
Ariff Abdullah
9622f4d439 Quick bandaid for possible broken multiple playback channels implementation.
Reported/Tested by:	Oliver Iberien <odilist@sonic.net>
2007-03-05 07:45:38 +00:00
Ariff Abdullah
b88d63a8ea Fix ALC883 microphone / recording issues. Setting high(er) VRef on
(external) microphone pin tend to screw it. Internal microphone (found
on several laptops) still need high VRef.

Tested by:	Pietro Cerutti <pietro.cerutti@gmail.com>
          	lenix <irc.freenode.net>
2007-02-25 06:17:56 +00:00
Ariff Abdullah
5583760956 - Revert arguments for several functions to pre bus_get_dma_tag()
changes. Each softc contains information about their own device_t,
  use that instead.
- bus_setup_intr() -> snd_setup_intr().
2007-02-23 19:41:16 +00:00
Ariff Abdullah
2cc08b748c - Compile time compatibility for pre/post newbus API (intr filter)
changes. This should ease the job of maintaining codebase since much
  of the regression tests are done across os versions.
- bus_setup_intr() -> snd_setup_intr().
2007-02-23 19:40:13 +00:00
Ariff Abdullah
78bb065b84 Use snd_setup_intr() instead of bus_setup_intr() , like other drivers. 2007-02-23 19:39:06 +00:00
Alexander Leidinger
0b989078d7 MFp4 (114068):
Use bus_get_dma_tag() to obtain the parent DMA tag to make the drivers
        a little bit more non-ia32/amd64 friendly.

        There is no man page for bus_get_dma_tag, so this is modelled after
        rev. 1.62 of src/sys/dev/sound/pci/es137x.c by marius.

        Inspired by:	commit by marius
2007-02-23 13:47:34 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
Ariff Abdullah
885d6cfbc1 Add codec id for Sigmatel STAC9271D.
Submitted by:	Michael Fuckner <michael@fuckner.net>
2007-02-16 17:43:29 +00:00
Ariff Abdullah
d82080b4cd Fix compilation for statically linked snd_envy24{ht}/spicds. Use explicit
struct mtx rather than void pointer.

PR:	kern/109147
2007-02-14 15:23:44 +00:00
Ariff Abdullah
5430d30e44 Add speaker control for HP xw4300. This hardware doesn't respond to
unsolicited pin sense event and need manual control to turn off speaker
volume while attaching headphone.

Tested by:		Ingeborg Hellemo <Ingeborg.Hellemo@cc.uit.no>

Disable global Acer + ALC883 headphone automute settings since there are
few models that does not respect this and causing broken behaviour.

Reported/Tested by:	Pavel Argentov <argentoff@rtelekom.ru>
2007-01-28 03:16:54 +00:00
Ariff Abdullah
b9ba7b9e78 Massive inlining cleanups/removal to make it survive on WARNS=2. 2007-01-27 13:30:19 +00:00
Ariff Abdullah
a12b5a0728 Reduce maximum DMA segments from 128 to 64. We don't need more than that. 2007-01-27 07:35:05 +00:00
Ariff Abdullah
f39ee7ef2e Total DMA segments should include total number of record channel(s). 2007-01-26 23:53:56 +00:00
Marius Strobl
c2175ff5ca Change the remainder of the drivers for DMA'ing devices enabled in the
sparc64 GENERIC and the sound device drivers known working on sparc64
to use bus_get_dma_tag() to obtain the parent DMA tag so we can get rid
of the sparc64_root_dma_tag kludge eventually. Except for ath(4), sk(4),
stge(4) and ti(4) these changes are runtime tested (unless I booted up
the wrong kernels again...).
2007-01-21 19:32:51 +00:00
Joel Dahl
5c92405025 Fix typo in a comment. 2007-01-16 12:27:13 +00:00
Ariff Abdullah
95af1064dc Fix headphone/speaker automute for [1] Acer Aspire 5050 and [2] MSI MS-1034
laptops.

Tested by:	[1] Lion G. <liontanker@hotmail.com>
          	[2] Pietro Cerutti <pietro.cerutti@gmail.com>

Specialized mixer initialization for STAC9221, much like STAC9220.

Tested by:	Devon H. O'Dell
2007-01-13 00:24:44 +00:00
Alexander Leidinger
f856af0466 Extend the emu10kx driver. With the words of the author:
---snip---
New features:
1.	Optional multichannel recording (32 channels on Live!, 64 channels
 	on Audigy).

 	All channels are 16bit/48000Hz/mono, format is fixed.
 	Half of them are copied from sound output, another half can be
 	used to record any data from DSP. What should be recorded is
 	hardcoded in DSP code. In this version it records dummy data, but
 	can be used to record all DSP inputs, for example..

 	Because there are no support of more-than-stereo sound streams
 	multichannell stream is presented as one 32(64)*48000 Hz 16bit mono
 	stream.

 	Channel map:

 	SB Live! (4.0/5.1)
 	offset (words)	substream
 	0x00		Front L
 	0x01		Front R
 	0x02		Digital Front L
 	0x03		Digital Front R
 	0x04		Digital Center
 	0x05		Digital Sub
 	0x06		Headphones L
 	0x07		Headphones R
 	0x08		Rear L
 	0x09		Rear R
 	0x0A		ADC (multi-rate recording) L
 	0x0B		ADC (multi-rate recording) R
 	0x0C		unused
 	0x0D		unused
 	0x0E		unused
 	0x0F		unused
 	0x10		Analog Center (Live! 5.1) / dummy (Live! 4.0)
 	0x11		Analog Sub (Live! 5.1) / dummy (Live! 4.0)
 	0x12..-0x1F	dummy

 	Audigy / Audigy 2 / Audigy 2 Value / Audigy 4
 	offset (words)	substream
 	0x00		Digital Front L
 	0x01		Digital Front R
 	0x02		Digital Center
 	0x03		Digital Sub
 	0x04		Digital Side L (7.1 cards) / Headphones L (5.1 cards)
 	0x05		Digital Side R (7.1 cards) / Headphones R (5.1 cards)
 	0x06		Digital Rear L
 	0x07		Digital Rear R
 	0x08		Front L
 	0x09		Front R
 	0x0A		Center
 	0x0B		Sub
 	0x0C		Side L
 	0x0D		Side R
 	0x0E		Rear L
 	0x0F		Rear R
 	0x10		output to AC97 input L (muted)
 	0x11		output to AC97 input R (muted)
 	0x12		unused
 	0x13		unused
 	0x14		unused
 	0x15		unused
 	0x16		ADC (multi-rate recording) L
 	0x17		ADC (multi-rate recording) R
 	0x18		unused
 	0x19		unused
 	0x1A		unused
 	0x1B		unused
 	0x1C		unused
 	0x1D		unused
 	0x1E		unused
 	0x1F		unused
 	0x20..0x3F	dummy

Fixes:
1.	Do not assign negative values to variables used to index emu_cards
 	array. This array was never accessed when index is negative, but
 	Alexander (netchild@) told me that Coverity does not like it.
 	After this change emu_cards[0] should never be used to identify
 	valid sound card.
2.	Fix off-by-one errors in interrupt manager. Add more checks there.
3.	Fixes to sound buffering code now allows driver to use large playback
 	buffers.
4.	Fix memory allocation bug when multichannel recording is not
 	enabled.
5.	Fix interrupt timeout when recording with low bitrate (8kHz).

Hardware:
1.	Add one more known Audigy ZS card to list. Add two cards with
 	PCI IDs betwen old known cards and new one.

Other changes:
1.	Do not use ALL CAPS in messages.

Incomplete code:
1.	Automute S/PDIF when S/PDIF signal is lost.

Tested on i386 only, gcc 3.4.6 & gcc41/gcc42 (syntax only).
---snip---

This commits enables a little bit of debugging output when the driver is
loaded as a module. I did a cross-build test for amd64.

The code has some style issues, this will be addressed later.

The multichannel recording part is some work in progress to allow playing
around with it until the generic sound code is better able to handle
multichannel streams.

This is supposed to fix
CID:		171187
Found by:	Coverity Prevent

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2007-01-06 18:59:35 +00:00
Ariff Abdullah
048b52987d Fix headphone/speaker automute for Toshiba Satellite Pro U200.
Reported/Tested by:	keramida
2007-01-04 18:13:04 +00:00
Ariff Abdullah
65de329ee2 Fix distorted sound on Intel Desktop Board D101GGC (ATI SB450/ALC861).
Turn on ALC861 quirk as default since it seems affecting all hardwares
with the same codec.

Reported/Tested by:	Darryl Yeoh <drl@MyBSD.org.my>
2006-12-22 11:55:59 +00:00
Ariff Abdullah
303f62b8a2 Fix distorted sound on Fujitsu Siemens AMILO Pa 1510.
Reported/Tested by:	infofarmer
2006-12-19 16:52:09 +00:00
Ariff Abdullah
378e0c5c89 Latest updates for Envy24/24HT. Fix various issues with LOR and panic
during verbose booting.

Submitted by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
2006-12-17 16:06:45 +00:00
Ariff Abdullah
5c46f47bd3 Add codec id for [1] Realtek ALC888 and [2] Sigmatel STAC9227
Found/Tested by:	[1] luigi
                	[2] Jean-Baptiste Quenot <jbq@caraldi.com>
2006-12-17 15:19:33 +00:00
Ariff Abdullah
dc9e52cfda Add support for Nvidia Nforce MCP04 AC97 controller.
PR:		kern/106829
Submitted by:	Frédéric Petit <fredantispam@free.fr>
2006-12-17 13:23:00 +00:00
Ariff Abdullah
210bece19a Miscellaneous fixups and quirks for ASUS A7M, LG LW20 and
HP NX6325 laptops.
2006-12-16 09:14:58 +00:00
Ariff Abdullah
7c302801bd Fix compilation using gcc 4.1.
Submitted by:	dougb
2006-12-15 05:15:17 +00:00
Ariff Abdullah
4ed06071e6 Fix distorted sound on ASUS P1-AH2 caused by accumulated input / output.
Reported/Tested by:	Hiroharu Tamaru <tamaru@myn.rcast.u-tokyo.ac.jp>
2006-12-11 18:45:11 +00:00
Ariff Abdullah
e150f641d0 Fix AD1986A (and possibily other codecs too) microphone issues.
Tested by:	xride (using skype, xanalyser, etc. ; play/record)
2006-12-10 06:13:41 +00:00
Ariff Abdullah
1b5c0d50f6 - Fix headphone/speakers automute on Lenovo 3000 N100.
Tested by:	xride

- GPIO commit cleanups and fixes for possible breakage during
  previous commit.
2006-12-09 17:52:54 +00:00
Ariff Abdullah
2229d0cfa2 Add support for Apple Intel/Mac.
- Playback and headphone/speaker automute works.
 - Recording untested due to me being deaf doing back-and-forth
   remote debugging.

Free Macbook donation is highly appreciated :)

Tested by:	Dennis Pielken <mips128@gmx.net>
2006-12-02 17:12:24 +00:00
Ariff Abdullah
fbf953b58e Add inverted amplifier sense quirk for HP Compaq nx4300.
PR:		kern/106104
Submitted by:	Shun-ichi Kobayashi <koba@mbox.kudpc.kyoto-u.ac.jp>
MFC after:	3 days
2006-12-01 06:53:13 +00:00
Ariff Abdullah
57d90e7fbe Fix support for Medion MD MD95257 (GPIO2 quirk).
Reported by:	Chris Tophe <cohika@gmail.com>
2006-11-29 15:15:30 +00:00
Ariff Abdullah
a799d1cd22 - LNV -> LENOVO
- Fix support for Samsung Q1 UltraMobile PC (inverted EAPD).

Reported by:	benno
2006-11-27 06:16:36 +00:00
Ariff Abdullah
a580b31a54 Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.

General
-------

- Multichannel safe, endian safe, format safe
   * Large part of critical pcm filters such as vchan.c, feeder_rate.c,
     feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
     using them does not cause the pcm data to be converted to 16bit little
     endian.
   * Macrosses for accessing pcm data safely are defined within sound.h in
     the form of PCM_READ_* / PCM_WRITE_*
   * Currently, most of them are probably limited for mono/stereo handling,
     but the future addition of true multichannel will be much easier.

- Low latency operation
  * Well, this require lot more works to do not just within sound driver,
    but we're heading towards right direction. Buffer/block sizing within
    channel.c is rewritten to calculate precise allocation for various
    combination of sample/data/rate size. As a result, applying correct
    SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
    to what commercial 4front driver do.
  * Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
    result long delay.
  * Eliminate sound truncation if the sound data is too small.
    DIY:
      1) Download / extract
         http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
      2) Do a comparison between "cat state*.au > /dev/dsp" and
         "for x in state*.au ; do cat $x > /dev/dsp ; done"
         - there should be no "perceivable" differences.
    Double close for PR kern/31445.

  CAVEAT: Low latency come with (unbearable) price especially for poorly
          written applications. Applications that trying to act smarter
	  by requesting (wrong) blocksize/blockcount will suffer the most.
	  Fixup samples/patches can be found at:
	  http://people.freebsd.org/~ariff/ports/

- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
  due to closer compatibility with 4front driver.
  Discussed with: marcus@ (long time ago?)

- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
  moved to their own dev sysctl nodes, notably:
  hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
  Bump __FreeBSD_version.

Driver specific
---------------

- Ditto for sysctls.

- snd_atiixp, snd_es137x, snd_via8233, snd_hda
  * Numerous cleanups and fixes.
  * _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
   This was intended for pure debugging and latency measurement, but proven
   good enough in few unexpected and rare cases (such as problematic shared
   IRQ with GIANT devices - USB). Polling can be enabled/disabled through
   dev.pcm.0.polling. Disabled by default.

- snd_ich
  * Fix possible overflow during speed calibration. Delay final
    initialization (pcm_setstatus) after calibration finished.
    PR: kern/100169
    Tested by: Kevin Overman <oberman@es.net>
  * Inverted EAPD for few Nec VersaPro.
    PR: kern/104715
    Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>

Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.

Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
Ariff Abdullah
55be51bf55 - Inverted EAPD quirk for ASUS A8Jc.
- Take the literal meaning of eapdbtl, but do the inversion during
  write.

Tested by:	Chung-liang Wei <idreamer@gmail.com>
2006-10-16 14:43:22 +00:00
Ariff Abdullah
1409858b3b - Fix support for ASUS U5F laptop. This laptop (and possibly others)
need a special inverted EAPD quirk.
- Add "eapdinv" config for future testing purposes.

Tested by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
          	#freebsd-azalia @ irc.freenode.net
2006-10-12 15:37:43 +00:00
Ariff Abdullah
0b414ccace Fix support for IBM/Lenovo Thinkcentre M52 series. Its vendorid / 0x1014
accidentally match with HP vendorid / 0x103c.

Reported by:	Robert Noland <rnoland@2hip.net>
2006-10-12 04:19:37 +00:00
Ariff Abdullah
bfb06714ec Added few more pci ids for Intel, ATI, NVidia, VIA and SiS. 2006-10-08 18:51:58 +00:00
Ariff Abdullah
8d999aa8a1 - Fix wrong id for ALC882, add ALC883 id.
- Add support for the Conexant Waikiki/CX20551-22, found
  in most Toshiba P100 series laptops. Despite of growing
  urban legend of "unsupported Conexant", this codec is fully
  supported in this driver.
  Note: Toshiba P100 has broken (acpi) BIOS, thus rendering
        its soundchip useless. Please disable ACPI, or get
        BIOS updates (if any).

  Found/tested by: Vulpes Velox <v.velox@vvelox.net>
  URL: http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-September/004896.html

- Parser cleanups to handle possible oss/mixer collision. Found
  after parsing Conexant Waikiki nodes.

- Increase resilient against resource failure during attach/detach.

- Implement simple config through hint.pcm.<unit>.config. Supported
  options:
    gpio0 (default on Acer), gpio1, gpio2, softpcmvol,
    fixedrate (default), forcestereo (default)
  * Option prefixed with "no" (such as "nofixedrate") will do
    the opposite.
  * Options can be separated using space " " or comma ",".
  * The "no" option will take precedence over anything else.
  Example:
    hint.pcm.0.config="gpio2,nofixedrate,noforcestereo,nogpio0,softpcmvol"
    hint.pcm.0.config="softpcmvol noforcestereo"
2006-10-06 18:59:27 +00:00
Ariff Abdullah
0f219a5803 - Streamline quirks management for a better future.
- Fix support for ASUS M5200ae (buggy BIOS)
- Fix few problems, reported by Coverity Prevent (TM).

CID:		246991, 246676, 246675, 246674, 246477
Found by:	Coverity Prevent (TM)
2006-10-02 16:30:04 +00:00
Ariff Abdullah
aab23ae39a Make this buildable on IA64.
Reported by:	phk
2006-10-02 15:26:37 +00:00
Ariff Abdullah
9f52a325cd Various cleanups. Revert DMA alignmnet back to 2 since the original
cause of DMA pointer train wreck has been solved.

Reminded by:	silby
MFC after:	1 month
2006-10-01 13:30:30 +00:00
Ariff Abdullah
1f0387f732 Add support for Intel High Definition Audio Controller.
This driver make a special guarantee that "playback" works
on majority hardwares with minimal or without specific vendor
quirk.

This driver is a product of collaborative effort made by:

  Stephane E. Potvin <sepotvin@videotron.ca>
       Andrea Bittau <a.bittau@cs.ucl.ac.uk>
       Wesley Morgan <morganw@chemikals.org>
      Daniel Eischen <deischen@FreeBSD.org>
     Maxime Guillaud <bsd-ports@mguillaud.net>
      Ariff Abdullah <ariff@FreeBSD.org>

....and various people from freebsd-multimedia@FreeBSD.org

Refer to snd_hda(4) for features and issues.

Welcome To HDA.

Sponsored by:	Defenxis Sdn. Bhd.
2006-10-01 11:13:00 +00:00
Alexander Leidinger
0971278e54 Driver for Envy24HT (ICE1724 or VT1724)-based cards like
Terratec Aureon 7.1 Space:	tested
  Terratec Aureon 5.1 Sky:	tested
  Terratec PHASE 28:		tested
  Terratec Aureon 7.1 Universe:	tested
  Audiotrak Prodigy 7.1:	tested
  Audiotrak Prodigy 7.1 LT:	not tested
  Terratec PHASE 22:		not tested
  M-Audio Revolution 7.1:	not tested
  M-Audio Revolution 5.1:	not tested
  M-Audio Audiophile 192:	tested

Submitted by:	"Konstantin Dimitrov" <kosio.dimitrov@gmail.com>
2006-09-30 17:52:28 +00:00
Alexander Leidinger
b7bfe2fc89 Remove the ak452x code, superseeded by spicds. 2006-09-30 17:14:14 +00:00
Alexander Leidinger
f0b43758d7 - fix memory leak, when "number of adcs" != "number of dacs"
- fix multiple initialization of the first codec (support for more than
  one codec should be added in the future)
- use spicds instead of ak452x module

Submitted by:	"Konstantin Dimitrov" <kosio.dimitrov@gmail.com>
2006-09-30 17:08:51 +00:00
Alexander Leidinger
f198ead2a5 After repo copy from ak452x.[ch]: SPIcds is the I2S SPI audio codec code
used by the Envy* drivers.

Submitted by:	"Konstantin Dimitrov" <kosio.dimitrov@gmail.com>
2006-09-30 16:53:40 +00:00
Pyun YongHyeon
03923cd3d2 Add inverted amplifier sense quirks for Compaq Presario B3800
Reported by:	Nick Withers < nick AT nickwithers DOT com >
Tested by:	Nick Withers < nick AT nickwithers DOT com >
No objection from:	ariff
MFC after:	1 week
2006-08-15 07:37:41 +00:00
Alexander Leidinger
04d895e8a4 Use a low probe-priority to ensure that the emu10kx driver has a higher
priority than this one when both are available.
2006-08-07 23:00:36 +00:00
Alexander Leidinger
507ec6d5c5 "Fix typos in volume control DSP code."
Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-08-07 22:56:41 +00:00
Alexander Leidinger
0c115520f1 "Fixe playback of mono files on stereo outputs. In previous version
mono files are played only on left channel."

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-08-07 22:55:21 +00:00
Alexander Leidinger
feaa7fe133 "Change type for flags bitmap to let use 1 as flag value without
overflow (to -1)."

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-08-07 22:50:26 +00:00
Alexander Leidinger
e4c87b14fd "Workaround for sound lag in current snd_emu10kx driver. Real problem
is interaction between in-kernel sound buffer handling and hardware.
 With small buffer, there are times when both harwdare reads and
 kernel writes to the same buffer (it is only visible on slow machines, i
 think). I'm digging in channel.c and buffer.c to find a solution that
 allow use of large hardware buffers without sound lags - hardware can
 handle buffers up to 32Mb."

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-08-07 22:44:01 +00:00
Alexander Leidinger
347edd7ee6 - fix memory leak after "kldunload snd_ak452x.ko"
- fix "No sound in KDE":
  The problem is related to the implementation of Envy24(1712) hardware
  mixer support in the driver. Envy24(1712) has very precise 36bit wide
  hardware mixer, which is superior that vchans (software sound mixer in
  the kernel). The driver supports Envy24(1712) hardware mixer, so up to
  10 channels (5 stereo pairs) can be playback simultaneously.
  However, there are problems with the implementation of Envy24(1712)
  hardware mixer support in the driver, one of them is the problem with
  "no sound in KDE":
      When playing back several channels simultaneously and
      stoping one of the channels, sound starts to stutter and
      plays at very low speed.
  Another problem is:
      Playing back simultaneously more than one 24bit/32bit
      sound file or 16bit sound file and 24bit/32bit sound
      file doesn't work as expected.

Submitted by:	"Konstantin Dimitrov" <kosio.dimitrov@gmail.com>
2006-07-28 18:06:39 +00:00
Alexander Leidinger
4002c39216 Prepend temporary sysctls with an underscore.
Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-07-17 17:28:44 +00:00
Alexander Leidinger
ca23ff1987 Fix a compile time problem on amd64. I'm not sure if the fix is correct
from a semantic point of view, but I notified the author of the driver
for confirmation. So far it at least fixes the build and should only
lead to not identifying or wrongly identifying a soundcard in the worst
case.
2006-07-16 20:10:08 +00:00
Alexander Leidinger
75d7240e18 Make the MIDI kobj class static. This brings it inline with the channel or
ac97 classes.

This allows to link emu10k1 and emu10kx into the same kernel (LINT).
2006-07-15 20:08:32 +00:00
Alexander Leidinger
d056fa046c Add snd_emu10kx driver for Creative SoundBlaster Live! and Audigy series
sound cards with optional pseudo-multichannel playback.

It's based on snd_emu10k1 sound driver. Single channel version is available
from audio/emu10kx port since some time.

The two new ALSA header files (GPLed), which contain Audigy 2 ("p16v") and
Audigy 2 Value ("p17v") specific interfaces, are latest versions from ALSA
Mercurial repository.

This is not connected to the build yet.

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-07-15 19:36:28 +00:00
Alexander Leidinger
53f4fb1109 - Update ALSA emu10k1.h (it was imported as emu10k1-alsa.h) header file to
latest version from Mercurial repository. It brings definition of some
  additional Audigy 2 / Audigy 2 Value registers.
- Use new #defines from ALSA emu10k1.h
- Remove unused include files:
  + emu10k1-ac97.h was imported from ALSA and never used,
  + emu10k1.h was imported from Creative Linux emu10k1 driver, but only
    AUDIGY_CODEBASE was used from it.

Submitted by:	Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
2006-07-15 19:19:54 +00:00
Pyun YongHyeon
8d934d5005 Fix a missing unlock operation in interrupt handler.
PR:		kern/99205
Submitted by:	Alexey Illarionov <littlesavage AT rambler DOT ru>
MFC after:	1 week
2006-07-06 10:39:58 +00:00
Alexander Leidinger
851a904af5 - Rename hw.snd.unit to hw.snd.default_unit to make the purpose more obvious.
- Enable 4 automatic vchan's by default.
- Add some comments which provide ides/questions for improvement.
- Prefix some temporary sysctl's with an underscore to denote that it is not
  an official API but a workaround until the real solution is implemented.
2006-06-18 14:14:41 +00:00
Alexander Leidinger
ce356b7017 - fix compatibility with newer versions of FreeBSD
- fix all warnings during compilation
- fix obvious bugs
- add support for more cards

Now supported:
 - M-Audio Delta Dio 2496
 - M-Audio Audiophile 2496
 - Terratec DMX 6fire

Known bugs (detected by Nokolas and Stefan):
 - $ kldunload snd_ak452x.ko
   Warning: memory type ak452x leaked memory on destroy (1 allocations,
   64 bytes leaked).
 - No sound in KDE: Everything works fine at the console but when I load KDE
   (3.5.3) the sound stutters and plays at less then 1/2 speed.
 - 'mixer: WRITE_MIXER: Device not configured' The message repeats x
   times at system startup, x = whatever hw.snd.maxautovchans is set to.
   (this is because only vol, pcm and line are supported, but the driver
   shows more than those mixer devices and setting those additional mixers
   results in this error message)
 - vchans don't work
 - 24 bit playback not supported (only 16/32 bit)
 - after kld(un)loading some times, the card fails to be probed until reboot

Datasheets are available from:
	http://www.nbritton.org/uploads/envy24/
	http://www.asahi-kasei.co.jp/akm/en/product/ak4528/ak4528_f01e.pdf
	http://www.asahi-kasei.co.jp/akm/en/product/ak4528/ekd4528-01.pdf
	http://www.asahi-kasei.co.jp/akm/en/product/ak4524/ak4524_f03e.pdf
	http://www.asahi-kasei.co.jp/akm/en/product/ak4524/ekd4524.pdf
	http://www.wolfson.co.uk/uploads/documents/en/WM8728.pdf
	http://www.richtech.co.kr/down/richtek/RT9131.pdf
	http://xkodi.svobodno.com/xkodi/space71.html
	http://people.freebsd.org/~lofi/envy24.pdf
	http://people.freebsd.org/~lofi/4524.pdf

Submitted by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
Tested by:	Nikolas Britton <nikolas.britton@gmail.com>
		Stefan Ehmann <shoesoft@gmx.net>
2006-06-17 15:11:36 +00:00
Alexander Leidinger
12ab72d345 dd the envy24 driver as is to the tree. It's not connected to the build
yet. More commits to follow.

I got no response from the author, but since the driver is BSD licensed
I don't think he will complain. :-)

I got it from http://people.freebsd.org/~lofi/envy24.tar.gz

Written by:	Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp>
2006-06-17 14:36:44 +00:00
Alexander Leidinger
f510d240d3 Commit the new (old) midi framework. It's based in parts on the NetBSD code,
but large parts are rewritten by matk and tanimura.

This is old code, it's not maintained since 2003. We also don't have a
maintainer for this! Yuriy Tsibizov took it and uses it in his emu10kx
driver. Since the emu10kx driver will enter the tree "soon" (some bugs
have to be fixed after Yuriy return from his holidays), I add it here
already.

This also contains some changes to emu10k1 and cmi, so if you're lucky,
you can now make some kind of use of midi with those soundcards.

To all those poor souls which don't have such a card: feel free to send
patches, we don't have a maintainer for this.

To those which miss a specific feature in the midi code: feel free to
submit patches, we don't have a maintainer for this.

Oh, did I already told that it would be nice if someone would take care
of it? Maintainer with midi equipment wanted! :-)

If you get LOR's, submit a PR and notify multimedia@ please. If you get
panics, submit a PR with a backtrace (compile the sound system into your
kernel instead of using modules in this case) and notify multimedia@
please.

Written by:	matk, tanimura
Submitted by:	"Yuriy Tsibizov" <Yuriy.Tsibizov@gfk.ru>
Based upon:	code from NetBSD
2006-05-27 16:51:37 +00:00
Ariff Abdullah
14055d2a09 Add inverted amplifier sense quirks for Sony VAIO VGN B1VP/B1XP.
Reported by:	Stan Behrens <s.behrens at kon.de>
2006-05-01 09:28:28 +00:00
Ariff Abdullah
ee8e8d867e Add support for (latest) VIA VT8251 (rev. 0x07) audio controller.
A slight difference of this chip from its previous siblings is that
it need a gentle "wake up" on every (full) DMA buffer completion to
avoid stalled interrupt handler.

Thanks to George Hartzell for permission on doing remote debugging.

Prime MFC candidate for 6.1-RELEASE. Please reply to this commit if
there are any objections  (so I won't bug re@),  since the  changes
are too small and only specific to VT8251.

PR:		i386/95949
Tested by:	[1] George Hartzel
          	myself (remotely)
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-April/004003.html
2006-04-22 09:44:00 +00:00
Ariff Abdullah
facebb04a5 Add device ID for nForce 410 MCP audio controller.
PR:		kern/95257
Submitted by:	cenix <cenixxx at gmail dot com>
MFC after:	3 days
2006-04-03 17:37:27 +00:00
Ariff Abdullah
6d52c3bf33 Don't set primary resume interrupt flag during channel initialization
since it can cause high interrupt rate (storm) and slowdown the entire
system.

Note: Please report back to me if this commit cause any abnormal
      behaviour, especially during suspend / resume.

Reported/Submitted by:	[1] Daan Vreeken [PA4DAN] <Danovitsch_at_vitsch dot net>
Reported/Confirmed by:	[2] Angka H. K. <harikurniawan at gmail dot com>

MFC after:		5 days

[1] http://lists.freebsd.org/mailman/htdig/freebsd-hackers/2004-December/009335.html
[2] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-March/003830.html
2006-03-22 22:24:23 +00:00
Ariff Abdullah
f2a1d71aaa Misc. fixups:
- [1] Make the driver friendly towards kernel without PREEMPTION.
  Use msleep(9) instead of simple unlock-check_variable-lock mechanisme
  since the later not really effective in non-preemptible kernel
  (especially during codec detection routine).
- Free most driver resources in a sane manner to avoid possible
  double free and panics especially during device detach and codec
  detection failure.

MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-questions/2006-March/116515.html
2006-03-22 21:29:47 +00:00
Ariff Abdullah
ead3cc4315 Add another inverted amplifier sense quirk for Kvazar-Micro Senator 3592XT.
Submitted by:	[1] Alexandr Krivulya <admin at marcom-group.com>
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-March/003773.html
2006-03-07 05:48:14 +00:00
Ariff Abdullah
428feeb3b9 Add another inverted amplifier sense quirk for Sony VAIO Type T.
PR:		kern/94056
Submitted by:	Yoshihiko Sarumaru <mistral at imasy.or.jp>
MFC after:	3 days
2006-03-05 02:26:51 +00:00
Ariff Abdullah
df010ca869 Trim unnecessary pointer alignment. 2006-02-24 09:29:32 +00:00
Ariff Abdullah
050519958c - Fix severe crackling after long running and abusive module load / unload by
forcing DMA alignment to default buffer size.
- Make sure DMA pointer properly aligned to avoid being truncated by caller
  which causing severe underruns and random popping (especially in 32bit
  playback / recording).
- Add AC97 inverted external amplifier quirk for Maxselect x710s
  - http://maxselect.ru/

MFC after:	1 week
2006-02-18 10:24:48 +00:00
Ariff Abdullah
fba6b23875 Fix random popping while playing in 32bit by increasing default buffer size
from 4096 to 8192.

MFC after:	1 week
2006-02-18 10:23:37 +00:00
Ariff Abdullah
34733eb529 Fix possible DMA leak and locking violation especially
during suspend <-> resume and module load <-> unload.

PR:		kern/92764
MFC after:	3 days
2006-02-12 10:42:47 +00:00
Alexander Leidinger
cd9de7ee61 A pointer was checked for NULL after dereferencing it. The check is not
needed here, except there's a bug which results in detaching the device
twice.

Move the NULL pointer check to the beginning of the function and convert
it into a KASSERT.

CID:		420
Found with:	Coverity Prevent(tm)
Discussed with:	ariff
MFC after:	5 days
2006-02-05 17:33:18 +00:00
Ariff Abdullah
86b391b2e1 Enable full duplex operation since it works and to solve panic issue.
PR:		kern/91992
MFC after:	2 days
2006-01-27 02:01:27 +00:00
Alexander Leidinger
5f35685cc2 Backput the "Dell ID" part of the last commit, it was already tried in
the past but didn't worked.

Noticed by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
2006-01-21 16:21:06 +00:00
Alexander Leidinger
30baa78df4 Merge rev. 1.5 and 1.6 from DFly:
- Add PCI identifier to match against a Dell OEM version of the SB Live!
 - Fix spurious warning about ANSI trigraphs

Obtained from:	DragonFlyBSD
2006-01-21 15:23:15 +00:00
Alexander Leidinger
a7571c3f6b Prevent dereferencing a NULL pointer if the malloc() fails.
CID:		219
Found with:	Coverity Prevent(tm)
2006-01-21 11:50:56 +00:00
Joel Dahl
16451fc93a Remove unused pointer.
Approved by:	ariff
2006-01-21 09:05:13 +00:00
Ariff Abdullah
8815a86933 Turn on native 32bit recording (at 48000hz).
It works perfectly on my Compaq Presario M2000Z, but my last attempt
on Acer Ferrari 4000 only produce garbled sound.

MFC after:	3 days
2006-01-20 19:35:44 +00:00
Ariff Abdullah
4aee05133b Remove Giant / busdma_lock_mutex from busdma_tag_create(). 2006-01-18 01:01:37 +00:00
Ariff Abdullah
f432c562bf Add another inverted EAPD quirk for Gateway 7326GZ.
Tested by:	Jeff Cross <jeff.cross at averageadmins.com>
MFC after:	3 days
2006-01-14 23:37:08 +00:00
Ariff Abdullah
8c437e077b Joyport blacklist. Either we're facing with broken hardware
or because this hardware need special (unknown) initialization
procedures.

Reported by:	[1] Rob Clark <vx2 at tds.net>
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003535.html
2006-01-13 04:54:34 +00:00
Ariff Abdullah
1738f66243 Fix broken playback capabilities to prevent impending disaster.
The minimum / maximum speed was way too low / high!

minspeed =   2000 - is this for real ?
maxspeed = 767999 - is this for real ?????

Wrap everything into 8000 - 48000 boundary, just to be safe.

MFC after:	3 days
2006-01-11 23:22:57 +00:00
Ariff Abdullah
40c012dd6d - Locking fixes. Release lock while chn_intr().
- Mark MPSAFE since most of the locking procedures already implemented.
- Turn on inverted external amplifier sense flag for selected boards.

Tested by:	bland
MFC after:	1 week
2006-01-11 08:02:15 +00:00
Ariff Abdullah
c02b454deb More thorough fixes to enable inverted external amplifier sense flag.
Instead of dragging the entire ICH4/82801DB into this mess, select
only few boards based on pci subdevice / subvendor.

Tested by:	Daisuke Orikasa <luxury-acura-3.5rl at nifty.com>
MFC after:	3 days
2006-01-10 06:52:59 +00:00
Ariff Abdullah
be0fee94a7 Turn on inverted external amplifier sense flags for ICH4/82801DB.
PR:		kern/66422, kern/75687, kern/84471
MFC after:	2 days
2006-01-09 11:20:37 +00:00
Ariff Abdullah
7659fda352 Fix obvious capabilities (rate) violation. Should be 5500, not 4000.
MFC after:	1 day
2006-01-09 06:05:25 +00:00
Ariff Abdullah
1332ddcb64 Fix locking violation, causing frantic diagnostic messages during boot.
Reported by:	[1] julian
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003408.html
2006-01-06 10:36:55 +00:00
Ariff Abdullah
8b6d3fe1b6 Another major fixes and enhancements:
- MPSAFE
    - Fix / reorganize attach routine. Device specific initialization must
      be done after generic bus / DMA setup. At last, Virtual Channels
      (vchan) works as expected.

Note: Recent commit / fix against this driver proves that major enhancements
      on the generic sound layer does indeed help to expose flaw within
      device specific code. There are probably other drivers that need to
      be addressed as well.

Tested by:	barner
MFC after:	1 week
2006-01-06 05:04:18 +00:00
Ariff Abdullah
1333b4a431 Fix broken capabilities, causing failure during channel reset.
Its min/max speed were off by -/+ 1000.

Reported by:	[1] Ion-Mihai Tetcu <itetcu@people.tecnik93.com>
            	[2] barner
MFC after:	1 day

[1] http://lists.freebsd.org/mailman/htdig/freebsd-multimedia/2005-December/003189.html
[2] http://lists.freebsd.org/mailman/htdig/freebsd-multimedia/2006-January/003422.html
2006-01-04 15:35:55 +00:00
Alexander Leidinger
9190333ce7 Fix the order of the stereo channels (left <-> right).
From the PR:
---snip---
 I think I have found the change which reversed the channels.
 Revision 1.44 of emu10k1.c, which added Audigy support, has the line

 emu_wrptr(sc, v->vnum, FXRT, 0xd01c0000);

 replaced with the following lines:

 if (sc->audigy) {
         emu_wrptr(sc, v->vnum, A_FXRT1, v->fxrt1);
         emu_wrptr(sc, v->vnum, A_FXRT2, v->fxrt2);
         emu_wrptr(sc, v->vnum, A_SENDAMOUNTS, 0);
 }
 else
         emu_wrptr(sc, v->vnum, FXRT, v->fxrt1 << 16);

 where v->fxrt1 << 16 == 0xd10c0000

 I don't have Audigy, so I'm not sure if the problem affects Audigy cards
 too. The order of the channels can't be tested by just altering mixer
 settings. Here's a small program to test if the channels are reversed on
 your sound card:

 #include <sys/soundcard.h>
 #include <fcntl.h>
 #include <unistd.h>

 int main(int argc, char **argv)
 {
 	int fd = open("/dev/dsp", O_WRONLY), format = AFMT_S16_LE;
   int channels = 2, rate = 22050, i;

   /* 450 Hz sine wave on left channel, right channel silent */
   unsigned char samples[] = {0, 0, 0, 0, 94, 16, 0, 0, 120, 32, 0, 0,
     9, 48, 0, 0, 208, 62, 0, 0, 143, 76, 0, 0, 12, 89, 0, 0, 19, 100,
     0, 0, 117, 109, 0, 0, 11, 117, 0, 0, 182, 122, 0, 0, 92, 126, 0,
     0, 239, 127, 0, 0, 105, 127, 0, 0, 202, 124, 0, 0, 32, 120, 0, 0,
     124, 113, 0, 0, 251, 104, 0, 0, 193, 94, 0, 0, 249, 82, 0, 0,
     212, 69, 0, 0, 138, 55, 0, 0, 85, 40, 0, 0, 120, 24, 0, 0, 51, 8,
     0, 0, 205, 247, 0, 0, 136, 231, 0, 0, 171, 215, 0, 0, 118, 200,
     0, 0, 44, 186, 0, 0, 7, 173, 0, 0, 63, 161, 0, 0, 5, 151, 0, 0,
     132, 142, 0, 0, 224, 135, 0, 0, 54, 131, 0, 0, 151, 128, 0, 0,
     17, 128, 0, 0, 164, 129, 0, 0, 74, 133, 0, 0, 245, 138, 0, 0,
     139, 146, 0, 0, 237, 155, 0, 0, 244, 166, 0, 0, 113, 179, 0, 0,
     48, 193, 0, 0, 247, 207, 0, 0, 136, 223, 0, 0, 162, 239, 0, 0};

   ioctl(fd, SNDCTL_DSP_SETFMT,&format);
   ioctl(fd, SNDCTL_DSP_CHANNELS,&channels);
   ioctl(fd, SNDCTL_DSP_SPEED,&rate);

   for(i=0;i<500;i++)
     write(fd, &samples, sizeof(samples));
   write(fd, &samples, 2); /* swap channels */
   for(i=0;i<500;i++)
     write(fd, &samples, sizeof(samples));

   return 0;
 }

 You should hear a sound on the left channel followed by a sound on the
 right channel. If you hear a sound on the right channel first, the
 channels are reversed.
---snip---

Owners of an audigy card should verify if it DTRT and report back.

Noticed by:	Matthias Buelow <mkb@mukappabeta.de>
Submitted by:	Juha-Matti Tilli <juhis@nallukka.net>
PR:		72221
2005-12-28 17:57:36 +00:00
Ariff Abdullah
88a50509af Add suspend and resume support. 2005-12-25 00:43:03 +00:00
Ruslan Ermilov
3238c6bd33 Fix -Wundef from compiling the amd64 LINT. 2005-12-04 10:06:06 +00:00