Skip to content

Commit 6037db6

Browse files
author
Mike Robinson
committed
EspSound mods to allow independent left / right volume setting
1 parent 5701669 commit 6037db6

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

src/Driver/es8388/es8388.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,21 @@ error_t es8388_config_fmt(codec_mode_t mode, i2s_format_t fmt) {
404404
* - (0) Success
405405
*/
406406
#if AI_THINKER_ES8388_VOLUME_HACK == 1
407+
error_t es8388_set_left_right_volume(int left_volume, int right_volume) {
408+
AD_LOGD("es8388_set_left_right_volume (HACK 1): %d %d", left_volume, right_volume);
409+
error_t res = RESULT_OK;
410+
411+
// https://dl.radxa.com/rock2/docs/hw/ds/ES8388%20user%20Guide.pdf pages 23 & 24
412+
// DAC Volume Control -DAC LDACVOL RDACVOL default 0 = 0DB; Default value 192 = – -96 dB
413+
res = es_write_reg(ES8388_ADDR, ES8388_DACCONTROL4, left_volume); // LDACVOL (digital volume control)
414+
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL5, right_volume); // RDACVOL
415+
// Lineout 1 & 2 - LOUT1 & 2, RLOUT1 & 2 volume: 6 bits
416+
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL24, 0b011110); // LOUT1VOL 0b011110 = 0db, 0b011111 = +1.5db, 0b011101 = -1.5db
417+
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL25, 0b011110); // ROUT1VOL
418+
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL26, 0b011110); // LOUT2VOL 0b011110 = 0db, 0b011111 = +1.5db, 0b011101 = -1.5db
419+
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0b011110); // ROUT2VOL
420+
return res;
421+
}
407422

408423
error_t es8388_set_voice_volume(int volume) {
409424
AD_LOGD("es8388_set_voice_volume (HACK 1): %d", volume);

src/Driver/es8388/es8388.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,27 @@ error_t es8388_start(codec_mode_t mode);
185185
*/
186186
error_t es8388_stop(codec_mode_t mode);
187187

188-
/**
189-
* @brief Set voice volume
190-
*
191-
* @param volume: voice volume (0~100)
192-
*
193-
* @return
194-
* - RESULT_OK
195-
* - RESULT_FAIL
196-
*/
197-
error_t es8388_set_voice_volume(int volume);
188+
/**
189+
* @brief Set voice volume for each channel indiviually *** MikeR hack ***
190+
*
191+
* @param volume: voice volume (0~100)
192+
*
193+
* @return
194+
* - RESULT_OK
195+
* - RESULT_FAIL
196+
*/
197+
error_t es8388_set_left_right_volume(int left_volume, int right_volume);
198+
199+
/**
200+
* @brief Set voice volume
201+
*
202+
* @param volume: voice volume (0~100)
203+
*
204+
* @return
205+
* - RESULT_OK
206+
* - RESULT_FAIL
207+
*/
208+
error_t es8388_set_voice_volume(int volume);
198209

199210
/**
200211
* @brief Get voice volume

0 commit comments

Comments
 (0)