4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_AUDIOIO_H
27 #define _SYS_AUDIOIO_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/types.h>
32 #include <sys/types32.h>
34 #include <sys/ioccom.h>
37 * These are the ioctl calls for all Solaris audio devices, including
38 * the x86 and SPARCstation audio devices.
40 * You are encouraged to design your code in a modular fashion so that
41 * future changes to the interface can be incorporated with little
50 * This structure contains state information for audio device IO streams.
54 * The following values describe the audio data encoding.
56 uint_t sample_rate
; /* samples per second */
57 uint_t channels
; /* number of interleaved channels */
58 uint_t precision
; /* bit-width of each sample */
59 uint_t encoding
; /* data encoding method */
62 * The following values control audio device configuration
64 uint_t gain
; /* gain level: 0 - 255 */
65 uint_t port
; /* selected I/O port (see below) */
66 uint_t avail_ports
; /* available I/O ports (see below) */
67 uint_t mod_ports
; /* I/O ports that are modifiable (see below) */
68 uint_t _xxx
; /* Reserved for future use */
70 uint_t buffer_size
; /* I/O buffer size */
73 * The following values describe driver state
75 uint_t samples
; /* number of samples converted */
76 uint_t eof
; /* End Of File counter (play only) */
78 uchar_t pause
; /* non-zero for pause, zero to resume */
79 uchar_t error
; /* non-zero if overflow/underflow */
80 uchar_t waiting
; /* non-zero if a process wants access */
81 uchar_t balance
; /* stereo channel balance */
86 * The following values are read-only state flags
88 uchar_t open
; /* non-zero if open access permitted */
89 uchar_t active
; /* non-zero if I/O is active */
91 typedef struct audio_prinfo audio_prinfo_t
;
95 * This structure describes the current state of the audio device.
99 * Per-stream information
101 audio_prinfo_t play
; /* output status information */
102 audio_prinfo_t record
; /* input status information */
105 * Per-unit/channel information
107 uint_t monitor_gain
; /* input to output mix: 0 - 255 */
108 uchar_t output_muted
; /* non-zero if output is muted */
109 uchar_t ref_cnt
; /* driver reference count, read only */
110 uchar_t _xxx
[2]; /* Reserved for future use */
111 uint_t hw_features
; /* hardware features this driver supports */
112 uint_t sw_features
; /* supported SW features */
113 uint_t sw_features_enabled
; /* supported SW feat. enabled */
115 typedef struct audio_info audio_info_t
;
119 * Audio encoding types
121 #define AUDIO_ENCODING_NONE (0) /* no encoding assigned */
122 #define AUDIO_ENCODING_ULAW (1) /* u-law encoding */
123 #define AUDIO_ENCODING_ALAW (2) /* A-law encoding */
124 #define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */
125 #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */
126 #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */
129 * These ranges apply to record, play, and monitor gain values
131 #define AUDIO_MIN_GAIN (0) /* minimum gain value */
132 #define AUDIO_MAX_GAIN (255) /* maximum gain value */
133 #define AUDIO_MID_GAIN (AUDIO_MAX_GAIN / 2)
136 * These values apply to the balance field to adjust channel gain values
138 #define AUDIO_LEFT_BALANCE (0) /* left channel only */
139 #define AUDIO_MID_BALANCE (32) /* equal left/right channel */
140 #define AUDIO_RIGHT_BALANCE (64) /* right channel only */
141 #define AUDIO_BALANCE_SHIFT (3)
144 * Generic minimum/maximum limits for number of channels, both modes
146 #define AUDIO_CHANNELS_MONO (1)
147 #define AUDIO_CHANNELS_STEREO (2)
148 #define AUDIO_MIN_PLAY_CHANNELS (AUDIO_CHANNELS_MONO)
149 #define AUDIO_MAX_PLAY_CHANNELS (AUDIO_CHANNELS_STEREO)
150 #define AUDIO_MIN_REC_CHANNELS (AUDIO_CHANNELS_MONO)
151 #define AUDIO_MAX_REC_CHANNELS (AUDIO_CHANNELS_STEREO)
154 * Generic minimum/maximum limits for sample precision
156 #define AUDIO_PRECISION_8 (8)
157 #define AUDIO_PRECISION_16 (16)
159 #define AUDIO_MIN_PLAY_PRECISION (8)
160 #define AUDIO_MAX_PLAY_PRECISION (32)
161 #define AUDIO_MIN_REC_PRECISION (8)
162 #define AUDIO_MAX_REC_PRECISION (32)
165 * Define some convenient names for typical audio ports
167 #define AUDIO_NONE 0x00 /* all ports off */
169 * output ports (several may be enabled simultaneously)
171 #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */
172 #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */
173 #define AUDIO_LINE_OUT 0x04 /* output to line out */
174 #define AUDIO_SPDIF_OUT 0x08 /* output to SPDIF port */
175 #define AUDIO_AUX1_OUT 0x10 /* output to aux1 out */
176 #define AUDIO_AUX2_OUT 0x20 /* output to aux2 out */
179 * input ports (usually only one at a time)
181 #define AUDIO_MICROPHONE 0x01 /* input from microphone */
182 #define AUDIO_LINE_IN 0x02 /* input from line in */
183 #define AUDIO_CD 0x04 /* input from on-board CD inputs */
184 #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */
185 #define AUDIO_SPDIF_IN 0x08 /* input from SPDIF port */
186 #define AUDIO_AUX1_IN 0x10 /* input from aux1 in */
187 #define AUDIO_AUX2_IN 0x20 /* input from aux2 in */
188 #define AUDIO_CODEC_LOOPB_IN 0x40 /* input from Codec internal loopback */
189 #define AUDIO_SUNVTS 0x80 /* SunVTS input setting-internal LB */
192 * Define the hw_features
194 #define AUDIO_HWFEATURE_DUPLEX 0x00000001u /* simult. play & rec support */
195 #define AUDIO_HWFEATURE_MSCODEC 0x00000002u /* multi-stream Codec */
196 #define AUDIO_HWFEATURE_IN2OUT 0x00000004u /* input to output loopback */
197 #define AUDIO_HWFEATURE_PLAY 0x00000008u /* device supports play */
198 #define AUDIO_HWFEATURE_RECORD 0x00000010u /* device supports record */
201 * Define the sw_features
203 #define AUDIO_SWFEATURE_MIXER 0x00000001u /* audio mixer audio pers mod */
206 * This macro initializes an audio_info structure to 'harmless' values.
207 * Note that (~0) might not be a harmless value for a flag that was
210 #define AUDIO_INITINFO(i) { \
212 for (__x__ = (uint_t *)(i); \
213 (char *)__x__ < (((char *)(i)) + sizeof (audio_info_t)); \
214 *__x__++ = (uint_t)~0); \
219 * Parameter for the AUDIO_GETDEV ioctl to determine current
222 #define MAX_AUDIO_DEV_LEN (16)
223 struct audio_device
{
224 char name
[MAX_AUDIO_DEV_LEN
];
225 char version
[MAX_AUDIO_DEV_LEN
];
226 char config
[MAX_AUDIO_DEV_LEN
];
228 typedef struct audio_device audio_device_t
;
232 * Ioctl calls for the audio device.
236 * AUDIO_GETINFO retrieves the current state of the audio device.
238 * AUDIO_SETINFO copies all fields of the audio_info structure whose
239 * values are not set to the initialized value (-1) to the device state.
240 * It performs an implicit AUDIO_GETINFO to return the new state of the
241 * device. Note that the record.samples and play.samples fields are set
242 * to the last value before the AUDIO_SETINFO took effect. This allows
243 * an application to reset the counters while atomically retrieving the
246 * AUDIO_DRAIN suspends the calling process until the write buffers are
249 * AUDIO_GETDEV returns a structure of type audio_device_t which contains
250 * three strings. The string "name" is a short identifying string (for
251 * example, the SBus Fcode name string), the string "version" identifies
252 * the current version of the device, and the "config" string identifies
253 * the specific configuration of the audio stream. All fields are
254 * device-dependent -- see the device specific manual pages for details.
256 #define AUDIO_GETINFO _IOR('A', 1, audio_info_t)
257 #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t)
258 #define AUDIO_DRAIN _IO('A', 3)
259 #define AUDIO_GETDEV _IOR('A', 4, audio_device_t)
262 * The following ioctl sets the audio device into an internal loopback mode,
263 * if the hardware supports this. The argument is TRUE to set loopback,
264 * FALSE to reset to normal operation. If the hardware does not support
265 * internal loopback, the ioctl should fail with EINVAL.
267 #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int)
271 * Structure sent up as a M_PROTO message on trace streams
273 struct audtrace_hdr
{
274 uint_t seq
; /* Sequence number (per-aud_stream) */
275 int type
; /* device-dependent */
276 #if defined(_LP64) || defined(_I32LPx)
277 struct timeval32 timestamp
;
279 struct timeval timestamp
;
281 char _f
[8]; /* filler */
283 typedef struct audtrace_hdr audtrace_hdr_t
;
289 #endif /* _SYS_AUDIOIO_H */