|
@@ -17,7 +17,6 @@
|
|
|
#include <thread>
|
|
|
|
|
|
#include <display/drm/mi_disp.h>
|
|
|
-#include <linux/xiaomi_touch.h>
|
|
|
|
|
|
#include "UdfpsHandler.h"
|
|
|
|
|
@@ -35,33 +34,11 @@
|
|
|
#define PARAM_FOD_RELEASED 0
|
|
|
|
|
|
#define DISP_FEATURE_PATH "/dev/mi_display/disp_feature"
|
|
|
-#define TOUCH_DEV_PATH "/dev/xiaomi-touch"
|
|
|
-
|
|
|
-#define FOD_PRESS_STATUS_PATH "/sys/class/touch/touch_dev/fod_press_status"
|
|
|
|
|
|
using ::aidl::android::hardware::biometrics::fingerprint::AcquiredInfo;
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
-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';
|
|
|
-}
|
|
|
-
|
|
|
static disp_event_resp* parseDispEvent(int fd) {
|
|
|
disp_event header;
|
|
|
ssize_t headerSize = read(fd, &header, sizeof(header));
|
|
@@ -95,46 +72,8 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|
|
public:
|
|
|
void init(fingerprint_device_t* device) {
|
|
|
mDevice = device;
|
|
|
- touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR));
|
|
|
disp_fd_ = android::base::unique_fd(open(DISP_FEATURE_PATH, O_RDWR));
|
|
|
|
|
|
- // Thread to notify fingeprint hwmodule about fod presses
|
|
|
- std::thread([this]() {
|
|
|
- int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY);
|
|
|
- if (fd < 0) {
|
|
|
- LOG(ERROR) << "failed to open " << FOD_PRESS_STATUS_PATH << " , 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 " << FOD_PRESS_STATUS_PATH << ", err: " << rc;
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- bool pressed = readBool(fd);
|
|
|
- mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, pressed ? lastPressX : 0);
|
|
|
- mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, pressed ? lastPressY : 0);
|
|
|
- mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS,
|
|
|
- pressed ? PARAM_FOD_PRESSED : PARAM_FOD_RELEASED);
|
|
|
-
|
|
|
- // Request HBM
|
|
|
- disp_local_hbm_req req;
|
|
|
- req.base.flag = 0;
|
|
|
- req.base.disp_id = MI_DISP_PRIMARY;
|
|
|
- req.local_hbm_value = pressed ? LHBM_TARGET_BRIGHTNESS_WHITE_1000NIT
|
|
|
- : LHBM_TARGET_BRIGHTNESS_OFF_FINGER_UP;
|
|
|
- ioctl(disp_fd_.get(), MI_DISP_IOCTL_SET_LOCAL_HBM, &req);
|
|
|
- }
|
|
|
- }).detach();
|
|
|
-
|
|
|
// Thread to listen for fod ui changes
|
|
|
std::thread([this]() {
|
|
|
int fd = open(DISP_FEATURE_PATH, O_RDWR);
|
|
@@ -190,24 +129,38 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|
|
|
|
|
void onFingerDown(uint32_t x, uint32_t y, float /*minor*/, float /*major*/) {
|
|
|
LOG(DEBUG) << __func__ << "x: " << x << ", y: " << y;
|
|
|
- // Track x and y coordinates
|
|
|
- lastPressX = x;
|
|
|
- lastPressY = y;
|
|
|
|
|
|
- // Notify touchscreen about press status
|
|
|
- setFingerDown(true);
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, x);
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, y);
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS, PARAM_FOD_PRESSED);
|
|
|
+
|
|
|
+ // Request HBM
|
|
|
+ disp_local_hbm_req req;
|
|
|
+ req.base.flag = 0;
|
|
|
+ req.base.disp_id = MI_DISP_PRIMARY;
|
|
|
+ req.local_hbm_value = LHBM_TARGET_BRIGHTNESS_WHITE_1000NIT;
|
|
|
+ ioctl(disp_fd_.get(), MI_DISP_IOCTL_SET_LOCAL_HBM, &req);
|
|
|
}
|
|
|
|
|
|
void onFingerUp() {
|
|
|
LOG(DEBUG) << __func__;
|
|
|
- // Notify touchscreen about press status
|
|
|
- setFingerDown(false);
|
|
|
+
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_X, 0);
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_Y, 0);
|
|
|
+ mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS, PARAM_FOD_RELEASED);
|
|
|
+
|
|
|
+ // Disable HBM
|
|
|
+ disp_local_hbm_req req;
|
|
|
+ req.base.flag = 0;
|
|
|
+ req.base.disp_id = MI_DISP_PRIMARY;
|
|
|
+ req.local_hbm_value = LHBM_TARGET_BRIGHTNESS_OFF_FINGER_UP;
|
|
|
+ ioctl(disp_fd_.get(), MI_DISP_IOCTL_SET_LOCAL_HBM, &req);
|
|
|
}
|
|
|
|
|
|
void onAcquired(int32_t result, int32_t vendorCode) {
|
|
|
LOG(DEBUG) << __func__ << " result: " << result << " vendorCode: " << vendorCode;
|
|
|
if (static_cast<AcquiredInfo>(result) == AcquiredInfo::GOOD) {
|
|
|
- setFingerDown(false);
|
|
|
+ onFingerUp();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -217,14 +170,7 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|
|
|
|
|
private:
|
|
|
fingerprint_device_t* mDevice;
|
|
|
- android::base::unique_fd touch_fd_;
|
|
|
android::base::unique_fd disp_fd_;
|
|
|
- uint32_t lastPressX, lastPressY;
|
|
|
-
|
|
|
- void setFingerDown(bool pressed) {
|
|
|
- int buf[MAX_BUF_SIZE] = {MI_DISP_PRIMARY, THP_FOD_DOWNUP_CTL, pressed ? 1 : 0};
|
|
|
- ioctl(touch_fd_.get(), TOUCH_IOC_SET_CUR_VALUE, &buf);
|
|
|
- }
|
|
|
};
|
|
|
|
|
|
static UdfpsHandler* create() {
|