sst-haswell-ipc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * Intel SST Haswell/Broadwell IPC Support
  3. *
  4. * Copyright (C) 2013, Intel Corporation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  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. *
  15. */
  16. #ifndef __SST_HASWELL_IPC_H
  17. #define __SST_HASWELL_IPC_H
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/platform_device.h>
  21. #define SST_HSW_NO_CHANNELS 2
  22. #define SST_HSW_MAX_DX_REGIONS 14
  23. #define SST_HSW_FW_LOG_CONFIG_DWORDS 12
  24. #define SST_HSW_GLOBAL_LOG 15
  25. /**
  26. * Upfront defined maximum message size that is
  27. * expected by the in/out communication pipes in FW.
  28. */
  29. #define SST_HSW_IPC_MAX_PAYLOAD_SIZE 400
  30. #define SST_HSW_MAX_INFO_SIZE 64
  31. #define SST_HSW_BUILD_HASH_LENGTH 40
  32. struct sst_hsw;
  33. struct sst_hsw_stream;
  34. struct sst_hsw_log_stream;
  35. struct sst_pdata;
  36. struct sst_module;
  37. extern struct sst_ops haswell_ops;
  38. /* Stream Allocate Path ID */
  39. enum sst_hsw_stream_path_id {
  40. SST_HSW_STREAM_PATH_SSP0_OUT = 0,
  41. SST_HSW_STREAM_PATH_SSP0_IN = 1,
  42. SST_HSW_STREAM_PATH_MAX_PATH_ID = 2,
  43. };
  44. /* Stream Allocate Stream Type */
  45. enum sst_hsw_stream_type {
  46. SST_HSW_STREAM_TYPE_RENDER = 0,
  47. SST_HSW_STREAM_TYPE_SYSTEM = 1,
  48. SST_HSW_STREAM_TYPE_CAPTURE = 2,
  49. SST_HSW_STREAM_TYPE_LOOPBACK = 3,
  50. SST_HSW_STREAM_TYPE_MAX_STREAM_TYPE = 4,
  51. };
  52. /* Stream Allocate Stream Format */
  53. enum sst_hsw_stream_format {
  54. SST_HSW_STREAM_FORMAT_PCM_FORMAT = 0,
  55. SST_HSW_STREAM_FORMAT_MP3_FORMAT = 1,
  56. SST_HSW_STREAM_FORMAT_AAC_FORMAT = 2,
  57. SST_HSW_STREAM_FORMAT_MAX_FORMAT_ID = 3,
  58. };
  59. /* Device ID */
  60. enum sst_hsw_device_id {
  61. SST_HSW_DEVICE_SSP_0 = 0,
  62. SST_HSW_DEVICE_SSP_1 = 1,
  63. };
  64. /* Device Master Clock Frequency */
  65. enum sst_hsw_device_mclk {
  66. SST_HSW_DEVICE_MCLK_OFF = 0,
  67. SST_HSW_DEVICE_MCLK_FREQ_6_MHZ = 1,
  68. SST_HSW_DEVICE_MCLK_FREQ_12_MHZ = 2,
  69. SST_HSW_DEVICE_MCLK_FREQ_24_MHZ = 3,
  70. };
  71. /* Device Clock Master */
  72. enum sst_hsw_device_mode {
  73. SST_HSW_DEVICE_CLOCK_SLAVE = 0,
  74. SST_HSW_DEVICE_CLOCK_MASTER = 1,
  75. };
  76. /* DX Power State */
  77. enum sst_hsw_dx_state {
  78. SST_HSW_DX_STATE_D0 = 0,
  79. SST_HSW_DX_STATE_D1 = 1,
  80. SST_HSW_DX_STATE_D3 = 3,
  81. SST_HSW_DX_STATE_MAX = 3,
  82. };
  83. /* Audio stream stage IDs */
  84. enum sst_hsw_fx_stage_id {
  85. SST_HSW_STAGE_ID_WAVES = 0,
  86. SST_HSW_STAGE_ID_DTS = 1,
  87. SST_HSW_STAGE_ID_DOLBY = 2,
  88. SST_HSW_STAGE_ID_BOOST = 3,
  89. SST_HSW_STAGE_ID_MAX_FX_ID
  90. };
  91. /* DX State Type */
  92. enum sst_hsw_dx_type {
  93. SST_HSW_DX_TYPE_FW_IMAGE = 0,
  94. SST_HSW_DX_TYPE_MEMORY_DUMP = 1
  95. };
  96. /* Volume Curve Type*/
  97. enum sst_hsw_volume_curve {
  98. SST_HSW_VOLUME_CURVE_NONE = 0,
  99. SST_HSW_VOLUME_CURVE_FADE = 1
  100. };
  101. /* Sample ordering */
  102. enum sst_hsw_interleaving {
  103. SST_HSW_INTERLEAVING_PER_CHANNEL = 0,
  104. SST_HSW_INTERLEAVING_PER_SAMPLE = 1,
  105. };
  106. /* Channel indices */
  107. enum sst_hsw_channel_index {
  108. SST_HSW_CHANNEL_LEFT = 0,
  109. SST_HSW_CHANNEL_CENTER = 1,
  110. SST_HSW_CHANNEL_RIGHT = 2,
  111. SST_HSW_CHANNEL_LEFT_SURROUND = 3,
  112. SST_HSW_CHANNEL_CENTER_SURROUND = 3,
  113. SST_HSW_CHANNEL_RIGHT_SURROUND = 4,
  114. SST_HSW_CHANNEL_LFE = 7,
  115. SST_HSW_CHANNEL_INVALID = 0xF,
  116. };
  117. /* List of supported channel maps. */
  118. enum sst_hsw_channel_config {
  119. SST_HSW_CHANNEL_CONFIG_MONO = 0, /* mono only. */
  120. SST_HSW_CHANNEL_CONFIG_STEREO = 1, /* L & R. */
  121. SST_HSW_CHANNEL_CONFIG_2_POINT_1 = 2, /* L, R & LFE; PCM only. */
  122. SST_HSW_CHANNEL_CONFIG_3_POINT_0 = 3, /* L, C & R; MP3 & AAC only. */
  123. SST_HSW_CHANNEL_CONFIG_3_POINT_1 = 4, /* L, C, R & LFE; PCM only. */
  124. SST_HSW_CHANNEL_CONFIG_QUATRO = 5, /* L, R, Ls & Rs; PCM only. */
  125. SST_HSW_CHANNEL_CONFIG_4_POINT_0 = 6, /* L, C, R & Cs; MP3 & AAC only. */
  126. SST_HSW_CHANNEL_CONFIG_5_POINT_0 = 7, /* L, C, R, Ls & Rs. */
  127. SST_HSW_CHANNEL_CONFIG_5_POINT_1 = 8, /* L, C, R, Ls, Rs & LFE. */
  128. SST_HSW_CHANNEL_CONFIG_DUAL_MONO = 9, /* One channel replicated in two. */
  129. SST_HSW_CHANNEL_CONFIG_INVALID,
  130. };
  131. /* List of supported bit depths. */
  132. enum sst_hsw_bitdepth {
  133. SST_HSW_DEPTH_8BIT = 8,
  134. SST_HSW_DEPTH_16BIT = 16,
  135. SST_HSW_DEPTH_24BIT = 24, /* Default. */
  136. SST_HSW_DEPTH_32BIT = 32,
  137. SST_HSW_DEPTH_INVALID = 33,
  138. };
  139. enum sst_hsw_module_id {
  140. SST_HSW_MODULE_BASE_FW = 0x0,
  141. SST_HSW_MODULE_MP3 = 0x1,
  142. SST_HSW_MODULE_AAC_5_1 = 0x2,
  143. SST_HSW_MODULE_AAC_2_0 = 0x3,
  144. SST_HSW_MODULE_SRC = 0x4,
  145. SST_HSW_MODULE_WAVES = 0x5,
  146. SST_HSW_MODULE_DOLBY = 0x6,
  147. SST_HSW_MODULE_BOOST = 0x7,
  148. SST_HSW_MODULE_LPAL = 0x8,
  149. SST_HSW_MODULE_DTS = 0x9,
  150. SST_HSW_MODULE_PCM_CAPTURE = 0xA,
  151. SST_HSW_MODULE_PCM_SYSTEM = 0xB,
  152. SST_HSW_MODULE_PCM_REFERENCE = 0xC,
  153. SST_HSW_MODULE_PCM = 0xD,
  154. SST_HSW_MODULE_BLUETOOTH_RENDER_MODULE = 0xE,
  155. SST_HSW_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF,
  156. SST_HSW_MAX_MODULE_ID,
  157. };
  158. enum sst_hsw_performance_action {
  159. SST_HSW_PERF_START = 0,
  160. SST_HSW_PERF_STOP = 1,
  161. };
  162. /* SST firmware module info */
  163. struct sst_hsw_module_info {
  164. u8 name[SST_HSW_MAX_INFO_SIZE];
  165. u8 version[SST_HSW_MAX_INFO_SIZE];
  166. } __attribute__((packed));
  167. /* Module entry point */
  168. struct sst_hsw_module_entry {
  169. enum sst_hsw_module_id module_id;
  170. u32 entry_point;
  171. } __attribute__((packed));
  172. /* Module map - alignement matches DSP */
  173. struct sst_hsw_module_map {
  174. u8 module_entries_count;
  175. struct sst_hsw_module_entry module_entries[1];
  176. } __attribute__((packed));
  177. struct sst_hsw_memory_info {
  178. u32 offset;
  179. u32 size;
  180. } __attribute__((packed));
  181. struct sst_hsw_fx_enable {
  182. struct sst_hsw_module_map module_map;
  183. struct sst_hsw_memory_info persistent_mem;
  184. } __attribute__((packed));
  185. struct sst_hsw_get_fx_param {
  186. u32 parameter_id;
  187. u32 param_size;
  188. } __attribute__((packed));
  189. struct sst_hsw_perf_action {
  190. u32 action;
  191. } __attribute__((packed));
  192. struct sst_hsw_perf_data {
  193. u64 timestamp;
  194. u64 cycles;
  195. u64 datatime;
  196. } __attribute__((packed));
  197. /* FW version */
  198. struct sst_hsw_ipc_fw_version {
  199. u8 build;
  200. u8 minor;
  201. u8 major;
  202. u8 type;
  203. u8 fw_build_hash[SST_HSW_BUILD_HASH_LENGTH];
  204. u32 fw_log_providers_hash;
  205. } __attribute__((packed));
  206. /* Stream ring info */
  207. struct sst_hsw_ipc_stream_ring {
  208. u32 ring_pt_address;
  209. u32 num_pages;
  210. u32 ring_size;
  211. u32 ring_offset;
  212. u32 ring_first_pfn;
  213. } __attribute__((packed));
  214. /* Debug Dump Log Enable Request */
  215. struct sst_hsw_ipc_debug_log_enable_req {
  216. struct sst_hsw_ipc_stream_ring ringinfo;
  217. u32 config[SST_HSW_FW_LOG_CONFIG_DWORDS];
  218. } __attribute__((packed));
  219. /* Debug Dump Log Reply */
  220. struct sst_hsw_ipc_debug_log_reply {
  221. u32 log_buffer_begining;
  222. u32 log_buffer_size;
  223. } __attribute__((packed));
  224. /* Stream glitch position */
  225. struct sst_hsw_ipc_stream_glitch_position {
  226. u32 glitch_type;
  227. u32 present_pos;
  228. u32 write_pos;
  229. } __attribute__((packed));
  230. /* Stream get position */
  231. struct sst_hsw_ipc_stream_get_position {
  232. u32 position;
  233. u32 fw_cycle_count;
  234. } __attribute__((packed));
  235. /* Stream set position */
  236. struct sst_hsw_ipc_stream_set_position {
  237. u32 position;
  238. u32 end_of_buffer;
  239. } __attribute__((packed));
  240. /* Stream Free Request */
  241. struct sst_hsw_ipc_stream_free_req {
  242. u8 stream_id;
  243. u8 reserved[3];
  244. } __attribute__((packed));
  245. /* Set Volume Request */
  246. struct sst_hsw_ipc_volume_req {
  247. u32 channel;
  248. u32 target_volume;
  249. u64 curve_duration;
  250. u32 curve_type;
  251. } __attribute__((packed));
  252. /* Device Configuration Request */
  253. struct sst_hsw_ipc_device_config_req {
  254. u32 ssp_interface;
  255. u32 clock_frequency;
  256. u32 mode;
  257. u16 clock_divider;
  258. u16 reserved;
  259. } __attribute__((packed));
  260. /* Audio Data formats */
  261. struct sst_hsw_audio_data_format_ipc {
  262. u32 frequency;
  263. u32 bitdepth;
  264. u32 map;
  265. u32 config;
  266. u32 style;
  267. u8 ch_num;
  268. u8 valid_bit;
  269. u8 reserved[2];
  270. } __attribute__((packed));
  271. /* Stream Allocate Request */
  272. struct sst_hsw_ipc_stream_alloc_req {
  273. u8 path_id;
  274. u8 stream_type;
  275. u8 format_id;
  276. u8 reserved;
  277. struct sst_hsw_audio_data_format_ipc format;
  278. struct sst_hsw_ipc_stream_ring ringinfo;
  279. struct sst_hsw_module_map map;
  280. struct sst_hsw_memory_info persistent_mem;
  281. struct sst_hsw_memory_info scratch_mem;
  282. u32 number_of_notifications;
  283. } __attribute__((packed));
  284. /* Stream Allocate Reply */
  285. struct sst_hsw_ipc_stream_alloc_reply {
  286. u32 stream_hw_id;
  287. u32 mixer_hw_id; // returns rate ????
  288. u32 read_position_register_address;
  289. u32 presentation_position_register_address;
  290. u32 peak_meter_register_address[SST_HSW_NO_CHANNELS];
  291. u32 volume_register_address[SST_HSW_NO_CHANNELS];
  292. } __attribute__((packed));
  293. /* Get Mixer Stream Info */
  294. struct sst_hsw_ipc_stream_info_reply {
  295. u32 mixer_hw_id;
  296. u32 peak_meter_register_address[SST_HSW_NO_CHANNELS];
  297. u32 volume_register_address[SST_HSW_NO_CHANNELS];
  298. } __attribute__((packed));
  299. /* DX State Request */
  300. struct sst_hsw_ipc_dx_req {
  301. u8 state;
  302. u8 reserved[3];
  303. } __attribute__((packed));
  304. /* DX State Reply Memory Info Item */
  305. struct sst_hsw_ipc_dx_memory_item {
  306. u32 offset;
  307. u32 size;
  308. u32 source;
  309. } __attribute__((packed));
  310. /* DX State Reply */
  311. struct sst_hsw_ipc_dx_reply {
  312. u32 entries_no;
  313. struct sst_hsw_ipc_dx_memory_item mem_info[SST_HSW_MAX_DX_REGIONS];
  314. } __attribute__((packed));
  315. struct sst_hsw_ipc_fw_version;
  316. /* SST Init & Free */
  317. struct sst_hsw *sst_hsw_new(struct device *dev, const u8 *fw, size_t fw_length,
  318. u32 fw_offset);
  319. void sst_hsw_free(struct sst_hsw *hsw);
  320. int sst_hsw_fw_get_version(struct sst_hsw *hsw,
  321. struct sst_hsw_ipc_fw_version *version);
  322. u32 create_channel_map(enum sst_hsw_channel_config config);
  323. /* Stream Mixer Controls - */
  324. int sst_hsw_stream_mute(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  325. u32 stage_id, u32 channel);
  326. int sst_hsw_stream_unmute(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  327. u32 stage_id, u32 channel);
  328. int sst_hsw_stream_set_volume(struct sst_hsw *hsw,
  329. struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume);
  330. int sst_hsw_stream_get_volume(struct sst_hsw *hsw,
  331. struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 *volume);
  332. int sst_hsw_stream_set_volume_curve(struct sst_hsw *hsw,
  333. struct sst_hsw_stream *stream, u64 curve_duration,
  334. enum sst_hsw_volume_curve curve);
  335. /* Global Mixer Controls - */
  336. int sst_hsw_mixer_mute(struct sst_hsw *hsw, u32 stage_id, u32 channel);
  337. int sst_hsw_mixer_unmute(struct sst_hsw *hsw, u32 stage_id, u32 channel);
  338. int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
  339. u32 volume);
  340. int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
  341. u32 *volume);
  342. int sst_hsw_mixer_set_volume_curve(struct sst_hsw *hsw,
  343. u64 curve_duration, enum sst_hsw_volume_curve curve);
  344. /* Stream API */
  345. struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id,
  346. u32 (*get_write_position)(struct sst_hsw_stream *stream, void *data),
  347. void *data);
  348. int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
  349. /* Stream Configuration */
  350. int sst_hsw_stream_format(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  351. enum sst_hsw_stream_path_id path_id,
  352. enum sst_hsw_stream_type stream_type,
  353. enum sst_hsw_stream_format format_id);
  354. int sst_hsw_stream_buffer(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  355. u32 ring_pt_address, u32 num_pages,
  356. u32 ring_size, u32 ring_offset, u32 ring_first_pfn);
  357. int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
  358. int sst_hsw_stream_set_valid(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  359. u32 bits);
  360. int sst_hsw_stream_set_rate(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  361. int rate);
  362. int sst_hsw_stream_set_bits(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  363. enum sst_hsw_bitdepth bits);
  364. int sst_hsw_stream_set_channels(struct sst_hsw *hsw,
  365. struct sst_hsw_stream *stream, int channels);
  366. int sst_hsw_stream_set_map_config(struct sst_hsw *hsw,
  367. struct sst_hsw_stream *stream, u32 map,
  368. enum sst_hsw_channel_config config);
  369. int sst_hsw_stream_set_style(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  370. enum sst_hsw_interleaving style);
  371. int sst_hsw_stream_set_module_info(struct sst_hsw *hsw,
  372. struct sst_hsw_stream *stream, enum sst_hsw_module_id module_id,
  373. u32 entry_point);
  374. int sst_hsw_stream_set_pmemory_info(struct sst_hsw *hsw,
  375. struct sst_hsw_stream *stream, u32 offset, u32 size);
  376. int sst_hsw_stream_set_smemory_info(struct sst_hsw *hsw,
  377. struct sst_hsw_stream *stream, u32 offset, u32 size);
  378. int sst_hsw_stream_get_hw_id(struct sst_hsw *hsw,
  379. struct sst_hsw_stream *stream);
  380. int sst_hsw_stream_get_mixer_id(struct sst_hsw *hsw,
  381. struct sst_hsw_stream *stream);
  382. u32 sst_hsw_stream_get_read_reg(struct sst_hsw *hsw,
  383. struct sst_hsw_stream *stream);
  384. u32 sst_hsw_stream_get_pointer_reg(struct sst_hsw *hsw,
  385. struct sst_hsw_stream *stream);
  386. u32 sst_hsw_stream_get_peak_reg(struct sst_hsw *hsw,
  387. struct sst_hsw_stream *stream, u32 channel);
  388. u32 sst_hsw_stream_get_vol_reg(struct sst_hsw *hsw,
  389. struct sst_hsw_stream *stream, u32 channel);
  390. int sst_hsw_mixer_get_info(struct sst_hsw *hsw);
  391. /* Stream ALSA trigger operations */
  392. int sst_hsw_stream_pause(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  393. int wait);
  394. int sst_hsw_stream_resume(struct sst_hsw *hsw, struct sst_hsw_stream *stream,
  395. int wait);
  396. int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream);
  397. /* Stream pointer positions */
  398. int sst_hsw_stream_get_read_pos(struct sst_hsw *hsw,
  399. struct sst_hsw_stream *stream, u32 *position);
  400. int sst_hsw_stream_get_write_pos(struct sst_hsw *hsw,
  401. struct sst_hsw_stream *stream, u32 *position);
  402. int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
  403. struct sst_hsw_stream *stream, u32 stage_id, u32 position);
  404. u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
  405. struct sst_hsw_stream *stream);
  406. u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
  407. struct sst_hsw_stream *stream);
  408. /* HW port config */
  409. int sst_hsw_device_set_config(struct sst_hsw *hsw,
  410. enum sst_hsw_device_id dev, enum sst_hsw_device_mclk mclk,
  411. enum sst_hsw_device_mode mode, u32 clock_divider);
  412. /* DX Config */
  413. int sst_hsw_dx_set_state(struct sst_hsw *hsw,
  414. enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx);
  415. int sst_hsw_dx_get_state(struct sst_hsw *hsw, u32 item,
  416. u32 *offset, u32 *size, u32 *source);
  417. /* init */
  418. int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata);
  419. void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata);
  420. struct sst_dsp *sst_hsw_get_dsp(struct sst_hsw *hsw);
  421. void sst_hsw_set_scratch_module(struct sst_hsw *hsw,
  422. struct sst_module *scratch);
  423. #endif