17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9acbbeafSnn * Common Development and Distribution License (the "License"). 6*9acbbeafSnn * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*9acbbeafSnn * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*9acbbeafSnn * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_AUDIOIO_H 277c478bd9Sstevel@tonic-gate #define _SYS_AUDIOIO_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <sys/types32.h> 337c478bd9Sstevel@tonic-gate #include <sys/time.h> 347c478bd9Sstevel@tonic-gate #include <sys/ioccom.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * These are the ioctl calls for all Solaris audio devices, including 387c478bd9Sstevel@tonic-gate * the x86 and SPARCstation audio devices. 397c478bd9Sstevel@tonic-gate * 407c478bd9Sstevel@tonic-gate * You are encouraged to design your code in a modular fashion so that 417c478bd9Sstevel@tonic-gate * future changes to the interface can be incorporated with little 427c478bd9Sstevel@tonic-gate * trouble. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifdef __cplusplus 467c478bd9Sstevel@tonic-gate extern "C" { 477c478bd9Sstevel@tonic-gate #endif 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * This structure contains state information for audio device IO streams. 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate struct audio_prinfo { 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * The following values describe the audio data encoding. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate uint_t sample_rate; /* samples per second */ 577c478bd9Sstevel@tonic-gate uint_t channels; /* number of interleaved channels */ 587c478bd9Sstevel@tonic-gate uint_t precision; /* bit-width of each sample */ 597c478bd9Sstevel@tonic-gate uint_t encoding; /* data encoding method */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * The following values control audio device configuration 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate uint_t gain; /* gain level: 0 - 255 */ 657c478bd9Sstevel@tonic-gate uint_t port; /* selected I/O port (see below) */ 667c478bd9Sstevel@tonic-gate uint_t avail_ports; /* available I/O ports (see below) */ 677c478bd9Sstevel@tonic-gate uint_t mod_ports; /* I/O ports that are modifiable (see below) */ 687c478bd9Sstevel@tonic-gate uint_t _xxx; /* Reserved for future use */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate uint_t buffer_size; /* I/O buffer size */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * The following values describe driver state 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate uint_t samples; /* number of samples converted */ 767c478bd9Sstevel@tonic-gate uint_t eof; /* End Of File counter (play only) */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate uchar_t pause; /* non-zero for pause, zero to resume */ 797c478bd9Sstevel@tonic-gate uchar_t error; /* non-zero if overflow/underflow */ 807c478bd9Sstevel@tonic-gate uchar_t waiting; /* non-zero if a process wants access */ 817c478bd9Sstevel@tonic-gate uchar_t balance; /* stereo channel balance */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate ushort_t minordev; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * The following values are read-only state flags 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate uchar_t open; /* non-zero if open access permitted */ 897c478bd9Sstevel@tonic-gate uchar_t active; /* non-zero if I/O is active */ 907c478bd9Sstevel@tonic-gate }; 917c478bd9Sstevel@tonic-gate typedef struct audio_prinfo audio_prinfo_t; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * This structure describes the current state of the audio device. 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate struct audio_info { 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * Per-stream information 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate audio_prinfo_t play; /* output status information */ 1027c478bd9Sstevel@tonic-gate audio_prinfo_t record; /* input status information */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * Per-unit/channel information 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate uint_t monitor_gain; /* input to output mix: 0 - 255 */ 1087c478bd9Sstevel@tonic-gate uchar_t output_muted; /* non-zero if output is muted */ 1097c478bd9Sstevel@tonic-gate uchar_t ref_cnt; /* driver reference count, read only */ 1107c478bd9Sstevel@tonic-gate uchar_t _xxx[2]; /* Reserved for future use */ 1117c478bd9Sstevel@tonic-gate uint_t hw_features; /* hardware features this driver supports */ 1127c478bd9Sstevel@tonic-gate uint_t sw_features; /* supported SW features */ 1137c478bd9Sstevel@tonic-gate uint_t sw_features_enabled; /* supported SW feat. enabled */ 1147c478bd9Sstevel@tonic-gate }; 1157c478bd9Sstevel@tonic-gate typedef struct audio_info audio_info_t; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * Audio encoding types 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_NONE (0) /* no encoding assigned */ 1227c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_ULAW (1) /* u-law encoding */ 1237c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_ALAW (2) /* A-law encoding */ 1247c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_LINEAR (3) /* Signed Linear PCM encoding */ 1257c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */ 1267c478bd9Sstevel@tonic-gate #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */ 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1297c478bd9Sstevel@tonic-gate * These ranges apply to record, play, and monitor gain values 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate #define AUDIO_MIN_GAIN (0) /* minimum gain value */ 1327c478bd9Sstevel@tonic-gate #define AUDIO_MAX_GAIN (255) /* maximum gain value */ 1337c478bd9Sstevel@tonic-gate #define AUDIO_MID_GAIN (AUDIO_MAX_GAIN / 2) 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * These values apply to the balance field to adjust channel gain values 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate #define AUDIO_LEFT_BALANCE (0) /* left channel only */ 1397c478bd9Sstevel@tonic-gate #define AUDIO_MID_BALANCE (32) /* equal left/right channel */ 1407c478bd9Sstevel@tonic-gate #define AUDIO_RIGHT_BALANCE (64) /* right channel only */ 1417c478bd9Sstevel@tonic-gate #define AUDIO_BALANCE_SHIFT (3) 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* 1447c478bd9Sstevel@tonic-gate * Generic minimum/maximum limits for number of channels, both modes 1457c478bd9Sstevel@tonic-gate */ 1467c478bd9Sstevel@tonic-gate #define AUDIO_CHANNELS_MONO (1) 1477c478bd9Sstevel@tonic-gate #define AUDIO_CHANNELS_STEREO (2) 1487c478bd9Sstevel@tonic-gate #define AUDIO_MIN_PLAY_CHANNELS (AUDIO_CHANNELS_MONO) 1497c478bd9Sstevel@tonic-gate #define AUDIO_MAX_PLAY_CHANNELS (AUDIO_CHANNELS_STEREO) 1507c478bd9Sstevel@tonic-gate #define AUDIO_MIN_REC_CHANNELS (AUDIO_CHANNELS_MONO) 1517c478bd9Sstevel@tonic-gate #define AUDIO_MAX_REC_CHANNELS (AUDIO_CHANNELS_STEREO) 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * Generic minimum/maximum limits for sample precision 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate #define AUDIO_PRECISION_8 (8) 1577c478bd9Sstevel@tonic-gate #define AUDIO_PRECISION_16 (16) 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate #define AUDIO_MIN_PLAY_PRECISION (8) 1607c478bd9Sstevel@tonic-gate #define AUDIO_MAX_PLAY_PRECISION (32) 1617c478bd9Sstevel@tonic-gate #define AUDIO_MIN_REC_PRECISION (8) 1627c478bd9Sstevel@tonic-gate #define AUDIO_MAX_REC_PRECISION (32) 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* 1657c478bd9Sstevel@tonic-gate * Define some convenient names for typical audio ports 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate #define AUDIO_NONE 0x00 /* all ports off */ 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * output ports (several may be enabled simultaneously) 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */ 1727c478bd9Sstevel@tonic-gate #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */ 1737c478bd9Sstevel@tonic-gate #define AUDIO_LINE_OUT 0x04 /* output to line out */ 1747c478bd9Sstevel@tonic-gate #define AUDIO_SPDIF_OUT 0x08 /* output to SPDIF port */ 1757c478bd9Sstevel@tonic-gate #define AUDIO_AUX1_OUT 0x10 /* output to aux1 out */ 1767c478bd9Sstevel@tonic-gate #define AUDIO_AUX2_OUT 0x20 /* output to aux2 out */ 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * input ports (usually only one at a time) 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate #define AUDIO_MICROPHONE 0x01 /* input from microphone */ 1827c478bd9Sstevel@tonic-gate #define AUDIO_LINE_IN 0x02 /* input from line in */ 1837c478bd9Sstevel@tonic-gate #define AUDIO_CD 0x04 /* input from on-board CD inputs */ 1847c478bd9Sstevel@tonic-gate #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */ 1857c478bd9Sstevel@tonic-gate #define AUDIO_SPDIF_IN 0x08 /* input from SPDIF port */ 1867c478bd9Sstevel@tonic-gate #define AUDIO_AUX1_IN 0x10 /* input from aux1 in */ 1877c478bd9Sstevel@tonic-gate #define AUDIO_AUX2_IN 0x20 /* input from aux2 in */ 1887c478bd9Sstevel@tonic-gate #define AUDIO_CODEC_LOOPB_IN 0x40 /* input from Codec internal loopback */ 1897c478bd9Sstevel@tonic-gate #define AUDIO_SUNVTS 0x80 /* SunVTS input setting-internal LB */ 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Define the hw_features 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate #define AUDIO_HWFEATURE_DUPLEX 0x00000001u /* simult. play & rec support */ 1957c478bd9Sstevel@tonic-gate #define AUDIO_HWFEATURE_MSCODEC 0x00000002u /* multi-stream Codec */ 1967c478bd9Sstevel@tonic-gate #define AUDIO_HWFEATURE_IN2OUT 0x00000004u /* input to output loopback */ 1977c478bd9Sstevel@tonic-gate #define AUDIO_HWFEATURE_PLAY 0x00000008u /* device supports play */ 1987c478bd9Sstevel@tonic-gate #define AUDIO_HWFEATURE_RECORD 0x00000010u /* device supports record */ 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate * Define the sw_features 2027c478bd9Sstevel@tonic-gate */ 2037c478bd9Sstevel@tonic-gate #define AUDIO_SWFEATURE_MIXER 0x00000001u /* audio mixer audio pers mod */ 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate /* 2067c478bd9Sstevel@tonic-gate * This macro initializes an audio_info structure to 'harmless' values. 2077c478bd9Sstevel@tonic-gate * Note that (~0) might not be a harmless value for a flag that was 2087c478bd9Sstevel@tonic-gate * a signed int. 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate #define AUDIO_INITINFO(i) { \ 211*9acbbeafSnn uint_t *__x__; \ 212*9acbbeafSnn for (__x__ = (uint_t *)(i); \ 2137c478bd9Sstevel@tonic-gate (char *)__x__ < (((char *)(i)) + sizeof (audio_info_t)); \ 214*9acbbeafSnn *__x__++ = (uint_t)~0); \ 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* 2197c478bd9Sstevel@tonic-gate * Parameter for the AUDIO_GETDEV ioctl to determine current 2207c478bd9Sstevel@tonic-gate * audio devices. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate #define MAX_AUDIO_DEV_LEN (16) 2237c478bd9Sstevel@tonic-gate struct audio_device { 2247c478bd9Sstevel@tonic-gate char name[MAX_AUDIO_DEV_LEN]; 2257c478bd9Sstevel@tonic-gate char version[MAX_AUDIO_DEV_LEN]; 2267c478bd9Sstevel@tonic-gate char config[MAX_AUDIO_DEV_LEN]; 2277c478bd9Sstevel@tonic-gate }; 2287c478bd9Sstevel@tonic-gate typedef struct audio_device audio_device_t; 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* 2327c478bd9Sstevel@tonic-gate * Ioctl calls for the audio device. 2337c478bd9Sstevel@tonic-gate */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* 2367c478bd9Sstevel@tonic-gate * AUDIO_GETINFO retrieves the current state of the audio device. 2377c478bd9Sstevel@tonic-gate * 2387c478bd9Sstevel@tonic-gate * AUDIO_SETINFO copies all fields of the audio_info structure whose 2397c478bd9Sstevel@tonic-gate * values are not set to the initialized value (-1) to the device state. 2407c478bd9Sstevel@tonic-gate * It performs an implicit AUDIO_GETINFO to return the new state of the 2417c478bd9Sstevel@tonic-gate * device. Note that the record.samples and play.samples fields are set 2427c478bd9Sstevel@tonic-gate * to the last value before the AUDIO_SETINFO took effect. This allows 2437c478bd9Sstevel@tonic-gate * an application to reset the counters while atomically retrieving the 2447c478bd9Sstevel@tonic-gate * last value. 2457c478bd9Sstevel@tonic-gate * 2467c478bd9Sstevel@tonic-gate * AUDIO_DRAIN suspends the calling process until the write buffers are 2477c478bd9Sstevel@tonic-gate * empty. 2487c478bd9Sstevel@tonic-gate * 2497c478bd9Sstevel@tonic-gate * AUDIO_GETDEV returns a structure of type audio_device_t which contains 2507c478bd9Sstevel@tonic-gate * three strings. The string "name" is a short identifying string (for 2517c478bd9Sstevel@tonic-gate * example, the SBus Fcode name string), the string "version" identifies 2527c478bd9Sstevel@tonic-gate * the current version of the device, and the "config" string identifies 2537c478bd9Sstevel@tonic-gate * the specific configuration of the audio stream. All fields are 2547c478bd9Sstevel@tonic-gate * device-dependent -- see the device specific manual pages for details. 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate #define AUDIO_GETINFO _IOR('A', 1, audio_info_t) 2577c478bd9Sstevel@tonic-gate #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t) 2587c478bd9Sstevel@tonic-gate #define AUDIO_DRAIN _IO('A', 3) 2597c478bd9Sstevel@tonic-gate #define AUDIO_GETDEV _IOR('A', 4, audio_device_t) 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * The following ioctl sets the audio device into an internal loopback mode, 2637c478bd9Sstevel@tonic-gate * if the hardware supports this. The argument is TRUE to set loopback, 2647c478bd9Sstevel@tonic-gate * FALSE to reset to normal operation. If the hardware does not support 2657c478bd9Sstevel@tonic-gate * internal loopback, the ioctl should fail with EINVAL. 2667c478bd9Sstevel@tonic-gate */ 2677c478bd9Sstevel@tonic-gate #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int) 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate /* 2717c478bd9Sstevel@tonic-gate * Structure sent up as a M_PROTO message on trace streams 2727c478bd9Sstevel@tonic-gate */ 2737c478bd9Sstevel@tonic-gate struct audtrace_hdr { 2747c478bd9Sstevel@tonic-gate uint_t seq; /* Sequence number (per-aud_stream) */ 2757c478bd9Sstevel@tonic-gate int type; /* device-dependent */ 2767c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx) 2777c478bd9Sstevel@tonic-gate struct timeval32 timestamp; 2787c478bd9Sstevel@tonic-gate #else 2797c478bd9Sstevel@tonic-gate struct timeval timestamp; 2807c478bd9Sstevel@tonic-gate #endif 2817c478bd9Sstevel@tonic-gate char _f[8]; /* filler */ 2827c478bd9Sstevel@tonic-gate }; 2837c478bd9Sstevel@tonic-gate typedef struct audtrace_hdr audtrace_hdr_t; 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate #endif 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate #endif /* _SYS_AUDIOIO_H */ 290