blob: c4181b80135e571704973d4b4664ba8a2f615d90 [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,
Ramkumar Radhakrishnan4e1cfa22020-03-19 21:47:40 -070051 kBuiltIn2,
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +053052};
53
54enum class ExternalStatus : int {
55 kInvalid,
56 kOffline,
57 kOnline,
58 kPause,
59 kResume,
60};
61
62enum class DynRefreshRateOp : int {
63 kInvalid,
64 kDisableMetadata,
65 kEnableMetadata,
66 kSetBinder,
67};
68
69enum class DisplayPortType : int {
70 kInvalid,
71 kDefault,
72 kDsi,
73 kDtv,
74 kWriteback,
75 kLvds,
76 kEdp,
77 kDp,
78};
79
80enum class PowerMode : int {
81 kOff,
82 kDoze,
83 kOn,
84 kDozeSuspend,
85};
86
87enum class QsyncMode : int {
88 kNone,
89 kWaitForFencesOneFrame,
90 kWaitForFencesEachFrame,
91 kWaitForCommitEachFrame,
92};
93
Ramkumar Radhakrishnan4e1cfa22020-03-19 21:47:40 -070094enum class TUIEventType : int {
95 kNone,
96 kPrepareTUITransition,
97 kStartTUITransition,
98 kEndTUITransition,
99};
100
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530101// Input and Output Params structures
102struct Attributes {
103 uint32_t vsync_period = 0;
104 uint32_t x_res = 0;
105 uint32_t y_res = 0;
106 float x_dpi = 0;
107 float y_dpi = 0;
108 DisplayPortType panel_type = DisplayPortType::kDefault;
109 bool is_yuv = 0;
110};
111
112struct HDRCapsParams {
113 std::vector<int> supported_hdr_types = {};
114 float max_luminance = 0;
115 float max_avg_luminance = 0;
116 float min_luminance = 0;
117};
118
119struct StatusParams {
120 DisplayType dpy = DisplayType::kInvalid;
121 ExternalStatus status = ExternalStatus::kInvalid;
122};
123
124struct DynRefreshRateParams {
125 DynRefreshRateOp op = DynRefreshRateOp::kInvalid;
126 uint32_t refresh_rate = 0;
127};
128
129struct ConfigParams {
130 DisplayType dpy = DisplayType::kInvalid;
131 uint32_t config = 0;
132};
133
134struct AttributesParams {
135 uint32_t config_index = 0;
136 DisplayType dpy = DisplayType::kInvalid;
137};
138
139struct MinHdcpEncLevelChangedParams {
140 DisplayType dpy = DisplayType::kInvalid;
141 uint32_t min_enc_level = 0;
142};
143
144struct PartialUpdateParams {
145 DisplayType dpy = DisplayType::kInvalid;
146 bool enable = 0;
147};
148
149struct AnimationParams {
150 uint64_t display_id = 0;
151 bool animating = 0;
152};
153
154struct IdlePcParams {
155 bool enable = 0;
156 bool synchronous = 0;
157};
158
159struct DppsAdRoiParams {
160 uint32_t display_id = 0;
161 uint32_t h_start = 0;
162 uint32_t h_end = 0;
163 uint32_t v_start = 0;
164 uint32_t v_end = 0;
165 uint32_t factor_in = 0;
166 uint32_t factor_out = 0;
167};
168
169struct PowerModeParams {
170 uint32_t disp_id = 0;
171 PowerMode power_mode = PowerMode::kOff;
172};
173
174struct LayerMaskParams {
175 uint32_t disp_id = 0;
176 uint64_t layer_id = 0;
177};
178
179struct PanelLumAttrParams {
180 uint32_t disp_id = 0;
181 float min_lum = 0;
182 float max_lum = 0;
183};
184
185struct Rect {
186 uint32_t left = 0;
187 uint32_t top = 0;
188 uint32_t right = 0;
189 uint32_t bottom = 0;
190};
191
192struct CwbBufferParams {
193 uint32_t disp_id = 0;
194 Rect rect;
195 bool post_processed = 0;
196};
197
198struct DsiClkParams {
199 uint32_t disp_id = 0;
200 uint64_t bit_clk = 0;
201};
202
203struct QsyncModeParams {
204 uint32_t disp_id = 0;
205 QsyncMode mode = QsyncMode::kNone;
206};
207
208struct SmartPanelCfgParams {
209 uint32_t disp_id = 0;
210 uint32_t config_id = 0;
211};
212
213struct VdsParams {
214 uint32_t width = 0;
215 uint32_t height = 0;
216 int format = 0;
217};
218
219struct RotatorFormatParams {
220 int hal_format = 0;
221 bool ubwc = 0;
222};
223
224struct QsyncCallbackParams {
225 bool qsync_enabled = 0;
226 int refresh_rate = 0;
227 int qsync_refresh_rate = 0;
228};
229
Ramkumar Radhakrishnan4e1cfa22020-03-19 21:47:40 -0700230struct TUIEventParams {
231 DisplayType dpy = DisplayType::kInvalid;
232 TUIEventType tui_event_type = TUIEventType::kNone;
233};
234
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530235/* Callback Interface */
236class ConfigCallback {
237 public:
238 virtual void NotifyCWBBufferDone(int error, const native_handle_t *buffer) { }
239 virtual void NotifyQsyncChange(bool qsync_enabled, int refresh_rate, int qsync_refresh_rate) { }
240
241 protected:
242 virtual ~ConfigCallback() { }
243};
244
245#define DEFAULT_RET { return -EINVAL; }
246
247/* Config Interface */
248class ConfigInterface {
249 public:
250 virtual int IsDisplayConnected(DisplayType dpy, bool *connected) DEFAULT_RET
251 virtual int SetDisplayStatus(DisplayType dpy, ExternalStatus status) DEFAULT_RET
252 virtual int ConfigureDynRefreshRate(DynRefreshRateOp op, uint32_t refresh_rate) DEFAULT_RET
253 virtual int GetConfigCount(DisplayType dpy, uint32_t *count) DEFAULT_RET
254 virtual int GetActiveConfig(DisplayType dpy, uint32_t *config) DEFAULT_RET
255 virtual int SetActiveConfig(DisplayType dpy, uint32_t config) DEFAULT_RET
256 virtual int GetDisplayAttributes(uint32_t config_index, DisplayType dpy,
257 Attributes *attributes) DEFAULT_RET
258 virtual int SetPanelBrightness(uint32_t level) DEFAULT_RET
259 virtual int GetPanelBrightness(uint32_t *level) DEFAULT_RET
260 virtual int MinHdcpEncryptionLevelChanged(DisplayType dpy, uint32_t min_enc_level) DEFAULT_RET
261 virtual int RefreshScreen() DEFAULT_RET
262 virtual int ControlPartialUpdate(DisplayType dpy, bool enable) DEFAULT_RET
263 virtual int ToggleScreenUpdate(bool on) DEFAULT_RET
264 virtual int SetIdleTimeout(uint32_t value) DEFAULT_RET
265 virtual int GetHDRCapabilities(DisplayType dpy, HDRCapsParams *caps) DEFAULT_RET
266 virtual int SetCameraLaunchStatus(uint32_t on) DEFAULT_RET
267 virtual int DisplayBWTransactionPending(bool *status) DEFAULT_RET
268 virtual int SetDisplayAnimating(uint64_t display_id, bool animating) DEFAULT_RET
269 virtual int ControlIdlePowerCollapse(bool enable, bool synchronous) DEFAULT_RET
270 virtual int GetWriteBackCapabilities(bool *is_wb_ubwc_supported) DEFAULT_RET
271 virtual int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
272 uint32_t v_start, uint32_t v_end, uint32_t factor_in,
273 uint32_t factor_out) DEFAULT_RET
274 virtual int UpdateVSyncSourceOnPowerModeOff() DEFAULT_RET
275 virtual int UpdateVSyncSourceOnPowerModeDoze() DEFAULT_RET
276 virtual int SetPowerMode(uint32_t disp_id, PowerMode power_mode) DEFAULT_RET
277 virtual int IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
278 virtual int IsHDRSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
279 virtual int IsWCGSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
280 virtual int SetLayerAsMask(uint32_t disp_id, uint64_t layer_id) DEFAULT_RET
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530281 virtual int GetDebugProperty(const std::string prop_name, std::string *value) DEFAULT_RET
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530282 virtual int GetActiveBuiltinDisplayAttributes(Attributes *attr) DEFAULT_RET
283 virtual int SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum,
284 float max_lum) DEFAULT_RET
285 virtual int IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin) DEFAULT_RET
286 virtual int IsAsyncVDSCreationSupported(bool *supported) DEFAULT_RET
287 virtual int CreateVirtualDisplay(uint32_t width, uint32_t height, int format) DEFAULT_RET
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530288 virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks) DEFAULT_RET
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530289 virtual int GetDSIClk(uint32_t disp_id, uint64_t *bit_clk) DEFAULT_RET
290 virtual int SetDSIClk(uint32_t disp_id, uint64_t bit_clk) DEFAULT_RET
291 virtual int SetCWBOutputBuffer(uint32_t disp_id, const Rect rect, bool post_processed,
292 const native_handle_t *buffer) DEFAULT_RET
293 virtual int SetQsyncMode(uint32_t disp_id, QsyncMode mode) DEFAULT_RET
294 virtual int IsSmartPanelConfig(uint32_t disp_id, uint32_t config_id, bool *is_smart) DEFAULT_RET
295 virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported) DEFAULT_RET
296 virtual int ControlQsyncCallback(bool enable) DEFAULT_RET
Ramkumar Radhakrishnan4e1cfa22020-03-19 21:47:40 -0700297 virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type) DEFAULT_RET
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530298
Padmanabhan Komanduru30f1b5d2020-05-05 21:00:21 +0530299 // deprecated APIs
300 virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET
301 virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> bit_clks) DEFAULT_RET
302
Padmanabhan Komandurud5010db2019-12-12 16:37:30 +0530303 protected:
304 virtual ~ConfigInterface() { }
305};
306
307} // namespace DisplayConfig
308
309#endif // __CONFIG_DEFS_H__