sm8450-common: udfps: Use 110 nit fod when the brightness is low
Change-Id: I892c8c5eaef6606a7576722ec1751db2f0a9b2ef
This commit is contained in:
parent
9b37d1a99e
commit
43650d15a4
1 changed files with 28 additions and 5 deletions
|
@ -20,8 +20,11 @@
|
|||
#include "xiaomi_touch.h"
|
||||
|
||||
#define COMMAND_NIT 10
|
||||
#define PARAM_NIT_FOD 1
|
||||
#define PARAM_NIT_NONE 0
|
||||
#define TARGET_BRIGHTNESS_OFF 0
|
||||
#define TARGET_BRIGHTNESS_1000NIT 1
|
||||
#define TARGET_BRIGHTNESS_110NIT 6
|
||||
|
||||
#define LOW_BRIGHTNESS_THRESHHOLD 100
|
||||
|
||||
#define COMMAND_FOD_PRESS_STATUS 1
|
||||
#define PARAM_FOD_PRESSED 1
|
||||
|
@ -115,12 +118,28 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|||
mDevice->extCmd(mDevice, COMMAND_FOD_PRESS_STATUS,
|
||||
pressed ? PARAM_FOD_PRESSED : PARAM_FOD_RELEASED);
|
||||
|
||||
// Get brightness
|
||||
struct disp_brightness_req brightness_req;
|
||||
int brightness = LOW_BRIGHTNESS_THRESHHOLD;
|
||||
brightness_req.base.flag = 0;
|
||||
brightness_req.base.disp_id = MI_DISP_PRIMARY;
|
||||
rc = ioctl(disp_fd_.get(), MI_DISP_IOCTL_GET_BRIGHTNESS, &brightness_req);
|
||||
if (rc) {
|
||||
LOG(ERROR) << "failed to get brightness, err: " << rc;
|
||||
} else if (brightness_req.brightness > 0) {
|
||||
brightness = brightness_req.brightness;
|
||||
}
|
||||
LOG(DEBUG) << "brightness is: " << (int)brightness_req.brightness;
|
||||
bool requestLowBrightness = brightness < LOW_BRIGHTNESS_THRESHHOLD;
|
||||
|
||||
// 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;
|
||||
req.local_hbm_value =
|
||||
pressed ? (requestLowBrightness ? LHBM_TARGET_BRIGHTNESS_WHITE_110NIT
|
||||
: LHBM_TARGET_BRIGHTNESS_WHITE_1000NIT)
|
||||
: LHBM_TARGET_BRIGHTNESS_OFF_FINGER_UP;
|
||||
ioctl(disp_fd_.get(), MI_DISP_IOCTL_SET_LOCAL_HBM, &req);
|
||||
}
|
||||
}).detach();
|
||||
|
@ -167,9 +186,13 @@ class XiaomiSm8450UdfpsHander : public UdfpsHandler {
|
|||
LOG(DEBUG) << "received data: " << std::bitset<8>(value);
|
||||
|
||||
bool localHbmUiReady = value & LOCAL_HBM_UI_READY;
|
||||
bool requestLowBrightnessCapture = value & FOD_LOW_BRIGHTNESS_CAPTURE;
|
||||
|
||||
mDevice->extCmd(mDevice, COMMAND_NIT,
|
||||
localHbmUiReady ? PARAM_NIT_FOD : PARAM_NIT_NONE);
|
||||
localHbmUiReady
|
||||
? (requestLowBrightnessCapture ? TARGET_BRIGHTNESS_110NIT
|
||||
: TARGET_BRIGHTNESS_1000NIT)
|
||||
: TARGET_BRIGHTNESS_OFF);
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue