audioio.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * include/asm-sparc/audioio.h
  3. *
  4. * Sparc Audio Midlayer
  5. * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
  6. */
  7. #ifndef _AUDIOIO_H_
  8. #define _AUDIOIO_H_
  9. /*
  10. * SunOS/Solaris /dev/audio interface
  11. */
  12. #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  13. #include <linux/types.h>
  14. #include <linux/time.h>
  15. #include <linux/ioctl.h>
  16. #endif
  17. /*
  18. * This structure contains state information for audio device IO streams.
  19. */
  20. typedef struct audio_prinfo {
  21. /*
  22. * The following values describe the audio data encoding.
  23. */
  24. unsigned int sample_rate; /* samples per second */
  25. unsigned int channels; /* number of interleaved channels */
  26. unsigned int precision; /* bit-width of each sample */
  27. unsigned int encoding; /* data encoding method */
  28. /*
  29. * The following values control audio device configuration
  30. */
  31. unsigned int gain; /* gain level: 0 - 255 */
  32. unsigned int port; /* selected I/O port (see below) */
  33. unsigned int avail_ports; /* available I/O ports (see below) */
  34. unsigned int _xxx[2]; /* Reserved for future use */
  35. unsigned int buffer_size; /* I/O buffer size */
  36. /*
  37. * The following values describe driver state
  38. */
  39. unsigned int samples; /* number of samples converted */
  40. unsigned int eof; /* End Of File counter (play only) */
  41. unsigned char pause; /* non-zero for pause, zero to resume */
  42. unsigned char error; /* non-zero if overflow/underflow */
  43. unsigned char waiting; /* non-zero if a process wants access */
  44. unsigned char balance; /* stereo channel balance */
  45. unsigned short minordev;
  46. /*
  47. * The following values are read-only state flags
  48. */
  49. unsigned char open; /* non-zero if open access permitted */
  50. unsigned char active; /* non-zero if I/O is active */
  51. } audio_prinfo_t;
  52. /*
  53. * This structure describes the current state of the audio device.
  54. */
  55. typedef struct audio_info {
  56. /*
  57. * Per-stream information
  58. */
  59. audio_prinfo_t play; /* output status information */
  60. audio_prinfo_t record; /* input status information */
  61. /*
  62. * Per-unit/channel information
  63. */
  64. unsigned int monitor_gain; /* input to output mix: 0 - 255 */
  65. unsigned char output_muted; /* non-zero if output is muted */
  66. unsigned char _xxx[3]; /* Reserved for future use */
  67. unsigned int _yyy[3]; /* Reserved for future use */
  68. } audio_info_t;
  69. /*
  70. * Audio encoding types
  71. */
  72. #define AUDIO_ENCODING_NONE (0) /* no encoding assigned */
  73. #define AUDIO_ENCODING_ULAW (1) /* u-law encoding */
  74. #define AUDIO_ENCODING_ALAW (2) /* A-law encoding */
  75. #define AUDIO_ENCODING_LINEAR (3) /* Linear PCM encoding */
  76. #define AUDIO_ENCODING_FLOAT (4) /* IEEE float (-1. <-> +1.) */
  77. #define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */
  78. #define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */
  79. #define AUDIO_ENCODING_LINEARLE (106) /* Linear PCM LE encoding */
  80. /*
  81. * These ranges apply to record, play, and monitor gain values
  82. */
  83. #define AUDIO_MIN_GAIN (0) /* minimum gain value */
  84. #define AUDIO_MAX_GAIN (255) /* maximum gain value */
  85. /*
  86. * These values apply to the balance field to adjust channel gain values
  87. */
  88. #define AUDIO_LEFT_BALANCE (0) /* left channel only */
  89. #define AUDIO_MID_BALANCE (32) /* equal left/right channel */
  90. #define AUDIO_RIGHT_BALANCE (64) /* right channel only */
  91. #define AUDIO_BALANCE_SHIFT (3)
  92. /*
  93. * Generic minimum/maximum limits for number of channels, both modes
  94. */
  95. #define AUDIO_MIN_PLAY_CHANNELS (1)
  96. #define AUDIO_MAX_PLAY_CHANNELS (4)
  97. #define AUDIO_MIN_REC_CHANNELS (1)
  98. #define AUDIO_MAX_REC_CHANNELS (4)
  99. /*
  100. * Generic minimum/maximum limits for sample precision
  101. */
  102. #define AUDIO_MIN_PLAY_PRECISION (8)
  103. #define AUDIO_MAX_PLAY_PRECISION (32)
  104. #define AUDIO_MIN_REC_PRECISION (8)
  105. #define AUDIO_MAX_REC_PRECISION (32)
  106. /*
  107. * Define some convenient names for typical audio ports
  108. */
  109. /*
  110. * output ports (several may be enabled simultaneously)
  111. */
  112. #define AUDIO_SPEAKER 0x01 /* output to built-in speaker */
  113. #define AUDIO_HEADPHONE 0x02 /* output to headphone jack */
  114. #define AUDIO_LINE_OUT 0x04 /* output to line out */
  115. /*
  116. * input ports (usually only one at a time)
  117. */
  118. #define AUDIO_MICROPHONE 0x01 /* input from microphone */
  119. #define AUDIO_LINE_IN 0x02 /* input from line in */
  120. #define AUDIO_CD 0x04 /* input from on-board CD inputs */
  121. #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */
  122. #define AUDIO_ANALOG_LOOPBACK 0x40 /* input from output */
  123. /*
  124. * This macro initializes an audio_info structure to 'harmless' values.
  125. * Note that (~0) might not be a harmless value for a flag that was
  126. * a signed int.
  127. */
  128. #define AUDIO_INITINFO(i) { \
  129. unsigned int *__x__; \
  130. for (__x__ = (unsigned int *)(i); \
  131. (char *) __x__ < (((char *)(i)) + sizeof (audio_info_t)); \
  132. *__x__++ = ~0); \
  133. }
  134. /*
  135. * These allow testing for what the user wants to set
  136. */
  137. #define AUD_INITVALUE (~0)
  138. #define Modify(X) ((unsigned int)(X) != AUD_INITVALUE)
  139. #define Modifys(X) ((X) != (unsigned short)AUD_INITVALUE)
  140. #define Modifyc(X) ((X) != (unsigned char)AUD_INITVALUE)
  141. /*
  142. * Parameter for the AUDIO_GETDEV ioctl to determine current
  143. * audio devices.
  144. */
  145. #define MAX_AUDIO_DEV_LEN (16)
  146. typedef struct audio_device {
  147. char name[MAX_AUDIO_DEV_LEN];
  148. char version[MAX_AUDIO_DEV_LEN];
  149. char config[MAX_AUDIO_DEV_LEN];
  150. } audio_device_t;
  151. /*
  152. * Ioctl calls for the audio device.
  153. */
  154. /*
  155. * AUDIO_GETINFO retrieves the current state of the audio device.
  156. *
  157. * AUDIO_SETINFO copies all fields of the audio_info structure whose
  158. * values are not set to the initialized value (-1) to the device state.
  159. * It performs an implicit AUDIO_GETINFO to return the new state of the
  160. * device. Note that the record.samples and play.samples fields are set
  161. * to the last value before the AUDIO_SETINFO took effect. This allows
  162. * an application to reset the counters while atomically retrieving the
  163. * last value.
  164. *
  165. * AUDIO_DRAIN suspends the calling process until the write buffers are
  166. * empty.
  167. *
  168. * AUDIO_GETDEV returns a structure of type audio_device_t which contains
  169. * three strings. The string "name" is a short identifying string (for
  170. * example, the SBus Fcode name string), the string "version" identifies
  171. * the current version of the device, and the "config" string identifies
  172. * the specific configuration of the audio stream. All fields are
  173. * device-dependent -- see the device specific manual pages for details.
  174. *
  175. * AUDIO_GETDEV_SUNOS returns a number which is an audio device defined
  176. * herein (making it not too portable)
  177. *
  178. * AUDIO_FLUSH stops all playback and recording, clears all queued buffers,
  179. * resets error counters, and restarts recording and playback as appropriate
  180. * for the current sampling mode.
  181. */
  182. #define AUDIO_GETINFO _IOR('A', 1, audio_info_t)
  183. #define AUDIO_SETINFO _IOWR('A', 2, audio_info_t)
  184. #define AUDIO_DRAIN _IO('A', 3)
  185. #define AUDIO_GETDEV _IOR('A', 4, audio_device_t)
  186. #define AUDIO_GETDEV_SUNOS _IOR('A', 4, int)
  187. #define AUDIO_FLUSH _IO('A', 5)
  188. /* Define possible audio hardware configurations for
  189. * old SunOS-style AUDIO_GETDEV ioctl */
  190. #define AUDIO_DEV_UNKNOWN (0) /* not defined */
  191. #define AUDIO_DEV_AMD (1) /* audioamd device */
  192. #define AUDIO_DEV_SPEAKERBOX (2) /* dbri device with speakerbox */
  193. #define AUDIO_DEV_CODEC (3) /* dbri device (internal speaker) */
  194. #define AUDIO_DEV_CS4231 (5) /* cs4231 device */
  195. /*
  196. * The following ioctl sets the audio device into an internal loopback mode,
  197. * if the hardware supports this. The argument is TRUE to set loopback,
  198. * FALSE to reset to normal operation. If the hardware does not support
  199. * internal loopback, the ioctl should fail with EINVAL.
  200. * Causes ADC data to be digitally mixed in and sent to the DAC.
  201. */
  202. #define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int)
  203. #endif /* _AUDIOIO_H_ */