blob: ac3917d20458a0018d2ec4c130df2523871a8090 [file] [log] [blame]
Peiyong Line9d809e2020-04-14 13:10:48 -07001/*
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#define ERROR_HAS_CHANGES 5
24
25namespace android {
26namespace hardware::graphics::composer::hal {
27
28namespace types = android::hardware::graphics::common;
29namespace V2_1 = android::hardware::graphics::composer::V2_1;
30namespace V2_2 = android::hardware::graphics::composer::V2_2;
31namespace V2_3 = android::hardware::graphics::composer::V2_3;
32namespace V2_4 = android::hardware::graphics::composer::V2_4;
33
34using types::V1_0::ColorTransform;
35using types::V1_0::Transform;
36using types::V1_1::RenderIntent;
37using types::V1_2::ColorMode;
38using types::V1_2::Dataspace;
39using types::V1_2::Hdr;
40using types::V1_2::PixelFormat;
41
42using V2_1::Error;
43using V2_4::IComposer;
44using V2_4::IComposerCallback;
45using V2_4::IComposerClient;
46using V2_4::VsyncPeriodChangeTimeline;
47using V2_4::VsyncPeriodNanos;
48
49using Attribute = IComposerClient::Attribute;
50using BlendMode = IComposerClient::BlendMode;
51using Color = IComposerClient::Color;
52using Composition = IComposerClient::Composition;
53using Connection = IComposerCallback::Connection;
54using ContentType = IComposerClient::ContentType;
55using Capability = IComposer::Capability;
56using DisplayCapability = IComposerClient::DisplayCapability;
57using DisplayRequest = IComposerClient::DisplayRequest;
58using DisplayType = IComposerClient::DisplayType;
59using HWConfigId = V2_1::Config;
60using HWDisplayId = V2_1::Display;
61using HWError = V2_1::Error;
62using HWLayerId = V2_1::Layer;
63using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
64using LayerRequest = IComposerClient::LayerRequest;
65using PerFrameMetadata = IComposerClient::PerFrameMetadata;
66using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
67using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
68using PowerMode = IComposerClient::PowerMode;
69using Vsync = IComposerClient::Vsync;
70using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
71
72} // namespace hardware::graphics::composer::hal
73
74inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
75 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
76}
77
78inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
79 switch (attribute) {
80 case hardware::graphics::composer::hal::Attribute::INVALID:
81 return "Invalid";
82 case hardware::graphics::composer::hal::Attribute::WIDTH:
83 return "Width";
84 case hardware::graphics::composer::hal::Attribute::HEIGHT:
85 return "Height";
86 case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
87 return "VsyncPeriod";
88 case hardware::graphics::composer::hal::Attribute::DPI_X:
89 return "DpiX";
90 case hardware::graphics::composer::hal::Attribute::DPI_Y:
91 return "DpiY";
92 default:
93 return "Unknown";
94 }
95}
96
97inline std::string to_string(hardware::graphics::composer::hal::Composition composition) {
98 switch (composition) {
99 case hardware::graphics::composer::hal::Composition::INVALID:
100 return "Invalid";
101 case hardware::graphics::composer::hal::Composition::CLIENT:
102 return "Client";
103 case hardware::graphics::composer::hal::Composition::DEVICE:
104 return "Device";
105 case hardware::graphics::composer::hal::Composition::SOLID_COLOR:
106 return "SolidColor";
107 case hardware::graphics::composer::hal::Composition::CURSOR:
108 return "Cursor";
109 case hardware::graphics::composer::hal::Composition::SIDEBAND:
110 return "Sideband";
111 default:
112 return "Unknown";
113 }
114}
115
116inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
117 // 5 is reserved for historical reason, during validation 5 means has changes.
118 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
119 return "HasChanges";
120 }
121 switch (error) {
122 case hardware::graphics::composer::hal::V2_4::Error::NONE:
123 return "None";
124 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
125 return "BadConfig";
126 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
127 return "BadDisplay";
128 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
129 return "BadLayer";
130 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
131 return "BadParameter";
132 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
133 return "NoResources";
134 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
135 return "NotValidated";
136 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
137 return "Unsupported";
138 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
139 return "SeamlessNotAllowed";
140 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
141 return "SeamlessNotPossible";
142 default:
143 return "Unknown";
144 }
145}
146
147inline std::string to_string(hardware::graphics::composer::hal::Error error) {
148 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
149}
150
151inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
152 switch (mode) {
153 case hardware::graphics::composer::hal::PowerMode::OFF:
154 return "Off";
155 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
156 return "DozeSuspend";
157 case hardware::graphics::composer::hal::PowerMode::DOZE:
158 return "Doze";
159 case hardware::graphics::composer::hal::PowerMode::ON:
160 return "On";
161 default:
162 return "Unknown";
163 }
164}
165
166} // namespace android