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