ASoC: codecs: ES8389: Modify the ES8389 driver
v4 cover ASoC: codecs: ES8389: Modify the ES8389 driver
Modify the initialization configuration and routes for ES8389, and add private members.
v4 -> v3:
-Modify the maximum value for the HPF-related kcontrol -No longer returns an error when the corresponding
configuration is not found in hw_params
v3 -> v2:
-Add Kcontrol for HPF,and removed the description of HPF in dts -If mclk is not accessible, set mclk_src to SCLK_PIN.
v2 -> v1:
-Keep the old ABI around mclk_src
-Describe the member related to the HPF frequency in the DTS. -Instead of accessing HPF-related register values from DTS,
set a specific frequency and then match the corresponding value in the code.
v1 -> v0:
-The binding patch has been placed before the corresponding code patch -Provide a more detailed description of the binding patch -Provide a more detailed description of the patch about HPF
Zhang Yi (6):
ASoC: codecs: ES8389: Modify volatile_register
ASoC: codecs: ES8389: Fix the issue about mclk_src
ASoC: codecs: ES8389: Modify the clock table
ASoC: codecs: ES8389: Modify the initial configuration
ASoC: codecs: ES8389: Add private members about HPF
ASoC: codecs: ES8389: Add INPUTL MUX and INPUTR MUX
sound/soc/codecs/es8389.c | 236 ++++++++++++++++++++++++++++++++------ sound/soc/codecs/es8389.h | 11 +- 2 files changed, 211 insertions(+), 36 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/6 ASoC: codecs: ES8389: Modify volatile_register
Mark some registers that are not volatile as false And modified the logic for cache_bypass during 8389_resume.
--- sound/soc/codecs/es8389.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
sound/soc/codecs/es8389.c +23 -4
@@ -50,10 +50,29 @@ static const char * const es8389_core_supplies[] = {static bool es8389_volatile_register (struct device *dev,unsigned int reg) { -if ((reg <=0xff )) -return true; -else +switch (reg) { +case ES8389_ADCL_VOL : +case ES8389_ADCR_VOL : +case ES8389_MIC1_GAIN : +case ES8389_MIC2_GAIN : +case ES8389_DACL_VOL : +case ES8389_DACR_VOL : +case ES8389_ALC_ON : +case ES8389_ALC_CTL : +case ES8389_ALC_TARGET : +case ES8389_ALC_GAIN : +case ES8389_ADC_MUTE : +case ES8389_OSR_VOL : +case ES8389_DAC_INV : +case ES8389_MIX_VOL : +case ES8389_DAC_MIX : +case ES8389_ADC_RESET : +case ES8389_ADC_MODE : +case ES8389_DMIC_EN :return false; +default : +return true; + } } static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
@@ -861,13 +880,13 @@ static int es8389_resume(struct snd_soc_component *component)regcache_cache_only (es8389->regmap, false);regcache_cache_bypass (es8389->regmap, true);regmap_read (es8389->regmap,ES8389_RESET , ®v); -regcache_cache_bypass (es8389->regmap, false);if (regv ==0xff )es8389_init (component);else es8389_set_bias_level (component,SND_SOC_BIAS_ON ); +regcache_cache_bypass (es8389->regmap, false);regcache_sync (es8389->regmap);return 0 ;
Signature · 1 line
2.17.1
PATCH v4 2/6 ASoC: codecs: ES8389: Fix the issue about mclk_src
In reply to Zhang YiFix the issue with incorrect modifications to mclk_src
When the system needs to be configured to use the MCLK from the SCLK pin, the code still sets the relevant registers to use the MCLK from the MCLK pin
--- sound/soc/codecs/es8389.c | 2 +- sound/soc/codecs/es8389.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-)
sound/soc/codecs/es8389.c +1 -1
@@ -609,7 +609,7 @@ static int es8389_pcm_hw_params(struct snd_pcm_substream *substream,if (es8389->mclk_src ==ES8389_SCLK_PIN ) {regmap_update_bits (es8389->regmap,ES8389_MASTER_CLK , -ES8389_MCLK_SOURCE , es8389->mclk_src); +ES8389_MCLK_MASK ,ES8389_MCLK_FROM_SCLK ); es8389->sysclk =params_channels (params) *params_width (params) *params_rate (params); }
sound/soc/codecs/es8389.h +5 -3
@@ -116,9 +116,11 @@#define ES8389_TDM_SLOT (0x70 << 0)#define ES8389_TDM_SHIFT 4 -#define ES8389_MCLK_SOURCE (1 << 6) -#define ES8389_MCLK_PIN (1 << 6) -#define ES8389_SCLK_PIN (0 << 6) +#define ES8389_MCLK_MASK (3 << 6) +#define ES8389_MCLK_FROM_SCLK (1 << 6) +#define ES8389_MCLK_SOURCE ES8389_MCLK_PIN +#define ES8389_MCLK_PIN 0 +#define ES8389_SCLK_PIN 1/* ES8389_FMT */ #define ES8389_S24_LE (0 << 5)
Signature · 1 line
2.17.1
PATCH v4 3/6 ASoC: codecs: ES8389: Modify the clock table
In reply to Zhang YiUpdated the configuration for certain frequencies
--- sound/soc/codecs/es8389.c | 46 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
sound/soc/codecs/es8389.c +24 -22
@@ -434,52 +434,54 @@ static const struct _coeff_div coeff_div[] = { {36, 576000, 16000, 0x00, 0x55, 0x84, 0xD0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x23, 0x8F, 0xBF, 0xC0, 0x1F, 0x8F, 0x01, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {48, 768000, 16000, 0x02, 0x57, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {50, 800000, 16000, 0x00, 0x7E, 0x01, 0xD9, 0x00, 0xC2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {64, 1024000, 16000, 0x00, 0x45, 0x24, 0xC0, 0x01, 0xD1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {72, 1152000, 16000, 0x00, 0x45, 0x24, 0xC0, 0x01, 0xD1, 0x90, 0x00, 0x00, 0x23, 0x8F, 0xBF, 0xC0, 0x1F, 0x8F, 0x01, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {64, 1024000, 16000, 0x00, 0x45, 0x24, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {72, 1152000, 16000, 0x00, 0x45, 0x24, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x23, 0x8F, 0xBF, 0xC0, 0x1F, 0x8F, 0x01, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {96, 1536000, 16000, 0x02, 0x55, 0x84, 0xD0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {128, 2048000, 16000, 0x00, 0x51, 0x04, 0xD0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {144, 2304000, 16000, 0x00, 0x51, 0x00, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x23, 0x8F, 0xBF, 0xC0, 0x1F, 0x8F, 0x01, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {150, 2400000, 16000, 0x02, 0x7E, 0x01, 0xC9, 0x00, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {192, 3072000, 16000, 0x02, 0x65, 0x25, 0xE0, 0x00, 0xE1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {256, 4096000, 16000, 0x00, 0x41, 0x04, 0xC0, 0x01, 0xD1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {256, 4096000, 16000, 0x00, 0x41, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {300, 4800000, 16000, 0x02, 0x66, 0x01, 0xD9, 0x00, 0xC2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {384, 6144000, 16000, 0x02, 0x51, 0x04, 0xD0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {512, 8192000, 16000, 0x01, 0x41, 0x04, 0xC0, 0x01, 0xD1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {512, 8192000, 16000, 0x01, 0x41, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {750, 12000000, 16000, 0x0E, 0x7E, 0x01, 0xC9, 0x00, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {768, 12288000, 16000, 0x02, 0x41, 0x04, 0xC0, 0x01, 0xD1, 0x90, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {1024, 16384000, 16000, 0x03, 0x41, 0x04, 0xC0, 0x01, 0xD1, 0x90, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {768, 12288000, 16000, 0x02, 0x41, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {1024, 16384000, 16000, 0x03, 0x41, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {1152, 18432000, 16000, 0x08, 0x51, 0x04, 0xD0, 0x01, 0xC1, 0x90, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {1200, 19200000, 16000, 0x0B, 0x66, 0x01, 0xD9, 0x00, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {1500, 24000000, 16000, 0x0E, 0x26, 0x01, 0xD9, 0x00, 0xC2, 0x80, 0xC0, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, - {1536, 24576000, 16000, 0x05, 0x41, 0x04, 0xC0, 0x01, 0xD1, 0x90, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, + {1536, 24576000, 16000, 0x05, 0x41, 0x04, 0xC0, 0x01, 0xC1, 0x90, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0xFF, 0x7F, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {1625, 26000000, 16000, 0x40, 0x6E, 0x05, 0xC8, 0x01, 0xC2, 0x90, 0xC0, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x12, 0x31, 0x0E, 2, 2}, {800, 19200000, 24000, 0x07, 0x66, 0x01, 0xD9, 0x00, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0xC7, 0x95, 0x00, 0x12, 0x00, 0x1A, 0x49, 0x14, 2, 2}, {375, 12000000, 32000, 0x0E, 0x2E, 0x05, 0xC8, 0x00, 0xC2, 0x80, 0x40, 0x01, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x23, 0x61, 0x1B, 2, 0}, - {600, 19200000, 32000, 0x05, 0x46, 0x01, 0xD8, 0x10, 0xD2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x23, 0x61, 0x1B, 2, 2}, - {32, 1411200, 44100, 0x00, 0x45, 0xA4, 0xD0, 0x10, 0xD1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {600, 19200000, 32000, 0x05, 0x46, 0x01, 0xD8, 0x10, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x23, 0x61, 0x1B, 2, 2}, + {32, 1411200, 44100, 0x00, 0x45, 0xA4, 0xD0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {64, 2822400, 44100, 0x00, 0x51, 0x00, 0xC0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {128, 5644800, 44100, 0x00, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {256, 11289600, 44100, 0x01, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {512, 22579200, 44100, 0x03, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {32, 1536000, 48000, 0x00, 0x45, 0xA4, 0xD0, 0x10, 0xD1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {128, 5644800, 44100, 0x00, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {256, 11289600, 44100, 0x01, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {512, 22579200, 44100, 0x03, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {32, 1536000, 48000, 0x00, 0x45, 0xA4, 0xD0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {48, 2304000, 48000, 0x02, 0x55, 0x04, 0xC0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {50, 2400000, 48000, 0x00, 0x76, 0x01, 0xC8, 0x10, 0xC2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {64, 3072000, 48000, 0x00, 0x51, 0x04, 0xC0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {100, 4800000, 48000, 0x00, 0x46, 0x01, 0xD8, 0x10, 0xD2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {100, 4800000, 48000, 0x00, 0x46, 0x01, 0xD8, 0x10, 0xC2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {125, 6000000, 48000, 0x04, 0x6E, 0x05, 0xC8, 0x10, 0xC2, 0x80, 0x00, 0x01, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {128, 6144000, 48000, 0x00, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {200, 9600000, 48000, 0x01, 0x46, 0x01, 0xD8, 0x10, 0xD2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {128, 6144000, 48000, 0x00, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {200, 9600000, 48000, 0x01, 0x46, 0x01, 0xD8, 0x10, 0xC2, 0x80, 0x00, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {250, 12000000, 48000, 0x04, 0x76, 0x01, 0xC8, 0x10, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {256, 12288000, 48000, 0x01, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {384, 18432000, 48000, 0x02, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {400, 19200000, 48000, 0x03, 0x46, 0x01, 0xD8, 0x10, 0xD2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {500, 24000000, 48000, 0x04, 0x46, 0x01, 0xD8, 0x10, 0xD2, 0x80, 0xC0, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, - {512, 24576000, 48000, 0x03, 0x41, 0x04, 0xD0, 0x10, 0xD1, 0x80, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {256, 12288000, 48000, 0x01, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {384, 18432000, 48000, 0x02, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0x40, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {400, 19200000, 48000, 0x03, 0x46, 0x01, 0xD8, 0x10, 0xC2, 0x80, 0x40, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {500, 24000000, 48000, 0x04, 0x46, 0x01, 0xD8, 0x10, 0xC2, 0x80, 0xC0, 0x00, 0x18, 0x95, 0xD0, 0xC0, 0x63, 0x95, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, + {512, 24576000, 48000, 0x03, 0x41, 0x04, 0xD0, 0x10, 0xC1, 0x80, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {800, 38400000, 48000, 0x18, 0x45, 0x04, 0xC0, 0x10, 0xC1, 0x80, 0xC0, 0x00, 0x1F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x00, 0x12, 0x00, 0x35, 0x91, 0x28, 2, 2}, {128, 11289600, 88200, 0x00, 0x50, 0x00, 0xC0, 0x10, 0xC1, 0x80, 0x40, 0x00, 0x9F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x32, 0x89, 0x25, 2, 2}, - {64, 6144000, 96000, 0x00, 0x41, 0x00, 0xD0, 0x10, 0xD1, 0x80, 0x00, 0x00, 0x9F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x35, 0x91, 0x28, 2, 2}, + {64, 6144000, 96000, 0x00, 0x41, 0x00, 0xD0, 0x10, 0xC1, 0x80, 0x00, 0x00, 0x9F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x35, 0x91, 0x28, 2, 2}, {96, 9216000, 96000, 0x02, 0x43, 0x00, 0xC0, 0x10, 0xC0, 0x80, 0x00, 0x00, 0x9F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x35, 0x91, 0x28, 2, 2}, {256, 24576000, 96000, 0x00, 0x40, 0x00, 0xC0, 0x10, 0xC1, 0x80, 0xC0, 0x00, 0x9F, 0x7F, 0xBF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x35, 0x91, 0x28, 2, 2}, {128, 24576000, 192000, 0x00, 0x50, 0x00, 0xC0, 0x18, 0xC1, 0x81, 0xC0, 0x00, 0x8F, 0x7F, 0xBF, 0xC0, 0x3F, 0x7F, 0x80, 0x12, 0xC0, 0x3F, 0xF9, 0x3F, 2, 2}, + {64, 12288000, 192000, 0x00, 0x41, 0x00, 0xC0, 0x18, 0xC1, 0x80, 0x00, 0x00, 0x8F, 0x7F, 0xEF, 0xC0, 0x7F, 0x7F, 0x80, 0x12, 0xC0, 0x3F, 0xF9, 0x3F, 1, 0}, };static inline int get_coeff (u8 vddd,u8 dmic,int mclk,int rate)
Signature · 1 line
2.17.1
PATCH v4 4/6 ASoC: codecs: ES8389: Modify the initial configuration
In reply to Zhang YiModify the initial configuration
--- sound/soc/codecs/es8389.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/es8389.c +2 -2
@@ -792,7 +792,7 @@ static void es8389_init(struct snd_soc_component *component)regmap_read (es8389->regmap,ES8389_MAX_REGISTER , ®); es8389->version = reg; -regmap_write (es8389->regmap,ES8389_ISO_CTL ,0x00 ); +regmap_write (es8389->regmap,ES8389_ISO_CTL ,0x56 );regmap_write (es8389->regmap,ES8389_RESET ,0x7E );regmap_write (es8389->regmap,ES8389_ISO_CTL ,0x38 );regmap_write (es8389->regmap,ES8389_ADC_HPF1 ,0x64 );
@@ -844,7 +844,7 @@ static void es8389_init(struct snd_soc_component *component)regmap_write (es8389->regmap,ES8389_SCLK_DIV ,0x04 );regmap_write (es8389->regmap,ES8389_LRCK_DIV1 ,0x01 );regmap_write (es8389->regmap,ES8389_LRCK_DIV2 ,0x00 ); -regmap_write (es8389->regmap,ES8389_OSC_CLK ,0x00 ); +regmap_write (es8389->regmap,ES8389_OSC_CLK ,0x10 );regmap_write (es8389->regmap,ES8389_ADC_OSR ,0x1F );regmap_write (es8389->regmap,ES8389_ADC_DSP ,0x7F );regmap_write (es8389->regmap,ES8389_ADC_MUTE ,0xC0 );
Signature · 1 line
2.17.1
PATCH v4 5/6 ASoC: codecs: ES8389: Add private members about HPF
In reply to Zhang YiAdd private members related to HPF.
Add Kcontrol for HPF
--- sound/soc/codecs/es8389.c | 122 +++++++++++++++++++++++++++++++++++++- sound/soc/codecs/es8389.h | 3 + 2 files changed, 123 insertions(+), 2 deletions(-)
sound/soc/codecs/es8389.c +120 -2
@@ -36,6 +36,10 @@ struct es8389_private {unsigned int sysclk;int mastermode; +u8 hpfl; +u8 hpfr; +u32 hpf_freq; +u32 capture_rate;u8 mclk_src;u8 vddd;int version;
@@ -82,6 +86,92 @@ static const DECLARE_TLV_DB_SCALE(mix_vol_tlv, -9500, 100, 0); static const DECLARE_TLV_DB_SCALE(alc_target_tlv, -3200, 200, 0); static const DECLARE_TLV_DB_SCALE(alc_max_level, -3200, 200, 0); +static const u32 hpf_table[10 ][10 ] = { + {1020 ,754 ,624 ,559 ,527 ,511 ,502 ,498 ,497 ,496 }, + {754 ,495 ,368 ,306 ,274 ,259 ,251 ,247 ,246 ,244 }, + {624 ,368 ,243 ,182 ,151 ,136 ,128 ,124 ,123 ,121 }, + {559 ,306 ,182 ,120 ,90 ,75 ,68 ,63 ,62 ,60 }, + {527 ,274 ,151 ,90 ,60 ,45 ,38 ,33 ,32 ,31 }, + {511 ,259 ,136 ,75 ,45 ,30 ,23 ,19 ,18 ,17 }, + {502 ,251 ,128 ,68 ,38 ,23 ,16 ,13 ,11 ,11 }, + {498 ,247 ,124 ,63 ,33 ,19 ,13 ,10 ,8 ,8 }, + {497 ,246 ,123 ,62 ,32 ,18 ,11 ,8 ,8 ,0 }, + {496 ,244 ,121 ,60 ,31 ,17 ,11 ,8 ,0 ,0 } +}; + +static bool find_best_hpf_freq (u32 target_hz,u8 *hpf1,u8 *hpf2,u32 *out) +{ +int best_row =-1 , best_col =-1 ; +u32 min_diff =U32_MAX ; +u32 f, diff; +int i, j; + +if ((target_hz >1020 ) | (target_hz <0 )) +return false; + +for (i =0 ; i <10 ; i++) { +for (j = i; j <10 ; j++) { + f = hpf_table[i][j]; + + diff = (target_hz > f) ? (target_hz - f) : (f - target_hz); +if (diff < min_diff) { + min_diff = diff; + best_row = i; + best_col = j; + *out = f; + } + } + } + + *hpf1 = best_col +ES8389_HPF_OFFSET ; + *hpf2 = best_row +ES8389_HPF_OFFSET ; + +return true; +} + +static int es8389_hpf_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); +struct es8389_private *es8389 =snd_soc_component_get_drvdata (component); + + ucontrol->value.integer.value[0 ] = es8389->hpf_freq; +return 0 ; +} + +static int es8389_hpf_set (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_component *component =snd_kcontrol_chip (kcontrol); +struct es8389_private *es8389 =snd_soc_component_get_drvdata (component); +u32 freq; +bool hpf; + +if (es8389->hpf_freq == ucontrol->value.integer.value[0 ]) +return 0 ; + +if (es8389->capture_rate) { + freq = (ucontrol->value.integer.value[0 ] *48000 ) / es8389->capture_rate; + + hpf =find_best_hpf_freq (freq, &es8389->hpfl, &es8389->hpfr, &es8389->hpf_freq); +if (!hpf) +return -EBUSY ; + +if (es8389->hpf_freq != ucontrol->value.integer.value[0 ]) +dev_dbg (component->dev,"At the %u Hz sampling rate, %ld Hz could not be obtained." +"the frequency has been set to the closest value, %u Hz\n" , + es8389->capture_rate, ucontrol->value.integer.value[0 ], es8389->hpf_freq); + +regmap_update_bits (es8389->regmap,ES8389_ADC_HPF1 ,0x0f , es8389->hpfl); +regmap_update_bits (es8389->regmap,ES8389_ADC_HPF2 ,0x0f , es8389->hpfr); + }else { + es8389->hpf_freq = ucontrol->value.integer.value[0 ]; +dev_dbg (component->dev,"PCM_STREAM_CAPTURE is not active.retain the input frequency\n" ); + } + +return 1 ; +} +static int es8389_dmic_set (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -259,6 +349,8 @@ static const struct snd_kcontrol_new es8389_snd_controls[] = {SOC_DOUBLE ("ADC OSR Volume ON Switch" ,ES8389_ADC_MUTE ,6 ,7 ,1 ,0 ),SOC_SINGLE_TLV ("ADC OSR Volume" ,ES8389_OSR_VOL ,0 ,0xFF ,0 , adc_vol_tlv),SOC_DOUBLE ("ADC OUTPUT Invert Switch" ,ES8389_ADC_HPF2 ,5 ,6 ,1 ,0 ), +SOC_SINGLE_EXT ("ADC HPF Freq Select" ,SND_SOC_NOPM ,0 ,1020 ,0 , + es8389_hpf_get, es8389_hpf_set),SOC_SINGLE_TLV ("DACL Playback Volume" ,ES8389_DACL_VOL ,0 ,0xFF ,0 , dac_vol_tlv), SOC_SINGLE_TLV("DACR Playback Volume", ES8389_DACR_VOL, 0, 0xFF, 0, dac_vol_tlv),
@@ -585,6 +677,8 @@ static int es8389_pcm_hw_params(struct snd_pcm_substream *substream,int coeff, ret;u8 dmic_enable, state =0 ;unsigned int regv; +u32 freq; +bool hpf;switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE :
@@ -662,6 +756,28 @@ static int es8389_pcm_hw_params(struct snd_pcm_substream *substream,dev_warn (component->dev,"Clock coefficients do not match" ); } +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE ) { + es8389->capture_rate =params_rate (params); + freq = (es8389->hpf_freq *48000 ) /params_rate (params); + hpf =find_best_hpf_freq (freq, &es8389->hpfl, &es8389->hpfr, &es8389->hpf_freq); +if (!hpf) { +dev_err (component->dev,"The HPF frequency is invalid\n" ); +return -EINVAL ; + } + } + +return 0 ; +} + +static int es8389_pcm_hw_free (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_component *component = dai->component; +struct es8389_private *es8389 =snd_soc_component_get_drvdata (component); + +if (substream->stream ==SNDRV_PCM_STREAM_CAPTURE ) + es8389->capture_rate =0 ; +return 0 ; }
@@ -742,8 +858,8 @@ static int es8389_mute(struct snd_soc_dai *dai, int mute, int direction)regmap_update_bits (es8389->regmap,ES8389_DAC_FORMAT_MUTE ,0x03 ,0x00 ); }else { -regmap_update_bits (es8389->regmap,ES8389_ADC_HPF1 ,0x0f ,0x0a ); -regmap_update_bits (es8389->regmap,ES8389_ADC_HPF2 ,0x0f ,0x0a ); +regmap_update_bits (es8389->regmap,ES8389_ADC_HPF1 ,0x0f , es8389->hpfl); +regmap_update_bits (es8389->regmap,ES8389_ADC_HPF2 ,0x0f , es8389->hpfr);regmap_update_bits (es8389->regmap,ES8389_ADC_FORMAT_MUTE ,0x03 ,0x00 ); }
@@ -759,6 +875,7 @@ static int es8389_mute(struct snd_soc_dai *dai, int mute, int direction)static const struct snd_soc_dai_ops es8389_ops = { .hw_params = es8389_pcm_hw_params, + .hw_free = es8389_pcm_hw_free, .set_fmt = es8389_set_dai_fmt, .set_sysclk = es8389_set_dai_sysclk, .set_tdm_slot = es8389_set_tdm_slot,
@@ -934,6 +1051,7 @@ static int es8389_probe(struct snd_soc_component *component)return ret; } + es8389->hpf_freq =ES8389_HPF_DEFAULT ;es8389_init (component);es8389_set_bias_level (component,SND_SOC_BIAS_STANDBY );
sound/soc/codecs/es8389.h +3 -0
@@ -106,6 +106,9 @@#define ES8389_MIC_SEL_MASK (7 << 4)#define ES8389_MIC_DEFAULT (1 << 4) +#define ES8389_HPF_DEFAULT 16 +#define ES8389_HPF_OFFSET 4 +#define ES8389_MASTER_MODE_EN (1 << 0)#define ES8389_TDM_OFF (0 << 0)
Signature · 1 line
2.17.1
PATCH v4 6/6 ASoC: codecs: ES8389: Add INPUTL MUX and INPUTR MUX
In reply to Zhang YiAdd INPUTL MUX and INPUTR MUX in route
--- sound/soc/codecs/es8389.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
sound/soc/codecs/es8389.c +33 -2
@@ -252,6 +252,16 @@ static const struct soc_enum alc_ramprate =static const struct soc_enum alc_winsize =SOC_ENUM_SINGLE (ES8389_ALC_CTL ,0 ,16 , winsize); +static const char *const es8389_adcl_mux_txt[] = { +"Normal" , +"ADC2 channel to ADC1 channel" , +}; + +static const char *const es8389_adcr_mux_txt[] = { +"Normal" , +"ADC1 channel to ADC2 channel" , +}; +static const char *const es8389_outl_mux_txt[] = {"Normal" ,"DAC2 channel to DAC1 channel" ,
@@ -279,6 +289,20 @@ static const unsigned int es8389_pga_values[] = { 1, 5, 6 }; +static const struct soc_enum es8389_adcl_mux_enum = +SOC_ENUM_SINGLE (ES8389_ADC_MODE ,5 , +ARRAY_SIZE (es8389_adcl_mux_txt), es8389_adcl_mux_txt); + +static const struct snd_kcontrol_new es8389_adcl_mux_controls = +SOC_DAPM_ENUM ("INPUTL MUX" , es8389_adcl_mux_enum); + +static const struct soc_enum es8389_adcr_mux_enum = +SOC_ENUM_SINGLE (ES8389_ADC_MODE ,4 , +ARRAY_SIZE (es8389_adcr_mux_txt), es8389_adcr_mux_txt); + +static const struct snd_kcontrol_new es8389_adcr_mux_controls = +SOC_DAPM_ENUM ("INPUTR MUX" , es8389_adcr_mux_enum); +static const struct soc_enum es8389_outl_mux_enum =SOC_ENUM_SINGLE (ES8389_DAC_MIX ,5 ,ARRAY_SIZE (es8389_outl_mux_txt), es8389_outl_mux_txt);
@@ -409,6 +433,8 @@ static const struct snd_soc_dapm_widget es8389_dapm_widgets[] = { &es8389_adc_mixer_controls[0], ARRAY_SIZE(es8389_adc_mixer_controls)),SND_SOC_DAPM_MUX ("ADC MUX" ,SND_SOC_NOPM ,0 ,0 , &es8389_dmic_mux_controls), +SND_SOC_DAPM_MUX ("INPUTL MUX" ,SND_SOC_NOPM ,0 ,0 , &es8389_adcl_mux_controls), +SND_SOC_DAPM_MUX ("INPUTR MUX" ,SND_SOC_NOPM ,0 ,0 , &es8389_adcr_mux_controls),SND_SOC_DAPM_MUX ("OUTL MUX" ,SND_SOC_NOPM ,0 ,0 , &es8389_outl_mux_controls), SND_SOC_DAPM_MUX("OUTR MUX", SND_SOC_NOPM, 0, 0, &es8389_outr_mux_controls),
@@ -422,10 +448,15 @@ static const struct snd_soc_dapm_route es8389_dapm_routes[] = { {"ADCL", NULL, "PGAL"}, {"ADCR", NULL, "PGAR"}, + {"INPUTL MUX", "Normal", "ADCL"}, + {"INPUTL MUX", "ADC2 channel to ADC1 channel", "ADCR"}, + {"INPUTR MUX", "Normal", "ADCR"}, + {"INPUTR MUX", "ADC1 channel to ADC2 channel", "ADCL"}, + {"ADC Mixer", "DACL ADCL Mixer", "DACL"}, {"ADC Mixer", "DACR ADCR Mixer", "DACR"}, - {"ADC Mixer", NULL, "ADCL"}, - {"ADC Mixer", NULL, "ADCR"}, + {"ADC Mixer", NULL, "INPUTL MUX"}, + {"ADC Mixer", NULL, "INPUTR MUX"}, {"ADC MUX", "AMIC", "ADC Mixer"}, {"ADC MUX", "DMIC", "DMIC"},
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 11 lines · Zhang Yi
ASoC: codecs: ES8389: Modify the ES8389 driver
Modify the initialization configuration and routes for ES8389, and add private members.
v4 -> v3:
-Modify the maximum value for the HPF-related kcontrol -No longer returns an error when the corresponding
configuration is not found inhw_params[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/6] ASoC: codecs: ES8389: Modify volatile_register
https://git.kernel.org/broonie/sound/c/882e55031187 [2/6] ASoC: codecs: ES8389: Fix the issue about mclk_src https://git.kernel.org/broonie/sound/c/cbc559dd8d46 [3/6] ASoC: codecs: ES8389: Modify the clock table https://git.kernel.org/broonie/sound/c/9367a244afc2 [4/6] ASoC: codecs: ES8389: Modify the initial configuration https://git.kernel.org/broonie/sound/c/3bea836903c2 [5/6] ASoC: codecs: ES8389: Add private members about HPF https://git.kernel.org/broonie/sound/c/87592da1a490 [6/6] ASoC: codecs: ES8389: Add INPUTL MUX and INPUTR MUX https://git.kernel.org/broonie/sound/c/2264927316e5
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark