-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squash of the following commits: fuxi: Drop unnecessary displayfeature from udfps handler kernel is _smart_ fuxi: Use onAcquired for fod_status fuxi: Disable fod after unlocking fuxi: Drop unnecessary udfps extension fuxi: Rework a bit and enable local hbm via disp_param fuxi: Handle fingerprint enroll vendor code fuxi: Notify goodix HAL on fod_press_status changes Modern fingerprint.goodix_fod6.so has moved the polling of this out of the hal and replaced it with extCmd 1. fuxi: Match vendorcode with fuxi fingerprint hal fuxi: Sswitch UDFPS to IXiaomiFingerprint add fingerprint init-permissions from mfd-daemon.rc to init.target.rc Co-authored-by: lolipuru <[email protected]> Co-authored-by: Fabian Leutenegger <[email protected]> Change-Id: I4dd5a571a1a48469ce1d25f1f982adef23fc714f
- Loading branch information
1 parent
8fc0cd2
commit 45d68ef
Showing
10 changed files
with
328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,14 @@ PRODUCT_PACKAGES += \ | |
PRODUCT_PACKAGES += \ | ||
fastbootd | ||
|
||
# Fingerprint | ||
PRODUCT_PACKAGES += \ | ||
[email protected] \ | ||
libudfpshandler | ||
|
||
PRODUCT_COPY_FILES += \ | ||
frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml | ||
|
||
# Gatekeeper | ||
PRODUCT_PACKAGES += \ | ||
[email protected] | ||
|
@@ -154,6 +162,7 @@ PRODUCT_PACKAGES += \ | |
fstab.qcom \ | ||
init.target.rc \ | ||
init.mi_thermald.rc \ | ||
init.mi_udfps.rc \ | ||
init.batterysecret.rc \ | ||
ueventd.xiaomi.rc | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
on early-boot | ||
chown system graphics /sys/bus/platform/devices/soc:xiaomi_fingerprint/fingerdown | ||
chmod 0664 /sys/bus/platform/devices/soc:xiaomi_fingerprint/fingerdown | ||
|
||
on boot | ||
chmod 0666 /dev/goodix_fp | ||
chown system system /dev/goodix_fp | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/irq | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/irq_enable | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/wakeup_enable | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/hw_reset | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/device_prepare | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/fingerdown_wait | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/vendor | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/request_vreg | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/simulate_irq | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/finger_irq | ||
chown system system /sys/bus/platform/devices/soc:fingerprint_fpc/power_cfg | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/irq | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/wakeup_enable | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/hw_reset | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/device_prepare | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/vendor | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/request_vreg | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/simulate_irq | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/finger_irq | ||
chmod 0700 /sys/bus/platform/devices/soc:fingerprint_fpc/power_cfg | ||
chmod 0666 /dev/input/event2 | ||
|
||
on post-fs-data | ||
mkdir /data/vendor/misc 01771 system system | ||
mkdir /data/vendor/misc/mi_fp 0770 system system | ||
mkdir /persist/mi_fp 0770 system system | ||
mkdir /mnt/vendor/persist/mi_fp 0770 system system | ||
mkdir /data/vendor/fpc 0770 system system | ||
mkdir /data/vendor/fpdump 0770 system system | ||
mkdir /data/vendor/goodix 0770 system system | ||
mkdir /data/vendor/fingerprint 0770 system system | ||
mkdir /mnt/vendor/persist/goodix 0770 system system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1699,6 +1699,17 @@ vendor/lib64/libesesbprovision.so | |
vendor/lib64/[email protected] | ||
vendor/lib64/[email protected] | ||
|
||
# Fingerprint | ||
odm/lib64/hw/fingerprint.goodix_fod.so:vendor/lib64/hw/fingerprint.goodix_fod.default.so | ||
odm/lib64/libgf_hal.so | ||
odm/lib64/[email protected] | ||
vendor/bin/hw/[email protected] | ||
vendor/etc/init/[email protected] | ||
vendor/etc/vintf/manifest/fod.xml | ||
vendor/lib64/[email protected] | ||
vendor/lib64/[email protected] | ||
vendor/lib64/[email protected] | ||
|
||
# FM | ||
vendor/etc/init/init.qti.fm.rc | ||
vendor/etc/init.qti.fm.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Copyright (C) 2022 The LineageOS Project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
cc_library { | ||
name: "libudfpshandler", | ||
vendor: true, | ||
srcs: ["UdfpsHandler.cpp"], | ||
shared_libs: [ | ||
"libbase", | ||
], | ||
header_libs: [ | ||
"//hardware/xiaomi:xiaomifingerprint_headers", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* | ||
* Copyright (C) 2022 The LineageOS Project | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#define LOG_TAG "UdfpsHandler.fuxi" | ||
|
||
#include <android-base/logging.h> | ||
#include <android-base/unique_fd.h> | ||
|
||
#include <poll.h> | ||
#include <sys/ioctl.h> | ||
#include <fstream> | ||
#include <thread> | ||
|
||
#include "UdfpsHandler.h" | ||
#include "xiaomi_touch.h" | ||
|
||
#define COMMAND_NIT 10 | ||
#define PARAM_NIT_FOD 1 | ||
#define PARAM_NIT_NONE 0 | ||
|
||
#define COMMAND_FOD_PRESS_STATUS 1 | ||
#define PARAM_FOD_PRESSED 1 | ||
#define PARAM_FOD_RELEASED 1 | ||
|
||
#define FOD_STATUS_OFF 0 | ||
#define FOD_STATUS_ON 1 | ||
|
||
#define TOUCH_DEV_PATH "/dev/xiaomi-touch" | ||
#define TOUCH_ID 0 | ||
#define TOUCH_MAGIC 'T' | ||
#define TOUCH_IOC_SET_CUR_VALUE _IO(TOUCH_MAGIC, SET_CUR_VALUE) | ||
#define TOUCH_IOC_GET_CUR_VALUE _IO(TOUCH_MAGIC, GET_CUR_VALUE) | ||
|
||
#define DISP_PARAM_PATH "sys/devices/virtual/mi_display/disp_feature/disp-DSI-0/disp_param" | ||
#define DISP_PARAM_LOCAL_HBM_MODE "9" | ||
#define DISP_PARAM_LOCAL_HBM_OFF "0" | ||
#define DISP_PARAM_LOCAL_HBM_ON "1" | ||
|
||
#define FOD_PRESS_STATUS_PATH "/sys/class/touch/touch_dev/fod_press_status" | ||
|
||
namespace { | ||
|
||
template <typename T> | ||
static void set(const std::string& path, const T& value) { | ||
std::ofstream file(path); | ||
file << value; | ||
} | ||
|
||
static bool readBool(int fd) { | ||
char c; | ||
int rc; | ||
|
||
rc = lseek(fd, 0, SEEK_SET); | ||
if (rc) { | ||
LOG(ERROR) << "failed to seek fd, err: " << rc; | ||
return false; | ||
} | ||
|
||
rc = read(fd, &c, sizeof(char)); | ||
if (rc != 1) { | ||
LOG(ERROR) << "failed to read bool from fd, err: " << rc; | ||
return false; | ||
} | ||
|
||
return c != '0'; | ||
} | ||
|
||
} // anonymous namespace | ||
|
||
class XiaomiSm8550UdfpsHander : public UdfpsHandler { | ||
public: | ||
void init(xiaomi_fingerprint_device_t* device) { | ||
mDevice = device; | ||
touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR)); | ||
|
||
std::thread([this]() { | ||
int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY); | ||
if (fd < 0) { | ||
LOG(ERROR) << "failed to open fd, err: " << fd; | ||
return; | ||
} | ||
|
||
struct pollfd fodPressStatusPoll = { | ||
.fd = fd, | ||
.events = POLLERR | POLLPRI, | ||
.revents = 0, | ||
}; | ||
|
||
while (true) { | ||
int rc = poll(&fodPressStatusPoll, 1, -1); | ||
if (rc < 0) { | ||
LOG(ERROR) << "failed to poll fd, err: " << rc; | ||
continue; | ||
} | ||
|
||
mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS, | ||
readBool(fd) ? PARAM_FOD_PRESSED : PARAM_FOD_RELEASED); | ||
} | ||
}).detach(); | ||
} | ||
|
||
void onFingerDown(uint32_t /*x*/, uint32_t /*y*/, float /*minor*/, float /*major*/) { | ||
LOG(INFO) << __func__; | ||
setFingerDown(true); | ||
} | ||
|
||
void onFingerUp() { | ||
LOG(INFO) << __func__; | ||
setFingerDown(false); | ||
} | ||
|
||
void onAcquired(int32_t result, int32_t vendorCode) { | ||
LOG(INFO) << __func__ << " result: " << result << " vendorCode: " << vendorCode; | ||
if (result == FINGERPRINT_ACQUIRED_GOOD) { | ||
setFingerDown(false); | ||
setFodStatus(FOD_STATUS_OFF); | ||
} else if (vendorCode == 20 || vendorCode == 22) { | ||
/* | ||
* vendorCode = 20 waiting for fingerprint authentication | ||
* vendorCode = 22 waiting for fingerprint enroll | ||
*/ | ||
setFodStatus(FOD_STATUS_ON); | ||
} | ||
} | ||
|
||
void cancel() { | ||
LOG(INFO) << __func__; | ||
setFingerDown(false); | ||
setFodStatus(FOD_STATUS_OFF); | ||
} | ||
|
||
private: | ||
xiaomi_fingerprint_device_t* mDevice; | ||
android::base::unique_fd touch_fd_; | ||
|
||
void setFodStatus(int value) { | ||
int buf[MAX_BUF_SIZE] = {TOUCH_ID, Touch_Fod_Enable, value}; | ||
ioctl(touch_fd_.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); | ||
} | ||
|
||
void setFingerDown(bool pressed) { | ||
mDevice->extCmd(mDevice, COMMAND_NIT, pressed ? PARAM_NIT_FOD : PARAM_NIT_NONE); | ||
|
||
int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, pressed ? 1 : 0}; | ||
ioctl(touch_fd_.get(), TOUCH_IOC_SET_CUR_VALUE, &buf); | ||
|
||
set(DISP_PARAM_PATH, | ||
std::string(DISP_PARAM_LOCAL_HBM_MODE) + " " + | ||
(pressed ? DISP_PARAM_LOCAL_HBM_ON : DISP_PARAM_LOCAL_HBM_OFF)); | ||
} | ||
}; | ||
|
||
static UdfpsHandler* create() { | ||
return new XiaomiSm8550UdfpsHander(); | ||
} | ||
|
||
static void destroy(UdfpsHandler* handler) { | ||
delete handler; | ||
} | ||
|
||
extern "C" UdfpsHandlerFactory UDFPS_HANDLER_FACTORY = { | ||
.create = create, | ||
.destroy = destroy, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2022 The LineageOS Project | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
/*CUR,DEFAULT,MIN,MAX*/ | ||
#define VALUE_TYPE_SIZE 6 | ||
#define VALUE_GRIP_SIZE 9 | ||
#define MAX_BUF_SIZE 256 | ||
#define BTN_INFO 0x152 | ||
#define MAX_TOUCH_ID 10 | ||
#define RAW_BUF_NUM 4 | ||
#define THP_CMD_BASE 1000 | ||
|
||
enum MODE_CMD { | ||
SET_CUR_VALUE = 0, | ||
GET_CUR_VALUE, | ||
GET_DEF_VALUE, | ||
GET_MIN_VALUE, | ||
GET_MAX_VALUE, | ||
GET_MODE_VALUE, | ||
RESET_MODE, | ||
SET_LONG_VALUE, | ||
}; | ||
|
||
enum MODE_TYPE { | ||
Touch_Game_Mode = 0, | ||
Touch_Active_MODE = 1, | ||
Touch_UP_THRESHOLD = 2, | ||
Touch_Tolerance = 3, | ||
Touch_Aim_Sensitivity = 4, | ||
Touch_Tap_Stability = 5, | ||
Touch_Expert_Mode = 6, | ||
Touch_Edge_Filter = 7, | ||
Touch_Panel_Orientation = 8, | ||
Touch_Report_Rate = 9, | ||
Touch_Fod_Enable = 10, | ||
Touch_Aod_Enable = 11, | ||
Touch_Resist_RF = 12, | ||
Touch_Idle_Time = 13, | ||
Touch_Doubletap_Mode = 14, | ||
Touch_Grip_Mode = 15, | ||
Touch_FodIcon_Enable = 16, | ||
Touch_Nonui_Mode = 17, | ||
Touch_Debug_Level = 18, | ||
Touch_Power_Status = 19, | ||
Touch_Mode_NUM = 20, | ||
THP_LOCK_SCAN_MODE = THP_CMD_BASE + 0, | ||
THP_FOD_DOWNUP_CTL = THP_CMD_BASE + 1, | ||
THP_SELF_CAP_SCAN = THP_CMD_BASE + 2, | ||
THP_REPORT_POINT_SWITCH = THP_CMD_BASE + 3, | ||
THP_HAL_INIT_READY = THP_CMD_BASE + 4, | ||
}; |