mirror of
https://github.com/Evolution-X-Devices/device_xiaomi_sm6150-common
synced 2026-01-27 12:07:36 +00:00
davinci: fod: Calculate dim amount based on real brightness
Change-Id: I72b7dd1fca426cc442f9a6fa382f413bbaadfc76
This commit is contained in:
@@ -38,8 +38,18 @@
|
|||||||
#define FOD_SENSOR_Y 1931
|
#define FOD_SENSOR_Y 1931
|
||||||
#define FOD_SENSOR_SIZE 190
|
#define FOD_SENSOR_SIZE 190
|
||||||
|
|
||||||
|
#define BRIGHTNESS_PATH "/sys/class/backlight/panel0-backlight/brightness"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static T get(const std::string& path, const T& def) {
|
||||||
|
std::ifstream file(path);
|
||||||
|
T result;
|
||||||
|
file >> result;
|
||||||
|
return file.fail() ? def : result;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void set(const std::string& path, const T& value) {
|
static void set(const std::string& path, const T& value) {
|
||||||
std::ofstream file(path);
|
std::ofstream file(path);
|
||||||
@@ -119,14 +129,17 @@ Return<void> FingerprintInscreen::setLongPressEnabled(bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t brightness) {
|
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t brightness) {
|
||||||
|
int realBrightness = get(BRIGHTNESS_PATH, 0);
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
||||||
if (brightness > 62) {
|
if (realBrightness > 500) {
|
||||||
alpha = 1.0 - pow(brightness / 255.0 * 430.0 / 600.0, 0.45);
|
alpha = 1.0 - pow(realBrightness / 2047.0 * 430.0 / 600.0, 0.455);
|
||||||
} else {
|
} else {
|
||||||
alpha = 1.0 - pow(brightness / 200.0, 0.45);
|
alpha = 1.0 - pow(realBrightness / 1680.0, 0.455);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) brightness;
|
||||||
|
|
||||||
return 255 * alpha;
|
return 255 * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user