blob: 7b4838a103d59370cceeb681223b430f8b3d476d [file] [log] [blame]
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +05301/*
2* Copyright (c) 2020 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 __CONFIG_DEFS_H__
31#define __CONFIG_DEFS_H__
32
33#include <vector>
34#include <string>
35
36// #defines specifying the API level supported
37// Client can use these API level #ifdefs in their implementation to call the
38// corresponding DisplayConfig API independent of the underlying DisplayConfig
39// implementation being present. When this ifdef gets enabled in this header, the
40// client code will automatically get compiled.
41#define DISPLAY_CONFIG_API_LEVEL_0
42
43namespace DisplayConfig {
44
45// enum definitions
46enum class DisplayType : int {
47 kInvalid,
48 kPrimary,
49 kExternal,
50 kVirtual,
51};
52
53enum class ExternalStatus : int {
54 kInvalid,
55 kOffline,
56 kOnline,
57 kPause,
58 kResume,
59};
60
61enum class DynRefreshRateOp : int {
62 kInvalid,
63 kDisableMetadata,
64 kEnableMetadata,
65 kSetBinder,
66};
67
68enum class DisplayPortType : int {
69 kInvalid,
70 kDefault,
71 kDsi,
72 kDtv,
73 kWriteback,
74 kLvds,
75 kEdp,
76 kDp,
77};
78
79enum class PowerMode : int {
80 kOff,
81 kDoze,
82 kOn,
83 kDozeSuspend,
84};
85
86enum class QsyncMode : int {
87 kNone,
88 kWaitForFencesOneFrame,
89 kWaitForFencesEachFrame,
90 kWaitForCommitEachFrame,
91};
92
93// Input and Output Params structures
94struct Attributes {
95 uint32_t vsync_period = 0;
96 uint32_t x_res = 0;
97 uint32_t y_res = 0;
98 float x_dpi = 0;
99 float y_dpi = 0;
100 DisplayPortType panel_type = DisplayPortType::kDefault;
101 bool is_yuv = 0;
102};
103
104struct HDRCapsParams {
105 std::vector<int> supported_hdr_types = {};
106 float max_luminance = 0;
107 float max_avg_luminance = 0;
108 float min_luminance = 0;
109};
110
111struct StatusParams {
112 DisplayType dpy = DisplayType::kInvalid;
113 ExternalStatus status = ExternalStatus::kInvalid;
114};
115
116struct DynRefreshRateParams {
117 DynRefreshRateOp op = DynRefreshRateOp::kInvalid;
118 uint32_t refresh_rate = 0;
119};
120
121struct ConfigParams {
122 DisplayType dpy = DisplayType::kInvalid;
123 uint32_t config = 0;
124};
125
126struct AttributesParams {
127 uint32_t config_index = 0;
128 DisplayType dpy = DisplayType::kInvalid;
129};
130
131struct MinHdcpEncLevelChangedParams {
132 DisplayType dpy = DisplayType::kInvalid;
133 uint32_t min_enc_level = 0;
134};
135
136struct PartialUpdateParams {
137 DisplayType dpy = DisplayType::kInvalid;
138 bool enable = 0;
139};
140
141struct AnimationParams {
142 uint64_t display_id = 0;
143 bool animating = 0;
144};
145
146struct IdlePcParams {
147 bool enable = 0;
148 bool synchronous = 0;
149};
150
151struct DppsAdRoiParams {
152 uint32_t display_id = 0;
153 uint32_t h_start = 0;
154 uint32_t h_end = 0;
155 uint32_t v_start = 0;
156 uint32_t v_end = 0;
157 uint32_t factor_in = 0;
158 uint32_t factor_out = 0;
159};
160
161struct PowerModeParams {
162 uint32_t disp_id = 0;
163 PowerMode power_mode = PowerMode::kOff;
164};
165
166struct LayerMaskParams {
167 uint32_t disp_id = 0;
168 uint64_t layer_id = 0;
169};
170
171struct PanelLumAttrParams {
172 uint32_t disp_id = 0;
173 float min_lum = 0;
174 float max_lum = 0;
175};
176
177struct Rect {
178 uint32_t left = 0;
179 uint32_t top = 0;
180 uint32_t right = 0;
181 uint32_t bottom = 0;
182};
183
184struct CwbBufferParams {
185 uint32_t disp_id = 0;
186 Rect rect;
187 bool post_processed = 0;
188};
189
190struct DsiClkParams {
191 uint32_t disp_id = 0;
192 uint64_t bit_clk = 0;
193};
194
195struct QsyncModeParams {
196 uint32_t disp_id = 0;
197 QsyncMode mode = QsyncMode::kNone;
198};
199
200struct SmartPanelCfgParams {
201 uint32_t disp_id = 0;
202 uint32_t config_id = 0;
203};
204
205struct VdsParams {
206 uint32_t width = 0;
207 uint32_t height = 0;
208 int format = 0;
209};
210
211struct RotatorFormatParams {
212 int hal_format = 0;
213 bool ubwc = 0;
214};
215
216struct QsyncCallbackParams {
217 bool qsync_enabled = 0;
218 int refresh_rate = 0;
219 int qsync_refresh_rate = 0;
220};
221
222/* Callback Interface */
223class ConfigCallback {
224 public:
225 virtual void NotifyCWBBufferDone(int error, const native_handle_t *buffer) { }
226 virtual void NotifyQsyncChange(bool qsync_enabled, int refresh_rate, int qsync_refresh_rate) { }
227
228 protected:
229 virtual ~ConfigCallback() { }
230};
231
232#define DEFAULT_RET { return -EINVAL; }
233
234/* Config Interface */
235class ConfigInterface {
236 public:
237 virtual int IsDisplayConnected(DisplayType dpy, bool *connected) DEFAULT_RET
238 virtual int SetDisplayStatus(DisplayType dpy, ExternalStatus status) DEFAULT_RET
239 virtual int ConfigureDynRefreshRate(DynRefreshRateOp op, uint32_t refresh_rate) DEFAULT_RET
240 virtual int GetConfigCount(DisplayType dpy, uint32_t *count) DEFAULT_RET
241 virtual int GetActiveConfig(DisplayType dpy, uint32_t *config) DEFAULT_RET
242 virtual int SetActiveConfig(DisplayType dpy, uint32_t config) DEFAULT_RET
243 virtual int GetDisplayAttributes(uint32_t config_index, DisplayType dpy,
244 Attributes *attributes) DEFAULT_RET
245 virtual int SetPanelBrightness(uint32_t level) DEFAULT_RET
246 virtual int GetPanelBrightness(uint32_t *level) DEFAULT_RET
247 virtual int MinHdcpEncryptionLevelChanged(DisplayType dpy, uint32_t min_enc_level) DEFAULT_RET
248 virtual int RefreshScreen() DEFAULT_RET
249 virtual int ControlPartialUpdate(DisplayType dpy, bool enable) DEFAULT_RET
250 virtual int ToggleScreenUpdate(bool on) DEFAULT_RET
251 virtual int SetIdleTimeout(uint32_t value) DEFAULT_RET
252 virtual int GetHDRCapabilities(DisplayType dpy, HDRCapsParams *caps) DEFAULT_RET
253 virtual int SetCameraLaunchStatus(uint32_t on) DEFAULT_RET
254 virtual int DisplayBWTransactionPending(bool *status) DEFAULT_RET
255 virtual int SetDisplayAnimating(uint64_t display_id, bool animating) DEFAULT_RET
256 virtual int ControlIdlePowerCollapse(bool enable, bool synchronous) DEFAULT_RET
257 virtual int GetWriteBackCapabilities(bool *is_wb_ubwc_supported) DEFAULT_RET
258 virtual int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
259 uint32_t v_start, uint32_t v_end, uint32_t factor_in,
260 uint32_t factor_out) DEFAULT_RET
261 virtual int UpdateVSyncSourceOnPowerModeOff() DEFAULT_RET
262 virtual int UpdateVSyncSourceOnPowerModeDoze() DEFAULT_RET
263 virtual int SetPowerMode(uint32_t disp_id, PowerMode power_mode) DEFAULT_RET
264 virtual int IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
265 virtual int IsHDRSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
266 virtual int IsWCGSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
267 virtual int SetLayerAsMask(uint32_t disp_id, uint64_t layer_id) DEFAULT_RET
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530268 virtual int GetDebugProperty(const std::string prop_name, std::string *value) DEFAULT_RET
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530269 virtual int GetActiveBuiltinDisplayAttributes(Attributes *attr) DEFAULT_RET
270 virtual int SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum,
271 float max_lum) DEFAULT_RET
272 virtual int IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin) DEFAULT_RET
273 virtual int IsAsyncVDSCreationSupported(bool *supported) DEFAULT_RET
274 virtual int CreateVirtualDisplay(uint32_t width, uint32_t height, int format) DEFAULT_RET
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530275 virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks) DEFAULT_RET
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530276 virtual int GetDSIClk(uint32_t disp_id, uint64_t *bit_clk) DEFAULT_RET
277 virtual int SetDSIClk(uint32_t disp_id, uint64_t bit_clk) DEFAULT_RET
278 virtual int SetCWBOutputBuffer(uint32_t disp_id, const Rect rect, bool post_processed,
279 const native_handle_t *buffer) DEFAULT_RET
280 virtual int SetQsyncMode(uint32_t disp_id, QsyncMode mode) DEFAULT_RET
281 virtual int IsSmartPanelConfig(uint32_t disp_id, uint32_t config_id, bool *is_smart) DEFAULT_RET
282 virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported) DEFAULT_RET
283 virtual int ControlQsyncCallback(bool enable) DEFAULT_RET
284
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530285 // deprecated APIs
286 virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET
287 virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> bit_clks) DEFAULT_RET
288
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530289 protected:
290 virtual ~ConfigInterface() { }
291};
292
293} // namespace DisplayConfig
294
295#endif // __CONFIG_DEFS_H__