ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / drivers / headset_observe / rk_headset_irq_hook_adc.c
old mode 100755 (executable)
new mode 100644 (file)
index 8fb3bc4..08f2bff
@@ -81,6 +81,12 @@ extern int rt5631_headset_mic_detect(bool headset_status);
 #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224)
 extern int rt3261_headset_mic_detect(int jack_insert);
 #endif
+#if defined(CONFIG_SND_SOC_ES8316)
+extern int es8316_headset_detect(int jack_insert);
+#endif
+#if defined(CONFIG_SND_SOC_CX2072X)
+extern int cx2072x_jack_report(void);
+#endif
 
 /* headset private data */
 struct headset_priv {
@@ -166,6 +172,11 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
        DBG("(headset in is %s)headset status is %s\n",
                pdata->headset_insert_type?"high level":"low level",
                headset_info->headset_status?"in":"out");
+
+       #if defined(CONFIG_SND_SOC_ES8316)
+       es8316_headset_detect(headset_info->headset_status);
+       #endif
+
        if(headset_info->headset_status == HEADSET_IN)
        {
                if(pdata->chan != 0)
@@ -189,7 +200,7 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
        }
        else if(headset_info->headset_status == HEADSET_OUT)
        {
-               headset_info->cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
+               headset_info->cur_headset_status = HEADSET_OUT;
                cancel_delayed_work(&headset_info->hook_work);
                if(headset_info->isMic)
                {
@@ -203,7 +214,8 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
                        #endif
                        #ifdef CONFIG_SND_SOC_RT5631_PHONE
                        rt5631_headset_mic_detect(false);
-                       #endif                          
+                       #endif
+                       headset_info->isMic = 0;
                }       
 
                if(pdata->headset_insert_type == HEADSET_IN_HIGH)
@@ -287,6 +299,13 @@ static void hook_once_work(struct work_struct *work)
        }
 
        headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC;
+
+       #if defined(CONFIG_SND_SOC_CX2072X)
+       if (cx2072x_jack_report() != -1)
+               headset_info->cur_headset_status =
+                       (cx2072x_jack_report() == 3) ?
+                       BIT_HEADSET : BIT_HEADSET_NO_MIC;
+       #endif
        
        switch_set_state(&headset_info->sdev, headset_info->cur_headset_status);        
        DBG("%s notice android headset status = %d\n",__func__,headset_info->cur_headset_status);
@@ -454,13 +473,8 @@ int rk_headset_adc_probe(struct platform_device *pdev,struct rk_headset_pdata *p
        }
 
        input_set_capability(headset->input_dev, EV_KEY, HOOK_KEY_CODE);
-//------------------------------------------------------------------
-       if (pdata->headset_gpio) {
-               if(!pdata->headset_gpio){
-                       dev_err(&pdev->dev,"failed init headset,please full hook_io_init function in board\n");
-                       goto failed_free_dev;
-               }
 
+       if (pdata->headset_gpio) {
                headset->irq[HEADSET] = gpio_to_irq(pdata->headset_gpio);
 
                if(pdata->headset_insert_type == HEADSET_IN_HIGH)
@@ -472,10 +486,11 @@ int rk_headset_adc_probe(struct platform_device *pdev,struct rk_headset_pdata *p
                        goto failed_free_dev;
                if (pdata->headset_wakeup)
                        enable_irq_wake(headset->irq[HEADSET]);
-       }
-       else
+       } else {
+               dev_err(&pdev->dev, "failed init headset,please full hook_io_init function in board\n");
                goto failed_free_dev;
-//------------------------------------------------------------------
+       }
+
        if(pdata->chan != NULL)
        {
                headset->chan = pdata->chan;