From 8bf9ed035bebd01fd89bb6eb1083e986c5d6f67c Mon Sep 17 00:00:00 2001 From: wengjun1 Date: Thu, 17 Oct 2019 14:02:52 +0800 Subject: [PATCH] Sofiap: Pen status notification to touch - Because now we are using stylus on sofiap and this will keep touch always on high sensitive mode which will easy to lead to the problem such as ghost touch , residue points etc. So we add a pen notifier to touch and then the firmware of the touch can adjust the mode according to the status of the pen. Change-Id: I328fbe973d960e0decc60b86e4d16140e66e2cb9 Signed-off-by: wengjun1 Reviewed-on: https://gerrit.mot.com/1438179 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqiu Huang Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/misc/pen/bu520xx_pen.c | 47 ++++++++++++++++++++++++++++ include/linux/pen_detection_notify.h | 25 +++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 include/linux/pen_detection_notify.h diff --git a/drivers/misc/pen/bu520xx_pen.c b/drivers/misc/pen/bu520xx_pen.c index 7593bc6ddd39..fd2a76a1d99e 100644 --- a/drivers/misc/pen/bu520xx_pen.c +++ b/drivers/misc/pen/bu520xx_pen.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_HAS_WAKELOCK #include #else @@ -69,6 +70,48 @@ static struct hall_sensor_str { struct delayed_work hall_sensor_dowork; }* hall_sensor_dev; +static BLOCKING_NOTIFIER_HEAD(pen_detection_notifier_list); + +/** + * pen_detection_register_client - register a client notifier + * @nb: notifier block to callback on events + * + * This function registers a notifier callback function + * to pen_detection_notifier_list, which would be called when + * the passive pen is inserted or pulled out. + */ +int pen_detection_register_client(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&pen_detection_notifier_list, + nb); +} +EXPORT_SYMBOL(pen_detection_register_client); + +/** + * pen_detection_unregister_client - unregister a client notifier + * @nb: notifier block to callback on events + * + * This function unregisters the callback function from + * pen_detection_notifier_list. + */ +int pen_detection_unregister_client(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&pen_detection_notifier_list, + nb); +} +EXPORT_SYMBOL(pen_detection_unregister_client); + +/** + * pen_detection_notifier_call_chain - notify clients of pen_detection_events + * @val: event PEN_DETECTION_INSERT or PEN_DETECTION_PULL + * @v: notifier data, inculde display pen detection event. + */ +static int pen_detection_notifier_call_chain(unsigned long val, void *v) +{ + return blocking_notifier_call_chain(&pen_detection_notifier_list, val, + v); +} + //static void hall_sensor_shutdown(struct platform_device *pdev); int pen_connect(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id){ pen_dbg_func_in(); @@ -288,6 +331,10 @@ static void pen_report_function(struct work_struct *dat) __pm_wakeup_event(&hall_sensor_dev->wake_lock, msecs_to_jiffies(3000)); #endif + if(!hall_sensor_dev->status) + pen_detection_notifier_call_chain(PEN_DETECTION_INSERT, NULL); + else + pen_detection_notifier_call_chain(PEN_DETECTION_PULL, NULL); pen_info("[%s] SW_pen report value = %d\n", DRIVER_NAME,!hall_sensor_dev->status); } diff --git a/include/linux/pen_detection_notify.h b/include/linux/pen_detection_notify.h new file mode 100644 index 000000000000..87f1898d5de9 --- /dev/null +++ b/include/linux/pen_detection_notify.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef _PEN_DETECTION_DRM_NOTIFY_H_ +#define _PEN_DETECTION_DRM_NOTIFY_H_ + +#include + +/* The event of pen insertion */ +#define PEN_DETECTION_INSERT 0x01 +/* The event of pen pull-out */ +#define PEN_DETECTION_PULL 0x02 + +int pen_detection_register_client(struct notifier_block *nb); +int pen_detection_unregister_client(struct notifier_block *nb); +#endif