[tas5805m] Add configuration for mono mixing (#115)

When bridge mode is active, by default, only the left input channel is send
to the output.

With the configuration, you can choose either the left or the right channel,
or a "mono" configuration which mix the two input channel.

Co-authored-by: Alex <alex@alexlg.org>
This commit is contained in:
Alexandre Thomazo
2025-02-23 20:54:47 +01:00
committed by GitHub
Unverified
parent 38d749e6cc
commit b484c2926b
2 changed files with 93 additions and 13 deletions

View File

@@ -172,13 +172,25 @@ menu "Audio Board"
endmenu
menu "DAC-Operation-Mode"
depends on DAC_TAS5805M
depends on DAC_TAS5805M
config DAC_BRIDGE_MODE
bool "Enable Bridge-Mode"
default false if DAC_TAS5805M
help
If enabled left channel will be played with more power. To use the right channel please change Word-Select-Setting in Logic-Level-Settings.
choice DAC_BRIDGE_MODE
prompt "Bridge-Mode selection"
default DAC_BRIDGE_MODE_DISABLED
config DAC_BRIDGE_MODE_DISABLED
bool "Stereo (bridge mode disabled)"
config DAC_BRIDGE_MODE_MONO
bool "Mono mode (Left + Right / 2)"
config DAC_BRIDGE_MODE_LEFT
bool "Output left input channel"
config DAC_BRIDGE_MODE_RIGHT
bool "Output right input channel"
endchoice
endmenu
menu "Merus MA120x0 interface Configuration"

View File

@@ -167,14 +167,82 @@ esp_err_t tas5805m_init() {
}
// Check if Bridge-Mode is enabled
#ifdef CONFIG_DAC_BRIDGE_MODE
uint8_t value = 0;
ret = tas5805m_read_byte(TAS5805M_DEVICE_CTRL_1_REGISTER, &value);
if (ret != ESP_OK) return ret;
value = 0b100;
#if defined(CONFIG_DAC_BRIDGE_MODE_MONO) || defined(CONFIG_DAC_BRIDGE_MODE_LEFT) || defined(CONFIG_DAC_BRIDGE_MODE_RIGHT)
ESP_LOGV(TAG, "Setting Bridge-Mode");
ret = tas5805m_write_byte(TAS5805M_DEVICE_CTRL_1_REGISTER, value);
if (ret != ESP_OK) return ret;
// enable bridge mode
ret = tas5805m_write_byte(TAS5805M_DEVICE_CTRL_1_REGISTER, 0x04);
// Mixer config
ret |= tas5805m_write_byte(0x0, 0x0);
ret |= tas5805m_write_byte(0x7f, 0x8c);
ret |= tas5805m_write_byte(0x0, 0x29);
#if defined(CONFIG_DAC_BRIDGE_MODE_MONO)
ESP_LOGI(TAG, "Defining Bridge-Mode to Mono");
// Left mixer input to left ouput (-6 dB)
ret |= tas5805m_write_byte(0x18, 0x00);
ret |= tas5805m_write_byte(0x19, 0x40);
ret |= tas5805m_write_byte(0x1a, 0x26);
ret |= tas5805m_write_byte(0x1b, 0xe7);
// Right mixer input to left ouput (-6 dB)
ret |= tas5805m_write_byte(0x1c, 0x00);
ret |= tas5805m_write_byte(0x1d, 0x40);
ret |= tas5805m_write_byte(0x1e, 0x26);
ret |= tas5805m_write_byte(0x1f, 0xe7);
#elif defined(CONFIG_DAC_BRIDGE_MODE_LEFT)
ESP_LOGI(TAG, "Defining Bridge-Mode to Left");
// Left mixer input to left ouput (0 dB)
ret |= tas5805m_write_byte(0x18, 0x00);
ret |= tas5805m_write_byte(0x19, 0x80);
ret |= tas5805m_write_byte(0x1a, 0x00);
ret |= tas5805m_write_byte(0x1b, 0x00);
// Right mixer input to left ouput (-110 dB)
ret |= tas5805m_write_byte(0x1c, 0x00);
ret |= tas5805m_write_byte(0x1d, 0x00);
ret |= tas5805m_write_byte(0x1e, 0x00);
ret |= tas5805m_write_byte(0x1f, 0x00);
#elif defined(CONFIG_DAC_BRIDGE_MODE_RIGHT)
ESP_LOGI(TAG, "Defining Bridge-Mode to Right");
// Left mixer input to left ouput (-110 dB)
ret |= tas5805m_write_byte(0x18, 0x00);
ret |= tas5805m_write_byte(0x19, 0x00);
ret |= tas5805m_write_byte(0x1a, 0x00);
ret |= tas5805m_write_byte(0x1b, 0x00);
// Right mixer input to left ouput (0 dB)
ret |= tas5805m_write_byte(0x1c, 0x00);
ret |= tas5805m_write_byte(0x1d, 0x80);
ret |= tas5805m_write_byte(0x1e, 0x00);
ret |= tas5805m_write_byte(0x1f, 0x00);
#endif
// Left mixer input to right ouput (-110 dB as the right output is not used)
ret |= tas5805m_write_byte(0x20, 0x00);
ret |= tas5805m_write_byte(0x21, 0x00);
ret |= tas5805m_write_byte(0x22, 0x00);
ret |= tas5805m_write_byte(0x23, 0x00);
// Right mixer input to right ouput (-110 dB as the right output is not used)
ret |= tas5805m_write_byte(0x24, 0x00);
ret |= tas5805m_write_byte(0x25, 0x00);
ret |= tas5805m_write_byte(0x26, 0x00);
ret |= tas5805m_write_byte(0x27, 0x00);
// End config
ret |= tas5805m_write_byte(0x0, 0x0);
ret |= tas5805m_write_byte(0x7f, 0x0);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Setting Bridge-Mode failed");
return ret;
}
#endif
return ret;