add base work success

This commit is contained in:
dylancaowugang 2022-08-16 09:30:33 +08:00
parent 235a402c8c
commit 136f7a43fa
21 changed files with 1417 additions and 18 deletions

View File

@ -20,6 +20,10 @@ ifeq ($(ANC_APP),1)
obj-y += anc/ obj-y += anc/
endif endif
ifeq ($(WL_DET),1)
obj-y += mic_alg/
endif
ifeq ($(VOICE_DETECTOR_EN),1) ifeq ($(VOICE_DETECTOR_EN),1)
obj-y += voice_detector/ obj-y += voice_detector/
endif endif

View File

@ -37,6 +37,8 @@ static int16_t *app_audioloop_play_cache = NULL;
static uint32_t app_factorymode_data_come(uint8_t *buf, uint32_t len) static uint32_t app_factorymode_data_come(uint8_t *buf, uint32_t len)
{ {
DUMP16("%d,",(int*)buf,30);
app_audio_pcmbuff_put(buf, len); app_audio_pcmbuff_put(buf, len);
if (a2dp_cache_status == APP_AUDIO_CACHE_QTY){ if (a2dp_cache_status == APP_AUDIO_CACHE_QTY){
a2dp_cache_status = APP_AUDIO_CACHE_OK; a2dp_cache_status = APP_AUDIO_CACHE_OK;

View File

@ -24,6 +24,7 @@ ccflags-y += \
-Iservices/resources \ -Iservices/resources \
-Iservices/audio_process \ -Iservices/audio_process \
-Iapps/apptester \ -Iapps/apptester \
-Iapps/mic_alg \
-Iapps/factory \ -Iapps/factory \
-Iutils/crc32 \ -Iutils/crc32 \
-Iplatform/drivers/bt \ -Iplatform/drivers/bt \

View File

@ -142,6 +142,11 @@
#include "ota_common.h" #include "ota_common.h"
#endif #endif
#ifdef WL_DET
#include "app_mic_alg.h"
#endif
#ifdef AUDIO_DEBUG_V0_1_0 #ifdef AUDIO_DEBUG_V0_1_0
extern "C" int speech_tuning_init(void); extern "C" int speech_tuning_init(void);
#endif #endif
@ -599,7 +604,6 @@ extern "C" int app_voice_stop(APP_STATUS_INDICATION_T status, uint8_t device_id)
} }
#endif #endif
/*
static void app_poweron_normal(APP_KEY_STATUS *status, void *param) static void app_poweron_normal(APP_KEY_STATUS *status, void *param)
{ {
TRACE(3,"%s %d,%d",__func__, status->code, status->event); TRACE(3,"%s %d,%d",__func__, status->code, status->event);
@ -607,8 +611,7 @@ static void app_poweron_normal(APP_KEY_STATUS *status, void *param)
signal_send_to_main_thread(0x2); signal_send_to_main_thread(0x2);
} }
*/ #if 1//!defined(BLE_ONLY_ENABLED)
#if 0//!defined(BLE_ONLY_ENABLED)
static void app_poweron_scan(APP_KEY_STATUS *status, void *param) static void app_poweron_scan(APP_KEY_STATUS *status, void *param)
{ {
TRACE(3,"%s %d,%d",__func__, status->code, status->event); TRACE(3,"%s %d,%d",__func__, status->code, status->event);
@ -684,7 +687,7 @@ static void app_poweron_key_init(void)
static uint8_t app_poweron_wait_case(void) static uint8_t app_poweron_wait_case(void)
{ {
// uint32_t stime = 0, etime = 0; uint32_t stime = 0, etime = 0;
#ifdef __POWERKEY_CTRL_ONOFF_ONLY__ #ifdef __POWERKEY_CTRL_ONOFF_ONLY__
g_pwron_case = APP_POWERON_CASE_NORMAL; g_pwron_case = APP_POWERON_CASE_NORMAL;
@ -1797,6 +1800,10 @@ int app_deinit(int deinit_case)
int nRet = 0; int nRet = 0;
TRACE(2,"%s case:%d",__func__, deinit_case); TRACE(2,"%s case:%d",__func__, deinit_case);
#ifdef WL_DET
app_mic_alg_audioloop(false,APP_SYSFREQ_78M);
#endif
#ifdef __PC_CMD_UART__ #ifdef __PC_CMD_UART__
app_cmd_close(); app_cmd_close();
#endif #endif
@ -2295,7 +2302,7 @@ int app_init(void)
#ifdef POWER_ON_ENTER_TWS_PAIRING_ENABLED #ifdef POWER_ON_ENTER_TWS_PAIRING_ENABLED
bool need_check_key = false; bool need_check_key = false;
#else #else
bool need_check_key = true; bool need_check_key = false;
#endif #endif
uint8_t pwron_case = APP_POWERON_CASE_INVALID; uint8_t pwron_case = APP_POWERON_CASE_INVALID;
#ifdef BT_USB_AUDIO_DUAL_MODE #ifdef BT_USB_AUDIO_DUAL_MODE
@ -2467,14 +2474,16 @@ extern int rpc_service_setup(void);
/*****************************************************************************/ /*****************************************************************************/
// app_bt_connect2tester_init(); // app_bt_connect2tester_init();
nv_record_env_get(&nvrecord_env); nv_record_env_get(&nvrecord_env);
/*
if( bt_addr[0] < 0x22 ||bt_addr[0] > 0x33 ||bt_addr[1] != 0x22 || bt_addr[2] != 0x22 ||bt_addr[3] != 0x22||bt_addr[4] != 0x22||bt_addr[5] != 0x22)
{ #ifdef AUDIO_LOOPBACK
TRACE(3,"BT ADDR ERRO!!!\n"); #ifdef WL_DET
nRet = -1; app_mic_alg_audioloop(true,APP_SYSFREQ_78M);
goto exit; #endif
}
*/ while(1);
#endif
#ifdef BISTO_ENABLED #ifdef BISTO_ENABLED
nv_record_gsound_rec_init(); nv_record_gsound_rec_init();
#endif #endif

46
apps/mic_alg/Makefile Normal file
View File

@ -0,0 +1,46 @@
cur_dir := $(dir $(lastword $(MAKEFILE_LIST)))
obj-y := $(patsubst $(cur_dir)%,%,$(wildcard $(cur_dir)*.c $(cur_dir)*.cpp $(cur_dir)*.S))
obj-y := $(obj-y:.c=.o)
obj-y := $(obj-y:.cpp=.o)
obj-y := $(obj-y:.S=.o)
ccflags-y += \
-Iutils/boot_struct \
-Iutils/intersyshci \
-Iutils/hwtimer_list \
-Iservices/bt_app \
-Iservices/nvrecord \
-Iservices/wl_filter \
-Iservices/bt_if/inc \
-Iservices/resources \
-Iservices/remoter \
-Iservices/wl_filter \
-Iservices/audio_dump/include \
-Iservices/multimedia/wl_alg/gcc_plat/include \
-Iservices/multimedia/wl_alg/vad_user/include \
-Iservices/overlay \
-Iservices/multimedia/wl_alg/nsx_main/include \
-Iservices/multimedia/wl_alg/agc/include \
-Iservices/multimedia/wl_alg/utility/include \
-Iservices/multimedia/wl_alg/notch_filter/include \
-Iservices/multimedia/algorithm/fft/include \
-Iservices/multimedia/speech/inc \
-Iapps/key \
-Iapps/i2c_sensor \
-Iplatform/drivers/bt \
-Iplatform/drivers/ana \
-Iplatform/drivers/usb/usb_dev/inc \
-Iapps/battery
ifeq ($(AUDIO_RESAMPLE),1)
CFLAGS_app_factory_audio.o += -D__AUDIO_RESAMPLE__
endif
ifeq ($(SW_CAPTURE_RESAMPLE),1)
CFLAGS_app_factory_audio.o += -DSW_CAPTURE_RESAMPLE
endif
ifeq ($(POWERKEY_I2C_SWITCH),1)
CFLAGS_app_factory.o += -DPOWERKEY_I2C_SWITCH
endif

View File

@ -0,0 +1,343 @@
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#include "cmsis_os.h"
#include "hal_trace.h"
#include "resources.h"
#include "app_bt_stream.h"
#include "app_media_player.h"
//#include "app_factory.h"
#include "string.h"
// for audio
#include "audioflinger.h"
#include "app_audio.h"
#include "app_utils.h"
#include "hal_timer.h"
#include "app_mic_alg.h"
#include "tgt_hardware.h"
#ifdef NOTCH_FILTER
#include "autowah.h"
#endif
#ifdef WL_NSX
#include "nsx_main.h"
#endif
#include "app_overlay.h"
#include "math.h"
#include "apps.h"
#ifdef WEBRTC_AGC
#include "agc_main.h"
#endif
#ifdef WL_NSX
#define WEBRTC_NSX_BUFF_SIZE (14000)
#endif
#ifdef WL_VAD
#include "vad_user.h"
#endif
#ifdef WL_DEBUG_MODE
#include "nvrecord_env.h"
#endif
#ifdef REMOTE_UART
#include "app_remoter_uart.h"
#endif
#if defined(WL_AEC)
#include "wl_sco_process.h"
#endif
#include "speech_memory.h"
#ifdef I2C_SENSOR
#include "app_i2c_sensor.h"
#endif
static inline float clampf(float v, float min, float max){
return v < min ? min : (v > max ? max : v);
}
#ifdef WL_NSX_5MS
#define BT_AUDIO_FACTORMODE_BUFF_SIZE (160*2)
#else
#define BT_AUDIO_FACTORMODE_BUFF_SIZE (6*320*16)
#endif
#define NSX_FRAME_SIZE 160
static enum APP_AUDIO_CACHE_T a2dp_cache_status = APP_AUDIO_CACHE_QTY;
#if defined(WL_AEC)
static short POSSIBLY_UNUSED aec_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static short POSSIBLY_UNUSED far_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
#endif
static short POSSIBLY_UNUSED out_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static short POSSIBLY_UNUSED tmp_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
//static short revert_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
//static short audio_uart_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
#if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2
static short POSSIBLY_UNUSED one_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static short POSSIBLY_UNUSED two_buff[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static short POSSIBLY_UNUSED left_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static short POSSIBLY_UNUSED right_out[BT_AUDIO_FACTORMODE_BUFF_SIZE>>2];
static void POSSIBLY_UNUSED aaudio_div_stero_to_rmono(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len)
{
// Copy from tail so that it works even if dst_buf == src_buf
for (uint32_t i = 0; i < src_len>>1; i++)
{
dst_buf[i] = src_buf[i*2 + 1];
}
}
static void POSSIBLY_UNUSED aaudio_div_stero_to_lmono(int16_t *dst_buf, int16_t *src_buf, uint32_t src_len)
{
// Copy from tail so that it works even if dst_buf == src_buf
for (uint32_t i = 0; i < src_len>>1; i++)
{
dst_buf[i] = src_buf[i*2 + 0];
}
}
static void POSSIBLY_UNUSED audio_mono2stereo_16bits(int16_t *dst_buf, int16_t *left_buf, int16_t *right_buf, uint32_t src_len)
{
uint32_t i = 0;
for (i = 0; i < src_len; ++i) {
dst_buf[i*2 + 0] = left_buf[i];
dst_buf[i*2 + 1] = right_buf[i];
}
}
#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3
#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 4
#endif
extern uint8_t supress_step;
extern uint32_t transfer_factor;
extern uint32_t diff_energy;
extern uint32_t level_shift;
static inline double convert_multiple_to_db(uint32_t multiple)
{
return 20*log10(multiple);
}
#define DUMP_FRAME_LEN 0x3C0
static short POSSIBLY_UNUSED revert_buff[2+1*DUMP_FRAME_LEN];
int32_t tx_pcmbuf32[960];
extern int app_reset(void);
extern void app_bt_volumeup();
extern void app_bt_volumedown();
void vol_state_process(uint32_t db_val)
{
TRACE(2,"db value is:%d volume_is:%d ",db_val,app_bt_stream_local_volume_get());
if((db_val < 52) && (app_bt_stream_local_volume_get() > 10))
{
app_bt_volumedown();
}
else if((db_val > 60) && (app_bt_stream_local_volume_get() < 13))
{
app_bt_volumeup();
}
else if((db_val > 72) && (app_bt_stream_local_volume_get() < 15))
{
app_bt_volumeup();
}
}
static uint32_t app_mic_alg_data_come(uint8_t *buf, uint32_t len)
{
uint32_t pcm_len = len>>1;
short POSSIBLY_UNUSED *tx_pcmbuf16 = (short*)buf;
//DUMP16("%d, ",tx_pcmbuf16,30);
// memcpy(tmp_buff,pcm_buff,len);
int32_t stime = 0;
static int32_t nsx_cnt = 0;
static int32_t dump_cnt = 0;
nsx_cnt++;
dump_cnt++;
DUMP16("%d,",tx_pcmbuf16,30);
if(false == (nsx_cnt & 0x3F))
{
stime = hal_sys_timer_get();
//TRACE("aecm echo time: lens:%d g_time_cnt:%d ",len, g_time_cnt);
}
#ifdef WL_DET
if(nsx_cnt > 100)
{
static double last_sum = 0,last_avg = 0;
uint32_t sum_ss = 0;
//short db_val = 0;
double db_sum = 0;
for (uint32_t i_cnt = 0; i_cnt < pcm_len; i_cnt++)
{
sum_ss += ABS(tx_pcmbuf16[i_cnt]);
}
sum_ss = 1*sum_ss/pcm_len;
db_sum = convert_multiple_to_db(sum_ss);
//db_val = (short)(100*db_sum);
last_sum += db_sum;
last_avg = last_sum/nsx_cnt;
db_sum = db_sum*(double)0.02 + last_avg*(double)0.98;
//TRACE(2,"db value is:%d sum_ss:%d ",(uint32_t)db_sum,sum_ss);
//TRACE(2,"db value is:%d ",(uint32_t)db_sum);
vol_state_process((uint32_t)db_sum);
}
#endif
if(false == (nsx_cnt & 0x3F))
{
//TRACE("drc 48 mic_alg 16k nsx 3 agc 15 closed speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get());
//TRACE("notch 500 mic_alg 16k nsx 3 agc 15 closed speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get());
TRACE(2,"denoise det speed time:%d ms and pcm_lens:%d freq:%d ", TICKS_TO_MS(hal_sys_timer_get() - stime), pcm_len,hal_sysfreq_get());
}
if (a2dp_cache_status == APP_AUDIO_CACHE_QTY){
a2dp_cache_status = APP_AUDIO_CACHE_OK;
}
return len;
}
// static uint32_t app_mic_uart_playback_data(uint8_t *buf, uint32_t len)
// {
// if (a2dp_cache_status != APP_AUDIO_CACHE_QTY){
// #if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2
// #ifdef WL_AEC
// app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len/2);
// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, app_audioloop_play_cache, len/2/2);
// #else
// app_audio_pcmbuff_get((uint8_t *)buf, len);
// #endif
// #else
// app_audio_pcmbuff_get((uint8_t *)app_audioloop_play_cache, len/2);
// app_bt_stream_copy_track_one_to_two_16bits((int16_t *)buf, app_audioloop_play_cache, len/2/2);
// #endif
// }
// return len;
// }
static uint8_t buff_capture[BT_AUDIO_FACTORMODE_BUFF_SIZE];
int app_mic_alg_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq)
{
struct AF_STREAM_CONFIG_T stream_cfg;
static bool isRun = false;
TRACE(2,"app_mic_alg work:%d op:%d freq:%d", isRun, on, freq);
if (isRun==on)
return 0;
if (on){
app_sysfreq_req(APP_SYSFREQ_USER_APP_0, freq);
a2dp_cache_status = APP_AUDIO_CACHE_QTY;
memset(&stream_cfg, 0, sizeof(stream_cfg));
stream_cfg.bits = AUD_BITS_16;
stream_cfg.channel_num = AUD_CHANNEL_NUM_1;
stream_cfg.sample_rate = AUD_SAMPRATE_48000;
stream_cfg.device = AUD_STREAM_USE_INT_CODEC;
stream_cfg.vol = CODEC_SADC_VOL;
stream_cfg.io_path = AUD_INPUT_PATH_ASRMIC;
stream_cfg.handler = app_mic_alg_data_come;
stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_capture);
stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*stream_cfg.channel_num;
af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE, &stream_cfg);
// stream_cfg.channel_num = AUD_CHANNEL_NUM_2;
// stream_cfg.io_path = AUD_OUTPUT_PATH_SPEAKER;
// stream_cfg.handler = app_mic_uart_playback_data;
// stream_cfg.data_ptr = BT_AUDIO_CACHE_2_UNCACHE(buff_play);
// stream_cfg.data_size = BT_AUDIO_FACTORMODE_BUFF_SIZE*2;
// af_stream_open(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK, &stream_cfg);
//af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK);
af_stream_start(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE);
TRACE(2,"app_mic_uart ss loopback on");
} else {
af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE);
//af_stream_stop(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK);
af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_CAPTURE);
//af_stream_close(AUD_STREAM_ID_0, AUD_STREAM_PLAYBACK);
TRACE(2,"app_mic_16k loopback off");
//app_sysfreq_req(APP_SYSFREQ_USER_APP_0, APP_SYSFREQ_32K);
}
isRun=on;
return 0;
}

View File

@ -0,0 +1,24 @@
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#ifndef __APP_MIC_ALG_H__
#define __APP_MIC_ALG_H__
#include "app_utils.h"
int app_mic_alg_audioloop(bool on, enum APP_SYSFREQ_FREQ_T freq);
void vol_state_process(uint32_t db_val);
#endif

8
build.sh Normal file
View File

@ -0,0 +1,8 @@
make -j T=mic_alg DEBUG=1 > log.txt 2>&1
if [ $? -eq 0 ];then
echo "build success"
else
echo "build failed and call log.txt"
cat log.txt | grep "error:*"
fi

1
clear.sh Normal file
View File

@ -0,0 +1 @@
make T=mic_back -j DEBUG=1 clean

View File

@ -1789,6 +1789,18 @@ ifeq ($(INTERACTION),1)
KBUILD_CPPFLAGS += -D__INTERACTION__ KBUILD_CPPFLAGS += -D__INTERACTION__
endif endif
export WL_DET ?= 0
ifeq ($(WL_DET),1)
KBUILD_CPPFLAGS += -DWL_DET
endif
export AUDIO_LOOPBACK ?= 0
ifeq ($(AUDIO_LOOPBACK),1)
KBUILD_CPPFLAGS += -DAUDIO_LOOPBACK
endif
export INTERACTION_FASTPAIR ?= 0 export INTERACTION_FASTPAIR ?= 0
ifeq ($(INTERACTION_FASTPAIR),1) ifeq ($(INTERACTION_FASTPAIR),1)
KBUILD_CPPFLAGS += -D__INTERACTION_FASTPAIR__ KBUILD_CPPFLAGS += -D__INTERACTION_FASTPAIR__

413
config/mic_alg/target.mk Normal file
View File

@ -0,0 +1,413 @@
CHIP ?= best2300p
DEBUG ?= 1
FPGA ?= 0
MBED ?= 0
RTOS ?= 1
#KERNEL ?= FREERTOS
LIBC_ROM ?= 1
export USER_SECURE_BOOT ?= 0
# enable:1
# disable:0
WATCHER_DOG ?= 0
DEBUG_PORT ?= 1
# 0: usb
# 1: uart0
# 2: uart1
FLASH_CHIP ?= ALL
# GD25Q80C
# GD25Q32C
# ALL
export NO_TRACE_TIME_STAMP ?=1
export FORCE_SIGNALINGMODE ?= 0
export FORCE_NOSIGNALINGMODE ?= 0
export FORCE_SCO_MAX_RETX ?= 0
export FA_RX_GAIN_CTRL ?= 1
export BT_FA_ECC ?= 0
export CONTROLLER_DUMP_ENABLE ?= 0
export CONTROLLER_MEM_LOG_ENABLE ?= 0
export INTERSYS_DEBUG ?= 1
export PROFILE_DEBUG ?= 0
export BTDUMP_ENABLE ?= 0
export BT_DEBUG_TPORTS ?= 0
TPORTS_KEY_COEXIST ?= 0
export SNIFF_MODE_CHECK ?= 0
AUDIO_OUTPUT_MONO ?= 0
AUDIO_OUTPUT_DIFF ?= 0
HW_FIR_EQ_PROCESS ?= 0
SW_IIR_EQ_PROCESS ?= 0
HW_DAC_IIR_EQ_PROCESS ?= 1
HW_IIR_EQ_PROCESS ?= 0
HW_DC_FILTER_WITH_IIR ?= 0
AUDIO_DRC ?= 0
AUDIO_DRC2 ?= 0
PC_CMD_UART ?= 0
AUDIO_SECTION_ENABLE ?= 0
AUDIO_RESAMPLE ?= 1
RESAMPLE_ANY_SAMPLE_RATE ?= 1
OSC_26M_X4_AUD2BB ?= 1
AUDIO_OUTPUT_VOLUME_DEFAULT ?= 12
# range:1~16
AUDIO_INPUT_CAPLESSMODE ?= 0
AUDIO_INPUT_LARGEGAIN ?= 0
AUDIO_CODEC_ASYNC_CLOSE ?= 0
AUDIO_SCO_BTPCM_CHANNEL ?= 1
export A2DP_CP_ACCEL ?= 1
export SCO_CP_ACCEL ?= 1
export SCO_TRACE_CP_ACCEL ?= 0
# For TWS SCO DMA snapshot and low delay
export PCM_FAST_MODE ?= 1
export CVSD_BYPASS ?= 1
export LOW_DELAY_SCO ?= 0
SPEECH_TX_DC_FILTER ?= 1
SPEECH_TX_AEC2FLOAT ?= 1
SPEECH_TX_NS3 ?= 0
SPEECH_TX_2MIC_NS2 ?= 0
SPEECH_TX_COMPEXP ?= 1
SPEECH_TX_EQ ?= 0
SPEECH_TX_POST_GAIN ?= 0
SPEECH_RX_NS2FLOAT ?= 0
SPEECH_RX_EQ ?= 0
SPEECH_RX_POST_GAIN ?= 0
LARGE_RAM ?= 1
HSP_ENABLE ?= 0
HFP_1_6_ENABLE ?= 1
MSBC_PLC_ENABLE ?= 1
MSBC_PLC_ENCODER ?= 1
MSBC_16K_SAMPLE_RATE ?= 1
SBC_FUNC_IN_ROM ?= 0
ROM_UTILS_ON ?= 0
APP_LINEIN_A2DP_SOURCE ?= 0
APP_I2S_A2DP_SOURCE ?= 0
VOICE_PROMPT ?= 1
export THROUGH_PUT ?= 0
#### Google related feature ####
# the overall google service switch
# currently, google service includes BISTO and GFPS
export GOOGLE_SERVICE_ENABLE ?= 0
# BISTO is a GVA service on Bluetooth audio device
# BISTO is an isolated service relative to GFPS
export BISTO_ENABLE ?= 0
# macro switch for reduced_guesture
export REDUCED_GUESTURE_ENABLE ?= 0
# GSOUND_HOTWORD is a hotword library running on Bluetooth audio device
# GSOUND_HOTWORD is a subset of BISTO
export GSOUND_HOTWORD_ENABLE ?= 0
# this is a subset choice for gsound hotword
export GSOUND_HOTWORD_EXTERNAL ?= 0
# GFPS is google fastpair service
# GFPS is an isolated service relative to BISTO
export GFPS_ENABLE ?= 0
#### Google related feature ####
BLE ?= 0
TOTA ?= 0
GATT_OVER_BR_EDR ?= 0
OTA_ENABLE ?= 0
TILE_DATAPATH_ENABLED ?= 0
CUSTOM_INFORMATION_TILE_ENABLE ?= 0
INTERCONNECTION ?= 0
INTERACTION ?= 0
INTERACTION_FASTPAIR ?= 0
BT_ONE_BRING_TWO ?= 0
DSD_SUPPORT ?= 0
A2DP_EQ_24BIT ?= 1
A2DP_AAC_ON ?= 1
A2DP_SCALABLE_ON ?= 0
A2DP_LHDC_ON ?= 0
ifeq ($(A2DP_LHDC_ON),1)
A2DP_LHDC_V3 ?= 1
A2DP_LHDC_LARC ?= 1
export FLASH_UNIQUE_ID ?= 1
endif
A2DP_LDAC_ON ?= 0
export TX_RX_PCM_MASK ?= 0
A2DP_SCALABLE_ON ?= 0
FACTORY_MODE ?= 1
ENGINEER_MODE ?= 1
ULTRA_LOW_POWER ?= 1
DAC_CLASSG_ENABLE ?= 1
NO_SLEEP ?= 0
CORE_DUMP ?= 1
CORE_DUMP_TO_FLASH ?= 0
ENHANCED_STACK ?= 1
export SYNC_BT_CTLR_PROFILE ?= 0
export A2DP_AVDTP_CP ?= 0
export A2DP_DECODER_VER := 2
export IBRT ?= 1
export IBRT_SEARCH_UI ?= 1
export BES_AUD ?= 1
export POWER_MODE ?= DIG_DCDC
export BT_RF_PREFER ?= 2M
export SPEECH_CODEC ?= 1
export TWS_PROMPT_SYNC ?= 0
export MIX_AUDIO_PROMPT_WITH_A2DP_MEDIA_ENABLED ?= 0
export IOS_MFI ?= 0
export FLASH_SIZE ?= 0x400000
export FLASH_SUSPEND ?= 1
ifeq ($(DSD_SUPPORT),1)
export BTUSB_AUDIO_MODE ?= 1
export AUDIO_INPUT_MONO ?= 1
export USB_ISO ?= 1
export USB_AUDIO_DYN_CFG ?= 1
export DELAY_STREAM_OPEN ?= 0
export KEEP_SAME_LATENCY ?= 1
export HW_FIR_DSD_PROCESS ?= 1
ifeq ($(HW_FIR_DSD_PROCESS),1)
ifeq ($(CHIP),best2300)
export HW_FIR_DSD_BUF_MID_ADDR ?= 0x200A0000
export DATA_BUF_START ?= 0x20040000
endif
endif
export USB_AUDIO_UAC2 ?= 1
export USB_HIGH_SPEED ?= 1
KBUILD_CPPFLAGS += \
-DHW_FIR_DSD_BUF_MID_ADDR=$(HW_FIR_DSD_BUF_MID_ADDR) \
-DDATA_BUF_START=$(DATA_BUF_START)
endif
USE_THIRDPARTY ?= 0
export USE_KNOWLES ?= 0
ifeq ($(CURRENT_TEST),1)
export VCODEC_VOLT ?= 1.6V
export VANA_VOLT ?= 1.35V
else
export VCODEC_VOLT ?= 1.8V
export VANA_VOLT ?= 1.35V
endif
export LAURENT_ALGORITHM ?= 0
export TX_IQ_CAL ?= 0
export BT_XTAL_SYNC ?= 1
export BTADDR_FOR_DEBUG ?= 1
export POWERKEY_I2C_SWITCH ?=0
export WL_DET ?= 1
export AUDIO_LOOPBACK ?= 0
AUTO_TEST ?= 0
BES_AUTOMATE_TEST ?= 0
export DUMP_NORMAL_LOG ?= 0
SUPPORT_BATTERY_REPORT ?= 1
SUPPORT_HF_INDICATORS ?= 0
SUPPORT_SIRI ?= 1
BES_AUDIO_DEV_Main_Board_9v0 ?= 0
APP_USE_LED_INDICATE_IBRT_STATUS ?= 0
export BT_EXT_LNA_PA ?=0
export BT_EXT_LNA ?=0
export BT_EXT_PA ?=0
ifeq ($(A2DP_LHDC_ON),1)
AUDIO_BUFFER_SIZE := 140*1024
else
AUDIO_BUFFER_SIZE := 100*1024
endif
export TRACE_BUF_SIZE := 16*1024
export TRACE_BAUD_RATE := 921600
init-y :=
core-y := platform/ services/ apps/ utils/cqueue/ utils/list/ services/multimedia/ utils/intersyshci/
KBUILD_CPPFLAGS += \
-Iplatform/cmsis/inc \
-Iservices/audioflinger \
-Iplatform/hal \
-Iservices/fs/ \
-Iservices/fs/sd \
-Iservices/fs/fat \
-Iservices/fs/fat/ChaN
KBUILD_CPPFLAGS += \
-DAPP_AUDIO_BUFFER_SIZE=$(AUDIO_BUFFER_SIZE) \
-DCHARGER_PLUGINOUT_RESET=0
# -D__A2DP_AVDTP_CP__ \
ifeq ($(BES_AUDIO_DEV_Main_Board_9v0),1)
KBUILD_CPPFLAGS += -DBES_AUDIO_DEV_Main_Board_9v0
endif
ifeq ($(TPORTS_KEY_COEXIST),1)
KBUILD_CPPFLAGS += -DTPORTS_KEY_COEXIST
endif
#-DIBRT_LINK_LOWLAYER_MONITOR
#-D_AUTO_SWITCH_POWER_MODE__
#-D__APP_KEY_FN_STYLE_A__
#-D__APP_KEY_FN_STYLE_B__
#-D__EARPHONE_STAY_BOTH_SCAN__
#-D__POWERKEY_CTRL_ONOFF_ONLY__
#-DAUDIO_LINEIN
ifeq ($(CURRENT_TEST),1)
INTSRAM_RUN ?= 1
endif
ifeq ($(INTSRAM_RUN),1)
LDS_FILE := best1000_intsram.lds
else
LDS_FILE := best1000.lds
endif
ifeq ($(GATT_OVER_BR_EDR),1)
export GATT_OVER_BR_EDR ?= 1
KBUILD_CPPFLAGS += -D__GATT_OVER_BR_EDR__
endif
ifeq ($(TOTA),1)
ifeq ($(BLE),1)
KBUILD_CPPFLAGS += -DBLE_TOTA_ENABLED
endif
KBUILD_CPPFLAGS += -DSHOW_RSSI
KBUILD_CPPFLAGS += -DTEST_OVER_THE_AIR_ENANBLED
export TEST_OVER_THE_AIR ?= 1
endif
KBUILD_CPPFLAGS += -DSHOW_RSSI
ifneq ($(A2DP_DECODER_VER), )
KBUILD_CPPFLAGS += -DA2DP_DECODER_VER=$(A2DP_DECODER_VER)
endif
KBUILD_CPPFLAGS += \
# -DHAL_TRACE_RX_ENABLE
KBUILD_CFLAGS +=
LIB_LDFLAGS += -lstdc++ -lsupc++
export BTIF_HID_DEVICE ?= 1
ifeq ($(BTIF_HID_DEVICE),1)
KBUILD_CPPFLAGS += -DBTIF_HID_DEVICE
endif
#CFLAGS_IMAGE += -u _printf_float -u _scanf_float
#LDFLAGS_IMAGE += --wrap main

View File

@ -0,0 +1,339 @@
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#include "tgt_hardware.h"
#include "iir_process.h"
#include "fir_process.h"
#include "drc.h"
#include "limiter.h"
#include "spectrum_fix.h"
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM] = {
#if (CFG_HW_PLW_NUM > 0)
{HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE},
{HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE},
#endif
};
#ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3] = {
{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE},
{HAL_IOMUX_PIN_LED1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE},
{HAL_IOMUX_PIN_LED2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VBAT, HAL_IOMUX_PIN_PULLUP_ENABLE},
};
#endif
#ifdef __KNOWLES
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2] = {
{HAL_IOMUX_PIN_P2_2, HAL_IOMUX_FUNC_UART2_RX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL},
{HAL_IOMUX_PIN_P2_3, HAL_IOMUX_FUNC_UART2_TX, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL},
};
#endif
//adckey define
const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER] = {
#if (CFG_HW_ADCKEY_NUMBER > 0)
HAL_KEY_CODE_FN9,HAL_KEY_CODE_FN8,HAL_KEY_CODE_FN7,
HAL_KEY_CODE_FN6,HAL_KEY_CODE_FN5,HAL_KEY_CODE_FN4,
HAL_KEY_CODE_FN3,HAL_KEY_CODE_FN2,HAL_KEY_CODE_FN1,
#endif
};
//gpiokey define
#define CFG_HW_GPIOKEY_DOWN_LEVEL (0)
#define CFG_HW_GPIOKEY_UP_LEVEL (1)
const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = {
/*
#if (CFG_HW_GPIOKEY_NUM > 0)
#ifdef BES_AUDIO_DEV_Main_Board_9v0
{HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P0_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P0_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P0_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN4,{HAL_IOMUX_PIN_P0_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
//{HAL_KEY_CODE_FN5,{HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
// {HAL_KEY_CODE_FN6,{HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
#else
#ifndef TPORTS_KEY_COEXIST
{HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN2,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
// {HAL_KEY_CODE_FN3,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
#else
{HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
{HAL_KEY_CODE_FN15,{HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
#endif
#endif
#ifdef IS_MULTI_AI_ENABLED
//{HAL_KEY_CODE_FN13,{HAL_IOMUX_PIN_P1_3, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
//{HAL_KEY_CODE_FN14,{HAL_IOMUX_PIN_P1_2, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
#endif
#endif
*/
{HAL_KEY_CODE_FN1,{HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE}},
};
//bt config
const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0";
const char *BLE_DEFAULT_NAME = "BES_BLE";
uint8_t ble_addr[6] = {
#ifdef BLE_DEV_ADDR
BLE_DEV_ADDR
#else
0xBE,0x99,0x34,0x45,0x56,0x67
#endif
};
uint8_t bt_addr[6] = {
#ifdef BT_DEV_ADDR
BT_DEV_ADDR
#else
0x1e,0x57,0x34,0x45,0x56,0x67
#endif
};
//audio config
//freq bands range {[0k:2.5K], [2.5k:5K], [5k:7.5K], [7.5K:10K], [10K:12.5K], [12.5K:15K], [15K:17.5K], [17.5K:20K]}
//gain range -12~+12
const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS] = {0, 0, 0, 0, 0, 0, 0, 0};
#define TX_PA_GAIN CODEC_TX_PA_GAIN_DEFAULT
const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = {
{TX_PA_GAIN,0x03,-21},
{TX_PA_GAIN,0x03,-99},
{TX_PA_GAIN,0x03,-45},
{TX_PA_GAIN,0x03,-42},
{TX_PA_GAIN,0x03,-39},
{TX_PA_GAIN,0x03,-36},
{TX_PA_GAIN,0x03,-33},
{TX_PA_GAIN,0x03,-30},
{TX_PA_GAIN,0x03,-27},
{TX_PA_GAIN,0x03,-24},
{TX_PA_GAIN,0x03,-21},
{TX_PA_GAIN,0x03,-18},
{TX_PA_GAIN,0x03,-15},
{TX_PA_GAIN,0x03,-12},
{TX_PA_GAIN,0x03, -9},
{TX_PA_GAIN,0x03, -6},
{TX_PA_GAIN,0x03, -3},
{TX_PA_GAIN,0x03, 0}, //0dBm
};
#if SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 2
#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC2|AUD_VMIC_MAP_VMIC3)
#elif SPEECH_CODEC_CAPTURE_CHANNEL_NUM == 3
#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1)
#else
#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (AUD_CHANNEL_MAP_CH3 | AUD_VMIC_MAP_VMIC4)
#endif
#define CFG_HW_AUD_INPUT_PATH_LINEIN_DEV (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)
#ifdef VOICE_DETECTOR_EN
#define CFG_HW_AUD_INPUT_PATH_VADMIC_DEV (AUD_CHANNEL_MAP_CH4 | AUD_VMIC_MAP_VMIC1)
#else
#define CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV (AUD_CHANNEL_MAP_CH0 | AUD_VMIC_MAP_VMIC1)
#endif
const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM] = {
#if defined(SPEECH_TX_AEC_CODEC_REF)
// NOTE: If enable Ch5 and CH6, need to add channel_num when setup audioflinger stream
{ AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV | AUD_CHANNEL_MAP_CH4, },
#else
{ AUD_INPUT_PATH_MAINMIC, CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV, },
#endif
{ AUD_INPUT_PATH_LINEIN, CFG_HW_AUD_INPUT_PATH_LINEIN_DEV, },
#ifdef VOICE_DETECTOR_EN
{ AUD_INPUT_PATH_VADMIC, CFG_HW_AUD_INPUT_PATH_VADMIC_DEV, },
#else
{ AUD_INPUT_PATH_ASRMIC, CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV, },
#endif
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP MuteOutPwl ={
HAL_IOMUX_PIN_P1_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_NOPULL
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg = {
HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg = {
HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg = {
HAL_IOMUX_PIN_NUM, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = {
HAL_IOMUX_PIN_P1_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE//HAL_IOMUX_PIN_P1_5 500:HAL_IOMUX_PIN_P2_5
};
/*
const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT ={
HAL_IOMUX_PIN_P1_5, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
*/
const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA ={
HAL_IOMUX_PIN_P2_1, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL ={
HAL_IOMUX_PIN_P2_0, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO, HAL_IOMUX_PIN_PULLUP_ENABLE
};
bool tgt_tws_get_channel_is_right(void)
{
#ifdef __FIXED_TWS_EAR_SIDE__
return TWS_EAR_SIDE_ROLE;
#else
return hal_gpio_pin_get_val((enum HAL_GPIO_PIN_T)cfg_hw_tws_channel_cfg.pin);
#endif
}
const IIR_CFG_T audio_eq_sw_iir_cfg = {
.gain0 = 0,
.gain1 = 0,
.num = 5,
.param = {
{IIR_TYPE_PEAK, .0, 200, 2},
{IIR_TYPE_PEAK, .0, 600, 2},
{IIR_TYPE_PEAK, .0, 2000.0, 2},
{IIR_TYPE_PEAK, .0, 6000.0, 2},
{IIR_TYPE_PEAK, .0, 12000.0, 2}
}
};
const IIR_CFG_T * const audio_eq_sw_iir_cfg_list[EQ_SW_IIR_LIST_NUM]={
&audio_eq_sw_iir_cfg,
};
const FIR_CFG_T audio_eq_hw_fir_cfg_44p1k = {
.gain = 0.0f,
.len = 384,
.coef =
{
(1<<23)-1,
}
};
const FIR_CFG_T audio_eq_hw_fir_cfg_48k = {
.gain = 0.0f,
.len = 384,
.coef =
{
(1<<23)-1,
}
};
const FIR_CFG_T audio_eq_hw_fir_cfg_96k = {
.gain = 0.0f,
.len = 384,
.coef =
{
(1<<23)-1,
}
};
const FIR_CFG_T * const audio_eq_hw_fir_cfg_list[EQ_HW_FIR_LIST_NUM]={
&audio_eq_hw_fir_cfg_44p1k,
&audio_eq_hw_fir_cfg_48k,
&audio_eq_hw_fir_cfg_96k,
};
//hardware dac iir eq
const IIR_CFG_T audio_eq_hw_dac_iir_cfg = {
.gain0 = 0,
.gain1 = 0,
.num = 8,
.param = {
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
{IIR_TYPE_PEAK, 0, 1000.0, 0.7},
}
};
const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_dac_iir_cfg_list[EQ_HW_DAC_IIR_LIST_NUM]={
&audio_eq_hw_dac_iir_cfg,
};
//hardware dac iir eq
const IIR_CFG_T audio_eq_hw_adc_iir_adc_cfg = {
.gain0 = 0,
.gain1 = 0,
.num = 1,
.param = {
{IIR_TYPE_PEAK, 0.0, 1000.0, 0.7},
}
};
const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_adc_iir_cfg_list[EQ_HW_ADC_IIR_LIST_NUM]={
&audio_eq_hw_adc_iir_adc_cfg,
};
//hardware iir eq
const IIR_CFG_T audio_eq_hw_iir_cfg = {
.gain0 = 0,
.gain1 = 0,
.num = 8,
.param = {
{IIR_TYPE_PEAK, -10.1, 100.0, 7},
{IIR_TYPE_PEAK, -10.1, 400.0, 7},
{IIR_TYPE_PEAK, -10.1, 700.0, 7},
{IIR_TYPE_PEAK, -10.1, 1000.0, 7},
{IIR_TYPE_PEAK, -10.1, 3000.0, 7},
{IIR_TYPE_PEAK, -10.1, 5000.0, 7},
{IIR_TYPE_PEAK, -10.1, 7000.0, 7},
{IIR_TYPE_PEAK, -10.1, 9000.0, 7},
}
};
const IIR_CFG_T * const POSSIBLY_UNUSED audio_eq_hw_iir_cfg_list[EQ_HW_IIR_LIST_NUM]={
&audio_eq_hw_iir_cfg,
};
const DrcConfig audio_drc_cfg = {
.knee = 3,
.filter_type = {14, -1},
.band_num = 2,
.look_ahead_time = 10,
.band_settings = {
{-20, 0, 2, 3, 3000, 1},
{-20, 0, 2, 3, 3000, 1},
}
};
const LimiterConfig audio_drc2_cfg = {
.knee = 2,
.look_ahead_time = 10,
.threshold = -20,
.makeup_gain = 19,
.ratio = 1000,
.attack_time = 3,
.release_time = 3000,
};
const SpectrumFixConfig audio_spectrum_cfg = {
.freq_num = 9,
.freq_list = {200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800},
};

View File

@ -0,0 +1,152 @@
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#ifndef __TGT_HARDWARE__
#define __TGT_HARDWARE__
#ifdef __cplusplus
extern "C" {
#endif
#include "hal_iomux.h"
#include "hal_gpio.h"
#include "hal_key.h"
#include "hal_aud.h"
//config hwardware codec iir.
#define EQ_HW_DAC_IIR_LIST_NUM 1
#define EQ_HW_ADC_IIR_LIST_NUM 1
#define EQ_HW_IIR_LIST_NUM 1
#define EQ_SW_IIR_LIST_NUM 1
#define EQ_HW_FIR_LIST_NUM 3
//pwl
#ifdef __BT_DEBUG_TPORTS__
#define CFG_HW_PLW_NUM (0)
#else
#ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__
#define CFG_HW_PLW_NUM (0)
#else
#define CFG_HW_PLW_NUM (2)
#endif
#endif
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PLW_NUM];
#ifdef __APP_USE_LED_INDICATE_IBRT_STATUS__
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_ibrt_indication_pinmux_pwl[3];
#endif
#ifdef __KNOWLES
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_pinmux_uart[2];
#endif
//adckey define
#define CFG_HW_ADCKEY_NUMBER 0
#define CFG_HW_ADCKEY_BASE 0
#define CFG_HW_ADCKEY_ADC_MAXVOLT 1000
#define CFG_HW_ADCKEY_ADC_MINVOLT 0
#define CFG_HW_ADCKEY_ADC_KEYVOLT_BASE 130
extern const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER];
#define BTA_AV_CO_SBC_MAX_BITPOOL 52
#ifdef __BT_DEBUG_TPORTS__
#ifdef TPORTS_KEY_COEXIST
#define CFG_HW_GPIOKEY_NUM (2)
#else
#define CFG_HW_GPIOKEY_NUM (0)
#endif
#else
//gpiokey define
#ifdef IS_MULTI_AI_ENABLED
#define CFG_HW_GPIOKEY_NUM (3)
#elif BES_AUDIO_DEV_Main_Board_9v0
#define CFG_HW_GPIOKEY_NUM (6)
#else
#define CFG_HW_GPIOKEY_NUM (1)
#endif
#endif
extern const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM];
// ANC function key
#define ANC_FUNCTION_KEY HAL_KEY_CODE_PWR
// ANC coefficient curve number
#define ANC_COEF_NUM (1)
//#define ANC_TALK_THROUGH
#ifdef ANC_TALK_THROUGH
#define ANC_COEF_LIST_NUM (ANC_COEF_NUM + 1)
#else
#define ANC_COEF_LIST_NUM (ANC_COEF_NUM)
#endif
#define ANC_FF_MIC_CH_L AUD_CHANNEL_MAP_CH0
#define ANC_FF_MIC_CH_R AUD_CHANNEL_MAP_CH1
#define ANC_FB_MIC_CH_L AUD_CHANNEL_MAP_CH2
#define ANC_FB_MIC_CH_R AUD_CHANNEL_MAP_CH3
// audio codec
#define CFG_HW_AUD_INPUT_PATH_NUM 3
extern const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM];
#define CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV (AUD_CHANNEL_MAP_CH0)
#define CFG_HW_AUD_SIDETONE_MIC_DEV (AUD_CHANNEL_MAP_CH0)
#define CFG_HW_AUD_SIDETONE_GAIN_DBVAL (-20)
//bt config
extern const char *BT_LOCAL_NAME;
extern const char *BLE_DEFAULT_NAME;
extern uint8_t ble_addr[6];
extern uint8_t bt_addr[6];
#define CODEC_SADC_VOL (12)
extern const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY];
//range -12~+12
#define CFG_HW_AUD_EQ_NUM_BANDS (8)
extern const int8_t cfg_aud_eq_sbc_band_settings[CFG_HW_AUD_EQ_NUM_BANDS];
#define CFG_AUD_EQ_IIR_NUM_BANDS (4)
//battery info
#define APP_BATTERY_MIN_MV (3200)
#define APP_BATTERY_PD_MV (3100)
#define APP_BATTERY_MAX_MV (4200)
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg;
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg;
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg;
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP MuteOutPwl;
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg;
//extern const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_INT;
extern bool tgt_tws_get_channel_is_right(void);
extern void app_mute_ctrl(bool Status);
extern void app_mutetimer_start();
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SDA;
extern const struct HAL_IOMUX_PIN_FUNCTION_MAP TOUCH_I2C_SCL;
#ifdef __cplusplus
}
#endif
#endif

8
download.sh Normal file
View File

@ -0,0 +1,8 @@
#! /bin/bash
num=$(ls -l /dev/ttyUSB* | rev | cut -c 1)
#num=5
echo com is:$num
sudo -S dldtool -c $num -f out/mic_alg/mic_alg.bin
sudo minicom port$num

View File

@ -43,9 +43,9 @@ typedef uint64_t GPIO_MAP_T;
typedef uint32_t GPIO_MAP_T; typedef uint32_t GPIO_MAP_T;
#endif #endif
#ifndef APP_TEST_MODE // #ifndef APP_TEST_MODE
#define CHECK_PWRKEY_AT_BOOT // #define CHECK_PWRKEY_AT_BOOT
#endif // #endif
#ifdef NO_PWRKEY #ifdef NO_PWRKEY
#undef CHECK_PWRKEY_AT_BOOT #undef CHECK_PWRKEY_AT_BOOT
#endif #endif

View File

@ -103,6 +103,8 @@ static void hal_trace_fault_handler(void);
#define TRACE_NEAR_FULL_THRESH 200 #define TRACE_NEAR_FULL_THRESH 200
#define TRACE_CRLF
#ifdef TRACE_CRLF #ifdef TRACE_CRLF
#define NEW_LINE_STR "\r\n" #define NEW_LINE_STR "\r\n"
#else #else
@ -1204,7 +1206,7 @@ int hal_trace_dump(const char *fmt, unsigned int size, unsigned int count, cons
case sizeof(uint16_t): case sizeof(uint16_t):
while(i<count && len<sizeof(buf)) while(i<count && len<sizeof(buf))
{ {
len += snprintf(&buf[len], sizeof(buf) - len, fmt, *(uint16_t *)((uint16_t *)buffer+i)); len += snprintf(&buf[len], sizeof(buf) - len, fmt, *(int16_t *)((int16_t *)buffer+i));
i++; i++;
} }
break; break;

View File

@ -117,7 +117,7 @@ extern void tws_playback_ticks_check_for_mix_prompt(void);
#define AF_STACK_SIZE (1024*10) #define AF_STACK_SIZE (1024*10)
#else #else
#ifndef AF_STACK_SIZE #ifndef AF_STACK_SIZE
#define AF_STACK_SIZE (1024*3) #define AF_STACK_SIZE (1024*8)
#endif #endif
#endif #endif

View File

@ -69,6 +69,7 @@ ccflags-y += \
-Iapps/anc/inc \ -Iapps/anc/inc \
-Iapps/key \ -Iapps/key \
-Iapps/main \ -Iapps/main \
-Iapps/mic_alg \
-Iapps/common \ -Iapps/common \
-Iapps/audioplayers \ -Iapps/audioplayers \
-Iapps/audioplayers/a2dp_decoder \ -Iapps/audioplayers/a2dp_decoder \

View File

@ -86,6 +86,12 @@
#include "audio_process.h" #include "audio_process.h"
#include "app_a2dp.h" #include "app_a2dp.h"
#include "audio_dump.h" #include "audio_dump.h"
#include "math.h"
#ifdef WL_DET
#include "app_mic_alg.h"
#endif
#if (A2DP_DECODER_VER == 2) #if (A2DP_DECODER_VER == 2)
#include "a2dp_decoder.h" #include "a2dp_decoder.h"
#endif #endif
@ -6000,6 +6006,11 @@ int bt_sco_player(bool on, enum APP_SYSFREQ_FREQ_T freq)
audio_prompt_stop_playing(); audio_prompt_stop_playing();
#endif #endif
#ifdef WL_DET
app_mic_alg_audioloop(false,APP_SYSFREQ_78M);
#endif
#if defined(IBRT) #if defined(IBRT)
app_ibrt_ui_rssi_reset(); app_ibrt_ui_rssi_reset();
app_ibrt_if_exec_sleep_hook_blocker_set(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO); app_ibrt_if_exec_sleep_hook_blocker_set(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO);
@ -6679,6 +6690,11 @@ int bt_sco_player(bool on, enum APP_SYSFREQ_FREQ_T freq)
app_ibrt_if_exec_sleep_hook_blocker_clr(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO); app_ibrt_if_exec_sleep_hook_blocker_clr(APP_IBRT_IF_SLEEP_HOOK_BLOCKER_HFP_SCO);
app_ibrt_ui_rssi_reset(); app_ibrt_ui_rssi_reset();
#endif #endif
#ifdef WL_DET
app_mic_alg_audioloop(true,APP_SYSFREQ_78M);
#endif
} }
isRun=on; isRun=on;

View File

@ -21,6 +21,10 @@
#include "app_bt_trace.h" #include "app_bt_trace.h"
#include "tgt_hardware.h" #include "tgt_hardware.h"
#ifdef WL_DET
#include "app_mic_alg.h"
#endif
#ifdef MEDIA_PLAYER_SUPPORT #ifdef MEDIA_PLAYER_SUPPORT
#include "hal_uart.h" #include "hal_uart.h"
@ -1273,6 +1277,11 @@ int app_play_audio_onoff(bool onoff, APP_AUDIO_STATUS* status)
return 0; return 0;
} }
if (onoff ) { if (onoff ) {
#ifdef WL_DET
app_mic_alg_audioloop(false,APP_SYSFREQ_78M);
#endif
#if defined(__AI_VOICE__)||defined(BISTO_ENABLED) #if defined(__AI_VOICE__)||defined(BISTO_ENABLED)
app_ai_if_inform_music_or_prompt_status(true, AUD_SAMPRATE_16000); app_ai_if_inform_music_or_prompt_status(true, AUD_SAMPRATE_16000);
app_ai_if_pre_music_or_prompt_check(); app_ai_if_pre_music_or_prompt_check();
@ -1475,6 +1484,9 @@ int app_play_audio_onoff(bool onoff, APP_AUDIO_STATUS* status)
app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START); app_thirdparty_specific_lib_event_handle(THIRDPARTY_FUNC_NO1,THIRDPARTY_START);
#endif #endif
#ifdef WL_DET
app_mic_alg_audioloop(true,APP_SYSFREQ_78M);
#endif
} }
isRun = onoff; isRun = onoff;

6
uart_log.sh Normal file
View File

@ -0,0 +1,6 @@
#! /bin/bash
num=$(ls -l /dev/ttyUSB* | rev | cut -c 1)
#num=1
echo $num
sudo minicom port$num