dmasound.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. #ifndef _dmasound_h_
  2. /*
  3. * linux/sound/oss/dmasound/dmasound.h
  4. *
  5. *
  6. * Minor numbers for the sound driver.
  7. *
  8. * Unfortunately Creative called the codec chip of SB as a DSP. For this
  9. * reason the /dev/dsp is reserved for digitized audio use. There is a
  10. * device for true DSP processors but it will be called something else.
  11. * In v3.0 it's /dev/sndproc but this could be a temporary solution.
  12. */
  13. #define _dmasound_h_
  14. #include <linux/types.h>
  15. #define SND_NDEVS 256 /* Number of supported devices */
  16. #define SND_DEV_CTL 0 /* Control port /dev/mixer */
  17. #define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
  18. synthesizer and MIDI output) */
  19. #define SND_DEV_MIDIN 2 /* Raw midi access */
  20. #define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
  21. #define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
  22. #define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
  23. #define SND_DEV_STATUS 6 /* /dev/sndstat */
  24. /* #7 not in use now. Was in 2.4. Free for use after v3.0. */
  25. #define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
  26. #define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
  27. #define SND_DEV_PSS SND_DEV_SNDPROC
  28. /* switch on various prinks */
  29. #define DEBUG_DMASOUND 1
  30. #define MAX_AUDIO_DEV 5
  31. #define MAX_MIXER_DEV 4
  32. #define MAX_SYNTH_DEV 3
  33. #define MAX_MIDI_DEV 6
  34. #define MAX_TIMER_DEV 3
  35. #define MAX_CATCH_RADIUS 10
  36. #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
  37. #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
  38. #define IOCTL_IN(arg, ret) \
  39. do { int error = get_user(ret, (int __user *)(arg)); \
  40. if (error) return error; \
  41. } while (0)
  42. #define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
  43. static inline int ioctl_return(int __user *addr, int value)
  44. {
  45. return value < 0 ? value : put_user(value, addr);
  46. }
  47. /*
  48. * Configuration
  49. */
  50. #undef HAS_8BIT_TABLES
  51. #if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\
  52. defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\
  53. defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE)
  54. #define HAS_8BIT_TABLES
  55. #define MIN_BUFFERS 4
  56. #define MIN_BUFSIZE (1<<12) /* in bytes (- where does this come from ?) */
  57. #define MIN_FRAG_SIZE 8 /* not 100% sure about this */
  58. #define MAX_BUFSIZE (1<<17) /* Limit for Amiga is 128 kb */
  59. #define MAX_FRAG_SIZE 15 /* allow *4 for mono-8 => stereo-16 (for multi) */
  60. #else /* is pmac and multi is off */
  61. #define MIN_BUFFERS 2
  62. #define MIN_BUFSIZE (1<<8) /* in bytes */
  63. #define MIN_FRAG_SIZE 8
  64. #define MAX_BUFSIZE (1<<18) /* this is somewhat arbitrary for pmac */
  65. #define MAX_FRAG_SIZE 16 /* need to allow *4 for mono-8 => stereo-16 */
  66. #endif
  67. #define DEFAULT_N_BUFFERS 4
  68. #define DEFAULT_BUFF_SIZE (1<<15)
  69. /*
  70. * Initialization
  71. */
  72. extern int dmasound_init(void);
  73. #ifdef MODULE
  74. extern void dmasound_deinit(void);
  75. #else
  76. #define dmasound_deinit() do { } while (0)
  77. #endif
  78. /* description of the set-up applies to either hard or soft settings */
  79. typedef struct {
  80. int format; /* AFMT_* */
  81. int stereo; /* 0 = mono, 1 = stereo */
  82. int size; /* 8/16 bit*/
  83. int speed; /* speed */
  84. } SETTINGS;
  85. /*
  86. * Machine definitions
  87. */
  88. typedef struct {
  89. const char *name;
  90. const char *name2;
  91. struct module *owner;
  92. void *(*dma_alloc)(unsigned int, gfp_t);
  93. void (*dma_free)(void *, unsigned int);
  94. int (*irqinit)(void);
  95. #ifdef MODULE
  96. void (*irqcleanup)(void);
  97. #endif
  98. void (*init)(void);
  99. void (*silence)(void);
  100. int (*setFormat)(int);
  101. int (*setVolume)(int);
  102. int (*setBass)(int);
  103. int (*setTreble)(int);
  104. int (*setGain)(int);
  105. void (*play)(void);
  106. void (*record)(void); /* optional */
  107. void (*mixer_init)(void); /* optional */
  108. int (*mixer_ioctl)(u_int, u_long); /* optional */
  109. int (*write_sq_setup)(void); /* optional */
  110. int (*read_sq_setup)(void); /* optional */
  111. int (*sq_open)(fmode_t); /* optional */
  112. int (*state_info)(char *, size_t); /* optional */
  113. void (*abort_read)(void); /* optional */
  114. int min_dsp_speed;
  115. int max_dsp_speed;
  116. int version ;
  117. int hardware_afmts ; /* OSS says we only return h'ware info */
  118. /* when queried via SNDCTL_DSP_GETFMTS */
  119. int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
  120. SETTINGS default_hard ; /* open() or init() should set something valid */
  121. SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
  122. } MACHINE;
  123. /*
  124. * Low level stuff
  125. */
  126. typedef struct {
  127. ssize_t (*ct_ulaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  128. ssize_t (*ct_alaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  129. ssize_t (*ct_s8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  130. ssize_t (*ct_u8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  131. ssize_t (*ct_s16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  132. ssize_t (*ct_u16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  133. ssize_t (*ct_s16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  134. ssize_t (*ct_u16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
  135. } TRANS;
  136. struct sound_settings {
  137. MACHINE mach; /* machine dependent things */
  138. SETTINGS hard; /* hardware settings */
  139. SETTINGS soft; /* software settings */
  140. SETTINGS dsp; /* /dev/dsp default settings */
  141. TRANS *trans_write; /* supported translations */
  142. int volume_left; /* volume (range is machine dependent) */
  143. int volume_right;
  144. int bass; /* tone (range is machine dependent) */
  145. int treble;
  146. int gain;
  147. int minDev; /* minor device number currently open */
  148. spinlock_t lock;
  149. };
  150. extern struct sound_settings dmasound;
  151. #ifdef HAS_8BIT_TABLES
  152. extern char dmasound_ulaw2dma8[];
  153. extern char dmasound_alaw2dma8[];
  154. #endif
  155. /*
  156. * Mid level stuff
  157. */
  158. static inline int dmasound_set_volume(int volume)
  159. {
  160. return dmasound.mach.setVolume(volume);
  161. }
  162. static inline int dmasound_set_bass(int bass)
  163. {
  164. return dmasound.mach.setBass ? dmasound.mach.setBass(bass) : 50;
  165. }
  166. static inline int dmasound_set_treble(int treble)
  167. {
  168. return dmasound.mach.setTreble ? dmasound.mach.setTreble(treble) : 50;
  169. }
  170. static inline int dmasound_set_gain(int gain)
  171. {
  172. return dmasound.mach.setGain ? dmasound.mach.setGain(gain) : 100;
  173. }
  174. /*
  175. * Sound queue stuff, the heart of the driver
  176. */
  177. struct sound_queue {
  178. /* buffers allocated for this queue */
  179. int numBufs; /* real limits on what the user can have */
  180. int bufSize; /* in bytes */
  181. char **buffers;
  182. /* current parameters */
  183. int locked ; /* params cannot be modified when != 0 */
  184. int user_frags ; /* user requests this many */
  185. int user_frag_size ; /* of this size */
  186. int max_count; /* actual # fragments <= numBufs */
  187. int block_size; /* internal block size in bytes */
  188. int max_active; /* in-use fragments <= max_count */
  189. /* it shouldn't be necessary to declare any of these volatile */
  190. int front, rear, count;
  191. int rear_size;
  192. /*
  193. * The use of the playing field depends on the hardware
  194. *
  195. * Atari, PMac: The number of frames that are loaded/playing
  196. *
  197. * Amiga: Bit 0 is set: a frame is loaded
  198. * Bit 1 is set: a frame is playing
  199. */
  200. int active;
  201. wait_queue_head_t action_queue, open_queue, sync_queue;
  202. int non_blocking;
  203. int busy, syncing, xruns, died;
  204. };
  205. #define WAKE_UP(queue) (wake_up_interruptible(&queue))
  206. extern struct sound_queue dmasound_write_sq;
  207. #define write_sq dmasound_write_sq
  208. extern int dmasound_catchRadius;
  209. #define catchRadius dmasound_catchRadius
  210. /* define the value to be put in the byte-swap reg in mac-io
  211. when we want it to swap for us.
  212. */
  213. #define BS_VAL 1
  214. #define SW_INPUT_VOLUME_SCALE 4
  215. #define SW_INPUT_VOLUME_DEFAULT (128 / SW_INPUT_VOLUME_SCALE)
  216. extern int expand_read_bal; /* Balance factor for reading */
  217. extern uint software_input_volume; /* software implemented recording volume! */
  218. #endif /* _dmasound_h_ */