• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <android/hardware/graphics/common/1.1/types.h>
20 #include <android/hardware/graphics/composer/2.4/IComposer.h>
21 #include <android/hardware/graphics/composer/2.4/IComposerClient.h>
22 
23 #include <aidl/android/hardware/graphics/composer3/Composition.h>
24 #include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
25 
26 #define ERROR_HAS_CHANGES 5
27 
28 namespace android {
29 namespace hardware::graphics::composer::hal {
30 
31 namespace types = android::hardware::graphics::common;
32 namespace V2_1 = android::hardware::graphics::composer::V2_1;
33 namespace V2_2 = android::hardware::graphics::composer::V2_2;
34 namespace V2_3 = android::hardware::graphics::composer::V2_3;
35 namespace V2_4 = android::hardware::graphics::composer::V2_4;
36 
37 using types::V1_0::ColorTransform;
38 using types::V1_0::Transform;
39 using types::V1_1::RenderIntent;
40 using types::V1_2::ColorMode;
41 using types::V1_2::Dataspace;
42 using types::V1_2::Hdr;
43 using types::V1_2::PixelFormat;
44 
45 using V2_1::Error;
46 using V2_4::IComposer;
47 using V2_4::IComposerCallback;
48 using V2_4::IComposerClient;
49 using V2_4::VsyncPeriodChangeTimeline;
50 using V2_4::VsyncPeriodNanos;
51 
52 using Attribute = IComposerClient::Attribute;
53 using BlendMode = IComposerClient::BlendMode;
54 using Connection = IComposerCallback::Connection;
55 using ContentType = IComposerClient::ContentType;
56 using Capability = IComposer::Capability;
57 using ClientTargetProperty = IComposerClient::ClientTargetProperty;
58 using DisplayRequest = IComposerClient::DisplayRequest;
59 using DisplayType = IComposerClient::DisplayType;
60 using HWConfigId = V2_1::Config;
61 using HWDisplayId = V2_1::Display;
62 using HWError = V2_1::Error;
63 using HWLayerId = V2_1::Layer;
64 using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
65 using LayerRequest = IComposerClient::LayerRequest;
66 using PerFrameMetadata = IComposerClient::PerFrameMetadata;
67 using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
68 using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
69 using PowerMode = IComposerClient::PowerMode;
70 using Vsync = IComposerClient::Vsync;
71 using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
72 
73 } // namespace hardware::graphics::composer::hal
74 
hasChangesError(hardware::graphics::composer::hal::Error error)75 inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
76     return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
77 }
78 
to_string(hardware::graphics::composer::hal::Attribute attribute)79 inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
80     switch (attribute) {
81         case hardware::graphics::composer::hal::Attribute::INVALID:
82             return "Invalid";
83         case hardware::graphics::composer::hal::Attribute::WIDTH:
84             return "Width";
85         case hardware::graphics::composer::hal::Attribute::HEIGHT:
86             return "Height";
87         case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
88             return "VsyncPeriod";
89         case hardware::graphics::composer::hal::Attribute::DPI_X:
90             return "DpiX";
91         case hardware::graphics::composer::hal::Attribute::DPI_Y:
92             return "DpiY";
93         default:
94             return "Unknown";
95     }
96 }
97 
to_string(aidl::android::hardware::graphics::composer3::Composition composition)98 inline std::string to_string(
99         aidl::android::hardware::graphics::composer3::Composition composition) {
100     switch (composition) {
101         case aidl::android::hardware::graphics::composer3::Composition::INVALID:
102             return "Invalid";
103         case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
104             return "Client";
105         case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
106             return "Device";
107         case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
108             return "SolidColor";
109         case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
110             return "Cursor";
111         case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
112             return "Sideband";
113         case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
114             return "DisplayDecoration";
115         default:
116             return "Unknown";
117     }
118 }
119 
to_string(aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability)120 inline std::string to_string(
121         aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
122     switch (displayCapability) {
123         case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
124             return "Invalid";
125         case aidl::android::hardware::graphics::composer3::DisplayCapability::
126                 SKIP_CLIENT_COLOR_TRANSFORM:
127             return "SkipColorTransform";
128         case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
129             return "Doze";
130         case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
131             return "Brightness";
132         case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
133             return "ProtectedContents";
134         case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
135             return "AutoLowLatencyMode";
136         case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
137             return "Suspend";
138         case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
139             return "DisplayIdleTimer";
140         default:
141             return "Unknown";
142     }
143 }
144 
to_string(hardware::graphics::composer::hal::V2_4::Error error)145 inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
146     // 5 is reserved for historical reason, during validation 5 means has changes.
147     if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
148         return "HasChanges";
149     }
150     switch (error) {
151         case hardware::graphics::composer::hal::V2_4::Error::NONE:
152             return "None";
153         case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
154             return "BadConfig";
155         case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
156             return "BadDisplay";
157         case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
158             return "BadLayer";
159         case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
160             return "BadParameter";
161         case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
162             return "NoResources";
163         case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
164             return "NotValidated";
165         case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
166             return "Unsupported";
167         case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
168             return "SeamlessNotAllowed";
169         case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
170             return "SeamlessNotPossible";
171         default:
172             return "Unknown";
173     }
174 }
175 
to_string(hardware::graphics::composer::hal::Error error)176 inline std::string to_string(hardware::graphics::composer::hal::Error error) {
177     return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
178 }
179 
to_string(hardware::graphics::composer::hal::PowerMode mode)180 inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
181     switch (mode) {
182         case hardware::graphics::composer::hal::PowerMode::OFF:
183             return "Off";
184         case hardware::graphics::composer::hal::PowerMode::DOZE:
185             return "Doze";
186         case hardware::graphics::composer::hal::PowerMode::ON:
187             return "On";
188         case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
189             return "DozeSuspend";
190         case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
191             return "OnSuspend";
192         default:
193             return "Unknown";
194     }
195 }
196 
to_string(hardware::graphics::composer::hal::Vsync vsync)197 inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
198     switch (vsync) {
199         case hardware::graphics::composer::hal::Vsync::ENABLE:
200             return "Enable";
201         case hardware::graphics::composer::hal::Vsync::DISABLE:
202             return "Disable";
203         default:
204             return "Unknown";
205     }
206 }
207 
208 } // namespace android
209