Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 17 | // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) |
| 18 | // #define LOG_NDEBUG 0 // Uncomment to see HWC2 API calls in logcat |
| 19 | |
Sean Paul | 468a754 | 2024-07-16 19:50:58 +0000 | [diff] [blame] | 20 | #define LOG_TAG "drmhwc" |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 21 | |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 22 | #include <cinttypes> |
| 23 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 24 | #include "DrmHwcTwo.h" |
| 25 | #include "backend/Backend.h" |
| 26 | #include "utils/log.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 30 | /* Converts long __PRETTY_FUNCTION__ result, e.g.: |
| 31 | * "int32_t android::LayerHook(hwc2_device_t *, hwc2_display_t, hwc2_layer_t," |
| 32 | * "Args...) [HookType = HWC2::Error (android::HwcLayer::*)(const native_handle" |
| 33 | * "*,int), func = &android::HwcLayer::SetLayerBuffer, Args = <const |
| 34 | * "native_handle, int>" |
| 35 | * to the short "android::HwcLayer::SetLayerBuffer" for better logs readability |
| 36 | */ |
| 37 | static std::string GetFuncName(const char *pretty_function) { |
Roman Stratiienko | a7913de | 2022-10-20 13:18:57 +0300 | [diff] [blame] | 38 | const std::string str(pretty_function); |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 39 | const char *start = "func = &"; |
Roman Stratiienko | a7913de | 2022-10-20 13:18:57 +0300 | [diff] [blame] | 40 | auto p1 = str.find(start); |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 41 | p1 += strlen(start); |
Roman Stratiienko | a7913de | 2022-10-20 13:18:57 +0300 | [diff] [blame] | 42 | auto p2 = str.find(',', p1); |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 43 | return str.substr(p1, p2 - p1); |
| 44 | } |
| 45 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 46 | struct Drmhwc2Device : hwc2_device { |
| 47 | DrmHwcTwo drmhwctwo; |
| 48 | }; |
| 49 | |
| 50 | static DrmHwcTwo *ToDrmHwcTwo(hwc2_device_t *dev) { |
| 51 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast): |
| 52 | return &static_cast<Drmhwc2Device *>(dev)->drmhwctwo; |
| 53 | } |
| 54 | |
| 55 | template <typename PFN, typename T> |
| 56 | static hwc2_function_pointer_t ToHook(T function) { |
| 57 | static_assert(std::is_same<PFN, T>::value, "Incompatible fn pointer"); |
| 58 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): |
| 59 | return reinterpret_cast<hwc2_function_pointer_t>(function); |
| 60 | } |
| 61 | |
| 62 | template <typename T, typename HookType, HookType func, typename... Args> |
| 63 | static T DeviceHook(hwc2_device_t *dev, Args... args) { |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 64 | ALOGV("Device hook: %s", GetFuncName(__PRETTY_FUNCTION__).c_str()); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 65 | DrmHwcTwo *hwc = ToDrmHwcTwo(dev); |
Roman Stratiienko | 9e2a2cd | 2022-12-28 20:47:29 +0200 | [diff] [blame] | 66 | const std::unique_lock lock(hwc->GetResMan().GetMainLock()); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 67 | return static_cast<T>(((*hwc).*func)(std::forward<Args>(args)...)); |
| 68 | } |
| 69 | |
| 70 | template <typename HookType, HookType func, typename... Args> |
| 71 | static int32_t DisplayHook(hwc2_device_t *dev, hwc2_display_t display_handle, |
| 72 | Args... args) { |
Roman Stratiienko | 1301752 | 2022-01-17 10:35:34 +0200 | [diff] [blame] | 73 | ALOGV("Display #%" PRIu64 " hook: %s", display_handle, |
| 74 | GetFuncName(__PRETTY_FUNCTION__).c_str()); |
Roman Stratiienko | 7492358 | 2022-01-17 11:24:21 +0200 | [diff] [blame] | 75 | DrmHwcTwo *hwc = ToDrmHwcTwo(dev); |
Roman Stratiienko | 9e2a2cd | 2022-12-28 20:47:29 +0200 | [diff] [blame] | 76 | const std::unique_lock lock(hwc->GetResMan().GetMainLock()); |
Roman Stratiienko | 938a742 | 2022-01-29 00:10:07 +0200 | [diff] [blame] | 77 | auto *display = hwc->GetDisplay(display_handle); |
| 78 | if (display == nullptr) |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 79 | return static_cast<int32_t>(HWC2::Error::BadDisplay); |
| 80 | |
| 81 | return static_cast<int32_t>((display->*func)(std::forward<Args>(args)...)); |
| 82 | } |
| 83 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 84 | static int HookDevClose(hw_device_t *dev) { |
| 85 | // NOLINTNEXTLINE (cppcoreguidelines-pro-type-reinterpret-cast): Safe |
| 86 | auto *hwc2_dev = reinterpret_cast<hwc2_device_t *>(dev); |
Roman Stratiienko | a7913de | 2022-10-20 13:18:57 +0300 | [diff] [blame] | 87 | const std::unique_ptr<DrmHwcTwo> ctx(ToDrmHwcTwo(hwc2_dev)); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static void HookDevGetCapabilities(hwc2_device_t * /*dev*/, uint32_t *out_count, |
| 92 | int32_t * /*out_capabilities*/) { |
| 93 | *out_count = 0; |
| 94 | } |
| 95 | |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 96 | // NOLINTBEGIN(cppcoreguidelines-macro-usage) |
| 97 | |
| 98 | #define LOCK_COMPOSER(dev) \ |
| 99 | auto *ihwc = ToDrmHwcTwo(dev); \ |
| 100 | const std::unique_lock lock(ihwc->GetResMan().GetMainLock()); |
| 101 | |
| 102 | #define GET_DISPLAY(display_id) \ |
| 103 | auto *idisplay = ihwc->GetDisplay(display_id); \ |
| 104 | if (!idisplay) \ |
| 105 | return static_cast<int32_t>(HWC2::Error::BadDisplay); |
| 106 | |
| 107 | #define GET_LAYER(layer_id) \ |
| 108 | auto *ilayer = idisplay->get_layer(layer_id); \ |
| 109 | if (!ilayer) \ |
| 110 | return static_cast<int32_t>(HWC2::Error::BadLayer); |
| 111 | |
| 112 | // NOLINTEND(cppcoreguidelines-macro-usage) |
| 113 | |
| 114 | static BufferColorSpace Hwc2ToColorSpace(int32_t dataspace) { |
| 115 | switch (dataspace & HAL_DATASPACE_STANDARD_MASK) { |
| 116 | case HAL_DATASPACE_STANDARD_BT709: |
| 117 | return BufferColorSpace::kItuRec709; |
| 118 | case HAL_DATASPACE_STANDARD_BT601_625: |
| 119 | case HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED: |
| 120 | case HAL_DATASPACE_STANDARD_BT601_525: |
| 121 | case HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED: |
| 122 | return BufferColorSpace::kItuRec601; |
| 123 | case HAL_DATASPACE_STANDARD_BT2020: |
| 124 | case HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE: |
| 125 | return BufferColorSpace::kItuRec2020; |
| 126 | default: |
| 127 | return BufferColorSpace::kUndefined; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | static BufferSampleRange Hwc2ToSampleRange(int32_t dataspace) { |
| 132 | switch (dataspace & HAL_DATASPACE_RANGE_MASK) { |
| 133 | case HAL_DATASPACE_RANGE_FULL: |
| 134 | return BufferSampleRange::kFullRange; |
| 135 | case HAL_DATASPACE_RANGE_LIMITED: |
| 136 | return BufferSampleRange::kLimitedRange; |
| 137 | default: |
| 138 | return BufferSampleRange::kUndefined; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | static int32_t SetLayerBlendMode(hwc2_device_t *device, hwc2_display_t display, |
| 143 | hwc2_layer_t layer, |
| 144 | int32_t /*hwc2_blend_mode_t*/ mode) { |
| 145 | ALOGV("SetLayerBlendMode"); |
| 146 | LOCK_COMPOSER(device); |
| 147 | GET_DISPLAY(display); |
| 148 | GET_LAYER(layer); |
| 149 | |
| 150 | BufferBlendMode blend_mode{}; |
| 151 | switch (static_cast<HWC2::BlendMode>(mode)) { |
| 152 | case HWC2::BlendMode::None: |
| 153 | blend_mode = BufferBlendMode::kNone; |
| 154 | break; |
| 155 | case HWC2::BlendMode::Premultiplied: |
| 156 | blend_mode = BufferBlendMode::kPreMult; |
| 157 | break; |
| 158 | case HWC2::BlendMode::Coverage: |
| 159 | blend_mode = BufferBlendMode::kCoverage; |
| 160 | break; |
| 161 | default: |
| 162 | ALOGE("Unknown blending mode b=%d", mode); |
| 163 | blend_mode = BufferBlendMode::kUndefined; |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | HwcLayer::LayerProperties layer_properties; |
| 168 | layer_properties.blend_mode = blend_mode; |
| 169 | |
| 170 | ilayer->SetLayerProperties(layer_properties); |
| 171 | |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | static int32_t SetLayerBuffer(hwc2_device_t *device, hwc2_display_t display, |
| 176 | hwc2_layer_t layer, buffer_handle_t buffer, |
| 177 | int32_t acquire_fence) { |
| 178 | ALOGV("SetLayerBuffer"); |
| 179 | LOCK_COMPOSER(device); |
| 180 | GET_DISPLAY(display); |
| 181 | GET_LAYER(layer); |
| 182 | |
| 183 | HwcLayer::LayerProperties layer_properties; |
| 184 | layer_properties.buffer = {.buffer_handle = buffer, |
| 185 | .acquire_fence = MakeSharedFd(acquire_fence)}; |
| 186 | ilayer->SetLayerProperties(layer_properties); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int32_t SetLayerDataspace(hwc2_device_t *device, hwc2_display_t display, |
| 192 | hwc2_layer_t layer, |
| 193 | int32_t /*android_dataspace_t*/ dataspace) { |
| 194 | ALOGV("SetLayerDataspace"); |
| 195 | LOCK_COMPOSER(device); |
| 196 | GET_DISPLAY(display); |
| 197 | GET_LAYER(layer); |
| 198 | |
| 199 | HwcLayer::LayerProperties layer_properties; |
| 200 | layer_properties.color_space = Hwc2ToColorSpace(dataspace); |
| 201 | layer_properties.sample_range = Hwc2ToSampleRange(dataspace); |
| 202 | ilayer->SetLayerProperties(layer_properties); |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | static int32_t SetCursorPosition(hwc2_device_t * /*device*/, |
| 207 | hwc2_display_t /*display*/, |
| 208 | hwc2_layer_t /*layer*/, int32_t /*x*/, |
| 209 | int32_t /*y*/) { |
| 210 | ALOGV("SetCursorPosition"); |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | static int32_t SetLayerColor(hwc2_device_t * /*device*/, |
| 215 | hwc2_display_t /*display*/, hwc2_layer_t /*layer*/, |
| 216 | hwc_color_t /*color*/) { |
| 217 | ALOGV("SetLayerColor"); |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | static int32_t SetLayerCompositionType(hwc2_device_t *device, |
| 222 | hwc2_display_t display, |
| 223 | hwc2_layer_t layer, |
| 224 | int32_t /*hwc2_composition_t*/ type) { |
| 225 | ALOGV("SetLayerCompositionType"); |
| 226 | LOCK_COMPOSER(device); |
| 227 | GET_DISPLAY(display); |
| 228 | GET_LAYER(layer); |
| 229 | |
| 230 | HwcLayer::LayerProperties layer_properties; |
| 231 | layer_properties.composition_type = static_cast<HWC2::Composition>(type); |
| 232 | ilayer->SetLayerProperties(layer_properties); |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | static int32_t SetLayerDisplayFrame(hwc2_device_t *device, |
| 238 | hwc2_display_t display, hwc2_layer_t layer, |
| 239 | hwc_rect_t frame) { |
| 240 | ALOGV("SetLayerDisplayFrame"); |
| 241 | LOCK_COMPOSER(device); |
| 242 | GET_DISPLAY(display); |
| 243 | GET_LAYER(layer); |
| 244 | |
| 245 | HwcLayer::LayerProperties layer_properties; |
| 246 | layer_properties.display_frame = frame; |
| 247 | ilayer->SetLayerProperties(layer_properties); |
| 248 | |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | static int32_t SetLayerPlaneAlpha(hwc2_device_t *device, hwc2_display_t display, |
| 253 | hwc2_layer_t layer, float alpha) { |
| 254 | ALOGV("SetLayerPlaneAlpha"); |
| 255 | LOCK_COMPOSER(device); |
| 256 | GET_DISPLAY(display); |
| 257 | GET_LAYER(layer); |
| 258 | |
| 259 | HwcLayer::LayerProperties layer_properties; |
| 260 | layer_properties.alpha = alpha; |
| 261 | ilayer->SetLayerProperties(layer_properties); |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | |
| 266 | static int32_t SetLayerSidebandStream(hwc2_device_t * /*device*/, |
| 267 | hwc2_display_t /*display*/, |
| 268 | hwc2_layer_t /*layer*/, |
| 269 | const native_handle_t * /*stream*/) { |
| 270 | ALOGV("SetLayerSidebandStream"); |
| 271 | return static_cast<int32_t>(HWC2::Error::Unsupported); |
| 272 | } |
| 273 | |
| 274 | static int32_t SetLayerSourceCrop(hwc2_device_t *device, hwc2_display_t display, |
| 275 | hwc2_layer_t layer, hwc_frect_t crop) { |
| 276 | ALOGV("SetLayerSourceCrop"); |
| 277 | LOCK_COMPOSER(device); |
| 278 | GET_DISPLAY(display); |
| 279 | GET_LAYER(layer); |
| 280 | |
| 281 | HwcLayer::LayerProperties layer_properties; |
| 282 | layer_properties.source_crop = crop; |
| 283 | ilayer->SetLayerProperties(layer_properties); |
| 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | static int32_t SetLayerSurfaceDamage(hwc2_device_t * /*device*/, |
| 289 | hwc2_display_t /*display*/, |
| 290 | hwc2_layer_t /*layer*/, |
| 291 | hwc_region_t /*damage*/) { |
| 292 | ALOGV("SetLayerSurfaceDamage"); |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | static int32_t SetLayerTransform(hwc2_device_t *device, hwc2_display_t display, |
| 297 | hwc2_layer_t layer, int32_t transform) { |
| 298 | ALOGV("SetLayerTransform"); |
| 299 | LOCK_COMPOSER(device); |
| 300 | GET_DISPLAY(display); |
| 301 | GET_LAYER(layer); |
| 302 | |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 303 | HwcLayer::LayerProperties layer_properties; |
Roman Stratiienko | da2fcf6 | 2025-01-23 17:47:03 +0200 | [diff] [blame] | 304 | layer_properties.transform = { |
| 305 | .hflip = (transform & HAL_TRANSFORM_FLIP_H) != 0, |
| 306 | .vflip = (transform & HAL_TRANSFORM_FLIP_V) != 0, |
| 307 | .rotate90 = (transform & HAL_TRANSFORM_ROT_90) != 0, |
| 308 | }; |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 309 | ilayer->SetLayerProperties(layer_properties); |
| 310 | |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | static int32_t SetLayerVisibleRegion(hwc2_device_t * /*device*/, |
| 315 | hwc2_display_t /*display*/, |
| 316 | hwc2_layer_t /*layer*/, |
| 317 | hwc_region_t /*visible*/) { |
| 318 | ALOGV("SetLayerVisibleRegion"); |
| 319 | return 0; |
| 320 | } |
| 321 | |
| 322 | static int32_t SetLayerZOrder(hwc2_device_t *device, hwc2_display_t display, |
| 323 | hwc2_layer_t layer, uint32_t z) { |
| 324 | ALOGV("SetLayerZOrder"); |
| 325 | LOCK_COMPOSER(device); |
| 326 | GET_DISPLAY(display); |
| 327 | GET_LAYER(layer); |
| 328 | |
| 329 | HwcLayer::LayerProperties layer_properties; |
| 330 | layer_properties.z_order = z; |
| 331 | ilayer->SetLayerProperties(layer_properties); |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | /* Entry point for the HWC2 API */ |
| 337 | // NOLINTBEGIN(cppcoreguidelines-pro-type-cstyle-cast) |
| 338 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 339 | static hwc2_function_pointer_t HookDevGetFunction(struct hwc2_device * /*dev*/, |
| 340 | int32_t descriptor) { |
| 341 | auto func = static_cast<HWC2::FunctionDescriptor>(descriptor); |
| 342 | switch (func) { |
| 343 | // Device functions |
| 344 | case HWC2::FunctionDescriptor::CreateVirtualDisplay: |
| 345 | return ToHook<HWC2_PFN_CREATE_VIRTUAL_DISPLAY>( |
| 346 | DeviceHook<int32_t, decltype(&DrmHwcTwo::CreateVirtualDisplay), |
| 347 | &DrmHwcTwo::CreateVirtualDisplay, uint32_t, uint32_t, |
| 348 | int32_t *, hwc2_display_t *>); |
| 349 | case HWC2::FunctionDescriptor::DestroyVirtualDisplay: |
| 350 | return ToHook<HWC2_PFN_DESTROY_VIRTUAL_DISPLAY>( |
| 351 | DeviceHook<int32_t, decltype(&DrmHwcTwo::DestroyVirtualDisplay), |
| 352 | &DrmHwcTwo::DestroyVirtualDisplay, hwc2_display_t>); |
| 353 | case HWC2::FunctionDescriptor::Dump: |
| 354 | return ToHook<HWC2_PFN_DUMP>( |
| 355 | DeviceHook<void, decltype(&DrmHwcTwo::Dump), &DrmHwcTwo::Dump, |
| 356 | uint32_t *, char *>); |
| 357 | case HWC2::FunctionDescriptor::GetMaxVirtualDisplayCount: |
| 358 | return ToHook<HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT>( |
| 359 | DeviceHook<uint32_t, decltype(&DrmHwcTwo::GetMaxVirtualDisplayCount), |
| 360 | &DrmHwcTwo::GetMaxVirtualDisplayCount>); |
| 361 | case HWC2::FunctionDescriptor::RegisterCallback: |
| 362 | return ToHook<HWC2_PFN_REGISTER_CALLBACK>( |
| 363 | DeviceHook<int32_t, decltype(&DrmHwcTwo::RegisterCallback), |
| 364 | &DrmHwcTwo::RegisterCallback, int32_t, |
| 365 | hwc2_callback_data_t, hwc2_function_pointer_t>); |
| 366 | |
| 367 | // Display functions |
| 368 | case HWC2::FunctionDescriptor::AcceptDisplayChanges: |
| 369 | return ToHook<HWC2_PFN_ACCEPT_DISPLAY_CHANGES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 370 | DisplayHook<decltype(&HwcDisplay::AcceptDisplayChanges), |
| 371 | &HwcDisplay::AcceptDisplayChanges>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 372 | case HWC2::FunctionDescriptor::CreateLayer: |
| 373 | return ToHook<HWC2_PFN_CREATE_LAYER>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 374 | DisplayHook<decltype(&HwcDisplay::CreateLayer), |
| 375 | &HwcDisplay::CreateLayer, hwc2_layer_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 376 | case HWC2::FunctionDescriptor::DestroyLayer: |
| 377 | return ToHook<HWC2_PFN_DESTROY_LAYER>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 378 | DisplayHook<decltype(&HwcDisplay::DestroyLayer), |
| 379 | &HwcDisplay::DestroyLayer, hwc2_layer_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 380 | case HWC2::FunctionDescriptor::GetActiveConfig: |
| 381 | return ToHook<HWC2_PFN_GET_ACTIVE_CONFIG>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 382 | DisplayHook<decltype(&HwcDisplay::GetActiveConfig), |
| 383 | &HwcDisplay::GetActiveConfig, hwc2_config_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 384 | case HWC2::FunctionDescriptor::GetChangedCompositionTypes: |
| 385 | return ToHook<HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 386 | DisplayHook<decltype(&HwcDisplay::GetChangedCompositionTypes), |
| 387 | &HwcDisplay::GetChangedCompositionTypes, uint32_t *, |
| 388 | hwc2_layer_t *, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 389 | case HWC2::FunctionDescriptor::GetClientTargetSupport: |
| 390 | return ToHook<HWC2_PFN_GET_CLIENT_TARGET_SUPPORT>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 391 | DisplayHook<decltype(&HwcDisplay::GetClientTargetSupport), |
| 392 | &HwcDisplay::GetClientTargetSupport, uint32_t, uint32_t, |
| 393 | int32_t, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 394 | case HWC2::FunctionDescriptor::GetColorModes: |
| 395 | return ToHook<HWC2_PFN_GET_COLOR_MODES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 396 | DisplayHook<decltype(&HwcDisplay::GetColorModes), |
| 397 | &HwcDisplay::GetColorModes, uint32_t *, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 398 | case HWC2::FunctionDescriptor::GetDisplayAttribute: |
| 399 | return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 400 | DisplayHook<decltype(&HwcDisplay::GetDisplayAttribute), |
| 401 | &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t, |
| 402 | int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 403 | case HWC2::FunctionDescriptor::GetDisplayConfigs: |
| 404 | return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>( |
Drew Davenport | f7e8833 | 2024-09-06 12:54:38 -0600 | [diff] [blame] | 405 | DisplayHook<decltype(&HwcDisplay::LegacyGetDisplayConfigs), |
| 406 | &HwcDisplay::LegacyGetDisplayConfigs, uint32_t *, |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 407 | hwc2_config_t *>); |
| 408 | case HWC2::FunctionDescriptor::GetDisplayName: |
| 409 | return ToHook<HWC2_PFN_GET_DISPLAY_NAME>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 410 | DisplayHook<decltype(&HwcDisplay::GetDisplayName), |
| 411 | &HwcDisplay::GetDisplayName, uint32_t *, char *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 412 | case HWC2::FunctionDescriptor::GetDisplayRequests: |
| 413 | return ToHook<HWC2_PFN_GET_DISPLAY_REQUESTS>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 414 | DisplayHook<decltype(&HwcDisplay::GetDisplayRequests), |
| 415 | &HwcDisplay::GetDisplayRequests, int32_t *, uint32_t *, |
| 416 | hwc2_layer_t *, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 417 | case HWC2::FunctionDescriptor::GetDisplayType: |
| 418 | return ToHook<HWC2_PFN_GET_DISPLAY_TYPE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 419 | DisplayHook<decltype(&HwcDisplay::GetDisplayType), |
| 420 | &HwcDisplay::GetDisplayType, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 421 | case HWC2::FunctionDescriptor::GetDozeSupport: |
| 422 | return ToHook<HWC2_PFN_GET_DOZE_SUPPORT>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 423 | DisplayHook<decltype(&HwcDisplay::GetDozeSupport), |
| 424 | &HwcDisplay::GetDozeSupport, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 425 | case HWC2::FunctionDescriptor::GetHdrCapabilities: |
| 426 | return ToHook<HWC2_PFN_GET_HDR_CAPABILITIES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 427 | DisplayHook<decltype(&HwcDisplay::GetHdrCapabilities), |
| 428 | &HwcDisplay::GetHdrCapabilities, uint32_t *, int32_t *, |
| 429 | float *, float *, float *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 430 | case HWC2::FunctionDescriptor::GetReleaseFences: |
| 431 | return ToHook<HWC2_PFN_GET_RELEASE_FENCES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 432 | DisplayHook<decltype(&HwcDisplay::GetReleaseFences), |
| 433 | &HwcDisplay::GetReleaseFences, uint32_t *, hwc2_layer_t *, |
| 434 | int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 435 | case HWC2::FunctionDescriptor::PresentDisplay: |
| 436 | return ToHook<HWC2_PFN_PRESENT_DISPLAY>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 437 | DisplayHook<decltype(&HwcDisplay::PresentDisplay), |
| 438 | &HwcDisplay::PresentDisplay, int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 439 | case HWC2::FunctionDescriptor::SetActiveConfig: |
| 440 | return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 441 | DisplayHook<decltype(&HwcDisplay::SetActiveConfig), |
| 442 | &HwcDisplay::SetActiveConfig, hwc2_config_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 443 | case HWC2::FunctionDescriptor::SetClientTarget: |
| 444 | return ToHook<HWC2_PFN_SET_CLIENT_TARGET>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 445 | DisplayHook<decltype(&HwcDisplay::SetClientTarget), |
| 446 | &HwcDisplay::SetClientTarget, buffer_handle_t, int32_t, |
| 447 | int32_t, hwc_region_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 448 | case HWC2::FunctionDescriptor::SetColorMode: |
| 449 | return ToHook<HWC2_PFN_SET_COLOR_MODE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 450 | DisplayHook<decltype(&HwcDisplay::SetColorMode), |
| 451 | &HwcDisplay::SetColorMode, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 452 | case HWC2::FunctionDescriptor::SetColorTransform: |
| 453 | return ToHook<HWC2_PFN_SET_COLOR_TRANSFORM>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 454 | DisplayHook<decltype(&HwcDisplay::SetColorTransform), |
| 455 | &HwcDisplay::SetColorTransform, const float *, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 456 | case HWC2::FunctionDescriptor::SetOutputBuffer: |
| 457 | return ToHook<HWC2_PFN_SET_OUTPUT_BUFFER>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 458 | DisplayHook<decltype(&HwcDisplay::SetOutputBuffer), |
| 459 | &HwcDisplay::SetOutputBuffer, buffer_handle_t, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 460 | case HWC2::FunctionDescriptor::SetPowerMode: |
| 461 | return ToHook<HWC2_PFN_SET_POWER_MODE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 462 | DisplayHook<decltype(&HwcDisplay::SetPowerMode), |
| 463 | &HwcDisplay::SetPowerMode, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 464 | case HWC2::FunctionDescriptor::SetVsyncEnabled: |
| 465 | return ToHook<HWC2_PFN_SET_VSYNC_ENABLED>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 466 | DisplayHook<decltype(&HwcDisplay::SetVsyncEnabled), |
| 467 | &HwcDisplay::SetVsyncEnabled, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 468 | case HWC2::FunctionDescriptor::ValidateDisplay: |
| 469 | return ToHook<HWC2_PFN_VALIDATE_DISPLAY>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 470 | DisplayHook<decltype(&HwcDisplay::ValidateDisplay), |
| 471 | &HwcDisplay::ValidateDisplay, uint32_t *, uint32_t *>); |
Roman Stratiienko | 6b40505 | 2022-12-10 19:09:10 +0200 | [diff] [blame] | 472 | #if __ANDROID_API__ > 27 |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 473 | case HWC2::FunctionDescriptor::GetRenderIntents: |
| 474 | return ToHook<HWC2_PFN_GET_RENDER_INTENTS>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 475 | DisplayHook<decltype(&HwcDisplay::GetRenderIntents), |
| 476 | &HwcDisplay::GetRenderIntents, int32_t, uint32_t *, |
| 477 | int32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 478 | case HWC2::FunctionDescriptor::SetColorModeWithRenderIntent: |
| 479 | return ToHook<HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 480 | DisplayHook<decltype(&HwcDisplay::SetColorModeWithIntent), |
| 481 | &HwcDisplay::SetColorModeWithIntent, int32_t, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 482 | #endif |
Roman Stratiienko | 6b40505 | 2022-12-10 19:09:10 +0200 | [diff] [blame] | 483 | #if __ANDROID_API__ > 28 |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 484 | case HWC2::FunctionDescriptor::GetDisplayIdentificationData: |
| 485 | return ToHook<HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 486 | DisplayHook<decltype(&HwcDisplay::GetDisplayIdentificationData), |
| 487 | &HwcDisplay::GetDisplayIdentificationData, uint8_t *, |
| 488 | uint32_t *, uint8_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 489 | case HWC2::FunctionDescriptor::GetDisplayCapabilities: |
| 490 | return ToHook<HWC2_PFN_GET_DISPLAY_CAPABILITIES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 491 | DisplayHook<decltype(&HwcDisplay::GetDisplayCapabilities), |
| 492 | &HwcDisplay::GetDisplayCapabilities, uint32_t *, |
| 493 | uint32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 494 | case HWC2::FunctionDescriptor::GetDisplayBrightnessSupport: |
| 495 | return ToHook<HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 496 | DisplayHook<decltype(&HwcDisplay::GetDisplayBrightnessSupport), |
| 497 | &HwcDisplay::GetDisplayBrightnessSupport, bool *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 498 | case HWC2::FunctionDescriptor::SetDisplayBrightness: |
| 499 | return ToHook<HWC2_PFN_SET_DISPLAY_BRIGHTNESS>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 500 | DisplayHook<decltype(&HwcDisplay::SetDisplayBrightness), |
| 501 | &HwcDisplay::SetDisplayBrightness, float>); |
Roman Stratiienko | 6b40505 | 2022-12-10 19:09:10 +0200 | [diff] [blame] | 502 | #endif /* __ANDROID_API__ > 28 */ |
| 503 | #if __ANDROID_API__ > 29 |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 504 | case HWC2::FunctionDescriptor::GetDisplayConnectionType: |
| 505 | return ToHook<HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 506 | DisplayHook<decltype(&HwcDisplay::GetDisplayConnectionType), |
| 507 | &HwcDisplay::GetDisplayConnectionType, uint32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 508 | case HWC2::FunctionDescriptor::GetDisplayVsyncPeriod: |
| 509 | return ToHook<HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 510 | DisplayHook<decltype(&HwcDisplay::GetDisplayVsyncPeriod), |
| 511 | &HwcDisplay::GetDisplayVsyncPeriod, |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 512 | hwc2_vsync_period_t *>); |
| 513 | case HWC2::FunctionDescriptor::SetActiveConfigWithConstraints: |
| 514 | return ToHook<HWC2_PFN_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 515 | DisplayHook<decltype(&HwcDisplay::SetActiveConfigWithConstraints), |
| 516 | &HwcDisplay::SetActiveConfigWithConstraints, |
| 517 | hwc2_config_t, hwc_vsync_period_change_constraints_t *, |
| 518 | hwc_vsync_period_change_timeline_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 519 | case HWC2::FunctionDescriptor::SetAutoLowLatencyMode: |
| 520 | return ToHook<HWC2_PFN_SET_AUTO_LOW_LATENCY_MODE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 521 | DisplayHook<decltype(&HwcDisplay::SetAutoLowLatencyMode), |
| 522 | &HwcDisplay::SetAutoLowLatencyMode, bool>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 523 | case HWC2::FunctionDescriptor::GetSupportedContentTypes: |
| 524 | return ToHook<HWC2_PFN_GET_SUPPORTED_CONTENT_TYPES>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 525 | DisplayHook<decltype(&HwcDisplay::GetSupportedContentTypes), |
| 526 | &HwcDisplay::GetSupportedContentTypes, uint32_t *, |
| 527 | uint32_t *>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 528 | case HWC2::FunctionDescriptor::SetContentType: |
| 529 | return ToHook<HWC2_PFN_SET_CONTENT_TYPE>( |
Roman Stratiienko | 3627beb | 2022-01-04 16:02:55 +0200 | [diff] [blame] | 530 | DisplayHook<decltype(&HwcDisplay::SetContentType), |
| 531 | &HwcDisplay::SetContentType, int32_t>); |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 532 | #endif |
| 533 | // Layer functions |
| 534 | case HWC2::FunctionDescriptor::SetCursorPosition: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 535 | return (hwc2_function_pointer_t)SetCursorPosition; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 536 | case HWC2::FunctionDescriptor::SetLayerBlendMode: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 537 | return (hwc2_function_pointer_t)SetLayerBlendMode; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 538 | case HWC2::FunctionDescriptor::SetLayerBuffer: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 539 | return (hwc2_function_pointer_t)SetLayerBuffer; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 540 | case HWC2::FunctionDescriptor::SetLayerColor: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 541 | return (hwc2_function_pointer_t)SetLayerColor; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 542 | case HWC2::FunctionDescriptor::SetLayerCompositionType: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 543 | return (hwc2_function_pointer_t)SetLayerCompositionType; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 544 | case HWC2::FunctionDescriptor::SetLayerDataspace: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 545 | return (hwc2_function_pointer_t)SetLayerDataspace; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 546 | case HWC2::FunctionDescriptor::SetLayerDisplayFrame: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 547 | return (hwc2_function_pointer_t)SetLayerDisplayFrame; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 548 | case HWC2::FunctionDescriptor::SetLayerPlaneAlpha: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 549 | return (hwc2_function_pointer_t)SetLayerPlaneAlpha; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 550 | case HWC2::FunctionDescriptor::SetLayerSidebandStream: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 551 | return (hwc2_function_pointer_t)SetLayerSidebandStream; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 552 | case HWC2::FunctionDescriptor::SetLayerSourceCrop: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 553 | return (hwc2_function_pointer_t)SetLayerSourceCrop; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 554 | case HWC2::FunctionDescriptor::SetLayerSurfaceDamage: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 555 | return (hwc2_function_pointer_t)SetLayerSurfaceDamage; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 556 | case HWC2::FunctionDescriptor::SetLayerTransform: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 557 | return (hwc2_function_pointer_t)SetLayerTransform; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 558 | case HWC2::FunctionDescriptor::SetLayerVisibleRegion: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 559 | return (hwc2_function_pointer_t)SetLayerVisibleRegion; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 560 | case HWC2::FunctionDescriptor::SetLayerZOrder: |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 561 | return (hwc2_function_pointer_t)SetLayerZOrder; |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 562 | case HWC2::FunctionDescriptor::Invalid: |
| 563 | default: |
| 564 | return nullptr; |
| 565 | } |
| 566 | } |
| 567 | |
Roman Stratiienko | 41cd950 | 2025-01-22 16:48:58 +0200 | [diff] [blame] | 568 | // NOLINTEND(cppcoreguidelines-pro-type-cstyle-cast) |
| 569 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 570 | static int HookDevOpen(const struct hw_module_t *module, const char *name, |
| 571 | struct hw_device_t **dev) { |
| 572 | if (strcmp(name, HWC_HARDWARE_COMPOSER) != 0) { |
| 573 | ALOGE("Invalid module name- %s", name); |
| 574 | return -EINVAL; |
| 575 | } |
| 576 | |
| 577 | auto ctx = std::make_unique<Drmhwc2Device>(); |
| 578 | if (!ctx) { |
| 579 | ALOGE("Failed to allocate DrmHwcTwo"); |
| 580 | return -ENOMEM; |
| 581 | } |
| 582 | |
| 583 | ctx->common.tag = HARDWARE_DEVICE_TAG; |
| 584 | ctx->common.version = HWC_DEVICE_API_VERSION_2_0; |
| 585 | ctx->common.close = HookDevClose; |
| 586 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) |
| 587 | ctx->common.module = (hw_module_t *)module; |
| 588 | ctx->getCapabilities = HookDevGetCapabilities; |
| 589 | ctx->getFunction = HookDevGetFunction; |
| 590 | |
Roman Stratiienko | 26fd2b2 | 2022-01-04 12:59:29 +0200 | [diff] [blame] | 591 | *dev = &ctx.release()->common; |
| 592 | |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | } // namespace android |
| 597 | |
| 598 | // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) |
| 599 | static struct hw_module_methods_t hwc2_module_methods = { |
| 600 | .open = android::HookDevOpen, |
| 601 | }; |
| 602 | |
| 603 | // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) |
| 604 | hw_module_t HAL_MODULE_INFO_SYM = { |
| 605 | .tag = HARDWARE_MODULE_TAG, |
| 606 | .module_api_version = HARDWARE_MODULE_API_VERSION(2, 0), |
| 607 | .id = HWC_HARDWARE_MODULE_ID, |
| 608 | .name = "DrmHwcTwo module", |
| 609 | .author = "The Android Open Source Project", |
| 610 | .methods = &hwc2_module_methods, |
| 611 | .dso = nullptr, |
| 612 | .reserved = {0}, |
| 613 | }; |