xref: /freebsd/share/man/man4/pcm.4 (revision 3193579b66fd7067f898dbc54bdea81a0e6f9bd0)
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 November 14, 2003
29.Dt PCM 4
30.Os
31.Sh NAME
32.Nm pcm ,
33.Nm snd
34.Nd FreeBSD PCM audio device infrastructure
35.Sh SYNOPSIS
36For a card with bridge driver support, and a PnP card:
37.Cd "device pcm"
38.Pp
39For a card without bridge driver support, and a non-PnP card,
40the following lines may be required in
41.Pa /boot/device.hints :
42.Cd hint.pcm.0.at="isa"
43.Cd hint.pcm.0.irq="5"
44.Cd hint.pcm.0.drq="1"
45.Cd hint.pcm.0.flags="0x0"
46.Sh DESCRIPTION
47The
48.Nm
49driver provides support for
50.Tn PCM
51audio play and capture.
52This driver also supports various
53.Tn PCI ,
54.Tn WSS/MSS
55compatible,
56.Tn ISA
57sound cards, and AC97 mixer.
58Once the
59.Nm
60driver attaches, supported devices provide audio record and
61playback channels.
62The
63.Fx
64sound system provides dynamic mixing
65.Dq VCHAN
66and rate conversion
67.Dq soft formats .
68True full duplex operation is available on most cards.
69.Pp
70If the sound card is supported by a bridge driver, the
71.Nm
72driver works in conjunction with the bridge driver.
73.Pp
74Apart from the usual parameters, the flags field is used to specify
75the secondary
76.Tn DMA
77channel (generally used for capture in full duplex cards).
78Flags are set to 0 for cards not using a secondary
79.Tn DMA
80channel, or to 0x10 + C to specify channel C.
81.Pp
82The driver works best with
83.Tn WSS/MSS
84cards, which have a very clean
85architecture and an orthogonal set of features.
86They also happen to be
87among the cheapest audio cards on the market.
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 device foo and can be
110loaded by the boot loader via
111.Pa boot/loader.conf
112or from the command line using the
113.Xr kldload 8
114utility.
115Options which can be specified in
116.Pa /boot/loader.conf
117include:
118.Bl -tag -width snd_emu10k1_load -offset indent
119.It Va snd_driver_load
120.Pq Dq NO
121If set to
122.Dq YES ,
123this option loads all available drivers.
124.It Va snd_emu10k1_load
125.Pq Dq NO
126If set to
127.Dq YES ,
128Only the SoundBlaster 5.1 driver and dependent modules will be loaded.
129.It Va snd_foo_load
130.Pq Dq NO
131If set to
132.Dq YES ,
133load driver for card/chipset foo.
134.El
135.Ss VCHANS
136Each device can optionally support more playback channels
137that physical hardware provides by using
138.Dq virtual channels
139or
140.Tn VCHANs .
141.Tn VCHAN
142options can be configured via the
143.Xr sysctl 8
144interface but can only be manipulated while the device is inactive.
145.Ss Runtime Configuration
146The following
147.Xr sysctl 8
148tunables are available:
149.Bl -tag -width ".It Va hw.snd.report_soft_formats" -offset indent
150.It Va hw.snd.pcm%d.buffersize
151Configure the amount of
152.Tn DMA
153bufferspace available for a device.
154.It Va hw.snd.targetirqrate
155Set the default block size such that continuous
156playback will achieve this
157.Tn IRQ
158rate.
159This value can be tuned to improve application performance.
160Increase this value when the sound lags and decrease
161it if sound stutters or breaks up.
162.It Va hw.snd.unit
163When using
164.Xr devfs 5 ,
165the default device for
166.Pa /dev/dsp .
167Equivalent to a symlink from
168.Pa /dev/dsp
169to
170.Pa /dev/dsp${hw.snd.unit} .
171.It Va hw.snd.report_soft_formats
172Controls the internal format conversion if it is
173available transparently to the application software.
174When disabled or not available, the application will
175only be able to select formats the device natively supports.
176.It Va hw.snd.verbose
177Level of verbosity for the
178.Pa /dev/sndstat
179device.
180Higher values include more output and the highest level,
181three, should be used when reported problems.
182Other options include:
1830 - Installed devices and their allocated bus resources.
1841 - The number of playback, record, virtual channels, and
185flags per device.
1862 - Channel information per device including the channel's
187current format, speed, and pseudo device statistics such as
188buffer overruns and buffer underruns.
1893 - File names and versions of the currently sound loaded modules.
190.It Va hw.snd.maxautovchans
191Global
192.Tn VCHAN
193setting that only affects devices that have only one playback channel.
194The sound system will dynamically create up this many
195.Tn VCHANs .
196Set to
197.Dq 0
198if no
199.Tn VCHANS
200are desired.
201.It Va hw.snd.pcm%d.vchans
202The current number of
203.Tn VCHANs
204allocated per device.
205This can be set to preallocate a certain number of
206.Tn VCHANs .
207Setting this value to
208.Dq 0
209will disable
210.Tn VCHANs
211for this device.
212.El
213.Ss Recording Channels
214On devices that have more than one recording source (ie: mic and line),
215there is a corresponding
216.Pa /dev/dspr%d.%d
217device.
218.Ss Statistics
219Channel statistics are only kept while the device is open.
220So with situations involving overruns and underruns, consider the output
221while the errant application is open and running.
222.Ss IOCTL Support
223The driver supports most of the
224.Tn OSS
225.Fn ioctl
226functions, and most applications work unmodified.
227A few differences exist, while memory mapped playback is
228supported natively and in Linux emulation, memory mapped recording is
229not due to
230.Tn VM
231system design.
232As a consequence, some applications may need to be recompiled
233with a slightly modified audio module.
234See
235.In sys/soundcard.h
236for a complete list of the supported
237.Fn ioctl
238functions.
239.Ss SUPPORTED CARDS
240Below we include a list of supported codecs/cards.
241If your sound card
242is not listed here, it may be supported by a bridge driver.
243.Bl -tag -width 2m
244.It CS4237, CS4236, CS4232, CS4231 (ISA)
245All these cards work perfectly in full duplex using the MSS mode.
246This chipset is used, among others, on the A/Open AW35 and AW32, on
247some Intel motherboards, and (the CS4231) on some non-PnP cards.
248.Pp
249The CS4232 is reported as buggy in the Voxware documentation but
250I am not sure if this is true.
251On one of my Intel motherboards,
252capture does not work simply because the capture DMA channel is
253not wired to the ISA DMA controller.
254.It Yamaha OPL-SAx (ISA)
255Works perfectly in all modes.
256This chip is used in several PnP cards,
257but also (in non-PnP mode) on motherboards and laptops (e.g. the
258Toshiba Libretto).
259.It OPTi931 (ISA)
260The chip is buggy, but the driver has many workarounds to make it work
261in full duplex because for some time these were the only full duplex
262cards I could find. u-law formats uses U8 format internally because of
263a bug in the chip.
264.It Trident 4DWave DX/NX (PCI)
265.It ENSONIQ AudioPCI ES1370/1371 (PCI)
266Creative Labs SoundBlaster PCI is supported as well.
267.It ESS Solo-1/1E (PCI)
268.It NeoMagic 256AV/ZX (PCI)
269.El
270.Sh FILES
271The
272.Nm
273drivers may create the following
274device nodes:
275.Pp
276.Bl -tag -width "/dev/dspr%d.%dXXX" -compact
277.It Pa /dev/audio%d.%d
278Sparc-compatible audio device.
279.It Pa /dev/dsp%d.%d
280Digitized voice device.
281.It Pa /dev/dspW%d.%d
282Like
283.Pa /dev/dsp ,
284but 16 bits per sample.
285.It Pa /dev/dspr%d.%d
286Should be connected to a record codec.
287.It Pa /dev/sndstat
288Current
289.Nm
290status, including all channels and drivers.
291.El
292.Pp
293The first number in the device node
294represents the unit number of the
295.Nm PCM
296device.
297All
298.Nm
299PCM
300devices are listed
301in
302.Pa /dev/sndstat.
303Additional messages are sometimes recorded when the
304device is probed and attached, these messages can be viewed with the
305.Xr dmesg 8
306utility.
307.Sh DIAGNOSTICS
308.Bl -tag -width 2m
309.It ac97: dac not ready
310AC97 codec is not likely to be accompanied with the sound card.
311.It unsupported subdevice XX
312A device node is not created properly.
313.El
314.Sh BUGS
315Some features of your cards (e.g. global volume control) might not
316be supported on all devices.
317.Sh HISTORY
318The
319.Nm
320device driver first appeared in
321.Fx 2.2.6 written by Luigi Rizzo.
322It was later
323rewritten in
324.Fx 4.0 by Cameron Grant.
325The API evolved from the VOXWARE
326standard which later became OSS standard.
327.Sh SEE ALSO
328.Xr csa 4 ,
329.Xr gusc 4 ,
330.Xr sbc 4 ,
331.Xr devfs 5 ,
332.Xr loader.conf 5 ,
333.Xr dmesg 8 ,
334.Xr kldload 8 ,
335.Xr sysctl 8
336.Rs
337.%T "The OSS API"
338.%O "http://www.opensound.com/pguide/oss.pdf"
339.Re
340.Sh AUTHORS
341.An -nosplit
342.An Luigi Rizzo Aq luigi@iet.unipi.it
343initially wrote the
344.Nm
345device driver and this manual page.
346.An Cameron Grant Aq gandalf@vilnya.demon.co.uk
347later revised the device driver for
348.Fx 4.0 .
349.An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
350revised this manual page.
351It was then rewritten for
352.Fx 5.2 .