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