q6asm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __Q6_ASM_H__
  3. #define __Q6_ASM_H__
  4. #include "q6dsp-common.h"
  5. /* ASM client callback events */
  6. #define CMD_PAUSE 0x0001
  7. #define ASM_CLIENT_EVENT_CMD_PAUSE_DONE 0x1001
  8. #define CMD_FLUSH 0x0002
  9. #define ASM_CLIENT_EVENT_CMD_FLUSH_DONE 0x1002
  10. #define CMD_EOS 0x0003
  11. #define ASM_CLIENT_EVENT_CMD_EOS_DONE 0x1003
  12. #define CMD_CLOSE 0x0004
  13. #define ASM_CLIENT_EVENT_CMD_CLOSE_DONE 0x1004
  14. #define CMD_OUT_FLUSH 0x0005
  15. #define ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE 0x1005
  16. #define CMD_SUSPEND 0x0006
  17. #define ASM_CLIENT_EVENT_CMD_SUSPEND_DONE 0x1006
  18. #define ASM_CLIENT_EVENT_CMD_RUN_DONE 0x1008
  19. #define ASM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009
  20. #define ASM_CLIENT_EVENT_DATA_READ_DONE 0x100a
  21. #define ASM_WRITE_TOKEN_MASK GENMASK(15, 0)
  22. #define ASM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16)
  23. #define ASM_WRITE_TOKEN_LEN_SHIFT 16
  24. enum {
  25. LEGACY_PCM_MODE = 0,
  26. LOW_LATENCY_PCM_MODE,
  27. ULTRA_LOW_LATENCY_PCM_MODE,
  28. ULL_POST_PROCESSING_PCM_MODE,
  29. };
  30. #define MAX_SESSIONS 8
  31. #define FORMAT_LINEAR_PCM 0x0000
  32. #define ASM_LAST_BUFFER_FLAG BIT(30)
  33. struct q6asm_flac_cfg {
  34. u32 sample_rate;
  35. u32 ext_sample_rate;
  36. u32 min_frame_size;
  37. u32 max_frame_size;
  38. u16 stream_info_present;
  39. u16 min_blk_size;
  40. u16 max_blk_size;
  41. u16 ch_cfg;
  42. u16 sample_size;
  43. u16 md5_sum;
  44. };
  45. struct q6asm_wma_cfg {
  46. u32 fmtag;
  47. u32 num_channels;
  48. u32 sample_rate;
  49. u32 bytes_per_sec;
  50. u32 block_align;
  51. u32 bits_per_sample;
  52. u32 channel_mask;
  53. u32 enc_options;
  54. u32 adv_enc_options;
  55. u32 adv_enc_options2;
  56. };
  57. struct q6asm_alac_cfg {
  58. u32 frame_length;
  59. u8 compatible_version;
  60. u8 bit_depth;
  61. u8 pb;
  62. u8 mb;
  63. u8 kb;
  64. u8 num_channels;
  65. u16 max_run;
  66. u32 max_frame_bytes;
  67. u32 avg_bit_rate;
  68. u32 sample_rate;
  69. u32 channel_layout_tag;
  70. };
  71. struct q6asm_ape_cfg {
  72. u16 compatible_version;
  73. u16 compression_level;
  74. u32 format_flags;
  75. u32 blocks_per_frame;
  76. u32 final_frame_blocks;
  77. u32 total_frames;
  78. u16 bits_per_sample;
  79. u16 num_channels;
  80. u32 sample_rate;
  81. u32 seek_table_present;
  82. };
  83. typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token,
  84. void *payload, void *priv);
  85. struct audio_client;
  86. struct audio_client *q6asm_audio_client_alloc(struct device *dev,
  87. q6asm_cb cb, void *priv,
  88. int session_id, int perf_mode);
  89. void q6asm_audio_client_free(struct audio_client *ac);
  90. int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
  91. uint32_t msw_ts, uint32_t lsw_ts, uint32_t wflags);
  92. int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
  93. uint32_t format, u32 codec_profile,
  94. uint16_t bits_per_sample, bool is_gapless);
  95. int q6asm_open_read(struct audio_client *ac, uint32_t stream_id,
  96. uint32_t format, uint16_t bits_per_sample);
  97. int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
  98. uint32_t stream_id, uint32_t rate,
  99. uint32_t channels,
  100. uint16_t bits_per_sample);
  101. int q6asm_read(struct audio_client *ac, uint32_t stream_id);
  102. int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
  103. uint32_t stream_id,
  104. uint32_t rate, uint32_t channels,
  105. u8 channel_map[PCM_MAX_NUM_CHANNEL],
  106. uint16_t bits_per_sample);
  107. int q6asm_stream_media_format_block_flac(struct audio_client *ac,
  108. uint32_t stream_id,
  109. struct q6asm_flac_cfg *cfg);
  110. int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
  111. uint32_t stream_id,
  112. struct q6asm_wma_cfg *cfg);
  113. int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
  114. uint32_t stream_id,
  115. struct q6asm_wma_cfg *cfg);
  116. int q6asm_stream_media_format_block_alac(struct audio_client *ac,
  117. uint32_t stream_id,
  118. struct q6asm_alac_cfg *cfg);
  119. int q6asm_stream_media_format_block_ape(struct audio_client *ac,
  120. uint32_t stream_id,
  121. struct q6asm_ape_cfg *cfg);
  122. int q6asm_run(struct audio_client *ac, uint32_t stream_id, uint32_t flags,
  123. uint32_t msw_ts, uint32_t lsw_ts);
  124. int q6asm_run_nowait(struct audio_client *ac, uint32_t stream_id,
  125. uint32_t flags, uint32_t msw_ts, uint32_t lsw_ts);
  126. int q6asm_stream_remove_initial_silence(struct audio_client *ac,
  127. uint32_t stream_id,
  128. uint32_t initial_samples);
  129. int q6asm_stream_remove_trailing_silence(struct audio_client *ac,
  130. uint32_t stream_id,
  131. uint32_t trailing_samples);
  132. int q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd);
  133. int q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id, int cmd);
  134. int q6asm_get_session_id(struct audio_client *c);
  135. int q6asm_map_memory_regions(unsigned int dir,
  136. struct audio_client *ac,
  137. phys_addr_t phys,
  138. size_t period_sz, unsigned int periods);
  139. int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac);
  140. #endif /* __Q6_ASM_H__ */