xref: /openbmc/linux/sound/soc/qcom/qdsp6/q6asm.h (revision 62975d27)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __Q6_ASM_H__
3 #define __Q6_ASM_H__
4 #include "q6dsp-common.h"
5 #include <dt-bindings/sound/qcom,q6asm.h>
6 
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 
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 
31 #define MAX_SESSIONS	8
32 #define NO_TIMESTAMP    0xFF00
33 #define FORMAT_LINEAR_PCM   0x0000
34 
35 struct q6asm_flac_cfg {
36         u32 sample_rate;
37         u32 ext_sample_rate;
38         u32 min_frame_size;
39         u32 max_frame_size;
40         u16 stream_info_present;
41         u16 min_blk_size;
42         u16 max_blk_size;
43         u16 ch_cfg;
44         u16 sample_size;
45         u16 md5_sum;
46 };
47 
48 struct q6asm_wma_cfg {
49 	u32 fmtag;
50 	u32 num_channels;
51 	u32 sample_rate;
52 	u32 bytes_per_sec;
53 	u32 block_align;
54 	u32 bits_per_sample;
55 	u32 channel_mask;
56 	u32 enc_options;
57 	u32 adv_enc_options;
58 	u32 adv_enc_options2;
59 };
60 
61 struct q6asm_alac_cfg {
62 	u32 frame_length;
63 	u8 compatible_version;
64 	u8 bit_depth;
65 	u8 pb;
66 	u8 mb;
67 	u8 kb;
68 	u8 num_channels;
69 	u16 max_run;
70 	u32 max_frame_bytes;
71 	u32 avg_bit_rate;
72 	u32 sample_rate;
73 	u32 channel_layout_tag;
74 };
75 
76 struct q6asm_ape_cfg {
77 	u16 compatible_version;
78 	u16 compression_level;
79 	u32 format_flags;
80 	u32 blocks_per_frame;
81 	u32 final_frame_blocks;
82 	u32 total_frames;
83 	u16 bits_per_sample;
84 	u16 num_channels;
85 	u32 sample_rate;
86 	u32 seek_table_present;
87 };
88 
89 typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token,
90 			  void *payload, void *priv);
91 struct audio_client;
92 struct audio_client *q6asm_audio_client_alloc(struct device *dev,
93 					      q6asm_cb cb, void *priv,
94 					      int session_id, int perf_mode);
95 void q6asm_audio_client_free(struct audio_client *ac);
96 int q6asm_write_async(struct audio_client *ac, uint32_t len, uint32_t msw_ts,
97 		       uint32_t lsw_ts, uint32_t flags);
98 int q6asm_open_write(struct audio_client *ac, uint32_t format,
99 		     u32 codec_profile, uint16_t bits_per_sample);
100 
101 int q6asm_open_read(struct audio_client *ac, uint32_t format,
102 		     uint16_t bits_per_sample);
103 int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
104 		uint32_t rate, uint32_t channels, uint16_t bits_per_sample);
105 int q6asm_read(struct audio_client *ac);
106 
107 int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
108 					  uint32_t rate, uint32_t channels,
109 					  u8 channel_map[PCM_MAX_NUM_CHANNEL],
110 					  uint16_t bits_per_sample);
111 int q6asm_stream_media_format_block_flac(struct audio_client *ac,
112 					 struct q6asm_flac_cfg *cfg);
113 int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
114 					   struct q6asm_wma_cfg *cfg);
115 int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
116 					    struct q6asm_wma_cfg *cfg);
117 int q6asm_stream_media_format_block_alac(struct audio_client *ac,
118 					 struct q6asm_alac_cfg *cfg);
119 int q6asm_stream_media_format_block_ape(struct audio_client *ac,
120 					struct q6asm_ape_cfg *cfg);
121 int q6asm_run(struct audio_client *ac, uint32_t flags, uint32_t msw_ts,
122 	      uint32_t lsw_ts);
123 int q6asm_run_nowait(struct audio_client *ac, uint32_t flags, uint32_t msw_ts,
124 		     uint32_t lsw_ts);
125 int q6asm_cmd(struct audio_client *ac, int cmd);
126 int q6asm_cmd_nowait(struct audio_client *ac, int cmd);
127 int q6asm_get_session_id(struct audio_client *ac);
128 int q6asm_map_memory_regions(unsigned int dir,
129 			     struct audio_client *ac,
130 			     phys_addr_t phys,
131 			     size_t bufsz, unsigned int bufcnt);
132 int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac);
133 #endif /* __Q6_ASM_H__ */
134