Skip to content

Commit e77a408

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: cs42l43: Correct handling of 3-pole jack load detection
The load detection process for 3-pole jacks requires slightly updated reference values to ensure an accurate result. Update the code to apply different tunings for the 3-pole and 4-pole cases. This also updates the thresholds overall so update the relevant comments to match. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20260130150927.2964664-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 6b64112 commit e77a408

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

sound/soc/codecs/cs42l43-jack.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,23 @@ void cs42l43_bias_sense_timeout(struct work_struct *work)
496496
pm_runtime_put_autosuspend(priv->dev);
497497
}
498498

499-
static void cs42l43_start_load_detect(struct cs42l43_codec *priv)
499+
static const struct reg_sequence cs42l43_3pole_patch[] = {
500+
{ 0x4000, 0x00000055 },
501+
{ 0x4000, 0x000000AA },
502+
{ 0x17420, 0x8500F300 },
503+
{ 0x17424, 0x36003E00 },
504+
{ 0x4000, 0x00000000 },
505+
};
506+
507+
static const struct reg_sequence cs42l43_4pole_patch[] = {
508+
{ 0x4000, 0x00000055 },
509+
{ 0x4000, 0x000000AA },
510+
{ 0x17420, 0x7800E600 },
511+
{ 0x17424, 0x36003800 },
512+
{ 0x4000, 0x00000000 },
513+
};
514+
515+
static void cs42l43_start_load_detect(struct cs42l43_codec *priv, bool mic)
500516
{
501517
struct cs42l43 *cs42l43 = priv->core;
502518

@@ -520,6 +536,15 @@ static void cs42l43_start_load_detect(struct cs42l43_codec *priv)
520536
dev_err(priv->dev, "Load detect HP power down timed out\n");
521537
}
522538

539+
if (mic)
540+
regmap_multi_reg_write_bypassed(cs42l43->regmap,
541+
cs42l43_4pole_patch,
542+
ARRAY_SIZE(cs42l43_4pole_patch));
543+
else
544+
regmap_multi_reg_write_bypassed(cs42l43->regmap,
545+
cs42l43_3pole_patch,
546+
ARRAY_SIZE(cs42l43_3pole_patch));
547+
523548
regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN3,
524549
CS42L43_ADC1_EN_MASK | CS42L43_ADC2_EN_MASK, 0);
525550
regmap_update_bits(cs42l43->regmap, CS42L43_DACCNFG2, CS42L43_HP_HPF_EN_MASK, 0);
@@ -598,7 +623,7 @@ static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic)
598623

599624
reinit_completion(&priv->load_detect);
600625

601-
cs42l43_start_load_detect(priv);
626+
cs42l43_start_load_detect(priv, mic);
602627
time_left = wait_for_completion_timeout(&priv->load_detect,
603628
msecs_to_jiffies(CS42L43_LOAD_TIMEOUT_MS));
604629
cs42l43_stop_load_detect(priv);
@@ -622,11 +647,11 @@ static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic)
622647
}
623648

624649
switch (val & CS42L43_AMP3_RES_DET_MASK) {
625-
case 0x0: // low impedance
626-
case 0x1: // high impedance
650+
case 0x0: // < 22 Ohm impedance
651+
case 0x1: // < 150 Ohm impedance
652+
case 0x2: // < 1000 Ohm impedance
627653
return CS42L43_JACK_HEADPHONE;
628-
case 0x2: // lineout
629-
case 0x3: // Open circuit
654+
case 0x3: // > 1000 Ohm impedance
630655
return CS42L43_JACK_LINEOUT;
631656
default:
632657
return -EINVAL;

0 commit comments

Comments
 (0)