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