1 /*
2 * Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *     * Redistributions of source code must retain the above copyright
8 *       notice, this list of conditions and the following disclaimer.
9 *     * Redistributions in binary form must reproduce the above
10 *       copyright notice, this list of conditions and the following
11 *       disclaimer in the documentation and/or other materials provided
12 *       with the distribution.
13 *     * Neither the name of The Linux Foundation nor the names of its
14 *       contributors may be used to endorse or promote products derived
15 *       from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 
30 #ifndef __DISPLAY_NULL_H__
31 #define __DISPLAY_NULL_H__
32 
33 #include <core/display_interface.h>
34 #include <string>
35 #include <vector>
36 
37 namespace sdm {
38 
39 using std::string;
40 using std::vector;
41 
42 #define MAKE_NO_OP(virtual_method_signature) \
43       virtual DisplayError virtual_method_signature { return kErrorNone; }
44 
45 class DisplayNull : public DisplayInterface {
46  public:
~DisplayNull()47   virtual ~DisplayNull() { }
48   virtual DisplayError Init();
49   virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
50 
51   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info);
52   virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *disp_attr);
53   virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info);
54   virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate);
55   virtual DisplayError GetActiveConfig(uint32_t *config);
56   virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count);
57   virtual DisplayError Prepare(LayerStack *layer_stack);
IsPrimaryDisplay()58   virtual bool IsPrimaryDisplay() { return true; }
IsUnderscanSupported()59   virtual bool IsUnderscanSupported() { return true; }
SetIdleTimeoutMs(uint32_t active_ms)60   virtual void SetIdleTimeoutMs(uint32_t active_ms) { }
61   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
62                                                     uint8_t *out_data);
CheckResourceState()63   virtual bool CheckResourceState() { return false; }
Dump()64   virtual string Dump() { return ""; }
IsSupportSsppTonemap()65   virtual bool IsSupportSsppTonemap() { return false; }
CanSkipValidate()66   virtual bool CanSkipValidate() { return true; }
GameEnhanceSupported()67   virtual bool GameEnhanceSupported() { return false; }
68 
69   MAKE_NO_OP(TeardownConcurrentWriteback(void))
70   MAKE_NO_OP(Commit(LayerStack *))
71   MAKE_NO_OP(GetDisplayState(DisplayState *))
72   MAKE_NO_OP(SetDisplayState(DisplayState, bool, shared_ptr<Fence> *))
73   MAKE_NO_OP(SetFrameBufferConfig(const DisplayConfigVariableInfo &))
74   MAKE_NO_OP(Flush(LayerStack *))
75   MAKE_NO_OP(GetVSyncState(bool *))
76   MAKE_NO_OP(SetActiveConfig(uint32_t))
77   MAKE_NO_OP(SetActiveConfig(DisplayConfigVariableInfo *))
78   MAKE_NO_OP(SetMaxMixerStages(uint32_t))
79   MAKE_NO_OP(ControlPartialUpdate(bool, uint32_t *))
80   MAKE_NO_OP(DisablePartialUpdateOneFrame())
81   MAKE_NO_OP(SetDisplayMode(uint32_t))
82   MAKE_NO_OP(SetPanelBrightness(float))
83   MAKE_NO_OP(CachePanelBrightness(int))
84   MAKE_NO_OP(OnMinHdcpEncryptionLevelChange(uint32_t))
85   MAKE_NO_OP(ColorSVCRequestRoute(const PPDisplayAPIPayload &, PPDisplayAPIPayload *,
86                                   PPPendingParams *))
87   MAKE_NO_OP(GetColorModeCount(uint32_t *))
88   MAKE_NO_OP(GetColorModes(uint32_t *, vector<string> *))
89   MAKE_NO_OP(GetColorModeAttr(const string &, AttrVal *))
90   MAKE_NO_OP(SetColorMode(const string &))
91   MAKE_NO_OP(SetColorModeById(int32_t))
92   MAKE_NO_OP(GetColorModeName(int32_t, string *))
93   MAKE_NO_OP(SetColorTransform(const uint32_t, const double *))
94   MAKE_NO_OP(GetDefaultColorMode(string *))
95   MAKE_NO_OP(ApplyDefaultDisplayMode())
96   MAKE_NO_OP(SetCursorPosition(int, int))
97   MAKE_NO_OP(SetRefreshRate(uint32_t, bool, bool))
98   MAKE_NO_OP(GetPanelBrightness(float *))
99   MAKE_NO_OP(GetPanelMaxBrightness(uint32_t *))
100   MAKE_NO_OP(GetRefreshRate(uint32_t *))
101   MAKE_NO_OP(SetVSyncState(bool))
102   MAKE_NO_OP(SetMixerResolution(uint32_t, uint32_t))
103   MAKE_NO_OP(SetDetailEnhancerData(const DisplayDetailEnhancerData &))
104   MAKE_NO_OP(GetDisplayPort(DisplayPort *))
105   MAKE_NO_OP(GetDisplayId(int32_t *))
106   MAKE_NO_OP(GetDisplayType(DisplayType *))
107   MAKE_NO_OP(SetCompositionState(LayerComposition, bool))
108   MAKE_NO_OP(GetClientTargetSupport(uint32_t, uint32_t, LayerBufferFormat,
109                                     const ColorMetaData &))
110   MAKE_NO_OP(HandleSecureEvent(SecureEvent, LayerStack *))
111   MAKE_NO_OP(SetQSyncMode(QSyncMode))
112   MAKE_NO_OP(ControlIdlePowerCollapse(bool, bool))
113   MAKE_NO_OP(SetDisplayDppsAdROI(void *))
114   MAKE_NO_OP(SetDynamicDSIClock(uint64_t bit_clk_rate))
115   MAKE_NO_OP(GetDynamicDSIClock(uint64_t *bit_clk_rate))
116   MAKE_NO_OP(GetSupportedDSIClock(vector<uint64_t> *bitclk_rates))
117   MAKE_NO_OP(SetFrameTriggerMode(FrameTriggerMode))
118   MAKE_NO_OP(SetPanelLuminanceAttributes(float min_lum, float max_lum))
119   MAKE_NO_OP(SetBLScale(uint32_t))
120   MAKE_NO_OP(GetQSyncMode(QSyncMode *))
121   MAKE_NO_OP(colorSamplingOn());
122   MAKE_NO_OP(colorSamplingOff());
123   MAKE_NO_OP(SetDisplayElapseTime(uint64_t))
MAKE_NO_OP(ClearLUTs ())124   MAKE_NO_OP(ClearLUTs())
125 
126   void SetActive(bool active) { active_ = active; }
IsActive()127   bool IsActive() { return active_; }
128 
129  private:
130   bool active_ = false;
131 
132  protected:
133   DisplayConfigVariableInfo default_variable_config_ = {};
134   DisplayConfigFixedInfo default_fixed_config_ = {};
135   // 1920x1080 60fps panel of name Null Display with PnPID QCM
136   // Contains many 'don't-care' fields and valid checksum bytes
137   const vector<uint8_t> edid_{
138     0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x44, 0x6D, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
139     0x1B, 0x10, 0x01, 0x03, 0x80, 0x50, 0x2D, 0x78, 0x0A, 0x0D, 0xC9, 0xA0, 0x57, 0x47, 0x98, 0x27,
140     0x12, 0x48, 0x4C, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
141     0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C,
142     0x45, 0x00, 0x50, 0x1D, 0x74, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x4E, 0x75, 0x6C,
143     0x6C, 0x20, 0x44, 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD1
146   };
147 };
148 
149 class DisplayNullExternal : public DisplayNull {
150  public:
151   virtual DisplayError Commit(LayerStack *layer_stack);
152   virtual DisplayError GetDisplayState(DisplayState *state);
153   virtual DisplayError SetDisplayState(DisplayState state, bool teardown,
154                                        shared_ptr<Fence> *release_fence);
155   virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info);
156   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info);
157   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
158                                                     uint8_t *out_data);
159  private:
160   DisplayState state_ = kStateOff;
161   DisplayConfigVariableInfo fb_config_ = {};
162 };
163 
164 }  // namespace sdm
165 
166 #endif  // __DISPLAY_NULL_H__
167