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