From: Richard Fitzgerald Date: Fri, 4 Aug 2017 10:26:39 +0000 (+0100) Subject: extcon: madera: Mark output shorted when less than short impedance X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=84fe47af5f69f9619b9266800a45a40854ac5221;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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);