Skip to content

Commit aa98697

Browse files
shumingfanbroonie
authored andcommitted
ASoC: rt5645: improve the depop sequences of CBJ detection
This patch will improve the depop function of CBJ detection before the headphone playback when the system resumes. We also want to complete the CBJ detection in the system-level resume function. It could avoid triggering the detection at the playing state of headphones. Signed-off-by: Shuming Fan <shumingf@realtek.com> Link: https://lore.kernel.org/r/20230818023732.2153170-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cfee987 commit aa98697

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

sound/soc/codecs/rt5645.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static const struct reg_sequence init_list[] = {
8080

8181
static const struct reg_sequence rt5650_init_list[] = {
8282
{0xf6, 0x0100},
83+
{RT5645_PWR_ANLG1, 0x02},
8384
};
8485

8586
static const struct reg_default rt5645_reg[] = {
@@ -1696,6 +1697,9 @@ static void hp_amp_power(struct snd_soc_component *component, int on)
16961697
regmap_write(rt5645->regmap, RT5645_PR_BASE +
16971698
RT5645_MAMP_INT_REG2, 0xfc00);
16981699
snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140);
1700+
snd_soc_component_update_bits(component, RT5645_PWR_ANLG1,
1701+
RT5645_PWR_HP_L | RT5645_PWR_HP_R,
1702+
RT5645_PWR_HP_L | RT5645_PWR_HP_R);
16991703
msleep(90);
17001704
} else {
17011705
/* depop parameters */
@@ -1743,7 +1747,8 @@ static void hp_amp_power(struct snd_soc_component *component, int on)
17431747
snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140);
17441748
msleep(100);
17451749
snd_soc_component_write(component, RT5645_DEPOP_M1, 0x0001);
1746-
1750+
snd_soc_component_update_bits(component, RT5645_PWR_ANLG1,
1751+
RT5645_PWR_HP_L | RT5645_PWR_HP_R, 0);
17471752
} else {
17481753
snd_soc_component_update_bits(component, RT5645_DEPOP_M1,
17491754
RT5645_HP_SG_MASK |
@@ -3150,7 +3155,7 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse
31503155
unsigned int val;
31513156

31523157
if (jack_insert) {
3153-
regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06);
3158+
regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0206);
31543159

31553160
/* for jack type detect */
31563161
snd_soc_dapm_force_enable_pin(dapm, "LDO2");
@@ -3195,6 +3200,8 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse
31953200
if (rt5645->pdata.level_trigger_irq)
31963201
regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
31973202
RT5645_JD_1_1_MASK, RT5645_JD_1_1_NOR);
3203+
3204+
regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06);
31983205
} else { /* jack out */
31993206
rt5645->jack_type = 0;
32003207

@@ -4003,13 +4010,13 @@ static int rt5645_i2c_probe(struct i2c_client *i2c)
40034010

40044011
regmap_write(rt5645->regmap, RT5645_AD_DA_MIXER, 0x8080);
40054012

4006-
ret = regmap_register_patch(rt5645->regmap, init_list,
4013+
ret = regmap_multi_reg_write(rt5645->regmap, init_list,
40074014
ARRAY_SIZE(init_list));
40084015
if (ret != 0)
40094016
dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
40104017

40114018
if (rt5645->codec_type == CODEC_TYPE_RT5650) {
4012-
ret = regmap_register_patch(rt5645->regmap, rt5650_init_list,
4019+
ret = regmap_multi_reg_write(rt5645->regmap, rt5650_init_list,
40134020
ARRAY_SIZE(rt5650_init_list));
40144021
if (ret != 0)
40154022
dev_warn(&i2c->dev, "Apply rt5650 patch failed: %d\n",
@@ -4220,8 +4227,7 @@ static int __maybe_unused rt5645_sys_resume(struct device *dev)
42204227

42214228
if (rt5645->hp_jack) {
42224229
rt5645->jack_type = 0;
4223-
queue_delayed_work(system_power_efficient_wq,
4224-
&rt5645->jack_detect_work, msecs_to_jiffies(0));
4230+
rt5645_jack_detect_work(&rt5645->jack_detect_work.work);
42254231
}
42264232
return 0;
42274233
}

0 commit comments

Comments
 (0)