composer: Allow dropping of SDR layer video histogram data
In current systems wide gamut SDR videos are seen to produce
histogram data when decoded by the video decoder hardware. The
presence of the histogram data requires additional processing,
resulting in a MIPS increase when compared to past platforms.
Introduce a vendor property that when set will skip retrieval
of histogram data for non-HDR layers. Usage of this property
will ensure SDR video performance operates closer to previous
targets.
Change-Id: I84981d4835723b4e528536f61855ce4bc814f674
diff --git a/composer/hwc_display.cpp b/composer/hwc_display.cpp
index d828d66..c2f55e3 100644
--- a/composer/hwc_display.cpp
+++ b/composer/hwc_display.cpp
@@ -509,6 +509,11 @@
DLOGI("HDR Handling disabled");
}
+ HWCDebugHandler::Get()->GetProperty(DISABLE_SDR_HISTOGRAM, &disable_sdr_histogram_);
+ if (disable_sdr_histogram_) {
+ DLOGI("Non-HDR histogram handling disabled");
+ }
+
int property_swap_interval = 1;
HWCDebugHandler::Get()->GetProperty(ZERO_SWAP_INTERVAL, &property_swap_interval);
if (property_swap_interval == 0) {
@@ -623,6 +628,9 @@
// LayerStack operations
HWC2::Error HWCDisplay::CreateLayer(hwc2_layer_t *out_layer_id) {
HWCLayer *layer = *layer_set_.emplace(new HWCLayer(id_, buffer_allocator_));
+ if (disable_sdr_histogram_)
+ layer->IgnoreSdrContentMetadata(true);
+
layer_map_.emplace(std::make_pair(layer->GetId(), layer));
*out_layer_id = layer->GetId();
geometry_changes_ |= GeometryChanges::kAdded;
diff --git a/composer/hwc_display.h b/composer/hwc_display.h
index 7ff6559..01480c5 100644
--- a/composer/hwc_display.h
+++ b/composer/hwc_display.h
@@ -560,6 +560,7 @@
HWCToneMapper *tone_mapper_ = nullptr;
uint32_t num_configs_ = 0;
int disable_hdr_handling_ = 0; // disables HDR handling.
+ int disable_sdr_histogram_ = 0; // disables handling of SDR histogram data.
bool pending_commit_ = false;
bool is_cmd_mode_ = false;
bool partial_update_enabled_ = false;
diff --git a/composer/hwc_layers.cpp b/composer/hwc_layers.cpp
index 8ebfc61..a44a3a6 100644
--- a/composer/hwc_layers.cpp
+++ b/composer/hwc_layers.cpp
@@ -146,6 +146,11 @@
return true;
}
+bool IsHdr(const ColorPrimaries &color_primary, const GammaTransfer &gamma_transfer) {
+ return (color_primary == ColorPrimaries_BT2020) &&
+ ((gamma_transfer == Transfer_SMPTE_ST2084) || (gamma_transfer == Transfer_HLG));
+}
+
bool IsBT2020(const ColorPrimaries &color_primary) {
switch (color_primary) {
case ColorPrimaries_BT2020:
@@ -910,6 +915,11 @@
// Handle colorMetaData / Dataspace handling now
ValidateAndSetCSC(handle);
+ if (ignore_sdr_content_md_ &&
+ !IsHdr(layer_buffer->color_metadata.colorPrimaries, layer_buffer->color_metadata.transfer)) {
+ return kErrorNone;
+ }
+
int hist_set = qtigralloc::getMetadataState(handle, QTI_VIDEO_HISTOGRAM_STATS);
if (hist_set > 0) {
VideoHistogramMetadata histogram = {};
diff --git a/composer/hwc_layers.h b/composer/hwc_layers.h
index b1df68b..eb29a50 100644
--- a/composer/hwc_layers.h
+++ b/composer/hwc_layers.h
@@ -119,6 +119,9 @@
shared_ptr<Fence> GetReleaseFence();
void SetReleaseFence(const shared_ptr<Fence> &release_fence);
bool IsLayerCompatible() { return compatible_; }
+ void IgnoreSdrContentMetadata(bool disable) {
+ ignore_sdr_content_md_ = disable;
+ }
private:
Layer *layer_ = nullptr;
@@ -142,6 +145,7 @@
bool buffer_flipped_ = false;
bool secure_ = false;
bool compatible_ = false;
+ bool ignore_sdr_content_md_ = false;
// Composition requested by client(SF) Original
HWC2::Composition client_requested_orig_ = HWC2::Composition::Device;
diff --git a/config/display-product.mk b/config/display-product.mk
index 31eb344..158aabd 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -122,7 +122,8 @@
vendor.display.enable_rounded_corner=1 \
vendor.display.disable_3d_adaptive_tm=1 \
vendor.display.disable_sdr_dimming=1 \
- vendor.display.enable_rc_support=1
+ vendor.display.enable_rc_support=1 \
+ vendor.display.disable_sdr_histogram=1
# Enable offline rotator for Bengal.
ifneq ($(TARGET_BOARD_PLATFORM),bengal)
diff --git a/include/display_properties.h b/include/display_properties.h
index d1c45ed..43057c7 100644
--- a/include/display_properties.h
+++ b/include/display_properties.h
@@ -121,6 +121,7 @@
#define ENABLE_POMS_DURING_DOZE DISPLAY_PROP("enable_poms_during_doze")
// Disable 3D adaptive tone mapping support
#define DISABLE_3D_ADAPTIVE_TM DISPLAY_PROP("disable_3d_adaptive_tm")
+#define DISABLE_SDR_HISTOGRAM DISPLAY_PROP("disable_sdr_histogram")
// Disable SDR dimming support
#define DISABLE_SDR_DIMMING DISPLAY_PROP("disable_sdr_dimming")