1 /* 2 * Copyright (c) 2014 - 2016, 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 33 #include "strategy.h" 34 #include "resource_default.h" 35 #include "hw_interface.h" 36 #include "dump_impl.h" 37 38 namespace sdm { 39 40 class CompManager : public DumpImpl { 41 public: 42 DisplayError Init(const HWResourceInfo &hw_res_info_, ExtensionInterface *extension_intf, 43 BufferSyncHandler *buffer_sync_handler); 44 DisplayError Deinit(); 45 DisplayError RegisterDisplay(DisplayType type, const HWDisplayAttributes &display_attributes, 46 const HWPanelInfo &hw_panel_info, 47 const HWMixerAttributes &mixer_attributes, 48 const DisplayConfigVariableInfo &fb_config, Handle *res_mgr_hnd); 49 DisplayError UnregisterDisplay(Handle res_mgr_hnd); 50 DisplayError ReconfigureDisplay(Handle display_ctx, const HWDisplayAttributes &display_attributes, 51 const HWPanelInfo &hw_panel_info, 52 const HWMixerAttributes &mixer_attributes, 53 const DisplayConfigVariableInfo &fb_config); 54 void PrePrepare(Handle display_ctx, HWLayers *hw_layers); 55 DisplayError Prepare(Handle display_ctx, HWLayers *hw_layers); 56 DisplayError PostPrepare(Handle display_ctx, HWLayers *hw_layers); 57 DisplayError ReConfigure(Handle display_ctx, HWLayers *hw_layers); 58 DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers); 59 void Purge(Handle display_ctx); 60 void ProcessIdleTimeout(Handle display_ctx); 61 void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level); 62 DisplayError SetMaxMixerStages(Handle display_ctx, uint32_t max_mixer_stages); 63 void ControlPartialUpdate(Handle display_ctx, bool enable); 64 DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90); 65 DisplayError ValidateCursorPosition(Handle display_ctx, HWLayers *hw_layers, int x, int y); 66 bool SupportLayerAsCursor(Handle display_ctx, HWLayers *hw_layers); 67 bool CanSetIdleTimeout(Handle display_ctx); 68 DisplayError SetMaxBandwidthMode(HWBwModes mode); 69 DisplayError GetScaleLutConfig(HWScaleLutInfo *lut_info); 70 DisplayError SetDetailEnhancerData(Handle display_ctx, const DisplayDetailEnhancerData &de_data); 71 72 // DumpImpl method 73 virtual void AppendDump(char *buffer, uint32_t length); 74 75 private: 76 static const int kMaxThermalLevel = 3; 77 78 void PrepareStrategyConstraints(Handle display_ctx, HWLayers *hw_layers); 79 80 struct DisplayCompositionContext { 81 Strategy *strategy = NULL; 82 StrategyConstraints constraints; 83 Handle display_resource_ctx = NULL; 84 DisplayType display_type = kPrimary; 85 uint32_t max_strategies = 0; 86 uint32_t remaining_strategies = 0; 87 bool idle_fallback = false; 88 bool fallback_ = false; 89 uint32_t partial_update_enable = true; 90 // Using primary panel flag of hw panel to configure Constraints. We do not need other hw 91 // panel parameters for now. 92 bool is_primary_panel = false; 93 }; 94 95 Locker locker_; 96 ResourceInterface *resource_intf_ = NULL; 97 ResourceDefault resource_default_; 98 std::bitset<kDisplayMax> registered_displays_; // Bit mask of registered displays 99 std::bitset<kDisplayMax> configured_displays_; // Bit mask of sucessfully configured displays 100 bool safe_mode_ = false; // Flag to notify all displays to be in resource crunch 101 // mode, where strategy manager chooses the best strategy 102 // that uses optimal number of pipes for each display 103 HWResourceInfo hw_res_info_; 104 ExtensionInterface *extension_intf_ = NULL; 105 uint32_t max_layers_ = kMaxSDELayers; 106 }; 107 108 } // namespace sdm 109 110 #endif // __COMP_MANAGER_H__ 111 112