1 #ifndef HAVE_SUN_AUDIO 2 /* 3 * SoX bit-rot detection file, obtained from: Solaris 9 /usr/include/sys 4 */ 5 #if defined __GNUC__ 6 #pragma GCC system_header 7 #endif 8 9 /* 10 * Copyright (c) 1995-2001 by Sun Microsystems, Inc. 11 * All rights reserved. 12 */ 13 14 #ifndef _SYS_AUDIOIO_H 15 #define _SYS_AUDIOIO_H 16 17 #pragma ident "@(#)audioio.h 1.30 01/01/10 SMI" 18 19 #include <sys/types.h> 20 #if 0 21 #include <sys/types32.h> 22 #include <sys/time.h> 23 #include <sys/ioccom.h> 24 #else 25 #define ushort_t unsigned short 26 #define uint_t unsigned int 27 #define uchar_t unsigned char 28 struct timeval32 29 { 30 unsigned tv_sec; 31 unsigned tv_usec; 32 }; 33 #endif 34 35 /* 36 * These are the ioctl calls for all Solaris audio devices, including 37 * the x86 and SPARCstation audio devices. 38 * 39 * You are encouraged to design your code in a modular fashion so that 40 * future changes to the interface can be incorporated with little 41 * trouble. 42 */ 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /* 49 * This structure contains state information for audio device IO streams. 50 */ 51 struct audio_prinfo { 52 /* 53 * The following values describe the audio data encoding. 54 */ 55 uint_t sample_rate; /* samples per second */ 56 uint_t channels; /* number of interleaved channels */ 57 uint_t precision; /* bit-width of each sample */ 58 uint_t encoding; /* data encoding method */ 59 60 /* 61 * The following values control audio device configuration 62 */ 63 uint_t gain; /* gain level: 0 - 255 */ 64 uint_t port; /* selected I/O port (see below) */ 65 uint_t avail_ports; /* available I/O ports (see below) */ 66 uint_t mod_ports; /* I/O ports that are modifiable (see below) */ 67 uint_t _xxx; /* Reserved for future use */ 68 69 uint_t buffer_size; /* I/O buffer size */ 70 71 /* 72 * The following values describe driver state 73 */ 74 uint_t samples; /* number of samples converted */ 75 uint_t eof; /* End Of File counter (play only) */ 76 77 uchar_t pause; /* non-zero for pause, zero to resume */ 78 uchar_t error; /* non-zero if overflow/underflow */ 79 uchar_t waiting; /* non-zero if a process wants access */ 80 uchar_t balance; /* stereo channel balance */ 81 82 ushort_t minordev; 83 84 /* 85 * The following values are read-only state flags 86 */ 87 uchar_t open; /* non-zero if open access permitted */ 88 uchar_t active; /* non-zero if I/O is active */ 89 }; 90 typedef struct audio_prinfo audio_prinfo_t; 91 92 93 /* 94 * This structure describes the current state of the audio device. 95 */ 96 struct audio_info { 97 /* 98 * Per-stream information 99 */ 100 audio_prinfo_t play; /* output status information */ 101 audio_prinfo_t record; /* input status information */ 102 103 /* 104 * Per-unit/channel information 105 */ 106 uint_t monitor_gain; /* input to output mix: 0 - 255 */ 107 uchar_t output_muted; /* non-zero if output is muted */ 108 uchar_t ref_cnt; /* driver reference count, read only */ 109 uchar_t _xxx[2]; /* Reserved for future use */ 110 uint_t hw_features; /* hardware features this driver supports */ 111 uint_t sw_features; /* supported SW features */ 112 uint_t sw_features_enabled; /* supported SW feat. enabled */ 113 }; 114 typedef struct audio_info audio_info_t; 115 116 117 /* 118 * Audio encoding types 119 */ 120 #define AUDIO_ENCODING_NONE (0) /* no encoding assigned */ 121 #define AUDIO_ENCODING_ULAW (1) /* u-law encoding */ 122 #define AUDIO_ENCODING_ALAW (2) /* A-law encoding */ 123 #define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */ 124 #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */ 125 #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */ 126 127 /* 128 * These ranges apply to record, play, and monitor gain values 129 */ 130 #define AUDIO_MIN_GAIN (0) /* minimum gain value */ 131 #define AUDIO_MAX_GAIN (255) /* maximum gain value */ 132 #define AUDIO_MID_GAIN (AUDIO_MAX_GAIN / 2) 133 134 /* 135 * These values apply to the balance field to adjust channel gain values 136 */ 137 #define AUDIO_LEFT_BALANCE (0) /* left channel only */ 138 #define AUDIO_MID_BALANCE (32) /* equal left/right channel */ 139 #define AUDIO_RIGHT_BALANCE (64) /* right channel only */ 140 #define AUDIO_BALANCE_SHIFT (3) 141 142 /* 143 * Generic minimum/maximum limits for number of channels, both modes 144 */ 145 #define AUDIO_CHANNELS_MONO (1) 146 #define AUDIO_CHANNELS_STEREO (2) 147 #define AUDIO_MIN_PLAY_CHANNELS (AUDIO_CHANNELS_MONO) 148 #define AUDIO_MAX_PLAY_CHANNELS (AUDIO_CHANNELS_STEREO) 149 #define AUDIO_MIN_REC_CHANNELS (AUDIO_CHANNELS_MONO) 150 #define AUDIO_MAX_REC_CHANNELS (AUDIO_CHANNELS_STEREO) 151 152 /* 153 * Generic minimum/maximum limits for sample precision 154 */ 155 #define AUDIO_PRECISION_8 (8) 156 #define AUDIO_PRECISION_16 (16) 157 158 #define AUDIO_MIN_PLAY_PRECISION (8) 159 #define AUDIO_MAX_PLAY_PRECISION (32) 160 #define AUDIO_MIN_REC_PRECISION (8) 161 #define AUDIO_MAX_REC_PRECISION (32) 162 163 /* 164 * Define some convenient names for typical audio ports 165 */ 166 #define AUDIO_NONE 0x00 /* all ports off */ 167 /* 168 * output ports (several may be enabled simultaneously) 169 */ 170 #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */ 171 #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */ 172 #define AUDIO_LINE_OUT 0x04 /* output to line out */ 173 #define AUDIO_SPDIF_OUT 0x08 /* output to SPDIF port */ 174 #define AUDIO_AUX1_OUT 0x10 /* output to aux1 out */ 175 #define AUDIO_AUX2_OUT 0x20 /* output to aux2 out */ 176 177 /* 178 * input ports (usually only one at a time) 179 */ 180 #define AUDIO_MICROPHONE 0x01 /* input from microphone */ 181 #define AUDIO_LINE_IN 0x02 /* input from line in */ 182 #define AUDIO_CD 0x04 /* input from on-board CD inputs */ 183 #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */ 184 #define AUDIO_SPDIF_IN 0x08 /* input from SPDIF port */ 185 #define AUDIO_AUX1_IN 0x10 /* input from aux1 in */ 186 #define AUDIO_AUX2_IN 0x20 /* input from aux2 in */ 187 #define AUDIO_CODEC_LOOPB_IN 0x40 /* input from Codec internal loopback */ 188 #define AUDIO_SUNVTS 0x80 /* SunVTS input setting-internal LB */ 189 190 /* 191 * Define the hw_features 192 */ 193 #define AUDIO_HWFEATURE_DUPLEX 0x00000001u /* simult. play & rec support */ 194 #define AUDIO_HWFEATURE_MSCODEC 0x00000002u /* multi-stream Codec */ 195 #define AUDIO_HWFEATURE_IN2OUT 0x00000004u /* input to output loopback */ 196 #define AUDIO_HWFEATURE_PLAY 0x00000008u /* device supports play */ 197 #define AUDIO_HWFEATURE_RECORD 0x00000010u /* device supports record */ 198 199 /* 200 * Define the sw_features 201 */ 202 #define AUDIO_SWFEATURE_MIXER 0x00000001u /* audio mixer audio pers mod */ 203 204 /* 205 * This macro initializes an audio_info structure to 'harmless' values. 206 * Note that (~0) might not be a harmless value for a flag that was 207 * a signed int. 208 */ 209 #define AUDIO_INITINFO(i) { \ 210 uint_t *__x__; \ 211 for (__x__ = (uint_t *)(i); \ 212 (char *)__x__ < (((char *)(i)) + sizeof (audio_info_t)); \ 213 *__x__++ = ~0); \ 214 } 215 216 217 /* 218 * Parameter for the AUDIO_GETDEV ioctl to determine current 219 * audio devices. 220 */ 221 #define MAX_AUDIO_DEV_LEN (16) 222 struct audio_device { 223 char name[MAX_AUDIO_DEV_LEN]; 224 char version[MAX_AUDIO_DEV_LEN]; 225 char config[MAX_AUDIO_DEV_LEN]; 226 }; 227 typedef struct audio_device audio_device_t; 228 229 230 /* 231 * Ioctl calls for the audio device. 232 */ 233 234 /* 235 * AUDIO_GETINFO retrieves the current state of the audio device. 236 * 237 * AUDIO_SETINFO copies all fields of the audio_info structure whose 238 * values are not set to the initialized value (-1) to the device state. 239 * It performs an implicit AUDIO_GETINFO to return the new state of the 240 * device. Note that the record.samples and play.samples fields are set 241 * to the last value before the AUDIO_SETINFO took effect. This allows 242 * an application to reset the counters while atomically retrieving the 243 * last value. 244 * 245 * AUDIO_DRAIN suspends the calling process until the write buffers are 246 * empty. 247 * 248 * AUDIO_GETDEV returns a structure of type audio_device_t which contains 249 * three strings. The string "name" is a short identifying string (for 250 * example, the SBus Fcode name string), the string "version" identifies 251 * the current version of the device, and the "config" string identifies 252 * the specific configuration of the audio stream. All fields are 253 * device-dependent -- see the device specific manual pages for details. 254 */ 255 #define AUDIO_GETINFO _IOR('A', 1, audio_info_t) 256 #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t) 257 #define AUDIO_DRAIN _IO('A', 3) 258 #define AUDIO_GETDEV _IOR('A', 4, audio_device_t) 259 260 /* 261 * The following ioctl sets the audio device into an internal loopback mode, 262 * if the hardware supports this. The argument is TRUE to set loopback, 263 * FALSE to reset to normal operation. If the hardware does not support 264 * internal loopback, the ioctl should fail with EINVAL. 265 */ 266 #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int) 267 268 269 /* 270 * Structure sent up as a M_PROTO message on trace streams 271 */ 272 struct audtrace_hdr { 273 uint_t seq; /* Sequence number (per-aud_stream) */ 274 int type; /* device-dependent */ 275 #if defined(_LP64) || defined(_I32LPx) 276 struct timeval32 timestamp; 277 #else 278 struct timeval timestamp; 279 #endif 280 char _f[8]; /* filler */ 281 }; 282 typedef struct audtrace_hdr audtrace_hdr_t; 283 284 #ifdef __cplusplus 285 } 286 #endif 287 288 #endif /* _SYS_AUDIOIO_H */ 289 #endif 290