#define ARIZONA_ACCDET_MODE_HPL 1
#define ARIZONA_ACCDET_MODE_HPR 2
+#define ARIZONA_HPDET_MAX 10000
+
#define HPDET_DEBOUNCE 500
struct arizona_extcon_info {
bool hpdet_active;
bool hpdet_done;
+ bool hpdet_retried;
int num_hpdet_res;
unsigned int hpdet_res[3];
NULL,
};
+static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
+
static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
unsigned int magic)
{
/* If we go out of range report top of range */
if (val < 100 || val > 0x3fb) {
dev_dbg(arizona->dev, "Measurement out of range\n");
- return 10000;
+ return ARIZONA_HPDET_MAX;
}
dev_dbg(arizona->dev, "HPDET read %d in range %d\n",
/* Take the headphone impedance for the main report */
*reading = info->hpdet_res[0];
+ /* Sometimes we get false readings due to slow insert */
+ if (*reading >= ARIZONA_HPDET_MAX && !info->hpdet_retried) {
+ dev_dbg(arizona->dev, "Retrying high impedance\n");
+ info->num_hpdet_res = 0;
+ info->hpdet_retried = true;
+ arizona_start_hpdet_acc_id(info);
+ pm_runtime_put(info->dev);
+ return -EAGAIN;
+ }
+
/*
* Either the two grounds measure differently or we
* measure the mic as high impedance.
info->hpdet_res[i] = 0;
info->mic = false;
info->hpdet_done = false;
+ info->hpdet_retried = false;
for (i = 0; i < info->num_micd_ranges; i++)
input_report_key(info->input,