1 /* 2 * Copyright (c) 2014 - 2019, The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, are permitted 5 * provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright notice, this list of 7 * conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided 10 * with the distribution. 11 * * Neither the name of The Linux Foundation nor the names of its contributors may be used to 12 * endorse or promote products derived from this software without specific prior written 13 * permission. 14 * 15 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25 #ifndef __COMP_MANAGER_H__ 26 #define __COMP_MANAGER_H__ 27 28 #include <core/display_interface.h> 29 #include <private/extension_interface.h> 30 #include <utils/locker.h> 31 #include <bitset> 32 #include <set> 33 #include <string> 34 #include <vector> 35 #include <string> 36 37 #include "strategy.h" 38 #include "resource_default.h" 39 #include "hw_interface.h" 40 41 namespace sdm { 42 43 class CompManager { 44 public: 45 DisplayError Init(const HWResourceInfo &hw_res_info_, ExtensionInterface *extension_intf, 46 BufferAllocator *buffer_allocator, BufferSyncHandler *buffer_sync_handler, 47 SocketHandler *socket_handler); 48 DisplayError Deinit(); 49 DisplayError RegisterDisplay(int32_t display_id, DisplayType type, 50 const HWDisplayAttributes &display_attributes, 51 const HWPanelInfo &hw_panel_info, 52 const HWMixerAttributes &mixer_attributes, 53 const DisplayConfigVariableInfo &fb_config, Handle *display_ctx, 54 uint32_t *default_clk_hz); 55 DisplayError UnregisterDisplay(Handle display_ctx); 56 DisplayError ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &display_attributes, 57 const HWPanelInfo &hw_panel_info, 58 const HWMixerAttributes &mixer_attributes, 59 const DisplayConfigVariableInfo &fb_config, 60 uint32_t *default_clk_hz); 61 void PrePrepare(Handle display_ctx, HWLayers *hw_layers); 62 DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers); 63 DisplayError Commit(Handle display_ctx, HWLayers *hw_layers); 64 DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers); 65 DisplayError ReConfigure(Handle display_ctx, HWLayers *hw_layers); 66 DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers); 67 void Purge(Handle display_ctx); 68 DisplayError SetIdleTimeoutMs(Handle display_ctx, uint32_t active_ms); 69 void ProcessIdleTimeout(Handle display_ctx); 70 void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level); 71 void ProcessIdlePowerCollapse(Handle display_ctx); 72 DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages); 73 void ControlPartialUpdate(Handle display_ctx, bool enable); 74 DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90); 75 DisplayError ValidateAndSetCursorPosition(Handle display_ctx, HWLayers *hw_layers, int x, int y); 76 bool SetDisplayState(Handle display_ctx, DisplayState state, int sync_handle); 77 DisplayError SetMaxBandwidthMode(HWBwModes mode); 78 DisplayError GetScaleLutConfig(HWScaleLutInfo *lut_info); 79 DisplayError SetDetailEnhancerData(Handle display_ctx, const DisplayDetailEnhancerData &de_data); 80 DisplayError SetCompositionState(Handle display_ctx, LayerComposition composition_type, 81 bool enable); 82 DisplayError ControlDpps(bool enable); 83 DisplayError SetColorModesInfo(Handle display_ctx, 84 const std::vector<PrimariesTransfer> &colormodes_cs); 85 DisplayError SetBlendSpace(Handle display_ctx, const PrimariesTransfer &blend_space); 86 void HandleSecureEvent(Handle display_ctx, SecureEvent secure_event); SetSafeMode(bool enable)87 void SetSafeMode(bool enable) { safe_mode_ = enable; } IsSafeMode()88 bool IsSafeMode() { return safe_mode_; } 89 void GenerateROI(Handle display_ctx, HWLayers *hw_layers); 90 bool CanSkipValidate(Handle display_ctx); 91 DisplayError CheckEnforceSplit(Handle comp_handle, uint32_t new_refresh_rate); 92 93 private: 94 static const int kMaxThermalLevel = 3; 95 static const int kSafeModeThreshold = 4; 96 97 void PrepareStrategyConstraints(Handle display_ctx, HWLayers *hw_layers); 98 void UpdateStrategyConstraints(bool is_primary, bool disabled); 99 std::string StringDisplayList(const std::set<int32_t> &displays); 100 101 struct DisplayCompositionContext { 102 Strategy *strategy = NULL; 103 StrategyConstraints constraints; 104 Handle display_resource_ctx = NULL; 105 int32_t display_id = -1; 106 DisplayType display_type = kBuiltIn; 107 uint32_t max_strategies = 0; 108 uint32_t remaining_strategies = 0; 109 bool idle_fallback = false; 110 bool thermal_fallback_ = false; 111 // Using primary panel flag of hw panel to configure Constraints. We do not need other hw 112 // panel parameters for now. 113 bool is_primary_panel = false; 114 PUConstraints pu_constraints = {}; 115 DisplayConfigVariableInfo fb_config = {}; 116 }; 117 118 Locker locker_; 119 ResourceInterface *resource_intf_ = NULL; 120 std::set<int32_t> registered_displays_; // List of registered displays 121 std::set<int32_t> configured_displays_; // List of sucessfully configured displays 122 std::set<int32_t> powered_on_displays_; // List of powered on displays. 123 bool safe_mode_ = false; // Flag to notify all displays to be in resource crunch 124 // mode, where strategy manager chooses the best strategy 125 // that uses optimal number of pipes for each display 126 HWResourceInfo hw_res_info_; 127 BufferAllocator *buffer_allocator_ = NULL; 128 ExtensionInterface *extension_intf_ = NULL; 129 uint32_t max_layers_ = kMaxSDELayers; 130 uint32_t max_sde_ext_layers_ = 0; 131 uint32_t max_sde_builtin_layers_ = 2; 132 DppsControlInterface *dpps_ctrl_intf_ = NULL; 133 }; 134 135 } // namespace sdm 136 137 #endif // __COMP_MANAGER_H__ 138 139