1 /*
2 * Copyright (c) 2021-2022 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 RS_BASE_SCREEN_TYPES
17 #define RS_BASE_SCREEN_TYPES
18
19 #include <cstdint>
20 #include <type_traits>
21
22 namespace OHOS {
23 namespace Rosen {
24 // Logical ScreenId for both physical and virtual screen.
25 using ScreenId = uint64_t;
26
27 // Screen Physical Id provided by hdi-backend.
28 using ScreenPhysicalId = uint32_t;
29
30 constexpr ScreenId INVALID_SCREEN_ID = ~(static_cast<ScreenId>(0));
31
32 constexpr int32_t INVALID_BACKLIGHT_VALUE = -1;
33
34 constexpr uint32_t LAYER_COMPOSITION_CAPACITY = 12;
35
36 constexpr uint32_t DEFAULT_SKIP_FRAME_INTERVAL = 1;
37
ToScreenId(ScreenPhysicalId physicalId)38 inline constexpr ScreenId ToScreenId(ScreenPhysicalId physicalId)
39 {
40 return static_cast<ScreenId>(physicalId);
41 }
42
ToScreenPhysicalId(ScreenId id)43 inline constexpr ScreenPhysicalId ToScreenPhysicalId(ScreenId id)
44 {
45 return static_cast<ScreenPhysicalId>(id);
46 }
47
48 enum class ScreenEvent : uint8_t {
49 CONNECTED,
50 DISCONNECTED,
51 UNKNOWN,
52 };
53
54 enum class ScreenRotation : uint32_t {
55 ROTATION_0 = 0,
56 ROTATION_90,
57 ROTATION_180,
58 ROTATION_270,
59 INVALID_SCREEN_ROTATION,
60 };
61
62 typedef enum : uint32_t {
63 BUILT_IN_TYPE_SCREEN = 0,
64 EXTERNAL_TYPE_SCREEN,
65 VIRTUAL_TYPE_SCREEN,
66 UNKNOWN_TYPE_SCREEN,
67 } RSScreenType;
68
69 typedef enum : uint32_t {
70 POWER_STATUS_ON = 0,
71 POWER_STATUS_STANDBY,
72 POWER_STATUS_SUSPEND,
73 POWER_STATUS_OFF,
74 POWER_STATUS_BUTT,
75 INVALID_POWER_STATUS,
76 } ScreenPowerStatus;
77
78 typedef enum : uint32_t {
79 DISP_INTF_HDMI = 0,
80 DISP_INTF_LCD,
81 DISP_INTF_BT1120,
82 DISP_INTF_BT656,
83 DISP_INTF_YPBPR,
84 DISP_INTF_RGB,
85 DISP_INTF_CVBS,
86 DISP_INTF_SVIDEO,
87 DISP_INTF_VGA,
88 DISP_INTF_MIPI,
89 DISP_INTF_PANEL,
90 DISP_INTF_BUTT,
91 DISP_INVALID,
92 } ScreenInterfaceType;
93
94 typedef enum : uint32_t {
95 COLOR_GAMUT_INVALID = UINT32_MAX,
96 COLOR_GAMUT_NATIVE = 0,
97 COLOR_GAMUT_STANDARD_BT601,
98 COLOR_GAMUT_STANDARD_BT709,
99 COLOR_GAMUT_DCI_P3,
100 COLOR_GAMUT_SRGB,
101 COLOR_GAMUT_ADOBE_RGB,
102 COLOR_GAMUT_DISPLAY_P3,
103 COLOR_GAMUT_BT2020,
104 COLOR_GAMUT_BT2100_PQ,
105 COLOR_GAMUT_BT2100_HLG,
106 COLOR_GAMUT_DISPLAY_BT2020,
107 } ScreenColorGamut;
108
109 typedef enum : uint32_t {
110 GAMUT_MAP_CONSTANT = 0,
111 GAMUT_MAP_EXTENSION,
112 GAMUT_MAP_HDR_CONSTANT,
113 GAMUT_MAP_HDR_EXTENSION,
114 } ScreenGamutMap;
115
116 typedef enum : uint32_t {
117 NOT_SUPPORT_HDR = 0,
118 DOLBY_VISION,
119 HDR10,
120 HLG,
121 HDR10_PLUS,
122 HDR_VIVID,
123 } ScreenHDRFormat;
124
125 typedef enum : uint32_t {
126 MATAKEY_RED_PRIMARY_X = 0,
127 MATAKEY_RED_PRIMARY_Y = 1,
128 MATAKEY_GREEN_PRIMARY_X = 2,
129 MATAKEY_GREEN_PRIMARY_Y = 3,
130 MATAKEY_BLUE_PRIMARY_X = 4,
131 MATAKEY_BLUE_PRIMARY_Y = 5,
132 MATAKEY_WHITE_PRIMARY_X = 6,
133 MATAKEY_WHITE_PRIMARY_Y = 7,
134 MATAKEY_MAX_LUMINANCE = 8,
135 MATAKEY_MIN_LUMINANCE = 9,
136 MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10,
137 MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
138 MATAKEY_HDR10_PLUS = 12,
139 MATAKEY_HDR_VIVID = 13,
140 } ScreenHDRMetadataKey;
141
142 typedef enum : uint32_t {
143 SUCCESS = 0,
144 SCREEN_NOT_FOUND,
145 RS_CONNECTION_ERROR,
146 SURFACE_NOT_UNIQUE,
147 RENDER_SERVICE_NULL,
148 INVALID_ARGUMENTS,
149 WRITE_PARCEL_ERR,
150 HDI_ERROR,
151 SCREEN_MANAGER_NULL,
152 } StatusCode;
153
154 // get the underlying type of an enum value.
155 template<typename EnumType>
ECast(EnumType t)156 inline constexpr typename std::underlying_type<EnumType>::type ECast(EnumType t)
157 {
158 return static_cast<typename std::underlying_type<EnumType>::type>(t);
159 }
160 } // namespace Rosen
161 } // namespace OHOS
162
163 #endif // RS_BASE_SCREEN_TYPES
164