msnd.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 DEFSAMPLERATE 44100
  31. #define DEFSAMPLESIZE SNDRV_PCM_FORMAT_S16
  32. #define DEFCHANNELS 1
  33. #define SRAM_BANK_SIZE 0x8000
  34. #define SRAM_CNTL_START 0x7F00
  35. #define SMA_STRUCT_START 0x7F40
  36. #define DSP_BASE_ADDR 0x4000
  37. #define DSP_BANK_BASE 0x4000
  38. #define AGND 0x01
  39. #define SIGNAL 0x02
  40. #define EXT_DSP_BIT_DCAL 0x0001
  41. #define EXT_DSP_BIT_MIDI_CON 0x0002
  42. #define BUFFSIZE 0x8000
  43. #define HOSTQ_SIZE 0x40
  44. #define DAP_BUFF_SIZE 0x2400
  45. #define DAPQ_STRUCT_SIZE 0x10
  46. #define DARQ_STRUCT_SIZE 0x10
  47. #define DAPQ_BUFF_SIZE (3 * 0x10)
  48. #define DARQ_BUFF_SIZE (3 * 0x10)
  49. #define MODQ_BUFF_SIZE 0x400
  50. #define DAPQ_DATA_BUFF 0x6C00
  51. #define DARQ_DATA_BUFF 0x6C30
  52. #define MODQ_DATA_BUFF 0x6C60
  53. #define MIDQ_DATA_BUFF 0x7060
  54. #define DAPQ_OFFSET SRAM_CNTL_START
  55. #define DARQ_OFFSET (SRAM_CNTL_START + 0x08)
  56. #define MODQ_OFFSET (SRAM_CNTL_START + 0x10)
  57. #define MIDQ_OFFSET (SRAM_CNTL_START + 0x18)
  58. #define DSPQ_OFFSET (SRAM_CNTL_START + 0x20)
  59. #define HP_ICR 0x00
  60. #define HP_CVR 0x01
  61. #define HP_ISR 0x02
  62. #define HP_IVR 0x03
  63. #define HP_NU 0x04
  64. #define HP_INFO 0x04
  65. #define HP_TXH 0x05
  66. #define HP_RXH 0x05
  67. #define HP_TXM 0x06
  68. #define HP_RXM 0x06
  69. #define HP_TXL 0x07
  70. #define HP_RXL 0x07
  71. #define HP_ICR_DEF 0x00
  72. #define HP_CVR_DEF 0x12
  73. #define HP_ISR_DEF 0x06
  74. #define HP_IVR_DEF 0x0f
  75. #define HP_NU_DEF 0x00
  76. #define HP_IRQM 0x09
  77. #define HPR_BLRC 0x08
  78. #define HPR_SPR1 0x09
  79. #define HPR_SPR2 0x0A
  80. #define HPR_TCL0 0x0B
  81. #define HPR_TCL1 0x0C
  82. #define HPR_TCL2 0x0D
  83. #define HPR_TCL3 0x0E
  84. #define HPR_TCL4 0x0F
  85. #define HPICR_INIT 0x80
  86. #define HPICR_HM1 0x40
  87. #define HPICR_HM0 0x20
  88. #define HPICR_HF1 0x10
  89. #define HPICR_HF0 0x08
  90. #define HPICR_TREQ 0x02
  91. #define HPICR_RREQ 0x01
  92. #define HPCVR_HC 0x80
  93. #define HPISR_HREQ 0x80
  94. #define HPISR_DMA 0x40
  95. #define HPISR_HF3 0x10
  96. #define HPISR_HF2 0x08
  97. #define HPISR_TRDY 0x04
  98. #define HPISR_TXDE 0x02
  99. #define HPISR_RXDF 0x01
  100. #define HPIO_290 0
  101. #define HPIO_260 1
  102. #define HPIO_250 2
  103. #define HPIO_240 3
  104. #define HPIO_230 4
  105. #define HPIO_220 5
  106. #define HPIO_210 6
  107. #define HPIO_3E0 7
  108. #define HPMEM_NONE 0
  109. #define HPMEM_B000 1
  110. #define HPMEM_C800 2
  111. #define HPMEM_D000 3
  112. #define HPMEM_D400 4
  113. #define HPMEM_D800 5
  114. #define HPMEM_E000 6
  115. #define HPMEM_E800 7
  116. #define HPIRQ_NONE 0
  117. #define HPIRQ_5 1
  118. #define HPIRQ_7 2
  119. #define HPIRQ_9 3
  120. #define HPIRQ_10 4
  121. #define HPIRQ_11 5
  122. #define HPIRQ_12 6
  123. #define HPIRQ_15 7
  124. #define HIMT_PLAY_DONE 0x00
  125. #define HIMT_RECORD_DONE 0x01
  126. #define HIMT_MIDI_EOS 0x02
  127. #define HIMT_MIDI_OUT 0x03
  128. #define HIMT_MIDI_IN_UCHAR 0x0E
  129. #define HIMT_DSP 0x0F
  130. #define HDEX_BASE 0x92
  131. #define HDEX_PLAY_START (0 + HDEX_BASE)
  132. #define HDEX_PLAY_STOP (1 + HDEX_BASE)
  133. #define HDEX_PLAY_PAUSE (2 + HDEX_BASE)
  134. #define HDEX_PLAY_RESUME (3 + HDEX_BASE)
  135. #define HDEX_RECORD_START (4 + HDEX_BASE)
  136. #define HDEX_RECORD_STOP (5 + HDEX_BASE)
  137. #define HDEX_MIDI_IN_START (6 + HDEX_BASE)
  138. #define HDEX_MIDI_IN_STOP (7 + HDEX_BASE)
  139. #define HDEX_MIDI_OUT_START (8 + HDEX_BASE)
  140. #define HDEX_MIDI_OUT_STOP (9 + HDEX_BASE)
  141. #define HDEX_AUX_REQ (10 + HDEX_BASE)
  142. #define HDEXAR_CLEAR_PEAKS 1
  143. #define HDEXAR_IN_SET_POTS 2
  144. #define HDEXAR_AUX_SET_POTS 3
  145. #define HDEXAR_CAL_A_TO_D 4
  146. #define HDEXAR_RD_EXT_DSP_BITS 5
  147. /* Pinnacle only HDEXAR defs */
  148. #define HDEXAR_SET_ANA_IN 0
  149. #define HDEXAR_SET_SYNTH_IN 4
  150. #define HDEXAR_READ_DAT_IN 5
  151. #define HDEXAR_MIC_SET_POTS 6
  152. #define HDEXAR_SET_DAT_IN 7
  153. #define HDEXAR_SET_SYNTH_48 8
  154. #define HDEXAR_SET_SYNTH_44 9
  155. #define HIWORD(l) ((u16)((((u32)(l)) >> 16) & 0xFFFF))
  156. #define LOWORD(l) ((u16)(u32)(l))
  157. #define HIBYTE(w) ((u8)(((u16)(w) >> 8) & 0xFF))
  158. #define LOBYTE(w) ((u8)(w))
  159. #define MAKELONG(low, hi) ((long)(((u16)(low))|(((u32)((u16)(hi)))<<16)))
  160. #define MAKEWORD(low, hi) ((u16)(((u8)(low))|(((u16)((u8)(hi)))<<8)))
  161. #define PCTODSP_OFFSET(w) (u16)((w)/2)
  162. #define PCTODSP_BASED(w) (u16)(((w)/2) + DSP_BASE_ADDR)
  163. #define DSPTOPC_BASED(w) (((w) - DSP_BASE_ADDR) * 2)
  164. #ifdef SLOWIO
  165. # undef outb
  166. # undef inb
  167. # define outb outb_p
  168. # define inb inb_p
  169. #endif
  170. /* JobQueueStruct */
  171. #define JQS_wStart 0x00
  172. #define JQS_wSize 0x02
  173. #define JQS_wHead 0x04
  174. #define JQS_wTail 0x06
  175. #define JQS__size 0x08
  176. /* DAQueueDataStruct */
  177. #define DAQDS_wStart 0x00
  178. #define DAQDS_wSize 0x02
  179. #define DAQDS_wFormat 0x04
  180. #define DAQDS_wSampleSize 0x06
  181. #define DAQDS_wChannels 0x08
  182. #define DAQDS_wSampleRate 0x0A
  183. #define DAQDS_wIntMsg 0x0C
  184. #define DAQDS_wFlags 0x0E
  185. #define DAQDS__size 0x10
  186. #include <sound/pcm.h>
  187. struct snd_msnd {
  188. void __iomem *mappedbase;
  189. int play_period_bytes;
  190. int playLimit;
  191. int playPeriods;
  192. int playDMAPos;
  193. int banksPlayed;
  194. int captureDMAPos;
  195. int capturePeriodBytes;
  196. int captureLimit;
  197. int capturePeriods;
  198. struct snd_card *card;
  199. void *msndmidi_mpu;
  200. struct snd_rawmidi *rmidi;
  201. /* Hardware resources */
  202. long io;
  203. int memid, irqid;
  204. int irq, irq_ref;
  205. unsigned long base;
  206. /* Motorola 56k DSP SMA */
  207. void __iomem *SMA;
  208. void __iomem *DAPQ;
  209. void __iomem *DARQ;
  210. void __iomem *MODQ;
  211. void __iomem *MIDQ;
  212. void __iomem *DSPQ;
  213. int dspq_data_buff, dspq_buff_size;
  214. /* State variables */
  215. enum { msndClassic, msndPinnacle } type;
  216. fmode_t mode;
  217. unsigned long flags;
  218. #define F_RESETTING 0
  219. #define F_HAVEDIGITAL 1
  220. #define F_AUDIO_WRITE_INUSE 2
  221. #define F_WRITING 3
  222. #define F_WRITEBLOCK 4
  223. #define F_WRITEFLUSH 5
  224. #define F_AUDIO_READ_INUSE 6
  225. #define F_READING 7
  226. #define F_READBLOCK 8
  227. #define F_EXT_MIDI_INUSE 9
  228. #define F_HDR_MIDI_INUSE 10
  229. #define F_DISABLE_WRITE_NDELAY 11
  230. spinlock_t lock;
  231. spinlock_t mixer_lock;
  232. int nresets;
  233. unsigned recsrc;
  234. #define LEVEL_ENTRIES 32
  235. int left_levels[LEVEL_ENTRIES];
  236. int right_levels[LEVEL_ENTRIES];
  237. int calibrate_signal;
  238. int play_sample_size, play_sample_rate, play_channels;
  239. int play_ndelay;
  240. int capture_sample_size, capture_sample_rate, capture_channels;
  241. int capture_ndelay;
  242. u8 bCurrentMidiPatch;
  243. int last_playbank, last_recbank;
  244. struct snd_pcm_substream *playback_substream;
  245. struct snd_pcm_substream *capture_substream;
  246. };
  247. void snd_msnd_init_queue(void *base, int start, int size);
  248. int snd_msnd_send_dsp_cmd(struct snd_msnd *chip, u8 cmd);
  249. int snd_msnd_send_word(struct snd_msnd *chip,
  250. unsigned char high,
  251. unsigned char mid,
  252. unsigned char low);
  253. int snd_msnd_upload_host(struct snd_msnd *chip,
  254. const u8 *bin, int len);
  255. int snd_msnd_enable_irq(struct snd_msnd *chip);
  256. int snd_msnd_disable_irq(struct snd_msnd *chip);
  257. void snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file);
  258. int snd_msnd_DAPQ(struct snd_msnd *chip, int start);
  259. int snd_msnd_DARQ(struct snd_msnd *chip, int start);
  260. int snd_msnd_pcm(struct snd_card *card, int device);
  261. int snd_msndmidi_new(struct snd_card *card, int device);
  262. void snd_msndmidi_input_read(void *mpu);
  263. void snd_msndmix_setup(struct snd_msnd *chip);
  264. int snd_msndmix_new(struct snd_card *card);
  265. int snd_msndmix_force_recsrc(struct snd_msnd *chip, int recsrc);
  266. #endif /* __MSND_H */