[BACK]Return to audioio.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/audioio.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: audioio.h,v 1.16 2005/12/14 13:59:04 fgsch Exp $      */
                      2: /*     $NetBSD: audioio.h,v 1.24 1998/08/13 06:28:41 mrg Exp $ */
                      3:
                      4: /*
                      5:  * Copyright (c) 1991-1993 Regents of the University of California.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the Computer Systems
                     19:  *     Engineering Group at Lawrence Berkeley Laboratory.
                     20:  * 4. Neither the name of the University nor of the Laboratory may be used
                     21:  *    to endorse or promote products derived from this software without
                     22:  *    specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  */
                     37:
                     38: #ifndef _SYS_AUDIOIO_H_
                     39: #define _SYS_AUDIOIO_H_
                     40:
                     41: /*
                     42:  * Audio device
                     43:  */
                     44: struct audio_prinfo {
                     45:        u_int   sample_rate;    /* sample rate in bit/s */
                     46:        u_int   channels;       /* number of channels, usually 1 or 2 */
                     47:        u_int   precision;      /* number of bits/sample */
                     48:        u_int   encoding;       /* data encoding (AUDIO_ENCODING_* below) */
                     49:        u_int   gain;           /* volume level */
                     50:        u_int   port;           /* selected I/O port */
                     51:        u_int   seek;           /* BSD extension */
                     52:        u_int   avail_ports;    /* available I/O ports */
                     53:        u_int   buffer_size;    /* total size audio buffer */
                     54:        u_int   _ispare[1];
                     55:        /* Current state of device: */
                     56:        u_int   samples;        /* number of samples */
                     57:        u_int   eof;            /* End Of File (zero-size writes) counter */
                     58:        u_char  pause;          /* non-zero if paused, zero to resume */
                     59:        u_char  error;          /* non-zero if underflow/overflow occurred */
                     60:        u_char  waiting;        /* non-zero if another process hangs in open */
                     61:        u_char  balance;        /* stereo channel balance */
                     62:        u_char  cspare[2];
                     63:        u_char  open;           /* non-zero if currently open */
                     64:        u_char  active;         /* non-zero if I/O is currently active */
                     65: };
                     66: typedef struct audio_prinfo audio_prinfo_t;
                     67:
                     68: struct audio_info {
                     69:        struct  audio_prinfo play;      /* Info for play (output) side */
                     70:        struct  audio_prinfo record;    /* Info for record (input) side */
                     71:
                     72:        u_int   monitor_gain;   /* input to output mix */
                     73:        /* BSD extensions */
                     74:        u_int   blocksize;      /* H/W read/write block size */
                     75:        u_int   hiwat;          /* output high water mark */
                     76:        u_int   lowat;          /* output low water mark */
                     77:        u_int   _ispare1;
                     78:        u_int   mode;           /* current device mode */
                     79: #define AUMODE_PLAY    0x01
                     80: #define AUMODE_RECORD  0x02
                     81: #define AUMODE_PLAY_ALL        0x04    /* don't do real-time correction */
                     82: };
                     83: typedef struct audio_info audio_info_t;
                     84:
                     85: #define AUDIO_INITINFO(p) \
                     86:        (void)memset((void *)(p), 0xff, sizeof(struct audio_info))
                     87:
                     88: /*
                     89:  * Parameter for the AUDIO_GETDEV ioctl to determine current
                     90:  * audio devices.
                     91:  */
                     92: #define MAX_AUDIO_DEV_LEN      16
                     93: typedef struct audio_device {
                     94:        char name[MAX_AUDIO_DEV_LEN];
                     95:        char version[MAX_AUDIO_DEV_LEN];
                     96:        char config[MAX_AUDIO_DEV_LEN];
                     97: } audio_device_t;
                     98:
                     99: typedef struct audio_offset {
                    100:        u_int   samples;        /* Total number of bytes transferred */
                    101:        u_int   deltablks;      /* Blocks transferred since last checked */
                    102:        u_int   offset;         /* Physical transfer offset in buffer */
                    103: } audio_offset_t;
                    104:
                    105: /*
                    106:  * Supported audio encodings
                    107:  */
                    108: /* Encoding ID's */
                    109: #define        AUDIO_ENCODING_NONE             0 /* no encoding assigned */
                    110: #define        AUDIO_ENCODING_ULAW             1 /* ITU G.711 mu-law */
                    111: #define        AUDIO_ENCODING_ALAW             2 /* ITU G.711 A-law */
                    112: #define        AUDIO_ENCODING_PCM16            3 /* signed linear PCM, obsolete */
                    113: #define AUDIO_ENCODING_LINEAR          AUDIO_ENCODING_PCM16 /* SunOS compat */
                    114: #define        AUDIO_ENCODING_PCM8             4 /* unsigned linear PCM, obsolete */
                    115: #define AUDIO_ENCODING_LINEAR8         AUDIO_ENCODING_PCM8 /* SunOS compat */
                    116: #define        AUDIO_ENCODING_ADPCM            5 /* adaptive differential PCM */
                    117: #define AUDIO_ENCODING_SLINEAR_LE      6
                    118: #define AUDIO_ENCODING_SLINEAR_BE      7
                    119: #define AUDIO_ENCODING_ULINEAR_LE      8
                    120: #define AUDIO_ENCODING_ULINEAR_BE      9
                    121: #define AUDIO_ENCODING_SLINEAR         10
                    122: #define AUDIO_ENCODING_ULINEAR         11
                    123: #define AUDIO_ENCODING_MPEG_L1_STREAM  12
                    124: #define AUDIO_ENCODING_MPEG_L1_PACKETS 13
                    125: #define AUDIO_ENCODING_MPEG_L1_SYSTEM  14
                    126: #define AUDIO_ENCODING_MPEG_L2_STREAM  15
                    127: #define AUDIO_ENCODING_MPEG_L2_PACKETS 16
                    128: #define AUDIO_ENCODING_MPEG_L2_SYSTEM  17
                    129: #define AUDIO_ENCODING_MPEG_L3_STREAM  18
                    130: #define AUDIO_ENCODING_MPEG_L3_PACKETS 19
                    131: #define AUDIO_ENCODING_MPEG_L3_SYSTEM  20
                    132:
                    133: typedef struct audio_encoding {
                    134:        int     index;
                    135:        char    name[MAX_AUDIO_DEV_LEN];
                    136:        int     encoding;
                    137:        int     precision;
                    138:        int     flags;
                    139: #define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
                    140: } audio_encoding_t;
                    141:
                    142: /*
                    143:  * Balance settings.
                    144:  */
                    145: #define        AUDIO_LEFT_BALANCE      0       /* left channel only    */
                    146: #define        AUDIO_MID_BALANCE       32      /* equal left/right channel */
                    147: #define        AUDIO_RIGHT_BALANCE     64      /* right channel only   */
                    148: #define        AUDIO_BALANCE_SHIFT     3
                    149:
                    150: /*
                    151:  * Output ports
                    152:  */
                    153: #define        AUDIO_SPEAKER           0x01    /* built-in speaker */
                    154: #define        AUDIO_HEADPHONE         0x02    /* headphone jack */
                    155: #define        AUDIO_LINE_OUT          0x04    /* line out      */
                    156:
                    157: /*
                    158:  * Input ports
                    159:  */
                    160: #define        AUDIO_MICROPHONE        0x01    /* microphone */
                    161: #define        AUDIO_LINE_IN           0x02    /* line in       */
                    162: #define        AUDIO_CD                0x04    /* on-board CD inputs */
                    163: #define        AUDIO_INTERNAL_CD_IN    AUDIO_CD        /* internal CDROM */
                    164:
                    165: /*
                    166:  * Audio device operations
                    167:  */
                    168: #define AUDIO_GETINFO  _IOR('A', 21, struct audio_info)
                    169: #define AUDIO_SETINFO  _IOWR('A', 22, struct audio_info)
                    170: #define AUDIO_DRAIN    _IO('A', 23)
                    171: #define AUDIO_FLUSH    _IO('A', 24)
                    172: #define AUDIO_WSEEK    _IOR('A', 25, u_long)
                    173: #define AUDIO_RERROR   _IOR('A', 26, int)
                    174: #define AUDIO_GETDEV   _IOR('A', 27, struct audio_device)
                    175: #define AUDIO_GETENC   _IOWR('A', 28, struct audio_encoding)
                    176: #define AUDIO_GETFD    _IOR('A', 29, int)
                    177: #define AUDIO_SETFD    _IOWR('A', 30, int)
                    178: #define AUDIO_PERROR   _IOR('A', 31, int)
                    179: #define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset)
                    180: #define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset)
                    181: #define AUDIO_GETPROPS _IOR('A', 34, int)
                    182: #define  AUDIO_PROP_FULLDUPLEX 0x01
                    183: #define  AUDIO_PROP_MMAP       0x02
                    184: #define  AUDIO_PROP_INDEPENDENT        0x04
                    185:
                    186: /*
                    187:  * Mixer device
                    188:  */
                    189: #define AUDIO_MIN_GAIN 0
                    190: #define AUDIO_MAX_GAIN 255
                    191:
                    192: typedef struct mixer_level {
                    193:        int num_channels;
                    194:        u_char level[8];        /* [num_channels] */
                    195: } mixer_level_t;
                    196: #define AUDIO_MIXER_LEVEL_MONO 0
                    197: #define AUDIO_MIXER_LEVEL_LEFT 0
                    198: #define AUDIO_MIXER_LEVEL_RIGHT        1
                    199:
                    200: /*
                    201:  * Device operations
                    202:  */
                    203:
                    204: typedef struct audio_mixer_name {
                    205:        char name[MAX_AUDIO_DEV_LEN];
                    206:        int msg_id;
                    207: } audio_mixer_name_t;
                    208:
                    209: typedef struct mixer_devinfo {
                    210:        int index;
                    211:        audio_mixer_name_t label;
                    212:        int type;
                    213: #define AUDIO_MIXER_CLASS      0
                    214: #define AUDIO_MIXER_ENUM       1
                    215: #define AUDIO_MIXER_SET                2
                    216: #define AUDIO_MIXER_VALUE      3
                    217:        int mixer_class;
                    218:        int next, prev;
                    219: #define AUDIO_MIXER_LAST       -1
                    220:        union {
                    221:                struct audio_mixer_enum {
                    222:                        int num_mem;
                    223:                        struct {
                    224:                                audio_mixer_name_t label;
                    225:                                int ord;
                    226:                        } member[32];
                    227:                } e;
                    228:                struct audio_mixer_set {
                    229:                        int num_mem;
                    230:                        struct {
                    231:                                audio_mixer_name_t label;
                    232:                                int mask;
                    233:                        } member[32];
                    234:                } s;
                    235:                struct audio_mixer_value {
                    236:                        audio_mixer_name_t units;
                    237:                        int num_channels;
                    238:                        int delta;
                    239:                } v;
                    240:        } un;
                    241: } mixer_devinfo_t;
                    242:
                    243:
                    244: typedef struct mixer_ctrl {
                    245:        int dev;
                    246:        int type;
                    247:        union {
                    248:                int ord;                /* enum */
                    249:                int mask;               /* set */
                    250:                mixer_level_t value;    /* value */
                    251:        } un;
                    252: } mixer_ctrl_t;
                    253:
                    254: /*
                    255:  * Mixer operations
                    256:  */
                    257: #define AUDIO_MIXER_READ               _IOWR('M', 0, mixer_ctrl_t)
                    258: #define AUDIO_MIXER_WRITE              _IOWR('M', 1, mixer_ctrl_t)
                    259: #define AUDIO_MIXER_DEVINFO            _IOWR('M', 2, mixer_devinfo_t)
                    260:
                    261: /*
                    262:  * Well known device names
                    263:  */
                    264: #define AudioNmicrophone       "mic"
                    265: #define AudioNline     "line"
                    266: #define AudioNcd       "cd"
                    267: #define AudioNdac      "dac"
                    268: #define AudioNaux      "aux"
                    269: #define AudioNrecord   "record"
                    270: #define AudioNvolume   "volume"
                    271: #define AudioNmonitor  "monitor"
                    272: #define AudioNtreble   "treble"
                    273: #define AudioNmid      "mid"
                    274: #define AudioNbass     "bass"
                    275: #define AudioNbassboost        "bassboost"
                    276: #define AudioNspeaker  "speaker"
                    277: #define AudioNheadphone        "headphones"
                    278: #define AudioNoutput   "output"
                    279: #define AudioNinput    "input"
                    280: #define AudioNmaster   "master"
                    281: #define AudioNstereo   "stereo"
                    282: #define AudioNmono     "mono"
                    283: #define AudioNloudness "loudness"
                    284: #define AudioNspatial  "spatial"
                    285: #define AudioNsurround "surround"
                    286: #define AudioNpseudo   "pseudo"
                    287: #define AudioNmute     "mute"
                    288: #define AudioNenhanced "enhanced"
                    289: #define AudioNpreamp   "preamp"
                    290: #define AudioNon       "on"
                    291: #define AudioNoff      "off"
                    292: #define AudioNmode     "mode"
                    293: #define AudioNsource   "source"
                    294: #define AudioNfmsynth  "fmsynth"
                    295: #define AudioNwave     "wave"
                    296: #define AudioNmidi     "midi"
                    297: #define AudioNmixerout "mixerout"
                    298: #define AudioNswap     "swap"  /* swap left and right channels */
                    299: #define AudioNagc      "agc"
                    300: #define AudioNdelay    "delay"
                    301: #define AudioNselect   "select" /* select destination */
                    302: #define AudioNvideo    "video"
                    303: #define AudioNcenter   "center"
                    304: #define AudioNdepth    "depth"
                    305: #define AudioNlfe      "lfe"
                    306: #define AudioNextamp   "extamp"
                    307:
                    308: #define AudioEmulaw            "mulaw"
                    309: #define AudioEalaw             "alaw"
                    310: #define AudioEadpcm            "adpcm"
                    311: #define AudioEslinear          "slinear"
                    312: #define AudioEslinear_le       "slinear_le"
                    313: #define AudioEslinear_be       "slinear_be"
                    314: #define AudioEulinear          "ulinear"
                    315: #define AudioEulinear_le       "ulinear_le"
                    316: #define AudioEulinear_be       "ulinear_be"
                    317: #define AudioEmpeg_l1_stream   "mpeg_l1_stream"
                    318: #define AudioEmpeg_l1_packets  "mpeg_l1_packets"
                    319: #define AudioEmpeg_l1_system   "mpeg_l1_system"
                    320: #define AudioEmpeg_l2_stream   "mpeg_l2_stream"
                    321: #define AudioEmpeg_l2_packets  "mpeg_l2_packets"
                    322: #define AudioEmpeg_l2_system   "mpeg_l2_system"
                    323:
                    324: #define AudioCinputs   "inputs"
                    325: #define AudioCoutputs  "outputs"
                    326: #define AudioCrecord   "record"
                    327: #define AudioCmonitor  "monitor"
                    328: #define AudioCequalization     "equalization"
                    329:
                    330: #endif /* !_SYS_AUDIOIO_H_ */

CVSweb