echoaudio_dsp.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /****************************************************************************
  2. Copyright Echo Digital Audio Corporation (c) 1998 - 2004
  3. All rights reserved
  4. www.echoaudio.com
  5. This file is part of Echo Digital Audio's generic driver library.
  6. Echo Digital Audio's generic driver library is free software;
  7. you can redistribute it and/or modify it under the terms of
  8. the GNU General Public License as published by the Free Software
  9. Foundation.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  17. MA 02111-1307, USA.
  18. *************************************************************************
  19. Translation from C++ and adaptation for use in ALSA-Driver
  20. were made by Giuliano Pochini <pochini@shiny.it>
  21. ****************************************************************************/
  22. #ifndef _ECHO_DSP_
  23. #define _ECHO_DSP_
  24. /**** Echogals: Darla20, Gina20, Layla20, and Darla24 ****/
  25. #if defined(ECHOGALS_FAMILY)
  26. #define NUM_ASIC_TESTS 5
  27. #define READ_DSP_TIMEOUT 1000000L /* one second */
  28. /**** Echo24: Gina24, Layla24, Mona, Mia, Mia-midi ****/
  29. #elif defined(ECHO24_FAMILY)
  30. #define DSP_56361 /* Some Echo24 cards use the 56361 DSP */
  31. #define READ_DSP_TIMEOUT 100000L /* .1 second */
  32. /**** 3G: Gina3G, Layla3G ****/
  33. #elif defined(ECHO3G_FAMILY)
  34. #define DSP_56361
  35. #define READ_DSP_TIMEOUT 100000L /* .1 second */
  36. #define MIN_MTC_1X_RATE 32000
  37. /**** Indigo: Indigo, Indigo IO, Indigo DJ ****/
  38. #elif defined(INDIGO_FAMILY)
  39. #define DSP_56361
  40. #define READ_DSP_TIMEOUT 100000L /* .1 second */
  41. #else
  42. #error No family is defined
  43. #endif
  44. /*
  45. *
  46. * Max inputs and outputs
  47. *
  48. */
  49. #define DSP_MAXAUDIOINPUTS 16 /* Max audio input channels */
  50. #define DSP_MAXAUDIOOUTPUTS 16 /* Max audio output channels */
  51. #define DSP_MAXPIPES 32 /* Max total pipes (input + output) */
  52. /*
  53. *
  54. * These are the offsets for the memory-mapped DSP registers; the DSP base
  55. * address is treated as the start of a u32 array.
  56. */
  57. #define CHI32_CONTROL_REG 4
  58. #define CHI32_STATUS_REG 5
  59. #define CHI32_VECTOR_REG 6
  60. #define CHI32_DATA_REG 7
  61. /*
  62. *
  63. * Interesting bits within the DSP registers
  64. *
  65. */
  66. #define CHI32_VECTOR_BUSY 0x00000001
  67. #define CHI32_STATUS_REG_HF3 0x00000008
  68. #define CHI32_STATUS_REG_HF4 0x00000010
  69. #define CHI32_STATUS_REG_HF5 0x00000020
  70. #define CHI32_STATUS_HOST_READ_FULL 0x00000004
  71. #define CHI32_STATUS_HOST_WRITE_EMPTY 0x00000002
  72. #define CHI32_STATUS_IRQ 0x00000040
  73. /*
  74. *
  75. * DSP commands sent via slave mode; these are sent to the DSP by write_dsp()
  76. *
  77. */
  78. #define DSP_FNC_SET_COMMPAGE_ADDR 0x02
  79. #define DSP_FNC_LOAD_LAYLA_ASIC 0xa0
  80. #define DSP_FNC_LOAD_GINA24_ASIC 0xa0
  81. #define DSP_FNC_LOAD_MONA_PCI_CARD_ASIC 0xa0
  82. #define DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC 0xa0
  83. #define DSP_FNC_LOAD_MONA_EXTERNAL_ASIC 0xa1
  84. #define DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC 0xa1
  85. #define DSP_FNC_LOAD_3G_ASIC 0xa0
  86. /*
  87. *
  88. * Defines to handle the MIDI input state engine; these are used to properly
  89. * extract MIDI time code bytes and their timestamps from the MIDI input stream.
  90. *
  91. */
  92. #define MIDI_IN_STATE_NORMAL 0
  93. #define MIDI_IN_STATE_TS_HIGH 1
  94. #define MIDI_IN_STATE_TS_LOW 2
  95. #define MIDI_IN_STATE_F1_DATA 3
  96. #define MIDI_IN_SKIP_DATA (-1)
  97. /*----------------------------------------------------------------------------
  98. Setting the sample rates on Layla24 is somewhat schizophrenic.
  99. For standard rates, it works exactly like Mona and Gina24. That is, for
  100. 8, 11.025, 16, 22.05, 32, 44.1, 48, 88.2, and 96 kHz, you just set the
  101. appropriate bits in the control register and write the control register.
  102. In order to support MIDI time code sync (and possibly SMPTE LTC sync in
  103. the future), Layla24 also has "continuous sample rate mode". In this mode,
  104. Layla24 can generate any sample rate between 25 and 50 kHz inclusive, or
  105. 50 to 100 kHz inclusive for double speed mode.
  106. To use continuous mode:
  107. -Set the clock select bits in the control register to 0xe (see the #define
  108. below)
  109. -Set double-speed mode if you want to use sample rates above 50 kHz
  110. -Write the control register as you would normally
  111. -Now, you need to set the frequency register. First, you need to determine the
  112. value for the frequency register. This is given by the following formula:
  113. frequency_reg = (LAYLA24_MAGIC_NUMBER / sample_rate) - 2
  114. Note the #define below for the magic number
  115. -Wait for the DSP handshake
  116. -Write the frequency_reg value to the .SampleRate field of the comm page
  117. -Send the vector command SET_LAYLA24_FREQUENCY_REG (see vmonkey.h)
  118. Once you have set the control register up for continuous mode, you can just
  119. write the frequency register to change the sample rate. This could be
  120. used for MIDI time code sync. For MTC sync, the control register is set for
  121. continuous mode. The driver then just keeps writing the
  122. SET_LAYLA24_FREQUENCY_REG command.
  123. -----------------------------------------------------------------------------*/
  124. #define LAYLA24_MAGIC_NUMBER 677376000
  125. #define LAYLA24_CONTINUOUS_CLOCK 0x000e
  126. /*
  127. *
  128. * DSP vector commands
  129. *
  130. */
  131. #define DSP_VC_RESET 0x80ff
  132. #ifndef DSP_56361
  133. #define DSP_VC_ACK_INT 0x8073
  134. #define DSP_VC_SET_VMIXER_GAIN 0x0000 /* Not used, only for compile */
  135. #define DSP_VC_START_TRANSFER 0x0075 /* Handshke rqd. */
  136. #define DSP_VC_METERS_ON 0x0079
  137. #define DSP_VC_METERS_OFF 0x007b
  138. #define DSP_VC_UPDATE_OUTVOL 0x007d /* Handshke rqd. */
  139. #define DSP_VC_UPDATE_INGAIN 0x007f /* Handshke rqd. */
  140. #define DSP_VC_ADD_AUDIO_BUFFER 0x0081 /* Handshke rqd. */
  141. #define DSP_VC_TEST_ASIC 0x00eb
  142. #define DSP_VC_UPDATE_CLOCKS 0x00ef /* Handshke rqd. */
  143. #define DSP_VC_SET_LAYLA_SAMPLE_RATE 0x00f1 /* Handshke rqd. */
  144. #define DSP_VC_SET_GD_AUDIO_STATE 0x00f1 /* Handshke rqd. */
  145. #define DSP_VC_WRITE_CONTROL_REG 0x00f1 /* Handshke rqd. */
  146. #define DSP_VC_MIDI_WRITE 0x00f5 /* Handshke rqd. */
  147. #define DSP_VC_STOP_TRANSFER 0x00f7 /* Handshke rqd. */
  148. #define DSP_VC_UPDATE_FLAGS 0x00fd /* Handshke rqd. */
  149. #define DSP_VC_GO_COMATOSE 0x00f9
  150. #else /* !DSP_56361 */
  151. /* Vector commands for families that use either the 56301 or 56361 */
  152. #define DSP_VC_ACK_INT 0x80F5
  153. #define DSP_VC_SET_VMIXER_GAIN 0x00DB /* Handshke rqd. */
  154. #define DSP_VC_START_TRANSFER 0x00DD /* Handshke rqd. */
  155. #define DSP_VC_METERS_ON 0x00EF
  156. #define DSP_VC_METERS_OFF 0x00F1
  157. #define DSP_VC_UPDATE_OUTVOL 0x00E3 /* Handshke rqd. */
  158. #define DSP_VC_UPDATE_INGAIN 0x00E5 /* Handshke rqd. */
  159. #define DSP_VC_ADD_AUDIO_BUFFER 0x00E1 /* Handshke rqd. */
  160. #define DSP_VC_TEST_ASIC 0x00ED
  161. #define DSP_VC_UPDATE_CLOCKS 0x00E9 /* Handshke rqd. */
  162. #define DSP_VC_SET_LAYLA24_FREQUENCY_REG 0x00E9 /* Handshke rqd. */
  163. #define DSP_VC_SET_LAYLA_SAMPLE_RATE 0x00EB /* Handshke rqd. */
  164. #define DSP_VC_SET_GD_AUDIO_STATE 0x00EB /* Handshke rqd. */
  165. #define DSP_VC_WRITE_CONTROL_REG 0x00EB /* Handshke rqd. */
  166. #define DSP_VC_MIDI_WRITE 0x00E7 /* Handshke rqd. */
  167. #define DSP_VC_STOP_TRANSFER 0x00DF /* Handshke rqd. */
  168. #define DSP_VC_UPDATE_FLAGS 0x00FB /* Handshke rqd. */
  169. #define DSP_VC_GO_COMATOSE 0x00d9
  170. #endif /* !DSP_56361 */
  171. /*
  172. *
  173. * Timeouts
  174. *
  175. */
  176. #define HANDSHAKE_TIMEOUT 20000 /* send_vector command timeout (20ms) */
  177. #define VECTOR_BUSY_TIMEOUT 100000 /* 100ms */
  178. #define MIDI_OUT_DELAY_USEC 2000 /* How long to wait after MIDI fills up */
  179. /*
  180. *
  181. * Flags for .Flags field in the comm page
  182. *
  183. */
  184. #define DSP_FLAG_MIDI_INPUT 0x0001 /* Enable MIDI input */
  185. #define DSP_FLAG_SPDIF_NONAUDIO 0x0002 /* Sets the "non-audio" bit
  186. * in the S/PDIF out status
  187. * bits. Clear this flag for
  188. * audio data;
  189. * set it for AC3 or WMA or
  190. * some such */
  191. #define DSP_FLAG_PROFESSIONAL_SPDIF 0x0008 /* 1 Professional, 0 Consumer */
  192. /*
  193. *
  194. * Clock detect bits reported by the DSP for Gina20, Layla20, Darla24, and Mia
  195. *
  196. */
  197. #define GLDM_CLOCK_DETECT_BIT_WORD 0x0002
  198. #define GLDM_CLOCK_DETECT_BIT_SUPER 0x0004
  199. #define GLDM_CLOCK_DETECT_BIT_SPDIF 0x0008
  200. #define GLDM_CLOCK_DETECT_BIT_ESYNC 0x0010
  201. /*
  202. *
  203. * Clock detect bits reported by the DSP for Gina24, Mona, and Layla24
  204. *
  205. */
  206. #define GML_CLOCK_DETECT_BIT_WORD96 0x0002
  207. #define GML_CLOCK_DETECT_BIT_WORD48 0x0004
  208. #define GML_CLOCK_DETECT_BIT_SPDIF48 0x0008
  209. #define GML_CLOCK_DETECT_BIT_SPDIF96 0x0010
  210. #define GML_CLOCK_DETECT_BIT_WORD (GML_CLOCK_DETECT_BIT_WORD96 | GML_CLOCK_DETECT_BIT_WORD48)
  211. #define GML_CLOCK_DETECT_BIT_SPDIF (GML_CLOCK_DETECT_BIT_SPDIF48 | GML_CLOCK_DETECT_BIT_SPDIF96)
  212. #define GML_CLOCK_DETECT_BIT_ESYNC 0x0020
  213. #define GML_CLOCK_DETECT_BIT_ADAT 0x0040
  214. /*
  215. *
  216. * Layla clock numbers to send to DSP
  217. *
  218. */
  219. #define LAYLA20_CLOCK_INTERNAL 0
  220. #define LAYLA20_CLOCK_SPDIF 1
  221. #define LAYLA20_CLOCK_WORD 2
  222. #define LAYLA20_CLOCK_SUPER 3
  223. /*
  224. *
  225. * Gina/Darla clock states
  226. *
  227. */
  228. #define GD_CLOCK_NOCHANGE 0
  229. #define GD_CLOCK_44 1
  230. #define GD_CLOCK_48 2
  231. #define GD_CLOCK_SPDIFIN 3
  232. #define GD_CLOCK_UNDEF 0xff
  233. /*
  234. *
  235. * Gina/Darla S/PDIF status bits
  236. *
  237. */
  238. #define GD_SPDIF_STATUS_NOCHANGE 0
  239. #define GD_SPDIF_STATUS_44 1
  240. #define GD_SPDIF_STATUS_48 2
  241. #define GD_SPDIF_STATUS_UNDEF 0xff
  242. /*
  243. *
  244. * Layla20 output clocks
  245. *
  246. */
  247. #define LAYLA20_OUTPUT_CLOCK_SUPER 0
  248. #define LAYLA20_OUTPUT_CLOCK_WORD 1
  249. /****************************************************************************
  250. Magic constants for the Darla24 hardware
  251. ****************************************************************************/
  252. #define GD24_96000 0x0
  253. #define GD24_48000 0x1
  254. #define GD24_44100 0x2
  255. #define GD24_32000 0x3
  256. #define GD24_22050 0x4
  257. #define GD24_16000 0x5
  258. #define GD24_11025 0x6
  259. #define GD24_8000 0x7
  260. #define GD24_88200 0x8
  261. #define GD24_EXT_SYNC 0x9
  262. /*
  263. *
  264. * Return values from the DSP when ASIC is loaded
  265. *
  266. */
  267. #define ASIC_ALREADY_LOADED 0x1
  268. #define ASIC_NOT_LOADED 0x0
  269. /*
  270. *
  271. * DSP Audio formats
  272. *
  273. * These are the audio formats that the DSP can transfer
  274. * via input and output pipes. LE means little-endian,
  275. * BE means big-endian.
  276. *
  277. * DSP_AUDIOFORM_MS_8
  278. *
  279. * 8-bit mono unsigned samples. For playback,
  280. * mono data is duplicated out the left and right channels
  281. * of the output bus. The "MS" part of the name
  282. * means mono->stereo.
  283. *
  284. * DSP_AUDIOFORM_MS_16LE
  285. *
  286. * 16-bit signed little-endian mono samples. Playback works
  287. * like the previous code.
  288. *
  289. * DSP_AUDIOFORM_MS_24LE
  290. *
  291. * 24-bit signed little-endian mono samples. Data is packed
  292. * three bytes per sample; if you had two samples 0x112233 and 0x445566
  293. * they would be stored in memory like this: 33 22 11 66 55 44.
  294. *
  295. * DSP_AUDIOFORM_MS_32LE
  296. *
  297. * 24-bit signed little-endian mono samples in a 32-bit
  298. * container. In other words, each sample is a 32-bit signed
  299. * integer, where the actual audio data is left-justified
  300. * in the 32 bits and only the 24 most significant bits are valid.
  301. *
  302. * DSP_AUDIOFORM_SS_8
  303. * DSP_AUDIOFORM_SS_16LE
  304. * DSP_AUDIOFORM_SS_24LE
  305. * DSP_AUDIOFORM_SS_32LE
  306. *
  307. * Like the previous ones, except now with stereo interleaved
  308. * data. "SS" means stereo->stereo.
  309. *
  310. * DSP_AUDIOFORM_MM_32LE
  311. *
  312. * Similar to DSP_AUDIOFORM_MS_32LE, except that the mono
  313. * data is not duplicated out both the left and right outputs.
  314. * This mode is used by the ASIO driver. Here, "MM" means
  315. * mono->mono.
  316. *
  317. * DSP_AUDIOFORM_MM_32BE
  318. *
  319. * Just like DSP_AUDIOFORM_MM_32LE, but now the data is
  320. * in big-endian format.
  321. *
  322. */
  323. #define DSP_AUDIOFORM_MS_8 0 /* 8 bit mono */
  324. #define DSP_AUDIOFORM_MS_16LE 1 /* 16 bit mono */
  325. #define DSP_AUDIOFORM_MS_24LE 2 /* 24 bit mono */
  326. #define DSP_AUDIOFORM_MS_32LE 3 /* 32 bit mono */
  327. #define DSP_AUDIOFORM_SS_8 4 /* 8 bit stereo */
  328. #define DSP_AUDIOFORM_SS_16LE 5 /* 16 bit stereo */
  329. #define DSP_AUDIOFORM_SS_24LE 6 /* 24 bit stereo */
  330. #define DSP_AUDIOFORM_SS_32LE 7 /* 32 bit stereo */
  331. #define DSP_AUDIOFORM_MM_32LE 8 /* 32 bit mono->mono little-endian */
  332. #define DSP_AUDIOFORM_MM_32BE 9 /* 32 bit mono->mono big-endian */
  333. #define DSP_AUDIOFORM_SS_32BE 10 /* 32 bit stereo big endian */
  334. #define DSP_AUDIOFORM_INVALID 0xFF /* Invalid audio format */
  335. /*
  336. *
  337. * Super-interleave is defined as interleaving by 4 or more. Darla20 and Gina20
  338. * do not support super interleave.
  339. *
  340. * 16 bit, 24 bit, and 32 bit little endian samples are supported for super
  341. * interleave. The interleave factor must be even. 16 - way interleave is the
  342. * current maximum, so you can interleave by 4, 6, 8, 10, 12, 14, and 16.
  343. *
  344. * The actual format code is derived by taking the define below and or-ing with
  345. * the interleave factor. So, 32 bit interleave by 6 is 0x86 and
  346. * 16 bit interleave by 16 is (0x40 | 0x10) = 0x50.
  347. *
  348. */
  349. #define DSP_AUDIOFORM_SUPER_INTERLEAVE_16LE 0x40
  350. #define DSP_AUDIOFORM_SUPER_INTERLEAVE_24LE 0xc0
  351. #define DSP_AUDIOFORM_SUPER_INTERLEAVE_32LE 0x80
  352. /*
  353. *
  354. * Gina24, Mona, and Layla24 control register defines
  355. *
  356. */
  357. #define GML_CONVERTER_ENABLE 0x0010
  358. #define GML_SPDIF_PRO_MODE 0x0020 /* Professional S/PDIF == 1,
  359. consumer == 0 */
  360. #define GML_SPDIF_SAMPLE_RATE0 0x0040
  361. #define GML_SPDIF_SAMPLE_RATE1 0x0080
  362. #define GML_SPDIF_TWO_CHANNEL 0x0100 /* 1 == two channels,
  363. 0 == one channel */
  364. #define GML_SPDIF_NOT_AUDIO 0x0200
  365. #define GML_SPDIF_COPY_PERMIT 0x0400
  366. #define GML_SPDIF_24_BIT 0x0800 /* 1 == 24 bit, 0 == 20 bit */
  367. #define GML_ADAT_MODE 0x1000 /* 1 == ADAT mode, 0 == S/PDIF mode */
  368. #define GML_SPDIF_OPTICAL_MODE 0x2000 /* 1 == optical mode, 0 == RCA mode */
  369. #define GML_SPDIF_CDROM_MODE 0x3000 /* 1 == CDROM mode,
  370. * 0 == RCA or optical mode */
  371. #define GML_DOUBLE_SPEED_MODE 0x4000 /* 1 == double speed,
  372. 0 == single speed */
  373. #define GML_DIGITAL_IN_AUTO_MUTE 0x800000
  374. #define GML_96KHZ (0x0 | GML_DOUBLE_SPEED_MODE)
  375. #define GML_88KHZ (0x1 | GML_DOUBLE_SPEED_MODE)
  376. #define GML_48KHZ 0x2
  377. #define GML_44KHZ 0x3
  378. #define GML_32KHZ 0x4
  379. #define GML_22KHZ 0x5
  380. #define GML_16KHZ 0x6
  381. #define GML_11KHZ 0x7
  382. #define GML_8KHZ 0x8
  383. #define GML_SPDIF_CLOCK 0x9
  384. #define GML_ADAT_CLOCK 0xA
  385. #define GML_WORD_CLOCK 0xB
  386. #define GML_ESYNC_CLOCK 0xC
  387. #define GML_ESYNCx2_CLOCK 0xD
  388. #define GML_CLOCK_CLEAR_MASK 0xffffbff0
  389. #define GML_SPDIF_RATE_CLEAR_MASK (~(GML_SPDIF_SAMPLE_RATE0|GML_SPDIF_SAMPLE_RATE1))
  390. #define GML_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
  391. #define GML_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
  392. /*
  393. *
  394. * Mia sample rate and clock setting constants
  395. *
  396. */
  397. #define MIA_32000 0x0040
  398. #define MIA_44100 0x0042
  399. #define MIA_48000 0x0041
  400. #define MIA_88200 0x0142
  401. #define MIA_96000 0x0141
  402. #define MIA_SPDIF 0x00000044
  403. #define MIA_SPDIF96 0x00000144
  404. #define MIA_MIDI_REV 1 /* Must be Mia rev 1 for MIDI support */
  405. /*
  406. *
  407. * 3G register bits
  408. *
  409. */
  410. #define E3G_CONVERTER_ENABLE 0x0010
  411. #define E3G_SPDIF_PRO_MODE 0x0020 /* Professional S/PDIF == 1,
  412. consumer == 0 */
  413. #define E3G_SPDIF_SAMPLE_RATE0 0x0040
  414. #define E3G_SPDIF_SAMPLE_RATE1 0x0080
  415. #define E3G_SPDIF_TWO_CHANNEL 0x0100 /* 1 == two channels,
  416. 0 == one channel */
  417. #define E3G_SPDIF_NOT_AUDIO 0x0200
  418. #define E3G_SPDIF_COPY_PERMIT 0x0400
  419. #define E3G_SPDIF_24_BIT 0x0800 /* 1 == 24 bit, 0 == 20 bit */
  420. #define E3G_DOUBLE_SPEED_MODE 0x4000 /* 1 == double speed,
  421. 0 == single speed */
  422. #define E3G_PHANTOM_POWER 0x8000 /* 1 == phantom power on,
  423. 0 == phantom power off */
  424. #define E3G_96KHZ (0x0 | E3G_DOUBLE_SPEED_MODE)
  425. #define E3G_88KHZ (0x1 | E3G_DOUBLE_SPEED_MODE)
  426. #define E3G_48KHZ 0x2
  427. #define E3G_44KHZ 0x3
  428. #define E3G_32KHZ 0x4
  429. #define E3G_22KHZ 0x5
  430. #define E3G_16KHZ 0x6
  431. #define E3G_11KHZ 0x7
  432. #define E3G_8KHZ 0x8
  433. #define E3G_SPDIF_CLOCK 0x9
  434. #define E3G_ADAT_CLOCK 0xA
  435. #define E3G_WORD_CLOCK 0xB
  436. #define E3G_CONTINUOUS_CLOCK 0xE
  437. #define E3G_ADAT_MODE 0x1000
  438. #define E3G_SPDIF_OPTICAL_MODE 0x2000
  439. #define E3G_CLOCK_CLEAR_MASK 0xbfffbff0
  440. #define E3G_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
  441. #define E3G_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
  442. /* Clock detect bits reported by the DSP */
  443. #define E3G_CLOCK_DETECT_BIT_WORD96 0x0001
  444. #define E3G_CLOCK_DETECT_BIT_WORD48 0x0002
  445. #define E3G_CLOCK_DETECT_BIT_SPDIF48 0x0004
  446. #define E3G_CLOCK_DETECT_BIT_ADAT 0x0004
  447. #define E3G_CLOCK_DETECT_BIT_SPDIF96 0x0008
  448. #define E3G_CLOCK_DETECT_BIT_WORD (E3G_CLOCK_DETECT_BIT_WORD96|E3G_CLOCK_DETECT_BIT_WORD48)
  449. #define E3G_CLOCK_DETECT_BIT_SPDIF (E3G_CLOCK_DETECT_BIT_SPDIF48|E3G_CLOCK_DETECT_BIT_SPDIF96)
  450. /* Frequency control register */
  451. #define E3G_MAGIC_NUMBER 677376000
  452. #define E3G_FREQ_REG_DEFAULT (E3G_MAGIC_NUMBER / 48000 - 2)
  453. #define E3G_FREQ_REG_MAX 0xffff
  454. /* 3G external box types */
  455. #define E3G_GINA3G_BOX_TYPE 0x00
  456. #define E3G_LAYLA3G_BOX_TYPE 0x10
  457. #define E3G_ASIC_NOT_LOADED 0xffff
  458. #define E3G_BOX_TYPE_MASK 0xf0
  459. /* Indigo express control register values */
  460. #define INDIGO_EXPRESS_32000 0x02
  461. #define INDIGO_EXPRESS_44100 0x01
  462. #define INDIGO_EXPRESS_48000 0x00
  463. #define INDIGO_EXPRESS_DOUBLE_SPEED 0x10
  464. #define INDIGO_EXPRESS_QUAD_SPEED 0x04
  465. #define INDIGO_EXPRESS_CLOCK_MASK 0x17
  466. /*
  467. *
  468. * Gina20 & Layla20 have input gain controls for the analog inputs;
  469. * this is the magic number for the hardware that gives you 0 dB at -10.
  470. *
  471. */
  472. #define GL20_INPUT_GAIN_MAGIC_NUMBER 0xC8
  473. /*
  474. *
  475. * Defines how much time must pass between DSP load attempts
  476. *
  477. */
  478. #define DSP_LOAD_ATTEMPT_PERIOD 1000000L /* One second */
  479. /*
  480. *
  481. * Size of arrays for the comm page. MAX_PLAY_TAPS and MAX_REC_TAPS are
  482. * no longer used, but the sizes must still be right for the DSP to see
  483. * the comm page correctly.
  484. *
  485. */
  486. #define MONITOR_ARRAY_SIZE 0x180
  487. #define VMIXER_ARRAY_SIZE 0x40
  488. #define MIDI_OUT_BUFFER_SIZE 32
  489. #define MIDI_IN_BUFFER_SIZE 256
  490. #define MAX_PLAY_TAPS 168
  491. #define MAX_REC_TAPS 192
  492. #define DSP_MIDI_OUT_FIFO_SIZE 64
  493. /* sg_entry is a single entry for the scatter-gather list. The array of struct
  494. sg_entry struct is read by the DSP, so all values must be little-endian. */
  495. #define MAX_SGLIST_ENTRIES 512
  496. struct sg_entry {
  497. u32 addr;
  498. u32 size;
  499. };
  500. /****************************************************************************
  501. The comm page. This structure is read and written by the DSP; the
  502. DSP code is a firm believer in the byte offsets written in the comments
  503. at the end of each line. This structure should not be changed.
  504. Any reads from or writes to this structure should be in little-endian format.
  505. ****************************************************************************/
  506. struct comm_page { /* Base Length*/
  507. u32 comm_size; /* size of this object 0x000 4 */
  508. u32 flags; /* See Appendix A below 0x004 4 */
  509. u32 unused; /* Unused entry 0x008 4 */
  510. u32 sample_rate; /* Card sample rate in Hz 0x00c 4 */
  511. u32 handshake; /* DSP command handshake 0x010 4 */
  512. u32 cmd_start; /* Chs. to start mask 0x014 4 */
  513. u32 cmd_stop; /* Chs. to stop mask 0x018 4 */
  514. u32 cmd_reset; /* Chs. to reset mask 0x01c 4 */
  515. u16 audio_format[DSP_MAXPIPES]; /* Chs. audio format 0x020 32*2 */
  516. struct sg_entry sglist_addr[DSP_MAXPIPES];
  517. /* Chs. Physical sglist addrs 0x060 32*8 */
  518. u32 position[DSP_MAXPIPES];
  519. /* Positions for ea. ch. 0x160 32*4 */
  520. s8 vu_meter[DSP_MAXPIPES];
  521. /* VU meters 0x1e0 32*1 */
  522. s8 peak_meter[DSP_MAXPIPES];
  523. /* Peak meters 0x200 32*1 */
  524. s8 line_out_level[DSP_MAXAUDIOOUTPUTS];
  525. /* Output gain 0x220 16*1 */
  526. s8 line_in_level[DSP_MAXAUDIOINPUTS];
  527. /* Input gain 0x230 16*1 */
  528. s8 monitors[MONITOR_ARRAY_SIZE];
  529. /* Monitor map 0x240 0x180 */
  530. u32 play_coeff[MAX_PLAY_TAPS];
  531. /* Gina/Darla play filters - obsolete 0x3c0 168*4 */
  532. u32 rec_coeff[MAX_REC_TAPS];
  533. /* Gina/Darla record filters - obsolete 0x660 192*4 */
  534. u16 midi_input[MIDI_IN_BUFFER_SIZE];
  535. /* MIDI input data transfer buffer 0x960 256*2 */
  536. u8 gd_clock_state; /* Chg Gina/Darla clock state 0xb60 1 */
  537. u8 gd_spdif_status; /* Chg. Gina/Darla S/PDIF state 0xb61 1 */
  538. u8 gd_resampler_state; /* Should always be 3 0xb62 1 */
  539. u8 filler2; /* 0xb63 1 */
  540. u32 nominal_level_mask; /* -10 level enable mask 0xb64 4 */
  541. u16 input_clock; /* Chg. Input clock state 0xb68 2 */
  542. u16 output_clock; /* Chg. Output clock state 0xb6a 2 */
  543. u32 status_clocks; /* Current Input clock state 0xb6c 4 */
  544. u32 ext_box_status; /* External box status 0xb70 4 */
  545. u32 cmd_add_buffer; /* Pipes to add (obsolete) 0xb74 4 */
  546. u32 midi_out_free_count;
  547. /* # of bytes free in MIDI output FIFO 0xb78 4 */
  548. u32 unused2; /* Cyclic pipes 0xb7c 4 */
  549. u32 control_register;
  550. /* Mona, Gina24, Layla24, 3G ctrl reg 0xb80 4 */
  551. u32 e3g_frq_register; /* 3G frequency register 0xb84 4 */
  552. u8 filler[24]; /* filler 0xb88 24*1 */
  553. s8 vmixer[VMIXER_ARRAY_SIZE];
  554. /* Vmixer levels 0xba0 64*1 */
  555. u8 midi_output[MIDI_OUT_BUFFER_SIZE];
  556. /* MIDI output data 0xbe0 32*1 */
  557. };
  558. #endif /* _ECHO_DSP_ */