2 .\" Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
5 .\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MIXER 7I "May 21, 2009"
8 mixer \- generic mixer device interface
12 \fB#include\fR \fB<sys/soundcard.h>\fR
19 .SS "Mixer Pseudo-Device"
22 The \fB/dev/mixer\fR pseudo-device is provided for two purposes:
27 The first purpose is for applications that wish to learn about the list of
28 audio devices on the system, so that they can select (or provide for users to
29 select) an appropriate audio device. The \fB/dev/mixer\fR pseudo-device
30 provides interfaces to enumerate all of the audio devices on the system.
36 The second purpose is for mixer panel type applications which need to control
37 master settings for the audio hardware in the system, such as gain levels,
38 balance, port functionality, and other device features.
42 Ordinary audio applications should \fBnot\fR attempt to adjust their playback
43 or record volumes or other device settings using this device. Instead, they
44 should use the \fBSNDCTL_DSP_SETPLAYVOL\fR and \fBSNDCTL_DSP_SETRECVOL\fR
45 ioctls that are documented in \fBdsp\fR(7I).
49 The \fB/dev/sndstat\fR device supports \fBread\fR(2), and can be read to
50 retrieve human-readable information about the audio devices on the system.
51 Software should not attempt to interpret the contents of this device.
53 .SS "Information IOCTLs"
56 The following ioctls are intended to aid applications in identifying the audio
57 devices available on the system. These ioctls can be issued against either the
58 pseudo-device \fB/dev/mixer\fR, or a against a file descriptor open to any
59 other audio device in the system.
62 Applications should issue \fBSNDCTL_SYSINFO\fR first to learn what audio
63 devices and mixers are available on the system, and then use
64 \fBSNDCTL_AUDIOINFO\fR or \fBSNDCTL_MIXERINFO\fR to obtain more information
65 about the audio devices or mixers, respectively.
69 \fB\fBOSS_GETVERSION\fR\fR
72 The argument is a pointer to an integer, which retrieves the version of the
73 \fBOSS API\fR used. The value is encoded with the major version (currently 4)
74 encoded in the most significant 16 bits, and a minor version encoded in the
81 \fB\fBSNDCTL_SYSINFO\fR\fR
84 The argument is a pointer to an \fBoss_sysinfo\fR structure, which has the
89 typedef struct oss_sysinfo {
90 char product[32]; /* E.g. SunOS Audio */
91 char version[32]; /* E.g. 4.0a */
92 int versionnum; /* See OSS_GETVERSION */
93 char options[128]; /* NOT SUPPORTED */
95 int numaudios; /* # of audio/dsp devices */
96 int openedaudio[8]; /* Reserved, always 0 */
98 int numsynths; /* NOT SUPPORTED, always 0 */
99 int nummidis; /* NOT SUPPORTED, always 0 */
100 int numtimers; /* NOT SUPPORTED, always 0 */
101 int nummixers; /* # of mixer devices */
103 int openedmidi[8]; /* Mask of midi devices are
105 int numcards; /* Number of sound cards in
107 int numaudioengines; /* Number of audio engines in
109 char license[16]; /* E.g. "GPL" or "CDDL" */
110 char revision_info[256]; /* Reserved */
111 int filler[172]; /* Reserved */
117 The important fields here are \fBnumaudios\fR, which is used to determine the
118 number of audio devices that can be queried with \fBSNDCTL_AUDIOINFO\fR,
119 \fBnummixers\fR which provides a count of mixers on the system, and
120 \fBnumcards\fR which counts to total number of aggregate devices. A \fBcard\fR
121 can consist of one or more audio devices and one or more mixers, although more
122 typically there is exactly one audio device and one mixer for each card.
128 \fB\fBSNDCTL_AUDIOINFO\fR\fR
131 The argument is a pointer to an \fBoss_audioinfo\fR structure, which has the
136 typedef struct oss_audioinfo {
137 int dev; /* Device to query */
138 char name[64]; /* Human readable name */
139 int busy; /* reserved */
140 int pid; /* reserved */
141 int caps; /* PCM_CAP_INPUT, PCM_CAP_OUTPUT */
142 int iformats; /* Supported input formats */
143 int oformats; /* Supported output formats */
144 int magic; /* reserved */
145 char cmd[64]; /* reserved */
147 int port_number; /* reserved */
149 int legacy_device; /* Obsolete field.
150 Replaced by devnode */
151 int enabled; /* reserved */
152 int flags; /* reserved */
153 int min_rate; /* Minimum sample rate */
154 int max_rate; /* Maximum sample rate */
155 int min_channels; /* Minimum number
157 int max_channels; /* Maximum number
159 int binding; /* reserved */
160 int rate_source; /* reserved */
161 char handle[32]; /* reserved */
162 unsigned int nrates; /* reserved */
163 unsigned int rates[20]; /* reserved */
164 char song_name[64]; /* reserved */
165 char label[16]; /* reserved */
166 int latency; /* reserved */
167 char devnode[32]; /* Device special file
168 name (absolute path) */
169 int next_play_engine; /* reserved */
170 int next_rec_engine; /* reserved */
171 int filler[184]; /* reserved */
177 In the above structure, all of the fields are reserved except the following:
178 d\fBev, name, card_number, mixer_dev, caps, min_rate, max_rate, min_channels,
179 max_channels,\fR and \fBdevnode\fR. The reserved fields are provided for
180 compatibility with other OSS implementations, and available for legacy
181 applications. New applications should not attempt to use these fields.
183 The \fBdev\fR field should be initialized by the application to the number of
184 the device to query. This is a number between zero (inclusive) and value of
185 \fBnumaudios\fR (exclusive) returned by \fBSNDCTL_SYSINFO\fR. Alternatively,
186 when issuing the ioctl against a real mixer or \fBdsp\fR device, the special
187 value \fB-1\fR can be used to indicate that the query is being made against the
188 device opened. If \fB-1\fR is used, the field is overwritten with the device
189 number for the current device on successful return.
191 No other fields are significant upon entry, but a successful return contains
192 details of the device.
194 The \fBname\fR field is a human readable name representing the device.
195 Applications should not try to interpret it.
197 The \fBcard_number\fR field indicates the number assigned to the aggregate
198 device. This can be used with the \fBSNDCTL_CARDINFO\fR ioctl.
200 The \fBmixer_dev\fR is the mixer device number for the mixing device associated
201 with the audio device. This can be used with the \fBSNDCTL_MIXERINFO\fR ioctl.
203 The caps field contains any of the bits \fBPCM_CAP_INPUT\fR,
204 \fBPCM_CAP_OUTPUT\fR, and \fBPCM_CAP_DUPLEX\fR. Indicating whether the device
205 support input, output, and whether input and output can be used simultaneously.
206 All other bits are reserved.
208 The \fBmin_rate\fR and \fBmax_rate\fR fields indicate the minimum and maximum
209 sample rates supported by the device. Most applications should try to use the
210 maximum supported rate for the best audio quality and lowest system resource
213 The \fBmin_channels\fR and \fBmax_channels\fR provide an indication of the
214 number of channels (1 for mono, 2 for stereo, 6 for 5.1, etc.) supported by the
217 The \fBdevnode\fR field contains the actual full path to the device node for
218 this device, such as \fB/dev/sound/audio810:0dsp\fR. Applications should open
219 this file to access the device.
225 \fB\fBSNDCTL_CARDINFO\fR\fR
228 The argument is a pointer to a \fBstruct oss_card_info\fR, which has the
229 following definition:
233 typedef struct oss_card_info {
237 int flags;/* reserved */
239 int intr_count;/* reserved */
240 int ack_count;/* reserved */
247 This ioctl is used to query for information about the aggregate audio device.
249 The \fBcard\fR field should be initialized by the application to the number of
250 the card to query. This is a number between zero inclusive and value of
251 \fBnumcards\fR (exclusive) returned by \fBSNDCTL_SYSINFO\fR.) Alternatively,
252 when issuing the ioctl against a real mixer or \fBdsp\fR device, the special
253 value \fB-1\fR can be used to indicate that the query is being made against the
254 device opened. If \fB-1\fR is used, the field is overwritten with the number
255 for the current hardware device on successful return.
257 The \fBshortname\fR, \fBlongname\fR, and \fBhw_info\fR contain \fBASCIIZ\fR
258 strings describing the device in more detail. The \fBhw_info\fR member can
259 contain multiple lines of detail, each line ending in a NEWLINE.
261 The flag, intr_count, and ack_count fields are not used by this implementation.
267 \fB\fBSNDCTL_MIXERINFO\fR\fR
270 The argument is a pointer to a \fBstruct oss_mixer_info\fR, which has the
271 following definition:
275 typedef struct oss_mixerinfo {
277 char id[16];/* Reserved */
281 int port_number;/* Reserved */
282 char handle[32];/* Reserved */
283 int magic;/* Reserved */
284 int enabled;/* Reserved */
285 int caps;/* Reserved */
286 int flags;/* Reserved */
289 char devnode[32];/* Device special file name
291 int legacy_device;/* Reserved */
292 int filler[245];/* Reserved */
298 In the above structure, all of the fields are reserved except the following:
299 \fBdev, name, modify_counter, card_number, nrext, priority,\fR and
300 \fBdevnode\fR. The reserved fields are provided for compatibility with other
301 OSS implementations, and available for legacy applications. New applications
302 should not attempt to use these fields.
304 The \fBdev\fR field should be initialized by the application to the number of
305 the device to query. This is a number between zero inclusive and value of
306 \fBnummixers\fR (exclusive) returned by \fBSNDCTL_SYSINFO\fR, or by
307 \fBSNDCTL_MIX_NRMIX\fR. Alternatively, when issuing the ioctl against a real
308 mixer or \fBdsp\fR device, the special value \fB-1\fR can be used to indicate
309 that the query is being made against the device opened. If \fB-1\fR is used,
310 the field is overwritten with the mixer number for the current open file on
313 No other fields are significant upon entry, but on successful return contains
314 details of the device.
316 The \fBname\fR field is a human readable name representing the device.
317 Applications should not try to interpret it.
319 The \fBmodify_counter\fR is changed by the mixer framework each time the
320 settings for the various controls or extensions of the device are changed.
321 Applications can poll this value to learn if any other changes need to be
324 The \fBcard_number\fR field is the number of the aggregate audio device this
325 mixer is located on. It can be used with the \fBSNDCTL_CARDINFO\fR ioctl.
327 The \fBnrext\fR field is the number of mixer extensions available on this
328 mixer. See the \fBSNDCTL_MIX_NREXT\fR description.
330 The priority is used by the framework to assign a preference that applications
331 can use in choosing a device. Higher values are preferable. Mixers with
332 priorities less than -1 should never be selected by default.
334 The \fBdevnode\fR field contains the actual full path to the device node for
335 the physical mixer, such as \fB/dev/sound/audio810:0mixer\fR. Applications
336 should open this file to access the mixer settings.
339 .SS "Mixer Extension IOCTLs"
342 The pseudo \fB/dev/mixer\fR device supports ioctls that can change the
343 various settings for the audio hardware in the system.
346 Those ioctls should only be used by dedicated mixer applications or desktop
347 volume controls, and not by typical ordinary audio applications such as media
348 players. Ordinary applications that wish to adjust their own volume settings
349 should use the \fBSNDCTL_DSP_SETPLAYVOL\fR or \fBSNDCTL_DSP_SETRECVOL\fR ioctls
350 for that purpose. See \fBdsp\fR(7I) for more information. Ordinary
351 applications should never attempt to change master port selection or hardware
352 settings such as monitor gain settings.
355 The ioctls in this section can only be used to access the mixer device that is
356 associated with the current file descriptor.
359 Applications should not assume that a single \fB/dev/mixer\fR node is able to
360 access any physical settings. Instead, they should use the ioctl
361 \fBSNDCTL_MIXERINFO\fR to determine the device path for the real mixer device,
362 and issue ioctls on a file descriptor opened against the corresponding
366 When a \fBdev\fR member is specified in each of the following ioctls, the
367 application should specify \fB-1\fR, although for compatibility the mixer
368 allows the application to specify the mixer device number.
372 \fB\fBSNDCTL_MIX_NRMIX\fR\fR
375 The argument is a pointer to an integer, which receives the number of mixer
376 devices in the system. Each can be queried by using its number with the
377 \fBSNDCTL_MIXERINFO\fR ioctl. The same information is available using the
378 \fBSNDCTL_SYSINFO\fR ioctl.
384 \fB\fBSNDCTL_MIX_NREXT\fR\fR
387 The argument is a pointer to an integer. On entry, the integer should contain
388 the special value \fB-1\fR. On return the argument receives the number of mixer
389 extensions (or mixer controls) supported by the mixer device. More details
390 about each extension can be obtained by \fBSNDCTL_MIX_EXTINFO\fR ioctl.
396 \fB\fBSNDCTL_MIX_EXTINFO\fR\fR
399 The argument is a pointer to an \fBoss_mixext\fR structure which is defined as
404 typedef struct oss_mixext {
405 int dev; /* Mixer device number */
406 int ctrl; /* Extension number */
407 int type; /* Entry type */
411 char id[16]; /* Mnemonic ID (internal use) */
412 int parent; /* Entry# of parent
414 int dummy; /* NOT SUPPORTED */
416 char data[64]; /* Reserved */
417 unsigned char enum_present[32]; /* Mask
421 int control_no; /* Reserved */
422 unsigned int desc; /* NOT SUPPORTED */
425 int filler[7]; /* Reserved */
431 On entry, the \fBdev\fR field should be initialized to the value \fB-1\fR, and
432 the \fBctrl\fR field should be initialized with the number of the extension
433 being accessed. Between 0, inclusive, and the value returned by
434 \fBSNDCTL_MIX_NREXT\fR, exclusive.
436 Mixer extensions are organized as a logical tree, starting with a root node.
437 The root node always has a \fBctrl\fR value of zero. The structure of the tree
438 can be determined by looking at the parent field, which contains the extension
439 number of the parent extension, or \fB-1\fR if the extension is the root
442 The type indicates the type of extension used. This implementation supports the
447 MIXT_DEVROOT Root node for extension tree
448 MIXT_GROUP Logical grouping of controls
449 MXIT_ONOFF Boolean value, 0 = off, 1 = on.
450 MIXT_ENUM Enumerated value, 0 to maxvalue.
451 MIXT_MONOSLIDER Monophonic slider, 0 to 255.
452 MIXT_STEREOSLIDER Stereophonic slider, 0 to 255
454 lower two bytes in value.)
455 MIXT_MARKER Place holder, can ignore.
460 The flags field is a bit array. This implementation makes use of the following
465 MIXF_READABLE Extension's value is readable.
466 MIXF_WRITEABLE Extension's value is modifiable.
467 MIXF_POLL Extension can self-update.
468 MIXF_PCMVOL Extension is for master
470 MIXF_MAINVOL Extension is for a typical
472 MIXF_RECVOL Extension is for master
474 MIXF_MONVOL Extension is for a monitor
480 The \fBid\fR field contains an \fBASCIIZ\fR identifier for the extension.
482 The timestamp field is set when the extension tree is first initialized.
483 Applications must use the same timestamp value when attempting to change the
484 values. A change in the timestamp indicates a change a in the structure of the
487 The \fBenum_present\fR field is a bit mask of possible enumeration values. If a
488 bit is present in the \fBenum_present\fR mask, then the corresponding
489 enumeration value is legal. The mask is in little endian order.
491 The \fBdesc\fR field provides information about scoping, which can be useful as
492 layout hints to applications. The following hints are available:
496 MIXEXT_SCOPE_MASK Mask of possible scope
498 MIXEXT_SCOPE_INPUT Extension is an input
500 MIXEXT_SCOPE_OUTPUT Extension is an
502 MIXEXT_SCOPE_MONITOR Extension relates to
504 MIXEXT_SCOPE_OTHER No scoping hint provided.
509 The \fBextname\fR is the full name of the extension.
511 The \fBupdate_counter\fR is incremented each time the control's value is
518 \fB\fBSNDCTL_MIX_ENUMINFO\fR\fR
521 The argument is a pointer to an \fBoss_mixer_enuminfo\fR structure, which is
526 typedef struct oss_mixer_enuminfo {
533 } oss_mixer_enuminfo;
538 On entry, the \fBdev\fR field should be initialized to the value \fB-1\fR, and
539 the \fBctrl\fR field should be initialized with the number of the extension
540 being accessed. Between 0, inclusive, and the value returned by
541 \fBSNDCTL_MIX_NREXT\fR, exclusive.
543 On return the \fBnvalues\fR field contains the number of values, and
544 \fBstrindex\fR contains an array of indices into the strings member, each index
545 pointing to an \fBASCIIZ\fR describing the enumeration value.
551 \fB\fBSNDCTL_MIX_READ\fR\fR
555 \fB\fBSNDCTL_MIX_WRITE\fR\fR
558 The argument is a pointer to an \fBoss_mixer_value\fR structure, defined as
563 typedef struct oss_mixer_value {
567 int flags; /* Reserved for future use.
569 int timestamp; /* Must be set to
570 oss_mixext.timestamp */
571 int filler[8]; /* Reserved for future use.
578 On entry, the \fBdev\fR field should be initialized to the value \fB-1\fR, and
579 the \fBctrl\fR field should be initialized with the number of the extension
580 being accessed. Between 0, inclusive, and the value returned by
581 \fBSNDCTL_MIX_NREXT\fR, exclusive. Additionally, the timestamp member must be
582 initialized to the same value as was supplied in the \fBoss_mixext\fR structure
583 used with \fBSNDCTL_MIX_EXTINFO\fR.
585 For \fBSNDCTL_MIX_WRITE\fR, the application should supply the new value for the
586 extension. For \fBSNDCTL_MIX_READ\fR, the mixer returns the extensions current
590 .SS "Compatibility IOCTLs"
593 The following ioctls are for compatibility use only:
597 SOUND_MIXER_READ_VOLUME
599 SOUND_MIXER_READ_OGAIN
600 SOUND_MIXER_READ_RECGAIN
601 SOUND_MIXER_READ_RECLEV
602 SOUND_MIXER_READ_IGAIN
603 SOUND_MIXER_READ_RECSRC
604 SOUND_MIXER_READ_RECMASK
605 SOUND_MIXER_READ_DEVMASK
606 SOUND_MIXER_READ_STEREODEVS
607 SOUND_MIXER_WRITE_VOLUME
608 SOUND_MIXER_WRITE_PCM
609 SOUND_MIXER_WRITE_OGAIN
610 SOUND_MIXER_WRITE_RECGAIN
611 SOUND_MIXER_WRITE_RECLEV
612 SOUND_MIXER_WRITE_IGAIN
613 SOUND_MIXER_WRITE_RECSRC
614 SOUND_MIXER_WRITE_RECMASK
624 These ioctls can affect the software volume levels associated with the calling
625 process. They have no effect on the physical hardware levels or settings. They
626 should not be used in new applications.
630 An \fBioctl()\fR fails if:
637 The parameter changes requested in the ioctl are invalid or are not supported
647 The device or extension referenced does not exist.
654 \fB\fB/dev/mixer\fR\fR
657 Symbolic link to the pseudo mixer device for the system
663 \fB\fB/dev/sndstat\fR\fR
672 See \fBattributes\fR(5) for a description of the following attributes:
680 ATTRIBUTE TYPE ATTRIBUTE VALUE
682 Architecture SPARC, x86
684 Stability Level See below.
689 The information and mixer extension IOCTLs are Uncommitted. The Compatibility
690 IOCTLs are Obsolete Uncommitted. The extension names are Uncommitted.
694 \fBclose\fR(2), \fBioctl\fR(2), \fBopen\fR(2), , \fBread\fR(2),
695 \fBattributes\fR(5), \fBdsp\fR(7I)
699 The names of mixer extensions are not guaranteed to be predictable.