1 /* $OpenBSD: soundcard.h,v 1.15 2015/01/22 00:07:15 deraadt Exp $ */ 2 /* $NetBSD: soundcard.h,v 1.11 2001/05/09 21:49:58 augustss Exp $ */ 3 4 /*- 5 * Copyright (c) 1997 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Lennart Augustsson. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * WARNING! WARNING! 35 * This is an OSS (Linux) audio emulator. 36 * Use the sndio(7) API for developing new code, and this 37 * only for compiling Linux programs. 38 */ 39 40 #ifndef _SOUNDCARD_H_ 41 #define _SOUNDCARD_H_ 42 43 #ifndef _SYS_IOCTL_H_ 44 #include <sys/ioctl.h> 45 #endif /* !_SYS_IOCTL_H_ */ 46 47 #define SOUND_VERSION 0x030001 48 49 #define SNDCTL_DSP_RESET _IO ('P', 0) 50 #define SNDCTL_DSP_SYNC _IO ('P', 1) 51 #define SNDCTL_DSP_SPEED _IOWR('P', 2, int) 52 #define SOUND_PCM_READ_RATE _IOR ('P', 2, int) 53 #define SNDCTL_DSP_STEREO _IOWR('P', 3, int) 54 #define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int) 55 #define SNDCTL_DSP_SETFMT _IOWR('P', 5, int) 56 #define AFMT_QUERY 0x00000000 57 #define AFMT_MU_LAW 0x00000001 58 #define AFMT_A_LAW 0x00000002 59 #define AFMT_IMA_ADPCM 0x00000004 60 #define AFMT_U8 0x00000008 61 #define AFMT_S16_LE 0x00000010 62 #define AFMT_S16_BE 0x00000020 63 #define AFMT_S8 0x00000040 64 #define AFMT_U16_LE 0x00000080 65 #define AFMT_U16_BE 0x00000100 66 #define AFMT_MPEG 0x00000200 67 #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 68 #define SOUND_PCM_READ_BITS _IOR ('P', 5, int) 69 #define SNDCTL_DSP_CHANNELS _IOWR('P', 6, int) 70 #define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS 71 #define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) 72 #define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) 73 #define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) 74 #define SNDCTL_DSP_POST _IO ('P', 8) 75 #define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) 76 #define SNDCTL_DSP_SETFRAGMENT _IOWR('P', 10, int) 77 #define SNDCTL_DSP_GETFMTS _IOR ('P', 11, int) 78 #define SNDCTL_DSP_GETOSPACE _IOR ('P',12, struct audio_buf_info) 79 #define SNDCTL_DSP_GETISPACE _IOR ('P',13, struct audio_buf_info) 80 #define SNDCTL_DSP_NONBLOCK _IO ('P',14) 81 #define SNDCTL_DSP_GETCAPS _IOR ('P',15, int) 82 # define DSP_CAP_REVISION 0x000000ff 83 # define DSP_CAP_DUPLEX 0x00000100 84 # define DSP_CAP_REALTIME 0x00000200 85 # define DSP_CAP_BATCH 0x00000400 86 # define DSP_CAP_COPROC 0x00000800 87 # define DSP_CAP_TRIGGER 0x00001000 88 # define DSP_CAP_MMAP 0x00002000 89 #define SNDCTL_DSP_GETTRIGGER _IOR ('P', 16, int) 90 #define SNDCTL_DSP_SETTRIGGER _IOW ('P', 16, int) 91 # define PCM_ENABLE_INPUT 0x00000001 92 # define PCM_ENABLE_OUTPUT 0x00000002 93 #define SNDCTL_DSP_GETIPTR _IOR ('P', 17, struct count_info) 94 #define SNDCTL_DSP_GETOPTR _IOR ('P', 18, struct count_info) 95 #define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, struct buffmem_desc) 96 #define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, struct buffmem_desc) 97 #define SNDCTL_DSP_SETSYNCRO _IO ('P', 21) 98 #define SNDCTL_DSP_SETDUPLEX _IO ('P', 22) 99 #define SNDCTL_DSP_PROFILE _IOW ('P', 23, int) 100 #define SNDCTL_DSP_GETODELAY _IOR ('P', 24, int) 101 #define APF_NORMAL 0 102 #define APF_NETWORK 1 103 #define APF_CPUINTENS 2 104 105 /* Need native 16 bit format which depends on byte order */ 106 /* XXX This isn't really a good way, but I don't want to 107 * include all of endian.h because it contains a lot 108 * junk symbols. [augustss] 109 */ 110 #if __BSD_VISIBLE 111 #undef __BSD_VISIBLE 112 #define __BSD_VISIBLE 0 /* avoid dragging in a lot of junk */ 113 #include <machine/endian.h> 114 #undef __BSD_VISIBLE 115 #define __BSD_VISIBLE 1 116 #else 117 #include <machine/endian.h> 118 #endif 119 #if _QUAD_LOWWORD == 0 120 #define AFMT_S16_NE AFMT_S16_LE 121 #else 122 #define AFMT_S16_NE AFMT_S16_BE 123 #endif 124 125 126 /* Aliases */ 127 #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 128 #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 129 #define SOUND_PCM_POST SNDCTL_DSP_POST 130 #define SOUND_PCM_RESET SNDCTL_DSP_RESET 131 #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 132 #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 133 #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 134 #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 135 #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 136 #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 137 #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 138 #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 139 #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 140 #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 141 #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 142 #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 143 #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 144 #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 145 #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 146 #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 147 148 /* Mixer defines */ 149 #define SOUND_MIXER_FIRST 0 150 #define SOUND_MIXER_NRDEVICES 25 151 152 #define SOUND_MIXER_VOLUME 0 153 #define SOUND_MIXER_BASS 1 154 #define SOUND_MIXER_TREBLE 2 155 #define SOUND_MIXER_SYNTH 3 156 #define SOUND_MIXER_PCM 4 157 #define SOUND_MIXER_SPEAKER 5 158 #define SOUND_MIXER_LINE 6 159 #define SOUND_MIXER_MIC 7 160 #define SOUND_MIXER_CD 8 161 #define SOUND_MIXER_IMIX 9 162 #define SOUND_MIXER_ALTPCM 10 163 #define SOUND_MIXER_RECLEV 11 164 #define SOUND_MIXER_IGAIN 12 165 #define SOUND_MIXER_OGAIN 13 166 #define SOUND_MIXER_LINE1 14 167 #define SOUND_MIXER_LINE2 15 168 #define SOUND_MIXER_LINE3 16 169 #define SOUND_MIXER_DIGITAL1 17 170 #define SOUND_MIXER_DIGITAL2 18 171 #define SOUND_MIXER_DIGITAL3 19 172 #define SOUND_MIXER_PHONEIN 20 173 #define SOUND_MIXER_PHONEOUT 21 174 #define SOUND_MIXER_VIDEO 22 175 #define SOUND_MIXER_RADIO 23 176 #define SOUND_MIXER_MONITOR 24 177 178 #define SOUND_ONOFF_MIN 28 179 #define SOUND_ONOFF_MAX 30 180 181 #define SOUND_MIXER_NONE 31 182 183 #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 184 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 185 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 186 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 187 188 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 189 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 190 "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 191 "phin", "phout", "video", "radio", "monitor"} 192 193 #define SOUND_MIXER_RECSRC 0xff 194 #define SOUND_MIXER_DEVMASK 0xfe 195 #define SOUND_MIXER_RECMASK 0xfd 196 #define SOUND_MIXER_CAPS 0xfc 197 #define SOUND_CAP_EXCL_INPUT 1 198 #define SOUND_MIXER_STEREODEVS 0xfb 199 200 #define MIXER_READ(dev) _IOR('M', dev, int) 201 202 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 203 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 204 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 205 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 206 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 207 208 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 209 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 210 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 211 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 212 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 213 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 214 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 215 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 216 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 217 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 218 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 219 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 220 #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 221 #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 222 #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 223 #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 224 #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 225 226 #define MIXER_WRITE(dev) _IOW ('M', dev, int) 227 #define MIXER_WRITE_R(dev) _IOWR('M', dev, int) 228 229 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 230 #define SOUND_MIXER_WRITE_R_RECSRC MIXER_WRITE_R(SOUND_MIXER_RECSRC) 231 232 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 233 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 234 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 235 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 236 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 237 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 238 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 239 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 240 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 241 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 242 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 243 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 244 #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 245 #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 246 #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 247 #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 248 #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 249 250 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 251 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 252 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 253 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 254 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 255 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 256 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 257 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 258 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 259 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 260 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 261 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 262 #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 263 #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 264 #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 265 #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 266 #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 267 #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 268 #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 269 #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 270 #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 271 #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 272 #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 273 #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 274 #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 275 276 typedef struct mixer_info { 277 char id[16]; 278 char name[32]; 279 int modify_counter; 280 int fillers[10]; 281 } mixer_info; 282 283 typedef struct _old_mixer_info { 284 char id[16]; 285 char name[32]; 286 } _old_mixer_info; 287 288 #define SOUND_MIXER_INFO _IOR ('M', 101, mixer_info) 289 #define SOUND_OLD_MIXER_INFO _IOR ('M', 101, _old_mixer_info) 290 291 #define OSS_GETVERSION _IOR ('M', 118, int) 292 293 typedef struct audio_buf_info { 294 int fragments; 295 int fragstotal; 296 int fragsize; 297 int bytes; 298 } audio_buf_info; 299 300 typedef struct count_info { 301 int bytes; 302 int blocks; 303 int ptr; 304 } count_info; 305 306 typedef struct buffmem_desc { 307 unsigned int *buffer; 308 int size; 309 } buffmem_desc; 310 311 #define ioctl _oss_ioctl 312 313 __BEGIN_DECLS 314 int _oss_ioctl(int, unsigned long com, ...); 315 __END_DECLS 316 317 #endif /* !_SOUNDCARD_H_ */ 318