diff --git a/components/squeezelite/adac_core.c b/components/squeezelite/adac_core.c index e83c2214..9f746f99 100644 --- a/components/squeezelite/adac_core.c +++ b/components/squeezelite/adac_core.c @@ -26,8 +26,16 @@ static int i2c_port = -1; int adac_init(char *config, int i2c_port_num) { char *p; int i2c_addr = 0; - i2c_port = i2c_port_num; + // some crappy codecs require MCLK to work + if ((p = strcasestr(config, "mck")) != NULL) { + ESP_LOGI(TAG, "Configuring MCLK on GPIO0"); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1); + REG_WRITE(PIN_CTRL, 0xFFFFFFF0); + } + + i2c_port = i2c_port_num; + // configure i2c i2c_config_t i2c_config = { .mode = I2C_MODE_MASTER, diff --git a/components/squeezelite/external/dac_external.c b/components/squeezelite/external/dac_external.c index e955dd21..c274b065 100644 --- a/components/squeezelite/external/dac_external.c +++ b/components/squeezelite/external/dac_external.c @@ -32,6 +32,21 @@ const struct adac_s dac_external = { "i2s", init, adac_deinit, power, speaker, h static cJSON *i2c_json; static int i2c_addr; +static struct { + char *model; + bool mclk; + char *controlset; +} codecs[] = { + { "es8388", true, + "{\"init\":[ \ + {\"reg\":8,\"val\":0}, {\"reg\":2,\"val\":243}, {\"reg\":43,\"val\":128}, {\"reg\":0,\"val\":5}, \ + {\"reg\":1,\"val\":64}, {\"reg\":4,\"val\":60}, {\"reg\":23,\"val\":24}, {\"reg\":24,\"val\":2}, \ + {\"reg\":26,\"val\":0}, {\"reg\":27,\"val\":0}, {\"reg\":25,\"val\":50}, {\"reg\":38,\"val\":0}, \ + {\"reg\":39,\"val\":184}, {\"reg\":42,\"val\":184}, {\"reg\":46,\"val\":30}, {\"reg\":47,\"val\":30}, \ + {\"reg\":48,\"val\":30}, {\"reg\":49,\"val\":30}, {\"reg\":2,\"val\":170}]}" }, + { NULL, false, NULL } +}; + /**************************************************************************************** * init */ @@ -44,10 +59,22 @@ static bool init(char *config, int i2c_port_num, i2s_config_t *i2s_config) { ESP_LOGI(TAG, "DAC on I2C @%d", i2c_addr); p = config_alloc_get_str("dac_controlset", CONFIG_DAC_CONTROLSET, NULL); + + if ((!p || !*p) && (p = strcasestr(config, "model")) != NULL) { + char model[32] = ""; + int i; + sscanf(p, "%*[^=]=%31[^,]", model); + for (i = 0; *model && ((p = codecs[i].controlset) != NULL) && strcasecmp(codecs[i].model, model); i++); + if (p && codecs[i].mclk) { + ESP_LOGI(TAG, "Configuring MCLK on GPIO0"); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1); + REG_WRITE(PIN_CTRL, 0xFFFFFFF0); + } + } + i2c_json = cJSON_Parse(p); if (!i2c_json) { - if (p) free(p); ESP_LOGW(TAG, "no i2c controlset found"); return true; } @@ -56,7 +83,7 @@ static bool init(char *config, int i2c_port_num, i2s_config_t *i2s_config) { ESP_LOGE(TAG, "could not intialize DAC"); return false; } - + return true; } diff --git a/components/squeezelite/wm8978/wm8978.c b/components/squeezelite/wm8978/wm8978.c index b55b8b6f..fd6b12f8 100644 --- a/components/squeezelite/wm8978/wm8978.c +++ b/components/squeezelite/wm8978/wm8978.c @@ -62,7 +62,7 @@ static bool init(char *config, int i2c_port, i2s_config_t *i2s_config) { i2c_write_shadow(49, 102); // Configure system clk to GPIO0 for DAC MCLK input - ESP_LOGI(TAG, "Configuring MCLK on pin:%d", 0); + ESP_LOGI(TAG, "Configuring MCLK on GPIO0"); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1); REG_WRITE(PIN_CTRL, 0xFFFFFFF0); diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 732ee2d3..fea336a1 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -49,49 +49,39 @@ menu "Squeezelite-ESP32" select I2C_LOCKED select LED_LOCKED select SPKFAULT_LOCKED - config A1S - bool "ESP32-A1S module" - select I2C_LOCKED - config DAC32 - bool "DAC32 module" + config BASIC_I2C_BT + bool "Generic I2S & Bluetooth" config TWATCH2020 bool "T-WATCH2020 by LilyGo" select I2C_LOCKED - config BASIC_I2C_BT - bool "Generic I2S & Bluetooth" endchoice config RELEASE_API string "Software update URL" - default "https://api.github.com/repos/sle118/squeezelite-esp32/releases" if !DAC32 - default "https://yourdomain/api/releases" if DAC32 + default "https://api.github.com/repos/sle118/squeezelite-esp32/releases" help Set the URL of the API that the front-end UI will use to fetch software updates config SQUEEZELITE_ESP32_RELEASE_URL string "Release URL" - default "https://github.com/sle118/squeezelite-esp32/releases" if !DAC32 - default "https://yourdomain/releases" if DAC32 + default "https://github.com/sle118/squeezelite-esp32/releases" help Set the URL where users can see a list of releases + # you can't change default values once they are set so changing "Target" will not reset + # project name if they are visible config - they have to be silent strings config PROJECT_NAME - string "Project Name" - default "Squeezelite-A1S" if A1S + string default "SqueezeAMP" if SQUEEZEAMP - default "DAC32" if DAC32 default "Squeezelite-TWATCH" if TWATCH2020 - default "Squeezelite-ESP32" if !A1S && !SQUEEZEAMP && !DAC32 && !TWATCH2020 + default "Squeezelite-ESP32" config FW_PLATFORM_NAME - string "Hardware Platform Name" + string default "SqueezeAmp" if SQUEEZEAMP - default "DAC32" if DAC32 - default "ESP32-A1S" if A1S default "TWATCH" if TWATCH2020 - default "I2S-4MFlash" if !A1S && !SQUEEZEAMP && !DAC32 && !TWATCH2020 + default "ESP32" # AGGREGATES - begin # these parameters are "aggregates" that take precedence. They must have a default value config DAC_CONFIG string default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP - default "model=AC101,bck=27,ws=26,do=25,di=35,sda=33,scl=32" if A1S default "model=I2S,bck=26,ws=25,do=33,i2c=53,sda=21,scl=22" if TWATCH2020 default "" config SPDIF_CONFIG @@ -138,7 +128,7 @@ menu "Squeezelite-ESP32" I2S data output gpio pin to use. config I2S_DI_IO int "I2S Data Input GPIO number. " - default -1 if !A1S + default -1 help I2S data input gpio pin to use (not used mostly, leave it to -1). endmenu @@ -188,16 +178,7 @@ menu "Squeezelite-ESP32" help I2S data output IO use to simulate SPDIF endmenu - - menu "SPDIF settings" - visible if A1S - config SPDIF_DO_IO - int "SPDIF Data I/O GPIO number" - default -1 - help - I2S data output IO use to simulate SPDIF - endmenu - + menu "A2DP settings" config A2DP_SINK_NAME string "Name of Bluetooth A2DP device"