extcon: madera: Mark output shorted when less than short impedance
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Fri, 4 Aug 2017 10:26:39 +0000 (11:26 +0100)
committer강신형 <s47.kang@samsung.com>
Tue, 19 Jun 2018 07:52:41 +0000 (16:52 +0900)
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 <rf@opensource.wolfsonmicro.com>
drivers/extcon/extcon-madera.c

index 4a199c4b0a1c96f23b11812d180b0964a0389f10..6900ac302210e3d23e35cf954c463b214846099e 100644 (file)
@@ -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);