1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include "q6dsp-common.h"
5 #include <dt-bindings/sound/qcom,q6asm.h>
7 /* ASM client callback events */
8 #define CMD_PAUSE 0x0001
9 #define ASM_CLIENT_EVENT_CMD_PAUSE_DONE 0x1001
10 #define CMD_FLUSH 0x0002
11 #define ASM_CLIENT_EVENT_CMD_FLUSH_DONE 0x1002
12 #define CMD_EOS 0x0003
13 #define ASM_CLIENT_EVENT_CMD_EOS_DONE 0x1003
14 #define CMD_CLOSE 0x0004
15 #define ASM_CLIENT_EVENT_CMD_CLOSE_DONE 0x1004
16 #define CMD_OUT_FLUSH 0x0005
17 #define ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE 0x1005
18 #define CMD_SUSPEND 0x0006
19 #define ASM_CLIENT_EVENT_CMD_SUSPEND_DONE 0x1006
20 #define ASM_CLIENT_EVENT_CMD_RUN_DONE 0x1008
21 #define ASM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009
22 #define ASM_CLIENT_EVENT_DATA_READ_DONE 0x100a
23 #define ASM_WRITE_TOKEN_MASK GENMASK(15, 0)
24 #define ASM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16)
25 #define ASM_WRITE_TOKEN_LEN_SHIFT 16
30 ULTRA_LOW_LATENCY_PCM_MODE,
31 ULL_POST_PROCESSING_PCM_MODE,
34 #define MAX_SESSIONS 8
35 #define FORMAT_LINEAR_PCM 0x0000
36 #define ASM_LAST_BUFFER_FLAG BIT(30)
38 struct q6asm_flac_cfg {
43 u16 stream_info_present;
51 struct q6asm_wma_cfg {
64 struct q6asm_alac_cfg {
66 u8 compatible_version;
76 u32 channel_layout_tag;
79 struct q6asm_ape_cfg {
80 u16 compatible_version;
81 u16 compression_level;
84 u32 final_frame_blocks;
89 u32 seek_table_present;
92 typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token,
93 void *payload, void *priv);
95 struct audio_client *q6asm_audio_client_alloc(struct device *dev,
96 q6asm_cb cb, void *priv,
97 int session_id, int perf_mode);
98 void q6asm_audio_client_free(struct audio_client *ac);
99 int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
100 uint32_t msw_ts, uint32_t lsw_ts, uint32_t flags);
101 int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
102 uint32_t format, u32 codec_profile,
103 uint16_t bits_per_sample, bool is_gapless);
105 int q6asm_open_read(struct audio_client *ac, uint32_t stream_id,
106 uint32_t format, uint16_t bits_per_sample);
107 int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
108 uint32_t stream_id, uint32_t rate,
110 uint16_t bits_per_sample);
112 int q6asm_read(struct audio_client *ac, uint32_t stream_id);
114 int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
116 uint32_t rate, uint32_t channels,
117 u8 channel_map[PCM_MAX_NUM_CHANNEL],
118 uint16_t bits_per_sample);
119 int q6asm_stream_media_format_block_flac(struct audio_client *ac,
121 struct q6asm_flac_cfg *cfg);
122 int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
124 struct q6asm_wma_cfg *cfg);
125 int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
127 struct q6asm_wma_cfg *cfg);
128 int q6asm_stream_media_format_block_alac(struct audio_client *ac,
130 struct q6asm_alac_cfg *cfg);
131 int q6asm_stream_media_format_block_ape(struct audio_client *ac,
133 struct q6asm_ape_cfg *cfg);
134 int q6asm_run(struct audio_client *ac, uint32_t stream_id, uint32_t flags,
135 uint32_t msw_ts, uint32_t lsw_ts);
136 int q6asm_run_nowait(struct audio_client *ac, uint32_t stream_id,
137 uint32_t flags, uint32_t msw_ts, uint32_t lsw_ts);
138 int q6asm_stream_remove_initial_silence(struct audio_client *ac,
140 uint32_t initial_samples);
141 int q6asm_stream_remove_trailing_silence(struct audio_client *ac,
143 uint32_t trailing_samples);
144 int q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd);
145 int q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id, int cmd);
146 int q6asm_get_session_id(struct audio_client *ac);
147 int q6asm_map_memory_regions(unsigned int dir,
148 struct audio_client *ac,
150 size_t bufsz, unsigned int bufcnt);
151 int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac);
152 #endif /* __Q6_ASM_H__ */