1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_LX_IOCTL_H 27 #define _SYS_LX_IOCTL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 extern int lx_ioctl_init(void); 36 37 /* 38 * LX_NCC must be different from LX_NCCS since while the termio and termios 39 * structures may look similar they are fundamentally different sizes and 40 * have different members. 41 */ 42 #define LX_NCC 8 43 #define LX_NCCS 19 44 45 struct lx_termio { 46 unsigned short c_iflag; /* input mode flags */ 47 unsigned short c_oflag; /* output mode flags */ 48 unsigned short c_cflag; /* control mode flags */ 49 unsigned short c_lflag; /* local mode flags */ 50 unsigned char c_line; /* line discipline */ 51 unsigned char c_cc[LX_NCC]; /* control characters */ 52 }; 53 54 struct lx_termios { 55 uint32_t c_iflag; /* input mode flags */ 56 uint32_t c_oflag; /* output mode flags */ 57 uint32_t c_cflag; /* control mode flags */ 58 uint32_t c_lflag; /* local mode flags */ 59 unsigned char c_line; /* line discipline */ 60 unsigned char c_cc[LX_NCCS]; /* control characters */ 61 }; 62 63 /* 64 * c_cc characters which are valid for lx_termio and lx_termios 65 */ 66 #define LX_VINTR 0 67 #define LX_VQUIT 1 68 #define LX_VERASE 2 69 #define LX_VKILL 3 70 #define LX_VEOF 4 71 #define LX_VTIME 5 72 #define LX_VMIN 6 73 #define LX_VSWTC 7 74 75 /* 76 * c_cc characters which are valid for lx_termios 77 */ 78 #define LX_VSTART 8 79 #define LX_VSTOP 9 80 #define LX_VSUSP 10 81 #define LX_VEOL 11 82 #define LX_VREPRINT 12 83 #define LX_VDISCARD 13 84 #define LX_VWERASE 14 85 #define LX_VLNEXT 15 86 #define LX_VEOL2 16 87 88 /* 89 * Sound formats 90 */ 91 #define LX_AFMT_QUERY 0x00000000 92 #define LX_AFMT_MU_LAW 0x00000001 93 #define LX_AFMT_A_LAW 0x00000002 94 #define LX_AFMT_IMA_ADPCM 0x00000004 95 #define LX_AFMT_U8 0x00000008 96 #define LX_AFMT_S16_LE 0x00000010 97 #define LX_AFMT_S16_BE 0x00000020 98 #define LX_AFMT_S8 0x00000040 99 #define LX_AFMT_U16_LE 0x00000080 100 #define LX_AFMT_U16_BE 0x00000100 101 #define LX_AFMT_MPEG 0x00000200 102 #define LX_AFMT_AC3 0x00000400 103 104 /* 105 * Supported ioctls 106 */ 107 #define LX_TCGETS 0x5401 108 #define LX_TCSETS 0x5402 109 #define LX_TCSETSW 0x5403 110 #define LX_TCSETSF 0x5404 111 #define LX_TCGETA 0x5405 112 #define LX_TCSETA 0x5406 113 #define LX_TCSETAW 0x5407 114 #define LX_TCSETAF 0x5408 115 #define LX_TCSBRK 0x5409 116 #define LX_TCXONC 0x540a 117 #define LX_TCFLSH 0x540b 118 #define LX_TIOCEXCL 0x540c 119 #define LX_TIOCNXCL 0x540d 120 #define LX_TIOCSCTTY 0x540e 121 #define LX_TIOCGPGRP 0x540f 122 #define LX_TIOCSPGRP 0x5410 123 #define LX_TIOCOUTQ 0x5411 124 #define LX_TIOCSTI 0x5412 125 #define LX_TIOCGWINSZ 0x5413 126 #define LX_TIOCSWINSZ 0x5414 127 #define LX_TIOCMGET 0x5415 128 #define LX_TIOCMBIS 0x5416 129 #define LX_TIOCMBIC 0x5417 130 #define LX_TIOCMSET 0x5418 131 #define LX_TIOCGSOFTCAR 0x5419 132 #define LX_TIOCSSOFTCAR 0x541a 133 #define LX_FIONREAD 0x541b 134 #define LX_TIOCPKT 0x5420 135 #define LX_FIONBIO 0x5421 136 #define LX_TIOCNOTTY 0x5422 137 #define LX_TIOCSETD 0x5423 138 #define LX_TIOCGETD 0x5424 139 #define LX_TCSBRKP 0x5425 140 #define LX_TIOCGSID 0x5429 141 #define LX_TIOCGPTN 0x80045430 142 #define LX_TIOCSPTLCK 0x40045431 143 #define LX_FIONCLEX 0x5450 144 #define LX_FIOCLEX 0x5451 145 #define LX_FIOASYNC 0x5452 146 #define LX_FIOSETOWN 0x8901 147 #define LX_SIOCSPGRP 0x8902 148 #define LX_FIOGETOWN 0x8903 149 #define LX_SIOCGPGRP 0x8904 150 #define LX_SIOCATMARK 0x8905 151 #define LX_SIOCGIFCONF 0x8912 152 #define LX_SIOCGIFFLAGS 0x8913 153 #define LX_SIOCSIFFLAGS 0x8914 154 #define LX_SIOCGIFADDR 0x8915 155 #define LX_SIOCSIFADDR 0x8916 156 #define LX_SIOCGIFDSTADDR 0x8917 157 #define LX_SIOCSIFDSTADDR 0x8918 158 #define LX_SIOCGIFBRDADDR 0x8919 159 #define LX_SIOCSIFBRDADDR 0x891a 160 #define LX_SIOCGIFNETMASK 0x891b 161 #define LX_SIOCSIFNETMASK 0x891c 162 #define LX_SIOCGIFMETRIC 0x891d 163 #define LX_SIOCSIFMETRIC 0x891e 164 #define LX_SIOCGIFMEM 0x891f 165 #define LX_SIOCSIFMEM 0x8920 166 #define LX_SIOCGIFMTU 0x8921 167 #define LX_SIOCSIFMTU 0x8922 168 #define LX_SIOCSIFHWADDR 0x8924 169 #define LX_SIOCGIFHWADDR 0x8927 170 171 /* 172 * /dev/dsp ioctls - supported 173 */ 174 #define LX_OSS_SNDCTL_DSP_RESET 0x5000 175 #define LX_OSS_SNDCTL_DSP_SYNC 0x5001 176 #define LX_OSS_SNDCTL_DSP_SPEED 0xc0045002 177 #define LX_OSS_SNDCTL_DSP_STEREO 0xc0045003 178 #define LX_OSS_SNDCTL_DSP_GETBLKSIZE 0xc0045004 179 #define LX_OSS_SNDCTL_DSP_SETFMTS 0xc0045005 180 #define LX_OSS_SNDCTL_DSP_CHANNELS 0xc0045006 181 #define LX_OSS_SNDCTL_DSP_SETFRAGMENT 0xc004500a 182 #define LX_OSS_SNDCTL_DSP_GETFMTS 0x8004500b 183 #define LX_OSS_SNDCTL_DSP_GETOSPACE 0x8010500c 184 #define LX_OSS_SNDCTL_DSP_GETCAPS 0x8004500f 185 #define LX_OSS_SNDCTL_DSP_SETTRIGGER 0x40045010 186 #define LX_OSS_SNDCTL_DSP_GETOPTR 0x800c5012 187 #define LX_OSS_SNDCTL_DSP_GETISPACE 0x8010500d 188 189 /* 190 * support for /dev/dsp SNDCTL_DSP_GETFMTS and SNDCTL_DSP_SETFMTS 191 */ 192 #define LX_OSS_AFMT_QUERY 0x0000 193 #define LX_OSS_AFMT_MU_LAW 0x0001 194 #define LX_OSS_AFMT_A_LAW 0x0002 195 #define LX_OSS_AFMT_IMA_ADPCM 0x0004 196 #define LX_OSS_AFMT_U8 0x0008 197 #define LX_OSS_AFMT_S16_LE 0x0010 198 #define LX_OSS_AFMT_S16_BE 0x0020 199 #define LX_OSS_AFMT_S8 0x0040 200 #define LX_OSS_AFMT_U16_LE 0x0080 201 #define LX_OSS_AFMT_U16_BE 0x0100 202 #define LX_OSS_AFMT_MPEG 0x0200 203 204 #ifdef _LITTLE_ENDIAN 205 #define LX_OSS_AFMT_S16_NE LX_OSS_AFMT_S16_LE 206 #define LX_OSS_AFMT_U16_NE LX_OSS_AFMT_U16_LE 207 #elif defined(_BIG_ENDIAN) 208 #define LX_OSS_AFMT_S16_NE LX_OSS_AFMT_S16_BE 209 #define LX_OSS_AFMT_U16_NE LX_OSS_AFMT_U16_BE 210 #else /* _LITTLE_ENDIAN */ 211 #error NO ENDIAN defined. 212 #endif /* _LITTLE_ENDIAN */ 213 214 /* 215 * support for /dev/dsp SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE 216 */ 217 typedef struct lx_oss_audio_buf_info { 218 int fragments; /* fragments that can be rd/wr without blocking */ 219 int fragstotal; /* total number of fragments allocated for buffering */ 220 int fragsize; /* size of fragments, same as SNDCTL_DSP_GETBLKSIZE */ 221 int bytes; /* what can be rd/wr immediatly without blocking */ 222 } lx_oss_audio_buf_info_t; 223 224 /* 225 * support for /dev/dsp SNDCTL_DSP_GETOPTR 226 */ 227 typedef struct lx_oss_count_info { 228 /* # of bytes processed since opening the device */ 229 int bytes; 230 231 /* 232 * # of fragment transitions since last call to this function. 233 * only valid for mmap acess mode. 234 */ 235 int blocks; 236 237 /* 238 * byte offset of the current recording/playback position from 239 * the beginning of the audio buffer. only valid for mmap access 240 * mode. 241 */ 242 int ptr; 243 } lx_oss_count_info_t; 244 245 /* 246 * support for /dev/dsp SNDCTL_DSP_GETCAPS 247 */ 248 #define LX_OSS_DSP_CAP_TRIGGER 0x1000 249 #define LX_OSS_DSP_CAP_MMAP 0x2000 250 251 /* 252 * support for /dev/dsp/ SNDCTL_DSP_SETTRIGGER 253 */ 254 #define LX_OSS_PCM_DISABLE_OUTPUT 0 255 #define LX_OSS_PCM_ENABLE_OUTPUT 2 256 257 /* 258 * /dev/mixer ioctl macros 259 */ 260 #define LX_OSS_SM_NRDEVICES 25 261 #define LX_OSS_SM_READ(x) (0x80044d00 | (x)) 262 #define LX_OSS_SM_WRITE(x) (0xc0044d00 | (x)) 263 264 /* 265 * /dev/mixer ioctls - supported 266 */ 267 #define LX_OSS_SOUND_MIXER_READ_VOLUME LX_OSS_SM_READ(LX_OSS_SM_VOLUME) 268 #define LX_OSS_SOUND_MIXER_READ_PCM LX_OSS_SM_READ(LX_OSS_SM_PCM) 269 #define LX_OSS_SOUND_MIXER_READ_MIC LX_OSS_SM_READ(LX_OSS_SM_MIC) 270 #define LX_OSS_SOUND_MIXER_READ_IGAIN LX_OSS_SM_READ(LX_OSS_SM_IGAIN) 271 #define LX_OSS_SOUND_MIXER_WRITE_VOLUME LX_OSS_SM_WRITE(LX_OSS_SM_VOLUME) 272 #define LX_OSS_SOUND_MIXER_WRITE_PCM LX_OSS_SM_WRITE(LX_OSS_SM_PCM) 273 #define LX_OSS_SOUND_MIXER_WRITE_MIC LX_OSS_SM_WRITE(LX_OSS_SM_MIC) 274 #define LX_OSS_SOUND_MIXER_WRITE_IGAIN LX_OSS_SM_WRITE(LX_OSS_SM_IGAIN) 275 #define LX_OSS_SOUND_MIXER_READ_STEREODEVS LX_OSS_SM_READ(LX_OSS_SM_STEREODEVS) 276 #define LX_OSS_SOUND_MIXER_READ_RECMASK LX_OSS_SM_READ(LX_OSS_SM_RECMASK) 277 #define LX_OSS_SOUND_MIXER_READ_DEVMASK LX_OSS_SM_READ(LX_OSS_SM_DEVMASK) 278 #define LX_OSS_SOUND_MIXER_READ_RECSRC LX_OSS_SM_READ(LX_OSS_SM_RECSRC) 279 280 /* 281 * /dev/mixer channels 282 */ 283 #define LX_OSS_SM_VOLUME 0 284 #define LX_OSS_SM_BASS 1 285 #define LX_OSS_SM_TREBLE 2 286 #define LX_OSS_SM_SYNTH 3 287 #define LX_OSS_SM_PCM 4 288 #define LX_OSS_SM_SPEAKER 5 289 #define LX_OSS_SM_LINE 6 290 #define LX_OSS_SM_MIC 7 291 #define LX_OSS_SM_CD 8 292 #define LX_OSS_SM_MIX 9 293 #define LX_OSS_SM_PCM2 10 294 #define LX_OSS_SM_REC 11 295 #define LX_OSS_SM_IGAIN 12 296 #define LX_OSS_SM_OGAIN 13 297 #define LX_OSS_SM_LINE1 14 298 #define LX_OSS_SM_LINE2 15 299 #define LX_OSS_SM_LINE3 16 300 #define LX_OSS_SM_DIGITAL1 17 301 #define LX_OSS_SM_DIGITAL2 18 302 #define LX_OSS_SM_DIGITAL3 19 303 #define LX_OSS_SM_PHONEIN 20 304 #define LX_OSS_SM_PHONEOUT 21 305 #define LX_OSS_SM_VIDEO 22 306 #define LX_OSS_SM_RADIO 23 307 #define LX_OSS_SM_MONITOR 24 308 309 /* 310 * /dev/mixer operations 311 */ 312 #define LX_OSS_SM_STEREODEVS 251 313 #define LX_OSS_SM_CAPS 252 314 #define LX_OSS_SM_RECMASK 253 315 #define LX_OSS_SM_DEVMASK 254 316 #define LX_OSS_SM_RECSRC 255 317 318 /* 319 * /dev/mixer value conversion macros 320 * 321 * solaris expects gain level on a scale of 0 - 255 322 * oss expects gain level on a scale of 0 - 100 323 * 324 * oss also encodes multiple channels volume values in a single int, 325 * one channel value per byte. 326 */ 327 #define LX_OSS_S2L_GAIN(v) (((v) * 100) / 255) 328 #define LX_OSS_L2S_GAIN(v) (((v) * 255) / 100) 329 #define LX_OSS_MIXER_DEC1(v) ((v) & 0xff) 330 #define LX_OSS_MIXER_DEC2(v) (((v) >> 8) & 0xff) 331 #define LX_OSS_MIXER_ENC2(v1, v2) (((v2) << 8) | (v1)) 332 333 /* 334 * /dev/mixer value verification macros 335 */ 336 #define LX_OSS_MIXER_VCHECK(x) (((int)(x) >= 0) && ((int)(x) <= 100)) 337 #define LX_OSS_MIXER_1CH_OK(x) ((((x) & ~0xff) == 0) && \ 338 LX_OSS_MIXER_VCHECK(LX_OSS_MIXER_DEC1(x))) 339 #define LX_OSS_MIXER_2CH_OK(x) ((((x) & ~0xffff) == 0) && \ 340 LX_OSS_MIXER_VCHECK(LX_OSS_MIXER_DEC1(x)) && \ 341 LX_OSS_MIXER_VCHECK(LX_OSS_MIXER_DEC2(x))) 342 343 /* 344 * Unsupported ioctls (NOT a comprehensive list) 345 */ 346 #define LX_TIOCLINUX 0x541c 347 #define LX_TIOCCONS 0x541d 348 #define LX_TIOCGSERIAL 0x541e 349 #define LX_TIOCSSERIAL 0x541f 350 #define LX_TIOCTTYGSTRUCT 0x5426 351 #define LX_TIOCSERCONFIG 0x5453 352 #define LX_TIOCSERGWILD 0x5454 353 #define LX_TIOCSERSWILD 0x5455 354 #define LX_TIOCGLCKTRMIOS 0x5456 355 #define LX_TIOCSLCKTRMIOS 0x5457 356 #define LX_TIOCSERGSTRUCT 0x5458 357 #define LX_TIOCSERGETLSR 0x5459 358 #define LX_TIOCSERGETMULTI 0x545a 359 #define LX_TIOCSERSETMULTI 0x545b 360 #define LX_OLD_SIOCGIFHWADDR 0x8923 361 #define LX_SIOCSIFENCAP 0x8926 362 #define LX_SIOCGIFSLAVE 0x8929 363 #define LX_SIOCSIFSLAVE 0x8930 364 #define LX_SIOCADDMULTI 0x8931 365 #define LX_SIOCDELMULTI 0x8932 366 #define LX_SIOCADDRTOLD 0x8940 367 #define LX_SIOCDELRTOLD 0x8941 368 #define LX_SIOCGIFTXQLEN 0x8942 369 #define LX_SIOCDARP 0x8950 370 #define LX_SIOCGARP 0x8951 371 #define LX_SIOCSARP 0x8952 372 #define LX_SIOCDRARP 0x8960 373 #define LX_SIOCGRARP 0x8961 374 #define LX_SIOCSRARP 0x8962 375 #define LX_SIOCGIFMAP 0x8970 376 #define LX_SIOCSIFMAP 0x8971 377 378 #ifdef __cplusplus 379 } 380 #endif 381 382 #endif /* _SYS_LX_IOCTL_H */