mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 00:00:00 -04:00
DLKM:add anc_fps_mmi driver
Reason: fps bringup work add anc_fps_mmi for JV0301 Change-Id: I17dadeccd45fc461f4800fd50e659bd1d217bd20 Signed-off-by: chenlj2 <chenlj2@motorola.com> Reviewed-on: https://gerrit.mot.com/2735787 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Yan Zhang <zhangy26@motorola.com> Reviewed-by: Tao Sun <suntao2@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
381ced2f26
commit
11f03a3ea7
10 changed files with 2187 additions and 0 deletions
14
drivers/input/misc/anc_fps_mmi/Android.mk
Normal file
14
drivers/input/misc/anc_fps_mmi/Android.mk
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := anc_fps_mmi.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
ifneq ($(findstring mmi_relay.ko,$(BOARD_VENDOR_KERNEL_MODULES)),)
|
||||
KERNEL_CFLAGS += CONFIG_MMI_RELAY=y
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(KERNEL_MODULES_OUT)/mmi_relay.ko
|
||||
endif
|
||||
KBUILD_OPTIONS_GKI += GKI_OBJ_MODULE_DIR=gki
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
|
||||
14
drivers/input/misc/anc_fps_mmi/Kbuild
Normal file
14
drivers/input/misc/anc_fps_mmi/Kbuild
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# add -Wall to try to catch everything we can.
|
||||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -DCONFIG_PM_WAKELOCKS
|
||||
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include \
|
||||
|
||||
ifneq ($(filter m y,$(CONFIG_MMI_RELAY)),)
|
||||
EXTRA_CFLAGS += -DMMI_RELAY_MODULE
|
||||
endif
|
||||
|
||||
anc_fps_mmi-y += jiiov_platform.o jiiov_netlink.o custom.o
|
||||
|
||||
obj-m += anc_fps_mmi.o
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../../mmi_relay/$(GKI_OBJ_MODULE_DIR)/Module.symvers
|
||||
14
drivers/input/misc/anc_fps_mmi/Makefile
Normal file
14
drivers/input/misc/anc_fps_mmi/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
all: modules
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
|
||||
|
||||
%:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
|
||||
rm -rf .tmp_versions
|
||||
12
drivers/input/misc/anc_fps_mmi/custom.c
Normal file
12
drivers/input/misc/anc_fps_mmi/custom.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#define LOG_TAG "[ANC][custom]"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
|
||||
// clang-format off
|
||||
#include "jiiov_log.h"
|
||||
#include "jiiov_platform.h"
|
||||
// clang-format on
|
||||
|
||||
int custom_send_command(CUSTOM_COMMAND cmd, void *p_param) {
|
||||
return 0;
|
||||
}
|
||||
20
drivers/input/misc/anc_fps_mmi/jiiov_config.h
Normal file
20
drivers/input/misc/anc_fps_mmi/jiiov_config.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef __JIIOV_CONFIG_H__
|
||||
#define __JIIOV_CONFIG_H__
|
||||
|
||||
/*Define the macro when using ree spi*/
|
||||
// #define ANC_USE_REE_SPI
|
||||
|
||||
/*Define the macro when using navigation function*/
|
||||
// #define ANC_SUPPORT_NAVIGATION_EVENT
|
||||
|
||||
/*Define the macro to adapt to the project platform*/
|
||||
// #define QSEE_PLATFORM
|
||||
// #define MTK_PLATFORM
|
||||
// #define TRUSTY_PLATFORM
|
||||
// #define SAMSUNG_PLATFORM
|
||||
|
||||
/*Define the macro to adapt to sensor type*/
|
||||
// #define CAPACITIVE
|
||||
// #define OPTICAL
|
||||
|
||||
#endif
|
||||
13
drivers/input/misc/anc_fps_mmi/jiiov_log.h
Normal file
13
drivers/input/misc/anc_fps_mmi/jiiov_log.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef __JIIOV_LOG_H__
|
||||
#define __JIIOV_LOG_H__
|
||||
|
||||
#define ANC_LOGD(format, ...) \
|
||||
printk(KERN_DEBUG "[D][ANC_DRIVER][%s] " format "\n", __func__, ##__VA_ARGS__)
|
||||
#define ANC_LOGI(format, ...) \
|
||||
printk(KERN_INFO "[I][ANC_DRIVER][%s] " format "\n", __func__, ##__VA_ARGS__)
|
||||
#define ANC_LOGW(format, ...) \
|
||||
printk(KERN_WARNING "[W][ANC_DRIVER][%s] " format "\n", __func__, ##__VA_ARGS__)
|
||||
#define ANC_LOGE(format, ...) \
|
||||
printk(KERN_ERR "[E][ANC_DRIVER][%s] " format "\n", __func__, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
108
drivers/input/misc/anc_fps_mmi/jiiov_netlink.c
Normal file
108
drivers/input/misc/anc_fps_mmi/jiiov_netlink.c
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* Netlink interface for JIIOV's fingerprint sensor.
|
||||
*
|
||||
* Copyright (C) 2020 JIIOV Corporation. <http://www.jiiov.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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.
|
||||
**/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/types.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
// clang-format off
|
||||
#include "jiiov_log.h"
|
||||
#include "jiiov_netlink.h"
|
||||
// clang-format on
|
||||
|
||||
#define NETLINK_ANC 30
|
||||
#define USER_PORT 100
|
||||
|
||||
static struct sock *gp_netlink_sock = NULL;
|
||||
extern struct net init_net; // by default
|
||||
|
||||
static int netlink_send_message(const char *p_buffer, uint16_t length) {
|
||||
int ret = 0;
|
||||
struct sk_buff *p_sk_buff = NULL;
|
||||
struct nlmsghdr *p_nlmsghdr = NULL;
|
||||
|
||||
/* 创建sk_buff 空间 */
|
||||
p_sk_buff = nlmsg_new(length, GFP_ATOMIC);
|
||||
if (NULL == p_sk_buff) {
|
||||
ANC_LOGE("netlink alloc failure");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 设置netlink消息头部 */
|
||||
p_nlmsghdr = nlmsg_put(p_sk_buff, 0, 0, NETLINK_ANC, length, 0);
|
||||
if (NULL == p_nlmsghdr) {
|
||||
ANC_LOGE("nlmsg_put failaure");
|
||||
nlmsg_free(p_sk_buff);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 拷贝数据发送 */
|
||||
memcpy(nlmsg_data(p_nlmsghdr), p_buffer, length);
|
||||
ret = netlink_unicast(gp_netlink_sock, p_sk_buff, USER_PORT, MSG_DONTWAIT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int netlink_send_message_to_user(const char *p_buffer, size_t length) {
|
||||
int ret = -1;
|
||||
|
||||
if ((NULL != p_buffer) && (length > 0)) {
|
||||
ANC_LOGE("send message to user: %d", *p_buffer);
|
||||
ret = netlink_send_message(p_buffer, length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void netlink_receive_message(struct sk_buff *p_sk_buffer) {
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
char *p_user_message = NULL;
|
||||
|
||||
if (p_sk_buffer->len >= nlmsg_total_size(0)) {
|
||||
nlh = nlmsg_hdr(p_sk_buffer);
|
||||
p_user_message = NLMSG_DATA(nlh);
|
||||
if (p_user_message) {
|
||||
ANC_LOGE("received message:%s, length:%lu", p_user_message, strlen(p_user_message));
|
||||
netlink_send_message_to_user(p_user_message, strlen(p_user_message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct netlink_kernel_cfg g_netlink_kernel_config = {
|
||||
.input = netlink_receive_message, /* set recv callback */
|
||||
};
|
||||
|
||||
int anc_netlink_init(void) {
|
||||
/* create netlink socket */
|
||||
gp_netlink_sock =
|
||||
(struct sock *)netlink_kernel_create(&init_net, NETLINK_ANC, &g_netlink_kernel_config);
|
||||
if (NULL == gp_netlink_sock) {
|
||||
ANC_LOGE("netlink_kernel_create error !");
|
||||
return -1;
|
||||
}
|
||||
ANC_LOGD("anc_netlink_init");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void anc_netlink_exit(void) {
|
||||
if (NULL != gp_netlink_sock) {
|
||||
netlink_kernel_release(gp_netlink_sock); /* release ..*/
|
||||
gp_netlink_sock = NULL;
|
||||
}
|
||||
ANC_LOGD("anc_netlink_exit!");
|
||||
}
|
||||
21
drivers/input/misc/anc_fps_mmi/jiiov_netlink.h
Normal file
21
drivers/input/misc/anc_fps_mmi/jiiov_netlink.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef __JIIOV_NETLINK_H__
|
||||
#define __JIIOV_NETLINK_H__
|
||||
|
||||
typedef enum {
|
||||
ANC_NETLINK_EVENT_TEST = 0,
|
||||
ANC_NETLINK_EVENT_IRQ,
|
||||
ANC_NETLINK_EVENT_SCR_OFF,
|
||||
ANC_NETLINK_EVENT_SCR_ON,
|
||||
ANC_NETLINK_EVENT_TOUCH_DOWN,
|
||||
ANC_NETLINK_EVENT_TOUCH_UP,
|
||||
ANC_NETLINK_EVENT_UI_READY,
|
||||
ANC_NETLINK_EVENT_EXIT,
|
||||
ANC_NETLINK_EVENT_INVALID,
|
||||
ANC_NETLINK_EVENT_MAX
|
||||
} ANC_NETLINK_EVENT_TYPE;
|
||||
|
||||
int netlink_send_message_to_user(const char *p_buffer, size_t length);
|
||||
int anc_netlink_init(void);
|
||||
void anc_netlink_exit(void);
|
||||
|
||||
#endif
|
||||
1941
drivers/input/misc/anc_fps_mmi/jiiov_platform.c
Normal file
1941
drivers/input/misc/anc_fps_mmi/jiiov_platform.c
Normal file
File diff suppressed because it is too large
Load diff
30
drivers/input/misc/anc_fps_mmi/jiiov_platform.h
Normal file
30
drivers/input/misc/anc_fps_mmi/jiiov_platform.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* User space driver API for JIIOV's fingerprint sensor.
|
||||
*
|
||||
* Copyright (C) 2020 JIIOV Corporation. <http://www.jiiov.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 __JIIOV_PLATFORM_H__
|
||||
#define __JIIOV_PLATFORM_H__
|
||||
|
||||
#define ANC_WAKELOCK_HOLD_TIME 500 /* ms */
|
||||
typedef enum {
|
||||
CUSTOM_COMMAND_INIT,
|
||||
CUSTOM_COMMAND_CLEAR_TOUCH_STATE,
|
||||
CUSTOM_COMMAND_SET_PRODUCT_ID,
|
||||
CUSTOM_COMMAND_DEINIT,
|
||||
} CUSTOM_COMMAND;
|
||||
|
||||
int custom_send_command(CUSTOM_COMMAND cmd, void *p_param);
|
||||
|
||||
#endif /* __JIIOV_PLATFORM_H__ */
|
||||
Loading…
Reference in a new issue