display: Add support for legacy Wide Color Gamut
- Add extended range in ColorMetadata.
- Send ColorPrimaryTransfer info from color modes to Strategy,
which will be used in determining the blend color space.
- Remove handling color primaries or gamut in HWC2.
- Handle invalid format or unsupported range in SDM.
- Remove FEATURE_WIDE_COLOR and enable by default.
Change-Id: If429e9fffdcdc59c18f1b5ef5d074efddd97f2af
Crs-fixed: 2215125
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index 483d7e7..26e4bae 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -46,9 +46,5 @@
hwc_buffer_allocator.cpp \
hwc_display_external_test.cpp
-ifeq ($(TARGET_HAS_WIDE_COLOR_DISPLAY), true)
- LOCAL_CFLAGS += -DFEATURE_WIDE_COLOR
-endif
-
include $(BUILD_SHARED_LIBRARY)
endif
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 45a5c3d..efc44a2 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -50,24 +50,6 @@
namespace sdm {
-// This weight function is needed because the color primaries are not sorted by gamut size
-static ColorPrimaries WidestPrimaries(ColorPrimaries p1, ColorPrimaries p2) {
- int weight = 10;
- int lp1 = p1, lp2 = p2;
- // TODO(user) add weight to other wide gamut primaries
- if (lp1 == ColorPrimaries_BT2020) {
- lp1 *= weight;
- }
- if (lp1 == ColorPrimaries_BT2020) {
- lp2 *= weight;
- }
- if (lp1 >= lp2) {
- return p1;
- } else {
- return p2;
- }
-}
-
HWCColorMode::HWCColorMode(DisplayInterface *display_intf) : display_intf_(display_intf) {}
HWC2::Error HWCColorMode::Init() {
@@ -493,15 +475,12 @@
layer_stack_ = LayerStack();
display_rect_ = LayerRect();
metadata_refresh_rate_ = 0;
- auto working_primaries = ColorPrimaries_BT709_5;
bool secure_display_active = false;
layer_stack_.flags.animating = animating_;
uint32_t color_mode_count = 0;
display_intf_->GetColorModeCount(&color_mode_count);
- bool extended_range = false;
-
// Add one layer for fb target
// TODO(user): Add blit target layers
for (auto hwc_layer : layer_set_) {
@@ -517,19 +496,9 @@
}
if (!hwc_layer->ValidateAndSetCSC()) {
-#ifdef FEATURE_WIDE_COLOR
layer->flags.skip = true;
-#endif
}
- auto range = hwc_layer->GetLayerDataspace() & HAL_DATASPACE_RANGE_MASK;
- if (range == HAL_DATASPACE_RANGE_EXTENDED) {
- extended_range = true;
- }
-
- working_primaries = WidestPrimaries(working_primaries,
- layer->input_buffer.color_metadata.colorPrimaries);
-
// set default composition as GPU for SDM
layer->composition = kCompositionGPU;
@@ -626,20 +595,6 @@
layer_stack_.layers.push_back(layer);
}
-
-#ifdef FEATURE_WIDE_COLOR
- for (auto hwc_layer : layer_set_) {
- auto layer = hwc_layer->GetSDMLayer();
- if (layer->input_buffer.color_metadata.colorPrimaries != working_primaries &&
- !hwc_layer->SupportLocalConversion(working_primaries)) {
- layer->flags.skip = true;
- }
- if (layer->flags.skip) {
- layer_stack_.flags.skip_present = true;
- }
- }
-#endif
-
// TODO(user): Set correctly when SDM supports geometry_changes as bitmask
layer_stack_.flags.geometry_changed = UINT32(geometry_changes_ > 0);
// Append client target to the layer stack
@@ -649,7 +604,7 @@
// fall back frame composition to GPU when client target is 10bit
// TODO(user): clarify the behaviour from Client(SF) and SDM Extn -
// when handling 10bit FBT, as it would affect blending
- if (Is10BitFormat(sdm_client_target->input_buffer.format) || extended_range) {
+ if (Is10BitFormat(sdm_client_target->input_buffer.format)) {
// Must fall back to client composition
MarkLayersForClientComposition();
}
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index 20978d0..a9be2bc 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -86,7 +86,7 @@
*color_primary = ColorPrimaries_BT2020;
break;
default:
- DLOGV_IF(kTagClient, "Unsupported Standard Request = %d", standard);
+ DLOGE("Unsupported Standard Request = %d", standard);
supported_csc = false;
}
return supported_csc;
@@ -124,7 +124,7 @@
return supported_transfer;
}
-void GetRange(const int32_t &dataspace, ColorRange *color_range) {
+bool GetRange(const int32_t &dataspace, ColorRange *color_range) {
auto range = dataspace & HAL_DATASPACE_RANGE_MASK;
switch (range) {
case HAL_DATASPACE_RANGE_FULL:
@@ -133,10 +133,14 @@
case HAL_DATASPACE_RANGE_LIMITED:
*color_range = Range_Limited;
break;
- default:
- DLOGV_IF(kTagClient, "Unsupported Range Request = %d", range);
+ case HAL_DATASPACE_RANGE_EXTENDED:
+ *color_range = Range_Extended;
break;
+ default:
+ DLOGE("Unsupported Range Request = %d", range);
+ return false;
}
+ return true;
}
bool IsBT2020(const ColorPrimaries &color_primary) {
@@ -153,16 +157,14 @@
bool GetSDMColorSpace(const int32_t &dataspace, ColorMetaData *color_metadata) {
bool valid = false;
valid = GetColorPrimary(dataspace, &(color_metadata->colorPrimaries));
- if (!valid) {
- return valid;
+ if (valid) {
+ valid = GetTransfer(dataspace, &(color_metadata->transfer));
}
- valid = GetTransfer(dataspace, &(color_metadata->transfer));
- if (!valid) {
- return valid;
+ if (valid) {
+ valid = GetRange(dataspace, &(color_metadata->range));
}
- GetRange(dataspace, &(color_metadata->range));
- return true;
+ return valid;
}
// Layer operations
@@ -799,16 +801,6 @@
return kErrorNone;
}
-
-
-bool HWCLayer::SupportLocalConversion(ColorPrimaries working_primaries) {
- if (layer_->input_buffer.color_metadata.colorPrimaries <= ColorPrimaries_BT601_6_525 &&
- working_primaries <= ColorPrimaries_BT601_6_525) {
- return true;
- }
- return false;
-}
-
bool HWCLayer::ValidateAndSetCSC() {
if (client_requested_ != HWC2::Composition::Device &&
client_requested_ != HWC2::Composition::Cursor) {
@@ -818,7 +810,6 @@
LayerBuffer *layer_buffer = &layer_->input_buffer;
bool use_color_metadata = true;
-#ifdef FEATURE_WIDE_COLOR
ColorMetaData csc = {};
if (dataspace_ != HAL_DATASPACE_UNKNOWN) {
use_color_metadata = false;
@@ -831,7 +822,6 @@
layer_buffer->color_metadata.colorPrimaries = csc.colorPrimaries;
layer_buffer->color_metadata.range = csc.range;
}
-#endif
if (IsBT2020(layer_buffer->color_metadata.colorPrimaries)) {
// android_dataspace_t doesnt support mastering display and light levels
diff --git a/sdm/libs/hwc2/hwc_layers.h b/sdm/libs/hwc2/hwc_layers.h
index 2a4d4b4..7d978c8 100644
--- a/sdm/libs/hwc2/hwc_layers.h
+++ b/sdm/libs/hwc2/hwc_layers.h
@@ -42,7 +42,7 @@
DisplayError SetCSC(const private_handle_t *pvt_handle, ColorMetaData *color_metadata);
bool GetColorPrimary(const int32_t &dataspace, ColorPrimaries *color_primary);
bool GetTransfer(const int32_t &dataspace, GammaTransfer *gamma_transfer);
-void GetRange(const int32_t &dataspace, ColorRange *color_range);
+bool GetRange(const int32_t &dataspace, ColorRange *color_range);
bool GetSDMColorSpace(const int32_t &dataspace, ColorMetaData *color_metadata);
bool IsBT2020(const ColorPrimaries &color_primary);
enum GeometryChanges {
@@ -92,7 +92,6 @@
int32_t PopBackReleaseFence(void);
int32_t PopFrontReleaseFence(void);
bool ValidateAndSetCSC();
- bool SupportLocalConversion(ColorPrimaries working_primaries);
void ResetValidation() { needs_validate_ = false; }
bool NeedsValidation() { return (needs_validate_ || geometry_changes_); }
bool IsSingleBuffered() { return single_buffer_; }