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