blob: 92a56ba8e8c4009ee34ea62e1f76a297a34c682e [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_audio_cfg.h
4 @brief audio config API, including audio initlization, audio configuration
5
6 @detailes
7 Quectel AG55x series module AUDIO service.
8
9 @htmlonly
10 <span style="font-weight: bold">History</span>
11 @endhtmlonly
12
13 when | who | what, where, why
14 -------- | --- | ----------------------------------------------------------
15 2021-11-03 | dameng.lin | Created .
16
17 Copyright (c) 2019 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
18 Quectel Wireless Solution Proprietary and Confidential.
19-------------------------------------------------------------------------------------------------*/
20#ifndef __QL_AUDIO_CFG_H__
21#define __QL_AUDIO_CFG_H__
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdint.h>
28
29#define QL_AUDIO_STATE_0 0
30#define QL_AUDIO_STATE_1 1
31
32
33/**
34 @brief The audio service error callback function
35 @param error error code.See ql_type.h for details.
36*/
37typedef void (*ql_audio_service_error_cb_f)(int error);
38
39extern ql_audio_service_error_cb_f audio_error_callback;
40/*-----------------------------------------------------------------------------------------------*/
41/**
42 @brief This function initializes an audio service.
43
44 @retval QL_ERR_OK Successful execution
45 @retval QL_ERR_SERVICE_NOT_READY Audio service not ready. Try again later.
46 @retval Others Failed execution.See ql_type.h for error codes
47 */
48/*-----------------------------------------------------------------------------------------------*/
49int ql_audio_init(void);
50
51/*-----------------------------------------------------------------------------------------------*/
52/**
53 @brief This function deinitializes audio services.
54
55 @retval QL_ERR_OK Successful
56 @retval QL_ERR_SERVICE_NOT_READY Service is not ready, need to retry
57 @retval Others Failed execution.See ql_type.h for error codes.
58 */
59/*-----------------------------------------------------------------------------------------------*/
60int ql_audio_deinit(void);
61
62/*-----------------------------------------------------------------------------------------------*/
63/**
64 @brief This function sets the value of a mixer.
65
66 @param[in] control the name of the mixer
67 @param[in] val_list the value of the mixer to be set. String type value.Multiple values are separated by spaces.
68
69 @retval QL_ERR_OK Successful execution
70 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
71 @retval Others Failed execution.See ql_type.h for error codes.
72 */
73/*-----------------------------------------------------------------------------------------------*/
74int ql_audio_set_mixer_control(const char *control, const char *val_list);
75
76/*-----------------------------------------------------------------------------------------------*/
77/**
78 @brief This function gets the value of the mixer.
79
80 @param[in] control the name of the mixer
81 @param[out] val_list_buf buffer for storing mixer values
82 @param[in] buf_size the buffer size. Unit:Byte
83
84 @retval QL_ERR_OK Successful execution.
85 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
86 @retval Others Failed execution.See ql_type.h for error codes.
87
88 @note Generally, 64 bytes is enough
89 */
90/*-----------------------------------------------------------------------------------------------*/
91int ql_audio_get_mixer_control(const char *control, char *val_list_buf, uint32_t buf_size);
92
93
94
95/*-----------------------------------------------------------------------------------------------*/
96/**
97 @brief This function sets the microphone gain for voice call uplink.
98
99 @param[in] mic_gain the microphone gain to be set. range:0-65535
100
101 @retval QL_ERR_OK Successful execution
102 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
103 @retval Others errorcode defined by ql_type.h.
104
105 @note The API should be called before a voice call
106 */
107/*-----------------------------------------------------------------------------------------------*/
108int ql_audio_set_tx_voice_mic_gain(int32_t mic_gain);
109
110/*-----------------------------------------------------------------------------------------------*/
111/**
112 @brief This function gets the microphone gain for voice call uplink.
113
114 @param[out] p_mic_gain the current microphone gain for voice call uplink.
115
116 @retval QL_ERR_OK Successful execution
117 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
118 @retval Others errorcode defined by ql_type.h.
119 */
120/*-----------------------------------------------------------------------------------------------*/
121int ql_audio_get_tx_voice_mic_gain(int32_t *p_mic_gain);
122
123
124
125/*-----------------------------------------------------------------------------------------------*/
126/**
127 @brief This function sets the speaker gain for voice call downlink.
128
129 @param[in] spkr_gain the speaker gain to be set. range:0-65535
130
131 @retval QL_ERR_OK Successful execution
132 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
133 @retval Others errorcode defined by ql_type.h.
134
135 @note The API should be called before a voice call
136 */
137/*-----------------------------------------------------------------------------------------------*/
138int ql_audio_set_rx_voice_spkr_gain(int32_t spkr_gain);
139
140/*-----------------------------------------------------------------------------------------------*/
141/**
142 @brief This function gets the speaker gain for voice call downlink.
143
144 @param[out] p_spkr_gain the current speaker gain for voice call downlink.
145
146 @retval QL_ERR_OK Successful execution
147 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
148 @retval Others errorcode defined by ql_type.h.
149 */
150/*-----------------------------------------------------------------------------------------------*/
151int ql_audio_get_rx_voice_spkr_gain(int32_t *p_spkr_gain);
152
153
154/*-----------------------------------------------------------------------------------------------*/
155/**
156 @brief This function sets the mute state of voice call uplink.
157
158 @param[in] mute_state the mute state to be set.
159 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
160
161 @retval QL_ERR_OK Successful execution
162 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
163 @retval Others errorcode defined by ql_type.h.
164
165 @note The API should be called during the call
166 */
167/*-----------------------------------------------------------------------------------------------*/
168int ql_audio_set_tx_voice_mute_state(int32_t mute_state);
169
170/*-----------------------------------------------------------------------------------------------*/
171/**
172 @brief This function gets the mute state of voice call uplink.
173
174 @param[out] p_mute_state the current mute state of voice call uplink. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
175
176 @retval QL_ERR_OK Successful execution
177 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
178 @retval Others errorcode defined by ql_type.h.
179 */
180/*-----------------------------------------------------------------------------------------------*/
181int ql_audio_get_tx_voice_mute_state(int32_t *p_mute_state);
182
183/*-----------------------------------------------------------------------------------------------*/
184/**
185 @brief This function sets the mute state of voice call downlink.
186
187 @param[in] mute_state the mute state to be set.
188 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
189
190 @retval QL_ERR_OK Successful execution
191 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
192 @retval Others errorcode defined by ql_type.h.
193
194 @note The API should be called during the call
195 */
196/*-----------------------------------------------------------------------------------------------*/
197int ql_audio_set_rx_voice_mute_state(int32_t mute_state);
198
199/*-----------------------------------------------------------------------------------------------*/
200/**
201 @brief This function gets the mute state of voice call downlink.
202
203 @param[out] p_mute_state the current mute state of voice call downlink. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
204
205 @retval QL_ERR_OK Successful execution
206 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
207 @retval Others errorcode defined by ql_type.h.
208 */
209/*-----------------------------------------------------------------------------------------------*/
210int ql_audio_get_rx_voice_mute_state(int32_t *p_mute_state);
211
212/*-----------------------------------------------------------------------------------------------*/
213/**
214 @brief This function sets the uplink volume of a codec.
215
216 @param[in] up_volume the uplink volume to be set. range:0-100
217
218 @retval QL_ERR_OK Successful execution
219 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
220 @retval Others errorcode defined by ql_type.h.
221 */
222/*-----------------------------------------------------------------------------------------------*/
223int ql_audio_set_codec_up_vol(int32_t up_volume);
224
225/*-----------------------------------------------------------------------------------------------*/
226/**
227 @brief This function gets the uplink volume of a codec.
228
229 @param[out] p_up_volume the current uplink volume of codec. range:0-100
230
231 @retval QL_ERR_OK Successful execution
232 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
233 @retval Others errorcode defined by ql_type.h.
234 */
235/*-----------------------------------------------------------------------------------------------*/
236int ql_audio_get_codec_up_vol(int32_t *p_up_volume);
237
238/*-----------------------------------------------------------------------------------------------*/
239/**
240 @brief This function sets the downlink volume of a codec.
241
242 @param[in] down_volume the volume to be set. range:0-100
243
244 @retval QL_ERR_OK Successful execution
245 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
246 @retval Others errorcode defined by ql_type.h.
247 */
248/*-----------------------------------------------------------------------------------------------*/
249int ql_audio_set_codec_down_vol(int32_t down_volume);
250
251/*-----------------------------------------------------------------------------------------------*/
252/**
253 @brief This function gets the downlink volume of a codec.
254
255 @param[out] p_down_volume the current downlink volume of codec. range:0-100
256
257 @retval QL_ERR_OK Successful execution
258 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
259 @retval Others errorcode defined by ql_type.h.
260 */
261/*-----------------------------------------------------------------------------------------------*/
262int ql_audio_get_codec_down_vol(int32_t *p_down_volume);
263
264/*-----------------------------------------------------------------------------------------------*/
265/**
266 @brief This function sets the microphone mute state of a codec.
267
268 @param[in] mute_state the muute state to be set.
269 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
270
271 @retval QL_ERR_OK Successful execution
272 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
273 @retval Others errorcode defined by ql_type.h.
274
275 @note The API should be called during the call or audio playback
276 */
277/*-----------------------------------------------------------------------------------------------*/
278int ql_audio_set_codec_mic_mute_state(int32_t mute_state);
279
280/*-----------------------------------------------------------------------------------------------*/
281/**
282 @brief This function gets the microphone mute state of a codec.
283
284 @param[out] p_mute_state the current microphone mute state of codec. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
285
286 @retval QL_ERR_OK Successful execution
287 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
288 @retval Others errorcode defined by ql_type.h.
289 */
290/*-----------------------------------------------------------------------------------------------*/
291int ql_audio_get_codec_mic_mute_state(int32_t *p_mute_state);
292
293/*-----------------------------------------------------------------------------------------------*/
294/**
295 @brief This function sets the speaker mute state of a codec.
296
297 @param[in] mute_state the mute state to be set.
298 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
299
300 @retval QL_ERR_OK Successful execution
301 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
302 @retval Others errorcode defined by ql_type.h.
303
304 @note The API should be called during the call or audio playback
305 */
306/*-----------------------------------------------------------------------------------------------*/
307int ql_audio_set_codec_spk_mute_state(int32_t mute_state);
308
309/*-----------------------------------------------------------------------------------------------*/
310/**
311 @brief This function gets the speaker mute state of a codec.
312
313 @param[out] p_mute_state the current speaker mute state of codec. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
314
315 @retval QL_ERR_OK Successful execution
316 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
317 @retval Others errorcode defined by ql_type.h.
318 */
319/*-----------------------------------------------------------------------------------------------*/
320int ql_audio_get_codec_spk_mute_state(int32_t *p_mute_state);
321
322
323/*-----------------------------------------------------------------------------------------------*/
324/**
325 @brief This function enables/disables loopback.
326
327 @param[in] enable_state enable/disable the loopback to be set.
328 QL_AUDIO_STATE_0: disable, QL_AUDIO_STATE_1: enable
329
330 @retval QL_ERR_OK Successful execution
331 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
332 @retval Others errorcode defined by ql_type.h.
333 */
334/*-----------------------------------------------------------------------------------------------*/
335int ql_audio_set_loopback_enable_state(int32_t enable_state);
336
337/*-----------------------------------------------------------------------------------------------*/
338/**
339 @brief The function gets the loopback state.
340
341 @param[out] p_enable_state the current loopback state. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
342
343 @retval QL_ERR_OK Successful execution
344 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
345 @retval Others errorcode defined by ql_type.h.
346 */
347/*-----------------------------------------------------------------------------------------------*/
348int ql_audio_get_loopback_enable_state(int32_t *p_enable_state);
349
350/*-----------------------------------------------------------------------------------------------*/
351/**
352 @brief This function sets the sidetone gain.
353
354 @param[in] sidetone_gain sidetone gain to be set. range: 0-65535
355
356 @retval QL_ERR_OK Successful execution
357 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
358 @retval Others errorcode defined by ql_type.h.
359 */
360/*-----------------------------------------------------------------------------------------------*/
361int ql_audio_set_sidetone_gain(int32_t sidetone_gain);
362
363/*-----------------------------------------------------------------------------------------------*/
364/**
365 @brief This function gets the sidetone gain.
366
367 @param[out] p_sidetone_gain the current sidetone gain. range: 0-65535, default value: 1298
368
369 @retval QL_ERR_OK Successful execution
370 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
371 @retval Others errorcode defined by ql_type.h.
372 */
373/*-----------------------------------------------------------------------------------------------*/
374int ql_audio_get_sidetone_gain(int32_t *p_sidetone_gain);
375
376
377/*-----------------------------------------------------------------------------------------------*/
378/**
379 @brief This function sets the voice call manager state. By default, voice call services such as ringtones, ringback
380tones, third-party ringtones and voice stream status control are all implemented by ql_audiod program
381automatically.
382
383 @param[in] manager_state The manager state to be set. Voice call services include ringtones, ringback tones, the third-party
384ringtones and voice stream status control. range: QL_AUDIO_STATE_0 and QL_AUDIO_STATE_1
385
386 @retval QL_ERR_OK Successful execution
387 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
388 @retval Others errorcode defined by ql_type.h.
389
390 @note The voice service, such as call ring, beep tone, will not work during a voice call
391 If the manager_state is set to QL_AUDIO_STATE_1
392 */
393/*-----------------------------------------------------------------------------------------------*/
394int ql_audio_set_voice_call_manager_state(int32_t manager_state);
395
396/*-----------------------------------------------------------------------------------------------*/
397/**
398 @brief This function gets the voice call manager state.
399
400 @param[out] p_manager_state the current voice call manager state.
401 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
402
403 @retval QL_ERR_OK Successful execution
404 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
405 @retval Others errorcode defined by ql_type.h.
406 */
407/*-----------------------------------------------------------------------------------------------*/
408int ql_audio_get_voice_call_manager_state(int32_t *p_manager_state);
409
410/*-----------------------------------------------------------------------------------------------*/
411/**
412 @brief This function sets the voice stream state.
413
414 @param[in] stream_state voice stream state to be set.
415 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
416
417 @retval QL_ERR_OK Successful execution
418 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
419 @retval Others errorcode defined by ql_type.h.
420
421 @note After the voice call manager state is set to QL_AUDIO_STATE_1 by calling
422ql_audio_set_voice_call_manager_state(), the service program ql_audiod will not enable voice stream
423while establishing a voice call. In such a case, call ql_audio_set_voice_stream_state() to enable voice
424stream state by setting stream_state to QL_AUDIO_STATE_1, and then the voice stream can be disabled
425by setting stream_state to QL_AUDIO_STATE_0.*/
426/*-----------------------------------------------------------------------------------------------*/
427//int ql_audio_set_voice_stream_state(int32_t stream_state);
428int ql_audio_set_voice_stream_state(int32_t stream_state);
429
430/*-----------------------------------------------------------------------------------------------*/
431/**
432 @brief The function gets the voice stream state.
433
434 @param[out] p_stream_state the current voice stream state. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
435
436 @retval QL_ERR_OK Successful execution
437 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
438 @retval Others errorcode defined by ql_type.h.
439 */
440/*-----------------------------------------------------------------------------------------------*/
441//int ql_audio_get_voice_stream_state(int32_t *p_stream_state);
442int ql_audio_get_voice_stream_state(int32_t *p_stream_state);
443
444
445/*-----------------------------------------------------------------------------------------------*/
446/**
447 @brief This function sets the callback function for audio service errors.
448 @param[in] cb The callback function for audio service errors.Only when the audioservice exit abnormally,the callback function is executed.
449 @retval QL_ERR_OK Successful execution
450 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
451 @retval Others errorcode defined by ql_type.h.
452 */
453/*-----------------------------------------------------------------------------------------------*/
454int ql_audio_set_service_error_cb(ql_audio_service_error_cb_f cb);
455
456
457/*-----------------------------------------------------------------------------------------------*/
458/**
459 @brief This function switch codec.
460
461 @param[in] codec_switch the which codec to be switch.
462 0:GSSP 1:internal codec
463
464 @retval QL_ERR_OK Successful execution
465 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
466 @retval Others errorcode defined by ql_type.h.
467 */
468/*-----------------------------------------------------------------------------------------------*/
469int ql_audio_set_codec_switch(int32_t codec_switch);
470
471
472/*-----------------------------------------------------------------------------------------------*/
473/**
474 @brief This function gets the tone state.
475
476 @param[out] p_codec_switch which codec has switch.
477
478 @retval QL_ERR_OK Successful execution
479 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
480 @retval Others errorcode defined by ql_type.h.
481 */
482/*-----------------------------------------------------------------------------------------------*/
483int ql_audio_get_codec_switch(int32_t *p_codec_switch);
484
485
486typedef struct ql_audio_tone_config_struct
487{
488 int32_t low_fre;
489 int32_t high_fre;
490 int32_t on_duration;
491 int32_t off_duration;
492 int32_t volume;
493 int32_t count;
494}ql_audio_tone_config_t;
495
496/*-----------------------------------------------------------------------------------------------*/
497/**
498 @brief Set tone enable state
499
500 @param[in] low_fre low frequency, range: 100~4000
501 @param[in] high_fre high frequency, range: 100~4000
502 @param[in] on_duration tone play time, unit is millisecond
503 @param[in] off_duration tone pause time, unit is millisecond
504 @param[in] volume tone play volume, range: 0~5000
505 @param[in] count tone play count
506
507 @return QL_ERR_OK - Successful
508 QL_ERR_INVALID_ARG - Invalid arguments
509 Other errorcode defined by ql_type.h
510 */
511/*-----------------------------------------------------------------------------------------------*/
512int ql_audio_set_tone_enable_state(int32_t enable_state,ql_audio_tone_config_t *p_tone_config);
513
514/*-----------------------------------------------------------------------------------------------*/
515/**
516 @brief Get tone enable state
517
518 @param[out] p_enable_state tone enable state,
519 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
520
521 @return QL_ERR_OK - Successful
522 QL_ERR_INVALID_ARG - Invalid arguments
523 Other errorcode defined by ql_type.h.
524 */
525/*-----------------------------------------------------------------------------------------------*/
526int ql_audio_get_tone_enable_state(int32_t *p_enable_state);
527
528
529#ifdef __cplusplus
530}
531#endif
532#endif
533