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