1 /* 2 * Copyright (c) 2014 - 2015, 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 __DISPLAY_BASE_H__ 26 #define __DISPLAY_BASE_H__ 27 28 #include <core/display_interface.h> 29 #include <private/strategy_interface.h> 30 #include <private/rotator_interface.h> 31 #include <private/color_interface.h> 32 #include <utils/locker.h> 33 34 #include "hw_interface.h" 35 #include "comp_manager.h" 36 #include "color_manager.h" 37 38 namespace sdm { 39 40 class RotatorCtrl; 41 class HWInfoInterface; 42 43 class DisplayBase : public DisplayInterface { 44 public: 45 DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler, 46 HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler, 47 CompManager *comp_manager, RotatorInterface *rotator_intf, 48 HWInfoInterface *hw_info_intf); ~DisplayBase()49 virtual ~DisplayBase() { } 50 virtual DisplayError Init(); 51 virtual DisplayError Deinit(); 52 virtual DisplayError Prepare(LayerStack *layer_stack); 53 virtual DisplayError Commit(LayerStack *layer_stack); 54 virtual DisplayError Flush(); 55 virtual DisplayError GetDisplayState(DisplayState *state); 56 virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count); 57 virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info); 58 virtual DisplayError GetActiveConfig(uint32_t *index); 59 virtual DisplayError GetVSyncState(bool *enabled); 60 virtual DisplayError SetDisplayState(DisplayState state); 61 virtual DisplayError SetActiveConfig(uint32_t index); 62 virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages); 63 virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending); 64 virtual DisplayError SetDisplayMode(uint32_t mode); 65 virtual DisplayError IsScalingValid(const LayerRect &crop, const LayerRect &dst, bool rotate90); 66 virtual bool IsUnderscanSupported(); 67 virtual DisplayError SetPanelBrightness(int level); 68 virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level); 69 virtual DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload, 70 PPDisplayAPIPayload *out_payload, 71 PPPendingParams *pending_action); 72 virtual DisplayError ApplyDefaultDisplayMode(void); 73 virtual DisplayError SetCursorPosition(int x, int y); 74 virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate); 75 virtual DisplayError GetPanelBrightness(int *level); 76 77 protected: 78 // DumpImpl method 79 void AppendDump(char *buffer, uint32_t length); 80 81 bool IsRotationRequired(HWLayers *hw_layers); 82 const char *GetName(const LayerComposition &composition); 83 const char *GetName(const LayerBufferFormat &format); 84 DisplayError ValidateGPUTarget(LayerStack *layer_stack); 85 86 DisplayType display_type_; 87 DisplayEventHandler *event_handler_ = NULL; 88 HWDeviceType hw_device_type_; 89 HWInterface *hw_intf_ = NULL; 90 HWPanelInfo hw_panel_info_; 91 BufferSyncHandler *buffer_sync_handler_ = NULL; 92 CompManager *comp_manager_ = NULL; 93 RotatorInterface *rotator_intf_ = NULL; 94 DisplayState state_ = kStateOff; 95 bool active_ = false; 96 Handle hw_device_ = 0; 97 Handle display_comp_ctx_ = 0; 98 Handle display_rotator_ctx_ = 0; 99 HWLayers hw_layers_; 100 bool pending_commit_ = false; 101 bool vsync_enable_ = false; 102 bool underscan_supported_ = false; 103 uint32_t max_mixer_stages_ = 0; 104 HWInfoInterface *hw_info_intf_ = NULL; 105 ColorManagerProxy *color_mgr_ = NULL; // each display object owns its ColorManagerProxy 106 bool partial_update_control_ = true; 107 108 private: 109 // Unused GetConfig(DisplayConfigFixedInfo * variable_info)110 virtual DisplayError GetConfig(DisplayConfigFixedInfo *variable_info) { 111 return kErrorNone; 112 } 113 }; 114 115 } // namespace sdm 116 117 #endif // __DISPLAY_BASE_H__ 118