Skip to content

Commit

Permalink
xiaomi13: Enable HBM via disp_feature
Browse files Browse the repository at this point in the history
Change-Id: I6ffdf1de9b0cf5eb2b479ce3ff66ca4f7e74e17c

display: mi_disp: Move fod_ui_ready_state to uapi headers
Change-Id: I40e37f65654294403a038ea41ea9c5a28302aa6e
  • Loading branch information
ArianK16a authored and 33bca committed Mar 25, 2024
1 parent 587c9ca commit 21c3f9a
Show file tree
Hide file tree
Showing 3 changed files with 892 additions and 13 deletions.
1 change: 1 addition & 0 deletions sepolicy/vendor/hal_fingerprint.te
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ allow hal_fingerprint_default vendor_sysfs_graphics:file rw_file_perms;
allow hal_fingerprint_default input_device:dir r_dir_perms;
allow hal_fingerprint_default input_device:chr_file rwx_file_perms;
allow hal_fingerprint_default mnt_vendor_file:dir search;
allow hal_fingerprint_default vendor_displayfeature_device:chr_file rwx_file_perms;
allow hal_fingerprint_default vendor_fingerprint_device:chr_file rwx_file_perms;
allow hal_fingerprint_default tee_device:chr_file rw_file_perms;
allow hal_fingerprint_default vendor_dmabuf_qseecom_heap_device:chr_file r_file_perms;
Expand Down
24 changes: 11 additions & 13 deletions udfps/UdfpsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fstream>
#include <thread>

#include "mi_disp.h"
#include "UdfpsHandler.h"
#include "xiaomi_touch.h"

Expand All @@ -36,21 +37,12 @@
#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 DISP_FEATURE_PATH "/dev/mi_display/disp_feature"

#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;
Expand Down Expand Up @@ -78,6 +70,7 @@ class XiaomiSm8550UdfpsHander : public UdfpsHandler {
mDevice = device;
mSku = android::base::GetProperty("ro.boot.hardware.sku", "");
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]() {
int fd = open(FOD_PRESS_STATUS_PATH, O_RDONLY);
Expand Down Expand Up @@ -140,6 +133,7 @@ class XiaomiSm8550UdfpsHander : public UdfpsHandler {
fingerprint_device_t* mDevice;
std::string mSku;
android::base::unique_fd touch_fd_;
android::base::unique_fd disp_fd_;

void setFodStatus(int value) {
int buf[MAX_BUF_SIZE] = {TOUCH_ID, Touch_Fod_Enable, value};
Expand All @@ -152,9 +146,13 @@ class XiaomiSm8550UdfpsHander : public UdfpsHandler {
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));
// 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);
}
};

Expand Down
Loading

0 comments on commit 21c3f9a

Please sign in to comment.