Skip to content

Commit 2837582

Browse files
committed
ASoC: codecs: ES8326: solve some hp issues and
Merge series from Zhang Yi <[email protected]>: We solved some issues related to headphone detection.And for using the same configuration in different power conditions,we modified the clock table
2 parents d619b0b + fec9c7f commit 2837582

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

sound/soc/codecs/es8326.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ static const struct _coeff_div coeff_div_v3[] = {
412412
{125, 48000, 6000000, 0x04, 0x04, 0x1F, 0x2D, 0x8A, 0x0A, 0x27, 0x27},
413413

414414
{128, 8000, 1024000, 0x60, 0x00, 0x05, 0x75, 0x8A, 0x1B, 0x1F, 0x7F},
415-
{128, 16000, 2048000, 0x20, 0x00, 0x31, 0x35, 0x8A, 0x1B, 0x1F, 0x3F},
416-
{128, 44100, 5644800, 0xE0, 0x00, 0x01, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
417-
{128, 48000, 6144000, 0xE0, 0x00, 0x01, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
415+
{128, 16000, 2048000, 0x20, 0x00, 0x31, 0x35, 0x08, 0x19, 0x1F, 0x3F},
416+
{128, 44100, 5644800, 0xE0, 0x00, 0x01, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
417+
{128, 48000, 6144000, 0xE0, 0x00, 0x01, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
418418
{144, 8000, 1152000, 0x20, 0x00, 0x03, 0x35, 0x8A, 0x1B, 0x23, 0x47},
419419
{144, 16000, 2304000, 0x20, 0x00, 0x11, 0x35, 0x8A, 0x1B, 0x23, 0x47},
420420
{192, 8000, 1536000, 0x60, 0x02, 0x0D, 0x75, 0x8A, 0x1B, 0x1F, 0x7F},
@@ -423,10 +423,10 @@ static const struct _coeff_div coeff_div_v3[] = {
423423

424424
{200, 48000, 9600000, 0x04, 0x04, 0x0F, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
425425
{250, 48000, 12000000, 0x04, 0x04, 0x0F, 0x2D, 0xCA, 0x0A, 0x27, 0x27},
426-
{256, 8000, 2048000, 0x60, 0x00, 0x31, 0x35, 0x8A, 0x1B, 0x1F, 0x7F},
427-
{256, 16000, 4096000, 0x20, 0x00, 0x01, 0x35, 0x8A, 0x1B, 0x1F, 0x3F},
428-
{256, 44100, 11289600, 0xE0, 0x00, 0x30, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
429-
{256, 48000, 12288000, 0xE0, 0x00, 0x30, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
426+
{256, 8000, 2048000, 0x60, 0x00, 0x31, 0x35, 0x08, 0x19, 0x1F, 0x7F},
427+
{256, 16000, 4096000, 0x20, 0x00, 0x01, 0x35, 0x08, 0x19, 0x1F, 0x3F},
428+
{256, 44100, 11289600, 0xE0, 0x01, 0x01, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
429+
{256, 48000, 12288000, 0xE0, 0x01, 0x01, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
430430
{288, 8000, 2304000, 0x20, 0x00, 0x01, 0x35, 0x8A, 0x1B, 0x23, 0x47},
431431
{384, 8000, 3072000, 0x60, 0x02, 0x05, 0x75, 0x8A, 0x1B, 0x1F, 0x7F},
432432
{384, 16000, 6144000, 0x20, 0x02, 0x03, 0x35, 0x8A, 0x1B, 0x1F, 0x3F},
@@ -435,10 +435,10 @@ static const struct _coeff_div coeff_div_v3[] = {
435435

436436
{400, 48000, 19200000, 0xE4, 0x04, 0x35, 0x6d, 0xCA, 0x0A, 0x1F, 0x1F},
437437
{500, 48000, 24000000, 0xF8, 0x04, 0x3F, 0x6D, 0xCA, 0x0A, 0x1F, 0x1F},
438-
{512, 8000, 4096000, 0x60, 0x00, 0x01, 0x35, 0x8A, 0x1B, 0x1F, 0x7F},
439-
{512, 16000, 8192000, 0x20, 0x00, 0x30, 0x35, 0x8A, 0x1B, 0x1F, 0x3F},
440-
{512, 44100, 22579200, 0xE0, 0x00, 0x00, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
441-
{512, 48000, 24576000, 0xE0, 0x00, 0x00, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
438+
{512, 8000, 4096000, 0x60, 0x00, 0x01, 0x08, 0x19, 0x1B, 0x1F, 0x7F},
439+
{512, 16000, 8192000, 0x20, 0x00, 0x30, 0x35, 0x08, 0x19, 0x1F, 0x3F},
440+
{512, 44100, 22579200, 0xE0, 0x00, 0x00, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
441+
{512, 48000, 24576000, 0xE0, 0x00, 0x00, 0x2D, 0x48, 0x08, 0x1F, 0x1F},
442442
{768, 8000, 6144000, 0x60, 0x02, 0x11, 0x35, 0x8A, 0x1B, 0x1F, 0x7F},
443443
{768, 16000, 12288000, 0x20, 0x02, 0x01, 0x35, 0x8A, 0x1B, 0x1F, 0x3F},
444444
{768, 32000, 24576000, 0xE0, 0x02, 0x30, 0x2D, 0xCA, 0x0A, 0x1F, 0x1F},
@@ -835,14 +835,14 @@ static void es8326_jack_detect_handler(struct work_struct *work)
835835
dev_dbg(comp->dev, "Report hp remove event\n");
836836
snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
837837
/* mute adc when mic path switch */
838-
regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33);
839838
regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44);
840839
regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x66);
841840
es8326->hp = 0;
842841
}
843842
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01);
844843
regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x0a);
845844
regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x03);
845+
regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9);
846846
/*
847847
* Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event
848848
*/
@@ -865,6 +865,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)
865865
* set auto-check mode, then restart jack_detect_work after 400ms.
866866
* Don't report jack status.
867867
*/
868+
regmap_write(es8326->regmap, ES8326_INT_SOURCE,
869+
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON));
868870
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01);
869871
es8326_enable_micbias(es8326->component);
870872
usleep_range(50000, 70000);
@@ -891,7 +893,6 @@ static void es8326_jack_detect_handler(struct work_struct *work)
891893
snd_soc_jack_report(es8326->jack,
892894
SND_JACK_HEADSET, SND_JACK_HEADSET);
893895

894-
regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33);
895896
regmap_update_bits(es8326->regmap, ES8326_PGA_PDN,
896897
0x08, 0x08);
897898
regmap_update_bits(es8326->regmap, ES8326_PGAGAIN,
@@ -987,7 +988,7 @@ static int es8326_resume(struct snd_soc_component *component)
987988
regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E);
988989
regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0);
989990
usleep_range(10000, 15000);
990-
regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0xe9);
991+
regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0xd9);
991992
regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xcb);
992993
/* set headphone default type and detect pin */
993994
regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x83);
@@ -1038,8 +1039,7 @@ static int es8326_resume(struct snd_soc_component *component)
10381039
es8326_enable_micbias(es8326->component);
10391040
usleep_range(50000, 70000);
10401041
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00);
1041-
regmap_write(es8326->regmap, ES8326_INT_SOURCE,
1042-
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON));
1042+
regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9);
10431043
regmap_write(es8326->regmap, ES8326_INTOUT_IO,
10441044
es8326->interrupt_clk);
10451045
regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
@@ -1060,6 +1060,8 @@ static int es8326_resume(struct snd_soc_component *component)
10601060
es8326->hp = 0;
10611061
es8326->hpl_vol = 0x03;
10621062
es8326->hpr_vol = 0x03;
1063+
1064+
es8326_irq(es8326->irq, es8326);
10631065
return 0;
10641066
}
10651067

@@ -1070,6 +1072,9 @@ static int es8326_suspend(struct snd_soc_component *component)
10701072
cancel_delayed_work_sync(&es8326->jack_detect_work);
10711073
es8326_disable_micbias(component);
10721074
es8326->calibrated = false;
1075+
regmap_write(es8326->regmap, ES8326_CLK_MUX, 0x2d);
1076+
regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x00);
1077+
regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b);
10731078
regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_OFF);
10741079
regcache_cache_only(es8326->regmap, true);
10751080
regcache_mark_dirty(es8326->regmap);

sound/soc/codecs/es8326.h

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

106106
/* ES8326_CLK_CTL */
107-
#define ES8326_CLK_ON (0x7e << 0)
107+
#define ES8326_CLK_ON (0x7f << 0)
108108
#define ES8326_CLK_OFF (0 << 0)
109109

110110
/* ES8326_CLK_INV */

0 commit comments

Comments
 (0)