Merge " hwc : Set bw limit on mdss when camera is on."
diff --git a/Android.mk b/Android.mk
index 6baef4a..9eb272f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,15 +1,15 @@
ifeq ($(call is-board-platform-in-list, msm8996),true)
- TARGET_USES_SDE = true
+ TARGET_USES_SDM = true
else
- TARGET_USES_SDE = false
+ TARGET_USES_SDM = false
endif
display-hals := libgralloc libcopybit liblight libmemtrack libqservice libqdutils
display-hals += hdmi_cec
-ifeq ($(TARGET_USES_SDE), true)
- sde-libs := displayengine/libs
- display-hals += $(sde-libs)/utils $(sde-libs)/core $(sde-libs)/hwc
+ifeq ($(TARGET_USES_SDM), true)
+ sdm-libs := sdm/libs
+ display-hals += $(sdm-libs)/utils $(sdm-libs)/core $(sdm-libs)/hwc
else
display-hals += libgenlock libhwcomposer liboverlay libhdmi
endif
diff --git a/common.mk b/common.mk
index 464f296..183ee99 100644
--- a/common.mk
+++ b/common.mk
@@ -29,6 +29,10 @@
common_flags += -DVENUS_COLOR_FORMAT
endif
+ifeq ($(call is-board-platform-in-list, $(MASTER_SIDE_CP_TARGET_LIST)), true)
+ common_flags += -DMASTER_SIDE_CP
+endif
+
common_deps :=
kernel_includes :=
diff --git a/displayengine/include/private/hw_info_types.h b/displayengine/include/private/hw_info_types.h
deleted file mode 100644
index 49abafe..0000000
--- a/displayengine/include/private/hw_info_types.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-* Copyright (c) 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*! @file hw_info_types.h
- @brief Definitions for types that contain information pertaining to hardware devices.
-*/
-
-#ifndef __HW_INFO_TYPES_H__
-#define __HW_INFO_TYPES_H__
-
-#include <stdint.h>
-#include <core/sde_types.h>
-
-namespace sde {
-
-/*! @brief This enumeration holds the possible hardware device types. */
-enum HWDeviceType {
- kDevicePrimary,
- kDeviceHDMI,
- kDeviceVirtual,
- kDeviceRotator,
- kDeviceMax,
-};
-
-/*! @brief This structure is a representation of hardware capabilities of the target device display
- driver.
-*/
-struct HWResourceInfo {
- uint32_t hw_version;
- uint32_t hw_revision;
- uint32_t num_dma_pipe;
- uint32_t num_vig_pipe;
- uint32_t num_rgb_pipe;
- uint32_t num_cursor_pipe;
- uint32_t num_blending_stages;
- uint32_t num_rotator;
- uint32_t num_control;
- uint32_t num_mixer_to_disp;
- uint32_t smp_total;
- uint32_t smp_size;
- uint32_t num_smp_per_pipe;
- uint32_t max_scale_up;
- uint32_t max_scale_down;
- uint64_t max_bandwidth_low;
- uint64_t max_bandwidth_high;
- uint32_t max_mixer_width;
- uint32_t max_pipe_bw;
- uint32_t max_sde_clk;
- float clk_fudge_factor;
- bool has_bwc;
- bool has_ubwc;
- bool has_decimation;
- bool has_macrotile;
- bool has_rotator_downscale;
- bool has_non_scalar_rgb;
- bool is_src_split;
-
- HWResourceInfo()
- : hw_version(0), hw_revision(0), num_dma_pipe(0), num_vig_pipe(0), num_rgb_pipe(0),
- num_cursor_pipe(0), num_blending_stages(0), num_rotator(0), num_control(0),
- num_mixer_to_disp(0), smp_total(0), smp_size(0), num_smp_per_pipe(0), max_scale_up(1),
- max_scale_down(1), max_bandwidth_low(0), max_bandwidth_high(0), max_mixer_width(2048),
- max_pipe_bw(0), max_sde_clk(0), clk_fudge_factor(1.0f), has_bwc(false), has_ubwc(false),
- has_decimation(false), has_macrotile(false), has_rotator_downscale(false),
- has_non_scalar_rgb(false), is_src_split(false) { }
-
- void Reset() { *this = HWResourceInfo(); }
-};
-
-/*! @brief This enumeration holds the possible display modes. */
-enum HWDisplayMode {
- kModeDefault,
- kModeVideo,
- kModeCommand,
-};
-
-/*! @brief This enumeration holds the all possible display port types. */
-enum HWDisplayPort {
- kPortDefault,
- kPortDSI,
- kPortDTv,
- kPortWriteBack,
- kPortLVDS,
- kPortEDP,
-};
-
-/*! @brief This structure describes the split configuration of a display panel. */
-struct HWSplitInfo {
- uint32_t left_split;
- uint32_t right_split;
- bool always_src_split;
-
- HWSplitInfo() : left_split(0), right_split(0), always_src_split(false) { }
-};
-
-/*! @brief This structure describes properties of a display panel. */
-struct HWPanelInfo {
- HWDisplayPort port; //!< Display port
- HWDisplayMode mode; //!< Display mode
- bool partial_update; //!< Partial update feature
- int left_align; //!< ROI left alignment restriction
- int width_align; //!< ROI width alignment restriction
- int top_align;; //!< ROI top alignment restriction
- int height_align; //!< ROI height alignment restriction
- int min_roi_width; //!< Min width needed for ROI
- int min_roi_height; //!< Min height needed for ROI
- bool needs_roi_merge; //!< Merge ROI's of both the DSI's
- bool dynamic_fps; //!< Panel Supports dynamic fps
- uint32_t min_fps; //!< Min fps supported by panel
- uint32_t max_fps; //!< Max fps supported by panel
- bool is_primary_panel; //!< Panel is primary display
- HWSplitInfo split_info; //!< Panel split configuration
-
- HWPanelInfo() : port(kPortDefault), mode(kModeDefault), partial_update(false), left_align(false),
- width_align(false), top_align(false), height_align(false), min_roi_width(0), min_roi_height(0),
- needs_roi_merge(false), dynamic_fps(false), min_fps(0), max_fps(0) { }
-};
-
-} // namespace sde
-
-#endif // __HW_INFO_TYPES_H__
-
diff --git a/displayengine/include/private/strategy_interface.h b/displayengine/include/private/strategy_interface.h
deleted file mode 100644
index df01c7f..0000000
--- a/displayengine/include/private/strategy_interface.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-* Copyright (c) 2014, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*! @file strategy_interface.h
- @brief Interface file for strategy manager which will be used by display core to select a
- composition strategy for a frame to be displayed on target.
-*/
-#ifndef __STRATEGY_INTERFACE_H__
-#define __STRATEGY_INTERFACE_H__
-
-#include <core/sde_types.h>
-#include <core/display_interface.h>
-#include "hw_info_types.h"
-
-namespace sde {
-
-/*! @brief Strategy library name
-
- @details This macro defines name for the composition strategy library. This macro shall be used
- to load library using dlopen().
-
- @sa CreateStrategyInterface
- @sa DestoryStrategyInterface
-*/
-#define STRATEGY_LIBRARY_NAME "libsdestrategy.so"
-
-/*! @brief Function name to create composer strategy interface
-
- @details This macro defines function name for CreateStrategyInterface() which is implemented in
- the composition strategy library. This macro shall be used to specify name of the function in
- dlsym().
-
- @sa CreateStrategyInterface
-*/
-#define CREATE_STRATEGY_INTERFACE_NAME "CreateStrategyInterface"
-
-/*! @brief Function name to destroy composer strategy interface
-
- @details This macro defines function name for DestroyStrategyInterface() which is implemented in
- the composition strategy library. This macro shall be used to specify name of the function in
- dlsym().
-
- @sa DestroyStrategyInterface
-*/
-#define DESTROY_STRATEGY_INTERFACE_NAME "DestroyStrategyInterface"
-
-/*! @brief Strategy interface version.
-
- @details Strategy interface is version tagged to maintain backward compatibility. This version is
- supplied as a default argument during strategy library initialization.
-
- Client may use an older version of interfaces and link to a higher version of strategy library,
- but vice versa is not allowed.
-
- @sa CreateStrategyInterface
-*/
-#define STRATEGY_REVISION_MAJOR (1)
-#define STRATEGY_REVISION_MINOR (0)
-
-#define STRATEGY_VERSION_TAG ((uint16_t) ((STRATEGY_REVISION_MAJOR << 8) | STRATEGY_REVISION_MINOR))
-
-class StrategyInterface;
-
-/*! @brief Function to create composer strategy interface.
-
- @details This function is used to create StrategyInterface object which resides in the composer
- strategy library loaded at runtime.
-
- @param[in] version \link STRATEGY_VERSION_TAG \endlink
- @param[in] type \link DisplayType \endlink
- @param[in] hw_resource_info \link HWResourceInfo \endlink
- @param[in] hw_panel_info \link HWPanelInfo \endlink
- @param[out] interface \link StrategyInterface \endlink
-
- @return \link DisplayError \endlink
-*/
-typedef DisplayError (*CreateStrategyInterface)(uint16_t version, DisplayType type,
- const HWResourceInfo *hw_resource_info, const HWPanelInfo *hw_panel_info,
- StrategyInterface **interface);
-
-/*! @brief Function to destroy composer strategy interface.
-
- @details This function is used to destroy StrategyInterface object.
-
- @param[in] interface \link StrategyInterface \endlink
-
- @return \link DisplayError \endlink
-*/
-typedef DisplayError (*DestroyStrategyInterface)(StrategyInterface *interface);
-
-/*! @brief Maximum number of layers that can be handled by hardware in a given layer stack.
-*/
-const int kMaxSDELayers = 16;
-
-/*! @brief This structure defines constraints and display properties that shall be considered for
- deciding a composition strategy.
-
- @sa GetNextStrategy
-*/
-struct StrategyConstraints {
- bool safe_mode; //!< In this mode, strategy manager chooses the composition strategy
- //!< that requires minimum number of pipe for the current frame. i.e.,
- //!< video only composition, secure only composition or GPU composition
-
- uint32_t max_layers; //!< Maximum number of layers that shall be programmed on hardware for the
- //!< given layer stack.
-
- StrategyConstraints() : safe_mode(false), max_layers(kMaxSDELayers) { }
-};
-
-/*! @brief This structure encapsulates information about the input layer stack and the layers which
- shall be programmed on hardware.
-
- @sa Start
-*/
-struct HWLayersInfo {
- LayerStack *stack; //!< Input layer stack. Set by the caller.
-
- uint32_t index[kMaxSDELayers];
- //!< Indexes of the layers from the layer stack which need to be
- //!< programmed on hardware.
-
- uint32_t count; //!< Total number of layers which need to be set on hardware.
-
- LayerRect left_partial_update;
- //!< Left ROI.
-
- LayerRect right_partial_update;
- //!< Right ROI.
-
-
- HWLayersInfo() : stack(NULL), count(0) { }
-};
-
-/*! @brief Strategy interface.
-
- @details This class defines Strategy interface. It contains methods which client shall use to
- determine which strategy to be used for layer composition. This interface is created during
- display device creation and remains valid until destroyed.
-*/
-
-class StrategyInterface {
- public:
- /*! @brief Method to indicate start of a new strategy selection iteration for a layer stack.
-
- @details Client shall call this method at beginning of each draw cycle before iterating
- through strategy selection. Strategy interface implementation uses this method to do
- preprocessing for a given layer stack.
-
- @param[in] layers_info \link HWLayersInfo \endlink
- @param[out] max_attempts Maximum calls to \link GetNextStrategy \endlink
-
- @return \link DisplayError \endlink
- */
- virtual DisplayError Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts) = 0;
-
-
- /*! @brief Method to get strategy for a layer stack. Caller can loop through this method to try
- get all applicable strategies.
-
- @param[in] constraints \link StrategyConstraints \endlink
-
- @return \link DisplayError \endlink
- */
- virtual DisplayError GetNextStrategy(StrategyConstraints *constraints) = 0;
-
- /*! @brief Method to indicate end of a strategy selection cycle.
-
- @return \link DisplayError \endlink
- */
- virtual DisplayError Stop() = 0;
-
- protected:
- virtual ~StrategyInterface() { }
-};
-
-} // namespace sde
-
-#endif // __STRATEGY_INTERFACE_H__
-
diff --git a/displayengine/libs/core/buffer_manager.cpp b/displayengine/libs/core/buffer_manager.cpp
deleted file mode 100644
index 95c310a..0000000
--- a/displayengine/libs/core/buffer_manager.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
-* Copyright (c) 2015, 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
-* met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/debug.h>
-#include <utils/constants.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-
-#include "buffer_manager.h"
-
-#define __CLASS__ "BufferManager"
-
-namespace sde {
-
-// --------------------------------- BufferSlot Implementation -------------------------------------
-
-DisplayError BufferManager::BufferSlot::Init() {
- uint32_t buffer_count = hw_buffer_info.buffer_config.buffer_count;
- size_t buffer_size = hw_buffer_info.alloc_buffer_info.size;
-
- release_fd = new int[buffer_count];
- if (release_fd == NULL) {
- return kErrorMemory;
- }
-
- offset = new uint32_t[buffer_count];
- if (offset == NULL) {
- delete[] release_fd;
- release_fd = NULL;
- return kErrorMemory;
- }
-
- for (uint32_t idx = 0; idx < buffer_count; idx++) {
- release_fd[idx] = -1;
- offset[idx] = UINT32((buffer_size / buffer_count) * idx);
- }
- curr_index = 0;
-
- return kErrorNone;
-}
-
-DisplayError BufferManager::BufferSlot::Deinit() {
- uint32_t buffer_count = hw_buffer_info.buffer_config.buffer_count;
-
- for (uint32_t idx = 0; idx < buffer_count; idx++) {
- if (release_fd[idx] >= 0) {
- close(release_fd[idx]);
- release_fd[idx] = -1;
- }
- }
-
- if (offset) {
- delete[] offset;
- offset = NULL;
- }
-
- if (release_fd) {
- delete[] release_fd;
- release_fd = NULL;
- }
-
- state = kBufferSlotFree;
- hw_buffer_info = HWBufferInfo();
-
- return kErrorNone;
-}
-
-// BufferManager State Transition
-// *******************************************************
-// Current State * Next State
-// *****************************************
-// * FREE READY ACQUIRED
-// *******************************************************
-// FREE * NA NA GetNextBuffer()
-// READY * Stop() NA GetNextBuffer()
-// ACQUIRED * NA Start() NA
-//********************************************************
-
-// ------------------------------- BufferManager Implementation ------------------------------------
-
-BufferManager::BufferManager(BufferAllocator *buffer_allocator,
- BufferSyncHandler *buffer_sync_handler)
- : buffer_allocator_(buffer_allocator), buffer_sync_handler_(buffer_sync_handler),
- num_used_slot_(0) {
-}
-
-void BufferManager::Start() {
- uint32_t slot = 0, num_ready_slot = 0;
-
- // Change the state of acquired buffer_slot to kBufferSlotReady
- while ((num_ready_slot < num_used_slot_) && (slot < kMaxBufferSlotCount)) {
- if (buffer_slot_[slot].state == kBufferSlotFree) {
- slot++;
- continue;
- }
-
- buffer_slot_[slot++].state = kBufferSlotReady;
- num_ready_slot++;
- }
-}
-
-DisplayError BufferManager::GetNextBuffer(HWBufferInfo *hw_buffer_info) {
- DisplayError error = kErrorNone;
- const BufferConfig &buffer_config = hw_buffer_info->buffer_config;
-
- DLOGI_IF(kTagBufferManager, "Input: w = %d h = %d f = %d", buffer_config.width,
- buffer_config.height, buffer_config.format);
-
- uint32_t free_slot = num_used_slot_;
- uint32_t acquired_slot = kMaxBufferSlotCount;
- uint32_t num_used_slot = 0;
-
- // First look for a buffer slot in ready state, if no buffer slot found in ready state matching
- // with current input config, assign a buffer slot in free state and allocate buffers for it.
- for (uint32_t slot = 0; slot < kMaxBufferSlotCount && num_used_slot < num_used_slot_; slot++) {
- HWBufferInfo &hw_buffer_info = buffer_slot_[slot].hw_buffer_info;
-
- if (buffer_slot_[slot].state == kBufferSlotFree) {
- free_slot = slot;
- } else {
- if ((buffer_slot_[slot].state == kBufferSlotReady)) {
- if ((::memcmp(&buffer_config, &hw_buffer_info.buffer_config, sizeof(BufferConfig)) == 0)) {
- buffer_slot_[slot].state = kBufferSlotAcquired;
- acquired_slot = slot;
- break;
- }
- }
- num_used_slot++;
- }
- }
-
- // If the input config does not match with existing config, then allocate buffers for the new
- // buffer slot and change the state to kBufferSlotAcquired
- if (acquired_slot == kMaxBufferSlotCount) {
- if (free_slot >= kMaxBufferSlotCount) {
- return kErrorMemory;
- }
-
- buffer_slot_[free_slot].hw_buffer_info.buffer_config = hw_buffer_info->buffer_config;
-
- error = buffer_allocator_->AllocateBuffer(&buffer_slot_[free_slot].hw_buffer_info);
- if (error != kErrorNone) {
- return error;
- }
-
- buffer_slot_[free_slot].Init();
- buffer_slot_[free_slot].state = kBufferSlotAcquired;
- acquired_slot = free_slot;
- num_used_slot_++;
-
- DLOGI_IF(kTagBufferManager, "Allocate Buffer acquired_slot = %d ", acquired_slot);
- }
-
- const AllocatedBufferInfo &alloc_buffer_info =
- buffer_slot_[acquired_slot].hw_buffer_info.alloc_buffer_info;
- uint32_t curr_index = buffer_slot_[acquired_slot].curr_index;
-
- // Wait for the release fence fd before buffer slot being given to the client.
- buffer_sync_handler_->SyncWait(buffer_slot_[acquired_slot].release_fd[curr_index]);
- buffer_slot_[acquired_slot].release_fd[curr_index] = -1;
-
- hw_buffer_info->output_buffer.width = buffer_config.width;
- hw_buffer_info->output_buffer.height = buffer_config.height;
- hw_buffer_info->output_buffer.format = buffer_config.format;
- hw_buffer_info->output_buffer.flags.secure = buffer_config.secure;
-
- hw_buffer_info->output_buffer.planes[0].stride = alloc_buffer_info.stride;
- hw_buffer_info->output_buffer.planes[0].fd = alloc_buffer_info.fd;
- hw_buffer_info->output_buffer.planes[0].offset = buffer_slot_[acquired_slot].offset[curr_index];
- hw_buffer_info->slot = acquired_slot;
-
- DLOGI_IF(kTagBufferManager, "Output: w = %d h = %d f = %d session_id %d acquired slot = %d " \
- "num_used_slot %d curr_index = %d offset %d", hw_buffer_info->output_buffer.width,
- hw_buffer_info->output_buffer.height, hw_buffer_info->output_buffer.format,
- hw_buffer_info->session_id, acquired_slot, num_used_slot_, curr_index,
- hw_buffer_info->output_buffer.planes[0].offset);
-
- return kErrorNone;
-}
-
-DisplayError BufferManager::Stop(int *session_ids) {
- DisplayError error = kErrorNone;
- uint32_t slot = 0, count = 0;
-
- // Free all the buffer slots which were not acquired in the current cycle and deallocate the
- // buffers associated with it.
- while ((num_used_slot_ > 0) && (slot < kMaxBufferSlotCount)) {
- if (buffer_slot_[slot].state == kBufferSlotReady) {
- if (buffer_slot_[slot].hw_buffer_info.session_id != -1) {
- session_ids[count++] = buffer_slot_[slot].hw_buffer_info.session_id;
- }
-
- error = FreeBufferSlot(slot);
- if (error != kErrorNone) {
- return error;
- }
-
- num_used_slot_--;
- }
- slot++;
- }
-
- session_ids[count] = -1;
-
- return kErrorNone;
-}
-
-DisplayError BufferManager::SetReleaseFd(uint32_t slot, int fd) {
- if ((slot >= kMaxBufferSlotCount) || (buffer_slot_[slot].state != kBufferSlotAcquired)) {
- DLOGE("Invalid Parameters slot %d state %s", slot, buffer_slot_[slot].state);
- kErrorParameters;
- }
-
- uint32_t &curr_index = buffer_slot_[slot].curr_index;
- const HWBufferInfo &hw_buffer_info = buffer_slot_[slot].hw_buffer_info;
- uint32_t buffer_count = hw_buffer_info.buffer_config.buffer_count;
-
- // 1. Store the release fence fd, so that buffer manager waits for the release fence fd to be
- // signaled and gives the buffer slot to the client.
- // 2. Modify the curr_index to point to next buffer.
- buffer_slot_[slot].release_fd[curr_index] = fd;
- curr_index = (curr_index + 1) % buffer_count;
-
- DLOGI_IF(kTagBufferManager, "w = %d h = %d f = %d session_id %d slot = %d curr_index = %d " \
- "sync fd %d", hw_buffer_info.output_buffer.width, hw_buffer_info.output_buffer.height,
- hw_buffer_info.output_buffer.format, hw_buffer_info.session_id, slot, curr_index, fd);
-
- return kErrorNone;
-}
-
-
-DisplayError BufferManager::SetSessionId(uint32_t slot, int session_id) {
- if ((slot >= kMaxBufferSlotCount) || (buffer_slot_[slot].state != kBufferSlotAcquired)) {
- DLOGE("Invalid Parameters slot %d state %s", slot, buffer_slot_[slot].state);
- kErrorParameters;
- }
-
- HWBufferInfo *hw_buffer_info = &buffer_slot_[slot].hw_buffer_info;
-
- hw_buffer_info->session_id = session_id;
-
- DLOGI_IF(kTagBufferManager, "w = %d h = %d f = %d session_id %d slot = %d",
- hw_buffer_info->output_buffer.width, hw_buffer_info->output_buffer.height,
- hw_buffer_info->output_buffer.format, hw_buffer_info->session_id, slot);
-
- return kErrorNone;
-}
-
-DisplayError BufferManager::FreeBufferSlot(uint32_t slot) {
- DisplayError error = kErrorNone;
-
- HWBufferInfo *hw_buffer_info = &buffer_slot_[slot].hw_buffer_info;
-
- error = buffer_allocator_->FreeBuffer(hw_buffer_info);
- if (error != kErrorNone) {
- return error;
- }
-
- DLOGI_IF(kTagBufferManager, "session_id %d slot = %d num_used_slot %d",
- hw_buffer_info->session_id, slot, num_used_slot_);
-
- buffer_slot_[slot].Deinit();
-
- return kErrorNone;
-}
-
-} // namespace sde
diff --git a/displayengine/libs/core/buffer_manager.h b/displayengine/libs/core/buffer_manager.h
deleted file mode 100644
index 29bcd03..0000000
--- a/displayengine/libs/core/buffer_manager.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-* Copyright (c) 2015, 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
-* met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __BUFFER_MANAGER_H__
-#define __BUFFER_MANAGER_H__
-
-#include <utils/locker.h>
-#include <core/buffer_allocator.h>
-#include "hw_interface.h"
-
-namespace sde {
-
-class BufferManager {
- public:
- BufferManager(BufferAllocator *buffer_allocator, BufferSyncHandler *buffer_sync_handler);
-
- void Start();
- DisplayError GetNextBuffer(HWBufferInfo *hw_buffer_info);
- DisplayError Stop(int *session_ids);
- DisplayError SetReleaseFd(uint32_t slot, int fd);
- DisplayError SetSessionId(uint32_t slot, int session_id);
-
- private:
- static const uint32_t kMaxBufferSlotCount = 32;
-
- enum kBufferSlotState {
- kBufferSlotFree = 0,
- kBufferSlotReady = 1,
- kBufferSlotAcquired = 2,
- };
-
- struct BufferSlot {
- HWBufferInfo hw_buffer_info;
- kBufferSlotState state;
- int *release_fd;
- uint32_t *offset;
- uint32_t curr_index;
-
- BufferSlot() : state(kBufferSlotFree), release_fd(NULL), offset(NULL), curr_index(0) { }
- DisplayError Init();
- DisplayError Deinit();
- };
-
- DisplayError FreeBufferSlot(uint32_t index);
-
- BufferSlot buffer_slot_[kMaxBufferSlotCount];
- BufferAllocator *buffer_allocator_;
- BufferSyncHandler *buffer_sync_handler_;
- uint32_t num_used_slot_;
-};
-
-} // namespace sde
-
-#endif // __BUFFER_MANAGER_H__
-
-
diff --git a/displayengine/libs/core/display_base.cpp b/displayengine/libs/core/display_base.cpp
deleted file mode 100644
index a70a7c9..0000000
--- a/displayengine/libs/core/display_base.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/constants.h>
-#include <utils/debug.h>
-
-#include "display_base.h"
-#include "offline_ctrl.h"
-
-#define __CLASS__ "DisplayBase"
-
-namespace sde {
-
-// TODO(user): Have a single structure handle carries all the interface pointers and variables.
-DisplayBase::DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
- HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler,
- CompManager *comp_manager, OfflineCtrl *offline_ctrl)
- : display_type_(display_type), event_handler_(event_handler), hw_device_type_(hw_device_type),
- buffer_sync_handler_(buffer_sync_handler), comp_manager_(comp_manager),
- offline_ctrl_(offline_ctrl), state_(kStateOff), hw_device_(0), display_comp_ctx_(0),
- display_attributes_(NULL), num_modes_(0), active_mode_index_(0), pending_commit_(false),
- vsync_enable_(false) {
-}
-
-DisplayError DisplayBase::Init() {
- DisplayError error = kErrorNone;
- hw_panel_info_ = HWPanelInfo();
- hw_intf_->GetHWPanelInfo(&hw_panel_info_);
-
- error = hw_intf_->GetNumDisplayAttributes(&num_modes_);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- display_attributes_ = new HWDisplayAttributes[num_modes_];
- if (!display_attributes_) {
- error = kErrorMemory;
- goto CleanupOnError;
- }
-
- for (uint32_t i = 0; i < num_modes_; i++) {
- error = hw_intf_->GetDisplayAttributes(&display_attributes_[i], i);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
- }
-
- active_mode_index_ = GetBestConfig();
-
- error = hw_intf_->SetDisplayAttributes(active_mode_index_);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- error = comp_manager_->RegisterDisplay(display_type_, display_attributes_[active_mode_index_],
- hw_panel_info_, &display_comp_ctx_);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- error = offline_ctrl_->RegisterDisplay(display_type_, &display_offline_ctx_);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- return kErrorNone;
-
-CleanupOnError:
- if (display_comp_ctx_) {
- comp_manager_->UnregisterDisplay(display_comp_ctx_);
- }
-
- if (display_attributes_) {
- delete[] display_attributes_;
- display_attributes_ = NULL;
- }
-
- hw_intf_->Close();
-
- return error;
-}
-
-DisplayError DisplayBase::Deinit() {
- offline_ctrl_->UnregisterDisplay(display_offline_ctx_);
-
- comp_manager_->UnregisterDisplay(display_comp_ctx_);
-
- if (display_attributes_) {
- delete[] display_attributes_;
- display_attributes_ = NULL;
- }
-
- hw_intf_->Close();
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::Prepare(LayerStack *layer_stack) {
- DisplayError error = kErrorNone;
-
- if (!layer_stack) {
- return kErrorParameters;
- }
-
- pending_commit_ = false;
-
- if (state_ == kStateOn) {
- // Clean hw layers for reuse.
- hw_layers_.info = HWLayersInfo();
- hw_layers_.info.stack = layer_stack;
-
- comp_manager_->PrePrepare(display_comp_ctx_, &hw_layers_);
- while (true) {
- error = comp_manager_->Prepare(display_comp_ctx_, &hw_layers_);
- if (error != kErrorNone) {
- break;
- }
-
- error = offline_ctrl_->Prepare(display_offline_ctx_, &hw_layers_);
- if (error == kErrorNone) {
- error = hw_intf_->Validate(&hw_layers_);
- if (error == kErrorNone) {
- // Strategy is successful now, wait for Commit().
- pending_commit_ = true;
- break;
- }
- }
- }
- comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_);
- } else {
- return kErrorNotSupported;
- }
-
- return error;
-}
-
-DisplayError DisplayBase::Commit(LayerStack *layer_stack) {
- DisplayError error = kErrorNone;
-
- if (!layer_stack) {
- return kErrorParameters;
- }
-
- if (state_ == kStateOn) {
- if (!pending_commit_) {
- DLOGE("Commit: Corresponding Prepare() is not called for display = %d", display_type_);
- return kErrorUndefined;
- }
-
- error = offline_ctrl_->Commit(display_offline_ctx_, &hw_layers_);
- if (error == kErrorNone) {
- error = hw_intf_->Commit(&hw_layers_);
- if (error == kErrorNone) {
- error = comp_manager_->PostCommit(display_comp_ctx_, &hw_layers_);
- if (error != kErrorNone) {
- DLOGE("Composition manager PostCommit failed");
- }
- } else {
- DLOGE("Unexpected error. Commit failed on driver.");
- }
- }
- } else {
- return kErrorNotSupported;
- }
-
- pending_commit_ = false;
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::Flush() {
- DisplayError error = kErrorNone;
-
- if (state_ != kStateOn) {
- return kErrorNone;
- }
-
- hw_layers_.info.count = 0;
- error = hw_intf_->Flush();
- if (error == kErrorNone) {
- comp_manager_->Purge(display_comp_ctx_);
- pending_commit_ = false;
- } else {
- DLOGV("Failed to flush device.");
- }
-
- return error;
-}
-
-DisplayError DisplayBase::GetDisplayState(DisplayState *state) {
- if (!state) {
- return kErrorParameters;
- }
-
- *state = state_;
- return kErrorNone;
-}
-
-DisplayError DisplayBase::GetNumVariableInfoConfigs(uint32_t *count) {
- if (!count) {
- return kErrorParameters;
- }
-
- *count = num_modes_;
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::GetConfig(DisplayConfigFixedInfo *fixed_info) {
- if (!fixed_info) {
- return kErrorParameters;
- }
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info) {
- if (!variable_info || index >= num_modes_) {
- return kErrorParameters;
- }
-
- *variable_info = display_attributes_[index];
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::GetActiveConfig(uint32_t *index) {
- if (!index) {
- return kErrorParameters;
- }
-
- *index = active_mode_index_;
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::GetVSyncState(bool *enabled) {
- if (!enabled) {
- return kErrorParameters;
- }
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::SetDisplayState(DisplayState state) {
- DisplayError error = kErrorNone;
-
- DLOGI("Set state = %d, display %d", state, display_type_);
-
- if (state == state_) {
- DLOGI("Same state transition is requested.");
- return kErrorNone;
- }
-
- switch (state) {
- case kStateOff:
- hw_layers_.info.count = 0;
- error = hw_intf_->Flush();
- if (error == kErrorNone) {
- comp_manager_->Purge(display_comp_ctx_);
-
- error = hw_intf_->PowerOff();
- }
- break;
-
- case kStateOn:
- error = hw_intf_->PowerOn();
- break;
-
- case kStateDoze:
- error = hw_intf_->Doze();
- break;
-
- case kStateStandby:
- error = hw_intf_->Standby();
- break;
-
- default:
- DLOGE("Spurious state = %d transition requested.", state);
- break;
- }
-
- if (error == kErrorNone) {
- state_ = state;
- }
-
- return error;
-}
-
-DisplayError DisplayBase::SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
- DisplayError error = kErrorNone;
-
- if (!variable_info) {
- return kErrorParameters;
- }
-
- HWDisplayAttributes display_attributes = display_attributes_[active_mode_index_];
-
- display_attributes.x_pixels = variable_info->x_pixels;
- display_attributes.y_pixels = variable_info->y_pixels;
- display_attributes.fps = variable_info->fps;
-
- // if display is already connected, unregister display from composition manager and register
- // the display with new configuration.
- if (display_comp_ctx_) {
- comp_manager_->UnregisterDisplay(display_comp_ctx_);
- }
-
- error = comp_manager_->RegisterDisplay(display_type_, display_attributes, hw_panel_info_,
- &display_comp_ctx_);
- if (error != kErrorNone) {
- return error;
- }
-
- display_attributes_[active_mode_index_] = display_attributes;
-
- return kErrorNone;
-}
-
-DisplayError DisplayBase::SetActiveConfig(uint32_t index) {
- DisplayError error = kErrorNone;
-
- if (index >= num_modes_) {
- return kErrorParameters;
- }
-
- error = hw_intf_->SetDisplayAttributes(index);
- if (error != kErrorNone) {
- return error;
- }
-
- active_mode_index_ = index;
-
- if (display_comp_ctx_) {
- comp_manager_->UnregisterDisplay(display_comp_ctx_);
- }
-
- error = comp_manager_->RegisterDisplay(display_type_, display_attributes_[index], hw_panel_info_,
- &display_comp_ctx_);
-
- return error;
-}
-
-DisplayError DisplayBase::SetMaxMixerStages(uint32_t max_mixer_stages) {
- DisplayError error = kErrorNone;
-
- if (comp_manager_) {
- error = comp_manager_->SetMaxMixerStages(display_comp_ctx_, max_mixer_stages);
- }
-
- return error;
-}
-
-DisplayError DisplayBase::SetDisplayMode(uint32_t mode) {
- return kErrorNotSupported;
-}
-
-void DisplayBase::AppendDump(char *buffer, uint32_t length) {
- DumpImpl::AppendString(buffer, length, "\n-----------------------");
- DumpImpl::AppendString(buffer, length, "\ndevice type: %u", display_type_);
- DumpImpl::AppendString(buffer, length, "\nstate: %u, vsync on: %u", state_, INT(vsync_enable_));
- DumpImpl::AppendString(buffer, length, "\nnum configs: %u, active config index: %u",
- num_modes_, active_mode_index_);
-
- DisplayConfigVariableInfo &info = display_attributes_[active_mode_index_];
- DumpImpl::AppendString(buffer, length, "\nres:%ux%u, dpi:%.2fx%.2f, fps:%.2f, vsync period: %u",
- info.x_pixels, info.y_pixels, info.x_dpi, info.y_dpi, info.fps,
- info.vsync_period_ns);
-
- uint32_t num_layers = 0;
- uint32_t num_hw_layers = 0;
- if (hw_layers_.info.stack) {
- num_layers = hw_layers_.info.stack->layer_count;
- num_hw_layers = hw_layers_.info.count;
- }
-
- DumpImpl::AppendString(buffer, length, "\n\nnum actual layers: %u, num sde layers: %u",
- num_layers, num_hw_layers);
-
- for (uint32_t i = 0; i < num_hw_layers; i++) {
- Layer &layer = hw_layers_.info.stack->layers[hw_layers_.info.index[i]];
- LayerBuffer *input_buffer = layer.input_buffer;
- HWLayerConfig &layer_config = hw_layers_.config[i];
- HWPipeInfo &left_pipe = hw_layers_.config[i].left_pipe;
- HWPipeInfo &right_pipe = hw_layers_.config[i].right_pipe;
- HWRotateInfo &left_rotate = hw_layers_.config[i].rotates[0];
- HWRotateInfo &right_rotate = hw_layers_.config[i].rotates[1];
-
- DumpImpl::AppendString(buffer, length, "\n\nsde idx: %u, actual idx: %u", i,
- hw_layers_.info.index[i]);
- DumpImpl::AppendString(buffer, length, "\nw: %u, h: %u, fmt: %u",
- input_buffer->width, input_buffer->height, input_buffer->format);
- AppendRect(buffer, length, "\nsrc_rect:", &layer.src_rect);
- AppendRect(buffer, length, "\ndst_rect:", &layer.dst_rect);
-
- if (left_rotate.valid) {
- DumpImpl::AppendString(buffer, length, "\n\tleft rotate =>");
- DumpImpl::AppendString(buffer, length, "\n\t pipe id: 0x%x", left_rotate.pipe_id);
- AppendRect(buffer, length, "\n\t src_roi:", &left_rotate.src_roi);
- AppendRect(buffer, length, "\n\t dst_roi:", &left_rotate.dst_roi);
- }
-
- if (right_rotate.valid) {
- DumpImpl::AppendString(buffer, length, "\n\tright rotate =>");
- DumpImpl::AppendString(buffer, length, "\n\t pipe id: 0x%x", right_rotate.pipe_id);
- AppendRect(buffer, length, "\n\t src_roi:", &right_rotate.src_roi);
- AppendRect(buffer, length, "\n\t dst_roi:", &right_rotate.dst_roi);
- }
-
- if (left_pipe.valid) {
- DumpImpl::AppendString(buffer, length, "\n\tleft pipe =>");
- DumpImpl::AppendString(buffer, length, "\n\t pipe id: 0x%x", left_pipe.pipe_id);
- AppendRect(buffer, length, "\n\t src_roi:", &left_pipe.src_roi);
- AppendRect(buffer, length, "\n\t dst_roi:", &left_pipe.dst_roi);
- }
-
- if (right_pipe.valid) {
- DumpImpl::AppendString(buffer, length, "\n\tright pipe =>");
- DumpImpl::AppendString(buffer, length, "\n\t pipe id: 0x%x", right_pipe.pipe_id);
- AppendRect(buffer, length, "\n\t src_roi:", &right_pipe.src_roi);
- AppendRect(buffer, length, "\n\t dst_roi:", &right_pipe.dst_roi);
- }
- }
-}
-
-void DisplayBase::AppendRect(char *buffer, uint32_t length, const char *rect_name,
- LayerRect *rect) {
- DumpImpl::AppendString(buffer, length, "%s %.1f, %.1f, %.1f, %.1f",
- rect_name, rect->left, rect->top, rect->right, rect->bottom);
-}
-
-int DisplayBase::GetBestConfig() {
- return (num_modes_ == 1) ? 0 : -1;
-}
-
-} // namespace sde
-
diff --git a/displayengine/libs/core/fb/hw_rotator.cpp b/displayengine/libs/core/fb/hw_rotator.cpp
deleted file mode 100644
index cc9caa5..0000000
--- a/displayengine/libs/core/fb/hw_rotator.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
-* Copyright (c) 2015, 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
-* met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/debug.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include "hw_rotator.h"
-
-#define __CLASS__ "HWRotator"
-
-namespace sde {
-
-DisplayError HWRotatorInterface::Create(HWRotatorInterface **intf,
- BufferSyncHandler *buffer_sync_handler) {
- DisplayError error = kErrorNone;
- HWRotator *hw_rotator = NULL;
-
- hw_rotator = new HWRotator(buffer_sync_handler);
- if (!hw_rotator) {
- error = kErrorMemory;
- } else {
- *intf = hw_rotator;
- }
- return error;
-}
-
-DisplayError HWRotatorInterface::Destroy(HWRotatorInterface *intf) {
- delete intf;
- intf = NULL;
-
- return kErrorNone;
-}
-
-HWRotator::HWRotator(BufferSyncHandler *buffer_sync_handler) : HWDevice(buffer_sync_handler) {
- HWDevice::device_type_ = kDeviceRotator;
- HWDevice::device_name_ = "Rotator Device";
-}
-
-DisplayError HWRotator::Open() {
- DisplayError error = kErrorNone;
-
- char device_name[64] = {0};
- snprintf(device_name, sizeof(device_name), "%s", "/dev/mdss_rotator");
-
- HWDevice::device_fd_ = open_(device_name, O_RDWR);
- if (HWDevice::device_fd_ < 0) {
- DLOGE("open %s failed err = %d errstr = %s", device_name, errno, strerror(errno));
- return kErrorResources;
- }
-
- return error;
-}
-
-DisplayError HWRotator::Close() {
- if (HWDevice::device_fd_ > 0) {
- close_(HWDevice::device_fd_);
- }
-
- return kErrorNone;
-}
-
-DisplayError HWRotator::OpenSession(HWRotateInfo *rotate_info) {
- LayerBuffer *input_buffer = rotate_info->input_buffer;
- HWBufferInfo *rot_buf_info = &rotate_info->hw_buffer_info;
-
- ResetRotatorParams();
-
- STRUCT_VAR(mdp_rotation_config, mdp_rot_config);
- mdp_rot_config.version = MDP_ROTATION_REQUEST_VERSION_1_0;
- mdp_rot_config.input.width = input_buffer->width;
- mdp_rot_config.input.height = input_buffer->height;
- HWDevice::SetFormat(input_buffer->format, &mdp_rot_config.input.format);
- mdp_rot_config.output.width = rot_buf_info->output_buffer.width;
- mdp_rot_config.output.height = rot_buf_info->output_buffer.height;
- HWDevice::SetFormat(rot_buf_info->output_buffer.format, &mdp_rot_config.output.format);
- mdp_rot_config.frame_rate = rotate_info->frame_rate;
-
- if (ioctl_(HWDevice::device_fd_, MDSS_ROTATION_OPEN, &mdp_rot_config) < 0) {
- IOCTL_LOGE(MDSS_ROTATION_OPEN, HWDevice::device_type_);
- return kErrorHardware;
- }
-
- rot_buf_info->session_id = mdp_rot_config.session_id;
-
- DLOGV_IF(kTagDriverConfig, "session_id %d", rot_buf_info->session_id);
-
- return kErrorNone;
-}
-
-DisplayError HWRotator::CloseSession(int32_t session_id) {
- if (ioctl_(HWDevice::device_fd_, MDSS_ROTATION_CLOSE, (uint32_t)session_id) < 0) {
- IOCTL_LOGE(MDSS_ROTATION_CLOSE, HWDevice::device_type_);
- return kErrorHardware;
- }
-
- DLOGV_IF(kTagDriverConfig, "session_id %d", session_id);
-
- return kErrorNone;
-}
-
-void HWRotator::SetRotatorCtrlParams(HWLayers *hw_layers) {
- DLOGV_IF(kTagDriverConfig, "************************* %s Validate Input ************************",
- HWDevice::device_name_);
-
- ResetRotatorParams();
-
- HWLayersInfo &hw_layer_info = hw_layers->info;
-
- uint32_t &rot_count = mdp_rot_request_.count;
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer& layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
-
- for (uint32_t count = 0; count < 2; count++) {
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
-
- if (rotate_info->valid) {
- HWBufferInfo *rot_buf_info = &rotate_info->hw_buffer_info;
- mdp_rotation_item *mdp_rot_item = &mdp_rot_request_.list[rot_count];
- bool rot90 = (layer.transform.rotation == 90.0f);
-
- if (rot90) {
- mdp_rot_item->flags |= MDP_ROTATION_90;
- }
-
- if (layer.transform.flip_horizontal) {
- mdp_rot_item->flags |= MDP_ROTATION_FLIP_LR;
- }
-
- if (layer.transform.flip_vertical) {
- mdp_rot_item->flags |= MDP_ROTATION_FLIP_UD;
- }
-
- HWDevice::SetRect(rotate_info->src_roi, &mdp_rot_item->src_rect);
- HWDevice::SetRect(rotate_info->dst_roi, &mdp_rot_item->dst_rect);
-
- // TODO(user): Need to assign the writeback id and pipe id returned from resource manager.
- mdp_rot_item->pipe_idx = 0;
- mdp_rot_item->wb_idx = 0;
-
- mdp_rot_item->input.width = layer.input_buffer->width;
- mdp_rot_item->input.height = layer.input_buffer->height;
- HWDevice::SetFormat(layer.input_buffer->format, &mdp_rot_item->input.format);
-
- mdp_rot_item->output.width = rot_buf_info->output_buffer.width;
- mdp_rot_item->output.height = rot_buf_info->output_buffer.height;
- HWDevice::SetFormat(rot_buf_info->output_buffer.format, &mdp_rot_item->output.format);
-
- rot_count++;
-
- DLOGV_IF(kTagDriverConfig, "******************** Layer[%d] %s rotate ********************",
- i, count ? "Right" : "Left");
- DLOGV_IF(kTagDriverConfig, "in_w %d, in_h %d, in_f %d,\t out_w %d, out_h %d, out_f %d",
- mdp_rot_item->input.width, mdp_rot_item->input.height, mdp_rot_item->input.format,
- mdp_rot_item->output.width, mdp_rot_item->output.height,
- mdp_rot_item->output.format);
- DLOGV_IF(kTagDriverConfig, "pipe_id %d, wb_id %d, rot_flag %d", mdp_rot_item->pipe_idx,
- mdp_rot_item->wb_idx, mdp_rot_item->flags);
- DLOGV_IF(kTagDriverConfig, "src_rect [%d, %d, %d, %d]", mdp_rot_item->src_rect.x,
- mdp_rot_item->src_rect.y, mdp_rot_item->src_rect.w, mdp_rot_item->src_rect.h);
- DLOGV_IF(kTagDriverConfig, "dst_rect [%d, %d, %d, %d]", mdp_rot_item->dst_rect.x,
- mdp_rot_item->dst_rect.y, mdp_rot_item->dst_rect.w, mdp_rot_item->dst_rect.h);
- DLOGV_IF(kTagDriverConfig, "*************************************************************");
- }
- }
- }
-}
-
-void HWRotator::SetRotatorBufferParams(HWLayers *hw_layers) {
- HWLayersInfo &hw_layer_info = hw_layers->info;
- uint32_t rot_count = 0;
-
- DLOGV_IF(kTagDriverConfig, "************************* %s Commit Input **************************",
- HWDevice::device_name_);
- DLOGV_IF(kTagDriverConfig, "Rotate layer count is %d", mdp_rot_request_.count);
-
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer& layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
-
- for (uint32_t count = 0; count < 2; count++) {
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
-
- if (rotate_info->valid) {
- HWBufferInfo *rot_buf_info = &rotate_info->hw_buffer_info;
- mdp_rotation_item *mdp_rot_item = &mdp_rot_request_.list[rot_count];
-
- mdp_rot_item->input.planes[0].fd = layer.input_buffer->planes[0].fd;
- mdp_rot_item->input.planes[0].offset = layer.input_buffer->planes[0].offset;
- HWDevice::SetStride(HWDevice::device_type_, layer.input_buffer->format,
- layer.input_buffer->width, &mdp_rot_item->input.planes[0].stride);
- mdp_rot_item->input.plane_count = 1;
- mdp_rot_item->input.fence = layer.input_buffer->acquire_fence_fd;
-
- mdp_rot_item->output.planes[0].fd = rot_buf_info->output_buffer.planes[0].fd;
- mdp_rot_item->output.planes[0].offset = rot_buf_info->output_buffer.planes[0].offset;
- HWDevice::SetStride(HWDevice::device_type_, rot_buf_info->output_buffer.format,
- rot_buf_info->output_buffer.planes[0].stride,
- &mdp_rot_item->output.planes[0].stride);
- mdp_rot_item->output.plane_count = 1;
- mdp_rot_item->output.fence = -1;
-
- rot_count++;
-
- DLOGV_IF(kTagDriverConfig, "******************** Layer[%d] %s rotate ********************",
- i, count ? "Right" : "Left");
- DLOGV_IF(kTagDriverConfig, "in_buf_fd %d, in_buf_offset %d, in_stride %d, " \
- "in_plane_count %d, in_fence %d", mdp_rot_item->input.planes[0].fd,
- mdp_rot_item->input.planes[0].offset, mdp_rot_item->input.planes[0].stride,
- mdp_rot_item->input.plane_count, mdp_rot_item->input.fence);
- DLOGV_IF(kTagDriverConfig, "out_fd %d, out_offset %d, out_stride %d, out_plane_count %d, " \
- "out_fence %d", mdp_rot_item->output.planes[0].fd,
- mdp_rot_item->output.planes[0].offset, mdp_rot_item->output.planes[0].stride,
- mdp_rot_item->output.plane_count, mdp_rot_item->output.fence);
- DLOGV_IF(kTagDriverConfig, "*************************************************************");
- }
- }
- }
-}
-
-DisplayError HWRotator::Validate(HWLayers *hw_layers) {
- SetRotatorCtrlParams(hw_layers);
-
- mdp_rot_request_.flags = MDSS_ROTATION_REQUEST_VALIDATE;
- if (ioctl_(HWDevice::device_fd_, MDSS_ROTATION_REQUEST, &mdp_rot_request_) < 0) {
- IOCTL_LOGE(MDSS_ROTATION_REQUEST, HWDevice::device_type_);
- return kErrorHardware;
- }
-
- return kErrorNone;
-}
-
-DisplayError HWRotator::Commit(HWLayers *hw_layers) {
- HWLayersInfo &hw_layer_info = hw_layers->info;
- uint32_t rot_count = 0;
-
- SetRotatorCtrlParams(hw_layers);
-
- SetRotatorBufferParams(hw_layers);
-
- mdp_rot_request_.flags &= ~MDSS_ROTATION_REQUEST_VALIDATE;
- if (ioctl_(HWDevice::device_fd_, MDSS_ROTATION_REQUEST, &mdp_rot_request_) < 0) {
- IOCTL_LOGE(MDSS_ROTATION_REQUEST, HWDevice::device_type_);
- return kErrorHardware;
- }
-
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer& layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
-
- layer.input_buffer->release_fence_fd = -1;
-
- for (uint32_t count = 0; count < 2; count++) {
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
-
- if (rotate_info->valid) {
- HWBufferInfo *rot_buf_info = &rotate_info->hw_buffer_info;
- mdp_rotation_item *mdp_rot_item = &mdp_rot_request_.list[rot_count];
-
- HWDevice::SyncMerge(layer.input_buffer->release_fence_fd, dup(mdp_rot_item->output.fence),
- &layer.input_buffer->release_fence_fd);
-
- rot_buf_info->output_buffer.acquire_fence_fd = dup(mdp_rot_item->output.fence);
-
- close_(mdp_rot_item->output.fence);
- rot_count++;
- }
- }
- }
-
- return kErrorNone;
-}
-
-void HWRotator::ResetRotatorParams() {
- memset(&mdp_rot_request_, 0, sizeof(mdp_rot_request_));
- memset(&mdp_rot_layers_, 0, sizeof(mdp_rot_layers_));
-
- for (uint32_t i = 0; i < kMaxSDELayers * 2; i++) {
- mdp_rot_layers_[i].input.fence = -1;
- mdp_rot_layers_[i].output.fence = -1;
- }
-
- mdp_rot_request_.version = MDP_ROTATION_REQUEST_VERSION_1_0;
- mdp_rot_request_.list = mdp_rot_layers_;
-}
-
-} // namespace sde
-
diff --git a/displayengine/libs/core/fb/hw_rotator.h b/displayengine/libs/core/fb/hw_rotator.h
deleted file mode 100644
index 6e7727d..0000000
--- a/displayengine/libs/core/fb/hw_rotator.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __HW_ROTATOR_H__
-#define __HW_ROTATOR_H__
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <linux/msm_mdp_ext.h>
-#include <video/msm_hdmi_modes.h>
-#include <linux/mdss_rotator.h>
-#include <poll.h>
-#include <pthread.h>
-
-#include "hw_device.h"
-#include "hw_rotator_interface.h"
-
-namespace sde {
-
-class HWRotator : public HWDevice, public HWRotatorInterface {
- public:
- explicit HWRotator(BufferSyncHandler *buffer_sync_handler);
- virtual DisplayError Open();
- virtual DisplayError Close();
- virtual DisplayError OpenSession(HWRotateInfo *hw_layers);
- virtual DisplayError CloseSession(int32_t session_id);
- virtual DisplayError Validate(HWLayers *hw_layers);
- virtual DisplayError Commit(HWLayers *hw_layers);
-
- private:
- void ResetRotatorParams();
- void SetRotatorCtrlParams(HWLayers *hw_layers);
- void SetRotatorBufferParams(HWLayers *hw_layers);
-
- struct mdp_rotation_request mdp_rot_request_;
- struct mdp_rotation_item mdp_rot_layers_[kMaxSDELayers * 2]; // split panel (left + right)
-};
-
-} // namespace sde
-
-#endif // __HW_ROTATOR_H__
-
diff --git a/displayengine/libs/core/hw_interface.h b/displayengine/libs/core/hw_interface.h
deleted file mode 100644
index 8cd608e..0000000
--- a/displayengine/libs/core/hw_interface.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __HW_INTERFACE_H__
-#define __HW_INTERFACE_H__
-
-#include <core/display_interface.h>
-#include <private/strategy_interface.h>
-#include <private/hw_info_types.h>
-#include <utils/constants.h>
-#include <core/buffer_allocator.h>
-#include <core/buffer_sync_handler.h>
-
-namespace sde {
-
-enum HWBlockType {
- kHWPrimary,
- kHWHDMI,
- kHWWriteback0,
- kHWWriteback1,
- kHWWriteback2,
- kHWBlockMax
-};
-
-struct HWBufferInfo : public BufferInfo {
- LayerBuffer output_buffer;
- int session_id;
- uint32_t slot;
-
- HWBufferInfo() : session_id(-1), slot(0) { }
-};
-
-struct HWRotateInfo {
- LayerBuffer *input_buffer;
- uint32_t pipe_id;
- LayerRect src_roi;
- LayerRect dst_roi;
- LayerBufferFormat dst_format;
- HWBlockType writeback_id;
- float downscale_ratio;
- HWBufferInfo hw_buffer_info;
- bool valid;
- uint32_t frame_rate;
-
- HWRotateInfo() : input_buffer(NULL), pipe_id(0), dst_format(kFormatInvalid),
- writeback_id(kHWWriteback0), downscale_ratio(1.0f), valid(false),
- frame_rate(0) { }
-
- void Reset() { *this = HWRotateInfo(); }
-};
-
-struct HWPipeInfo {
- uint32_t pipe_id;
- LayerRect src_roi;
- LayerRect dst_roi;
- uint8_t horizontal_decimation;
- uint8_t vertical_decimation;
- bool valid;
- uint32_t z_order;
-
- HWPipeInfo() : pipe_id(0), horizontal_decimation(0), vertical_decimation(0), valid(false),
- z_order(0) { }
-
- void Reset() { *this = HWPipeInfo(); }
-};
-
-struct HWLayerConfig {
- bool use_non_dma_pipe; // set by client
- HWPipeInfo left_pipe; // pipe for left side of output
- HWPipeInfo right_pipe; // pipe for right side of output
- uint32_t num_rotate; // number of rotate
- HWRotateInfo rotates[kMaxRotatePerLayer]; // rotation for the buffer
-
- HWLayerConfig() : use_non_dma_pipe(false), num_rotate(0) { }
-
- void Reset() { *this = HWLayerConfig(); }
-};
-
-struct HWLayers {
- HWLayersInfo info;
- HWLayerConfig config[kMaxSDELayers];
- int closed_session_ids[kMaxSDELayers * 2]; // split panel (left + right)
-
- HWLayers() { memset(closed_session_ids, -1, sizeof(closed_session_ids)); }
-
- void Reset() { *this = HWLayers(); }
-};
-
-struct HWDisplayAttributes : DisplayConfigVariableInfo {
- bool is_device_split;
- uint32_t split_left;
- bool always_src_split;
-
- HWDisplayAttributes() : is_device_split(false), split_left(0), always_src_split(false) { }
-
- void Reset() { *this = HWDisplayAttributes(); }
-};
-
-// HWEventHandler - Implemented in DisplayBase and HWInterface implementation
-class HWEventHandler {
- public:
- virtual DisplayError VSync(int64_t timestamp) = 0;
- virtual DisplayError Blank(bool blank) = 0;
- virtual void IdleTimeout() = 0;
- virtual void ThermalEvent(int64_t thermal_level) = 0;
- protected:
- virtual ~HWEventHandler() { }
-};
-
-class HWInterface {
- public:
- virtual DisplayError Open(HWEventHandler *eventhandler) = 0;
- virtual DisplayError Close() = 0;
- virtual DisplayError GetNumDisplayAttributes(uint32_t *count) = 0;
- virtual DisplayError GetDisplayAttributes(HWDisplayAttributes *display_attributes,
- uint32_t index) = 0;
- virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info) = 0;
- virtual DisplayError SetDisplayAttributes(uint32_t index) = 0;
- virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index) = 0;
- virtual DisplayError PowerOn() = 0;
- virtual DisplayError PowerOff() = 0;
- virtual DisplayError Doze() = 0;
- virtual DisplayError Standby() = 0;
- virtual DisplayError Validate(HWLayers *hw_layers) = 0;
- virtual DisplayError Commit(HWLayers *hw_layers) = 0;
- virtual DisplayError Flush() = 0;
-
- protected:
- virtual ~HWInterface() { }
-};
-
-} // namespace sde
-
-#endif // __HW_INTERFACE_H__
-
diff --git a/displayengine/libs/core/hw_rotator_interface.h b/displayengine/libs/core/hw_rotator_interface.h
deleted file mode 100644
index 35876d6..0000000
--- a/displayengine/libs/core/hw_rotator_interface.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (c) 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __HW_ROTATOR_INTERFACE_H__
-#define __HW_ROTATOR_INTERFACE_H__
-
-namespace sde {
-
-class BufferSyncHandler;
-struct HWRotateInfo;
-struct HWLayers;
-
-class HWRotatorInterface {
- public:
- static DisplayError Create(HWRotatorInterface **intf, BufferSyncHandler *buffer_sync_handler);
- static DisplayError Destroy(HWRotatorInterface *intf);
- virtual DisplayError Open() = 0;
- virtual DisplayError Close() = 0;
- virtual DisplayError OpenSession(HWRotateInfo *rotate_info) = 0;
- virtual DisplayError CloseSession(int32_t session_id) = 0;
- virtual DisplayError Validate(HWLayers *hw_layers) = 0;
- virtual DisplayError Commit(HWLayers *hw_layers) = 0;
-
- protected:
- virtual ~HWRotatorInterface() { }
-};
-
-} // namespace sde
-
-#endif // __HW_ROTATOR_INTERFACE_H__
-
diff --git a/displayengine/libs/core/offline_ctrl.cpp b/displayengine/libs/core/offline_ctrl.cpp
deleted file mode 100644
index b7d5eef..0000000
--- a/displayengine/libs/core/offline_ctrl.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/constants.h>
-#include <utils/debug.h>
-
-#include "offline_ctrl.h"
-#include "hw_rotator_interface.h"
-#include <core/buffer_sync_handler.h>
-#include "hw_interface.h"
-
-#define __CLASS__ "OfflineCtrl"
-
-namespace sde {
-
-// TODO(user): Move this offline controller under composition manager like other modules
-// [resource manager]. Implement session management and buffer management in offline controller.
-OfflineCtrl::OfflineCtrl() : hw_rotator_intf_(NULL), hw_rotator_present_(false) {
-}
-
-DisplayError OfflineCtrl::Init(BufferSyncHandler *buffer_sync_handler) {
- DisplayError error = kErrorNone;
-
- error = HWRotatorInterface::Create(&hw_rotator_intf_, buffer_sync_handler);
- if (error != kErrorNone) {
- if (hw_rotator_intf_) {
- HWRotatorInterface::Destroy(hw_rotator_intf_);
- }
- return error;
- }
-
- error = hw_rotator_intf_->Open();
- if (error != kErrorNone) {
- DLOGW("Failed to open rotator device");
- } else {
- hw_rotator_present_ = true;
- }
-
- return kErrorNone;
-}
-
-DisplayError OfflineCtrl::Deinit() {
- DisplayError error = kErrorNone;
-
- error = hw_rotator_intf_->Close();
- if (error != kErrorNone) {
- DLOGW("Failed to close rotator device");
- return error;
- }
- hw_rotator_present_ = false;
- HWRotatorInterface::Destroy(hw_rotator_intf_);
-
- return kErrorNone;
-}
-
-DisplayError OfflineCtrl::RegisterDisplay(DisplayType type, Handle *display_ctx) {
- DisplayOfflineContext *disp_offline_ctx = new DisplayOfflineContext();
- if (disp_offline_ctx == NULL) {
- return kErrorMemory;
- }
-
- disp_offline_ctx->display_type = type;
- *display_ctx = disp_offline_ctx;
-
- return kErrorNone;
-}
-
-void OfflineCtrl::UnregisterDisplay(Handle display_ctx) {
- DisplayOfflineContext *disp_offline_ctx = reinterpret_cast<DisplayOfflineContext *>(display_ctx);
-
- delete disp_offline_ctx;
- disp_offline_ctx = NULL;
-}
-
-
-DisplayError OfflineCtrl::Prepare(Handle display_ctx, HWLayers *hw_layers) {
- DisplayError error = kErrorNone;
-
- DisplayOfflineContext *disp_offline_ctx = reinterpret_cast<DisplayOfflineContext *>(display_ctx);
-
- disp_offline_ctx->pending_rot_commit = false;
-
- if (!hw_rotator_present_ && IsRotationRequired(hw_layers)) {
- DLOGV_IF(kTagOfflineCtrl, "No Rotator device found");
- return kErrorHardware;
- }
-
- error = CloseRotatorSession(hw_layers);
- if (error != kErrorNone) {
- DLOGE("Close rotator session failed for display %d", disp_offline_ctx->display_type);
- return error;
- }
-
-
- if (IsRotationRequired(hw_layers)) {
- error = OpenRotatorSession(hw_layers);
- if (error != kErrorNone) {
- DLOGE("Open rotator session failed for display %d", disp_offline_ctx->display_type);
- return error;
- }
-
- error = hw_rotator_intf_->Validate(hw_layers);
- if (error != kErrorNone) {
- DLOGE("Rotator validation failed for display %d", disp_offline_ctx->display_type);
- return error;
- }
- disp_offline_ctx->pending_rot_commit = true;
- }
-
- return kErrorNone;
-}
-
-DisplayError OfflineCtrl::Commit(Handle display_ctx, HWLayers *hw_layers) {
- DisplayError error = kErrorNone;
-
- DisplayOfflineContext *disp_offline_ctx = reinterpret_cast<DisplayOfflineContext *>(display_ctx);
-
- if (disp_offline_ctx->pending_rot_commit) {
- error = hw_rotator_intf_->Commit(hw_layers);
- if (error != kErrorNone) {
- DLOGE("Rotator commit failed for display %d", disp_offline_ctx->display_type);
- return error;
- }
- disp_offline_ctx->pending_rot_commit = false;
- }
-
- return kErrorNone;
-}
-
-DisplayError OfflineCtrl::OpenRotatorSession(HWLayers *hw_layers) {
- HWLayersInfo &hw_layer_info = hw_layers->info;
- DisplayError error = kErrorNone;
-
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer& layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
- bool rot90 = (layer.transform.rotation == 90.0f);
-
- for (uint32_t count = 0; count < 2; count++) {
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
- HWBufferInfo *rot_buf_info = &rotate_info->hw_buffer_info;
-
- if (!rotate_info->valid || rot_buf_info->session_id >= 0) {
- continue;
- }
-
- rotate_info->input_buffer = layer.input_buffer;
- rotate_info->frame_rate = layer.frame_rate;
-
- error = hw_rotator_intf_->OpenSession(rotate_info);
- if (error != kErrorNone) {
- return error;
- }
- }
- }
-
- return kErrorNone;
-}
-
-DisplayError OfflineCtrl::CloseRotatorSession(HWLayers *hw_layers) {
- DisplayError error = kErrorNone;
- uint32_t i = 0;
-
- while (hw_layers->closed_session_ids[i] >= 0) {
- error = hw_rotator_intf_->CloseSession(hw_layers->closed_session_ids[i]);
- if (error != kErrorNone) {
- return error;
- }
- hw_layers->closed_session_ids[i++] = -1;
- }
-
- return kErrorNone;
-}
-
-bool OfflineCtrl::IsRotationRequired(HWLayers *hw_layers) {
- HWLayersInfo &layer_info = hw_layers->info;
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer& layer = layer_info.stack->layers[layer_info.index[i]];
-
- HWRotateInfo *rotate = &hw_layers->config[i].rotates[0];
- if (rotate->valid) {
- return true;
- }
-
- rotate = &hw_layers->config[i].rotates[1];
- if (rotate->valid) {
- return true;
- }
- }
- return false;
-}
-
-} // namespace sde
-
diff --git a/displayengine/libs/core/offline_ctrl.h b/displayengine/libs/core/offline_ctrl.h
deleted file mode 100644
index 1525bb8..0000000
--- a/displayengine/libs/core/offline_ctrl.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __OFFLINE_CTRL_H__
-#define __OFFLINE_CTRL_H__
-
-#include <utils/locker.h>
-#include <utils/debug.h>
-#include <core/display_interface.h>
-
-namespace sde {
-
-class HWRotatorInterface;
-class BufferSyncHandler;
-struct HWLayers;
-
-class OfflineCtrl {
- public:
- OfflineCtrl();
- DisplayError Init(BufferSyncHandler *buffer_sync_handler);
- DisplayError Deinit();
- DisplayError RegisterDisplay(DisplayType type, Handle *display_ctx);
- void UnregisterDisplay(Handle display_ctx);
- DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers);
- DisplayError Commit(Handle display_ctx, HWLayers *hw_layers);
-
- private:
- struct DisplayOfflineContext {
- DisplayType display_type;
- bool pending_rot_commit;
-
- DisplayOfflineContext() : display_type(kPrimary), pending_rot_commit(false) { }
- };
-
- DisplayError OpenRotatorSession(HWLayers *hw_layers);
- DisplayError CloseRotatorSession(HWLayers *hw_layers);
- bool IsRotationRequired(HWLayers *hw_layers);
-
- HWRotatorInterface *hw_rotator_intf_;
- bool hw_rotator_present_;
-};
-
-} // namespace sde
-
-#endif // __OFFLINE_CTRL_H__
-
diff --git a/displayengine/libs/core/res_config.cpp b/displayengine/libs/core/res_config.cpp
deleted file mode 100644
index ecd8ef1..0000000
--- a/displayengine/libs/core/res_config.cpp
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <math.h>
-#include <utils/constants.h>
-#include <utils/debug.h>
-#include <utils/rect.h>
-
-#include "res_manager.h"
-
-#define __CLASS__ "ResManager"
-
-namespace sde {
-
-static void GetAlignFactor(const LayerBufferFormat &format, uint32_t *align_x, uint32_t *align_y) {
- *align_x = 1;
- *align_y = 1;
- if (!IS_RGB_FORMAT(format)) {
- *align_x = 2;
- *align_y = 2;
- }
-}
-
-void ResManager::RotationConfig(const Layer &layer, const float &downscale, LayerRect *src_rect,
- struct HWLayerConfig *layer_config, uint32_t *rotate_count) {
- HWRotateInfo *rotate = &layer_config->rotates[0];
- float src_width = src_rect->right - src_rect->left;
- float src_height = src_rect->bottom - src_rect->top;
- bool rot90 = IsRotationNeeded(layer.transform.rotation);
- bool is_opaque = (layer.blending == kBlendingOpaque);
- LayerRect dst_rect;
- // Rotate output is a temp buffer, always output to the top left corner for saving memory
- dst_rect.top = 0.0f;
- dst_rect.left = 0.0f;
-
- rotate->downscale_ratio = downscale;
- uint32_t align_x, align_y;
- GetAlignFactor(layer.input_buffer->format, &align_x, &align_y);
-
- // downscale when doing rotation
- if (rot90) {
- if (downscale > 1.0f) {
- src_height = ROUND_UP_ALIGN_DOWN(src_height, downscale * FLOAT(align_x));
- src_rect->bottom = src_rect->top + src_height;
- src_width = ROUND_UP_ALIGN_DOWN(src_width, downscale * FLOAT(align_y));
- src_rect->right = src_rect->left + src_width;
- }
- dst_rect.right = src_height / downscale;
- dst_rect.bottom = src_width / downscale;
- } else {
- if (downscale > 1.0f) {
- src_width = ROUND_UP_ALIGN_DOWN(src_width, downscale * FLOAT(align_x));
- src_rect->right = src_rect->left + src_width;
- src_height = ROUND_UP_ALIGN_DOWN(src_height, downscale * FLOAT(align_y));
- src_rect->bottom = src_rect->top + src_height;
- }
- dst_rect.right = src_width / downscale;
- dst_rect.bottom = src_height / downscale;
- }
-
- rotate->src_roi = *src_rect;
- rotate->valid = true;
- rotate->dst_roi = dst_rect;
-
- // Set WHF for Rotator output
- LayerBufferFormat output_format;
- SetRotatorOutputFormat(layer.input_buffer->format, is_opaque, rot90, (downscale > 1.0f),
- &output_format);
- HWBufferInfo *hw_buffer_info = &rotate->hw_buffer_info;
- hw_buffer_info->buffer_config.format = output_format;
- hw_buffer_info->buffer_config.width = UINT32(rotate->dst_roi.right);
- hw_buffer_info->buffer_config.height = UINT32(rotate->dst_roi.bottom);
-
- *src_rect = dst_rect;
- layer_config->num_rotate = 1;
- (*rotate_count)++;
-}
-
-DisplayError ResManager::SrcSplitConfig(DisplayResourceContext *display_resource_ctx,
- const LayerTransform &transform, const LayerRect &src_rect,
- const LayerRect &dst_rect, HWLayerConfig *layer_config,
- uint32_t align_x) {
- HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
- HWPipeInfo *left_pipe = &layer_config->left_pipe;
- HWPipeInfo *right_pipe = &layer_config->right_pipe;
- float src_width = src_rect.right - src_rect.left;
- float dst_width = dst_rect.right - dst_rect.left;
- float src_height = src_rect.bottom - src_rect.top;
- float dst_height = dst_rect.bottom - dst_rect.top;
- float left_mixer_width = FLOAT(display_attributes.split_left);
-
- uint8_t decimation = 0;
- if (CalculateDecimation((src_height / dst_height), &decimation) != kErrorNone) {
- return kErrorNotSupported;
- }
- // Adjust source height to consider decimation
- src_height /= powf(2.0f, decimation);
-
- // No need to include common factors in clock calculation of pipe & mixer
- float pipe_clock = MAX(dst_width, (dst_width * src_height / dst_height));
- float mixer_clock = left_mixer_width;
-
- // Layer cannot qualify for SrcSplit if source or destination width exceeds max pipe width.
- // For perf/power optimization, even if "always_src_split" is enabled, use 2 pipes only if:
- // 1. Source width is greater than split_left (left_mixer_width)
- // 2. Pipe clock exceeds the mixer clock
- if ((src_width > kMaxSourcePipeWidth) || (dst_width > kMaxSourcePipeWidth) ||
- (display_resource_ctx->display_attributes.always_src_split &&
- ((src_width > left_mixer_width) || (pipe_clock > mixer_clock)))) {
- SplitRect(transform.flip_horizontal, src_rect, dst_rect, &left_pipe->src_roi,
- &left_pipe->dst_roi, &right_pipe->src_roi, &right_pipe->dst_roi, align_x);
- left_pipe->valid = true;
- right_pipe->valid = true;
- } else {
- left_pipe->src_roi = src_rect;
- left_pipe->dst_roi = dst_rect;
- left_pipe->valid = true;
- right_pipe->Reset();
- }
-
- return kErrorNone;
-}
-
-DisplayError ResManager::DisplaySplitConfig(DisplayResourceContext *display_resource_ctx,
- const LayerTransform &transform,
- const LayerRect &src_rect, const LayerRect &dst_rect,
- HWLayerConfig *layer_config, uint32_t align_x) {
- LayerRect scissor_dst_left, scissor_dst_right;
- HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
-
- // for display split case
- HWPipeInfo *left_pipe = &layer_config->left_pipe;
- HWPipeInfo *right_pipe = &layer_config->right_pipe;
- LayerRect scissor, dst_left, crop_left, crop_right, dst_right;
- scissor.right = FLOAT(display_attributes.split_left);
- scissor.bottom = FLOAT(display_attributes.y_pixels);
-
- crop_left = src_rect;
- dst_left = dst_rect;
- crop_right = crop_left;
- dst_right = dst_left;
- bool crop_left_valid = CalculateCropRects(scissor, transform, &crop_left, &dst_left);
-
- scissor.left = FLOAT(display_attributes.split_left);
- scissor.top = 0.0f;
- scissor.right = FLOAT(display_attributes.x_pixels);
- scissor.bottom = FLOAT(display_attributes.y_pixels);
- bool crop_right_valid = false;
-
- if (IsValid(scissor)) {
- crop_right_valid = CalculateCropRects(scissor, transform, &crop_right, &dst_right);
- }
-
- if (crop_left_valid && (crop_left.right - crop_left.left) > kMaxSourcePipeWidth) {
- if (crop_right_valid) {
- DLOGV_IF(kTagResources, "Need more than 2 pipes: left width = %.0f, right width = %.0f",
- crop_left.right - crop_left.left, crop_right.right - crop_right.left);
- return kErrorNotSupported;
- }
- // 2 pipes both are on the left
- SplitRect(transform.flip_horizontal, crop_left, dst_left, &left_pipe->src_roi,
- &left_pipe->dst_roi, &right_pipe->src_roi, &right_pipe->dst_roi, align_x);
- left_pipe->valid = true;
- right_pipe->valid = true;
- crop_right_valid = true;
- } else if (crop_right_valid && (crop_right.right - crop_right.left) > kMaxSourcePipeWidth) {
- if (crop_left_valid) {
- DLOGV_IF(kTagResources, "Need more than 2 pipes: left width = %.0f, right width = %.0f",
- crop_left.right - crop_left.left, crop_right.right - crop_right.left);
- return kErrorNotSupported;
- }
- // 2 pipes both are on the right
- SplitRect(transform.flip_horizontal, crop_right, dst_right, &left_pipe->src_roi,
- &left_pipe->dst_roi, &right_pipe->src_roi, &right_pipe->dst_roi, align_x);
- left_pipe->valid = true;
- right_pipe->valid = true;
- crop_left_valid = true;
- } else if (crop_left_valid) {
- // assign left pipe
- left_pipe->src_roi = crop_left;
- left_pipe->dst_roi = dst_left;
- left_pipe->valid = true;
- } else {
- // Set default value, left_pipe is not needed.
- left_pipe->Reset();
- }
-
- // assign right pipe if needed
- if (crop_right_valid) {
- if (left_pipe->valid) {
- right_pipe->src_roi = crop_right;
- right_pipe->dst_roi = dst_right;
- right_pipe->valid = true;
- } else {
- // If left pipe is not used, use left pipe first.
- left_pipe->src_roi = crop_right;
- left_pipe->dst_roi = dst_right;
- left_pipe->valid = true;
- right_pipe->Reset();
- }
- } else {
- // need not right pipe
- right_pipe->Reset();
- }
-
- return kErrorNone;
-}
-
-DisplayError ResManager::Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers,
- uint32_t *rotate_count) {
- HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
- HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
- HWLayersInfo &layer_info = hw_layers->info;
- DisplayError error = kErrorNone;
- uint32_t z_order = 0;
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer& layer = layer_info.stack->layers[layer_info.index[i]];
- float rot_scale = 1.0f;
- if (!IsValidDimension(layer.src_rect, layer.dst_rect)) {
- DLOGV_IF(kTagResources, "Input is invalid");
- Log(kTagResources, "input layer src_rect", layer.src_rect);
- Log(kTagResources, "input layer dst_rect", layer.dst_rect);
- return kErrorNotSupported;
- }
-
- LayerRect scissor, src_rect, dst_rect;
- src_rect = layer.src_rect;
- dst_rect = layer.dst_rect;
- scissor.right = FLOAT(display_attributes.x_pixels);
- scissor.bottom = FLOAT(display_attributes.y_pixels);
-
- struct HWLayerConfig *layer_config = &hw_layers->config[i];
- HWPipeInfo &left_pipe = layer_config->left_pipe;
- HWPipeInfo &right_pipe = layer_config->right_pipe;
-
- if (!CalculateCropRects(scissor, layer.transform, &src_rect, &dst_rect)) {
- layer_config->Reset();
- left_pipe.Reset();
- right_pipe.Reset();
- continue;
- }
-
- uint32_t align_x, align_y;
- GetAlignFactor(layer.input_buffer->format, &align_x, &align_y);
- if (align_x > 1 || align_y > 1) {
- Normalize(align_x, align_y, &src_rect);
- }
-
- if (ValidateScaling(layer, src_rect, dst_rect, &rot_scale)) {
- return kErrorNotSupported;
- }
-
- // config rotator first
- for (uint32_t j = 0; j < kMaxRotatePerLayer; j++) {
- layer_config->rotates[j].Reset();
- }
- layer_config->num_rotate = 0;
-
- LayerTransform transform = layer.transform;
- if (IsRotationNeeded(transform.rotation) || UINT32(rot_scale) != 1) {
- RotationConfig(layer, rot_scale, &src_rect, layer_config, rotate_count);
- // rotator will take care of flipping, reset tranform
- transform = LayerTransform();
- }
-
- if (hw_res_info_.is_src_split) {
- error = SrcSplitConfig(display_resource_ctx, transform, src_rect,
- dst_rect, layer_config, align_x);
- } else {
- error = DisplaySplitConfig(display_resource_ctx, transform, src_rect,
- dst_rect, layer_config, align_x);
- }
-
- if (error != kErrorNone) {
- break;
- }
-
- error = AlignPipeConfig(layer, transform, &left_pipe, &right_pipe, align_x, align_y);
- if (error != kErrorNone) {
- break;
- }
-
- DLOGV_IF(kTagResources, "==== layer = %d, left pipe valid = %d ====",
- i, layer_config->left_pipe.valid);
- Log(kTagResources, "input layer src_rect", layer.src_rect);
- Log(kTagResources, "input layer dst_rect", layer.dst_rect);
- for (uint32_t k = 0; k < layer_config->num_rotate; k++) {
- DLOGV_IF(kTagResources, "rotate num = %d, scale_x = %.2f", k, rot_scale);
- Log(kTagResources, "rotate src", layer_config->rotates[k].src_roi);
- Log(kTagResources, "rotate dst", layer_config->rotates[k].dst_roi);
- }
-
- Log(kTagResources, "cropped src_rect", src_rect);
- Log(kTagResources, "cropped dst_rect", dst_rect);
- Log(kTagResources, "left pipe src", layer_config->left_pipe.src_roi);
- Log(kTagResources, "left pipe dst", layer_config->left_pipe.dst_roi);
- if (hw_layers->config[i].right_pipe.valid) {
- Log(kTagResources, "right pipe src", layer_config->right_pipe.src_roi);
- Log(kTagResources, "right pipe dst", layer_config->right_pipe.dst_roi);
- }
- // set z_order, left_pipe should always be valid
- left_pipe.z_order = z_order;
- if (layer_config->right_pipe.valid) {
- // use different z_order if 2 pipes are on one mixer and without src split support
- if (!hw_res_info_.is_src_split &&
- ((left_pipe.dst_roi.right <= display_attributes.split_left &&
- right_pipe.dst_roi.right <= display_attributes.split_left) ||
- (left_pipe.dst_roi.left >= display_attributes.split_left &&
- right_pipe.dst_roi.left >= display_attributes.split_left))) {
- z_order++;
- }
- layer_config->right_pipe.z_order = z_order;
- }
- z_order++;
- if (z_order > display_resource_ctx->max_mixer_stages) {
- DLOGV_IF(kTagResources, "z_order is over the limit of max_mixer_stages = %d",
- display_resource_ctx->max_mixer_stages);
- return kErrorResources;
- }
- }
-
- return error;
-}
-
-DisplayError ResManager::ValidateScaling(const Layer &layer, const LayerRect &crop,
- const LayerRect &dst, float *rot_scale) {
- bool rotated90 = IsRotationNeeded(layer.transform.rotation) && (rot_scale != NULL);
- float crop_width = rotated90 ? crop.bottom - crop.top : crop.right - crop.left;
- float crop_height = rotated90 ? crop.right - crop.left : crop.bottom - crop.top;
- float dst_width = dst.right - dst.left;
- float dst_height = dst.bottom - dst.top;
-
- if ((dst_width < 1.0f) || (dst_height < 1.0f)) {
- DLOGV_IF(kTagResources, "dst ROI is too small w = %.0f, h = %.0f, right = %.0f, bottom = %.0f",
- dst_width, dst_height, dst.right, dst.bottom);
- return kErrorNotSupported;
- }
-
- if ((crop_width < 1.0f) || (crop_height < 1.0f)) {
- DLOGV_IF(kTagResources, "src ROI is too small w = %.0f, h = %.0f, right = %.0f, bottom = %.0f",
- crop_width, crop_height, crop.right, crop.bottom);
- return kErrorNotSupported;
- }
-
- if ((UINT32(crop_width - dst_width) == 1) || (UINT32(crop_height - dst_height) == 1)) {
- DLOGV_IF(kTagResources, "One pixel downscaling detected crop_w = %.0f, dst_w = %.0f, " \
- "crop_h = %.0f, dst_h = %.0f", crop_width, dst_width, crop_height, dst_height);
- return kErrorNotSupported;
- }
-
- float scale_x = crop_width / dst_width;
- float scale_y = crop_height / dst_height;
- uint32_t rot_scale_local = 1;
-
- if ((UINT32(scale_x) > 1) || (UINT32(scale_y) > 1)) {
- float max_scale_down = FLOAT(hw_res_info_.max_scale_down);
-
- if (hw_res_info_.has_rotator_downscale && !property_setting_.disable_rotator_downscaling &&
- rot_scale && !IsMacroTileFormat(layer.input_buffer)) {
- float scale_min = MIN(scale_x, scale_y);
- float scale_max = MAX(scale_x, scale_y);
- // use rotator to downscale when over the pipe scaling ability
- if (UINT32(scale_min) >= 2 && scale_max > max_scale_down) {
- // downscaling ratio needs be the same for both direction, use the smaller one.
- rot_scale_local = 1 << UINT32(ceilf(log2f(scale_min / max_scale_down)));
- if (rot_scale_local > kMaxRotateDownScaleRatio)
- rot_scale_local = kMaxRotateDownScaleRatio;
- scale_x /= FLOAT(rot_scale_local);
- scale_y /= FLOAT(rot_scale_local);
- }
- *rot_scale = FLOAT(rot_scale_local);
- }
-
- if (hw_res_info_.has_decimation && !property_setting_.disable_decimation &&
- !IsMacroTileFormat(layer.input_buffer)) {
- max_scale_down *= FLOAT(kMaxDecimationDownScaleRatio);
- }
-
- if (scale_x > max_scale_down || scale_y > max_scale_down) {
- DLOGV_IF(kTagResources,
- "Scaling down is over the limit: is_tile = %d, scale_x = %.0f, scale_y = %.0f, " \
- "crop_w = %.0f, dst_w = %.0f, has_deci = %d, disable_deci = %d, rot_scale = %d",
- IsMacroTileFormat(layer.input_buffer), scale_x, scale_y, crop_width, dst_width,
- hw_res_info_.has_decimation, property_setting_.disable_decimation, rot_scale_local);
- return kErrorNotSupported;
- }
- }
-
- float max_scale_up = FLOAT(hw_res_info_.max_scale_up);
- if (UINT32(scale_x) < 1 && scale_x > 0.0f) {
- if ((1.0f / scale_x) > max_scale_up) {
- DLOGV_IF(kTagResources, "Scaling up is over limit scale_x = %f", 1.0f / scale_x);
- return kErrorNotSupported;
- }
- }
-
- if (UINT32(scale_y) < 1 && scale_y > 0.0f) {
- if ((1.0f / scale_y) > max_scale_up) {
- DLOGV_IF(kTagResources, "Scaling up is over limit scale_y = %f", 1.0f / scale_y);
- return kErrorNotSupported;
- }
- }
-
- DLOGV_IF(kTagResources, "scale_x = %.4f, scale_y = %.4f, rot_scale = %d",
- scale_x, scale_y, rot_scale_local);
-
- return kErrorNone;
-}
-
-void ResManager::CalculateCut(const LayerTransform &transform, float *left_cut_ratio,
- float *top_cut_ratio, float *right_cut_ratio,
- float *bottom_cut_ratio) {
- if (transform.flip_horizontal) {
- Swap(*left_cut_ratio, *right_cut_ratio);
- }
-
- if (transform.flip_vertical) {
- Swap(*top_cut_ratio, *bottom_cut_ratio);
- }
-
- if (IsRotationNeeded(transform.rotation)) {
- // Anti clock swapping
- float tmp_cut_ratio = *left_cut_ratio;
- *left_cut_ratio = *top_cut_ratio;
- *top_cut_ratio = *right_cut_ratio;
- *right_cut_ratio = *bottom_cut_ratio;
- *bottom_cut_ratio = tmp_cut_ratio;
- }
-}
-
-bool ResManager::CalculateCropRects(const LayerRect &scissor, const LayerTransform &transform,
- LayerRect *crop, LayerRect *dst) {
- float &crop_left = crop->left;
- float &crop_top = crop->top;
- float &crop_right = crop->right;
- float &crop_bottom = crop->bottom;
- float crop_width = crop->right - crop->left;
- float crop_height = crop->bottom - crop->top;
-
- float &dst_left = dst->left;
- float &dst_top = dst->top;
- float &dst_right = dst->right;
- float &dst_bottom = dst->bottom;
- float dst_width = dst->right - dst->left;
- float dst_height = dst->bottom - dst->top;
-
- const float &sci_left = scissor.left;
- const float &sci_top = scissor.top;
- const float &sci_right = scissor.right;
- const float &sci_bottom = scissor.bottom;
-
- float left_cut_ratio = 0.0, right_cut_ratio = 0.0, top_cut_ratio = 0.0, bottom_cut_ratio = 0.0;
- bool need_cut = false;
-
- if (dst_left < sci_left) {
- left_cut_ratio = (sci_left - dst_left) / dst_width;
- dst_left = sci_left;
- need_cut = true;
- }
-
- if (dst_right > sci_right) {
- right_cut_ratio = (dst_right - sci_right) / dst_width;
- dst_right = sci_right;
- need_cut = true;
- }
-
- if (dst_top < sci_top) {
- top_cut_ratio = (sci_top - dst_top) / (dst_height);
- dst_top = sci_top;
- need_cut = true;
- }
-
- if (dst_bottom > sci_bottom) {
- bottom_cut_ratio = (dst_bottom - sci_bottom) / (dst_height);
- dst_bottom = sci_bottom;
- need_cut = true;
- }
-
- if (!need_cut)
- return true;
-
- CalculateCut(transform, &left_cut_ratio, &top_cut_ratio, &right_cut_ratio, &bottom_cut_ratio);
-
- crop_left += crop_width * left_cut_ratio;
- crop_top += crop_height * top_cut_ratio;
- crop_right -= crop_width * right_cut_ratio;
- crop_bottom -= crop_height * bottom_cut_ratio;
- Normalize(1, 1, crop);
- Normalize(1, 1, dst);
- if (IsValid(*crop) && IsValid(*dst))
- return true;
- else
- return false;
-}
-
-bool ResManager::IsValidDimension(const LayerRect &src, const LayerRect &dst) {
- // Make sure source in integral
- if (src.left - roundf(src.left) ||
- src.top - roundf(src.top) ||
- src.right - roundf(src.right) ||
- src.bottom - roundf(src.bottom)) {
- DLOGV_IF(kTagResources, "Input ROI is not integral");
- return false;
- }
-
- if (src.left > src.right || src.top > src.bottom || dst.left > dst.right ||
- dst.top > dst.bottom) {
- return false;
- } else {
- return true;
- }
-}
-
-DisplayError ResManager::SetDecimationFactor(HWPipeInfo *pipe) {
- float src_h = pipe->src_roi.bottom - pipe->src_roi.top;
- float dst_h = pipe->dst_roi.bottom - pipe->dst_roi.top;
- float down_scale_h = src_h / dst_h;
-
- float src_w = pipe->src_roi.right - pipe->src_roi.left;
- float dst_w = pipe->dst_roi.right - pipe->dst_roi.left;
- float down_scale_w = src_w / dst_w;
-
- pipe->horizontal_decimation = 0;
- pipe->vertical_decimation = 0;
-
- if (CalculateDecimation(down_scale_w, &pipe->horizontal_decimation) != kErrorNone) {
- return kErrorNotSupported;
- }
-
- if (CalculateDecimation(down_scale_h, &pipe->vertical_decimation) != kErrorNone) {
- return kErrorNotSupported;
- }
-
- DLOGI_IF(kTagResources, "horizontal_decimation %d, vertical_decimation %d",
- pipe->horizontal_decimation, pipe->vertical_decimation);
-
- return kErrorNone;
-}
-
-void ResManager::SplitRect(bool flip_horizontal, const LayerRect &src_rect,
- const LayerRect &dst_rect, LayerRect *src_left, LayerRect *dst_left,
- LayerRect *src_right, LayerRect *dst_right, uint32_t align_x) {
- // Split rectangle horizontally and evenly into two.
- float src_width = src_rect.right - src_rect.left;
- float dst_width = dst_rect.right - dst_rect.left;
- float src_width_ori = src_width;
- src_width = ROUND_UP_ALIGN_DOWN(src_width / 2, align_x);
- dst_width = ROUND_UP_ALIGN_DOWN(dst_width * src_width / src_width_ori, 1);
-
- if (flip_horizontal) {
- src_left->left = src_rect.right - src_width;
- src_left->right = src_rect.right;
-
- src_right->left = src_rect.left;
- src_right->right = src_left->left;
- } else {
- src_left->left = src_rect.left;
- src_left->right = src_rect.left + src_width;
-
- src_right->left = src_left->right;
- src_right->right = src_rect.right;
- }
-
- src_left->top = src_rect.top;
- src_left->bottom = src_rect.bottom;
- dst_left->top = dst_rect.top;
- dst_left->bottom = dst_rect.bottom;
-
- src_right->top = src_rect.top;
- src_right->bottom = src_rect.bottom;
- dst_right->top = dst_rect.top;
- dst_right->bottom = dst_rect.bottom;
-
- dst_left->left = dst_rect.left;
- dst_left->right = dst_rect.left + dst_width;
- dst_right->left = dst_left->right;
- dst_right->right = dst_rect.right;
-}
-
-DisplayError ResManager::AlignPipeConfig(const Layer &layer, const LayerTransform &transform,
- HWPipeInfo *left_pipe, HWPipeInfo *right_pipe,
- uint32_t align_x, uint32_t align_y) {
- DisplayError error = kErrorNone;
- if (!left_pipe->valid) {
- DLOGE_IF(kTagResources, "left_pipe should not be invalid");
- return kErrorNotSupported;
- }
- // 1. Normalize video layer source rectangle to multiple of 2, as MDP hardware require source
- // rectangle of video layer to be even.
- // 2. Normalize source and destination rect of a layer to multiple of 1.
- // TODO(user) Check buffer format and check if rotate is involved.
-
- Normalize(align_x, align_y, &left_pipe->src_roi);
- Normalize(1, 1, &left_pipe->dst_roi);
-
- if (right_pipe->valid) {
- Normalize(align_x, align_y, &right_pipe->src_roi);
- Normalize(1, 1, &right_pipe->dst_roi);
- }
-
- if (right_pipe->valid) {
- // Make sure the left and right ROI are conjunct
- if (transform.flip_horizontal) {
- left_pipe->src_roi.left = right_pipe->src_roi.right;
- } else {
- right_pipe->src_roi.left = left_pipe->src_roi.right;
- }
- right_pipe->dst_roi.left = left_pipe->dst_roi.right;
- }
- error = ValidateScaling(layer, left_pipe->src_roi, left_pipe->dst_roi, NULL);
- if (error != kErrorNone) {
- goto PipeConfigExit;
- }
-
- if (right_pipe->valid) {
- error = ValidateScaling(layer, right_pipe->src_roi, right_pipe->dst_roi, NULL);
- }
-PipeConfigExit:
- if (error != kErrorNone) {
- DLOGV_IF(kTagResources, "AlignPipeConfig failed");
- }
- return error;
-}
-
-DisplayError ResManager::CalculateDecimation(float downscale, uint8_t *decimation) {
- float max_down_scale = FLOAT(hw_res_info_.max_scale_down);
-
- if (downscale <= max_down_scale) {
- *decimation = 0;
- return kErrorNone;
- } else if (!hw_res_info_.has_decimation) {
- DLOGE("Downscaling exceeds the maximum MDP downscale limit but decimation not enabled");
- return kErrorNotSupported;
- }
-
- // Decimation is the remaining downscale factor after doing max SDE downscale.
- // In SDE, decimation is supported in powers of 2.
- // For ex: If a pipe needs downscale of 8 but max_down_scale is 4
- // So decimation = powf(2.0, ceilf(log2f(8 / 4))) = powf(2.0, 1.0) = 2
- *decimation = UINT8(ceilf(log2f(downscale / max_down_scale)));
- return kErrorNone;
-}
-
-} // namespace sde
diff --git a/displayengine/libs/core/res_manager.cpp b/displayengine/libs/core/res_manager.cpp
deleted file mode 100644
index 4101fc8..0000000
--- a/displayengine/libs/core/res_manager.cpp
+++ /dev/null
@@ -1,1213 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <math.h>
-#include <utils/constants.h>
-#include <utils/debug.h>
-#include <dlfcn.h>
-
-#include "res_manager.h"
-#include "scalar_helper.h"
-
-#define __CLASS__ "ResManager"
-
-namespace sde {
-
-ResManager::ResManager()
- : num_pipe_(0), vig_pipes_(NULL), rgb_pipes_(NULL), dma_pipes_(NULL), virtual_count_(0),
- buffer_allocator_(NULL), buffer_sync_handler_(NULL) {
-}
-
-DisplayError ResManager::Init(const HWResourceInfo &hw_res_info, BufferAllocator *buffer_allocator,
- BufferSyncHandler *buffer_sync_handler) {
- hw_res_info_ = hw_res_info;
-
- buffer_sync_handler_ = buffer_sync_handler;
-
- if (!hw_res_info_.max_mixer_width)
- hw_res_info_.max_mixer_width = kMaxSourcePipeWidth;
-
- buffer_allocator_ = buffer_allocator;
-
- buffer_sync_handler_ = buffer_sync_handler;
-
- DisplayError error = kErrorNone;
-
- num_pipe_ = hw_res_info_.num_vig_pipe + hw_res_info_.num_rgb_pipe + hw_res_info_.num_dma_pipe;
-
- if (num_pipe_ > kPipeIdMax) {
- DLOGE("Number of pipe is over the limit! %d", num_pipe_);
- return kErrorParameters;
- }
-
- // Init pipe info
- vig_pipes_ = &src_pipes_[0];
- rgb_pipes_ = &src_pipes_[hw_res_info_.num_vig_pipe];
- dma_pipes_ = &src_pipes_[hw_res_info_.num_vig_pipe + hw_res_info_.num_rgb_pipe];
-
- for (uint32_t i = 0; i < hw_res_info_.num_vig_pipe; i++) {
- vig_pipes_[i].type = kPipeTypeVIG;
- vig_pipes_[i].index = i;
- vig_pipes_[i].mdss_pipe_id = GetMdssPipeId(vig_pipes_[i].type, i);
- }
-
- for (uint32_t i = 0; i < hw_res_info_.num_rgb_pipe; i++) {
- rgb_pipes_[i].type = kPipeTypeRGB;
- rgb_pipes_[i].index = i + hw_res_info_.num_vig_pipe;
- rgb_pipes_[i].mdss_pipe_id = GetMdssPipeId(rgb_pipes_[i].type, i);
- }
-
- for (uint32_t i = 0; i < hw_res_info_.num_dma_pipe; i++) {
- dma_pipes_[i].type = kPipeTypeDMA;
- dma_pipes_[i].index = i + hw_res_info_.num_vig_pipe + hw_res_info_.num_rgb_pipe;
- dma_pipes_[i].mdss_pipe_id = GetMdssPipeId(dma_pipes_[i].type, i);
- }
-
- for (uint32_t i = 0; i < num_pipe_; i++) {
- src_pipes_[i].priority = i;
- }
-
- DLOGI("hw_rev=%x, DMA=%d RGB=%d VIG=%d", hw_res_info_.hw_revision, hw_res_info_.num_dma_pipe,
- hw_res_info_.num_rgb_pipe, hw_res_info_.num_vig_pipe);
-
- // TODO(user): Need to get it from HW capability
- hw_res_info_.num_rotator = 2;
-
- if (hw_res_info_.num_rotator > kMaxNumRotator) {
- DLOGE("Number of rotator is over the limit! %d", hw_res_info_.num_rotator);
- hw_res_info_.num_rotator = kMaxNumRotator;
- }
-
- if (hw_res_info_.max_scale_down < 1 || hw_res_info_.max_scale_up < 1) {
- DLOGE("Max scaling setting is invalid! max_scale_down = %d, max_scale_up = %d",
- hw_res_info_.max_scale_down, hw_res_info_.max_scale_up);
- hw_res_info_.max_scale_down = 1;
- hw_res_info_.max_scale_up = 1;
- }
-
- if (hw_res_info_.num_rotator > 0) {
- rotators_[0].pipe_index = dma_pipes_[0].index;
- rotators_[0].writeback_id = kHWWriteback0;
- }
- if (hw_res_info_.num_rotator > 1) {
- rotators_[1].pipe_index = dma_pipes_[1].index;
- rotators_[1].writeback_id = kHWWriteback1;
- }
-
- // Used by splash screen
- rgb_pipes_[0].state = kPipeStateOwnedByKernel;
- rgb_pipes_[1].state = kPipeStateOwnedByKernel;
-
-#ifdef USES_SCALAR
- ScalarHelper::GetInstance()->Init();
-#endif
-
- max_system_bw_ = FLOAT(hw_res_info_.max_bandwidth_high);
- return kErrorNone;
-}
-
-DisplayError ResManager::Deinit() {
-#ifdef USES_SCALAR
- ScalarHelper::GetInstance()->Deinit();
-#endif
- return kErrorNone;
-}
-
-DisplayError ResManager::RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
- const HWPanelInfo &hw_panel_info, Handle *display_ctx) {
- DisplayError error = kErrorNone;
-
- HWBlockType hw_block_id = kHWBlockMax;
- switch (type) {
- case kPrimary:
- if (!hw_block_ctx_[kHWPrimary].is_in_use) {
- hw_block_id = kHWPrimary;
- }
- break;
-
- case kHDMI:
- if (!hw_block_ctx_[kHWHDMI].is_in_use) {
- hw_block_id = kHWHDMI;
- }
- break;
-
- case kVirtual:
- // TODO(user): read this block id from kernel
- virtual_count_++;
- hw_block_id = kHWWriteback2;
- break;
-
- default:
- DLOGW("RegisterDisplay, invalid type %d", type);
- return kErrorParameters;
- }
-
- if (hw_block_id == kHWBlockMax) {
- return kErrorResources;
- }
-
- DisplayResourceContext *display_resource_ctx = new DisplayResourceContext();
- if (!display_resource_ctx) {
- return kErrorMemory;
- }
-
- display_resource_ctx->hw_panel_info_ = hw_panel_info;
- display_resource_ctx->buffer_manager = new BufferManager(buffer_allocator_, buffer_sync_handler_);
- if (display_resource_ctx->buffer_manager == NULL) {
- delete display_resource_ctx;
- display_resource_ctx = NULL;
- return kErrorMemory;
- }
-
- hw_block_ctx_[hw_block_id].is_in_use = true;
-
- display_resource_ctx->display_attributes = attributes;
- display_resource_ctx->display_type = type;
- display_resource_ctx->hw_block_id = hw_block_id;
- if (!display_resource_ctx->display_attributes.is_device_split)
- display_resource_ctx->display_attributes.split_left =
- display_resource_ctx->display_attributes.x_pixels;
-
- display_resource_ctx->max_mixer_stages = hw_res_info_.num_blending_stages;
-
- *display_ctx = display_resource_ctx;
- return error;
-}
-
-DisplayError ResManager::UnregisterDisplay(Handle display_ctx) {
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
-
- if (display_resource_ctx->hw_block_id == kHWWriteback2) {
- virtual_count_--;
- if (!virtual_count_)
- hw_block_ctx_[display_resource_ctx->hw_block_id].is_in_use = false;
- } else {
- hw_block_ctx_[display_resource_ctx->hw_block_id].is_in_use = false;
- }
-
- if (!hw_block_ctx_[display_resource_ctx->hw_block_id].is_in_use)
- Purge(display_ctx);
-
- delete display_resource_ctx;
-
- return kErrorNone;
-}
-
-DisplayError ResManager::Start(Handle display_ctx) {
- locker_.Lock();
-
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
-
- if (display_resource_ctx->frame_start) {
- return kErrorNone; // keep context locked.
- }
-
- // First call in the cycle
- display_resource_ctx->frame_start = true;
- display_resource_ctx->frame_count++;
-
- // Release the pipes not used in the previous cycle
- HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if ((src_pipes_[i].hw_block_id == hw_block_id) &&
- (src_pipes_[i].state == kPipeStateToRelease)) {
- src_pipes_[i].state = kPipeStateIdle;
- }
- }
-
- // Clear rotator usage
- for (uint32_t i = 0; i < hw_res_info_.num_rotator; i++) {
- uint32_t pipe_index;
- pipe_index = rotators_[i].pipe_index;
- rotators_[i].ClearState(display_resource_ctx->hw_block_id);
- if (rotators_[i].client_bit_mask == 0 &&
- src_pipes_[pipe_index].state == kPipeStateToRelease &&
- src_pipes_[pipe_index].hw_block_id == rotators_[i].writeback_id) {
- src_pipes_[pipe_index].dedicated_hw_block = kHWBlockMax;
- src_pipes_[pipe_index].state = kPipeStateIdle;
- }
- }
-
- property_setting_.disable_rotator_downscaling = Debug::IsRotatorDownScaleDisabled();
- property_setting_.disable_decimation = Debug::IsDecimationDisabled();
-
- return kErrorNone;
-}
-
-DisplayError ResManager::Stop(Handle display_ctx) {
- locker_.Unlock();
-
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
-
- return kErrorNone;
-}
-
-DisplayError ResManager::Acquire(Handle display_ctx, HWLayers *hw_layers) {
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
-
- DisplayError error = kErrorNone;
- const struct HWLayersInfo &layer_info = hw_layers->info;
- HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
-
- DLOGV_IF(kTagResources, "==== Resource reserving start: hw_block = %d ====", hw_block_id);
-
- if (layer_info.count > num_pipe_) {
- DLOGV_IF(kTagResources, "layer count exceeds pipe limit of %d, layer count %d", num_pipe_,
- layer_info.count);
- return kErrorResources;
- }
-
- if (layer_info.count > display_resource_ctx->max_mixer_stages) {
- DLOGV_IF(kTagResources, "layer count exceeds max mixer stage limit of %d, layer count %d",
- display_resource_ctx->max_mixer_stages, layer_info.count);
- return kErrorResources;
- }
-
- uint32_t rotate_count = 0;
- error = Config(display_resource_ctx, hw_layers, &rotate_count);
- if (error != kErrorNone) {
- DLOGV_IF(kTagResources, "Resource config failed");
- return error;
- }
-
- uint32_t left_index = kPipeIdMax;
- bool need_scale = false;
- HWBlockType rotator_block = kHWBlockMax;
-
- // Clear reserved marking
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if (src_pipes_[i].reserved_hw_block == hw_block_id)
- src_pipes_[i].reserved_hw_block = kHWBlockMax;
- }
-
- // allocate rotator
- error = AcquireRotator(display_resource_ctx, rotate_count);
- if (error != kErrorNone) {
- return error;
- }
-
- rotate_count = 0;
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer &layer = layer_info.stack->layers[layer_info.index[i]];
- struct HWLayerConfig &layer_config = hw_layers->config[i];
- bool use_non_dma_pipe = layer_config.use_non_dma_pipe;
-
- // TODO(user): set this from comp_manager
- if (hw_block_id == kHWPrimary) {
- use_non_dma_pipe = true;
- }
-
- for (uint32_t j = 0; j < layer_config.num_rotate; j++) {
- AssignRotator(&layer_config.rotates[j], &rotate_count);
- }
-
- HWPipeInfo *pipe_info = &layer_config.left_pipe;
-
- bool is_yuv = !IS_RGB_FORMAT(layer.input_buffer->format);
-
- // left pipe is needed
- if (pipe_info->valid) {
- need_scale = IsScalingNeeded(pipe_info);
- left_index = GetPipe(hw_block_id, is_yuv, need_scale, false, use_non_dma_pipe);
- if (left_index >= num_pipe_) {
- DLOGV_IF(kTagResources, "Get left pipe failed: hw_block_id = %d, is_yuv = %d, " \
- "need_scale = %d, use_non_dma_pipe= %d",
- hw_block_id, is_yuv, need_scale, use_non_dma_pipe);
- ResourceStateLog();
- goto CleanupOnError;
- }
- src_pipes_[left_index].reserved_hw_block = hw_block_id;
- }
-
- error = SetDecimationFactor(pipe_info);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- pipe_info = &layer_config.right_pipe;
- if (!pipe_info->valid) {
- // assign single pipe
- if (left_index < num_pipe_) {
- layer_config.left_pipe.pipe_id = src_pipes_[left_index].mdss_pipe_id;
- src_pipes_[left_index].at_right = false;
- }
- DLOGV_IF(kTagResources, "1 pipe acquired, layer index = %d, left_pipe = %x",
- i, layer_config.left_pipe.pipe_id);
- continue;
- }
-
- need_scale = IsScalingNeeded(pipe_info);
-
- uint32_t right_index;
- right_index = GetPipe(hw_block_id, is_yuv, need_scale, true, use_non_dma_pipe);
- if (right_index >= num_pipe_) {
- DLOGV_IF(kTagResources, "Get right pipe failed: hw_block_id = %d, is_yuv = %d, " \
- "need_scale = %d, use_non_dma_pipe= %d",
- hw_block_id, is_yuv, need_scale, use_non_dma_pipe);
- ResourceStateLog();
- goto CleanupOnError;
- }
-
- if (src_pipes_[right_index].priority < src_pipes_[left_index].priority) {
- // Swap pipe based on priority
- Swap(left_index, right_index);
- }
-
- // assign dual pipes
- pipe_info->pipe_id = src_pipes_[right_index].mdss_pipe_id;
- src_pipes_[right_index].reserved_hw_block = hw_block_id;
- src_pipes_[right_index].at_right = true;
- src_pipes_[left_index].reserved_hw_block = hw_block_id;
- src_pipes_[left_index].at_right = false;
- layer_config.left_pipe.pipe_id = src_pipes_[left_index].mdss_pipe_id;
- error = SetDecimationFactor(pipe_info);
- if (error != kErrorNone) {
- goto CleanupOnError;
- }
-
- DLOGV_IF(kTagResources, "2 pipes acquired, layer index = %d, left_pipe = %x, right_pipe = %x",
- i, layer_config.left_pipe.pipe_id, pipe_info->pipe_id);
- }
-
-#ifdef USES_SCALAR
- if (!ScalarHelper::GetInstance()->ConfigureScale(hw_layers)) {
- DLOGV_IF(kTagResources, "Scale data configuration has failed!");
- goto CleanupOnError;
- }
-#endif
-
- if (!CheckBandwidth(display_resource_ctx, hw_layers)) {
- DLOGV_IF(kTagResources, "Bandwidth check failed!");
- goto CleanupOnError;
- }
-
- error = AllocRotatorBuffer(display_ctx, hw_layers);
- if (error != kErrorNone) {
- DLOGV_IF(kTagResources, "Rotator buffer allocation failed");
- goto CleanupOnError;
- }
-
- return kErrorNone;
-
-CleanupOnError:
- DLOGV_IF(kTagResources, "Resource reserving failed! hw_block = %d", hw_block_id);
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if (src_pipes_[i].reserved_hw_block == hw_block_id)
- src_pipes_[i].reserved_hw_block = kHWBlockMax;
- }
- return kErrorResources;
-}
-
-bool ResManager::CheckBandwidth(DisplayResourceContext *display_ctx, HWLayers *hw_layers) {
- // No need to check bandwidth for virtual displays
- if (display_ctx->display_type == kVirtual) {
- return true;
- }
-
- float max_pipe_bw = FLOAT(hw_res_info_.max_pipe_bw) / 1000000; // KBps to GBps
- float max_sde_clk = FLOAT(hw_res_info_.max_sde_clk) / 1000000; // Hz to MHz
- const struct HWLayersInfo &layer_info = hw_layers->info;
-
- float left_pipe_bw[kMaxSDELayers] = {0};
- float right_pipe_bw[kMaxSDELayers] = {0};
- float left_max_clk = 0;
- float right_max_clk = 0;
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer &layer = layer_info.stack->layers[layer_info.index[i]];
- float bpp = GetBpp(layer.input_buffer->format);
- HWPipeInfo *left_pipe = &hw_layers->config[i].left_pipe;
- HWPipeInfo *right_pipe = &hw_layers->config[i].right_pipe;
-
- left_pipe_bw[i] = left_pipe->valid ? GetPipeBw(display_ctx, left_pipe, bpp) : 0;
- right_pipe_bw[i] = right_pipe->valid ? GetPipeBw(display_ctx, right_pipe, bpp) : 0;
-
- if ((left_pipe_bw[i] > max_pipe_bw) || (right_pipe_bw[i] > max_pipe_bw)) {
- DLOGV_IF(kTagResources, "Pipe bandwidth exceeds limit for layer index=%d !" \
- " left_pipe_bw=%f, right_pipe_bw=%f, max_pipe_bw=%f",
- i, left_pipe_bw[i], right_pipe_bw[i], max_pipe_bw);
- return false;
- }
-
- float left_clk = left_pipe->valid ? GetClockForPipe(display_ctx, left_pipe) : 0;
- float right_clk = right_pipe->valid ? GetClockForPipe(display_ctx, right_pipe) : 0;
-
- left_max_clk = MAX(left_clk, left_max_clk);
- right_max_clk = MAX(right_clk, right_max_clk);
- }
-
- float left_mixer_bw = GetOverlapBw(hw_layers, left_pipe_bw, true);
- float right_mixer_bw = GetOverlapBw(hw_layers, right_pipe_bw, false);
- float display_bw = left_mixer_bw + right_mixer_bw;
-
- // Check system bandwidth (nth External + max(nth, n-1th) Primary)
- if (display_ctx->hw_block_id == kHWPrimary) {
- display_bw = MAX(display_bw, last_primary_bw_);
- last_primary_bw_ = left_mixer_bw + right_mixer_bw;
- }
-
- // If system has Video mode panel, then bw limit is max_bandwidth_low
- if (display_ctx->hw_panel_info_.mode == kModeVideo) {
- max_system_bw_ = FLOAT(hw_res_info_.max_bandwidth_low);
- }
-
- if ((display_bw + bw_claimed_) > (max_system_bw_ / 1000000)) {
- DLOGV_IF(kTagResources, "Overlap bandwidth: %f exceeds system limit: %f (GBps)!",
- (display_bw + bw_claimed_), (max_system_bw_ / 1000000));
- return false;
- }
-
- // Max clock requirement of display
- float display_clk = MAX(left_max_clk, right_max_clk);
-
- // Check max clock requirement of system
- float system_clk = MAX(display_clk, clk_claimed_);
-
- // Apply fudge factor to consider in-efficieny
- if ((system_clk * hw_res_info_.clk_fudge_factor) > max_sde_clk) {
- DLOGV_IF(kTagResources, "Clock requirement: %f exceeds system limit: %f (MHz)!",
- (system_clk * hw_res_info_.clk_fudge_factor), max_sde_clk);
- return false;
- }
-
- // If Primary display, reset claimed bw & clk for next cycle
- if (display_ctx->hw_block_id == kHWPrimary) {
- bw_claimed_ = 0.0f;
- clk_claimed_ = 0.0f;
- } else {
- bw_claimed_ = display_bw;
- clk_claimed_ = display_clk;
- }
-
- return true;
-}
-
-float ResManager::GetPipeBw(DisplayResourceContext *display_ctx, HWPipeInfo *pipe, float bpp) {
- HWDisplayAttributes &display_attributes = display_ctx->display_attributes;
- float src_w = pipe->src_roi.right - pipe->src_roi.left;
- float src_h = pipe->src_roi.bottom - pipe->src_roi.top;
- float dst_h = pipe->dst_roi.bottom - pipe->dst_roi.top;
-
- // Adjust src_h with pipe decimation
- float decimation = powf(2.0f, pipe->vertical_decimation);
- src_h /= decimation;
-
- float bw = src_w * src_h * bpp * display_attributes.fps;
-
- // Consider panel dimension
- // (v_total / v_active) * (v_active / dst_h)
- bw *= FLOAT(display_attributes.v_total) / dst_h;
-
- // Bandwidth is the rate at which data needs to be fetched from source to MDP (bytes/time).
- // On Video mode panel, there is no transfer of data from MDP to panel in horizontal blanking
- // time (hBP + hFP + hPW). So MDP gets this extra time to fetch data from source. But on the
- // Command mode panel, data gets transferred from MDP to panel during blanking time as well,
- // which means MDP needs to fetch the data faster. So pipe bandwidth needs to be adjusted.
- if (display_ctx->hw_panel_info_.mode == kModeCommand) {
- bw *= FLOAT(display_attributes.h_total) / FLOAT(display_attributes.x_pixels);
- }
-
- // Bandwidth in GBps
- return (bw / 1000000000.0f);
-}
-
-float ResManager::GetClockForPipe(DisplayResourceContext *display_ctx, HWPipeInfo *pipe) {
- HWDisplayAttributes &display_attributes = display_ctx->display_attributes;
- float v_total = FLOAT(display_attributes.v_total);
- float fps = display_attributes.fps;
-
- float src_h = pipe->src_roi.bottom - pipe->src_roi.top;
- float dst_h = pipe->dst_roi.bottom - pipe->dst_roi.top;
- float dst_w = pipe->dst_roi.right - pipe->dst_roi.left;
-
- // Adjust src_h with pipe decimation
- float decimation = powf(2.0f, pipe->vertical_decimation);
- src_h /= decimation;
-
-
- // SDE Clock requirement in MHz
- float clk = (dst_w * v_total * fps) / 1000000.0f;
-
- // Consider down-scaling
- if (src_h > dst_h)
- clk *= (src_h / dst_h);
-
- return clk;
-}
-
-float ResManager::GetOverlapBw(HWLayers *hw_layers, float *pipe_bw, bool left_mixer) {
- uint32_t count = hw_layers->info.count;
- float overlap_bw[count][count];
- float overall_max = 0;
-
- memset(overlap_bw, 0, sizeof(overlap_bw));
-
- // Algorithm:
- // 1.Create an 'n' by 'n' sized 2D array, overlap_bw[n][n] (n = # of layers).
- // 2.Get overlap_bw between two layers, i and j, and account for other overlaps (prev_max) if any.
- // This will fill the bottom-left half of the array including diagonal (0 <= i < n, 0 <= j <= i)
- // {1. pipe_bw[i], where i == j
- // overlap_bw[i][j] = {2. 0, where i != j && !Overlap(i, j)
- // {3. pipe_bw[i] + pipe_bw[j] + prev_max, where i != j && Overlap(i, j)
- //
- // Overlap(i, j) = !(bottom_i <= top_j || top_i >= bottom_j)
- // prev_max = max(prev_max, overlap_bw[j, k]), where 0 <= k < j and prev_max initially 0
- // prev_max = prev_max ? (prev_max - pipe_bw[j]) : 0; (to account for "double counting")
- // 3.Get the max value in 2D array, overlap_bw[n][n], for the final overall_max bandwidth.
- // overall_max = max(overlap_bw[i, j]), where 0 <= i < n, 0 <= j <= i
-
- for (uint32_t i = 0; i < count; i++) {
- HWPipeInfo &pipe1 = left_mixer ? hw_layers->config[i].left_pipe :
- hw_layers->config[i].right_pipe;
-
- // Non existing pipe never overlaps
- if (pipe_bw[i] == 0)
- continue;
-
- float top1 = pipe1.dst_roi.top;
- float bottom1 = pipe1.dst_roi.bottom;
- float row_max = 0;
-
- for (uint32_t j = 0; j <= i; j++) {
- HWPipeInfo &pipe2 = left_mixer ? hw_layers->config[j].left_pipe :
- hw_layers->config[j].right_pipe;
-
- if ((pipe_bw[j] == 0) || (i == j)) {
- overlap_bw[i][j] = pipe_bw[j];
- row_max = MAX(pipe_bw[j], row_max);
- continue;
- }
-
- float top2 = pipe2.dst_roi.top;
- float bottom2 = pipe2.dst_roi.bottom;
-
- if ((bottom1 <= top2) || (top1 >= bottom2)) {
- overlap_bw[i][j] = 0;
- continue;
- }
-
- overlap_bw[i][j] = pipe_bw[i] + pipe_bw[j];
-
- float prev_max = 0;
- for (uint32_t k = 0; k < j; k++) {
- if (overlap_bw[j][k])
- prev_max = MAX(overlap_bw[j][k], prev_max);
- }
- overlap_bw[i][j] += (prev_max > 0) ? (prev_max - pipe_bw[j]) : 0;
- row_max = MAX(overlap_bw[i][j], row_max);
- }
-
- overall_max = MAX(row_max, overall_max);
- }
-
- return overall_max;
-}
-
-float ResManager::GetBpp(LayerBufferFormat format) {
- switch (format) {
- case kFormatARGB8888:
- case kFormatRGBA8888:
- case kFormatBGRA8888:
- case kFormatXRGB8888:
- case kFormatRGBX8888:
- case kFormatBGRX8888:
- return 4.0f;
- case kFormatRGB888:
- case kFormatBGR888:
- return 3.0f;
- case kFormatRGB565:
- case kFormatRGBA5551:
- case kFormatRGBA4444:
- case kFormatYCbCr422H2V1Packed:
- case kFormatYCrCb422H2V1SemiPlanar:
- case kFormatYCrCb422H1V2SemiPlanar:
- case kFormatYCbCr422H2V1SemiPlanar:
- case kFormatYCbCr422H1V2SemiPlanar:
- return 2.0f;
- case kFormatYCbCr420Planar:
- case kFormatYCrCb420Planar:
- case kFormatYCbCr420SemiPlanar:
- case kFormatYCrCb420SemiPlanar:
- case kFormatYCbCr420SemiPlanarVenus:
- case kFormatYCbCr420SPVenusUbwc:
- return 1.5f;
- default:
- DLOGE("GetBpp: Invalid buffer format: %x", format);
- return 0.0f;
- }
-}
-
-DisplayError ResManager::AllocRotatorBuffer(Handle display_ctx, HWLayers *hw_layers) {
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
- DisplayError error = kErrorNone;
-
- BufferManager *buffer_manager = display_resource_ctx->buffer_manager;
- HWLayersInfo &layer_info = hw_layers->info;
-
- // TODO(user): Do session management during prepare and allocate buffer and associate that with
- // the session during commit.
- buffer_manager->Start();
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer& layer = layer_info.stack->layers[layer_info.index[i]];
- HWRotateInfo *rotate = &hw_layers->config[i].rotates[0];
-
- if (rotate->valid) {
- HWBufferInfo *hw_buffer_info = &rotate->hw_buffer_info;
- // Allocate two rotator output buffers by default for double buffering.
- hw_buffer_info->buffer_config.buffer_count = 2;
- hw_buffer_info->buffer_config.secure = layer.input_buffer->flags.secure;
-
- error = buffer_manager->GetNextBuffer(hw_buffer_info);
- if (error != kErrorNone) {
- return error;
- }
- }
-
- rotate = &hw_layers->config[i].rotates[1];
- if (rotate->valid) {
- HWBufferInfo *hw_buffer_info = &rotate->hw_buffer_info;
- // Allocate two rotator output buffers by default for double buffering.
- hw_buffer_info->buffer_config.buffer_count = 2;
- hw_buffer_info->buffer_config.secure = layer.input_buffer->flags.secure;
-
- error = buffer_manager->GetNextBuffer(hw_buffer_info);
- if (error != kErrorNone) {
- return error;
- }
- }
- }
- buffer_manager->Stop(hw_layers->closed_session_ids);
-
- return kErrorNone;
-}
-
-DisplayError ResManager::PostPrepare(Handle display_ctx, HWLayers *hw_layers) {
- SCOPE_LOCK(locker_);
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
- DisplayError error = kErrorNone;
-
- BufferManager *buffer_manager = display_resource_ctx->buffer_manager;
- HWLayersInfo &layer_info = hw_layers->info;
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer& layer = layer_info.stack->layers[layer_info.index[i]];
- HWRotateInfo *rotate = &hw_layers->config[i].rotates[0];
-
- if (rotate->valid) {
- HWBufferInfo *hw_buffer_info = &rotate->hw_buffer_info;
-
- error = buffer_manager->SetSessionId(hw_buffer_info->slot, hw_buffer_info->session_id);
- if (error != kErrorNone) {
- return error;
- }
- }
-
- rotate = &hw_layers->config[i].rotates[1];
- if (rotate->valid) {
- HWBufferInfo *hw_buffer_info = &rotate->hw_buffer_info;
-
- error = buffer_manager->SetSessionId(hw_buffer_info->slot, hw_buffer_info->session_id);
- if (error != kErrorNone) {
- return error;
- }
- }
- }
-
- return kErrorNone;
-}
-
-DisplayError ResManager::PostCommit(Handle display_ctx, HWLayers *hw_layers) {
- SCOPE_LOCK(locker_);
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
- HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
- uint64_t frame_count = display_resource_ctx->frame_count;
- DisplayError error = kErrorNone;
-
- DLOGV_IF(kTagResources, "Resource for hw_block = %d, frame_count = %d", hw_block_id, frame_count);
-
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if (src_pipes_[i].reserved_hw_block == hw_block_id) {
- src_pipes_[i].hw_block_id = hw_block_id;
- src_pipes_[i].state = kPipeStateAcquired;
- src_pipes_[i].state_frame_count = frame_count;
- DLOGV_IF(kTagResources, "Pipe acquired index = %d, type = %d, pipe_id = %x", i,
- src_pipes_[i].type, src_pipes_[i].mdss_pipe_id);
- } else if ((src_pipes_[i].hw_block_id == hw_block_id) &&
- (src_pipes_[i].state == kPipeStateAcquired)) {
- src_pipes_[i].state = kPipeStateToRelease;
- src_pipes_[i].state_frame_count = frame_count;
- DLOGV_IF(kTagResources, "Pipe to release index = %d, type = %d, pipe_id = %x", i,
- src_pipes_[i].type, src_pipes_[i].mdss_pipe_id);
- }
- }
-
- // handoff pipes which are used by splash screen
- if ((frame_count == 1) && (hw_block_id == kHWPrimary)) {
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if ((src_pipes_[i].state == kPipeStateOwnedByKernel)) {
- src_pipes_[i].state = kPipeStateToRelease;
- src_pipes_[i].hw_block_id = kHWPrimary;
- }
- }
- }
- // set rotator pipes
- for (uint32_t i = 0; i < hw_res_info_.num_rotator; i++) {
- uint32_t pipe_index = rotators_[i].pipe_index;
-
- if (IS_BIT_SET(rotators_[i].client_bit_mask, hw_block_id)) {
- src_pipes_[pipe_index].hw_block_id = rotators_[i].writeback_id;
- src_pipes_[pipe_index].state = kPipeStateAcquired;
- } else if (!rotators_[i].client_bit_mask &&
- src_pipes_[pipe_index].hw_block_id == rotators_[i].writeback_id &&
- src_pipes_[pipe_index].state == kPipeStateAcquired) {
- src_pipes_[pipe_index].state = kPipeStateToRelease;
- src_pipes_[pipe_index].state_frame_count = frame_count;
- }
- // If no request on the rotation, release the pipe.
- if (!rotators_[i].request_bit_mask) {
- src_pipes_[pipe_index].dedicated_hw_block = kHWBlockMax;
- }
- }
- display_resource_ctx->frame_start = false;
-
- BufferManager *buffer_manager = display_resource_ctx->buffer_manager;
- HWLayersInfo &layer_info = hw_layers->info;
-
- for (uint32_t i = 0; i < layer_info.count; i++) {
- Layer& layer = layer_info.stack->layers[layer_info.index[i]];
- HWRotateInfo *rotate = &hw_layers->config[i].rotates[0];
-
- if (rotate->valid) {
- HWBufferInfo *rot_buf_info = &rotate->hw_buffer_info;
-
- error = buffer_manager->SetReleaseFd(rot_buf_info->slot,
- rot_buf_info->output_buffer.release_fence_fd);
- if (error != kErrorNone) {
- return error;
- }
- }
-
- rotate = &hw_layers->config[i].rotates[1];
- if (rotate->valid) {
- HWBufferInfo *rot_buf_info = &rotate->hw_buffer_info;
-
- error = buffer_manager->SetReleaseFd(rot_buf_info->slot,
- rot_buf_info->output_buffer.release_fence_fd);
- if (error != kErrorNone) {
- return error;
- }
- }
- }
-
- return kErrorNone;
-}
-
-void ResManager::Purge(Handle display_ctx) {
- SCOPE_LOCK(locker_);
-
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
- HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
-
- for (uint32_t i = 0; i < num_pipe_; i++) {
- if (src_pipes_[i].hw_block_id == hw_block_id)
- src_pipes_[i].ResetState();
- }
- ClearRotator(display_resource_ctx);
- DLOGV_IF(kTagResources, "display id = %d", display_resource_ctx->hw_block_id);
-}
-
-DisplayError ResManager::SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages) {
- SCOPE_LOCK(locker_);
-
- if (max_mixer_stages < 1 || max_mixer_stages > hw_res_info_.num_blending_stages) {
- DLOGE("Max mixer stages = %d and that should be in between 1 to %d", max_mixer_stages,
- hw_res_info_.num_blending_stages);
-
- return kErrorParameters;
- }
-
- DisplayResourceContext *display_resource_ctx =
- reinterpret_cast<DisplayResourceContext *>(display_ctx);
-
- if (display_resource_ctx) {
- display_resource_ctx->max_mixer_stages = max_mixer_stages;
- }
-
- return kErrorNone;
-}
-
-uint32_t ResManager::GetMdssPipeId(PipeType type, uint32_t index) {
- uint32_t mdss_id = kPipeIdMax;
- switch (type) {
- case kPipeTypeVIG:
- if (index < 3) {
- mdss_id = kPipeIdVIG0 + index;
- } else if (index == 3) {
- mdss_id = kPipeIdVIG3;
- } else {
- DLOGE("vig pipe index is over the limit! %d", index);
- }
- break;
- case kPipeTypeRGB:
- if (index < 3) {
- mdss_id = kPipeIdRGB0 + index;
- } else if (index == 3) {
- mdss_id = kPipeIdRGB3;
- } else {
- DLOGE("rgb pipe index is over the limit! %d", index);
- }
- break;
- case kPipeTypeDMA:
- if (index < 2) {
- mdss_id = kPipeIdDMA0 + index;
- } else {
- DLOGE("dma pipe index is over the limit! %d", index);
- }
- break;
- default:
- DLOGE("wrong pipe type! %d", type);
- break;
- }
-
- return (1 << mdss_id);
-}
-
-uint32_t ResManager::SearchPipe(HWBlockType hw_block_id, SourcePipe *src_pipes,
- uint32_t num_pipe, bool at_right) {
- uint32_t index = kPipeIdMax;
- SourcePipe *src_pipe;
- HWBlockType dedicated_block;
-
- // search dedicated idle pipes
- for (uint32_t i = 0; i < num_pipe; i++) {
- src_pipe = &src_pipes[i];
- if (src_pipe->reserved_hw_block == kHWBlockMax &&
- src_pipe->state == kPipeStateIdle &&
- src_pipe->dedicated_hw_block == hw_block_id) {
- index = src_pipe->index;
- break;
- }
- }
-
- // found
- if (index < num_pipe_) {
- return index;
- }
-
- // search the pipe being used
- for (uint32_t i = 0; i < num_pipe; i++) {
- src_pipe = &src_pipes[i];
- dedicated_block = src_pipe->dedicated_hw_block;
- if (src_pipe->reserved_hw_block == kHWBlockMax &&
- (src_pipe->state == kPipeStateAcquired) &&
- (src_pipe->hw_block_id == hw_block_id) &&
- (src_pipe->at_right == at_right) &&
- (dedicated_block == hw_block_id || dedicated_block == kHWBlockMax)) {
- index = src_pipe->index;
- break;
- }
- }
-
- // found
- if (index < num_pipe_) {
- return index;
- }
-
- // search the pipes idle or being used but not at the same side
- for (uint32_t i = 0; i < num_pipe; i++) {
- src_pipe = &src_pipes[i];
- dedicated_block = src_pipe->dedicated_hw_block;
- if (src_pipe->reserved_hw_block == kHWBlockMax &&
- ((src_pipe->state == kPipeStateIdle) ||
- (src_pipe->state == kPipeStateAcquired && src_pipe->hw_block_id == hw_block_id)) &&
- (dedicated_block == hw_block_id || dedicated_block == kHWBlockMax)) {
- index = src_pipe->index;
- break;
- }
- }
- return index;
-}
-
-uint32_t ResManager::NextPipe(PipeType type, HWBlockType hw_block_id, bool at_right) {
- uint32_t num_pipe = 0;
- SourcePipe *src_pipes = NULL;
-
- switch (type) {
- case kPipeTypeVIG:
- src_pipes = vig_pipes_;
- num_pipe = hw_res_info_.num_vig_pipe;
- break;
- case kPipeTypeRGB:
- src_pipes = rgb_pipes_;
- num_pipe = hw_res_info_.num_rgb_pipe;
- break;
- case kPipeTypeDMA:
- default:
- src_pipes = dma_pipes_;
- num_pipe = hw_res_info_.num_dma_pipe;
- break;
- }
-
- return SearchPipe(hw_block_id, src_pipes, num_pipe, at_right);
-}
-
-uint32_t ResManager::GetPipe(HWBlockType hw_block_id, bool is_yuv, bool need_scale, bool at_right,
- bool use_non_dma_pipe) {
- uint32_t index = kPipeIdMax;
-
- // The default behavior is to assume RGB and VG pipes have scalars
- if (is_yuv) {
- return NextPipe(kPipeTypeVIG, hw_block_id, at_right);
- } else {
- if (!need_scale && !use_non_dma_pipe) {
- index = NextPipe(kPipeTypeDMA, hw_block_id, at_right);
- }
-
- if ((index >= num_pipe_) && (!need_scale || !hw_res_info_.has_non_scalar_rgb)) {
- index = NextPipe(kPipeTypeRGB, hw_block_id, at_right);
- }
-
- if (index >= num_pipe_) {
- index = NextPipe(kPipeTypeVIG, hw_block_id, at_right);
- }
- }
-
- return index;
-}
-
-bool ResManager::IsScalingNeeded(const HWPipeInfo *pipe_info) {
- const LayerRect &src_roi = pipe_info->src_roi;
- const LayerRect &dst_roi = pipe_info->dst_roi;
-
- return ((dst_roi.right - dst_roi.left) != (src_roi.right - src_roi.left)) ||
- ((dst_roi.bottom - dst_roi.top) != (src_roi.bottom - src_roi.top));
-}
-
-void ResManager::AppendDump(char *buffer, uint32_t length) {
- SCOPE_LOCK(locker_);
- AppendString(buffer, length, "\nresource manager pipe state");
- uint32_t i;
- for (i = 0; i < num_pipe_; i++) {
- SourcePipe *src_pipe = &src_pipes_[i];
- AppendString(buffer, length,
- "\nindex = %d, id = %x, reserved = %d, state = %d, hw_block = %d, dedicated = %d",
- src_pipe->index, src_pipe->mdss_pipe_id, src_pipe->reserved_hw_block,
- src_pipe->state, src_pipe->hw_block_id, src_pipe->dedicated_hw_block);
- }
-
- for (i = 0; i < hw_res_info_.num_rotator; i++) {
- if (rotators_[i].client_bit_mask || rotators_[i].request_bit_mask) {
- AppendString(buffer, length,
- "\nrotator = %d, pipe index = %x, client_bit_mask = %x, request_bit_mask = %x",
- i, rotators_[i].pipe_index, rotators_[i].client_bit_mask,
- rotators_[i].request_bit_mask);
- }
- }
-}
-
-void ResManager::ResourceStateLog() {
- DLOGV_IF(kTagResources, "==== resource manager pipe state ====");
- uint32_t i;
- for (i = 0; i < num_pipe_; i++) {
- SourcePipe *src_pipe = &src_pipes_[i];
- DLOGV_IF(kTagResources,
- "index = %d, id = %x, reserved = %d, state = %d, hw_block = %d, dedicated = %d",
- src_pipe->index, src_pipe->mdss_pipe_id, src_pipe->reserved_hw_block,
- src_pipe->state, src_pipe->hw_block_id, src_pipe->dedicated_hw_block);
- }
-
- for (i = 0; i < hw_res_info_.num_rotator; i++) {
- if (rotators_[i].client_bit_mask || rotators_[i].request_bit_mask) {
- DLOGV_IF(kTagResources,
- "rotator = %d, pipe index = %x, client_bit_mask = %x, request_bit_mask = %x",
- i, rotators_[i].pipe_index, rotators_[i].client_bit_mask,
- rotators_[i].request_bit_mask);
- }
- }
-}
-
-DisplayError ResManager::AcquireRotator(DisplayResourceContext *display_resource_ctx,
- const uint32_t rotate_count) {
- if (rotate_count == 0)
- return kErrorNone;
- if (hw_res_info_.num_rotator == 0) {
- DLOGV_IF(kTagResources, "Rotator hardware is not available");
- return kErrorResources;
- }
-
- uint32_t i, j, pipe_index, num_rotator;
- if (rotate_count > hw_res_info_.num_rotator)
- num_rotator = hw_res_info_.num_rotator;
- else
- num_rotator = rotate_count;
-
- for (i = 0; i < num_rotator; i++) {
- uint32_t rotate_pipe_index = rotators_[i].pipe_index;
- SourcePipe *src_pipe = &src_pipes_[rotate_pipe_index];
-
- if (src_pipe->dedicated_hw_block != kHWBlockMax)
- DLOGV_IF(kTagResources, "Overwrite dedicated block %d", src_pipe->dedicated_hw_block);
- src_pipe->dedicated_hw_block = rotators_[i].writeback_id;
- SET_BIT(rotators_[i].request_bit_mask, display_resource_ctx->hw_block_id);
- }
-
- for (i = 0; i < num_rotator; i++) {
- uint32_t rotate_pipe_index = rotators_[i].pipe_index;
- if (src_pipes_[rotate_pipe_index].reserved_hw_block != kHWBlockMax) {
- DLOGV_IF(kTagResources, "pipe %x is reserved by block:%d",
- src_pipes_[rotate_pipe_index].mdss_pipe_id,
- src_pipes_[rotate_pipe_index].reserved_hw_block);
- return kErrorResources;
- }
- pipe_index = SearchPipe(rotators_[i].writeback_id, &src_pipes_[rotate_pipe_index], 1, false);
- if (pipe_index >= num_pipe_) {
- DLOGV_IF(kTagResources, "pipe %x is not ready for rotator",
- src_pipes_[rotate_pipe_index].mdss_pipe_id);
- return kErrorResources;
- }
- }
-
- for (i = 0; i < num_rotator; i++)
- SET_BIT(rotators_[i].client_bit_mask, display_resource_ctx->hw_block_id);
-
- return kErrorNone;
-}
-
-void ResManager::AssignRotator(HWRotateInfo *rotate, uint32_t *rotate_count) {
- if (!rotate->valid)
- return;
- // Interleave rotator assignment
- if ((*rotate_count & 0x1) && (hw_res_info_.num_rotator > 1)) {
- rotate->pipe_id = src_pipes_[rotators_[1].pipe_index].mdss_pipe_id;
- rotate->writeback_id = rotators_[1].writeback_id;
- } else {
- rotate->pipe_id = src_pipes_[rotators_[0].pipe_index].mdss_pipe_id;
- rotate->writeback_id = rotators_[0].writeback_id;
- }
- (*rotate_count)++;
-}
-
-void ResManager::ClearRotator(DisplayResourceContext *display_resource_ctx) {
- for (uint32_t i = 0; i < hw_res_info_.num_rotator; i++) {
- uint32_t pipe_index;
- pipe_index = rotators_[i].pipe_index;
- rotators_[i].ClearState(display_resource_ctx->hw_block_id);
- if (rotators_[i].client_bit_mask)
- continue;
-
- if (src_pipes_[pipe_index].hw_block_id == rotators_[i].writeback_id) {
- src_pipes_[pipe_index].ResetState();
- } else if (src_pipes_[pipe_index].dedicated_hw_block == rotators_[i].writeback_id) {
- src_pipes_[pipe_index].dedicated_hw_block = kHWBlockMax;
- }
- }
-}
-
-void ResManager::SetRotatorOutputFormat(const LayerBufferFormat &input_format,
- const bool &is_opaque, const bool &rot90,
- const bool &downscale, LayerBufferFormat *output_format) {
- // Initialize the output format with input format by default.
- *output_format = input_format;
-
- switch (input_format) {
- case kFormatARGB8888:
- case kFormatRGBA8888:
- if (is_opaque) {
- *output_format = kFormatRGB888;
- }
- break;
- case kFormatBGRA8888:
- if (is_opaque) {
- *output_format = kFormatBGR888;
- }
- break;
- case kFormatBGRX8888:
- *output_format = kFormatBGR888;
- break;
- case kFormatXRGB8888:
- case kFormatRGBX8888:
- *output_format = kFormatRGB888;
- break;
- case kFormatYCrCb420SemiPlanar:
- case kFormatYCbCr420SemiPlanar:
- case kFormatYCbCr420SemiPlanarVenus:
- *output_format = kFormatYCbCr420SemiPlanar;
- break;
- default:
- break;
- }
-
- // TODO(user): UBWC RGB formats will be handled separately
- if (downscale) {
- switch (input_format) {
- case kFormatYCbCr420SPVenusUbwc:
- *output_format = kFormatYCbCr420SemiPlanar;
- break;
- default:
- break;
- }
- } else {
- if (hw_res_info_.has_ubwc) {
- switch (input_format) {
- case kFormatYCrCb420SemiPlanar:
- case kFormatYCbCr420SemiPlanar:
- case kFormatYCbCr420SemiPlanarVenus:
- *output_format = kFormatYCbCr420SPVenusUbwc;
- break;
- default:
- break;
- }
- }
- }
-
- if (rot90) {
- if (input_format == kFormatYCbCr422H2V1SemiPlanar) {
- *output_format = kFormatYCbCr422H1V2SemiPlanar;
- } else if (input_format == kFormatYCbCr422H1V2SemiPlanar) {
- *output_format = kFormatYCbCr422H2V1SemiPlanar;
- } else if (input_format == kFormatYCrCb422H2V1SemiPlanar) {
- *output_format = kFormatYCrCb422H1V2SemiPlanar;
- } else if (input_format == kFormatYCrCb422H1V2SemiPlanar) {
- *output_format = kFormatYCrCb422H2V1SemiPlanar;
- }
- }
-
- DLOGV_IF(kTagResources, "Input format = %x, Output format = %x, rot90 = %d, ubwc = %d,"
- "downscale = %d", input_format, *output_format, rot90, hw_res_info_.has_ubwc,
- downscale);
-
- return;
-}
-
-} // namespace sde
-
diff --git a/displayengine/libs/core/res_manager.h b/displayengine/libs/core/res_manager.h
deleted file mode 100644
index 1653c0a..0000000
--- a/displayengine/libs/core/res_manager.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
-* Copyright (c) 2014 - 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __RES_MANAGER_H__
-#define __RES_MANAGER_H__
-
-#include <core/display_interface.h>
-#include <private/hw_info_types.h>
-#include <utils/locker.h>
-
-#include "hw_interface.h"
-#include "dump_impl.h"
-#include "buffer_manager.h"
-
-namespace sde {
-
-class ResManager : public DumpImpl {
- public:
- ResManager();
- DisplayError Init(const HWResourceInfo &hw_res_info, BufferAllocator *buffer_allocator,
- BufferSyncHandler *buffer_sync_handler);
- DisplayError Deinit();
- DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
- const HWPanelInfo &hw_panel_info, Handle *display_ctx);
- DisplayError UnregisterDisplay(Handle display_ctx);
- DisplayError Start(Handle display_ctx);
- DisplayError Stop(Handle display_ctx);
- DisplayError Acquire(Handle display_ctx, HWLayers *hw_layers);
- DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers);
- DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers);
- void Purge(Handle display_ctx);
- DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages);
-
- // DumpImpl method
- virtual void AppendDump(char *buffer, uint32_t length);
-
- private:
- enum PipeId {
- kPipeIdVIG0,
- kPipeIdVIG1,
- kPipeIdVIG2,
- kPipeIdRGB0,
- kPipeIdRGB1,
- kPipeIdRGB2,
- kPipeIdDMA0,
- kPipeIdDMA1,
- kPipeIdVIG3,
- kPipeIdRGB3,
- kPipeIdMax,
- };
-
- enum PipeType {
- kPipeTypeUnused,
- kPipeTypeVIG,
- kPipeTypeRGB,
- kPipeTypeDMA,
- kPipeTypeMax,
- };
-
- enum PipeState {
- kPipeStateIdle, // Pipe state when it is available for reservation
- kPipeStateAcquired, // Pipe state after successful commit
- kPipeStateToRelease, // Pipe state that can be moved to Idle when releasefence is signaled
- kPipeStateOwnedByKernel, // Pipe state when pipe is owned by kernel
- };
-
- // todo: retrieve all these from kernel
- enum {
- kMaxSourcePipeWidth = 2048,
- kMaxInterfaceWidth = 2048,
- kMaxRotateDownScaleRatio = 8,
- kMaxDecimationDownScaleRatio = 8,
- kMaxNumRotator = 2,
- };
-
- struct SourcePipe {
- PipeType type;
- uint32_t mdss_pipe_id;
- uint32_t index;
- PipeState state;
- HWBlockType hw_block_id;
- bool at_right;
- uint64_t state_frame_count;
- int priority;
- HWBlockType reserved_hw_block;
- HWBlockType dedicated_hw_block;
-
- SourcePipe() : type(kPipeTypeUnused), mdss_pipe_id(kPipeIdMax), index(0),
- state(kPipeStateIdle), hw_block_id(kHWBlockMax), at_right(false),
- state_frame_count(0), priority(0), reserved_hw_block(kHWBlockMax),
- dedicated_hw_block(kHWBlockMax) { }
-
- inline void ResetState() { state = kPipeStateIdle; hw_block_id = kHWBlockMax;
- at_right = false; reserved_hw_block = kHWBlockMax; dedicated_hw_block = kHWBlockMax; }
- };
-
- struct DisplayResourceContext {
- HWDisplayAttributes display_attributes;
- BufferManager *buffer_manager;
- DisplayType display_type;
- HWBlockType hw_block_id;
- HWPanelInfo hw_panel_info_;
- uint64_t frame_count;
- int32_t session_id; // applicable for virtual display sessions only
- uint32_t rotate_count;
- bool frame_start;
- uint32_t max_mixer_stages;
-
- DisplayResourceContext() : hw_block_id(kHWBlockMax), frame_count(0), session_id(-1),
- rotate_count(0), frame_start(false), max_mixer_stages(0) { }
-
- ~DisplayResourceContext() {
- if (buffer_manager) {
- delete buffer_manager;
- buffer_manager = NULL;
- }
- }
- };
-
- struct HWBlockContext {
- bool is_in_use;
- HWBlockContext() : is_in_use(false) { }
- };
-
- struct HWRotator {
- uint32_t pipe_index;
- HWBlockType writeback_id;
- uint32_t client_bit_mask;
- uint32_t request_bit_mask;
- HWRotator() : pipe_index(0), writeback_id(kHWBlockMax), client_bit_mask(0),
- request_bit_mask(0) { }
-
- inline void ClearState(HWBlockType block) { CLEAR_BIT(client_bit_mask, block);
- CLEAR_BIT(request_bit_mask, block); }
- };
-
- struct PropertySetting {
- bool disable_rotator_downscaling;
- bool disable_decimation;
- PropertySetting() : disable_rotator_downscaling(false), disable_decimation(false) { }
- };
-
- uint32_t GetMdssPipeId(PipeType pipe_type, uint32_t index);
- uint32_t NextPipe(PipeType pipe_type, HWBlockType hw_block_id, bool at_right);
- uint32_t SearchPipe(HWBlockType hw_block_id, SourcePipe *src_pipes, uint32_t num_pipe,
- bool at_right);
- uint32_t GetPipe(HWBlockType hw_block_id, bool is_yuv, bool need_scale, bool at_right,
- bool use_non_dma_pipe);
- bool IsScalingNeeded(const HWPipeInfo *pipe_info);
- DisplayError Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers,
- uint32_t *rotate_count);
- DisplayError DisplaySplitConfig(DisplayResourceContext *display_resource_ctx,
- const LayerTransform &transform, const LayerRect &src_rect,
- const LayerRect &dst_rect, HWLayerConfig *layer_config,
- uint32_t align_x);
- DisplayError ValidateScaling(const Layer &layer, const LayerRect &crop,
- const LayerRect &dst, float *rot_scale);
- DisplayError SrcSplitConfig(DisplayResourceContext *display_resource_ctx,
- const LayerTransform &transform, const LayerRect &src_rect,
- const LayerRect &dst_rect, HWLayerConfig *layer_config,
- uint32_t align_x);
- void CalculateCut(const LayerTransform &transform, float *left_cut_ratio, float *top_cut_ratio,
- float *right_cut_ratio, float *bottom_cut_ratio);
- bool CalculateCropRects(const LayerRect &scissor, const LayerTransform &transform,
- LayerRect *crop, LayerRect *dst);
- bool IsValidDimension(const LayerRect &src, const LayerRect &dst);
- bool CheckBandwidth(DisplayResourceContext *display_ctx, HWLayers *hw_layers);
- float GetPipeBw(DisplayResourceContext *display_ctx, HWPipeInfo *pipe, float bpp);
- float GetClockForPipe(DisplayResourceContext *display_ctx, HWPipeInfo *pipe);
- float GetOverlapBw(HWLayers *hw_layers, float *pipe_bw, bool left_mixer);
- DisplayError SetDecimationFactor(HWPipeInfo *pipe);
- float GetBpp(LayerBufferFormat format);
- void SplitRect(bool flip_horizontal, const LayerRect &src_rect, const LayerRect &dst_rect,
- LayerRect *src_left, LayerRect *dst_left, LayerRect *src_right,
- LayerRect *dst_right, uint32_t align_x);
- bool IsMacroTileFormat(const LayerBuffer *buffer) { return buffer->flags.macro_tile; }
- bool IsRotationNeeded(float rotation)
- { return (UINT32(rotation) == 90 || UINT32(rotation) == 270); }
- void RotationConfig(const Layer &layer, const float &downscale, LayerRect *src_rect,
- HWLayerConfig *layer_config, uint32_t *rotate_count);
- DisplayError AcquireRotator(DisplayResourceContext *display_resource_ctx,
- const uint32_t roate_cnt);
- void AssignRotator(HWRotateInfo *rotate, uint32_t *rotate_cnt);
- void ClearRotator(DisplayResourceContext *display_resource_ctx);
- DisplayError AllocRotatorBuffer(Handle display_ctx, HWLayers *hw_layers);
- void SetRotatorOutputFormat(const LayerBufferFormat &input_format, const bool &is_opaque,
- const bool &rot90, const bool &downscale,
- LayerBufferFormat *output_format);
- DisplayError AlignPipeConfig(const Layer &layer, const LayerTransform &transform,
- HWPipeInfo *left_pipe, HWPipeInfo *right_pipe,
- uint32_t align_x, uint32_t align_y);
- void ResourceStateLog(void);
- DisplayError CalculateDecimation(float downscale, uint8_t* decimation);
-
- Locker locker_;
- HWResourceInfo hw_res_info_;
- HWBlockContext hw_block_ctx_[kHWBlockMax];
- SourcePipe src_pipes_[kPipeIdMax];
- uint32_t num_pipe_;
- SourcePipe *vig_pipes_;
- SourcePipe *rgb_pipes_;
- SourcePipe *dma_pipes_;
- bool frame_start_;
- float bw_claimed_; // Bandwidth claimed by other display
- float clk_claimed_; // Clock claimed by other display
- float last_primary_bw_;
- float max_system_bw_;
- uint32_t virtual_count_;
- struct HWRotator rotators_[kMaxNumRotator];
- BufferAllocator *buffer_allocator_;
- BufferSyncHandler *buffer_sync_handler_; // Pointer to buffer sync handler that was defined by
- // the display engine's client
- PropertySetting property_setting_;
-};
-
-} // namespace sde
-
-#endif // __RES_MANAGER_H__
-
diff --git a/displayengine/libs/core/scalar_helper.cpp b/displayengine/libs/core/scalar_helper.cpp
deleted file mode 100644
index 55b462f..0000000
--- a/displayengine/libs/core/scalar_helper.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-* Copyright (c) 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef USES_SCALAR
-
-#include <dlfcn.h>
-#include <utils/debug.h>
-#include "scalar_helper.h"
-
-#define __CLASS__ "ScalarHelper"
-
-namespace sde {
-
-ScalarHelper* ScalarHelper::scalar_helper_ = NULL;
-
-ScalarHelper* ScalarHelper::GetInstance() {
- if (scalar_helper_ == NULL) {
- scalar_helper_ = new ScalarHelper();
- }
- return scalar_helper_;
-}
-
-// Scalar helper functions
-static void SetPipeInfo(HWPipeInfo* hw_pipe, scalar::PipeInfo* pipe) {
- pipe->id = hw_pipe->pipe_id;
- pipe->horz_deci = hw_pipe->horizontal_decimation;
- pipe->vert_deci = hw_pipe->vertical_decimation;
-
- pipe->src_rect.x = UINT32(hw_pipe->src_roi.left);
- pipe->src_rect.y = UINT32(hw_pipe->src_roi.top);
- pipe->src_rect.w = UINT32(hw_pipe->src_roi.right) - pipe->src_rect.x;
- pipe->src_rect.h = UINT32(hw_pipe->src_roi.bottom) - pipe->src_rect.y;
-
- pipe->dst_rect.x = UINT32(hw_pipe->dst_roi.left);
- pipe->dst_rect.y = UINT32(hw_pipe->dst_roi.top);
- pipe->dst_rect.w = UINT32(hw_pipe->dst_roi.right) - pipe->dst_rect.x;
- pipe->dst_rect.h = UINT32(hw_pipe->dst_roi.bottom) - pipe->dst_rect.y;
-}
-
-static void UpdateSrcRoi(scalar::PipeInfo* pipe, HWPipeInfo* hw_pipe) {
- hw_pipe->src_roi.left = FLOAT(pipe->src_rect.x);
- hw_pipe->src_roi.top = FLOAT(pipe->src_rect.y);
- hw_pipe->src_roi.right = FLOAT(pipe->src_rect.x + pipe->src_rect.w);
- hw_pipe->src_roi.bottom = FLOAT(pipe->src_rect.y + pipe->src_rect.h);
-}
-
-static uint32_t GetScalarFormat(LayerBufferFormat source) {
- uint32_t format = scalar::UNKNOWN_FORMAT;
-
- switch (source) {
- case kFormatARGB8888: format = scalar::ARGB_8888; break;
- case kFormatRGBA8888: format = scalar::RGBA_8888; break;
- case kFormatBGRA8888: format = scalar::BGRA_8888; break;
- case kFormatXRGB8888: format = scalar::XRGB_8888; break;
- case kFormatRGBX8888: format = scalar::RGBX_8888; break;
- case kFormatBGRX8888: format = scalar::BGRX_8888; break;
- case kFormatRGBA5551: format = scalar::RGBA_5551; break;
- case kFormatRGBA4444: format = scalar::RGBA_4444; break;
- case kFormatRGB888: format = scalar::RGB_888; break;
- case kFormatBGR888: format = scalar::BGR_888; break;
- case kFormatRGB565: format = scalar::RGB_565; break;
- case kFormatYCbCr420Planar: format = scalar::Y_CB_CR_H2V2; break;
- case kFormatYCrCb420Planar: format = scalar::Y_CR_CB_H2V2; break;
- case kFormatYCbCr420SemiPlanar: format = scalar::Y_CBCR_H2V2; break;
- case kFormatYCrCb420SemiPlanar: format = scalar::Y_CRCB_H2V2; break;
- case kFormatYCbCr422H1V2SemiPlanar: format = scalar::Y_CBCR_H1V2; break;
- case kFormatYCrCb422H1V2SemiPlanar: format = scalar::Y_CRCB_H1V2; break;
- case kFormatYCbCr422H2V1SemiPlanar: format = scalar::Y_CBCR_H2V1; break;
- case kFormatYCrCb422H2V1SemiPlanar: format = scalar::Y_CRCB_H2V1; break;
- case kFormatYCbCr422H2V1Packed: format = scalar::YCBYCR_H2V1; break;
- case kFormatYCbCr420SemiPlanarVenus: format = scalar::Y_CBCR_H2V2_VENUS; break;
- case kFormatRGBA8888Ubwc: format = scalar::RGBA_8888_UBWC; break;
- case kFormatRGB565Ubwc: format = scalar::RGB_565_UBWC; break;
- case kFormatYCbCr420SPVenusUbwc: format = scalar::Y_CBCR_H2V2_UBWC; break;
- default:
- DLOGE("Unsupported source format: %x", source);
- break;
- }
- return format;
-}
-
-void ScalarHelper::Init() {
- lib_scalar_handle_ = NULL;
- ScalarConfigureScale = NULL;
-
- lib_scalar_handle_ = dlopen(SCALAR_LIBRARY_NAME, RTLD_NOW);
- if (lib_scalar_handle_) {
- void **scalar_func = reinterpret_cast<void **>(&ScalarConfigureScale);
- *scalar_func = ::dlsym(lib_scalar_handle_, "configureScale");
- } else {
- DLOGW("Unable to load %s !", SCALAR_LIBRARY_NAME);
- }
-}
-
-void ScalarHelper::Deinit() {
- if (lib_scalar_handle_) {
- dlclose(lib_scalar_handle_);
- lib_scalar_handle_ = NULL;
- }
-}
-
-bool ScalarHelper::ConfigureScale(HWLayers *hw_layers) {
-
- if (!lib_scalar_handle_ || !ScalarConfigureScale) {
- // No scalar library
- return true;
- }
-
- // Reset scale data
- memset(&scale_data_, 0, sizeof(scale_data_));
- HWLayersInfo &hw_layer_info = hw_layers->info;
-
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer &layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
- uint32_t width = layer.input_buffer->width;
- LayerBufferFormat format = layer.input_buffer->format;
- HWPipeInfo* left_pipe = &hw_layers->config[i].left_pipe;
- HWPipeInfo* right_pipe = &hw_layers->config[i].right_pipe;
-
- // Prepare data structure for lib scalar
- uint32_t flags = 0;
- struct scalar::LayerInfo layer_info;
-
- if (layer.transform.rotation == 90.0f) {
- // Flips will be taken care by rotator, if layer requires 90 rotation
- flags |= scalar::SCALAR_SOURCE_ROTATED_90;
- } else {
- flags |= layer.transform.flip_vertical ? scalar::SCALAR_FLIP_UD : 0;
- flags |= layer.transform.flip_horizontal ? scalar::SCALAR_FLIP_LR : 0;
- }
-
- for (uint32_t count = 0; count < 2; count++) {
- HWPipeInfo* hw_pipe = (count == 0) ? left_pipe : right_pipe;
- HWRotateInfo* rotate_info = &hw_layers->config[i].rotates[count];
- scalar::PipeInfo* pipe = (count == 0) ? &layer_info.left_pipe : &layer_info.right_pipe;
-
- if (rotate_info->valid) {
- width = rotate_info->hw_buffer_info.buffer_config.width;
- format = rotate_info->hw_buffer_info.buffer_config.format;
- }
-
- pipe->flags = flags;
- pipe->scale_data = GetScaleRef(i, !count);
- pipe->scale_data->src_width = width;
- SetPipeInfo(hw_pipe, pipe);
- }
- layer_info.src_format = GetScalarFormat(format);
-
- DLOGV_IF(kTagScalar, "Scalar Input[%d] flags=%x format=%x", i, flags, layer_info.src_format);
- DLOGV_IF(kTagScalar, "Left: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
- layer_info.left_pipe.id, layer_info.left_pipe.horz_deci, layer_info.left_pipe.vert_deci,
- layer_info.left_pipe.src_rect.x, layer_info.left_pipe.src_rect.y,
- layer_info.left_pipe.src_rect.w, layer_info.left_pipe.src_rect.h,
- layer_info.left_pipe.dst_rect.x, layer_info.left_pipe.dst_rect.y,
- layer_info.left_pipe.dst_rect.w, layer_info.left_pipe.dst_rect.h);
- DLOGV_IF(kTagScalar, "Right: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
- layer_info.right_pipe.id, layer_info.right_pipe.horz_deci, layer_info.right_pipe.vert_deci,
- layer_info.right_pipe.src_rect.x, layer_info.right_pipe.src_rect.y,
- layer_info.right_pipe.src_rect.w, layer_info.right_pipe.src_rect.h,
- layer_info.right_pipe.dst_rect.x, layer_info.right_pipe.dst_rect.y,
- layer_info.right_pipe.dst_rect.w, layer_info.right_pipe.dst_rect.h);
-
- // Configure scale data structure
- if (ScalarConfigureScale(&layer_info) < 0) {
- DLOGE("Scalar library failed to configure scale data!");
- return false;
- }
-
- // Update Src Roi in HWPipeInfo
- if (layer_info.left_pipe.scale_data->enable_pxl_ext)
- UpdateSrcRoi(&layer_info.left_pipe, left_pipe);
- if (layer_info.right_pipe.scale_data->enable_pxl_ext)
- UpdateSrcRoi(&layer_info.right_pipe, right_pipe);
- }
- return true;
-}
-
-void ScalarHelper::UpdateSrcWidth(uint32_t index, bool left, uint32_t* width) {
- *width = GetScaleRef(index, left)->src_width;
-}
-
-void ScalarHelper::SetScaleData(uint32_t index, bool left, mdp_scale_data* mdp_scale) {
-
- if (!lib_scalar_handle_ || !ScalarConfigureScale)
- return;
-
- scalar::Scale* scale = GetScaleRef(index, left);
- mdp_scale->enable_pxl_ext = scale->enable_pxl_ext;
-
- for (int i = 0; i < MAX_PLANES; i++) {
- mdp_scale->init_phase_x[i] = scale->init_phase_x[i];
- mdp_scale->phase_step_x[i] = scale->phase_step_x[i];
- mdp_scale->init_phase_y[i] = scale->init_phase_y[i];
- mdp_scale->phase_step_y[i] = scale->phase_step_y[i];
-
- mdp_scale->num_ext_pxls_left[i] = scale->left.extension[i];
- mdp_scale->num_ext_pxls_top[i] = scale->top.extension[i];
- mdp_scale->num_ext_pxls_right[i] = scale->right.extension[i];
- mdp_scale->num_ext_pxls_btm[i] = scale->bottom.extension[i];
-
- mdp_scale->left_ftch[i] = scale->left.overfetch[i];
- mdp_scale->top_ftch[i] = scale->top.overfetch[i];
- mdp_scale->right_ftch[i] = scale->right.overfetch[i];
- mdp_scale->btm_ftch[i] = scale->bottom.overfetch[i];
-
- mdp_scale->left_rpt[i] = scale->left.repeat[i];
- mdp_scale->top_rpt[i] = scale->top.repeat[i];
- mdp_scale->right_rpt[i] = scale->right.repeat[i];
- mdp_scale->btm_rpt[i] = scale->bottom.repeat[i];
-
- mdp_scale->roi_w[i] = scale->roi_width[i];
- }
-}
-
-} // namespace sde
-
-#endif
diff --git a/displayengine/libs/core/scalar_helper.h b/displayengine/libs/core/scalar_helper.h
deleted file mode 100755
index a54cb0c..0000000
--- a/displayengine/libs/core/scalar_helper.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2015, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __SCALAR_HELPER_H__
-#define __SCALAR_HELPER_H__
-
-#ifdef USES_SCALAR
-
-#include <sys/types.h>
-#include <linux/msm_mdp_ext.h>
-#include <hw_interface.h>
-#include <scalar.h>
-
-#define SCALAR_LIBRARY_NAME "libscalar.so"
-
-namespace sde {
-
-class ScalarHelper {
-
- public:
- void Init();
- void Deinit();
- bool ConfigureScale(HWLayers *hw_layers);
- void UpdateSrcWidth(uint32_t index, bool left, uint32_t* src_width);
- void SetScaleData(uint32_t index, bool left, mdp_scale_data* mdp_scale);
- static ScalarHelper* GetInstance();
-
- private:
- explicit ScalarHelper() { }
- struct ScaleData {
- scalar::Scale left_scale;
- scalar::Scale right_scale;
- };
- struct ScaleData scale_data_[kMaxSDELayers];
- void* lib_scalar_handle_;
- int (*ScalarConfigureScale)(struct scalar::LayerInfo* layer);
- scalar::Scale* GetScaleRef(uint32_t index, bool left) {
- return (left ? &scale_data_[index].left_scale : &scale_data_[index].right_scale);
- }
- static ScalarHelper* scalar_helper_; // Singleton Instance
-};
-
-} // namespace sde
-
-#endif
-#endif // __SCALAR_HELPER_H__
diff --git a/displayengine/libs/core/strategy_default.cpp b/displayengine/libs/core/strategy_default.cpp
deleted file mode 100644
index 48fc79d..0000000
--- a/displayengine/libs/core/strategy_default.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-* Copyright (c) 2014, 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 met:
-* * Redistributions of source code must retain the above copyright notice, this list of
-* conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright notice, this list of
-* conditions and the following disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-* endorse or promote products derived from this software without specific prior written
-* permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <utils/constants.h>
-#include <utils/debug.h>
-
-#include "strategy_default.h"
-
-#define __CLASS__ "StrategyDefault"
-
-namespace sde {
-
-StrategyDefault::StrategyDefault() : hw_layers_info_(NULL) {
-}
-
-DisplayError StrategyDefault::CreateStrategyInterface(uint16_t version, DisplayType type,
- const HWResourceInfo *hw_resource_info,
- const HWPanelInfo *hw_panel_info,
- StrategyInterface **interface) {
- StrategyDefault *strategy_default = new StrategyDefault();
-
- if (!strategy_default) {
- return kErrorMemory;
- }
-
- *interface = strategy_default;
-
- return kErrorNone;
-}
-
-DisplayError StrategyDefault::DestroyStrategyInterface(StrategyInterface *interface) {
- StrategyDefault *strategy_default = static_cast<StrategyDefault *>(interface);
-
- if (!strategy_default) {
- return kErrorParameters;
- }
-
- delete strategy_default;
-
- return kErrorNone;
-}
-
-DisplayError StrategyDefault::Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts) {
- if (!hw_layers_info) {
- return kErrorParameters;
- }
-
- hw_layers_info_ = hw_layers_info;
- *max_attempts = 1;
-
- return kErrorNone;
-}
-
-DisplayError StrategyDefault::Stop() {
- return kErrorNone;
-}
-
-DisplayError StrategyDefault::GetNextStrategy(StrategyConstraints *constraints) {
- // Mark all layers for GPU composition. Find GPU target buffer and store its index for programming
- // the hardware.
- LayerStack *layer_stack = hw_layers_info_->stack;
- uint32_t &hw_layer_count = hw_layers_info_->count;
-
- hw_layer_count = 0;
- for (uint32_t i = 0; i < layer_stack->layer_count; i++) {
- LayerComposition &composition = layer_stack->layers[i].composition;
- if (composition != kCompositionGPUTarget) {
- composition = kCompositionGPU;
- } else {
- hw_layers_info_->index[hw_layer_count++] = i;
- }
- }
-
- // There can be one and only one GPU target buffer.
- if (hw_layer_count != 1) {
- return kErrorParameters;
- }
-
- return kErrorNone;
-}
-
-} // namespace sde
-
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index 02f0c7e..10f5943 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -146,6 +146,7 @@
case HAL_PIXEL_FORMAT_YCbCr_420_SP: return MDP_Y_CBCR_H2V2;
case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO: return MDP_Y_CBCR_H2V2_ADRENO;
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: return MDP_Y_CBCR_H2V2_VENUS;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS: return MDP_Y_CRCB_H2V2_VENUS;
case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: return MDP_Y_CBCR_H2V2;
}
return -1;
diff --git a/libgralloc/adreno_utils.h b/libgralloc/adreno_utils.h
index 78f49da..31f9d52 100644
--- a/libgralloc/adreno_utils.h
+++ b/libgralloc/adreno_utils.h
@@ -26,7 +26,7 @@
typedef enum {
ADRENO_PIXELFORMAT_UNKNOWN = 0,
- ADRENO_PIXELFORMAT_R8G8B8A8 = 27,
+ ADRENO_PIXELFORMAT_R8G8B8A8 = 28,
ADRENO_PIXELFORMAT_R8G8B8A8_SRGB = 29,
ADRENO_PIXELFORMAT_B5G6R5 = 85,
ADRENO_PIXELFORMAT_B5G5R5A1 = 86,
@@ -37,6 +37,7 @@
ADRENO_PIXELFORMAT_YUY2 = 107,
ADRENO_PIXELFORMAT_B4G4R4A4 = 115,
ADRENO_PIXELFORMAT_NV12_EXT = 506, // NV12 with non-std alignment and offsets
+ ADRENO_PIXELFORMAT_R8G8B8X8 = 507, // GL_RGB8 (Internal)
ADRENO_PIXELFORMAT_R8G8B8 = 508, // GL_RGB8
ADRENO_PIXELFORMAT_A1B5G5R5 = 519, // GL_RGB5_A1
ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520, // GL_SRGB8
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 4f342db..695de9b 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -49,6 +49,28 @@
#define ASTC_BLOCK_SIZE 16
+#ifndef ION_FLAG_CP_PIXEL
+#define ION_FLAG_CP_PIXEL 0
+#endif
+
+#ifndef ION_FLAG_ALLOW_NON_CONTIG
+#define ION_FLAG_ALLOW_NON_CONTIG 0
+#endif
+
+#ifdef MASTER_SIDE_CP
+#define CP_HEAP_ID ION_SECURE_HEAP_ID
+/* Please Add the new SD ION Heap here */
+#define SD_HEAP_ID 0
+#define ION_CP_FLAGS (ION_SECURE | ION_FLAG_CP_PIXEL)
+/* Please Add the new SD ION Flag here */
+#define ION_SD_FLAGS ION_SECURE
+#else // SLAVE_SIDE_CP
+#define CP_HEAP_ID ION_CP_MM_HEAP_ID
+#define SD_HEAP_ID CP_HEAP_ID
+#define ION_CP_FLAGS (ION_SECURE | ION_FLAG_ALLOW_NON_CONTIG)
+#define ION_SD_FLAGS ION_SECURE
+#endif
+
using namespace gralloc;
using namespace qdutils;
@@ -97,6 +119,16 @@
*(void **)&LINK_adreno_isUBWCSupportedByGpu =
::dlsym(libadreno_utils, "isUBWCSupportedByGpu");
}
+
+ // Check if the overriding property debug.gralloc.gfx_ubwc_disable
+ // that disables UBWC allocations for the graphics stack is set
+ gfx_ubwc_disable = 0;
+ char property[PROPERTY_VALUE_MAX];
+ property_get("debug.gralloc.gfx_ubwc_disable", property, "0");
+ if(!(strncmp(property, "1", PROPERTY_VALUE_MAX)) ||
+ !(strncmp(property, "true", PROPERTY_VALUE_MAX))) {
+ gfx_ubwc_disable = 1;
+ }
}
AdrenoMemInfo::~AdrenoMemInfo()
@@ -121,15 +153,17 @@
int usage, int& aligned_w, int& aligned_h)
{
+ bool ubwc_enabled = isUBwcEnabled(format, usage);
+
// Currently surface padding is only computed for RGB* surfaces.
if (format <= HAL_PIXEL_FORMAT_sRGB_X_8888) {
- int tileEnabled = isMacroTileEnabled(format, usage);
+ int tileEnabled = ubwc_enabled || isMacroTileEnabled(format, usage);
AdrenoMemInfo::getInstance().getGpuAlignedWidthHeight(width,
height, format, tileEnabled, aligned_w, aligned_h);
return;
}
- if (isUBwcEnabled(format, usage)) {
+ if (ubwc_enabled) {
getUBwcWidthAndHeight(width, height, format, aligned_w, aligned_h);
return;
}
@@ -140,9 +174,11 @@
{
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
- case HAL_PIXEL_FORMAT_RAW_SENSOR:
aligned_w = ALIGN(width, 32);
break;
+ case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ aligned_w = ALIGN(width, 16);
+ break;
case HAL_PIXEL_FORMAT_RAW10:
aligned_w = ALIGN(width * 10 /8, 16);
break;
@@ -162,6 +198,10 @@
aligned_w = VENUS_Y_STRIDE(COLOR_FMT_NV12, width);
aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV12, height);
break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+ aligned_w = VENUS_Y_STRIDE(COLOR_FMT_NV21, width);
+ aligned_h = VENUS_Y_SCANLINES(COLOR_FMT_NV21, height);
+ break;
case HAL_PIXEL_FORMAT_BLOB:
break;
case HAL_PIXEL_FORMAT_NV21_ZSL:
@@ -271,7 +311,7 @@
int AdrenoMemInfo::isUBWCSupportedByGPU(int format)
{
- if (libadreno_utils) {
+ if (!gfx_ubwc_disable && libadreno_utils) {
if (LINK_adreno_isUBWCSupportedByGpu) {
ADRENOPIXELFORMAT gpu_format = getGpuPixelFormat(format);
return LINK_adreno_isUBWCSupportedByGpu(gpu_format);
@@ -285,6 +325,8 @@
switch (hal_format) {
case HAL_PIXEL_FORMAT_RGBA_8888:
return ADRENO_PIXELFORMAT_R8G8B8A8;
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ return ADRENO_PIXELFORMAT_R8G8B8X8;
case HAL_PIXEL_FORMAT_RGB_565:
return ADRENO_PIXELFORMAT_B5G6R5;
case HAL_PIXEL_FORMAT_sRGB_A_8888:
@@ -334,13 +376,17 @@
if(usage & GRALLOC_USAGE_PROTECTED) {
if (usage & GRALLOC_USAGE_PRIVATE_MM_HEAP) {
- ionHeapId |= ION_HEAP(ION_CP_MM_HEAP_ID);
- ionFlags |= ION_SECURE;
-#ifdef ION_FLAG_ALLOW_NON_CONTIG
- if (!(usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY)) {
- ionFlags |= ION_FLAG_ALLOW_NON_CONTIG;
+ if (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY) {
+ ionHeapId = ION_HEAP(SD_HEAP_ID);
+ /*
+ * There is currently no flag in ION for Secure Display
+ * VM. Please add it to the define once available.
+ */
+ ionFlags |= ION_SD_FLAGS;
+ } else {
+ ionHeapId = ION_HEAP(CP_HEAP_ID);
+ ionFlags |= ION_CP_FLAGS;
}
-#endif
} else {
// for targets/OEMs which do not need HW level protection
// do not set ion secure flag & MM heap. Fallback to system heap.
@@ -497,6 +543,9 @@
case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
size = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, width, height);
break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+ size = VENUS_BUFFER_SIZE(COLOR_FMT_NV21, width, height);
+ break;
case HAL_PIXEL_FORMAT_BLOB:
if(height != 1) {
ALOGE("%s: Buffers with format HAL_PIXEL_FORMAT_BLOB \
@@ -582,9 +631,9 @@
void getBufferAttributes(int width, int height, int format, int usage,
- int& alignedw, int &alignedh, int& tileEnabled, unsigned int& size)
+ int& alignedw, int &alignedh, int& tiled, unsigned int& size)
{
- tileEnabled = isMacroTileEnabled(format, usage);
+ tiled = isUBwcEnabled(format, usage) || isMacroTileEnabled(format, usage);
AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
height,
@@ -660,6 +709,7 @@
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCrCb_422_SP:
case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
case HAL_PIXEL_FORMAT_NV21_ZSL:
case HAL_PIXEL_FORMAT_RAW_SENSOR:
case HAL_PIXEL_FORMAT_RAW10:
@@ -767,6 +817,7 @@
{
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_sRGB_A_8888:
case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
@@ -859,7 +910,7 @@
meta_width = ALIGN(((width + block_width - 1) / block_width), 64);
// Align meta buffer size to 4K
- size = ((meta_width * meta_height), 4096);
+ size = ALIGN((meta_width * meta_height), 4096);
return size;
}
@@ -873,6 +924,7 @@
size += getUBwcMetaBufferSize(width, height, 2);
break;
case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_sRGB_A_8888:
size = alignedw * alignedh * 4;
size += getUBwcMetaBufferSize(width, height, 4);
@@ -888,3 +940,38 @@
}
return size;
}
+
+int getRgbDataAddress(private_handle_t* hnd, void** rgb_data)
+{
+ int err = 0;
+
+ // This api is for RGB* formats
+ if (hnd->format > HAL_PIXEL_FORMAT_sRGB_X_8888) {
+ return -EINVAL;
+ }
+
+ // linear buffer
+ if (!(hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED)) {
+ *rgb_data = (void*)hnd->base;
+ return err;
+ }
+
+ unsigned int meta_size = 0;
+ switch (hnd->format) {
+ case HAL_PIXEL_FORMAT_RGB_565:
+ meta_size = getUBwcMetaBufferSize(hnd->width, hnd->height, 2);
+ break;
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_sRGB_A_8888:
+ meta_size = getUBwcMetaBufferSize(hnd->width, hnd->height, 4);
+ break;
+ default:
+ ALOGE("%s:Unsupported RGB format: 0x%x", __FUNCTION__, hnd->format);
+ err = -EINVAL;
+ break;
+ }
+
+ *rgb_data = (void*)(hnd->base + meta_size);
+ return err;
+}
diff --git a/libgralloc/alloc_controller.h b/libgralloc/alloc_controller.h
index f0b8ed9..919e572 100644
--- a/libgralloc/alloc_controller.h
+++ b/libgralloc/alloc_controller.h
@@ -29,6 +29,17 @@
#ifndef GRALLOC_ALLOCCONTROLLER_H
#define GRALLOC_ALLOCCONTROLLER_H
+#define SZ_2M 0x200000
+#define SZ_1M 0x100000
+#define SZ_4K 0x1000
+
+/* TODO: Move this to the common makefile */
+#ifdef MASTER_SIDE_CP
+#define SECURE_ALIGN SZ_4K
+#else
+#define SECURE_ALIGN SZ_1M
+#endif
+
namespace gralloc {
struct alloc_data;
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index 9be93d6..256b023 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -26,11 +26,10 @@
#include "memalloc.h"
#include "alloc_controller.h"
#include <qdMetaData.h>
+#include <linux/msm_ion.h>
using namespace gralloc;
-#define SZ_1M 0x100000
-
gpu_context_t::gpu_context_t(const private_module_t* module,
IAllocController* alloc_ctrl ) :
mAllocCtrl(alloc_ctrl)
@@ -64,10 +63,14 @@
else
data.align = getpagesize();
- /* force 1MB alignment selectively for secure buffers, MDP5 onwards */
if ((usage & GRALLOC_USAGE_PROTECTED) &&
(usage & GRALLOC_USAGE_PRIVATE_MM_HEAP)) {
- data.align = ALIGN((int) data.align, SZ_1M);
+ if (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY) {
+ /* The alignment here reflects qsee mmu V7L/V8L requirement */
+ data.align = SZ_2M;
+ } else {
+ data.align = SECURE_ALIGN;
+ }
size = ALIGN(size, data.align);
}
@@ -142,9 +145,10 @@
flags |= private_handle_t::PRIV_FLAGS_TILE_RENDERED;
}
- if (AdrenoMemInfo::getInstance().isUBWCSupportedByGPU(format) &&
- isUBwcEnabled(format, usage)) {
+ if (isUBwcEnabled(format, usage) &&
+ AdrenoMemInfo::getInstance().isUBWCSupportedByGPU(format)) {
flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
+ flags |= private_handle_t::PRIV_FLAGS_TILE_RENDERED;
}
if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) {
@@ -295,6 +299,25 @@
grallocFormat = HAL_PIXEL_FORMAT_RGBA_8888;
}
+ bool useFbMem = false;
+ char property[PROPERTY_VALUE_MAX];
+ char isUBWC[PROPERTY_VALUE_MAX];
+ if (usage & GRALLOC_USAGE_HW_FB) {
+ if ((property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) &&
+ (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
+ (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
+ useFbMem = true;
+ } else {
+ if (property_get("debug.gralloc.enable_fb_ubwc", isUBWC, NULL) > 0){
+ if ((!strncmp(isUBWC, "1", PROPERTY_VALUE_MAX)) ||
+ (!strncasecmp(isUBWC, "true", PROPERTY_VALUE_MAX))) {
+ // Allocate UBWC aligned framebuffer
+ usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ }
+ }
+ }
+ }
+
getGrallocInformationFromFormat(grallocFormat, &bufferType);
size = getBufferSizeAndDimensions(w, h, grallocFormat, usage, alignedw,
alignedh);
@@ -303,15 +326,6 @@
return -EINVAL;
size = (bufferSize >= size)? bufferSize : size;
- bool useFbMem = false;
- char property[PROPERTY_VALUE_MAX];
- if((usage & GRALLOC_USAGE_HW_FB) &&
- (property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) &&
- (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
- (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
- useFbMem = true;
- }
-
int err = 0;
if(useFbMem) {
err = gralloc_alloc_framebuffer(usage, pHandle);
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index 5ee0cf8..e27203a 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -71,6 +71,7 @@
int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage);
void free_buffer(private_handle_t *hnd);
int getYUVPlaneInfo(private_handle_t* pHnd, struct android_ycbcr* ycbcr);
+int getRgbDataAddress(private_handle_t* pHnd, void** rgb_data);
// To query if UBWC is enabled, based on format and usage flags
bool isUBwcEnabled(int format, int usage);
@@ -148,6 +149,8 @@
ADRENOPIXELFORMAT getGpuPixelFormat(int hal_format);
private:
+ // Overriding flag to disable UBWC alloc for graphics stack
+ int gfx_ubwc_disable;
// Pointer to the padding library.
void *libadreno_utils;
diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h
index 676c3bc..2601953 100755
--- a/libgralloc/gralloc_priv.h
+++ b/libgralloc/gralloc_priv.h
@@ -85,6 +85,7 @@
#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7
#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
+#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
/* OEM specific HAL formats */
@@ -103,6 +104,7 @@
#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111
#define HAL_PIXEL_FORMAT_BGRX_8888 0x112
#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114
#define HAL_PIXEL_FORMAT_INTERLACE 0x180
//v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index acac5b4..cf365ce 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -66,8 +66,11 @@
unsigned int size = 0;
int err = 0;
IMemAlloc* memalloc = getAllocator(hnd->flags) ;
- void *mappedAddress;
- // Dont map FRAMEBUFFER and SECURE_BUFFERS
+ void *mappedAddress = MAP_FAILED;
+ hnd->base = 0;
+ hnd->base_metadata = 0;
+
+ // Dont map framebuffer and secure buffers
if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) &&
!(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) {
size = hnd->size;
@@ -76,14 +79,14 @@
if(err || mappedAddress == MAP_FAILED) {
ALOGE("Could not mmap handle %p, fd=%d (%s)",
handle, hnd->fd, strerror(errno));
- hnd->base = 0;
return -errno;
}
hnd->base = uint64_t(mappedAddress) + hnd->offset;
}
- //Allow mapping of metadata for all buffers and SECURE_BUFFER
+ //Allow mapping of metadata for all buffers including secure ones, but not
+ //of framebuffer
if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) {
mappedAddress = MAP_FAILED;
size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
@@ -92,7 +95,6 @@
if(err || mappedAddress == MAP_FAILED) {
ALOGE("Could not mmap handle %p, fd=%d (%s)",
handle, hnd->fd_metadata, strerror(errno));
- hnd->base_metadata = 0;
return -errno;
}
hnd->base_metadata = uint64_t(mappedAddress) + hnd->offset_metadata;
@@ -104,32 +106,37 @@
buffer_handle_t handle)
{
ATRACE_CALL();
+ int err = -EINVAL;
if(!module)
- return -EINVAL;
+ return err;
private_handle_t* hnd = (private_handle_t*)handle;
- if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) {
- int err = -EINVAL;
- void* base = (void*)hnd->base;
- unsigned int size = hnd->size;
- IMemAlloc* memalloc = getAllocator(hnd->flags) ;
- if(memalloc != NULL) {
- err = memalloc->unmap_buffer(base, size, hnd->offset);
- if (err) {
- ALOGE("Could not unmap memory at address %p", base);
- }
- base = (void*)hnd->base_metadata;
- size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
- err = memalloc->unmap_buffer(base, size, hnd->offset_metadata);
- if (err) {
- ALOGE("Could not unmap memory at address %p", base);
- }
+ IMemAlloc* memalloc = getAllocator(hnd->flags) ;
+ if(!memalloc)
+ return err;
+
+ if(hnd->base) {
+ err = memalloc->unmap_buffer((void*)hnd->base, hnd->size, hnd->offset);
+ if (err) {
+ ALOGE("Could not unmap memory at address %p, %s", hnd->base,
+ strerror(errno));
+ return -errno;
}
+ hnd->base = 0;
}
- /* need to initialize the pointer to NULL otherwise unmapping for that
- * buffer happens twice which leads to crash */
- hnd->base = 0;
- hnd->base_metadata = 0;
+
+ if(hnd->base_metadata) {
+ unsigned int size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
+ err = memalloc->unmap_buffer((void*)hnd->base_metadata,
+ size, hnd->offset_metadata);
+ if (err) {
+ ALOGE("Could not unmap memory at address %p, %s",
+ hnd->base_metadata, strerror(errno));
+ return -errno;
+ }
+ hnd->base_metadata = 0;
+ }
+
return 0;
}
@@ -146,8 +153,6 @@
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;
- // In this implementation, we don't need to do anything here
-
/* NOTE: we need to initialize the buffer as not mapped/not locked
* because it shouldn't when this function is called the first time
* in a new process. Ideally these flags shouldn't be part of the
@@ -155,9 +160,6 @@
* out-of-line
*/
- private_handle_t* hnd = (private_handle_t*)handle;
- hnd->base = 0;
- hnd->base_metadata = 0;
int err = gralloc_map(module, handle);
if (err) {
ALOGE("%s: gralloc_map failed", __FUNCTION__);
@@ -178,16 +180,9 @@
* If the buffer has been mapped during a lock operation, it's time
* to un-map it. It's an error to be here with a locked buffer.
* NOTE: the framebuffer is handled differently and is never unmapped.
+ * Also base and base_metadata are reset.
*/
-
- private_handle_t* hnd = (private_handle_t*)handle;
-
- if (hnd->base != 0) {
- gralloc_unmap(module, handle);
- }
- hnd->base = 0;
- hnd->base_metadata = 0;
- return 0;
+ return gralloc_unmap(module, handle);
}
int terminateBuffer(gralloc_module_t const* module,
@@ -200,20 +195,10 @@
/*
* If the buffer has been mapped during a lock operation, it's time
* to un-map it. It's an error to be here with a locked buffer.
+ * NOTE: the framebuffer is handled differently and is never unmapped.
+ * Also base and base_metadata are reset.
*/
-
- if (hnd->base != 0) {
- // this buffer was mapped, unmap it now
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
- gralloc_unmap(module, hnd);
- } else {
- ALOGE("terminateBuffer: unmapping a non pmem/ashmem buffer flags = 0x%x",
- hnd->flags);
- gralloc_unmap(module, hnd);
- }
- }
-
- return 0;
+ return gralloc_unmap(module, hnd);
}
static int gralloc_map_and_invalidate (gralloc_module_t const* module,
@@ -401,7 +386,8 @@
int *alignedWidth = va_arg(args, int *);
int *alignedHeight = va_arg(args, int *);
int *tileEnabled = va_arg(args,int *);
- *tileEnabled = isMacroTileEnabled(format, usage);
+ *tileEnabled = isUBwcEnabled(format, usage) ||
+ isMacroTileEnabled(format, usage);
AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
height, format, usage, *alignedWidth, *alignedHeight);
res = 0;
@@ -457,6 +443,15 @@
res = 0;
} break;
+ case GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS:
+ {
+ private_handle_t* hnd = va_arg(args, private_handle_t*);
+ void** rgb_data = va_arg(args, void**);
+ if (!private_handle_t::validate(hnd)) {
+ res = getRgbDataAddress(hnd, rgb_data);
+ }
+ } break;
+
default:
break;
}
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 7423c29..c51efba 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -281,13 +281,15 @@
hwc_context_t* ctx = (hwc_context_t*)(dev);
const int dpy = HWC_DISPLAY_PRIMARY;
bool fbComp = false;
-
+ static int compStart = false;
if (!ctx->mBootAnimCompleted)
processBootAnimCompleted(ctx);
- if (LIKELY(list && list->numHwLayers > 1) && ctx->dpyAttr[dpy].connected &&
- (ctx->dpyAttr[dpy].isActive ||
+ if (LIKELY(list && (list->numHwLayers > 1 ||
+ (ctx->mMDP.version < qdutils::MDP_V4_0 && compStart))) &&
+ ctx->dpyAttr[dpy].connected && (ctx->dpyAttr[dpy].isActive ||
ctx->mHDMIDisplay->isHDMIPrimaryDisplay())
&& !ctx->dpyAttr[dpy].isPause) {
+ compStart = true;
// When HDMI is primary we should rely on the first valid
// draw call in order to activate the display
@@ -623,7 +625,8 @@
supported |= HWC_DISPLAY_VIRTUAL_BIT;
if(!(qdutils::MDPVersion::getInstance().is8x26() ||
qdutils::MDPVersion::getInstance().is8x16() ||
- qdutils::MDPVersion::getInstance().is8x39()))
+ qdutils::MDPVersion::getInstance().is8x39() ||
+ qdutils::MDPVersion::getInstance().is8x52()))
supported |= HWC_DISPLAY_EXTERNAL_BIT;
}
value[0] = supported;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index f44a707..e7c2928 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -82,6 +82,29 @@
return true;
}
+bool CopyBit::isSmartBlitPossible(const hwc_display_contents_1_t *list){
+ if(list->numHwLayers > 2) {
+ hwc_rect_t displayFrame0 = {0, 0, 0, 0};
+ hwc_rect_t displayFrame1 = {0, 0, 0, 0};
+ for (unsigned int i=0; i<list->numHwLayers -1; i++) {
+ hwc_rect_t displayFrame = getIntersection(mDirtyRect,
+ list->hwLayers[i].displayFrame);
+ if (isValidRect(displayFrame) && !isValidRect(displayFrame0)) {
+ displayFrame0 = displayFrame;
+ } else if(isValidRect(displayFrame)) {
+ displayFrame1 = displayFrame;
+ break;
+ }
+ }
+ if((displayFrame0 == displayFrame1) &&
+ not (list->flags & (MDP_ROT_90 | MDP_FLIP_UD | MDP_FLIP_LR))) {
+ ALOGD_IF (DEBUG_COPYBIT, "%s:Smart Bilt Possible",__FUNCTION__);
+ return true;
+ }
+ }
+ return false;
+}
+
bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx,
hwc_display_contents_1_t *list,
int dpy) {
@@ -99,7 +122,11 @@
unsigned int renderArea = getRGBRenderingArea(ctx, list);
ALOGD_IF (DEBUG_COPYBIT, "%s:renderArea %u, fbArea %u",
__FUNCTION__, renderArea, fbArea);
- if (renderArea < (mDynThreshold * fbArea)) {
+ double dynThreshold = mDynThreshold;
+ if(not isSmartBlitPossible(list))
+ dynThreshold -= 1;
+
+ if (renderArea < (dynThreshold * fbArea)) {
return true;
}
} else if ((compositionType & qdutils::COMPOSITION_TYPE_MDP)) {
@@ -148,16 +175,19 @@
return 0;
}
-int CopyBit::getLayersChanging(hwc_context_t *ctx,
- hwc_display_contents_1_t *list,
- int dpy){
-
- int changingLayerIndex = -1;
- if(mLayerCache.layerCount != ctx->listStats[dpy].numAppLayers) {
+bool CopyBit::prepareSwapRect(hwc_context_t *ctx,
+ hwc_display_contents_1_t *list,
+ int dpy) {
+ bool canUseSwapRect = 0;
+ hwc_rect_t dirtyRect = {0, 0, 0, 0};
+ hwc_rect_t displayRect = {0, 0, 0, 0};
+ if((mLayerCache.layerCount != ctx->listStats[dpy].numAppLayers) ||
+ not mSwapRectEnable) {
mLayerCache.reset();
mFbCache.reset();
mLayerCache.updateCounts(ctx,list,dpy);
- return -1;
+ mDirtyRect = displayRect;
+ return 0;
}
int updatingLayerCount = 0;
@@ -165,8 +195,10 @@
//swap rect will kick in only for single updating layer
if(isLayerChanging(ctx, list, k)) {
updatingLayerCount ++;
- if(updatingLayerCount == 1)
- changingLayerIndex = k;
+ hwc_layer_1_t layer = list->hwLayers[k];
+ canUseSwapRect = 1;
+ dirtyRect = getUnion(dirtyRect, layer.dirtyRect);
+ displayRect = getUnion(displayRect, layer.displayFrame);
}
}
//since we are using more than one framebuffers,we have to
@@ -174,19 +206,13 @@
//dirty rect for same layer at least equal of number of
//framebuffers
- if ( updatingLayerCount <= 1 ) {
- hwc_rect_t dirtyRect;
+ if (canUseSwapRect || updatingLayerCount == 0) {
if (updatingLayerCount == 0) {
dirtyRect.left = INVALID_DIMENSION;
dirtyRect.top = INVALID_DIMENSION;
dirtyRect.right = INVALID_DIMENSION;
dirtyRect.bottom = INVALID_DIMENSION;
- changingLayerIndex = NO_UPDATING_LAYER;
- } else {
- dirtyRect = list->hwLayers[changingLayerIndex].displayFrame;
-#ifdef QCOM_BSP
- dirtyRect = list->hwLayers[changingLayerIndex].dirtyRect;
-#endif
+ canUseSwapRect = 1;
}
for (int k = ctx->listStats[dpy].numAppLayers-1; k >= 0 ; k--) {
@@ -195,34 +221,36 @@
if(needsScaling(&list->hwLayers[k])||( hnd && isYuvBuffer(hnd)) ||
(list->hwLayers[k].transform & HAL_TRANSFORM_ROT_90)) {
mFbCache.reset();
- return -1;
+ displayRect.bottom = 0;
+ displayRect.top = 0;
+ displayRect.right = 0;
+ displayRect.bottom = 0;
+ mDirtyRect = displayRect;
+ return 0;
}
}
- hwc_rect_t displayRect = list->hwLayers[changingLayerIndex].displayFrame;
+
if(mFbCache.getUnchangedFbDRCount(dirtyRect, displayRect) <
NUM_RENDER_BUFFERS) {
mFbCache.insertAndUpdateFbCache(dirtyRect, displayRect);
- changingLayerIndex = -1;
+ canUseSwapRect = 0;
+ displayRect.bottom = 0;
+ displayRect.top = 0;
+ displayRect.right = 0;
+ displayRect.bottom = 0;
}
} else {
mFbCache.reset();
- changingLayerIndex = -1;
+ canUseSwapRect = 0;
+ displayRect.bottom = 0;
+ displayRect.top = 0;
+ displayRect.right = 0;
+ displayRect.bottom = 0;
+
}
+ mDirtyRect = displayRect;
mLayerCache.updateCounts(ctx,list,dpy);
- return changingLayerIndex;
-}
-
-int CopyBit::checkDirtyRect(hwc_context_t *ctx,
- hwc_display_contents_1_t *list,
- int dpy) {
-
- //dirty rect will enable only if
- //1.Only single layer is updating.
- //2.No scaling
- //3.No video layer
- if(mSwapRectEnable == false)
- return -1;
- return getLayersChanging(ctx, list, dpy);
+ return canUseSwapRect;
}
bool CopyBit::prepareOverlap(hwc_context_t *ctx,
@@ -326,6 +354,13 @@
return false;
}
+ int last = (uint32_t)list->numHwLayers - 1;
+ mDirtyRect = list->hwLayers[last].displayFrame;
+ mSwapRect = prepareSwapRect(ctx, list, dpy);
+ ALOGD_IF (DEBUG_COPYBIT, "%s: mSwapRect: %d mDirtyRect: [%d, %d, %d, %d]",
+ __FUNCTION__, mSwapRect, mDirtyRect.left,
+ mDirtyRect.top, mDirtyRect.right, mDirtyRect.bottom);
+
bool useCopybitForYUV = canUseCopybitForYUV(ctx);
bool useCopybitForRGB = canUseCopybitForRGB(ctx, list, dpy);
LayerProp *layerProp = ctx->layerProp[dpy];
@@ -498,7 +533,7 @@
list->hwLayers[abcRenderBufIdx].acquireFenceFd);
}
for(int i = abcRenderBufIdx + 1; i < layerCount; i++){
- mDirtyLayerIndex = -1;
+ mSwapRect = 0;
int retVal = drawLayerUsingCopybit(ctx,
&(list->hwLayers[i]),renderBuffer, 0);
if(retVal < 0) {
@@ -559,34 +594,11 @@
}
}
- mDirtyLayerIndex = checkDirtyRect(ctx, list, dpy);
- ALOGD_IF (DEBUG_COPYBIT, "%s:Dirty Layer Index: %d",
- __FUNCTION__, mDirtyLayerIndex);
- // repetitive frame will have mDirtyLayerIndex as NO_UPDATING_LAYER
- if (mDirtyLayerIndex == NO_UPDATING_LAYER) {
- ALOGD_IF (DEBUG_COPYBIT, "%s: No Updating Layers", __FUNCTION__);
- return true;
+ if (not CBUtils::uiClearRegion(list, ctx->mMDP.version, layerProp,
+ mDirtyRect, mEngine, renderBuffer)){
+ mSwapRect = 0;
}
- hwc_rect_t clearRegion = {0,0,0,0};
- mDirtyRect = list->hwLayers[last].displayFrame;
-
- if (CBUtils::getuiClearRegion(list, clearRegion, layerProp,
- mDirtyLayerIndex)) {
- int clear_w = clearRegion.right - clearRegion.left;
- int clear_h = clearRegion.bottom - clearRegion.top;
- //mdp can't handle solid fill for one line
- //making solid fill as full in this case
- //disable swap rect if presents
- if ((clear_w == 1) || (clear_h ==1)) {
- clear(renderBuffer, mDirtyRect);
- mDirtyLayerIndex = -1;
- }else
- clear(renderBuffer, clearRegion);
- }
- if (mDirtyLayerIndex != -1)
- mDirtyRect = list->hwLayers[mDirtyLayerIndex].displayFrame;
-
// numAppLayers-1, as we iterate from 0th layer index with HWC_COPYBIT flag
for (int i = 0; i <= (ctx->listStats[dpy].numAppLayers-1); i++) {
if(!(layerProp[i].mFlags & HWC_COPYBIT)) {
@@ -647,10 +659,10 @@
}
//Clear the transparent or left out region on the render buffer
- hwc_rect_t clearRegion = {0,0,0,0};
LayerProp *layerProp = ctx->layerProp[0];
- if(CBUtils::getuiClearRegion(list, clearRegion, layerProp))
- clear(renderBuffer, clearRegion);
+ hwc_rect_t clearRegion = {0, 0, 0, 0};
+ CBUtils::uiClearRegion(list, ctx->mMDP.version, layerProp, clearRegion,
+ mEngine, renderBuffer);
int copybitLayerCount = 0;
for(int j = 0; j < ptorInfo->count; j++) {
@@ -900,7 +912,7 @@
displayFrame.bottom};
#ifdef QCOM_BSP
//change src and dst with dirtyRect
- if(mDirtyLayerIndex != -1) {
+ if(mSwapRect) {
hwc_rect_t result = getIntersection(displayFrame, mDirtyRect);
if(!isValidRect(result))
return true;
@@ -1071,7 +1083,8 @@
copybit->set_parameter(copybit, COPYBIT_DITHER,
(dst.format == HAL_PIXEL_FORMAT_RGB_565)?
COPYBIT_ENABLE : COPYBIT_DISABLE);
- copybit->set_parameter(copybit, COPYBIT_FG_LAYER, isFG ?
+ copybit->set_parameter(copybit, COPYBIT_FG_LAYER,
+ (layer->blending == HWC_BLENDING_NONE || isFG ) ?
COPYBIT_ENABLE : COPYBIT_DISABLE);
copybit->set_parameter(copybit, COPYBIT_BLIT_TO_FRAMEBUFFER,
@@ -1145,9 +1158,10 @@
unsigned int& width, unsigned int& height)
{
hwc_rect_t displayFrame = layer->displayFrame;
+ hwc_rect_t result = getIntersection(mDirtyRect, displayFrame);
- width = displayFrame.right - displayFrame.left;
- height = displayFrame.bottom - displayFrame.top;
+ width = result.right - result.left;
+ height = result.bottom - result.top;
}
bool CopyBit::validateParams(hwc_context_t *ctx,
@@ -1236,7 +1250,7 @@
property_get("debug.sf.swaprect", value, "0");
mSwapRectEnable = atoi(value) ? true:false ;
- mDirtyLayerIndex = -1;
+ mSwapRect = 0;
if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) {
if(copybit_open(module, &mEngine) < 0) {
ALOGE("FATAL ERROR: copybit open failed.");
diff --git a/libhwcomposer/hwc_copybit.h b/libhwcomposer/hwc_copybit.h
index 993c790..a1601cc 100644
--- a/libhwcomposer/hwc_copybit.h
+++ b/libhwcomposer/hwc_copybit.h
@@ -131,16 +131,15 @@
bool mSwapRectEnable;
int mAlignedWidth;
int mAlignedHeight;
- int mDirtyLayerIndex;
+ int mSwapRect;
LayerCache mLayerCache;
FbCache mFbCache;
hwc_rect_t mDirtyRect;
- int getLayersChanging(hwc_context_t *ctx, hwc_display_contents_1_t *list,
- int dpy);
- int checkDirtyRect(hwc_context_t *ctx, hwc_display_contents_1_t *list,
+ bool prepareSwapRect(hwc_context_t *ctx, hwc_display_contents_1_t *list,
int dpy);
bool isLayerChanging(hwc_context_t *ctx,
hwc_display_contents_1_t *list, int k);
+ bool isSmartBlitPossible(const hwc_display_contents_1_t *list);
};
}; //namespace qhwc
diff --git a/libhwcomposer/hwc_dump_layers.cpp b/libhwcomposer/hwc_dump_layers.cpp
index aad984d..fca8a5c 100644
--- a/libhwcomposer/hwc_dump_layers.cpp
+++ b/libhwcomposer/hwc_dump_layers.cpp
@@ -448,6 +448,9 @@
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
strlcpy(pixFormatStr, "YCbCr_420_SP_VENUS", sizeof(pixFormatStr));
break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+ strlcpy(pixFormatStr, "YCrCb_420_SP_VENUS", sizeof(pixFormatStr));
+ break;
default:
size_t len = sizeof(pixFormatStr);
snprintf(pixFormatStr, len, "Unknown0x%X", format);
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index fdd7f0f..e2c4677 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -55,6 +55,7 @@
int (*MDPComp::sPerfLockAcquire)(int, int, int*, int) = NULL;
int (*MDPComp::sPerfLockRelease)(int value) = NULL;
int MDPComp::sPerfHintWindow = -1;
+float MDPComp::sDownscaleThreshold = 1.0;
enum AllocOrder { FORMAT_YUV, FORMAT_RGB, FORMAT_MAX };
@@ -177,10 +178,11 @@
bool defaultPTOR = false;
//Enable PTOR when "persist.hwc.ptor.enable" is not defined for
- //8x16 and 8x39 targets by default
+ //Bear family targets by default
if((property_get("persist.hwc.ptor.enable", property, NULL) <= 0) &&
(qdutils::MDPVersion::getInstance().is8x16() ||
- qdutils::MDPVersion::getInstance().is8x39())) {
+ qdutils::MDPVersion::getInstance().is8x39() ||
+ qdutils::MDPVersion::getInstance().is8x52())) {
defaultPTOR = true;
}
@@ -211,6 +213,10 @@
}
}
+ if(property_get("persist.hwc.downscale_threshold", property, "1.0") > 0) {
+ sDownscaleThreshold = (float)atof(property);
+ }
+
return true;
}
@@ -429,6 +435,24 @@
//More conditions here, sRGB+Blend etc
return false;
}
+
+ //In targets with fewer pipes, frequent composition switch between MDP/GPU
+ //can happen for a layer due to lack of pipes. When this switch happens
+ //continuously for RGB downscaled layer with downscale greater than
+ //threshold, it appears as flicker as output
+ //of MDP and GPU are different as they use different filters for downscale.
+ //To avoid this flicker, punt RGB downscaled layer with downscale greater
+ //than threshold value to GPU always.
+ if((sDownscaleThreshold > 1.0)) {
+ if(((not isYuvBuffer(hnd))
+ and (not isDownscaleWithinThreshold(layer,
+ sDownscaleThreshold)))) {
+ ALOGD_IF(isDebug(), "%s: required downscale is greater than \
+ threshold %f", __FUNCTION__, sDownscaleThreshold);
+ return false;
+ }
+ }
+
return true;
}
@@ -530,18 +554,15 @@
if(!isEnabled()) {
ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__);
ret = false;
- } else if((qdutils::MDPVersion::getInstance().is8x26() ||
- qdutils::MDPVersion::getInstance().is8x16() ||
- qdutils::MDPVersion::getInstance().is8x39()) &&
- ctx->mVideoTransFlag &&
- isSecondaryConnected(ctx)) {
+ } else if(ctx->mVideoTransFlag && isSecondaryConnected(ctx)) {
//1 Padding round to shift pipes across mixers
ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round",
__FUNCTION__);
ret = false;
} else if((qdutils::MDPVersion::getInstance().is8x26() ||
qdutils::MDPVersion::getInstance().is8x16() ||
- qdutils::MDPVersion::getInstance().is8x39()) &&
+ qdutils::MDPVersion::getInstance().is8x39() ||
+ qdutils::MDPVersion::getInstance().is8x52()) &&
!mDpy && isSecondaryAnimating(ctx) &&
isYuvPresent(ctx,HWC_DISPLAY_VIRTUAL)) {
ALOGD_IF(isDebug(),"%s: Display animation in progress",
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index db68e82..5c43aa7 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -283,6 +283,7 @@
static int (*sPerfLockAcquire)(int, int, int*, int);
static int (*sPerfLockRelease)(int value);
static int sPerfHintWindow;
+ static float sDownscaleThreshold;
};
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 2f5aed0..5de3081 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -554,7 +554,37 @@
}
}
-//Helper to roundoff the refreshrates
+uint32_t getRefreshRate(hwc_context_t* ctx, uint32_t requestedRefreshRate) {
+
+ qdutils::MDPVersion& mdpHw = qdutils::MDPVersion::getInstance();
+ int dpy = HWC_DISPLAY_PRIMARY;
+ uint32_t defaultRefreshRate = ctx->dpyAttr[dpy].refreshRate;
+ uint32_t rate = defaultRefreshRate;
+
+ if(!requestedRefreshRate)
+ return defaultRefreshRate;
+
+ uint32_t maxNumIterations =
+ (uint32_t)ceil(
+ (float)mdpHw.getMaxFpsSupported()/
+ (float)requestedRefreshRate);
+
+ for(uint32_t i = 1; i <= maxNumIterations; i++) {
+ rate = roundOff(i * requestedRefreshRate);
+ if(rate < mdpHw.getMinFpsSupported()) {
+ continue;
+ } else if((rate >= mdpHw.getMinFpsSupported() &&
+ rate <= mdpHw.getMaxFpsSupported())) {
+ break;
+ } else {
+ rate = defaultRefreshRate;
+ break;
+ }
+ }
+ return rate;
+}
+
+//Helper to roundoff the refreshrates to the std refresh-rates
uint32_t roundOff(uint32_t refreshRate) {
int count = (int) (sizeof(stdRefreshRates)/sizeof(stdRefreshRates[0]));
uint32_t rate = refreshRate;
@@ -937,11 +967,39 @@
src_w = sourceCrop.right - sourceCrop.left;
src_h = sourceCrop.bottom - sourceCrop.top;
+ if(layer->transform & HWC_TRANSFORM_ROT_90)
+ swap(src_w, src_h);
+
if(((src_w > dst_w) || (src_h > dst_h)))
return true;
return false;
}
+
+bool isDownscaleWithinThreshold(hwc_layer_1_t const* layer, float threshold) {
+ hwc_rect_t displayFrame = layer->displayFrame;
+ hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
+ int dst_w, dst_h, src_w, src_h;
+ float downscale = 1.0;
+ dst_w = displayFrame.right - displayFrame.left;
+ dst_h = displayFrame.bottom - displayFrame.top;
+ src_w = sourceCrop.right - sourceCrop.left;
+ src_h = sourceCrop.bottom - sourceCrop.top;
+
+ if(layer->transform & HWC_TRANSFORM_ROT_90)
+ swap(src_w, src_h);
+
+ if(dst_w && dst_h) {
+ float w_scale = ((float)src_w / (float)dst_w);
+ float h_scale = ((float)src_h / (float)dst_h);
+
+ if((w_scale > threshold) or (h_scale > threshold))
+ return false;
+ }
+
+ return true;
+}
+
bool needsScaling(hwc_layer_1_t const* layer) {
int dst_w, dst_h, src_w, src_h;
hwc_rect_t displayFrame = layer->displayFrame;
@@ -1175,21 +1233,18 @@
#ifdef DYNAMIC_FPS
if (!dpy && mdpHw.isDynFpsSupported() && ctx->mUseMetaDataRefreshRate){
- //dyn fps: get refreshrate from metadata
- //Support multiple refresh rates if they are same
- //else set to default
+ /* Dyn fps: get refreshrate from metadata */
MetaData_t *mdata = hnd ? (MetaData_t *)hnd->base_metadata : NULL;
if (mdata && (mdata->operation & UPDATE_REFRESH_RATE)) {
// Valid refreshRate in metadata and within the range
- uint32_t rate = roundOff(mdata->refreshrate);
- if((rate >= mdpHw.getMinFpsSupported() &&
- rate <= mdpHw.getMaxFpsSupported())) {
- if (!refreshRate) {
- refreshRate = rate;
- } else if(refreshRate != rate) {
- // multiple refreshrate requests, set to default
- refreshRate = ctx->dpyAttr[dpy].refreshRate;
- }
+ uint32_t rate = getRefreshRate(ctx, mdata->refreshrate);
+ if (!refreshRate) {
+ refreshRate = rate;
+ } else if(refreshRate != rate) {
+ /* Support multiple refresh rates if they are same
+ * else set to default.
+ */
+ refreshRate = ctx->dpyAttr[dpy].refreshRate;
}
}
}
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index a74d59a..4849baf 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -309,6 +309,7 @@
bool isAlphaScaled(hwc_layer_1_t const* layer);
bool needsScaling(hwc_layer_1_t const* layer);
bool isDownscaleRequired(hwc_layer_1_t const* layer);
+bool isDownscaleWithinThreshold(hwc_layer_1_t const* layer, float threshold);
bool needsScalingWithSplit(hwc_context_t* ctx, hwc_layer_1_t const* layer,
const int& dpy);
void sanitizeSourceCrop(hwc_rect_t& cropL, hwc_rect_t& cropR,
@@ -352,6 +353,8 @@
void getAspectRatioPosition(hwc_context_t* ctx, int dpy, int extOrientation,
hwc_rect_t& inRect, hwc_rect_t& outRect);
+uint32_t getRefreshRate(hwc_context_t* ctx, uint32_t requestedRefreshRate);
+
uint32_t roundOff(uint32_t refreshRate);
void setRefreshRate(hwc_context_t *ctx, int dpy, uint32_t refreshRate);
diff --git a/liblight/lights.c b/liblight/lights.c
index 615ddd8..12af384 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -162,7 +162,16 @@
blue = colorRGB & 0xFF;
if (onMS > 0 && offMS > 0) {
- blink = 1;
+ /*
+ * if ON time == OFF time
+ * use blink mode 2
+ * else
+ * use blink mode 1
+ */
+ if (onMS == offMS)
+ blink = 2;
+ else
+ blink = 1;
} else {
blink = 0;
}
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index b7c7fcc..da24382 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -149,10 +149,10 @@
return getPipe_8x16(pipeSpecs);
} else if(MDPVersion::getInstance().is8x39()) {
return getPipe_8x39(pipeSpecs);
+ } else if(MDPVersion::getInstance().is8x52()) {
+ return getPipe_8x52(pipeSpecs);
} else if(MDPVersion::getInstance().is8994()) {
return getPipe_8994(pipeSpecs);
- } else if(MDPVersion::getInstance().is8992()) {
- return getPipe_8992(pipeSpecs);
}
eDest dest = OV_INVALID;
@@ -247,19 +247,18 @@
return getPipe_8x16(pipeSpecs);
}
+utils::eDest Overlay::getPipe_8x52(const PipeSpecs& pipeSpecs) {
+ //8x16 & 8x52 has same number of pipes, pipe-types & scaling capabilities.
+ //Rely on 8x16 until we see a need to change.
+ return getPipe_8x16(pipeSpecs);
+}
+
utils::eDest Overlay::getPipe_8994(const PipeSpecs& pipeSpecs) {
//If DMA pipes need to be used in block mode for downscale, there could be
//cases where consecutive rounds need separate modes, which cannot be
//supported since we at least need 1 round in between where the DMA is
//unused
eDest dest = OV_INVALID;
-
- // Reset format type to FORMAT_NONE to select the pipe irrespective of the
- // format specifed by the client. This is required for the device where
- // SMP starvation is unlikely, we need not keep track of formats
- // programmed in the pipes to avoid potential pipe crunching.
- resetPipeBookFormat(pipeSpecs.dpy);
-
if(pipeSpecs.formatClass == FORMAT_YUV) {
return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
} else {
@@ -271,14 +270,9 @@
dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
}
}
-
return dest;
}
-utils::eDest Overlay::getPipe_8992(const PipeSpecs& pipeSpecs) {
- return getPipe_8994(pipeSpecs);
-}
-
void Overlay::endAllSessions() {
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
if(mPipeBook[i].valid() && mPipeBook[i].mSession==PipeBook::START)
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 49be930..affb4db 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -177,10 +177,8 @@
utils::eDest getPipe_8x26(const PipeSpecs& pipeSpecs);
utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs);
utils::eDest getPipe_8x39(const PipeSpecs& pipeSpecs);
+ utils::eDest getPipe_8x52(const PipeSpecs& pipeSpecs);
utils::eDest getPipe_8994(const PipeSpecs& pipeSpecs);
- utils::eDest getPipe_8992(const PipeSpecs& pipeSpecs);
-
- void resetPipeBookFormat(const int &dpy);
/* Returns the handle to libscale.so's programScale function */
static int (*getFnProgramScale())(struct mdp_overlay_list *);
@@ -344,7 +342,8 @@
inline bool Overlay::isUIScalingOnExternalSupported() {
if(qdutils::MDPVersion::getInstance().is8x26() or
qdutils::MDPVersion::getInstance().is8x16() or
- qdutils::MDPVersion::getInstance().is8x39()) {
+ qdutils::MDPVersion::getInstance().is8x39() or
+ qdutils::MDPVersion::getInstance().is8x52()) {
return false;
}
return true;
@@ -446,14 +445,6 @@
return "Invalid";
}
-inline void Overlay::resetPipeBookFormat(const int &dpy) {
- for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
- if (mPipeBook[i].mDisplay == dpy) {
- mPipeBook[i].mFormatType = FORMAT_NONE;
- }
- }
-}
-
}; // overlay
#endif // OVERLAY_H
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 828f4fc..95bdc23 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -399,7 +399,7 @@
int errVal = mdp_wrapper::validateAndSet(fbFd, list);
if(errVal) {
/* No dump for failure due to insufficient resource */
- if(errVal != E2BIG) {
+ if(errVal != E2BIG && errVal != EBADSLT) {
//ENODEV is returned when the driver cannot satisfy a pipe request.
//This could happen if previous round's UNSET hasn't been commited
//yet, either because of a missed vsync or because of difference in
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index b37eba9..d87bee6 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -128,6 +128,8 @@
//NV12 encodeable format maps to the venus format on
//B-Family targets
return MDP_Y_CBCR_H2V2_VENUS;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+ return MDP_Y_CRCB_H2V2_VENUS;
default:
//Unsupported by MDP
//---gralloc_priv.h-----
@@ -227,6 +229,8 @@
return HAL_PIXEL_FORMAT_YCrCb_444_SP;
case MDP_Y_CBCR_H2V2_VENUS:
return HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
+ case MDP_Y_CRCB_H2V2_VENUS:
+ return HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS;
default:
ALOGE("%s: Unsupported MDP format = 0x%x", __func__, mdpFormat);
return -1;
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index 5e3bd1f..17ec268 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -420,6 +420,7 @@
case MDP_Y_CR_CB_H2V2:
case MDP_Y_CR_CB_GH2V2:
case MDP_Y_CBCR_H2V2_VENUS:
+ case MDP_Y_CRCB_H2V2_VENUS:
case MDP_YCBYCR_H2V1:
case MDP_YCRYCB_H2V1:
return true;
@@ -478,6 +479,7 @@
formats[MDP_BGR_565] = STR(MDP_BGR_565);
formats[MDP_BGR_888] = STR(MDP_BGR_888);
formats[MDP_Y_CBCR_H2V2_VENUS] = STR(MDP_Y_CBCR_H2V2_VENUS);
+ formats[MDP_Y_CRCB_H2V2_VENUS] = STR(MDP_Y_CRCB_H2V2_VENUS);
formats[MDP_BGRX_8888] = STR(MDP_BGRX_8888);
formats[MDP_RGBA_8888_TILE] = STR(MDP_RGBA_8888_TILE);
formats[MDP_ARGB_8888_TILE] = STR(MDP_ARGB_8888_TILE);
diff --git a/libqdutils/cb_utils.cpp b/libqdutils/cb_utils.cpp
index c17842a..b85b901 100644
--- a/libqdutils/cb_utils.cpp
+++ b/libqdutils/cb_utils.cpp
@@ -36,37 +36,39 @@
irect.bottom = max(rect1.bottom, rect2.bottom);
}
+int clear (copybit_device_t *copybit, private_handle_t* hnd, hwc_rect_t& rect)
+{
+ int ret = 0;
+ copybit_rect_t clear_rect = {rect.left, rect.top,rect.right,rect.bottom};
+
+ copybit_image_t buf;
+ buf.w = ALIGN(getWidth(hnd),32);
+ buf.h = getHeight(hnd);
+ buf.format = hnd->format;
+ buf.base = (void *)hnd->base;
+ buf.handle = (native_handle_t *)hnd;
+
+ ret = copybit->clear(copybit, &buf, &clear_rect);
+ return ret;
+}
using namespace android;
using namespace qhwc;
namespace qdutils {
-int CBUtils::getuiClearRegion(hwc_display_contents_1_t* list,
- hwc_rect_t &clearWormholeRect, LayerProp *layerProp, int dirtyIndex) {
+int CBUtils::uiClearRegion(hwc_display_contents_1_t* list,
+ int version, LayerProp *layerProp, hwc_rect_t dirtyRect,
+ copybit_device_t *copybit, private_handle_t *renderBuffer) {
size_t last = list->numHwLayers - 1;
hwc_rect_t fbFrame = list->hwLayers[last].displayFrame;
Rect fbFrameRect(fbFrame.left,fbFrame.top,fbFrame.right,fbFrame.bottom);
Region wormholeRegion(fbFrameRect);
- if (dirtyIndex != -1) {
+ if ((dirtyRect.right - dirtyRect.left > 0) &&
+ (dirtyRect.bottom - dirtyRect.top > 0)) {
#ifdef QCOM_BSP
- /*
- * 1. Map dirty rect of updating layer to its display frame.
- * 2. Use this display frame as wormholeRegion instead of full Frame
- * */
- hwc_rect_t dirtyRect = list->hwLayers[dirtyIndex].dirtyRect;
- hwc_rect_t displayFrame = list->hwLayers[dirtyIndex].displayFrame;
- hwc_frect_t sCropF = list->hwLayers[dirtyIndex].sourceCropf;
- hwc_rect_t srcRect = {int(ceilf(sCropF.left)), int(ceilf(sCropF.top)),
- int(ceilf(sCropF.right)), int(ceilf(sCropF.bottom))};
-
- displayFrame.left += dirtyRect.left - srcRect.left;
- displayFrame.top += dirtyRect.top - srcRect.top;
- displayFrame.right -= srcRect.right - dirtyRect.right;
- displayFrame.bottom -= srcRect.bottom - dirtyRect.bottom;
-
- Rect tmpRect(displayFrame.left,displayFrame.top,displayFrame.right,
- displayFrame.bottom);
+ Rect tmpRect(dirtyRect.left,dirtyRect.top,dirtyRect.right,
+ dirtyRect.bottom);
Region tmpRegion(tmpRect);
wormholeRegion = wormholeRegion.intersect(tmpRegion);
#endif
@@ -100,7 +102,7 @@
}
}
if(wormholeRegion.isEmpty()){
- return 0;
+ return 1;
}
//TO DO :- 1. remove union and call clear for each rect.
Region::const_iterator it = wormholeRegion.begin();
@@ -108,14 +110,22 @@
while (it != end) {
const Rect& r = *it++;
hwc_rect_t tmpWormRect = {r.left,r.top,r.right,r.bottom};
- int dst_w = clearWormholeRect.right - clearWormholeRect.left;
- int dst_h = clearWormholeRect.bottom - clearWormholeRect.top;
-
- if (!(dst_w || dst_h))
- clearWormholeRect = tmpWormRect;
- else
- getUnion(clearWormholeRect, tmpWormRect, clearWormholeRect);
-
+ if (version == qdutils::MDP_V3_0_4 ||
+ version == qdutils::MDP_V3_0_5) {
+ int clear_w = tmpWormRect.right - tmpWormRect.left;
+ int clear_h = tmpWormRect.bottom - tmpWormRect.top;
+ //mdp can't handle solid fill for one line
+ //making solid fill as full in this case
+ //disable swap rect if presents
+ if ((clear_w == 1) || (clear_h ==1)) {
+ clear(copybit, renderBuffer, fbFrame);
+ return 0;
+ } else {
+ clear(copybit, renderBuffer, tmpWormRect);
+ }
+ } else {
+ clear(copybit, renderBuffer, tmpWormRect);
+ }
}
return 1;
}
diff --git a/libqdutils/cb_utils.h b/libqdutils/cb_utils.h
index 59f452b..55225b6 100644
--- a/libqdutils/cb_utils.h
+++ b/libqdutils/cb_utils.h
@@ -31,14 +31,15 @@
#include <ui/Region.h>
#include "hwc_utils.h"
+#include "copybit.h"
using namespace qhwc;
namespace qdutils {
class CBUtils {
public:
-static int getuiClearRegion(hwc_display_contents_1_t* list,
- hwc_rect_t &clearWormholeRec,
- LayerProp *layerProp, int dirtyIndex = -1);
+ static int uiClearRegion(hwc_display_contents_1_t* list,
+ int version, LayerProp *layerProp, hwc_rect_t dirtyIndex,
+ copybit_device_t *copybit, private_handle_t *renderBuffer);
};
}//namespace qdutils
#endif /* end of include guard: CB_UTIL_H*/
diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp
index 350192d..0c62ffe 100644
--- a/libqdutils/display_config.cpp
+++ b/libqdutils/display_config.cpp
@@ -440,3 +440,12 @@
ret = screenRefresh();
return ret;
}
+
+// ----------------------------------------------------------------------------
+// Native daemons needs to send enable partial update ack for PU to enable
+// ----------------------------------------------------------------------------
+extern "C" int setPartialUpdateState() {
+ int ret = 0;
+ ret = setPartialUpdate(IQService::ENABLE_PARTIAL_UPDATE);
+ return ret;
+}
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index c02e28d..f62f3d0 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -77,6 +77,15 @@
#ifndef MDSS_MDP_HW_REV_110
#define MDSS_MDP_HW_REV_110 0x100a0000 //8992
#endif
+#ifndef MDSS_MDP_HW_REV_111
+#define MDSS_MDP_HW_REV_111 0x100b0000 //Unused or Next version
+#endif
+#ifndef MDSS_MDP_HW_REV_112
+#define MDSS_MDP_HW_REV_112 0x100c0000 // 8x52
+#endif
+#ifndef MDSS_MDP_HW_REV_113
+#define MDSS_MDP_HW_REV_113 0x100d0000 //Unused Next version
+#endif
#ifndef MDSS_MDP_HW_REV_200
#define MDSS_MDP_HW_REV_200 0x20000000 //8092
#endif
@@ -516,5 +525,10 @@
mMdpRev < MDSS_MDP_HW_REV_200));
}
+bool MDPVersion::is8x52() {
+ return (mMdpRev >= MDSS_MDP_HW_REV_112 and
+ mMdpRev < MDSS_MDP_HW_REV_113);
+}
+
}; //namespace qdutils
diff --git a/libqdutils/mdp_version.h b/libqdutils/mdp_version.h
index 6ebe558..25356f8 100644
--- a/libqdutils/mdp_version.h
+++ b/libqdutils/mdp_version.h
@@ -153,6 +153,7 @@
bool is8994();
bool is8x16();
bool is8x39();
+ bool is8x52();
bool is8992();
bool updateSplitInfo();
diff --git a/libqservice/IQService.h b/libqservice/IQService.h
index 0f69d40..00bf90e 100644
--- a/libqservice/IQService.h
+++ b/libqservice/IQService.h
@@ -89,8 +89,8 @@
};
enum {
- PREF_PARTIAL_UPDATE,
PREF_POST_PROCESSING,
+ PREF_PARTIAL_UPDATE,
ENABLE_PARTIAL_UPDATE,
};
diff --git a/displayengine/include/core/buffer_allocator.h b/sdm/include/core/buffer_allocator.h
similarity index 89%
rename from displayengine/include/core/buffer_allocator.h
rename to sdm/include/core/buffer_allocator.h
index 4081c54..578a0f9 100644
--- a/displayengine/include/core/buffer_allocator.h
+++ b/sdm/include/core/buffer_allocator.h
@@ -30,8 +30,7 @@
/*! @file buffer_allocator.h
@brief Interface file for platform specific buffer allocator.
- @details Buffer manager in display engine uses this interface to allocate buffer for internal
- usage.
+ @details This interface is used by SDM to allocate internal buffers.
*/
#ifndef __BUFFER_ALLOCATOR_H__
@@ -39,11 +38,11 @@
#include <core/layer_buffer.h>
-namespace sde {
- /*! @brief Input configuration set by the client for buffer allocation.
+namespace sdm {
+/*! @brief Input configuration set by the client for buffer allocation.
- @sa BufferInfo::BufferConfig
- */
+ @sa BufferInfo::BufferConfig
+*/
struct BufferConfig {
uint32_t width; //!< Specifies buffer width for buffer allocation.
@@ -87,11 +86,10 @@
/*! @brief Buffer allocator implemented by the client
@details This class declares prototype for BufferAllocator methods which must be
- implemented by the client. Buffer manager in display engine will use these methods to
- allocate/deallocate buffers for display engine.
+ implemented by the client. Buffer manager in display manager will use these methods to
+ allocate/deallocate buffers for display manager.
- @sa CompManager::Init
- @sa ResManager::Init
+ @sa CoreInterface::CreateCore
*/
class BufferAllocator {
public:
@@ -102,8 +100,6 @@
@param[in] buffer_info \link BufferInfo \endlink
@return \link DisplayError \endlink
-
- @sa BufferManager
*/
virtual DisplayError AllocateBuffer(BufferInfo *buffer_info) = 0;
@@ -115,8 +111,6 @@
@param[in] buffer_info \link BufferInfo \endlink
@return \link DisplayError \endlink
-
- @sa BufferManager
*/
virtual DisplayError FreeBuffer(BufferInfo *buffer_info) = 0;
@@ -124,7 +118,7 @@
virtual ~BufferAllocator() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __BUFFER_ALLOCATOR_H__
diff --git a/displayengine/include/core/buffer_sync_handler.h b/sdm/include/core/buffer_sync_handler.h
similarity index 83%
rename from displayengine/include/core/buffer_sync_handler.h
rename to sdm/include/core/buffer_sync_handler.h
index d0d062e..c0faf08 100644
--- a/displayengine/include/core/buffer_sync_handler.h
+++ b/sdm/include/core/buffer_sync_handler.h
@@ -30,24 +30,22 @@
/*! @file buffer_sync_handler.h
@brief Interface file for platform specific buffer allocator.
- @details Buffer manager in display engine uses this interface to wait for buffer sync fd to be
- signaled/merge the two buffer sync fds into one
+ @details SDM will use this interface to wait for buffer sync fd to be signaled/merge
+ the two buffer sync fds into one.
*/
#ifndef __BUFFER_SYNC_HANDLER_H__
#define __BUFFER_SYNC_HANDLER_H__
-namespace sde {
+namespace sdm {
/*! @brief Buffer sync handler implemented by the client
@details This class declares prototype for BufferSyncHandler methods which must be
- implemented by the client. Buffer manager and HWFramebuffer in display engine will use these
- methods to wait for buffer sync fd to be signaled/merge two buffer sync fds into one.
+ implemented by the client. SDM will use these methods to wait for buffer sync fd to be
+ signaled/merge two buffer sync fds into one.
- @sa CompManager::Init
- @sa ResManager::Init
- @sa HWInterface::Create
+ @sa CoreInterface::CreateCore
*/
class BufferSyncHandler {
public:
@@ -58,8 +56,6 @@
@param[in] fd
@return \link DisplayError \endlink
-
- @sa BufferManager::GetNextBuffer
*/
virtual DisplayError SyncWait(int fd) = 0;
@@ -74,8 +70,6 @@
@param[out] merged_fd
@return \link DisplayError \endlink
-
- @sa HWFrameBuffer::RotatorCommit
*/
virtual DisplayError SyncMerge(int fd1, int fd2, int *merged_fd) = 0;
@@ -84,7 +78,7 @@
virtual ~BufferSyncHandler() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __BUFFER_SYNC_HANDLER_H__
diff --git a/displayengine/include/core/core_interface.h b/sdm/include/core/core_interface.h
similarity index 90%
rename from displayengine/include/core/core_interface.h
rename to sdm/include/core/core_interface.h
index 114d9aa..882d050 100644
--- a/displayengine/include/core/core_interface.h
+++ b/sdm/include/core/core_interface.h
@@ -40,23 +40,23 @@
#include <stdint.h>
#include "display_interface.h"
-#include "sde_types.h"
+#include "sdm_types.h"
#include "buffer_allocator.h"
class BufferSyncHandler;
-/*! @brief Display engine interface version.
+/*! @brief Display manager interface version.
- @details Display engine interfaces are version tagged to maintain backward compatibility. This
+ @details Display manager interfaces are version tagged to maintain backward compatibility. This
version is supplied as a default argument during display core initialization.
- Client may use an older version of interfaces and link to a higher version of display engine
+ Client may use an older version of interfaces and link to a higher version of display manager
library, but vice versa is not allowed.
A 32-bit client must use 32-bit display core library and a 64-bit client must use 64-bit display
core library.
- Display engine interfaces follow default data structures alignment. Client must not override the
+ Display manager interfaces follow default data structures alignment. Client must not override the
default padding rules while using these interfaces.
@warning It is assumed that client upgrades or downgrades display core interface all at once
@@ -65,13 +65,13 @@
@sa CoreInterface::CreateCore
*/
-#define SDE_REVISION_MAJOR (1)
-#define SDE_REVISION_MINOR (0)
+#define SDM_REVISION_MAJOR (1)
+#define SDM_REVISION_MINOR (0)
-#define SDE_VERSION_TAG ((uint32_t) ((SDE_REVISION_MAJOR << 24) | (SDE_REVISION_MINOR << 16) | \
- (sizeof(SDECompatibility) << 8) | sizeof(int *)))
+#define SDM_VERSION_TAG ((uint32_t) ((SDM_REVISION_MAJOR << 24) | (SDM_REVISION_MINOR << 16) | \
+ (sizeof(SDMCompatibility) << 8) | sizeof(int *)))
-namespace sde {
+namespace sdm {
/*! @brief Forward declaration for debug handler.
*/
@@ -137,7 +137,7 @@
@param[in] buffer_allocator \link BufferAllocator \endlink
@param[in] buffer_sync_handler \link BufferSyncHandler \endlink
@param[out] interface \link CoreInterface \endlink
- @param[in] version \link SDE_VERSION_TAG \endlink. Client must not override this argument.
+ @param[in] version \link SDM_VERSION_TAG \endlink. Client must not override this argument.
@return \link DisplayError \endlink
@@ -146,7 +146,7 @@
static DisplayError CreateCore(CoreEventHandler *event_handler, DebugHandler *debug_handler,
BufferAllocator *buffer_allocator,
BufferSyncHandler *buffer_sync_handler, CoreInterface **interface,
- uint32_t version = SDE_VERSION_TAG);
+ uint32_t version = SDM_VERSION_TAG);
/*! @brief Method to release handle to display core interface.
@@ -195,7 +195,7 @@
virtual ~CoreInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __CORE_INTERFACE_H__
diff --git a/displayengine/include/core/debug_interface.h b/sdm/include/core/debug_interface.h
similarity index 93%
rename from displayengine/include/core/debug_interface.h
rename to sdm/include/core/debug_interface.h
index ff72321..ca6f81a 100644
--- a/displayengine/include/core/debug_interface.h
+++ b/sdm/include/core/debug_interface.h
@@ -28,12 +28,12 @@
*/
/*! @file debug_interface.h
- @brief This file provides the debug interface for display engine.
+ @brief This file provides the debug interface for display manager.
*/
#ifndef __DEBUG_INTERFACE_H__
#define __DEBUG_INTERFACE_H__
-namespace sde {
+namespace sdm {
/*! @brief This enum represents different modules/logical unit tags that a log message may
be associated with. Client may use this to filter messages for dynamic logging.
@@ -46,15 +46,14 @@
kTagStrategy, //!< Debug log is tagged for strategy decisions.
kTagCompManager, //!< Debug log is tagged for composition manager.
kTagDriverConfig, //!< Debug log is tagged for driver config.
- kTagBufferManager, //!< Debug log is tagged for buffer manager state transitions.
- kTagOfflineCtrl, //!< Debug log is tagged for offline controller.
+ kTagRotator, //!< Debug log is tagged for rotator.
kTagScalar, //!< Debug log is tagged for Scalar Helper.
};
/*! @brief Display debug handler class.
@details This class defines display debug handler. The handle contains methods which client
- should implement to get different levels of logging/tracing from display engine. Display engine
+ should implement to get different levels of logging/tracing from display manager. Display manager
will call into these methods at appropriate times to send logging/tracing information.
@sa CoreInterface::CreateCore
@@ -121,7 +120,7 @@
~ScopeTracer() { T::Get()->EndTrace(); }
};
-} // namespace sde
+} // namespace sdm
#endif // __DEBUG_INTERFACE_H__
diff --git a/displayengine/include/core/display_interface.h b/sdm/include/core/display_interface.h
similarity index 88%
rename from displayengine/include/core/display_interface.h
rename to sdm/include/core/display_interface.h
index 782d8fc..b16e43c 100644
--- a/displayengine/include/core/display_interface.h
+++ b/sdm/include/core/display_interface.h
@@ -36,9 +36,9 @@
#include <stdint.h>
#include "layer_stack.h"
-#include "sde_types.h"
+#include "sdm_types.h"
-namespace sde {
+namespace sdm {
/*! @brief This enum represents display device types where contents can be rendered.
@@ -63,8 +63,11 @@
kStateOn, //!< Display is ON. Contents are rendered in this state.
- kStateDoze, //!< Display is ON but not updating contents. Client shall not push any contents
- //!< in this state.
+ kStateDoze, //!< Display is ON and it is configured in a low power state.
+
+ kStateDozeSuspend,
+ //!< Display is ON in a low power state and continue showing its current
+ //!< contents indefinitely until the mode changes.
kStateStandby, //!< Display is OFF. Client will continue to receive VSync events in this state
//!< if VSync is enabled. Contents are not rendered in this state.
@@ -92,13 +95,13 @@
uint32_t y_pixels; //!< Total number of pixels in Y-direction on the display panel.
float x_dpi; //!< Dots per inch in X-direction.
float y_dpi; //!< Dots per inch in Y-direction.
- float fps; //!< Frame rate per second.
+ uint32_t fps; //!< Frame rate per second.
uint32_t vsync_period_ns; //!< VSync period in nanoseconds.
- uint32_t v_total; //!< Total lines in Y-direction (vActive + vFP + vBP + vPulseWidth).
+ uint32_t v_total; //!< Total height of panel (vActive + vFP + vBP + vPulseWidth).
uint32_t h_total; //!< Total width of panel (hActive + hFP + hBP + hPulseWidth).
DisplayConfigVariableInfo() : x_pixels(0), y_pixels(0), x_dpi(0.0f), y_dpi(0.0f),
- fps(0.0f), vsync_period_ns(0), v_total(0), h_total(0) { }
+ fps(0), vsync_period_ns(0), v_total(0), h_total(0) { }
};
/*! @brief Event data associated with VSync event.
@@ -115,7 +118,7 @@
@details This class declares prototype for display device event handler methods which must be
implemented by the client. Display device will use these methods to notify events to the client.
- Client must post heavy-weight event handling to a separate thread and unblock display engine
+ Client must post heavy-weight event handling to a separate thread and unblock display manager
thread instantly.
@sa CoreInterface::CreateDisplay
@@ -167,13 +170,13 @@
/*! @brief Method to determine hardware capability to compose layers associated with given frame.
@details Client shall send all layers associated with a frame targeted for current display
- using this method and check the layers which can be handled completely in display engine.
+ using this method and check the layers which can be handled completely in display manager.
Client shall mark composition type for one of the layer as kCompositionGPUTarget; the GPU
composed output would be rendered at the specified layer if some of the layers are not handled
- by SDE.
+ by SDM.
- Display engine will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
+ Display manager will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
shall render all the layers marked as kCompositionGPU using GPU.
This method can be called multiple times but only last call prevails. This method must be
@@ -210,7 +213,7 @@
/*! @brief Method to flush any pending buffers/fences submitted previously via Commit() call.
- @details Client shall call this method to request the Display Engine to release all buffers and
+ @details Client shall call this method to request the Display manager to release all buffers and
respective fences currently in use. This operation may result in a blank display on the panel
until a new frame is submitted for composition.
@@ -331,11 +334,32 @@
*/
virtual DisplayError SetDisplayMode(uint32_t mode) = 0;
+ /*! @brief Method to determine whether scaling for a custom resolution is valid.
+
+ @return \link DisplayError \endlink
+ */
+ virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) = 0;
+
+ /*! @brief Method to set the refresh rate of a display.
+
+ @param[in] new refresh rate of the display.
+
+ @return \link DisplayError \endlink
+ */
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate) = 0;
+
+ /*! @brief Method to query whether scanning is support for the HDMI display.
+
+ @return \link DisplayError \endlink
+ */
+ virtual bool IsUnderscanSupported() = 0;
+
protected:
virtual ~DisplayInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __DISPLAY_INTERFACE_H__
diff --git a/displayengine/include/core/dump_interface.h b/sdm/include/core/dump_interface.h
old mode 100755
new mode 100644
similarity index 90%
rename from displayengine/include/core/dump_interface.h
rename to sdm/include/core/dump_interface.h
index 20ab748..6882e5d
--- a/displayengine/include/core/dump_interface.h
+++ b/sdm/include/core/dump_interface.h
@@ -23,7 +23,7 @@
*/
/*! @file dump_interface.h
- @brief Interface file for dump options provided by display engine.
+ @brief Interface file for dump options provided by display manager.
*/
#ifndef __DUMP_INTERFACE_H__
@@ -31,20 +31,20 @@
#include <stdint.h>
-#include "sde_types.h"
+#include "sdm_types.h"
-namespace sde {
+namespace sdm {
/*! @brief Display dump interface.
- @details This class defines dump methods provided by display engine.
+ @details This class defines dump methods provided by display manager.
*/
class DumpInterface {
public:
/*! @brief Method to get dump information in form of a string.
- @details Client shall use this method to get current snapshot of display engine context as a
+ @details Client shall use this method to get current snapshot of display manager context as a
formatted string for logging or dumping purposes.
@param[inout] buffer String buffer allocated by the client. Filled with null terminated dump
@@ -62,7 +62,7 @@
virtual ~DumpInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __DUMP_INTERFACE_H__
diff --git a/displayengine/include/core/layer_buffer.h b/sdm/include/core/layer_buffer.h
similarity index 82%
rename from displayengine/include/core/layer_buffer.h
rename to sdm/include/core/layer_buffer.h
index e4a73c3..fe2b85c 100644
--- a/displayengine/include/core/layer_buffer.h
+++ b/sdm/include/core/layer_buffer.h
@@ -31,11 +31,11 @@
#include <stdint.h>
-#include "sde_types.h"
+#include "sdm_types.h"
-namespace sde {
+namespace sdm {
-/*! @brief This enum represents different buffer formats supported by display engine.
+/*! @brief This enum represents different buffer formats supported by display manager.
@sa LayerBuffer
*/
@@ -54,6 +54,9 @@
kFormatRGB888, //!< 8-bits Red, Green, Blue interleaved in RGB order. No Alpha.
kFormatBGR888, //!< 8-bits Blue, Green, Red interleaved in BGR order. No Alpha.
kFormatRGB565, //!< 5-bit Red, 6-bit Green, 5-bit Blue interleaved in RGB order. No Alpha.
+ kFormatRGBA8888Ubwc, //!< UBWC aligned RGBA8888 format
+ kFormatRGBX8888Ubwc, //!< UBWC aligned RGBX8888 format
+ kFormatRGB565Ubwc, //!< UBWC aligned RGB565 format
/* All YUV-Planar formats, Any new format will be added towards end of this group to maintain
backward compatibility.
@@ -99,6 +102,8 @@
//!< horizontally subsampled interleaved VU-plane:
//!< v(0), u(1), v(2), u(3) ... v(n-1), u(n)
+ kFormatYCbCr420SPVenusUbwc, //!< UBWC aligned YCbCr420SemiPlanarVenus format
+
/* All YUV-Packed formats, Any new format will be added towards end of this group to maintain
backward compatibility.
*/
@@ -107,15 +112,6 @@
//!< y(0), u(0), y(1), v(0), y(2), u(2), y(3), v(2)
//!< y(n-1), u(n-1), y(n), v(n-1)
- /* All UBWC aligned formats. Any new format will be added towards end of this group to maintain
- backward compatibility.
- */
- kFormatRGBA8888Ubwc = 0x400, //!< UBWC aligned RGBA8888 format
-
- kFormatRGB565Ubwc, //!< UBWC aligned RGB565 format
-
- kFormatYCbCr420SPVenusUbwc, //!< UBWC aligned Venus NV12 format
-
kFormatInvalid = 0xFFFFFFFF,
};
@@ -138,14 +134,30 @@
@sa LayerBuffer
*/
struct LayerBufferFlags {
- uint64_t secure : 1; //!< This flag shall be set by client to indicate that the buffer need
- //!< to be handled securely.
- uint64_t video : 1; //!< This flag shall be set by client to indicate that the buffer is
- //!< video/ui buffer
- uint64_t macro_tile : 1; //!< This flag shall be set by client to indicate that the buffer format
- //!< is macro tiled.
+ union {
+ struct {
+ uint32_t secure : 1; //!< This flag shall be set by client to indicate that the
+ //!< buffer need to be handled securely.
- LayerBufferFlags() : secure(0), video(0), macro_tile(0) { }
+ uint32_t video : 1; //!< This flag shall be set by client to indicate that the
+ //!< buffer is video/ui buffer.
+
+ uint32_t macro_tile : 1; //!< This flag shall be set by client to indicate that the
+ //!< buffer format is macro tiled.
+
+ uint32_t interlace : 1; //!< This flag shall be set by the client to indicate that
+ //!< the buffer has interlaced content.
+
+ uint32_t secure_display : 1;
+ //!< This flag shall be set by the client to indicate that the
+ //!< secure display session is in progress. Secure display
+ //!< session can not coexist with non-secure session.
+ };
+
+ uint32_t flags; //!< For initialization purpose only. Client shall not refer it directly.
+ };
+
+ LayerBufferFlags() : flags(0) { }
};
/*! @brief This structure defines a layer buffer handle which contains raw buffer and its associated
@@ -164,25 +176,25 @@
//!< on the buffer format specified.
int acquire_fence_fd; //!< File descriptor referring to a sync fence object which will be
- //!< signaled when buffer can be read/write by display engine.
+ //!< signaled when buffer can be read/write by display manager.
//!< This fence object is set by the client during Commit(). For
//!< input buffers client shall signal this fence when buffer
- //!< content is available and can be read by display engine. For
+ //!< content is available and can be read by display manager. For
//!< output buffers, client shall signal fence when buffer is ready
- //!< to be written by display engine.
+ //!< to be written by display manager.
//!< This field is used only during Commit() and shall be set to -1
//!< by the client when buffer is already available for read/write.
int release_fence_fd; //!< File descriptor referring to a sync fence object which will be
- //!< signaled when buffer has been read/written by display engine.
- //!< This fence object is set by display engine during Commit().
- //!< For input buffers display engine will signal this fence when
- //!< buffer has been consumed. For output buffers, display engine
+ //!< signaled when buffer has been read/written by display manager.
+ //!< This fence object is set by display manager during Commit().
+ //!< For input buffers display manager will signal this fence when
+ //!< buffer has been consumed. For output buffers, display manager
//!< will signal this fence when buffer is produced.
//!< This field is used only during Commit() and will be set to -1
- //!< by display engine when buffer is already available for
+ //!< by display manager when buffer is already available for
//!< read/write.
LayerBufferFlags flags; //!< Flags associated with this buffer.
@@ -191,7 +203,7 @@
release_fence_fd(-1) { }
};
-} // namespace sde
+} // namespace sdm
#endif // __LAYER_BUFFER_H__
diff --git a/displayengine/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
similarity index 82%
rename from displayengine/include/core/layer_stack.h
rename to sdm/include/core/layer_stack.h
index d85fd98..17e866a 100644
--- a/displayengine/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -35,9 +35,9 @@
#include <utils/constants.h>
#include "layer_buffer.h"
-#include "sde_types.h"
+#include "sdm_types.h"
-namespace sde {
+namespace sdm {
/*! @brief This enum represents display layer blending types.
@@ -92,15 +92,22 @@
@sa LayerBuffer
*/
struct LayerFlags {
- uint64_t skip : 1; //!< This flag shall be set by client to indicate that this layer will be
- //!< handled by GPU. Display Device will not consider it for composition.
+ union {
+ struct {
+ uint32_t skip : 1; //!< This flag shall be set by client to indicate that this layer
+ //!< will be handled by GPU. Display Device will not consider it
+ //!< for composition.
- uint64_t updating : 1; //!< This flag shall be set by client to indicate that this is updating/
- //!< non-updating. so strategy manager will mark them for SDE/GPU
- //!< composition respectively when the layer stack qualifies for cache
- //!< based composition.
+ uint32_t updating : 1; //!< This flag shall be set by client to indicate that this is
+ //!< updating non-updating. so strategy manager will mark them for
+ //!< SDE/GPU composition respectively when the layer stack qualifies
+ //!< for cache based composition.
+ };
- LayerFlags() : skip(0), updating(0) { }
+ uint32_t flags; //!< For initialization purpose only. Client shall not refer it directly.
+ };
+
+ LayerFlags() : flags(0) { }
};
/*! @brief This structure defines flags associated with a layer stack. The 1-bit flag can be set to
@@ -109,24 +116,29 @@
@sa LayerBuffer
*/
struct LayerStackFlags {
- uint64_t geometry_changed : 1; //!< This flag shall be set by client to indicate that the layer
- //!< set passed to Prepare() has changed by more than just the
- //!< buffer handles and acquire fences.
+ union {
+ struct {
+ uint32_t geometry_changed : 1; //!< This flag shall be set by client to indicate that the
+ //!< layer set passed to Prepare() has changed by more than
+ //!< just the buffer handles and acquire fences.
- uint64_t skip_present : 1; //!< This flag will be set to true, if the current layer stack
- //!< contains skip layers.
+ uint32_t skip_present : 1; //!< This flag will be set to true, if the current layer
+ //!< stack contains skip layers.
- uint64_t video_present : 1; //!< This flag will be set to true, if current layer stack
- //!< contains video.
+ uint32_t video_present : 1; //!< This flag will be set to true, if current layer stack
+ //!< contains video.
- uint64_t secure_present : 1; //!< This flag will be set to true, if the current layer stack
- //!< contains secure layers.
+ uint32_t secure_present : 1; //!< This flag will be set to true, if the current layer
+ //!< stack contains secure layers.
- uint64_t animating : 1; //!< This flag shall be set by client to indicate that the current
- //!< frame is animating.
+ uint32_t animating : 1; //!< This flag shall be set by client to indicate that the
+ //!< current frame is animating.
+ };
- LayerStackFlags()
- : geometry_changed(0), skip_present(0), video_present(0), secure_present(0), animating(0) { }
+ uint32_t flags; //!< For initialization purpose only. Client shall not refer it directly.
+ };
+
+ LayerStackFlags() : flags(0) { }
};
/*! @brief This structure defines a rectanglular area inside a display layer.
@@ -232,7 +244,7 @@
LayerStack() : layers(NULL), layer_count(0), retire_fence_fd(-1), output_buffer(NULL) { }
};
-} // namespace sde
+} // namespace sdm
#endif // __LAYER_STACK_H__
diff --git a/displayengine/include/core/sde_types.h b/sdm/include/core/sdm_types.h
similarity index 92%
rename from displayengine/include/core/sde_types.h
rename to sdm/include/core/sdm_types.h
index 0055306..45c98ef 100644
--- a/displayengine/include/core/sde_types.h
+++ b/sdm/include/core/sdm_types.h
@@ -27,13 +27,13 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*! @file sde_types.h
+/*! @file sdm_types.h
@brief This file contains miscellaneous data types used across display interfaces.
*/
-#ifndef __SDE_TYPES_H__
-#define __SDE_TYPES_H__
+#ifndef __SDM_TYPES_H__
+#define __SDM_TYPES_H__
-namespace sde {
+namespace sdm {
/*! @brief This enum represents different error codes that display interfaces may return.
*/
@@ -54,17 +54,17 @@
};
/*! @brief This structure is defined for client and library compatibility check purpose only. This
- structure is used in SDE_VERSION_TAG definition only. Client should not refer it directly for
+ structure is used in SDM_VERSION_TAG definition only. Client should not refer it directly for
any purpose.
*/
-struct SDECompatibility {
+struct SDMCompatibility {
char c1;
int i1;
char c2;
int i2;
};
-} // namespace sde
+} // namespace sdm
-#endif // __SDE_TYPES_H__
+#endif // __SDM_TYPES_H__
diff --git a/sdm/include/private/extension_interface.h b/sdm/include/private/extension_interface.h
new file mode 100644
index 0000000..8425db5
--- /dev/null
+++ b/sdm/include/private/extension_interface.h
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __EXTENSION_INTERFACE_H__
+#define __EXTENSION_INTERFACE_H__
+
+#include <core/sdm_types.h>
+#include <core/display_interface.h>
+
+#include "partial_update_interface.h"
+#include "strategy_interface.h"
+#include "resource_interface.h"
+#include "rotator_interface.h"
+
+namespace sdm {
+
+#define EXTENSION_LIBRARY_NAME "libsdmextension.so"
+#define CREATE_EXTENSION_INTERFACE_NAME "CreateExtensionInterface"
+#define DESTROY_EXTENSION_INTERFACE_NAME "DestroyExtensionInterface"
+
+#define EXTENSION_REVISION_MAJOR (1)
+#define EXTENSION_REVISION_MINOR (0)
+
+#define EXTENSION_VERSION_TAG ((uint16_t) ((EXTENSION_REVISION_MAJOR << 8) \
+ | EXTENSION_REVISION_MINOR))
+
+class ExtensionInterface;
+
+typedef DisplayError (*CreateExtensionInterface)(uint16_t version, ExtensionInterface **interface);
+typedef DisplayError (*DestroyExtensionInterface)(ExtensionInterface *interface);
+
+class ExtensionInterface {
+ public:
+ virtual DisplayError CreatePartialUpdate(DisplayType type, const HWResourceInfo &hw_resource_info,
+ const HWPanelInfo &hw_panel_info,
+ PartialUpdateInterface **interface) = 0;
+ virtual DisplayError DestroyPartialUpdate(PartialUpdateInterface *interface) = 0;
+
+ virtual DisplayError CreateStrategyExtn(DisplayType type, StrategyInterface **interface) = 0;
+ virtual DisplayError DestroyStrategyExtn(StrategyInterface *interface) = 0;
+
+ virtual DisplayError CreateResourceExtn(const HWResourceInfo &hw_resource_info,
+ ResourceInterface **interface) = 0;
+ virtual DisplayError DestroyResourceExtn(ResourceInterface *interface) = 0;
+
+ virtual DisplayError CreateRotator(BufferAllocator *buffer_allocator,
+ BufferSyncHandler *buffer_sync_handler,
+ RotatorInterface **intf) = 0;
+ virtual DisplayError DestroyRotator(RotatorInterface *intf) = 0;
+
+ protected:
+ virtual ~ExtensionInterface() { }
+};
+
+} // namespace sdm
+
+#endif // __EXTENSION_INTERFACE_H__
+
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
new file mode 100644
index 0000000..3360fb4
--- /dev/null
+++ b/sdm/include/private/hw_info_types.h
@@ -0,0 +1,340 @@
+/*
+* Copyright (c) 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __HW_INFO_TYPES_H__
+#define __HW_INFO_TYPES_H__
+
+#include <stdint.h>
+#include <core/display_interface.h>
+
+namespace sdm {
+
+const int kMaxSDELayers = 16; // Maximum number of layers that can be handled by hardware in a
+ // given layer stack.
+
+enum HWDeviceType {
+ kDevicePrimary,
+ kDeviceHDMI,
+ kDeviceVirtual,
+ kDeviceRotator,
+ kDeviceMax,
+};
+
+enum HWBlockType {
+ kHWPrimary,
+ kHWHDMI,
+ kHWWriteback0,
+ kHWWriteback1,
+ kHWWriteback2,
+ kHWBlockMax
+};
+
+enum HWDisplayMode {
+ kModeDefault,
+ kModeVideo,
+ kModeCommand,
+};
+
+enum HWDisplayPort {
+ kPortDefault,
+ kPortDSI,
+ kPortDTv,
+ kPortWriteBack,
+ kPortLVDS,
+ kPortEDP,
+};
+
+struct HWResourceInfo {
+ uint32_t hw_version;
+ uint32_t hw_revision;
+ uint32_t num_dma_pipe;
+ uint32_t num_vig_pipe;
+ uint32_t num_rgb_pipe;
+ uint32_t num_cursor_pipe;
+ uint32_t num_blending_stages;
+ uint32_t num_rotator;
+ uint32_t num_control;
+ uint32_t num_mixer_to_disp;
+ uint32_t smp_total;
+ uint32_t smp_size;
+ uint32_t num_smp_per_pipe;
+ uint32_t max_scale_up;
+ uint32_t max_scale_down;
+ uint64_t max_bandwidth_low;
+ uint64_t max_bandwidth_high;
+ uint32_t max_mixer_width;
+ uint32_t max_pipe_width;
+ uint32_t max_pipe_bw;
+ uint32_t max_sde_clk;
+ float clk_fudge_factor;
+ bool has_bwc;
+ bool has_ubwc;
+ bool has_decimation;
+ bool has_macrotile;
+ bool has_rotator_downscale;
+ bool has_non_scalar_rgb;
+ bool is_src_split;
+
+ HWResourceInfo()
+ : hw_version(0), hw_revision(0), num_dma_pipe(0), num_vig_pipe(0), num_rgb_pipe(0),
+ num_cursor_pipe(0), num_blending_stages(0), num_rotator(0), num_control(0),
+ num_mixer_to_disp(0), smp_total(0), smp_size(0), num_smp_per_pipe(0), max_scale_up(1),
+ max_scale_down(1), max_bandwidth_low(0), max_bandwidth_high(0), max_mixer_width(2048),
+ max_pipe_width(2048), max_pipe_bw(0), max_sde_clk(0), clk_fudge_factor(1.0f), has_bwc(false),
+ has_ubwc(false), has_decimation(false), has_macrotile(false), has_rotator_downscale(false),
+ has_non_scalar_rgb(false), is_src_split(false) { }
+
+ void Reset() { *this = HWResourceInfo(); }
+};
+
+struct HWSplitInfo {
+ uint32_t left_split;
+ uint32_t right_split;
+ bool always_src_split;
+
+ HWSplitInfo() : left_split(0), right_split(0), always_src_split(false) { }
+
+ bool operator !=(const HWSplitInfo &split_info) {
+ return ((left_split != split_info.left_split) || (right_split != split_info.right_split) ||
+ (always_src_split != split_info.always_src_split));
+ }
+
+ bool operator ==(const HWSplitInfo &split_info) {
+ return !(operator !=(split_info));
+ }
+};
+
+struct HWPanelInfo {
+ HWDisplayPort port; // Display port
+ HWDisplayMode mode; // Display mode
+ bool partial_update; // Partial update feature
+ int left_align; // ROI left alignment restriction
+ int width_align; // ROI width alignment restriction
+ int top_align;; // ROI top alignment restriction
+ int height_align; // ROI height alignment restriction
+ int min_roi_width; // Min width needed for ROI
+ int min_roi_height; // Min height needed for ROI
+ bool needs_roi_merge; // Merge ROI's of both the DSI's
+ bool dynamic_fps; // Panel Supports dynamic fps
+ uint32_t min_fps; // Min fps supported by panel
+ uint32_t max_fps; // Max fps supported by panel
+ bool is_primary_panel; // Panel is primary display
+ HWSplitInfo split_info; // Panel split configuration
+
+ HWPanelInfo() : port(kPortDefault), mode(kModeDefault), partial_update(false), left_align(false),
+ width_align(false), top_align(false), height_align(false), min_roi_width(0), min_roi_height(0),
+ needs_roi_merge(false), dynamic_fps(false), min_fps(0), max_fps(0) { }
+
+ bool operator !=(const HWPanelInfo &panel_info) {
+ return ((port != panel_info.port) || (mode != panel_info.mode) ||
+ (partial_update != panel_info.partial_update) ||
+ (left_align != panel_info.left_align) || (width_align != panel_info.width_align) ||
+ (top_align != panel_info.top_align) || (height_align != panel_info.height_align) ||
+ (min_roi_width != panel_info.min_roi_width) ||
+ (min_roi_height != panel_info.min_roi_height) ||
+ (needs_roi_merge != panel_info.needs_roi_merge) ||
+ (dynamic_fps != panel_info.dynamic_fps) || (min_fps != panel_info.min_fps) ||
+ (max_fps != panel_info.max_fps) || (is_primary_panel != panel_info.is_primary_panel) ||
+ (split_info != panel_info.split_info));
+ }
+
+ bool operator ==(const HWPanelInfo &panel_info) {
+ return !(operator !=(panel_info));
+ }
+};
+
+struct HWSessionConfig {
+ uint32_t src_width;
+ uint32_t src_height;
+ LayerBufferFormat src_format;
+ uint32_t dst_width;
+ uint32_t dst_height;
+ LayerBufferFormat dst_format;
+ uint32_t buffer_count;
+ bool secure;
+ bool cache;
+ uint32_t frame_rate;
+
+ HWSessionConfig()
+ : src_width(0), src_height(0), src_format(kFormatInvalid), dst_width(0), dst_height(0),
+ dst_format(kFormatInvalid), buffer_count(0), secure(false), cache(false), frame_rate(0) { }
+
+ bool operator != (const HWSessionConfig &input_config) const {
+ if ((src_width != input_config.src_width) || (src_height != input_config.src_height) ||
+ (src_format != input_config.src_format) || (dst_width != input_config.dst_width) ||
+ (dst_height != input_config.dst_height) || (dst_format != input_config.dst_format) ||
+ (buffer_count != input_config.buffer_count) || (secure != input_config.secure) ||
+ (cache != input_config.cache) || (frame_rate != input_config.frame_rate)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ bool operator == (const HWSessionConfig &input_config) const {
+ return !(operator != (input_config));
+ }
+};
+
+struct HWRotateInfo {
+ uint32_t pipe_id;
+ LayerRect src_roi;
+ LayerRect dst_roi;
+ HWBlockType writeback_id;
+ bool valid;
+ int rotate_id;
+
+ HWRotateInfo()
+ : pipe_id(0), writeback_id(kHWWriteback0), valid(false), rotate_id(-1) { }
+
+ void Reset() { *this = HWRotateInfo(); }
+};
+
+struct HWRotatorSession {
+ HWRotateInfo hw_rotate_info[kMaxRotatePerLayer];
+ uint32_t hw_block_count; // number of rotator hw blocks used by rotator session
+ float downscale_ratio;
+ LayerTransform transform;
+ HWSessionConfig hw_session_config;
+ LayerBuffer output_buffer;
+ int session_id;
+ float input_compression;
+ float output_compression;
+
+ HWRotatorSession()
+ : hw_block_count(0), downscale_ratio(1.0f), session_id(-1), input_compression(1.0f),
+ output_compression(1.0f) { }
+};
+
+struct HWPixelExtension {
+ int extension; // Number of pixels extension in left, right, top and bottom directions for all
+ // color components. This pixel value for each color component should be sum of
+ // fetch and repeat pixels.
+
+ int overfetch; // Number of pixels need to be overfetched in left, right, top and bottom
+ // directions from source image for scaling.
+
+ int repeat; // Number of pixels need to be repeated in left, right, top and bottom directions
+ // for scaling.
+};
+
+struct HWPlane {
+ int init_phase_x;
+ int phase_step_x;
+ int init_phase_y;
+ int phase_step_y;
+ HWPixelExtension left;
+ HWPixelExtension top;
+ HWPixelExtension right;
+ HWPixelExtension bottom;
+ uint32_t roi_width;
+};
+
+struct ScaleData {
+ uint8_t enable_pixel_ext;
+ uint32_t src_width;
+ uint32_t src_height;
+ HWPlane plane[4];
+};
+
+struct HWPipeInfo {
+ uint32_t pipe_id;
+ LayerRect src_roi;
+ LayerRect dst_roi;
+ uint8_t horizontal_decimation;
+ uint8_t vertical_decimation;
+ ScaleData scale_data;
+ bool valid;
+ uint32_t z_order;
+
+ HWPipeInfo()
+ : pipe_id(0), horizontal_decimation(0), vertical_decimation(0), valid(false), z_order(0) { }
+
+ void Reset() { *this = HWPipeInfo(); }
+};
+
+struct HWLayerConfig {
+ bool use_non_dma_pipe; // set by client
+ HWPipeInfo left_pipe; // pipe for left side of output
+ HWPipeInfo right_pipe; // pipe for right side of output
+ HWRotatorSession hw_rotator_session;
+ float compression;
+
+ HWLayerConfig() : use_non_dma_pipe(false), compression(1.0f) { }
+
+ void Reset() { *this = HWLayerConfig(); }
+};
+
+struct HWLayersInfo {
+ LayerStack *stack; // Input layer stack. Set by the caller.
+
+ uint32_t index[kMaxSDELayers];
+ // Indexes of the layers from the layer stack which need to be
+ // programmed on hardware.
+
+ uint32_t count; // Total number of layers which need to be set on hardware.
+
+ LayerRect left_partial_update;
+ // Left ROI.
+
+ LayerRect right_partial_update;
+ // Right ROI.
+
+
+ HWLayersInfo() : stack(NULL), count(0) { }
+};
+
+struct HWLayers {
+ HWLayersInfo info;
+ HWLayerConfig config[kMaxSDELayers];
+ float output_compression;
+};
+
+struct HWDisplayAttributes : DisplayConfigVariableInfo {
+ bool is_device_split;
+ uint32_t split_left;
+ bool always_src_split;
+
+ HWDisplayAttributes() : is_device_split(false), split_left(0), always_src_split(false) { }
+
+ void Reset() { *this = HWDisplayAttributes(); }
+
+ bool operator !=(const HWDisplayAttributes &attributes) {
+ return ((is_device_split != attributes.is_device_split) ||
+ (split_left != attributes.split_left) ||
+ (always_src_split != attributes.always_src_split) ||
+ (x_pixels != attributes.x_pixels) || (y_pixels != attributes.y_pixels) ||
+ (x_dpi != attributes.x_dpi) || (y_dpi != attributes.y_dpi) || (fps != attributes.fps) ||
+ (vsync_period_ns != attributes.vsync_period_ns) || (v_total != attributes.v_total));
+ }
+
+ bool operator ==(const HWDisplayAttributes &attributes) {
+ return !(operator !=(attributes));
+ }
+};
+
+} // namespace sdm
+
+#endif // __HW_INFO_TYPES_H__
+
diff --git a/displayengine/libs/core/hw_hdmi_interface.h b/sdm/include/private/partial_update_interface.h
similarity index 76%
copy from displayengine/libs/core/hw_hdmi_interface.h
copy to sdm/include/private/partial_update_interface.h
index 36ca991..8b421c4 100644
--- a/displayengine/libs/core/hw_hdmi_interface.h
+++ b/sdm/include/private/partial_update_interface.h
@@ -22,26 +22,26 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __HW_HDMI_INTERFACE_H__
-#define __HW_HDMI_INTERFACE_H__
+#ifndef __PARTIAL_UPDATE_INTERFACE_H__
+#define __PARTIAL_UPDATE_INTERFACE_H__
-#include "hw_interface.h"
+#include <core/display_interface.h>
+#include <core/buffer_allocator.h>
+#include <core/buffer_sync_handler.h>
-namespace sde {
+#include "hw_info_types.h"
-class HWInfoInterface;
+namespace sdm {
-class HWHDMIInterface: virtual public HWInterface {
+class PartialUpdateInterface {
public:
- static DisplayError Create(HWHDMIInterface **intf, HWInfoInterface *hw_info_intf,
- BufferSyncHandler *buffer_sync_handler);
- static DisplayError Destroy(HWHDMIInterface *intf);
+ virtual DisplayError GenerateROI(HWLayersInfo *hw_layers_info) = 0;
protected:
- virtual ~HWHDMIInterface() { }
+ virtual ~PartialUpdateInterface() { }
};
-} // namespace sde
+} // namespace sdm
-#endif // __HW_HDMI_INTERFACE_H__
+#endif // __PARTIAL_UPDATE_INTERFACE_H__
diff --git a/sdm/include/private/resource_interface.h b/sdm/include/private/resource_interface.h
new file mode 100644
index 0000000..23447b6
--- /dev/null
+++ b/sdm/include/private/resource_interface.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __RESOURCE_INTERFACE_H__
+#define __RESOURCE_INTERFACE_H__
+
+#include <core/display_interface.h>
+#include "hw_info_types.h"
+
+namespace sdm {
+
+class ResourceInterface {
+ public:
+ virtual DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info, Handle *display_ctx) = 0;
+ virtual DisplayError UnregisterDisplay(Handle display_ctx) = 0;
+ virtual void ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info) = 0;
+ virtual DisplayError Start(Handle display_ctx) = 0;
+ virtual DisplayError Stop(Handle display_ctx) = 0;
+ virtual DisplayError Acquire(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual void Purge(Handle display_ctx) = 0;
+ virtual DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages) = 0;
+ virtual DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) = 0;
+
+ protected:
+ virtual ~ResourceInterface() { }
+};
+
+} // namespace sdm
+
+#endif // __RESOURCE_INTERFACE_H__
+
diff --git a/displayengine/libs/core/hw_primary_interface.h b/sdm/include/private/rotator_interface.h
similarity index 66%
copy from displayengine/libs/core/hw_primary_interface.h
copy to sdm/include/private/rotator_interface.h
index d195348..9901d21 100644
--- a/displayengine/libs/core/hw_primary_interface.h
+++ b/sdm/include/private/rotator_interface.h
@@ -22,28 +22,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __HW_PRIMARY_INTERFACE_H__
-#define __HW_PRIMARY_INTERFACE_H__
+#ifndef __ROTATOR_INTERFACE_H__
+#define __ROTATOR_INTERFACE_H__
-namespace sde {
+#include <core/display_interface.h>
+#include <core/buffer_allocator.h>
+#include <core/buffer_sync_handler.h>
-class BufferSyncHandler;
-class HWInfoInterface;
+#include "hw_info_types.h"
-class HWPrimaryInterface: virtual public HWInterface {
+namespace sdm {
+
+class RotatorInterface {
public:
- static DisplayError Create(HWPrimaryInterface **intf, HWInfoInterface *hw_info_intf,
- BufferSyncHandler *buffer_sync_handler);
- static DisplayError Destroy(HWPrimaryInterface *intf);
- virtual DisplayError SetVSyncState(bool enable) = 0;
- virtual void SetIdleTimeoutMs(uint32_t timeout_ms) = 0;
- virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode) = 0;
+ virtual DisplayError RegisterDisplay(DisplayType type, Handle *display_ctx) = 0;
+ virtual void UnregisterDisplay(Handle display_ctx) = 0;
+ virtual DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual DisplayError Commit(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers) = 0;
+ virtual DisplayError Purge(Handle display_ctx, HWLayers *hw_layers) = 0;
protected:
- virtual ~HWPrimaryInterface() { }
+ virtual ~RotatorInterface() { }
};
-} // namespace sde
+} // namespace sdm
-#endif // __HW_PRIMARY_INTERFACE_H__
+#endif // __ROTATOR_INTERFACE_H__
diff --git a/displayengine/libs/core/strategy_default.h b/sdm/include/private/strategy_interface.h
similarity index 62%
copy from displayengine/libs/core/strategy_default.h
copy to sdm/include/private/strategy_interface.h
index 7b6f594..73c6d58 100644
--- a/displayengine/libs/core/strategy_default.h
+++ b/sdm/include/private/strategy_interface.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2015, 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 met:
@@ -22,33 +22,37 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __STRATEGY_DEFAULT_H__
-#define __STRATEGY_DEFAULT_H__
+#ifndef __STRATEGY_INTERFACE_H__
+#define __STRATEGY_INTERFACE_H__
+#include <core/sdm_types.h>
#include <core/display_interface.h>
-#include <private/strategy_interface.h>
+#include "hw_info_types.h"
-namespace sde {
+namespace sdm {
-class StrategyDefault : public StrategyInterface {
- public:
- StrategyDefault();
+struct StrategyConstraints {
+ bool safe_mode; //!< In this mode, strategy manager chooses the composition strategy
+ //!< that requires minimum number of pipe for the current frame. i.e.,
+ //!< video only composition, secure only composition or GPU composition
- static DisplayError CreateStrategyInterface(uint16_t version, DisplayType type,
- const HWResourceInfo *hw_resource_info,
- const HWPanelInfo *hw_panel_info,
- StrategyInterface **interface);
- static DisplayError DestroyStrategyInterface(StrategyInterface *interface);
+ uint32_t max_layers; //!< Maximum number of layers that shall be programmed on hardware for the
+ //!< given layer stack.
- virtual DisplayError Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts);
- virtual DisplayError GetNextStrategy(StrategyConstraints *constraints);
- virtual DisplayError Stop();
-
- private:
- HWLayersInfo *hw_layers_info_;
+ StrategyConstraints() : safe_mode(false), max_layers(kMaxSDELayers) { }
};
-} // namespace sde
+class StrategyInterface {
+ public:
+ virtual DisplayError Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts) = 0;
+ virtual DisplayError GetNextStrategy(StrategyConstraints *constraints) = 0;
+ virtual DisplayError Stop() = 0;
-#endif // __STRATEGY_DEFAULT_H__
+ protected:
+ virtual ~StrategyInterface() { }
+};
+
+} // namespace sdm
+
+#endif // __STRATEGY_INTERFACE_H__
diff --git a/displayengine/include/utils/constants.h b/sdm/include/utils/constants.h
similarity index 98%
rename from displayengine/include/utils/constants.h
rename to sdm/include/utils/constants.h
index 1a7d62a..75f845b 100644
--- a/displayengine/include/utils/constants.h
+++ b/sdm/include/utils/constants.h
@@ -76,14 +76,14 @@
return (T1)((value + (factor - 1)) & (~(factor - 1)));
}
-namespace sde {
+namespace sdm {
const int kThreadPriorityUrgent = -9;
const int kMaxRotatePerLayer = 2;
typedef void * Handle;
-} // namespace sde
+} // namespace sdm
#endif // __CONSTANTS_H__
diff --git a/displayengine/include/utils/debug.h b/sdm/include/utils/debug.h
similarity index 94%
rename from displayengine/include/utils/debug.h
rename to sdm/include/utils/debug.h
index 2cef5d7..7f9209e 100644
--- a/displayengine/include/utils/debug.h
+++ b/sdm/include/utils/debug.h
@@ -31,7 +31,7 @@
#define __DEBUG_H__
#include <stdint.h>
-#include <core/sde_types.h>
+#include <core/sdm_types.h>
#include <core/debug_interface.h>
#define DLOG(tag, method, format, ...) Debug::Get()->method(tag, __CLASS__ "::%s: " format, \
@@ -51,7 +51,7 @@
#define DTRACE_END() Debug::Get()->EndTrace()
#define DTRACE_SCOPED() ScopeTracer <Debug> scope_tracer(__CLASS__, __FUNCTION__)
-namespace sde {
+namespace sdm {
class Debug {
public:
@@ -65,13 +65,13 @@
static uint32_t GetIdleTimeoutMs();
static bool IsRotatorDownScaleDisabled();
static bool IsDecimationDisabled();
- static bool IsPartialUpdate();
+ static bool IsPartialUpdateEnabled();
private:
Debug();
- // By default, drop any log messages/traces coming from Display Engine. It will be overriden by
- // Display Engine client when core is successfully initialized.
+ // By default, drop any log messages/traces coming from Display manager. It will be overriden by
+ // Display manager client when core is successfully initialized.
class DefaultDebugHandler : public DebugHandler {
public:
virtual void Error(DebugTag /*tag*/, const char */*format*/, ...) { }
@@ -89,7 +89,7 @@
static Debug debug_;
};
-} // namespace sde
+} // namespace sdm
#endif // __DEBUG_H__
diff --git a/displayengine/include/utils/locker.h b/sdm/include/utils/locker.h
similarity index 98%
rename from displayengine/include/utils/locker.h
rename to sdm/include/utils/locker.h
index 549a282..3bc92d3 100644
--- a/displayengine/include/utils/locker.h
+++ b/sdm/include/utils/locker.h
@@ -34,7 +34,7 @@
#define SEQUENCE_WAIT_SCOPE_LOCK(locker) Locker::SequenceWaitScopeLock lock(locker)
#define SEQUENCE_CANCEL_SCOPE_LOCK(locker) Locker::SequenceCancelScopeLock lock(locker)
-namespace sde {
+namespace sdm {
class Locker {
public:
@@ -159,7 +159,7 @@
// further processing.
};
-} // namespace sde
+} // namespace sdm
#endif // __LOCKER_H__
diff --git a/displayengine/include/utils/rect.h b/sdm/include/utils/rect.h
similarity index 96%
rename from displayengine/include/utils/rect.h
rename to sdm/include/utils/rect.h
index dd60672..1b75d40 100644
--- a/displayengine/include/utils/rect.h
+++ b/sdm/include/utils/rect.h
@@ -31,11 +31,11 @@
#define __RECT_H__
#include <stdint.h>
-#include <core/sde_types.h>
+#include <core/sdm_types.h>
#include <core/layer_stack.h>
#include <utils/debug.h>
-namespace sde {
+namespace sdm {
bool IsValid(const LayerRect &rect);
bool IsCongruent(const LayerRect &rect1, const LayerRect &rect2);
@@ -45,7 +45,7 @@
LayerRect Intersection(const LayerRect &rect1, const LayerRect &rect2);
LayerRect Subtract(const LayerRect &rect1, const LayerRect &rect2);
LayerRect Reposition(const LayerRect &rect1, const int &x_offset, const int &y_offset);
-} // namespace sde
+} // namespace sdm
#endif // __RECT_H__
diff --git a/displayengine/libs/core/Android.mk b/sdm/libs/core/Android.mk
similarity index 60%
rename from displayengine/libs/core/Android.mk
rename to sdm/libs/core/Android.mk
index 5623283..8831c3f 100644
--- a/displayengine/libs/core/Android.mk
+++ b/sdm/libs/core/Android.mk
@@ -1,19 +1,15 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := libsde
+LOCAL_MODULE := libsdmcore
LOCAL_MODULE_TAGS := optional
-LOCAL_C_INCLUDES := hardware/qcom/display/displayengine/include/ \
+LOCAL_C_INCLUDES := hardware/qcom/display/sdm/include/ \
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \
-Wconversion -Wall -Werror \
- -DLOG_TAG=\"SDE\"
-ifeq ($(TARGET_USES_SCALAR), true)
- LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/scalar/inc
- LOCAL_CFLAGS += -DUSES_SCALAR
-endif
-LOCAL_HW_INTF_PATH := fb
-LOCAL_SHARED_LIBRARIES := libdl libsdeutils libcutils
+ -DLOG_TAG=\"SDM\"
+LOCAL_HW_INTF_PATH := fb
+LOCAL_SHARED_LIBRARIES := libdl libsdmutils
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_SRC_FILES := core_interface.cpp \
core_impl.cpp \
@@ -22,17 +18,12 @@
display_hdmi.cpp \
display_virtual.cpp \
comp_manager.cpp \
- strategy_default.cpp \
- res_manager.cpp \
- res_config.cpp \
- offline_ctrl.cpp \
+ strategy.cpp \
+ resource_default.cpp \
dump_impl.cpp \
- buffer_manager.cpp \
- scalar_helper.cpp \
$(LOCAL_HW_INTF_PATH)/hw_info.cpp \
$(LOCAL_HW_INTF_PATH)/hw_device.cpp \
$(LOCAL_HW_INTF_PATH)/hw_primary.cpp \
- $(LOCAL_HW_INTF_PATH)/hw_rotator.cpp \
$(LOCAL_HW_INTF_PATH)/hw_hdmi.cpp \
$(LOCAL_HW_INTF_PATH)/hw_virtual.cpp
diff --git a/displayengine/libs/core/comp_manager.cpp b/sdm/libs/core/comp_manager.cpp
similarity index 76%
rename from displayengine/libs/core/comp_manager.cpp
rename to sdm/libs/core/comp_manager.cpp
index 1ca7c16..69e3ec7 100644
--- a/displayengine/libs/core/comp_manager.cpp
+++ b/sdm/libs/core/comp_manager.cpp
@@ -22,65 +22,41 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <dlfcn.h>
#include <utils/constants.h>
#include <utils/debug.h>
#include <core/buffer_allocator.h>
#include "comp_manager.h"
-#include "strategy_default.h"
+#include "strategy.h"
#define __CLASS__ "CompManager"
-namespace sde {
+namespace sdm {
CompManager::CompManager()
- : strategy_lib_(NULL), create_strategy_intf_(NULL), destroy_strategy_intf_(NULL),
- registered_displays_(0), configured_displays_(0), safe_mode_(false) {
+ : resource_intf_(NULL), registered_displays_(0), configured_displays_(0), safe_mode_(false),
+ extension_intf_(NULL) {
}
-DisplayError CompManager::Init(const HWResourceInfo &hw_res_info, BufferAllocator *buffer_allocator,
- BufferSyncHandler *buffer_sync_handler) {
+DisplayError CompManager::Init(const HWResourceInfo &hw_res_info,
+ ExtensionInterface *extension_intf) {
SCOPE_LOCK(locker_);
DisplayError error = kErrorNone;
- error = res_mgr_.Init(hw_res_info, buffer_allocator, buffer_sync_handler);
+ if (extension_intf) {
+ error = extension_intf->CreateResourceExtn(hw_res_info, &resource_intf_);
+ } else {
+ resource_intf_ = &resource_default_;
+ error = resource_default_.Init(hw_res_info);
+ }
+
if (error != kErrorNone) {
return error;
}
- // Try to load strategy library & get handle to its interface.
- // Default to GPU only composition on failure.
- strategy_lib_ = ::dlopen(STRATEGY_LIBRARY_NAME, RTLD_NOW);
- if (strategy_lib_) {
- void **create_sym = reinterpret_cast<void **>(&create_strategy_intf_);
- void **destroy_sym = reinterpret_cast<void **>(&destroy_strategy_intf_);
-
- *create_sym = ::dlsym(strategy_lib_, CREATE_STRATEGY_INTERFACE_NAME);
- *destroy_sym = ::dlsym(strategy_lib_, DESTROY_STRATEGY_INTERFACE_NAME);
-
- if (!create_strategy_intf_) {
- DLOGE("Unable to find symbol for %s", CREATE_STRATEGY_INTERFACE_NAME);
- error = kErrorUndefined;
- }
-
- if (!destroy_strategy_intf_) {
- DLOGE("Unable to find symbol for %s", DESTROY_STRATEGY_INTERFACE_NAME);
- error = kErrorUndefined;
- }
-
- if (error != kErrorNone) {
- ::dlclose(strategy_lib_);
- res_mgr_.Deinit();
- }
- } else {
- DLOGW("Unable to load = %s, using GPU only (default) composition", STRATEGY_LIBRARY_NAME);
- create_strategy_intf_ = StrategyDefault::CreateStrategyInterface;
- destroy_strategy_intf_ = StrategyDefault::DestroyStrategyInterface;
- }
-
hw_res_info_ = hw_res_info;
+ extension_intf_ = extension_intf;
return error;
}
@@ -88,12 +64,12 @@
DisplayError CompManager::Deinit() {
SCOPE_LOCK(locker_);
- if (strategy_lib_) {
- ::dlclose(strategy_lib_);
+ if (extension_intf_) {
+ extension_intf_->DestroyResourceExtn(resource_intf_);
+ } else {
+ resource_default_.Deinit();
}
- res_mgr_.Deinit();
-
return kErrorNone;
}
@@ -108,18 +84,26 @@
return kErrorMemory;
}
- if (create_strategy_intf_(STRATEGY_VERSION_TAG, type, &hw_res_info_, &hw_panel_info,
- &display_comp_ctx->strategy_intf) != kErrorNone) {
- DLOGW("Unable to create strategy interface");
+ Strategy *&strategy = display_comp_ctx->strategy;
+ strategy = new Strategy(extension_intf_, type, hw_res_info_, hw_panel_info);
+ if (!strategy) {
+ DLOGE("Unable to create strategy");
delete display_comp_ctx;
- display_comp_ctx = NULL;
- return kErrorUndefined;
+ return kErrorMemory;
}
- error = res_mgr_.RegisterDisplay(type, attributes, hw_panel_info,
- &display_comp_ctx->display_resource_ctx);
+ error = strategy->Init();
if (error != kErrorNone) {
- destroy_strategy_intf_(display_comp_ctx->strategy_intf);
+ delete strategy;
+ delete display_comp_ctx;
+ return error;
+ }
+
+ error = resource_intf_->RegisterDisplay(type, attributes, hw_panel_info,
+ &display_comp_ctx->display_resource_ctx);
+ if (error != kErrorNone) {
+ strategy->Deinit();
+ delete strategy;
delete display_comp_ctx;
display_comp_ctx = NULL;
return error;
@@ -151,8 +135,11 @@
return kErrorParameters;
}
- res_mgr_.UnregisterDisplay(display_comp_ctx->display_resource_ctx);
- destroy_strategy_intf_(display_comp_ctx->strategy_intf);
+ resource_intf_->UnregisterDisplay(display_comp_ctx->display_resource_ctx);
+
+ Strategy *&strategy = display_comp_ctx->strategy;
+ strategy->Deinit();
+ delete strategy;
CLEAR_BIT(registered_displays_, display_comp_ctx->display_type);
CLEAR_BIT(configured_displays_, display_comp_ctx->display_type);
@@ -166,6 +153,17 @@
return kErrorNone;
}
+void CompManager::ReconfigureDisplay(Handle comp_handle, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info) {
+ DisplayCompositionContext *display_comp_ctx =
+ reinterpret_cast<DisplayCompositionContext *>(comp_handle);
+
+ resource_intf_->ReconfigureDisplay(display_comp_ctx->display_resource_ctx, attributes,
+ hw_panel_info);
+
+ // TODO(user): Need to reconfigure strategy with updated panel info
+}
+
void CompManager::PrepareStrategyConstraints(Handle comp_handle, HWLayers *hw_layers) {
DisplayCompositionContext *display_comp_ctx =
reinterpret_cast<DisplayCompositionContext *>(comp_handle);
@@ -192,8 +190,7 @@
SCOPE_LOCK(locker_);
DisplayCompositionContext *display_comp_ctx =
reinterpret_cast<DisplayCompositionContext *>(display_ctx);
- display_comp_ctx->strategy_intf->Start(&hw_layers->info,
- &display_comp_ctx->max_strategies);
+ display_comp_ctx->strategy->Start(&hw_layers->info, &display_comp_ctx->max_strategies);
display_comp_ctx->remaining_strategies = display_comp_ctx->max_strategies;
// Avoid idle fallback, if there is only one app layer.
@@ -216,12 +213,12 @@
PrepareStrategyConstraints(display_ctx, hw_layers);
// Select a composition strategy, and try to allocate resources for it.
- res_mgr_.Start(display_resource_ctx);
+ resource_intf_->Start(display_resource_ctx);
bool exit = false;
uint32_t &count = display_comp_ctx->remaining_strategies;
for (; !exit && count > 0; count--) {
- error = display_comp_ctx->strategy_intf->GetNextStrategy(&display_comp_ctx->constraints);
+ error = display_comp_ctx->strategy->GetNextStrategy(&display_comp_ctx->constraints);
if (error != kErrorNone) {
// Composition strategies exhausted. Resource Manager could not allocate resources even for
// GPU composition. This will never happen.
@@ -229,7 +226,7 @@
}
if (!exit) {
- error = res_mgr_.Acquire(display_resource_ctx, hw_layers);
+ error = resource_intf_->Acquire(display_resource_ctx, hw_layers);
// Exit if successfully allocated resource, else try next strategy.
exit = (error == kErrorNone);
}
@@ -239,7 +236,7 @@
DLOGE("Composition strategies exhausted for display = %d", display_comp_ctx->display_type);
}
- res_mgr_.Stop(display_resource_ctx);
+ resource_intf_->Stop(display_resource_ctx);
return error;
}
@@ -251,12 +248,12 @@
Handle &display_resource_ctx = display_comp_ctx->display_resource_ctx;
DisplayError error = kErrorNone;
- error = res_mgr_.PostPrepare(display_resource_ctx, hw_layers);
+ error = resource_intf_->PostPrepare(display_resource_ctx, hw_layers);
if (error != kErrorNone) {
return error;
}
- display_comp_ctx->strategy_intf->Stop();
+ display_comp_ctx->strategy->Stop();
return kErrorNone;
}
@@ -272,7 +269,7 @@
safe_mode_ = false;
}
- error = res_mgr_.PostCommit(display_comp_ctx->display_resource_ctx, hw_layers);
+ error = resource_intf_->PostCommit(display_comp_ctx->display_resource_ctx, hw_layers);
if (error != kErrorNone) {
return error;
}
@@ -292,7 +289,7 @@
DisplayCompositionContext *display_comp_ctx =
reinterpret_cast<DisplayCompositionContext *>(display_ctx);
- res_mgr_.Purge(display_comp_ctx->display_resource_ctx);
+ resource_intf_->Purge(display_comp_ctx->display_resource_ctx);
}
bool CompManager::ProcessIdleTimeout(Handle display_ctx) {
@@ -342,7 +339,8 @@
reinterpret_cast<DisplayCompositionContext *>(display_ctx);
if (display_comp_ctx) {
- error = res_mgr_.SetMaxMixerStages(display_comp_ctx->display_resource_ctx, max_mixer_stages);
+ error = resource_intf_->SetMaxMixerStages(display_comp_ctx->display_resource_ctx,
+ max_mixer_stages);
}
return error;
@@ -352,5 +350,10 @@
SCOPE_LOCK(locker_);
}
-} // namespace sde
+DisplayError CompManager::ValidateScaling(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ return resource_intf_->ValidateScaling(crop, dst, rotate90);
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/core/comp_manager.h b/sdm/libs/core/comp_manager.h
similarity index 85%
rename from displayengine/libs/core/comp_manager.h
rename to sdm/libs/core/comp_manager.h
index c445418..f48beed 100644
--- a/displayengine/libs/core/comp_manager.h
+++ b/sdm/libs/core/comp_manager.h
@@ -26,22 +26,26 @@
#define __COMP_MANAGER_H__
#include <core/display_interface.h>
+#include <private/extension_interface.h>
+#include <utils/locker.h>
+#include "strategy.h"
+#include "resource_default.h"
#include "hw_interface.h"
-#include "res_manager.h"
#include "dump_impl.h"
-namespace sde {
+namespace sdm {
class CompManager : public DumpImpl {
public:
CompManager();
- DisplayError Init(const HWResourceInfo &hw_res_info_, BufferAllocator *buffer_allocator,
- BufferSyncHandler *buffer_sync_handler_);
+ DisplayError Init(const HWResourceInfo &hw_res_info_, ExtensionInterface *extension_intf);
DisplayError Deinit();
DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
const HWPanelInfo &hw_panel_info, Handle *res_mgr_hnd);
DisplayError UnregisterDisplay(Handle res_mgr_hnd);
+ void ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info);
void PrePrepare(Handle display_ctx, HWLayers *hw_layers);
DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers);
DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers);
@@ -50,6 +54,7 @@
bool ProcessIdleTimeout(Handle display_ctx);
void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level);
DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages);
+ DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90);
// DumpImpl method
virtual void AppendDump(char *buffer, uint32_t length);
@@ -60,7 +65,7 @@
void PrepareStrategyConstraints(Handle display_ctx, HWLayers *hw_layers);
struct DisplayCompositionContext {
- StrategyInterface *strategy_intf;
+ Strategy *strategy;
StrategyConstraints constraints;
Handle display_resource_ctx;
DisplayType display_type;
@@ -77,19 +82,18 @@
};
Locker locker_;
- void *strategy_lib_;
- CreateStrategyInterface create_strategy_intf_;
- DestroyStrategyInterface destroy_strategy_intf_;
- ResManager res_mgr_;
+ ResourceInterface *resource_intf_;
+ ResourceDefault resource_default_;
uint64_t registered_displays_; // Stores the bit mask of registered displays
uint64_t configured_displays_; // Stores the bit mask of sucessfully configured displays
bool safe_mode_; // Flag to notify all displays to be in resource crunch
// mode, where strategy manager chooses the best strategy
// that uses optimal number of pipes for each display
HWResourceInfo hw_res_info_;
+ ExtensionInterface *extension_intf_;
};
-} // namespace sde
+} // namespace sdm
#endif // __COMP_MANAGER_H__
diff --git a/displayengine/libs/core/core_impl.cpp b/sdm/libs/core/core_impl.cpp
similarity index 64%
rename from displayengine/libs/core/core_impl.cpp
rename to sdm/libs/core/core_impl.cpp
index f04bbb9..f017d8d 100644
--- a/displayengine/libs/core/core_impl.cpp
+++ b/sdm/libs/core/core_impl.cpp
@@ -22,6 +22,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <dlfcn.h>
#include <utils/locker.h>
#include <utils/constants.h>
#include <utils/debug.h>
@@ -34,53 +35,90 @@
#define __CLASS__ "CoreImpl"
-namespace sde {
+namespace sdm {
CoreImpl::CoreImpl(CoreEventHandler *event_handler, BufferAllocator *buffer_allocator,
BufferSyncHandler *buffer_sync_handler)
: event_handler_(event_handler), buffer_allocator_(buffer_allocator),
- buffer_sync_handler_(buffer_sync_handler), hw_resource_(NULL) {
+ buffer_sync_handler_(buffer_sync_handler), hw_resource_(NULL), hw_info_intf_(NULL),
+ rotator_intf_(NULL), extension_lib_(NULL), extension_intf_(NULL),
+ create_extension_intf_(NULL), destroy_extension_intf_(NULL) {
}
DisplayError CoreImpl::Init() {
SCOPE_LOCK(locker_);
DisplayError error = kErrorNone;
+ // Try to load extension library & get handle to its interface.
+ extension_lib_ = ::dlopen(EXTENSION_LIBRARY_NAME, RTLD_NOW);
+ if (extension_lib_) {
+ void **create_sym = reinterpret_cast<void **>(&create_extension_intf_);
+ void **destroy_sym = reinterpret_cast<void **>(&destroy_extension_intf_);
+
+ *create_sym = ::dlsym(extension_lib_, CREATE_EXTENSION_INTERFACE_NAME);
+ *destroy_sym = ::dlsym(extension_lib_, DESTROY_EXTENSION_INTERFACE_NAME);
+
+ if (!create_extension_intf_ || !destroy_extension_intf_) {
+ DLOGE("Unable to load symbols");
+ ::dlclose(extension_lib_);
+ return kErrorUndefined;
+ }
+
+ error = create_extension_intf_(EXTENSION_VERSION_TAG, &extension_intf_);
+ if(error != kErrorNone) {
+ DLOGE("Unable to create interface");
+ ::dlclose(extension_lib_);
+ return error;
+ }
+ } else {
+ DLOGW("Unable to load = %s", EXTENSION_LIBRARY_NAME);
+ }
+
error = HWInfoInterface::Create(&hw_info_intf_);
if (error != kErrorNone) {
- return error;
+ goto CleanupOnError;
}
hw_resource_ = new HWResourceInfo();
if (!hw_resource_) {
error = kErrorMemory;
- goto CleanUpOnError;
+ goto CleanupOnError;
}
error = hw_info_intf_->GetHWResourceInfo(hw_resource_);
if (error != kErrorNone) {
- goto CleanUpOnError;
+ goto CleanupOnError;
}
- error = comp_mgr_.Init(*hw_resource_, buffer_allocator_, buffer_sync_handler_);
+ error = comp_mgr_.Init(*hw_resource_, extension_intf_);
if (error != kErrorNone) {
- comp_mgr_.Deinit();
- goto CleanUpOnError;
+ goto CleanupOnError;
}
- error = offline_ctrl_.Init(buffer_sync_handler_);
- if (error != kErrorNone) {
- goto CleanUpOnError;
+ if (extension_intf_) {
+ error = extension_intf_->CreateRotator(buffer_allocator_, buffer_sync_handler_,
+ &rotator_intf_);
+ if (error != kErrorNone) {
+ comp_mgr_.Deinit();
+ goto CleanupOnError;
+ }
}
+
return kErrorNone;
-CleanUpOnError:
- if (hw_resource_) {
- delete hw_resource_;
- hw_resource_ = NULL;
+CleanupOnError:
+ if (hw_info_intf_) {
+ HWInfoInterface::Destroy(hw_info_intf_);
}
- HWInfoInterface::Destroy(hw_info_intf_);
+ if (hw_resource_) {
+ delete hw_resource_;
+ }
+
+ if (extension_lib_) {
+ destroy_extension_intf_(extension_intf_);
+ ::dlclose(extension_lib_);
+ }
return error;
}
@@ -88,10 +126,22 @@
DisplayError CoreImpl::Deinit() {
SCOPE_LOCK(locker_);
- offline_ctrl_.Deinit();
+ if (extension_intf_) {
+ extension_intf_->DestroyRotator(rotator_intf_);
+ }
+
comp_mgr_.Deinit();
HWInfoInterface::Destroy(hw_info_intf_);
+ if (hw_resource_) {
+ delete hw_resource_;
+ }
+
+ if (extension_lib_) {
+ destroy_extension_intf_(extension_intf_);
+ ::dlclose(extension_lib_);
+ }
+
return kErrorNone;
}
@@ -108,15 +158,15 @@
switch (type) {
case kPrimary:
display_base = new DisplayPrimary(event_handler, hw_info_intf_, buffer_sync_handler_,
- &comp_mgr_, &offline_ctrl_);
+ &comp_mgr_, rotator_intf_);
break;
case kHDMI:
display_base = new DisplayHDMI(event_handler, hw_info_intf_, buffer_sync_handler_,
- &comp_mgr_, &offline_ctrl_);
+ &comp_mgr_, rotator_intf_);
break;
case kVirtual:
display_base = new DisplayVirtual(event_handler, hw_info_intf_, buffer_sync_handler_,
- &comp_mgr_, &offline_ctrl_);
+ &comp_mgr_, rotator_intf_);
break;
default:
DLOGE("Spurious display type %d", type);
@@ -154,5 +204,5 @@
return kErrorNone;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/core_impl.h b/sdm/libs/core/core_impl.h
similarity index 90%
rename from displayengine/libs/core/core_impl.h
rename to sdm/libs/core/core_impl.h
index 03733a8..bad241c 100644
--- a/displayengine/libs/core/core_impl.h
+++ b/sdm/libs/core/core_impl.h
@@ -26,18 +26,18 @@
#define __CORE_IMPL_H__
#include <core/core_interface.h>
-#include <private/strategy_interface.h>
+#include <private/extension_interface.h>
#include <utils/locker.h>
#include "hw_interface.h"
#include "comp_manager.h"
-#include "offline_ctrl.h"
#define SET_REVISION(major, minor) ((major << 8) | minor)
-namespace sde {
+namespace sdm {
class HWInfoInterface;
+class RotatorCtrl;
class CoreImpl : public CoreInterface {
public:
@@ -66,11 +66,15 @@
BufferSyncHandler *buffer_sync_handler_;
HWResourceInfo *hw_resource_;
CompManager comp_mgr_;
- OfflineCtrl offline_ctrl_;
HWInfoInterface *hw_info_intf_;
+ RotatorInterface *rotator_intf_;
+ void *extension_lib_;
+ ExtensionInterface *extension_intf_;
+ CreateExtensionInterface create_extension_intf_;
+ DestroyExtensionInterface destroy_extension_intf_;
};
-} // namespace sde
+} // namespace sdm
#endif // __CORE_IMPL_H__
diff --git a/displayengine/libs/core/core_interface.cpp b/sdm/libs/core/core_interface.cpp
similarity index 97%
rename from displayengine/libs/core/core_interface.cpp
rename to sdm/libs/core/core_interface.cpp
index 0cfec66..34eceff 100644
--- a/displayengine/libs/core/core_interface.cpp
+++ b/sdm/libs/core/core_interface.cpp
@@ -40,7 +40,7 @@
#define GET_DATA_ALIGNMENT(version) ((version >> 8) & 0xFF)
#define GET_INSTRUCTION_SET(version) (version & 0xFF)
-namespace sde {
+namespace sdm {
// Currently, we support only one client and one session for display core. So, create a global
// singleton core object.
@@ -63,7 +63,7 @@
}
// Check compatibility of client and core.
- uint32_t lib_version = SDE_VERSION_TAG;
+ uint32_t lib_version = SDM_VERSION_TAG;
if (GET_REVISION(client_version) > GET_REVISION(lib_version)) {
return kErrorVersion;
} else if (GET_DATA_ALIGNMENT(client_version) != GET_DATA_ALIGNMENT(lib_version)) {
@@ -120,5 +120,5 @@
return kErrorNone;
}
-} // namespace sde
+} // namespace sdm
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
new file mode 100644
index 0000000..8dc9b19
--- /dev/null
+++ b/sdm/libs/core/display_base.cpp
@@ -0,0 +1,564 @@
+/*
+* Copyright (c) 2014 - 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <utils/constants.h>
+#include <utils/debug.h>
+
+#include "display_base.h"
+
+#define __CLASS__ "DisplayBase"
+
+namespace sdm {
+
+// TODO(user): Have a single structure handle carries all the interface pointers and variables.
+DisplayBase::DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
+ HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler,
+ CompManager *comp_manager, RotatorInterface *rotator_intf)
+ : display_type_(display_type), event_handler_(event_handler), hw_device_type_(hw_device_type),
+ buffer_sync_handler_(buffer_sync_handler), comp_manager_(comp_manager),
+ rotator_intf_(rotator_intf), state_(kStateOff), hw_device_(0), display_comp_ctx_(0),
+ display_attributes_(NULL), num_modes_(0), active_mode_index_(0), pending_commit_(false),
+ vsync_enable_(false), underscan_supported_(false) {
+}
+
+DisplayError DisplayBase::Init() {
+ DisplayError error = kErrorNone;
+ hw_panel_info_ = HWPanelInfo();
+ hw_intf_->GetHWPanelInfo(&hw_panel_info_);
+
+ error = hw_intf_->GetNumDisplayAttributes(&num_modes_);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+
+ display_attributes_ = new HWDisplayAttributes[num_modes_];
+ if (!display_attributes_) {
+ error = kErrorMemory;
+ goto CleanupOnError;
+ }
+
+ for (uint32_t i = 0; i < num_modes_; i++) {
+ error = hw_intf_->GetDisplayAttributes(&display_attributes_[i], i);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+ }
+
+ active_mode_index_ = GetBestConfig();
+
+ error = hw_intf_->SetDisplayAttributes(active_mode_index_);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+
+ error = comp_manager_->RegisterDisplay(display_type_, display_attributes_[active_mode_index_],
+ hw_panel_info_, &display_comp_ctx_);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+
+ if (rotator_intf_) {
+ error = rotator_intf_->RegisterDisplay(display_type_, &display_rotator_ctx_);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+ }
+
+ return kErrorNone;
+
+CleanupOnError:
+ if (display_comp_ctx_) {
+ comp_manager_->UnregisterDisplay(display_comp_ctx_);
+ }
+
+ if (display_attributes_) {
+ delete[] display_attributes_;
+ display_attributes_ = NULL;
+ }
+
+ hw_intf_->Close();
+
+ return error;
+}
+
+DisplayError DisplayBase::Deinit() {
+ if (rotator_intf_) {
+ rotator_intf_->UnregisterDisplay(display_rotator_ctx_);
+ }
+
+ comp_manager_->UnregisterDisplay(display_comp_ctx_);
+
+ if (display_attributes_) {
+ delete[] display_attributes_;
+ display_attributes_ = NULL;
+ }
+
+ hw_intf_->Close();
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::Prepare(LayerStack *layer_stack) {
+ DisplayError error = kErrorNone;
+
+ if (!layer_stack) {
+ return kErrorParameters;
+ }
+
+ pending_commit_ = false;
+
+ if (state_ == kStateOn) {
+ // Clean hw layers for reuse.
+ hw_layers_.info = HWLayersInfo();
+ hw_layers_.info.stack = layer_stack;
+ hw_layers_.output_compression = 1.0f;
+
+ comp_manager_->PrePrepare(display_comp_ctx_, &hw_layers_);
+ while (true) {
+ error = comp_manager_->Prepare(display_comp_ctx_, &hw_layers_);
+ if (error != kErrorNone) {
+ break;
+ }
+
+ if (IsRotationRequired(&hw_layers_)) {
+ if (!rotator_intf_) {
+ continue;
+ }
+ error = rotator_intf_->Prepare(display_rotator_ctx_, &hw_layers_);
+ } else {
+ // Release all the previous rotator sessions.
+ if (rotator_intf_) {
+ error = rotator_intf_->Purge(display_rotator_ctx_, &hw_layers_);
+ }
+ }
+
+ if (error == kErrorNone) {
+ error = hw_intf_->Validate(&hw_layers_);
+ if (error == kErrorNone) {
+ // Strategy is successful now, wait for Commit().
+ pending_commit_ = true;
+ break;
+ }
+ }
+ }
+ comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_);
+ } else {
+ return kErrorNotSupported;
+ }
+
+ return error;
+}
+
+DisplayError DisplayBase::Commit(LayerStack *layer_stack) {
+ DisplayError error = kErrorNone;
+
+ if (!layer_stack) {
+ return kErrorParameters;
+ }
+
+ if (state_ != kStateOn) {
+ return kErrorNotSupported;
+ }
+
+ if (!pending_commit_) {
+ DLOGE("Commit: Corresponding Prepare() is not called for display = %d", display_type_);
+ return kErrorUndefined;
+ }
+
+ pending_commit_ = false;
+
+ if (rotator_intf_ && IsRotationRequired(&hw_layers_)) {
+ error = rotator_intf_->Commit(display_rotator_ctx_, &hw_layers_);
+ if (error != kErrorNone) {
+ return error;
+ }
+ }
+
+ error = hw_intf_->Commit(&hw_layers_);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ if (rotator_intf_ && IsRotationRequired(&hw_layers_)) {
+ error = rotator_intf_->PostCommit(display_rotator_ctx_, &hw_layers_);
+ if (error != kErrorNone) {
+ return error;
+ }
+ }
+
+ error = comp_manager_->PostCommit(display_comp_ctx_, &hw_layers_);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::Flush() {
+ DisplayError error = kErrorNone;
+
+ if (state_ != kStateOn) {
+ return kErrorNone;
+ }
+
+ hw_layers_.info.count = 0;
+ error = hw_intf_->Flush();
+ if (error == kErrorNone) {
+ comp_manager_->Purge(display_comp_ctx_);
+ pending_commit_ = false;
+ } else {
+ DLOGV("Failed to flush device.");
+ }
+
+ return error;
+}
+
+DisplayError DisplayBase::GetDisplayState(DisplayState *state) {
+ if (!state) {
+ return kErrorParameters;
+ }
+
+ *state = state_;
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::GetNumVariableInfoConfigs(uint32_t *count) {
+ if (!count) {
+ return kErrorParameters;
+ }
+
+ *count = num_modes_;
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::GetConfig(DisplayConfigFixedInfo *fixed_info) {
+ if (!fixed_info) {
+ return kErrorParameters;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info) {
+ if (!variable_info || index >= num_modes_) {
+ return kErrorParameters;
+ }
+
+ *variable_info = display_attributes_[index];
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::GetActiveConfig(uint32_t *index) {
+ if (!index) {
+ return kErrorParameters;
+ }
+
+ *index = active_mode_index_;
+
+ return kErrorNone;
+}
+
+DisplayError DisplayBase::GetVSyncState(bool *enabled) {
+ if (!enabled) {
+ return kErrorParameters;
+ }
+
+ return kErrorNone;
+}
+
+bool DisplayBase::IsUnderscanSupported() {
+ return underscan_supported_;
+}
+
+DisplayError DisplayBase::SetDisplayState(DisplayState state) {
+ DisplayError error = kErrorNone;
+
+ DLOGI("Set state = %d, display %d", state, display_type_);
+
+ if (state == state_) {
+ DLOGI("Same state transition is requested.");
+ return kErrorNone;
+ }
+
+ switch (state) {
+ case kStateOff:
+ hw_layers_.info.count = 0;
+ error = hw_intf_->Flush();
+ if (error == kErrorNone) {
+ comp_manager_->Purge(display_comp_ctx_);
+
+ error = hw_intf_->PowerOff();
+ }
+ break;
+
+ case kStateOn:
+ error = hw_intf_->PowerOn();
+ break;
+
+ case kStateDoze:
+ error = hw_intf_->Doze();
+ break;
+
+ case kStateDozeSuspend:
+ error = hw_intf_->DozeSuspend();
+ break;
+
+ case kStateStandby:
+ error = hw_intf_->Standby();
+ break;
+
+ default:
+ DLOGE("Spurious state = %d transition requested.", state);
+ break;
+ }
+
+ if (error == kErrorNone) {
+ state_ = state;
+ }
+
+ return error;
+}
+
+DisplayError DisplayBase::SetActiveConfig(uint32_t index) {
+ DisplayError error = kErrorNone;
+
+ if (index >= num_modes_) {
+ return kErrorParameters;
+ }
+
+ error = hw_intf_->SetDisplayAttributes(index);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ active_mode_index_ = index;
+
+ if (display_comp_ctx_) {
+ comp_manager_->UnregisterDisplay(display_comp_ctx_);
+ }
+
+ error = comp_manager_->RegisterDisplay(display_type_, display_attributes_[index], hw_panel_info_,
+ &display_comp_ctx_);
+
+ return error;
+}
+
+DisplayError DisplayBase::SetMaxMixerStages(uint32_t max_mixer_stages) {
+ DisplayError error = kErrorNone;
+
+ if (comp_manager_) {
+ error = comp_manager_->SetMaxMixerStages(display_comp_ctx_, max_mixer_stages);
+ }
+
+ return error;
+}
+
+DisplayError DisplayBase::SetDisplayMode(uint32_t mode) {
+ return kErrorNotSupported;
+}
+
+DisplayError DisplayBase::IsScalingValid(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ return comp_manager_->ValidateScaling(crop, dst, rotate90);
+}
+
+void DisplayBase::AppendDump(char *buffer, uint32_t length) {
+ DumpImpl::AppendString(buffer, length, "\n-----------------------");
+ DumpImpl::AppendString(buffer, length, "\ndevice type: %u", display_type_);
+ DumpImpl::AppendString(buffer, length, "\nstate: %u, vsync on: %u", state_, INT(vsync_enable_));
+ DumpImpl::AppendString(buffer, length, "\nnum configs: %u, active config index: %u",
+ num_modes_, active_mode_index_);
+
+ DisplayConfigVariableInfo &info = display_attributes_[active_mode_index_];
+ DumpImpl::AppendString(buffer, length, "\nres:%u x %u, dpi:%.2f x %.2f, fps:%.2f,"
+ "vsync period: %u", info.x_pixels, info.y_pixels, info.x_dpi,
+ info.y_dpi, info.fps, info.vsync_period_ns);
+
+ DumpImpl::AppendString(buffer, length, "\n");
+
+ uint32_t num_layers = 0;
+ uint32_t num_hw_layers = 0;
+ if (hw_layers_.info.stack) {
+ num_layers = hw_layers_.info.stack->layer_count;
+ num_hw_layers = hw_layers_.info.count;
+ }
+
+ if (num_hw_layers == 0) {
+ DumpImpl::AppendString(buffer, length, "\nNo hardware layers programmed");
+ return;
+ }
+
+ HWLayersInfo &layer_info = hw_layers_.info;
+ LayerRect &l_roi = layer_info.left_partial_update;
+ LayerRect &r_roi = layer_info.right_partial_update;
+ DumpImpl::AppendString(buffer, length, "\nROI(L T R B) : LEFT(%d %d %d %d), RIGHT(%d %d %d %d)",
+ INT(l_roi.left), INT(l_roi.top), INT(l_roi.right), INT(l_roi.bottom),
+ INT(r_roi.left), INT(r_roi.top), INT(r_roi.right), INT(r_roi.bottom));
+
+ const char *header = "\n| Idx | Comp Type | Split | WB | Pipe | W x H | Format | Src Rect (L T R B) | Dst Rect (L T R B) | Z | Flags | Deci(HxV) |"; //NOLINT
+ const char *newline = "\n|-----|-------------|--------|----|-------|-------------|--------------------|---------------------|---------------------|----|------------|-----------|"; //NOLINT
+ const char *format = "\n| %3s | %11s " "| %6s " "| %2s | 0x%03x | %4d x %4d | %18s " "| %4d %4d %4d %4d " "| %4d %4d %4d %4d " "| %2s | %10s " "| %9s |"; //NOLINT
+
+ DumpImpl::AppendString(buffer, length, "\n");
+ DumpImpl::AppendString(buffer, length, newline);
+ DumpImpl::AppendString(buffer, length, header);
+ DumpImpl::AppendString(buffer, length, newline);
+
+ for (uint32_t i = 0; i < num_hw_layers; i++) {
+ uint32_t layer_index = hw_layers_.info.index[i];
+ Layer &layer = hw_layers_.info.stack->layers[layer_index];
+ LayerBuffer *input_buffer = layer.input_buffer;
+ HWLayerConfig &layer_config = hw_layers_.config[i];
+ HWRotatorSession &hw_rotator_session = layer_config.hw_rotator_session;
+
+ char idx[8] = { 0 };
+ const char *comp_type = GetName(layer.composition);
+ const char *buffer_format = GetName(input_buffer->format);
+ const char *rotate_split[2] = { "Rot-L", "Rot-R" };
+ const char *comp_split[2] = { "Comp-L", "Comp-R" };
+
+ snprintf(idx, sizeof(idx), "%d", layer_index);
+
+ for (uint32_t count = 0; count < hw_rotator_session.hw_block_count; count++) {
+ char writeback_id[8];
+ HWRotateInfo &rotate = hw_rotator_session.hw_rotate_info[count];
+ LayerRect &src_roi = rotate.src_roi;
+ LayerRect &dst_roi = rotate.dst_roi;
+
+ snprintf(writeback_id, sizeof(writeback_id), "%d", rotate.writeback_id);
+
+ DumpImpl::AppendString(buffer, length, format, idx, comp_type, rotate_split[count],
+ writeback_id, rotate.pipe_id, input_buffer->width,
+ input_buffer->height, buffer_format, INT(src_roi.left),
+ INT(src_roi.top), INT(src_roi.right), INT(src_roi.bottom),
+ INT(dst_roi.left), INT(dst_roi.top), INT(dst_roi.right),
+ INT(dst_roi.bottom), "-", "- ", "- ");
+
+ // print the below only once per layer block, fill with spaces for rest.
+ idx[0] = 0;
+ comp_type = "";
+ }
+
+ if (hw_rotator_session.hw_block_count > 0) {
+ input_buffer = &hw_rotator_session.output_buffer;
+ buffer_format = GetName(input_buffer->format);
+ }
+
+ for (uint32_t count = 0; count < 2; count++) {
+ char decimation[16];
+ char flags[16];
+ char z_order[8];
+ HWPipeInfo &pipe = (count == 0) ? layer_config.left_pipe : layer_config.right_pipe;
+
+ if (!pipe.valid) {
+ continue;
+ }
+
+ LayerRect &src_roi = pipe.src_roi;
+ LayerRect &dst_roi = pipe.dst_roi;
+
+ snprintf(z_order, sizeof(z_order), "%d", pipe.z_order);
+ snprintf(flags, sizeof(flags), "0x%08x", layer.flags.flags);
+ snprintf(decimation, sizeof(decimation), "%3d x %3d", pipe.horizontal_decimation,
+ pipe.vertical_decimation);
+
+ DumpImpl::AppendString(buffer, length, format, idx, comp_type, comp_split[count],
+ "-", pipe.pipe_id, input_buffer->width, input_buffer->height,
+ buffer_format, INT(src_roi.left), INT(src_roi.top),
+ INT(src_roi.right), INT(src_roi.bottom), INT(dst_roi.left),
+ INT(dst_roi.top), INT(dst_roi.right), INT(dst_roi.bottom),
+ z_order, flags, decimation);
+
+ // print the below only once per layer block, fill with spaces for rest.
+ idx[0] = 0;
+ comp_type = "";
+ }
+
+ DumpImpl::AppendString(buffer, length, newline);
+ }
+}
+
+int DisplayBase::GetBestConfig() {
+ return (num_modes_ == 1) ? 0 : -1;
+}
+
+bool DisplayBase::IsRotationRequired(HWLayers *hw_layers) {
+ HWLayersInfo &layer_info = hw_layers->info;
+
+ for (uint32_t i = 0; i < layer_info.count; i++) {
+ Layer& layer = layer_info.stack->layers[layer_info.index[i]];
+ HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
+
+ if (hw_rotator_session->hw_block_count) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+const char * DisplayBase::GetName(const LayerComposition &composition) {
+ switch (composition) {
+ case kCompositionGPU: return "GPU";
+ case kCompositionSDE: return "SDE";
+ case kCompositionGPUTarget: return "GPU_TARGET";
+ default: return "UNKNOWN";
+ }
+}
+
+const char * DisplayBase::GetName(const LayerBufferFormat &format) {
+ switch (format) {
+ case kFormatARGB8888: return "ARGB_8888";
+ case kFormatRGBA8888: return "RGBA_8888";
+ case kFormatBGRA8888: return "BGRA_8888";
+ case kFormatXRGB8888: return "XRGB_8888";
+ case kFormatRGBX8888: return "RGBX_8888";
+ case kFormatBGRX8888: return "BGRX_8888";
+ case kFormatRGBA5551: return "RGBA_5551";
+ case kFormatRGBA4444: return "RGBA_4444";
+ case kFormatRGB888: return "RGB_888";
+ case kFormatBGR888: return "BGR_888";
+ case kFormatRGB565: return "RGB_565";
+ case kFormatRGBA8888Ubwc: return "RGBA_8888_UBWC";
+ case kFormatRGBX8888Ubwc: return "RGBX_8888_UBWC";
+ case kFormatRGB565Ubwc: return "RGB_565_UBWC";
+ case kFormatYCbCr420Planar: return "Y_CB_CR_420";
+ case kFormatYCrCb420Planar: return "Y_CR_CB_420";
+ case kFormatYCbCr420SemiPlanar: return "Y_CBCR_420";
+ case kFormatYCrCb420SemiPlanar: return "Y_CRCB_420";
+ case kFormatYCbCr420SemiPlanarVenus: return "Y_CBCR_420_VENUS";
+ case kFormatYCbCr422H1V2SemiPlanar: return "Y_CBCR_422_H1V2";
+ case kFormatYCrCb422H1V2SemiPlanar: return "Y_CRCB_422_H1V2";
+ case kFormatYCbCr422H2V1SemiPlanar: return "Y_CBCR_422_H2V1";
+ case kFormatYCrCb422H2V1SemiPlanar: return "Y_CRCB_422_H2V2";
+ case kFormatYCbCr420SPVenusUbwc: return "Y_CBCR_420_VENUS_UBWC";
+ case kFormatYCbCr422H2V1Packed: return "YCBYCR_422_H2V1";
+ default: return "UNKNOWN";
+ }
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/core/display_base.h b/sdm/libs/core/display_base.h
similarity index 85%
rename from displayengine/libs/core/display_base.h
rename to sdm/libs/core/display_base.h
index 6d107a0..56e6682 100644
--- a/displayengine/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -27,22 +27,22 @@
#include <core/display_interface.h>
#include <private/strategy_interface.h>
+#include <private/rotator_interface.h>
#include <utils/locker.h>
#include "hw_interface.h"
#include "comp_manager.h"
-#include "buffer_manager.h"
-namespace sde {
+namespace sdm {
-class OfflineCtrl;
+class RotatorCtrl;
class DisplayBase : public DisplayInterface {
public:
DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler,
- CompManager *comp_manager, OfflineCtrl *offline_ctrl);
+ CompManager *comp_manager, RotatorInterface *rotator_intf);
virtual ~DisplayBase() { }
virtual DisplayError Init();
virtual DisplayError Deinit();
@@ -56,17 +56,20 @@
virtual DisplayError GetActiveConfig(uint32_t *index);
virtual DisplayError GetVSyncState(bool *enabled);
virtual DisplayError SetDisplayState(DisplayState state);
- virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info);
virtual DisplayError SetActiveConfig(uint32_t index);
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
virtual DisplayError SetDisplayMode(uint32_t mode);
+ virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst, bool rotate90);
+ virtual bool IsUnderscanSupported();
protected:
// DumpImpl method
void AppendDump(char *buffer, uint32_t length);
- void AppendRect(char *buffer, uint32_t length, const char *rect_name, LayerRect *rect);
virtual int GetBestConfig();
+ bool IsRotationRequired(HWLayers *hw_layers);
+ const char * GetName(const LayerComposition &composition);
+ const char * GetName(const LayerBufferFormat &format);
DisplayType display_type_;
DisplayEventHandler *event_handler_;
@@ -75,20 +78,21 @@
HWPanelInfo hw_panel_info_;
BufferSyncHandler *buffer_sync_handler_;
CompManager *comp_manager_;
- OfflineCtrl *offline_ctrl_;
+ RotatorInterface *rotator_intf_;
DisplayState state_;
Handle hw_device_;
Handle display_comp_ctx_;
- Handle display_offline_ctx_;
+ Handle display_rotator_ctx_;
HWDisplayAttributes *display_attributes_;
uint32_t num_modes_;
uint32_t active_mode_index_;
HWLayers hw_layers_;
bool pending_commit_;
bool vsync_enable_;
+ bool underscan_supported_;
};
-} // namespace sde
+} // namespace sdm
#endif // __DISPLAY_BASE_H__
diff --git a/displayengine/libs/core/display_hdmi.cpp b/sdm/libs/core/display_hdmi.cpp
similarity index 77%
rename from displayengine/libs/core/display_hdmi.cpp
rename to sdm/libs/core/display_hdmi.cpp
index 2b6ba81..ef25b90 100644
--- a/displayengine/libs/core/display_hdmi.cpp
+++ b/sdm/libs/core/display_hdmi.cpp
@@ -31,13 +31,13 @@
#define __CLASS__ "DisplayHDMI"
-namespace sde {
+namespace sdm {
DisplayHDMI::DisplayHDMI(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl)
+ RotatorInterface *rotator_intf)
: DisplayBase(kHDMI, event_handler, kDeviceHDMI, buffer_sync_handler, comp_manager,
- offline_ctrl), hw_info_intf_(hw_info_intf) {
+ rotator_intf), hw_info_intf_(hw_info_intf) {
}
DisplayError DisplayHDMI::Init() {
@@ -60,6 +60,9 @@
HWHDMIInterface::Destroy(hw_hdmi_intf_);
}
+ GetScanSupport();
+ underscan_supported_ = (scan_support_ == kScanAlwaysUnderscanned) || (scan_support_ == kScanBoth);
+
return error;
}
@@ -127,7 +130,7 @@
DisplayError DisplayHDMI::SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
SCOPE_LOCK(locker_);
- return DisplayBase::SetActiveConfig(variable_info);
+ return kErrorNotSupported;
}
DisplayError DisplayHDMI::SetActiveConfig(uint32_t index) {
@@ -152,6 +155,22 @@
return DisplayBase::SetDisplayMode(mode);
}
+DisplayError DisplayHDMI::IsScalingValid(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsScalingValid(crop, dst, rotate90);
+}
+
+DisplayError DisplayHDMI::SetRefreshRate(uint32_t refresh_rate) {
+ SCOPE_LOCK(locker_);
+ return kErrorNotSupported;
+}
+
+bool DisplayHDMI::IsUnderscanSupported() {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsUnderscanSupported();
+}
+
int DisplayHDMI::GetBestConfig() {
uint32_t best_config_mode = 0;
HWDisplayAttributes *best = &display_attributes_[0];
@@ -193,10 +212,40 @@
return best_config_mode;
}
+void DisplayHDMI::GetScanSupport() {
+ DisplayError error = kErrorNone;
+ uint32_t video_format = -1;
+ uint32_t max_cea_format = -1;
+ HWScanInfo scan_info = HWScanInfo();
+ hw_hdmi_intf_->GetHWScanInfo(&scan_info);
+
+ error = hw_hdmi_intf_->GetVideoFormat(active_mode_index_, &video_format);
+ if (error != kErrorNone) {
+ return;
+ }
+
+ error = hw_hdmi_intf_->GetMaxCEAFormat(&max_cea_format);
+ if (error != kErrorNone) {
+ return;
+ }
+
+ // The scan support for a given HDMI TV must be read from scan info corresponding to
+ // Preferred Timing if the preferred timing of the display is currently active, and if it is
+ // valid. In all other cases, we must read the scan support from CEA scan info if
+ // the resolution is a CEA resolution, or from IT scan info for all other resolutions.
+ if (active_mode_index_ == 0 && scan_info.pt_scan_support != kScanNotSupported) {
+ scan_support_ = scan_info.pt_scan_support;
+ } else if (video_format < max_cea_format) {
+ scan_support_ = scan_info.cea_scan_support;
+ } else {
+ scan_support_ = scan_info.it_scan_support;
+ }
+}
+
void DisplayHDMI::AppendDump(char *buffer, uint32_t length) {
SCOPE_LOCK(locker_);
DisplayBase::AppendDump(buffer, length);
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/display_hdmi.h b/sdm/libs/core/display_hdmi.h
similarity index 89%
rename from displayengine/libs/core/display_hdmi.h
rename to sdm/libs/core/display_hdmi.h
index fc2be21..96b9eea 100644
--- a/displayengine/libs/core/display_hdmi.h
+++ b/sdm/libs/core/display_hdmi.h
@@ -26,8 +26,9 @@
#define __DISPLAY_HDMI_H__
#include "display_base.h"
+#include "dump_impl.h"
-namespace sde {
+namespace sdm {
class HWHDMIInterface;
class HWInfoInterface;
@@ -36,7 +37,7 @@
public:
DisplayHDMI(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl);
+ RotatorInterface *rotator_intf);
virtual DisplayError Init();
virtual DisplayError Deinit();
virtual DisplayError Prepare(LayerStack *layer_stack);
@@ -55,17 +56,22 @@
virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
virtual DisplayError SetDisplayMode(uint32_t mode);
+ virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst, bool rotate90);
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
+ virtual bool IsUnderscanSupported();
virtual void AppendDump(char *buffer, uint32_t length);
private:
virtual int GetBestConfig();
+ virtual void GetScanSupport();
Locker locker_;
HWHDMIInterface *hw_hdmi_intf_;
HWInfoInterface *hw_info_intf_;
+ HWScanSupport scan_support_;
};
-} // namespace sde
+} // namespace sdm
#endif // __DISPLAY_HDMI_H__
diff --git a/displayengine/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
similarity index 82%
rename from displayengine/libs/core/display_primary.cpp
rename to sdm/libs/core/display_primary.cpp
index 1dcd05b..63ee78b 100644
--- a/displayengine/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -31,13 +31,13 @@
#define __CLASS__ "DisplayPrimary"
-namespace sde {
+namespace sdm {
DisplayPrimary::DisplayPrimary(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl)
+ RotatorInterface *rotator_intf)
: DisplayBase(kPrimary, event_handler, kDevicePrimary, buffer_sync_handler, comp_manager,
- offline_ctrl), hw_info_intf_(hw_info_intf) {
+ rotator_intf), hw_info_intf_(hw_info_intf) {
}
DisplayError DisplayPrimary::Init() {
@@ -88,14 +88,25 @@
DisplayError DisplayPrimary::Commit(LayerStack *layer_stack) {
SCOPE_LOCK(locker_);
DisplayError error = kErrorNone;
+ HWPanelInfo panel_info;
+ HWDisplayAttributes display_attributes;
error = DisplayBase::Commit(layer_stack);
if (error != kErrorNone) {
return error;
}
- hw_primary_intf_->GetHWPanelInfo(&hw_panel_info_);
- // TODO(user): Update panel info in composition manager and resource manager
+ hw_primary_intf_->GetHWPanelInfo(&panel_info);
+
+ hw_primary_intf_->GetDisplayAttributes(&display_attributes, active_mode_index_);
+
+ if (panel_info != hw_panel_info_ ||
+ display_attributes != display_attributes_[active_mode_index_]) {
+ comp_manager_->ReconfigureDisplay(display_comp_ctx_, display_attributes, panel_info);
+
+ hw_panel_info_ = panel_info;
+ display_attributes_[active_mode_index_] = display_attributes;
+ }
return error;
}
@@ -135,6 +146,11 @@
return DisplayBase::GetVSyncState(enabled);
}
+bool DisplayPrimary::IsUnderscanSupported() {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsUnderscanSupported();
+}
+
DisplayError DisplayPrimary::SetDisplayState(DisplayState state) {
SCOPE_LOCK(locker_);
return DisplayBase::SetDisplayState(state);
@@ -142,7 +158,7 @@
DisplayError DisplayPrimary::SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
SCOPE_LOCK(locker_);
- return DisplayBase::SetActiveConfig(variable_info);
+ return kErrorNotSupported;
}
DisplayError DisplayPrimary::SetActiveConfig(uint32_t index) {
@@ -186,7 +202,7 @@
return kErrorNotSupported;
}
- switch(mode) {
+ switch (mode) {
case kModeVideo:
hw_display_mode = kModeVideo;
break;
@@ -214,13 +230,37 @@
return error;
}
+DisplayError DisplayPrimary::IsScalingValid(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsScalingValid(crop, dst, rotate90);
+}
+
+DisplayError DisplayPrimary::SetRefreshRate(uint32_t refresh_rate) {
+ SCOPE_LOCK(locker_);
+
+ DisplayError error = kErrorNone;
+
+ if (!hw_panel_info_.dynamic_fps) {
+ DLOGW("Dynamic fps feature is not supported");
+ return kErrorNotSupported;
+ }
+
+ if (refresh_rate > hw_panel_info_.max_fps) {
+ refresh_rate = hw_panel_info_.max_fps;
+ } else if (refresh_rate < hw_panel_info_.min_fps) {
+ refresh_rate = hw_panel_info_.min_fps;
+ }
+
+ return hw_primary_intf_->SetRefreshRate(refresh_rate);
+}
+
void DisplayPrimary::AppendDump(char *buffer, uint32_t length) {
SCOPE_LOCK(locker_);
DisplayBase::AppendDump(buffer, length);
}
DisplayError DisplayPrimary::VSync(int64_t timestamp) {
- SCOPE_LOCK(locker_);
if (vsync_enable_) {
DisplayEventVSync vsync;
vsync.timestamp = timestamp;
@@ -248,5 +288,5 @@
comp_manager_->ProcessThermalEvent(display_comp_ctx_, thermal_level);
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/display_primary.h b/sdm/libs/core/display_primary.h
similarity index 91%
rename from displayengine/libs/core/display_primary.h
rename to sdm/libs/core/display_primary.h
index da84fe6..2cbae4b 100644
--- a/displayengine/libs/core/display_primary.h
+++ b/sdm/libs/core/display_primary.h
@@ -26,8 +26,9 @@
#define __DISPLAY_PRIMARY_H__
#include "display_base.h"
+#include "dump_impl.h"
-namespace sde {
+namespace sdm {
class HWPrimaryInterface;
class HWInfoInterface;
@@ -36,7 +37,7 @@
public:
DisplayPrimary(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl);
+ RotatorInterface *rotator_intf);
virtual DisplayError Init();
virtual DisplayError Deinit();
virtual DisplayError Prepare(LayerStack *layer_stack);
@@ -55,6 +56,9 @@
virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
virtual DisplayError SetDisplayMode(uint32_t mode);
+ virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst, bool rotate90);
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
+ virtual bool IsUnderscanSupported();
virtual void AppendDump(char *buffer, uint32_t length);
// Implement the HWEventHandlers
@@ -69,7 +73,7 @@
HWInfoInterface *hw_info_intf_;
};
-} // namespace sde
+} // namespace sdm
#endif // __DISPLAY_PRIMARY_H__
diff --git a/displayengine/libs/core/display_virtual.cpp b/sdm/libs/core/display_virtual.cpp
similarity index 77%
rename from displayengine/libs/core/display_virtual.cpp
rename to sdm/libs/core/display_virtual.cpp
index a5af9bf..262db7f 100644
--- a/displayengine/libs/core/display_virtual.cpp
+++ b/sdm/libs/core/display_virtual.cpp
@@ -31,13 +31,13 @@
#define __CLASS__ "DisplayVirtual"
-namespace sde {
+namespace sdm {
DisplayVirtual::DisplayVirtual(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl)
+ RotatorInterface *rotator_intf)
: DisplayBase(kVirtual, event_handler, kDeviceVirtual, buffer_sync_handler, comp_manager,
- offline_ctrl), hw_info_intf_(hw_info_intf) {
+ rotator_intf), hw_info_intf_(hw_info_intf) {
}
DisplayError DisplayVirtual::Init() {
@@ -120,6 +120,11 @@
return DisplayBase::GetVSyncState(enabled);
}
+bool DisplayVirtual::IsUnderscanSupported() {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsUnderscanSupported();
+}
+
DisplayError DisplayVirtual::SetDisplayState(DisplayState state) {
SCOPE_LOCK(locker_);
return DisplayBase::SetDisplayState(state);
@@ -127,7 +132,33 @@
DisplayError DisplayVirtual::SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
SCOPE_LOCK(locker_);
- return DisplayBase::SetActiveConfig(variable_info);
+ DisplayError error = kErrorNone;
+
+ if (!variable_info) {
+ return kErrorParameters;
+ }
+
+ HWDisplayAttributes display_attributes = display_attributes_[active_mode_index_];
+
+ display_attributes.x_pixels = variable_info->x_pixels;
+ display_attributes.y_pixels = variable_info->y_pixels;
+ display_attributes.fps = variable_info->fps;
+
+ // if display is already connected, unregister display from composition manager and register
+ // the display with new configuration.
+ if (display_comp_ctx_) {
+ comp_manager_->UnregisterDisplay(display_comp_ctx_);
+ }
+
+ error = comp_manager_->RegisterDisplay(display_type_, display_attributes, hw_panel_info_,
+ &display_comp_ctx_);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ display_attributes_[active_mode_index_] = display_attributes;
+
+ return error;
}
DisplayError DisplayVirtual::SetActiveConfig(uint32_t index) {
@@ -152,10 +183,21 @@
return DisplayBase::SetDisplayMode(mode);
}
+DisplayError DisplayVirtual::IsScalingValid(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ SCOPE_LOCK(locker_);
+ return DisplayBase::IsScalingValid(crop, dst, rotate90);
+}
+
+DisplayError DisplayVirtual::SetRefreshRate(uint32_t refresh_rate) {
+ SCOPE_LOCK(locker_);
+ return kErrorNotSupported;
+}
+
void DisplayVirtual::AppendDump(char *buffer, uint32_t length) {
SCOPE_LOCK(locker_);
DisplayBase::AppendDump(buffer, length);
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/display_virtual.h b/sdm/libs/core/display_virtual.h
similarity index 90%
rename from displayengine/libs/core/display_virtual.h
rename to sdm/libs/core/display_virtual.h
index 419c6ec..2065534 100644
--- a/displayengine/libs/core/display_virtual.h
+++ b/sdm/libs/core/display_virtual.h
@@ -26,8 +26,9 @@
#define __DISPLAY_VIRTUAL_H__
#include "display_base.h"
+#include "dump_impl.h"
-namespace sde {
+namespace sdm {
class HWVirtualInterface;
class HWInfoInterface;
@@ -36,7 +37,7 @@
public:
DisplayVirtual(DisplayEventHandler *event_handler, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler, CompManager *comp_manager,
- OfflineCtrl *offline_ctrl);
+ RotatorInterface *rotator_intf);
virtual DisplayError Init();
virtual DisplayError Deinit();
virtual DisplayError Prepare(LayerStack *layer_stack);
@@ -55,6 +56,9 @@
virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
virtual DisplayError SetDisplayMode(uint32_t mode);
+ virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst, bool rotate90);
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
+ virtual bool IsUnderscanSupported();
virtual void AppendDump(char *buffer, uint32_t length);
private:
@@ -63,7 +67,7 @@
HWInfoInterface *hw_info_intf_;
};
-} // namespace sde
+} // namespace sdm
#endif // __DISPLAY_VIRTUAL_H__
diff --git a/displayengine/libs/core/dump_impl.cpp b/sdm/libs/core/dump_impl.cpp
old mode 100755
new mode 100644
similarity index 94%
rename from displayengine/libs/core/dump_impl.cpp
rename to sdm/libs/core/dump_impl.cpp
index a5aca81..0d6c9b2
--- a/displayengine/libs/core/dump_impl.cpp
+++ b/sdm/libs/core/dump_impl.cpp
@@ -29,7 +29,7 @@
#include "dump_impl.h"
-namespace sde {
+namespace sdm {
DumpImpl* DumpImpl::dump_list_[] = { 0 };
uint32_t DumpImpl::dump_count_ = 0;
@@ -40,11 +40,11 @@
}
buffer[0] = '\0';
- DumpImpl::AppendString(buffer, length, "\n-------- Snapdragon Display Engine --------");
+ DumpImpl::AppendString(buffer, length, "\n-------- Snapdragon Display Manager --------");
for (uint32_t i = 0; i < DumpImpl::dump_count_; i++) {
DumpImpl::dump_list_[i]->AppendDump(buffer, length);
}
- DumpImpl::AppendString(buffer, length, "\n-------------------------------------------\n");
+ DumpImpl::AppendString(buffer, length, "\n\n");
return kErrorNone;
}
@@ -89,5 +89,5 @@
}
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/dump_impl.h b/sdm/libs/core/dump_impl.h
similarity index 98%
rename from displayengine/libs/core/dump_impl.h
rename to sdm/libs/core/dump_impl.h
index 83197e5..123c568 100644
--- a/displayengine/libs/core/dump_impl.h
+++ b/sdm/libs/core/dump_impl.h
@@ -27,7 +27,7 @@
#include <core/dump_interface.h>
-namespace sde {
+namespace sdm {
class DumpImpl {
public:
@@ -52,7 +52,7 @@
friend DumpInterface;
};
-} // namespace sde
+} // namespace sdm
#endif // __DUMP_IMPL_H__
diff --git a/displayengine/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
similarity index 84%
rename from displayengine/libs/core/fb/hw_device.cpp
rename to sdm/libs/core/fb/hw_device.cpp
index a0a0fe2..b905c31 100644
--- a/displayengine/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -40,7 +40,6 @@
#include <utils/debug.h>
#include "hw_device.h"
-#include "scalar_helper.h"
#define __CLASS__ "HWDevice"
@@ -54,10 +53,9 @@
extern FILE* virtual_fopen(const char *fname, const char *mode);
extern int virtual_fclose(FILE* fileptr);
extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream);
-
#endif
-namespace sde {
+namespace sdm {
HWDevice::HWDevice(BufferSyncHandler *buffer_sync_handler)
: fb_node_index_(-1), fb_path_("/sys/devices/virtual/graphics/fb"), hotplug_enabled_(false),
@@ -183,6 +181,10 @@
return kErrorNone;
}
+DisplayError HWDevice::DozeSuspend() {
+ return kErrorNone;
+}
+
DisplayError HWDevice::Standby() {
return kErrorNone;
}
@@ -191,7 +193,6 @@
DTRACE_SCOPED();
DisplayError error = kErrorNone;
- ResetDisplayParams();
HWLayersInfo &hw_layer_info = hw_layers->info;
LayerStack *stack = hw_layer_info.stack;
@@ -203,20 +204,27 @@
mdp_layer_commit_v1 &mdp_commit = mdp_disp_commit_.commit_v1;
uint32_t &mdp_layer_count = mdp_commit.input_layer_cnt;
+ DLOGI_IF(kTagDriverConfig, "left_roi: x = %d, y = %d, w = %d, h = %d", mdp_commit.left_roi.x,
+ mdp_commit.left_roi.y, mdp_commit.left_roi.w, mdp_commit.left_roi.h);
+ DLOGI_IF(kTagDriverConfig, "right_roi: x = %d, y = %d, w = %d, h = %d", mdp_commit.right_roi.x,
+ mdp_commit.right_roi.y, mdp_commit.right_roi.w, mdp_commit.right_roi.h);
+
for (uint32_t i = 0; i < hw_layer_info.count; i++) {
uint32_t layer_index = hw_layer_info.index[i];
Layer &layer = stack->layers[layer_index];
LayerBuffer *input_buffer = layer.input_buffer;
HWPipeInfo *left_pipe = &hw_layers->config[i].left_pipe;
HWPipeInfo *right_pipe = &hw_layers->config[i].right_pipe;
+ HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
+ bool is_rotator_used = (hw_rotator_session->hw_block_count != 0);
mdp_input_layer mdp_layer;
for (uint32_t count = 0; count < 2; count++) {
HWPipeInfo *pipe_info = (count == 0) ? left_pipe : right_pipe;
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
+ HWRotateInfo *hw_rotate_info = &hw_rotator_session->hw_rotate_info[count];
- if (rotate_info->valid) {
- input_buffer = &rotate_info->hw_buffer_info.output_buffer;
+ if (hw_rotate_info->valid) {
+ input_buffer = &hw_rotator_session->output_buffer;
}
if (pipe_info->valid) {
@@ -225,6 +233,8 @@
mdp_buffer.width = input_buffer->width;
mdp_buffer.height = input_buffer->height;
+ mdp_buffer.comp_ratio.denom = 1000;
+ mdp_buffer.comp_ratio.numer = UINT32(hw_layers->config[i].compression * 1000);
error = SetFormat(input_buffer->format, &mdp_buffer.format);
if (error != kErrorNone) {
@@ -241,30 +251,17 @@
SetRect(pipe_info->src_roi, &mdp_layer.src_rect);
SetRect(pipe_info->dst_roi, &mdp_layer.dst_rect);
+ SetMDPFlags(layer, is_rotator_used, &mdp_layer.flags);
- // Flips will be taken care by rotator, if layer requires 90 rotation. So Dont use MDP for
- // flip operation, if layer transform is 90.
- if (!layer.transform.rotation) {
- if (layer.transform.flip_vertical) {
- mdp_layer.flags |= MDP_LAYER_FLIP_UD;
+ if (pipe_info->scale_data.enable_pixel_ext) {
+ if ((mdp_layer.flags & MDP_LAYER_DEINTERLACE) && (layer.transform.rotation == 90.0f)) {
+ mdp_buffer.width = pipe_info->scale_data.src_width;
}
-
- if (layer.transform.flip_horizontal) {
- mdp_layer.flags |= MDP_LAYER_FLIP_LR;
- }
+ SetHWScaleData(pipe_info->scale_data, mdp_layer_count);
}
- mdp_scale_data* mdp_scale = GetScaleDataRef(mdp_layer_count);
-#ifdef USES_SCALAR
- // Set the configured scale data for MDP driver
- ScalarHelper::GetInstance()->SetScaleData(i, !count, mdp_scale);
- if (mdp_scale->enable_pxl_ext) {
- if ((mdp_layer.flags & MDP_LAYER_DEINTERLACE) && (layer.transform.rotation == 90.0f))
- ScalarHelper::GetInstance()->UpdateSrcWidth(i, !count, &mdp_buffer.width);
- }
-#endif
- mdp_layer.scale = mdp_scale;
-
+ // Send scale data to MDP driver
+ mdp_layer.scale = GetScaleDataRef(mdp_layer_count);
mdp_layer_count++;
DLOGV_IF(kTagDriverConfig, "******************* Layer[%d] %s pipe Input ******************",
@@ -272,13 +269,14 @@
DLOGV_IF(kTagDriverConfig, "in_w %d, in_h %d, in_f %d", mdp_buffer.width, mdp_buffer.height,
mdp_buffer.format);
DLOGV_IF(kTagDriverConfig, "plane_alpha %d, zorder %d, blending %d, horz_deci %d, "
- "vert_deci %d", mdp_layer.alpha, mdp_layer.z_order, mdp_layer.blend_op,
- mdp_layer.horz_deci, mdp_layer.vert_deci);
+ "vert_deci %d, pipe_id = 0x%x, mdp_flags 0x%x", mdp_layer.alpha, mdp_layer.z_order,
+ mdp_layer.blend_op, mdp_layer.horz_deci, mdp_layer.vert_deci, mdp_layer.pipe_ndx,
+ mdp_layer.flags);
DLOGV_IF(kTagDriverConfig, "src_rect [%d, %d, %d, %d]", mdp_layer.src_rect.x,
mdp_layer.src_rect.y, mdp_layer.src_rect.w, mdp_layer.src_rect.h);
DLOGV_IF(kTagDriverConfig, "dst_rect [%d, %d, %d, %d]", mdp_layer.dst_rect.x,
mdp_layer.dst_rect.y, mdp_layer.dst_rect.w, mdp_layer.dst_rect.h);
- for (int j = 0; j < MAX_PLANES; j++) {
+ for (int j = 0; j < 4; j++) {
DLOGV_IF(kTagDriverConfig, "Scale Data[%d]: Phase=[%x %x %x %x] Pixel_Ext=[%d %d %d %d]",
j, mdp_layer.scale->init_phase_x[j], mdp_layer.scale->phase_step_x[j],
mdp_layer.scale->init_phase_y[j], mdp_layer.scale->phase_step_y[j],
@@ -303,13 +301,15 @@
mdp_out_layer_.writeback_ndx = 2;
mdp_out_layer_.buffer.width = output_buffer->width;
mdp_out_layer_.buffer.height = output_buffer->height;
+ mdp_out_layer_.buffer.comp_ratio.denom = 1000;
+ mdp_out_layer_.buffer.comp_ratio.numer = UINT32(hw_layers->output_compression * 1000);
SetFormat(output_buffer->format, &mdp_out_layer_.buffer.format);
- DLOGI_IF(kTagDriverConfig, "******************* Output buffer Info **********************");
+ DLOGI_IF(kTagDriverConfig, "********************* Output buffer Info ************************");
DLOGI_IF(kTagDriverConfig, "out_w %d, out_h %d, out_f %d, wb_id %d",
mdp_out_layer_.buffer.width, mdp_out_layer_.buffer.height,
mdp_out_layer_.buffer.format, mdp_out_layer_.writeback_ndx);
- DLOGI_IF(kTagDriverConfig, "*************************************************************");
+ DLOGI_IF(kTagDriverConfig, "*****************************************************************");
}
mdp_commit.flags |= MDP_VALIDATE_LAYER;
@@ -322,22 +322,22 @@
return kErrorNone;
}
-void HWDevice::DumpLayerCommit(mdp_layer_commit &layer_commit) {
- mdp_layer_commit_v1 &mdp_commit = layer_commit.commit_v1;
- mdp_input_layer *mdp_layers = mdp_commit.input_layers;
+void HWDevice::DumpLayerCommit(const mdp_layer_commit &layer_commit) {
+ const mdp_layer_commit_v1 &mdp_commit = layer_commit.commit_v1;
+ const mdp_input_layer *mdp_layers = mdp_commit.input_layers;
- DLOGE("mdp_commt: flags = %x, release fence = %x", mdp_commit.flags, mdp_commit.release_fence);
+ DLOGE("mdp_commit: flags = %x, release fence = %x", mdp_commit.flags, mdp_commit.release_fence);
DLOGE("left_roi: x = %d, y = %d, w = %d, h = %d", mdp_commit.left_roi.x, mdp_commit.left_roi.y,
mdp_commit.left_roi.w, mdp_commit.left_roi.h);
DLOGE("right_roi: x = %d, y = %d, w = %d, h = %d", mdp_commit.right_roi.x,
mdp_commit.right_roi.y, mdp_commit.right_roi.w, mdp_commit.right_roi.h);
for (uint32_t i = 0; i < mdp_commit.input_layer_cnt; i++) {
- DLOGE("mdp_commt: layer_cnt = %d, pipe_ndx = %x, zorder = %d, flags = %x",
+ DLOGE("mdp_commit: layer_cnt = %d, pipe_ndx = %x, zorder = %d, flags = %x",
i, mdp_layers[i].pipe_ndx, mdp_layers[i].z_order, mdp_layers[i].flags);
- mdp_rect &src_rect = mdp_layers[i].src_rect;
+ const mdp_rect &src_rect = mdp_layers[i].src_rect;
DLOGE("src rect: x = %d, y = %d, w = %d, h = %d",
src_rect.x, src_rect.y, src_rect.w, src_rect.h);
- mdp_rect &dst_rect = mdp_layers[i].dst_rect;
+ const mdp_rect &dst_rect = mdp_layers[i].dst_rect;
DLOGE("dst rect: x = %d, y = %d, w = %d, h = %d",
dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
}
@@ -361,13 +361,14 @@
LayerBuffer *input_buffer = stack->layers[layer_index].input_buffer;
HWPipeInfo *left_pipe = &hw_layers->config[i].left_pipe;
HWPipeInfo *right_pipe = &hw_layers->config[i].right_pipe;
+ HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
for (uint32_t count = 0; count < 2; count++) {
HWPipeInfo *pipe_info = (count == 0) ? left_pipe : right_pipe;
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
+ HWRotateInfo *hw_rotate_info = &hw_rotator_session->hw_rotate_info[count];
- if (rotate_info->valid) {
- input_buffer = &rotate_info->hw_buffer_info.output_buffer;
+ if (hw_rotate_info->valid) {
+ input_buffer = &hw_rotator_session->output_buffer;
}
if (pipe_info->valid) {
@@ -416,11 +417,11 @@
mdp_out_layer_.buffer.fence = output_buffer->acquire_fence_fd;
- DLOGI_IF(kTagDriverConfig, "******************* Output buffer Info **********************");
+ DLOGI_IF(kTagDriverConfig, "********************** Output buffer Info ***********************");
DLOGI_IF(kTagDriverConfig, "out_fd %d, out_offset %d, out_stride %d, acquire_fence %d",
mdp_out_layer_.buffer.planes[0].fd, mdp_out_layer_.buffer.planes[0].offset,
mdp_out_layer_.buffer.planes[0].stride, mdp_out_layer_.buffer.fence);
- DLOGI_IF(kTagDriverConfig, "*************************************************************");
+ DLOGI_IF(kTagDriverConfig, "*****************************************************************");
}
mdp_commit.release_fence = -1;
@@ -442,8 +443,9 @@
for (uint32_t i = 0; i < hw_layer_info.count; i++) {
uint32_t layer_index = hw_layer_info.index[i];
LayerBuffer *input_buffer = stack->layers[layer_index].input_buffer;
- HWRotateInfo *left_rotate = &hw_layers->config[i].rotates[0];
- HWRotateInfo *right_rotate = &hw_layers->config[i].rotates[1];
+ HWRotatorSession *hw_rotator_session = &hw_layers->config[i].hw_rotator_session;
+ HWRotateInfo *left_rotate = &hw_rotator_session->hw_rotate_info[0];
+ HWRotateInfo *right_rotate = &hw_rotator_session->hw_rotate_info[1];
if (!left_rotate->valid && !right_rotate->valid) {
input_buffer->release_fence_fd = dup(mdp_commit.release_fence);
@@ -451,9 +453,9 @@
}
for (uint32_t count = 0; count < 2; count++) {
- HWRotateInfo *rotate_info = &hw_layers->config[i].rotates[count];
- if (rotate_info->valid) {
- input_buffer = &rotate_info->hw_buffer_info.output_buffer;
+ HWRotateInfo *hw_rotate_info = &hw_rotator_session->hw_rotate_info[count];
+ if (hw_rotate_info->valid) {
+ input_buffer = &hw_rotator_session->output_buffer;
input_buffer->release_fence_fd = dup(mdp_commit.release_fence);
close_(input_buffer->acquire_fence_fd);
input_buffer->acquire_fence_fd = -1;
@@ -463,7 +465,7 @@
DLOGI_IF(kTagDriverConfig, "*************************** %s Commit Input ************************",
device_name_);
DLOGI_IF(kTagDriverConfig, "retire_fence_fd %d", stack->retire_fence_fd);
- DLOGI_IF(kTagDriverConfig, "*************************************************************");
+ DLOGI_IF(kTagDriverConfig, "*******************************************************************");
close_(mdp_commit.release_fence);
@@ -515,6 +517,7 @@
case kFormatYCbCr422H2V1Packed: *target = MDP_YCBYCR_H2V1; break;
case kFormatYCbCr420SemiPlanarVenus: *target = MDP_Y_CBCR_H2V2_VENUS; break;
case kFormatRGBA8888Ubwc: *target = MDP_RGBA_8888_UBWC; break;
+ case kFormatRGBX8888Ubwc: *target = MDP_RGBX_8888_UBWC; break;
case kFormatRGB565Ubwc: *target = MDP_RGB_565_UBWC; break;
case kFormatYCbCr420SPVenusUbwc: *target = MDP_Y_CBCR_H2V2_UBWC; break;
default:
@@ -527,7 +530,7 @@
DisplayError HWDevice::SetStride(HWDeviceType device_type, LayerBufferFormat format,
uint32_t width, uint32_t *target) {
- // TODO(user): This SetStride function is an workaround to satisfy the driver expectation for
+ // TODO(user): This SetStride function is a workaround to satisfy the driver expectation for
// rotator and virtual devices. Eventually this will be taken care in the driver.
if (device_type != kDeviceRotator && device_type != kDeviceVirtual) {
*target = width;
@@ -540,6 +543,8 @@
case kFormatBGRA8888:
case kFormatRGBX8888:
case kFormatBGRX8888:
+ case kFormatRGBA8888Ubwc:
+ case kFormatRGBX8888Ubwc:
*target = width * 4;
break;
case kFormatRGB888:
@@ -547,7 +552,8 @@
*target = width * 3;
break;
case kFormatRGB565:
- *target = width * 3;
+ case kFormatRGB565Ubwc:
+ *target = width * 2;
break;
case kFormatYCbCr420SemiPlanarVenus:
case kFormatYCbCr420SPVenusUbwc:
@@ -589,6 +595,35 @@
target->h = UINT32(source.bottom) - target->y;
}
+void HWDevice::SetMDPFlags(const Layer &layer, const bool &is_rotator_used,
+ uint32_t *mdp_flags) {
+ LayerBuffer *input_buffer = layer.input_buffer;
+
+ // Flips will be taken care by rotator, if layer uses rotator for downscale/rotation. So ignore
+ // flip flags for MDP.
+ if (!is_rotator_used) {
+ if (layer.transform.flip_vertical) {
+ *mdp_flags |= MDP_LAYER_FLIP_UD;
+ }
+
+ if (layer.transform.flip_horizontal) {
+ *mdp_flags |= MDP_LAYER_FLIP_LR;
+ }
+ }
+
+ if (input_buffer->flags.interlace) {
+ *mdp_flags |= MDP_LAYER_DEINTERLACE;
+ }
+
+ if (input_buffer->flags.secure) {
+ *mdp_flags |= MDP_LAYER_SECURE_SESSION;
+ }
+
+ if (input_buffer->flags.secure_display) {
+ *mdp_flags |= MDP_SECURE_DISPLAY_OVERLAY_SESSION;
+ }
+}
+
void HWDevice::SyncMerge(const int &fd1, const int &fd2, int *target) {
if (fd1 >= 0 && fd2 >= 0) {
buffer_sync_handler_->SyncMerge(fd1, fd2, target);
@@ -876,5 +911,36 @@
mdp_disp_commit_.commit_v1.retire_fence = -1;
}
-} // namespace sde
+void HWDevice::SetHWScaleData(const ScaleData &scale, uint32_t index) {
+ mdp_scale_data *mdp_scale = GetScaleDataRef(index);
+ mdp_scale->enable_pxl_ext = scale.enable_pixel_ext;
+
+ for (int i = 0; i < 4; i++) {
+ const HWPlane &plane = scale.plane[i];
+ mdp_scale->init_phase_x[i] = plane.init_phase_x;
+ mdp_scale->phase_step_x[i] = plane.phase_step_x;
+ mdp_scale->init_phase_y[i] = plane.init_phase_y;
+ mdp_scale->phase_step_y[i] = plane.phase_step_y;
+
+ mdp_scale->num_ext_pxls_left[i] = plane.left.extension;
+ mdp_scale->left_ftch[i] = plane.left.overfetch;
+ mdp_scale->left_rpt[i] = plane.left.repeat;
+
+ mdp_scale->num_ext_pxls_top[i] = plane.top.extension;
+ mdp_scale->top_ftch[i] = plane.top.overfetch;
+ mdp_scale->top_rpt[i] = plane.top.repeat;
+
+ mdp_scale->num_ext_pxls_right[i] = plane.right.extension;
+ mdp_scale->right_ftch[i] = plane.right.overfetch;
+ mdp_scale->right_rpt[i] = plane.right.repeat;
+
+ mdp_scale->num_ext_pxls_btm[i] = plane.bottom.extension;
+ mdp_scale->btm_ftch[i] = plane.bottom.overfetch;
+ mdp_scale->btm_rpt[i] = plane.bottom.repeat;
+
+ mdp_scale->roi_w[i] = plane.roi_width;
+ }
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/core/fb/hw_device.h b/sdm/libs/core/fb/hw_device.h
similarity index 94%
rename from displayengine/libs/core/fb/hw_device.h
rename to sdm/libs/core/fb/hw_device.h
index c1dc99d..7d617f0 100644
--- a/displayengine/libs/core/fb/hw_device.h
+++ b/sdm/libs/core/fb/hw_device.h
@@ -29,7 +29,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <linux/msm_mdp_ext.h>
-#include <video/msm_hdmi_modes.h>
#include <linux/mdss_rotator.h>
#include <poll.h>
#include <pthread.h>
@@ -40,7 +39,7 @@
#define IOCTL_LOGE(ioctl, type) DLOGE("ioctl %s, device = %d errno = %d, desc = %s", #ioctl, \
type, errno, strerror(errno))
-namespace sde {
+namespace sdm {
class HWDevice {
protected:
@@ -57,6 +56,7 @@
DisplayError PowerOn();
DisplayError PowerOff();
DisplayError Doze();
+ DisplayError DozeSuspend();
DisplayError Standby();
DisplayError Validate(HWLayers *hw_layers);
DisplayError Commit(HWLayers *hw_layers);
@@ -71,12 +71,13 @@
static const int kNumPhysicalDisplays = 2;
static const int kNumDisplayEvents = 4;
- void DumpLayerCommit(mdp_layer_commit &layer_commit);
+ void DumpLayerCommit(const mdp_layer_commit &layer_commit);
DisplayError SetFormat(const LayerBufferFormat &source, uint32_t *target);
DisplayError SetStride(HWDeviceType device_type, LayerBufferFormat format,
uint32_t width, uint32_t *target);
void SetBlending(const LayerBlending &source, mdss_mdp_blend_op *target);
void SetRect(const LayerRect &source, mdp_rect *target);
+ void SetMDPFlags(const Layer &layer, const bool &is_rotator_used, uint32_t *mdp_flags);
void SyncMerge(const int &fd1, const int &fd2, int *target);
// Retrieves HW FrameBuffer Node Index
@@ -89,6 +90,7 @@
void GetSplitInfo(int device_node, HWPanelInfo *panel_info);
int ParseLine(char *input, char *tokens[], const uint32_t max_token, uint32_t *count);
mdp_scale_data* GetScaleDataRef(uint32_t index) { return &scale_data_[index]; }
+ void SetHWScaleData(const ScaleData &scale, uint32_t index);
void ResetDisplayParams();
bool EnableHotPlugDetection(int enable);
@@ -123,7 +125,7 @@
bool synchronous_commit_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_DEVICE_H__
diff --git a/displayengine/libs/core/fb/hw_hdmi.cpp b/sdm/libs/core/fb/hw_hdmi.cpp
similarity index 79%
rename from displayengine/libs/core/fb/hw_hdmi.cpp
rename to sdm/libs/core/fb/hw_hdmi.cpp
index d45a620..1a5c538 100644
--- a/displayengine/libs/core/fb/hw_hdmi.cpp
+++ b/sdm/libs/core/fb/hw_hdmi.cpp
@@ -35,7 +35,7 @@
#define __CLASS__ "HWHDMI"
-namespace sde {
+namespace sdm {
static int ParseLine(char *input, char *tokens[], const uint32_t max_token, uint32_t *count) {
char *tmp_token = NULL;
@@ -105,7 +105,7 @@
}
HWHDMI::HWHDMI(BufferSyncHandler *buffer_sync_handler, HWInfoInterface *hw_info_intf)
- : HWDevice(buffer_sync_handler) {
+ : HWDevice(buffer_sync_handler), hw_scan_info_() {
HWDevice::device_type_ = kDeviceHDMI;
HWDevice::device_name_ = "HDMI Display Device";
HWDevice::hw_info_intf_ = hw_info_intf;
@@ -129,6 +129,7 @@
MSM_HDMI_MODES_INIT_TIMINGS(supported_video_modes_);
MSM_HDMI_MODES_SET_SUPP_TIMINGS(supported_video_modes_, MSM_HDMI_MODES_ALL);
+ ReadScanInfo();
return kErrorNone;
CleanupOnError:
@@ -222,16 +223,18 @@
display_attributes->y_pixels = timing_mode->active_v;
display_attributes->v_total = timing_mode->active_v + timing_mode->front_porch_v +
timing_mode->back_porch_v + timing_mode->pulse_width_v;
- display_attributes->h_total = timing_mode->active_h + timing_mode->front_porch_h +
- timing_mode->back_porch_h + timing_mode->pulse_width_h;
+ uint32_t h_blanking = timing_mode->front_porch_h + timing_mode->back_porch_h +
+ timing_mode->pulse_width_h;
+ display_attributes->h_total = timing_mode->active_h + h_blanking;
display_attributes->x_dpi = 0;
display_attributes->y_dpi = 0;
- display_attributes->fps = FLOAT(timing_mode->refresh_rate) / 1000.0f;
+ display_attributes->fps = timing_mode->refresh_rate / 1000;
display_attributes->vsync_period_ns = UINT32(1000000000L / display_attributes->fps);
display_attributes->split_left = display_attributes->x_pixels;
if (display_attributes->x_pixels > hw_resource_.max_mixer_width) {
display_attributes->is_device_split = true;
display_attributes->split_left = display_attributes->x_pixels / 2;
+ display_attributes->h_total += h_blanking;
}
return kErrorNone;
}
@@ -314,11 +317,16 @@
return HWDevice::Doze();
}
+DisplayError HWHDMI::DozeSuspend() {
+ return HWDevice::DozeSuspend();
+}
+
DisplayError HWHDMI::Standby() {
return HWDevice::Standby();
}
DisplayError HWHDMI::Validate(HWLayers *hw_layers) {
+ HWDevice::ResetDisplayParams();
return HWDevice::Validate(hw_layers);
}
@@ -334,5 +342,80 @@
return HWDevice::GetHWPanelInfo(panel_info);
}
-} // namespace sde
+DisplayError HWHDMI::GetHWScanInfo(HWScanInfo *scan_info) {
+ if (!scan_info) {
+ return kErrorParameters;
+ }
+ *scan_info = hw_scan_info_;
+ return kErrorNone;
+}
+
+DisplayError HWHDMI::GetVideoFormat(uint32_t config_index, uint32_t *video_format) {
+ *video_format = hdmi_modes_[config_index];
+
+ return kErrorNone;
+}
+
+DisplayError HWHDMI::GetMaxCEAFormat(uint32_t *max_cea_format) {
+ *max_cea_format = HDMI_VFRMT_END;
+
+ return kErrorNone;
+}
+
+HWScanSupport HWHDMI::MapHWScanSupport(uint32_t value) {
+ switch (value) {
+ // TODO(user): Read the scan type from driver defined values instead of hardcoding
+ case 0:
+ return kScanNotSupported;
+ case 1:
+ return kScanAlwaysOverscanned;
+ case 2:
+ return kScanAlwaysUnderscanned;
+ case 3:
+ return kScanBoth;
+ default:
+ return kScanNotSupported;
+ break;
+ }
+}
+
+void HWHDMI::ReadScanInfo() {
+ int scan_info_file = -1;
+ ssize_t len = -1;
+ char data[PAGE_SIZE] = {'\0'};
+
+ snprintf(data, sizeof(data), "%s%d/scan_info", fb_path_, fb_node_index_);
+ scan_info_file = open_(data, O_RDONLY);
+ if (scan_info_file < 0) {
+ DLOGW("File '%s' not found.", data);
+ return;
+ }
+
+ memset(&data[0], 0, sizeof(data));
+ len = read(scan_info_file, data, sizeof(data) - 1);
+ if (len <= 0) {
+ close_(scan_info_file);
+ DLOGW("File %s%d/scan_info is empty.", fb_path_, fb_node_index_);
+ return;
+ }
+ data[len] = '\0';
+ close_(scan_info_file);
+
+ const uint32_t scan_info_max_count = 3;
+ uint32_t scan_info_count = 0;
+ char *tokens[scan_info_max_count] = { NULL };
+ ParseLine(data, tokens, scan_info_max_count, &scan_info_count);
+ if (scan_info_count != scan_info_max_count) {
+ DLOGW("Failed to parse scan info string %s", data);
+ return;
+ }
+
+ hw_scan_info_.pt_scan_support = MapHWScanSupport(atoi(tokens[0]));
+ hw_scan_info_.it_scan_support = MapHWScanSupport(atoi(tokens[1]));
+ hw_scan_info_.cea_scan_support = MapHWScanSupport(atoi(tokens[2]));
+ DLOGI("PT %d IT %d CEA %d", hw_scan_info_.pt_scan_support, hw_scan_info_.it_scan_support,
+ hw_scan_info_.cea_scan_support);
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/core/fb/hw_hdmi.h b/sdm/libs/core/fb/hw_hdmi.h
similarity index 86%
rename from displayengine/libs/core/fb/hw_hdmi.h
rename to sdm/libs/core/fb/hw_hdmi.h
index 8fc3c47..8ac491d 100644
--- a/displayengine/libs/core/fb/hw_hdmi.h
+++ b/sdm/libs/core/fb/hw_hdmi.h
@@ -25,10 +25,11 @@
#ifndef __HW_HDMI_H__
#define __HW_HDMI_H__
+#include <video/msm_hdmi_modes.h>
#include "hw_device.h"
#include "hw_hdmi_interface.h"
-namespace sde {
+namespace sdm {
class HWHDMI : public HWDevice, public HWHDMIInterface {
public:
@@ -41,11 +42,15 @@
virtual DisplayError GetDisplayAttributes(HWDisplayAttributes *display_attributes,
uint32_t index);
virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info);
+ virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info);
+ virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format);
+ virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format);
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index);
virtual DisplayError PowerOn();
virtual DisplayError PowerOff();
virtual DisplayError Doze();
+ virtual DisplayError DozeSuspend();
virtual DisplayError Standby();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
@@ -53,14 +58,17 @@
private:
int GetHDMIModeCount();
+ void ReadScanInfo();
+ HWScanSupport MapHWScanSupport(uint32_t value);
uint32_t hdmi_mode_count_;
uint32_t hdmi_modes_[256];
// Holds the hdmi timing information. Ex: resolution, fps etc.,
msm_hdmi_mode_timing_info *supported_video_modes_;
+ HWScanInfo hw_scan_info_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_HDMI_H__
diff --git a/displayengine/libs/core/fb/hw_info.cpp b/sdm/libs/core/fb/hw_info.cpp
similarity index 97%
rename from displayengine/libs/core/fb/hw_info.cpp
rename to sdm/libs/core/fb/hw_info.cpp
index cddb590..b998a46 100644
--- a/displayengine/libs/core/fb/hw_info.cpp
+++ b/sdm/libs/core/fb/hw_info.cpp
@@ -33,7 +33,7 @@
#define __CLASS__ "HWInfo"
-namespace sde {
+namespace sdm {
int HWInfo::ParseLine(char *input, char *tokens[], const uint32_t max_token, uint32_t *count) {
char *tmp_token = NULL;
@@ -123,6 +123,8 @@
hw_resource->max_bandwidth_high = atol(tokens[1]);
} else if (!strncmp(tokens[0], "max_mixer_width", strlen("max_mixer_width"))) {
hw_resource->max_mixer_width = atoi(tokens[1]);
+ } else if (!strncmp(tokens[0], "max_pipe_width", strlen("max_pipe_width"))) {
+ hw_resource->max_pipe_width = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "max_pipe_bw", strlen("max_pipe_bw"))) {
hw_resource->max_pipe_bw = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "max_mdp_clk", strlen("max_mdp_clk"))) {
@@ -167,5 +169,5 @@
return kErrorNone;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/fb/hw_info.h b/sdm/libs/core/fb/hw_info.h
similarity index 96%
rename from displayengine/libs/core/fb/hw_info.h
rename to sdm/libs/core/fb/hw_info.h
index 31667ae..95f669f 100644
--- a/displayengine/libs/core/fb/hw_info.h
+++ b/sdm/libs/core/fb/hw_info.h
@@ -26,11 +26,11 @@
#define __HW_INFO_H__
#include <inttypes.h>
-#include <core/sde_types.h>
+#include <core/sdm_types.h>
#include <private/hw_info_types.h>
#include "hw_info_interface.h"
-namespace sde {
+namespace sdm {
class HWInfo: public HWInfoInterface {
public:
@@ -48,7 +48,7 @@
static int ParseLine(char *input, char *tokens[], const uint32_t max_token, uint32_t *count);
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_INFO_H__
diff --git a/displayengine/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp
similarity index 77%
rename from displayengine/libs/core/fb/hw_primary.cpp
rename to sdm/libs/core/fb/hw_primary.cpp
index 33f28bb..cb4d8b2 100644
--- a/displayengine/libs/core/fb/hw_primary.cpp
+++ b/sdm/libs/core/fb/hw_primary.cpp
@@ -37,7 +37,7 @@
#define __CLASS__ "HWPrimary"
-namespace sde {
+namespace sdm {
DisplayError HWPrimaryInterface::Create(HWPrimaryInterface **intf, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler) {
@@ -64,8 +64,8 @@
}
HWPrimary::HWPrimary(BufferSyncHandler *buffer_sync_handler, HWInfoInterface *hw_info_intf)
- : HWDevice(buffer_sync_handler), event_thread_name_("SDE_EventThread"), fake_vsync_(false),
- exit_threads_(false) {
+ : HWDevice(buffer_sync_handler), event_thread_name_("SDM_EventThread"), fake_vsync_(false),
+ exit_threads_(false), config_changed_(true) {
HWDevice::device_type_ = kDevicePrimary;
HWDevice::device_name_ = "Primary Display Device";
HWDevice::hw_info_intf_ = hw_info_intf;
@@ -163,6 +163,21 @@
DisplayError HWPrimary::GetDisplayAttributes(HWDisplayAttributes *display_attributes,
uint32_t index) {
+ if (!display_attributes) {
+ return kErrorParameters;
+ }
+
+ if (config_changed_) {
+ PopulateDisplayAttributes();
+ config_changed_ = false;
+ }
+
+ *display_attributes = display_attributes_;
+
+ return kErrorNone;
+}
+
+DisplayError HWPrimary::PopulateDisplayAttributes() {
DTRACE_SCOPED();
// Variable screen info
@@ -187,23 +202,26 @@
var_screeninfo.height = INT(((FLOAT(var_screeninfo.yres) * 25.4f)/160.0f) + 0.5f);
}
- display_attributes->x_pixels = var_screeninfo.xres;
- display_attributes->y_pixels = var_screeninfo.yres;
- display_attributes->v_total = var_screeninfo.yres + var_screeninfo.lower_margin +
+ display_attributes_.x_pixels = var_screeninfo.xres;
+ display_attributes_.y_pixels = var_screeninfo.yres;
+ display_attributes_.v_total = var_screeninfo.yres + var_screeninfo.lower_margin +
var_screeninfo.upper_margin + var_screeninfo.vsync_len;
- display_attributes->h_total = var_screeninfo.xres + var_screeninfo.right_margin +
+ uint32_t h_blanking = var_screeninfo.right_margin + var_screeninfo.left_margin +
+ var_screeninfo.hsync_len;
+ display_attributes_.h_total = var_screeninfo.xres + var_screeninfo.right_margin +
var_screeninfo.left_margin + var_screeninfo.hsync_len;
- display_attributes->x_dpi =
+ display_attributes_.x_dpi =
(FLOAT(var_screeninfo.xres) * 25.4f) / FLOAT(var_screeninfo.width);
- display_attributes->y_dpi =
+ display_attributes_.y_dpi =
(FLOAT(var_screeninfo.yres) * 25.4f) / FLOAT(var_screeninfo.height);
- display_attributes->fps = FLOAT(meta_data.data.panel_frame_rate);
- display_attributes->vsync_period_ns = UINT32(1000000000L / display_attributes->fps);
- display_attributes->is_device_split = (hw_panel_info_.split_info.left_split ||
+ display_attributes_.fps = meta_data.data.panel_frame_rate;
+ display_attributes_.vsync_period_ns = UINT32(1000000000L / display_attributes_.fps);
+ display_attributes_.is_device_split = (hw_panel_info_.split_info.left_split ||
(var_screeninfo.xres > hw_resource_.max_mixer_width)) ? true : false;
- display_attributes->split_left = hw_panel_info_.split_info.left_split ?
- hw_panel_info_.split_info.left_split : display_attributes->x_pixels / 2;
- display_attributes->always_src_split = hw_panel_info_.split_info.always_src_split;
+ display_attributes_.split_left = hw_panel_info_.split_info.left_split ?
+ hw_panel_info_.split_info.left_split : display_attributes_.x_pixels / 2;
+ display_attributes_.always_src_split = hw_panel_info_.split_info.always_src_split;
+ display_attributes_.h_total += display_attributes_.is_device_split ? h_blanking : 0;
return kErrorNone;
}
@@ -212,6 +230,35 @@
return HWDevice::SetDisplayAttributes(index);
}
+DisplayError HWPrimary::SetRefreshRate(uint32_t refresh_rate) {
+ char node_path[kMaxStringLength] = {0};
+
+ DLOGI("Setting refresh rate to = %d fps", refresh_rate);
+
+ snprintf(node_path, sizeof(node_path), "%s%d/dynamic_fps", fb_path_, fb_node_index_);
+
+ int fd = open_(node_path, O_WRONLY);
+ if (fd < 0) {
+ DLOGE("Failed to open %s with error %s", node_path, strerror(errno));
+ return kErrorFileDescriptor;
+ }
+
+ char refresh_rate_string[kMaxStringLength];
+ snprintf(refresh_rate_string, sizeof(refresh_rate_string), "%d", refresh_rate);
+ ssize_t len = pwrite_(fd, refresh_rate_string, strlen(refresh_rate_string), 0);
+ if (len < 0) {
+ DLOGE("Failed to write %d with error %s", refresh_rate, strerror(errno));
+ close_(fd);
+ return kErrorUndefined;
+ }
+ close_(fd);
+
+ config_changed_ = true;
+ synchronous_commit_ = true;
+
+ return kErrorNone;
+}
+
DisplayError HWPrimary::GetConfigIndex(uint32_t mode, uint32_t *index) {
return HWDevice::GetConfigIndex(mode, index);
}
@@ -225,11 +272,26 @@
IOCTL_LOGE(FB_BLANK_POWERDOWN, device_type_);
return kErrorHardware;
}
+
return kErrorNone;
}
DisplayError HWPrimary::Doze() {
- return HWDevice::Doze();
+ if (ioctl_(device_fd_, FBIOBLANK, FB_BLANK_NORMAL) < 0) {
+ IOCTL_LOGE(FB_BLANK_NORMAL, device_type_);
+ return kErrorHardware;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError HWPrimary::DozeSuspend() {
+ if (ioctl_(device_fd_, FBIOBLANK, FB_BLANK_VSYNC_SUSPEND) < 0) {
+ IOCTL_LOGE(FB_BLANK_VSYNC_SUSPEND, device_type_);
+ return kErrorHardware;
+ }
+
+ return kErrorNone;
}
DisplayError HWPrimary::Standby() {
@@ -237,6 +299,27 @@
}
DisplayError HWPrimary::Validate(HWLayers *hw_layers) {
+ HWDevice::ResetDisplayParams();
+
+ mdp_layer_commit_v1 &mdp_commit = mdp_disp_commit_.commit_v1;
+
+ LayerRect left_roi = hw_layers->info.left_partial_update;
+ LayerRect right_roi = hw_layers->info.right_partial_update;
+ mdp_commit.left_roi.x = INT(left_roi.left);
+ mdp_commit.left_roi.y = INT(left_roi.top);
+ mdp_commit.left_roi.w = INT(left_roi.right - left_roi.left);
+ mdp_commit.left_roi.h = INT(left_roi.bottom - left_roi.top);
+
+ // SDM treats ROI as one full coordinate system.
+ // In case source split is disabled, However, Driver assumes Mixer to operate in
+ // different co-ordinate system.
+ if (!hw_resource_.is_src_split) {
+ mdp_commit.right_roi.x = INT(right_roi.left) - hw_panel_info_.split_info.left_split;
+ mdp_commit.right_roi.y = INT(right_roi.top);
+ mdp_commit.right_roi.w = INT(right_roi.right - right_roi.left);
+ mdp_commit.right_roi.h = INT(right_roi.bottom - right_roi.top);
+ }
+
return HWDevice::Validate(hw_layers);
}
@@ -340,7 +423,7 @@
thermal_level = strtoull(data + strlen("thermal_level="), NULL, 0);
}
- DLOGI("Received thermal notification with thermal level = %d",thermal_level);
+ DLOGI("Received thermal notification with thermal level = %d", thermal_level);
event_handler_->ThermalEvent(thermal_level);
}
@@ -411,5 +494,5 @@
return kErrorNone;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/fb/hw_primary.h b/sdm/libs/core/fb/hw_primary.h
similarity index 92%
rename from displayengine/libs/core/fb/hw_primary.h
rename to sdm/libs/core/fb/hw_primary.h
index 8d61d74..f7ccef2 100644
--- a/displayengine/libs/core/fb/hw_primary.h
+++ b/sdm/libs/core/fb/hw_primary.h
@@ -28,7 +28,7 @@
#include "hw_device.h"
#include "hw_primary_interface.h"
-namespace sde {
+namespace sdm {
class HWPrimary : public HWDevice, public HWPrimaryInterface {
public:
@@ -46,6 +46,7 @@
virtual DisplayError PowerOn();
virtual DisplayError PowerOff();
virtual DisplayError Doze();
+ virtual DisplayError DozeSuspend();
virtual DisplayError Standby();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
@@ -53,6 +54,7 @@
virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual DisplayError SetVSyncState(bool enable);
virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
private:
// Panel modes for the MSMFB_LPM_ENABLE ioctl
@@ -69,15 +71,18 @@
void HandleBlank(char *data);
void HandleIdleTimeout(char *data);
void HandleThermal(char *data);
+ DisplayError PopulateDisplayAttributes();
pollfd poll_fds_[kNumDisplayEvents];
pthread_t event_thread_;
const char *event_thread_name_;
bool fake_vsync_;
bool exit_threads_;
+ HWDisplayAttributes display_attributes_;
+ bool config_changed_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_PRIMARY_H__
diff --git a/displayengine/libs/core/fb/hw_virtual.cpp b/sdm/libs/core/fb/hw_virtual.cpp
similarity index 96%
rename from displayengine/libs/core/fb/hw_virtual.cpp
rename to sdm/libs/core/fb/hw_virtual.cpp
index 81b31d0..79c9537 100644
--- a/displayengine/libs/core/fb/hw_virtual.cpp
+++ b/sdm/libs/core/fb/hw_virtual.cpp
@@ -32,7 +32,7 @@
#define __CLASS__ "HWVirtual"
-namespace sde {
+namespace sdm {
DisplayError HWVirtualInterface::Create(HWVirtualInterface **intf, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler) {
@@ -110,11 +110,16 @@
return HWDevice::Doze();
}
+DisplayError HWVirtual::DozeSuspend() {
+ return HWDevice::DozeSuspend();
+}
+
DisplayError HWVirtual::Standby() {
return HWDevice::Standby();
}
DisplayError HWVirtual::Validate(HWLayers *hw_layers) {
+ HWDevice::ResetDisplayParams();
return HWDevice::Validate(hw_layers);
}
@@ -130,5 +135,5 @@
return HWDevice::GetHWPanelInfo(panel_info);
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/core/fb/hw_virtual.h b/sdm/libs/core/fb/hw_virtual.h
similarity index 96%
rename from displayengine/libs/core/fb/hw_virtual.h
rename to sdm/libs/core/fb/hw_virtual.h
index fb7c784..507de88 100644
--- a/displayengine/libs/core/fb/hw_virtual.h
+++ b/sdm/libs/core/fb/hw_virtual.h
@@ -28,7 +28,7 @@
#include "hw_device.h"
#include "hw_virtual_interface.h"
-namespace sde {
+namespace sdm {
class HWVirtual : public HWDevice, public HWVirtualInterface {
public:
@@ -46,13 +46,14 @@
virtual DisplayError PowerOn();
virtual DisplayError PowerOff();
virtual DisplayError Doze();
+ virtual DisplayError DozeSuspend();
virtual DisplayError Standby();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
virtual DisplayError Flush();
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_VIRTUAL_H__
diff --git a/displayengine/libs/core/hw_hdmi_interface.h b/sdm/libs/core/hw_hdmi_interface.h
similarity index 88%
rename from displayengine/libs/core/hw_hdmi_interface.h
rename to sdm/libs/core/hw_hdmi_interface.h
index 36ca991..0d3d800 100644
--- a/displayengine/libs/core/hw_hdmi_interface.h
+++ b/sdm/libs/core/hw_hdmi_interface.h
@@ -27,7 +27,7 @@
#include "hw_interface.h"
-namespace sde {
+namespace sdm {
class HWInfoInterface;
@@ -36,12 +36,15 @@
static DisplayError Create(HWHDMIInterface **intf, HWInfoInterface *hw_info_intf,
BufferSyncHandler *buffer_sync_handler);
static DisplayError Destroy(HWHDMIInterface *intf);
+ virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info) = 0;
+ virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format) = 0;
+ virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format) = 0;
protected:
virtual ~HWHDMIInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_HDMI_INTERFACE_H__
diff --git a/displayengine/libs/core/hw_info_interface.h b/sdm/libs/core/hw_info_interface.h
similarity index 97%
rename from displayengine/libs/core/hw_info_interface.h
rename to sdm/libs/core/hw_info_interface.h
index 035db40..014ab0d 100644
--- a/displayengine/libs/core/hw_info_interface.h
+++ b/sdm/libs/core/hw_info_interface.h
@@ -28,7 +28,7 @@
#include <inttypes.h>
#include <private/hw_info_types.h>
-namespace sde {
+namespace sdm {
class HWInfoInterface {
public:
@@ -40,7 +40,7 @@
virtual ~HWInfoInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_INFO_INTERFACE_H__
diff --git a/sdm/libs/core/hw_interface.h b/sdm/libs/core/hw_interface.h
new file mode 100644
index 0000000..317e087
--- /dev/null
+++ b/sdm/libs/core/hw_interface.h
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2014 - 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __HW_INTERFACE_H__
+#define __HW_INTERFACE_H__
+
+#include <core/display_interface.h>
+#include <private/strategy_interface.h>
+#include <private/hw_info_types.h>
+#include <utils/constants.h>
+#include <core/buffer_allocator.h>
+#include <core/buffer_sync_handler.h>
+
+namespace sdm {
+
+enum HWScanSupport {
+ kScanNotSupported,
+ kScanAlwaysOverscanned,
+ kScanAlwaysUnderscanned,
+ kScanBoth,
+};
+
+struct HWScanInfo {
+ HWScanSupport pt_scan_support; // Scan support for preferred timing
+ HWScanSupport it_scan_support; // Scan support for digital monitor or industry timings
+ HWScanSupport cea_scan_support; // Scan support for CEA resolution timings
+
+ HWScanInfo() : pt_scan_support(kScanNotSupported), it_scan_support(kScanNotSupported),
+ cea_scan_support(kScanNotSupported) { }
+};
+
+// HWEventHandler - Implemented in DisplayBase and HWInterface implementation
+class HWEventHandler {
+ public:
+ virtual DisplayError VSync(int64_t timestamp) = 0;
+ virtual DisplayError Blank(bool blank) = 0;
+ virtual void IdleTimeout() = 0;
+ virtual void ThermalEvent(int64_t thermal_level) = 0;
+ protected:
+ virtual ~HWEventHandler() { }
+};
+
+class HWInterface {
+ public:
+ virtual DisplayError Open(HWEventHandler *eventhandler) = 0;
+ virtual DisplayError Close() = 0;
+ virtual DisplayError GetNumDisplayAttributes(uint32_t *count) = 0;
+ virtual DisplayError GetDisplayAttributes(HWDisplayAttributes *display_attributes,
+ uint32_t index) = 0;
+ virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info) = 0;
+ virtual DisplayError SetDisplayAttributes(uint32_t index) = 0;
+ virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index) = 0;
+ virtual DisplayError PowerOn() = 0;
+ virtual DisplayError PowerOff() = 0;
+ virtual DisplayError Doze() = 0;
+ virtual DisplayError DozeSuspend() = 0;
+ virtual DisplayError Standby() = 0;
+ virtual DisplayError Validate(HWLayers *hw_layers) = 0;
+ virtual DisplayError Commit(HWLayers *hw_layers) = 0;
+ virtual DisplayError Flush() = 0;
+
+ protected:
+ virtual ~HWInterface() { }
+};
+
+} // namespace sdm
+
+#endif // __HW_INTERFACE_H__
+
diff --git a/displayengine/libs/core/hw_primary_interface.h b/sdm/libs/core/hw_primary_interface.h
similarity index 95%
rename from displayengine/libs/core/hw_primary_interface.h
rename to sdm/libs/core/hw_primary_interface.h
index d195348..9faa6e5 100644
--- a/displayengine/libs/core/hw_primary_interface.h
+++ b/sdm/libs/core/hw_primary_interface.h
@@ -25,7 +25,7 @@
#ifndef __HW_PRIMARY_INTERFACE_H__
#define __HW_PRIMARY_INTERFACE_H__
-namespace sde {
+namespace sdm {
class BufferSyncHandler;
class HWInfoInterface;
@@ -38,12 +38,13 @@
virtual DisplayError SetVSyncState(bool enable) = 0;
virtual void SetIdleTimeoutMs(uint32_t timeout_ms) = 0;
virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode) = 0;
+ virtual DisplayError SetRefreshRate(uint32_t refresh_rate) = 0;
protected:
virtual ~HWPrimaryInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_PRIMARY_INTERFACE_H__
diff --git a/displayengine/libs/core/hw_virtual_interface.h b/sdm/libs/core/hw_virtual_interface.h
similarity index 97%
rename from displayengine/libs/core/hw_virtual_interface.h
rename to sdm/libs/core/hw_virtual_interface.h
index 6976955..ba14ae6 100644
--- a/displayengine/libs/core/hw_virtual_interface.h
+++ b/sdm/libs/core/hw_virtual_interface.h
@@ -27,7 +27,7 @@
#include "hw_interface.h"
-namespace sde {
+namespace sdm {
class HWInfoInterface;
@@ -41,7 +41,7 @@
virtual ~HWVirtualInterface() { }
};
-} // namespace sde
+} // namespace sdm
#endif // __HW_VIRTUAL_INTERFACE_H__
diff --git a/sdm/libs/core/resource_default.cpp b/sdm/libs/core/resource_default.cpp
new file mode 100644
index 0000000..783b621
--- /dev/null
+++ b/sdm/libs/core/resource_default.cpp
@@ -0,0 +1,912 @@
+/*
+* Copyright (c) 2014 - 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <math.h>
+#include <utils/constants.h>
+#include <utils/debug.h>
+#include <utils/rect.h>
+#include <dlfcn.h>
+
+#include "resource_default.h"
+
+#define __CLASS__ "ResourceDefault"
+
+namespace sdm {
+
+ResourceDefault::ResourceDefault()
+ : num_pipe_(0), vig_pipes_(NULL), rgb_pipes_(NULL), dma_pipes_(NULL) {
+}
+
+DisplayError ResourceDefault::Init(const HWResourceInfo &hw_res_info) {
+ DisplayError error = kErrorNone;
+ uint32_t num_pipe = 0;
+
+ num_pipe = hw_res_info.num_vig_pipe + hw_res_info.num_rgb_pipe + hw_res_info.num_dma_pipe;
+
+ if (num_pipe > kPipeIdMax) {
+ DLOGE("Number of pipe is over the limit! %d", num_pipe);
+ return kErrorParameters;
+ }
+
+ num_pipe_ = num_pipe;
+ hw_res_info_ = hw_res_info;
+ // Init pipe info
+ vig_pipes_ = &src_pipes_[0];
+ rgb_pipes_ = &src_pipes_[hw_res_info_.num_vig_pipe];
+ dma_pipes_ = &src_pipes_[hw_res_info_.num_vig_pipe + hw_res_info_.num_rgb_pipe];
+
+ for (uint32_t i = 0; i < hw_res_info_.num_vig_pipe; i++) {
+ vig_pipes_[i].type = kPipeTypeVIG;
+ vig_pipes_[i].index = i;
+ vig_pipes_[i].mdss_pipe_id = GetMdssPipeId(vig_pipes_[i].type, i);
+ }
+
+ for (uint32_t i = 0; i < hw_res_info_.num_rgb_pipe; i++) {
+ rgb_pipes_[i].type = kPipeTypeRGB;
+ rgb_pipes_[i].index = i + hw_res_info_.num_vig_pipe;
+ rgb_pipes_[i].mdss_pipe_id = GetMdssPipeId(rgb_pipes_[i].type, i);
+ }
+
+ for (uint32_t i = 0; i < hw_res_info_.num_dma_pipe; i++) {
+ dma_pipes_[i].type = kPipeTypeDMA;
+ dma_pipes_[i].index = i + hw_res_info_.num_vig_pipe + hw_res_info_.num_rgb_pipe;
+ dma_pipes_[i].mdss_pipe_id = GetMdssPipeId(dma_pipes_[i].type, i);
+ }
+
+ for (uint32_t i = 0; i < num_pipe_; i++) {
+ src_pipes_[i].priority = i;
+ }
+
+ DLOGI("hw_rev=%x, DMA=%d RGB=%d VIG=%d", hw_res_info_.hw_revision, hw_res_info_.num_dma_pipe,
+ hw_res_info_.num_rgb_pipe, hw_res_info_.num_vig_pipe);
+
+ if (hw_res_info_.max_scale_down < 1 || hw_res_info_.max_scale_up < 1) {
+ DLOGE("Max scaling setting is invalid! max_scale_down = %d, max_scale_up = %d",
+ hw_res_info_.max_scale_down, hw_res_info_.max_scale_up);
+ hw_res_info_.max_scale_down = 1;
+ hw_res_info_.max_scale_up = 1;
+ }
+
+ rgb_pipes_[0].owner = kPipeOwnerKernelMode;
+ rgb_pipes_[1].owner = kPipeOwnerKernelMode;
+
+ return error;
+}
+
+DisplayError ResourceDefault::Deinit() {
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::RegisterDisplay(DisplayType type,
+ const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info,
+ Handle *display_ctx) {
+ DisplayError error = kErrorNone;
+
+ HWBlockType hw_block_id = kHWBlockMax;
+ switch (type) {
+ case kPrimary:
+ if (!hw_block_ctx_[kHWPrimary].is_in_use) {
+ hw_block_id = kHWPrimary;
+ }
+ break;
+
+ case kHDMI:
+ if (!hw_block_ctx_[kHWHDMI].is_in_use) {
+ hw_block_id = kHWHDMI;
+ }
+ break;
+
+ default:
+ DLOGW("RegisterDisplay, invalid type %d", type);
+ return kErrorParameters;
+ }
+
+ if (hw_block_id == kHWBlockMax) {
+ return kErrorResources;
+ }
+
+ DisplayResourceContext *display_resource_ctx = new DisplayResourceContext();
+ if (!display_resource_ctx) {
+ return kErrorMemory;
+ }
+
+ hw_block_ctx_[hw_block_id].is_in_use = true;
+
+ display_resource_ctx->display_attributes = attributes;
+ display_resource_ctx->hw_block_id = hw_block_id;
+
+ if (!display_resource_ctx->display_attributes.is_device_split) {
+ display_resource_ctx->display_attributes.split_left = attributes.x_pixels;
+ }
+
+ *display_ctx = display_resource_ctx;
+ return error;
+}
+
+DisplayError ResourceDefault::UnregisterDisplay(Handle display_ctx) {
+ DisplayResourceContext *display_resource_ctx =
+ reinterpret_cast<DisplayResourceContext *>(display_ctx);
+ Purge(display_ctx);
+
+ hw_block_ctx_[display_resource_ctx->hw_block_id].is_in_use = false;
+
+ delete display_resource_ctx;
+
+ return kErrorNone;
+}
+
+void ResourceDefault::ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info) {
+ SCOPE_LOCK(locker_);
+
+ DisplayResourceContext *display_resource_ctx =
+ reinterpret_cast<DisplayResourceContext *>(display_ctx);
+
+ display_resource_ctx->display_attributes = attributes;
+}
+
+DisplayError ResourceDefault::Start(Handle display_ctx) {
+ locker_.Lock();
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::Stop(Handle display_ctx) {
+ locker_.Unlock();
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::Acquire(Handle display_ctx, HWLayers *hw_layers) {
+ DisplayResourceContext *display_resource_ctx =
+ reinterpret_cast<DisplayResourceContext *>(display_ctx);
+
+ DisplayError error = kErrorNone;
+ const struct HWLayersInfo &layer_info = hw_layers->info;
+ HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
+
+ DLOGV_IF(kTagResources, "==== Resource reserving start: hw_block = %d ====", hw_block_id);
+
+ if (layer_info.count > 1) {
+ DLOGV_IF(kTagResources, "More than one FB layers");
+ return kErrorResources;
+ }
+
+ Layer &layer = layer_info.stack->layers[layer_info.index[0]];
+
+ if (layer.composition != kCompositionGPUTarget) {
+ DLOGV_IF(kTagResources, "Not an FB layer");
+ return kErrorParameters;
+ }
+
+ error = Config(display_resource_ctx, hw_layers);
+ if (error != kErrorNone) {
+ DLOGV_IF(kTagResources, "Resource config failed");
+ return error;
+ }
+
+ for (uint32_t i = 0; i < num_pipe_; i++) {
+ if (src_pipes_[i].hw_block_id == hw_block_id && src_pipes_[i].owner == kPipeOwnerUserMode) {
+ src_pipes_[i].ResetState();
+ }
+ }
+
+ uint32_t left_index = kPipeIdMax;
+ uint32_t right_index = kPipeIdMax;
+ bool need_scale = false;
+
+ struct HWLayerConfig &layer_config = hw_layers->config[0];
+
+ HWPipeInfo *left_pipe = &layer_config.left_pipe;
+ HWPipeInfo *right_pipe = &layer_config.right_pipe;
+
+ // left pipe is needed
+ if (left_pipe->valid) {
+ need_scale = IsScalingNeeded(left_pipe);
+ left_index = GetPipe(hw_block_id, need_scale);
+ if (left_index >= num_pipe_) {
+ DLOGV_IF(kTagResources, "Get left pipe failed: hw_block_id = %d, need_scale = %d",
+ hw_block_id, need_scale);
+ ResourceStateLog();
+ goto CleanupOnError;
+ }
+ }
+
+ error = SetDecimationFactor(left_pipe);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+
+ if (!right_pipe->valid) {
+ // assign single pipe
+ if (left_index < num_pipe_) {
+ left_pipe->pipe_id = src_pipes_[left_index].mdss_pipe_id;
+ }
+ DLOGV_IF(kTagResources, "1 pipe acquired for FB layer, left_pipe = %x", left_pipe->pipe_id);
+ return kErrorNone;
+ }
+
+ need_scale = IsScalingNeeded(right_pipe);
+
+ right_index = GetPipe(hw_block_id, need_scale);
+ if (right_index >= num_pipe_) {
+ DLOGV_IF(kTagResources, "Get right pipe failed: hw_block_id = %d, need_scale = %d", hw_block_id,
+ need_scale);
+ ResourceStateLog();
+ goto CleanupOnError;
+ }
+
+ if (src_pipes_[right_index].priority < src_pipes_[left_index].priority) {
+ // Swap pipe based on priority
+ Swap(left_index, right_index);
+ }
+
+ // assign dual pipes
+ left_pipe->pipe_id = src_pipes_[left_index].mdss_pipe_id;
+ right_pipe->pipe_id = src_pipes_[right_index].mdss_pipe_id;
+
+ error = SetDecimationFactor(right_pipe);
+ if (error != kErrorNone) {
+ goto CleanupOnError;
+ }
+
+ DLOGV_IF(kTagResources, "2 pipes acquired for FB layer, left_pipe = %x, right_pipe = %x",
+ left_pipe->pipe_id, right_pipe->pipe_id);
+
+ return kErrorNone;
+
+CleanupOnError:
+ DLOGV_IF(kTagResources, "Resource reserving failed! hw_block = %d", hw_block_id);
+
+ return kErrorResources;
+}
+
+DisplayError ResourceDefault::PostPrepare(Handle display_ctx, HWLayers *hw_layers) {
+ SCOPE_LOCK(locker_);
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::PostCommit(Handle display_ctx, HWLayers *hw_layers) {
+ SCOPE_LOCK(locker_);
+ DisplayResourceContext *display_resource_ctx =
+ reinterpret_cast<DisplayResourceContext *>(display_ctx);
+ HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
+ uint64_t frame_count = display_resource_ctx->frame_count;
+ DisplayError error = kErrorNone;
+
+ DLOGV_IF(kTagResources, "Resource for hw_block = %d, frame_count = %d", hw_block_id, frame_count);
+
+ // handoff pipes which are used by splash screen
+ if ((frame_count == 0) && (hw_block_id == kHWPrimary)) {
+ for (uint32_t i = 0; i < num_pipe_; i++) {
+ if (src_pipes_[i].hw_block_id == hw_block_id && src_pipes_[i].owner == kPipeOwnerKernelMode) {
+ src_pipes_[i].owner = kPipeOwnerUserMode;
+ }
+ }
+ }
+
+ display_resource_ctx->frame_count++;
+
+ return kErrorNone;
+}
+
+void ResourceDefault::Purge(Handle display_ctx) {
+ SCOPE_LOCK(locker_);
+
+ DisplayResourceContext *display_resource_ctx =
+ reinterpret_cast<DisplayResourceContext *>(display_ctx);
+ HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
+
+ for (uint32_t i = 0; i < num_pipe_; i++) {
+ if (src_pipes_[i].hw_block_id == hw_block_id && src_pipes_[i].owner == kPipeOwnerUserMode) {
+ src_pipes_[i].ResetState();
+ }
+ }
+ DLOGV_IF(kTagResources, "display id = %d", display_resource_ctx->hw_block_id);
+}
+
+DisplayError ResourceDefault::SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages) {
+ SCOPE_LOCK(locker_);
+
+ return kErrorNone;
+}
+
+uint32_t ResourceDefault::GetMdssPipeId(PipeType type, uint32_t index) {
+ uint32_t mdss_id = kPipeIdMax;
+ switch (type) {
+ case kPipeTypeVIG:
+ if (index < 3) {
+ mdss_id = kPipeIdVIG0 + index;
+ } else if (index == 3) {
+ mdss_id = kPipeIdVIG3;
+ } else {
+ DLOGE("vig pipe index is over the limit! %d", index);
+ }
+ break;
+ case kPipeTypeRGB:
+ if (index < 3) {
+ mdss_id = kPipeIdRGB0 + index;
+ } else if (index == 3) {
+ mdss_id = kPipeIdRGB3;
+ } else {
+ DLOGE("rgb pipe index is over the limit! %d", index);
+ }
+ break;
+ case kPipeTypeDMA:
+ if (index < 2) {
+ mdss_id = kPipeIdDMA0 + index;
+ } else {
+ DLOGE("dma pipe index is over the limit! %d", index);
+ }
+ break;
+ default:
+ DLOGE("wrong pipe type! %d", type);
+ break;
+ }
+
+ return (1 << mdss_id);
+}
+
+uint32_t ResourceDefault::SearchPipe(HWBlockType hw_block_id, SourcePipe *src_pipes,
+ uint32_t num_pipe) {
+ uint32_t index = kPipeIdMax;
+ SourcePipe *src_pipe;
+
+ // search the pipe being used
+ for (uint32_t i = 0; i < num_pipe; i++) {
+ src_pipe = &src_pipes[i];
+ if (src_pipe->owner == kPipeOwnerUserMode && src_pipe->hw_block_id == kHWBlockMax) {
+ index = src_pipe->index;
+ src_pipe->hw_block_id = hw_block_id;
+ break;
+ }
+ }
+
+ return index;
+}
+
+uint32_t ResourceDefault::NextPipe(PipeType type, HWBlockType hw_block_id) {
+ uint32_t num_pipe = 0;
+ SourcePipe *src_pipes = NULL;
+
+ switch (type) {
+ case kPipeTypeVIG:
+ src_pipes = vig_pipes_;
+ num_pipe = hw_res_info_.num_vig_pipe;
+ break;
+ case kPipeTypeRGB:
+ src_pipes = rgb_pipes_;
+ num_pipe = hw_res_info_.num_rgb_pipe;
+ break;
+ case kPipeTypeDMA:
+ default:
+ src_pipes = dma_pipes_;
+ num_pipe = hw_res_info_.num_dma_pipe;
+ break;
+ }
+
+ return SearchPipe(hw_block_id, src_pipes, num_pipe);
+}
+
+uint32_t ResourceDefault::GetPipe(HWBlockType hw_block_id, bool need_scale) {
+ uint32_t index = kPipeIdMax;
+
+ // The default behavior is to assume RGB and VG pipes have scalars
+ if (!need_scale) {
+ index = NextPipe(kPipeTypeDMA, hw_block_id);
+ }
+
+ if ((index >= num_pipe_) && (!need_scale || !hw_res_info_.has_non_scalar_rgb)) {
+ index = NextPipe(kPipeTypeRGB, hw_block_id);
+ }
+
+ if (index >= num_pipe_) {
+ index = NextPipe(kPipeTypeVIG, hw_block_id);
+ }
+
+ return index;
+}
+
+bool ResourceDefault::IsScalingNeeded(const HWPipeInfo *pipe_info) {
+ const LayerRect &src_roi = pipe_info->src_roi;
+ const LayerRect &dst_roi = pipe_info->dst_roi;
+
+ return ((dst_roi.right - dst_roi.left) != (src_roi.right - src_roi.left)) ||
+ ((dst_roi.bottom - dst_roi.top) != (src_roi.bottom - src_roi.top));
+}
+
+void ResourceDefault::ResourceStateLog() {
+ DLOGV_IF(kTagResources, "==== resource manager pipe state ====");
+ uint32_t i;
+ for (i = 0; i < num_pipe_; i++) {
+ SourcePipe *src_pipe = &src_pipes_[i];
+ DLOGV_IF(kTagResources, "index = %d, id = %x, hw_block = %d, owner = %s",
+ src_pipe->index, src_pipe->mdss_pipe_id, src_pipe->hw_block_id,
+ (src_pipe->owner == kPipeOwnerUserMode) ? "user mode" : "kernel mode");
+ }
+}
+
+DisplayError ResourceDefault::SrcSplitConfig(DisplayResourceContext *display_resource_ctx,
+ const LayerRect &src_rect, const LayerRect &dst_rect,
+ HWLayerConfig *layer_config) {
+ HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
+ HWPipeInfo *left_pipe = &layer_config->left_pipe;
+ HWPipeInfo *right_pipe = &layer_config->right_pipe;
+ float src_width = src_rect.right - src_rect.left;
+ float dst_width = dst_rect.right - dst_rect.left;
+ float src_height = src_rect.bottom - src_rect.top;
+ float dst_height = dst_rect.bottom - dst_rect.top;
+ float left_mixer_width = FLOAT(display_attributes.split_left);
+
+ // Layer cannot qualify for SrcSplit if source or destination width exceeds max pipe width.
+ // For perf/power optimization, even if "always_src_split" is enabled, use 2 pipes only if:
+ // Source width is greater than split_left (left_mixer_width)
+ if ((src_width > hw_res_info_.max_pipe_width) || (dst_width > hw_res_info_.max_pipe_width) ||
+ (display_resource_ctx->display_attributes.always_src_split && src_width > left_mixer_width)) {
+ SplitRect(src_rect, dst_rect, &left_pipe->src_roi, &left_pipe->dst_roi, &right_pipe->src_roi,
+ &right_pipe->dst_roi);
+ left_pipe->valid = true;
+ right_pipe->valid = true;
+ } else {
+ left_pipe->src_roi = src_rect;
+ left_pipe->dst_roi = dst_rect;
+ left_pipe->valid = true;
+ right_pipe->Reset();
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::DisplaySplitConfig(DisplayResourceContext *display_resource_ctx,
+ const LayerRect &src_rect, const LayerRect &dst_rect,
+ HWLayerConfig *layer_config) {
+ HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
+
+ // for display split case
+ HWPipeInfo *left_pipe = &layer_config->left_pipe;
+ HWPipeInfo *right_pipe = &layer_config->right_pipe;
+ LayerRect scissor_left, scissor_right, dst_left, crop_left, crop_right, dst_right;
+
+ scissor_left.right = FLOAT(display_attributes.split_left);
+ scissor_left.bottom = FLOAT(display_attributes.y_pixels);
+
+ scissor_right.left = FLOAT(display_attributes.split_left);
+ scissor_right.top = 0.0f;
+ scissor_right.right = FLOAT(display_attributes.x_pixels);
+ scissor_right.bottom = FLOAT(display_attributes.y_pixels);
+
+ crop_left = src_rect;
+ dst_left = dst_rect;
+ crop_right = crop_left;
+ dst_right = dst_left;
+
+ bool crop_left_valid = CalculateCropRects(scissor_left, &crop_left, &dst_left);
+ bool crop_right_valid = false;
+
+ if (IsValid(scissor_right)) {
+ crop_right_valid = CalculateCropRects(scissor_right, &crop_right, &dst_right);
+ }
+
+ // Reset left_pipe and right_pipe to invalid by default
+ left_pipe->Reset();
+ right_pipe->Reset();
+
+ if (crop_left_valid) {
+ // assign left pipe
+ left_pipe->src_roi = crop_left;
+ left_pipe->dst_roi = dst_left;
+ left_pipe->valid = true;
+ }
+
+ // assign right pipe if needed
+ if (crop_right_valid) {
+ right_pipe->src_roi = crop_right;
+ right_pipe->dst_roi = dst_right;
+ right_pipe->valid = true;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::Config(DisplayResourceContext *display_resource_ctx,
+ HWLayers *hw_layers) {
+ HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
+ HWLayersInfo &layer_info = hw_layers->info;
+ DisplayError error = kErrorNone;
+ uint32_t z_order = 0;
+
+ Layer& layer = layer_info.stack->layers[layer_info.index[0]];
+
+ error = ValidateLayerDimensions(layer);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ struct HWLayerConfig *layer_config = &hw_layers->config[0];
+ HWPipeInfo &left_pipe = layer_config->left_pipe;
+ HWPipeInfo &right_pipe = layer_config->right_pipe;
+
+ LayerRect src_rect = layer.src_rect;
+ LayerRect dst_rect = layer.dst_rect;
+
+ error = ValidateDimensions(src_rect, dst_rect);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ error = ValidateScaling(src_rect, dst_rect, false);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ if (hw_res_info_.is_src_split) {
+ error = SrcSplitConfig(display_resource_ctx, src_rect, dst_rect, layer_config);
+ } else {
+ error = DisplaySplitConfig(display_resource_ctx, src_rect, dst_rect, layer_config);
+ }
+
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ error = AlignPipeConfig(layer, &left_pipe, &right_pipe);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ // set z_order, left_pipe should always be valid
+ left_pipe.z_order = 0;
+
+ DLOGV_IF(kTagResources, "==== FB layer Config ====");
+ Log(kTagResources, "input layer src_rect", layer.src_rect);
+ Log(kTagResources, "input layer dst_rect", layer.dst_rect);
+ Log(kTagResources, "cropped src_rect", src_rect);
+ Log(kTagResources, "cropped dst_rect", dst_rect);
+ Log(kTagResources, "left pipe src", layer_config->left_pipe.src_roi);
+ Log(kTagResources, "left pipe dst", layer_config->left_pipe.dst_roi);
+ if (right_pipe.valid) {
+ right_pipe.z_order = 0;
+ Log(kTagResources, "right pipe src", layer_config->right_pipe.src_roi);
+ Log(kTagResources, "right pipe dst", layer_config->right_pipe.dst_roi);
+ }
+
+ return error;
+}
+
+bool ResourceDefault::CalculateCropRects(const LayerRect &scissor, LayerRect *crop,
+ LayerRect *dst) {
+ float &crop_left = crop->left;
+ float &crop_top = crop->top;
+ float &crop_right = crop->right;
+ float &crop_bottom = crop->bottom;
+ float crop_width = crop->right - crop->left;
+ float crop_height = crop->bottom - crop->top;
+
+ float &dst_left = dst->left;
+ float &dst_top = dst->top;
+ float &dst_right = dst->right;
+ float &dst_bottom = dst->bottom;
+ float dst_width = dst->right - dst->left;
+ float dst_height = dst->bottom - dst->top;
+
+ const float &sci_left = scissor.left;
+ const float &sci_top = scissor.top;
+ const float &sci_right = scissor.right;
+ const float &sci_bottom = scissor.bottom;
+
+ float left_cut_ratio = 0.0, right_cut_ratio = 0.0, top_cut_ratio = 0.0, bottom_cut_ratio = 0.0;
+ bool need_cut = false;
+
+ if (dst_left < sci_left) {
+ left_cut_ratio = (sci_left - dst_left) / dst_width;
+ dst_left = sci_left;
+ need_cut = true;
+ }
+
+ if (dst_right > sci_right) {
+ right_cut_ratio = (dst_right - sci_right) / dst_width;
+ dst_right = sci_right;
+ need_cut = true;
+ }
+
+ if (dst_top < sci_top) {
+ top_cut_ratio = (sci_top - dst_top) / (dst_height);
+ dst_top = sci_top;
+ need_cut = true;
+ }
+
+ if (dst_bottom > sci_bottom) {
+ bottom_cut_ratio = (dst_bottom - sci_bottom) / (dst_height);
+ dst_bottom = sci_bottom;
+ need_cut = true;
+ }
+
+ if (!need_cut)
+ return true;
+
+ crop_left += crop_width * left_cut_ratio;
+ crop_top += crop_height * top_cut_ratio;
+ crop_right -= crop_width * right_cut_ratio;
+ crop_bottom -= crop_height * bottom_cut_ratio;
+ Normalize(1, 1, crop);
+ Normalize(1, 1, dst);
+ if (IsValid(*crop) && IsValid(*dst))
+ return true;
+ else
+ return false;
+}
+
+DisplayError ResourceDefault::ValidateLayerDimensions(const Layer &layer) {
+ const LayerRect &src = layer.src_rect;
+ const LayerRect &dst = layer.dst_rect;
+ LayerBuffer *input_buffer = layer.input_buffer;
+
+ if (!IsValid(src) || !IsValid(dst)) {
+ Log(kTagResources, "input layer src_rect", src);
+ Log(kTagResources, "input layer dst_rect", dst);
+ return kErrorNotSupported;
+ }
+
+ // Make sure source in integral only if it is a non secure layer.
+ if (!input_buffer->flags.secure && (src.left - roundf(src.left) || src.top - roundf(src.top) ||
+ src.right - roundf(src.right) || src.bottom - roundf(src.bottom))) {
+ DLOGV_IF(kTagResources, "Input ROI is not integral");
+ return kErrorNotSupported;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::ValidateDimensions(const LayerRect &crop, const LayerRect &dst) {
+ if (!IsValid(crop)) {
+ Log(kTagResources, "Invalid crop rect", crop);
+ return kErrorNotSupported;
+ }
+
+ if (!IsValid(dst)) {
+ Log(kTagResources, "Invalid dst rect", dst);
+ return kErrorNotSupported;
+ }
+
+ float crop_width = crop.right - crop.left;
+ float crop_height = crop.bottom - crop.top;
+ float dst_width = dst.right - dst.left;
+ float dst_height = dst.bottom - dst.top;
+
+ if ((UINT32(crop_width - dst_width) == 1) || (UINT32(crop_height - dst_height) == 1)) {
+ DLOGV_IF(kTagResources, "One pixel downscaling detected crop_w = %.0f, dst_w = %.0f, " \
+ "crop_h = %.0f, dst_h = %.0f", crop_width, dst_width, crop_height, dst_height);
+ return kErrorNotSupported;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::ValidatePipeParams(HWPipeInfo *pipe_info) {
+ DisplayError error = kErrorNone;
+
+ const LayerRect &src_rect = pipe_info->src_roi;
+ const LayerRect &dst_rect = pipe_info->dst_roi;
+
+ error = ValidateDimensions(src_rect, dst_rect);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ error = ValidateScaling(src_rect, dst_rect, false);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::ValidateScaling(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90) {
+ DisplayError error = kErrorNone;
+
+ float scale_x = 1.0f;
+ float scale_y = 1.0f;
+
+ error = GetScaleFactor(crop, dst, &scale_x, &scale_y);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ error = ValidateDownScaling(scale_x, scale_y);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ error = ValidateUpScaling(scale_x, scale_y);
+ if (error != kErrorNone) {
+ return error;
+ }
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::ValidateDownScaling(float scale_x, float scale_y) {
+ if ((UINT32(scale_x) > 1) || (UINT32(scale_y) > 1)) {
+ float max_scale_down = FLOAT(hw_res_info_.max_scale_down);
+
+ if (hw_res_info_.has_decimation) {
+ max_scale_down *= FLOAT(kMaxDecimationDownScaleRatio);
+ }
+
+ if (scale_x > max_scale_down || scale_y > max_scale_down) {
+ DLOGV_IF(kTagResources,
+ "Scaling down is over the limit: scale_x = %.0f, scale_y = %.0f, " \
+ "has_deci = %d", scale_x, scale_y, hw_res_info_.has_decimation);
+ return kErrorNotSupported;
+ }
+ }
+
+ DLOGV_IF(kTagResources, "scale_x = %.4f, scale_y = %.4f", scale_x, scale_y);
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::ValidateUpScaling(float scale_x, float scale_y) {
+ float max_scale_up = FLOAT(hw_res_info_.max_scale_up);
+
+ if (UINT32(scale_x) < 1 && scale_x > 0.0f) {
+ if ((1.0f / scale_x) > max_scale_up) {
+ DLOGV_IF(kTagResources, "Scaling up is over limit scale_x = %f", 1.0f / scale_x);
+ return kErrorNotSupported;
+ }
+ }
+
+ if (UINT32(scale_y) < 1 && scale_y > 0.0f) {
+ if ((1.0f / scale_y) > max_scale_up) {
+ DLOGV_IF(kTagResources, "Scaling up is over limit scale_y = %f", 1.0f / scale_y);
+ return kErrorNotSupported;
+ }
+ }
+
+ DLOGV_IF(kTagResources, "scale_x = %.4f, scale_y = %.4f", scale_x, scale_y);
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::GetScaleFactor(const LayerRect &crop, const LayerRect &dst,
+ float *scale_x, float *scale_y) {
+ float crop_width = crop.right - crop.left;
+ float crop_height = crop.bottom - crop.top;
+ float dst_width = dst.right - dst.left;
+ float dst_height = dst.bottom - dst.top;
+
+ *scale_x = crop_width / dst_width;
+ *scale_y = crop_height / dst_height;
+
+ return kErrorNone;
+}
+
+DisplayError ResourceDefault::SetDecimationFactor(HWPipeInfo *pipe) {
+ float src_h = pipe->src_roi.bottom - pipe->src_roi.top;
+ float dst_h = pipe->dst_roi.bottom - pipe->dst_roi.top;
+ float down_scale_h = src_h / dst_h;
+
+ float src_w = pipe->src_roi.right - pipe->src_roi.left;
+ float dst_w = pipe->dst_roi.right - pipe->dst_roi.left;
+ float down_scale_w = src_w / dst_w;
+
+ pipe->horizontal_decimation = 0;
+ pipe->vertical_decimation = 0;
+
+ if (CalculateDecimation(down_scale_w, &pipe->horizontal_decimation) != kErrorNone) {
+ return kErrorNotSupported;
+ }
+
+ if (CalculateDecimation(down_scale_h, &pipe->vertical_decimation) != kErrorNone) {
+ return kErrorNotSupported;
+ }
+
+ DLOGI_IF(kTagResources, "horizontal_decimation %d, vertical_decimation %d",
+ pipe->horizontal_decimation, pipe->vertical_decimation);
+
+ return kErrorNone;
+}
+
+void ResourceDefault::SplitRect(const LayerRect &src_rect, const LayerRect &dst_rect,
+ LayerRect *src_left, LayerRect *dst_left, LayerRect *src_right,
+ LayerRect *dst_right) {
+ // Split rectangle horizontally and evenly into two.
+ float src_width = src_rect.right - src_rect.left;
+ float dst_width = dst_rect.right - dst_rect.left;
+ float src_width_ori = src_width;
+ src_width = ROUND_UP_ALIGN_DOWN(src_width / 2, 1);
+ dst_width = ROUND_UP_ALIGN_DOWN(dst_width * src_width / src_width_ori, 1);
+
+ src_left->left = src_rect.left;
+ src_left->right = src_rect.left + src_width;
+ src_right->left = src_left->right;
+ src_right->right = src_rect.right;
+
+ src_left->top = src_rect.top;
+ src_left->bottom = src_rect.bottom;
+ src_right->top = src_rect.top;
+ src_right->bottom = src_rect.bottom;
+
+ dst_left->top = dst_rect.top;
+ dst_left->bottom = dst_rect.bottom;
+ dst_right->top = dst_rect.top;
+ dst_right->bottom = dst_rect.bottom;
+
+ dst_left->left = dst_rect.left;
+ dst_left->right = dst_rect.left + dst_width;
+ dst_right->left = dst_left->right;
+ dst_right->right = dst_rect.right;
+}
+
+DisplayError ResourceDefault::AlignPipeConfig(const Layer &layer, HWPipeInfo *left_pipe,
+ HWPipeInfo *right_pipe) {
+ DisplayError error = kErrorNone;
+ if (!left_pipe->valid) {
+ DLOGE_IF(kTagResources, "left_pipe should not be invalid");
+ return kErrorNotSupported;
+ }
+
+ error = ValidatePipeParams(left_pipe);
+ if (error != kErrorNone) {
+ goto PipeConfigExit;
+ }
+
+ if (right_pipe->valid) {
+ // Make sure the left and right ROI are conjunct
+ right_pipe->src_roi.left = left_pipe->src_roi.right;
+ right_pipe->dst_roi.left = left_pipe->dst_roi.right;
+ error = ValidatePipeParams(right_pipe);
+ }
+
+PipeConfigExit:
+ if (error != kErrorNone) {
+ DLOGV_IF(kTagResources, "AlignPipeConfig failed");
+ }
+ return error;
+}
+
+DisplayError ResourceDefault::CalculateDecimation(float downscale, uint8_t *decimation) {
+ float max_down_scale = FLOAT(hw_res_info_.max_scale_down);
+
+ if (downscale <= max_down_scale) {
+ *decimation = 0;
+ return kErrorNone;
+ } else if (!hw_res_info_.has_decimation) {
+ DLOGE("Downscaling exceeds the maximum MDP downscale limit but decimation not enabled");
+ return kErrorNotSupported;
+ }
+
+ // Decimation is the remaining downscale factor after doing max SDE downscale.
+ // In SDE, decimation is supported in powers of 2.
+ // For ex: If a pipe needs downscale of 8 but max_down_scale is 4
+ // So decimation = powf(2.0, ceilf(log2f(8 / 4))) = powf(2.0, 1.0) = 2
+ *decimation = UINT8(ceilf(log2f(downscale / max_down_scale)));
+ return kErrorNone;
+}
+
+} // namespace sdm
+
diff --git a/sdm/libs/core/resource_default.h b/sdm/libs/core/resource_default.h
new file mode 100644
index 0000000..14174d1
--- /dev/null
+++ b/sdm/libs/core/resource_default.h
@@ -0,0 +1,156 @@
+/*
+* Copyright (c) 2014 - 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __RESOURCE_DEFAULT_H__
+#define __RESOURCE_DEFAULT_H__
+
+#include <core/display_interface.h>
+#include <private/resource_interface.h>
+#include <utils/locker.h>
+
+#include "hw_interface.h"
+
+namespace sdm {
+
+class ResourceDefault : public ResourceInterface {
+ public:
+ ResourceDefault();
+ DisplayError Init(const HWResourceInfo &hw_resource_info);
+ DisplayError Deinit();
+ virtual DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info, Handle *display_ctx);
+ virtual DisplayError UnregisterDisplay(Handle display_ctx);
+ virtual void ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &attributes,
+ const HWPanelInfo &hw_panel_info);
+ virtual DisplayError Start(Handle display_ctx);
+ virtual DisplayError Stop(Handle display_ctx);
+ virtual DisplayError Acquire(Handle display_ctx, HWLayers *hw_layers);
+ virtual DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers);
+ virtual DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers);
+ virtual void Purge(Handle display_ctx);
+ virtual DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages);
+ virtual DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst,
+ bool rotate90);
+
+ private:
+ enum PipeId {
+ kPipeIdVIG0,
+ kPipeIdVIG1,
+ kPipeIdVIG2,
+ kPipeIdRGB0,
+ kPipeIdRGB1,
+ kPipeIdRGB2,
+ kPipeIdDMA0,
+ kPipeIdDMA1,
+ kPipeIdVIG3,
+ kPipeIdRGB3,
+ kPipeIdMax,
+ };
+
+ enum PipeType {
+ kPipeTypeUnused,
+ kPipeTypeVIG,
+ kPipeTypeRGB,
+ kPipeTypeDMA,
+ kPipeTypeMax,
+ };
+
+ enum PipeOwner {
+ kPipeOwnerUserMode, // Pipe state when it is available for reservation
+ kPipeOwnerKernelMode, // Pipe state when pipe is owned by kernel
+ };
+
+ // todo: retrieve all these from kernel
+ enum {
+ kMaxDecimationDownScaleRatio = 8,
+ };
+
+ struct SourcePipe {
+ PipeType type;
+ PipeOwner owner;
+ uint32_t mdss_pipe_id;
+ uint32_t index;
+ HWBlockType hw_block_id;
+ int priority;
+
+ SourcePipe() : type(kPipeTypeUnused), owner(kPipeOwnerUserMode), mdss_pipe_id(kPipeIdMax),
+ index(0), hw_block_id(kHWBlockMax), priority(0) { }
+
+ inline void ResetState() { hw_block_id = kHWBlockMax;}
+ };
+
+ struct DisplayResourceContext {
+ HWDisplayAttributes display_attributes;
+ HWBlockType hw_block_id;
+ uint64_t frame_count;
+
+ DisplayResourceContext() : hw_block_id(kHWBlockMax), frame_count(0) { }
+ };
+
+ struct HWBlockContext {
+ bool is_in_use;
+ HWBlockContext() : is_in_use(false) { }
+ };
+
+ uint32_t GetMdssPipeId(PipeType pipe_type, uint32_t index);
+ uint32_t NextPipe(PipeType pipe_type, HWBlockType hw_block_id);
+ uint32_t SearchPipe(HWBlockType hw_block_id, SourcePipe *src_pipes, uint32_t num_pipe);
+ uint32_t GetPipe(HWBlockType hw_block_id, bool need_scale);
+ bool IsScalingNeeded(const HWPipeInfo *pipe_info);
+ DisplayError Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers);
+ DisplayError DisplaySplitConfig(DisplayResourceContext *display_resource_ctx,
+ const LayerRect &src_rect, const LayerRect &dst_rect,
+ HWLayerConfig *layer_config);
+ DisplayError SrcSplitConfig(DisplayResourceContext *display_resource_ctx,
+ const LayerRect &src_rect, const LayerRect &dst_rect,
+ HWLayerConfig *layer_config);
+ bool CalculateCropRects(const LayerRect &scissor, LayerRect *crop, LayerRect *dst);
+ DisplayError ValidateLayerDimensions(const Layer &layer);
+ DisplayError ValidateDimensions(const LayerRect &crop, const LayerRect &dst);
+ DisplayError ValidatePipeParams(HWPipeInfo *pipe_info);
+ DisplayError ValidateDownScaling(float scale_x, float scale_y);
+ DisplayError ValidateUpScaling(float scale_x, float scale_y);
+ DisplayError GetScaleFactor(const LayerRect &crop, const LayerRect &dst, float *scale_x,
+ float *scale_y);
+ DisplayError SetDecimationFactor(HWPipeInfo *pipe);
+ void SplitRect(const LayerRect &src_rect, const LayerRect &dst_rect, LayerRect *src_left,
+ LayerRect *dst_left, LayerRect *src_right, LayerRect *dst_right);
+ DisplayError AlignPipeConfig(const Layer &layer, HWPipeInfo *left_pipe, HWPipeInfo *right_pipe);
+ void ResourceStateLog(void);
+ DisplayError CalculateDecimation(float downscale, uint8_t *decimation);
+
+ Locker locker_;
+ HWResourceInfo hw_res_info_;
+ HWBlockContext hw_block_ctx_[kHWBlockMax];
+ SourcePipe src_pipes_[kPipeIdMax];
+ uint32_t num_pipe_;
+ SourcePipe *vig_pipes_;
+ SourcePipe *rgb_pipes_;
+ SourcePipe *dma_pipes_;
+};
+
+} // namespace sdm
+
+#endif // __RESOURCE_DEFAULT_H__
+
diff --git a/sdm/libs/core/strategy.cpp b/sdm/libs/core/strategy.cpp
new file mode 100644
index 0000000..16e3f63
--- /dev/null
+++ b/sdm/libs/core/strategy.cpp
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2014 - 2015, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <utils/constants.h>
+#include <utils/debug.h>
+
+#include "strategy.h"
+
+#define __CLASS__ "Strategy"
+
+namespace sdm {
+
+Strategy::Strategy(ExtensionInterface *extension_intf, DisplayType type,
+ const HWResourceInfo &hw_resource_info, const HWPanelInfo &hw_panel_info)
+ : extension_intf_(extension_intf), strategy_intf_(NULL), partial_update_intf_(NULL),
+ display_type_(type),hw_resource_info_(hw_resource_info), hw_panel_info_(hw_panel_info),
+ hw_layers_info_(NULL), fb_layer_index_(0), extn_start_success_(false), tried_default_(false) {
+}
+
+DisplayError Strategy::Init() {
+ DisplayError error = kErrorNone;
+
+ if (extension_intf_) {
+ error = extension_intf_->CreateStrategyExtn(display_type_, &strategy_intf_);
+ if (error != kErrorNone) {
+ DLOGE("Failed to create strategy");
+ return error;
+ }
+
+ error = extension_intf_->CreatePartialUpdate(display_type_, hw_resource_info_,
+ hw_panel_info_, &partial_update_intf_);
+ if (error != kErrorNone) {
+ DLOGW("Partial Update creation failed, Continue without partial update.");
+ }
+ }
+
+ return kErrorNone;
+}
+
+DisplayError Strategy::Deinit() {
+ if (strategy_intf_) {
+ if (partial_update_intf_) {
+ extension_intf_->DestroyPartialUpdate(partial_update_intf_);
+ }
+
+ extension_intf_->DestroyStrategyExtn(strategy_intf_);
+ }
+
+ return kErrorNone;
+}
+
+DisplayError Strategy::Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts) {
+ DisplayError error = kErrorNone;
+
+ hw_layers_info_ = hw_layers_info;
+ extn_start_success_ = false;
+ tried_default_ = false;
+
+ uint32_t i = 0;
+ LayerStack *layer_stack = hw_layers_info_->stack;
+ for (; i < layer_stack->layer_count; i++) {
+ if (layer_stack->layers[i].composition == kCompositionGPUTarget) {
+ fb_layer_index_ = i;
+ break;
+ }
+ }
+
+ if (i == layer_stack->layer_count) {
+ return kErrorUndefined;
+ }
+
+ GenerateROI();
+
+ if (strategy_intf_) {
+ error = strategy_intf_->Start(hw_layers_info_, max_attempts);
+ if (error == kErrorNone) {
+ extn_start_success_ = true;
+ return kErrorNone;
+ }
+ }
+
+ *max_attempts = 1;
+
+ return kErrorNone;
+}
+
+DisplayError Strategy::Stop() {
+ if (extn_start_success_) {
+ return strategy_intf_->Stop();
+ }
+
+ return kErrorNone;
+}
+
+DisplayError Strategy::GetNextStrategy(StrategyConstraints *constraints) {
+ DisplayError error = kErrorNone;
+
+ if (extn_start_success_) {
+ error = strategy_intf_->GetNextStrategy(constraints);
+ if (error == kErrorNone) {
+ return kErrorNone;
+ }
+ }
+
+ // Default composition is already tried.
+ if (tried_default_) {
+ return kErrorUndefined;
+ }
+
+ // Mark all layers for GPU composition. Find GPU target buffer and store its index for
+ // programming the hardware.
+ LayerStack *layer_stack = hw_layers_info_->stack;
+ uint32_t &hw_layer_count = hw_layers_info_->count;
+ hw_layer_count = 0;
+ for (uint32_t i = 0; i < layer_stack->layer_count; i++) {
+ LayerComposition &composition = layer_stack->layers[i].composition;
+ if (composition == kCompositionGPUTarget) {
+ hw_layers_info_->index[hw_layer_count++] = i;
+ } else {
+ composition = kCompositionGPU;
+ }
+ }
+
+ tried_default_ = true;
+
+ // There can be one and only one GPU target buffer.
+ if (hw_layer_count != 1) {
+ return kErrorParameters;
+ }
+
+ return kErrorNone;
+}
+
+void Strategy::GenerateROI() {
+ bool split_display = false;
+
+ if (partial_update_intf_ && partial_update_intf_->GenerateROI(hw_layers_info_) == kErrorNone) {
+ return;
+ }
+
+ LayerStack *layer_stack = hw_layers_info_->stack;
+ LayerRect &src_rect = layer_stack->layers[fb_layer_index_].src_rect;
+ // TODO(user): read panels x_pixels and y_pixels instead of fb_x_res and fb_y_res
+ float fb_x_res = src_rect.right - src_rect.left;
+ float fb_y_res = src_rect.bottom - src_rect.top;
+
+ if (!hw_resource_info_.is_src_split &&
+ ((fb_x_res > hw_resource_info_.max_mixer_width) ||
+ ((display_type_ == kPrimary) && hw_panel_info_.split_info.right_split))) {
+ split_display = true;
+ }
+
+ if (split_display) {
+ float left_split = FLOAT(hw_panel_info_.split_info.left_split);
+ hw_layers_info_->left_partial_update = (LayerRect) {0.0f, 0.0f, left_split, fb_y_res};
+ hw_layers_info_->right_partial_update = (LayerRect) {left_split, 0.0f, fb_x_res, fb_y_res};
+ } else {
+ hw_layers_info_->left_partial_update = (LayerRect) {0.0f, 0.0f, fb_x_res, fb_y_res};
+ hw_layers_info_->right_partial_update = (LayerRect) {0.0f, 0.0f, 0.0f, 0.0f};
+ }
+}
+
+} // namespace sdm
+
diff --git a/displayengine/libs/core/strategy_default.h b/sdm/libs/core/strategy.h
similarity index 62%
rename from displayengine/libs/core/strategy_default.h
rename to sdm/libs/core/strategy.h
index 7b6f594..c7a67d9 100644
--- a/displayengine/libs/core/strategy_default.h
+++ b/sdm/libs/core/strategy.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 2015, 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 met:
@@ -22,33 +22,42 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __STRATEGY_DEFAULT_H__
-#define __STRATEGY_DEFAULT_H__
+#ifndef __STRATEGY_H__
+#define __STRATEGY_H__
#include <core/display_interface.h>
-#include <private/strategy_interface.h>
+#include <private/extension_interface.h>
-namespace sde {
+namespace sdm {
-class StrategyDefault : public StrategyInterface {
+class Strategy {
public:
- StrategyDefault();
+ Strategy(ExtensionInterface *extension_intf, DisplayType type,
+ const HWResourceInfo &hw_resource_info, const HWPanelInfo &hw_panel_info);
- static DisplayError CreateStrategyInterface(uint16_t version, DisplayType type,
- const HWResourceInfo *hw_resource_info,
- const HWPanelInfo *hw_panel_info,
- StrategyInterface **interface);
- static DisplayError DestroyStrategyInterface(StrategyInterface *interface);
+ DisplayError Init();
+ DisplayError Deinit();
- virtual DisplayError Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts);
- virtual DisplayError GetNextStrategy(StrategyConstraints *constraints);
- virtual DisplayError Stop();
+ DisplayError Start(HWLayersInfo *hw_layers_info, uint32_t *max_attempts);
+ DisplayError GetNextStrategy(StrategyConstraints *constraints);
+ DisplayError Stop();
private:
+ void GenerateROI();
+
+ ExtensionInterface *extension_intf_;
+ StrategyInterface *strategy_intf_;
+ PartialUpdateInterface *partial_update_intf_;
+ DisplayType display_type_;
+ HWResourceInfo hw_resource_info_;
+ HWPanelInfo hw_panel_info_;
HWLayersInfo *hw_layers_info_;
+ uint32_t fb_layer_index_;
+ bool extn_start_success_;
+ bool tried_default_;
};
-} // namespace sde
+} // namespace sdm
-#endif // __STRATEGY_DEFAULT_H__
+#endif // __STRATEGY_H__
diff --git a/displayengine/libs/hwc/Android.mk b/sdm/libs/hwc/Android.mk
similarity index 74%
rename from displayengine/libs/hwc/Android.mk
rename to sdm/libs/hwc/Android.mk
index d31c71e..f233557 100644
--- a/displayengine/libs/hwc/Android.mk
+++ b/sdm/libs/hwc/Android.mk
@@ -4,14 +4,20 @@
LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
-LOCAL_C_INCLUDES := hardware/qcom/display/displayengine/include/ \
+LOCAL_C_INCLUDES := hardware/qcom/display/sdm/include/ \
hardware/qcom/display/libgralloc/ \
hardware/qcom/display/libqservice/ \
hardware/qcom/display/libqdutils/
LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \
-Wconversion -Wall -Werror \
- -DLOG_TAG=\"SDE\"
-LOCAL_SHARED_LIBRARIES := libsde libqservice libbinder libhardware libhardware_legacy \
+ -DLOG_TAG=\"SDM\"
+
+# TODO: Move this to the common makefile
+ifeq ($(call is-board-platform-in-list, $(MASTER_SIDE_CP_TARGET_LIST)), true)
+ LOCAL_CFLAGS += -DMASTER_SIDE_CP
+endif
+
+LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware libhardware_legacy \
libutils libcutils libsync libmemalloc libqdutils
LOCAL_SRC_FILES := hwc_session.cpp \
hwc_display.cpp \
diff --git a/displayengine/libs/hwc/hwc_buffer_allocator.cpp b/sdm/libs/hwc/hwc_buffer_allocator.cpp
similarity index 88%
rename from displayengine/libs/hwc/hwc_buffer_allocator.cpp
rename to sdm/libs/hwc/hwc_buffer_allocator.cpp
index 2adfc3a..2d79f0d 100644
--- a/displayengine/libs/hwc/hwc_buffer_allocator.cpp
+++ b/sdm/libs/hwc/hwc_buffer_allocator.cpp
@@ -39,7 +39,7 @@
#define __CLASS__ "HWCBufferAllocator"
-namespace sde {
+namespace sdm {
HWCBufferAllocator::HWCBufferAllocator() {
alloc_controller_ = gralloc::IAllocController::getInstance();
@@ -63,15 +63,10 @@
int height = INT(buffer_config.height);
int format;
- error = SetHALFormat(buffer_config.format, &format);
- if (error != 0) {
- return kErrorParameters;
- }
-
if (buffer_config.secure) {
alloc_flags = GRALLOC_USAGE_PRIVATE_MM_HEAP;
alloc_flags |= GRALLOC_USAGE_PROTECTED;
- data.align = kSecureBufferAlignment;
+ data.align = SECURE_ALIGN;
} else {
data.align = getpagesize();
}
@@ -81,11 +76,16 @@
alloc_flags |= GRALLOC_USAGE_PRIVATE_UNCACHED;
}
+ error = SetBufferInfo(buffer_config.format, &format, &alloc_flags);
+ if (error != 0) {
+ return kErrorParameters;
+ }
+
int aligned_width = 0, aligned_height = 0;
uint32_t buffer_size = getBufferSizeAndDimensions(width, height, format, alloc_flags,
aligned_width, aligned_height);
- buffer_size = ROUND_UP((buffer_size * buffer_config.buffer_count), data.align);
+ buffer_size = ROUND_UP(buffer_size, data.align) * buffer_config.buffer_count;
data.base = 0;
data.fd = -1;
@@ -116,8 +116,9 @@
AllocatedBufferInfo *alloc_buffer_info = &buffer_info->alloc_buffer_info;
MetaBufferInfo *meta_buffer_info = static_cast<MetaBufferInfo *> (buffer_info->private_data);
- if ((alloc_buffer_info->fd < 0) || (meta_buffer_info->base_addr == NULL)) {
- return kErrorNone;
+ if (alloc_buffer_info->fd < 0) {
+ DLOGE("Invalid parameters: fd %d", alloc_buffer_info->fd);
+ return kErrorParameters;
}
gralloc::IMemAlloc *memalloc = alloc_controller_->getAllocator(meta_buffer_info->alloc_type);
@@ -147,7 +148,7 @@
return kErrorNone;
}
-int HWCBufferAllocator::SetHALFormat(LayerBufferFormat format, int *target) {
+int HWCBufferAllocator::SetBufferInfo(LayerBufferFormat format, int *target, int *flags) {
switch (format) {
case kFormatRGBA8888: *target = HAL_PIXEL_FORMAT_RGBA_8888; break;
case kFormatRGBX8888: *target = HAL_PIXEL_FORMAT_RGBX_8888; break;
@@ -163,7 +164,18 @@
case kFormatYCbCr420SPVenusUbwc: *target = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC; break;
case kFormatRGBA5551: *target = HAL_PIXEL_FORMAT_RGBA_5551; break;
case kFormatRGBA4444: *target = HAL_PIXEL_FORMAT_RGBA_4444; break;
-
+ case kFormatRGBA8888Ubwc:
+ *target = HAL_PIXEL_FORMAT_RGBA_8888;
+ *flags |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ break;
+ case kFormatRGBX8888Ubwc:
+ *target = HAL_PIXEL_FORMAT_RGBX_8888;
+ *flags |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ break;
+ case kFormatRGB565Ubwc:
+ *target = HAL_PIXEL_FORMAT_RGB_565;
+ *flags |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ break;
default:
DLOGE("Unsupported format = 0x%x", format);
return -EINVAL;
@@ -172,4 +184,4 @@
return 0;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_buffer_allocator.h b/sdm/libs/hwc/hwc_buffer_allocator.h
similarity index 93%
rename from displayengine/libs/hwc/hwc_buffer_allocator.h
rename to sdm/libs/hwc/hwc_buffer_allocator.h
index 123f04a..b3f8add 100644
--- a/displayengine/libs/hwc/hwc_buffer_allocator.h
+++ b/sdm/libs/hwc/hwc_buffer_allocator.h
@@ -40,7 +40,7 @@
} // namespace gralloc
-namespace sde {
+namespace sdm {
class HWCBufferAllocator : public BufferAllocator {
public:
@@ -50,18 +50,16 @@
DisplayError FreeBuffer(BufferInfo *buffer_info);
private:
- static const size_t kSecureBufferAlignment = 0x00100000;
-
struct MetaBufferInfo {
int alloc_type; //!< Specifies allocation type set by the buffer allocator.
void *base_addr; //!< Specifies the base address of the allocated output buffer.
};
- int SetHALFormat(LayerBufferFormat format, int *target);
+ int SetBufferInfo(LayerBufferFormat format, int *target, int *flags);
gralloc::IAllocController *alloc_controller_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_BUFFER_ALLOCATOR_H__
diff --git a/displayengine/libs/hwc/hwc_buffer_sync_handler.cpp b/sdm/libs/hwc/hwc_buffer_sync_handler.cpp
similarity index 98%
rename from displayengine/libs/hwc/hwc_buffer_sync_handler.cpp
rename to sdm/libs/hwc/hwc_buffer_sync_handler.cpp
index 31788ea..9bc4ec9 100644
--- a/displayengine/libs/hwc/hwc_buffer_sync_handler.cpp
+++ b/sdm/libs/hwc/hwc_buffer_sync_handler.cpp
@@ -35,7 +35,7 @@
#define __CLASS__ "HWCBufferSyncHandler"
-namespace sde {
+namespace sdm {
DisplayError HWCBufferSyncHandler::SyncWait(int fd) {
int error = 0;
@@ -67,5 +67,5 @@
return error;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_buffer_sync_handler.h b/sdm/libs/hwc/hwc_buffer_sync_handler.h
similarity index 96%
rename from displayengine/libs/hwc/hwc_buffer_sync_handler.h
rename to sdm/libs/hwc/hwc_buffer_sync_handler.h
index 26b1d33..da94650 100644
--- a/displayengine/libs/hwc/hwc_buffer_sync_handler.h
+++ b/sdm/libs/hwc/hwc_buffer_sync_handler.h
@@ -33,10 +33,10 @@
#include <sys/mman.h>
#include <fcntl.h>
-#include <core/sde_types.h>
+#include <core/sdm_types.h>
#include <core/buffer_sync_handler.h>
-namespace sde {
+namespace sdm {
class HWCBufferSyncHandler : public BufferSyncHandler {
public:
@@ -46,7 +46,7 @@
virtual DisplayError SyncMerge(int fd1, int fd2, int *merged_fd);
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_BUFFER_SYNC_HANDLER_H__
diff --git a/displayengine/libs/hwc/hwc_debugger.cpp b/sdm/libs/hwc/hwc_debugger.cpp
similarity index 91%
rename from displayengine/libs/hwc/hwc_debugger.cpp
rename to sdm/libs/hwc/hwc_debugger.cpp
index d35e9cf..ab9309e 100644
--- a/displayengine/libs/hwc/hwc_debugger.cpp
+++ b/sdm/libs/hwc/hwc_debugger.cpp
@@ -31,7 +31,7 @@
#include "hwc_debugger.h"
-namespace sde {
+namespace sdm {
HWCDebugHandler HWCDebugHandler::debug_handler_;
uint32_t HWCDebugHandler::debug_flags_ = 0x1;
@@ -76,19 +76,11 @@
}
}
-void HWCDebugHandler::DebugBufferManager(bool enable) {
+void HWCDebugHandler::DebugRotator(bool enable) {
if (enable) {
- SET_BIT(debug_flags_, kTagBufferManager);
+ SET_BIT(debug_flags_, kTagRotator);
} else {
- CLEAR_BIT(debug_flags_, kTagBufferManager);
- }
-}
-
-void HWCDebugHandler::DebugOfflineCtrl(bool enable) {
- if (enable) {
- SET_BIT(debug_flags_, kTagOfflineCtrl);
- } else {
- CLEAR_BIT(debug_flags_, kTagOfflineCtrl);
+ CLEAR_BIT(debug_flags_, kTagRotator);
}
}
@@ -131,5 +123,5 @@
atrace_end(ATRACE_TAG);
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_debugger.h b/sdm/libs/hwc/hwc_debugger.h
similarity index 95%
rename from displayengine/libs/hwc/hwc_debugger.h
rename to sdm/libs/hwc/hwc_debugger.h
index def31db..61a1b6f 100644
--- a/displayengine/libs/hwc/hwc_debugger.h
+++ b/sdm/libs/hwc/hwc_debugger.h
@@ -32,7 +32,7 @@
#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
-#include <core/sde_types.h>
+#include <core/sdm_types.h>
#include <core/debug_interface.h>
#include <cutils/log.h>
#include <utils/Trace.h>
@@ -49,7 +49,7 @@
#define DTRACE_END() HWCDebugHandler::Get()->EndTrace()
#define DTRACE_SCOPED() ScopeTracer<HWCDebugHandler> scope_tracer(__CLASS__, __FUNCTION__)
-namespace sde {
+namespace sdm {
class HWCDebugHandler : public DebugHandler {
public:
@@ -59,8 +59,7 @@
static void DebugStrategy(bool enable);
static void DebugCompManager(bool enable);
static void DebugDriverConfig(bool enable);
- static void DebugBufferManager(bool enable);
- static void DebugOfflineCtrl(bool enable);
+ static void DebugRotator(bool enable);
virtual void Error(DebugTag tag, const char *format, ...);
virtual void Warning(DebugTag tag, const char *format, ...);
@@ -75,7 +74,7 @@
static uint32_t debug_flags_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_DEBUGGER_H__
diff --git a/displayengine/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
similarity index 73%
rename from displayengine/libs/hwc/hwc_display.cpp
rename to sdm/libs/hwc/hwc_display.cpp
index 8d7e94a..0278c90 100644
--- a/displayengine/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -33,19 +33,21 @@
#include <utils/constants.h>
#include <qdMetaData.h>
#include <sync/sync.h>
+#include <cutils/properties.h>
#include "hwc_display.h"
#include "hwc_debugger.h"
#define __CLASS__ "HWCDisplay"
-namespace sde {
+namespace sdm {
HWCDisplay::HWCDisplay(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, DisplayType type,
int id)
: core_intf_(core_intf), hwc_procs_(hwc_procs), type_(type), id_(id), display_intf_(NULL),
flush_(false), output_buffer_(NULL), dump_frame_count_(0), dump_frame_index_(0),
- dump_input_layers_(false) {
+ dump_input_layers_(false), swap_interval_zero_(false), framebuffer_config_(NULL),
+ display_paused_(false), use_metadata_refresh_rate_(false), metadata_refresh_rate_(0) {
}
int HWCDisplay::Init() {
@@ -56,6 +58,20 @@
return -EINVAL;
}
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get("debug.egl.swapinterval", property, "1") > 0) {
+ if (atoi(property) == 0) {
+ swap_interval_zero_ = true;
+ }
+ }
+
+ framebuffer_config_ = new DisplayConfigVariableInfo();
+ if (!framebuffer_config_) {
+ DLOGV("Failed to allocate memory for custom framebuffer config.");
+ core_intf_->DestroyDisplay(display_intf_);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -71,6 +87,8 @@
layer_stack_memory_.raw = NULL;
}
+ delete framebuffer_config_;
+
return 0;
}
@@ -109,10 +127,13 @@
last_power_mode_ = HWC_POWER_MODE_NORMAL;
break;
case HWC_POWER_MODE_DOZE:
- case HWC_POWER_MODE_DOZE_SUSPEND:
state = kStateDoze;
last_power_mode_ = HWC_POWER_MODE_DOZE;
break;
+ case HWC_POWER_MODE_DOZE_SUSPEND:
+ state = kStateDozeSuspend;
+ last_power_mode_ = HWC_POWER_MODE_DOZE_SUSPEND;
+ break;
default:
return -EINVAL;
}
@@ -139,10 +160,15 @@
DisplayError error = kErrorNone;
DisplayConfigVariableInfo variable_config;
- error = display_intf_->GetConfig(config, &variable_config);
- if (error != kErrorNone) {
- DLOGE("GetConfig variable info failed. Error = %d", error);
- return -EINVAL;
+ uint32_t active_config = UINT32(GetActiveConfig());
+ if (IsFrameBufferScaled() && config == active_config) {
+ variable_config = *framebuffer_config_;
+ } else {
+ error = display_intf_->GetConfig(config, &variable_config);
+ if (error != kErrorNone) {
+ DLOGE("GetConfig variable info failed. Error = %d", error);
+ return -EINVAL;
+ }
}
for (int i = 0; attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE; i++) {
@@ -316,6 +342,12 @@
return 0;
}
+ DisplayConfigVariableInfo active_config;
+ uint32_t active_config_index = 0;
+ display_intf_->GetActiveConfig(&active_config_index);
+
+ display_intf_->GetConfig(active_config_index, &active_config);
+
// Configure each layer
for (size_t i = 0; i < num_hw_layers; i++) {
hwc_layer_1_t &hwc_layer = content_list->hwLayers[i];
@@ -325,7 +357,7 @@
LayerBuffer *layer_buffer = layer.input_buffer;
if (pvt_handle) {
- layer_buffer->format = GetSDEFormat(pvt_handle->format, pvt_handle->flags);
+ layer_buffer->format = GetSDMFormat(pvt_handle->format, pvt_handle->flags);
if (layer_buffer->format == kFormatInvalid) {
return -EINVAL;
}
@@ -341,15 +373,26 @@
layer_buffer->flags.secure = true;
}
- // TODO(user) : Initialize it to display refresh rate
- layer.frame_rate = 60;
+ layer.frame_rate = UINT32(active_config.fps);
MetaData_t *meta_data = reinterpret_cast<MetaData_t *>(pvt_handle->base_metadata);
if (meta_data && meta_data->operation & UPDATE_REFRESH_RATE) {
- layer.frame_rate = meta_data->refreshrate;
+ layer.frame_rate = RoundToStandardFPS(meta_data->refreshrate);
+ }
+
+ if (meta_data && meta_data->operation == PP_PARAM_INTERLACED && meta_data->interlaced) {
+ layer_buffer->flags.interlace = true;
+ }
+
+ if (pvt_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_DISPLAY) {
+ layer_buffer->flags.secure_display = true;
}
}
- SetRect(hwc_layer.displayFrame, &layer.dst_rect);
+ hwc_rect_t scaled_display_frame = hwc_layer.displayFrame;
+ ScaleDisplayFrame(&scaled_display_frame);
+ ApplyScanAdjustment(&scaled_display_frame);
+
+ SetRect(scaled_display_frame, &layer.dst_rect);
SetRect(hwc_layer.sourceCropf, &layer.src_rect);
for (size_t j = 0; j < hwc_layer.visibleRegionScreen.numRects; j++) {
SetRect(hwc_layer.visibleRegionScreen.rects[j], &layer.visible_regions.rect[j]);
@@ -393,6 +436,8 @@
bool needs_fb_refresh = NeedsFrameBufferRefresh(content_list);
+ metadata_refresh_rate_ = 0;
+
for (size_t i = 0; i < num_hw_layers; i++) {
hwc_layer_1_t &hwc_layer = content_list->hwLayers[i];
Layer &layer = layer_stack_.layers[i];
@@ -400,6 +445,10 @@
if (composition == kCompositionSDE) {
hwc_layer.hints |= HWC_HINT_CLEAR_FB;
+
+ if (use_metadata_refresh_rate_ && layer.frame_rate > metadata_refresh_rate_) {
+ metadata_refresh_rate_ = layer.frame_rate;
+ }
}
// If current layer does not need frame buffer redraw, then mark it as HWC_OVERLAY
@@ -441,6 +490,11 @@
layer_buffer->planes[0].stride = pvt_handle->width;
}
+ // if swapinterval property is set to 0 then close and reset the acquireFd
+ if (swap_interval_zero_ && hwc_layer.acquireFenceFd >= 0) {
+ close(hwc_layer.acquireFenceFd);
+ hwc_layer.acquireFenceFd = -1;
+ }
layer_buffer->acquire_fence_fd = hwc_layer.acquireFenceFd;
}
@@ -474,11 +528,19 @@
LayerBuffer *layer_buffer = layer_stack_.layers[i].input_buffer;
if (!flush_) {
+ // if swapinterval property is set to 0 then do not update f/w release fences with driver
+ // values
+ if (swap_interval_zero_) {
+ hwc_layer.releaseFenceFd = -1;
+ close(layer_buffer->release_fence_fd);
+ layer_buffer->release_fence_fd = -1;
+ }
+
if (layer.composition != kCompositionGPU) {
hwc_layer.releaseFenceFd = layer_buffer->release_fence_fd;
}
- // During animation on external/virtual display, Display Engine will use the cached
+ // During animation on external/virtual display, SDM will use the cached
// framebuffer layer throughout animation and do not allow framework to do eglswapbuffer on
// framebuffer target. So graphics doesn't close the release fence fd of framebuffer target,
// Hence close the release fencefd of framebuffer target here.
@@ -498,6 +560,11 @@
if (!flush_) {
layer_stack_cache_.animating = layer_stack_.flags.animating;
+ // if swapinterval property is set to 0 then close and reset the list retire fence
+ if (swap_interval_zero_) {
+ close(layer_stack_.retire_fence_fd);
+ layer_stack_.retire_fence_fd = -1;
+ }
content_list->retireFenceFd = layer_stack_.retire_fence_fd;
if (dump_frame_count_) {
@@ -617,11 +684,12 @@
return error;
}
-LayerBufferFormat HWCDisplay::GetSDEFormat(const int32_t &source, const int flags) {
+LayerBufferFormat HWCDisplay::GetSDMFormat(const int32_t &source, const int flags) {
LayerBufferFormat format = kFormatInvalid;
if (flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED) {
switch (source) {
case HAL_PIXEL_FORMAT_RGBA_8888: format = kFormatRGBA8888Ubwc; break;
+ case HAL_PIXEL_FORMAT_RGBX_8888: format = kFormatRGBX8888Ubwc; break;
case HAL_PIXEL_FORMAT_RGB_565: format = kFormatRGB565Ubwc; break;
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
@@ -752,6 +820,8 @@
return "INTERLACE";
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
return "YCbCr_420_SP_VENUS";
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
+ return "YCbCr_420_SP_VENUS_UBWC";
default:
return "Unknown pixel format";
}
@@ -770,5 +840,169 @@
}
}
-} // namespace sde
+int HWCDisplay::SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels) {
+ if (x_pixels <= 0 || y_pixels <= 0) {
+ DLOGV("Unsupported config: x_pixels=%d, y_pixels=%d", x_pixels, y_pixels);
+ return -EINVAL;
+ }
+
+ if (framebuffer_config_->x_pixels == x_pixels && framebuffer_config_->y_pixels == y_pixels) {
+ return 0;
+ }
+
+ DisplayConfigVariableInfo active_config;
+ int active_config_index = GetActiveConfig();
+ DisplayError error = display_intf_->GetConfig(active_config_index, &active_config);
+ if (error != kErrorNone) {
+ DLOGV("GetConfig variable info failed. Error = %d", error);
+ return -EINVAL;
+ }
+
+ if (active_config.x_pixels <= 0 || active_config.y_pixels <= 0) {
+ DLOGV("Invalid panel resolution (%dx%d)", active_config.x_pixels, active_config.y_pixels);
+ return -EINVAL;
+ }
+
+ // Create rects to represent the new source and destination crops
+ LayerRect crop = LayerRect(0, 0, FLOAT(x_pixels), FLOAT(y_pixels));
+ LayerRect dst = LayerRect(0, 0, FLOAT(active_config.x_pixels), FLOAT(active_config.y_pixels));
+ // Set rotate90 to false since this is taken care of during regular composition.
+ bool rotate90 = false;
+ error = display_intf_->IsScalingValid(crop, dst, rotate90);
+ if (error != kErrorNone) {
+ DLOGV("Unsupported resolution: (%dx%d)", x_pixels, y_pixels);
+ return -EINVAL;
+ }
+
+ uint32_t panel_width =
+ UINT32((FLOAT(active_config.x_pixels) * 25.4f) / FLOAT(active_config.x_dpi));
+ uint32_t panel_height =
+ UINT32((FLOAT(active_config.y_pixels) * 25.4f) / FLOAT(active_config.y_dpi));
+ framebuffer_config_->x_pixels = x_pixels;
+ framebuffer_config_->y_pixels = y_pixels;
+ framebuffer_config_->vsync_period_ns = active_config.vsync_period_ns;
+ framebuffer_config_->x_dpi =
+ (FLOAT(framebuffer_config_->x_pixels) * 25.4f) / FLOAT(panel_width);
+ framebuffer_config_->y_dpi =
+ (FLOAT(framebuffer_config_->y_pixels) * 25.4f) / FLOAT(panel_height);
+
+ DLOGI("New framebuffer resolution (%dx%d)", framebuffer_config_->x_pixels,
+ framebuffer_config_->y_pixels);
+
+ return 0;
+}
+
+void HWCDisplay::GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels) {
+ *x_pixels = framebuffer_config_->x_pixels;
+ *y_pixels = framebuffer_config_->y_pixels;
+}
+
+void HWCDisplay::ScaleDisplayFrame(hwc_rect_t *display_frame) {
+ if (!IsFrameBufferScaled()) {
+ return;
+ }
+
+ int active_config_index = GetActiveConfig();
+ DisplayConfigVariableInfo active_config;
+ DisplayError error = display_intf_->GetConfig(active_config_index, &active_config);
+ if (error != kErrorNone) {
+ DLOGE("GetConfig variable info failed. Error = %d", error);
+ return;
+ }
+
+ float custom_x_pixels = FLOAT(framebuffer_config_->x_pixels);
+ float custom_y_pixels = FLOAT(framebuffer_config_->y_pixels);
+ float active_x_pixels = FLOAT(active_config.x_pixels);
+ float active_y_pixels = FLOAT(active_config.y_pixels);
+ float x_pixels_ratio = active_x_pixels / custom_x_pixels;
+ float y_pixels_ratio = active_y_pixels / custom_y_pixels;
+ float layer_width = FLOAT(display_frame->right - display_frame->left);
+ float layer_height = FLOAT(display_frame->bottom - display_frame->top);
+
+ display_frame->left = INT(x_pixels_ratio * FLOAT(display_frame->left));
+ display_frame->top = INT(y_pixels_ratio * FLOAT(display_frame->top));
+ display_frame->right = INT(FLOAT(display_frame->left) + layer_width * x_pixels_ratio);
+ display_frame->bottom = INT(FLOAT(display_frame->top) + layer_height * y_pixels_ratio);
+}
+
+bool HWCDisplay::IsFrameBufferScaled() {
+ if (framebuffer_config_->x_pixels == 0 || framebuffer_config_->y_pixels == 0) {
+ return false;
+ }
+ uint32_t panel_x_pixels = 0;
+ uint32_t panel_y_pixels = 0;
+ GetPanelResolution(&panel_x_pixels, &panel_y_pixels);
+ return (framebuffer_config_->x_pixels != panel_x_pixels) ||
+ (framebuffer_config_->y_pixels != panel_y_pixels);
+}
+
+void HWCDisplay::GetPanelResolution(uint32_t *x_pixels, uint32_t *y_pixels) {
+ DisplayConfigVariableInfo active_config;
+ int active_config_index = GetActiveConfig();
+ DisplayError error = display_intf_->GetConfig(active_config_index, &active_config);
+ if (error != kErrorNone) {
+ DLOGE("GetConfig variable info failed. Error = %d", error);
+ return;
+ }
+ *x_pixels = active_config.x_pixels;
+ *y_pixels = active_config.y_pixels;
+}
+
+int HWCDisplay::SetDisplayStatus(uint32_t display_status) {
+ int status = 0;
+
+ switch (display_status) {
+ case kDisplayStatusResume:
+ display_paused_ = false;
+ case kDisplayStatusOnline:
+ status = SetPowerMode(HWC_POWER_MODE_NORMAL);
+ break;
+ case kDisplayStatusPause:
+ display_paused_ = true;
+ case kDisplayStatusOffline:
+ status = SetPowerMode(HWC_POWER_MODE_OFF);
+ break;
+ default:
+ DLOGW("Invalid display status %d", display_status);
+ return -EINVAL;
+ }
+
+ return status;
+}
+
+void HWCDisplay::MarkLayersForGPUBypass(hwc_display_contents_1_t *content_list) {
+ for (size_t i = 0 ; i < (content_list->numHwLayers - 1); i++) {
+ hwc_layer_1_t *layer = &content_list->hwLayers[i];
+ layer->compositionType = HWC_OVERLAY;
+ }
+}
+
+void HWCDisplay::CloseAcquireFences(hwc_display_contents_1_t *content_list) {
+ for (size_t i = 0; i < content_list->numHwLayers; i++) {
+ if (content_list->hwLayers[i].acquireFenceFd >= 0) {
+ close(content_list->hwLayers[i].acquireFenceFd);
+ content_list->hwLayers[i].acquireFenceFd = -1;
+ }
+ }
+}
+
+uint32_t HWCDisplay::RoundToStandardFPS(uint32_t fps) {
+ static const uint32_t standard_fps[4] = {30, 24, 48, 60};
+
+ int count = INT(sizeof(standard_fps) / sizeof(standard_fps[0]));
+ for (int i = 0; i < count; i++) {
+ if (abs(standard_fps[i] - fps) < 2) {
+ // Most likely used for video, the fps can fluctuate
+ // Ex: b/w 29 and 30 for 30 fps clip
+ return standard_fps[i];
+ }
+ }
+
+ return fps;
+}
+
+void HWCDisplay::ApplyScanAdjustment(hwc_rect_t *display_frame) {
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_display.h b/sdm/libs/hwc/hwc_display.h
similarity index 82%
rename from displayengine/libs/hwc/hwc_display.h
rename to sdm/libs/hwc/hwc_display.h
index 7ef8187..2df0928 100644
--- a/displayengine/libs/hwc/hwc_display.h
+++ b/sdm/libs/hwc/hwc_display.h
@@ -28,7 +28,7 @@
#include <hardware/hwcomposer.h>
#include <core/core_interface.h>
-namespace sde {
+namespace sdm {
class HWCDisplay : public DisplayEventHandler {
public:
@@ -42,14 +42,25 @@
virtual int GetDisplayAttributes(uint32_t config, const uint32_t *attributes, int32_t *values);
virtual int GetActiveConfig();
virtual int SetActiveConfig(int index);
- virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual int SetActiveConfig(hwc_display_contents_1_t *content_list);
+ virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type);
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
virtual uint32_t GetLastPowerMode();
+ virtual int SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels);
+ virtual void GetFrameBufferResolution(uint32_t *x_pixels, uint32_t *y_pixels);
+ virtual void GetPanelResolution(uint32_t *x_pixels, uint32_t *y_pixels);
+ virtual int SetDisplayStatus(uint32_t display_status);
protected:
- // Maximum number of layers supported by display engine.
+ enum DisplayStatus {
+ kDisplayStatusOffline = 0,
+ kDisplayStatusOnline,
+ kDisplayStatusPause,
+ kDisplayStatusResume,
+ };
+
+ // Maximum number of layers supported by display manager.
static const uint32_t kMaxLayerCount = 32;
// Structure to track memory allocation for layer stack (layers, rectangles) object.
@@ -95,10 +106,16 @@
inline void SetComposition(const int32_t &source, int32_t *target);
inline void SetBlending(const int32_t &source, LayerBlending *target);
int SetFormat(const int32_t &source, const int flags, LayerBufferFormat *target);
- LayerBufferFormat GetSDEFormat(const int32_t &source, const int flags);
+ LayerBufferFormat GetSDMFormat(const int32_t &source, const int flags);
void DumpInputBuffers(hwc_display_contents_1_t *content_list);
const char *GetHALPixelFormatString(int format);
const char *GetDisplayString();
+ void ScaleDisplayFrame(hwc_rect_t *display_frame);
+ bool IsFrameBufferScaled();
+ void MarkLayersForGPUBypass(hwc_display_contents_1_t *content_list);
+ void CloseAcquireFences(hwc_display_contents_1_t *content_list);
+ uint32_t RoundToStandardFPS(uint32_t fps);
+ virtual void ApplyScanAdjustment(hwc_rect_t *display_frame);
enum {
INPUT_LAYER_DUMP,
@@ -119,9 +136,14 @@
uint32_t dump_frame_index_;
bool dump_input_layers_;
uint32_t last_power_mode_;
+ bool swap_interval_zero_;
+ DisplayConfigVariableInfo *framebuffer_config_;
+ bool display_paused_;
+ bool use_metadata_refresh_rate_;
+ uint32_t metadata_refresh_rate_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_DISPLAY_H__
diff --git a/displayengine/libs/hwc/hwc_display_external.cpp b/sdm/libs/hwc/hwc_display_external.cpp
similarity index 67%
rename from displayengine/libs/hwc/hwc_display_external.cpp
rename to sdm/libs/hwc/hwc_display_external.cpp
index 2758e3a..52c64d1 100644
--- a/displayengine/libs/hwc/hwc_display_external.cpp
+++ b/sdm/libs/hwc/hwc_display_external.cpp
@@ -27,6 +27,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <cutils/properties.h>
#include <utils/constants.h>
#include "hwc_display_external.h"
@@ -34,12 +35,23 @@
#define __CLASS__ "HWCDisplayExternal"
-namespace sde {
+namespace sdm {
HWCDisplayExternal::HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
: HWCDisplay(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
}
+int HWCDisplayExternal::Init() {
+ int status = 0;
+
+ status = HWCDisplay::Init();
+ if (status != 0) {
+ return status;
+ }
+
+ return status;
+}
+
int HWCDisplayExternal::Prepare(hwc_display_contents_1_t *content_list) {
int status = 0;
@@ -91,5 +103,39 @@
return 0;
}
-} // namespace sde
+void HWCDisplayExternal::ApplyScanAdjustment(hwc_rect_t *display_frame) {
+ if (display_intf_->IsUnderscanSupported()) {
+ return;
+ }
+
+ // Read user defined width and height ratio
+ char property[PROPERTY_VALUE_MAX];
+ property_get("persist.sys.actionsafe.width", property, "0");
+ float width_ratio = FLOAT(atoi(property)) / 100.0f;
+ property_get("persist.sys.actionsafe.height", property, "0");
+ float height_ratio = FLOAT(atoi(property)) / 100.0f;
+
+ if (width_ratio == 0.0f || height_ratio == 0.0f) {
+ return;
+ }
+
+ uint32_t panel_width = 0;
+ uint32_t panel_height = 0;
+ GetPanelResolution(&panel_width, &panel_height);
+
+ if (panel_width == 0 || panel_height == 0) {
+ DLOGV("Invalid panel dimensions (%d, %d)", panel_width, panel_height);
+ return;
+ }
+
+ int x_offset = INT((FLOAT(panel_width) * width_ratio) / 2.0f);
+ int y_offset = INT((FLOAT(panel_height) * height_ratio) / 2.0f);
+
+ display_frame->left = display_frame->left + x_offset;
+ display_frame->top = display_frame->top + y_offset;
+ display_frame->right = display_frame->right - x_offset;
+ display_frame->bottom = display_frame->bottom - y_offset;
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_display_external.h b/sdm/libs/hwc/hwc_display_external.h
similarity index 93%
rename from displayengine/libs/hwc/hwc_display_external.h
rename to sdm/libs/hwc/hwc_display_external.h
index e268621..6d3e229 100644
--- a/displayengine/libs/hwc/hwc_display_external.h
+++ b/sdm/libs/hwc/hwc_display_external.h
@@ -27,17 +27,20 @@
#include "hwc_display.h"
-namespace sde {
+namespace sdm {
class HWCDisplayExternal : public HWCDisplay {
public:
explicit HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+ virtual int Init();
virtual int Prepare(hwc_display_contents_1_t *content_list);
virtual int Commit(hwc_display_contents_1_t *content_list);
virtual int GetDisplayConfigs(uint32_t *configs, size_t *num_configs);
+ private:
+ virtual void ApplyScanAdjustment(hwc_rect_t *display_frame);
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_DISPLAY_EXTERNAL_H__
diff --git a/displayengine/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
similarity index 80%
rename from displayengine/libs/hwc/hwc_display_primary.cpp
rename to sdm/libs/hwc/hwc_display_primary.cpp
index d1cd2d2..53110ca 100644
--- a/displayengine/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -34,7 +34,7 @@
#define __CLASS__ "HWCDisplayPrimary"
-namespace sde {
+namespace sdm {
HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
: HWCDisplay(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY) {
@@ -53,6 +53,10 @@
return status;
}
+ if (use_metadata_refresh_rate_) {
+ SetRefreshRate(metadata_refresh_rate_);
+ }
+
return 0;
}
@@ -82,5 +86,29 @@
return error;
}
-} // namespace sde
+int HWCDisplayPrimary::SetActiveConfig(uint32_t index) {
+ DisplayError error = kErrorNone;
+
+ if (display_intf_) {
+ error = display_intf_->SetActiveConfig(index);
+ }
+
+ return error;
+}
+
+int HWCDisplayPrimary::SetRefreshRate(uint32_t refresh_rate) {
+ DisplayError error = kErrorNone;
+
+ if (display_intf_) {
+ error = display_intf_->SetRefreshRate(refresh_rate);
+ }
+
+ return error;
+}
+
+void HWCDisplayPrimary::SetMetaDataRefreshRateFlag(bool enable) {
+ use_metadata_refresh_rate_ = enable;
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_display_primary.h b/sdm/libs/hwc/hwc_display_primary.h
similarity index 90%
rename from displayengine/libs/hwc/hwc_display_primary.h
rename to sdm/libs/hwc/hwc_display_primary.h
index 5015fff..e862508 100644
--- a/displayengine/libs/hwc/hwc_display_primary.h
+++ b/sdm/libs/hwc/hwc_display_primary.h
@@ -27,7 +27,7 @@
#include "hwc_display.h"
-namespace sde {
+namespace sdm {
class HWCDisplayPrimary : public HWCDisplay {
public:
@@ -35,9 +35,12 @@
virtual int Prepare(hwc_display_contents_1_t *content_list);
virtual int Commit(hwc_display_contents_1_t *content_list);
virtual DisplayError SetDisplayMode(uint32_t mode);
+ virtual int SetActiveConfig(uint32_t index);
+ virtual int SetRefreshRate(uint32_t refresh_rate);
+ virtual void SetMetaDataRefreshRateFlag(bool enable);
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_DISPLAY_PRIMARY_H__
diff --git a/displayengine/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp
similarity index 78%
rename from displayengine/libs/hwc/hwc_display_virtual.cpp
rename to sdm/libs/hwc/hwc_display_virtual.cpp
index 9601e63..d36a171 100644
--- a/displayengine/libs/hwc/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -28,7 +28,6 @@
*/
#include <utils/constants.h>
-#include <gralloc_priv.h>
#include <sync/sync.h>
#include "hwc_display_virtual.h"
@@ -36,7 +35,7 @@
#define __CLASS__ "HWCDisplayVirtual"
-namespace sde {
+namespace sdm {
HWCDisplayVirtual::HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
: HWCDisplay(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL),
@@ -71,6 +70,11 @@
int HWCDisplayVirtual::Prepare(hwc_display_contents_1_t *content_list) {
int status = 0;
+ if (display_paused_) {
+ MarkLayersForGPUBypass(content_list);
+ return status;
+ }
+
status = AllocateLayerStack(content_list);
if (status) {
return status;
@@ -91,6 +95,22 @@
int HWCDisplayVirtual::Commit(hwc_display_contents_1_t *content_list) {
int status = 0;
+ if (display_paused_) {
+ if (content_list->outbufAcquireFenceFd >= 0) {
+ // If we do not handle the frame set retireFenceFd to outbufAcquireFenceFd,
+ // which will make sure the framework waits on it and closes it.
+ content_list->retireFenceFd = dup(content_list->outbufAcquireFenceFd);
+ close(content_list->outbufAcquireFenceFd);
+ content_list->outbufAcquireFenceFd = -1;
+ }
+ CloseAcquireFences(content_list);
+
+ DisplayError error = display_intf_->Flush();
+ if (error != kErrorNone) {
+ DLOGE("Flush failed. Error = %d", error);
+ }
+ return status;
+ }
status = HWCDisplay::CommitLayerStack(content_list);
if (status) {
@@ -119,18 +139,20 @@
int status = 0;
if (output_handle) {
- LayerBufferFormat format = GetSDEFormat(output_handle->format, output_handle->flags);
+ LayerBufferFormat format = GetSDMFormat(output_handle->format, output_handle->flags);
if (format == kFormatInvalid) {
return -EINVAL;
}
- if ((output_handle->width != INT(output_buffer_->width)) ||
- (output_handle->height != INT(output_buffer_->height)) ||
+ int active_width = GetWidth(output_handle);
+ int active_height = GetHeight(output_handle);
+
+ if ((active_width != INT(output_buffer_->width)) ||
+ (active_height!= INT(output_buffer_->height)) ||
(format != output_buffer_->format)) {
DisplayConfigVariableInfo variable_info;
-
- variable_info.x_pixels = output_handle->width;
- variable_info.y_pixels = output_handle->height;
+ variable_info.x_pixels = active_width;
+ variable_info.y_pixels = active_height;
// TODO(user): Need to get the framerate of primary display and update it.
variable_info.fps = 60;
@@ -159,13 +181,13 @@
output_buffer_->acquire_fence_fd = content_list->outbufAcquireFenceFd;
if (output_handle) {
- output_buffer_->format = GetSDEFormat(output_handle->format, output_handle->flags);
+ output_buffer_->format = GetSDMFormat(output_handle->format, output_handle->flags);
if (output_buffer_->format == kFormatInvalid) {
return -EINVAL;
}
- output_buffer_->width = output_handle->width;
- output_buffer_->height = output_handle->height;
+ output_buffer_->width = GetWidth(output_handle);
+ output_buffer_->height = GetHeight(output_handle);
output_buffer_->flags.secure = 0;
output_buffer_->flags.video = 0;
@@ -234,5 +256,23 @@
DLOGI("output_layer_dump_enable %d", dump_output_layer_);
}
-} // namespace sde
+int HWCDisplayVirtual::GetWidth(const private_handle_t* handle) {
+ MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+ if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ return metadata->bufferDim.sliceWidth;
+ }
+
+ return handle->width;
+}
+
+int HWCDisplayVirtual::GetHeight(const private_handle_t* handle) {
+ MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+ if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
+ return metadata->bufferDim.sliceHeight;
+ }
+
+ return handle->height;
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_display_virtual.h b/sdm/libs/hwc/hwc_display_virtual.h
similarity index 92%
rename from displayengine/libs/hwc/hwc_display_virtual.h
rename to sdm/libs/hwc/hwc_display_virtual.h
index 7ac7c22..74285d7 100644
--- a/displayengine/libs/hwc/hwc_display_virtual.h
+++ b/sdm/libs/hwc/hwc_display_virtual.h
@@ -25,9 +25,11 @@
#ifndef __HWC_DISPLAY_VIRTUAL_H__
#define __HWC_DISPLAY_VIRTUAL_H__
+#include <qdMetaData.h>
+#include <gralloc_priv.h>
#include "hwc_display.h"
-namespace sde {
+namespace sdm {
class HWCDisplayVirtual : public HWCDisplay {
public:
@@ -42,11 +44,13 @@
private:
int SetOutputBuffer(hwc_display_contents_1_t *content_list);
void DumpOutputBuffer(hwc_display_contents_1_t *content_list);
+ int GetWidth(const private_handle_t* handle);
+ int GetHeight(const private_handle_t* handle);
bool dump_output_layer_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_DISPLAY_VIRTUAL_H__
diff --git a/displayengine/libs/hwc/hwc_session.cpp b/sdm/libs/hwc/hwc_session.cpp
similarity index 78%
rename from displayengine/libs/hwc/hwc_session.cpp
rename to sdm/libs/hwc/hwc_session.cpp
index 652d7e0..e5ffda9 100644
--- a/displayengine/libs/hwc/hwc_session.cpp
+++ b/sdm/libs/hwc/hwc_session.cpp
@@ -28,14 +28,18 @@
*/
#include <core/dump_interface.h>
+#include <core/buffer_allocator.h>
#include <utils/constants.h>
#include <utils/String16.h>
+#include <cutils/properties.h>
#include <hardware_legacy/uevent.h>
#include <sys/resource.h>
#include <sys/prctl.h>
#include <binder/Parcel.h>
#include <QService.h>
-#include <core/buffer_allocator.h>
+#include <gr.h>
+#include <gralloc_priv.h>
+#include <display_config.h>
#include "hwc_buffer_allocator.h"
#include "hwc_buffer_sync_handler.h"
@@ -47,7 +51,7 @@
#define HWC_UEVENT_SWITCH_HDMI "change@/devices/virtual/switch/hdmi"
#define HWC_UEVENT_GRAPHICS_FB0 "change@/devices/virtual/graphics/fb0"
-static sde::HWCSession::HWCModuleMethods g_hwc_module_methods;
+static sdm::HWCSession::HWCModuleMethods g_hwc_module_methods;
hwc_module_t HAL_MODULE_INFO_SYM = {
common: {
@@ -63,7 +67,7 @@
}
};
-namespace sde {
+namespace sdm {
Locker HWCSession::locker_;
bool HWCSession::reset_panel_ = false;
@@ -153,6 +157,8 @@
return -errno;
}
+ SetFrameBufferResolution(HWC_DISPLAY_PRIMARY, NULL);
+
return 0;
}
@@ -240,10 +246,13 @@
}
break;
case HWC_DISPLAY_VIRTUAL:
+ if (hwc_session->display_external_) {
+ break;
+ }
if (hwc_session->ValidateContentList(content_list)) {
- hwc_session->CreateVirtualDisplay(hwc_session, content_list);
+ hwc_session->CreateVirtualDisplay(content_list);
} else {
- hwc_session->DestroyVirtualDisplay(hwc_session);
+ hwc_session->DestroyVirtualDisplay();
}
if (hwc_session->display_virtual_) {
@@ -284,6 +293,21 @@
}
break;
case HWC_DISPLAY_VIRTUAL:
+ if (hwc_session->display_external_) {
+ if (content_list) {
+ for (size_t i = 0; i < content_list->numHwLayers; i++) {
+ if (content_list->hwLayers[i].acquireFenceFd >= 0) {
+ close(content_list->hwLayers[i].acquireFenceFd);
+ content_list->hwLayers[i].acquireFenceFd = -1;
+ }
+ }
+ if (content_list->outbufAcquireFenceFd >= 0) {
+ close(content_list->outbufAcquireFenceFd);
+ content_list->outbufAcquireFenceFd = -1;
+ }
+ content_list->retireFenceFd = -1;
+ }
+ }
if (hwc_session->display_virtual_) {
hwc_session->display_virtual_->Commit(content_list);
}
@@ -514,49 +538,50 @@
return (content_list && content_list->numHwLayers > 0 && content_list->outbuf);
}
-int HWCSession::CreateVirtualDisplay(HWCSession *hwc_session,
- hwc_display_contents_1_t *content_list) {
+int HWCSession::CreateVirtualDisplay(hwc_display_contents_1_t *content_list) {
int status = 0;
- if (!hwc_session->display_virtual_) {
+ if (!display_virtual_) {
// Create virtual display device
- hwc_session->display_virtual_ = new HWCDisplayVirtual(hwc_session->core_intf_,
- &hwc_session->hwc_procs_);
- if (!hwc_session->display_virtual_) {
+ display_virtual_ = new HWCDisplayVirtual(core_intf_, &hwc_procs_);
+ if (!display_virtual_) {
// This is not catastrophic. Leave a warning message for now.
DLOGW("Virtual Display creation failed");
return -ENOMEM;
}
- status = hwc_session->display_virtual_->Init();
+ status = display_virtual_->Init();
if (status) {
goto CleanupOnError;
}
- status = hwc_session->display_virtual_->SetPowerMode(HWC_POWER_MODE_NORMAL);
+ status = display_virtual_->SetPowerMode(HWC_POWER_MODE_NORMAL);
if (status) {
goto CleanupOnError;
}
}
- if (hwc_session->display_virtual_) {
- status = hwc_session->display_virtual_->SetActiveConfig(content_list);
+ if (display_virtual_) {
+ SetFrameBufferResolution(HWC_DISPLAY_VIRTUAL, content_list);
+ status = display_virtual_->SetActiveConfig(content_list);
}
return status;
CleanupOnError:
- return hwc_session->DestroyVirtualDisplay(hwc_session);
+ return DestroyVirtualDisplay();
}
-int HWCSession::DestroyVirtualDisplay(HWCSession *hwc_session) {
+int HWCSession::DestroyVirtualDisplay() {
int status = 0;
- if (hwc_session->display_virtual_) {
- status = hwc_session->display_virtual_->Deinit();
+ if (display_virtual_) {
+ status = display_virtual_->Deinit();
if (!status) {
- delete hwc_session->display_virtual_;
- hwc_session->display_virtual_ = NULL;
+ delete display_virtual_;
+ display_virtual_ = NULL;
+ // Signal the HotPlug thread to continue with the external display connection
+ locker_.Signal();
}
}
@@ -600,6 +625,13 @@
case qService::IQService::SET_DISPLAY_MODE:
status = SetDisplayMode(input_parcel);
break;
+ case qService::IQService::SET_SECONDARY_DISPLAY_STATUS:
+ status = SetSecondaryDisplayStatus(input_parcel);
+ break;
+
+ case qService::IQService::CONFIGURE_DYN_REFRESH_RATE:
+ status = ConfigureRefreshRate(input_parcel);
+ break;
default:
DLOGW("QService command = %d is not supported", command);
@@ -609,6 +641,55 @@
return status;
}
+android::status_t HWCSession::SetSecondaryDisplayStatus(const android::Parcel *input_parcel) {
+ uint32_t display_id = UINT32(input_parcel->readInt32());
+ uint32_t display_status = UINT32(input_parcel->readInt32());
+ HWCDisplay *display = NULL;
+
+ DLOGI("Display %d Status %d", display_id, display_status);
+ switch (display_id) {
+ case HWC_DISPLAY_EXTERNAL:
+ display = display_external_;
+ break;
+ case HWC_DISPLAY_VIRTUAL:
+ display = display_virtual_;
+ break;
+ default:
+ DLOGW("Not supported for display %d", display_id);
+ return -EINVAL;
+ }
+
+ return display->SetDisplayStatus(display_status);
+}
+
+android::status_t HWCSession::ConfigureRefreshRate(const android::Parcel *input_parcel) {
+ uint32_t operation = UINT32(input_parcel->readInt32());
+
+ switch (operation) {
+ case qdutils::DISABLE_METADATA_DYN_REFRESH_RATE:
+ display_primary_->SetMetaDataRefreshRateFlag(false);
+ break;
+
+ case qdutils::ENABLE_METADATA_DYN_REFRESH_RATE:
+ display_primary_->SetMetaDataRefreshRateFlag(true);
+ break;
+
+ case qdutils::SET_BINDER_DYN_REFRESH_RATE:
+ {
+ uint32_t refresh_rate = UINT32(input_parcel->readInt32());
+
+ display_primary_->SetRefreshRate(refresh_rate);
+ break;
+ }
+
+ default:
+ DLOGW("Invalid operation %d", operation);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
android::status_t HWCSession::SetDisplayMode(const android::Parcel *input_parcel) {
DisplayError error = kErrorNone;
uint32_t mode = UINT32(input_parcel->readInt32());
@@ -706,8 +787,7 @@
case qService::IQService::DEBUG_ROTATOR:
HWCDebugHandler::DebugResources(enable);
HWCDebugHandler::DebugDriverConfig(enable);
- HWCDebugHandler::DebugBufferManager(enable);
- HWCDebugHandler::DebugOfflineCtrl(enable);
+ HWCDebugHandler::DebugRotator(enable);
break;
default:
@@ -754,8 +834,9 @@
if (hwc_procs_) {
reset_panel_ = true;
hwc_procs_->invalidate(hwc_procs_);
- } else
+ } else {
DLOGW("Ignore resetpanel - hwc_proc not registered");
+ }
}
}
}
@@ -783,19 +864,19 @@
DLOGI("Powering off primary");
status = display_primary_->SetPowerMode(HWC_POWER_MODE_OFF);
if (status) {
- DLOGE("power-off on primary failed with error = %d",status);
+ DLOGE("power-off on primary failed with error = %d", status);
}
DLOGI("Restoring power mode on primary");
uint32_t mode = display_primary_->GetLastPowerMode();
status = display_primary_->SetPowerMode(mode);
if (status) {
- DLOGE("Setting power mode = %d on primary failed with error = %d", mode,status);
+ DLOGE("Setting power mode = %d on primary failed with error = %d", mode, status);
}
status = display_primary_->EventControl(HWC_EVENT_VSYNC, 1);
if (status) {
- DLOGE("enabling vsync failed for primary with error = %d",status);
+ DLOGE("enabling vsync failed for primary with error = %d", status);
}
reset_panel_ = false;
@@ -809,6 +890,14 @@
if (connected) {
SEQUENCE_WAIT_SCOPE_LOCK(locker_);
+ if (display_virtual_) {
+ // Wait for the virtual display to tear down
+ int status = locker_.WaitFinite(kExternalConnectionTimeoutMs);
+ if (status != 0) {
+ DLOGE("Timed out while waiting for virtual display to tear down.");
+ return -1;
+ }
+ }
if (display_external_) {
DLOGE("HDMI already connected");
return -1;
@@ -824,6 +913,7 @@
display_external_ = NULL;
return -1;
}
+ SetFrameBufferResolution(HWC_DISPLAY_EXTERNAL, NULL);
} else {
SEQUENCE_WAIT_SCOPE_LOCK(locker_);
if (!display_external_) {
@@ -843,5 +933,72 @@
return 0;
}
-} // namespace sde
+void HWCSession::SetFrameBufferResolution(int disp, hwc_display_contents_1_t *content_list) {
+ char property[PROPERTY_VALUE_MAX];
+ uint32_t primary_width = 0;
+ uint32_t primary_height = 0;
+
+ switch (disp) {
+ case HWC_DISPLAY_PRIMARY:
+ {
+ display_primary_->GetPanelResolution(&primary_width, &primary_height);
+ if (property_get("debug.hwc.fbsize", property, NULL) > 0) {
+ char *yptr = strcasestr(property, "x");
+ primary_width = atoi(property);
+ primary_height = atoi(yptr + 1);
+ }
+ display_primary_->SetFrameBufferResolution(primary_width, primary_height);
+ break;
+ }
+
+ case HWC_DISPLAY_EXTERNAL:
+ {
+ uint32_t external_width = 0;
+ uint32_t external_height = 0;
+ display_external_->GetPanelResolution(&external_width, &external_height);
+
+ if (property_get("sys.hwc.mdp_downscale_enabled", property, "false") &&
+ !strcmp(property, "true")) {
+ display_primary_->GetFrameBufferResolution(&primary_width, &primary_height);
+ uint32_t primary_area = primary_width * primary_height;
+ uint32_t external_area = external_width * external_height;
+
+ if (primary_area > external_area) {
+ if (primary_height > primary_width) {
+ Swap(primary_height, primary_width);
+ }
+ AdjustSourceResolution(primary_width, primary_height,
+ &external_width, &external_height);
+ }
+ }
+ display_external_->SetFrameBufferResolution(external_width, external_height);
+ break;
+ }
+
+ case HWC_DISPLAY_VIRTUAL:
+ {
+ if (ValidateContentList(content_list)) {
+ const private_handle_t *output_handle =
+ static_cast<const private_handle_t *>(content_list->outbuf);
+ int virtual_width = 0;
+ int virtual_height = 0;
+ getBufferSizeAndDimensions(output_handle->width, output_handle->height, output_handle->format,
+ virtual_width, virtual_height);
+ display_virtual_->SetFrameBufferResolution(virtual_width, virtual_height);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+void HWCSession::AdjustSourceResolution(uint32_t dst_width, uint32_t dst_height,
+ uint32_t *src_width, uint32_t *src_height) {
+ *src_height = (dst_width * (*src_height)) / (*src_width);
+ *src_width = dst_width;
+}
+
+} // namespace sdm
diff --git a/displayengine/libs/hwc/hwc_session.h b/sdm/libs/hwc/hwc_session.h
similarity index 88%
rename from displayengine/libs/hwc/hwc_session.h
rename to sdm/libs/hwc/hwc_session.h
index dffa864..15b762c 100644
--- a/displayengine/libs/hwc/hwc_session.h
+++ b/sdm/libs/hwc/hwc_session.h
@@ -34,7 +34,7 @@
#include "hwc_display_external.h"
#include "hwc_display_virtual.h"
-namespace sde {
+namespace sdm {
class HWCSession : hwc_composer_device_1_t, CoreEventHandler, public qClient::BnQClient {
public:
@@ -49,6 +49,8 @@
int Deinit();
private:
+ static const int kExternalConnectionTimeoutMs = 500;
+
// hwc methods
static int Open(const hw_module_t *module, const char* name, hw_device_t **device);
static int Close(hw_device_t *device);
@@ -75,8 +77,8 @@
int HotPlugHandler(bool connected);
void ResetPanel();
bool ValidateContentList(hwc_display_contents_1_t *content_list);
- int CreateVirtualDisplay(HWCSession *hwc_session, hwc_display_contents_1_t *content_list);
- int DestroyVirtualDisplay(HWCSession *hwc_session);
+ int CreateVirtualDisplay(hwc_display_contents_1_t *content_list);
+ int DestroyVirtualDisplay();
// CoreEventHandler methods
virtual DisplayError Hotplug(const CoreEventHotplug &hotplug);
@@ -88,6 +90,11 @@
void SetFrameDumpConfig(const android::Parcel *input_parcel);
android::status_t SetMaxMixerStages(const android::Parcel *input_parcel);
android::status_t SetDisplayMode(const android::Parcel *input_parcel);
+ android::status_t SetSecondaryDisplayStatus(const android::Parcel *input_parcel);
+ void SetFrameBufferResolution(int disp, hwc_display_contents_1_t *content_list);
+ void AdjustSourceResolution(uint32_t dst_width, uint32_t dst_height,
+ uint32_t *src_width, uint32_t *src_height);
+ android::status_t ConfigureRefreshRate(const android::Parcel *input_parcel);
static Locker locker_;
CoreInterface *core_intf_;
@@ -103,7 +110,7 @@
HWCBufferSyncHandler *buffer_sync_handler_;
};
-} // namespace sde
+} // namespace sdm
#endif // __HWC_SESSION_H__
diff --git a/displayengine/libs/utils/Android.mk b/sdm/libs/utils/Android.mk
similarity index 68%
rename from displayengine/libs/utils/Android.mk
rename to sdm/libs/utils/Android.mk
index 264c40a..57c2088 100644
--- a/displayengine/libs/utils/Android.mk
+++ b/sdm/libs/utils/Android.mk
@@ -1,12 +1,12 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := libsdeutils
+LOCAL_MODULE := libsdmutils
LOCAL_MODULE_TAGS := optional
-LOCAL_C_INCLUDES := hardware/qcom/display/displayengine/include/
+LOCAL_C_INCLUDES := hardware/qcom/display/sdm/include/
LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \
-Wconversion -Wall -Werror \
- -DLOG_TAG=\"SDE\"
+ -DLOG_TAG=\"SDM\"
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_SRC_FILES := debug_android.cpp rect.cpp
diff --git a/displayengine/libs/utils/debug_android.cpp b/sdm/libs/utils/debug_android.cpp
similarity index 91%
rename from displayengine/libs/utils/debug_android.cpp
rename to sdm/libs/utils/debug_android.cpp
index 77c82b0..f57d04d 100644
--- a/displayengine/libs/utils/debug_android.cpp
+++ b/sdm/libs/utils/debug_android.cpp
@@ -33,7 +33,7 @@
#include <cutils/log.h>
#include <cutils/properties.h>
-namespace sde {
+namespace sdm {
Debug Debug::debug_;
@@ -73,7 +73,7 @@
bool Debug::IsRotatorDownScaleDisabled() {
char property[PROPERTY_VALUE_MAX];
- if (property_get("sde.disable_rotator_downscaling", property, NULL) > 0) {
+ if (property_get("sdm.disable_rotator_downscaling", property, NULL) > 0) {
return (atoi(property) ? 0 : false, true);
}
@@ -82,7 +82,7 @@
bool Debug::IsDecimationDisabled() {
char property[PROPERTY_VALUE_MAX];
- if (property_get("sde.disable_decimation", property, NULL) > 0) {
+ if (property_get("sdm.disable_decimation", property, NULL) > 0) {
return (atoi(property) ? 0 : false, true);
}
@@ -90,14 +90,14 @@
}
// This property serves to disable/enable partial update
-bool Debug::IsPartialUpdate() {
+bool Debug::IsPartialUpdateEnabled() {
char property[PROPERTY_VALUE_MAX];
- if (property_get("sde.hwc.partial_update", property, NULL) > 0) {
+ if (property_get("sdm.hwc.partial_update", property, NULL) > 0) {
return (atoi(property) ? 1 : true, false);
}
return false;
}
-} // namespace sde
+} // namespace sdm
diff --git a/displayengine/libs/utils/rect.cpp b/sdm/libs/utils/rect.cpp
similarity index 97%
rename from displayengine/libs/utils/rect.cpp
rename to sdm/libs/utils/rect.cpp
index 9b05951..9edc4f4 100644
--- a/displayengine/libs/utils/rect.cpp
+++ b/sdm/libs/utils/rect.cpp
@@ -33,7 +33,7 @@
#define __CLASS__ "RectUtils"
-namespace sde {
+namespace sdm {
bool IsValid(const LayerRect &rect) {
return ((rect.bottom > rect.top) && (rect.right > rect.left));
@@ -122,11 +122,11 @@
return LayerRect();
}
- if(!IsValid(rect1)){
+ if (!IsValid(rect1)) {
return rect2;
}
- if(!IsValid(rect2)){
+ if (!IsValid(rect2)) {
return rect1;
}
@@ -138,5 +138,5 @@
return res;
}
-} // namespace sde
+} // namespace sdm