vx_cmd.h 7.1 KB

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