From 1a10bf33108b39fb01feb5deedf302b2e1cbe4b6 Mon Sep 17 00:00:00 2001 From: Tharaga Balachandran Date: Thu, 14 Nov 2019 11:44:46 -0500 Subject: display: config: Add mapper packages Change-Id: I6dc015874667e49e3be99881eae37454e12f7dbe --- config/display-product.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/config/display-product.mk b/config/display-product.mk index deef6bbf..753101b4 100644 --- a/config/display-product.mk +++ b/config/display-product.mk @@ -24,6 +24,7 @@ PRODUCT_PACKAGES += \ vendor.display.config@1.7.vendor \ vendor.display.config@1.8.vendor \ vendor.display.config@1.9.vendor \ + vendor.qti.hardware.display.mapper@2.0.vendor \ modetest #QDCM calibration xml file for 2k panel -- cgit v1.2.3 From 776d37eaf7749a8ff42b6eb3fd395a673b668c88 Mon Sep 17 00:00:00 2001 From: Gousemoodhin Nadaf Date: Fri, 1 Mar 2019 19:46:38 +0530 Subject: hwc2: Add support for HDR10PLUS - Add support HDR10PLUS hdr capability. - Add support for SetLayerPerFrameMetadataBlobs from composer 2.3. - Populate the dynamic metadata from the new composer API into the layer structure and set validate if the data changes. - Prioritize PerFrameMetadata/Blob over ColorMetaData. Change-Id: Idd9b6f4f104d1584cce31a4cb7022e11eb2751ad CRs-Fixed: 2545757 --- sdm/libs/hwc2/Android.mk | 1 + sdm/libs/hwc2/hwc_display.cpp | 29 ++++++++++------------- sdm/libs/hwc2/hwc_layers.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ sdm/libs/hwc2/hwc_layers.h | 7 ++++-- sdm/libs/hwc2/hwc_session.cpp | 12 ++++++++++ 5 files changed, 85 insertions(+), 19 deletions(-) diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk index 78bce5e5..dae90f8a 100644 --- a/sdm/libs/hwc2/Android.mk +++ b/sdm/libs/hwc2/Android.mk @@ -27,6 +27,7 @@ LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware li android.hardware.graphics.mapper@2.1 \ android.hardware.graphics.allocator@2.0 \ android.hardware.graphics.composer@2.2 \ + android.hardware.graphics.composer@2.3 $(info IDisplayConfig version: $(display_config_version)) ifeq ($(display_config_version), DISPLAY_CONFIG_1_1) diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp index 97f023e3..5adc93b3 100644 --- a/sdm/libs/hwc2/hwc_display.cpp +++ b/sdm/libs/hwc2/hwc_display.cpp @@ -1099,20 +1099,14 @@ HWC2::Error HWCDisplay::GetPerFrameMetadataKeys(uint32_t *out_num_keys, if (out_num_keys == nullptr) { return HWC2::Error::BadParameter; } - *out_num_keys = UINT32(PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL) + 1; - if (out_keys != nullptr) { - out_keys[0] = PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X; - out_keys[1] = PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y; - out_keys[2] = PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X; - out_keys[3] = PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y; - out_keys[4] = PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X; - out_keys[5] = PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y; - out_keys[6] = PerFrameMetadataKey::WHITE_POINT_X; - out_keys[7] = PerFrameMetadataKey::WHITE_POINT_Y; - out_keys[8] = PerFrameMetadataKey::MAX_LUMINANCE; - out_keys[9] = PerFrameMetadataKey::MIN_LUMINANCE; - out_keys[10] = PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL; - out_keys[11] = PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL; + const uint32_t num_keys = UINT32(PerFrameMetadataKey::HDR10_PLUS_SEI) + 1; + if (out_keys == nullptr) { + *out_num_keys = num_keys; + } else { + uint32_t max_out_key_elements = std::min(*out_num_keys, num_keys); + for (int32_t i = 0; i < max_out_key_elements; i++) { + out_keys[i] = static_cast(i); + } } return HWC2::Error::None; } @@ -1453,12 +1447,13 @@ HWC2::Error HWCDisplay::GetHdrCapabilities(uint32_t *out_num_types, int32_t *out } if (out_types == nullptr) { - // We support HDR10 and HLG - *out_num_types = 2; + // We support HDR10, HLG and HDR10_PLUS. + *out_num_types = 3; } else { - // HDR10 and HLG are supported + // HDR10, HLG and HDR10_PLUS are supported. out_types[0] = HAL_HDR_HDR10; out_types[1] = HAL_HDR_HLG; + out_types[2] = HAL_HDR_HDR10_PLUS; *out_max_luminance = fixed_info.max_luminance; *out_max_average_luminance = fixed_info.average_luminance; *out_min_luminance = fixed_info.min_luminance; diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp index 6b345b1c..2065cb49 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -549,6 +549,8 @@ HWC2::Error HWCLayer::SetLayerZOrder(uint32_t z) { HWC2::Error HWCLayer::SetLayerPerFrameMetadata(uint32_t num_elements, const PerFrameMetadataKey *keys, const float *metadata) { + auto old_mastering_display = layer_->input_buffer.color_metadata.masteringDisplayInfo; + auto old_content_light = layer_->input_buffer.color_metadata.contentLightLevel; auto &mastering_display = layer_->input_buffer.color_metadata.masteringDisplayInfo; auto &content_light = layer_->input_buffer.color_metadata.contentLightLevel; for (uint32_t i = 0; i < num_elements; i++) { @@ -591,6 +593,51 @@ HWC2::Error HWCLayer::SetLayerPerFrameMetadata(uint32_t num_elements, case PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL: content_light.minPicAverageLightLevel = UINT32(metadata[i] * 10000); break; + default: + break; + } + } + if ((!SameConfig(&old_mastering_display, &mastering_display, UINT32(sizeof(MasteringDisplay)))) || + (!SameConfig(&old_content_light, &content_light, UINT32(sizeof(ContentLightLevel))))) { + per_frame_hdr_metadata_ = true; + layer_->update_mask.set(kMetadataUpdate); + geometry_changes_ |= kDataspace; + } + return HWC2::Error::None; +} + +HWC2::Error HWCLayer::SetLayerPerFrameMetadataBlobs(uint32_t num_elements, + const PerFrameMetadataKey *keys, + const uint32_t *sizes, + const uint8_t* metadata) { + if (!keys || !sizes || !metadata) { + DLOGE("metadata or sizes or keys is null"); + return HWC2::Error::BadParameter; + } + + ColorMetaData &color_metadata = layer_->input_buffer.color_metadata; + for (uint32_t i = 0; i < num_elements; i++) { + switch (keys[i]) { + case PerFrameMetadataKey::HDR10_PLUS_SEI: + if (sizes[i] > HDR_DYNAMIC_META_DATA_SZ) { + DLOGE("Size of HDR10_PLUS_SEI = %d", sizes[i]); + return HWC2::Error::BadParameter; + } + per_frame_hdr_metadata_ = false; + // if dynamic metadata changes, store and set needs validate + if (!SameConfig(static_cast(color_metadata.dynamicMetaDataPayload), + metadata, sizes[i])) { + geometry_changes_ |= kDataspace; + color_metadata.dynamicMetaDataValid = true; + color_metadata.dynamicMetaDataLen = sizes[i]; + std::memcpy(color_metadata.dynamicMetaDataPayload, metadata, sizes[i]); + per_frame_hdr_metadata_ = true; + layer_->update_mask.set(kMetadataUpdate); + } + break; + default: + DLOGW("Invalid key = %d", keys[i]); + return HWC2::Error::BadParameter; } } return HWC2::Error::None; @@ -904,6 +951,11 @@ bool HWCLayer::IsDataSpaceSupported() { } void HWCLayer::ValidateAndSetCSC(const private_handle_t *handle) { + if (per_frame_hdr_metadata_) { + // Since client has set PerFrameMetadata, dataspace will be valid + // so we can skip reading from ColorMetaData. + return; + } LayerBuffer *layer_buffer = &layer_->input_buffer; bool use_color_metadata = true; ColorMetaData csc = {}; @@ -942,6 +994,9 @@ void HWCLayer::ValidateAndSetCSC(const private_handle_t *handle) { (layer_buffer->color_metadata.range != old_meta_data.range)) { layer_->update_mask.set(kMetadataUpdate); } + DLOGV_IF(kTagClient, "Dynamic Metadata valid = %d size = %d", + layer_buffer->color_metadata.dynamicMetaDataValid, + layer_buffer->color_metadata.dynamicMetaDataLen); if (layer_buffer->color_metadata.dynamicMetaDataValid && !SameConfig(layer_buffer->color_metadata.dynamicMetaDataPayload, old_meta_data.dynamicMetaDataPayload, HDR_DYNAMIC_META_DATA_SZ)) { diff --git a/sdm/libs/hwc2/hwc_layers.h b/sdm/libs/hwc2/hwc_layers.h index 362eaa96..538f4df3 100644 --- a/sdm/libs/hwc2/hwc_layers.h +++ b/sdm/libs/hwc2/hwc_layers.h @@ -33,7 +33,7 @@ #include #undef HWC2_INCLUDE_STRINGIFICATION #undef HWC2_USE_CPP11 -#include +#include #include #include #include @@ -41,7 +41,7 @@ #include "hwc_buffer_allocator.h" using PerFrameMetadataKey = - android::hardware::graphics::composer::V2_2::IComposerClient::PerFrameMetadataKey; + android::hardware::graphics::composer::V2_3::IComposerClient::PerFrameMetadataKey; namespace sdm { @@ -91,6 +91,8 @@ class HWCLayer { HWC2::Error SetLayerVisibleRegion(hwc_region_t visible); HWC2::Error SetLayerPerFrameMetadata(uint32_t num_elements, const PerFrameMetadataKey *keys, const float *metadata); + HWC2::Error SetLayerPerFrameMetadataBlobs(uint32_t num_elements, const PerFrameMetadataKey *keys, + const uint32_t *sizes, const uint8_t* metadata); HWC2::Error SetLayerZOrder(uint32_t z); void SetComposition(const LayerComposition &sdm_composition); HWC2::Composition GetClientRequestedCompositionType() { return client_requested_; } @@ -137,6 +139,7 @@ class HWCLayer { bool non_integral_source_crop_ = false; bool has_metadata_refresh_rate_ = false; bool buffer_flipped_ = false; + bool per_frame_hdr_metadata_ = false; // used to track if perframe metadata and blob is set. // Composition requested by client(SF) Original HWC2::Composition client_requested_orig_ = HWC2::Composition::Device; diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 5305b411..e258be6e 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -658,6 +658,16 @@ static int32_t SetLayerPerFrameMetadata(hwc2_device_t *device, hwc2_display_t di num_elements, keys, metadata); } +static int32_t SetLayerPerFrameMetadataBlobs(hwc2_device_t *device, hwc2_display_t display, + hwc2_layer_t layer, uint32_t num_elements, + const int32_t *int_keys, const uint32_t *sizes, + const uint8_t *metadata) { + auto keys = reinterpret_cast(int_keys); + return HWCSession::CallLayerFunction(device, display, layer, + &HWCLayer::SetLayerPerFrameMetadataBlobs, + num_elements, keys, sizes, metadata); +} + static int32_t GetDisplayAttribute(hwc2_device_t *device, hwc2_display_t display, hwc2_config_t config, int32_t int_attribute, int32_t *out_value) { @@ -1209,6 +1219,8 @@ hwc2_function_pointer_t HWCSession::GetFunction(struct hwc2_device *device, return AsFP(GetPerFrameMetadataKeys); case HWC2::FunctionDescriptor::SetLayerPerFrameMetadata: return AsFP(SetLayerPerFrameMetadata); + case HWC2::FunctionDescriptor::SetLayerPerFrameMetadataBlobs: + return AsFP(SetLayerPerFrameMetadataBlobs); case HWC2::FunctionDescriptor::GetDisplayIdentificationData: return AsFP (HWCSession::GetDisplayIdentificationData); -- cgit v1.2.3 From b290fb490d97670d0287c913fdc7c97939efe8a9 Mon Sep 17 00:00:00 2001 From: Gousemoodhin Nadaf Date: Tue, 26 Nov 2019 18:11:05 +0530 Subject: hwc2: Handle reading hdr color metadata If client SF sets PerFrameMetadata, dataspace will be valid, so skip reading from ColorMetaData. Change-Id: I5597c3ec43ae7fea2ab008ce3f38cc923baa0550 CRs-Fixed: 2570482 --- sdm/libs/hwc2/hwc_layers.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp index 2065cb49..2ecfdfc1 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -951,11 +951,6 @@ bool HWCLayer::IsDataSpaceSupported() { } void HWCLayer::ValidateAndSetCSC(const private_handle_t *handle) { - if (per_frame_hdr_metadata_) { - // Since client has set PerFrameMetadata, dataspace will be valid - // so we can skip reading from ColorMetaData. - return; - } LayerBuffer *layer_buffer = &layer_->input_buffer; bool use_color_metadata = true; ColorMetaData csc = {}; @@ -986,7 +981,9 @@ void HWCLayer::ValidateAndSetCSC(const private_handle_t *handle) { use_color_metadata = true; } - if (use_color_metadata) { + // Since client has set PerFrameMetadata, dataspace will be valid + // so we can skip reading from ColorMetaData. + if (use_color_metadata && !per_frame_hdr_metadata_) { ColorMetaData old_meta_data = layer_buffer->color_metadata; if (sdm::SetCSC(handle, &layer_buffer->color_metadata) == kErrorNone) { if ((layer_buffer->color_metadata.colorPrimaries != old_meta_data.colorPrimaries) || -- cgit v1.2.3 From d4f2dbd3a54b4291c3f1fc7011497eb906c2e9a8 Mon Sep 17 00:00:00 2001 From: Pullakavi Srinivas Date: Fri, 26 Jul 2019 11:09:30 +0530 Subject: hwc2: Update video flag prior to its usage. CRs-Fixed: 2497512 Change-Id: I84d31241648a261780e41492ca5a73f827ec11a1 --- sdm/libs/hwc2/hwc_layers.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp index 2ecfdfc1..f288a3d9 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -270,12 +270,11 @@ HWC2::Error HWCLayer::SetLayerBuffer(buffer_handle_t buffer, int32_t acquire_fen layer_buffer->unaligned_width = UINT32(handle->unaligned_width); layer_buffer->unaligned_height = UINT32(handle->unaligned_height); + layer_buffer->flags.video = (handle->buffer_type == BUFFER_TYPE_VIDEO) ? true : false; if (SetMetaData(const_cast(handle), layer_) != kErrorNone) { return HWC2::Error::BadLayer; } - layer_buffer->flags.video = (handle->buffer_type == BUFFER_TYPE_VIDEO) ? true : false; - // TZ Protected Buffer - L1 bool secure = (handle->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER); bool secure_camera = secure && (handle->flags & private_handle_t::PRIV_FLAGS_CAMERA_WRITE); -- cgit v1.2.3 From 9b9dd456c9692b8bcb585e6c012c5979d1dd9fcb Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Tue, 6 Aug 2019 16:15:56 +0530 Subject: gralloc: Add support for QtiMapperExtension version 1.1 Add new API getSurfaceMetadata_V1() which will take a valid pointer to surface metadata and fill it with metadata values. CRs-Fixed: 2505696 Change-Id: I82882a7cb36a5bd18417fd43a19976e078c77ca9 --- gralloc/Android.mk | 3 ++- gralloc/QtiMapper.h | 6 +++--- gralloc/QtiMapperExtensions.cpp | 19 +++++++++++++++++-- gralloc/QtiMapperExtensions.h | 12 ++++++++---- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/gralloc/Android.mk b/gralloc/Android.mk index 6603f43b..9ad44e52 100644 --- a/gralloc/Android.mk +++ b/gralloc/Android.mk @@ -71,7 +71,8 @@ LOCAL_SHARED_LIBRARIES := $(common_libs) \ vendor.qti.hardware.display.mapper@2.0 \ vendor.qti.hardware.display.mapperextensions@1.0 \ android.hardware.graphics.mapper@2.0 \ - android.hardware.graphics.mapper@2.1 + android.hardware.graphics.mapper@2.1 \ + vendor.qti.hardware.display.mapperextensions@1.1 LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) LOCAL_SRC_FILES := QtiMapper.cpp QtiMapperExtensions.cpp diff --git a/gralloc/QtiMapper.h b/gralloc/QtiMapper.h index eca74f03..7302e5e3 100644 --- a/gralloc/QtiMapper.h +++ b/gralloc/QtiMapper.h @@ -59,8 +59,8 @@ using ::android::hidl::base::V1_0::DebugInfo; using ::android::hidl::base::V1_0::IBase; using gralloc::BufferManager; using ::vendor::qti::hardware::display::mapper::V2_0::IQtiMapper; -using ::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions; -using ::vendor::qti::hardware::display::mapperextensions::V1_0::implementation::QtiMapperExtensions; +using ::vendor::qti::hardware::display::mapperextensions::V1_1::IQtiMapperExtensions; +using ::vendor::qti::hardware::display::mapperextensions::V1_1::implementation::QtiMapperExtensions; using IMapper_2_1 = android::hardware::graphics::mapper::V2_1::IMapper; using BufferDescriptorInfo_2_0 = @@ -92,7 +92,7 @@ class QtiMapper : public IQtiMapper { createDescriptor_2_1_cb _hidl_cb) override; Return getMapperExtensions(getMapperExtensions_cb hidl_cb); - sp extensions_ = nullptr; + sp extensions_ = nullptr; private: BufferManager *buf_mgr_ = nullptr; diff --git a/gralloc/QtiMapperExtensions.cpp b/gralloc/QtiMapperExtensions.cpp index b47c2067..cace7ba6 100644 --- a/gralloc/QtiMapperExtensions.cpp +++ b/gralloc/QtiMapperExtensions.cpp @@ -40,7 +40,7 @@ namespace qti { namespace hardware { namespace display { namespace mapperextensions { -namespace V1_0 { +namespace V1_1 { namespace implementation { using gralloc::BufferInfo; @@ -386,8 +386,23 @@ Return QtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage return Void(); } +Return QtiMapperExtensions::getSurfaceMetadata_V1(void *buffer, void *metadata) { + auto err = Error::BAD_BUFFER; + auto hnd = static_cast(buffer); + if (metadata != nullptr && buffer != nullptr && private_handle_t::validate(hnd) == 0) { + if (getMetaData(hnd, GET_GRAPHICS_METADATA, metadata) == 0) { + err = Error::NONE; + } else { + err = Error::UNSUPPORTED; + } + } else { + ALOGE("%s: buffer pointer: %p, metadata pointer: %p ", __FUNCTION__, buffer, metadata); + } + return err; +} + } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace mapperextensions } // namespace display } // namespace hardware diff --git a/gralloc/QtiMapperExtensions.h b/gralloc/QtiMapperExtensions.h index e266e66a..b3333123 100644 --- a/gralloc/QtiMapperExtensions.h +++ b/gralloc/QtiMapperExtensions.h @@ -32,7 +32,7 @@ #include #include -#include +#include #include "gr_buf_mgr.h" namespace vendor { @@ -40,7 +40,7 @@ namespace qti { namespace hardware { namespace display { namespace mapperextensions { -namespace V1_0 { +namespace V1_1 { namespace implementation { using ::android::sp; @@ -56,7 +56,10 @@ using ::android::hardware::graphics::mapper::V2_0::IMapper; using ::android::hidl::base::V1_0::DebugInfo; using ::android::hidl::base::V1_0::IBase; using gralloc::BufferManager; -using ::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions; +using ::vendor::qti::hardware::display::mapperextensions::V1_1::IQtiMapperExtensions; +using ::vendor::qti::hardware::display::mapperextensions::V1_0::Error; +using ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout; +using ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout; class QtiMapperExtensions : public IQtiMapperExtensions { public: @@ -88,10 +91,11 @@ class QtiMapperExtensions : public IQtiMapperExtensions { Return getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb _hidl_cb) override; Return getFormatLayout(int32_t format, uint64_t usage, int32_t flags, int32_t width, int32_t height, getFormatLayout_cb hidl_cb) override; + Return getSurfaceMetadata_V1(void *buffer, void *metadata) override; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace mapperextensions } // namespace display } // namespace hardware -- cgit v1.2.3 From d6ecf9d3fb4db22698f73f9f2c58e9960c964be5 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Fri, 15 Nov 2019 18:15:22 +0530 Subject: gralloc: Add RGB format support in getFormatLayout API CRs-Fixed: 2568703 Change-Id: I183a85fe5d30dc15454de0f5bec39658c24775ee --- gralloc/QtiMapperExtensions.cpp | 57 +++++++++++++++++------------- gralloc/gr_utils.cpp | 78 +++++++++++++++++++++++++++++++++-------- gralloc/gr_utils.h | 4 +++ 3 files changed, 99 insertions(+), 40 deletions(-) diff --git a/gralloc/QtiMapperExtensions.cpp b/gralloc/QtiMapperExtensions.cpp index cace7ba6..33cd23dc 100644 --- a/gralloc/QtiMapperExtensions.cpp +++ b/gralloc/QtiMapperExtensions.cpp @@ -344,7 +344,7 @@ Return QtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage getFormatLayout_cb hidl_cb) { ALOGD_IF(DEBUG, "%s: Input parameters - wxh: %dx%d usage: 0x%" PRIu64 " format: %d", __FUNCTION__, width, height, usage, format); - auto err = Error::BAD_BUFFER; + auto err = Error::NONE; hidl_vec plane_info; unsigned int alignedw = 0, alignedh = 0; int plane_count = 0; @@ -353,34 +353,41 @@ Return QtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage BufferInfo info(width, height, custom_format, usage); gralloc::GetAlignedWidthAndHeight(info, &alignedw, &alignedh); size = gralloc::GetSize(info, alignedw, alignedh); + gralloc::PlaneLayoutInfo plane_layout[8] = {}; ALOGD_IF(DEBUG, "%s: Aligned width and height - wxh: %ux%u custom_format = %d", __FUNCTION__, alignedw, alignedh, custom_format); if (gralloc::IsYuvFormat(custom_format)) { - gralloc::PlaneLayoutInfo yuv_plane_info[8] = {}; gralloc::GetYUVPlaneInfo(info, custom_format, alignedw, alignedh, flags, &plane_count, - yuv_plane_info); - ALOGD_IF(DEBUG, "%s: Number of plane - %d, custom_format - %d", __FUNCTION__, plane_count, - custom_format); - plane_info.resize(plane_count); - for (int i = 0; i < plane_count; i++) { - plane_info[i].component = yuv_plane_info[i].component; - plane_info[i].h_subsampling = yuv_plane_info[i].h_subsampling; - plane_info[i].v_subsampling = yuv_plane_info[i].v_subsampling; - plane_info[i].offset = yuv_plane_info[i].offset; - plane_info[i].pixel_increment = yuv_plane_info[i].step; - plane_info[i].stride = yuv_plane_info[i].stride; - plane_info[i].stride_bytes = yuv_plane_info[i].stride_bytes; - plane_info[i].scanlines = yuv_plane_info[i].scanlines; - plane_info[i].size = yuv_plane_info[i].size; - ALOGD_IF(DEBUG, "%s: plane info: component - %d", __FUNCTION__, plane_info[i].component); - ALOGD_IF(DEBUG, "h_subsampling - %u, v_subsampling - %u, offset - %u, pixel_increment - %d", - plane_info[i].h_subsampling, plane_info[i].v_subsampling, plane_info[i].offset, - plane_info[i].pixel_increment); - ALOGD_IF(DEBUG, "stride_pixel - %d, stride_bytes - %d, scanlines - %d, size - %u", - plane_info[i].stride, plane_info[i].stride_bytes, plane_info[i].scanlines, - plane_info[i].size); - } - err = Error::NONE; + plane_layout); + } else if (gralloc::IsUncompressedRGBFormat(custom_format) || + gralloc::IsCompressedRGBFormat(custom_format)) { + gralloc::GetRGBPlaneInfo(info, custom_format, alignedw, alignedh, flags, &plane_count, + plane_layout); + } else { + err = Error::BAD_BUFFER; + hidl_cb(err, size, plane_info); + return Void(); + } + ALOGD_IF(DEBUG, "%s: Number of plane - %d, custom_format - %d", __FUNCTION__, plane_count, + custom_format); + plane_info.resize(plane_count); + for (int i = 0; i < plane_count; i++) { + plane_info[i].component = plane_layout[i].component; + plane_info[i].h_subsampling = plane_layout[i].h_subsampling; + plane_info[i].v_subsampling = plane_layout[i].v_subsampling; + plane_info[i].offset = plane_layout[i].offset; + plane_info[i].pixel_increment = plane_layout[i].step; + plane_info[i].stride = plane_layout[i].stride; + plane_info[i].stride_bytes = plane_layout[i].stride_bytes; + plane_info[i].scanlines = plane_layout[i].scanlines; + plane_info[i].size = plane_layout[i].size; + ALOGD_IF(DEBUG, "%s: plane info: component - %d", __FUNCTION__, plane_info[i].component); + ALOGD_IF(DEBUG, "h_subsampling - %u, v_subsampling - %u, offset - %u, pixel_increment - %d", + plane_info[i].h_subsampling, plane_info[i].v_subsampling, plane_info[i].offset, + plane_info[i].pixel_increment); + ALOGD_IF(DEBUG, "stride_pixel - %d, stride_bytes - %d, scanlines - %d, size - %u", + plane_info[i].stride, plane_info[i].stride_bytes, plane_info[i].scanlines, + plane_info[i].size); } hidl_cb(err, size, plane_info); return Void(); diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp index 9eca92df..6eb414e2 100644 --- a/gralloc/gr_utils.cpp +++ b/gralloc/gr_utils.cpp @@ -794,6 +794,28 @@ unsigned int GetUBwcSize(int width, int height, int format, unsigned int aligned return size; } +unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage) { + unsigned int meta_size = 0; + if (!IsUBwcEnabled(format, usage)) { + return meta_size; + } + uint32_t bpp = GetBppForUncompressedRGB(format); + switch (format) { + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_RGBA_FP16: + meta_size = GetRgbUBwcMetaBufferSize(width, height, bpp); + break; + default: + ALOGE("%s:Unsupported RGB format: 0x%x", __FUNCTION__, format); + break; + } + return meta_size; +} + int GetRgbDataAddress(private_handle_t *hnd, void **rgb_data) { int err = 0; @@ -807,22 +829,8 @@ int GetRgbDataAddress(private_handle_t *hnd, void **rgb_data) { *rgb_data = reinterpret_cast(hnd->base); return err; } + unsigned int meta_size = GetRgbMetaSize(hnd->format, hnd->width, hnd->height, hnd->usage); - unsigned int meta_size = 0; - uint32_t bpp = GetBppForUncompressedRGB(hnd->format); - switch (hnd->format) { - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_RGBX_1010102: - meta_size = GetRgbUBwcMetaBufferSize(hnd->width, hnd->height, bpp); - break; - default: - ALOGE("%s:Unsupported RGB format: 0x%x", __FUNCTION__, hnd->format); - err = -EINVAL; - break; - } *rgb_data = reinterpret_cast(hnd->base + meta_size); return err; @@ -1560,4 +1568,44 @@ void CopyPlaneLayoutInfotoAndroidYcbcr(uint64_t base, int plane_count, PlaneLayo } } +bool HasAlphaComponent(int32_t format) { + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_ARGB_2101010: + case HAL_PIXEL_FORMAT_BGRA_1010102: + case HAL_PIXEL_FORMAT_ABGR_2101010: + case HAL_PIXEL_FORMAT_RGBA_FP16: + return true; + default: + return false; + } +} + +void GetRGBPlaneInfo(const BufferInfo &info, int32_t format, int32_t width, int32_t height, + int32_t /* flags */, int *plane_count, PlaneLayoutInfo *plane_info) { + uint64_t usage = info.usage; + *plane_count = 1; + uint32_t bpp = 0; + if (IsUncompressedRGBFormat(format)) { + bpp = GetBppForUncompressedRGB(format); + } + plane_info->component = + (PlaneComponent)(PLANE_COMPONENT_R | PLANE_COMPONENT_G | PLANE_COMPONENT_B); + if (HasAlphaComponent(format)) { + plane_info->component = (PlaneComponent)(plane_info->component | PLANE_COMPONENT_A); + } + plane_info->size = GetSize(info, width, height); + plane_info->step = bpp; + plane_info->offset = GetRgbMetaSize(format, width, height, usage); + plane_info->h_subsampling = 0; + plane_info->v_subsampling = 0; + plane_info->stride = width; + plane_info->stride_bytes = width * plane_info->step; + plane_info->scanlines = height; +} + } // namespace gralloc diff --git a/gralloc/gr_utils.h b/gralloc/gr_utils.h index 8ecb90f6..39d7e9bd 100644 --- a/gralloc/gr_utils.h +++ b/gralloc/gr_utils.h @@ -144,6 +144,9 @@ void GetAlignedWidthAndHeight(const BufferInfo &d, unsigned int *aligned_w, int GetYUVPlaneInfo(const private_handle_t *hnd, struct android_ycbcr ycbcr[2]); int GetYUVPlaneInfo(const BufferInfo &info, int32_t format, int32_t width, int32_t height, int32_t flags, int *plane_count, PlaneLayoutInfo plane_info[8]); +void GetRGBPlaneInfo(const BufferInfo &info, int32_t format, int32_t width, int32_t height, + int32_t flags, int *plane_count, PlaneLayoutInfo *plane_info); +unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage); void GetYuvSubSamplingFactor(int32_t format, int *h_subsampling, int *v_subsampling); void CopyPlaneLayoutInfotoAndroidYcbcr(uint64_t base, int plane_count, PlaneLayoutInfo *plane_info, struct android_ycbcr *ycbcr); @@ -178,6 +181,7 @@ int GetImplDefinedFormat(uint64_t usage, int format); int GetCustomFormatFlags(int format, uint64_t usage, int *custom_format, uint64_t *priv_flags); int GetBufferType(int inputFormat); bool IsGPUFlagSupported(uint64_t usage); +bool HasAlphaComponent(int32_t format); } // namespace gralloc #endif // __GR_UTILS_H__ -- cgit v1.2.3 From 3f77edd72dfdaa2b0595596fb9db6c5a95931abe Mon Sep 17 00:00:00 2001 From: Venkat Thogaru Date: Mon, 3 Jun 2019 16:16:42 +0530 Subject: sdm: Disable idle power collapse if hdr present Luts re-programming after idle power collpase taking more than one vsync some times causing flickering. Hence disable idle power collapse during this time. CRs-Fixed: 2432683 Change-Id: Iceb4d63d00e9b53ae01924d6c16d38505f546e96 --- sdm/libs/hwc2/hwc_display_builtin.cpp | 7 ++++++- sdm/libs/hwc2/hwc_display_builtin.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sdm/libs/hwc2/hwc_display_builtin.cpp b/sdm/libs/hwc2/hwc_display_builtin.cpp index 5aaa5316..199e0b04 100644 --- a/sdm/libs/hwc2/hwc_display_builtin.cpp +++ b/sdm/libs/hwc2/hwc_display_builtin.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. +* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -229,6 +229,11 @@ HWC2::Error HWCDisplayBuiltIn::Validate(uint32_t *out_num_types, uint32_t *out_n layer_stack_.flags.post_processed_output = post_processed_output_; } } + // Todo: relook this case + if (layer_stack_.flags.hdr_present != hdr_present_) { + error = display_intf_->ControlIdlePowerCollapse(!layer_stack_.flags.hdr_present, true); + hdr_present_ = layer_stack_.flags.hdr_present; + } uint32_t num_updating_layers = GetUpdatingLayersCount(); bool one_updating_layer = (num_updating_layers == 1); diff --git a/sdm/libs/hwc2/hwc_display_builtin.h b/sdm/libs/hwc2/hwc_display_builtin.h index 071e1d45..4de6853a 100644 --- a/sdm/libs/hwc2/hwc_display_builtin.h +++ b/sdm/libs/hwc2/hwc_display_builtin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -143,6 +143,7 @@ class HWCDisplayBuiltIn : public HWCDisplay { int default_mode_status_ = 0; bool pending_refresh_ = true; bool enable_drop_refresh_ = false; + bool hdr_present_ = false; // Members for 1 frame capture in a client provided buffer bool frame_capture_buffer_queued_ = false; -- cgit v1.2.3