xref: /freebsd/share/man/man4/pcm.4 (revision 195ebc7e9e4b129de810833791a19dfb4349d6a9)
1.\"
2.\" Copyright (c) 1998, Luigi Rizzo
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
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.
13.\"
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
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd June 1, 2009
29.Dt SOUND 4
30.Os
31.Sh NAME
32.Nm sound ,
33.Nm pcm ,
34.Nm snd
35.Nd
36.Fx
37PCM audio device infrastructure
38.Sh SYNOPSIS
39To compile this driver into the kernel, place the following line in your
40kernel configuration file:
41.Bd -ragged -offset indent
42.Cd "device sound"
43.Ed
44.Pp
45Non-PnP sound cards require the following lines in
46.Xr device.hints 5 :
47.Bd -literal -offset indent
48hint.pcm.0.at="isa"
49hint.pcm.0.irq="5"
50hint.pcm.0.drq="1"
51hint.pcm.0.flags="0x0"
52.Ed
53.Sh DESCRIPTION
54The
55.Nm
56driver provides support for
57.Tn PCM
58audio play and capture.
59This driver also supports various
60.Tn PCI ,
61.Tn ISA ,
62.Tn WSS/MSS
63compatible
64sound cards, AC97 mixer and High Definition Audio.
65Once the
66.Nm
67driver attaches, supported devices provide audio record and
68playback channels.
69The
70.Fx
71sound system provides dynamic mixing
72.Dq VCHAN
73and rate conversion
74.Dq soft formats .
75True full duplex operation is available on most sound cards.
76.Pp
77If the sound card is supported by a bridge driver, the
78.Nm
79driver works in conjunction with the bridge driver.
80.Pp
81Apart from the usual parameters, the flags field is used to specify
82the secondary
83.Tn DMA
84channel (generally used for capture in full duplex cards).
85Flags are set to 0 for cards not using a secondary
86.Tn DMA
87channel, or to 0x10 + C to specify channel C.
88.Pp
89The driver does its best to recognize the installed hardware and drive
90it correctly so the user is not required to add several lines in
91.Pa /boot/device.hints .
92For
93.Tn PCI
94and
95.Tn ISA
96.Tn PnP
97cards this is actually easy
98since they identify themselves.
99For legacy
100.Tn ISA
101cards, the driver looks for
102.Tn MSS
103cards at addresses 0x530 and 0x604 (unless overridden
104in
105.Pa /boot/device.hints ) .
106.Ss Boot Variables
107In general, the module
108.Pa snd_foo
109corresponds to
110.Cd "device snd_foo"
111and can be
112loaded by the boot
113.Xr loader 8
114via
115.Xr loader.conf 5
116or from the command line using the
117.Xr kldload 8
118utility.
119Options which can be specified in
120.Pa /boot/loader.conf
121include:
122.Bl -tag -width ".Va snd_emu10k1_load" -offset indent
123.It Va snd_driver_load
124.Pq Dq Li NO
125If set to
126.Dq Li YES ,
127this option loads all available drivers.
128.It Va snd_emu10k1_load
129.Pq Dq Li NO
130If set to
131.Dq Li YES ,
132only the SoundBlaster 5.1 driver and dependent modules will be loaded.
133.It Va snd_foo_load
134.Pq Dq Li NO
135If set to
136.Dq Li YES ,
137load driver for card/chipset foo.
138.El
139.Pp
140To define default values for the different mixer channels,
141set the channel to the preferred value using hints, e.g.:
142.Va hint.pcm.0.line Ns = Ns Qq Li 0 .
143This will mute the input channel per default.
144.Ss VCHANs
145Each device can optionally support more playback and recording channels
146than physical hardware provides by using
147.Dq virtual channels
148or
149.Tn VCHANs .
150.Tn VCHAN
151options can be configured via the
152.Xr sysctl 8
153interface but can only be manipulated while the device is inactive.
154.Ss Runtime Configuration
155There are a number of
156.Xr sysctl 8
157variables available.
158.Va hw.snd.*
159tunables are global settings and
160.Va dev.pcm.*
161are device specific.
162.Bl -tag -width ".Va hw.snd.report_soft_formats" -offset indent
163.It Va hw.snd.compat_linux_mmap
164Enable to allow PROT_EXEC page mappings.
165All Linux applications using sound and
166.Xr mmap 2
167require this.
168.It Va hw.snd.default_auto
169Enable to automatically assign default sound unit to the most recent
170attached device.
171.It Va hw.snd.default_unit
172Default sound card for systems with multiple sound cards.
173When using
174.Xr devfs 5 ,
175the default device for
176.Pa /dev/dsp .
177Equivalent to a symlink from
178.Pa /dev/dsp
179to
180.Pa /dev/dsp Ns Va ${hw.snd.default_unit} .
181.It Va hw.snd.feeder_rate_max
182Maximum allowable sample rate.
183.It Va hw.snd.feeder_rate_min
184Minimum allowable sample rate.
185.It Va hw.snd.feeder_rate_round
186Sample rate rounding threshold, to avoid large prime division at the
187cost of accuracy.
188All requested sample rates will be rounded to the nearest threshold value.
189Possible values range between 0 (disabled) and 500.
190Default is 25.
191.It Va hw.snd.latency
192Configure the buffering latency.
193Only affects applications that do not explicitly request
194blocksize / fragments.
195This tunable provides finer granularity than the
196.Va hw.snd.latency_profile
197tunable.
198Possible values range between 0 (lowest latency) and 10 (highest latency).
199.It Va hw.snd.latency_profile
200Define sets of buffering latency conversion tables for the
201.Va hw.snd.latency
202tunable.
203A value of 0 will use a low and aggressive latency profile which can result
204in possible underruns if the application cannot keep up with a rapid irq
205rate, especially during high workload.
206The default value is 1, which is considered a moderate/safe latency profile.
207.It Va hw.snd.maxautovchans
208Global
209.Tn VCHAN
210setting that only affects devices with at least one playback or recording channel available.
211The sound system will dynamically create up this many
212.Tn VCHANs .
213Set to
214.Dq 0
215if no
216.Tn VCHANS
217are desired.
218Maximum value is 256.
219.It Va hw.snd.report_soft_formats
220Controls the internal format conversion if it is
221available transparently to the application software.
222When disabled or not available, the application will
223only be able to select formats the device natively supports.
224.It Va hw.snd.verbose
225Level of verbosity for the
226.Pa /dev/sndstat
227device.
228Higher values include more output and the highest level,
229four, should be used when reporting problems.
230Other options include:
231.Bl -tag -width 2n
232.It 0
233Installed devices and their allocated bus resources.
234.It 1
235The number of playback, record, virtual channels, and
236flags per device.
237.It 2
238Channel information per device including the channel's
239current format, speed, and pseudo device statistics such as
240buffer overruns and buffer underruns.
241.It 3
242File names and versions of the currently loaded sound modules.
243.It 4
244Various messages intended for debugging.
245.El
246.It Va dev.pcm.%d.[play|rec].vchans
247The current number of
248.Tn VCHANs
249allocated per device.
250This can be set to preallocate a certain number of
251.Tn VCHANs .
252Setting this value to
253.Dq 0
254will disable
255.Tn VCHANs
256for this device.
257.It Va dev.pcm.%d.[play|rec].vchanformat
258Format for
259.Tn VCHAN
260mixing.
261All playback paths will be converted to this format before the mixing
262process begins.
263.It Va dev.pcm.%d.[play|rec].vchanrate
264Sample rate speed for
265.Tn VCHAN
266mixing.
267All playback paths will be converted to this sample rate before the mixing
268process begins.
269.It Va dev.pcm.%d.polling
270Experimental polling mode support where the driver operates by querying the
271device state on each tick using a
272.Xr callout 9
273mechanism.
274Disabled by default and currently only available for a few device drivers.
275.El
276.Ss Recording Channels
277On devices that have more than one recording source (ie: mic and line),
278there is a corresponding
279.Pa /dev/dsp%d.r%d
280device.
281.Ss Statistics
282Channel statistics are only kept while the device is open.
283So with situations involving overruns and underruns, consider the output
284while the errant application is open and running.
285.Ss IOCTL Support
286The driver supports most of the
287.Tn OSS
288.Fn ioctl
289functions, and most applications work unmodified.
290A few differences exist, while memory mapped playback is
291supported natively and in
292.Tn Linux
293emulation, memory mapped recording is
294not due to
295.Tn VM
296system design.
297As a consequence, some applications may need to be recompiled
298with a slightly modified audio module.
299See
300.In sys/soundcard.h
301for a complete list of the supported
302.Fn ioctl
303functions.
304.Sh FILES
305The
306.Nm
307drivers may create the following
308device nodes:
309.Pp
310.Bl -tag -width ".Pa /dev/audio%d.%d" -compact
311.It Pa /dev/audio%d.%d
312Sparc-compatible audio device.
313.It Pa /dev/dsp%d.%d
314Digitized voice device.
315.It Pa /dev/dspW%d.%d
316Like
317.Pa /dev/dsp ,
318but 16 bits per sample.
319.It Pa /dev/dsp%d.p%d
320Playback channel.
321.It Pa /dev/dsp%d.r%d
322Record channel.
323.It Pa /dev/dsp%d.vp%d
324Virtual playback channel.
325.It Pa /dev/dsp%d.vr%d
326Virtual recording channel.
327.It Pa /dev/sndstat
328Current
329.Nm
330status, including all channels and drivers.
331.El
332.Pp
333The first number in the device node
334represents the unit number of the
335.Nm
336device.
337All
338.Nm
339devices are listed
340in
341.Pa /dev/sndstat .
342Additional messages are sometimes recorded when the
343device is probed and attached, these messages can be viewed with the
344.Xr dmesg 8
345utility.
346.Pp
347The above device nodes are only created on demand through the dynamic
348.Xr devfs 5
349clone handler.
350Users are strongly discouraged to access them directly.
351For specific sound card access, please instead use
352.Pa /dev/dsp
353or
354.Pa /dev/dsp%d .
355.Sh DIAGNOSTICS
356.Bl -diag
357.It pcm%d:play:%d:dsp%d.p%d: play interrupt timeout, channel dead
358The hardware does not generate interrupts to serve incoming (play)
359or outgoing (record) data.
360.It unsupported subdevice XX
361A device node is not created properly.
362.El
363.Sh SEE ALSO
364.Xr snd_ad1816 4 ,
365.Xr snd_als4000 4 ,
366.Xr snd_atiixp 4 ,
367.Xr snd_audiocs 4 ,
368.Xr snd_cmi 4 ,
369.Xr snd_cs4281 4 ,
370.Xr snd_csa 4 ,
371.Xr snd_ds1 4 ,
372.Xr snd_emu10k1 4 ,
373.Xr snd_emu10kx 4 ,
374.Xr snd_envy24 4 ,
375.Xr snd_envy24ht 4 ,
376.Xr snd_es137x 4 ,
377.Xr snd_ess 4 ,
378.Xr snd_fm801 4 ,
379.Xr snd_gusc 4 ,
380.Xr snd_hda 4 ,
381.Xr snd_ich 4 ,
382.Xr snd_maestro 4 ,
383.Xr snd_maestro3 4 ,
384.Xr snd_mss 4 ,
385.Xr snd_neomagic 4 ,
386.Xr snd_sbc 4 ,
387.Xr snd_solo 4 ,
388.Xr snd_spicds 4 ,
389.Xr snd_t4dwave 4 ,
390.Xr snd_uaudio 4 ,
391.Xr snd_via8233 4 ,
392.Xr snd_via82c686 4 ,
393.Xr snd_vibes 4 ,
394.Xr devfs 5 ,
395.Xr device.hints 5 ,
396.Xr loader.conf 5 ,
397.Xr dmesg 8 ,
398.Xr kldload 8 ,
399.Xr sysctl 8
400.Rs
401.%T "The OSS API"
402.%O "http://www.opensound.com/pguide/oss.pdf"
403.Re
404.Sh HISTORY
405The
406.Nm
407device driver first appeared in
408.Fx 2.2.6
409as
410.Nm pcm ,
411written by
412.An Luigi Rizzo .
413It was later
414rewritten in
415.Fx 4.0
416by
417.An Cameron Grant .
418The API evolved from the VOXWARE
419standard which later became OSS standard.
420.Sh AUTHORS
421.An -nosplit
422.An Luigi Rizzo Aq luigi@iet.unipi.it
423initially wrote the
424.Nm pcm
425device driver and this manual page.
426.An Cameron Grant Aq gandalf@vilnya.demon.co.uk
427later revised the device driver for
428.Fx 4.0 .
429.An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
430revised this manual page.
431It was then rewritten for
432.Fx 5.2 .
433.Sh BUGS
434Some features of your sound card (e.g., global volume control) might not
435be supported on all devices.
436