diff options
author | linpeter <linpeter@google.com> | 2018-07-13 21:29:40 +0800 |
---|---|---|
committer | linpeter <linpeter@google.com> | 2018-07-13 21:29:40 +0800 |
commit | e7f05d57fbde773cd38ed66b60875953c140ef16 (patch) | |
tree | 56a0e7922fd3f8bf55dc74c5550c48b0bec9966a /sdm/libs/hwc2/hwc_display_primary.cpp | |
parent | 9e43ef2ab99828ba6f5b25b096d07e3102ce2739 (diff) | |
download | display-e7f05d57fbde773cd38ed66b60875953c140ef16.tar.gz |
hwc2: Enable HBM based on HDR layer coverage
Enable high brightness mode when the largest HDR layer covers >50% of
the screen. Use hardware.google.light@1.0 interface.
Bug: 109762428
Change-Id: Ib5830e5f02d380824116d1f3ed7ad0727fca9385
Diffstat (limited to 'sdm/libs/hwc2/hwc_display_primary.cpp')
-rw-r--r-- | sdm/libs/hwc2/hwc_display_primary.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sdm/libs/hwc2/hwc_display_primary.cpp b/sdm/libs/hwc2/hwc_display_primary.cpp index f86fbe1d..31258ecf 100644 --- a/sdm/libs/hwc2/hwc_display_primary.cpp +++ b/sdm/libs/hwc2/hwc_display_primary.cpp @@ -251,6 +251,33 @@ HWC2::Error HWCDisplayPrimary::Present(int32_t *out_retire_fence) { } } + if (CC_UNLIKELY(!has_init_light_server_)) { + using ILight = ::hardware::google::light::V1_0::ILight; + vendor_ILight_ = ILight::getService(); + if (vendor_ILight_ != nullptr) { + vendor_ILight_->setHbm(false); + } else { + DLOGE("failed to get vendor light service"); + } + + uint32_t panel_x, panel_y; + GetPanelResolution(&panel_x, &panel_y); + hbm_threshold_px_ = float(panel_x * panel_y) * hbm_threshold_pct_; + DLOGI("Configure hbm_threshold_px_ to %f", hbm_threshold_px_); + + has_init_light_server_ = true; + } + + const bool enable_hbm(hdr_largest_layer_px_ > hbm_threshold_px_); + if (high_brightness_mode_ != enable_hbm && vendor_ILight_ != nullptr) { + using ::android::hardware::light::V2_0::Status; + if (Status::SUCCESS == vendor_ILight_->setHbm(enable_hbm)) { + high_brightness_mode_ = enable_hbm; + } else { + DLOGE("failed to setHbm to %d", enable_hbm); + } + } + CloseFd(&output_buffer_.acquire_fence_fd); pending_commit_ = false; return status; |