vx_cmd.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Driver for Digigram VX soundcards
  3. *
  4. * Definitions of DSP commands
  5. *
  6. * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
  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; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef __VX_CMD_H
  23. #define __VX_CMD_H
  24. enum {
  25. CMD_VERSION,
  26. CMD_SUPPORTED,
  27. CMD_TEST_IT,
  28. CMD_SEND_IRQA,
  29. CMD_IBL,
  30. CMD_ASYNC,
  31. CMD_RES_PIPE,
  32. CMD_FREE_PIPE,
  33. CMD_CONF_PIPE,
  34. CMD_ABORT_CONF_PIPE,
  35. CMD_PARAM_OUTPUT_PIPE,
  36. CMD_STOP_PIPE,
  37. CMD_PIPE_STATE,
  38. CMD_PIPE_SPL_COUNT,
  39. CMD_CAN_START_PIPE,
  40. CMD_SIZE_HBUFFER,
  41. CMD_START_STREAM,
  42. CMD_START_ONE_STREAM,
  43. CMD_PAUSE_STREAM,
  44. CMD_PAUSE_ONE_STREAM,
  45. CMD_STREAM_OUT_LEVEL_ADJUST,
  46. CMD_STOP_STREAM,
  47. CMD_FORMAT_STREAM_OUT,
  48. CMD_FORMAT_STREAM_IN,
  49. CMD_GET_STREAM_STATE,
  50. CMD_DROP_BYTES_AWAY,
  51. CMD_GET_REMAINING_BYTES,
  52. CMD_CONNECT_AUDIO,
  53. CMD_AUDIO_LEVEL_ADJUST,
  54. CMD_AUDIO_VU_PIC_METER,
  55. CMD_GET_AUDIO_LEVELS,
  56. CMD_GET_NOTIFY_EVENT,
  57. CMD_INFO_NOTIFIED,
  58. CMD_ACCESS_IO_FCT,
  59. CMD_STATUS_R_BUFFERS,
  60. CMD_UPDATE_R_BUFFERS,
  61. CMD_LOAD_EFFECT_CONTEXT,
  62. CMD_EFFECT_ONE_PIPE,
  63. CMD_MODIFY_CLOCK,
  64. CMD_STREAM1_OUT_SET_N_LEVELS,
  65. CMD_PURGE_STREAM_DCMDS,
  66. CMD_NOTIFY_PIPE_TIME,
  67. CMD_LOAD_EFFECT_CONTEXT_PACKET,
  68. CMD_RELIC_R_BUFFER,
  69. CMD_RESYNC_AUDIO_INPUTS,
  70. CMD_NOTIFY_STREAM_TIME,
  71. CMD_STREAM_SAMPLE_COUNT,
  72. CMD_CONFIG_TIME_CODE,
  73. CMD_GET_TIME_CODE,
  74. CMD_MANAGE_SIGNAL,
  75. CMD_PARAMETER_STREAM_OUT,
  76. CMD_READ_BOARD_FREQ,
  77. CMD_GET_STREAM_LEVELS,
  78. CMD_PURGE_PIPE_DCMDS,
  79. // CMD_SET_STREAM_OUT_EFFECTS,
  80. // CMD_GET_STREAM_OUT_EFFECTS,
  81. CMD_CONNECT_MONITORING,
  82. CMD_STREAM2_OUT_SET_N_LEVELS,
  83. CMD_CANCEL_R_BUFFERS,
  84. CMD_NOTIFY_END_OF_BUFFER,
  85. CMD_GET_STREAM_VU_METER,
  86. CMD_LAST_INDEX
  87. };
  88. struct vx_cmd_info {
  89. unsigned int opcode; /* command word */
  90. int length; /* command length (in words) */
  91. int st_type; /* status type (RMH_SSIZE_XXX) */
  92. int st_length; /* fixed length */
  93. };
  94. /* Family and code op of some DSP requests. */
  95. #define CODE_OP_PIPE_TIME 0x004e0000
  96. #define CODE_OP_START_STREAM 0x00800000
  97. #define CODE_OP_PAUSE_STREAM 0x00810000
  98. #define CODE_OP_OUT_STREAM_LEVEL 0x00820000
  99. #define CODE_OP_UPDATE_R_BUFFERS 0x00840000
  100. #define CODE_OP_OUT_STREAM1_LEVEL_CURVE 0x00850000
  101. #define CODE_OP_OUT_STREAM2_LEVEL_CURVE 0x00930000
  102. #define CODE_OP_OUT_STREAM_FORMAT 0x00860000
  103. #define CODE_OP_STREAM_TIME 0x008f0000
  104. #define CODE_OP_OUT_STREAM_EXTRAPARAMETER 0x00910000
  105. #define CODE_OP_OUT_AUDIO_LEVEL 0x00c20000
  106. #define NOTIFY_LAST_COMMAND 0x00400000
  107. /* Values for a user delay */
  108. #define DC_DIFFERED_DELAY (1<<BIT_DIFFERED_COMMAND)
  109. #define DC_NOTIFY_DELAY (1<<BIT_NOTIFIED_COMMAND)
  110. #define DC_HBUFFER_DELAY (1<<BIT_TIME_RELATIVE_TO_BUFFER)
  111. #define DC_MULTIPLE_DELAY (1<<BIT_RESERVED)
  112. #define DC_STREAM_TIME_DELAY (1<<BIT_STREAM_TIME)
  113. #define DC_CANCELLED_DELAY (1<<BIT_CANCELLED_COMMAND)
  114. /* Values for tiDelayed field in TIME_INFO structure,
  115. * and for pbPause field in PLAY_BUFFER_INFO structure
  116. */
  117. #define BIT_DIFFERED_COMMAND 0
  118. #define BIT_NOTIFIED_COMMAND 1
  119. #define BIT_TIME_RELATIVE_TO_BUFFER 2
  120. #define BIT_RESERVED 3
  121. #define BIT_STREAM_TIME 4
  122. #define BIT_CANCELLED_COMMAND 5
  123. /* Access to the "Size" field of the response of the CMD_GET_NOTIFY_EVENT request. */
  124. #define GET_NOTIFY_EVENT_SIZE_FIELD_MASK 0x000000ff
  125. /* DSP commands general masks */
  126. #define OPCODE_MASK 0x00ff0000
  127. #define DSP_DIFFERED_COMMAND_MASK 0x0000C000
  128. /* Notifications (NOTIFY_INFO) */
  129. #define ALL_CMDS_NOTIFIED 0x0000 // reserved
  130. #define START_STREAM_NOTIFIED 0x0001
  131. #define PAUSE_STREAM_NOTIFIED 0x0002
  132. #define OUT_STREAM_LEVEL_NOTIFIED 0x0003
  133. #define OUT_STREAM_PARAMETER_NOTIFIED 0x0004 // left for backward compatibility
  134. #define OUT_STREAM_FORMAT_NOTIFIED 0x0004
  135. #define PIPE_TIME_NOTIFIED 0x0005
  136. #define OUT_AUDIO_LEVEL_NOTIFIED 0x0006
  137. #define OUT_STREAM_LEVEL_CURVE_NOTIFIED 0x0007
  138. #define STREAM_TIME_NOTIFIED 0x0008
  139. #define OUT_STREAM_EXTRAPARAMETER_NOTIFIED 0x0009
  140. #define UNKNOWN_COMMAND_NOTIFIED 0xffff
  141. /* Output pipe parameters setting */
  142. #define MASK_VALID_PIPE_MPEG_PARAM 0x000040
  143. #define MASK_VALID_PIPE_BACKWARD_PARAM 0x000020
  144. #define MASK_SET_PIPE_MPEG_PARAM 0x000002
  145. #define MASK_SET_PIPE_BACKWARD_PARAM 0x000001
  146. #define MASK_DSP_WORD 0x00FFFFFF
  147. #define MASK_ALL_STREAM 0x00FFFFFF
  148. #define MASK_DSP_WORD_LEVEL 0x000001FF
  149. #define MASK_FIRST_FIELD 0x0000001F
  150. #define FIELD_SIZE 5
  151. #define COMMAND_RECORD_MASK 0x000800
  152. /* PipeManagement definition bits (PIPE_DECL_INFO) */
  153. #define P_UNDERRUN_SKIP_SOUND_MASK 0x01
  154. #define P_PREPARE_FOR_MPEG3_MASK 0x02
  155. #define P_DO_NOT_RESET_ANALOG_LEVELS 0x04
  156. #define P_ALLOW_UNDER_ALLOCATION_MASK 0x08
  157. #define P_DATA_MODE_MASK 0x10
  158. #define P_ASIO_BUFFER_MANAGEMENT_MASK 0x20
  159. #define BIT_SKIP_SOUND 0x08 // bit 3
  160. #define BIT_DATA_MODE 0x10 // bit 4
  161. /* Bits in the CMD_MODIFY_CLOCK request. */
  162. #define CMD_MODIFY_CLOCK_FD_BIT 0x00000001
  163. #define CMD_MODIFY_CLOCK_T_BIT 0x00000002
  164. #define CMD_MODIFY_CLOCK_S_BIT 0x00000004
  165. /* Access to the results of the CMD_GET_TIME_CODE RMH. */
  166. #define TIME_CODE_V_MASK 0x00800000
  167. #define TIME_CODE_N_MASK 0x00400000
  168. #define TIME_CODE_B_MASK 0x00200000
  169. #define TIME_CODE_W_MASK 0x00100000
  170. /* Values for the CMD_MANAGE_SIGNAL RMH. */
  171. #define MANAGE_SIGNAL_TIME_CODE 0x01
  172. #define MANAGE_SIGNAL_MIDI 0x02
  173. /* Values for the CMD_CONFIG_TIME_CODE RMH. */
  174. #define CONFIG_TIME_CODE_CANCEL 0x00001000
  175. /* Mask to get only the effective time from the
  176. * high word out of the 2 returned by the DSP
  177. */
  178. #define PCX_TIME_HI_MASK 0x000fffff
  179. /* Values for setting a H-Buffer time */
  180. #define HBUFFER_TIME_HIGH 0x00200000
  181. #define HBUFFER_TIME_LOW 0x00000000
  182. #define NOTIFY_MASK_TIME_HIGH 0x00400000
  183. #define MULTIPLE_MASK_TIME_HIGH 0x00100000
  184. #define STREAM_MASK_TIME_HIGH 0x00800000
  185. /*
  186. *
  187. */
  188. void vx_init_rmh(struct vx_rmh *rmh, unsigned int cmd);
  189. /**
  190. * vx_send_pipe_cmd_params - fill first command word for pipe commands
  191. * @rmh: the rmh to be modified
  192. * @is_capture: 0 = playback, 1 = capture operation
  193. * @param1: first pipe-parameter
  194. * @param2: second pipe-parameter
  195. */
  196. static inline void vx_set_pipe_cmd_params(struct vx_rmh *rmh, int is_capture,
  197. int param1, int param2)
  198. {
  199. if (is_capture)
  200. rmh->Cmd[0] |= COMMAND_RECORD_MASK;
  201. rmh->Cmd[0] |= (((u32)param1 & MASK_FIRST_FIELD) << FIELD_SIZE) & MASK_DSP_WORD;
  202. if (param2)
  203. rmh->Cmd[0] |= ((u32)param2 & MASK_FIRST_FIELD) & MASK_DSP_WORD;
  204. }
  205. /**
  206. * vx_set_stream_cmd_params - fill first command word for stream commands
  207. * @rmh: the rmh to be modified
  208. * @is_capture: 0 = playback, 1 = capture operation
  209. * @pipe: the pipe index (zero-based)
  210. */
  211. static inline void vx_set_stream_cmd_params(struct vx_rmh *rmh, int is_capture, int pipe)
  212. {
  213. if (is_capture)
  214. rmh->Cmd[0] |= COMMAND_RECORD_MASK;
  215. rmh->Cmd[0] |= (((u32)pipe & MASK_FIRST_FIELD) << FIELD_SIZE) & MASK_DSP_WORD;
  216. }
  217. #endif /* __VX_CMD_H */