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