Skip to content

Commit 14a0a1e

Browse files
Zhu Ningbroonie
authored andcommitted
ASoC: codecs: ES8326: Improving the THD+N performance
We update the values of some registers in the initialization sequence in es8326_resume function to improve THD+N performance. THD+N performance decreases if the output level on headphone is close to full scale. So we change the register setting in es8326_jack_detect_handler function to improve THD+N performance if headphone pulgged. Also, the register setting should be restored when the headset is unplugged Signed-off-by: Zhu Ning <zhuning0077@gmail.com> Link: https://msgid.link/r/20240120101240.12496-3-zhuning0077@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 523d242 commit 14a0a1e

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

sound/soc/codecs/es8326.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)
752752
es8326->hp = 0;
753753
}
754754
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01);
755+
regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x0a);
756+
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x03);
755757
/*
756758
* Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event
757759
*/
@@ -777,6 +779,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)
777779
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01);
778780
usleep_range(50000, 70000);
779781
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00);
782+
regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x1f);
783+
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x08);
780784
queue_delayed_work(system_wq, &es8326->jack_detect_work,
781785
msecs_to_jiffies(400));
782786
es8326->hp = 1;
@@ -846,14 +850,14 @@ static int es8326_calibrate(struct snd_soc_component *component)
846850
if ((es8326->version == ES8326_VERSION_B) && (es8326->calibrated == false)) {
847851
dev_dbg(component->dev, "ES8326_VERSION_B, calibrating\n");
848852
regmap_write(es8326->regmap, ES8326_CLK_INV, 0xc0);
849-
regmap_write(es8326->regmap, ES8326_CLK_DIV1, 0x01);
853+
regmap_write(es8326->regmap, ES8326_CLK_DIV1, 0x03);
850854
regmap_write(es8326->regmap, ES8326_CLK_DLL, 0x30);
851855
regmap_write(es8326->regmap, ES8326_CLK_MUX, 0xed);
852856
regmap_write(es8326->regmap, ES8326_CLK_DAC_SEL, 0x08);
853857
regmap_write(es8326->regmap, ES8326_CLK_TRI, 0xc1);
854858
regmap_write(es8326->regmap, ES8326_DAC_MUTE, 0x03);
855859
regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7f);
856-
regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x03);
860+
regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23);
857861
regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x88);
858862
usleep_range(15000, 20000);
859863
regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c);
@@ -894,28 +898,29 @@ static int es8326_resume(struct snd_soc_component *component)
894898
/* reset internal clock state */
895899
regmap_write(es8326->regmap, ES8326_RESET, 0x1f);
896900
regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
901+
regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
897902
usleep_range(10000, 15000);
898903
regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0xe9);
899-
regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4b);
904+
regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xcb);
900905
/* set headphone default type and detect pin */
901906
regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x83);
902907
regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05);
903-
regmap_write(es8326->regmap, ES8326_HP_MISC, 0x30);
904908

905909
/* set internal oscillator as clock source of headpone cp */
906910
regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x89);
907911
regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON);
908912
/* clock manager reset release */
909913
regmap_write(es8326->regmap, ES8326_RESET, 0x17);
910914
/* set headphone detection as half scan mode */
911-
regmap_write(es8326->regmap, ES8326_HP_MISC, 0x30);
915+
regmap_write(es8326->regmap, ES8326_HP_MISC, 0x3d);
912916
regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x00);
913917

914918
/* enable headphone driver */
919+
regmap_write(es8326->regmap, ES8326_HP_VOL, 0xc4);
915920
regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7);
916921
usleep_range(2000, 5000);
917-
regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xa3);
918-
regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xb3);
922+
regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x23);
923+
regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x33);
919924
regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1);
920925

921926
regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00);
@@ -946,7 +951,7 @@ static int es8326_resume(struct snd_soc_component *component)
946951
(ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));
947952
regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT);
948953

949-
regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
954+
regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00);
950955
regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON);
951956
regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK,
952957
ES8326_MIC1_SEL);

sound/soc/codecs/es8326.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
#define ES8326_MUTE (3 << 0)
102102

103103
/* ES8326_CLK_CTL */
104-
#define ES8326_CLK_ON (0x7f << 0)
104+
#define ES8326_CLK_ON (0x7e << 0)
105105
#define ES8326_CLK_OFF (0 << 0)
106106

107107
/* ES8326_CLK_INV */

0 commit comments

Comments
 (0)