lx_defs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /* -*- linux-c -*- *
  2. *
  3. * ALSA driver for the digigram lx6464es interface
  4. * adapted upstream headers
  5. *
  6. * Copyright (c) 2009 Tim Blechmann <tim@klingt.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; see the file COPYING. If not, write to
  20. * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. * Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. #ifndef LX_DEFS_H
  25. #define LX_DEFS_H
  26. /* code adapted from ethersound.h */
  27. #define XES_FREQ_COUNT8_MASK 0x00001FFF /* compteur 25MHz entre 8 ech. */
  28. #define XES_FREQ_COUNT8_44_MIN 0x00001288 /* 25M /
  29. * [ 44k - ( 44.1k + 48k ) / 2 ]
  30. * * 8 */
  31. #define XES_FREQ_COUNT8_44_MAX 0x000010F0 /* 25M / [ ( 44.1k + 48k ) / 2 ]
  32. * * 8 */
  33. #define XES_FREQ_COUNT8_48_MAX 0x00000F08 /* 25M /
  34. * [ 48k + ( 44.1k + 48k ) / 2 ]
  35. * * 8 */
  36. /* code adapted from LXES_registers.h */
  37. #define IOCR_OUTPUTS_OFFSET 0 /* (rw) offset for the number of OUTs in the
  38. * ConfES register. */
  39. #define IOCR_INPUTS_OFFSET 8 /* (rw) offset for the number of INs in the
  40. * ConfES register. */
  41. #define FREQ_RATIO_OFFSET 19 /* (rw) offset for frequency ratio in the
  42. * ConfES register. */
  43. #define FREQ_RATIO_SINGLE_MODE 0x01 /* value for single mode frequency ratio:
  44. * sample rate = frequency rate. */
  45. #define CONFES_READ_PART_MASK 0x00070000
  46. #define CONFES_WRITE_PART_MASK 0x00F80000
  47. /* code adapted from if_drv_mb.h */
  48. #define MASK_SYS_STATUS_ERROR (1L << 31) /* events that lead to a PCI irq if
  49. * not yet pending */
  50. #define MASK_SYS_STATUS_URUN (1L << 30)
  51. #define MASK_SYS_STATUS_ORUN (1L << 29)
  52. #define MASK_SYS_STATUS_EOBO (1L << 28)
  53. #define MASK_SYS_STATUS_EOBI (1L << 27)
  54. #define MASK_SYS_STATUS_FREQ (1L << 26)
  55. #define MASK_SYS_STATUS_ESA (1L << 25) /* reserved, this is set by the
  56. * XES */
  57. #define MASK_SYS_STATUS_TIMER (1L << 24)
  58. #define MASK_SYS_ASYNC_EVENTS (MASK_SYS_STATUS_ERROR | \
  59. MASK_SYS_STATUS_URUN | \
  60. MASK_SYS_STATUS_ORUN | \
  61. MASK_SYS_STATUS_EOBO | \
  62. MASK_SYS_STATUS_EOBI | \
  63. MASK_SYS_STATUS_FREQ | \
  64. MASK_SYS_STATUS_ESA)
  65. #define MASK_SYS_PCI_EVENTS (MASK_SYS_ASYNC_EVENTS | \
  66. MASK_SYS_STATUS_TIMER)
  67. #define MASK_SYS_TIMER_COUNT 0x0000FFFF
  68. #define MASK_SYS_STATUS_EOT_PLX (1L << 22) /* event that remains
  69. * internal: reserved fo end
  70. * of plx dma */
  71. #define MASK_SYS_STATUS_XES (1L << 21) /* event that remains
  72. * internal: pending XES
  73. * IRQ */
  74. #define MASK_SYS_STATUS_CMD_DONE (1L << 20) /* alternate command
  75. * management: notify driver
  76. * instead of polling */
  77. #define MAX_STREAM_BUFFER 5 /* max amount of stream buffers. */
  78. #define MICROBLAZE_IBL_MIN 32
  79. #define MICROBLAZE_IBL_DEFAULT 128
  80. #define MICROBLAZE_IBL_MAX 512
  81. /* #define MASK_GRANULARITY (2*MICROBLAZE_IBL_MAX-1) */
  82. /* command opcodes, see reference for details */
  83. /*
  84. the capture bit position in the object_id field in driver commands
  85. depends upon the number of managed channels. For now, 64 IN + 64 OUT are
  86. supported. HOwever, the communication protocol forsees 1024 channels, hence
  87. bit 10 indicates a capture (input) object).
  88. */
  89. #define ID_IS_CAPTURE (1L << 10)
  90. #define ID_OFFSET 13 /* object ID is at the 13th bit in the
  91. * 1st command word.*/
  92. #define ID_CH_MASK 0x3F
  93. #define OPCODE_OFFSET 24 /* offset of the command opcode in the first
  94. * command word.*/
  95. enum cmd_mb_opcodes {
  96. CMD_00_INFO_DEBUG = 0x00,
  97. CMD_01_GET_SYS_CFG = 0x01,
  98. CMD_02_SET_GRANULARITY = 0x02,
  99. CMD_03_SET_TIMER_IRQ = 0x03,
  100. CMD_04_GET_EVENT = 0x04,
  101. CMD_05_GET_PIPES = 0x05,
  102. CMD_06_ALLOCATE_PIPE = 0x06,
  103. CMD_07_RELEASE_PIPE = 0x07,
  104. CMD_08_ASK_BUFFERS = 0x08,
  105. CMD_09_STOP_PIPE = 0x09,
  106. CMD_0A_GET_PIPE_SPL_COUNT = 0x0a,
  107. CMD_0B_TOGGLE_PIPE_STATE = 0x0b,
  108. CMD_0C_DEF_STREAM = 0x0c,
  109. CMD_0D_SET_MUTE = 0x0d,
  110. CMD_0E_GET_STREAM_SPL_COUNT = 0x0e,
  111. CMD_0F_UPDATE_BUFFER = 0x0f,
  112. CMD_10_GET_BUFFER = 0x10,
  113. CMD_11_CANCEL_BUFFER = 0x11,
  114. CMD_12_GET_PEAK = 0x12,
  115. CMD_13_SET_STREAM_STATE = 0x13,
  116. CMD_14_INVALID = 0x14,
  117. };
  118. /* pipe states */
  119. enum pipe_state_t {
  120. PSTATE_IDLE = 0, /* the pipe is not processed in the XES_IRQ
  121. * (free or stopped, or paused). */
  122. PSTATE_RUN = 1, /* sustained play/record state. */
  123. PSTATE_PURGE = 2, /* the ES channels are now off, render pipes do
  124. * not DMA, record pipe do a last DMA. */
  125. PSTATE_ACQUIRE = 3, /* the ES channels are now on, render pipes do
  126. * not yet increase their sample count, record
  127. * pipes do not DMA. */
  128. PSTATE_CLOSING = 4, /* the pipe is releasing, and may not yet
  129. * receive an "alloc" command. */
  130. };
  131. /* stream states */
  132. enum stream_state_t {
  133. SSTATE_STOP = 0x00, /* setting to stop resets the stream spl
  134. * count.*/
  135. SSTATE_RUN = (0x01 << 0), /* start DMA and spl count handling. */
  136. SSTATE_PAUSE = (0x01 << 1), /* pause DMA and spl count handling. */
  137. };
  138. /* buffer flags */
  139. enum buffer_flags {
  140. BF_VALID = 0x80, /* set if the buffer is valid, clear if free.*/
  141. BF_CURRENT = 0x40, /* set if this is the current buffer (there is
  142. * always a current buffer).*/
  143. BF_NOTIFY_EOB = 0x20, /* set if this buffer must cause a PCI event
  144. * when finished.*/
  145. BF_CIRCULAR = 0x10, /* set if buffer[1] must be copied to buffer[0]
  146. * by the end of this buffer.*/
  147. BF_64BITS_ADR = 0x08, /* set if the hi part of the address is valid.*/
  148. BF_xx = 0x04, /* future extension.*/
  149. BF_EOB = 0x02, /* set if finished, but not yet free.*/
  150. BF_PAUSE = 0x01, /* pause stream at buffer end.*/
  151. BF_ZERO = 0x00, /* no flags (init).*/
  152. };
  153. /*
  154. * Stream Flags definitions
  155. */
  156. enum stream_flags {
  157. SF_ZERO = 0x00000000, /* no flags (stream invalid). */
  158. SF_VALID = 0x10000000, /* the stream has a valid DMA_conf
  159. * info (setstreamformat). */
  160. SF_XRUN = 0x20000000, /* the stream is un x-run state. */
  161. SF_START = 0x40000000, /* the DMA is running.*/
  162. SF_ASIO = 0x80000000, /* ASIO.*/
  163. };
  164. #define MASK_SPL_COUNT_HI 0x00FFFFFF /* 4 MSBits are status bits */
  165. #define PSTATE_OFFSET 28 /* 4 MSBits are status bits */
  166. #define MASK_STREAM_HAS_MAPPING (1L << 12)
  167. #define MASK_STREAM_IS_ASIO (1L << 9)
  168. #define STREAM_FMT_OFFSET 10 /* the stream fmt bits start at the 10th
  169. * bit in the command word. */
  170. #define STREAM_FMT_16b 0x02
  171. #define STREAM_FMT_intel 0x01
  172. #define FREQ_FIELD_OFFSET 15 /* offset of the freq field in the response
  173. * word */
  174. #define BUFF_FLAGS_OFFSET 24 /* offset of the buffer flags in the
  175. * response word. */
  176. #define MASK_DATA_SIZE 0x00FFFFFF /* this must match the field size of
  177. * datasize in the buffer_t structure. */
  178. #define MASK_BUFFER_ID 0xFF /* the cancel command awaits a buffer ID,
  179. * may be 0xFF for "current". */
  180. /* code adapted from PcxErr_e.h */
  181. /* Bits masks */
  182. #define ERROR_MASK 0x8000
  183. #define SOURCE_MASK 0x7800
  184. #define E_SOURCE_BOARD 0x4000 /* 8 >> 1 */
  185. #define E_SOURCE_DRV 0x2000 /* 4 >> 1 */
  186. #define E_SOURCE_API 0x1000 /* 2 >> 1 */
  187. /* Error tools */
  188. #define E_SOURCE_TOOLS 0x0800 /* 1 >> 1 */
  189. /* Error pcxaudio */
  190. #define E_SOURCE_AUDIO 0x1800 /* 3 >> 1 */
  191. /* Error virtual pcx */
  192. #define E_SOURCE_VPCX 0x2800 /* 5 >> 1 */
  193. /* Error dispatcher */
  194. #define E_SOURCE_DISPATCHER 0x3000 /* 6 >> 1 */
  195. /* Error from CobraNet firmware */
  196. #define E_SOURCE_COBRANET 0x3800 /* 7 >> 1 */
  197. #define E_SOURCE_USER 0x7800
  198. #define CLASS_MASK 0x0700
  199. #define CODE_MASK 0x00FF
  200. /* Bits values */
  201. /* Values for the error/warning bit */
  202. #define ERROR_VALUE 0x8000
  203. #define WARNING_VALUE 0x0000
  204. /* Class values */
  205. #define E_CLASS_GENERAL 0x0000
  206. #define E_CLASS_INVALID_CMD 0x0100
  207. #define E_CLASS_INVALID_STD_OBJECT 0x0200
  208. #define E_CLASS_RSRC_IMPOSSIBLE 0x0300
  209. #define E_CLASS_WRONG_CONTEXT 0x0400
  210. #define E_CLASS_BAD_SPECIFIC_PARAMETER 0x0500
  211. #define E_CLASS_REAL_TIME_ERROR 0x0600
  212. #define E_CLASS_DIRECTSHOW 0x0700
  213. #define E_CLASS_FREE 0x0700
  214. /* Complete DRV error code for the general class */
  215. #define ED_GN (ERROR_VALUE | E_SOURCE_DRV | E_CLASS_GENERAL)
  216. #define ED_CONCURRENCY (ED_GN | 0x01)
  217. #define ED_DSP_CRASHED (ED_GN | 0x02)
  218. #define ED_UNKNOWN_BOARD (ED_GN | 0x03)
  219. #define ED_NOT_INSTALLED (ED_GN | 0x04)
  220. #define ED_CANNOT_OPEN_SVC_MANAGER (ED_GN | 0x05)
  221. #define ED_CANNOT_READ_REGISTRY (ED_GN | 0x06)
  222. #define ED_DSP_VERSION_MISMATCH (ED_GN | 0x07)
  223. #define ED_UNAVAILABLE_FEATURE (ED_GN | 0x08)
  224. #define ED_CANCELLED (ED_GN | 0x09)
  225. #define ED_NO_RESPONSE_AT_IRQA (ED_GN | 0x10)
  226. #define ED_INVALID_ADDRESS (ED_GN | 0x11)
  227. #define ED_DSP_CORRUPTED (ED_GN | 0x12)
  228. #define ED_PENDING_OPERATION (ED_GN | 0x13)
  229. #define ED_NET_ALLOCATE_MEMORY_IMPOSSIBLE (ED_GN | 0x14)
  230. #define ED_NET_REGISTER_ERROR (ED_GN | 0x15)
  231. #define ED_NET_THREAD_ERROR (ED_GN | 0x16)
  232. #define ED_NET_OPEN_ERROR (ED_GN | 0x17)
  233. #define ED_NET_CLOSE_ERROR (ED_GN | 0x18)
  234. #define ED_NET_NO_MORE_PACKET (ED_GN | 0x19)
  235. #define ED_NET_NO_MORE_BUFFER (ED_GN | 0x1A)
  236. #define ED_NET_SEND_ERROR (ED_GN | 0x1B)
  237. #define ED_NET_RECEIVE_ERROR (ED_GN | 0x1C)
  238. #define ED_NET_WRONG_MSG_SIZE (ED_GN | 0x1D)
  239. #define ED_NET_WAIT_ERROR (ED_GN | 0x1E)
  240. #define ED_NET_EEPROM_ERROR (ED_GN | 0x1F)
  241. #define ED_INVALID_RS232_COM_NUMBER (ED_GN | 0x20)
  242. #define ED_INVALID_RS232_INIT (ED_GN | 0x21)
  243. #define ED_FILE_ERROR (ED_GN | 0x22)
  244. #define ED_INVALID_GPIO_CMD (ED_GN | 0x23)
  245. #define ED_RS232_ALREADY_OPENED (ED_GN | 0x24)
  246. #define ED_RS232_NOT_OPENED (ED_GN | 0x25)
  247. #define ED_GPIO_ALREADY_OPENED (ED_GN | 0x26)
  248. #define ED_GPIO_NOT_OPENED (ED_GN | 0x27)
  249. #define ED_REGISTRY_ERROR (ED_GN | 0x28) /* <- NCX */
  250. #define ED_INVALID_SERVICE (ED_GN | 0x29) /* <- NCX */
  251. #define ED_READ_FILE_ALREADY_OPENED (ED_GN | 0x2a) /* <- Decalage
  252. * pour RCX
  253. * (old 0x28)
  254. * */
  255. #define ED_READ_FILE_INVALID_COMMAND (ED_GN | 0x2b) /* ~ */
  256. #define ED_READ_FILE_INVALID_PARAMETER (ED_GN | 0x2c) /* ~ */
  257. #define ED_READ_FILE_ALREADY_CLOSED (ED_GN | 0x2d) /* ~ */
  258. #define ED_READ_FILE_NO_INFORMATION (ED_GN | 0x2e) /* ~ */
  259. #define ED_READ_FILE_INVALID_HANDLE (ED_GN | 0x2f) /* ~ */
  260. #define ED_READ_FILE_END_OF_FILE (ED_GN | 0x30) /* ~ */
  261. #define ED_READ_FILE_ERROR (ED_GN | 0x31) /* ~ */
  262. #define ED_DSP_CRASHED_EXC_DSPSTACK_OVERFLOW (ED_GN | 0x32) /* <- Decalage pour
  263. * PCX (old 0x14) */
  264. #define ED_DSP_CRASHED_EXC_SYSSTACK_OVERFLOW (ED_GN | 0x33) /* ~ */
  265. #define ED_DSP_CRASHED_EXC_ILLEGAL (ED_GN | 0x34) /* ~ */
  266. #define ED_DSP_CRASHED_EXC_TIMER_REENTRY (ED_GN | 0x35) /* ~ */
  267. #define ED_DSP_CRASHED_EXC_FATAL_ERROR (ED_GN | 0x36) /* ~ */
  268. #define ED_FLASH_PCCARD_NOT_PRESENT (ED_GN | 0x37)
  269. #define ED_NO_CURRENT_CLOCK (ED_GN | 0x38)
  270. /* Complete DRV error code for real time class */
  271. #define ED_RT (ERROR_VALUE | E_SOURCE_DRV | E_CLASS_REAL_TIME_ERROR)
  272. #define ED_DSP_TIMED_OUT (ED_RT | 0x01)
  273. #define ED_DSP_CHK_TIMED_OUT (ED_RT | 0x02)
  274. #define ED_STREAM_OVERRUN (ED_RT | 0x03)
  275. #define ED_DSP_BUSY (ED_RT | 0x04)
  276. #define ED_DSP_SEMAPHORE_TIME_OUT (ED_RT | 0x05)
  277. #define ED_BOARD_TIME_OUT (ED_RT | 0x06)
  278. #define ED_XILINX_ERROR (ED_RT | 0x07)
  279. #define ED_COBRANET_ITF_NOT_RESPONDING (ED_RT | 0x08)
  280. /* Complete BOARD error code for the invaid standard object class */
  281. #define EB_ISO (ERROR_VALUE | E_SOURCE_BOARD | \
  282. E_CLASS_INVALID_STD_OBJECT)
  283. #define EB_INVALID_EFFECT (EB_ISO | 0x00)
  284. #define EB_INVALID_PIPE (EB_ISO | 0x40)
  285. #define EB_INVALID_STREAM (EB_ISO | 0x80)
  286. #define EB_INVALID_AUDIO (EB_ISO | 0xC0)
  287. /* Complete BOARD error code for impossible resource allocation class */
  288. #define EB_RI (ERROR_VALUE | E_SOURCE_BOARD | E_CLASS_RSRC_IMPOSSIBLE)
  289. #define EB_ALLOCATE_ALL_STREAM_TRANSFERT_BUFFERS_IMPOSSIBLE (EB_RI | 0x01)
  290. #define EB_ALLOCATE_PIPE_SAMPLE_BUFFER_IMPOSSIBLE (EB_RI | 0x02)
  291. #define EB_ALLOCATE_MEM_STREAM_IMPOSSIBLE \
  292. EB_ALLOCATE_ALL_STREAM_TRANSFERT_BUFFERS_IMPOSSIBLE
  293. #define EB_ALLOCATE_MEM_PIPE_IMPOSSIBLE \
  294. EB_ALLOCATE_PIPE_SAMPLE_BUFFER_IMPOSSIBLE
  295. #define EB_ALLOCATE_DIFFERED_CMD_IMPOSSIBLE (EB_RI | 0x03)
  296. #define EB_TOO_MANY_DIFFERED_CMD (EB_RI | 0x04)
  297. #define EB_RBUFFERS_TABLE_OVERFLOW (EB_RI | 0x05)
  298. #define EB_ALLOCATE_EFFECTS_IMPOSSIBLE (EB_RI | 0x08)
  299. #define EB_ALLOCATE_EFFECT_POS_IMPOSSIBLE (EB_RI | 0x09)
  300. #define EB_RBUFFER_NOT_AVAILABLE (EB_RI | 0x0A)
  301. #define EB_ALLOCATE_CONTEXT_LIII_IMPOSSIBLE (EB_RI | 0x0B)
  302. #define EB_STATUS_DIALOG_IMPOSSIBLE (EB_RI | 0x1D)
  303. #define EB_CONTROL_CMD_IMPOSSIBLE (EB_RI | 0x1E)
  304. #define EB_STATUS_SEND_IMPOSSIBLE (EB_RI | 0x1F)
  305. #define EB_ALLOCATE_PIPE_IMPOSSIBLE (EB_RI | 0x40)
  306. #define EB_ALLOCATE_STREAM_IMPOSSIBLE (EB_RI | 0x80)
  307. #define EB_ALLOCATE_AUDIO_IMPOSSIBLE (EB_RI | 0xC0)
  308. /* Complete BOARD error code for wrong call context class */
  309. #define EB_WCC (ERROR_VALUE | E_SOURCE_BOARD | E_CLASS_WRONG_CONTEXT)
  310. #define EB_CMD_REFUSED (EB_WCC | 0x00)
  311. #define EB_START_STREAM_REFUSED (EB_WCC | 0xFC)
  312. #define EB_SPC_REFUSED (EB_WCC | 0xFD)
  313. #define EB_CSN_REFUSED (EB_WCC | 0xFE)
  314. #define EB_CSE_REFUSED (EB_WCC | 0xFF)
  315. #endif /* LX_DEFS_H */