1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OH_NATIVE_DISPLAY_INFO_H
17 #define OH_NATIVE_DISPLAY_INFO_H
18 
19 /**
20  * @addtogroup OH_DisplayInfo
21  * @{
22  *
23  * @brief Defines the data structures for the C APIs of the display module.
24  *
25  * @syscap SystemCapability.WindowManager.WindowManager.Core
26  * @since 12
27  * @version 1.0
28  */
29 
30 /**
31  * @file oh_display_info.h
32  *
33  * @brief Defines the data structures for the C APIs of the display module.
34  *
35  * @kit ArkUI
36  * @library libnative_display_manager.so
37  * @syscap SystemCapability.WindowManager.WindowManager.Core
38  * @since 12
39  * @version 1.0
40  */
41 
42 #include "stdint.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief display name length
50  * @since 14
51  */
52 #define OH_DISPLAY_NAME_LENGTH 32
53 
54 /**
55  * @brief Enumerates rotations.
56  *
57  * @since 12
58  * @version 1.0
59  */
60 typedef enum {
61     /** device rotation 0 degree */
62     DISPLAY_MANAGER_ROTATION_0,
63 
64     /** device rotation 90 degrees */
65     DISPLAY_MANAGER_ROTATION_90,
66 
67     /** device rotation 180 degrees */
68     DISPLAY_MANAGER_ROTATION_180,
69 
70     /** device rotation 270 degree */
71     DISPLAY_MANAGER_ROTATION_270,
72 } NativeDisplayManager_Rotation;
73 
74 /**
75  * @brief Enumerates orientations.
76  *
77  * @since 12
78  * @version 1.0
79  */
80 typedef enum {
81     /** device portrait show */
82     DISPLAY_MANAGER_PORTRAIT = 0,
83 
84     /** device landscape show */
85     DISPLAY_MANAGER_LANDSCAPE = 1,
86 
87     /** device portrait inverted show */
88     DISPLAY_MANAGER_PORTRAIT_INVERTED = 2,
89 
90     /** device landscape inverted show */
91     DISPLAY_MANAGER_LANDSCAPE_INVERTED = 3,
92 
93     /** device unknow show */
94     DISPLAY_MANAGER_UNKNOWN,
95 } NativeDisplayManager_Orientation;
96 
97 /**
98  * @brief Enumerates the result types of the display manager interface.
99  *
100  * @since 12
101  * @version 1.0
102  */
103 typedef enum {
104     /** @error Operation is successful */
105     DISPLAY_MANAGER_OK = 0,
106 
107     /** @error Operation no permission */
108     DISPLAY_MANAGER_ERROR_NO_PERMISSION = 201,
109 
110     /** @error Operation not system app */
111     DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP = 202,
112 
113     /** @error Operation invalid param */
114     DISPLAY_MANAGER_ERROR_INVALID_PARAM = 401,
115 
116     /** @error Operation device not supported */
117     DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED = 801,
118 
119     /** @error Operation screen invalid */
120     DISPLAY_MANAGER_ERROR_INVALID_SCREEN = 1400001,
121 
122     /** @error Operation invalid call */
123     DISPLAY_MANAGER_ERROR_INVALID_CALL = 1400002,
124 
125     /** @error Operation system abnormal */
126     DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL = 1400003,
127 } NativeDisplayManager_ErrorCode;
128 
129 /**
130  * @brief Enumerates the fold display mode.
131  *
132  * @since 12
133  * @version 1.0
134  */
135 typedef enum {
136     /** display mode unknown */
137     DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN = 0,
138 
139     /** display mode full */
140     DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL = 1,
141 
142     /** display mode main */
143     DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN = 2,
144 
145     /** display mode sub */
146     DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB = 3,
147 
148     /** display mode coordination */
149     DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION = 4,
150 } NativeDisplayManager_FoldDisplayMode;
151 
152 /**
153  * @brief Defines the display rect data structure.
154  *
155  * @since 12
156  * @version 1.0
157  */
158 typedef struct {
159     /** rect left */
160     int32_t left;
161 
162     /** rect top */
163     int32_t top;
164 
165     /** rect width */
166     uint32_t width;
167 
168     /** rect height */
169     uint32_t height;
170 } NativeDisplayManager_Rect;
171 
172 /**
173  * @brief Defines the display waterfallDisplayAreaRects data structure.
174  *
175  * @since 12
176  * @version 1.0
177  */
178 typedef struct {
179     /** waterfall left rect */
180     NativeDisplayManager_Rect left;
181 
182     /** waterfall top rect */
183     NativeDisplayManager_Rect top;
184 
185     /** waterfall right rect */
186     NativeDisplayManager_Rect right;
187 
188     /** waterfall bottom rect */
189     NativeDisplayManager_Rect bottom;
190 } NativeDisplayManager_WaterfallDisplayAreaRects;
191 
192 /**
193  * @brief Defines the display cutout info data structure.
194  *
195  * @since 12
196  * @version 1.0
197  */
198 typedef struct {
199     /** boundingRects length */
200     int32_t boundingRectsLength;
201 
202     /** boundingRects info pointer */
203     NativeDisplayManager_Rect *boundingRects;
204 
205     /** waterfallDisplayAreaRects info */
206     NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects;
207 } NativeDisplayManager_CutoutInfo;
208 
209 /**
210  * @brief Enumerates of the display state.
211  *
212  * @since 14
213  * @version 1.0
214  */
215 typedef enum {
216     /** display state unknown */
217     DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0,
218 
219     /** display state off */
220     DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1,
221 
222     /** display state on */
223     DISPLAY_MANAGER_DISPLAY_STATE_ON = 2,
224 
225     /** display state doze */
226     DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3,
227 
228     /** display state doze suspend */
229     DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4,
230 
231     /** display state vr */
232     DISPLAY_MANAGER_DISPLAY_STATE_VR = 5,
233 
234     /** display state on suspend */
235     DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6,
236 } NativeDisplayManager_DisplayState;
237 
238 /**
239  * @brief Defines the display hdr structure.
240  *
241  * @since 14
242  * @version 1.0
243  */
244 typedef struct {
245     /** hdrFormat length */
246     uint32_t hdrFormatLength;
247 
248     /** hdrFormat pointer */
249     uint32_t *hdrFormats;
250 } NativeDisplayManager_DisplayHdrFormat;
251 
252 /**
253  * @brief Defines the display color space structure.
254  *
255  * @since 14
256  * @version 1.0
257  */
258 typedef struct {
259     /** color space length */
260     uint32_t colorSpaceLength;
261 
262     /** color space pointer */
263     uint32_t *colorSpaces;
264 } NativeDisplayManager_DisplayColorSpace;
265 
266 /**
267  * @brief Defines the display structure.
268  *
269  * @since 14
270  * @version 1.0
271  */
272 typedef struct {
273     /** display id */
274     uint32_t id;
275 
276     /** display name */
277     char name[OH_DISPLAY_NAME_LENGTH + 1];
278 
279     /** display is alive */
280     bool isAlive;
281 
282     /** display width */
283     int32_t width;
284 
285     /** display height */
286     int32_t height;
287 
288     /** display physical width */
289     int32_t physicalWidth;
290 
291     /** display physical height */
292     int32_t physicalHeight;
293 
294     /** display refresh rate */
295     uint32_t refreshRate;
296 
297     /** display available width */
298     uint32_t availableWidth;
299 
300     /** display available height */
301     uint32_t availableHeight;
302 
303     /** display density dpi */
304     float densityDPI;
305 
306     /** display density pixels */
307     float densityPixels;
308 
309     /** display scale density */
310     float scaledDensity;
311 
312     /** display xdpi*/
313     float xDPI;
314 
315     /** display ydpi */
316     float yDPI;
317 
318     /** display rotation */
319     NativeDisplayManager_Rotation rotation;
320 
321     /** display state */
322     NativeDisplayManager_DisplayState state;
323 
324     /** display orientation */
325     NativeDisplayManager_Orientation orientation;
326 
327     /** display hdr format */
328     NativeDisplayManager_DisplayHdrFormat *hdrFormat;
329 
330     /** display color space */
331     NativeDisplayManager_DisplayColorSpace *colorSpace;
332 } NativeDisplayManager_DisplayInfo;
333 
334 /**
335  * @brief Defines the displays structure.
336  *
337  * @since 14
338  * @version 1.0
339  */
340 typedef struct {
341     /** displays length */
342     uint32_t displaysLength;
343 
344     /** displays pointer */
345     NativeDisplayManager_DisplayInfo *displaysInfo;
346 } NativeDisplayManager_DisplaysInfo;
347 
348 #ifdef __cplusplus
349 }
350 #endif
351 /** @} */
352 #endif // OH_NATIVE_DISPLAY_INFO_H