Compare commits

...

16 Commits

Author SHA1 Message Date
Rudis Muiznieks 0d1d09bda5
custom button mapping 2023-09-24 14:36:54 -05:00
Ben V. Brown c7372d21d2
Turn off resample for now (to avoid 56k profile) 2023-09-23 13:58:34 -05:00
Ben V. Brown 16cfcb1002
Port fb tuning values 2023-09-23 13:58:34 -05:00
Ben V. Brown 8e91ed7282
Update decoder 2023-09-23 13:58:34 -05:00
Ben V. Brown 9a747bdaad
Port some rough anc numbers from firmware dump 2023-09-23 13:58:34 -05:00
Ben V. Brown 94e2f92c29
Scratching debug tool for anc poking 2023-09-23 13:58:34 -05:00
Ben V. Brown 64e193ad66
Note WNR is off 2023-09-23 13:58:34 -05:00
Ben V. Brown 33fdf13003
Try higher gain for anc 2023-09-23 13:58:33 -05:00
Ben V. Brown 396ea8e2a7
Update target.mk 2023-09-23 13:58:33 -05:00
Ben V. Brown c5570b96ca
Update target.mk 2023-09-23 13:58:33 -05:00
Ben V. Brown 037cee323a
Update analog_best2300p.c 2023-09-23 13:58:33 -05:00
Ben V. Brown 0a82336258
Add logging to anc init 2023-09-23 13:58:33 -05:00
Ben V. Brown 5678f70284
Cant do inline comments on makefile target config 2023-09-23 13:58:33 -05:00
Ben V. Brown 399f466954
Make warning on no anc VMIC 2023-09-23 13:58:33 -05:00
Ben V. Brown 9c14484f09
Edit config for mics 2023-09-23 13:58:33 -05:00
Ben V. Brown 97c2a54186
Annotate config options 2023-09-23 13:58:29 -05:00
10 changed files with 666 additions and 386 deletions

View File

@ -47,8 +47,8 @@
#endif
#include "co_math.h"
//#define ANC_MODE_SWITCH_WITHOUT_FADE //Comment this line if you need fade
// function between anc mode
// #define ANC_MODE_SWITCH_WITHOUT_FADE //Comment this line if you need fade
// function between anc mode
#ifndef _ANC_FADE_STACK_SIZE
#define _ANC_FADE_STACK_SIZE (1 * 1024)
@ -1060,31 +1060,41 @@ void app_anc_open_anc(void) {
capture_rate = anc_sample_rate[AUD_STREAM_CAPTURE];
pmu_anc_config(1);
int result = 0;
#ifdef ANC_FF_ENABLED
af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler);
anc_open(ANC_FEEDFORWARD);
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_FEEDFORWARD, ANC_GAIN_DELAY);
result = af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler);
TRACE(2, "af_anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_open(ANC_FEEDFORWARD);
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_FEEDFORWARD, ANC_GAIN_DELAY);
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
#endif
#ifdef ANC_FB_ENABLED
af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler);
anc_open(ANC_FEEDBACK);
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_FEEDBACK, ANC_GAIN_DELAY);
result = af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler);
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_open(ANC_FEEDBACK);
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_FEEDBACK, ANC_GAIN_DELAY);
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
#endif
#ifdef AUDIO_ANC_FB_MC_HW
anc_open(ANC_MUSICCANCLE);
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY);
result = anc_open(ANC_MUSICCANCLE);
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY);
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
#endif
#if defined(AUDIO_ANC_TT_HW)
anc_open(ANC_TALKTHRU);
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_TALKTHRU, ANC_GAIN_NO_DELAY);
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
ANC_TALKTHRU, ANC_GAIN_NO_DELAY);
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
#endif
#ifdef AUDIO_ANC_FB_MC_HW

View File

@ -144,28 +144,7 @@ void app_key_double_tap(APP_KEY_STATUS *status, void *param) {
if (!app_tws_ibrt_tws_link_connected()) {
// No other bud paired
TRACE(0, "Handling %s in single bud mode", __func__);
send_next_track();
} else {
// Bud's are working as a pair
if (app_tws_is_left_side()) {
TRACE(0, "Handling %s as left bud", __func__);
// Lefty
send_prev_track();
} else {
TRACE(0, "Handling %s as right bud", __func__);
// Righty
send_next_track();
}
}
}
void app_key_triple_tap(APP_KEY_STATUS *status, void *param) {
TRACE(2, "%s event %d", __func__, status->event);
if (!app_tws_ibrt_tws_link_connected()) {
// No other bud paired
TRACE(0, "Handling %s in single bud mode", __func__);
send_vol_up();
send_vol_down();
} else {
// Bud's are working as a pair
if (app_tws_is_left_side()) {
@ -179,7 +158,28 @@ void app_key_triple_tap(APP_KEY_STATUS *status, void *param) {
}
}
}
void app_key_quad_tap(APP_KEY_STATUS *status, void *param) {
void app_key_triple_tap(APP_KEY_STATUS *status, void *param) {
TRACE(2, "%s event %d", __func__, status->event);
if (!app_tws_ibrt_tws_link_connected()) {
// No other bud paired
TRACE(0, "Handling %s in single bud mode", __func__);
send_vol_up();
}/* else {
// Bud's are working as a pair
if (app_tws_is_left_side()) {
TRACE(0, "Handling %s as left bud", __func__);
// Lefty
send_vol_down();
} else {
TRACE(0, "Handling %s as right bud", __func__);
// Righty
send_vol_up();
}
}*/
}
/*void app_key_quad_tap(APP_KEY_STATUS *status, void *param) {
TRACE(2, "%s event %d", __func__, status->event);
if (!app_tws_ibrt_tws_link_connected()) {
@ -196,7 +196,7 @@ void app_key_quad_tap(APP_KEY_STATUS *status, void *param) {
// Righty
}
}
}
}*/
void app_key_long_press_down(APP_KEY_STATUS *status, void *param) {
TRACE(2, "%s event %d", __func__, status->event);
@ -204,7 +204,7 @@ void app_key_long_press_down(APP_KEY_STATUS *status, void *param) {
if (!app_tws_ibrt_tws_link_connected()) {
// No other bud paired
TRACE(0, "Handling %s in single bud mode", __func__);
send_prev_track();
//send_prev_track();
} else {
// Bud's are working as a pair
app_anc_key(status, param);
@ -231,10 +231,10 @@ void app_key_init(void) {
"",
app_key_triple_tap,
NULL},
{{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK},
/*{{APP_KEY_CODE_PWR, APP_KEY_EVENT_ULTRACLICK},
"",
app_key_quad_tap,
NULL},
NULL},*/
{{APP_KEY_CODE_PWR, APP_KEY_EVENT_LONGPRESS},
"",
app_key_long_press_down,
@ -268,4 +268,4 @@ void app_key_init_on_charging(void) {
for (i = 0; i < (sizeof(key_cfg) / sizeof(APP_KEY_HANDLE)); i++) {
app_key_handle_registration(&key_cfg[i]);
}
}
}

View File

@ -7,8 +7,8 @@ MBED ?= 0
RTOS ?= 1
#KERNEL ?= FREERTOS
NO_PWRKEY = 0 # We have powerkey input
# We have powerkey input
NO_PWRKEY = 0
LIBC_ROM ?= 1
export USER_SECURE_BOOT ?= 0
@ -61,18 +61,26 @@ AUDIO_OUTPUT_DIFF ?= 0
#### ANC DEFINE START ######
export ANC_APP ?= 1
# Feed Forward ANC configuration (external mic)
export ANC_FF_ENABLED ?= 1
# Feed Backward ANC configuration (internal mic)
export ANC_FB_ENABLED ?= 1
export ANC_WNR_ENABLED ?= 0
export AUDIO_ANC_FB_MC ?= 0
export AUDIO_SECTION_SUPPT ?= 0
export AUD_SECTION_STRUCT_VERSION ?= 2
export AUDIO_ANC_FB_MC_HW ?=0
# Music cancel hardware?
export AUDIO_ANC_FB_MC_HW ?=1
export APP_ANC_KEY ?= 1
export ANC_FB_CHECK ?= 1
##### ANC DEFINE END ######
# Build in ANC testing app (closed source)
APP_ANC_TEST ?= 0
# Allow test commands via bluetooth
TEST_OVER_THE_AIR ?= 0
HW_FIR_EQ_PROCESS ?= 0
@ -93,7 +101,7 @@ PC_CMD_UART ?= 0
AUDIO_SECTION_ENABLE ?= 0
AUDIO_RESAMPLE ?= 1
AUDIO_RESAMPLE ?= 0
RESAMPLE_ANY_SAMPLE_RATE ?= 1
@ -206,8 +214,8 @@ TILE_DATAPATH_ENABLED ?= 0
CUSTOM_INFORMATION_TILE_ENABLE ?= 0
INTERCONNECTION ?= 0
INTERACTION ?= 0 # Looks like Find-My-Device support?
# Looks like Find-My-Device support?
INTERACTION ?= 0
INTERACTION_FASTPAIR ?= 0

View File

@ -104,7 +104,7 @@ const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM] = {
// bt config
// const char *BT_LOCAL_NAME = TO_STRING(BT_DEV_NAME) "\0";
const char *BT_LOCAL_NAME = "PineBuds Pro";
const char *BLE_DEFAULT_NAME = "BES_BLE";
const char *BLE_DEFAULT_NAME = "PineBuds Pro BLE";
uint8_t ble_addr[6] = {
#ifdef BLE_DEV_ADDR
BLE_DEV_ADDR
@ -122,6 +122,7 @@ uint8_t bt_addr[6] = {
#endif
};
/// True Wireless side configuration using resistor fitment
const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_tws_channel_cfg = {
HAL_IOMUX_PIN_P1_4, HAL_IOMUX_FUNC_AS_GPIO, HAL_IOMUX_PIN_VOLTAGE_VIO,
HAL_IOMUX_PIN_PULLUP_ENABLE};
@ -159,21 +160,22 @@ const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = {
{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_CH4 | AUD_VMIC_MAP_VMIC3)
#endif
// MIC and channel configurations
// Pinebuds pro have the following mic's and biases
/*
* User Voice (Talking) = MIC5 input and VMIC3 Bias
* ANC Feed Forward = MIC1 input and VMIC2 Bias
* ANC Feed Backward = MIC3 input and VMIC2 Bias
*
* Note that AUD_CHANNEL_MAP is offset by 1 (0 start)
*/
#define USER_TALK_MIC AUD_CHANNEL_MAP_CH4
#define USER_TALK_VMIC_CFG AUD_VMIC_MAP_VMIC3
#define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV (USER_TALK_MIC | USER_TALK_VMIC_CFG)
#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)
@ -184,32 +186,23 @@ const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY] = {
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,
CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV,
},
#ifdef VOICE_DETECTOR_EN
{
AUD_INPUT_PATH_VADMIC,
CFG_HW_AUD_INPUT_PATH_VADMIC_DEV,
CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV,
},
#else
{
AUD_INPUT_PATH_ASRMIC,
CFG_HW_AUD_INPUT_PATH_ASRMIC_DEV,
CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV,
},
#endif
};
@ -233,28 +226,18 @@ 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
// };
#define IIR_COUNTER_FF_L (6)
#define IIR_COUNTER_FF_R (6)
#define IIR_COUNTER_FB_L (5)
#define IIR_COUNTER_FB_R (5)
#define IIR_COUNTER_FF_L (8)
#define IIR_COUNTER_FF_R (8)
#define IIR_COUNTER_FB_L (6)
#define IIR_COUNTER_FB_R (6)
static const struct_anc_cfg POSSIBLY_UNUSED
AncFirCoef_50p7k_mode0 =
{
.anc_cfg_ff_l =
{
// .total_gain = 440,
.total_gain = 350,
.total_gain = 440,
// .total_gain = 350,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_L,
@ -285,12 +268,12 @@ static const struct_anc_cfg POSSIBLY_UNUSED
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
.anc_cfg_ff_r =
{
// .total_gain = 382,
.total_gain = 350,
.total_gain = 382,
// .total_gain = 350,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_R,
@ -321,7 +304,7 @@ static const struct_anc_cfg POSSIBLY_UNUSED
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
/*
@ -375,7 +358,7 @@ static const struct_anc_cfg POSSIBLY_UNUSED
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
.anc_cfg_fb_r =
{
@ -410,75 +393,51 @@ static const struct_anc_cfg POSSIBLY_UNUSED
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
};
/*
//ff
Filter1_B=[ 42463913, -84860822, 42396935];
Filter1_A=[ 134217728, -268353516, 134135801];
Filter2_B=[ 136002894, -267154076, 131168209];
Filter2_A=[ 134217728, -267154076, 132953376];
Filter3_B=[ 132863566, -263674901, 130888668];
Filter3_A=[ 134217728, -263674901, 129534506];
Filter4_B=[ 131621817, -256639526, 125746382];
Filter4_A=[ 134217728, -256639526, 123150471];
*/
static const struct_anc_cfg POSSIBLY_UNUSED
AncFirCoef_48k_mode0 =
{
.anc_cfg_ff_l =
{
// .total_gain = 440,
.total_gain = 312,
.total_gain = 302,
// .total_gain = 312,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_L,
.iir_coef[0].coef_b = {42463913, -84860822, 42396935},
.iir_coef[0].coef_a = {134217728, -268353516, 134135801},
.iir_coef[0].coef_b = {47756600, -94784525, 47030952},
.iir_coef[0].coef_a = {134217728, -267141655, 132927324},
.iir_coef[1].coef_b = {136002894, -267154076, 131168209},
.iir_coef[1].coef_a = {134217728, -267154076, 132953376},
.iir_coef[1].coef_b = {95026235, -189959646, 94933615},
.iir_coef[1].coef_a = {134217728, -268325174, 134107649},
.iir_coef[2].coef_b = {132863566, -263674901, 130888668},
.iir_coef[2].coef_a = {134217728, -263674901, 129534506},
.iir_coef[2].coef_b = {137182418, -258280236, 121193611},
.iir_coef[2].coef_a = {134217728, -258309065, 124129473},
.iir_coef[3].coef_b = {131621817, -256639526, 125746382},
.iir_coef[3].coef_a = {134217728, -256639526, 123150471},
.iir_coef[3].coef_b = {119863779, -218243094, 100875648},
.iir_coef[3].coef_a = {134217728, -218243094, 86521699},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[4].coef_b = {118677290, -210108781, 98119610},
.iir_coef[4].coef_a = {134217728, -210108781, 82579171},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {133493787, -264941439, 131633425},
.iir_coef[5].coef_a = {134217728, -264941439, 130909484},
.iir_coef[6].coef_b = {134779906, -266962984, 132210881},
.iir_coef[6].coef_a = {134217728, -266962984, 132773059},
.iir_coef[7].coef_b = {134235269, -268350403, 134115242},
.iir_coef[7].coef_a = {134217728, -268350430, 134132755},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = -24,
},
.anc_cfg_ff_r =
{
// .total_gain = 382,
.total_gain = 288,
.total_gain = 382,
// .total_gain = 288,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_R,
@ -508,60 +467,36 @@ static const struct_anc_cfg POSSIBLY_UNUSED
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
/*
Filter1_B=[ 27172676, -53803459, 26691412];
Filter1_A=[ 134217728, -214195429, 80219070];
Filter2_B=[ 138529480, -267551490, 129040578];
Filter2_A=[ 134217728, -267551490, 133352330];
Filter3_B=[ 134516353, -268162980, 133647489];
Filter3_A=[ 134217728, -268162980, 133946114];
Filter4_B=[ 133595549, -264581113, 131087955];
Filter4_A=[ 134217728, -264581113, 130465777];
*/
.anc_cfg_fb_l =
{
.total_gain = 511,
.total_gain = 512,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FB_L,
.iir_coef[0].coef_b = {27172676, -53803459, 26691412},
.iir_coef[0].coef_a = {134217728, -214195429, 80219070},
.iir_coef[0].coef_b = {75662976, -150466868, 74809339},
.iir_coef[0].coef_a = {134217728, -267572133, 133364091},
.iir_coef[1].coef_b = {138529480, -267551490, 129040578},
.iir_coef[1].coef_a = {134217728, -267551490, 133352330},
.iir_coef[1].coef_b = {136259446, -267048746, 130806222},
.iir_coef[1].coef_a = {134217728, -267048746, 132847940},
.iir_coef[2].coef_b = {134516353, -268162980, 133647489},
.iir_coef[2].coef_a = {134217728, -268162980, 133946114},
.iir_coef[2].coef_b = {134365088, -267930698, 133570324},
.iir_coef[2].coef_a = {134217728, -267932117, 133716266},
.iir_coef[3].coef_b = {133595549, -264581113, 131087955},
.iir_coef[3].coef_a = {134217728, -264581113, 130465777},
.iir_coef[3].coef_b = {124587325, -241835594, 118126292},
.iir_coef[3].coef_a = {134217728, -241835594, 108495889},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[4].coef_b = {130235205, -255036797, 124966921},
.iir_coef[4].coef_a = {134217728, -255036797, 120984398},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {134327171, -268333985, 134007055},
.iir_coef[5].coef_a = {134217728, -268333985, 134116498},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = -24,
},
.anc_cfg_fb_r =
{
@ -596,7 +531,7 @@ static const struct_anc_cfg POSSIBLY_UNUSED
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
#if (AUD_SECTION_STRUCT_VERSION == 2)
@ -675,7 +610,7 @@ static const struct_anc_cfg POSSIBLY_UNUSED
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
.anc_cfg_mc_r =
{
@ -703,269 +638,321 @@ static const struct_anc_cfg POSSIBLY_UNUSED
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
.adc_gain_offset = (2) * 4,
},
#endif
};
/*
//ff
Filter1_B=[ 42465729, -84858529, 42392831];
Filter1_A=[ 134217728, -268346271, 134128558];
Filter2_B=[ 136159949, -267039705, 130899919];
Filter2_A=[ 134217728, -267039705, 132842140];
Filter3_B=[ 132746107, -263254540, 130599907];
Filter3_A=[ 134217728, -263254540, 129128286];
Filter4_B=[ 131402980, -255575175, 125032243];
Filter4_A=[ 134217728, -255575175, 122217496];
*/
static const struct_anc_cfg POSSIBLY_UNUSED
AncFirCoef_44p1k_mode0 =
{
.anc_cfg_ff_l =
{
// .total_gain = 440,
.total_gain = 312,
AncFirCoef_44p1k_mode0 = {
.anc_cfg_ff_l =
{
.total_gain = 512,
// .total_gain = 312,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_L,
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_L,
.iir_coef[0].coef_b = {42465729, -84858529, 42392831},
.iir_coef[0].coef_a = {134217728, -268346271, 134128558},
.iir_coef[0].coef_b = {47768463, -94743857, 46978979},
.iir_coef[0].coef_a = {134217728, -267027510, 132813804},
.iir_coef[1].coef_b = {136159949, -267039705, 130899919},
.iir_coef[1].coef_a = {134217728, -267039705, 132842140},
.iir_coef[1].coef_b = {95026887, -189952726, 94926080},
.iir_coef[1].coef_a = {134217728, -268315406, 134097919},
.iir_coef[2].coef_b = {132746107, -263254540, 130599907},
.iir_coef[2].coef_a = {134217728, -263254540, 129128286},
.iir_coef[2].coef_b = {137435276, -257412413, 120090247},
.iir_coef[2].coef_a = {134217728, -257446453, 123273755},
.iir_coef[3].coef_b = {131402980, -255575175, 125032243},
.iir_coef[3].coef_a = {134217728, -255575175, 122217496},
.iir_coef[3].coef_b = {118844778, -214442434, 98508661},
.iir_coef[3].coef_a = {134217728, -214442434, 83135711},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[4].coef_b = {117611223, -205468073, 95643298},
.iir_coef[4].coef_a = {134217728, -205468073, 79036793},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {133430657, -264618880, 131408063},
.iir_coef[5].coef_a = {134217728, -264618880, 130620992},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.anc_cfg_ff_r =
{
// .total_gain = 382,
.total_gain = 288,
.iir_coef[6].coef_b = {134829328, -266830863, 132034457},
.iir_coef[6].coef_a = {134217728, -266830863, 132646057},
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_R,
.iir_coef[7].coef_b = {134236821, -268342876, 134106183},
.iir_coef[7].coef_a = {134217728, -268342908, 134125243},
.iir_coef[0].coef_b = {42465729, -84858529, 42392831},
.iir_coef[0].coef_a = {134217728, -268346271, 134128558},
// .fir_bypass_flag = 0,
// .fir_len = AUD_COEF_LEN,
// .fir_coef =
// {
// 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, -6144, 0, 0, 0,
// 1, 0, 2048, -13511, -4060, -9831, 2011, 0,
// 2048, -13511, -4060, -9831, 2011, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, -6144, 512, 0, 0, 6, -14642,
// 1154, -18440, -2296, -26004, 1140, 0, 2048,
// 22833, -4082, -11362, 2033, -6957, 2081, 2958,
// -4073, 24038, 1991, 0, 2048, 2958, -4073,
// 17081, 2025, 29362, 2050, 25335, -4088, 16424,
// 2037, 0, 2048, 23654, -4088, -21431, 2039,
// 28309, 1889, 16812, -3657, 3193, 1783, 0, 2048,
// 16812, -3657, 31503, 1624, 9636, 1982, -13421,
// -3875, 2188, 1895, 0, 2048, -13421, -3875,
// 11824, 1829, -11954, 2049, -20607, -4095, -32689,
// 2044, 0, 2048, -20607, -4095, 20894, 2046, 0,
// 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, -6144, 0,
// 0, 0, 1, 0, 2048, -13511, -4060,
// -9831, 2011, 0, 2048, -13511, -4060, -9831,
// 2011, 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0, 0,
// },
.reserved_for_drc =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
},
.dac_gain_offset = 0,
.adc_gain_offset = -24,
},
.anc_cfg_ff_r =
{
.total_gain = 382,
// .total_gain = 288,
.iir_coef[1].coef_b = {136159949, -267039705, 130899919},
.iir_coef[1].coef_a = {134217728, -267039705, 132842140},
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FF_R,
.iir_coef[2].coef_b = {132746107, -263254540, 130599907},
.iir_coef[2].coef_a = {134217728, -263254540, 129128286},
.iir_coef[0].coef_b = {42465729, -84858529, 42392831},
.iir_coef[0].coef_a = {134217728, -268346271, 134128558},
.iir_coef[3].coef_b = {131402980, -255575175, 125032243},
.iir_coef[3].coef_a = {134217728, -255575175, 122217496},
.iir_coef[1].coef_b = {136159949, -267039705, 130899919},
.iir_coef[1].coef_a = {134217728, -267039705, 132842140},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[2].coef_b = {132746107, -263254540, 130599907},
.iir_coef[2].coef_a = {134217728, -263254540, 129128286},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[3].coef_b = {131402980, -255575175, 125032243},
.iir_coef[3].coef_a = {134217728, -255575175, 122217496},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
/*
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
Filter1_B=[ 26719020, -52852829, 26204379];
Filter1_A=[ 134217728, -210410903, 76474119];
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (2) * 4,
},
Filter2_B=[ 138909433, -267471808, 128584365];
Filter2_A=[ 134217728, -267471808, 133276071];
/*
Filter3_B=[ 134542733, -268138827, 133597115];
Filter3_A=[ 134217728, -268138827, 133922120];
Filter1_B=[ 26719020, -52852829, 26204379];
Filter1_A=[ 134217728, -210410903, 76474119];
Filter4_B=[ 133541379, -264235686, 130815458];
Filter4_A=[ 134217728, -264235686, 130139109];
Filter2_B=[ 138909433, -267471808, 128584365];
Filter2_A=[ 134217728, -267471808, 133276071];
*/
Filter3_B=[ 134542733, -268138827, 133597115];
Filter3_A=[ 134217728, -268138827, 133922120];
.anc_cfg_fb_l =
{
.total_gain = 511,
Filter4_B=[ 133541379, -264235686, 130815458];
Filter4_A=[ 134217728, -264235686, 130139109];
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FB_L,
*/
.iir_coef[0].coef_b = {26719020, -52852829, 26204379},
.iir_coef[0].coef_a = {134217728, -210410903, 76474119},
.anc_cfg_fb_l =
{
.total_gain = 512,
.iir_coef[1].coef_b = {138909433, -267471808, 128584365},
.iir_coef[1].coef_a = {134217728, -267471808, 133276071},
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FB_L,
.iir_coef[2].coef_b = {134542733, -268138827, 133597115},
.iir_coef[2].coef_a = {134217728, -268138827, 133922120},
.iir_coef[0].coef_b = {75679438, -150423560, 74750572},
.iir_coef[0].coef_a = {134217728, -267495119, 133288862},
.iir_coef[3].coef_b = {133541379, -264235686, 130815458},
.iir_coef[3].coef_a = {134217728, -264235686, 130139109},
.iir_coef[1].coef_b = {136438995, -266925170, 130506214},
.iir_coef[1].coef_a = {134217728, -266925170, 132727481},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[2].coef_b = {134378162, -267885833, 133513256},
.iir_coef[2].coef_a = {134217728, -267887514, 133672009},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[3].coef_b = {123825813, -239648340, 116853881},
.iir_coef[3].coef_a = {134217728, -239648340, 106461967},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.anc_cfg_fb_r =
{
.total_gain = 511,
.iir_coef[4].coef_b = {129901988, -253899885, 124192908},
.iir_coef[4].coef_a = {134217728, -253899885, 119877168},
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FB_R,
.iir_coef[5].coef_b = {134336846, -268324991, 133988431},
.iir_coef[5].coef_a = {134217728, -268324991, 134107550},
.iir_coef[0].coef_b = {26719020, -52852829, 26204379},
.iir_coef[0].coef_a = {134217728, -210410903, 76474119},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = -24,
},
.anc_cfg_fb_r =
{
.total_gain = 511,
.iir_coef[1].coef_b = {138909433, -267471808, 128584365},
.iir_coef[1].coef_a = {134217728, -267471808, 133276071},
.iir_bypass_flag = 0,
.iir_counter = IIR_COUNTER_FB_R,
.iir_coef[2].coef_b = {134542733, -268138827, 133597115},
.iir_coef[2].coef_a = {134217728, -268138827, 133922120},
.iir_coef[0].coef_b = {26719020, -52852829, 26204379},
.iir_coef[0].coef_a = {134217728, -210410903, 76474119},
.iir_coef[3].coef_b = {133541379, -264235686, 130815458},
.iir_coef[3].coef_a = {134217728, -264235686, 130139109},
.iir_coef[1].coef_b = {138909433, -267471808, 128584365},
.iir_coef[1].coef_a = {134217728, -267471808, 133276071},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[2].coef_b = {134542733, -268138827, 133597115},
.iir_coef[2].coef_a = {134217728, -268138827, 133922120},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[3].coef_b = {133541379, -264235686, 130815458},
.iir_coef[3].coef_a = {134217728, -264235686, 130139109},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.iir_coef[4].coef_b = {0x8000000, 0, 0},
.iir_coef[4].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
/* .fir_bypass_flag=1,
.fir_len = AUD_COEF_LEN,
.fir_coef =
{
32767,
},
*/
.dac_gain_offset = 0,
.adc_gain_offset = (2) * 4,
},
#if (AUD_SECTION_STRUCT_VERSION == 2)
/*
/*
Filter1_B=[ 19847881, -39594823, 19747071];
Filter1_A=[ 16777216, -33314517, 16538159];
Filter1_B=[ 19847881, -39594823, 19747071];
Filter1_A=[ 16777216, -33314517, 16538159];
Filter2_B=[ 9442890, -16603187, 7330251];
Filter2_A=[ 16777216, -16603187, -4075];
Filter2_B=[ 9442890, -16603187, 7330251];
Filter2_A=[ 16777216, -16603187, -4075];
Filter3_B=[ 18107639, -32779315, 14701642];
Filter3_A=[ 16777216, -32779315, 16032065];
Filter3_B=[ 18107639, -32779315, 14701642];
Filter3_A=[ 16777216, -32779315, 16032065];
Filter4_B=[ 12666347, -24058210, 11437046];
Filter4_A=[ 16777216, -32089673, 15357640];
Filter4_B=[ 12666347, -24058210, 11437046];
Filter4_A=[ 16777216, -32089673, 15357640];
Filter5_B=[ 16466312, -31915122, 15523589];
Filter5_A=[ 16777216, -31915122, 15212684];
*/
Filter5_B=[ 16466312, -31915122, 15523589];
Filter5_A=[ 16777216, -31915122, 15212684];
*/
.anc_cfg_mc_l =
{
.total_gain = 1228,
.anc_cfg_mc_l =
{
.total_gain = 1228,
.iir_bypass_flag = 0,
.iir_counter = 5,
.iir_bypass_flag = 0,
.iir_counter = 5,
.iir_coef[0].coef_b = {19847881, -39594823, 19747071},
.iir_coef[0].coef_a = {16777216, -33314517, 16538159},
.iir_coef[0].coef_b = {19847881, -39594823, 19747071},
.iir_coef[0].coef_a = {16777216, -33314517, 16538159},
.iir_coef[1].coef_b = {9442890, -16603187, 7330251},
.iir_coef[1].coef_a = {16777216, -16603187, -4075},
.iir_coef[1].coef_b = {9442890, -16603187, 7330251},
.iir_coef[1].coef_a = {16777216, -16603187, -4075},
.iir_coef[2].coef_b = {18107639, -32779315, 14701642},
.iir_coef[2].coef_a = {16777216, -32779315, 16032065},
.iir_coef[2].coef_b = {18107639, -32779315, 14701642},
.iir_coef[2].coef_a = {16777216, -32779315, 16032065},
.iir_coef[3].coef_b = {12666347, -24058210, 11437046},
.iir_coef[3].coef_a = {16777216, -32089673, 15357640},
.iir_coef[3].coef_b = {12666347, -24058210, 11437046},
.iir_coef[3].coef_a = {16777216, -32089673, 15357640},
.iir_coef[4].coef_b = {16466312, -31915122, 15523589},
.iir_coef[4].coef_a = {16777216, -31915122, 15212684},
.iir_coef[4].coef_b = {16466312, -31915122, 15523589},
.iir_coef[4].coef_a = {16777216, -31915122, 15212684},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.anc_cfg_mc_r =
{
.total_gain = 1331,
.dac_gain_offset = 0,
.adc_gain_offset = (2) * 4,
},
.anc_cfg_mc_r =
{
.total_gain = 1331,
.iir_bypass_flag = 0,
.iir_counter = 5,
.iir_bypass_flag = 0,
.iir_counter = 5,
.iir_coef[0].coef_b = {19847881, -39594823, 19747071},
.iir_coef[0].coef_a = {16777216, -33314517, 16538159},
.iir_coef[0].coef_b = {19847881, -39594823, 19747071},
.iir_coef[0].coef_a = {16777216, -33314517, 16538159},
.iir_coef[1].coef_b = {9442890, -16603187, 7330251},
.iir_coef[1].coef_a = {16777216, -16603187, -4075},
.iir_coef[1].coef_b = {9442890, -16603187, 7330251},
.iir_coef[1].coef_a = {16777216, -16603187, -4075},
.iir_coef[2].coef_b = {18107639, -32779315, 14701642},
.iir_coef[2].coef_a = {16777216, -32779315, 16032065},
.iir_coef[2].coef_b = {18107639, -32779315, 14701642},
.iir_coef[2].coef_a = {16777216, -32779315, 16032065},
.iir_coef[3].coef_b = {12666347, -24058210, 11437046},
.iir_coef[3].coef_a = {16777216, -32089673, 15357640},
.iir_coef[3].coef_b = {12666347, -24058210, 11437046},
.iir_coef[3].coef_a = {16777216, -32089673, 15357640},
.iir_coef[4].coef_b = {16466312, -31915122, 15523589},
.iir_coef[4].coef_a = {16777216, -31915122, 15212684},
.iir_coef[4].coef_b = {16466312, -31915122, 15523589},
.iir_coef[4].coef_a = {16777216, -31915122, 15212684},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.iir_coef[5].coef_b = {0x8000000, 0, 0},
.iir_coef[5].coef_a = {0x8000000, 0, 0},
.dac_gain_offset = 0,
.adc_gain_offset = (0) * 4,
},
.dac_gain_offset = 0,
.adc_gain_offset = (2) * 4,
},
#endif
};

View File

@ -96,10 +96,25 @@ extern const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM
#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
// MIC and channel configurations
// Pinebuds pro have the following mic's and biases
/*
* User Voice (Talking) = MIC5 input and VMIC3 Bias
* ANC Feed Forward = MIC1 input and VMIC2 Bias
* ANC Feed Backward = MIC3 input and VMIC2 Bias
*
* Note that AUD_CHANNEL_MAP is offset by 1 (0 start)
*/
#define ANC_FF_MIC AUD_CHANNEL_MAP_CH0
#define ANC_FB_MIC AUD_CHANNEL_MAP_CH2
#define ANC_FF_MIC_CH_L ANC_FF_MIC
#define ANC_FF_MIC_CH_R 0
#define ANC_FB_MIC_CH_L ANC_FB_MIC
#define ANC_FB_MIC_CH_R 0
#define ANC_VMIC_CFG AUD_VMIC_MAP_VMIC2
// audio codec
#define CFG_HW_AUD_INPUT_PATH_NUM 3
@ -107,7 +122,7 @@ extern const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_
#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_MIC_DEV (AUD_CHANNEL_MAP_CH4)
#define CFG_HW_AUD_SIDETONE_GAIN_DBVAL (-20)
//bt config
@ -139,8 +154,6 @@ extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator
extern bool tgt_tws_get_channel_is_right(void);
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

1
dev_tools/anc_decoder/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

119
dev_tools/anc_decoder/Cargo.lock generated Normal file
View File

@ -0,0 +1,119 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anc_decoder"
version = "0.1.0"
dependencies = [
"declio",
]
[[package]]
name = "darling"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "declio"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae2d0ab09a05314050f1b66e78c2497af54dad2335e15b815f208d1594c85264"
dependencies = [
"declio_derive",
]
[[package]]
name = "declio_derive"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eb284008990d1298ed56c741ca8823481789d72ff055031bf21ceaeb61c0053"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "proc-macro2"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
dependencies = [
"proc-macro2",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73"

View File

@ -0,0 +1,9 @@
[package]
name = "anc_decoder"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
declio = "0.2.0"

View File

@ -0,0 +1,132 @@
use declio::ctx::Endian;
use declio::{Decode, Encode};
use std::fs::File;
use std::io::Read;
//Super experimental dumb tooling for parsing out the ANC data
// This is not production code, expect panics
const AUDIO_START: usize = 0x003EE000;
const AUDIO_LEN: usize = 16;
const AUD_IIR_NUM: usize = 8;
const AUD_COEF_LEN: usize = 0;
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct AudSectionHead {
#[declio(ctx = "Endian::Little")]
magic: u16,
#[declio(ctx = "Endian::Little")]
vesrion: u16,
#[declio(ctx = "Endian::Little")]
crc: u32,
#[declio(ctx = "Endian::Little")]
reserved0: u32,
#[declio(ctx = "Endian::Little")]
reserved1: u32,
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct AudSectionBodyIdent {
anc_ver: [u8; 16], // These are actually char* but honestly doesnt matter as seem to always be 0x00
batch_info: [u8; 16], // These are actually char* but honestly doesnt matter as seem to always be 0x00
serial: [u8; 16], // These are actually char* but honestly doesnt matter as seem to always be 0x00
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct anc_iir_coefs {
#[declio(ctx = "Endian::Little")]
coef_b: [i32; 3],
#[declio(ctx = "Endian::Little")]
coef_a: [i32; 3],
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct aud_item {
#[declio(ctx = "Endian::Little")]
total_gain: u32,
#[declio(ctx = "Endian::Little")]
iir_bypass_flag: u16,
#[declio(ctx = "Endian::Little")]
iir_counter: u16,
iir_coef: [anc_iir_coefs; AUD_IIR_NUM],
// #if (AUD_SECTION_STRUCT_VERSION == 1)
// #[declio(ctx = "Endian::Little")]
// fir_bypass_flag: u16,
// #[declio(ctx = "Endian::Little")]
// fir_len: u16,
// #[declio(ctx = "Endian::Little")]
// fir_coef: [i16; AUD_COEF_LEN],
// pos_tab: [i8; 16],
// #elif (AUD_SECTION_STRUCT_VERSION == 2)
#[declio(ctx = "Endian::Little")]
reserved_for_drc: [u32; 32],
// #elif (AUD_SECTION_STRUCT_VERSION == 3)
// #endif
#[declio(ctx = "Endian::Little")]
reserved1: i16,
dac_gain_offset: i8, // in qdb (quater of dB)
adc_gain_offset: i8, // in qdb (quater of dB)
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct struct_anc_cfg {
//V1+
anc_cfg_ff_l: aud_item,
anc_cfg_ff_r: aud_item,
anc_cfg_fb_l: aud_item,
anc_cfg_fb_r: aud_item,
//V2
anc_cfg_tt_l: aud_item,
anc_cfg_tt_r: aud_item,
anc_cfg_mc_l: aud_item,
anc_cfg_mc_r: aud_item,
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct pctool_struct_anc_cfg {
//
anc_cfg: [struct_anc_cfg; 2], //0 == 41k, 2==44k
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct AudSectionBodyConfig {
anc_config_arr: [pctool_struct_anc_cfg; 1], // we may only use first of 4 entries
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct AudSectionBody {
anc_ident: AudSectionBodyIdent,
anc_config: AudSectionBodyConfig,
}
#[derive(Debug, PartialEq, Encode, Decode, Copy, Clone, Default)]
struct PctoolAudSection {
header: AudSectionHead,
body: AudSectionBody,
}
fn main() {
println!("Super dumb anc firmware details dumper");
println!("By Ralim <ralim@ralimtek.com>");
println!("Reading firmware.bin");
let file_contents = get_firmware_file("firmware.bin");
println!("Running decoder");
let dummy_init: PctoolAudSection = PctoolAudSection::default();
let dummy_serialised = declio::to_bytes(dummy_init).unwrap();
let decoded: PctoolAudSection =
declio::from_bytes(&file_contents[AUDIO_START..AUDIO_START + dummy_serialised.len()])
.expect("decode failed");
println!("Decoded {:#?}", decoded)
}
fn get_firmware_file(filename: &str) -> Vec<u8> {
let mut f = File::open(&filename).expect("no file found");
let mut buffer = Vec::new();
// read the whole file
f.read_to_end(&mut buffer).expect("could not read file");
buffer
}

View File

@ -123,6 +123,7 @@
#endif
#ifndef ANC_VMIC_CFG
#error "No ANC VMIC configured"
#define ANC_VMIC_CFG (AUD_VMIC_MAP_VMIC1)
#endif