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 | |
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')
-rw-r--r-- | sdm/libs/hwc2/Android.mk | 3 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display.cpp | 6 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display.h | 1 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display_primary.cpp | 27 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display_primary.h | 9 |
5 files changed, 45 insertions, 1 deletions
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk index a671c31b..3aab819d 100644 --- a/sdm/libs/hwc2/Android.mk +++ b/sdm/libs/hwc2/Android.mk @@ -24,7 +24,8 @@ LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware li android.hardware.graphics.mapper@2.1 \ android.hardware.graphics.composer@2.2 \ android.hardware.graphics.allocator@2.0 \ - libdisplaydebug + libdisplaydebug \ + hardware.google.light@1.0 ifeq ($(display_config_version), DISPLAY_CONFIG_1_1) LOCAL_SHARED_LIBRARIES += vendor.display.config@1.1 diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp index 15add54d..cef6c350 100644 --- a/sdm/libs/hwc2/hwc_display.cpp +++ b/sdm/libs/hwc2/hwc_display.cpp @@ -455,6 +455,7 @@ void HWCDisplay::BuildLayerStack() { uint32_t color_mode_count = 0; display_intf_->GetColorModeCount(&color_mode_count); + hdr_largest_layer_px_ = 0.0f; // Add one layer for fb target // TODO(user): Add blit target layers @@ -537,6 +538,11 @@ void HWCDisplay::BuildLayerStack() { // In such cases, we should not handle HDR as the HDR mode isn't applied layer->input_buffer.flags.hdr = true; layer_stack_.flags.hdr_present = true; + + // HDR area + auto hdr_layer_area = (layer->dst_rect.right - layer->dst_rect.left) * + (layer->dst_rect.bottom - layer->dst_rect.top); + hdr_largest_layer_px_ = std::max(hdr_largest_layer_px_, hdr_layer_area); } if (hwc_layer->IsNonIntegralSourceCrop() && !is_secure && !layer->flags.solid_fill) { diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h index 084a2a5c..61b11aaf 100644 --- a/sdm/libs/hwc2/hwc_display.h +++ b/sdm/libs/hwc2/hwc_display.h @@ -341,6 +341,7 @@ class HWCDisplay : public DisplayEventHandler { ColorMode current_color_mode_ = ColorMode::NATIVE; ColorPrimaries working_primaries_ = ColorPrimaries_BT709_5; GammaTransfer working_transfer_ = Transfer_sRGB; + float hdr_largest_layer_px_ = 0.0f; private: void DumpInputBuffers(void); 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; diff --git a/sdm/libs/hwc2/hwc_display_primary.h b/sdm/libs/hwc2/hwc_display_primary.h index 7f5e50c9..6737e4db 100644 --- a/sdm/libs/hwc2/hwc_display_primary.h +++ b/sdm/libs/hwc2/hwc_display_primary.h @@ -30,6 +30,8 @@ #ifndef __HWC_DISPLAY_PRIMARY_H__ #define __HWC_DISPLAY_PRIMARY_H__ +#include <hardware/google/light/1.0/ILight.h> +#include <limits> #include <string> #include "cpuhint.h" @@ -107,6 +109,13 @@ class HWCDisplayPrimary : public HWCDisplay { BufferInfo output_buffer_info_ = {}; void *output_buffer_base_ = nullptr; int default_mode_status_ = 0; + + // Members for HBM feature + static constexpr float hbm_threshold_pct_ = 0.5f; + float hbm_threshold_px_ = std::numeric_limits<float>::max(); + android::sp<hardware::google::light::V1_0::ILight> vendor_ILight_ = nullptr; + bool has_init_light_server_ = false; + bool high_brightness_mode_ = false; }; } // namespace sdm |