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)
94 .Xr snd_davbus 4 (enabled by default on powerpc)
106 .Xr snd_es137x 4 (enabled by default on amd64, i386, sparc64)
114 .Xr snd_hda 4 (enabled by default on amd64, i386)
116 .Xr snd_ich 4 (enabled by default on amd64, i386)
136 .Xr snd_t4dwave 4 (enabled by default on sparc64)
138 .Xr snd_uaudio 4 (enabled by default on amd64, i386, powerpc, sparc64)
140 .Xr snd_via8233 4 (enabled by default on amd64, i386)
147 Refer to the manual page for each bridge device driver for driver specific
148 settings and information.
152 cards, the driver looks for
158 These values can be overridden in
159 .Pa /boot/device.hints .
160 Non-PnP sound cards require the following lines in
162 .Bd -literal -offset indent
166 hint.pcm.0.flags="0x0"
169 Apart from the usual parameters, the flags field is used to specify
172 channel (generally used for capture in full duplex cards).
173 Flags are set to 0 for cards not using a secondary
175 channel, or to 0x10 + C to specify channel C.
177 In general, the module
186 or from the command line using the
189 Options which can be specified in
190 .Pa /boot/loader.conf
192 .Bl -tag -width ".Va snd_driver_load" -offset indent
193 .It Va snd_driver_load
197 this option loads all available drivers.
202 only the Intel High Definition Audio bridge device driver and dependent
203 modules will be loaded.
208 load driver for card/chipset foo.
211 To define default values for the different mixer channels,
212 set the channel to the preferred value using hints, e.g.:
213 .Va hint.pcm.0.line Ns = Ns Qq Li 0 .
214 This will mute the input channel per default.
215 .Ss Multichannel Audio
216 Multichannel audio, popularly referred to as
218 is supported and enabled by default.
219 The FreeBSD multichannel matrix processor supports up to 18 interleaved
220 channels, but the limit is currently set to 8 channels (as commonly used
221 for 7.1 surround sound).
222 The internal matrix mapping can handle reduction, expansion or
223 re-routing of channels.
224 This provides a base interface for related multichannel
227 Multichannel audio works both with and without
230 Most bridge device drivers are still missing multichannel matrixing
231 support, but in most cases this should be trivial to implement.
233 .Va dev.pcm.%d.[play|rec].vchanformat
235 to adjust the number of channels used.
236 The current multichannel interleaved structure and arrangement was
237 implemented by inspecting various popular UNIX applications.
238 There were no single standard, so much care has been taken to try
239 to satisfy each possible scenario, despite the fact that each
240 application has its own conflicting standard.
242 The Parametric Software Equalizer (EQ) enables the use of
244 controls (bass and treble).
245 Commonly used for ear-candy or frequency compensation due to the vast
246 difference in hardware quality.
247 EQ is disabled by default, but can be enabled with the
251 Each device can optionally support more playback and recording channels
252 than physical hardware provides by using
257 options can be configured via the
259 interface but can only be manipulated while the device is inactive.
261 FreeBSD supports independent and individual volume controls for each active
262 application, without touching the master
265 This is sometimes referred to as Volume Per Channel (VPC).
268 feature is enabled by default.
270 The following loader tunables are used to set driver configuration at the
272 prompt before booting the kernel, or they can be stored in
273 .Pa /boot/loader.conf
274 in order to automatically set them before booting the kernel.
275 It is also possible to use
277 to change these tunables before loading the
280 The following tunables can not be changed during runtime using
282 .Bl -tag -width indent
283 .It Va hint.pcm.%d.eq
284 Set to 1 or 0 to explicitly enable (1) or disable (0) the equalizer.
285 Requires a driver reload if changed.
286 Enabling this will make bass and treble controls appear in mixer applications.
287 This tunable is undefined by default.
288 Equalizing is disabled by default.
289 .It Va hint.pcm.%d.vpc
290 Set to 1 or 0 to explicitly enable (1) or disable (0) the
293 This tunable is undefined by default.
295 is however enabled by default.
297 .Ss Runtime Configuration
298 There are a number of
300 variables available which can be modified during runtime.
301 These values can also be stored in
303 in order to automatically set them during the boot process.
305 are global settings and
308 .Bl -tag -width indent
309 .It Va hw.snd.compat_linux_mmap
313 The following values are supported (default is 0):
316 Force disabling/denying PROT_EXEC
320 Auto detect proc/ABI type, allow
322 for Linux applications, and deny for everything else.
324 Always allow PROT_EXEC page mappings.
326 .It Va hw.snd.default_auto
327 Automatically assign the default sound unit.
328 The following values are supported (default is 1):
331 Do not assign the default sound unit automatically.
333 Use the best available sound device based on playing and recording
334 capabilities of the device.
336 Use the most recently attached device.
338 .It Va hw.snd.default_unit
339 Default sound card for systems with multiple sound cards.
342 the default device for
344 Equivalent to a symlink from
347 .Pa /dev/dsp Ns Va ${hw.snd.default_unit} .
348 .It Va hw.snd.feeder_eq_exact_rate
349 Only certain rates are allowed for precise processing.
350 The default behavior is however to allow sloppy processing for all rates,
351 even the unsupported ones.
352 Enable to toggle this requirement and only allow processing for supported
354 .It Va hw.snd.feeder_rate_max
355 Maximum allowable sample rate.
356 .It Va hw.snd.feeder_rate_min
357 Minimum allowable sample rate.
358 .It Va hw.snd.feeder_rate_polyphase_max
359 Adjust to set the maximum number of allowed polyphase entries during the
360 process of building resampling filters.
361 Disabling polyphase resampling has the benefit of reducing memory usage, at
362 the expense of slower and lower quality conversion.
363 Only applicable when the SINC interpolator is used.
364 Default value is 183040.
365 Set to 0 to disable polyphase resampling.
366 .It Va hw.snd.feeder_rate_quality
367 Sample rate converter quality.
368 Default value is 1, linear interpolation.
369 Available options include:
372 Zero Order Hold, ZOH.
373 Very fast, but with poor quality.
375 Linear interpolation.
376 Fast, quality is subject to personal preference.
377 Technically the quality is poor however, due to the lack of anti-aliasing
380 Bandlimited SINC interpolator.
381 Implements polyphase banking to boost the conversion speed, at the cost of
382 memory usage, with multiple high quality polynomial interpolators to improve
383 the conversion accuracy.
384 100% fixed point, 64bit accumulator with 32bit coefficients and high precision
386 Quality values are 100dB stopband, 8 taps and 85% bandwidth.
388 Continuation of the bandlimited SINC interpolator, with 100dB stopband, 36
389 taps and 90% bandwidth as quality values.
391 Continuation of the bandlimited SINC inteprolator, with 100dB stopband, 164
392 taps and 97% bandwidth as quality values.
394 .It Va hw.snd.feeder_rate_round
395 Sample rate rounding threshold, to avoid large prime division at the
397 All requested sample rates will be rounded to the nearest threshold value.
398 Possible values range between 0 (disabled) and 500.
400 .It Va hw.snd.latency
401 Configure the buffering latency.
402 Only affects applications that do not explicitly request
403 blocksize / fragments.
404 This tunable provides finer granularity than the
405 .Va hw.snd.latency_profile
407 Possible values range between 0 (lowest latency) and 10 (highest latency).
408 .It Va hw.snd.latency_profile
409 Define sets of buffering latency conversion tables for the
412 A value of 0 will use a low and aggressive latency profile which can result
413 in possible underruns if the application cannot keep up with a rapid irq
414 rate, especially during high workload.
415 The default value is 1, which is considered a moderate/safe latency profile.
416 .It Va hw.snd.maxautovchans
419 setting that only affects devices with at least one playback or recording channel available.
420 The sound system will dynamically create up to this many
427 Maximum value is 256.
428 .It Va hw.snd.report_soft_formats
429 Controls the internal format conversion if it is
430 available transparently to the application software.
431 When disabled or not available, the application will
432 only be able to select formats the device natively supports.
433 .It Va hw.snd.report_soft_matrix
434 Enable seamless channel matrixing even if the hardware does not support it.
435 Makes it possible to play multichannel streams even with a simple stereo
437 .It Va hw.snd.verbose
438 Level of verbosity for the
441 Higher values include more output and the highest level,
442 four, should be used when reporting problems.
443 Other options include:
446 Installed devices and their allocated bus resources.
448 The number of playback, record, virtual channels, and
451 Channel information per device including the channel's
452 current format, speed, and pseudo device statistics such as
453 buffer overruns and buffer underruns.
455 File names and versions of the currently loaded sound modules.
457 Various messages intended for debugging.
459 .It Va hw.snd.vpc_0db
463 Increase to give more room for attenuation control.
464 Decrease for more amplification, with the possible cost of sound clipping.
465 .It Va hw.snd.vpc_autoreset
466 When a channel is closed the channel volume will be reset to 0db.
467 This means that any changes to the volume will be lost.
468 Enabling this will preserve the volume, at the cost of possible confusion
469 when applications tries to re-open the same device.
470 .It Va hw.snd.vpc_mixer_bypass
471 The recommended way to use the
473 feature is to teach applications to use
476 .Dv SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
477 .Dv SNDCTL_DSP_SETRECVOL, SNDCTL_DSP_SETRECVOL.
478 This is however not always possible.
479 Enable this to allow applications to use their own existing mixer logic
480 to control their own channel volume.
481 .It Va hw.snd.vpc_reset
482 Enable to restore all channel volumes back to the default value of 0db.
483 .It Va dev.pcm.%d.bitperfect
484 Enable or disable bitperfect mode.
485 When enabled, channels will skip all dsp processing, such as channel
486 matrixing, rate converting and equalizing.
489 stream will be fed directly to the hardware.
492 are enabled, the bitperfect mode will use the
494 format/rate as the definitive format/rate target.
495 The recommended way to use bitperfect mode is to disable
497 and enable this sysctl.
499 .It Va dev.pcm.%d.[play|rec].vchans
500 The current number of
502 allocated per device.
503 This can be set to preallocate a certain number of
505 Setting this value to
510 .It Va dev.pcm.%d.[play|rec].vchanformat
514 All playback paths will be converted to this format before the mixing
516 By default only 2 channels are enabled.
517 Available options include:
522 Stereo, 2 channels (left, right).
524 3 channels (left, right, LFE).
526 3 channels (left, right, rear center).
528 Quadraphonic, 4 channels (front/rear left and right).
530 5 channels (4.0 + LFE).
532 5 channels (4.0 + center).
534 6 channels (4.0 + center + LFE).
536 6 channels (4.0 + front/rear center).
538 7 channels (6.0 + LFE).
540 8 channels (4.0 + center + LFE + left and right side).
542 .It Va dev.pcm.%d.[play|rec].vchanmode
544 format/rate selection.
545 Available options include:
548 Channel mixing is done using fixed format/rate.
549 Advanced operations such as digital passthrough will not work.
550 Can be considered as a
553 This is the default mode for hardware channels which lack support for digital
556 Channel mixing is done using fixed format/rate, but advanced operations such
557 as digital passthrough also work.
558 All channels will produce sound as usual until a digital format playback is
560 When this happens all other channels will be muted and the latest incoming
561 digital format will be allowed to pass through undisturbed.
562 Multiple concurrent digital streams are supported, but the latest stream will
563 take precedence and mute all other streams.
567 mode, but is a bit smarter, especially for
570 channels with different format/rate.
571 When a new channel is about to start, the entire list of virtual channels will
572 be scanned, and the channel with the best format/rate (usually the
573 highest/biggest) will be selected.
574 This ensures that mixing quality depends on the best channel.
575 The downside is that the hardware DMA mode needs to be restarted, which may
576 cause annoying pops or clicks.
578 .It Va dev.pcm.%d.[play|rec].vchanrate
579 Sample rate speed for
582 All playback paths will be converted to this sample rate before the mixing
584 .It Va dev.pcm.%d.polling
585 Experimental polling mode support where the driver operates by querying the
586 device state on each tick using a
589 Disabled by default and currently only available for a few device drivers.
591 .Ss Recording Channels
592 On devices that have more than one recording source (ie: mic and line),
593 there is a corresponding
598 utility can be used to start and stop recording from an specific device.
600 Channel statistics are only kept while the device is open.
601 So with situations involving overruns and underruns, consider the output
602 while the errant application is open and running.
604 The driver supports most of the
607 functions, and most applications work unmodified.
608 A few differences exist, while memory mapped playback is
609 supported natively and in
611 emulation, memory mapped recording is
615 As a consequence, some applications may need to be recompiled
616 with a slightly modified audio module.
619 for a complete list of the supported
625 drivers may create the following
628 .Bl -tag -width ".Pa /dev/audio%d.%d" -compact
629 .It Pa /dev/audio%d.%d
630 Sparc-compatible audio device.
632 Digitized voice device.
633 .It Pa /dev/dspW%d.%d
636 but 16 bits per sample.
637 .It Pa /dev/dsp%d.p%d
639 .It Pa /dev/dsp%d.r%d
641 .It Pa /dev/dsp%d.vp%d
642 Virtual playback channel.
643 .It Pa /dev/dsp%d.vr%d
644 Virtual recording channel.
648 status, including all channels and drivers.
651 The first number in the device node
652 represents the unit number of the
660 Additional messages are sometimes recorded when the
661 device is probed and attached, these messages can be viewed with the
665 The above device nodes are only created on demand through the dynamic
668 Users are strongly discouraged to access them directly.
669 For specific sound card access, please instead use
674 Use the sound metadriver to load all
676 bridge device drivers at once
677 (for example if it is unclear which the correct driver to use is):
679 .Dl kldload snd_driver
681 Load a specific bridge device driver, in this case the Intel
682 High Definition Audio driver:
686 Check the status of all detected
692 Change the default sound device, in this case to the second device.
693 This is handy if there are multiple
697 .Dl sysctl hw.snd.default_unit=1
700 .It pcm%d:play:%d:dsp%d.p%d: play interrupt timeout, channel dead
701 The hardware does not generate interrupts to serve incoming (play)
702 or outgoing (record) data.
703 .It unsupported subdevice XX
704 A device node is not created properly.
737 .Xr snd_via82c686 4 ,
747 .%T "Cookbook formulae for audio EQ biquad filter coefficients, by Robert Bristow-Johnson"
748 .%U "http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt"
751 .%T "Julius O'Smith's Digital Audio Resampling"
752 .%U "http://ccrma.stanford.edu/~jos/resample/"
755 .%T "Polynomial Interpolators for High-Quality Resampling of Oversampled Audio, by Olli Niemitalo"
756 .%U "http://www.student.oulu.fi/~oniemita/dsp/deip.pdf"
760 .%U "http://www.opensound.com/pguide/oss.pdf"
765 device driver first appeared in
776 The API evolved from the VOXWARE
777 standard which later became OSS standard.
780 .An Luigi Rizzo Aq luigi@iet.unipi.it
783 device driver and this manual page.
784 .An Cameron Grant Aq gandalf@vilnya.demon.co.uk
785 later revised the device driver for
787 .An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
788 revised this manual page.
789 It was then rewritten for
792 Some features of your sound card (e.g., global volume control) might not
793 be supported on all devices.