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
26 .\" $FreeBSD: head/share/man/man4/pcm.4 267938 2014-06-26 21:46:14Z bapt $
34 .Nd DragonFly PCM audio device infrastructure
36 To compile this driver into the kernel, place the following line in your
37 kernel configuration file:
38 .Bd -ragged -offset indent
44 driver is the main component of the
47 It works in conjunction with a bridge device driver on supported devices
48 and provides PCM audio record and playback once it attaches.
49 Each bridge device driver supports a specific set of audio chipsets and
50 needs to be enabled together with the
54 Some of the main features of the
56 driver are: multichannel audio, per-application
57 volume control, dynamic mixing through virtual sound channels, true full
58 duplex operation, bit perfect audio, rate conversion and low latency
63 driver is enabled by default, along with several bridge device drivers.
64 Those not enabled by default can be loaded during runtime with
68 The following bridge device drivers are available:
117 Refer to the manual page for each bridge device driver for driver specific
118 settings and information.
120 In general, the module
129 or from the command line using the
132 Options which can be specified in
133 .Pa /boot/loader.conf
135 .Bl -tag -width ".Va snd_driver_load" -offset indent
136 .It Va snd_driver_load
140 this option loads all available drivers.
145 only the Intel High Definition Audio bridge device driver and dependent
146 modules will be loaded.
151 load driver for card/chipset foo.
154 To define default values for the different mixer channels,
155 set the channel to the preferred value using hints, e.g.:
156 .Va hint.pcm.0.line Ns = Ns Qq Li 0 .
157 This will mute the input channel per default.
158 .Ss Multichannel Audio
159 Multichannel audio, popularly referred to as
161 is supported and enabled by default.
164 multichannel matrix processor supports up to 18 interleaved
165 channels, but the limit is currently set to 8 channels (as commonly used
166 for 7.1 surround sound).
167 The internal matrix mapping can handle reduction, expansion or
168 re-routing of channels.
169 This provides a base interface for related multichannel
172 Multichannel audio works both with and without
175 Most bridge device drivers are still missing multichannel matrixing
176 support, but in most cases this should be trivial to implement.
178 .Va dev.pcm.%d.[play|rec].vchanformat
180 to adjust the number of channels used.
181 The current multichannel interleaved structure and arrangement was
182 implemented by inspecting various popular UNIX applications.
183 There were no single standard, so much care has been taken to try
184 to satisfy each possible scenario, despite the fact that each
185 application has its own conflicting standard.
187 The Parametric Software Equalizer (EQ) enables the use of
189 controls (bass and treble).
190 Commonly used for ear-candy or frequency compensation due to the vast
191 difference in hardware quality.
192 EQ is disabled by default, but can be enabled with the
196 Each device can optionally support more playback and recording channels
197 than physical hardware provides by using
202 options can be configured via the
204 interface but can only be manipulated while the device is inactive.
207 supports independent and individual volume controls for each active
208 application, without touching the master
211 This is sometimes referred to as Volume Per Channel (VPC).
214 feature is enabled by default.
216 The following loader tunables are used to set driver configuration at the
218 prompt before booting the kernel, or they can be stored in
219 .Pa /boot/loader.conf
220 in order to automatically set them before booting the kernel.
221 .\"It is also possible to use
223 .\"to change these tunables before loading the
226 The following tunables can not be changed during runtime using
228 .Bl -tag -width indent
229 .It Va hint.pcm.%d.eq
230 Set to 1 or 0 to explicitly enable (1) or disable (0) the equalizer.
231 Requires a driver reload if changed.
232 Enabling this will make bass and treble controls appear in mixer applications.
233 This tunable is undefined by default.
234 Equalizing is disabled by default.
235 .It Va hint.pcm.%d.vpc
236 Set to 1 or 0 to explicitly enable (1) or disable (0) the
239 This tunable is undefined by default.
241 is however enabled by default.
243 .Ss Runtime Configuration
244 There are a number of
246 variables available which can be modified during runtime.
247 These values can also be stored in
249 in order to automatically set them during the boot process.
251 are global settings and
254 .Bl -tag -width indent
255 .It Va hw.snd.compat_linux_mmap
259 The following values are supported (default is 0):
262 Force disabling/denying PROT_EXEC
266 Auto detect proc/ABI type, allow
268 for Linux applications, and deny for everything else.
270 Always allow PROT_EXEC page mappings.
272 .It Va hw.snd.default_auto
273 Automatically assign the default sound unit.
274 The following values are supported (default is 1):
277 Do not assign the default sound unit automatically.
279 Use the best available sound device based on playing and recording
280 capabilities of the device.
282 Use the most recently attached device.
284 .It Va hw.snd.default_unit
285 Default sound card for systems with multiple sound cards.
288 the default device for
290 Equivalent to a symlink from
293 .Pa /dev/dsp Ns Va ${hw.snd.default_unit} .
294 .It Va hw.snd.feeder_eq_exact_rate
295 Only certain rates are allowed for precise processing.
296 The default behavior is however to allow sloppy processing for all rates,
297 even the unsupported ones.
298 Enable to toggle this requirement and only allow processing for supported
300 .It Va hw.snd.feeder_rate_max
301 Maximum allowable sample rate.
302 .It Va hw.snd.feeder_rate_min
303 Minimum allowable sample rate.
304 .It Va hw.snd.feeder_rate_polyphase_max
305 Adjust to set the maximum number of allowed polyphase entries during the
306 process of building resampling filters.
307 Disabling polyphase resampling has the benefit of reducing memory usage, at
308 the expense of slower and lower quality conversion.
309 Only applicable when the SINC interpolator is used.
310 Default value is 183040.
311 Set to 0 to disable polyphase resampling.
312 .It Va hw.snd.feeder_rate_quality
313 Sample rate converter quality.
314 Default value is 1, linear interpolation.
315 Available options include:
318 Zero Order Hold, ZOH.
319 Very fast, but with poor quality.
321 Linear interpolation.
322 Fast, quality is subject to personal preference.
323 Technically the quality is poor however, due to the lack of anti-aliasing
326 Bandlimited SINC interpolator.
327 Implements polyphase banking to boost the conversion speed, at the cost of
328 memory usage, with multiple high quality polynomial interpolators to improve
329 the conversion accuracy.
330 100% fixed point, 64bit accumulator with 32bit coefficients and high precision
332 Quality values are 100dB stopband, 8 taps and 85% bandwidth.
334 Continuation of the bandlimited SINC interpolator, with 100dB stopband, 36
335 taps and 90% bandwidth as quality values.
337 Continuation of the bandlimited SINC interprolator, with 100dB stopband, 164
338 taps and 97% bandwidth as quality values.
340 .It Va hw.snd.feeder_rate_round
341 Sample rate rounding threshold, to avoid large prime division at the
343 All requested sample rates will be rounded to the nearest threshold value.
344 Possible values range between 0 (disabled) and 500.
346 .It Va hw.snd.latency
347 Configure the buffering latency.
348 Only affects applications that do not explicitly request
349 blocksize / fragments.
350 This tunable provides finer granularity than the
351 .Va hw.snd.latency_profile
353 Possible values range between 0 (lowest latency) and 10 (highest latency).
354 .It Va hw.snd.latency_profile
355 Define sets of buffering latency conversion tables for the
358 A value of 0 will use a low and aggressive latency profile which can result
359 in possible underruns if the application cannot keep up with a rapid irq
360 rate, especially during high workload.
361 The default value is 1, which is considered a moderate/safe latency profile.
362 .It Va hw.snd.maxautovchans
365 setting that only affects devices with at least one playback or recording channel available.
366 The sound system will dynamically create up to this many
373 Maximum value is 256.
374 .It Va hw.snd.report_soft_formats
375 Controls the internal format conversion if it is
376 available transparently to the application software.
377 When disabled or not available, the application will
378 only be able to select formats the device natively supports.
379 .It Va hw.snd.report_soft_matrix
380 Enable seamless channel matrixing even if the hardware does not support it.
381 Makes it possible to play multichannel streams even with a simple stereo
383 .It Va hw.snd.verbose
384 Level of verbosity for the
387 Higher values include more output and the highest level,
388 four, should be used when reporting problems.
389 Other options include:
392 Installed devices and their allocated bus resources.
394 The number of playback, record, virtual channels, and
397 Channel information per device including the channel's
398 current format, speed, and pseudo device statistics such as
399 buffer overruns and buffer underruns.
401 File names and versions of the currently loaded sound modules.
403 Various messages intended for debugging.
405 .It Va hw.snd.vpc_0db
409 Increase to give more room for attenuation control.
410 Decrease for more amplification, with the possible cost of sound clipping.
411 .It Va hw.snd.vpc_autoreset
412 When a channel is closed the channel volume will be reset to 0db.
413 This means that any changes to the volume will be lost.
414 Enabling this will preserve the volume, at the cost of possible confusion
415 when applications tries to re-open the same device.
416 .It Va hw.snd.vpc_mixer_bypass
417 The recommended way to use the
419 feature is to teach applications to use
422 .Dv SNDCTL_DSP_GETPLAYVOL , SNDCTL_DSP_SETPLAYVOL ,
423 .Dv SNDCTL_DSP_SETRECVOL , SNDCTL_DSP_SETRECVOL .
424 This is however not always possible.
425 Enable this to allow applications to use their own existing mixer logic
426 to control their own channel volume.
427 .It Va hw.snd.vpc_reset
428 Enable to restore all channel volumes back to the default value of 0db.
429 .It Va dev.pcm.%d.bitperfect
430 Enable or disable bitperfect mode.
431 When enabled, channels will skip all dsp processing, such as channel
432 matrixing, rate converting and equalizing.
435 stream will be fed directly to the hardware.
438 are enabled, the bitperfect mode will use the
440 format/rate as the definitive format/rate target.
441 The recommended way to use bitperfect mode is to disable
443 and enable this sysctl.
445 .It Va dev.pcm.%d.[play|rec].vchans
446 The current number of
448 allocated per device.
449 This can be set to preallocate a certain number of
451 Setting this value to
456 .It Va dev.pcm.%d.[play|rec].vchanformat
460 All playback paths will be converted to this format before the mixing
462 By default only 2 channels are enabled.
463 Available options include:
468 Stereo, 2 channels (left, right).
470 3 channels (left, right, LFE).
472 3 channels (left, right, rear center).
474 Quadraphonic, 4 channels (front/rear left and right).
476 5 channels (4.0 + LFE).
478 5 channels (4.0 + center).
480 6 channels (4.0 + center + LFE).
482 6 channels (4.0 + front/rear center).
484 7 channels (6.0 + LFE).
486 8 channels (4.0 + center + LFE + left and right side).
488 .It Va dev.pcm.%d.[play|rec].vchanmode
490 format/rate selection.
491 Available options include:
494 Channel mixing is done using fixed format/rate.
495 Advanced operations such as digital passthrough will not work.
496 Can be considered as a
499 This is the default mode for hardware channels which lack support for digital
502 Channel mixing is done using fixed format/rate, but advanced operations such
503 as digital passthrough also work.
504 All channels will produce sound as usual until a digital format playback is
506 When this happens all other channels will be muted and the latest incoming
507 digital format will be allowed to pass through undisturbed.
508 Multiple concurrent digital streams are supported, but the latest stream will
509 take precedence and mute all other streams.
513 mode, but is a bit smarter, especially for
516 channels with different format/rate.
517 When a new channel is about to start, the entire list of virtual channels will
518 be scanned, and the channel with the best format/rate (usually the
519 highest/biggest) will be selected.
520 This ensures that mixing quality depends on the best channel.
521 The downside is that the hardware DMA mode needs to be restarted, which may
522 cause annoying pops or clicks.
524 .It Va dev.pcm.%d.[play|rec].vchanrate
525 Sample rate speed for
528 All playback paths will be converted to this sample rate before the mixing
530 .It Va dev.pcm.%d.polling
531 Experimental polling mode support where the driver operates by querying the
532 device state on each tick using a
535 Disabled by default and currently only available for a few device drivers.
537 .Ss Recording Channels
538 On devices that have more than one recording source (ie: mic and line),
539 there is a corresponding
544 utility can be used to start and stop recording from a specific device.
546 Channel statistics are only kept while the device is open.
547 So with situations involving overruns and underruns, consider the output
548 while the errant application is open and running.
550 The driver supports most of the
553 functions, and most applications work unmodified.
554 A few differences exist, while memory mapped playback is
555 supported natively, memory mapped recording is not due to
558 As a consequence, some applications may need to be recompiled
559 with a slightly modified audio module.
562 for a complete list of the supported
568 drivers may create the following
571 .Bl -tag -width ".Pa /dev/audio%d.%d" -compact
572 .It Pa /dev/audio%d.%d
573 Sparc-compatible audio device.
575 Digitized voice device.
576 .It Pa /dev/dspW%d.%d
579 but 16 bits per sample.
580 .It Pa /dev/dsp%d.p%d
582 .It Pa /dev/dsp%d.r%d
584 .It Pa /dev/dsp%d.vp%d
585 Virtual playback channel.
586 .It Pa /dev/dsp%d.vr%d
587 Virtual recording channel.
591 status, including all channels and drivers.
594 The first number in the device node
595 represents the unit number of the
603 Additional messages are sometimes recorded when the
604 device is probed and attached, these messages can be viewed with the
608 The above device nodes are only created on demand through the dynamic
611 Users are strongly discouraged to access them directly.
612 For specific sound card access, please instead use
617 Use the sound metadriver to load all
619 bridge device drivers at once
620 (for example if it is unclear which the correct driver to use is):
622 .Dl kldload snd_driver
624 Load a specific bridge device driver, in this case the Intel
625 High Definition Audio driver:
629 Check the status of all detected
635 Change the default sound device, in this case to the second device.
636 This is handy if there are multiple
640 .Dl sysctl hw.snd.default_unit=1
643 .It pcm%d:play:%d:dsp%d.p%d: play interrupt timeout, channel dead
644 The hardware does not generate interrupts to serve incoming (play)
645 or outgoing (record) data.
646 .It unsupported subdevice XX
647 A device node is not created properly.
670 .Xr snd_via82c686 4 ,
679 .%T "Cookbook formulae for audio EQ biquad filter coefficients, by Robert Bristow-Johnson"
680 .%O "http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt"
683 .%T "Julius O'Smith's Digital Audio Resampling"
684 .%O "http://ccrma.stanford.edu/~jos/resample/"
687 .%T "Polynomial Interpolators for High-Quality Resampling of Oversampled Audio, by Olli Niemitalo"
688 .%O "http://www.student.oulu.fi/~oniemita/dsp/deip.pdf"
692 .%O "http://www.opensound.com/pguide/oss.pdf"
697 device driver first appeared in
708 The API evolved from the VOXWARE
709 standard which later became OSS standard.
712 .An Luigi Rizzo Aq Mt luigi@iet.unipi.it
715 device driver and this manual page.
716 .An Cameron Grant Aq Mt gandalf@vilnya.demon.co.uk
717 later revised the device driver for
719 .An Seigo Tanimura Aq Mt tanimura@r.dl.itc.u-tokyo.ac.jp
720 revised this manual page.
721 It was then rewritten for
724 Some features of your sound card (e.g., global volume control) might not
725 be supported on all devices.