10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52712Snn35248 * Common Development and Distribution License (the "License"). 62712Snn35248 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*9484Sgarrett.damore@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 232712Snn35248 * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_AUDIOIO_H 270Sstevel@tonic-gate #define _SYS_AUDIOIO_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/types32.h> 310Sstevel@tonic-gate #include <sys/time.h> 320Sstevel@tonic-gate #include <sys/ioccom.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate /* 350Sstevel@tonic-gate * These are the ioctl calls for all Solaris audio devices, including 360Sstevel@tonic-gate * the x86 and SPARCstation audio devices. 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * You are encouraged to design your code in a modular fashion so that 390Sstevel@tonic-gate * future changes to the interface can be incorporated with little 400Sstevel@tonic-gate * trouble. 410Sstevel@tonic-gate */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate #ifdef __cplusplus 440Sstevel@tonic-gate extern "C" { 450Sstevel@tonic-gate #endif 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* 480Sstevel@tonic-gate * This structure contains state information for audio device IO streams. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate struct audio_prinfo { 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * The following values describe the audio data encoding. 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate uint_t sample_rate; /* samples per second */ 550Sstevel@tonic-gate uint_t channels; /* number of interleaved channels */ 560Sstevel@tonic-gate uint_t precision; /* bit-width of each sample */ 570Sstevel@tonic-gate uint_t encoding; /* data encoding method */ 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * The following values control audio device configuration 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate uint_t gain; /* gain level: 0 - 255 */ 630Sstevel@tonic-gate uint_t port; /* selected I/O port (see below) */ 640Sstevel@tonic-gate uint_t avail_ports; /* available I/O ports (see below) */ 650Sstevel@tonic-gate uint_t mod_ports; /* I/O ports that are modifiable (see below) */ 660Sstevel@tonic-gate uint_t _xxx; /* Reserved for future use */ 670Sstevel@tonic-gate 680Sstevel@tonic-gate uint_t buffer_size; /* I/O buffer size */ 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * The following values describe driver state 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate uint_t samples; /* number of samples converted */ 740Sstevel@tonic-gate uint_t eof; /* End Of File counter (play only) */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate uchar_t pause; /* non-zero for pause, zero to resume */ 770Sstevel@tonic-gate uchar_t error; /* non-zero if overflow/underflow */ 780Sstevel@tonic-gate uchar_t waiting; /* non-zero if a process wants access */ 790Sstevel@tonic-gate uchar_t balance; /* stereo channel balance */ 800Sstevel@tonic-gate 810Sstevel@tonic-gate ushort_t minordev; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * The following values are read-only state flags 850Sstevel@tonic-gate */ 860Sstevel@tonic-gate uchar_t open; /* non-zero if open access permitted */ 870Sstevel@tonic-gate uchar_t active; /* non-zero if I/O is active */ 880Sstevel@tonic-gate }; 890Sstevel@tonic-gate typedef struct audio_prinfo audio_prinfo_t; 900Sstevel@tonic-gate 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * This structure describes the current state of the audio device. 940Sstevel@tonic-gate */ 950Sstevel@tonic-gate struct audio_info { 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * Per-stream information 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate audio_prinfo_t play; /* output status information */ 1000Sstevel@tonic-gate audio_prinfo_t record; /* input status information */ 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Per-unit/channel information 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate uint_t monitor_gain; /* input to output mix: 0 - 255 */ 1060Sstevel@tonic-gate uchar_t output_muted; /* non-zero if output is muted */ 1070Sstevel@tonic-gate uchar_t ref_cnt; /* driver reference count, read only */ 1080Sstevel@tonic-gate uchar_t _xxx[2]; /* Reserved for future use */ 1090Sstevel@tonic-gate uint_t hw_features; /* hardware features this driver supports */ 1100Sstevel@tonic-gate uint_t sw_features; /* supported SW features */ 1110Sstevel@tonic-gate uint_t sw_features_enabled; /* supported SW feat. enabled */ 1120Sstevel@tonic-gate }; 1130Sstevel@tonic-gate typedef struct audio_info audio_info_t; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* 1170Sstevel@tonic-gate * Audio encoding types 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate #define AUDIO_ENCODING_NONE (0) /* no encoding assigned */ 1200Sstevel@tonic-gate #define AUDIO_ENCODING_ULAW (1) /* u-law encoding */ 1210Sstevel@tonic-gate #define AUDIO_ENCODING_ALAW (2) /* A-law encoding */ 1220Sstevel@tonic-gate #define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */ 1230Sstevel@tonic-gate #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */ 1240Sstevel@tonic-gate #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */ 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* 1270Sstevel@tonic-gate * These ranges apply to record, play, and monitor gain values 1280Sstevel@tonic-gate */ 1290Sstevel@tonic-gate #define AUDIO_MIN_GAIN (0) /* minimum gain value */ 1300Sstevel@tonic-gate #define AUDIO_MAX_GAIN (255) /* maximum gain value */ 1310Sstevel@tonic-gate #define AUDIO_MID_GAIN (AUDIO_MAX_GAIN / 2) 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* 1340Sstevel@tonic-gate * These values apply to the balance field to adjust channel gain values 1350Sstevel@tonic-gate */ 1360Sstevel@tonic-gate #define AUDIO_LEFT_BALANCE (0) /* left channel only */ 1370Sstevel@tonic-gate #define AUDIO_MID_BALANCE (32) /* equal left/right channel */ 1380Sstevel@tonic-gate #define AUDIO_RIGHT_BALANCE (64) /* right channel only */ 1390Sstevel@tonic-gate #define AUDIO_BALANCE_SHIFT (3) 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * Generic minimum/maximum limits for number of channels, both modes 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate #define AUDIO_CHANNELS_MONO (1) 1450Sstevel@tonic-gate #define AUDIO_CHANNELS_STEREO (2) 1460Sstevel@tonic-gate #define AUDIO_MIN_PLAY_CHANNELS (AUDIO_CHANNELS_MONO) 1470Sstevel@tonic-gate #define AUDIO_MAX_PLAY_CHANNELS (AUDIO_CHANNELS_STEREO) 1480Sstevel@tonic-gate #define AUDIO_MIN_REC_CHANNELS (AUDIO_CHANNELS_MONO) 1490Sstevel@tonic-gate #define AUDIO_MAX_REC_CHANNELS (AUDIO_CHANNELS_STEREO) 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * Generic minimum/maximum limits for sample precision 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate #define AUDIO_PRECISION_8 (8) 1550Sstevel@tonic-gate #define AUDIO_PRECISION_16 (16) 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #define AUDIO_MIN_PLAY_PRECISION (8) 1580Sstevel@tonic-gate #define AUDIO_MAX_PLAY_PRECISION (32) 1590Sstevel@tonic-gate #define AUDIO_MIN_REC_PRECISION (8) 1600Sstevel@tonic-gate #define AUDIO_MAX_REC_PRECISION (32) 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate /* 1630Sstevel@tonic-gate * Define some convenient names for typical audio ports 1640Sstevel@tonic-gate */ 1650Sstevel@tonic-gate #define AUDIO_NONE 0x00 /* all ports off */ 1660Sstevel@tonic-gate /* 1670Sstevel@tonic-gate * output ports (several may be enabled simultaneously) 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */ 1700Sstevel@tonic-gate #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */ 1710Sstevel@tonic-gate #define AUDIO_LINE_OUT 0x04 /* output to line out */ 1720Sstevel@tonic-gate #define AUDIO_SPDIF_OUT 0x08 /* output to SPDIF port */ 1730Sstevel@tonic-gate #define AUDIO_AUX1_OUT 0x10 /* output to aux1 out */ 1740Sstevel@tonic-gate #define AUDIO_AUX2_OUT 0x20 /* output to aux2 out */ 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /* 1770Sstevel@tonic-gate * input ports (usually only one at a time) 1780Sstevel@tonic-gate */ 1790Sstevel@tonic-gate #define AUDIO_MICROPHONE 0x01 /* input from microphone */ 1800Sstevel@tonic-gate #define AUDIO_LINE_IN 0x02 /* input from line in */ 1810Sstevel@tonic-gate #define AUDIO_CD 0x04 /* input from on-board CD inputs */ 1820Sstevel@tonic-gate #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */ 1830Sstevel@tonic-gate #define AUDIO_SPDIF_IN 0x08 /* input from SPDIF port */ 1840Sstevel@tonic-gate #define AUDIO_AUX1_IN 0x10 /* input from aux1 in */ 1850Sstevel@tonic-gate #define AUDIO_AUX2_IN 0x20 /* input from aux2 in */ 1860Sstevel@tonic-gate #define AUDIO_CODEC_LOOPB_IN 0x40 /* input from Codec internal loopback */ 1870Sstevel@tonic-gate #define AUDIO_SUNVTS 0x80 /* SunVTS input setting-internal LB */ 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate /* 1900Sstevel@tonic-gate * Define the hw_features 1910Sstevel@tonic-gate */ 1920Sstevel@tonic-gate #define AUDIO_HWFEATURE_DUPLEX 0x00000001u /* simult. play & rec support */ 1930Sstevel@tonic-gate #define AUDIO_HWFEATURE_MSCODEC 0x00000002u /* multi-stream Codec */ 1940Sstevel@tonic-gate #define AUDIO_HWFEATURE_IN2OUT 0x00000004u /* input to output loopback */ 1950Sstevel@tonic-gate #define AUDIO_HWFEATURE_PLAY 0x00000008u /* device supports play */ 1960Sstevel@tonic-gate #define AUDIO_HWFEATURE_RECORD 0x00000010u /* device supports record */ 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate /* 1990Sstevel@tonic-gate * Define the sw_features 2000Sstevel@tonic-gate */ 2010Sstevel@tonic-gate #define AUDIO_SWFEATURE_MIXER 0x00000001u /* audio mixer audio pers mod */ 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * This macro initializes an audio_info structure to 'harmless' values. 2050Sstevel@tonic-gate * Note that (~0) might not be a harmless value for a flag that was 2060Sstevel@tonic-gate * a signed int. 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate #define AUDIO_INITINFO(i) { \ 2092712Snn35248 uint_t *__x__; \ 2102712Snn35248 for (__x__ = (uint_t *)(i); \ 2110Sstevel@tonic-gate (char *)__x__ < (((char *)(i)) + sizeof (audio_info_t)); \ 2122712Snn35248 *__x__++ = (uint_t)~0); \ 2130Sstevel@tonic-gate } 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate /* 2170Sstevel@tonic-gate * Parameter for the AUDIO_GETDEV ioctl to determine current 2180Sstevel@tonic-gate * audio devices. 2190Sstevel@tonic-gate */ 2200Sstevel@tonic-gate #define MAX_AUDIO_DEV_LEN (16) 2210Sstevel@tonic-gate struct audio_device { 2220Sstevel@tonic-gate char name[MAX_AUDIO_DEV_LEN]; 2230Sstevel@tonic-gate char version[MAX_AUDIO_DEV_LEN]; 2240Sstevel@tonic-gate char config[MAX_AUDIO_DEV_LEN]; 2250Sstevel@tonic-gate }; 2260Sstevel@tonic-gate typedef struct audio_device audio_device_t; 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* 2300Sstevel@tonic-gate * Ioctl calls for the audio device. 2310Sstevel@tonic-gate */ 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /* 2340Sstevel@tonic-gate * AUDIO_GETINFO retrieves the current state of the audio device. 2350Sstevel@tonic-gate * 2360Sstevel@tonic-gate * AUDIO_SETINFO copies all fields of the audio_info structure whose 2370Sstevel@tonic-gate * values are not set to the initialized value (-1) to the device state. 2380Sstevel@tonic-gate * It performs an implicit AUDIO_GETINFO to return the new state of the 2390Sstevel@tonic-gate * device. Note that the record.samples and play.samples fields are set 2400Sstevel@tonic-gate * to the last value before the AUDIO_SETINFO took effect. This allows 2410Sstevel@tonic-gate * an application to reset the counters while atomically retrieving the 2420Sstevel@tonic-gate * last value. 2430Sstevel@tonic-gate * 2440Sstevel@tonic-gate * AUDIO_DRAIN suspends the calling process until the write buffers are 2450Sstevel@tonic-gate * empty. 2460Sstevel@tonic-gate * 2470Sstevel@tonic-gate * AUDIO_GETDEV returns a structure of type audio_device_t which contains 2480Sstevel@tonic-gate * three strings. The string "name" is a short identifying string (for 2490Sstevel@tonic-gate * example, the SBus Fcode name string), the string "version" identifies 2500Sstevel@tonic-gate * the current version of the device, and the "config" string identifies 2510Sstevel@tonic-gate * the specific configuration of the audio stream. All fields are 2520Sstevel@tonic-gate * device-dependent -- see the device specific manual pages for details. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate #define AUDIO_GETINFO _IOR('A', 1, audio_info_t) 2550Sstevel@tonic-gate #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t) 2560Sstevel@tonic-gate #define AUDIO_DRAIN _IO('A', 3) 2570Sstevel@tonic-gate #define AUDIO_GETDEV _IOR('A', 4, audio_device_t) 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate /* 2600Sstevel@tonic-gate * The following ioctl sets the audio device into an internal loopback mode, 2610Sstevel@tonic-gate * if the hardware supports this. The argument is TRUE to set loopback, 2620Sstevel@tonic-gate * FALSE to reset to normal operation. If the hardware does not support 2630Sstevel@tonic-gate * internal loopback, the ioctl should fail with EINVAL. 2640Sstevel@tonic-gate */ 2650Sstevel@tonic-gate #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int) 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate #ifdef __cplusplus 2680Sstevel@tonic-gate } 2690Sstevel@tonic-gate #endif 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate #endif /* _SYS_AUDIOIO_H */ 272