msnd.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*********************************************************************
  2. *
  3. * msnd.h
  4. *
  5. * Turtle Beach MultiSound Sound Card Driver for Linux
  6. *
  7. * Some parts of this header file were derived from the Turtle Beach
  8. * MultiSound Driver Development Kit.
  9. *
  10. * Copyright (C) 1998 Andrew Veliath
  11. * Copyright (C) 1993 Turtle Beach Systems, Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. *
  27. ********************************************************************/
  28. #ifndef __MSND_H
  29. #define __MSND_H
  30. #define VERSION "0.8.3.1"
  31. #define DEFSAMPLERATE DSP_DEFAULT_SPEED
  32. #define DEFSAMPLESIZE AFMT_U8
  33. #define DEFCHANNELS 1
  34. #define DEFFIFOSIZE 128
  35. #define SNDCARD_MSND 38
  36. #define SRAM_BANK_SIZE 0x8000
  37. #define SRAM_CNTL_START 0x7F00
  38. #define DSP_BASE_ADDR 0x4000
  39. #define DSP_BANK_BASE 0x4000
  40. #define HP_ICR 0x00
  41. #define HP_CVR 0x01
  42. #define HP_ISR 0x02
  43. #define HP_IVR 0x03
  44. #define HP_NU 0x04
  45. #define HP_INFO 0x04
  46. #define HP_TXH 0x05
  47. #define HP_RXH 0x05
  48. #define HP_TXM 0x06
  49. #define HP_RXM 0x06
  50. #define HP_TXL 0x07
  51. #define HP_RXL 0x07
  52. #define HP_ICR_DEF 0x00
  53. #define HP_CVR_DEF 0x12
  54. #define HP_ISR_DEF 0x06
  55. #define HP_IVR_DEF 0x0f
  56. #define HP_NU_DEF 0x00
  57. #define HP_IRQM 0x09
  58. #define HPR_BLRC 0x08
  59. #define HPR_SPR1 0x09
  60. #define HPR_SPR2 0x0A
  61. #define HPR_TCL0 0x0B
  62. #define HPR_TCL1 0x0C
  63. #define HPR_TCL2 0x0D
  64. #define HPR_TCL3 0x0E
  65. #define HPR_TCL4 0x0F
  66. #define HPICR_INIT 0x80
  67. #define HPICR_HM1 0x40
  68. #define HPICR_HM0 0x20
  69. #define HPICR_HF1 0x10
  70. #define HPICR_HF0 0x08
  71. #define HPICR_TREQ 0x02
  72. #define HPICR_RREQ 0x01
  73. #define HPCVR_HC 0x80
  74. #define HPISR_HREQ 0x80
  75. #define HPISR_DMA 0x40
  76. #define HPISR_HF3 0x10
  77. #define HPISR_HF2 0x08
  78. #define HPISR_TRDY 0x04
  79. #define HPISR_TXDE 0x02
  80. #define HPISR_RXDF 0x01
  81. #define HPIO_290 0
  82. #define HPIO_260 1
  83. #define HPIO_250 2
  84. #define HPIO_240 3
  85. #define HPIO_230 4
  86. #define HPIO_220 5
  87. #define HPIO_210 6
  88. #define HPIO_3E0 7
  89. #define HPMEM_NONE 0
  90. #define HPMEM_B000 1
  91. #define HPMEM_C800 2
  92. #define HPMEM_D000 3
  93. #define HPMEM_D400 4
  94. #define HPMEM_D800 5
  95. #define HPMEM_E000 6
  96. #define HPMEM_E800 7
  97. #define HPIRQ_NONE 0
  98. #define HPIRQ_5 1
  99. #define HPIRQ_7 2
  100. #define HPIRQ_9 3
  101. #define HPIRQ_10 4
  102. #define HPIRQ_11 5
  103. #define HPIRQ_12 6
  104. #define HPIRQ_15 7
  105. #define HIMT_PLAY_DONE 0x00
  106. #define HIMT_RECORD_DONE 0x01
  107. #define HIMT_MIDI_EOS 0x02
  108. #define HIMT_MIDI_OUT 0x03
  109. #define HIMT_MIDI_IN_UCHAR 0x0E
  110. #define HIMT_DSP 0x0F
  111. #define HDEX_BASE 0x92
  112. #define HDEX_PLAY_START (0 + HDEX_BASE)
  113. #define HDEX_PLAY_STOP (1 + HDEX_BASE)
  114. #define HDEX_PLAY_PAUSE (2 + HDEX_BASE)
  115. #define HDEX_PLAY_RESUME (3 + HDEX_BASE)
  116. #define HDEX_RECORD_START (4 + HDEX_BASE)
  117. #define HDEX_RECORD_STOP (5 + HDEX_BASE)
  118. #define HDEX_MIDI_IN_START (6 + HDEX_BASE)
  119. #define HDEX_MIDI_IN_STOP (7 + HDEX_BASE)
  120. #define HDEX_MIDI_OUT_START (8 + HDEX_BASE)
  121. #define HDEX_MIDI_OUT_STOP (9 + HDEX_BASE)
  122. #define HDEX_AUX_REQ (10 + HDEX_BASE)
  123. #define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xFFFF))
  124. #define LOWORD(l) ((WORD)(DWORD)(l))
  125. #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
  126. #define LOBYTE(w) ((BYTE)(w))
  127. #define MAKELONG(low,hi) ((long)(((WORD)(low))|(((DWORD)((WORD)(hi)))<<16)))
  128. #define MAKEWORD(low,hi) ((WORD)(((BYTE)(low))|(((WORD)((BYTE)(hi)))<<8)))
  129. #define PCTODSP_OFFSET(w) (USHORT)((w)/2)
  130. #define PCTODSP_BASED(w) (USHORT)(((w)/2) + DSP_BASE_ADDR)
  131. #define DSPTOPC_BASED(w) (((w) - DSP_BASE_ADDR) * 2)
  132. #ifdef SLOWIO
  133. #define msnd_outb outb_p
  134. #define msnd_inb inb_p
  135. #else
  136. #define msnd_outb outb
  137. #define msnd_inb inb
  138. #endif
  139. /* JobQueueStruct */
  140. #define JQS_wStart 0x00
  141. #define JQS_wSize 0x02
  142. #define JQS_wHead 0x04
  143. #define JQS_wTail 0x06
  144. #define JQS__size 0x08
  145. /* DAQueueDataStruct */
  146. #define DAQDS_wStart 0x00
  147. #define DAQDS_wSize 0x02
  148. #define DAQDS_wFormat 0x04
  149. #define DAQDS_wSampleSize 0x06
  150. #define DAQDS_wChannels 0x08
  151. #define DAQDS_wSampleRate 0x0A
  152. #define DAQDS_wIntMsg 0x0C
  153. #define DAQDS_wFlags 0x0E
  154. #define DAQDS__size 0x10
  155. typedef u8 BYTE;
  156. typedef u16 USHORT;
  157. typedef u16 WORD;
  158. typedef u32 DWORD;
  159. typedef void __iomem * LPDAQD;
  160. /* Generic FIFO */
  161. typedef struct {
  162. size_t n, len;
  163. char *data;
  164. int head, tail;
  165. } msnd_fifo;
  166. typedef struct multisound_dev {
  167. /* Linux device info */
  168. char *name;
  169. int dsp_minor, mixer_minor;
  170. int ext_midi_dev, hdr_midi_dev;
  171. /* Hardware resources */
  172. int io, numio;
  173. int memid, irqid;
  174. int irq, irq_ref;
  175. unsigned char info;
  176. void __iomem *base;
  177. /* Motorola 56k DSP SMA */
  178. void __iomem *SMA;
  179. void __iomem *DAPQ, *DARQ, *MODQ, *MIDQ, *DSPQ;
  180. void __iomem *pwDSPQData, *pwMIDQData, *pwMODQData;
  181. int dspq_data_buff, dspq_buff_size;
  182. /* State variables */
  183. enum { msndClassic, msndPinnacle } type;
  184. fmode_t mode;
  185. unsigned long flags;
  186. #define F_RESETTING 0
  187. #define F_HAVEDIGITAL 1
  188. #define F_AUDIO_WRITE_INUSE 2
  189. #define F_WRITING 3
  190. #define F_WRITEBLOCK 4
  191. #define F_WRITEFLUSH 5
  192. #define F_AUDIO_READ_INUSE 6
  193. #define F_READING 7
  194. #define F_READBLOCK 8
  195. #define F_EXT_MIDI_INUSE 9
  196. #define F_HDR_MIDI_INUSE 10
  197. #define F_DISABLE_WRITE_NDELAY 11
  198. wait_queue_head_t writeblock;
  199. wait_queue_head_t readblock;
  200. wait_queue_head_t writeflush;
  201. spinlock_t lock;
  202. int nresets;
  203. unsigned long recsrc;
  204. int left_levels[32];
  205. int right_levels[32];
  206. int mixer_mod_count;
  207. int calibrate_signal;
  208. int play_sample_size, play_sample_rate, play_channels;
  209. int play_ndelay;
  210. int rec_sample_size, rec_sample_rate, rec_channels;
  211. int rec_ndelay;
  212. BYTE bCurrentMidiPatch;
  213. /* Digital audio FIFOs */
  214. msnd_fifo DAPF, DARF;
  215. int fifosize;
  216. int last_playbank, last_recbank;
  217. /* MIDI in callback */
  218. void (*midi_in_interrupt)(struct multisound_dev *);
  219. } multisound_dev_t;
  220. #ifndef mdelay
  221. # define mdelay(a) udelay((a) * 1000)
  222. #endif
  223. int msnd_register(multisound_dev_t *dev);
  224. void msnd_unregister(multisound_dev_t *dev);
  225. void msnd_init_queue(void __iomem *, int start, int size);
  226. void msnd_fifo_init(msnd_fifo *f);
  227. void msnd_fifo_free(msnd_fifo *f);
  228. int msnd_fifo_alloc(msnd_fifo *f, size_t n);
  229. void msnd_fifo_make_empty(msnd_fifo *f);
  230. int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len);
  231. int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len);
  232. int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len);
  233. int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len);
  234. int msnd_send_dsp_cmd(multisound_dev_t *dev, BYTE cmd);
  235. int msnd_send_word(multisound_dev_t *dev, unsigned char high,
  236. unsigned char mid, unsigned char low);
  237. int msnd_upload_host(multisound_dev_t *dev, char *bin, int len);
  238. int msnd_enable_irq(multisound_dev_t *dev);
  239. int msnd_disable_irq(multisound_dev_t *dev);
  240. #endif /* __MSND_H */