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