Commit Graph

1543 Commits

Author SHA1 Message Date
Eitan Adler
2da1951583 Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

This is a subset of 241856 (which was reverted)

Reviewed by:	des
Approved by:	cperciva (implicit)
MFC after:	1 week
2012-10-22 22:29:48 +00:00
Eitan Adler
a8de37b024 This isn't functionally identical. In some cases a hint to disable
unit 0 would in fact disable all units.

This reverts r241856

Approved by: cperciva (implicit)
2012-10-22 13:06:09 +00:00
Eitan Adler
76b7512247 Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

Reviewed by:	des
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:41:14 +00:00
Eitan Adler
db702c59cf remove duplicate semicolons where possible.
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:00:37 +00:00
Alexander Motin
675dce071a Cast vendor-specific spell on VIA VT1818S codecs alike to VT1708S to
make analog input loopback and dual-stream playback work by enabling
signal mixing by nid 22, as it should be according to info returned by
the CODEC.  Otherwise pin nid 28 receives only signal from DAC nid 16.

PR:		kern/169124
MFC after:	1 week
2012-10-09 17:06:31 +00:00
Kevin Lo
b5db12bfb5 Free result of device_get_children(9). 2012-09-30 09:21:10 +00:00
Alexander Motin
076b76e871 Fix panic caused by wrong pointer dereference, left after pin sense rewrite
at r230551.

Also while there, make sense polling use reported for each node separately
instead of reporting accumulated total status.

Submitted by:	Barbara <barbara.freebsd@gmail.com> (1)
MFC after:	3 days
2012-09-24 08:23:05 +00:00
Hans Petter Selasky
e2524b2ec9 Implement support for USB Audio v2.0. Remove some redundant
USB audio v1.0 debug data, hence userspace tools like lsusb
exist to show this information properly.
2012-09-17 15:43:57 +00:00
Hans Petter Selasky
aead9631e7 Add required USB AUDIO v2.0 structure definitions.
PR:	misc/171254
2012-09-03 19:17:25 +00:00
Alexander Motin
7d0ec9dd3f Add bunch of ATI HDMI HDA controller IDs.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2012-08-30 15:47:20 +00:00
Andreas Tobler
9c3fbfbd6a Add a new sound driver for PowerMacs, found here on my Quad G5.
It allows simple playback and volume control like the other Mac drivers,
not more.
2012-08-19 19:40:33 +00:00
Alexander Motin
52e9cf7de5 Fix "speaker" volume control, broken at r230451.
Reported and tested by:	Slawa Olhovchenkov <slw@zxy.spb.ru>
MFC after:	1 month
2012-08-16 07:43:15 +00:00
Alexander Motin
8684fef07d Fix multichannel input signals tracing on some CODECs like ALC260.
Reported and tested by:	Slawa Olhovchenkov <slw@zxy.spb.ru>
MFC after:	1 month
2012-08-14 14:07:34 +00:00
Andreas Tobler
6e8fcacda4 Fix typo in comment. 2012-08-14 05:16:35 +00:00
Alexander Motin
52ce0de418 Remove 14 not very useful characters " HDA CODEC PCM" from HDA pcm device
names to shorten them. PulseAudio reported to have problems with names
longer then 63 chars and at least in XMMS long names are inconvinient.

Reported by:	hselasky
MFC after:	3 days
2012-07-02 20:25:50 +00:00
Alexander Motin
3c461fd01b Restore GPIO config quirks handling, lost during last big refactoring.
Tested by:	hselasky
MFC after:	3 days
2012-07-02 18:35:08 +00:00
Gleb Smirnoff
35d393bf63 - Call bus_generic_attach() at end of hdspe_attach().
- Use own devclass_t in DRIVER_MODULE().

This fixes operation of hdspe(4) when built as loadable module.

Submitted by:	Ruslan Bukin <br bsdpad.com>
2012-07-02 07:39:55 +00:00
Peter Holm
85f6230a1d Added D_TRACKCLOSE to sndstat_cdevsw to fix the situation when
another process is in open() or stat() for the device node, then
close() from the owning process does not result in cdevsw close
method call. This fixes the pemanent "Device busy" seen.

Changed the sndstat_lock from mutex to sx.  This allows to extend
the region covered by the lock, to include the uiomove() call in
sndstat_read() and bufptr increment. This fixes the "panic:
sbuf_put_byte called with finished or corrupt sbuf" seen.

In collaboration with:	kib
MFC after:	1 week
2012-05-02 19:32:11 +00:00
Hans Petter Selasky
6d917491f5 Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after:	1 weeks
2012-04-02 10:50:42 +00:00
Alexander Motin
742963ff31 Reenable unsolicited responses on CODEC if hdaa_sense_init() called again.
This fixes jack connection events handling after suspend/resume.

PR:		kern/166382
MFC after:	1 week
2012-03-30 08:33:08 +00:00
Alexander Motin
16b8ad6420 Stop HDA controller polling callout on suspend and reset it on resume.
PR:		kern/166382
MFC after:	1 week
2012-03-28 13:28:09 +00:00
John Baldwin
d02a6470bf Don't cast a bus address to a uint8_t pointer just to add an offset to
it.  Instead, add the offset directly to the bus address.
2012-03-23 12:34:39 +00:00
Alexander Motin
e4afd792df Add driver for the RME HDSPe AIO/RayDAT sound cards -- snd_hdspe(4).
Cards are expensive and so rare, so leave the driver as module.

Submitted by:	Ruslan Bukin <br@bsdpad.com>
MFC after:	2 weeks
2012-03-01 13:10:18 +00:00
Hans Petter Selasky
9b5da8166e Avoid creating PCM devices for MIDI adapters.
MFC after:	3 days
2012-02-23 07:56:19 +00:00
Alexander Motin
5525b53de5 Do not handle MOD_SHUTDOWN equally to MOD_UNLOAD in sound kernel module.
MOD_SHUTDOWN is not an end of existence, and there is a life after it.
In particular, code previously called on MOD_SHUTDOWN grabbed lock and
deallocated unit numbering. That caused infinite wait loop if snd_uaudio
tried to destroy its PCM device after that point.

MFC after:	3 days
2012-02-14 09:19:30 +00:00
Ed Schouten
7870adb640 Remove direct access to si_name.
Code should just use the devtoname() function to obtain the name of a
character device. Also add const keywords to pieces of code that need it
to build properly.

MFC after:	2 weeks
2012-02-10 12:35:57 +00:00
Alexander Motin
2345f2a366 Remove extra semicolon.
Submitted by:	emaste
2012-02-05 16:41:06 +00:00
Pedro F. Giffuni
7106ed257d Use new OSS-based BSD-licensed header for cs sound driver.
The cs driver requires a table with firmware values. An
alternative firmware is available in a similar Open Sound
System driver. This is actually a partial revert of
Revision 77504.

Special thanks to joel@ for patiently testing several
replacement attempts.

The csa driver and the complete sound system are now free
of the GPL.

Tested by:	joel
Approved by:	jhb (mentor)
MFC after:	3 weeks
2012-02-01 21:38:01 +00:00
Alexander Motin
fd578f6543 Make sound(4) more flexible in setting soft buffer and block sizes when
hardware imposes strict limitations on hard buffer and block sizes.

Previous code set soft buffer to be no smaller then hard buffer. On some
cards with fixed 64K physical buffer that caused up to 800ms play latency.
New code allows to set soft buffer size down to just two blocks of the hard
buffer and to not write more then that size ahead to the hardware buffer.
As result of that change I was able to reduce full practically measured
record-playback loop delay in those conditions down to only about 115ms
with theoretical playback latency of only about 50ms.

New code works fine for both vchans and direct cases. In both cases sound(4)
tries to follow hw.snd.latency_profile and hw.snd.latency values and
application-requested buffer and block sizes as much as limitation of two
hardware blocks allows.

Reviewed by:	silence on multimedia@
2012-01-31 21:46:28 +00:00
Alexander Motin
c6c4eaa848 Just in case, clear stream interrupts before enabling them. 2012-01-31 12:57:21 +00:00
Alexander Motin
4bff0fc61b Fix typo in comments. 2012-01-30 09:59:33 +00:00
Alexander Motin
f4cb8238fd Fix HBR enabling condition. cchs is from 0 to 7, not from 1 to 8. 2012-01-28 09:24:57 +00:00
Pedro F. Giffuni
bb9e5fb3bd Minor cleanups to the csa snd driver.
Remove unneeded temporary variable (data) to better match the OSS code.
Remove some unused constants and type definitions.

Tested by:	joel
Approved by:	jhb (mentor)
MFC after:	3 weeks
2012-01-26 21:43:11 +00:00
Alexander Motin
c0e199f61b Press some more info into the PCM device name:
- add "+HP" in case of headphones redirection;
 - add device type for analog devices, if all pins have the same.

As result now it may look like "Analog 5.1+HP/2.0" or "Front Analog Mic".
I hope it will be more useful than long and confusing.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-26 12:09:04 +00:00
Alexander Motin
586ec6d396 Fix typo in r230571.
Submitted by:	trasz
2012-01-26 10:30:50 +00:00
Alexander Motin
5409d3ee9e Add another bunch of CODEC IDs. 2012-01-26 09:45:14 +00:00
Alexander Motin
7599ae7787 Oops, fix the loader tunable name added in r230551. 2012-01-25 20:54:16 +00:00
Alexander Motin
d9360bbfc4 Rewrite jack presence detection and implement automatic recording source
selection in snd_hda(4) driver.

Now driver tracks jack presence detection status for every CODEC pin. For
playback associations, when configured, that information, same as before,
can be used to automatically redirect audio to headphones. Also same as
before, these events are used to track digital display connection status
and fetch ELD. Now in addition to that driver uses that information to
automatically switch recording source of the mixer to the connected input.

When there are devices with no jack detection and with one both connected,
last ones will have the precedence. As result, on most laptops after boot
internal microphone should be automatically selected. But if external one
(for example, headset) connected, it will be selected automatically.
When external mic disconnected, internal one will be selected again.

Automatic recording source selection is enabled by default now to make
recording work out of the box without touching mixer. But it can be
disabled or limited only to attach time using hint.pcm.X.rec.autosrc loader
tunables or dev.pcm.X.rec.autosrc sysctls.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-25 20:46:10 +00:00
Alexander Motin
3ba9d9e926 Allow PASSTHROUGH (AC3) to have more then 2 channels.
8 channels can be used to get more then 6.144Mbps bandwidth.
2012-01-25 11:45:50 +00:00
Alexander Motin
89a8fedd77 Fix word order in hdaa_subvendor_id() to match PCI (where it comes from),
broken at r230130. This should fix applying system-specific patches.
2012-01-25 09:57:34 +00:00
Alexander Motin
bf318c6aa2 In addition to r230511, allow 8 channel AC3 formats. 2012-01-24 22:40:24 +00:00
Alexander Motin
53b95d1799 Enable High Bit Rate (HBR) Encoded Packet Type (EPT), if supported
(HDMI and HBR bits set) and needed (AC3 format used with 8 channels).
This should allow DTS-HD/TrueHD pass-through with rates above 6.144Mbps.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-24 17:31:27 +00:00
Alexander Motin
e0f1c0d777 HDMI and DisplayPort support can coexist in HDA CODEC.
Report "HDMI/DP" in PCM device name if both supported.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-24 14:17:13 +00:00
Alexander Motin
4f24090354 Realtek CODECs declare support for 32bit samples on S/PDIF input/output
widgets. I am not sure if S/PDIF supports 32bit samples, but my Marantz
SR4001 doesn't, producing only single clicks on playback start/stop.
Because HDA controller requires 32bit alignment for all samples above 16bit,
we can't handle this situation in regular way and have to set 32bit format
in sound(4) for anything above 16bit. To workaround the problem, prefer
to setup hardware to use 24/20bit samples when 32bit format requested. Add
dev.pcm.X.play.32bit and dev.pcm.X.rec.32bit sysctls to control what format
really use for 32bit samples.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-23 17:05:11 +00:00
Alexander Motin
661268263e Increase snd_hda(4) default maximal buffer size from 16K to 64K and
maximal from 64K to 256K.

We usually don't need 750 sound interrupts per second (1.3ms latency)
when playing 192K/24/8 stream. 187 should be better. On usual 48K/16/2
it is just enough for hw.snd.latency=9 at hw.snd.latency_profile=1 with
23 and 6 interrupts per second.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2012-01-22 15:44:20 +00:00
Alexander Motin
3d741b14a7 Complete rewrite of the snd_hda(4) volume control.
Previous code was relatively dumb. During CODEC probe it was tracing signals
and statically binding amplifier controls to the OSS mixer controls. To set
volume it just set all bound amplifier controls proportionally to mixer
level, not looking on their hierarchy and amplification levels/offsets.

New code is much smarter. It also traces signals during probe, but mostly
to find out possible amplification control rages in dB for each specific
signal. To set volume it retraces each affected signal again and sets
amplifiers controls recursively to reach desired amplification level in dB.
It would be nice to export values in dB to user, but unluckily our OSS mixer
API is too simple for that.

As result of this change:
 - cascaded amplifiers will work together to reach maximal precision.
If some input has 0/+40dB preamplifier with 10dB step and -10/+10dB mixer
with 1dB step after it, new code will use both to provide 0/+40dB control
with 1dB step! We could even get -10/+50dB range there, but that is
intentionally blocked for now.
 - different channels of multichannel associations on non-uniform CODECs
such as VIA VT1708S will have the same volume, not looking that control
ranges are different. It was not good when fronts were 12dB louder.
 - for multiplexed recording, when we can record from only one source at
a time, we can now use recording amplifier controls to set different
volume levels for different inputs if they have no own controls of they
are less precise. If recording source change, amplifiers will be
reconfigured.

To improve out-of-the-box behavior, ignore default volume levels set by
sound(4) and use own, more reasonable: +20dB for mics, -10dB for analog
output volume and 0dB for the rest of controls. sound(4) defaults of 75%
mean absolutely random things for different controls of different CODECs
because of very different control ranges.
Together with further planned automatic recording source selection this
should allow users to get fine playback and recording without touching
mixer first.
Note that existing users should delete /var/db/mixer*-state and reboot
or trigger CODEC reconfiguration to get new default values.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-22 10:24:12 +00:00
Pedro F. Giffuni
5dcd37b17d Replace GPLd headers from the Maestro3 driver with BSD licensed
versions derived from /usr/ports/audio/oss.

The particular headers used were taken from the
attic/drv/oss_allegro directory and are mostly identical
to the previous files.

The Maestro3 driver is now free from the GPL.

NOTE: due to lack of testers this driver is being
considered for deprecation and removal.

PR:		kern/153920
Approved by:	jhb (mentor)
MFC after:	2 weeks
2012-01-20 22:37:10 +00:00
Alexander Motin
5bcd25de3e Print controller/codec IDs for unknown chips instead of useless and
frightening "unknown" word. In most cases we don't need to know chips
to properly handle them, but having IDs in logs may simplify debugging.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2012-01-19 11:18:21 +00:00
Alexander Motin
6fa8e691a3 Two 192/24/8 playback streams overflow single mandatory output line (SDO)
of HDA bus. Handle that from two directions:
 - Add support for "striping" (using several SDO lines), if supported.
 - Account HDA bus utilization and return error on new stream allocation
attempt if remaining bandwidth is unsifficient.

Most of HDA controllers have one SDO line with 46Mbps output bandwidth.
NVIDIA GF210 has 2 lines - 92Mbps. NVIDIA GF520 has 4 lines - 184Mbps!

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-19 01:55:48 +00:00
Alexander Motin
88addcbe26 Improve HDMI/DisplayPort audio support in snd_hda(4):
- Enable and handle unsolicited responses from digital display pins,
reporting connection and EDID-Like Data (ELD) validity status changes.
 - Fetch ELD data, describing connected digital display device audio
capabilities. These data not really used at the moment (user is not
denied to use audio formats not supported by the device), only printed to
verbose logs. But they are useful for debugging. The fact that ELD was
received tells that HDMI link was established and video driver enabled
HDMI audio passthrough. Some old chips may not return ELD, so lack of it
is not necessary a problem.
 - Add some more points to CODEC configuration sequence:
   - For converter widgets, supporting more then two channels (HDMI/DP
     converter widgets support 8), set number of channels to handle.
   - For digital display pins (HDMI/DP) fill audio infoframe, reporting
     connected device about number of channels and speakers allocation.
   - For digital display pins (HDMI/DP) set mapping between channels seen
     by software and channels transferred via HDMI/DisplayPort.
 - Allow more audio formats, not used for analog connections because of
stereo pairs orientation, but easily applicable to HDMI/DisplayPort: 2.1,
3.0, 3.1, 4.1, 5.0, 6.0, 6.1, 7.0. That list may be filtered later using
info from ELD.
 - Disable MSI interrupts for NVIDIA HDA controllers before GT520.

At this point I can successfully play audio over HDMI from NVIDIA GT210
and GT520 cards with nvidia-driver-290.10 driver to Marantz SR4001
receiver in 2.0, 2.1, 3.0, 4.0, 4.1, 5.0 and 5.1 PCM formats at 44, 48,
88 and 96KHz at 16 and 24 bits, same as do AC3/DTS passthrough.
6.0, 6.1, 7.0 and 7.1 PCM formats are not working for me, but I think
it is because of receiver age.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-18 19:12:33 +00:00
Alexander Motin
20332cc2b2 Add check to avoid assertion panic on duplicate stop.
Reported by:	Yuri Pankov <yuri.pankov@gmail.com>
MFC after:	2 months
2012-01-16 00:26:52 +00:00
Joel Dahl
2fc8344891 Fix a few comment typos. 2012-01-15 13:36:47 +00:00
Ulrich Spörlein
004a39cd57 Remove spurious 8bit chars, turning files into plain ASCII. 2012-01-15 13:23:33 +00:00
Alexander Motin
7c6b05d280 Major snd_hda driver rewrite:
- Huge old hdac driver was split into three independent pieces: HDA
controller driver (hdac), HDA CODEC driver (hdacc) and HDA sudio function
driver (hdaa).
 - Support for multichannel recording was added. Now, as specification
defines, driver checks input associations for pins with sequence numbers
14 and 15, and if found (usually) -- works as before, mixing signals
together. If it doesn't, it configures input association as multichannel.
 - Signal tracer was improved to look for cases where several DACs/ADCs in
CODEC can work with the same audio signal. If such case found, driver
registers additional playback/record stream (channel) for the pcm device.
 - New controller streams reservation mechanism was implemented. That
allows to have more pcm devices then streams supported by the controller
(usually 4 in each direction). Now it limits only number of simultaneously
transferred audio streams, that is rarely reachable and properly reported
if happens.
 - Codec pins and GPIO signals configuration was exported via set of
writable sysctls. Another sysctl dev.hdaa.X.reconfig allows to trigger
driver reconfiguration in run-time.
 - Driver now decodes pins location and connector type names. In some cases
it allows to hint user where on the system case connectors, related to the
pcm device, are located. Number of channels supported by pcm device,
reported now (if it is not 2), should also make search easier.
 - Added workaround for digital mic on some Asus laptops/netbooks.

MFC after:	2 months
Sponsored by:	iXsystems, Inc.
2012-01-15 13:21:36 +00:00
Pedro F. Giffuni
70e0bbedef Replace GPL'd headers in the emu10kx snd driver code.
This uses the emuxkireg.h already used in the emu10k1
snd driver. Special thanks go to Alexander Motin as
he was able to find some errors and reverse engineer
some wrong values in the emuxkireg header.

The emu10kx driver is now free from the GPL.

PR:		153901
Tested by:	mav, joel
Approved by:	jhb (mentor)
MFC after:	2 weeks
2012-01-11 21:17:14 +00:00
Pedro F. Giffuni
7523592f91 Fix an inconsistency that crept in while replacing constants
from the new header.

Approved by:	jhb (mentor)
MFC after:	3 days
2012-01-11 21:03:54 +00:00
Pedro F. Giffuni
c7e0c9db2b Replace a GPL'd header in the emu10k1 snd driver code.
This brings in the emuxkireg.h from NetBSD (dev/pci) which
is used for the same purpose but is smaller. The emu10k1
is now free from the GPL.

PR:		153901
Obtained from:	NetBSD
Approved by:	core (mentor implicit)
MFC after:	2 weeks
2012-01-03 21:04:54 +00:00
Alexander Motin
823efe3764 Oops, list of IDs is not sequential. Have to list all of them expoicitly. 2011-12-20 02:42:53 +00:00
Alexander Motin
3e6059772d Cast some vendor-specific spell on VIA VT1708S codecs to:
- make analog input loopback work;
 - get access to the mics boost controls.

Sponsored by:	iXsystems, Inc.
MFC after:	1 month
2011-12-20 02:00:27 +00:00
Hans Petter Selasky
11b81cedfd Use usbd_transfer_unsetup() instead of usbd_transfer_stop() so that
we don't have to worry about locking.

MFC after:	1 weeks
2011-12-14 01:03:07 +00:00
Hans Petter Selasky
a6ed493726 Stop USB audio transfers early so that any audio applications
will time out and close opened /dev/dspX.Y device(s), if
any. This is a workaround because we cannot unregister PCM
devices while the audio character device is in use.

Add a missing inclusion guard.

MFC after:	1 weeks
2011-12-14 00:48:20 +00:00
Marius Strobl
4b7ec27007 - There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
  (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
  since r52045) but even recently added device drivers do this unnecessarily.
  Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
  Discussed with: jhb
- Also while at it, use __FBSDID.
2011-11-22 21:28:20 +00:00
Ed Schouten
6472ac3d8a Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.
The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.
2011-11-07 15:43:11 +00:00
Ed Schouten
d745c852be Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.
This means that their use is restricted to a single C file.
2011-11-07 06:44:47 +00:00
Kip Macy
8451d0dd78 In order to maximize the re-usability of kernel code in user space this
patch modifies makesyscalls.sh to prefix all of the non-compatibility
calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel
entry points and all places in the code that use them. It also
fixes an additional name space collision between the kernel function
psignal and the libc function of the same name by renaming the kernel
psignal kern_psignal(). By introducing this change now we will ease future
MFCs that change syscalls.

Reviewed by:	rwatson
Approved by:	re (bz)
2011-09-16 13:58:51 +00:00
Andriy Gapon
7a2aafc355 dsp_ioctl: fix type of variable used to store ioctl request
PR:		kern/156433
Submitted by:	Grigori Goronzy <greg@chown.ath.cx>
Reviewed by:	hselasky
Approved by:	re (kib)
MFC after:	1 week
2011-09-12 08:38:21 +00:00
Hans Petter Selasky
5dc9d76584 Fix precedence warning when compiling kernel with clang.
Approved by:	re (kib)
Submitted by:	dim
MFC after:	1 week
2011-09-06 08:15:55 +00:00
Alexander Motin
ad06556a91 Fix headphones pin configuration on Lenovo B450 laptop.
Submitted by:	"Sergey V. Dyatko" <sergey.dyatko@gmail.com>
Approved by:	re (kib)
2011-08-18 13:33:34 +00:00
Hans Petter Selasky
e0b17a622d Restore USB MIDI transmit buffer size to 1Kbyte.
MFC after:	1 week
2011-07-14 17:43:18 +00:00
Hans Petter Selasky
4944c3a882 Introduce a quirk for broken USB MIDI hardware instead of limiting performance
in general.

MFC after:	1 week
2011-07-03 13:27:23 +00:00
Hans Petter Selasky
910f1dcf71 Fix problem about USB MIDI TX data format, that some devices only accept
a maximum of 4 bytes (one command) per short terminated USB transfer.
Optimise the TX case by sending multiple USB frames.

MFC after:	1 week
2011-07-02 20:26:37 +00:00
Nathan Whitehorn
7e5fa6df32 Do not attach to the sound device on G5 Xserves, which is actually an
LED controller used to run the load graph on the server's front panel.

Reported by:	Paul Mather <paul at gromit dot dlib dot vt dot edu>
MFC after:	3 days
2011-06-26 00:35:11 +00:00
Hans Petter Selasky
f1a16106b6 - Move all USB device ID arrays into so-called sections,
sorted according to the mode which they support:
	host, device or dual mode
- Add generic tool to extract these data:
	tools/bus_autoconf

Discussed with:	imp
Suggested by:	Robert Millan <rmh@debian.org>
PR:		misc/157903
MFC after:	14 days
2011-06-24 02:30:02 +00:00
Joel Dahl
d2c60314e4 Hide driver revision behind bootverbose.
Approved by:	mav
2011-06-15 19:53:08 +00:00
Alexander Motin
180c2b3829 Add bunch of Conexant codec IDs. For some of them add quirks to disable
excessive signal paths to simplify tracer's life.
2011-06-13 20:34:12 +00:00
Alexander Motin
cbebc90de0 Make automatic hw.snd.default_unit choice a bit more intelligent. Instead
of just setting it to the first registered device, reevaluate it for each
device registered, trying to choose best candidate, unless one was forced.
For now use such preference order: play&rec, play, rec.

As side effect, this should workaround the situation when HDMI audio output
of the video card, usually not connected to anything, becomes default, that
requires manual user intervention to make sound working. If at some point
this won't be enough, we can try to fetch some additional priority flags
from the device driver.
2011-06-07 17:01:52 +00:00
Alexander Motin
0591ab9c30 Add better names for the Intel HDMI audio codecs. 2011-05-26 06:43:10 +00:00
Andriy Gapon
cd10bffa61 usb: change to one-pass probing of device drivers
This brings USB bus more in line with how newbus is supposed to be used.
Also, because of the two-pass probing the following message was produced
by devd in default configuration when almost any USB device was
connected:
	Unknown USB device: vendor <> product <> bus <>
This should be fixed now.

Note that many USB device drivers pass some information from probe
method to attach method via ivars.  For this to continue working we rely
on the fact that the subr_bus code calls probe method of a winning driver
again before calling its attach method in the case where multiple
drivers claim to support a device.  This is done because device
description is set in successful probe methods and we want to get a correct
device description from a winning driver.  So now this logic is re-used
for setting ivars too.

Reviewed by:	hselasky
MFC after:	1 month
2011-05-18 07:40:12 +00:00
Andriy Gapon
76dc2afdc7 fix build on 32-bit platforms for r221803
Casting a pointer to a wide integer is probably not that bad, but I am
still guilty of not testing this.

Pointyhat to:	avg
MFC after:	1 week
X-MFC with:	r221803
2011-05-12 12:18:01 +00:00
Andriy Gapon
a5669965bd dsp/pcm: allow to mmap both read and write buffers using the same fd
This brings our implementation in line with OSS specification for
systems that support mmap.  The change should also improve compatibility
with OSS software not specifically written for FreeBSD, e.g. PulseAudio
OSS plugin.

Reviewed by:	kib, jhb
MFC after:	1 week
2011-05-12 07:44:41 +00:00
Jack F Vogel
4cc96c3e8f Correct a typo 2011-05-12 00:10:29 +00:00
Jack F Vogel
73e3bb6563 Chipset support for the new Intel Panther Point PCH, thanks
to Seth Heasley for preparing the changes.
2011-05-11 20:31:27 +00:00
Hans Petter Selasky
f895cc0c50 Workaround for broken no-name USB audio devices sold by dealextreme
called "3D sound" and the alike.

MFC after:	14 days
2011-05-09 15:57:04 +00:00
Andriy Gapon
e3888a9820 SNDCTL_DSP_GETIPTR: set pointer to sndbuf_getfreeptr()
Rationale:
- unlike current behavior this seems to be compliant with OSS
  specification:
  http://manuals.opensound.com/developer/SNDCTL_DSP_GETIPTR.html
- this seems to meet expectations of some OSS programs compiled for or
  ported from Linux, e.g. ALSA OSS plugin
- this doesn't seem to break any programs as far as current testing
  shows

Tested by:	nox, hselasky
MFC after:	4 days
2011-05-03 15:50:22 +00:00
Hans Petter Selasky
aca2249d54 Only set the sample rate if the USB audio channel reports
that it supports the frequency control request.

MFC after:	7 days
Approved by:	thompsa (mentor)
2011-04-20 19:41:08 +00:00
Marius Strobl
496a7fcaae Allocate the sound buffer DMA memory coherent. While NetBSD typically
also does this for sound drivers it's probably not necessary for all
combinations of controllers and drivers. However, given that our sound
drivers completely lack bus_dmamap_sync(9) calls this at least serves
as a workaround when enabling use of the IOMMU streaming buffers on
sparc64 and generally for arm and mips.

MFC after:	2 weeks
2011-03-11 22:42:04 +00:00
Hans Petter Selasky
25b74dab1d - Add support for some non-standard USB MIDI devices from Roland, by
means of allowing vendor specific interface class for audio and MIDI devices.
- Add new quirks for this. The vendor and product list in OpenBSD's
dev/usb/umidi_quirks.c was used as reference.

MFC after:	14 days
Approved by:	thompsa (mentor)
2011-02-24 09:13:47 +00:00
Rebecca Cran
6bccea7c2b Fix typos - remove duplicate "the".
PR:	bin/154928
Submitted by:	Eitan Adler <lists at eitanadler.com>
MFC after: 	3 days
2011-02-21 09:01:34 +00:00
Hans Petter Selasky
6f068a4313 - Make an enum for all the umidi USB transfers.
- Use the USB stack's builtin clear-stall feature.
- Wrap some long lines.
- Use memcpy() instead of bcopy().
- Use memset() instead of bzero().
- Tested applications:
	/usr/ports/audio/fluidsynth

MFC after:	7 days
Approved by:	thompsa (mentor)
2011-02-18 07:37:30 +00:00
Marius Strobl
1115e138a9 Correct signedness and off-by-one issues in parameters used for DMA tag
creation.

PR:		154259
Submitted by:	Vladislav Movchan (partially)
MFC after:	3 days
2011-02-09 11:28:57 +00:00
Jack F Vogel
bf0477b215 Support for the new Patsburg PCH chipset:
- SMBus Controller
     - SATA Controller
     - HD Audio Controller
     - Watchdog Controller

Thanks to Seth Heasley (seth.heasley@intel.com) for providing us code.

MFC after 3 days
2011-02-01 01:05:11 +00:00
Matthew D Fleming
240577c2a7 Fix up a few more sysctl(9) mis-typing found in various LINT builds. 2011-01-13 18:20:27 +00:00
Matthew D Fleming
6dc7dc9a3e sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
Commit the rest of the devices.
2011-01-12 19:53:56 +00:00
John Baldwin
58ccf5b41c Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by:	bde
2011-01-11 13:59:06 +00:00
Pyun YongHyeon
deb4ef8291 Add device id for RDC M3010 which is found on Vortex86 SoC.
Reviewed by:	mav
2010-12-28 17:45:43 +00:00
Tijl Coosemans
81bd5041a2 Merge amd64 and i386 bus.h and move the resulting header to x86. Replace
the original amd64 and i386 headers with stubs.

Rename (AMD64|I386)_BUS_SPACE_* to X86_BUS_SPACE_* everywhere.

Reviewed by:	imp (previous version), jhb
Approved by:	kib (mentor)
2010-12-20 16:39:43 +00:00
Tijl Coosemans
0e4e9e170c Use convenience functions where possible instead of accessing the PCI
configuration registers directly.

Remove pci_enable_io calls where they are redundant. The PCI bus driver
will set the right bits when the corresponding bus resource is activated.

Remove redundant pci_* function calls from suspend/resume methods. The
bus driver already saves and restores the PCI configuration.

Reviewed by:	jhb
Approved by:	kib (mentor)
2010-12-18 14:21:28 +00:00
Rebecca Cran
b1ce21c6ef Fix typos.
PR:	bin/148894
Submitted by:	olgeni
2010-11-09 10:59:09 +00:00
Alexander Motin
6ea7128dbd Make hw.snd.vpc_0db to be also a loader tunable. 2010-10-25 08:25:44 +00:00
Rui Paulo
577fedb6b1 Fix a brain-o: wrong case statement semantics.
Found with:	clang
2010-10-13 14:39:54 +00:00
Jack F Vogel
f0d5a975b3 Add Intel Cougar Point PCH HD Audio Controller ID
MFC in a week
2010-08-28 00:23:13 +00:00
Gavin Atkinson
af9800150c Do not free sc if attach failed, as it was allocated by the bus
infrastructure, not us.  This appears to be a leftover from an older
version of the driver.

Submitted by:	avg
Tested by:	Anton Shterenlikht <mexas bristol.ac.uk>
MFC after:	1 week
X-MFC-Note:	To stable/8 and stable/7 only
2010-08-04 07:49:40 +00:00
Andrew Thompson
e3e05e50d9 - fix for USB audio devices which use the 7-byte endpoint descriptor instead of
the 9-byte one.
- remove sync-endpoint code, which is currently unused.

Reported by:	Antun Matanovi
Submitted by:	Hans Petter Selasky
2010-06-22 21:16:18 +00:00
Andrew Thompson
3851442c61 Reduce MIDI input buffer size to one USB packet, hence some USB devices don't
properly short terminate their transfers. This fixes a problem where input
appears several seconds late.

Reported by:	Alexander Yerenkow
Submitted by:	Hans Petter Selasky
2010-06-22 21:13:36 +00:00
Andriy Gapon
a9bdb5d3ad sound/pcm: use non-const string as a value with SYSCTL_STRING
Although the sysctls are marked with CTLFLAG_RD and the values will stay
immutable, current sysctl implementation stores value pointer in
void* type, which means that const qualifier is discarded anyway
and some newer compilers complaint about that.
We can't use de-const trick in sysctl implementation, because in that
case we could miss an opposite situation where a const value is used
with CTLFLAG_RW sysctl.

Complaint from:	gcc 4.4, clang
MFC after:	2 weeks
2010-06-15 07:06:54 +00:00
Alexander Motin
c4219fc1b0 Add set of codec IDs.
PR:		kern/147466
2010-06-09 05:49:02 +00:00
Jung-uk Kim
c909aebcbb - Remove more dead code[1]. Since r207330, we only need to check division
by zero of the second argument 'from'.
- Prefer u_int32_t over unsigned int to make its intention more clearer.
- Move the function to a header file and make it a static inline function.

Pointed out by:	Andrew Reilly (areilly at bigpond dot net dot au)[1]
MFC after:	3 days
2010-05-04 16:56:59 +00:00
Jung-uk Kim
8c975e70af Remove dead code. Calculated greatest common divisor was not used at all.
On top of that, LLVM+Clang mis-compiles this code because of its register
allocator bug.

Analyzed by:	Andrew Reilly (areilly at bigpond dot net dot au)
Reviewed by:	ariff, rdivacky
MFC after:	3 days
2010-04-28 17:26:05 +00:00
Andrew Thompson
b850ecc180 Change USB_DEBUG to #ifdef and allow it to be turned off. Previously this had
the illusion of a tunable setting but was always turned on regardless.

MFC after:	1 week
2010-04-22 21:31:34 +00:00
Joel Dahl
d821b5aa40 Fix the gap between mute and lowest possible volume. The es1370 mixer
volumes were incorrectly calculated.

I've tested this with one of my es1370 cards and I can confirm that it
works.

PR:		98167
Submitted by:	Joseph Terner <jtsn@gmx.de>
Approved by:	kib
2010-04-01 11:30:46 +00:00
Joel Dahl
b40d342195 Start copyright notices with /*- 2010-03-29 20:27:17 +00:00
Alexander Motin
42d008a11c Fix lock leakage.
PR:		kern/145081
2010-03-27 15:39:19 +00:00
Alexander Motin
b0423064be Add some more codec IDs. 2010-03-21 15:14:21 +00:00
Joel Dahl
4260c12796 Looks like I forgot to add half of the copyright text when we switched to
our preferred license.
2010-03-08 18:51:28 +00:00
Alexander Motin
28889a0022 Fix bug in headphones audio redirection using separate DAC. It was exposed
by removing channel duplication during multichannel audio implementation.
2010-02-26 09:31:50 +00:00
Rebecca Cran
4c21be9b2d Rename usb2_ structures and variables to usb_.
Approved by:	rrs (mentor)
Discussed with:	hps
2010-02-08 19:44:09 +00:00
Alexander Motin
8da30a896a Oops! r202789 broke recording from input mixer. Restore previous "mix"
usage and use "igain" instead for input-to-output monitoring loopback.
2010-01-22 09:54:40 +00:00
Alexander Motin
028b92a574 - Improve tracer, to handle more cases of input-to-output monitoring
loopback.
- Change the meaning of "mix" OSS control. Now it controls loopback level,
according to comments in soundcard.h.
- Allow AD1981HD codecs to use playback mixer. Now driver should be able to
really use it.
- Fix bug in shared muters operation.
2010-01-22 09:31:10 +00:00
Alexander Motin
09aa060e71 Print playback channels paths in order of their sequence numbers, not nids. 2010-01-21 09:11:50 +00:00
Alexander Motin
1d676e56c6 Hide from default sndstat some information not used on daily basis,
to make it readable by average user with average screen size.
2010-01-13 22:22:16 +00:00
Alexander Motin
b7d561a3f1 Make OSS_GETVERSION ioctl supported also for DSP devices,
same as 4Front and Linux do.

MFC after:	1 month
2010-01-12 20:10:40 +00:00
Alexander Motin
d6b230d20a Make default recording source choosing more intelligent.
Change default recording level from 0 to 75.
It should increase chances for things to work just out of the box.
2010-01-12 19:41:07 +00:00
Alexander Motin
481ad2f5b4 Align buffer size to LCM of 128bytes, required by hardware, and alignment of
current format. This fixes problems with non-power-of-2 number of channels.

Enable 5.1 formats support, as they are working fine now.
2010-01-12 16:40:13 +00:00
Alexander Motin
2fdb5f0b86 Make OSS_GETVERSION ioctl really work. It has 'M' group, not 'P',
as different nearby ones, and was grabbed by MIXER_xxx() handler.

While there, replace '(cmd & MIXER_xxx(0)) == MIXER_xxx(0)' expressions
with more correct '(cmd & ~0xff) == MIXER_READ(0)'. Use of bit operations
to compare numeric fields doesn't looks sane.

MFC after:	1 month
2010-01-12 11:11:25 +00:00
Alexander Motin
fbf9cd2256 Add multichannel (4.0 and 7.1) playback support. 5.1 mode support blocked
now due to unidentified synchonization problem. For 7.1 soundcards 5.1
support handled correctly via software upmix done by sound(4).

Stereo stream is no more duplicated to all ports. If you loose sound, check
you are using right connectors. Front speakers connector is usually green,
center/LFE - orange, rear - black, side - gray.
2010-01-11 22:57:52 +00:00
Martin Blapp
c2ede4b379 Remove extraneous semicolons, no functional changes.
Submitted by:	Marc Balmer <marc@msys.ch>
MFC after:	1 week
2010-01-07 21:01:37 +00:00
Robert Noland
cfd7bacef2 Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.
This replaces d_mmap() with the d_mmap2() implementation and also
changes the type of offset to vm_ooffset_t.

Purge d_mmap2().

All driver modules will need to be rebuilt since D_VERSION is also
bumped.

Reviewed by:	jhb@
MFC after:	Not in this lifetime...
2009-12-29 21:51:28 +00:00
Antoine Brodin
13e403fdea (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR:		137213
Submitted by:	Eygene Ryabinkin (initial version)
MFC after:	1 month
2009-12-28 22:56:30 +00:00
Andrew Thompson
afbfddd901 - add support for more than 2 audio channels. [1]
- add support for more sample rates

Submitted by:	[1] ariff (earlier version), Hans Petter Selasky
2009-12-22 02:11:37 +00:00
Alexander Motin
1969c3f4ea Add one more set of codec IDs. 2009-12-11 00:38:13 +00:00
Alexander Motin
eb3d6abdf9 Add two Cirrus Logic codec IDs.
Add GPIO setting quirk for Apple MacBookPro5,5.

Submitted by:	ed
2009-11-26 20:25:57 +00:00
Andrew Thompson
dc6942514b add support for MIDI devices without audio control stream.
Submitted by:	Hans Petter Selasky
2009-11-22 21:26:27 +00:00
Andrew Thompson
7fb4357098 remove volume alignment (was previously not correctly implemented)
Submitted by:	HPS
Reported by:	Jaakko Heinonen
2009-11-20 09:00:38 +00:00
Alexander Motin
a1c0421a4a Add more codec IDs. 2009-11-13 21:06:33 +00:00
Andrew Thompson
b029f6bb95 Improve support for High-speed USB audio devices.
- fix issues regarding the mixer, where the interface number was not set in
  time.
- fix wrong use of resolution parameter.

Submitted by:	Hans Petter Selasky
2009-11-08 21:00:50 +00:00
Alexander Motin
2ad05ba238 Fix typo in previous commit.
Add Realtek ALC887 codec ID.
2009-09-30 11:05:12 +00:00
Alexander Motin
ef0097a6aa Add some bits of HDMI/DisplayPort support from later specification updates.
It may be not enough to make them work, but at least should give some
information about these beasts.
2009-09-29 09:36:38 +00:00
Joel Dahl
2ee4e98c7e Move es137x.c and es137x.h to a 2-clause BSD license. Also move a few
comments.

Submitted by:	Joachim Kuebart
Approved by:	core, Russell Cattelan <cattelan@thebarn.com>
2009-09-22 13:23:59 +00:00
Marius Strobl
eb811915d2 - According to Linux, the ALi M5451 can do 31-bit DMA instead of just
30-bit like the reset of the controllers supported by this driver.
  Actually ALi M5451 can be setup up to generate 32-bit addresses by
  setting the 31st bit via the accompanying ISA bridge, which allows
  it to work in sparc64 machines whose IOMMU require at least 32-bit
  DMA. Even though other architectures would also benefit from 32-bit
  DMA, enabling this bit is limited to sparc64 as bus_dma(9) doesn't
  generally guarantee that a low address of BUS_SPACE_MAXADDR_32BIT
  results in a buffer in the 32-bit range.
- According to Tatsuo YOKOGAWA's ali(4), the the DMA transfer size of
  ALi M5451 is fixed to 64k and in fact using the default size of 4k
- The 4DWAVE DX and NX require the recording buffer to be 8-byte
  aligned so adjust the bus_dma_tag_create(9) accordingly.
- Unlike the rest of the controllers supported by this driver, the
  ALi M5451 only has 32 hardware channels instead of 64 so limit the
  loop in tr_intr() accordingly. [1]

Submitted by:	yongari [1]
Reviewed by:	yongari (superset of what is committed)
MFC after:	3 days
2009-09-22 11:38:45 +00:00
Alexander Motin
f66de33a6a Add NVidia MCP89 HDA controller IDs. 2009-09-09 04:48:41 +00:00
Alexander Motin
f147bd6d3d Add Intel 82801JD (one more ICH10) HDA controller ID.
Submitted by:	yongari
2009-09-09 04:36:56 +00:00
Alexander Motin
46681d6e45 Improve HDA controller capabilities logging. 2009-09-02 11:39:19 +00:00
Alfred Perlstein
f24b6817d6 Remove redundant Giant reference. Giant will be dropped
automatically when the mutex argument is NULL.

Reported by: Various people
Submitted by: hps
2009-08-24 04:57:48 +00:00
John Baldwin
a56fe095f0 Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by:	re (kib), attilio
2009-08-20 19:17:53 +00:00
Attilio Rao
444b91868b Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by:    ed, hps, jhb, imp, mav, scottl
No answer by:   ariff, thompsa, yongari
Tested by:      pho,
                G. Trematerra <giovanni dot trematerra at gmail dot com>,
                Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by:   Yahoo! Incorporated
Approved by:	re (ksmith)
2009-08-02 14:28:40 +00:00
Alfred Perlstein
3d11bc19a0 USB audio:
- code factoring patch from "Eygene Ryabinkin"
- P4 ID: 166149

Submitted by:	hps
Approved by:	re
2009-07-30 00:14:56 +00:00
Alexander Motin
5487ee5507 Disable MSI by default for nVidia MCP55 chipset.
It is reported to be broken in the same way as MCP51.

PR:		kern/136429
Approved by:	re (kib)
2009-07-14 19:18:31 +00:00
Ariff Abdullah
df41a638f7 - Do aggresive saturation on various polynomial interpolators.
This dramatically pushing 99.9% interpolations and quantizations
  error _below_ -180dB on 32bit dynamic range, resulting extremely
  high quality conversion.
- Use BSPLINE interpolator for filter oversampling factor greater or
  equal than 64 (log2 6).

Approved by:	re (kib)
2009-07-14 18:53:34 +00:00
Marcel Moolenaar
c5e2d1885c Isochronous transfers only have 1 frame buffer, but multiple
frame lengths. The frame buffer is at index 0.

Approved by:	re (kensmith)
Obtained from:	HPS
2009-07-12 16:50:32 +00:00
Ariff Abdullah
5c663ce9cf Rearrange shift operation to increase interpolation accuracy,
further reducing conversion artifacts and better worst case SNR.

Approved by:	re (kib)
2009-07-09 22:21:18 +00:00
Ariff Abdullah
96831ae59b - Increase dynamic range of filter coefficients from 28bit to 30bit.
This cause dramatic effect in overall precision and conversion quality
  by pushing down most aliasing artifacts around -180 dB.

  Spectrogram analysis/comparison:

  	http://people.freebsd.org/~ariff/z_comparison/z_28vs30/

- Guard against possible 64bit overflow during accumulation process by
  slightly normalize and saturate sample and coefficient multiplication,
  possible during extreme 32bit downsampling (eg. 380KHz -> 8KHz) with
  custom preset that require more than ~7000 taps filter (which is
  overkill).

- Add knobs through FEEDER_RATE_PRESETS to set dynamic range of filter
  coefficients/accumulator and prefered polynomial interpolator:

  	COEFFICIENT_BIT:X
	(where 1 <= X <= 30, default: 30)

	ACCUMULATOR_BIT:X
	(where 32 <= X <=64, default: 58)

	INTERPOLATOR:I
	(where I = ZOH, LINEAR, QUADRATIC, HERMITE, BSPLINE,
 	           OPT32X, OPT16X, OPT8X, OPT4X, OPT2X)

Approved by:	re (kib)
2009-07-05 18:15:06 +00:00
Andrew Thompson
7e6e6b6766 Use the correct mutex in umidi_open()
Submitted by:	Hans Petter Selasky
Approved by:	re (kib)
2009-06-27 21:21:11 +00:00
Konstantin Belousov
9f80ce043d Change the type of uio_resid member of struct uio from int to ssize_t.
Note that this does not actually enable full-range i/o requests for
64 architectures, and is done now to update KBI only.

Tested by:	pho
Reviewed by:	jhb, bde (as part of the review of the bigger patch)
2009-06-25 18:46:30 +00:00
Alexander Motin
8380c28e5a Some DMA related changes:
- honor parent DMA tag limitations, as man page requires,
 - allow data buffer to be allocated within full 64bit address range, when
   support is announced by hardware,
 - add quirk, disabling 64bit addresses for broken chips, use it for MCP78.
2009-06-24 17:03:06 +00:00
Ariff Abdullah
f3bf5def20 Slight comment fix. 2009-06-24 02:01:16 +00:00
Andrew Thompson
8f9e0ef947 Fix a typeo in the frame len function to unbreak the build, make it shorter
while I am here.
2009-06-23 06:00:31 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Ariff Abdullah
164e1f20ec - Add a way to change filter oversampling factor through
FEEDER_RATE_PRESET "OVERSAMPLING_FACTOR:X .. .." where
  X = log2(oversampling factor).

- Lower down default filter oversampling factor from 128
  (log2 = 7) to 32 (log2 = 5), saving worth of 80 Kb.
  The use of better polynomial interpolator will raise
  its conversion quality/accuracy to match (or slightly
  better) with previous settings.

- Bump driver version.
2009-06-15 04:31:34 +00:00
Ariff Abdullah
eedb75f16b Remap type of polynomial interpolators for better polyphase
coefficients quality:
- Linear interpolator for oversampling factor larger and equal
  than 4096 (log2 = 12).
- Quadratic interpolator for oversampling factor larger and equal
  than 256 (log2 = 8).

Default oversampling factor (128 ~ log2 = 7) will use OPT32X, which
provides better accuracy.
2009-06-15 04:05:38 +00:00
Andrew Thompson
a593f6b8de s/usb2_/usb_|usbd_/ on all function names for the USB stack. 2009-06-15 01:02:43 +00:00
Alexander Motin
ff0ef2c596 Fix type of lowaddr variable. 2009-06-14 07:34:21 +00:00
Ariff Abdullah
5870e3c990 Remove custom KOBJMETHOD(), CHANNEL_DECLARE() and MIXER_DECLARE()
(enabled with SND_DEBUG) that was intended to provoke build failure
due to inconsistencies.
2009-06-11 09:06:09 +00:00
Ariff Abdullah
5cda20cfdb Move machine dependant AFMT_* definition from sound.h
to global soundcard.h .
2009-06-10 03:56:24 +00:00
Ariff Abdullah
c7215acf82 Fix compile time warning on sparc64, thanks to strict kobj signatures checking.
Noticed by:	bz
2009-06-08 23:24:01 +00:00
Ariff Abdullah
d88ff2a221 Fix powerpc build failure due to strict kobj signatures checking. 2009-06-08 08:10:52 +00:00
Ariff Abdullah
c5c15a7b9a Fix build on sparc64.
Pointy hat:	ariff@
2009-06-07 23:38:16 +00:00
Ariff Abdullah
db77ea6c22 Bump driver revision (should have bumped it earlier). 2009-06-07 19:36:25 +00:00
Ariff Abdullah
90da2b2859 Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
	[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .

Summary of changes includes:

1 Volume Per-Channel (vpc).  Provides private / standalone volume control
  unique per-stream pcm channel without touching master volume / pcm.
  Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
  backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
  instead of /dev/mixer.  Special "bypass" mode is enabled through
  /dev/mixer which will automatically detect if the adjustment is made
  through /dev/mixer and forward its request to this private volume
  controller.  Changes to this volume object will not interfere with
  other channels.

  Requirements:
    - SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
      require specific application modifications (preferred).
    - No modifications required for using bypass mode, so applications
      like mplayer or xmms should work out of the box.

  Kernel hints:
    - hint.pcm.%d.vpc (0 = disable vpc).

  Kernel sysctls:
    - hw.snd.vpc_mixer_bypass (default: 1).  Enable or disable /dev/mixer
      bypass mode.
    - hw.snd.vpc_autoreset (default: 1).  By default, closing/opening
      /dev/dsp will reset the volume back to 0 db gain/attenuation.
      Setting this to 0 will preserve its settings across device
      closing/opening.
    - hw.snd.vpc_reset (default: 0).  Panic/reset button to reset all
      volume settings back to 0 db.
    - hw.snd.vpc_0db (default: 45).  0 db relative to linear mixer value.

2 High quality fixed-point Bandlimited SINC sampling rate converter,
  based on Julius O'Smith's Digital Audio Resampling -
  http://ccrma.stanford.edu/~jos/resample/.  It includes a filter design
  script written in awk (the clumsiest joke I've ever written)
    - 100% 32bit fixed-point, 64bit accumulator.
    - Possibly among the fastest (if not fastest) of its kind.
    - Resampling quality is tunable, either runtime or during kernel
      compilation (FEEDER_RATE_PRESETS).
    - Quality can be further customized during kernel compilation by
      defining FEEDER_RATE_PRESETS in /etc/make.conf.

  Kernel sysctls:
    - hw.snd.feeder_rate_quality.
      0 - Zero-order Hold (ZOH).  Fastest, bad quality.
      1 - Linear Interpolation (LINEAR).  Slightly slower than ZOH,
          better quality but still does not eliminate aliasing.
      2 - (and above) - Sinc Interpolation(SINC).  Best quality.  SINC
          quality always start from 2 and above.

  Rough quality comparisons:
    - http://people.freebsd.org/~ariff/z_comparison/

3 Bit-perfect mode.  Bypasses all feeder/dsp effects.  Pure sound will be
  directly fed into the hardware.

4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
  be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.

5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
  vchans in order to make digital format pass through.  It also makes
  vchans more dynamic by choosing a better format/rate among all the
  concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
  becomes sort of optional.

6 Exclusive Stream, with special open() mode O_EXCL.  This will "mute"
  other concurrent vchan streams and only allow a single channel with
  O_EXCL set to keep producing sound.

Other Changes:
    * most feeder_* stuffs are compilable in userland. Let's not
      speculate whether we should go all out for it (save that for
      FreeBSD 16.0-RELEASE).
    * kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
    * pull out channel mixing logic out of vchan.c and create its own
      feeder_mixer for world justice.
    * various refactoring here and there, for good or bad.
    * activation of few more OSSv4 ioctls() (see [1] above).
    * opt_snd.h for possible compile time configuration:
      (mostly for debugging purposes, don't try these at home)
        SND_DEBUG
        SND_DIAGNOSTIC
        SND_FEEDER_MULTIFORMAT
        SND_FEEDER_FULL_MULTIFORMAT
        SND_FEEDER_RATE_HP
        SND_PCM_64
        SND_OLDSTEREO

Manual page updates are on the way.

Tested by:	joel, Olivier SMEDTS <olivier at gid0 d org>, too many
          	unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
Andrew Thompson
c737a63263 revert r162516. We only support 1 or 2 channels per stream
which reflects mono and stereo.

Submitted by:	Hans Petter Selasky
2009-06-04 21:59:28 +00:00
Alexander Motin
ba98ce6bad Comment out old Realtek ALC883 quirk, that was disabling phantop power on
mic inputs. I have no idea what for it was made that time, but now I have
several reports that it should be removed to make microphones work. If
this quirk is still required for some systems then they should be identified
and specified explicitly.
2009-06-01 13:13:47 +00:00
Andrew Thompson
e0a69b51ac s/usb2_/usb_/ on all typedefs for the USB stack. 2009-05-29 18:46:57 +00:00
Andrew Thompson
760bc48e7e s/usb2_/usb_/ on all C structs for the USB stack. 2009-05-28 17:36:36 +00:00
Andrew Thompson
1ff7682866 Provide a workaround for USB devices that do not support mono or stereo
operation by overriding the channel count.

Submitted by:	Hans Petter Selasky
Reported by:	MIHIRA Sanpei Yoshiro
2009-05-27 19:45:04 +00:00
Joel Dahl
999da77859 Slightly adjust copyright text.
Approved by:	Hannu Savolainen <hannu@opensound.com>
2009-05-27 18:17:58 +00:00
Joel Dahl
40ac6e1726 Slightly adjust copyright text.
Approved by:	luigi
2009-05-27 18:16:53 +00:00
Joel Dahl
f2907a755d Separate comments from the license text. 2009-05-27 18:13:15 +00:00
Andrew Thompson
fadc970b77 Fix a few variable renames of usb2_mode outside dev/usb. 2009-05-21 02:09:12 +00:00
Joel Dahl
498a9afee2 Slightly adjust copyright text.
Approved by:	matk
2009-05-20 18:38:43 +00:00
Joel Dahl
e05a128eb7 Remove license clauses 3 and 4 as per rev. 1.65 of midi.c in NetBSD.
Approved by:	matk
2009-05-20 18:34:26 +00:00
Joel Dahl
4367b59545 Remove license clauses 3 and 4 as per rev. 1.65 of auvia.c in NetBSD. 2009-05-20 18:31:11 +00:00
Joel Dahl
1d631ee69a Remove license clauses 3 and 4 as per rev. 1.112 of uaudio.c and rev. 1.15 of
uaudioreg.h in NetBSD.
2009-05-20 18:15:13 +00:00
Joel Dahl
ba55ca9732 Remove license clauses 3 and 4 as per rev. 1.12 of cs4231reg.h in NetBSD. 2009-05-20 18:04:56 +00:00
Alexander Motin
6e8e2779b3 Add one more board ID with inverted external amplifier control.
PR:		kern/121156
2009-05-08 03:19:57 +00:00
Stanislav Sedov
219c5a5a96 - Unlock softc mutex on failure.
MFC after:	1 week
2009-04-20 13:15:25 +00:00
Stanislav Sedov
852761c216 - Properly unlock mutex on failure in channel_trigger. Before this
the function just returned with the mutex held.

MFC after:	1 week
2009-04-20 12:43:07 +00:00
Andrew Thompson
4eae601ebd MFp4 //depot/projects/usb@159909
- make usb2_power_mask_t 16-bit
- remove "usb2_config_sub" structure from "usb2_config". To compensate for this
  "usb2_config" has a new field called "usb_mode" which select for which mode
  the current xfer entry is active. Options are: a) Device mode only b) Host
  mode only (default-by-zero) c) Both modes.  This change was scripted using
  the following sed script: "s/\.mh\././g".
- the standard packet size table in "usb_transfer.c" is now a function, hence
  the code for the function uses less memory than the table itself.

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:38 +00:00
Alexander Motin
cb11662602 Add some more logic for AD1986A codec input tracing. Use mic preamplifier
only for mic-type inputs. This gives better chances to use it.

Change default configuration for some AD1986A codec based ASUS boards,
use it also for ASUS P5PL2 board. This makes front mic preamplifier working.

Tested by:	Vadim Frolov <frolov@frolov.ck.ua>
2009-04-01 18:55:08 +00:00
Alexander Motin
f7cdd867ec Fixup relative pointers after channel realloc. It fixes crash on systems
with several HDA codecs per controller.

While I am there, remove some unneeded dereferences.

Submitted by:	Tor Egge <Tor.Egge@cvsup.no.freebsd.org>
2009-03-29 07:10:52 +00:00
Alexander Motin
83c59ed283 Remove CD input hack for ALC268 based Acer systems. Latest systems does not
implement CD input in hardware, while unconditional showing it confuse users.
Also it was made in the way that sometimes improper with present driver.

Add patch for ALC268 based Acer TM5320 to make headphones jack sensing work.
Default configuration defines two separate playback associations, which
current driver unable to trace properly due to order they are defined and
limited codec uniformity.

Submitted by:	G. Mirov <g.mirov AT gmail.com>
2009-03-16 15:50:29 +00:00
Alexander Motin
ad7de3aafb Fix spelling in message. 2009-03-16 12:42:23 +00:00
Warner Losh
155a83e87a remove now-redunant cardbus attachment. 2009-03-09 13:23:54 +00:00
Andrew Thompson
9aef556d71 Rename the ushub device class back to uhub as it was in the old usb stack,
moused(8) looks for "uhub/ums" to decide if needs to load the module.

Reported by:	Garrett Cooper
2009-03-02 05:37:05 +00:00
Alexander Motin
8363eacca1 Copy/paste bug fix for previos commit. 2009-02-27 23:49:26 +00:00
Andrew Thompson
ee3e3ff5c2 Change USB over to make_dev() for all device nodes, previously it hooked into
the devfs clone handler to open the (invisible) devices on the fly.

The /dev entries are layed out as follows,

 /dev/usbctl      = master device
 /dev/usb/0.1.0.5 = usb device, (<bus>.<dev>.<iface>.<endpoint>)
 /dev/ugen0.1 -> usb/0.1.0.0 = ugen link to ctrl endpoint

This also removes the custom permissions model from USB.  Bump
__FreeBSD_version to 800066.

Submitted by:	rink (earlier version)
2009-02-27 17:27:16 +00:00
Alexander Motin
edce9c994e Add MSI blacklisting support.
Disable MSI for nVidia MCP51 controller. Enabling MSI there leads to
unexpected errors and timeouts, that should not happen even if interrupts
are not working completely.
2009-02-26 20:00:14 +00:00
Andrew Thompson
3a3f90c6c3 Move the uaudio and ata-usb drivers into their correct locations. 2009-02-23 21:19:18 +00:00
Andrew Thompson
e02917222d Move two missed usb drivers out to the graveyard location under sys/legacy/dev. 2009-02-23 21:07:20 +00:00
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