touch/gti: Support pm qos.

Bug: 201610482
Signed-off-by: Super Liu <supercjliu@google.com>
Change-Id: I47604343ce0abe90b107ed6b77307d62e6216e50
diff --git a/goog_touch_interface.c b/goog_touch_interface.c
index db5666b..266e9c9 100644
--- a/goog_touch_interface.c
+++ b/goog_touch_interface.c
@@ -2686,6 +2686,8 @@
 	init_completion(&pm->bus_resumed);
 	complete_all(&pm->bus_resumed);
 
+	/* init pm_qos. */
+	cpu_latency_qos_add_request(&gti->pm_qos_req, PM_QOS_DEFAULT_VALUE);
 	pm->enabled = true;
 
 	return ret;
@@ -2697,9 +2699,13 @@
 static int goog_pm_remove(struct goog_touch_interface *gti)
 {
 	struct gti_pm* pm = &gti->pm;
-	pm->enabled = false;
-	if (pm->event_wq)
-		destroy_workqueue(pm->event_wq);
+
+	if (pm->enabled) {
+		pm->enabled = false;
+		cpu_latency_qos_remove_request(&gti->pm_qos_req);
+		if (pm->event_wq)
+			destroy_workqueue(pm->event_wq);
+	}
 	return 0;
 }
 
@@ -2723,12 +2729,14 @@
 	struct goog_touch_interface *gti = (struct goog_touch_interface *)data;
 
 	ATRACE_BEGIN(__func__);
+	cpu_latency_qos_update_request(&gti->pm_qos_req, 100 /* usec */);
 	if (gti->vendor_irq_thread_fn)
 		ret = gti->vendor_irq_thread_fn(irq, gti->vendor_irq_cookie);
 	else
 		ret = IRQ_HANDLED;
 	goog_input_process(gti);
 	gti_debug_hc_update(gti, false);
+	cpu_latency_qos_update_request(&gti->pm_qos_req, PM_QOS_DEFAULT_VALUE);
 	ATRACE_END();
 
 	return ret;
diff --git a/goog_touch_interface.h b/goog_touch_interface.h
index 0bb1e36..379284c 100644
--- a/goog_touch_interface.h
+++ b/goog_touch_interface.h
@@ -12,6 +12,7 @@
 #include <drm/drm_bridge.h>
 #include <drm/drm_connector.h>
 #include <linux/kfifo.h>
+#include <linux/pm_qos.h>
 
 #include "heatmap.h"
 #include "touch_offload.h"
@@ -465,6 +466,7 @@
  * @screen_protector_mode_setting: the setting of screen protector mode.
  * @tbn_register_mask: the tbn_mask that used to request/release touch bus.
  * @pm: struct that used by gti pm.
+ * @pm_qos_req: struct that used by pm qos.
  * @panel_is_lp_mode: display is in low power mode.
  * @force_legacy_report: force to directly report input by kernel input API.
  * @offload_enable: touch offload is enabled or not.
@@ -518,6 +520,7 @@
 	enum gti_screen_protector_mode screen_protector_mode_setting;
 	u32 tbn_register_mask;
 	struct gti_pm pm;
+	struct pm_qos_request pm_qos_req;
 
 	bool panel_is_lp_mode;
 	bool force_legacy_report;