Merge "(CR):[kane]:tp:Modify the charger change tp parameter" into huaqin/exynos9609
authorhq_qiaoquanbin_tmp <qiaoquanbin@huaqin.com>
Thu, 6 Dec 2018 02:34:27 +0000 (10:34 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:30:02 +0000 (17:30 +0800)
Change-Id: I9df38bd907c121f3313f79af9300bcc5338b142c
Signed-off-by: hq_qiaoquanbin_tmp <qiaoquanbin@huaqin.com>
drivers/input/touchscreen/hxchipset/himax_common.c
drivers/input/touchscreen/hxchipset/himax_common.h
drivers/input/touchscreen/hxchipset/himax_platform.c
drivers/input/touchscreen/nt36xxx/nt36xxx.c
drivers/input/touchscreen/nt36xxx/nt36xxx.h

index bca87f9222640eb88b69c8a93d67b8cff7e610e9..eca4f3f02343ea29351fdd2ee40b95fdf32fa0ba 100755 (executable)
@@ -2415,6 +2415,34 @@ device_destroy:
        return -ENODEV;
 }
 
+#if defined(HX_USB_DETECT_GLOBAL)
+static int charger_notifier_callback(struct notifier_block *nb,
+                                                               unsigned long val, void *v) {
+       int ret = 0;
+       struct power_supply *psy = NULL;
+       struct himax_ts_data *ts = container_of(nb, struct himax_ts_data, charger_notif);
+       union power_supply_propval prop;
+
+       psy= power_supply_get_by_name("usb");
+       if (!psy) {
+               return -EINVAL;
+               E("Couldn't get usbpsy\n");
+       }
+       if (!strcmp(psy->desc->name, "usb")) {
+               if (psy && ts && val == POWER_SUPPLY_PROP_STATUS) {
+                       ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,&prop);
+                       if (ret < 0) {
+                               E("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
+                               return ret;
+                       } else {
+                               USB_detect_flag = prop.intval;
+                       }
+               }
+       }
+       return 0;
+}
+#endif
+
 int himax_chip_common_init(void)
 {
 
@@ -2563,6 +2591,13 @@ FW_force_upgrade:
 #if defined(HX_USB_DETECT_CALLBACK) || defined(HX_USB_DETECT_GLOBAL)
        ts->usb_connected = 0x00;
        ts->cable_config = pdata->cable_config;
+
+       ts->charger_notif.notifier_call = charger_notifier_callback;
+       ret = power_supply_reg_notifier(&ts->charger_notif);
+       if (ret) {
+               E("Unable to register charger_notifier: %d\n",ret);
+               goto err_register_charger_notify_failed;
+       }
 #endif
 #ifdef HX_PROTOCOL_A
        ts->protocol_type = PROTOCOL_TYPE_A;
@@ -2677,6 +2712,11 @@ err_detect_failed:
        }
 err_update_wq_failed:
 #endif
+#if defined(HX_USB_DETECT_GLOBAL)
+err_register_charger_notify_failed:
+       if (ts->charger_notif.notifier_call)
+               power_supply_unreg_notifier(&ts->charger_notif);
+#endif
 error_ic_detect_failed:
        if (gpio_is_valid(pdata->gpio_irq)) {
                gpio_free(pdata->gpio_irq);
index ae99bf5bc0e32782d76ef3f4c8ed20a38da82509..a5ed349eecff065db74ae62d9dd5ceb55f10c25c 100755 (executable)
@@ -67,7 +67,7 @@
 /*#define HX_GESTURE_TRACK*/
 /*#define HX_HIGH_SENSE*/
 /*#define HX_PALM_REPORT*/
-/*#define HX_USB_DETECT_GLOBAL*/
+#define HX_USB_DETECT_GLOBAL
 /*#define HX_USB_DETECT_CALLBACK*/
 /*#define HX_PROTOCOL_A*/                              /* for MTK special platform.If turning on,it will report to system by using specific format. */
 /*#define HX_RESUME_HW_RESET*/
        /*#define HX_PLATFOME_DEFINE_KEY*/              /* for specfic platform to set key(button) */
 #endif
 
+#ifdef HX_USB_DETECT_GLOBAL
+#include <linux/power_supply.h>
+#endif
+
 #define HX_KEY_MAX_COUNT             4
 #define DEFAULT_RETRY_CNT            3
 
@@ -368,9 +372,8 @@ struct himax_ts_data {
 #if defined(HX_USB_DETECT_CALLBACK) || defined(HX_USB_DETECT_GLOBAL)
        uint8_t usb_connected;
        uint8_t *cable_config;
+       struct notifier_block charger_notif;
 #endif
-
-
 };
 
 struct himax_debug {
index 696b0b0f08fdc3d83a8405f2625a49a5b6a17ce9..4e038e899e9d7fbe63fbaeca0d93fee32fdecc4b 100755 (executable)
@@ -682,11 +682,9 @@ int fb_notifier_callback(struct notifier_block *self,
        struct fb_event *evdata = data;
        int *blank;
        struct himax_ts_data *ts =
-           container_of(self, struct himax_ts_data, fb_notif);
-       I(" %s\n", __func__);
+               container_of(self, struct himax_ts_data, fb_notif);
 
-       if (evdata && evdata->data && event == FB_EVENT_BLANK && ts &&
-           ts->client) {
+       if (evdata && evdata->data && event == FB_EVENT_BLANK && ts && ts->client) {
                blank = evdata->data;
 
                switch (*blank) {
@@ -743,8 +741,14 @@ int himax_chip_common_probe(struct i2c_client *client, const struct i2c_device_i
 
 int himax_chip_common_remove(struct i2c_client *client)
 {
+       struct himax_ts_data *ts = private_ts;
        himax_chip_common_deinit();
 
+#if defined(HX_USB_DETECT_GLOBAL)
+       if (ts->charger_notif.notifier_call)
+               power_supply_unreg_notifier(&ts->charger_notif);
+#endif
+
        return 0;
 }
 
index f5f3f76ea4e7800cc6fddd0ca28c346bd50ae790..72d4020bc8bf02504aacbc591a76a546b7849263 100755 (executable)
 #elif defined(CONFIG_HAS_EARLYSUSPEND)
 #include <linux/earlysuspend.h>
 #endif
+
+#include "nt36xxx.h"
+
 #if defined(CONFIG_CHARGER_NOTIFY)
 #include <linux/power_supply.h>
 #endif
 
-#include "nt36xxx.h"
-
 #if NVT_TOUCH_ESD_PROTECT
 #include <linux/jiffies.h>
 
@@ -1809,7 +1810,7 @@ static int charger_notifier_callback(struct notifier_block *nb,
        }
        if (!strcmp(psy->desc->name, "usb")){
                if (psy && ts && val == POWER_SUPPLY_PROP_STATUS) {
-                       ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,&prop);
+                       ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,&prop);
                        if (ret < 0) {
                                NVT_ERR("Couldn't get POWER_SUPPLY_PROP_ONLINE rc=%d\n", ret);
                                return ret;
@@ -1822,7 +1823,7 @@ static int charger_notifier_callback(struct notifier_block *nb,
                                                  ts->usb_connected = USB_DETECT_OUT;
                                         }
                                         if (bTouchIsAwake){
-                                                queue_work(ts->nvt_charger_notify_wq, &ts->charger_notify_work);
+                                               queue_work(ts->nvt_charger_notify_wq, &ts->charger_notify_work);
                                        }
                                }
                        }
index 9f4415fcd77511eafc76f19ab2d5e238fea6f8db..21c3558eb3096a31b6ddd1c4288cf5d50f752c46 100755 (executable)
@@ -30,6 +30,7 @@
 #include "nt36xxx_mem_map.h"
 
 #define NVT_DEBUG 0
+#define CONFIG_CHARGER_NOTIFY
 
 //---GPIO number---
 #define NVTTOUCH_RST_PIN 980