summaryrefslogtreecommitdiff
path: root/include/linux/qdsp6v2/sdsp_anc.h
blob: 5c1b7055c1d5e4df3863e149dae5d0ad7e88b23a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef __SDSP_ANC_H__
#define __SDSP_ANC_H__

#include <sound/q6afe-v2.h>
#include <sound/apr_audio-v2.h>

#define AUD_MSVC_MODULE_AUDIO_DEV_RESOURCE_SHARE           0x0001028A
#define AUD_MSVC_PARAM_ID_PORT_SHARE_RESOURCE_CONFIG       0x00010297
#define AUD_MSVC_API_VERSION_SHARE_RESOURCE_CONFIG         0x1
#define AUD_MSVC_MODULE_AUDIO_DEV_ANC_REFS                 0x00010254
#define AUD_MSVC_PARAM_ID_DEV_ANC_REFS_CONFIG              0x00010286
#define AUD_MSVC_API_VERSION_DEV_ANC_REFS_CONFIG           0x1
#define AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO                 0x00010234

struct aud_msvc_port_param_data_v2 {
	/* ID of the module to be configured.
	 * Supported values: Valid module ID
	 */
	u32 module_id;

	/* ID of the parameter corresponding to the supported parameters
	 * for the module ID.
	 * Supported values: Valid parameter ID
	 */
	u32 param_id;

	/* Actual size of the data for the
	 * module_id/param_id pair. The size is a
	 * multiple of four bytes.
	 * Supported values: > 0
	 */
	u16 param_size;

	/* This field must be set to zero.
	 */
	u16 reserved;
} __packed;


/*  Payload of the #AFE_PORT_CMD_SET_PARAM_V2 command's
 * configuration/calibration settings for the AFE port.
 */
struct aud_msvc_port_cmd_set_param_v2 {
	/* Port interface and direction (Rx or Tx) to start.
	 */
	u16 port_id;

	/* Actual size of the payload in bytes.
	 * This is used for parsing the parameter payload.
	 * Supported values: > 0
	 */
	u16 payload_size;

	/* LSW of 64 bit Payload address.
	 * Address should be 32-byte,
	 * 4kbyte aligned and must be contiguous memory.
	 */
	u32 payload_address_lsw;

	/* MSW of 64 bit Payload address.
	 * In case of 32-bit shared memory address,
	 * this field must be set to zero.
	 * In case of 36-bit shared memory address,
	 * bit-4 to bit-31 must be set to zero.
	 * Address should be 32-byte, 4kbyte aligned
	 * and must be contiguous memory.
	 */
	u32 payload_address_msw;

	/* Memory map handle returned by
	 * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
	 * Supported Values:
	 * - NULL -- Message. The parameter data is in-band.
	 * - Non-NULL -- The parameter data is Out-band.Pointer to
	 * the physical address
	 * in shared memory of the payload data.
	 * An optional field is available if parameter
	 * data is in-band:
	 * aud_msvc_param_data_v2 param_data[...].
	 * For detailed payload content, see the
	 * aud_msvc_port_param_data_v2 structure.
	 */
	u32 mem_map_handle;

} __packed;

/*  Payload of the #AFE_PORT_CMD_GET_PARAM_V2 command,
 * which queries for one post/preprocessing parameter of a
 * stream.
 */
struct aud_msvc_port_cmd_get_param_v2 {
	/* Port interface and direction (Rx or Tx) to start. */
	u16 port_id;

	/* Maximum data size of the parameter ID/module ID combination.
	 * This is a multiple of four bytes
	 * Supported values: > 0
	 */
	u16 payload_size;

	/* LSW of 64 bit Payload address. Address should be 32-byte,
	 * 4kbyte aligned and must be contig memory.
	 */
	u32 payload_address_lsw;

	/* MSW of 64 bit Payload address. In case of 32-bit shared
	 * memory address, this field must be set to zero. In case of 36-bit
	 * shared memory address, bit-4 to bit-31 must be set to zero.
	 * Address should be 32-byte, 4kbyte aligned and must be contiguous
	 * memory.
	 */
	u32 payload_address_msw;

	/* Memory map handle returned by
	 * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
	 * Supported Values: - NULL -- Message. The parameter data is
	 * in-band. - Non-NULL -- The parameter data is Out-band.Pointer to
	 * - the physical address in shared memory of the payload data.
	 * For detailed payload content, see the aud_msvc_port_param_data_v2
	 * structure
	 */
	u32 mem_map_handle;

	/* ID of the module to be queried.
	 * Supported values: Valid module ID
	 */
	 u32 module_id;

	 /* ID of the parameter to be queried.
	 * Supported values: Valid parameter ID
	 */
	u32 param_id;

} __packed;

struct aud_audioif_config_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	union afe_port_config            port;
} __packed;

struct aud_msvc_param_id_dev_share_resource_cfg {
	u32                  minor_version;
	u16                  rddma_idx;
	u16                  wrdma_idx;
	u32                  lpm_start_addr;
	u32                  lpm_length;
} __packed;

struct aud_msvc_param_id_dev_anc_refs_cfg {
	u32                  minor_version;
	u16                  port_id;
	u16                  num_channel;
	u32                  sample_rate;
	u32                  bit_width;
} __packed;

struct anc_share_resource_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	struct aud_msvc_param_id_dev_share_resource_cfg resource;
} __packed;

struct anc_config_ref_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	struct aud_msvc_param_id_dev_anc_refs_cfg refs;
} __packed;

#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_MODULE_ID      0x0001023A

struct aud_msvc_param_id_dev_anc_algo_module_id {
	uint32_t                  minor_version;
	uint32_t                  module_id;
} __packed;

struct anc_set_algo_module_id_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	struct aud_msvc_param_id_dev_anc_algo_module_id set_algo_module_id;
} __packed;


#define AUD_MSVC_PARAM_ID_PORT_ANC_MIC_SPKR_LAYOUT_INFO   0x0001029C

#define AUD_MSVC_API_VERSION_DEV_ANC_MIC_SPKR_LAYOUT_INFO        0x1

#define AUD_MSVC_ANC_MAX_NUM_OF_MICS              16
#define AUD_MSVC_ANC_MAX_NUM_OF_SPKRS             16

struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info {
	uint32_t minor_version;
	uint16_t mic_layout_array[AUD_MSVC_ANC_MAX_NUM_OF_MICS];
	uint16_t spkr_layout_array[AUD_MSVC_ANC_MAX_NUM_OF_SPKRS];
	uint16_t num_anc_mic;
	uint16_t num_anc_spkr;
	uint16_t num_add_mic_signal;
	uint16_t num_add_spkr_signal;
} __packed;

struct anc_set_mic_spkr_layout_info_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info
		set_mic_spkr_layout;
} __packed;

struct anc_set_algo_module_cali_data_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_set_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	/*
	 * calibration data payload followed
	 */
} __packed;

struct anc_get_algo_module_cali_data_command {
	struct apr_hdr hdr;
	struct aud_msvc_port_cmd_get_param_v2 param;
	struct aud_msvc_port_param_data_v2    pdata;
	/*
	 * calibration data payload followed
	 */
} __packed;

struct anc_get_algo_module_cali_data_resp {
	uint32_t status;
	struct aud_msvc_port_param_data_v2 pdata;
	uint32_t payload[128];
} __packed;

int anc_if_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port);

int anc_if_tdm_port_stop(u16 port_id);

int anc_if_share_resource(u16 port_id, u16 rddma_idx, u16 wrdma_idx,
		u32 lpm_start_addr, u32 lpm_length);

int anc_if_config_ref(u16 port_id, u32 sample_rate, u32 bit_width,
		u16 num_channel);

int anc_if_set_algo_module_id(u16 port_id, u32 module_id);

int anc_if_set_anc_mic_spkr_layout(u16 port_id,
struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p);

int anc_if_set_algo_module_cali_data(u16 port_id, void *data_p);

int anc_if_get_algo_module_cali_data(u16 port_id, void *data_p);

int anc_if_shared_mem_map(void);

int anc_if_shared_mem_unmap(void);

#endif /* __SDSP_ANC_H__ */