From 24f6d92ddb50b574aaf715c5de6fd3928192ef51 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Fri, 4 Aug 2017 11:26:39 +0100 Subject: [PATCH] extcon: madera: Mark output shorted when less than short impedance We should be updating out_shorted[] based on the measured impedance so that the codec driver knows whether it is safe to enable the output. Change-Id: Idfa200589d638f9ae3b501debfa1546d4ed1615e Signed-off-by: Richard Fitzgerald --- drivers/extcon/extcon-madera.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index 4a199c4b0a1c..6900ac302210 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -730,19 +730,22 @@ static void madera_extcon_hp_clamp(struct madera_extcon *info, bool clamp) } /* Restore the desired state while not doing the clamp */ - if (!clamp && - (madera->hp_impedance_x100[0]) > info->hpdet_short_x100) && - !ep_sel) { - ret = regmap_update_bits(madera->regmap, - MADERA_OUTPUT_ENABLES_1, - (MADERA_OUT1L_ENA | - MADERA_OUT1R_ENA) << - (2 * (info->pdata->output - 1)), - madera->hp_ena); - if (ret) - dev_warn(info->dev, - "Failed to restore headphone outputs: %d\n", - ret); + if (!clamp) { + madera->out_shorted[0] = (madera->hp_impedance_x100[0] <= + info->hpdet_short_x100); + + if (!madera->out_shorted[0] && !ep_sel) { + ret = regmap_update_bits(madera->regmap, + MADERA_OUTPUT_ENABLES_1, + (MADERA_OUT1L_ENA | + MADERA_OUT1R_ENA) << + (2 * (info->pdata->output - 1)), + madera->hp_ena); + if (ret) + dev_warn(info->dev, + "Failed to restore headphone outputs: %d\n", + ret); + } } snd_soc_dapm_mutex_unlock(madera->dapm); -- 2.20.1