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