Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 18 | #define LOG_TAG "hwc-drm-two" |
| 19 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 20 | #include "DrmHwcTwo.h" |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 21 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 22 | #include <cutils/properties.h> |
| 23 | #include <hardware/hardware.h> |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 24 | #include <hardware/hwcomposer2.h> |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 25 | #include <log/log.h> |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 26 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 27 | #include <cinttypes> |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 28 | #include <string> |
| 29 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 30 | #include "backend/BackendManager.h" |
Roman Stratiienko | 33365c2 | 2020-10-10 23:06:36 +0300 | [diff] [blame] | 31 | #include "bufferinfo/BufferInfoGetter.h" |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 32 | #include "compositor/DrmDisplayComposition.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 33 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 34 | namespace android { |
| 35 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 36 | DrmHwcTwo::DrmHwcTwo() : hwc2_device() { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 37 | common.tag = HARDWARE_DEVICE_TAG; |
| 38 | common.version = HWC_DEVICE_API_VERSION_2_0; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 39 | common.close = HookDevClose; |
| 40 | getCapabilities = HookDevGetCapabilities; |
| 41 | getFunction = HookDevGetFunction; |
| 42 | } |
| 43 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 44 | HWC2::Error DrmHwcTwo::CreateDisplay(hwc2_display_t displ, |
| 45 | HWC2::DisplayType type) { |
| 46 | DrmDevice *drm = resource_manager_.GetDrmDevice(displ); |
| 47 | std::shared_ptr<Importer> importer = resource_manager_.GetImporter(displ); |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 48 | if (!drm || !importer) { |
| 49 | ALOGE("Failed to get a valid drmresource and importer"); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 50 | return HWC2::Error::NoResources; |
| 51 | } |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 52 | displays_.emplace(std::piecewise_construct, std::forward_as_tuple(displ), |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 53 | std::forward_as_tuple(&resource_manager_, drm, importer, |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 54 | displ, type)); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 55 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 56 | DrmCrtc *crtc = drm->GetCrtcForDisplay(static_cast<int>(displ)); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 57 | if (!crtc) { |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 58 | ALOGE("Failed to get crtc for display %d", static_cast<int>(displ)); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 59 | return HWC2::Error::BadDisplay; |
| 60 | } |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 61 | std::vector<DrmPlane *> display_planes; |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 62 | for (auto &plane : drm->planes()) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 63 | if (plane->GetCrtcSupported(*crtc)) |
| 64 | display_planes.push_back(plane.get()); |
| 65 | } |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 66 | displays_.at(displ).Init(&display_planes); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 67 | return HWC2::Error::None; |
| 68 | } |
| 69 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 70 | HWC2::Error DrmHwcTwo::Init() { |
| 71 | int rv = resource_manager_.Init(); |
| 72 | if (rv) { |
| 73 | ALOGE("Can't initialize the resource manager %d", rv); |
| 74 | return HWC2::Error::NoResources; |
| 75 | } |
| 76 | |
| 77 | HWC2::Error ret = HWC2::Error::None; |
| 78 | for (int i = 0; i < resource_manager_.getDisplayCount(); i++) { |
| 79 | ret = CreateDisplay(i, HWC2::DisplayType::Physical); |
| 80 | if (ret != HWC2::Error::None) { |
| 81 | ALOGE("Failed to create display %d with error %d", i, ret); |
| 82 | return ret; |
| 83 | } |
| 84 | } |
| 85 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 86 | auto &drm_devices = resource_manager_.getDrmDevices(); |
| 87 | for (auto &device : drm_devices) { |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 88 | // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 89 | device->RegisterHotplugHandler(new DrmHotplugHandler(this, device.get())); |
| 90 | } |
| 91 | return ret; |
| 92 | } |
| 93 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 94 | template <typename... Args> |
| 95 | static inline HWC2::Error unsupported(char const *func, Args... /*args*/) { |
| 96 | ALOGV("Unsupported function: %s", func); |
| 97 | return HWC2::Error::Unsupported; |
| 98 | } |
| 99 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 100 | static inline void supported(char const *func) { |
| 101 | ALOGV("Supported function: %s", func); |
| 102 | } |
| 103 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 104 | HWC2::Error DrmHwcTwo::CreateVirtualDisplay(uint32_t width, uint32_t height, |
| 105 | int32_t *format, |
| 106 | hwc2_display_t *display) { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 107 | // TODO(nobody): Implement virtual display |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 108 | return unsupported(__func__, width, height, format, display); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | HWC2::Error DrmHwcTwo::DestroyVirtualDisplay(hwc2_display_t display) { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 112 | // TODO(nobody): Implement virtual display |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 113 | return unsupported(__func__, display); |
| 114 | } |
| 115 | |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 116 | std::string DrmHwcTwo::HwcDisplay::DumpDelta( |
| 117 | DrmHwcTwo::HwcDisplay::Stats delta) { |
| 118 | if (delta.total_pixops_ == 0) |
| 119 | return "No stats yet"; |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 120 | double ratio = 1.0 - double(delta.gpu_pixops_) / double(delta.total_pixops_); |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 121 | |
| 122 | return (std::stringstream() |
| 123 | << " Total frames count: " << delta.total_frames_ << "\n" |
| 124 | << " Failed to test commit frames: " << delta.failed_kms_validate_ |
| 125 | << "\n" |
| 126 | << " Failed to commit frames: " << delta.failed_kms_present_ << "\n" |
| 127 | << ((delta.failed_kms_present_ > 0) |
| 128 | ? " !!! Internal failure, FIX it please\n" |
| 129 | : "") |
Roman Kovalivskyi | 9170b31 | 2020-02-03 18:13:57 +0200 | [diff] [blame] | 130 | << " Flattened frames: " << delta.frames_flattened_ << "\n" |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 131 | << " Pixel operations (free units)" |
| 132 | << " : [TOTAL: " << delta.total_pixops_ |
| 133 | << " / GPU: " << delta.gpu_pixops_ << "]\n" |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 134 | << " Composition efficiency: " << ratio) |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 135 | .str(); |
| 136 | } |
| 137 | |
| 138 | std::string DrmHwcTwo::HwcDisplay::Dump() { |
| 139 | auto out = (std::stringstream() |
| 140 | << "- Display on: " << connector_->name() << "\n" |
Roman Kovalivskyi | 9170b31 | 2020-02-03 18:13:57 +0200 | [diff] [blame] | 141 | << " Flattening state: " << compositor_.GetFlatteningState() |
| 142 | << "\n" |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 143 | << "Statistics since system boot:\n" |
| 144 | << DumpDelta(total_stats_) << "\n\n" |
| 145 | << "Statistics since last dumpsys request:\n" |
| 146 | << DumpDelta(total_stats_.minus(prev_stats_)) << "\n\n") |
| 147 | .str(); |
| 148 | |
| 149 | memcpy(&prev_stats_, &total_stats_, sizeof(Stats)); |
| 150 | return out; |
| 151 | } |
| 152 | |
| 153 | void DrmHwcTwo::Dump(uint32_t *outSize, char *outBuffer) { |
| 154 | supported(__func__); |
| 155 | |
| 156 | if (outBuffer != nullptr) { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 157 | auto copied_bytes = mDumpString.copy(outBuffer, *outSize); |
| 158 | *outSize = static_cast<uint32_t>(copied_bytes); |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | |
| 162 | std::stringstream output; |
| 163 | |
| 164 | output << "-- drm_hwcomposer --\n\n"; |
| 165 | |
| 166 | for (std::pair<const hwc2_display_t, DrmHwcTwo::HwcDisplay> &dp : displays_) |
| 167 | output << dp.second.Dump(); |
| 168 | |
| 169 | mDumpString = output.str(); |
| 170 | *outSize = static_cast<uint32_t>(mDumpString.size()); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | uint32_t DrmHwcTwo::GetMaxVirtualDisplayCount() { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 174 | // TODO(nobody): Implement virtual display |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 175 | unsupported(__func__); |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | HWC2::Error DrmHwcTwo::RegisterCallback(int32_t descriptor, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 180 | hwc2_callback_data_t data, |
| 181 | hwc2_function_pointer_t function) { |
| 182 | supported(__func__); |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 183 | |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 184 | switch (static_cast<HWC2::Callback>(descriptor)) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 185 | case HWC2::Callback::Hotplug: { |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 186 | SetHotplugCallback(data, function); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 187 | auto &drm_devices = resource_manager_.getDrmDevices(); |
| 188 | for (auto &device : drm_devices) |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 189 | HandleInitialHotplugState(device.get()); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 190 | break; |
| 191 | } |
Roman Kovalivskyi | 8fae156 | 2020-01-30 20:20:47 +0200 | [diff] [blame] | 192 | case HWC2::Callback::Refresh: { |
| 193 | for (std::pair<const hwc2_display_t, DrmHwcTwo::HwcDisplay> &d : |
| 194 | displays_) |
| 195 | d.second.RegisterRefreshCallback(data, function); |
| 196 | break; |
| 197 | } |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 198 | case HWC2::Callback::Vsync: { |
| 199 | for (std::pair<const hwc2_display_t, DrmHwcTwo::HwcDisplay> &d : |
| 200 | displays_) |
| 201 | d.second.RegisterVsyncCallback(data, function); |
| 202 | break; |
| 203 | } |
| 204 | default: |
| 205 | break; |
| 206 | } |
| 207 | return HWC2::Error::None; |
| 208 | } |
| 209 | |
Alexandru Gheorghe | 6f0030f | 2018-05-01 17:25:48 +0100 | [diff] [blame] | 210 | DrmHwcTwo::HwcDisplay::HwcDisplay(ResourceManager *resource_manager, |
| 211 | DrmDevice *drm, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 212 | std::shared_ptr<Importer> importer, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 213 | hwc2_display_t handle, HWC2::DisplayType type) |
Alexandru Gheorghe | 6f0030f | 2018-05-01 17:25:48 +0100 | [diff] [blame] | 214 | : resource_manager_(resource_manager), |
| 215 | drm_(drm), |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 216 | importer_(std::move(importer)), |
Alexandru Gheorghe | 6f0030f | 2018-05-01 17:25:48 +0100 | [diff] [blame] | 217 | handle_(handle), |
Roman Kovalivskyi | 12b91a3 | 2019-12-11 19:09:51 +0200 | [diff] [blame] | 218 | type_(type), |
| 219 | color_transform_hint_(HAL_COLOR_TRANSFORM_IDENTITY) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 220 | supported(__func__); |
Roman Kovalivskyi | 12b91a3 | 2019-12-11 19:09:51 +0200 | [diff] [blame] | 221 | |
| 222 | // clang-format off |
| 223 | color_transform_matrix_ = {1.0, 0.0, 0.0, 0.0, |
| 224 | 0.0, 1.0, 0.0, 0.0, |
| 225 | 0.0, 0.0, 1.0, 0.0, |
| 226 | 0.0, 0.0, 0.0, 1.0}; |
| 227 | // clang-format on |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 228 | } |
| 229 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 230 | void DrmHwcTwo::HwcDisplay::ClearDisplay() { |
| 231 | compositor_.ClearDisplay(); |
| 232 | } |
| 233 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 234 | HWC2::Error DrmHwcTwo::HwcDisplay::Init(std::vector<DrmPlane *> *planes) { |
| 235 | supported(__func__); |
| 236 | planner_ = Planner::CreateInstance(drm_); |
| 237 | if (!planner_) { |
| 238 | ALOGE("Failed to create planner instance for composition"); |
| 239 | return HWC2::Error::NoResources; |
| 240 | } |
| 241 | |
| 242 | int display = static_cast<int>(handle_); |
Alexandru Gheorghe | 62e2d2c | 2018-05-11 11:40:53 +0100 | [diff] [blame] | 243 | int ret = compositor_.Init(resource_manager_, display); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 244 | if (ret) { |
| 245 | ALOGE("Failed display compositor init for display %d (%d)", display, ret); |
| 246 | return HWC2::Error::NoResources; |
| 247 | } |
| 248 | |
| 249 | // Split up the given display planes into primary and overlay to properly |
| 250 | // interface with the composition |
| 251 | char use_overlay_planes_prop[PROPERTY_VALUE_MAX]; |
Jason Macnak | f1af957 | 2020-08-20 11:49:51 -0700 | [diff] [blame] | 252 | property_get("vendor.hwc.drm.use_overlay_planes", use_overlay_planes_prop, |
| 253 | "1"); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 254 | bool use_overlay_planes = strtol(use_overlay_planes_prop, nullptr, 10); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 255 | for (auto &plane : *planes) { |
| 256 | if (plane->type() == DRM_PLANE_TYPE_PRIMARY) |
| 257 | primary_planes_.push_back(plane); |
| 258 | else if (use_overlay_planes && (plane)->type() == DRM_PLANE_TYPE_OVERLAY) |
| 259 | overlay_planes_.push_back(plane); |
| 260 | } |
| 261 | |
| 262 | crtc_ = drm_->GetCrtcForDisplay(display); |
| 263 | if (!crtc_) { |
| 264 | ALOGE("Failed to get crtc for display %d", display); |
| 265 | return HWC2::Error::BadDisplay; |
| 266 | } |
| 267 | |
| 268 | connector_ = drm_->GetConnectorForDisplay(display); |
| 269 | if (!connector_) { |
| 270 | ALOGE("Failed to get connector for display %d", display); |
| 271 | return HWC2::Error::BadDisplay; |
| 272 | } |
| 273 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 274 | ret = vsync_worker_.Init(drm_, display); |
| 275 | if (ret) { |
| 276 | ALOGE("Failed to create event worker for d=%d %d\n", display, ret); |
| 277 | return HWC2::Error::BadDisplay; |
| 278 | } |
| 279 | |
Matvii Zorin | ef3c797 | 2020-08-11 15:15:44 +0300 | [diff] [blame] | 280 | ret = BackendManager::GetInstance().SetBackendForDisplay(this); |
| 281 | if (ret) { |
| 282 | ALOGE("Failed to set backend for d=%d %d\n", display, ret); |
| 283 | return HWC2::Error::BadDisplay; |
| 284 | } |
| 285 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 286 | return ChosePreferredConfig(); |
| 287 | } |
| 288 | |
| 289 | HWC2::Error DrmHwcTwo::HwcDisplay::ChosePreferredConfig() { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 290 | // Fetch the number of modes from the display |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 291 | uint32_t num_configs = 0; |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 292 | HWC2::Error err = GetDisplayConfigs(&num_configs, nullptr); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 293 | if (err != HWC2::Error::None || !num_configs) |
| 294 | return err; |
| 295 | |
Andrii Chepurnyi | 1b1e35e | 2019-02-19 21:38:13 +0200 | [diff] [blame] | 296 | return SetActiveConfig(connector_->get_preferred_mode_id()); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 297 | } |
| 298 | |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 299 | void DrmHwcTwo::HwcDisplay::RegisterVsyncCallback( |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 300 | hwc2_callback_data_t data, hwc2_function_pointer_t func) { |
| 301 | supported(__func__); |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 302 | vsync_worker_.RegisterClientCallback(data, func); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 303 | } |
| 304 | |
Roman Kovalivskyi | 8fae156 | 2020-01-30 20:20:47 +0200 | [diff] [blame] | 305 | void DrmHwcTwo::HwcDisplay::RegisterRefreshCallback( |
| 306 | hwc2_callback_data_t data, hwc2_function_pointer_t func) { |
| 307 | supported(__func__); |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 308 | compositor_.SetRefreshCallback(data, func); |
Roman Kovalivskyi | 8fae156 | 2020-01-30 20:20:47 +0200 | [diff] [blame] | 309 | } |
| 310 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 311 | HWC2::Error DrmHwcTwo::HwcDisplay::AcceptDisplayChanges() { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 312 | supported(__func__); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 313 | for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) |
| 314 | l.second.accept_type_change(); |
| 315 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | HWC2::Error DrmHwcTwo::HwcDisplay::CreateLayer(hwc2_layer_t *layer) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 319 | supported(__func__); |
| 320 | layers_.emplace(static_cast<hwc2_layer_t>(layer_idx_), HwcLayer()); |
| 321 | *layer = static_cast<hwc2_layer_t>(layer_idx_); |
| 322 | ++layer_idx_; |
| 323 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | HWC2::Error DrmHwcTwo::HwcDisplay::DestroyLayer(hwc2_layer_t layer) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 327 | supported(__func__); |
Vincent Donnefort | 9abec03 | 2019-10-09 15:43:43 +0100 | [diff] [blame] | 328 | if (!get_layer(layer)) |
| 329 | return HWC2::Error::BadLayer; |
| 330 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 331 | layers_.erase(layer); |
| 332 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | HWC2::Error DrmHwcTwo::HwcDisplay::GetActiveConfig(hwc2_config_t *config) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 336 | supported(__func__); |
| 337 | DrmMode const &mode = connector_->active_mode(); |
| 338 | if (mode.id() == 0) |
| 339 | return HWC2::Error::BadConfig; |
| 340 | |
| 341 | *config = mode.id(); |
| 342 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | HWC2::Error DrmHwcTwo::HwcDisplay::GetChangedCompositionTypes( |
| 346 | uint32_t *num_elements, hwc2_layer_t *layers, int32_t *types) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 347 | supported(__func__); |
| 348 | uint32_t num_changes = 0; |
| 349 | for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) { |
| 350 | if (l.second.type_changed()) { |
| 351 | if (layers && num_changes < *num_elements) |
| 352 | layers[num_changes] = l.first; |
| 353 | if (types && num_changes < *num_elements) |
| 354 | types[num_changes] = static_cast<int32_t>(l.second.validated_type()); |
| 355 | ++num_changes; |
| 356 | } |
| 357 | } |
| 358 | if (!layers && !types) |
| 359 | *num_elements = num_changes; |
| 360 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | HWC2::Error DrmHwcTwo::HwcDisplay::GetClientTargetSupport(uint32_t width, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 364 | uint32_t height, |
| 365 | int32_t /*format*/, |
| 366 | int32_t dataspace) { |
| 367 | supported(__func__); |
| 368 | std::pair<uint32_t, uint32_t> min = drm_->min_resolution(); |
| 369 | std::pair<uint32_t, uint32_t> max = drm_->max_resolution(); |
| 370 | |
| 371 | if (width < min.first || height < min.second) |
| 372 | return HWC2::Error::Unsupported; |
| 373 | |
| 374 | if (width > max.first || height > max.second) |
| 375 | return HWC2::Error::Unsupported; |
| 376 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 377 | if (dataspace != HAL_DATASPACE_UNKNOWN) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 378 | return HWC2::Error::Unsupported; |
| 379 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 380 | // TODO(nobody): Validate format can be handled by either GL or planes |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 381 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | HWC2::Error DrmHwcTwo::HwcDisplay::GetColorModes(uint32_t *num_modes, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 385 | int32_t *modes) { |
| 386 | supported(__func__); |
Kalyan Kondapally | da5839c | 2016-11-10 10:59:50 -0800 | [diff] [blame] | 387 | if (!modes) |
| 388 | *num_modes = 1; |
| 389 | |
| 390 | if (modes) |
| 391 | *modes = HAL_COLOR_MODE_NATIVE; |
| 392 | |
| 393 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayAttribute(hwc2_config_t config, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 397 | int32_t attribute_in, |
| 398 | int32_t *value) { |
| 399 | supported(__func__); |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 400 | auto mode = std::find_if(connector_->modes().begin(), |
| 401 | connector_->modes().end(), |
| 402 | [config](DrmMode const &m) { |
| 403 | return m.id() == config; |
| 404 | }); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 405 | if (mode == connector_->modes().end()) { |
| 406 | ALOGE("Could not find active mode for %d", config); |
| 407 | return HWC2::Error::BadConfig; |
| 408 | } |
| 409 | |
| 410 | static const int32_t kUmPerInch = 25400; |
| 411 | uint32_t mm_width = connector_->mm_width(); |
| 412 | uint32_t mm_height = connector_->mm_height(); |
| 413 | auto attribute = static_cast<HWC2::Attribute>(attribute_in); |
| 414 | switch (attribute) { |
| 415 | case HWC2::Attribute::Width: |
| 416 | *value = mode->h_display(); |
| 417 | break; |
| 418 | case HWC2::Attribute::Height: |
| 419 | *value = mode->v_display(); |
| 420 | break; |
| 421 | case HWC2::Attribute::VsyncPeriod: |
| 422 | // in nanoseconds |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 423 | *value = 1000.0 * 1000.0 * 1000.0 / mode->v_refresh(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 424 | break; |
| 425 | case HWC2::Attribute::DpiX: |
| 426 | // Dots per 1000 inches |
| 427 | *value = mm_width ? (mode->h_display() * kUmPerInch) / mm_width : -1; |
| 428 | break; |
| 429 | case HWC2::Attribute::DpiY: |
| 430 | // Dots per 1000 inches |
| 431 | *value = mm_height ? (mode->v_display() * kUmPerInch) / mm_height : -1; |
| 432 | break; |
Roman Stratiienko | 6f5df17 | 2020-09-27 22:48:08 +0300 | [diff] [blame] | 433 | #if PLATFORM_SDK_VERSION > 29 |
| 434 | case HWC2::Attribute::ConfigGroup: |
| 435 | *value = 0; /* TODO: Add support for config groups */ |
| 436 | break; |
| 437 | #endif |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 438 | default: |
| 439 | *value = -1; |
| 440 | return HWC2::Error::BadConfig; |
| 441 | } |
| 442 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayConfigs(uint32_t *num_configs, |
| 446 | hwc2_config_t *configs) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 447 | supported(__func__); |
| 448 | // Since this callback is normally invoked twice (once to get the count, and |
| 449 | // once to populate configs), we don't really want to read the edid |
| 450 | // redundantly. Instead, only update the modes on the first invocation. While |
| 451 | // it's possible this will result in stale modes, it'll all come out in the |
| 452 | // wash when we try to set the active config later. |
| 453 | if (!configs) { |
| 454 | int ret = connector_->UpdateModes(); |
| 455 | if (ret) { |
| 456 | ALOGE("Failed to update display modes %d", ret); |
| 457 | return HWC2::Error::BadDisplay; |
| 458 | } |
| 459 | } |
| 460 | |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 461 | // Since the upper layers only look at vactive/hactive/refresh, height and |
| 462 | // width, it doesn't differentiate interlaced from progressive and other |
| 463 | // similar modes. Depending on the order of modes we return to SF, it could |
| 464 | // end up choosing a suboptimal configuration and dropping the preferred |
| 465 | // mode. To workaround this, don't offer interlaced modes to SF if there is |
| 466 | // at least one non-interlaced alternative and only offer a single WxH@R |
| 467 | // mode with at least the prefered mode from in DrmConnector::UpdateModes() |
| 468 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 469 | // TODO(nobody): Remove the following block of code until AOSP handles all |
| 470 | // modes |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 471 | std::vector<DrmMode> sel_modes; |
| 472 | |
| 473 | // Add the preferred mode first to be sure it's not dropped |
| 474 | auto mode = std::find_if(connector_->modes().begin(), |
| 475 | connector_->modes().end(), [&](DrmMode const &m) { |
| 476 | return m.id() == |
| 477 | connector_->get_preferred_mode_id(); |
| 478 | }); |
| 479 | if (mode != connector_->modes().end()) |
| 480 | sel_modes.push_back(*mode); |
| 481 | |
| 482 | // Add the active mode if different from preferred mode |
| 483 | if (connector_->active_mode().id() != connector_->get_preferred_mode_id()) |
| 484 | sel_modes.push_back(connector_->active_mode()); |
| 485 | |
| 486 | // Cycle over the modes and filter out "similar" modes, keeping only the |
| 487 | // first ones in the order given by DRM (from CEA ids and timings order) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 488 | for (const DrmMode &mode : connector_->modes()) { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 489 | // TODO(nobody): Remove this when 3D Attributes are in AOSP |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 490 | if (mode.flags() & DRM_MODE_FLAG_3D_MASK) |
| 491 | continue; |
| 492 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 493 | // TODO(nobody): Remove this when the Interlaced attribute is in AOSP |
Neil Armstrong | 4c027a7 | 2019-06-04 14:48:02 +0000 | [diff] [blame] | 494 | if (mode.flags() & DRM_MODE_FLAG_INTERLACE) { |
| 495 | auto m = std::find_if(connector_->modes().begin(), |
| 496 | connector_->modes().end(), |
| 497 | [&mode](DrmMode const &m) { |
| 498 | return !(m.flags() & DRM_MODE_FLAG_INTERLACE) && |
| 499 | m.h_display() == mode.h_display() && |
| 500 | m.v_display() == mode.v_display(); |
| 501 | }); |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 502 | if (m == connector_->modes().end()) |
| 503 | sel_modes.push_back(mode); |
| 504 | |
| 505 | continue; |
Neil Armstrong | 4c027a7 | 2019-06-04 14:48:02 +0000 | [diff] [blame] | 506 | } |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 507 | |
| 508 | // Search for a similar WxH@R mode in the filtered list and drop it if |
| 509 | // another mode with the same WxH@R has already been selected |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 510 | // TODO(nobody): Remove this when AOSP handles duplicates modes |
Neil Armstrong | b67d049 | 2019-06-20 09:00:21 +0000 | [diff] [blame] | 511 | auto m = std::find_if(sel_modes.begin(), sel_modes.end(), |
| 512 | [&mode](DrmMode const &m) { |
| 513 | return m.h_display() == mode.h_display() && |
| 514 | m.v_display() == mode.v_display() && |
| 515 | m.v_refresh() == mode.v_refresh(); |
| 516 | }); |
| 517 | if (m == sel_modes.end()) |
| 518 | sel_modes.push_back(mode); |
| 519 | } |
| 520 | |
| 521 | auto num_modes = static_cast<uint32_t>(sel_modes.size()); |
| 522 | if (!configs) { |
| 523 | *num_configs = num_modes; |
| 524 | return HWC2::Error::None; |
| 525 | } |
| 526 | |
| 527 | uint32_t idx = 0; |
| 528 | for (const DrmMode &mode : sel_modes) { |
| 529 | if (idx >= *num_configs) |
| 530 | break; |
| 531 | configs[idx++] = mode.id(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 532 | } |
| 533 | *num_configs = idx; |
| 534 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayName(uint32_t *size, char *name) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 538 | supported(__func__); |
| 539 | std::ostringstream stream; |
| 540 | stream << "display-" << connector_->id(); |
| 541 | std::string string = stream.str(); |
| 542 | size_t length = string.length(); |
| 543 | if (!name) { |
| 544 | *size = length; |
| 545 | return HWC2::Error::None; |
| 546 | } |
| 547 | |
| 548 | *size = std::min<uint32_t>(static_cast<uint32_t>(length - 1), *size); |
| 549 | strncpy(name, string.c_str(), *size); |
| 550 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 551 | } |
| 552 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 553 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayRequests(int32_t *display_requests, |
| 554 | uint32_t *num_elements, |
| 555 | hwc2_layer_t *layers, |
| 556 | int32_t *layer_requests) { |
| 557 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 558 | // TODO(nobody): I think virtual display should request |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 559 | // HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT here |
| 560 | unsupported(__func__, display_requests, num_elements, layers, layer_requests); |
| 561 | *num_elements = 0; |
| 562 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayType(int32_t *type) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 566 | supported(__func__); |
| 567 | *type = static_cast<int32_t>(type_); |
| 568 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDozeSupport(int32_t *support) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 572 | supported(__func__); |
| 573 | *support = 0; |
| 574 | return HWC2::Error::None; |
| 575 | } |
| 576 | |
| 577 | HWC2::Error DrmHwcTwo::HwcDisplay::GetHdrCapabilities( |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 578 | uint32_t *num_types, int32_t * /*types*/, float * /*max_luminance*/, |
| 579 | float * /*max_average_luminance*/, float * /*min_luminance*/) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 580 | supported(__func__); |
| 581 | *num_types = 0; |
| 582 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | HWC2::Error DrmHwcTwo::HwcDisplay::GetReleaseFences(uint32_t *num_elements, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 586 | hwc2_layer_t *layers, |
| 587 | int32_t *fences) { |
| 588 | supported(__func__); |
| 589 | uint32_t num_layers = 0; |
| 590 | |
| 591 | for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) { |
| 592 | ++num_layers; |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 593 | if (layers == nullptr || fences == nullptr) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 594 | continue; |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 595 | |
| 596 | if (num_layers > *num_elements) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 597 | ALOGW("Overflow num_elements %d/%d", num_layers, *num_elements); |
| 598 | return HWC2::Error::None; |
| 599 | } |
| 600 | |
| 601 | layers[num_layers - 1] = l.first; |
| 602 | fences[num_layers - 1] = l.second.take_release_fence(); |
| 603 | } |
| 604 | *num_elements = num_layers; |
| 605 | return HWC2::Error::None; |
| 606 | } |
| 607 | |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 608 | void DrmHwcTwo::HwcDisplay::AddFenceToPresentFence(int fd) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 609 | if (fd < 0) |
| 610 | return; |
| 611 | |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 612 | if (present_fence_.get() >= 0) { |
| 613 | int old_fence = present_fence_.get(); |
| 614 | present_fence_.Set(sync_merge("dc_present", old_fence, fd)); |
| 615 | close(fd); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 616 | } else { |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 617 | present_fence_.Set(fd); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 618 | } |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 619 | } |
| 620 | |
Roman Stratiienko | afb3689 | 2019-11-08 17:16:11 +0200 | [diff] [blame] | 621 | bool DrmHwcTwo::HwcDisplay::HardwareSupportsLayerType( |
| 622 | HWC2::Composition comp_type) { |
| 623 | return comp_type == HWC2::Composition::Device || |
| 624 | comp_type == HWC2::Composition::Cursor; |
| 625 | } |
| 626 | |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 627 | HWC2::Error DrmHwcTwo::HwcDisplay::CreateComposition(bool test) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 628 | std::vector<DrmCompositionDisplayLayersMap> layers_map; |
| 629 | layers_map.emplace_back(); |
| 630 | DrmCompositionDisplayLayersMap &map = layers_map.back(); |
| 631 | |
| 632 | map.display = static_cast<int>(handle_); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 633 | map.geometry_changed = true; // TODO(nobody): Fix this |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 634 | |
| 635 | // order the layers by z-order |
| 636 | bool use_client_layer = false; |
Alexandru Gheorghe | 1542d29 | 2018-06-13 16:46:36 +0100 | [diff] [blame] | 637 | uint32_t client_z_order = UINT32_MAX; |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 638 | std::map<uint32_t, DrmHwcTwo::HwcLayer *> z_map; |
| 639 | for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) { |
Roman Stratiienko | f264723 | 2019-11-21 01:58:35 +0200 | [diff] [blame] | 640 | switch (l.second.validated_type()) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 641 | case HWC2::Composition::Device: |
| 642 | z_map.emplace(std::make_pair(l.second.z_order(), &l.second)); |
| 643 | break; |
| 644 | case HWC2::Composition::Client: |
Alexandru Gheorghe | 1542d29 | 2018-06-13 16:46:36 +0100 | [diff] [blame] | 645 | // Place it at the z_order of the lowest client layer |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 646 | use_client_layer = true; |
Alexandru Gheorghe | 1542d29 | 2018-06-13 16:46:36 +0100 | [diff] [blame] | 647 | client_z_order = std::min(client_z_order, l.second.z_order()); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 648 | break; |
| 649 | default: |
| 650 | continue; |
| 651 | } |
| 652 | } |
| 653 | if (use_client_layer) |
| 654 | z_map.emplace(std::make_pair(client_z_order, &client_layer_)); |
| 655 | |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 656 | if (z_map.empty()) |
| 657 | return HWC2::Error::BadLayer; |
| 658 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 659 | // now that they're ordered by z, add them to the composition |
| 660 | for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) { |
| 661 | DrmHwcLayer layer; |
| 662 | l.second->PopulateDrmLayer(&layer); |
Andrii Chepurnyi | dc1278c | 2018-03-20 19:41:18 +0200 | [diff] [blame] | 663 | int ret = layer.ImportBuffer(importer_.get()); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 664 | if (ret) { |
| 665 | ALOGE("Failed to import layer, ret=%d", ret); |
| 666 | return HWC2::Error::NoResources; |
| 667 | } |
| 668 | map.layers.emplace_back(std::move(layer)); |
| 669 | } |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 670 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 671 | std::unique_ptr<DrmDisplayComposition> composition = compositor_ |
| 672 | .CreateComposition(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 673 | composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_); |
| 674 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 675 | // TODO(nobody): Don't always assume geometry changed |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 676 | int ret = composition->SetLayers(map.layers.data(), map.layers.size(), true); |
| 677 | if (ret) { |
| 678 | ALOGE("Failed to set layers in the composition ret=%d", ret); |
| 679 | return HWC2::Error::BadLayer; |
| 680 | } |
| 681 | |
| 682 | std::vector<DrmPlane *> primary_planes(primary_planes_); |
| 683 | std::vector<DrmPlane *> overlay_planes(overlay_planes_); |
Rob Herring | af0d975 | 2018-05-04 16:34:19 -0500 | [diff] [blame] | 684 | ret = composition->Plan(&primary_planes, &overlay_planes); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 685 | if (ret) { |
| 686 | ALOGE("Failed to plan the composition ret=%d", ret); |
| 687 | return HWC2::Error::BadConfig; |
| 688 | } |
| 689 | |
| 690 | // Disable the planes we're not using |
| 691 | for (auto i = primary_planes.begin(); i != primary_planes.end();) { |
| 692 | composition->AddPlaneDisable(*i); |
| 693 | i = primary_planes.erase(i); |
| 694 | } |
| 695 | for (auto i = overlay_planes.begin(); i != overlay_planes.end();) { |
| 696 | composition->AddPlaneDisable(*i); |
| 697 | i = overlay_planes.erase(i); |
| 698 | } |
| 699 | |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 700 | if (test) { |
| 701 | ret = compositor_.TestComposition(composition.get()); |
| 702 | } else { |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 703 | ret = compositor_.ApplyComposition(std::move(composition)); |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 704 | AddFenceToPresentFence(compositor_.TakeOutFence()); |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 705 | } |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 706 | if (ret) { |
John Stultz | 78c9f6c | 2018-05-24 16:43:35 -0700 | [diff] [blame] | 707 | if (!test) |
| 708 | ALOGE("Failed to apply the frame composition ret=%d", ret); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 709 | return HWC2::Error::BadParameter; |
| 710 | } |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 711 | return HWC2::Error::None; |
| 712 | } |
| 713 | |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 714 | HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *present_fence) { |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 715 | supported(__func__); |
| 716 | HWC2::Error ret; |
| 717 | |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 718 | ++total_stats_.total_frames_; |
| 719 | |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 720 | ret = CreateComposition(false); |
Roman Stratiienko | 0d1a2cd | 2019-11-28 17:51:16 +0200 | [diff] [blame] | 721 | if (ret != HWC2::Error::None) |
| 722 | ++total_stats_.failed_kms_present_; |
| 723 | |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 724 | if (ret == HWC2::Error::BadLayer) { |
| 725 | // Can we really have no client or device layers? |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 726 | *present_fence = -1; |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 727 | return HWC2::Error::None; |
| 728 | } |
| 729 | if (ret != HWC2::Error::None) |
| 730 | return ret; |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 731 | |
Matteo Franchin | c56eede | 2019-12-03 17:10:38 +0000 | [diff] [blame] | 732 | *present_fence = present_fence_.Release(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 733 | |
| 734 | ++frame_no_; |
| 735 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | HWC2::Error DrmHwcTwo::HwcDisplay::SetActiveConfig(hwc2_config_t config) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 739 | supported(__func__); |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 740 | auto mode = std::find_if(connector_->modes().begin(), |
| 741 | connector_->modes().end(), |
| 742 | [config](DrmMode const &m) { |
| 743 | return m.id() == config; |
| 744 | }); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 745 | if (mode == connector_->modes().end()) { |
| 746 | ALOGE("Could not find active mode for %d", config); |
| 747 | return HWC2::Error::BadConfig; |
| 748 | } |
| 749 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 750 | std::unique_ptr<DrmDisplayComposition> composition = compositor_ |
| 751 | .CreateComposition(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 752 | composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_); |
| 753 | int ret = composition->SetDisplayMode(*mode); |
Roman Stratiienko | 6a10c4c | 2021-02-15 11:25:23 +0200 | [diff] [blame] | 754 | if (ret) { |
| 755 | return HWC2::Error::BadConfig; |
| 756 | } |
Sean Paul | ed45a8e | 2017-02-28 13:17:34 -0500 | [diff] [blame] | 757 | ret = compositor_.ApplyComposition(std::move(composition)); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 758 | if (ret) { |
| 759 | ALOGE("Failed to queue dpms composition on %d", ret); |
| 760 | return HWC2::Error::BadConfig; |
| 761 | } |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 762 | |
| 763 | connector_->set_active_mode(*mode); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 764 | |
| 765 | // Setup the client layer's dimensions |
| 766 | hwc_rect_t display_frame = {.left = 0, |
| 767 | .top = 0, |
| 768 | .right = static_cast<int>(mode->h_display()), |
| 769 | .bottom = static_cast<int>(mode->v_display())}; |
| 770 | client_layer_.SetLayerDisplayFrame(display_frame); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 771 | |
| 772 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | HWC2::Error DrmHwcTwo::HwcDisplay::SetClientTarget(buffer_handle_t target, |
| 776 | int32_t acquire_fence, |
| 777 | int32_t dataspace, |
Rob Herring | 1b2685c | 2017-11-29 10:19:57 -0600 | [diff] [blame] | 778 | hwc_region_t /*damage*/) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 779 | supported(__func__); |
| 780 | UniqueFd uf(acquire_fence); |
| 781 | |
| 782 | client_layer_.set_buffer(target); |
| 783 | client_layer_.set_acquire_fence(uf.get()); |
| 784 | client_layer_.SetLayerDataspace(dataspace); |
Roman Stratiienko | 33365c2 | 2020-10-10 23:06:36 +0300 | [diff] [blame] | 785 | |
| 786 | /* TODO: Do not update source_crop every call. |
| 787 | * It makes sense to do it once after every hotplug event. */ |
| 788 | hwc_drm_bo bo{}; |
| 789 | BufferInfoGetter::GetInstance()->ConvertBoInfo(target, &bo); |
| 790 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 791 | hwc_frect_t source_crop = {.left = 0.0F, |
| 792 | .top = 0.0F, |
| 793 | .right = bo.width + 0.0F, |
| 794 | .bottom = bo.height + 0.0F}; |
Roman Stratiienko | 33365c2 | 2020-10-10 23:06:36 +0300 | [diff] [blame] | 795 | client_layer_.SetLayerSourceCrop(source_crop); |
| 796 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 797 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | HWC2::Error DrmHwcTwo::HwcDisplay::SetColorMode(int32_t mode) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 801 | supported(__func__); |
Kalyan Kondapally | da5839c | 2016-11-10 10:59:50 -0800 | [diff] [blame] | 802 | |
Roman Stratiienko | d146d6d | 2020-10-04 23:56:46 +0300 | [diff] [blame] | 803 | if (mode < HAL_COLOR_MODE_NATIVE || mode > HAL_COLOR_MODE_BT2100_HLG) |
| 804 | return HWC2::Error::BadParameter; |
| 805 | |
Kalyan Kondapally | da5839c | 2016-11-10 10:59:50 -0800 | [diff] [blame] | 806 | if (mode != HAL_COLOR_MODE_NATIVE) |
Roman Stratiienko | 27d2ed6 | 2020-09-26 23:59:19 +0300 | [diff] [blame] | 807 | return HWC2::Error::Unsupported; |
Kalyan Kondapally | da5839c | 2016-11-10 10:59:50 -0800 | [diff] [blame] | 808 | |
| 809 | color_mode_ = mode; |
| 810 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | HWC2::Error DrmHwcTwo::HwcDisplay::SetColorTransform(const float *matrix, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 814 | int32_t hint) { |
| 815 | supported(__func__); |
Roman Kovalivskyi | 12b91a3 | 2019-12-11 19:09:51 +0200 | [diff] [blame] | 816 | if (hint < HAL_COLOR_TRANSFORM_IDENTITY || |
| 817 | hint > HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA) |
| 818 | return HWC2::Error::BadParameter; |
| 819 | |
| 820 | if (!matrix && hint == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX) |
| 821 | return HWC2::Error::BadParameter; |
| 822 | |
| 823 | color_transform_hint_ = static_cast<android_color_transform_t>(hint); |
| 824 | if (color_transform_hint_ == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX) |
| 825 | std::copy(matrix, matrix + MATRIX_SIZE, color_transform_matrix_.begin()); |
| 826 | |
| 827 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | HWC2::Error DrmHwcTwo::HwcDisplay::SetOutputBuffer(buffer_handle_t buffer, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 831 | int32_t release_fence) { |
| 832 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 833 | // TODO(nobody): Need virtual display support |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 834 | return unsupported(__func__, buffer, release_fence); |
| 835 | } |
| 836 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 837 | HWC2::Error DrmHwcTwo::HwcDisplay::SetPowerMode(int32_t mode_in) { |
| 838 | supported(__func__); |
| 839 | uint64_t dpms_value = 0; |
| 840 | auto mode = static_cast<HWC2::PowerMode>(mode_in); |
| 841 | switch (mode) { |
| 842 | case HWC2::PowerMode::Off: |
| 843 | dpms_value = DRM_MODE_DPMS_OFF; |
| 844 | break; |
| 845 | case HWC2::PowerMode::On: |
| 846 | dpms_value = DRM_MODE_DPMS_ON; |
| 847 | break; |
Vincent Donnefort | 60ef7eb | 2019-10-09 11:39:28 +0100 | [diff] [blame] | 848 | case HWC2::PowerMode::Doze: |
| 849 | case HWC2::PowerMode::DozeSuspend: |
| 850 | return HWC2::Error::Unsupported; |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 851 | default: |
| 852 | ALOGI("Power mode %d is unsupported\n", mode); |
Vincent Donnefort | 60ef7eb | 2019-10-09 11:39:28 +0100 | [diff] [blame] | 853 | return HWC2::Error::BadParameter; |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 854 | }; |
| 855 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 856 | std::unique_ptr<DrmDisplayComposition> composition = compositor_ |
| 857 | .CreateComposition(); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 858 | composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_); |
| 859 | composition->SetDpmsMode(dpms_value); |
Sean Paul | ed45a8e | 2017-02-28 13:17:34 -0500 | [diff] [blame] | 860 | int ret = compositor_.ApplyComposition(std::move(composition)); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 861 | if (ret) { |
| 862 | ALOGE("Failed to apply the dpms composition ret=%d", ret); |
| 863 | return HWC2::Error::BadParameter; |
| 864 | } |
| 865 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | HWC2::Error DrmHwcTwo::HwcDisplay::SetVsyncEnabled(int32_t enabled) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 869 | supported(__func__); |
Andrii Chepurnyi | 4bdd0fe | 2018-07-27 15:14:37 +0300 | [diff] [blame] | 870 | vsync_worker_.VSyncControl(HWC2_VSYNC_ENABLE == enabled); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 871 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 872 | } |
| 873 | |
Roman Stratiienko | b7b81cf | 2019-12-13 19:28:56 +0200 | [diff] [blame] | 874 | uint32_t DrmHwcTwo::HwcDisplay::CalcPixOps( |
| 875 | std::map<uint32_t, DrmHwcTwo::HwcLayer *> &z_map, size_t first_z, |
| 876 | size_t size) { |
| 877 | uint32_t pixops = 0; |
| 878 | for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) { |
| 879 | if (l.first >= first_z && l.first < first_z + size) { |
| 880 | hwc_rect_t df = l.second->display_frame(); |
| 881 | pixops += (df.right - df.left) * (df.bottom - df.top); |
| 882 | } |
| 883 | } |
| 884 | return pixops; |
| 885 | } |
| 886 | |
| 887 | void DrmHwcTwo::HwcDisplay::MarkValidated( |
| 888 | std::map<uint32_t, DrmHwcTwo::HwcLayer *> &z_map, size_t client_first_z, |
| 889 | size_t client_size) { |
| 890 | for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) { |
| 891 | if (l.first >= client_first_z && l.first < client_first_z + client_size) |
| 892 | l.second->set_validated_type(HWC2::Composition::Client); |
| 893 | else |
| 894 | l.second->set_validated_type(HWC2::Composition::Device); |
| 895 | } |
| 896 | } |
| 897 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 898 | HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 899 | uint32_t *num_requests) { |
| 900 | supported(__func__); |
Rob Herring | 4f6c62e | 2018-05-17 14:33:02 -0500 | [diff] [blame] | 901 | |
Matvii Zorin | ef3c797 | 2020-08-11 15:15:44 +0300 | [diff] [blame] | 902 | return backend_->ValidateDisplay(this, num_types, num_requests); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 903 | } |
| 904 | |
Roman Stratiienko | 6f5df17 | 2020-09-27 22:48:08 +0300 | [diff] [blame] | 905 | #if PLATFORM_SDK_VERSION > 29 |
| 906 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayConnectionType(uint32_t *outType) { |
| 907 | if (connector_->internal()) |
| 908 | *outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::Internal); |
| 909 | else if (connector_->external()) |
| 910 | *outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::External); |
| 911 | else |
| 912 | return HWC2::Error::BadConfig; |
| 913 | |
| 914 | return HWC2::Error::None; |
| 915 | } |
| 916 | |
| 917 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayVsyncPeriod( |
| 918 | hwc2_vsync_period_t *outVsyncPeriod /* ns */) { |
| 919 | supported(__func__); |
| 920 | DrmMode const &mode = connector_->active_mode(); |
| 921 | if (mode.id() == 0) |
| 922 | return HWC2::Error::BadConfig; |
| 923 | |
| 924 | *outVsyncPeriod = 1E9 / mode.v_refresh(); |
| 925 | return HWC2::Error::None; |
| 926 | } |
| 927 | |
| 928 | HWC2::Error DrmHwcTwo::HwcDisplay::SetActiveConfigWithConstraints( |
| 929 | hwc2_config_t /*config*/, |
| 930 | hwc_vsync_period_change_constraints_t *vsyncPeriodChangeConstraints, |
| 931 | hwc_vsync_period_change_timeline_t *outTimeline) { |
| 932 | supported(__func__); |
| 933 | |
| 934 | if (vsyncPeriodChangeConstraints == nullptr || outTimeline == nullptr) { |
| 935 | return HWC2::Error::BadParameter; |
| 936 | } |
| 937 | |
| 938 | return HWC2::Error::BadConfig; |
| 939 | } |
| 940 | |
| 941 | HWC2::Error DrmHwcTwo::HwcDisplay::SetAutoLowLatencyMode(bool /*on*/) { |
| 942 | return HWC2::Error::Unsupported; |
| 943 | } |
| 944 | |
| 945 | HWC2::Error DrmHwcTwo::HwcDisplay::GetSupportedContentTypes( |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 946 | uint32_t *outNumSupportedContentTypes, |
| 947 | const uint32_t *outSupportedContentTypes) { |
Roman Stratiienko | 6f5df17 | 2020-09-27 22:48:08 +0300 | [diff] [blame] | 948 | if (outSupportedContentTypes == nullptr) |
| 949 | *outNumSupportedContentTypes = 0; |
| 950 | |
| 951 | return HWC2::Error::None; |
| 952 | } |
| 953 | |
| 954 | HWC2::Error DrmHwcTwo::HwcDisplay::SetContentType(int32_t contentType) { |
| 955 | supported(__func__); |
| 956 | |
| 957 | if (contentType != HWC2_CONTENT_TYPE_NONE) |
| 958 | return HWC2::Error::Unsupported; |
| 959 | |
| 960 | /* TODO: Map to the DRM Connector property: |
| 961 | * https://elixir.bootlin.com/linux/v5.4-rc5/source/drivers/gpu/drm/drm_connector.c#L809 |
| 962 | */ |
| 963 | |
| 964 | return HWC2::Error::None; |
| 965 | } |
| 966 | #endif |
| 967 | |
John Stultz | 8c7229d | 2020-02-07 21:31:08 +0000 | [diff] [blame] | 968 | #if PLATFORM_SDK_VERSION > 28 |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 969 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayIdentificationData( |
| 970 | uint8_t *outPort, uint32_t *outDataSize, uint8_t *outData) { |
| 971 | supported(__func__); |
| 972 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 973 | drmModePropertyBlobPtr blob = nullptr; |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 974 | |
Andrii Chepurnyi | adc5d82 | 2020-07-10 16:07:03 +0300 | [diff] [blame] | 975 | if (connector_->GetEdidBlob(blob)) { |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 976 | ALOGE("Failed to get edid property value."); |
| 977 | return HWC2::Error::Unsupported; |
| 978 | } |
| 979 | |
Andrii Chepurnyi | 8115dbe | 2020-04-14 13:03:57 +0300 | [diff] [blame] | 980 | if (outData) { |
| 981 | *outDataSize = std::min(*outDataSize, blob->length); |
| 982 | memcpy(outData, blob->data, *outDataSize); |
| 983 | } else { |
| 984 | *outDataSize = blob->length; |
| 985 | } |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 986 | *outPort = connector_->id(); |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 987 | |
| 988 | return HWC2::Error::None; |
| 989 | } |
| 990 | |
| 991 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayCapabilities( |
| 992 | uint32_t *outNumCapabilities, uint32_t *outCapabilities) { |
| 993 | unsupported(__func__, outCapabilities); |
| 994 | |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 995 | if (outNumCapabilities == nullptr) { |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 996 | return HWC2::Error::BadParameter; |
| 997 | } |
| 998 | |
| 999 | *outNumCapabilities = 0; |
| 1000 | |
| 1001 | return HWC2::Error::None; |
| 1002 | } |
Andrii Chepurnyi | 2619aab | 2020-07-03 11:21:33 +0300 | [diff] [blame] | 1003 | |
| 1004 | HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayBrightnessSupport( |
| 1005 | bool *supported) { |
| 1006 | *supported = false; |
| 1007 | return HWC2::Error::None; |
| 1008 | } |
| 1009 | |
| 1010 | HWC2::Error DrmHwcTwo::HwcDisplay::SetDisplayBrightness( |
| 1011 | float /* brightness */) { |
| 1012 | return HWC2::Error::Unsupported; |
| 1013 | } |
| 1014 | |
John Stultz | 8c7229d | 2020-02-07 21:31:08 +0000 | [diff] [blame] | 1015 | #endif /* PLATFORM_SDK_VERSION > 28 */ |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 1016 | |
Andrii Chepurnyi | 50d3745 | 2020-04-24 14:20:24 +0300 | [diff] [blame] | 1017 | #if PLATFORM_SDK_VERSION > 27 |
| 1018 | |
| 1019 | HWC2::Error DrmHwcTwo::HwcDisplay::GetRenderIntents( |
| 1020 | int32_t mode, uint32_t *outNumIntents, |
| 1021 | int32_t * /*android_render_intent_v1_1_t*/ outIntents) { |
| 1022 | if (mode != HAL_COLOR_MODE_NATIVE) { |
| 1023 | return HWC2::Error::BadParameter; |
| 1024 | } |
| 1025 | |
| 1026 | if (outIntents == nullptr) { |
| 1027 | *outNumIntents = 1; |
| 1028 | return HWC2::Error::None; |
| 1029 | } |
| 1030 | *outNumIntents = 1; |
| 1031 | outIntents[0] = HAL_RENDER_INTENT_COLORIMETRIC; |
| 1032 | return HWC2::Error::None; |
| 1033 | } |
| 1034 | |
Andrii Chepurnyi | 857a53f | 2020-04-29 23:15:28 +0300 | [diff] [blame] | 1035 | HWC2::Error DrmHwcTwo::HwcDisplay::SetColorModeWithIntent(int32_t mode, |
| 1036 | int32_t intent) { |
Roman Stratiienko | 27d2ed6 | 2020-09-26 23:59:19 +0300 | [diff] [blame] | 1037 | if (intent < HAL_RENDER_INTENT_COLORIMETRIC || |
| 1038 | intent > HAL_RENDER_INTENT_TONE_MAP_ENHANCE) |
| 1039 | return HWC2::Error::BadParameter; |
| 1040 | |
| 1041 | if (mode < HAL_COLOR_MODE_NATIVE || mode > HAL_COLOR_MODE_BT2100_HLG) |
| 1042 | return HWC2::Error::BadParameter; |
| 1043 | |
Andrii Chepurnyi | 857a53f | 2020-04-29 23:15:28 +0300 | [diff] [blame] | 1044 | if (mode != HAL_COLOR_MODE_NATIVE) |
Roman Stratiienko | 27d2ed6 | 2020-09-26 23:59:19 +0300 | [diff] [blame] | 1045 | return HWC2::Error::Unsupported; |
| 1046 | |
Andrii Chepurnyi | 857a53f | 2020-04-29 23:15:28 +0300 | [diff] [blame] | 1047 | if (intent != HAL_RENDER_INTENT_COLORIMETRIC) |
Roman Stratiienko | 27d2ed6 | 2020-09-26 23:59:19 +0300 | [diff] [blame] | 1048 | return HWC2::Error::Unsupported; |
| 1049 | |
Andrii Chepurnyi | 857a53f | 2020-04-29 23:15:28 +0300 | [diff] [blame] | 1050 | color_mode_ = mode; |
| 1051 | return HWC2::Error::None; |
| 1052 | } |
| 1053 | |
Andrii Chepurnyi | 50d3745 | 2020-04-24 14:20:24 +0300 | [diff] [blame] | 1054 | #endif /* PLATFORM_SDK_VERSION > 27 */ |
| 1055 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1056 | HWC2::Error DrmHwcTwo::HwcLayer::SetCursorPosition(int32_t x, int32_t y) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1057 | supported(__func__); |
Kalyan Kondapally | da5839c | 2016-11-10 10:59:50 -0800 | [diff] [blame] | 1058 | cursor_x_ = x; |
| 1059 | cursor_y_ = y; |
| 1060 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerBlendMode(int32_t mode) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1064 | supported(__func__); |
| 1065 | blending_ = static_cast<HWC2::BlendMode>(mode); |
| 1066 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerBuffer(buffer_handle_t buffer, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1070 | int32_t acquire_fence) { |
| 1071 | supported(__func__); |
| 1072 | UniqueFd uf(acquire_fence); |
| 1073 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1074 | set_buffer(buffer); |
| 1075 | set_acquire_fence(uf.get()); |
| 1076 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1077 | } |
| 1078 | |
| 1079 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerColor(hwc_color_t color) { |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1080 | // TODO(nobody): Put to client composition here? |
Roman Kovalivskyi | bb37569 | 2019-12-11 17:48:44 +0200 | [diff] [blame] | 1081 | supported(__func__); |
| 1082 | layer_color_ = color; |
| 1083 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerCompositionType(int32_t type) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1087 | sf_type_ = static_cast<HWC2::Composition>(type); |
| 1088 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerDataspace(int32_t dataspace) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1092 | supported(__func__); |
| 1093 | dataspace_ = static_cast<android_dataspace_t>(dataspace); |
| 1094 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerDisplayFrame(hwc_rect_t frame) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1098 | supported(__func__); |
| 1099 | display_frame_ = frame; |
| 1100 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerPlaneAlpha(float alpha) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1104 | supported(__func__); |
| 1105 | alpha_ = alpha; |
| 1106 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerSidebandStream( |
| 1110 | const native_handle_t *stream) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1111 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1112 | // TODO(nobody): We don't support sideband |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1113 | return unsupported(__func__, stream); |
| 1114 | } |
| 1115 | |
| 1116 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerSourceCrop(hwc_frect_t crop) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1117 | supported(__func__); |
| 1118 | source_crop_ = crop; |
| 1119 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1120 | } |
| 1121 | |
| 1122 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerSurfaceDamage(hwc_region_t damage) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1123 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1124 | // TODO(nobody): We don't use surface damage, marking as unsupported |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1125 | unsupported(__func__, damage); |
| 1126 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerTransform(int32_t transform) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1130 | supported(__func__); |
| 1131 | transform_ = static_cast<HWC2::Transform>(transform); |
| 1132 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerVisibleRegion(hwc_region_t visible) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1136 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1137 | // TODO(nobody): We don't use this information, marking as unsupported |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1138 | unsupported(__func__, visible); |
| 1139 | return HWC2::Error::None; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1140 | } |
| 1141 | |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1142 | HWC2::Error DrmHwcTwo::HwcLayer::SetLayerZOrder(uint32_t order) { |
| 1143 | supported(__func__); |
| 1144 | z_order_ = order; |
| 1145 | return HWC2::Error::None; |
| 1146 | } |
| 1147 | |
| 1148 | void DrmHwcTwo::HwcLayer::PopulateDrmLayer(DrmHwcLayer *layer) { |
| 1149 | supported(__func__); |
| 1150 | switch (blending_) { |
| 1151 | case HWC2::BlendMode::None: |
| 1152 | layer->blending = DrmHwcBlending::kNone; |
| 1153 | break; |
| 1154 | case HWC2::BlendMode::Premultiplied: |
| 1155 | layer->blending = DrmHwcBlending::kPreMult; |
| 1156 | break; |
| 1157 | case HWC2::BlendMode::Coverage: |
| 1158 | layer->blending = DrmHwcBlending::kCoverage; |
| 1159 | break; |
| 1160 | default: |
| 1161 | ALOGE("Unknown blending mode b=%d", blending_); |
| 1162 | layer->blending = DrmHwcBlending::kNone; |
| 1163 | break; |
| 1164 | } |
| 1165 | |
| 1166 | OutputFd release_fence = release_fence_output(); |
| 1167 | |
| 1168 | layer->sf_handle = buffer_; |
| 1169 | layer->acquire_fence = acquire_fence_.Release(); |
| 1170 | layer->release_fence = std::move(release_fence); |
| 1171 | layer->SetDisplayFrame(display_frame_); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1172 | layer->alpha = lround(65535.0F * alpha_); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1173 | layer->SetSourceCrop(source_crop_); |
| 1174 | layer->SetTransform(static_cast<int32_t>(transform_)); |
Matvii Zorin | 8338c34 | 2020-09-08 16:12:51 +0300 | [diff] [blame] | 1175 | layer->dataspace = dataspace_; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1176 | } |
| 1177 | |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 1178 | void DrmHwcTwo::HandleDisplayHotplug(hwc2_display_t displayid, int state) { |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 1179 | const std::lock_guard<std::mutex> lock(hotplug_callback_lock); |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 1180 | |
Roman Stratiienko | 2370109 | 2020-09-26 02:08:41 +0300 | [diff] [blame] | 1181 | if (hotplug_callback_hook_ && hotplug_callback_data_) |
| 1182 | hotplug_callback_hook_(hotplug_callback_data_, displayid, |
| 1183 | state == DRM_MODE_CONNECTED |
| 1184 | ? HWC2_CONNECTION_CONNECTED |
| 1185 | : HWC2_CONNECTION_DISCONNECTED); |
Andrii Chepurnyi | 495e4cc | 2018-08-01 17:42:56 +0300 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | void DrmHwcTwo::HandleInitialHotplugState(DrmDevice *drmDevice) { |
| 1189 | for (auto &conn : drmDevice->connectors()) { |
| 1190 | if (conn->state() != DRM_MODE_CONNECTED) |
| 1191 | continue; |
| 1192 | HandleDisplayHotplug(conn->display(), conn->state()); |
| 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | void DrmHwcTwo::DrmHotplugHandler::HandleEvent(uint64_t timestamp_us) { |
| 1197 | for (auto &conn : drm_->connectors()) { |
| 1198 | drmModeConnection old_state = conn->state(); |
| 1199 | drmModeConnection cur_state = conn->UpdateModes() |
| 1200 | ? DRM_MODE_UNKNOWNCONNECTION |
| 1201 | : conn->state(); |
| 1202 | |
| 1203 | if (cur_state == old_state) |
| 1204 | continue; |
| 1205 | |
| 1206 | ALOGI("%s event @%" PRIu64 " for connector %u on display %d", |
| 1207 | cur_state == DRM_MODE_CONNECTED ? "Plug" : "Unplug", timestamp_us, |
| 1208 | conn->id(), conn->display()); |
| 1209 | |
| 1210 | int display_id = conn->display(); |
| 1211 | if (cur_state == DRM_MODE_CONNECTED) { |
| 1212 | auto &display = hwc2_->displays_.at(display_id); |
| 1213 | display.ChosePreferredConfig(); |
| 1214 | } else { |
| 1215 | auto &display = hwc2_->displays_.at(display_id); |
| 1216 | display.ClearDisplay(); |
| 1217 | } |
| 1218 | |
| 1219 | hwc2_->HandleDisplayHotplug(display_id, cur_state); |
| 1220 | } |
| 1221 | } |
| 1222 | |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1223 | // static |
| 1224 | int DrmHwcTwo::HookDevClose(hw_device_t * /*dev*/) { |
| 1225 | unsupported(__func__); |
| 1226 | return 0; |
| 1227 | } |
| 1228 | |
| 1229 | // static |
| 1230 | void DrmHwcTwo::HookDevGetCapabilities(hwc2_device_t * /*dev*/, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1231 | uint32_t *out_count, |
| 1232 | int32_t * /*out_capabilities*/) { |
| 1233 | supported(__func__); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1234 | *out_count = 0; |
| 1235 | } |
| 1236 | |
| 1237 | // static |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1238 | hwc2_function_pointer_t DrmHwcTwo::HookDevGetFunction( |
| 1239 | struct hwc2_device * /*dev*/, int32_t descriptor) { |
| 1240 | supported(__func__); |
| 1241 | auto func = static_cast<HWC2::FunctionDescriptor>(descriptor); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1242 | switch (func) { |
| 1243 | // Device functions |
| 1244 | case HWC2::FunctionDescriptor::CreateVirtualDisplay: |
| 1245 | return ToHook<HWC2_PFN_CREATE_VIRTUAL_DISPLAY>( |
| 1246 | DeviceHook<int32_t, decltype(&DrmHwcTwo::CreateVirtualDisplay), |
| 1247 | &DrmHwcTwo::CreateVirtualDisplay, uint32_t, uint32_t, |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1248 | int32_t *, hwc2_display_t *>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1249 | case HWC2::FunctionDescriptor::DestroyVirtualDisplay: |
| 1250 | return ToHook<HWC2_PFN_DESTROY_VIRTUAL_DISPLAY>( |
| 1251 | DeviceHook<int32_t, decltype(&DrmHwcTwo::DestroyVirtualDisplay), |
| 1252 | &DrmHwcTwo::DestroyVirtualDisplay, hwc2_display_t>); |
| 1253 | case HWC2::FunctionDescriptor::Dump: |
| 1254 | return ToHook<HWC2_PFN_DUMP>( |
| 1255 | DeviceHook<void, decltype(&DrmHwcTwo::Dump), &DrmHwcTwo::Dump, |
| 1256 | uint32_t *, char *>); |
| 1257 | case HWC2::FunctionDescriptor::GetMaxVirtualDisplayCount: |
| 1258 | return ToHook<HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT>( |
| 1259 | DeviceHook<uint32_t, decltype(&DrmHwcTwo::GetMaxVirtualDisplayCount), |
| 1260 | &DrmHwcTwo::GetMaxVirtualDisplayCount>); |
| 1261 | case HWC2::FunctionDescriptor::RegisterCallback: |
| 1262 | return ToHook<HWC2_PFN_REGISTER_CALLBACK>( |
| 1263 | DeviceHook<int32_t, decltype(&DrmHwcTwo::RegisterCallback), |
| 1264 | &DrmHwcTwo::RegisterCallback, int32_t, |
| 1265 | hwc2_callback_data_t, hwc2_function_pointer_t>); |
| 1266 | |
| 1267 | // Display functions |
| 1268 | case HWC2::FunctionDescriptor::AcceptDisplayChanges: |
| 1269 | return ToHook<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>( |
| 1270 | DisplayHook<decltype(&HwcDisplay::AcceptDisplayChanges), |
| 1271 | &HwcDisplay::AcceptDisplayChanges>); |
| 1272 | case HWC2::FunctionDescriptor::CreateLayer: |
| 1273 | return ToHook<HWC2_PFN_CREATE_LAYER>( |
| 1274 | DisplayHook<decltype(&HwcDisplay::CreateLayer), |
| 1275 | &HwcDisplay::CreateLayer, hwc2_layer_t *>); |
| 1276 | case HWC2::FunctionDescriptor::DestroyLayer: |
| 1277 | return ToHook<HWC2_PFN_DESTROY_LAYER>( |
| 1278 | DisplayHook<decltype(&HwcDisplay::DestroyLayer), |
| 1279 | &HwcDisplay::DestroyLayer, hwc2_layer_t>); |
| 1280 | case HWC2::FunctionDescriptor::GetActiveConfig: |
| 1281 | return ToHook<HWC2_PFN_GET_ACTIVE_CONFIG>( |
| 1282 | DisplayHook<decltype(&HwcDisplay::GetActiveConfig), |
| 1283 | &HwcDisplay::GetActiveConfig, hwc2_config_t *>); |
| 1284 | case HWC2::FunctionDescriptor::GetChangedCompositionTypes: |
| 1285 | return ToHook<HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES>( |
| 1286 | DisplayHook<decltype(&HwcDisplay::GetChangedCompositionTypes), |
| 1287 | &HwcDisplay::GetChangedCompositionTypes, uint32_t *, |
| 1288 | hwc2_layer_t *, int32_t *>); |
| 1289 | case HWC2::FunctionDescriptor::GetClientTargetSupport: |
| 1290 | return ToHook<HWC2_PFN_GET_CLIENT_TARGET_SUPPORT>( |
| 1291 | DisplayHook<decltype(&HwcDisplay::GetClientTargetSupport), |
| 1292 | &HwcDisplay::GetClientTargetSupport, uint32_t, uint32_t, |
| 1293 | int32_t, int32_t>); |
| 1294 | case HWC2::FunctionDescriptor::GetColorModes: |
| 1295 | return ToHook<HWC2_PFN_GET_COLOR_MODES>( |
| 1296 | DisplayHook<decltype(&HwcDisplay::GetColorModes), |
| 1297 | &HwcDisplay::GetColorModes, uint32_t *, int32_t *>); |
| 1298 | case HWC2::FunctionDescriptor::GetDisplayAttribute: |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1299 | return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>( |
| 1300 | DisplayHook<decltype(&HwcDisplay::GetDisplayAttribute), |
| 1301 | &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t, |
| 1302 | int32_t *>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1303 | case HWC2::FunctionDescriptor::GetDisplayConfigs: |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1304 | return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>( |
| 1305 | DisplayHook<decltype(&HwcDisplay::GetDisplayConfigs), |
| 1306 | &HwcDisplay::GetDisplayConfigs, uint32_t *, |
| 1307 | hwc2_config_t *>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1308 | case HWC2::FunctionDescriptor::GetDisplayName: |
| 1309 | return ToHook<HWC2_PFN_GET_DISPLAY_NAME>( |
| 1310 | DisplayHook<decltype(&HwcDisplay::GetDisplayName), |
| 1311 | &HwcDisplay::GetDisplayName, uint32_t *, char *>); |
| 1312 | case HWC2::FunctionDescriptor::GetDisplayRequests: |
| 1313 | return ToHook<HWC2_PFN_GET_DISPLAY_REQUESTS>( |
| 1314 | DisplayHook<decltype(&HwcDisplay::GetDisplayRequests), |
| 1315 | &HwcDisplay::GetDisplayRequests, int32_t *, uint32_t *, |
| 1316 | hwc2_layer_t *, int32_t *>); |
| 1317 | case HWC2::FunctionDescriptor::GetDisplayType: |
| 1318 | return ToHook<HWC2_PFN_GET_DISPLAY_TYPE>( |
| 1319 | DisplayHook<decltype(&HwcDisplay::GetDisplayType), |
| 1320 | &HwcDisplay::GetDisplayType, int32_t *>); |
| 1321 | case HWC2::FunctionDescriptor::GetDozeSupport: |
| 1322 | return ToHook<HWC2_PFN_GET_DOZE_SUPPORT>( |
| 1323 | DisplayHook<decltype(&HwcDisplay::GetDozeSupport), |
| 1324 | &HwcDisplay::GetDozeSupport, int32_t *>); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1325 | case HWC2::FunctionDescriptor::GetHdrCapabilities: |
| 1326 | return ToHook<HWC2_PFN_GET_HDR_CAPABILITIES>( |
| 1327 | DisplayHook<decltype(&HwcDisplay::GetHdrCapabilities), |
| 1328 | &HwcDisplay::GetHdrCapabilities, uint32_t *, int32_t *, |
| 1329 | float *, float *, float *>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1330 | case HWC2::FunctionDescriptor::GetReleaseFences: |
| 1331 | return ToHook<HWC2_PFN_GET_RELEASE_FENCES>( |
| 1332 | DisplayHook<decltype(&HwcDisplay::GetReleaseFences), |
| 1333 | &HwcDisplay::GetReleaseFences, uint32_t *, hwc2_layer_t *, |
| 1334 | int32_t *>); |
| 1335 | case HWC2::FunctionDescriptor::PresentDisplay: |
| 1336 | return ToHook<HWC2_PFN_PRESENT_DISPLAY>( |
| 1337 | DisplayHook<decltype(&HwcDisplay::PresentDisplay), |
| 1338 | &HwcDisplay::PresentDisplay, int32_t *>); |
| 1339 | case HWC2::FunctionDescriptor::SetActiveConfig: |
| 1340 | return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG>( |
| 1341 | DisplayHook<decltype(&HwcDisplay::SetActiveConfig), |
| 1342 | &HwcDisplay::SetActiveConfig, hwc2_config_t>); |
| 1343 | case HWC2::FunctionDescriptor::SetClientTarget: |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1344 | return ToHook<HWC2_PFN_SET_CLIENT_TARGET>( |
| 1345 | DisplayHook<decltype(&HwcDisplay::SetClientTarget), |
| 1346 | &HwcDisplay::SetClientTarget, buffer_handle_t, int32_t, |
| 1347 | int32_t, hwc_region_t>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1348 | case HWC2::FunctionDescriptor::SetColorMode: |
| 1349 | return ToHook<HWC2_PFN_SET_COLOR_MODE>( |
| 1350 | DisplayHook<decltype(&HwcDisplay::SetColorMode), |
| 1351 | &HwcDisplay::SetColorMode, int32_t>); |
| 1352 | case HWC2::FunctionDescriptor::SetColorTransform: |
| 1353 | return ToHook<HWC2_PFN_SET_COLOR_TRANSFORM>( |
| 1354 | DisplayHook<decltype(&HwcDisplay::SetColorTransform), |
| 1355 | &HwcDisplay::SetColorTransform, const float *, int32_t>); |
| 1356 | case HWC2::FunctionDescriptor::SetOutputBuffer: |
| 1357 | return ToHook<HWC2_PFN_SET_OUTPUT_BUFFER>( |
| 1358 | DisplayHook<decltype(&HwcDisplay::SetOutputBuffer), |
| 1359 | &HwcDisplay::SetOutputBuffer, buffer_handle_t, int32_t>); |
| 1360 | case HWC2::FunctionDescriptor::SetPowerMode: |
| 1361 | return ToHook<HWC2_PFN_SET_POWER_MODE>( |
| 1362 | DisplayHook<decltype(&HwcDisplay::SetPowerMode), |
| 1363 | &HwcDisplay::SetPowerMode, int32_t>); |
| 1364 | case HWC2::FunctionDescriptor::SetVsyncEnabled: |
| 1365 | return ToHook<HWC2_PFN_SET_VSYNC_ENABLED>( |
| 1366 | DisplayHook<decltype(&HwcDisplay::SetVsyncEnabled), |
| 1367 | &HwcDisplay::SetVsyncEnabled, int32_t>); |
| 1368 | case HWC2::FunctionDescriptor::ValidateDisplay: |
| 1369 | return ToHook<HWC2_PFN_VALIDATE_DISPLAY>( |
| 1370 | DisplayHook<decltype(&HwcDisplay::ValidateDisplay), |
| 1371 | &HwcDisplay::ValidateDisplay, uint32_t *, uint32_t *>); |
Andrii Chepurnyi | 50d3745 | 2020-04-24 14:20:24 +0300 | [diff] [blame] | 1372 | #if PLATFORM_SDK_VERSION > 27 |
| 1373 | case HWC2::FunctionDescriptor::GetRenderIntents: |
| 1374 | return ToHook<HWC2_PFN_GET_RENDER_INTENTS>( |
| 1375 | DisplayHook<decltype(&HwcDisplay::GetRenderIntents), |
| 1376 | &HwcDisplay::GetRenderIntents, int32_t, uint32_t *, |
| 1377 | int32_t *>); |
Andrii Chepurnyi | 857a53f | 2020-04-29 23:15:28 +0300 | [diff] [blame] | 1378 | case HWC2::FunctionDescriptor::SetColorModeWithRenderIntent: |
| 1379 | return ToHook<HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT>( |
| 1380 | DisplayHook<decltype(&HwcDisplay::SetColorModeWithIntent), |
| 1381 | &HwcDisplay::SetColorModeWithIntent, int32_t, int32_t>); |
Andrii Chepurnyi | 50d3745 | 2020-04-24 14:20:24 +0300 | [diff] [blame] | 1382 | #endif |
John Stultz | 8c7229d | 2020-02-07 21:31:08 +0000 | [diff] [blame] | 1383 | #if PLATFORM_SDK_VERSION > 28 |
Lowry Li (Arm Technology China) | b3d8178 | 2019-12-18 14:28:22 +0800 | [diff] [blame] | 1384 | case HWC2::FunctionDescriptor::GetDisplayIdentificationData: |
| 1385 | return ToHook<HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA>( |
| 1386 | DisplayHook<decltype(&HwcDisplay::GetDisplayIdentificationData), |
| 1387 | &HwcDisplay::GetDisplayIdentificationData, uint8_t *, |
| 1388 | uint32_t *, uint8_t *>); |
| 1389 | case HWC2::FunctionDescriptor::GetDisplayCapabilities: |
| 1390 | return ToHook<HWC2_PFN_GET_DISPLAY_CAPABILITIES>( |
| 1391 | DisplayHook<decltype(&HwcDisplay::GetDisplayCapabilities), |
| 1392 | &HwcDisplay::GetDisplayCapabilities, uint32_t *, |
| 1393 | uint32_t *>); |
Andrii Chepurnyi | 2619aab | 2020-07-03 11:21:33 +0300 | [diff] [blame] | 1394 | case HWC2::FunctionDescriptor::GetDisplayBrightnessSupport: |
| 1395 | return ToHook<HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT>( |
| 1396 | DisplayHook<decltype(&HwcDisplay::GetDisplayBrightnessSupport), |
| 1397 | &HwcDisplay::GetDisplayBrightnessSupport, bool *>); |
| 1398 | case HWC2::FunctionDescriptor::SetDisplayBrightness: |
| 1399 | return ToHook<HWC2_PFN_SET_DISPLAY_BRIGHTNESS>( |
| 1400 | DisplayHook<decltype(&HwcDisplay::SetDisplayBrightness), |
| 1401 | &HwcDisplay::SetDisplayBrightness, float>); |
John Stultz | 8c7229d | 2020-02-07 21:31:08 +0000 | [diff] [blame] | 1402 | #endif /* PLATFORM_SDK_VERSION > 28 */ |
Roman Stratiienko | 6f5df17 | 2020-09-27 22:48:08 +0300 | [diff] [blame] | 1403 | #if PLATFORM_SDK_VERSION > 29 |
| 1404 | case HWC2::FunctionDescriptor::GetDisplayConnectionType: |
| 1405 | return ToHook<HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE>( |
| 1406 | DisplayHook<decltype(&HwcDisplay::GetDisplayConnectionType), |
| 1407 | &HwcDisplay::GetDisplayConnectionType, uint32_t *>); |
| 1408 | case HWC2::FunctionDescriptor::GetDisplayVsyncPeriod: |
| 1409 | return ToHook<HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD>( |
| 1410 | DisplayHook<decltype(&HwcDisplay::GetDisplayVsyncPeriod), |
| 1411 | &HwcDisplay::GetDisplayVsyncPeriod, |
| 1412 | hwc2_vsync_period_t *>); |
| 1413 | case HWC2::FunctionDescriptor::SetActiveConfigWithConstraints: |
| 1414 | return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS>( |
| 1415 | DisplayHook<decltype(&HwcDisplay::SetActiveConfigWithConstraints), |
| 1416 | &HwcDisplay::SetActiveConfigWithConstraints, |
| 1417 | hwc2_config_t, hwc_vsync_period_change_constraints_t *, |
| 1418 | hwc_vsync_period_change_timeline_t *>); |
| 1419 | case HWC2::FunctionDescriptor::SetAutoLowLatencyMode: |
| 1420 | return ToHook<HWC2_PFN_SET_AUTO_LOW_LATENCY_MODE>( |
| 1421 | DisplayHook<decltype(&HwcDisplay::SetAutoLowLatencyMode), |
| 1422 | &HwcDisplay::SetAutoLowLatencyMode, bool>); |
| 1423 | case HWC2::FunctionDescriptor::GetSupportedContentTypes: |
| 1424 | return ToHook<HWC2_PFN_GET_SUPPORTED_CONTENT_TYPES>( |
| 1425 | DisplayHook<decltype(&HwcDisplay::GetSupportedContentTypes), |
| 1426 | &HwcDisplay::GetSupportedContentTypes, uint32_t *, |
| 1427 | uint32_t *>); |
| 1428 | case HWC2::FunctionDescriptor::SetContentType: |
| 1429 | return ToHook<HWC2_PFN_SET_CONTENT_TYPE>( |
| 1430 | DisplayHook<decltype(&HwcDisplay::SetContentType), |
| 1431 | &HwcDisplay::SetContentType, int32_t>); |
| 1432 | #endif |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1433 | // Layer functions |
| 1434 | case HWC2::FunctionDescriptor::SetCursorPosition: |
| 1435 | return ToHook<HWC2_PFN_SET_CURSOR_POSITION>( |
| 1436 | LayerHook<decltype(&HwcLayer::SetCursorPosition), |
| 1437 | &HwcLayer::SetCursorPosition, int32_t, int32_t>); |
| 1438 | case HWC2::FunctionDescriptor::SetLayerBlendMode: |
| 1439 | return ToHook<HWC2_PFN_SET_LAYER_BLEND_MODE>( |
| 1440 | LayerHook<decltype(&HwcLayer::SetLayerBlendMode), |
| 1441 | &HwcLayer::SetLayerBlendMode, int32_t>); |
| 1442 | case HWC2::FunctionDescriptor::SetLayerBuffer: |
| 1443 | return ToHook<HWC2_PFN_SET_LAYER_BUFFER>( |
| 1444 | LayerHook<decltype(&HwcLayer::SetLayerBuffer), |
| 1445 | &HwcLayer::SetLayerBuffer, buffer_handle_t, int32_t>); |
| 1446 | case HWC2::FunctionDescriptor::SetLayerColor: |
| 1447 | return ToHook<HWC2_PFN_SET_LAYER_COLOR>( |
| 1448 | LayerHook<decltype(&HwcLayer::SetLayerColor), |
| 1449 | &HwcLayer::SetLayerColor, hwc_color_t>); |
| 1450 | case HWC2::FunctionDescriptor::SetLayerCompositionType: |
| 1451 | return ToHook<HWC2_PFN_SET_LAYER_COMPOSITION_TYPE>( |
| 1452 | LayerHook<decltype(&HwcLayer::SetLayerCompositionType), |
| 1453 | &HwcLayer::SetLayerCompositionType, int32_t>); |
| 1454 | case HWC2::FunctionDescriptor::SetLayerDataspace: |
| 1455 | return ToHook<HWC2_PFN_SET_LAYER_DATASPACE>( |
| 1456 | LayerHook<decltype(&HwcLayer::SetLayerDataspace), |
| 1457 | &HwcLayer::SetLayerDataspace, int32_t>); |
| 1458 | case HWC2::FunctionDescriptor::SetLayerDisplayFrame: |
| 1459 | return ToHook<HWC2_PFN_SET_LAYER_DISPLAY_FRAME>( |
| 1460 | LayerHook<decltype(&HwcLayer::SetLayerDisplayFrame), |
| 1461 | &HwcLayer::SetLayerDisplayFrame, hwc_rect_t>); |
| 1462 | case HWC2::FunctionDescriptor::SetLayerPlaneAlpha: |
| 1463 | return ToHook<HWC2_PFN_SET_LAYER_PLANE_ALPHA>( |
| 1464 | LayerHook<decltype(&HwcLayer::SetLayerPlaneAlpha), |
| 1465 | &HwcLayer::SetLayerPlaneAlpha, float>); |
| 1466 | case HWC2::FunctionDescriptor::SetLayerSidebandStream: |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1467 | return ToHook<HWC2_PFN_SET_LAYER_SIDEBAND_STREAM>( |
| 1468 | LayerHook<decltype(&HwcLayer::SetLayerSidebandStream), |
| 1469 | &HwcLayer::SetLayerSidebandStream, |
| 1470 | const native_handle_t *>); |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1471 | case HWC2::FunctionDescriptor::SetLayerSourceCrop: |
| 1472 | return ToHook<HWC2_PFN_SET_LAYER_SOURCE_CROP>( |
| 1473 | LayerHook<decltype(&HwcLayer::SetLayerSourceCrop), |
| 1474 | &HwcLayer::SetLayerSourceCrop, hwc_frect_t>); |
| 1475 | case HWC2::FunctionDescriptor::SetLayerSurfaceDamage: |
| 1476 | return ToHook<HWC2_PFN_SET_LAYER_SURFACE_DAMAGE>( |
| 1477 | LayerHook<decltype(&HwcLayer::SetLayerSurfaceDamage), |
| 1478 | &HwcLayer::SetLayerSurfaceDamage, hwc_region_t>); |
| 1479 | case HWC2::FunctionDescriptor::SetLayerTransform: |
| 1480 | return ToHook<HWC2_PFN_SET_LAYER_TRANSFORM>( |
| 1481 | LayerHook<decltype(&HwcLayer::SetLayerTransform), |
| 1482 | &HwcLayer::SetLayerTransform, int32_t>); |
| 1483 | case HWC2::FunctionDescriptor::SetLayerVisibleRegion: |
| 1484 | return ToHook<HWC2_PFN_SET_LAYER_VISIBLE_REGION>( |
| 1485 | LayerHook<decltype(&HwcLayer::SetLayerVisibleRegion), |
| 1486 | &HwcLayer::SetLayerVisibleRegion, hwc_region_t>); |
| 1487 | case HWC2::FunctionDescriptor::SetLayerZOrder: |
| 1488 | return ToHook<HWC2_PFN_SET_LAYER_Z_ORDER>( |
| 1489 | LayerHook<decltype(&HwcLayer::SetLayerZOrder), |
| 1490 | &HwcLayer::SetLayerZOrder, uint32_t>); |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1491 | case HWC2::FunctionDescriptor::Invalid: |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1492 | default: |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1493 | return nullptr; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1494 | } |
| 1495 | } |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1496 | |
| 1497 | // static |
| 1498 | int DrmHwcTwo::HookDevOpen(const struct hw_module_t *module, const char *name, |
| 1499 | struct hw_device_t **dev) { |
| 1500 | supported(__func__); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1501 | if (strcmp(name, HWC_HARDWARE_COMPOSER) != 0) { |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1502 | ALOGE("Invalid module name- %s", name); |
| 1503 | return -EINVAL; |
| 1504 | } |
| 1505 | |
| 1506 | std::unique_ptr<DrmHwcTwo> ctx(new DrmHwcTwo()); |
| 1507 | if (!ctx) { |
| 1508 | ALOGE("Failed to allocate DrmHwcTwo"); |
| 1509 | return -ENOMEM; |
| 1510 | } |
| 1511 | |
| 1512 | HWC2::Error err = ctx->Init(); |
| 1513 | if (err != HWC2::Error::None) { |
| 1514 | ALOGE("Failed to initialize DrmHwcTwo err=%d\n", err); |
| 1515 | return -EINVAL; |
| 1516 | } |
| 1517 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 1518 | ctx->common.module = (hw_module_t *)module; |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1519 | *dev = &ctx->common; |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1520 | ctx.release(); // NOLINT(bugprone-unused-return-value) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1521 | return 0; |
Sean Paul | ed2ec4b | 2016-03-10 15:35:40 -0500 | [diff] [blame] | 1522 | } |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 1523 | } // namespace android |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1524 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 1525 | // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1526 | static struct hw_module_methods_t hwc2_module_methods = { |
| 1527 | .open = android::DrmHwcTwo::HookDevOpen, |
| 1528 | }; |
| 1529 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame^] | 1530 | // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1531 | hw_module_t HAL_MODULE_INFO_SYM = { |
| 1532 | .tag = HARDWARE_MODULE_TAG, |
| 1533 | .module_api_version = HARDWARE_MODULE_API_VERSION(2, 0), |
| 1534 | .id = HWC_HARDWARE_MODULE_ID, |
| 1535 | .name = "DrmHwcTwo module", |
| 1536 | .author = "The Android Open Source Project", |
| 1537 | .methods = &hwc2_module_methods, |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 1538 | .dso = nullptr, |
Sean Paul | ac87415 | 2016-03-10 16:00:26 -0500 | [diff] [blame] | 1539 | .reserved = {0}, |
| 1540 | }; |