diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2017-01-12 04:42:33 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-01-12 04:42:32 -0800 |
commit | fb2f2a8a03ee655ae0ce673aa4b368a4640dc680 (patch) | |
tree | 81436677214d263b1cf64e5ff9751248995d7eb2 | |
parent | 230492a90517f7eb75df53c1f35e01eeb78ba943 (diff) | |
parent | db087f65b88a6ad6feec92617a2246e75ba286e4 (diff) | |
download | display-fb2f2a8a03ee655ae0ce673aa4b368a4640dc680.tar.gz |
Merge "sdm: Add GetBufferInfo Interface"
-rw-r--r-- | sdm/include/core/buffer_allocator.h | 15 | ||||
-rw-r--r-- | sdm/include/private/extension_interface.h | 3 | ||||
-rw-r--r-- | sdm/libs/core/comp_manager.cpp | 5 | ||||
-rw-r--r-- | sdm/libs/core/comp_manager.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/strategy.cpp | 11 | ||||
-rw-r--r-- | sdm/libs/core/strategy.h | 5 | ||||
-rw-r--r-- | sdm/libs/hwc/hwc_buffer_allocator.cpp | 36 | ||||
-rw-r--r-- | sdm/libs/hwc/hwc_buffer_allocator.h | 4 |
8 files changed, 71 insertions, 9 deletions
diff --git a/sdm/include/core/buffer_allocator.h b/sdm/include/core/buffer_allocator.h index 86cc02af..4dc41254 100644 --- a/sdm/include/core/buffer_allocator.h +++ b/sdm/include/core/buffer_allocator.h @@ -60,6 +60,7 @@ struct BufferConfig { @sa BufferAllocator::AllocateBuffer @sa BufferAllocator::FreeBuffer + @sa BufferAllocator::GetAllocatedBufferInfo */ struct AllocatedBufferInfo { int fd = -1; //!< Specifies the fd of the allocated buffer. @@ -123,6 +124,20 @@ class BufferAllocator { */ virtual uint32_t GetBufferSize(BufferInfo *buffer_info) = 0; + /*! @brief Method to Get the AllocatedBufferInfo only. + + @details This method populates the AllocatedBufferInfo as per the configuration in BufferInfo, + but fd will be invalid. + + @param[in] buffer_info \link BufferInfo \endlink + + @param[out] allocated_buffer_info \link AllocatedBufferInfo \endlink + + @return \link DisplayError \endlink + */ + virtual DisplayError GetAllocatedBufferInfo(const BufferConfig &buffer_config, + AllocatedBufferInfo *allocated_buffer_info) = 0; + protected: virtual ~BufferAllocator() { } }; diff --git a/sdm/include/private/extension_interface.h b/sdm/include/private/extension_interface.h index d8a37eb4..c5e6dcb7 100644 --- a/sdm/include/private/extension_interface.h +++ b/sdm/include/private/extension_interface.h @@ -59,7 +59,8 @@ class ExtensionInterface { PartialUpdateInterface **interface) = 0; virtual DisplayError DestroyPartialUpdate(PartialUpdateInterface *interface) = 0; - virtual DisplayError CreateStrategyExtn(DisplayType type, const HWResourceInfo &hw_resource_info, + virtual DisplayError CreateStrategyExtn(DisplayType type, BufferAllocator *buffer_allocator, + const HWResourceInfo &hw_resource_info, const HWPanelInfo &hw_panel_info, const HWMixerAttributes &mixer_attributes, const DisplayConfigVariableInfo &fb_config, diff --git a/sdm/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp index c7515f42..be5cb75e 100644 --- a/sdm/libs/core/comp_manager.cpp +++ b/sdm/libs/core/comp_manager.cpp @@ -64,6 +64,7 @@ DisplayError CompManager::Init(const HWResourceInfo &hw_res_info, } hw_res_info_ = hw_res_info; + buffer_allocator_ = buffer_allocator; extension_intf_ = extension_intf; return error; @@ -98,8 +99,8 @@ DisplayError CompManager::RegisterDisplay(DisplayType type, } Strategy *&strategy = display_comp_ctx->strategy; - strategy = new Strategy(extension_intf_, type, hw_res_info_, hw_panel_info, mixer_attributes, - display_attributes, fb_config); + strategy = new Strategy(extension_intf_, buffer_allocator_, type, hw_res_info_, hw_panel_info, + mixer_attributes, display_attributes, fb_config); if (!strategy) { DLOGE("Unable to create strategy"); delete display_comp_ctx; diff --git a/sdm/libs/core/comp_manager.h b/sdm/libs/core/comp_manager.h index 9f91eca1..2bcc6b98 100644 --- a/sdm/libs/core/comp_manager.h +++ b/sdm/libs/core/comp_manager.h @@ -108,6 +108,7 @@ class CompManager : public DumpImpl { // mode, where strategy manager chooses the best strategy // that uses optimal number of pipes for each display HWResourceInfo hw_res_info_; + BufferAllocator *buffer_allocator_ = NULL; ExtensionInterface *extension_intf_ = NULL; uint32_t max_layers_ = kMaxSDELayers; uint32_t max_sde_ext_layers_ = 0; diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp index c987fd0b..97a6cc36 100644 --- a/sdm/libs/core/strategy.cpp +++ b/sdm/libs/core/strategy.cpp @@ -32,22 +32,25 @@ namespace sdm { -Strategy::Strategy(ExtensionInterface *extension_intf, DisplayType type, +Strategy::Strategy(ExtensionInterface *extension_intf, BufferAllocator *buffer_allocator, + DisplayType type, const HWResourceInfo &hw_resource_info, const HWPanelInfo &hw_panel_info, const HWMixerAttributes &mixer_attributes, const HWDisplayAttributes &display_attributes, const DisplayConfigVariableInfo &fb_config) : extension_intf_(extension_intf), display_type_(type), hw_resource_info_(hw_resource_info), hw_panel_info_(hw_panel_info), mixer_attributes_(mixer_attributes), - display_attributes_(display_attributes), fb_config_(fb_config) { + display_attributes_(display_attributes), fb_config_(fb_config), + buffer_allocator_(buffer_allocator) { } DisplayError Strategy::Init() { DisplayError error = kErrorNone; if (extension_intf_) { - error = extension_intf_->CreateStrategyExtn(display_type_, hw_resource_info_, hw_panel_info_, - mixer_attributes_, fb_config_, &strategy_intf_); + error = extension_intf_->CreateStrategyExtn(display_type_, buffer_allocator_, hw_resource_info_, + hw_panel_info_, mixer_attributes_, fb_config_, + &strategy_intf_); if (error != kErrorNone) { DLOGE("Failed to create strategy"); return error; diff --git a/sdm/libs/core/strategy.h b/sdm/libs/core/strategy.h index a84d1398..d69283fa 100644 --- a/sdm/libs/core/strategy.h +++ b/sdm/libs/core/strategy.h @@ -27,12 +27,14 @@ #include <core/display_interface.h> #include <private/extension_interface.h> +#include <core/buffer_allocator.h> namespace sdm { class Strategy { public: - Strategy(ExtensionInterface *extension_intf, DisplayType type, + Strategy(ExtensionInterface *extension_intf, BufferAllocator *buffer_allocator, + DisplayType type, const HWResourceInfo &hw_resource_info, const HWPanelInfo &hw_panel_info, const HWMixerAttributes &mixer_attributes, const HWDisplayAttributes &display_attributes, const DisplayConfigVariableInfo &fb_config); @@ -67,6 +69,7 @@ class Strategy { bool extn_start_success_ = false; bool tried_default_ = false; bool disable_gpu_comp_ = false; + BufferAllocator *buffer_allocator_ = NULL; }; } // namespace sdm diff --git a/sdm/libs/hwc/hwc_buffer_allocator.cpp b/sdm/libs/hwc/hwc_buffer_allocator.cpp index 906b96da..bda316f6 100644 --- a/sdm/libs/hwc/hwc_buffer_allocator.cpp +++ b/sdm/libs/hwc/hwc_buffer_allocator.cpp @@ -255,4 +255,40 @@ int HWCBufferAllocator::SetBufferInfo(LayerBufferFormat format, int *target, int return 0; } +DisplayError HWCBufferAllocator::GetAllocatedBufferInfo(const BufferConfig &buffer_config, + AllocatedBufferInfo *allocated_buffer_info) { + int width = INT(buffer_config.width); + int height = INT(buffer_config.height); + int alloc_flags = INT(GRALLOC_USAGE_PRIVATE_IOMMU_HEAP); + + if (buffer_config.secure) { + alloc_flags = INT(GRALLOC_USAGE_PRIVATE_MM_HEAP); + alloc_flags |= INT(GRALLOC_USAGE_PROTECTED); + } + + if (buffer_config.cache == false) { + // Allocate uncached buffers + alloc_flags |= GRALLOC_USAGE_PRIVATE_UNCACHED; + } + + int format; + int error = SetBufferInfo(buffer_config.format, &format, &alloc_flags); + if (error) { + DLOGE("Failed: format = %d or width = %d height = %d", buffer_config.format, width, height); + return kErrorNotSupported; + } + + int width_aligned = 0, height_aligned = 0; + uint32_t buffer_size = 0; + buffer_size = getBufferSizeAndDimensions(width, height, format, alloc_flags, + width_aligned, height_aligned); + + allocated_buffer_info->stride = UINT32(width_aligned); + allocated_buffer_info->aligned_width = UINT32(width_aligned); + allocated_buffer_info->aligned_height = UINT32(height_aligned); + allocated_buffer_info->size = UINT32(buffer_size); + + return kErrorNone; +} + } // namespace sdm diff --git a/sdm/libs/hwc/hwc_buffer_allocator.h b/sdm/libs/hwc/hwc_buffer_allocator.h index e576fe81..897c3b91 100644 --- a/sdm/libs/hwc/hwc_buffer_allocator.h +++ b/sdm/libs/hwc/hwc_buffer_allocator.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015, The Linux Foundation. All rights reserved. +* Copyright (c) 2015-2016, 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 @@ -49,6 +49,8 @@ class HWCBufferAllocator : public BufferAllocator { DisplayError AllocateBuffer(BufferInfo *buffer_info); DisplayError FreeBuffer(BufferInfo *buffer_info); uint32_t GetBufferSize(BufferInfo *buffer_info); + DisplayError GetAllocatedBufferInfo(const BufferConfig &buffer_config, + AllocatedBufferInfo *allocated_buffer_info); private: struct MetaBufferInfo { |