Bring up touchscreen_mmi in Rogue S project.

1. Add DRM_PANEL_EVENT nofification for Andorid S.
2. support touchscreen_mmi and related modules build in kernel-5.10.
3. Use timespec64 instead of timespec function.

Change-Id: If0252015e10bff24c10d54b13df2e0f6aa156a6e
Reviewed-on: https://gerrit.mot.com/1965128
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jun Weng <wengjun1@motorola.com>
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
litong20 2021-06-25 15:29:33 +08:00 • committed by litong
commit b1b4a16e76
10 changed files with 202 additions and 75 deletions

View file

@ -14,15 +14,19 @@ ifeq ($(TOUCHCLASS_MMI_GESTURE_POISON_EVENT),true)
endif
ifeq ($(TOUCHCLASS_MMI_MULTIWAY_UPDATE_FW),true)
KERNEL_CFLAGS += CONFIG_TOUCHCLASS_MMI_MULTIWAY_UPDATE_FW=y
KBUILD_OPTIONS += CONFIG_TOUCHCLASS_MMI_MULTIWAY_UPDATE_FW=y
endif
ifeq ($(DRM_PANEL_NOTIFICATIONS),true)
KERNEL_CFLAGS += CONFIG_DRM_PANEL_NOTIFICATIONS=y
KBUILD_OPTIONS += CONFIG_DRM_PANEL_NOTIFICATIONS=y
endif
ifeq ($(DRM_PANEL_EVENT_NOTIFICATIONS),true)
KBUILD_OPTIONS += CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS=y
endif
ifeq ($(TOUCH_PANEL_NOTIFICATIONS),true)
KERNEL_CFLAGS += CONFIG_TOUCH_PANEL_NOTIFICATIONS=y
KBUILD_OPTIONS += CONFIG_TOUCH_PANEL_NOTIFICATIONS=y
endif
ifneq (,$(findstring gki, $(KERNEL_DEFCONFIG)))

View file

@ -20,6 +20,9 @@ endif
ifneq ($(filter m y, $(CONFIG_DRM_PANEL_NOTIFICATIONS)),)
EXTRA_CFLAGS += -DCONFIG_DRM_PANEL_NOTIFICATIONS
endif
ifneq ($(filter m y, $(CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)),)
EXTRA_CFLAGS += -DCONFIG_DRM_PANEL_EVENT_NOTIFICATIONS
endif
ifneq ($(filter m y, $(CONFIG_TOUCH_PANEL_NOTIFICATIONS)),)
EXTRA_CFLAGS += -DCONFIG_PANEL_NOTIFICATIONS
endif

View file

@ -1,10 +1,13 @@
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
all: modules
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
modules:
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
%:
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
KBUILD_EXTRA_SYMBOLS += $(M)/../../../sensors/Module.symvers
KBUILD_EXTRA_SYMBOLS += $(M)/../../../mmi_relay/Module.symvers

View file

@ -612,7 +612,7 @@ int ts_mmi_dev_register(struct device *parent,
mutex_init(&touch_cdev->extif_mutex);
mutex_init(&touch_cdev->method_mutex);
#ifdef CONFIG_DRM_PANEL_NOTIFICATIONS
#if defined (CONFIG_DRM_PANEL_NOTIFICATIONS) || defined (CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)
ret = ts_mmi_check_drm_panel(DEV_TS->of_node);
if (ret < 0) {
dev_err(DEV_TS, "%s: check drm panel failed. %d\n", __func__, ret);

View file

@ -92,13 +92,104 @@ static int inline ts_mmi_panel_on(struct ts_mmi_dev *touch_cdev) {
return schedule_delayed_work(&touch_cdev->work, 0) == false;
}
static int ts_mmi_panel_event_handle(struct ts_mmi_dev *touch_cdev, enum panel_event event)
{
int ret = 0;
/* entering suspend upon early blank event */
/* to ensure shared power supply is still on */
/* for in-cell design touch solutions */
switch (event) {
case PANEL_EVENT_PRE_DISPLAY_OFF:
cancel_delayed_work_sync(&touch_cdev->work);
ts_mmi_panel_off(touch_cdev);
if (NEED_TO_SET_PINCTRL) {
dev_dbg(DEV_MMI, "%s: touch pinctrl off\n", __func__);
TRY_TO_CALL(pinctrl, TS_MMI_PINCTL_OFF);
}
break;
case PANEL_EVENT_DISPLAY_OFF:
if (NEED_TO_SET_POWER) {
/* then proceed with de-powering */
TRY_TO_CALL(power, TS_MMI_POWER_OFF);
dev_dbg(DEV_MMI, "%s: touch powered off\n", __func__);
}
break;
case PANEL_EVENT_PRE_DISPLAY_ON:
if (NEED_TO_SET_POWER) {
/* powering on early */
TRY_TO_CALL(power, TS_MMI_POWER_ON);
dev_dbg(DEV_MMI, "%s: touch powered on\n", __func__);
} else if (touch_cdev->pdata.reset &&
touch_cdev->mdata->reset) {
/* Power is not off in previous suspend.
* But need reset IC in resume.
*/
dev_dbg(DEV_MMI, "%s: resetting...\n", __func__);
TRY_TO_CALL(reset, TS_MMI_RESET_HARD);
}
break;
case PANEL_EVENT_DISPLAY_ON:
/* out of reset to allow wait for boot complete */
if (NEED_TO_SET_PINCTRL) {
TRY_TO_CALL(pinctrl, TS_MMI_PINCTL_ON);
dev_dbg(DEV_MMI, "%s: touch pinctrl_on\n", __func__);
}
ts_mmi_panel_on(touch_cdev);
break;
default:
dev_dbg(DEV_TS, "%s: function not implemented\n", __func__);
break;
}
return ret;
}
#ifdef CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS
static void ts_mmi_panel_cb(enum panel_event_notifier_tag tag,
struct panel_event_notification *notification, void *client_data)
{
int event = 0;
enum panel_event panel_event;
struct ts_mmi_dev *touch_cdev = client_data;
struct panel_event_notification_data evdata;
if (!touch_cdev || !notification) {
dev_err(DEV_MMI, "%s: invalid evdata\n", __func__); \
return;
}
event = notification->notif_type;
evdata = notification->notif_data;
dev_dbg(DEV_MMI, "%s: %s Notify_type=%d, early=%d\n", __func__,
EVENT_PRE_DISPLAY_OFF ? "EVENT_PRE_DISPLAY_OFF" :
(EVENT_DISPLAY_OFF ? "EVENT_DISPLAY_OFF" :
(EVENT_PRE_DISPLAY_ON ? "EVENT_PRE_DISPLAY_ON" :
(EVENT_DISPLAY_ON ? "EVENT_DISPLAY_ON" : "Unknown"))),
event, (evdata.early_trigger ? 1 : 0));
panel_event = EVENT_PRE_DISPLAY_OFF ? PANEL_EVENT_PRE_DISPLAY_OFF :
(EVENT_DISPLAY_OFF ? PANEL_EVENT_DISPLAY_OFF :
(EVENT_PRE_DISPLAY_ON ? PANEL_EVENT_PRE_DISPLAY_ON :
(EVENT_DISPLAY_ON ? PANEL_EVENT_DISPLAY_ON : PANEL_EVENT_UNKNOWN)));
ts_mmi_panel_event_handle(touch_cdev, panel_event);
return;
}
#else
static int ts_mmi_panel_cb(struct notifier_block *nb,
unsigned long event, void *evd)
{
int idx = -1;
struct ts_mmi_dev *touch_cdev =
container_of(nb, struct ts_mmi_dev, panel_nb);
int ret = 0;
enum panel_event panel_event;
struct ts_mmi_dev *touch_cdev =
container_of(nb, struct ts_mmi_dev, panel_nb);
GET_CONTROL_DSI_INDEX;
@ -115,48 +206,16 @@ static int ts_mmi_panel_cb(struct notifier_block *nb,
if (touch_cdev->pdata.ctrl_dsi != idx)
return 0;
/* entering suspend upon early blank event */
/* to ensure shared power supply is still on */
/* for in-cell design touch solutions */
if (EVENT_PRE_DISPLAY_OFF) {
cancel_delayed_work_sync(&touch_cdev->work);
ts_mmi_panel_off(touch_cdev);
if (NEED_TO_SET_PINCTRL) {
dev_dbg(DEV_MMI, "%s: touch pinctrl off\n", __func__);
TRY_TO_CALL(pinctrl, TS_MMI_PINCTL_OFF);
}
} else if (EVENT_DISPLAY_OFF) {
if (NEED_TO_SET_POWER) {
/* then proceed with de-powering */
TRY_TO_CALL(power, TS_MMI_POWER_OFF);
dev_dbg(DEV_MMI, "%s: touch powered off\n", __func__);
}
} else if (EVENT_PRE_DISPLAY_ON) {
if (NEED_TO_SET_POWER) {
/* powering on early */
TRY_TO_CALL(power, TS_MMI_POWER_ON);
dev_dbg(DEV_MMI, "%s: touch powered on\n", __func__);
} else if (touch_cdev->pdata.reset &&
touch_cdev->mdata->reset) {
/* Power is not off in previous suspend.
* But need reset IC in resume.
*/
dev_dbg(DEV_MMI, "%s: resetting...\n", __func__);
TRY_TO_CALL(reset, TS_MMI_RESET_HARD);
}
} else if (EVENT_DISPLAY_ON) {
/* out of reset to allow wait for boot complete */
if (NEED_TO_SET_PINCTRL) {
TRY_TO_CALL(pinctrl, TS_MMI_PINCTL_ON);
dev_dbg(DEV_MMI, "%s: touch pinctrl_on\n", __func__);
}
ts_mmi_panel_on(touch_cdev);
} else {
dev_dbg(DEV_TS, "%s: function not implemented\n", __func__);
}
panel_event = EVENT_PRE_DISPLAY_OFF ? PANEL_EVENT_PRE_DISPLAY_OFF :
(EVENT_DISPLAY_OFF ? PANEL_EVENT_DISPLAY_OFF :
(EVENT_PRE_DISPLAY_ON ? PANEL_EVENT_PRE_DISPLAY_ON :
(EVENT_DISPLAY_ON ? PANEL_EVENT_DISPLAY_ON : PANEL_EVENT_UNKNOWN)));
return 0;
ret = ts_mmi_panel_event_handle(touch_cdev, panel_event);
return ret;
}
#endif
static inline void ts_mmi_restore_settings(struct ts_mmi_dev *touch_cdev)
{
@ -458,8 +517,7 @@ int ts_mmi_notifiers_register(struct ts_mmi_dev *touch_cdev)
touch_cdev->pm_mode = TS_MMI_PM_ACTIVE;
if (!touch_cdev->panel_status) {
touch_cdev->panel_nb.notifier_call = ts_mmi_panel_cb;
ret = register_panel_notifier(&touch_cdev->panel_nb);
REGISTER_PANEL_NOTIFIER;
if (ret)
goto PANEL_NOTIF_REGISTER_FAILED;
}
@ -483,7 +541,7 @@ int ts_mmi_notifiers_register(struct ts_mmi_dev *touch_cdev)
FREQ_NOTIF_REGISTER_FAILED:
if (!touch_cdev->panel_status)
unregister_panel_notifier(&touch_cdev->panel_nb);
UNREGISTER_PANEL_NOTIFIER;
PANEL_NOTIF_REGISTER_FAILED:
cancel_delayed_work(&touch_cdev->work);
PS_NOTIF_REGISTER_FAILED:
@ -509,7 +567,7 @@ void ts_mmi_notifiers_unregister(struct ts_mmi_dev *touch_cdev)
power_supply_unreg_notifier(&touch_cdev->ps_notif);
if (!touch_cdev->panel_status)
unregister_panel_notifier(&touch_cdev->panel_nb);
UNREGISTER_PANEL_NOTIFIER;
cancel_delayed_work(&touch_cdev->work);
kfifo_free(&touch_cdev->cmd_pipe);

View file

@ -235,7 +235,7 @@ done:
return 0;
}
#ifdef CONFIG_DRM_PANEL_NOTIFICATIONS
#if defined(CONFIG_DRM_PANEL_NOTIFICATIONS) || defined (CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)
struct drm_panel *active_panel;
static int ts_mmi_check_dt(struct device_node *np)

View file

@ -1,10 +1,14 @@
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
all: modules
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
modules:
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
%:
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
rm -rf .tmp_versions

View file

@ -1,10 +1,14 @@
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
all: modules
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
modules:
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
%:
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
rm -rf .tmp_versions

View file

@ -16,14 +16,6 @@
#include <linux/notifier.h>
enum panel_event {
PANEL_EVENT_PRE_DISPLAY_OFF,
PANEL_EVENT_PRE_DISPLAY_ON,
PANEL_EVENT_DISPLAY_OFF,
PANEL_EVENT_DISPLAY_ON,
PANEL_EVENT_DISPLAY_ON_PREPARE,
};
#ifdef CONFIG_PANEL_NOTIFICATIONS
int panel_register_notifier(struct notifier_block *nb);

View file

@ -25,8 +25,14 @@
#include <linux/panel_notifier.h>
#define register_panel_notifier panel_register_notifier
#define unregister_panel_notifier panel_unregister_notifier
#define REGISTER_PANEL_NOTIFIER {\
touch_cdev->panel_nb.notifier_call = ts_mmi_panel_cb; \
ret = panel_register_notifier(&touch_cdev->panel_nb); \
}
#define UNREGISTER_PANEL_NOTIFIER {\
panel_unregister_notifier(&touch_cdev->panel_nb); \
}
#define GET_CONTROL_DSI_INDEX { \
if (evd) \
@ -46,19 +52,52 @@
(event == PANEL_EVENT_DISPLAY_ON)
#else /* CONFIG_PANEL_NOTIFICATIONS */
#if defined(CONFIG_DRM_PANEL_NOTIFICATIONS)
#include <drm/drm_panel.h>
#if defined(CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)
#include <linux/soc/qcom/panel_event_notifier.h>
extern struct drm_panel *active_panel;
static inline int register_panel_notifier(struct notifier_block *nb)
{
return drm_panel_notifier_register(active_panel, nb);
#define REGISTER_PANEL_NOTIFIER { \
void *cookie = NULL; \
cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY, \
PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH, active_panel, \
&ts_mmi_panel_cb, touch_cdev); \
if (!cookie) \
ret = -1; \
else \
touch_cdev->notifier_cookie = cookie; \
}
static inline void unregister_panel_notifier(struct notifier_block *nb)
{
drm_panel_notifier_unregister(active_panel, nb);
#define UNREGISTER_PANEL_NOTIFIER { \
panel_event_notifier_unregister(touch_cdev->notifier_cookie); \
}
#define EVENT_PRE_DISPLAY_OFF \
((event == DRM_PANEL_EVENT_BLANK) && \
(evdata.early_trigger))
#define EVENT_DISPLAY_OFF \
((event == DRM_PANEL_EVENT_BLANK) && \
(!evdata.early_trigger))
#define EVENT_PRE_DISPLAY_ON \
((event == DRM_PANEL_EVENT_UNBLANK) && \
(evdata.early_trigger))
#define EVENT_DISPLAY_ON \
((event == DRM_PANEL_EVENT_UNBLANK) && \
(!evdata.early_trigger))
#else /* CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS */
#if defined(CONFIG_DRM_PANEL_NOTIFICATIONS)
#include <drm/drm_panel.h>
extern struct drm_panel *active_panel;
#define REGISTER_PANEL_NOTIFIER {\
touch_cdev->panel_nb.notifier_call = ts_mmi_panel_cb; \
ret = drm_panel_notifier_register(active_panel, &touch_cdev->panel_nb); \
}
#define UNREGISTER_PANEL_NOTIFIER {\
drm_panel_notifier_unregister(active_panel, &touch_cdev->panel_nb);\
}
#define GET_CONTROL_DSI_INDEX \
@ -97,8 +136,14 @@ struct drm_panel_notifier *evdata = evd; \
#include <linux/msm_drm_notify.h>
#define register_panel_notifier msm_drm_register_client
#define unregister_panel_notifier msm_drm_unregister_client
#define REGISTER_PANEL_NOTIFIER {\
touch_cdev->panel_nb.notifier_call = ts_mmi_panel_cb; \
ret = msm_drm_register_client(&touch_cdev->panel_nb); \
}
#define UNREGISTER_PANEL_NOTIFIER {\
msm_drm_unregister_client(&touch_cdev->panel_nb); \
}
#define GET_CONTROL_DSI_INDEX \
int *blank; \
@ -148,6 +193,7 @@ struct msm_drm_notifier *evdata = evd; \
#endif /* LINUX_VERSION_CODE */
#endif /* CONFIG_DRM_PANEL_NOTIFICATIONS */
#endif /* CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS */
#endif /* CONFIG_PANEL_NOTIFICATIONS */
@ -163,9 +209,9 @@ struct msm_drm_notifier *evdata = evd; \
#define NANO_TO_MSEC 1000000
static inline unsigned long long timediff_ms(
struct timespec start, struct timespec end)
struct timespec64 start, struct timespec64 end)
{
struct timespec temp;
struct timespec64 temp;
if ((end.tv_nsec - start.tv_nsec) < 0) {
temp.tv_sec = end.tv_sec - start.tv_sec - 1;
@ -236,6 +282,15 @@ enum ts_mmi_pm_mode {
TS_MMI_PM_ACTIVE,
};
enum panel_event {
PANEL_EVENT_PRE_DISPLAY_OFF,
PANEL_EVENT_PRE_DISPLAY_ON,
PANEL_EVENT_DISPLAY_OFF,
PANEL_EVENT_DISPLAY_ON,
PANEL_EVENT_DISPLAY_ON_PREPARE,
PANEL_EVENT_UNKNOWN
};
#define TS_MMI_RESET_SOFT 0
#define TS_MMI_RESET_HARD 1
#define TS_MMI_POWER_OFF 0
@ -379,7 +434,11 @@ struct ts_mmi_dev {
int forcereflash;
int panel_status;
struct ts_mmi_dev_pdata pdata;
#ifdef CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS
void *notifier_cookie;
#else
struct notifier_block panel_nb;
#endif
struct mutex extif_mutex;
struct mutex method_mutex;
struct pinctrl *pinctrl_node;
@ -484,7 +543,7 @@ extern int ts_mmi_palm_remove(struct ts_mmi_dev *data);
#ifdef TS_MMI_TOUCH_EDGE_GESTURE
extern int ts_mmi_gesture_suspend(struct ts_mmi_dev *touch_cdev);
#endif
#ifdef CONFIG_DRM_PANEL_NOTIFICATIONS
#if defined (CONFIG_DRM_PANEL_NOTIFICATIONS) || defined (CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)
int ts_mmi_check_drm_panel(struct device_node *of_node);
#endif
extern bool ts_mmi_is_panel_match(const char *panel_node, char *touch_ic_name);