• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
ToScreenId(ScreenPhysicalId physicalId)34 inline constexpr ScreenId ToScreenId(ScreenPhysicalId physicalId)
35 {
36     return static_cast<ScreenId>(physicalId);
37 }
38 
ToScreenPhysicalId(ScreenId id)39 inline constexpr ScreenPhysicalId ToScreenPhysicalId(ScreenId id)
40 {
41     return static_cast<ScreenPhysicalId>(id);
42 }
43 
44 enum class ScreenEvent : uint8_t {
45     CONNECTED,
46     DISCONNECTED,
47     UNKNOWN,
48 };
49 
50 enum class ScreenRotation : uint32_t {
51     ROTATION_0 = 0,
52     ROTATION_90,
53     ROTATION_180,
54     ROTATION_270,
55     INVALID_SCREEN_ROTATION,
56 };
57 
58 typedef enum : uint32_t {
59     POWER_STATUS_ON = 0,
60     POWER_STATUS_STANDBY,
61     POWER_STATUS_SUSPEND,
62     POWER_STATUS_OFF,
63     POWER_STATUS_BUTT,
64     INVALID_POWER_STATUS,
65 }ScreenPowerStatus;
66 
67 typedef enum : uint32_t {
68     DISP_INTF_HDMI = 0,
69     DISP_INTF_LCD,
70     DISP_INTF_BT1120,
71     DISP_INTF_BT656,
72     DISP_INTF_YPBPR,
73     DISP_INTF_RGB,
74     DISP_INTF_CVBS,
75     DISP_INTF_SVIDEO,
76     DISP_INTF_VGA,
77     DISP_INTF_MIPI,
78     DISP_INTF_PANEL,
79     DISP_INTF_BUTT,
80     DISP_INVALID,
81 }ScreenInterfaceType;
82 
83 typedef enum : uint32_t {
84     COLOR_GAMUT_INVALID = UINT32_MAX,
85     COLOR_GAMUT_NATIVE = 0,
86     COLOR_GAMUT_STANDARD_BT601,
87     COLOR_GAMUT_STANDARD_BT709,
88     COLOR_GAMUT_DCI_P3,
89     COLOR_GAMUT_SRGB,
90     COLOR_GAMUT_ADOBE_RGB,
91     COLOR_GAMUT_DISPLAY_P3,
92     COLOR_GAMUT_BT2020,
93     COLOR_GAMUT_BT2100_PQ,
94     COLOR_GAMUT_BT2100_HLG,
95     COLOR_GAMUT_DISPLAY_BT2020,
96 } ScreenColorGamut;
97 
98 typedef enum : uint32_t {
99     GAMUT_MAP_CONSTANT = 0,
100     GAMUT_MAP_EXTENSION,
101     GAMUT_MAP_HDR_CONSTANT,
102     GAMUT_MAP_HDR_EXTENSION,
103 } ScreenGamutMap;
104 
105 typedef enum : uint32_t {
106     SUCCESS = 0,
107     SCREEN_NOT_FOUND,
108     RS_CONNECTION_ERROR,
109     SURFACE_NOT_UNIQUE,
110     RENDER_SERVICE_NULL,
111     INVALID_ARGUMENTS,
112     WRITE_PARCEL_ERR,
113     HDI_ERROR,
114 } StatusCode;
115 
116 // get the underlying type of an enum value.
117 template<typename EnumType>
ECast(EnumType t)118 inline constexpr typename std::underlying_type<EnumType>::type ECast(EnumType t)
119 {
120     return static_cast<typename std::underlying_type<EnumType>::type>(t);
121 }
122 } // namespace Rosen
123 } // namespace OHOS
124 
125 #endif // RS_BASE_SCREEN_TYPES
126