Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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 | #undef LOG_TAG |
| 18 | #define LOG_TAG "HwcComposer" |
| 19 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 20 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 21 | #include "AidlComposerHal.h" |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 22 | |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 23 | #include <android-base/file.h> |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 24 | #include <android/binder_ibinder_platform.h> |
| 25 | #include <android/binder_manager.h> |
| 26 | #include <log/log.h> |
| 27 | #include <utils/Trace.h> |
| 28 | |
| 29 | #include <aidl/android/hardware/graphics/composer3/BnComposerCallback.h> |
| 30 | |
| 31 | #include <algorithm> |
| 32 | #include <cinttypes> |
| 33 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 34 | #include "HWC2.h" |
| 35 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 36 | namespace android { |
| 37 | |
| 38 | using hardware::hidl_handle; |
| 39 | using hardware::hidl_vec; |
| 40 | using hardware::Return; |
| 41 | |
| 42 | using aidl::android::hardware::graphics::composer3::BnComposerCallback; |
| 43 | using aidl::android::hardware::graphics::composer3::Capability; |
Alec Mouri | 8506569 | 2022-03-18 00:58:26 +0000 | [diff] [blame] | 44 | using aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 45 | using aidl::android::hardware::graphics::composer3::PowerMode; |
| 46 | using aidl::android::hardware::graphics::composer3::VirtualDisplay; |
| 47 | |
Ady Abraham | 4297736 | 2021-12-07 21:04:49 -0800 | [diff] [blame] | 48 | using aidl::android::hardware::graphics::composer3::CommandResultPayload; |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 49 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 50 | using AidlColorMode = aidl::android::hardware::graphics::composer3::ColorMode; |
| 51 | using AidlContentType = aidl::android::hardware::graphics::composer3::ContentType; |
| 52 | using AidlDisplayIdentification = |
| 53 | aidl::android::hardware::graphics::composer3::DisplayIdentification; |
| 54 | using AidlDisplayContentSample = aidl::android::hardware::graphics::composer3::DisplayContentSample; |
| 55 | using AidlDisplayAttribute = aidl::android::hardware::graphics::composer3::DisplayAttribute; |
| 56 | using AidlDisplayCapability = aidl::android::hardware::graphics::composer3::DisplayCapability; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 57 | using AidlHdrCapabilities = aidl::android::hardware::graphics::composer3::HdrCapabilities; |
Sally Qi | 0cbd08b | 2022-08-17 12:12:28 -0700 | [diff] [blame] | 58 | using AidlOverlayProperties = aidl::android::hardware::graphics::composer3::OverlayProperties; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 59 | using AidlPerFrameMetadata = aidl::android::hardware::graphics::composer3::PerFrameMetadata; |
| 60 | using AidlPerFrameMetadataKey = aidl::android::hardware::graphics::composer3::PerFrameMetadataKey; |
| 61 | using AidlPerFrameMetadataBlob = aidl::android::hardware::graphics::composer3::PerFrameMetadataBlob; |
| 62 | using AidlRenderIntent = aidl::android::hardware::graphics::composer3::RenderIntent; |
| 63 | using AidlVsyncPeriodChangeConstraints = |
| 64 | aidl::android::hardware::graphics::composer3::VsyncPeriodChangeConstraints; |
| 65 | using AidlVsyncPeriodChangeTimeline = |
| 66 | aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 67 | using AidlDisplayContentSamplingAttributes = |
| 68 | aidl::android::hardware::graphics::composer3::DisplayContentSamplingAttributes; |
| 69 | using AidlFormatColorComponent = aidl::android::hardware::graphics::composer3::FormatColorComponent; |
| 70 | using AidlDisplayConnectionType = |
| 71 | aidl::android::hardware::graphics::composer3::DisplayConnectionType; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 72 | |
| 73 | using AidlColorTransform = aidl::android::hardware::graphics::common::ColorTransform; |
| 74 | using AidlDataspace = aidl::android::hardware::graphics::common::Dataspace; |
| 75 | using AidlFRect = aidl::android::hardware::graphics::common::FRect; |
| 76 | using AidlRect = aidl::android::hardware::graphics::common::Rect; |
| 77 | using AidlTransform = aidl::android::hardware::graphics::common::Transform; |
| 78 | |
| 79 | namespace Hwc2 { |
| 80 | |
| 81 | namespace { |
| 82 | |
| 83 | template <typename To, typename From> |
| 84 | To translate(From x) { |
| 85 | return static_cast<To>(x); |
| 86 | } |
| 87 | |
| 88 | template <typename To, typename From> |
| 89 | std::vector<To> translate(const std::vector<From>& in) { |
| 90 | std::vector<To> out; |
| 91 | out.reserve(in.size()); |
| 92 | std::transform(in.begin(), in.end(), std::back_inserter(out), |
| 93 | [](From x) { return translate<To>(x); }); |
| 94 | return out; |
| 95 | } |
| 96 | |
| 97 | template <> |
| 98 | AidlRect translate(IComposerClient::Rect x) { |
| 99 | return AidlRect{ |
| 100 | .left = x.left, |
| 101 | .top = x.top, |
| 102 | .right = x.right, |
| 103 | .bottom = x.bottom, |
| 104 | }; |
| 105 | } |
| 106 | |
| 107 | template <> |
| 108 | AidlFRect translate(IComposerClient::FRect x) { |
| 109 | return AidlFRect{ |
| 110 | .left = x.left, |
| 111 | .top = x.top, |
| 112 | .right = x.right, |
| 113 | .bottom = x.bottom, |
| 114 | }; |
| 115 | } |
| 116 | |
| 117 | template <> |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 118 | AidlPerFrameMetadataBlob translate(IComposerClient::PerFrameMetadataBlob x) { |
| 119 | AidlPerFrameMetadataBlob blob; |
| 120 | blob.key = translate<AidlPerFrameMetadataKey>(x.key), |
Long Ling | a462878 | 2022-02-18 13:44:26 -0800 | [diff] [blame] | 121 | std::copy(x.blob.begin(), x.blob.end(), std::inserter(blob.blob, blob.blob.end())); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 122 | return blob; |
| 123 | } |
| 124 | |
| 125 | template <> |
| 126 | AidlPerFrameMetadata translate(IComposerClient::PerFrameMetadata x) { |
| 127 | return AidlPerFrameMetadata{ |
| 128 | .key = translate<AidlPerFrameMetadataKey>(x.key), |
| 129 | .value = x.value, |
| 130 | }; |
| 131 | } |
| 132 | |
| 133 | template <> |
| 134 | DisplayedFrameStats translate(AidlDisplayContentSample x) { |
| 135 | return DisplayedFrameStats{ |
| 136 | .numFrames = static_cast<uint64_t>(x.frameCount), |
| 137 | .component_0_sample = translate<uint64_t>(x.sampleComponent0), |
| 138 | .component_1_sample = translate<uint64_t>(x.sampleComponent1), |
| 139 | .component_2_sample = translate<uint64_t>(x.sampleComponent2), |
| 140 | .component_3_sample = translate<uint64_t>(x.sampleComponent3), |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | template <> |
| 145 | AidlVsyncPeriodChangeConstraints translate(IComposerClient::VsyncPeriodChangeConstraints x) { |
| 146 | return AidlVsyncPeriodChangeConstraints{ |
| 147 | .desiredTimeNanos = x.desiredTimeNanos, |
| 148 | .seamlessRequired = x.seamlessRequired, |
| 149 | }; |
| 150 | } |
| 151 | |
| 152 | template <> |
| 153 | VsyncPeriodChangeTimeline translate(AidlVsyncPeriodChangeTimeline x) { |
| 154 | return VsyncPeriodChangeTimeline{ |
| 155 | .newVsyncAppliedTimeNanos = x.newVsyncAppliedTimeNanos, |
| 156 | .refreshRequired = x.refreshRequired, |
| 157 | .refreshTimeNanos = x.refreshTimeNanos, |
| 158 | }; |
| 159 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 160 | mat4 makeMat4(std::vector<float> in) { |
| 161 | return mat4(static_cast<const float*>(in.data())); |
| 162 | } |
| 163 | |
| 164 | } // namespace |
| 165 | |
| 166 | class AidlIComposerCallbackWrapper : public BnComposerCallback { |
| 167 | public: |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 168 | AidlIComposerCallbackWrapper(HWC2::ComposerCallback& callback) : mCallback(callback) {} |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 169 | |
| 170 | ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override { |
| 171 | const auto connection = in_connected ? V2_4::IComposerCallback::Connection::CONNECTED |
| 172 | : V2_4::IComposerCallback::Connection::DISCONNECTED; |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 173 | mCallback.onComposerHalHotplug(translate<Display>(in_display), connection); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 174 | return ::ndk::ScopedAStatus::ok(); |
| 175 | } |
| 176 | |
| 177 | ::ndk::ScopedAStatus onRefresh(int64_t in_display) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 178 | mCallback.onComposerHalRefresh(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 179 | return ::ndk::ScopedAStatus::ok(); |
| 180 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 181 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 182 | ::ndk::ScopedAStatus onSeamlessPossible(int64_t in_display) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 183 | mCallback.onComposerHalSeamlessPossible(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 184 | return ::ndk::ScopedAStatus::ok(); |
| 185 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 186 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 187 | ::ndk::ScopedAStatus onVsync(int64_t in_display, int64_t in_timestamp, |
| 188 | int32_t in_vsyncPeriodNanos) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 189 | mCallback.onComposerHalVsync(translate<Display>(in_display), in_timestamp, |
| 190 | static_cast<uint32_t>(in_vsyncPeriodNanos)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 191 | return ::ndk::ScopedAStatus::ok(); |
| 192 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 193 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 194 | ::ndk::ScopedAStatus onVsyncPeriodTimingChanged( |
| 195 | int64_t in_display, const AidlVsyncPeriodChangeTimeline& in_updatedTimeline) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 196 | mCallback.onComposerHalVsyncPeriodTimingChanged(translate<Display>(in_display), |
| 197 | translate<V2_4::VsyncPeriodChangeTimeline>( |
| 198 | in_updatedTimeline)); |
| 199 | return ::ndk::ScopedAStatus::ok(); |
| 200 | } |
| 201 | |
| 202 | ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override { |
| 203 | mCallback.onComposerHalVsyncIdle(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 204 | return ::ndk::ScopedAStatus::ok(); |
| 205 | } |
| 206 | |
| 207 | private: |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 208 | HWC2::ComposerCallback& mCallback; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 209 | }; |
| 210 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 211 | std::string AidlComposer::instance(const std::string& serviceName) { |
| 212 | return std::string(AidlIComposer::descriptor) + "/" + serviceName; |
| 213 | } |
| 214 | |
| 215 | bool AidlComposer::isDeclared(const std::string& serviceName) { |
| 216 | return AServiceManager_isDeclared(instance(serviceName).c_str()); |
| 217 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 218 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 219 | AidlComposer::AidlComposer(const std::string& serviceName) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 220 | // This only waits if the service is actually declared |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 221 | mAidlComposer = AidlIComposer::fromBinder( |
| 222 | ndk::SpAIBinder(AServiceManager_waitForService(instance(serviceName).c_str()))); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 223 | if (!mAidlComposer) { |
| 224 | LOG_ALWAYS_FATAL("Failed to get AIDL composer service"); |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | if (!mAidlComposer->createClient(&mAidlComposerClient).isOk()) { |
| 229 | LOG_ALWAYS_FATAL("Can't create AidlComposerClient, fallback to HIDL"); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | ALOGI("Loaded AIDL composer3 HAL service"); |
| 234 | } |
| 235 | |
| 236 | AidlComposer::~AidlComposer() = default; |
| 237 | |
Ady Abraham | 4d211cf | 2021-12-14 16:19:03 -0800 | [diff] [blame] | 238 | bool AidlComposer::isSupported(OptionalFeature feature) const { |
| 239 | switch (feature) { |
| 240 | case OptionalFeature::RefreshRateSwitching: |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 241 | case OptionalFeature::ExpectedPresentTime: |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 242 | case OptionalFeature::DisplayBrightnessCommand: |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 243 | case OptionalFeature::KernelIdleTimer: |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 244 | case OptionalFeature::PhysicalDisplayOrientation: |
Ady Abraham | 4d211cf | 2021-12-14 16:19:03 -0800 | [diff] [blame] | 245 | return true; |
| 246 | } |
| 247 | } |
| 248 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 249 | std::vector<Capability> AidlComposer::getCapabilities() { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 250 | std::vector<Capability> capabilities; |
| 251 | const auto status = mAidlComposer->getCapabilities(&capabilities); |
| 252 | if (!status.isOk()) { |
| 253 | ALOGE("getCapabilities failed %s", status.getDescription().c_str()); |
| 254 | return {}; |
| 255 | } |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 256 | return capabilities; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | std::string AidlComposer::dumpDebugInfo() { |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 260 | int pipefds[2]; |
| 261 | int result = pipe(pipefds); |
| 262 | if (result < 0) { |
| 263 | ALOGE("dumpDebugInfo: pipe failed: %s", strerror(errno)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 264 | return {}; |
| 265 | } |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 266 | |
| 267 | std::string str; |
yihsing.shen | 58847c5 | 2022-09-23 15:39:30 +0800 | [diff] [blame] | 268 | // Use other thread to read pipe to prevent |
| 269 | // pipe is full, making HWC be blocked in writing. |
| 270 | std::thread t([&]() { |
| 271 | base::ReadFdToString(pipefds[0], &str); |
| 272 | }); |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 273 | const auto status = mAidlComposer->dump(pipefds[1], /*args*/ nullptr, /*numArgs*/ 0); |
| 274 | // Close the write-end of the pipe to make sure that when reading from the |
| 275 | // read-end we will get eof instead of blocking forever |
| 276 | close(pipefds[1]); |
| 277 | |
yihsing.shen | 58847c5 | 2022-09-23 15:39:30 +0800 | [diff] [blame] | 278 | if (status != STATUS_OK) { |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 279 | ALOGE("dumpDebugInfo: dump failed: %d", status); |
| 280 | } |
| 281 | |
yihsing.shen | 58847c5 | 2022-09-23 15:39:30 +0800 | [diff] [blame] | 282 | t.join(); |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame] | 283 | close(pipefds[0]); |
| 284 | return str; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 287 | void AidlComposer::registerCallback(HWC2::ComposerCallback& callback) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 288 | if (mAidlComposerCallback) { |
| 289 | ALOGE("Callback already registered"); |
| 290 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 291 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 292 | mAidlComposerCallback = ndk::SharedRefBase::make<AidlIComposerCallbackWrapper>(callback); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 293 | AIBinder_setMinSchedulerPolicy(mAidlComposerCallback->asBinder().get(), SCHED_FIFO, 2); |
| 294 | |
| 295 | const auto status = mAidlComposerClient->registerCallback(mAidlComposerCallback); |
| 296 | if (!status.isOk()) { |
| 297 | ALOGE("registerCallback failed %s", status.getDescription().c_str()); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | void AidlComposer::resetCommands() { |
| 302 | mWriter.reset(); |
| 303 | } |
| 304 | |
| 305 | Error AidlComposer::executeCommands() { |
| 306 | return execute(); |
| 307 | } |
| 308 | |
| 309 | uint32_t AidlComposer::getMaxVirtualDisplayCount() { |
| 310 | int32_t count = 0; |
| 311 | const auto status = mAidlComposerClient->getMaxVirtualDisplayCount(&count); |
| 312 | if (!status.isOk()) { |
| 313 | ALOGE("getMaxVirtualDisplayCount failed %s", status.getDescription().c_str()); |
| 314 | return 0; |
| 315 | } |
| 316 | return static_cast<uint32_t>(count); |
| 317 | } |
| 318 | |
| 319 | Error AidlComposer::createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, |
| 320 | Display* outDisplay) { |
| 321 | using AidlPixelFormat = aidl::android::hardware::graphics::common::PixelFormat; |
| 322 | const int32_t bufferSlotCount = 1; |
| 323 | VirtualDisplay virtualDisplay; |
| 324 | const auto status = |
| 325 | mAidlComposerClient->createVirtualDisplay(static_cast<int32_t>(width), |
| 326 | static_cast<int32_t>(height), |
| 327 | static_cast<AidlPixelFormat>(*format), |
| 328 | bufferSlotCount, &virtualDisplay); |
| 329 | |
| 330 | if (!status.isOk()) { |
| 331 | ALOGE("createVirtualDisplay failed %s", status.getDescription().c_str()); |
| 332 | return static_cast<Error>(status.getServiceSpecificError()); |
| 333 | } |
| 334 | |
| 335 | *outDisplay = translate<Display>(virtualDisplay.display); |
| 336 | *format = static_cast<PixelFormat>(virtualDisplay.format); |
| 337 | return Error::NONE; |
| 338 | } |
| 339 | |
| 340 | Error AidlComposer::destroyVirtualDisplay(Display display) { |
| 341 | const auto status = mAidlComposerClient->destroyVirtualDisplay(translate<int64_t>(display)); |
| 342 | if (!status.isOk()) { |
| 343 | ALOGE("destroyVirtualDisplay failed %s", status.getDescription().c_str()); |
| 344 | return static_cast<Error>(status.getServiceSpecificError()); |
| 345 | } |
| 346 | return Error::NONE; |
| 347 | } |
| 348 | |
| 349 | Error AidlComposer::acceptDisplayChanges(Display display) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 350 | mWriter.acceptDisplayChanges(translate<int64_t>(display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 351 | return Error::NONE; |
| 352 | } |
| 353 | |
| 354 | Error AidlComposer::createLayer(Display display, Layer* outLayer) { |
| 355 | int64_t layer; |
| 356 | const auto status = mAidlComposerClient->createLayer(translate<int64_t>(display), |
| 357 | kMaxLayerBufferCount, &layer); |
| 358 | if (!status.isOk()) { |
| 359 | ALOGE("createLayer failed %s", status.getDescription().c_str()); |
| 360 | return static_cast<Error>(status.getServiceSpecificError()); |
| 361 | } |
| 362 | |
| 363 | *outLayer = translate<Layer>(layer); |
| 364 | return Error::NONE; |
| 365 | } |
| 366 | |
| 367 | Error AidlComposer::destroyLayer(Display display, Layer layer) { |
| 368 | const auto status = mAidlComposerClient->destroyLayer(translate<int64_t>(display), |
| 369 | translate<int64_t>(layer)); |
| 370 | if (!status.isOk()) { |
| 371 | ALOGE("destroyLayer failed %s", status.getDescription().c_str()); |
| 372 | return static_cast<Error>(status.getServiceSpecificError()); |
| 373 | } |
| 374 | return Error::NONE; |
| 375 | } |
| 376 | |
| 377 | Error AidlComposer::getActiveConfig(Display display, Config* outConfig) { |
| 378 | int32_t config; |
| 379 | const auto status = mAidlComposerClient->getActiveConfig(translate<int64_t>(display), &config); |
| 380 | if (!status.isOk()) { |
| 381 | ALOGE("getActiveConfig failed %s", status.getDescription().c_str()); |
| 382 | return static_cast<Error>(status.getServiceSpecificError()); |
| 383 | } |
| 384 | *outConfig = translate<Config>(config); |
| 385 | return Error::NONE; |
| 386 | } |
| 387 | |
| 388 | Error AidlComposer::getChangedCompositionTypes( |
| 389 | Display display, std::vector<Layer>* outLayers, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 390 | std::vector<aidl::android::hardware::graphics::composer3::Composition>* outTypes) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 391 | const auto changedLayers = mReader.takeChangedCompositionTypes(translate<int64_t>(display)); |
| 392 | outLayers->reserve(changedLayers.size()); |
| 393 | outTypes->reserve(changedLayers.size()); |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 394 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 395 | for (const auto& layer : changedLayers) { |
| 396 | outLayers->emplace_back(translate<Layer>(layer.layer)); |
| 397 | outTypes->emplace_back(layer.composition); |
| 398 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 399 | return Error::NONE; |
| 400 | } |
| 401 | |
| 402 | Error AidlComposer::getColorModes(Display display, std::vector<ColorMode>* outModes) { |
| 403 | std::vector<AidlColorMode> modes; |
| 404 | const auto status = mAidlComposerClient->getColorModes(translate<int64_t>(display), &modes); |
| 405 | if (!status.isOk()) { |
| 406 | ALOGE("getColorModes failed %s", status.getDescription().c_str()); |
| 407 | return static_cast<Error>(status.getServiceSpecificError()); |
| 408 | } |
| 409 | *outModes = translate<ColorMode>(modes); |
| 410 | return Error::NONE; |
| 411 | } |
| 412 | |
| 413 | Error AidlComposer::getDisplayAttribute(Display display, Config config, |
| 414 | IComposerClient::Attribute attribute, int32_t* outValue) { |
| 415 | const auto status = |
| 416 | mAidlComposerClient->getDisplayAttribute(translate<int64_t>(display), |
| 417 | translate<int32_t>(config), |
| 418 | static_cast<AidlDisplayAttribute>(attribute), |
| 419 | outValue); |
| 420 | if (!status.isOk()) { |
| 421 | ALOGE("getDisplayAttribute failed %s", status.getDescription().c_str()); |
| 422 | return static_cast<Error>(status.getServiceSpecificError()); |
| 423 | } |
| 424 | return Error::NONE; |
| 425 | } |
| 426 | |
| 427 | Error AidlComposer::getDisplayConfigs(Display display, std::vector<Config>* outConfigs) { |
| 428 | std::vector<int32_t> configs; |
| 429 | const auto status = |
| 430 | mAidlComposerClient->getDisplayConfigs(translate<int64_t>(display), &configs); |
| 431 | if (!status.isOk()) { |
| 432 | ALOGE("getDisplayConfigs failed %s", status.getDescription().c_str()); |
| 433 | return static_cast<Error>(status.getServiceSpecificError()); |
| 434 | } |
| 435 | *outConfigs = translate<Config>(configs); |
| 436 | return Error::NONE; |
| 437 | } |
| 438 | |
| 439 | Error AidlComposer::getDisplayName(Display display, std::string* outName) { |
| 440 | const auto status = mAidlComposerClient->getDisplayName(translate<int64_t>(display), outName); |
| 441 | if (!status.isOk()) { |
| 442 | ALOGE("getDisplayName failed %s", status.getDescription().c_str()); |
| 443 | return static_cast<Error>(status.getServiceSpecificError()); |
| 444 | } |
| 445 | return Error::NONE; |
| 446 | } |
| 447 | |
| 448 | Error AidlComposer::getDisplayRequests(Display display, uint32_t* outDisplayRequestMask, |
| 449 | std::vector<Layer>* outLayers, |
| 450 | std::vector<uint32_t>* outLayerRequestMasks) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 451 | const auto displayRequests = mReader.takeDisplayRequests(translate<int64_t>(display)); |
| 452 | *outDisplayRequestMask = translate<uint32_t>(displayRequests.mask); |
| 453 | outLayers->reserve(displayRequests.layerRequests.size()); |
| 454 | outLayerRequestMasks->reserve(displayRequests.layerRequests.size()); |
| 455 | |
| 456 | for (const auto& layer : displayRequests.layerRequests) { |
| 457 | outLayers->emplace_back(translate<Layer>(layer.layer)); |
| 458 | outLayerRequestMasks->emplace_back(translate<uint32_t>(layer.mask)); |
| 459 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 460 | return Error::NONE; |
| 461 | } |
| 462 | |
| 463 | Error AidlComposer::getDozeSupport(Display display, bool* outSupport) { |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 464 | std::vector<AidlDisplayCapability> capabilities; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 465 | const auto status = |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 466 | mAidlComposerClient->getDisplayCapabilities(translate<int64_t>(display), &capabilities); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 467 | if (!status.isOk()) { |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 468 | ALOGE("getDisplayCapabilities failed %s", status.getDescription().c_str()); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 469 | return static_cast<Error>(status.getServiceSpecificError()); |
| 470 | } |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 471 | *outSupport = std::find(capabilities.begin(), capabilities.end(), |
| 472 | AidlDisplayCapability::DOZE) != capabilities.end(); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 473 | return Error::NONE; |
| 474 | } |
| 475 | |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 476 | Error AidlComposer::hasDisplayIdleTimerCapability(Display display, bool* outSupport) { |
| 477 | std::vector<AidlDisplayCapability> capabilities; |
| 478 | const auto status = |
| 479 | mAidlComposerClient->getDisplayCapabilities(translate<int64_t>(display), &capabilities); |
| 480 | if (!status.isOk()) { |
| 481 | ALOGE("getDisplayCapabilities failed %s", status.getDescription().c_str()); |
| 482 | return static_cast<Error>(status.getServiceSpecificError()); |
| 483 | } |
| 484 | *outSupport = std::find(capabilities.begin(), capabilities.end(), |
| 485 | AidlDisplayCapability::DISPLAY_IDLE_TIMER) != capabilities.end(); |
| 486 | return Error::NONE; |
| 487 | } |
| 488 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 489 | Error AidlComposer::getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, |
| 490 | float* outMaxLuminance, float* outMaxAverageLuminance, |
| 491 | float* outMinLuminance) { |
| 492 | AidlHdrCapabilities capabilities; |
| 493 | const auto status = |
| 494 | mAidlComposerClient->getHdrCapabilities(translate<int64_t>(display), &capabilities); |
| 495 | if (!status.isOk()) { |
| 496 | ALOGE("getHdrCapabilities failed %s", status.getDescription().c_str()); |
| 497 | return static_cast<Error>(status.getServiceSpecificError()); |
| 498 | } |
| 499 | |
| 500 | *outTypes = translate<Hdr>(capabilities.types); |
| 501 | *outMaxLuminance = capabilities.maxLuminance; |
| 502 | *outMaxAverageLuminance = capabilities.maxAverageLuminance; |
| 503 | *outMinLuminance = capabilities.minLuminance; |
| 504 | return Error::NONE; |
| 505 | } |
| 506 | |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame^] | 507 | Error AidlComposer::getOverlaySupport(AidlOverlayProperties* outProperties) { |
| 508 | const auto status = mAidlComposerClient->getOverlaySupport(outProperties); |
| 509 | if (!status.isOk()) { |
| 510 | ALOGE("getOverlaySupport failed %s", status.getDescription().c_str()); |
| 511 | return static_cast<Error>(status.getServiceSpecificError()); |
| 512 | } |
Sally Qi | 0cbd08b | 2022-08-17 12:12:28 -0700 | [diff] [blame] | 513 | return Error::NONE; |
| 514 | } |
| 515 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 516 | Error AidlComposer::getReleaseFences(Display display, std::vector<Layer>* outLayers, |
| 517 | std::vector<int>* outReleaseFences) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 518 | auto fences = mReader.takeReleaseFences(translate<int64_t>(display)); |
| 519 | outLayers->reserve(fences.size()); |
| 520 | outReleaseFences->reserve(fences.size()); |
| 521 | |
| 522 | for (auto& fence : fences) { |
| 523 | outLayers->emplace_back(translate<Layer>(fence.layer)); |
| 524 | // take ownership |
| 525 | const int fenceOwner = fence.fence.get(); |
| 526 | *fence.fence.getR() = -1; |
| 527 | outReleaseFences->emplace_back(fenceOwner); |
| 528 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 529 | return Error::NONE; |
| 530 | } |
| 531 | |
| 532 | Error AidlComposer::presentDisplay(Display display, int* outPresentFence) { |
| 533 | ATRACE_NAME("HwcPresentDisplay"); |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 534 | mWriter.presentDisplay(translate<int64_t>(display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 535 | |
| 536 | Error error = execute(); |
| 537 | if (error != Error::NONE) { |
| 538 | return error; |
| 539 | } |
| 540 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 541 | auto fence = mReader.takePresentFence(translate<int64_t>(display)); |
| 542 | // take ownership |
| 543 | *outPresentFence = fence.get(); |
| 544 | *fence.getR() = -1; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 545 | return Error::NONE; |
| 546 | } |
| 547 | |
| 548 | Error AidlComposer::setActiveConfig(Display display, Config config) { |
| 549 | const auto status = mAidlComposerClient->setActiveConfig(translate<int64_t>(display), |
| 550 | translate<int32_t>(config)); |
| 551 | if (!status.isOk()) { |
| 552 | ALOGE("setActiveConfig failed %s", status.getDescription().c_str()); |
| 553 | return static_cast<Error>(status.getServiceSpecificError()); |
| 554 | } |
| 555 | return Error::NONE; |
| 556 | } |
| 557 | |
| 558 | Error AidlComposer::setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target, |
| 559 | int acquireFence, Dataspace dataspace, |
| 560 | const std::vector<IComposerClient::Rect>& damage) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 561 | const native_handle_t* handle = nullptr; |
| 562 | if (target.get()) { |
| 563 | handle = target->getNativeBuffer()->handle; |
| 564 | } |
| 565 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 566 | mWriter.setClientTarget(translate<int64_t>(display), slot, handle, acquireFence, |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 567 | translate<aidl::android::hardware::graphics::common::Dataspace>( |
| 568 | dataspace), |
| 569 | translate<AidlRect>(damage)); |
| 570 | return Error::NONE; |
| 571 | } |
| 572 | |
| 573 | Error AidlComposer::setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) { |
| 574 | const auto status = |
| 575 | mAidlComposerClient->setColorMode(translate<int64_t>(display), |
| 576 | translate<AidlColorMode>(mode), |
| 577 | translate<AidlRenderIntent>(renderIntent)); |
| 578 | if (!status.isOk()) { |
| 579 | ALOGE("setColorMode failed %s", status.getDescription().c_str()); |
| 580 | return static_cast<Error>(status.getServiceSpecificError()); |
| 581 | } |
| 582 | return Error::NONE; |
| 583 | } |
| 584 | |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 585 | Error AidlComposer::setColorTransform(Display display, const float* matrix) { |
| 586 | mWriter.setColorTransform(translate<int64_t>(display), matrix); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 587 | return Error::NONE; |
| 588 | } |
| 589 | |
| 590 | Error AidlComposer::setOutputBuffer(Display display, const native_handle_t* buffer, |
| 591 | int releaseFence) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 592 | mWriter.setOutputBuffer(translate<int64_t>(display), 0, buffer, dup(releaseFence)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 593 | return Error::NONE; |
| 594 | } |
| 595 | |
| 596 | Error AidlComposer::setPowerMode(Display display, IComposerClient::PowerMode mode) { |
| 597 | const auto status = mAidlComposerClient->setPowerMode(translate<int64_t>(display), |
| 598 | translate<PowerMode>(mode)); |
| 599 | if (!status.isOk()) { |
| 600 | ALOGE("setPowerMode failed %s", status.getDescription().c_str()); |
| 601 | return static_cast<Error>(status.getServiceSpecificError()); |
| 602 | } |
| 603 | return Error::NONE; |
| 604 | } |
| 605 | |
| 606 | Error AidlComposer::setVsyncEnabled(Display display, IComposerClient::Vsync enabled) { |
| 607 | const bool enableVsync = enabled == IComposerClient::Vsync::ENABLE; |
| 608 | const auto status = |
| 609 | mAidlComposerClient->setVsyncEnabled(translate<int64_t>(display), enableVsync); |
| 610 | if (!status.isOk()) { |
| 611 | ALOGE("setVsyncEnabled failed %s", status.getDescription().c_str()); |
| 612 | return static_cast<Error>(status.getServiceSpecificError()); |
| 613 | } |
| 614 | return Error::NONE; |
| 615 | } |
| 616 | |
| 617 | Error AidlComposer::setClientTargetSlotCount(Display display) { |
| 618 | const int32_t bufferSlotCount = BufferQueue::NUM_BUFFER_SLOTS; |
| 619 | const auto status = mAidlComposerClient->setClientTargetSlotCount(translate<int64_t>(display), |
| 620 | bufferSlotCount); |
| 621 | if (!status.isOk()) { |
| 622 | ALOGE("setClientTargetSlotCount failed %s", status.getDescription().c_str()); |
| 623 | return static_cast<Error>(status.getServiceSpecificError()); |
| 624 | } |
| 625 | return Error::NONE; |
| 626 | } |
| 627 | |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 628 | Error AidlComposer::validateDisplay(Display display, nsecs_t expectedPresentTime, |
| 629 | uint32_t* outNumTypes, uint32_t* outNumRequests) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 630 | ATRACE_NAME("HwcValidateDisplay"); |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 631 | mWriter.validateDisplay(translate<int64_t>(display), |
| 632 | ClockMonotonicTimestamp{expectedPresentTime}); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 633 | |
| 634 | Error error = execute(); |
| 635 | if (error != Error::NONE) { |
| 636 | return error; |
| 637 | } |
| 638 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 639 | mReader.hasChanges(translate<int64_t>(display), outNumTypes, outNumRequests); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 640 | |
| 641 | return Error::NONE; |
| 642 | } |
| 643 | |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 644 | Error AidlComposer::presentOrValidateDisplay(Display display, nsecs_t expectedPresentTime, |
| 645 | uint32_t* outNumTypes, uint32_t* outNumRequests, |
| 646 | int* outPresentFence, uint32_t* state) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 647 | ATRACE_NAME("HwcPresentOrValidateDisplay"); |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 648 | mWriter.presentOrvalidateDisplay(translate<int64_t>(display), |
| 649 | ClockMonotonicTimestamp{expectedPresentTime}); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 650 | |
| 651 | Error error = execute(); |
| 652 | if (error != Error::NONE) { |
| 653 | return error; |
| 654 | } |
| 655 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 656 | const auto result = mReader.takePresentOrValidateStage(translate<int64_t>(display)); |
| 657 | if (!result.has_value()) { |
| 658 | *state = translate<uint32_t>(-1); |
| 659 | return Error::NO_RESOURCES; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 662 | *state = translate<uint32_t>(*result); |
| 663 | |
| 664 | if (*result == PresentOrValidate::Result::Presented) { |
| 665 | auto fence = mReader.takePresentFence(translate<int64_t>(display)); |
| 666 | // take ownership |
| 667 | *outPresentFence = fence.get(); |
| 668 | *fence.getR() = -1; |
| 669 | } |
| 670 | |
| 671 | if (*result == PresentOrValidate::Result::Validated) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 672 | mReader.hasChanges(translate<int64_t>(display), outNumTypes, outNumRequests); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | return Error::NONE; |
| 676 | } |
| 677 | |
| 678 | Error AidlComposer::setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 679 | mWriter.setLayerCursorPosition(translate<int64_t>(display), translate<int64_t>(layer), x, y); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 680 | return Error::NONE; |
| 681 | } |
| 682 | |
| 683 | Error AidlComposer::setLayerBuffer(Display display, Layer layer, uint32_t slot, |
| 684 | const sp<GraphicBuffer>& buffer, int acquireFence) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 685 | const native_handle_t* handle = nullptr; |
| 686 | if (buffer.get()) { |
| 687 | handle = buffer->getNativeBuffer()->handle; |
| 688 | } |
| 689 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 690 | mWriter.setLayerBuffer(translate<int64_t>(display), translate<int64_t>(layer), slot, handle, |
| 691 | acquireFence); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 692 | return Error::NONE; |
| 693 | } |
| 694 | |
| 695 | Error AidlComposer::setLayerSurfaceDamage(Display display, Layer layer, |
| 696 | const std::vector<IComposerClient::Rect>& damage) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 697 | mWriter.setLayerSurfaceDamage(translate<int64_t>(display), translate<int64_t>(layer), |
| 698 | translate<AidlRect>(damage)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 699 | return Error::NONE; |
| 700 | } |
| 701 | |
| 702 | Error AidlComposer::setLayerBlendMode(Display display, Layer layer, |
| 703 | IComposerClient::BlendMode mode) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 704 | mWriter.setLayerBlendMode(translate<int64_t>(display), translate<int64_t>(layer), |
| 705 | translate<BlendMode>(mode)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 706 | return Error::NONE; |
| 707 | } |
| 708 | |
Ady Abraham | 6e60b14 | 2022-01-06 18:10:35 -0800 | [diff] [blame] | 709 | Error AidlComposer::setLayerColor(Display display, Layer layer, const Color& color) { |
| 710 | mWriter.setLayerColor(translate<int64_t>(display), translate<int64_t>(layer), color); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 711 | return Error::NONE; |
| 712 | } |
| 713 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 714 | Error AidlComposer::setLayerCompositionType( |
| 715 | Display display, Layer layer, |
| 716 | aidl::android::hardware::graphics::composer3::Composition type) { |
| 717 | mWriter.setLayerCompositionType(translate<int64_t>(display), translate<int64_t>(layer), type); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 718 | return Error::NONE; |
| 719 | } |
| 720 | |
| 721 | Error AidlComposer::setLayerDataspace(Display display, Layer layer, Dataspace dataspace) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 722 | mWriter.setLayerDataspace(translate<int64_t>(display), translate<int64_t>(layer), |
| 723 | translate<AidlDataspace>(dataspace)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 724 | return Error::NONE; |
| 725 | } |
| 726 | |
| 727 | Error AidlComposer::setLayerDisplayFrame(Display display, Layer layer, |
| 728 | const IComposerClient::Rect& frame) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 729 | mWriter.setLayerDisplayFrame(translate<int64_t>(display), translate<int64_t>(layer), |
| 730 | translate<AidlRect>(frame)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 731 | return Error::NONE; |
| 732 | } |
| 733 | |
| 734 | Error AidlComposer::setLayerPlaneAlpha(Display display, Layer layer, float alpha) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 735 | mWriter.setLayerPlaneAlpha(translate<int64_t>(display), translate<int64_t>(layer), alpha); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 736 | return Error::NONE; |
| 737 | } |
| 738 | |
| 739 | Error AidlComposer::setLayerSidebandStream(Display display, Layer layer, |
| 740 | const native_handle_t* stream) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 741 | mWriter.setLayerSidebandStream(translate<int64_t>(display), translate<int64_t>(layer), stream); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 742 | return Error::NONE; |
| 743 | } |
| 744 | |
| 745 | Error AidlComposer::setLayerSourceCrop(Display display, Layer layer, |
| 746 | const IComposerClient::FRect& crop) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 747 | mWriter.setLayerSourceCrop(translate<int64_t>(display), translate<int64_t>(layer), |
| 748 | translate<AidlFRect>(crop)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 749 | return Error::NONE; |
| 750 | } |
| 751 | |
| 752 | Error AidlComposer::setLayerTransform(Display display, Layer layer, Transform transform) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 753 | mWriter.setLayerTransform(translate<int64_t>(display), translate<int64_t>(layer), |
| 754 | translate<AidlTransform>(transform)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 755 | return Error::NONE; |
| 756 | } |
| 757 | |
| 758 | Error AidlComposer::setLayerVisibleRegion(Display display, Layer layer, |
| 759 | const std::vector<IComposerClient::Rect>& visible) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 760 | mWriter.setLayerVisibleRegion(translate<int64_t>(display), translate<int64_t>(layer), |
| 761 | translate<AidlRect>(visible)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 762 | return Error::NONE; |
| 763 | } |
| 764 | |
| 765 | Error AidlComposer::setLayerZOrder(Display display, Layer layer, uint32_t z) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 766 | mWriter.setLayerZOrder(translate<int64_t>(display), translate<int64_t>(layer), z); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 767 | return Error::NONE; |
| 768 | } |
| 769 | |
| 770 | Error AidlComposer::execute() { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 771 | const auto& commands = mWriter.getPendingCommands(); |
| 772 | if (commands.empty()) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 773 | mWriter.reset(); |
| 774 | return Error::NONE; |
| 775 | } |
| 776 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 777 | { // scope for results |
| 778 | std::vector<CommandResultPayload> results; |
| 779 | auto status = mAidlComposerClient->executeCommands(commands, &results); |
| 780 | if (!status.isOk()) { |
| 781 | ALOGE("executeCommands failed %s", status.getDescription().c_str()); |
| 782 | return static_cast<Error>(status.getServiceSpecificError()); |
| 783 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 784 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 785 | mReader.parse(std::move(results)); |
| 786 | } |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 787 | const auto commandErrors = mReader.takeErrors(); |
| 788 | Error error = Error::NONE; |
| 789 | for (const auto& cmdErr : commandErrors) { |
| 790 | const auto index = static_cast<size_t>(cmdErr.commandIndex); |
| 791 | if (index < 0 || index >= commands.size()) { |
| 792 | ALOGE("invalid command index %zu", index); |
| 793 | return Error::BAD_PARAMETER; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 796 | const auto& command = commands[index]; |
Ady Abraham | 4297736 | 2021-12-07 21:04:49 -0800 | [diff] [blame] | 797 | if (command.validateDisplay || command.presentDisplay || command.presentOrValidateDisplay) { |
| 798 | error = translate<Error>(cmdErr.errorCode); |
| 799 | } else { |
| 800 | ALOGW("command '%s' generated error %" PRId32, command.toString().c_str(), |
| 801 | cmdErr.errorCode); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 802 | } |
| 803 | } |
| 804 | |
| 805 | mWriter.reset(); |
| 806 | |
| 807 | return error; |
| 808 | } |
| 809 | |
| 810 | Error AidlComposer::setLayerPerFrameMetadata( |
| 811 | Display display, Layer layer, |
| 812 | const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 813 | mWriter.setLayerPerFrameMetadata(translate<int64_t>(display), translate<int64_t>(layer), |
| 814 | translate<AidlPerFrameMetadata>(perFrameMetadatas)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 815 | return Error::NONE; |
| 816 | } |
| 817 | |
| 818 | std::vector<IComposerClient::PerFrameMetadataKey> AidlComposer::getPerFrameMetadataKeys( |
| 819 | Display display) { |
| 820 | std::vector<AidlPerFrameMetadataKey> keys; |
| 821 | const auto status = |
| 822 | mAidlComposerClient->getPerFrameMetadataKeys(translate<int64_t>(display), &keys); |
| 823 | if (!status.isOk()) { |
| 824 | ALOGE("getPerFrameMetadataKeys failed %s", status.getDescription().c_str()); |
| 825 | return {}; |
| 826 | } |
| 827 | return translate<IComposerClient::PerFrameMetadataKey>(keys); |
| 828 | } |
| 829 | |
| 830 | Error AidlComposer::getRenderIntents(Display display, ColorMode colorMode, |
| 831 | std::vector<RenderIntent>* outRenderIntents) { |
| 832 | std::vector<AidlRenderIntent> renderIntents; |
| 833 | const auto status = mAidlComposerClient->getRenderIntents(translate<int64_t>(display), |
| 834 | translate<AidlColorMode>(colorMode), |
| 835 | &renderIntents); |
| 836 | if (!status.isOk()) { |
| 837 | ALOGE("getRenderIntents failed %s", status.getDescription().c_str()); |
| 838 | return static_cast<Error>(status.getServiceSpecificError()); |
| 839 | } |
| 840 | *outRenderIntents = translate<RenderIntent>(renderIntents); |
| 841 | return Error::NONE; |
| 842 | } |
| 843 | |
| 844 | Error AidlComposer::getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) { |
| 845 | std::vector<float> matrix; |
| 846 | const auto status = |
| 847 | mAidlComposerClient->getDataspaceSaturationMatrix(translate<AidlDataspace>(dataspace), |
| 848 | &matrix); |
| 849 | if (!status.isOk()) { |
| 850 | ALOGE("getDataspaceSaturationMatrix failed %s", status.getDescription().c_str()); |
| 851 | return static_cast<Error>(status.getServiceSpecificError()); |
| 852 | } |
| 853 | *outMatrix = makeMat4(matrix); |
| 854 | return Error::NONE; |
| 855 | } |
| 856 | |
| 857 | Error AidlComposer::getDisplayIdentificationData(Display display, uint8_t* outPort, |
| 858 | std::vector<uint8_t>* outData) { |
| 859 | AidlDisplayIdentification displayIdentification; |
| 860 | const auto status = |
| 861 | mAidlComposerClient->getDisplayIdentificationData(translate<int64_t>(display), |
| 862 | &displayIdentification); |
| 863 | if (!status.isOk()) { |
| 864 | ALOGE("getDisplayIdentificationData failed %s", status.getDescription().c_str()); |
| 865 | return static_cast<Error>(status.getServiceSpecificError()); |
| 866 | } |
| 867 | |
| 868 | *outPort = static_cast<uint8_t>(displayIdentification.port); |
| 869 | *outData = displayIdentification.data; |
| 870 | |
| 871 | return Error::NONE; |
| 872 | } |
| 873 | |
| 874 | Error AidlComposer::setLayerColorTransform(Display display, Layer layer, const float* matrix) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 875 | mWriter.setLayerColorTransform(translate<int64_t>(display), translate<int64_t>(layer), matrix); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 876 | return Error::NONE; |
| 877 | } |
| 878 | |
| 879 | Error AidlComposer::getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat, |
| 880 | Dataspace* outDataspace, |
| 881 | uint8_t* outComponentMask) { |
| 882 | if (!outFormat || !outDataspace || !outComponentMask) { |
| 883 | return Error::BAD_PARAMETER; |
| 884 | } |
| 885 | |
| 886 | AidlDisplayContentSamplingAttributes attributes; |
| 887 | const auto status = |
| 888 | mAidlComposerClient->getDisplayedContentSamplingAttributes(translate<int64_t>(display), |
| 889 | &attributes); |
| 890 | if (!status.isOk()) { |
| 891 | ALOGE("getDisplayedContentSamplingAttributes failed %s", status.getDescription().c_str()); |
| 892 | return static_cast<Error>(status.getServiceSpecificError()); |
| 893 | } |
| 894 | |
| 895 | *outFormat = translate<PixelFormat>(attributes.format); |
| 896 | *outDataspace = translate<Dataspace>(attributes.dataspace); |
| 897 | *outComponentMask = static_cast<uint8_t>(attributes.componentMask); |
| 898 | return Error::NONE; |
| 899 | } |
| 900 | |
| 901 | Error AidlComposer::setDisplayContentSamplingEnabled(Display display, bool enabled, |
| 902 | uint8_t componentMask, uint64_t maxFrames) { |
| 903 | const auto status = |
| 904 | mAidlComposerClient |
| 905 | ->setDisplayedContentSamplingEnabled(translate<int64_t>(display), enabled, |
| 906 | static_cast<AidlFormatColorComponent>( |
| 907 | componentMask), |
| 908 | static_cast<int64_t>(maxFrames)); |
| 909 | if (!status.isOk()) { |
| 910 | ALOGE("setDisplayedContentSamplingEnabled failed %s", status.getDescription().c_str()); |
| 911 | return static_cast<Error>(status.getServiceSpecificError()); |
| 912 | } |
| 913 | return Error::NONE; |
| 914 | } |
| 915 | |
| 916 | Error AidlComposer::getDisplayedContentSample(Display display, uint64_t maxFrames, |
| 917 | uint64_t timestamp, DisplayedFrameStats* outStats) { |
| 918 | if (!outStats) { |
| 919 | return Error::BAD_PARAMETER; |
| 920 | } |
| 921 | |
| 922 | AidlDisplayContentSample sample; |
| 923 | const auto status = |
| 924 | mAidlComposerClient->getDisplayedContentSample(translate<int64_t>(display), |
| 925 | static_cast<int64_t>(maxFrames), |
| 926 | static_cast<int64_t>(timestamp), |
| 927 | &sample); |
| 928 | if (!status.isOk()) { |
| 929 | ALOGE("getDisplayedContentSample failed %s", status.getDescription().c_str()); |
| 930 | return static_cast<Error>(status.getServiceSpecificError()); |
| 931 | } |
| 932 | *outStats = translate<DisplayedFrameStats>(sample); |
| 933 | return Error::NONE; |
| 934 | } |
| 935 | |
| 936 | Error AidlComposer::setLayerPerFrameMetadataBlobs( |
| 937 | Display display, Layer layer, |
| 938 | const std::vector<IComposerClient::PerFrameMetadataBlob>& metadata) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 939 | mWriter.setLayerPerFrameMetadataBlobs(translate<int64_t>(display), translate<int64_t>(layer), |
| 940 | translate<AidlPerFrameMetadataBlob>(metadata)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 941 | return Error::NONE; |
| 942 | } |
| 943 | |
Alec Mouri | 4d8a05d | 2022-03-23 18:14:26 +0000 | [diff] [blame] | 944 | Error AidlComposer::setDisplayBrightness(Display display, float brightness, float brightnessNits, |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 945 | const DisplayBrightnessOptions& options) { |
Alec Mouri | 4d8a05d | 2022-03-23 18:14:26 +0000 | [diff] [blame] | 946 | mWriter.setDisplayBrightness(translate<int64_t>(display), brightness, brightnessNits); |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 947 | |
| 948 | if (options.applyImmediately) { |
| 949 | return execute(); |
| 950 | } |
| 951 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 952 | return Error::NONE; |
| 953 | } |
| 954 | |
| 955 | Error AidlComposer::getDisplayCapabilities(Display display, |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 956 | std::vector<AidlDisplayCapability>* outCapabilities) { |
| 957 | const auto status = mAidlComposerClient->getDisplayCapabilities(translate<int64_t>(display), |
| 958 | outCapabilities); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 959 | if (!status.isOk()) { |
| 960 | ALOGE("getDisplayCapabilities failed %s", status.getDescription().c_str()); |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 961 | outCapabilities->clear(); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 962 | return static_cast<Error>(status.getServiceSpecificError()); |
| 963 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 964 | return Error::NONE; |
| 965 | } |
| 966 | |
| 967 | V2_4::Error AidlComposer::getDisplayConnectionType( |
| 968 | Display display, IComposerClient::DisplayConnectionType* outType) { |
| 969 | AidlDisplayConnectionType type; |
| 970 | const auto status = |
| 971 | mAidlComposerClient->getDisplayConnectionType(translate<int64_t>(display), &type); |
| 972 | if (!status.isOk()) { |
| 973 | ALOGE("getDisplayConnectionType failed %s", status.getDescription().c_str()); |
| 974 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 975 | } |
| 976 | *outType = translate<IComposerClient::DisplayConnectionType>(type); |
| 977 | return V2_4::Error::NONE; |
| 978 | } |
| 979 | |
| 980 | V2_4::Error AidlComposer::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) { |
| 981 | int32_t vsyncPeriod; |
| 982 | const auto status = |
| 983 | mAidlComposerClient->getDisplayVsyncPeriod(translate<int64_t>(display), &vsyncPeriod); |
| 984 | if (!status.isOk()) { |
| 985 | ALOGE("getDisplayVsyncPeriod failed %s", status.getDescription().c_str()); |
| 986 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 987 | } |
| 988 | *outVsyncPeriod = translate<VsyncPeriodNanos>(vsyncPeriod); |
| 989 | return V2_4::Error::NONE; |
| 990 | } |
| 991 | |
| 992 | V2_4::Error AidlComposer::setActiveConfigWithConstraints( |
| 993 | Display display, Config config, |
| 994 | const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints, |
| 995 | VsyncPeriodChangeTimeline* outTimeline) { |
| 996 | AidlVsyncPeriodChangeTimeline timeline; |
| 997 | const auto status = |
| 998 | mAidlComposerClient |
| 999 | ->setActiveConfigWithConstraints(translate<int64_t>(display), |
| 1000 | translate<int32_t>(config), |
| 1001 | translate<AidlVsyncPeriodChangeConstraints>( |
| 1002 | vsyncPeriodChangeConstraints), |
| 1003 | &timeline); |
| 1004 | if (!status.isOk()) { |
| 1005 | ALOGE("setActiveConfigWithConstraints failed %s", status.getDescription().c_str()); |
| 1006 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1007 | } |
| 1008 | *outTimeline = translate<VsyncPeriodChangeTimeline>(timeline); |
| 1009 | return V2_4::Error::NONE; |
| 1010 | } |
| 1011 | |
| 1012 | V2_4::Error AidlComposer::setAutoLowLatencyMode(Display display, bool on) { |
| 1013 | const auto status = mAidlComposerClient->setAutoLowLatencyMode(translate<int64_t>(display), on); |
| 1014 | if (!status.isOk()) { |
| 1015 | ALOGE("setAutoLowLatencyMode failed %s", status.getDescription().c_str()); |
| 1016 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1017 | } |
| 1018 | return V2_4::Error::NONE; |
| 1019 | } |
| 1020 | |
| 1021 | V2_4::Error AidlComposer::getSupportedContentTypes( |
| 1022 | Display displayId, std::vector<IComposerClient::ContentType>* outSupportedContentTypes) { |
| 1023 | std::vector<AidlContentType> types; |
| 1024 | const auto status = |
| 1025 | mAidlComposerClient->getSupportedContentTypes(translate<int64_t>(displayId), &types); |
| 1026 | if (!status.isOk()) { |
| 1027 | ALOGE("getSupportedContentTypes failed %s", status.getDescription().c_str()); |
| 1028 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1029 | } |
| 1030 | *outSupportedContentTypes = translate<IComposerClient::ContentType>(types); |
| 1031 | return V2_4::Error::NONE; |
| 1032 | } |
| 1033 | |
| 1034 | V2_4::Error AidlComposer::setContentType(Display display, |
| 1035 | IComposerClient::ContentType contentType) { |
| 1036 | const auto status = |
| 1037 | mAidlComposerClient->setContentType(translate<int64_t>(display), |
| 1038 | translate<AidlContentType>(contentType)); |
| 1039 | if (!status.isOk()) { |
| 1040 | ALOGE("setContentType failed %s", status.getDescription().c_str()); |
| 1041 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1042 | } |
| 1043 | return V2_4::Error::NONE; |
| 1044 | } |
| 1045 | |
Ady Abraham | 3f97675 | 2021-12-20 16:17:50 -0800 | [diff] [blame] | 1046 | V2_4::Error AidlComposer::setLayerGenericMetadata(Display, Layer, const std::string&, bool, |
| 1047 | const std::vector<uint8_t>&) { |
| 1048 | // There are no users for this API. See b/209691612. |
| 1049 | return V2_4::Error::UNSUPPORTED; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | V2_4::Error AidlComposer::getLayerGenericMetadataKeys( |
Ady Abraham | 3f97675 | 2021-12-20 16:17:50 -0800 | [diff] [blame] | 1053 | std::vector<IComposerClient::LayerGenericMetadataKey>*) { |
| 1054 | // There are no users for this API. See b/209691612. |
| 1055 | return V2_4::Error::UNSUPPORTED; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 1058 | Error AidlComposer::setBootDisplayConfig(Display display, Config config) { |
| 1059 | const auto status = mAidlComposerClient->setBootDisplayConfig(translate<int64_t>(display), |
| 1060 | translate<int32_t>(config)); |
| 1061 | if (!status.isOk()) { |
| 1062 | ALOGE("setBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1063 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1064 | } |
| 1065 | return Error::NONE; |
| 1066 | } |
| 1067 | |
| 1068 | Error AidlComposer::clearBootDisplayConfig(Display display) { |
| 1069 | const auto status = mAidlComposerClient->clearBootDisplayConfig(translate<int64_t>(display)); |
| 1070 | if (!status.isOk()) { |
| 1071 | ALOGE("clearBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1072 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1073 | } |
| 1074 | return Error::NONE; |
| 1075 | } |
| 1076 | |
| 1077 | Error AidlComposer::getPreferredBootDisplayConfig(Display display, Config* config) { |
| 1078 | int32_t displayConfig; |
| 1079 | const auto status = |
| 1080 | mAidlComposerClient->getPreferredBootDisplayConfig(translate<int64_t>(display), |
| 1081 | &displayConfig); |
| 1082 | if (!status.isOk()) { |
| 1083 | ALOGE("getPreferredBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1084 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1085 | } |
| 1086 | *config = translate<uint32_t>(displayConfig); |
| 1087 | return Error::NONE; |
| 1088 | } |
| 1089 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1090 | Error AidlComposer::getClientTargetProperty( |
Alec Mouri | 8506569 | 2022-03-18 00:58:26 +0000 | [diff] [blame] | 1091 | Display display, ClientTargetPropertyWithBrightness* outClientTargetProperty) { |
| 1092 | *outClientTargetProperty = mReader.takeClientTargetProperty(translate<int64_t>(display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1093 | return Error::NONE; |
| 1094 | } |
| 1095 | |
Alec Mouri | 6da0e27 | 2022-02-07 12:45:57 -0800 | [diff] [blame] | 1096 | Error AidlComposer::setLayerBrightness(Display display, Layer layer, float brightness) { |
| 1097 | mWriter.setLayerBrightness(translate<int64_t>(display), translate<int64_t>(layer), brightness); |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1098 | return Error::NONE; |
| 1099 | } |
| 1100 | |
Leon Scroggins III | d77d316 | 2022-01-05 10:42:28 -0500 | [diff] [blame] | 1101 | Error AidlComposer::setLayerBlockingRegion(Display display, Layer layer, |
| 1102 | const std::vector<IComposerClient::Rect>& blocking) { |
| 1103 | mWriter.setLayerBlockingRegion(translate<int64_t>(display), translate<int64_t>(layer), |
| 1104 | translate<AidlRect>(blocking)); |
| 1105 | return Error::NONE; |
| 1106 | } |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 1107 | |
| 1108 | Error AidlComposer::getDisplayDecorationSupport(Display display, |
| 1109 | std::optional<DisplayDecorationSupport>* support) { |
| 1110 | const auto status = |
| 1111 | mAidlComposerClient->getDisplayDecorationSupport(translate<int64_t>(display), support); |
| 1112 | if (!status.isOk()) { |
| 1113 | ALOGE("getDisplayDecorationSupport failed %s", status.getDescription().c_str()); |
| 1114 | support->reset(); |
| 1115 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1116 | } |
| 1117 | return Error::NONE; |
| 1118 | } |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 1119 | |
| 1120 | Error AidlComposer::setIdleTimerEnabled(Display displayId, std::chrono::milliseconds timeout) { |
| 1121 | const auto status = |
| 1122 | mAidlComposerClient->setIdleTimerEnabled(translate<int64_t>(displayId), |
| 1123 | translate<int32_t>(timeout.count())); |
| 1124 | if (!status.isOk()) { |
| 1125 | ALOGE("setIdleTimerEnabled failed %s", status.getDescription().c_str()); |
| 1126 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1127 | } |
| 1128 | return Error::NONE; |
| 1129 | } |
| 1130 | |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 1131 | Error AidlComposer::getPhysicalDisplayOrientation(Display displayId, |
| 1132 | AidlTransform* outDisplayOrientation) { |
| 1133 | const auto status = |
| 1134 | mAidlComposerClient->getDisplayPhysicalOrientation(translate<int64_t>(displayId), |
| 1135 | outDisplayOrientation); |
| 1136 | if (!status.isOk()) { |
| 1137 | ALOGE("getPhysicalDisplayOrientation failed %s", status.getDescription().c_str()); |
| 1138 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1139 | } |
| 1140 | return Error::NONE; |
| 1141 | } |
| 1142 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1143 | } // namespace Hwc2 |
| 1144 | } // namespace android |