2 .\" Copyright (c) 2009-2011 Joel Dahl <joel@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 PCM audio device infrastructure
39 To compile this driver into the kernel, place the following line in your
40 kernel configuration file:
41 .Bd -ragged -offset indent
47 driver is the main component of the
50 It works in conjunction with a bridge device driver on supported devices
51 and provides PCM audio record and playback once it attaches.
52 Each bridge device driver supports a specific set of audio chipsets and
53 needs to be enabled together with the
56 PCI and ISA PnP audio devices identify themselves so users are usually not
57 required to add anything to
58 .Pa /boot/device.hints .
60 Some of the main features of the
62 driver are: multichannel audio, per-application
63 volume control, dynamic mixing through virtual sound channels, true full
64 duplex operation, bit perfect audio, rate conversion and low latency
69 driver is enabled by default, along with several bridge device drivers.
70 Those not enabled by default can be loaded during runtime with
74 The following bridge device drivers are available:
80 .Xr snd_ai2s 4 (enabled by default on powerpc)
86 .Xr snd_audiocs 4 (enabled by default on sparc64)
88 .Xr snd_cmi 4 (enabled by default on amd64, i386)
92 .Xr snd_csa 4 (enabled by default on amd64, i386)
94 .Xr snd_davbus 4 (enabled by default on powerpc)
100 .Xr snd_emu10kx 4 (enabled by default on amd64, i386)
106 .Xr snd_es137x 4 (enabled by default on amd64, i386, sparc64)
114 .Xr snd_hda 4 (enabled by default on amd64, i386)
118 .Xr snd_ich 4 (enabled by default on amd64, i386)
138 .Xr snd_t4dwave 4 (enabled by default on sparc64)
140 .Xr snd_uaudio 4 (enabled by default on amd64, i386, powerpc, sparc64)
142 .Xr snd_via8233 4 (enabled by default on amd64, i386)
149 Refer to the manual page for each bridge device driver for driver specific
150 settings and information.
154 cards, the driver looks for
160 These values can be overridden in
161 .Pa /boot/device.hints .
162 Non-PnP sound cards require the following lines in
164 .Bd -literal -offset indent
168 hint.pcm.0.flags="0x0"
171 Apart from the usual parameters, the flags field is used to specify
174 channel (generally used for capture in full duplex cards).
175 Flags are set to 0 for cards not using a secondary
177 channel, or to 0x10 + C to specify channel C.
179 In general, the module
188 or from the command line using the
191 Options which can be specified in
192 .Pa /boot/loader.conf
194 .Bl -tag -width ".Va snd_driver_load" -offset indent
195 .It Va snd_driver_load
199 this option loads all available drivers.
204 only the Intel High Definition Audio bridge device driver and dependent
205 modules will be loaded.
210 load driver for card/chipset foo.
213 To define default values for the different mixer channels,
214 set the channel to the preferred value using hints, e.g.:
215 .Va hint.pcm.0.line Ns = Ns Qq Li 0 .
216 This will mute the input channel per default.
217 .Ss Multichannel Audio
218 Multichannel audio, popularly referred to as
220 is supported and enabled by default.
221 The FreeBSD multichannel matrix processor supports up to 18 interleaved
222 channels, but the limit is currently set to 8 channels (as commonly used
223 for 7.1 surround sound).
224 The internal matrix mapping can handle reduction, expansion or
225 re-routing of channels.
226 This provides a base interface for related multichannel
229 Multichannel audio works both with and without
232 Most bridge device drivers are still missing multichannel matrixing
233 support, but in most cases this should be trivial to implement.
235 .Va dev.pcm.%d.[play|rec].vchanformat
237 to adjust the number of channels used.
238 The current multichannel interleaved structure and arrangement was
239 implemented by inspecting various popular UNIX applications.
240 There were no single standard, so much care has been taken to try
241 to satisfy each possible scenario, despite the fact that each
242 application has its own conflicting standard.
244 The Parametric Software Equalizer (EQ) enables the use of
246 controls (bass and treble).
247 Commonly used for ear-candy or frequency compensation due to the vast
248 difference in hardware quality.
249 EQ is disabled by default, but can be enabled with the
253 Each device can optionally support more playback and recording channels
254 than physical hardware provides by using
259 options can be configured via the
261 interface but can only be manipulated while the device is inactive.
263 FreeBSD supports independent and individual volume controls for each active
264 application, without touching the master
267 This is sometimes referred to as Volume Per Channel (VPC).
270 feature is enabled by default.
272 The following loader tunables are used to set driver configuration at the
274 prompt before booting the kernel, or they can be stored in
275 .Pa /boot/loader.conf
276 in order to automatically set them before booting the kernel.
277 It is also possible to use
279 to change these tunables before loading the
282 The following tunables can not be changed during runtime using
284 .Bl -tag -width indent
285 .It Va hint.pcm.%d.eq
286 Set to 1 or 0 to explicitly enable (1) or disable (0) the equalizer.
287 Requires a driver reload if changed.
288 Enabling this will make bass and treble controls appear in mixer applications.
289 This tunable is undefined by default.
290 Equalizing is disabled by default.
291 .It Va hint.pcm.%d.vpc
292 Set to 1 or 0 to explicitly enable (1) or disable (0) the
295 This tunable is undefined by default.
297 is however enabled by default.
299 .Ss Runtime Configuration
300 There are a number of
302 variables available which can be modified during runtime.
303 These values can also be stored in
305 in order to automatically set them during the boot process.
307 are global settings and
310 .Bl -tag -width indent
311 .It Va hw.snd.compat_linux_mmap
315 The following values are supported (default is 0):
318 Force disabling/denying PROT_EXEC
322 Auto detect proc/ABI type, allow
324 for Linux applications, and deny for everything else.
326 Always allow PROT_EXEC page mappings.
328 .It Va hw.snd.default_auto
329 Automatically assign the default sound unit.
330 The following values are supported (default is 1):
333 Do not assign the default sound unit automatically.
335 Use the best available sound device based on playing and recording
336 capabilities of the device.
338 Use the most recently attached device.
340 .It Va hw.snd.default_unit
341 Default sound card for systems with multiple sound cards.
344 the default device for
346 Equivalent to a symlink from
349 .Pa /dev/dsp Ns Va ${hw.snd.default_unit} .
350 .It Va hw.snd.feeder_eq_exact_rate
351 Only certain rates are allowed for precise processing.
352 The default behavior is however to allow sloppy processing for all rates,
353 even the unsupported ones.
354 Enable to toggle this requirement and only allow processing for supported
356 .It Va hw.snd.feeder_rate_max
357 Maximum allowable sample rate.
358 .It Va hw.snd.feeder_rate_min
359 Minimum allowable sample rate.
360 .It Va hw.snd.feeder_rate_polyphase_max
361 Adjust to set the maximum number of allowed polyphase entries during the
362 process of building resampling filters.
363 Disabling polyphase resampling has the benefit of reducing memory usage, at
364 the expense of slower and lower quality conversion.
365 Only applicable when the SINC interpolator is used.
366 Default value is 183040.
367 Set to 0 to disable polyphase resampling.
368 .It Va hw.snd.feeder_rate_quality
369 Sample rate converter quality.
370 Default value is 1, linear interpolation.
371 Available options include:
374 Zero Order Hold, ZOH.
375 Very fast, but with poor quality.
377 Linear interpolation.
378 Fast, quality is subject to personal preference.
379 Technically the quality is poor however, due to the lack of anti-aliasing
382 Bandlimited SINC interpolator.
383 Implements polyphase banking to boost the conversion speed, at the cost of
384 memory usage, with multiple high quality polynomial interpolators to improve
385 the conversion accuracy.
386 100% fixed point, 64bit accumulator with 32bit coefficients and high precision
388 Quality values are 100dB stopband, 8 taps and 85% bandwidth.
390 Continuation of the bandlimited SINC interpolator, with 100dB stopband, 36
391 taps and 90% bandwidth as quality values.
393 Continuation of the bandlimited SINC interprolator, with 100dB stopband, 164
394 taps and 97% bandwidth as quality values.
396 .It Va hw.snd.feeder_rate_round
397 Sample rate rounding threshold, to avoid large prime division at the
399 All requested sample rates will be rounded to the nearest threshold value.
400 Possible values range between 0 (disabled) and 500.
402 .It Va hw.snd.latency
403 Configure the buffering latency.
404 Only affects applications that do not explicitly request
405 blocksize / fragments.
406 This tunable provides finer granularity than the
407 .Va hw.snd.latency_profile
409 Possible values range between 0 (lowest latency) and 10 (highest latency).
410 .It Va hw.snd.latency_profile
411 Define sets of buffering latency conversion tables for the
414 A value of 0 will use a low and aggressive latency profile which can result
415 in possible underruns if the application cannot keep up with a rapid irq
416 rate, especially during high workload.
417 The default value is 1, which is considered a moderate/safe latency profile.
418 .It Va hw.snd.maxautovchans
421 setting that only affects devices with at least one playback or recording channel available.
422 The sound system will dynamically create up to this many
429 Maximum value is 256.
430 .It Va hw.snd.report_soft_formats
431 Controls the internal format conversion if it is
432 available transparently to the application software.
433 When disabled or not available, the application will
434 only be able to select formats the device natively supports.
435 .It Va hw.snd.report_soft_matrix
436 Enable seamless channel matrixing even if the hardware does not support it.
437 Makes it possible to play multichannel streams even with a simple stereo
439 .It Va hw.snd.verbose
440 Level of verbosity for the
443 Higher values include more output and the highest level,
444 four, should be used when reporting problems.
445 Other options include:
448 Installed devices and their allocated bus resources.
450 The number of playback, record, virtual channels, and
453 Channel information per device including the channel's
454 current format, speed, and pseudo device statistics such as
455 buffer overruns and buffer underruns.
457 File names and versions of the currently loaded sound modules.
459 Various messages intended for debugging.
461 .It Va hw.snd.vpc_0db
465 Increase to give more room for attenuation control.
466 Decrease for more amplification, with the possible cost of sound clipping.
467 .It Va hw.snd.vpc_autoreset
468 When a channel is closed the channel volume will be reset to 0db.
469 This means that any changes to the volume will be lost.
470 Enabling this will preserve the volume, at the cost of possible confusion
471 when applications tries to re-open the same device.
472 .It Va hw.snd.vpc_mixer_bypass
473 The recommended way to use the
475 feature is to teach applications to use
478 .Dv SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
479 .Dv SNDCTL_DSP_SETRECVOL, SNDCTL_DSP_SETRECVOL.
480 This is however not always possible.
481 Enable this to allow applications to use their own existing mixer logic
482 to control their own channel volume.
483 .It Va hw.snd.vpc_reset
484 Enable to restore all channel volumes back to the default value of 0db.
485 .It Va dev.pcm.%d.bitperfect
486 Enable or disable bitperfect mode.
487 When enabled, channels will skip all dsp processing, such as channel
488 matrixing, rate converting and equalizing.
491 stream will be fed directly to the hardware.
494 are enabled, the bitperfect mode will use the
496 format/rate as the definitive format/rate target.
497 The recommended way to use bitperfect mode is to disable
499 and enable this sysctl.
501 .It Va dev.pcm.%d.[play|rec].vchans
502 The current number of
504 allocated per device.
505 This can be set to preallocate a certain number of
507 Setting this value to
512 .It Va dev.pcm.%d.[play|rec].vchanformat
516 All playback paths will be converted to this format before the mixing
518 By default only 2 channels are enabled.
519 Available options include:
524 Stereo, 2 channels (left, right).
526 3 channels (left, right, LFE).
528 3 channels (left, right, rear center).
530 Quadraphonic, 4 channels (front/rear left and right).
532 5 channels (4.0 + LFE).
534 5 channels (4.0 + center).
536 6 channels (4.0 + center + LFE).
538 6 channels (4.0 + front/rear center).
540 7 channels (6.0 + LFE).
542 8 channels (4.0 + center + LFE + left and right side).
544 .It Va dev.pcm.%d.[play|rec].vchanmode
546 format/rate selection.
547 Available options include:
550 Channel mixing is done using fixed format/rate.
551 Advanced operations such as digital passthrough will not work.
552 Can be considered as a
555 This is the default mode for hardware channels which lack support for digital
558 Channel mixing is done using fixed format/rate, but advanced operations such
559 as digital passthrough also work.
560 All channels will produce sound as usual until a digital format playback is
562 When this happens all other channels will be muted and the latest incoming
563 digital format will be allowed to pass through undisturbed.
564 Multiple concurrent digital streams are supported, but the latest stream will
565 take precedence and mute all other streams.
569 mode, but is a bit smarter, especially for
572 channels with different format/rate.
573 When a new channel is about to start, the entire list of virtual channels will
574 be scanned, and the channel with the best format/rate (usually the
575 highest/biggest) will be selected.
576 This ensures that mixing quality depends on the best channel.
577 The downside is that the hardware DMA mode needs to be restarted, which may
578 cause annoying pops or clicks.
580 .It Va dev.pcm.%d.[play|rec].vchanrate
581 Sample rate speed for
584 All playback paths will be converted to this sample rate before the mixing
586 .It Va dev.pcm.%d.polling
587 Experimental polling mode support where the driver operates by querying the
588 device state on each tick using a
591 Disabled by default and currently only available for a few device drivers.
593 .Ss Recording Channels
594 On devices that have more than one recording source (ie: mic and line),
595 there is a corresponding
600 utility can be used to start and stop recording from an specific device.
602 Channel statistics are only kept while the device is open.
603 So with situations involving overruns and underruns, consider the output
604 while the errant application is open and running.
606 The driver supports most of the
609 functions, and most applications work unmodified.
610 A few differences exist, while memory mapped playback is
611 supported natively and in
613 emulation, memory mapped recording is
617 As a consequence, some applications may need to be recompiled
618 with a slightly modified audio module.
621 for a complete list of the supported
627 drivers may create the following
630 .Bl -tag -width ".Pa /dev/audio%d.%d" -compact
631 .It Pa /dev/audio%d.%d
632 Sparc-compatible audio device.
634 Digitized voice device.
635 .It Pa /dev/dspW%d.%d
638 but 16 bits per sample.
639 .It Pa /dev/dsp%d.p%d
641 .It Pa /dev/dsp%d.r%d
643 .It Pa /dev/dsp%d.vp%d
644 Virtual playback channel.
645 .It Pa /dev/dsp%d.vr%d
646 Virtual recording channel.
650 status, including all channels and drivers.
653 The first number in the device node
654 represents the unit number of the
662 Additional messages are sometimes recorded when the
663 device is probed and attached, these messages can be viewed with the
667 The above device nodes are only created on demand through the dynamic
670 Users are strongly discouraged to access them directly.
671 For specific sound card access, please instead use
676 Use the sound metadriver to load all
678 bridge device drivers at once
679 (for example if it is unclear which the correct driver to use is):
681 .Dl kldload snd_driver
683 Load a specific bridge device driver, in this case the Intel
684 High Definition Audio driver:
688 Check the status of all detected
694 Change the default sound device, in this case to the second device.
695 This is handy if there are multiple
699 .Dl sysctl hw.snd.default_unit=1
702 .It pcm%d:play:%d:dsp%d.p%d: play interrupt timeout, channel dead
703 The hardware does not generate interrupts to serve incoming (play)
704 or outgoing (record) data.
705 .It unsupported subdevice XX
706 A device node is not created properly.
740 .Xr snd_via82c686 4 ,
750 .%T "Cookbook formulae for audio EQ biquad filter coefficients, by Robert Bristow-Johnson"
751 .%U "http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt"
754 .%T "Julius O'Smith's Digital Audio Resampling"
755 .%U "http://ccrma.stanford.edu/~jos/resample/"
758 .%T "Polynomial Interpolators for High-Quality Resampling of Oversampled Audio, by Olli Niemitalo"
759 .%U "http://www.student.oulu.fi/~oniemita/dsp/deip.pdf"
763 .%U "http://www.opensound.com/pguide/oss.pdf"
768 device driver first appeared in
779 The API evolved from the VOXWARE
780 standard which later became OSS standard.
783 .An Luigi Rizzo Aq luigi@iet.unipi.it
786 device driver and this manual page.
787 .An Cameron Grant Aq gandalf@vilnya.demon.co.uk
788 later revised the device driver for
790 .An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
791 revised this manual page.
792 It was then rewritten for
795 Some features of your sound card (e.g., global volume control) might not
796 be supported on all devices.