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 <wengjun1@motorola.com>
Reviewed-on: https://gerrit.mot.com/1438179
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jianqiu Huang <huangjq9@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wengjun1 2019-10-17 14:02:52 +08:00 • committed by Jun Weng
commit 8bf9ed035b
2 changed files with 72 additions and 0 deletions

View file

@ -19,6 +19,7 @@
#include <asm/uaccess.h>
#include <linux/of_gpio.h>
#include <linux/irq.h>
#include <linux/pen_detection_notify.h>
#ifdef CONFIG_HAS_WAKELOCK
#include <linux/wakelock.h>
#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);
}

View file

@ -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 <linux/notifier.h>
/* 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