1 /* 2 * Copyright (c) 2014 - 2018, 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 36 #include "strategy.h" 37 #include "resource_default.h" 38 #include "hw_interface.h" 39 40 namespace sdm { 41 42 class CompManager { 43 public: 44 DisplayError Init(const HWResourceInfo &hw_res_info_, ExtensionInterface *extension_intf, 45 BufferAllocator *buffer_allocator, BufferSyncHandler *buffer_sync_handler, 46 SocketHandler *socket_handler); 47 DisplayError Deinit(); 48 DisplayError RegisterDisplay(int32_t display_id, DisplayType type, 49 const HWDisplayAttributes &display_attributes, 50 const HWPanelInfo &hw_panel_info, 51 const HWMixerAttributes &mixer_attributes, 52 const DisplayConfigVariableInfo &fb_config, Handle *display_ctx, 53 uint32_t *default_clk_hz); 54 DisplayError UnregisterDisplay(Handle display_ctx); 55 DisplayError ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &display_attributes, 56 const HWPanelInfo &hw_panel_info, 57 const HWMixerAttributes &mixer_attributes, 58 const DisplayConfigVariableInfo &fb_config, 59 uint32_t *default_clk_hz); 60 void PrePrepare(Handle display_ctx, HWLayers *hw_layers); 61 DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers); 62 DisplayError Commit(Handle display_ctx, HWLayers *hw_layers); 63 DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers); 64 DisplayError ReConfigure(Handle display_ctx, HWLayers *hw_layers); 65 DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers); 66 void Purge(Handle display_ctx); 67 DisplayError SetIdleTimeoutMs(Handle display_ctx, uint32_t active_ms); 68 void ProcessIdleTimeout(Handle display_ctx); 69 void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level); 70 void ProcessIdlePowerCollapse(Handle display_ctx); 71 DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages); 72 void ControlPartialUpdate(Handle display_ctx, bool enable); 73 DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90); 74 DisplayError ValidateAndSetCursorPosition(Handle display_ctx, HWLayers *hw_layers, int x, int y); 75 bool SetDisplayState(Handle display_ctx, DisplayState state); 76 DisplayError SetMaxBandwidthMode(HWBwModes mode); 77 DisplayError GetScaleLutConfig(HWScaleLutInfo *lut_info); 78 DisplayError SetDetailEnhancerData(Handle display_ctx, const DisplayDetailEnhancerData &de_data); 79 DisplayError SetCompositionState(Handle display_ctx, LayerComposition composition_type, 80 bool enable); 81 DisplayError ControlDpps(bool enable); 82 DisplayError SetColorModesInfo(Handle display_ctx, 83 const std::vector<PrimariesTransfer> &colormodes_cs); 84 DisplayError SetBlendSpace(Handle display_ctx, const PrimariesTransfer &blend_space); 85 void HandleSecureEvent(Handle display_ctx, SecureEvent secure_event); SetSafeMode(bool enable)86 void SetSafeMode(bool enable) { safe_mode_ = enable; } IsSafeMode()87 bool IsSafeMode() { return safe_mode_; } 88 void GenerateROI(Handle display_ctx, HWLayers *hw_layers); 89 90 private: 91 static const int kMaxThermalLevel = 3; 92 static const int kSafeModeThreshold = 4; 93 94 void PrepareStrategyConstraints(Handle display_ctx, HWLayers *hw_layers); 95 void UpdateStrategyConstraints(bool is_primary, bool disabled); 96 std::string StringDisplayList(const std::set<int32_t> &displays); 97 98 struct DisplayCompositionContext { 99 Strategy *strategy = NULL; 100 StrategyConstraints constraints; 101 Handle display_resource_ctx = NULL; 102 int32_t display_id = -1; 103 DisplayType display_type = kBuiltIn; 104 uint32_t max_strategies = 0; 105 uint32_t remaining_strategies = 0; 106 bool idle_fallback = false; 107 bool thermal_fallback_ = false; 108 // Using primary panel flag of hw panel to configure Constraints. We do not need other hw 109 // panel parameters for now. 110 bool is_primary_panel = false; 111 PUConstraints pu_constraints = {}; 112 DisplayConfigVariableInfo fb_config = {}; 113 }; 114 115 Locker locker_; 116 ResourceInterface *resource_intf_ = NULL; 117 std::set<int32_t> registered_displays_; // List of registered displays 118 std::set<int32_t> configured_displays_; // List of sucessfully configured displays 119 std::set<int32_t> powered_on_displays_; // List of powered on displays. 120 bool safe_mode_ = false; // Flag to notify all displays to be in resource crunch 121 // mode, where strategy manager chooses the best strategy 122 // that uses optimal number of pipes for each display 123 HWResourceInfo hw_res_info_; 124 BufferAllocator *buffer_allocator_ = NULL; 125 ExtensionInterface *extension_intf_ = NULL; 126 uint32_t max_layers_ = kMaxSDELayers; 127 uint32_t max_sde_ext_layers_ = 0; 128 uint32_t max_sde_builtin_layers_ = 2; 129 DppsControlInterface *dpps_ctrl_intf_ = NULL; 130 }; 131 132 } // namespace sdm 133 134 #endif // __COMP_MANAGER_H__ 135 136