msnd.h 7.2 KB

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