messages.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright(c) 2020 Intel Corporation. All rights reserved.
  4. *
  5. * Author: Cezary Rojewski <[email protected]>
  6. */
  7. #ifndef __SND_SOC_INTEL_CATPT_MSG_H
  8. #define __SND_SOC_INTEL_CATPT_MSG_H
  9. struct catpt_dev;
  10. /* IPC messages base types */
  11. enum catpt_reply_status {
  12. CATPT_REPLY_SUCCESS = 0,
  13. CATPT_REPLY_ERROR_INVALID_PARAM = 1,
  14. CATPT_REPLY_UNKNOWN_MESSAGE_TYPE = 2,
  15. CATPT_REPLY_OUT_OF_RESOURCES = 3,
  16. CATPT_REPLY_BUSY = 4,
  17. CATPT_REPLY_PENDING = 5,
  18. CATPT_REPLY_FAILURE = 6,
  19. CATPT_REPLY_INVALID_REQUEST = 7,
  20. CATPT_REPLY_UNINITIALIZED = 8,
  21. CATPT_REPLY_NOT_FOUND = 9,
  22. CATPT_REPLY_SOURCE_NOT_STARTED = 10,
  23. };
  24. /* GLOBAL messages */
  25. enum catpt_global_msg_type {
  26. CATPT_GLB_GET_FW_VERSION = 0,
  27. CATPT_GLB_ALLOCATE_STREAM = 3,
  28. CATPT_GLB_FREE_STREAM = 4,
  29. CATPT_GLB_STREAM_MESSAGE = 6,
  30. CATPT_GLB_REQUEST_CORE_DUMP = 7,
  31. CATPT_GLB_SET_DEVICE_FORMATS = 10,
  32. CATPT_GLB_ENTER_DX_STATE = 12,
  33. CATPT_GLB_GET_MIXER_STREAM_INFO = 13,
  34. };
  35. union catpt_global_msg {
  36. u32 val;
  37. struct {
  38. u32 status:5;
  39. u32 context:19; /* stream or module specific */
  40. u32 global_msg_type:5;
  41. u32 fw_ready:1;
  42. u32 done:1;
  43. u32 busy:1;
  44. };
  45. } __packed;
  46. #define CATPT_MSG(hdr) { .val = hdr }
  47. #define CATPT_GLOBAL_MSG(msg_type) \
  48. { .global_msg_type = CATPT_GLB_##msg_type }
  49. #define BUILD_HASH_SIZE 40
  50. struct catpt_fw_version {
  51. u8 build;
  52. u8 minor;
  53. u8 major;
  54. u8 type;
  55. u8 build_hash[BUILD_HASH_SIZE];
  56. u32 log_providers_hash;
  57. } __packed;
  58. int catpt_ipc_get_fw_version(struct catpt_dev *cdev,
  59. struct catpt_fw_version *version);
  60. enum catpt_pin_id {
  61. CATPT_PIN_ID_SYSTEM = 0,
  62. CATPT_PIN_ID_REFERENCE = 1,
  63. CATPT_PIN_ID_CAPTURE1 = 2,
  64. CATPT_PIN_ID_CAPTURE2 = 3,
  65. CATPT_PIN_ID_OFFLOAD1 = 4,
  66. CATPT_PIN_ID_OFFLOAD2 = 5,
  67. CATPT_PIN_ID_MIXER = 7,
  68. CATPT_PIN_ID_BLUETOOTH_CAPTURE = 8,
  69. CATPT_PIN_ID_BLUETOOTH_RENDER = 9,
  70. };
  71. enum catpt_path_id {
  72. CATPT_PATH_SSP0_OUT = 0,
  73. CATPT_PATH_SSP0_IN = 1,
  74. CATPT_PATH_SSP1_OUT = 2,
  75. CATPT_PATH_SSP1_IN = 3,
  76. /* duplicated audio in capture path */
  77. CATPT_PATH_SSP0_IN_DUP = 4,
  78. };
  79. enum catpt_stream_type {
  80. CATPT_STRM_TYPE_RENDER = 0, /* offload */
  81. CATPT_STRM_TYPE_SYSTEM = 1,
  82. CATPT_STRM_TYPE_CAPTURE = 2,
  83. CATPT_STRM_TYPE_LOOPBACK = 3,
  84. CATPT_STRM_TYPE_BLUETOOTH_RENDER = 4,
  85. CATPT_STRM_TYPE_BLUETOOTH_CAPTURE = 5,
  86. };
  87. enum catpt_format_id {
  88. CATPT_FORMAT_PCM = 0,
  89. CATPT_FORMAT_MP3 = 1,
  90. CATPT_FORMAT_AAC = 2,
  91. CATPT_FORMAT_WMA = 3,
  92. };
  93. enum catpt_channel_index {
  94. CATPT_CHANNEL_LEFT = 0x0,
  95. CATPT_CHANNEL_CENTER = 0x1,
  96. CATPT_CHANNEL_RIGHT = 0x2,
  97. CATPT_CHANNEL_LEFT_SURROUND = 0x3,
  98. CATPT_CHANNEL_CENTER_SURROUND = 0x3,
  99. CATPT_CHANNEL_RIGHT_SURROUND = 0x4,
  100. CATPT_CHANNEL_LFE = 0x7,
  101. CATPT_CHANNEL_INVALID = 0xF,
  102. };
  103. enum catpt_channel_config {
  104. CATPT_CHANNEL_CONFIG_MONO = 0, /* One channel only */
  105. CATPT_CHANNEL_CONFIG_STEREO = 1, /* L & R */
  106. CATPT_CHANNEL_CONFIG_2_POINT_1 = 2, /* L, R & LFE; PCM only */
  107. CATPT_CHANNEL_CONFIG_3_POINT_0 = 3, /* L, C & R; MP3 & AAC only */
  108. CATPT_CHANNEL_CONFIG_3_POINT_1 = 4, /* L, C, R & LFE; PCM only */
  109. CATPT_CHANNEL_CONFIG_QUATRO = 5, /* L, R, Ls & Rs; PCM only */
  110. CATPT_CHANNEL_CONFIG_4_POINT_0 = 6, /* L, C, R & Cs; MP3 & AAC only */
  111. CATPT_CHANNEL_CONFIG_5_POINT_0 = 7, /* L, C, R, Ls & Rs */
  112. CATPT_CHANNEL_CONFIG_5_POINT_1 = 8, /* L, C, R, Ls, Rs & LFE */
  113. CATPT_CHANNEL_CONFIG_DUAL_MONO = 9, /* One channel replicated in two */
  114. CATPT_CHANNEL_CONFIG_INVALID = 10,
  115. };
  116. enum catpt_interleaving_style {
  117. CATPT_INTERLEAVING_PER_CHANNEL = 0,
  118. CATPT_INTERLEAVING_PER_SAMPLE = 1,
  119. };
  120. struct catpt_audio_format {
  121. u32 sample_rate;
  122. u32 bit_depth;
  123. u32 channel_map;
  124. u32 channel_config;
  125. u32 interleaving;
  126. u8 num_channels;
  127. u8 valid_bit_depth;
  128. u8 reserved[2];
  129. } __packed;
  130. struct catpt_ring_info {
  131. u32 page_table_addr;
  132. u32 num_pages;
  133. u32 size;
  134. u32 offset;
  135. u32 ring_first_page_pfn;
  136. } __packed;
  137. #define CATPT_MODULE_COUNT (CATPT_MODID_LAST + 1)
  138. enum catpt_module_id {
  139. CATPT_MODID_BASE_FW = 0x0,
  140. CATPT_MODID_MP3 = 0x1,
  141. CATPT_MODID_AAC_5_1 = 0x2,
  142. CATPT_MODID_AAC_2_0 = 0x3,
  143. CATPT_MODID_SRC = 0x4,
  144. CATPT_MODID_WAVES = 0x5,
  145. CATPT_MODID_DOLBY = 0x6,
  146. CATPT_MODID_BOOST = 0x7,
  147. CATPT_MODID_LPAL = 0x8,
  148. CATPT_MODID_DTS = 0x9,
  149. CATPT_MODID_PCM_CAPTURE = 0xA,
  150. CATPT_MODID_PCM_SYSTEM = 0xB,
  151. CATPT_MODID_PCM_REFERENCE = 0xC,
  152. CATPT_MODID_PCM = 0xD, /* offload */
  153. CATPT_MODID_BLUETOOTH_RENDER = 0xE,
  154. CATPT_MODID_BLUETOOTH_CAPTURE = 0xF,
  155. CATPT_MODID_LAST = CATPT_MODID_BLUETOOTH_CAPTURE,
  156. };
  157. struct catpt_module_entry {
  158. u32 module_id;
  159. u32 entry_point;
  160. } __packed;
  161. struct catpt_module_map {
  162. u8 num_entries;
  163. struct catpt_module_entry entries[];
  164. } __packed;
  165. struct catpt_memory_info {
  166. u32 offset;
  167. u32 size;
  168. } __packed;
  169. #define CATPT_CHANNELS_MAX 4
  170. #define CATPT_ALL_CHANNELS_MASK UINT_MAX
  171. struct catpt_stream_info {
  172. u32 stream_hw_id;
  173. u32 reserved;
  174. u32 read_pos_regaddr;
  175. u32 pres_pos_regaddr;
  176. u32 peak_meter_regaddr[CATPT_CHANNELS_MAX];
  177. u32 volume_regaddr[CATPT_CHANNELS_MAX];
  178. } __packed;
  179. int catpt_ipc_alloc_stream(struct catpt_dev *cdev,
  180. enum catpt_path_id path_id,
  181. enum catpt_stream_type type,
  182. struct catpt_audio_format *afmt,
  183. struct catpt_ring_info *rinfo,
  184. u8 num_modules,
  185. struct catpt_module_entry *modules,
  186. struct resource *persistent,
  187. struct resource *scratch,
  188. struct catpt_stream_info *sinfo);
  189. int catpt_ipc_free_stream(struct catpt_dev *cdev, u8 stream_hw_id);
  190. enum catpt_ssp_iface {
  191. CATPT_SSP_IFACE_0 = 0,
  192. CATPT_SSP_IFACE_1 = 1,
  193. CATPT_SSP_COUNT,
  194. };
  195. enum catpt_mclk_frequency {
  196. CATPT_MCLK_OFF = 0,
  197. CATPT_MCLK_FREQ_6_MHZ = 1,
  198. CATPT_MCLK_FREQ_21_MHZ = 2,
  199. CATPT_MCLK_FREQ_24_MHZ = 3,
  200. };
  201. enum catpt_ssp_mode {
  202. CATPT_SSP_MODE_I2S_CONSUMER = 0,
  203. CATPT_SSP_MODE_I2S_PROVIDER = 1,
  204. CATPT_SSP_MODE_TDM_PROVIDER = 2,
  205. };
  206. struct catpt_ssp_device_format {
  207. u32 iface;
  208. u32 mclk;
  209. u32 mode;
  210. u16 clock_divider;
  211. u8 channels;
  212. } __packed;
  213. int catpt_ipc_set_device_format(struct catpt_dev *cdev,
  214. struct catpt_ssp_device_format *devfmt);
  215. enum catpt_dx_state {
  216. CATPT_DX_STATE_D3 = 3,
  217. };
  218. enum catpt_dx_type {
  219. CATPT_DX_TYPE_FW_IMAGE = 0,
  220. CATPT_DX_TYPE_MEMORY_DUMP = 1,
  221. };
  222. struct catpt_save_meminfo {
  223. u32 offset;
  224. u32 size;
  225. u32 source;
  226. } __packed;
  227. #define SAVE_MEMINFO_MAX 14
  228. struct catpt_dx_context {
  229. u32 num_meminfo;
  230. struct catpt_save_meminfo meminfo[SAVE_MEMINFO_MAX];
  231. } __packed;
  232. int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state,
  233. struct catpt_dx_context *context);
  234. struct catpt_mixer_stream_info {
  235. u32 mixer_hw_id;
  236. u32 peak_meter_regaddr[CATPT_CHANNELS_MAX];
  237. u32 volume_regaddr[CATPT_CHANNELS_MAX];
  238. } __packed;
  239. int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev,
  240. struct catpt_mixer_stream_info *info);
  241. /* STREAM messages */
  242. enum catpt_stream_msg_type {
  243. CATPT_STRM_RESET_STREAM = 0,
  244. CATPT_STRM_PAUSE_STREAM = 1,
  245. CATPT_STRM_RESUME_STREAM = 2,
  246. CATPT_STRM_STAGE_MESSAGE = 3,
  247. CATPT_STRM_NOTIFICATION = 4,
  248. };
  249. enum catpt_stage_action {
  250. CATPT_STG_SET_VOLUME = 1,
  251. CATPT_STG_SET_WRITE_POSITION = 2,
  252. CATPT_STG_MUTE_LOOPBACK = 3,
  253. };
  254. union catpt_stream_msg {
  255. u32 val;
  256. struct {
  257. u32 status:5;
  258. u32 reserved:7;
  259. u32 stage_action:4;
  260. u32 stream_hw_id:4;
  261. u32 stream_msg_type:4;
  262. u32 global_msg_type:5;
  263. u32 fw_ready:1;
  264. u32 done:1;
  265. u32 busy:1;
  266. };
  267. } __packed;
  268. #define CATPT_STREAM_MSG(msg_type) \
  269. { \
  270. .stream_msg_type = CATPT_STRM_##msg_type, \
  271. .global_msg_type = CATPT_GLB_STREAM_MESSAGE }
  272. #define CATPT_STAGE_MSG(msg_type) \
  273. { \
  274. .stage_action = CATPT_STG_##msg_type, \
  275. .stream_msg_type = CATPT_STRM_STAGE_MESSAGE, \
  276. .global_msg_type = CATPT_GLB_STREAM_MESSAGE }
  277. int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id);
  278. int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id);
  279. int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id);
  280. /* STREAM messages - STAGE subtype */
  281. enum catpt_audio_curve_type {
  282. CATPT_AUDIO_CURVE_NONE = 0,
  283. CATPT_AUDIO_CURVE_WINDOWS_FADE = 1,
  284. };
  285. int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id,
  286. u32 channel, u32 volume,
  287. u32 curve_duration,
  288. enum catpt_audio_curve_type curve_type);
  289. int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id,
  290. u32 pos, bool eob, bool ll);
  291. int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute);
  292. /* NOTIFICATION messages */
  293. enum catpt_notify_reason {
  294. CATPT_NOTIFY_POSITION_CHANGED = 0,
  295. CATPT_NOTIFY_GLITCH_OCCURRED = 1,
  296. };
  297. union catpt_notify_msg {
  298. u32 val;
  299. struct {
  300. u32 mailbox_address:29;
  301. u32 fw_ready:1;
  302. u32 done:1;
  303. u32 busy:1;
  304. };
  305. struct {
  306. u32 status:5;
  307. u32 reserved:7;
  308. u32 notify_reason:4;
  309. u32 stream_hw_id:4;
  310. u32 stream_msg_type:4;
  311. u32 global_msg_type:5;
  312. u32 hdr:3; /* fw_ready, done, busy */
  313. };
  314. } __packed;
  315. #define FW_INFO_SIZE_MAX 100
  316. struct catpt_fw_ready {
  317. u32 inbox_offset;
  318. u32 outbox_offset;
  319. u32 inbox_size;
  320. u32 outbox_size;
  321. u32 fw_info_size;
  322. char fw_info[FW_INFO_SIZE_MAX];
  323. } __packed;
  324. struct catpt_notify_position {
  325. u32 stream_position;
  326. u32 fw_cycle_count;
  327. } __packed;
  328. enum catpt_glitch_type {
  329. CATPT_GLITCH_UNDERRUN = 1,
  330. CATPT_GLITCH_DECODER_ERROR = 2,
  331. CATPT_GLITCH_DOUBLED_WRITE_POS = 3,
  332. };
  333. struct catpt_notify_glitch {
  334. u32 type;
  335. u64 presentation_pos;
  336. u32 write_pos;
  337. } __packed;
  338. #endif