Skip to content

Commit

Permalink
umi: udfps: Disable HBM at fod_status changes
Browse files Browse the repository at this point in the history
* This is a hack to ensure that no screen flash occurs when the finger is released.
* Idea from Demon's Xiaomi sm8350-common.

Change-Id: Ic29d0fabec1c97493370018223fb4559fb0ad622
  • Loading branch information
markakash authored and chaptsand committed Sep 2, 2022
1 parent 04def82 commit 867d70b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions init/init.xiaomi.rc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ on boot

chmod 0666 /dev/input/event2

chown system system /sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/disp_param
chmod 0660 /sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/disp_param

on property:sys.boot_completed=1
# configure input boost settings
write /sys/devices/system/cpu/cpu_boost/input_boost_freq "0:1344000"
Expand Down
30 changes: 24 additions & 6 deletions udfps/UdfpsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
#include <fcntl.h>
#include <fstream>
#include <poll.h>
#include <thread>
#include <unistd.h>
Expand All @@ -27,11 +28,24 @@
#define TOUCH_MAGIC 0x5400
#define TOUCH_IOC_SETMODE TOUCH_MAGIC + 0

#define DISPPARAM_PATH "/sys/devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/disp_param"
#define DISPPARAM_FOD_HBM_OFF "0xE0000"

static const char* kFodUiPaths[] = {
"/sys/devices/platform/soc/soc:qcom,dsi-display-primary/fod_ui",
"/sys/devices/platform/soc/soc:qcom,dsi-display/fod_ui",
};

namespace {

template <typename T>
static void set(const std::string& path, const T& value) {
std::ofstream file(path);
file << value;
}

} // anonymous namespace

static bool readBool(int fd) {
char c;
int rc;
Expand Down Expand Up @@ -84,12 +98,16 @@ class XiaomiKonaUdfpsHander : public UdfpsHandler {
continue;
}

mDevice->extCmd(mDevice, COMMAND_NIT,
readBool(fd) ? PARAM_NIT_FOD : PARAM_NIT_NONE);

int arg[2] = {TOUCH_FOD_ENABLE,
readBool(fd) ? FOD_STATUS_ON : FOD_STATUS_OFF};
ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg);
if (readBool(fd)) {
mDevice->extCmd(mDevice, COMMAND_NIT, PARAM_NIT_FOD);
int arg[2] = {TOUCH_FOD_ENABLE, FOD_STATUS_ON};
ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg);
} else {
mDevice->extCmd(mDevice, COMMAND_NIT, PARAM_NIT_NONE);
set(DISPPARAM_PATH, DISPPARAM_FOD_HBM_OFF);
int arg[2] = {TOUCH_FOD_ENABLE, FOD_STATUS_OFF};
ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg);
}
}
}).detach();
}
Expand Down

0 comments on commit 867d70b

Please # to comment.