Skip to content

Commit dfdb3ad

Browse files
authored
Merge pull request #102 from pine64/anc-testing
ANC Support
2 parents 6c1f50f + 6a72642 commit dfdb3ad

File tree

13 files changed

+696
-403
lines changed

13 files changed

+696
-403
lines changed

apps/anc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ endif
2525

2626
ifeq ($(ANC_ASSIST_ENABLED),1)
2727
CFLAGS_app_anc.o += -DANC_ASSIST_ENABLED
28+
CFLAGS_anc_assist.o += -DANC_ASSIST_ENABLED
2829

2930
ifeq ($(ANC_ASSIST_WNR_ENABLED),1)
3031
CFLAGS_anc_assist.o += -DANC_ASSIST_WNR_ENABLED

apps/anc/src/app_anc.c

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
#endif
4848

4949
#include "co_math.h"
50-
//#define ANC_MODE_SWITCH_WITHOUT_FADE //Comment this line if you need fade
51-
// function between anc mode
50+
// #define ANC_MODE_SWITCH_WITHOUT_FADE //Comment this line if you need fade
51+
// function between anc mode
5252

5353
#ifndef _ANC_FADE_STACK_SIZE
5454
#define _ANC_FADE_STACK_SIZE (1 * 1024)
@@ -1060,31 +1060,41 @@ void app_anc_open_anc(void) {
10601060
capture_rate = anc_sample_rate[AUD_STREAM_CAPTURE];
10611061

10621062
pmu_anc_config(1);
1063-
1063+
int result = 0;
10641064
#ifdef ANC_FF_ENABLED
1065-
af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler);
1066-
anc_open(ANC_FEEDFORWARD);
1067-
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1068-
ANC_FEEDFORWARD, ANC_GAIN_DELAY);
1065+
result = af_anc_open(ANC_FEEDFORWARD, playback_rate, capture_rate, handler);
1066+
TRACE(2, "af_anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1067+
result = anc_open(ANC_FEEDFORWARD);
1068+
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1069+
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1070+
ANC_FEEDFORWARD, ANC_GAIN_DELAY);
1071+
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
10691072
#endif
10701073

10711074
#ifdef ANC_FB_ENABLED
1072-
af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler);
1073-
anc_open(ANC_FEEDBACK);
1074-
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1075-
ANC_FEEDBACK, ANC_GAIN_DELAY);
1075+
result = af_anc_open(ANC_FEEDBACK, playback_rate, capture_rate, handler);
1076+
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1077+
result = anc_open(ANC_FEEDBACK);
1078+
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1079+
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1080+
ANC_FEEDBACK, ANC_GAIN_DELAY);
1081+
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
10761082
#endif
10771083

10781084
#ifdef AUDIO_ANC_FB_MC_HW
1079-
anc_open(ANC_MUSICCANCLE);
1080-
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1081-
ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY);
1085+
result = anc_open(ANC_MUSICCANCLE);
1086+
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1087+
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1088+
ANC_MUSICCANCLE, ANC_GAIN_NO_DELAY);
1089+
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
10821090
#endif
10831091

10841092
#if defined(AUDIO_ANC_TT_HW)
10851093
anc_open(ANC_TALKTHRU);
1086-
anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1087-
ANC_TALKTHRU, ANC_GAIN_NO_DELAY);
1094+
TRACE(2, "anc_open %s %d -> %d\n", __FUNCTION__, __LINE__, result);
1095+
result = anc_select_coef(anc_sample_rate[AUD_STREAM_PLAYBACK], anc_coef_idx,
1096+
ANC_TALKTHRU, ANC_GAIN_NO_DELAY);
1097+
TRACE(2, "anc_select_coef %s %d -> %d\n", __FUNCTION__, __LINE__, result);
10881098
#endif
10891099

10901100
#ifdef AUDIO_ANC_FB_MC_HW
@@ -1521,13 +1531,6 @@ void app_anc_key(APP_KEY_STATUS *status, void *param) {
15211531
bool flag = app_anc_work_status();
15221532

15231533
#if defined(IBRT)
1524-
ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx();
1525-
1526-
TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role);
1527-
if (p_ibrt_ctrl->current_role == IBRT_SLAVE) {
1528-
app_anc_notify_master_to_exchange_coef(0, 0);
1529-
return;
1530-
}
15311534
app_anc_status_sync(!flag);
15321535
#endif
15331536
app_anc_status_post(!flag);

apps/main/key_handler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ void send_prev_track(void) {
118118
uint8_t action[] = {IBRT_ACTION_BACKWARD};
119119
app_ibrt_if_start_user_action(action, sizeof(action));
120120
}
121+
122+
void send_enable_disable_anc(void) {
123+
uint8_t action[] = {IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF};
124+
app_ibrt_if_start_user_action(action, sizeof(action));
125+
}
126+
121127
void app_key_single_tap(APP_KEY_STATUS *status, void *param) {
122128
TRACE(2, "%s event %d", __func__, status->event);
123129
/*
@@ -200,7 +206,7 @@ void app_key_long_press_down(APP_KEY_STATUS *status, void *param) {
200206
send_prev_track();
201207
} else {
202208
// Bud's are working as a pair
203-
app_anc_key(status, param);
209+
send_enable_disable_anc();
204210
}
205211
}
206212

config/open_source/target.mk

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ MBED ?= 0
77
RTOS ?= 1
88

99
#KERNEL ?= FREERTOS
10-
11-
NO_PWRKEY = 0 # We have powerkey input
10+
# We have powerkey input
11+
NO_PWRKEY = 0
1212
LIBC_ROM ?= 1
1313

14+
# Extas added by Open source community
15+
CONNECTED_BLUE_LIGHT = 1 # if set to 1, the blue light will flash when connected
16+
# end our extras
17+
1418
export USER_SECURE_BOOT ?= 0
1519
# enable:1
1620
# disable:0
@@ -54,25 +58,38 @@ export BT_DEBUG_TPORTS ?= 0
5458
TPORTS_KEY_COEXIST ?= 0
5559

5660
export SNIFF_MODE_CHECK ?= 0
57-
61+
# Merge L+R stream down to mono
5862
AUDIO_OUTPUT_MONO ?= 0
5963

6064
AUDIO_OUTPUT_DIFF ?= 0
6165

66+
# Raise mic bias from 2.2V to 3.3V
67+
DIGMIC_HIGH_VOLT ?= 0
68+
6269
#### ANC DEFINE START ######
6370
export ANC_APP ?= 1
71+
# Feed Forward ANC configuration (external mic)
6472
export ANC_FF_ENABLED ?= 1
73+
# Feed Backward ANC configuration (internal mic)
6574
export ANC_FB_ENABLED ?= 1
75+
# Wind noise reduction mode
76+
export ANC_WNR_ENABLED ?= 0
77+
78+
# Music cancel mode. Conflicts with audio resampling
6679
export AUDIO_ANC_FB_MC ?= 0
6780
export AUDIO_SECTION_SUPPT ?= 0
6881
export AUD_SECTION_STRUCT_VERSION ?= 2
82+
# Music cancel hardware?
6983
export AUDIO_ANC_FB_MC_HW ?=0
7084
export APP_ANC_KEY ?= 1
85+
# Feedback check for feedforward mic. Locked on due to blobs
7186
export ANC_FB_CHECK ?= 1
72-
##### ANC DEFINE END ######
73-
87+
# Build in ANC testing app (closed source)
7488
APP_ANC_TEST ?= 0
89+
export ANC_ASSIST_ENABLED ?= 0
90+
##### ANC DEFINE END ######
7591

92+
# Allow test commands via bluetooth
7693
TEST_OVER_THE_AIR ?= 0
7794

7895
HW_FIR_EQ_PROCESS ?= 0
@@ -93,7 +110,7 @@ PC_CMD_UART ?= 0
93110

94111
AUDIO_SECTION_ENABLE ?= 0
95112

96-
AUDIO_RESAMPLE ?= 1
113+
AUDIO_RESAMPLE ?= 0
97114

98115
RESAMPLE_ANY_SAMPLE_RATE ?= 1
99116

@@ -206,8 +223,8 @@ TILE_DATAPATH_ENABLED ?= 0
206223
CUSTOM_INFORMATION_TILE_ENABLE ?= 0
207224

208225
INTERCONNECTION ?= 0
209-
210-
INTERACTION ?= 0 # Looks like Find-My-Device support?
226+
# Looks like Find-My-Device support?
227+
INTERACTION ?= 0
211228

212229
INTERACTION_FASTPAIR ?= 0
213230

0 commit comments

Comments
 (0)