Skip to content

Commit

Permalink
Merge branch 'feature/update_es7210_drvier' into 'master'
Browse files Browse the repository at this point in the history
audio_hal: update es7210 driver

See merge request adf/esp-adf-internal!1199
  • Loading branch information
jason-mao committed Aug 8, 2024
2 parents 9b44e1a + ebb804b commit 89226fa
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 217 deletions.
19 changes: 9 additions & 10 deletions components/audio_board/esp32_s2_kaluga_1_v1_2/board_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,17 @@
#define ESP_SD_PIN_D0 -1
#define ESP_SD_PIN_D3 -1


/**
* @brief Audio Codec Chip Function Definition
* @brief Audio Codec Chip Function Definition
*/
#define FUNC_AUDIO_CODEC_EN (1)
#define PA_ENABLE_GPIO 10
#define ES8311_MCLK_SOURCE 1 /* 0 From MCLK, 1 From BCLK */
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (16) /* 16bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (false)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define FUNC_AUDIO_CODEC_EN (1)
#define PA_ENABLE_GPIO (10)
#define ES8311_MCLK_SOURCE (1) /* 0 From MCLK, 1 From BCLK */
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (16) /* 16bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (false)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */

extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE;
#define AUDIO_CODEC_DEFAULT_CONFIG(){ \
Expand Down
1 change: 1 addition & 0 deletions components/audio_board/esp32_s3_box/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ audio_board_handle_t audio_board_init(void)
audio_hal_handle_t audio_board_adc_init(void)
{
audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG();
audio_codec_cfg.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE;
audio_hal_handle_t adc_hal = NULL;
adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7210_DEFAULT_HANDLE);
AUDIO_NULL_CHECK(TAG, adc_hal, return NULL);
Expand Down
20 changes: 10 additions & 10 deletions components/audio_board/esp32_s3_box/board_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@
#define TOUCH_PANEL_INVERSE_X (1)
#define TOUCH_PANEL_INVERSE_Y (0)


/**
* @brief Audio Codec Chip Function Definition
* @brief Audio Codec Chip Function Definition
*/
#define FUNC_AUDIO_CODEC_EN (1)
#define PA_ENABLE_GPIO GPIO_NUM_46
#define HEADPHONE_DETECT -1
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define FUNC_AUDIO_CODEC_EN (1)
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define PA_ENABLE_GPIO GPIO_NUM_46
#define HEADPHONE_DETECT -1
#define ES7210_MIC_SELECT (ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2 | ES7210_INPUT_MIC3)

extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE;
extern audio_hal_func_t AUDIO_CODEC_ES7210_DEFAULT_HANDLE;
Expand Down
1 change: 1 addition & 0 deletions components/audio_board/esp32_s3_box_3/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ audio_board_handle_t audio_board_init(void)
audio_hal_handle_t audio_board_adc_init(void)
{
audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG();
audio_codec_cfg.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE;
audio_hal_handle_t adc_hal = NULL;
adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7210_DEFAULT_HANDLE);
AUDIO_NULL_CHECK(TAG, adc_hal, return NULL);
Expand Down
19 changes: 10 additions & 9 deletions components/audio_board/esp32_s3_box_3/board_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,17 @@
#define TOUCH_PANEL_INVERSE_Y (0)

/**
* @brief Audio Codec Chip Function Definition
* @brief Audio Codec Chip Function Definition
*/
#define FUNC_AUDIO_CODEC_EN (1)
#define PA_ENABLE_GPIO GPIO_NUM_46
#define HEADPHONE_DETECT (-1)
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define FUNC_AUDIO_CODEC_EN (1)
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define PA_ENABLE_GPIO GPIO_NUM_46
#define HEADPHONE_DETECT (-1)
#define ES7210_MIC_SELECT (ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2 | ES7210_INPUT_MIC3)

extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE;
extern audio_hal_func_t AUDIO_CODEC_ES7210_DEFAULT_HANDLE;
Expand Down
1 change: 1 addition & 0 deletions components/audio_board/esp32_s3_box_lite/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ audio_board_handle_t audio_board_init(void)
audio_hal_handle_t audio_board_adc_init(void)
{
audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG();
audio_codec_cfg.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE;
audio_hal_handle_t adc_hal = NULL;
adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243E_DEFAULT_HANDLE);
AUDIO_NULL_CHECK(TAG, adc_hal, return NULL);
Expand Down
23 changes: 11 additions & 12 deletions components/audio_board/esp32_s3_korvo2_v3/board_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@
#define TOUCH_PANEL_INVERSE_X (1)
#define TOUCH_PANEL_INVERSE_Y (0)


/**
* @brief Audio Codec Chip Function Definition
* @brief Audio Codec Chip Function Definition
*/
#define FUNC_AUDIO_CODEC_EN (1)
#define ES8311_MCLK_SOURCE (0) /* 0 From MCLK of esp32 1 From BCLK */
#define HEADPHONE_DETECT (-1)
#define PA_ENABLE_GPIO GPIO_NUM_48
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (6) /* Power amplifier gain defined by board (dB) */
#define FUNC_AUDIO_CODEC_EN (1)
#define CODEC_ADC_I2S_PORT (0)
#define CODEC_ADC_BITS_PER_SAMPLE (32) /* 32bit */
#define CODEC_ADC_SAMPLE_RATE (48000)
#define RECORD_HARDWARE_AEC (true)
#define BOARD_PA_GAIN (6) /* Power amplifier gain defined by board (dB) */
#define HEADPHONE_DETECT (-1)
#define PA_ENABLE_GPIO GPIO_NUM_48
#define ES8311_MCLK_SOURCE (0) /* 0 From MCLK of esp32 1 From BCLK */
#define ES7210_MIC_SELECT (ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2 | ES7210_INPUT_MIC3)

extern audio_hal_func_t AUDIO_CODEC_ES8311_DEFAULT_HANDLE;
extern audio_hal_func_t AUDIO_CODEC_ES7210_DEFAULT_HANDLE;
Expand All @@ -135,7 +135,6 @@ extern audio_hal_func_t AUDIO_CODEC_ES7210_DEFAULT_HANDLE;
}, \
};


/**
* @brief Button Function Definition
*/
Expand Down
1 change: 1 addition & 0 deletions components/audio_board/lyrat_mini_v1_1/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ audio_board_handle_t audio_board_init(void)
audio_hal_handle_t audio_board_adc_init(void)
{
audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG();
audio_codec_cfg.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE;
audio_hal_handle_t adc_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES7243_DEFAULT_HANDLE);
AUDIO_NULL_CHECK(TAG, adc_hal, return NULL);
return adc_hal;
Expand Down
8 changes: 5 additions & 3 deletions components/audio_hal/audio_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static const char *TAG = "AUDIO_HAL";
audio_hal_handle_t audio_hal_init(audio_hal_codec_config_t *audio_hal_conf, audio_hal_func_t *audio_hal_func)
{
esp_err_t ret = 0;
audio_hal_handle_t audio_hal = (audio_hal_handle_t) audio_calloc(1, sizeof(audio_hal_func_t));
audio_hal_handle_t audio_hal = (audio_hal_handle_t)audio_calloc(1, sizeof(audio_hal_func_t));
AUDIO_MEM_CHECK(TAG, audio_hal, return NULL);
memcpy(audio_hal, audio_hal_func, sizeof(audio_hal_func_t));
audio_hal->audio_hal_lock = mutex_create();
Expand All @@ -51,7 +51,7 @@ audio_hal_handle_t audio_hal_init(audio_hal_codec_config_t *audio_hal_conf, audi
return NULL;
});
mutex_lock(audio_hal->audio_hal_lock);
ret = audio_hal->audio_codec_initialize(audio_hal_conf);
ret = audio_hal->audio_codec_initialize(audio_hal_conf);
if (ret == ESP_FAIL) {
audio_free(audio_hal);
if (audio_hal_func->handle) {
Expand All @@ -62,7 +62,9 @@ audio_hal_handle_t audio_hal_init(audio_hal_codec_config_t *audio_hal_conf, audi
}
}
ret |= audio_hal->audio_codec_config_iface(audio_hal_conf->codec_mode, &audio_hal_conf->i2s_iface);
ret |= audio_hal->audio_codec_set_volume(AUDIO_HAL_VOL_DEFAULT);
if ((audio_hal_conf->codec_mode == AUDIO_HAL_CODEC_MODE_DECODE) || (audio_hal_conf->codec_mode == AUDIO_HAL_CODEC_MODE_BOTH)) {
ret |= audio_hal->audio_codec_set_volume(AUDIO_HAL_VOL_DEFAULT);
}
AUDIO_RET_ON_FALSE(TAG, ret, return NULL, "audio_hal_init failed");
audio_hal->handle = audio_hal;
audio_hal_func->handle = audio_hal;
Expand Down
Loading

0 comments on commit 89226fa

Please sign in to comment.