mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 12:25:00 -04:00
Hall sensor add passive pen code
Modify hall_pen.c file to add pen detection code Modify Android.mk and Kbuild to add definition Change-Id: Ica36be5f69eeb5205bc9d7573a6801602d4db7a0 Signed-off-by: Zhibang Li <lizb15@motorola.com> Reviewed-on: https://gerrit.mot.com/2733379 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Lijun Chen <chenlj2@motorola.com> Reviewed-by: Yeqing Wang <wangyq13@motorola.com> Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
1c6c1799d5
commit
e89bd60d41
3 changed files with 64 additions and 0 deletions
|
|
@ -1,6 +1,10 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifeq ($(HALL_PASSIVE_PEN),true)
|
||||
KBUILD_OPTIONS += CONFIG_HALL_PASSIVE_PEN=y
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := hall_pen.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ KERNEL_PLATFORM_PATH = $(shell find $(ANDROID_BUILD_TOP) -maxdepth 1 -name "kern
|
|||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include
|
||||
|
||||
ifneq ($(filter m y,$(CONFIG_HALL_PASSIVE_PEN)),)
|
||||
EXTRA_CFLAGS += -DCONFIG_HALL_PASSIVE_PEN
|
||||
endif
|
||||
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../sensors/$(GKI_OBJ_MODULE_DIR)/Module.symvers
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
#include <linux/irq.h>
|
||||
#include <linux/sensors.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#ifdef CONFIG_HALL_PASSIVE_PEN
|
||||
#include <linux/pen_detection_notify.h>
|
||||
#endif
|
||||
|
||||
#define DRIVER_NAME "hall_pen_detect"
|
||||
#define LOG_DBG(fmt, args...) pr_debug(DRIVER_NAME " [DBG]" "<%s:%d>"fmt, __func__, __LINE__, ##args)
|
||||
|
|
@ -70,6 +73,50 @@ static struct platform_driver hall_pen_driver = {
|
|||
},
|
||||
};
|
||||
|
||||
#ifdef CONFIG_HALL_PASSIVE_PEN
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
void check_and_send(void)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -89,6 +136,13 @@ void check_and_send(void)
|
|||
input_report_abs(hall_sensor_dev->hall_dev, ABS_DISTANCE, report_val);
|
||||
input_sync(hall_sensor_dev->hall_dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HALL_PASSIVE_PEN
|
||||
if(hall_sensor_dev->report_val)
|
||||
pen_detection_notifier_call_chain(PEN_DETECTION_INSERT, NULL);
|
||||
else
|
||||
pen_detection_notifier_call_chain(PEN_DETECTION_PULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void hall_enable(bool enable)
|
||||
|
|
@ -294,7 +348,9 @@ static int hall_sensor_probe(struct platform_device *pdev)
|
|||
hall_sensor_dev->gpio_list[i].irq = 0;
|
||||
goto fail_for_irq;
|
||||
}
|
||||
#ifndef CONFIG_HALL_PASSIVE_PEN
|
||||
disable_irq(hall_sensor_dev->gpio_list[i].irq);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue