Export usb connection status
authorChengwei Yang <chengwei.yang@intel.com>
Thu, 13 Jun 2013 01:45:58 +0000 (09:45 +0800)
committerYin Kangkai <kangkai.yin@linux.intel.com>
Thu, 26 Dec 2013 14:33:49 +0000 (22:33 +0800)
There are several components depends on kernel export usb connection
status correctly. First, system-server check usb status by calling OEM
interface to launch usb-server; second, usb-server does the usb mode
setting work and launch syspopup. In addition, setting usb mode from UI
depends on usb-server too.

This also fix TZSP-3142.

Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
[Port from mfld kernel and support CTP]
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
arch/x86/platform/intel-mid/device_libs/platform_ctp_audio.c
arch/x86/platform/intel-mid/device_libs/platform_msic_audio.c
drivers/usb/otg/penwell_otg.c

index 2d7e256..6ae3fd4 100644 (file)
@@ -30,7 +30,7 @@ static struct ctp_audio_platform_data ctp_audio_pdata = {
 
 #ifdef CONFIG_JACK_MON
 static struct jack_platform_data jack_data = {
-       .usb_online             = -1,
+       .usb_online             = 0,
        .charger_online         = -1,
        .hdmi_online            = -1,
        .earjack_online         = 0,
index 0c0f304..183fa66 100644 (file)
@@ -44,7 +44,7 @@ static struct msic_audio_platform_data msic_audio_pdata = {
 
 #ifdef CONFIG_JACK_MON
 static struct jack_platform_data jack_data = {
-       .usb_online             = -1,
+       .usb_online             = 0,
        .charger_online         = -1,
        .hdmi_online            = -1,
        .earjack_online         = 0,
index d70ebca..efe7152 100644 (file)
@@ -38,7 +38,8 @@
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
 #include <linux/wakelock.h>
- #include <asm/intel_scu_pmic.h>
+#include <linux/jack.h>
+#include <asm/intel_scu_pmic.h>
 #include <asm/intel_scu_ipc.h>
 #include <asm/intel-mid.h>
 #include "../core/usb.h"
@@ -2946,6 +2947,14 @@ static void penwell_otg_sdp_check_work(struct work_struct *work)
        penwell_otg_update_chrg_cap(CHRG_SDP_INVAL, CHRG_CURR_SDP_INVAL);
 }
 
+static bool connected(enum usb_otg_state state)
+{
+       if (state == OTG_STATE_A_HOST || state == OTG_STATE_A_PERIPHERAL ||
+                       state == OTG_STATE_B_HOST || state == OTG_STATE_B_PERIPHERAL)
+               return true;
+       return false;
+}
+
 static void penwell_otg_work(struct work_struct *work)
 {
        struct penwell_otg              *pnw = container_of(work,
@@ -2957,9 +2966,12 @@ static void penwell_otg_work(struct work_struct *work)
        int                             retval;
        struct pci_dev                  *pdev;
        unsigned long                   flags;
+       enum usb_otg_state old_state;
+       enum usb_otg_state new_state;
 
+       old_state = iotg->otg.state;
        dev_dbg(pnw->dev,
-               "old state = %s\n", state_string(iotg->otg.state));
+               "old state = %s\n", state_string(old_state));
 
        pm_runtime_get_sync(pnw->dev);
 
@@ -4231,8 +4243,16 @@ static void penwell_otg_work(struct work_struct *work)
 
        pm_runtime_put_sync(pnw->dev);
 
+       new_state = iotg->otg.state;
        dev_dbg(pnw->dev,
-                       "new state = %s\n", state_string(iotg->otg.state));
+               "new state = %s\n", state_string(new_state));
+
+#ifdef CONFIG_JACK_MON
+       if (connected(old_state) && !connected(new_state))
+               jack_event_handler("usb", 0);
+       else if (!connected(old_state) && connected(new_state))
+               jack_event_handler("usb", 1);
+#endif
 }
 
 static ssize_t