Browse Source

touch: Add synaptics_tcm touch driver for khaje

Add synaptic touch module and register DRM Panel notifier.

Change-Id: Id8d83c359dec25daedf1e09735e4cba6cd3bd236
Signed-off-by: Raghu Dudda Papanna <[email protected]>
Raghu Dudda Papanna 2 years ago
parent
commit
7b9f8fe0cd

+ 10 - 0
Android.mk

@@ -66,5 +66,15 @@ ifeq ($(TOUCH_DLKM_ENABLE),  true)
 	include $(DLKM_DIR)/Build_external_kernelmodule.mk
 	###########################################################
 
+	###########################################################
+	include $(CLEAR_VARS)
+	LOCAL_SRC_FILES   := $(wildcard $(LOCAL_PATH)/**/*) $(wildcard $(LOCAL_PATH)/*)
+	LOCAL_MODULE              := synaptics_tcm_ts.ko
+	LOCAL_MODULE_KBUILD_NAME  := synaptics_tcm_ts.ko
+	LOCAL_MODULE_TAGS         := optional
+	#LOCAL_MODULE_DEBUG_ENABLE := true
+	LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+	include $(DLKM_DIR)/Build_external_kernelmodule.mk
+	###########################################################
 	endif # DLKM check
 endif

+ 15 - 0
Kbuild

@@ -11,6 +11,11 @@ endif
 	LINUX_INC += -include $(TOUCH_ROOT)/config/gki_kalamatouchconf.h
 #endif
 
+#ifeq ($(CONFIG_ARCH_KHAJE), y)
+	include $(TOUCH_ROOT)/config/gki_khajetouch.conf
+	LINUX_INC += -include $(TOUCH_ROOT)/config/gki_khajetouchconf.h
+#endif
+
 LINUX_INC +=	-Iinclude/linux \
 		-Iinclude/linux/drm \
 		-Iinclude/linux/gunyah \
@@ -121,4 +126,14 @@ ifeq ($(CONFIG_TOUCHSCREEN_DUMMY), y)
 	obj-$(CONFIG_MSM_TOUCH) += dummy_ts.o
 endif
 
+ifeq ($(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM), y)
+	synaptics_tcm_ts-y := \
+		 ./synaptics_tcm/synaptics_tcm_core.o \
+		 ./synaptics_tcm/synaptics_tcm_i2c.o \
+		 ./synaptics_tcm/synaptics_tcm_touch.o
+
+	obj-$(CONFIG_MSM_TOUCH) += synaptics_tcm_ts.o
+
+endif
+
 CDEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"

+ 5 - 0
config/gki_khajetouch.conf

@@ -0,0 +1,5 @@
+export CONFIG_TOUCHSCREEN_SYNAPTICS_TCM=y
+export CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_I2C=y
+export CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_CORE=y
+export CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_TOUCH=y
+export CONFIG_MSM_TOUCH=m

+ 10 - 0
config/gki_khajetouchconf.h

@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#define CONFIG_TOUCHSCREEN_SYNAPTICS_TCM 1
+#define CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_I2C 1
+#define CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_CORE 1
+#define CONFIG_TOUCHSCREEN_SYNAPTICS_TCM_TOUCH 1
+

+ 57 - 24
synaptics_tcm/synaptics_tcm_core.c

@@ -207,6 +207,9 @@ static struct device_attribute *dynamic_config_attrs[] = {
 	ATTRIFY(enable_glove),
 };
 
+extern int touch_module_init(void);
+extern void touch_module_exit(void);
+
 static ssize_t syna_tcm_sysfs_info_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -3044,7 +3047,7 @@ static int syna_tcm_suspend(struct device *dev)
 
 
 #ifdef CONFIG_DRM
-
+#if 0
 static int syna_tcm_early_suspend(struct device *dev)
 {
 #ifndef WAKEUP_GESTURE
@@ -3101,21 +3104,51 @@ static int syna_tcm_early_suspend(struct device *dev)
 
 	return 0;
 }
+#endif
 
-static int syna_tcm_fb_notifier_cb(struct notifier_block *nb,
-		unsigned long action, void *data)
+static void syna_tcm_fb_notifier_cb(enum panel_event_notifier_tag tag,
+                                struct panel_event_notification *notification,
+                                        void *pvt_data)
 {
 	int retval = 0;
-	int transition;
-	struct drm_panel_notifier *evdata = data;
-	struct syna_tcm_hcd *tcm_hcd =
-			container_of(nb, struct syna_tcm_hcd, fb_notifier);
-
-	if (!evdata)
-		return 0;
-
-	transition = *(int *)evdata->data;
-
+	struct syna_tcm_hcd *tcm_hcd = (struct syna_tcm_hcd *) pvt_data;
+
+	 if (!notification) {
+                pr_err("Invalid notification\n");
+                return;
+        }
+
+        pr_debug("Notification type:%d, early_trigger:%d",
+                        notification->notif_type,
+                        notification->notif_data.early_trigger);
+        switch (notification->notif_type) {
+        case DRM_PANEL_EVENT_UNBLANK:
+                if (notification->notif_data.early_trigger)
+                        pr_debug("resume notification pre commit\n");
+                else
+                  retval = syna_tcm_resume(&tcm_hcd->pdev->dev);
+                break;
+        case DRM_PANEL_EVENT_BLANK:
+                if (notification->notif_data.early_trigger) {
+                  retval = syna_tcm_suspend(&tcm_hcd->pdev->dev);
+                } else {
+                        pr_debug("suspend notification post commit\n");
+                }
+                break;
+        case DRM_PANEL_EVENT_BLANK_LP:
+                pr_debug("received lp event\n");
+                break;
+        case DRM_PANEL_EVENT_FPS_CHANGE:
+                pr_debug("Received fps change old fps:%d new fps:%d\n",
+                                notification->notif_data.old_fps,
+                                notification->notif_data.new_fps);
+                break;
+        default:
+                pr_debug("notification not serviced :%d\n",
+                                notification->notif_type);
+		break;
+	}
+#if 0
 	if (atomic_read(&tcm_hcd->firmware_flashing)
 		&& transition == DRM_PANEL_BLANK_POWERDOWN) {
 		retval = wait_event_interruptible_timeout(tcm_hcd->reflash_wq,
@@ -3149,9 +3182,8 @@ static int syna_tcm_fb_notifier_cb(struct notifier_block *nb,
 		tcm_hcd->fb_ready++;
 #endif
 	}
+#endif
 
-
-	return 0;
 }
 
 #elif CONFIG_FB
@@ -3313,6 +3345,7 @@ static int syna_tcm_probe(struct platform_device *pdev)
 	const struct syna_tcm_board_data *bdata;
 	const struct syna_tcm_hw_interface *hw_if;
 	struct drm_panel *active_panel = tcm_get_panel();
+	void *cookie;
 
 	hw_if = pdev->dev.platform_data;
 	if (!hw_if) {
@@ -3488,16 +3521,17 @@ static int syna_tcm_probe(struct platform_device *pdev)
 	}
 
 #ifdef CONFIG_DRM
-	tcm_hcd->fb_notifier.notifier_call = syna_tcm_fb_notifier_cb;
 	if (active_panel) {
-		retval = drm_panel_notifier_register(active_panel,
-				&tcm_hcd->fb_notifier);
-		if (retval < 0) {
+                cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY,
+                        PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH, active_panel,
+                        &syna_tcm_fb_notifier_cb, tcm_hcd);
+		if (!cookie) {
 			dev_err(&pdev->dev,
 					"%s: Failed to register fb notifier client\n",
 					__func__);
 			goto err_drm_reg;
 		}
+		tcm_hcd->notifier_cookie = cookie;
 	}
 
 #elif CONFIG_FB
@@ -3536,15 +3570,14 @@ static int syna_tcm_probe(struct platform_device *pdev)
 	mod_pool.tcm_hcd = tcm_hcd;
 	mod_pool.queue_work = true;
 	mod_pool.reconstructing = false;
-
+	touch_module_init();
 	return 0;
 
 
 err_create_run_kthread:
 #ifdef CONFIG_DRM
 	if (active_panel)
-		drm_panel_notifier_unregister(active_panel,
-				&tcm_hcd->fb_notifier);
+		panel_event_notifier_unregister(tcm_hcd->notifier_cookie);
 #elif CONFIG_FB
 	fb_unregister_client(&tcm_hcd->fb_notifier);
 #endif
@@ -3647,6 +3680,7 @@ static int syna_tcm_remove(struct platform_device *pdev)
 	const struct syna_tcm_board_data *bdata = tcm_hcd->hw_if->bdata;
 	struct drm_panel *active_panel = tcm_get_panel();
 
+	touch_module_exit();
 	mutex_lock(&mod_pool.mutex);
 
 	if (!list_empty(&mod_pool.list)) {
@@ -3687,8 +3721,7 @@ static int syna_tcm_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_DRM
 	if (active_panel)
-		drm_panel_notifier_unregister(active_panel,
-				&tcm_hcd->fb_notifier);
+		panel_event_notifier_unregister(tcm_hcd->notifier_cookie);
 #elif CONFIG_FB
 	fb_unregister_client(&tcm_hcd->fb_notifier);
 #endif

+ 3 - 1
synaptics_tcm/synaptics_tcm_core.h

@@ -40,9 +40,10 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-#include <linux/input/synaptics_tcm.h>
+#include "synaptics_tcm.h"
 #ifdef CONFIG_DRM
 #include <drm/drm_panel.h>
+#include <linux/soc/qcom/panel_event_notifier.h>
 #elif CONFIG_FB
 #include <linux/fb.h>
 #include <linux/notifier.h>
@@ -434,6 +435,7 @@ struct syna_tcm_hcd {
 #if defined(CONFIG_DRM) || defined(CONFIG_FB)
 	struct notifier_block fb_notifier;
 #endif
+	void   *notifier_cookie;
 	struct syna_tcm_buffer in;
 	struct syna_tcm_buffer out;
 	struct syna_tcm_buffer resp;

+ 4 - 9
synaptics_tcm/synaptics_tcm_touch.c

@@ -1252,21 +1252,16 @@ static struct syna_tcm_module_cb touch_module = {
 	.early_suspend = touch_early_suspend,
 };
 
-static int __init touch_module_init(void)
+ int touch_module_init(void)
 {
 	return syna_tcm_add_module(&touch_module, true);
 }
-
-static void __exit touch_module_exit(void)
+EXPORT_SYMBOL(touch_module_init);
+ void touch_module_exit(void)
 {
 	syna_tcm_add_module(&touch_module, false);
 
 	wait_for_completion(&touch_remove_complete);
 }
+EXPORT_SYMBOL(touch_module_exit);
 
-module_init(touch_module_init);
-module_exit(touch_module_exit);
-
-MODULE_AUTHOR("Synaptics, Inc.");
-MODULE_DESCRIPTION("Synaptics TCM Touch Module");
-MODULE_LICENSE("GPL v2");

+ 2 - 1
touch_driver_board.mk

@@ -10,7 +10,8 @@ ifeq ($(TOUCH_DLKM_ENABLE),  true)
 		ifeq ($(call is-board-platform-in-list,$(TARGET_BOARD_PLATFORM)),true)
 			BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/nt36xxx-i2c.ko \
 				$(KERNEL_MODULES_OUT)/goodix_ts.ko \
-				$(KERNEL_MODULES_OUT)/atmel_mxt_ts.ko
+				$(KERNEL_MODULES_OUT)/atmel_mxt_ts.ko \
+				$(KERNEL_MODULES_OUT)/synaptics_tcm_ts.ko
 		endif
 	endif
 endif

+ 2 - 1
touch_driver_product.mk

@@ -8,5 +8,6 @@ endif
 ifeq ($(TOUCH_DLKM_ENABLE),  true)
 	PRODUCT_PACKAGES += $(KERNEL_MODULES_OUT)/nt36xxx-i2c.ko \
 		$(KERNEL_MODULES_OUT)/goodix_ts.ko \
-		$(KERNEL_MODULES_OUT)/atmel_mxt_ts.ko
+		$(KERNEL_MODULES_OUT)/atmel_mxt_ts.ko \
+		$(KERNEL_MODULES_OUT)/synaptics_tcm_ts.ko
 endif