KT24-1110_65E-HA-651B/cpu/br25/audio_config.h

211 lines
7.7 KiB
C
Raw Normal View History

2024-11-10 10:44:17 +00:00
#ifndef _AUDIO_CONFIG_H_
#define _AUDIO_CONFIG_H_
#include "generic/typedef.h"
#include "app_config.h"
#include "board_config.h"
#define AUDIO_MIXER_LEN (128 * 4 * 2)
/*解码任务cpu占用率跟踪*/
#define TCFG_AUDIO_DECODER_OCCUPY_TRACE 1
#if BT_SUPPORT_MUSIC_VOL_SYNC
#define TCFG_MAX_VOL_PROMPT 0
#else
#define TCFG_MAX_VOL_PROMPT 1
#endif
//*********************************************************************************//
// USB Audio配置 //
//*********************************************************************************//
/*usb mic的数据是否经过CVP,包括里面的回音消除(AEC)、非线性回音压制(NLP)、降噪(ANS)模块*/
#define TCFG_USB_MIC_CVP_ENABLE DISABLE_THIS_MOUDLE
#define TCFG_USB_MIC_CVP_MODE (ANS_EN | NLP_EN)
/*
*
*
*
*vol_sync.c
*
*/
#define TCFG_VOL_RESET_WHEN_NO_SUPPORT_VOL_SYNC 0 //不支持音量同步的设备默认最大音量
#if TCFG_MIC_CAPLESS_ENABLE
/*
*mic偏置电压自动调整()
*1
*2,()
*3
*/
#define MC_BIAS_ADJUST_DISABLE 0 //省电容mic偏置校准关闭
#define MC_BIAS_ADJUST_ONE 1 //省电容mic偏置只校准一次跟dac trim一样
#define MC_BIAS_ADJUST_POWER_ON 2 //省电容mic偏置每次上电复位都校准(Power_On_Reset)
#define MC_BIAS_ADJUST_ALWAYS 3 //省电容mic偏置每次开机都校准(包括上电复位和其他复位)
#define TCFG_MC_BIAS_AUTO_ADJUST MC_BIAS_ADJUST_POWER_ON
#define TCFG_MC_CONVERGE_TRACE 0 //省电容mic收敛值跟踪
#else
#define TCFG_MC_BIAS_AUTO_ADJUST MC_BIAS_ADJUST_DISABLE
#define TCFG_MC_CONVERGE_TRACE 0 //省电容mic收敛值跟踪
#endif/*TCFG_MIC_CAPLESS_ENABLE*/
#define TCFG_MC_MIC_ONLINE_CHECK_EN 0 //省电容mic在线检测
/*
*mic收敛步进限制
*0:, >0:
*mic的模拟增益或者数字增益很大的时候mic_capless模式收敛过程,
*
*()
*/
#define TCFG_MC_DTB_STEP_LIMIT 15 //最大收敛步进值
#if TCFG_USER_BLE_ENABLE
#define TCFG_AEC_SIMPLEX 0 //通话单工模式配置
#else
#define TCFG_AEC_SIMPLEX 0 //通话单工模式配置
#endif
#define TCFG_ESCO_PLC 1 //通话丢包修复
#define TCFG_DIG_PHASE_INVERTER_EN 1 //数字反相器用来矫正DAC的输出相位
#ifdef CONFIG_SOUNDBOX_FLASH_256K
#define TCFG_ESCO_LIMITER 0 //通话近端底噪/限幅器
#else
#define TCFG_ESCO_LIMITER 0 //通话近端底噪/限幅器
#endif
/*
*[]
*300~3031
*/
#if (TCFG_AUDIO_DAC_CONNECT_MODE == DAC_OUTPUT_MONO_LR_DIFF || \
TCFG_AUDIO_DAC_CONNECT_MODE == DAC_OUTPUT_DUAL_LR_DIFF)
2024-11-10 13:14:01 +00:00
#define MAX_ANA_VOL (28)
2024-11-10 10:44:17 +00:00
#else
#define MAX_ANA_VOL (30)
#endif/*TCFG_AUDIO_DAC_CONNECT_MODE*/
/*
*[]
* (combined_vol_list)
*300~3031
*/
#define MAX_COM_VOL (30)
/*
*[]
*300~3031
*/
#define MAX_DIG_VOL (100)
#define MAX_DIG_GR_VOL (30)//数字音量组的最大值
#if ((SYS_VOL_TYPE == VOL_TYPE_DIGITAL) || (SYS_VOL_TYPE == VOL_TYPE_DIGITAL_HW))
#define SYS_MAX_VOL MAX_DIG_VOL
#elif (SYS_VOL_TYPE == VOL_TYPE_ANALOG)
#define SYS_MAX_VOL MAX_ANA_VOL
#elif (SYS_VOL_TYPE == VOL_TYPE_AD)
#define SYS_MAX_VOL MAX_COM_VOL
#elif (SYS_VOL_TYPE == VOL_TYPE_DIGGROUP)
#define SYS_MAX_VOL MAX_DIG_GR_VOL
#else
#error "SYS_VOL_TYPE define error"
#endif
2024-11-10 13:14:01 +00:00
#define SYS_DEFAULT_VOL SYS_MAX_VOL/2 //(SYS_MAX_VOL/2)
#define SYS_DEFAULT_TONE_VOL 18//(SYS_MAX_VOL)
2024-11-10 10:44:17 +00:00
#define SYS_DEFAULT_SIN_VOL 17
#define APP_AUDIO_STATE_IDLE 0
#define APP_AUDIO_STATE_MUSIC 1
#define APP_AUDIO_STATE_CALL 2
#define APP_AUDIO_STATE_WTONE 3
#define APP_AUDIO_STATE_LINEIN 4
#define APP_AUDIO_CURRENT_STATE 5
#define APP_AUDIO_MAX_STATE (APP_AUDIO_CURRENT_STATE + 1)
#ifdef TCFG_IIS_ENABLE
#define AUDIO_OUTPUT_ONLY_IIS \
(TCFG_IIS_ENABLE && TCFG_IIS_OUTPUT_EN && AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_IIS)
#define AUDIO_OUTPUT_DAC_AND_IIS \
(AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_DAC_IIS && TCFG_IIS_ENABLE && TCFG_IIS_OUTPUT_EN)
#else
#define AUDIO_OUTPUT_ONLY_IIS 0
#define AUDIO_OUTPUT_DAC_AND_IIS (AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_DAC_IIS)
#endif
#define AUDIO_OUTPUT_INCLUDE_IIS (AUDIO_OUTPUT_ONLY_IIS || AUDIO_OUTPUT_DAC_AND_IIS)
#define AUDIO_OUTPUT_ONLY_DAC (AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_DAC)
#define AUDIO_OUTPUT_INCLUDE_DAC ((AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_DAC) \
|| (AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_BT) \
|| (AUDIO_OUTPUT_WAY == AUDIO_OUTPUT_WAY_DONGLE) \
|| (AUDIO_OUTPUT_DAC_AND_IIS))
u8 get_max_sys_vol(void);
u8 get_tone_vol(void);
void app_audio_output_init(void);
void app_audio_output_sync_buff_init(void *sync_buff, int len);
int app_audio_output_channel_set(u8 output);
int app_audio_output_channel_get(void);
int app_audio_output_mode_set(u8 output);
int app_audio_output_mode_get(void);
int app_audio_output_write(void *buf, int len);
int app_audio_output_samplerate_select(u32 sample_rate, u8 high);
int app_audio_output_samplerate_set(int sample_rate);
int app_audio_output_samplerate_get(void);
int app_audio_output_start(void);
int app_audio_output_stop(void);
int app_audio_output_reset(u32 msecs);
int app_audio_output_state_get(void);
void app_audio_output_ch_mute(u8 ch, u8 mute);
int app_audio_output_ch_analog_gain_set(u8 ch, u8 again);
int app_audio_output_ch_digital_gain_set(u8 ch, u32 dgain);
int app_audio_output_get_cur_buf_points(void);
s8 app_audio_get_volume(u8 state);
void app_audio_set_volume(u8 state, s8 volume, u8 fade);
void app_audio_set_volume_each_channel(u8 state, s8 volume_l, s8 volume_r, u8 fade);
void app_audio_volume_up(u8 value);
void app_audio_volume_down(u8 value);
void app_audio_state_switch(u8 state, s16 max_volume);
void app_audio_mute(u8 value);
s16 app_audio_get_max_volume(void);
void app_audio_state_switch(u8 state, s16 max_volume);
void app_audio_state_exit(u8 state);
u8 app_audio_get_state(void);
void volume_up_down_direct(s8 value);
void app_audio_volume_init(void);
void app_audio_set_digital_volume(s16 volume);
void dac_trim_hook(u8 pos);
void audio_combined_vol_init(u8 cfg_en);
void *app_audio_alloc_use_buff(int use_len);
void app_audio_release_use_buff(void *buf);
int audio_output_buf_time(void);
int audio_output_dev_is_working(void);
int audio_output_sync_start(void);
int audio_output_sync_stop(void);
void app_set_sys_vol(s16 vol_l, s16 vol_r);
void app_set_max_vol(s16 vol);
u32 phone_call_eq_open();
int eq_mode_sw();
int mic_test_start();
int mic_test_stop();
void dac_power_on(void);
void dac_power_off(void);
void set_dac_start_delay_time(u16 dac_delay_ms, u8 save_last_config_en); //设置dac通道的启动延时
#endif/*_AUDIO_CONFIG_H_*/