Export usb connection status
authorChengwei Yang <chengwei.yang@intel.com>
Wed, 26 Sep 2012 04:28:00 +0000 (12:28 +0800)
committerChengwei Yang <chengwei.yang@intel.com>
Wed, 26 Sep 2012 07:16:55 +0000 (15:16 +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.

Change-Id: I430e588069a807b195cb364846d1a6421cafff14
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
arch/x86/platform/intel-mid/device_libs/platform_msic_audio.c
drivers/usb/otg/penwell_otg.c

index b1f0006..773f455 100644 (file)
@@ -56,7 +56,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 7988b3f..4553226 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
 #include <linux/wakelock.h>
+#include <linux/jack.h>
 #include <asm/intel_scu_ipc.h>
 #include <asm/intel-mid.h>
 #include "../core/usb.h"
@@ -2482,6 +2483,14 @@ static void penwell_otg_psc_notify_work(struct work_struct *work)
        power_supply_charger_event(psc_cap);
 }
 
+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,
@@ -2493,9 +2502,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);
 
@@ -2704,7 +2716,6 @@ static void penwell_otg_work(struct work_struct *work)
                                penwell_otg_start_ulpi_poll();
 
                        iotg->otg.state = OTG_STATE_B_PERIPHERAL;
-
                } else if ((hsm->b_bus_req || hsm->power_up || hsm->adp_change
                                || hsm->otg_srp_reqd) && !hsm->b_srp_fail_tmr) {
 
@@ -3712,8 +3723,15 @@ 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