sm8450-common: udfps: Enable HBM via disp_feature
Change-Id: I6ffdf1de9b0cf5eb2b479ce3ff66ca4f7e74e17c
This commit is contained in:
1
sepolicy/vendor/hal_fingerprint.te
vendored
1
sepolicy/vendor/hal_fingerprint.te
vendored
@@ -26,6 +26,7 @@ allow hal_fingerprint_default vendor_sysfs_graphics:file rw_file_perms;
|
|||||||
allow hal_fingerprint_default vendor_xdsp_device:chr_file r_file_perms;
|
allow hal_fingerprint_default vendor_xdsp_device:chr_file r_file_perms;
|
||||||
allow hal_fingerprint_default vendor_xdsp_device:file r_file_perms;
|
allow hal_fingerprint_default vendor_xdsp_device:file r_file_perms;
|
||||||
allow hal_fingerprint_default mnt_vendor_file:dir search;
|
allow hal_fingerprint_default mnt_vendor_file:dir search;
|
||||||
|
allow hal_fingerprint_default vendor_displayfeature_device:chr_file { ioctl open read write };
|
||||||
|
|
||||||
get_prop(hal_fingerprint_default, vendor_adsprpc_prop)
|
get_prop(hal_fingerprint_default, vendor_adsprpc_prop)
|
||||||
get_prop(hal_fingerprint_default, vendor_panel_info_prop)
|
get_prop(hal_fingerprint_default, vendor_panel_info_prop)
|
||||||
|
@@ -12,6 +12,7 @@ cc_library {
|
|||||||
"libbase",
|
"libbase",
|
||||||
],
|
],
|
||||||
header_libs: [
|
header_libs: [
|
||||||
|
"generated_kernel_headers",
|
||||||
"//hardware/xiaomi:xiaomifingerprint_headers",
|
"//hardware/xiaomi:xiaomifingerprint_headers",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include <display/drm/mi_disp.h>
|
||||||
|
|
||||||
#include "UdfpsHandler.h"
|
#include "UdfpsHandler.h"
|
||||||
#include "xiaomi_touch.h"
|
#include "xiaomi_touch.h"
|
||||||
|
|
||||||
@@ -34,21 +36,12 @@
|
|||||||
#define TOUCH_IOC_SET_CUR_VALUE _IO(TOUCH_MAGIC, SET_CUR_VALUE)
|
#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 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_FEATURE_PATH "/dev/mi_display/disp_feature"
|
||||||
#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"
|
#define FOD_PRESS_STATUS_PATH "/sys/class/touch/touch_dev/fod_press_status"
|
||||||
|
|
||||||
namespace {
|
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) {
|
static bool readBool(int fd) {
|
||||||
char c;
|
char c;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -75,6 +68,7 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|||||||
void init(fingerprint_device_t* device) {
|
void init(fingerprint_device_t* device) {
|
||||||
mDevice = device;
|
mDevice = device;
|
||||||
touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR));
|
touch_fd_ = android::base::unique_fd(open(TOUCH_DEV_PATH, O_RDWR));
|
||||||
|
disp_fd_ = android::base::unique_fd(open(DISP_FEATURE_PATH, O_RDWR));
|
||||||
|
|
||||||
std::thread([this]() {
|
std::thread([this]() {
|
||||||
int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY);
|
int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY);
|
||||||
@@ -156,6 +150,7 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|||||||
private:
|
private:
|
||||||
fingerprint_device_t* mDevice;
|
fingerprint_device_t* mDevice;
|
||||||
android::base::unique_fd touch_fd_;
|
android::base::unique_fd touch_fd_;
|
||||||
|
android::base::unique_fd disp_fd_;
|
||||||
bool enrolling = false;
|
bool enrolling = false;
|
||||||
|
|
||||||
void setFodStatus(int value) {
|
void setFodStatus(int value) {
|
||||||
@@ -169,9 +164,13 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|||||||
int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, pressed ? 1 : 0};
|
int buf[MAX_BUF_SIZE] = {TOUCH_ID, THP_FOD_DOWNUP_CTL, pressed ? 1 : 0};
|
||||||
ioctl(touch_fd_.get(), TOUCH_IOC_SET_CUR_VALUE, &buf);
|
ioctl(touch_fd_.get(), TOUCH_IOC_SET_CUR_VALUE, &buf);
|
||||||
|
|
||||||
set(DISP_PARAM_PATH,
|
// Request HBM
|
||||||
std::string(DISP_PARAM_LOCAL_HBM_MODE) + " " +
|
disp_local_hbm_req req;
|
||||||
(pressed ? DISP_PARAM_LOCAL_HBM_ON : DISP_PARAM_LOCAL_HBM_OFF));
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user