• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __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 
33 #include <map>
34 #include <mutex>
35 #include <string>
36 #include <vector>
37 
38 #include "hw_interface.h"
39 #include "comp_manager.h"
40 #include "color_manager.h"
41 #include "hw_events_interface.h"
42 
43 namespace sdm {
44 
45 using std::recursive_mutex;
46 using std::lock_guard;
47 
48 class RotatorCtrl;
49 class HWInfoInterface;
50 
51 class DisplayBase : public DisplayInterface, DumpImpl {
52  public:
53   DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
54               HWDeviceType hw_device_type, BufferSyncHandler *buffer_sync_handler,
55               CompManager *comp_manager, RotatorInterface *rotator_intf,
56               HWInfoInterface *hw_info_intf);
~DisplayBase()57   virtual ~DisplayBase() { }
58   virtual DisplayError Init();
59   virtual DisplayError Deinit();
60   DisplayError Prepare(LayerStack *layer_stack);
61   DisplayError Commit(LayerStack *layer_stack);
62   virtual DisplayError Flush();
63   virtual DisplayError GetDisplayState(DisplayState *state);
64   virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count);
65   virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info);
66   virtual DisplayError GetActiveConfig(uint32_t *index);
67   virtual DisplayError GetVSyncState(bool *enabled);
68   virtual DisplayError SetDisplayState(DisplayState state);
69   virtual DisplayError SetActiveConfig(uint32_t index);
SetActiveConfig(DisplayConfigVariableInfo * variable_info)70   virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
71     return kErrorNotSupported;
72   }
73   virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages);
ControlPartialUpdate(bool enable,uint32_t * pending)74   virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) {
75     return kErrorNotSupported;
76   }
DisablePartialUpdateOneFrame()77   virtual DisplayError DisablePartialUpdateOneFrame() {
78     return kErrorNotSupported;
79   }
SetDisplayMode(uint32_t mode)80   virtual DisplayError SetDisplayMode(uint32_t mode) {
81     return kErrorNotSupported;
82   }
IsUnderscanSupported()83   virtual bool IsUnderscanSupported() {
84     return false;
85   }
SetPanelBrightness(int level)86   virtual DisplayError SetPanelBrightness(int level) {
87     return kErrorNotSupported;
88   }
OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level)89   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) {
90     return kErrorNotSupported;
91   }
92   virtual DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload,
93                                             PPDisplayAPIPayload *out_payload,
94                                             PPPendingParams *pending_action);
95   virtual DisplayError GetColorModeCount(uint32_t *mode_count);
96   virtual DisplayError GetColorModes(uint32_t *mode_count, std::vector<std::string> *color_modes);
97   virtual DisplayError SetColorMode(const std::string &color_mode);
98   virtual DisplayError SetColorTransform(const uint32_t length, const double *color_transform);
99   virtual DisplayError ApplyDefaultDisplayMode(void);
100   virtual DisplayError SetCursorPosition(int x, int y);
101   virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate);
GetPanelBrightness(int * level)102   virtual DisplayError GetPanelBrightness(int *level) {
103     return kErrorNotSupported;
104   }
105   virtual DisplayError SetVSyncState(bool enable);
SetIdleTimeoutMs(uint32_t timeout_ms)106   virtual void SetIdleTimeoutMs(uint32_t timeout_ms) {}
107   virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height);
108   virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
109   virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info);
110   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info);
111   virtual DisplayError SetDetailEnhancerData(const DisplayDetailEnhancerData &de_data);
112 
113  protected:
114   // DumpImpl method
115   void AppendDump(char *buffer, uint32_t length);
116 
117   bool IsRotationRequired(HWLayers *hw_layers);
118   const char *GetName(const LayerComposition &composition);
119   DisplayError ValidateGPUTarget(LayerStack *layer_stack);
120   DisplayError ReconfigureDisplay();
121   bool NeedsMixerReconfiguration(LayerStack *layer_stack, uint32_t *new_mixer_width,
122                                  uint32_t *new_mixer_height);
123   DisplayError ReconfigureMixer(uint32_t width, uint32_t height);
124 
125   recursive_mutex recursive_mutex_;
126   DisplayType display_type_;
127   DisplayEventHandler *event_handler_ = NULL;
128   HWDeviceType hw_device_type_;
129   HWInterface *hw_intf_ = NULL;
130   HWPanelInfo hw_panel_info_;
131   BufferSyncHandler *buffer_sync_handler_ = NULL;
132   CompManager *comp_manager_ = NULL;
133   RotatorInterface *rotator_intf_ = NULL;
134   DisplayState state_ = kStateOff;
135   bool active_ = false;
136   Handle hw_device_ = 0;
137   Handle display_comp_ctx_ = 0;
138   Handle display_rotator_ctx_ = 0;
139   HWLayers hw_layers_;
140   bool pending_commit_ = false;
141   bool vsync_enable_ = false;
142   uint32_t max_mixer_stages_ = 0;
143   HWInfoInterface *hw_info_intf_ = NULL;
144   ColorManagerProxy *color_mgr_ = NULL;  // each display object owns its ColorManagerProxy
145   bool partial_update_control_ = true;
146   HWEventsInterface *hw_events_intf_ = NULL;
147   bool disable_pu_one_frame_ = false;
148   uint32_t num_color_modes_ = 0;
149   std::vector<SDEDisplayMode> color_modes_;
150   typedef std::map<std::string, SDEDisplayMode *> ColorModeMap;
151   ColorModeMap color_mode_map_ = {};
152   HWDisplayAttributes display_attributes_ = {};
153   HWMixerAttributes mixer_attributes_ = {};
154   DisplayConfigVariableInfo fb_config_ = {};
155 
156  private:
157   // Unused
GetConfig(DisplayConfigFixedInfo * variable_info)158   virtual DisplayError GetConfig(DisplayConfigFixedInfo *variable_info) {
159     return kErrorNone;
160   }
161 };
162 
163 }  // namespace sdm
164 
165 #endif  // __DISPLAY_BASE_H__
166