msnd.h 7.3 KB

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