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