From 0113d20d468b5372685c7ae286f4fe4ab7a58fa0 Mon Sep 17 00:00:00 2001 From: Drew Davenport Date: Tue, 15 Apr 2025 12:00:43 -0600 Subject: [PATCH] drm_hwcomposer: Remove HWC2 LegacyGetDisplayConfigs This was only used by the HWC2 frontend. Move the function to hwc2_device. Change-Id: I4b539e9a37ea09bd577eadd44c205e17230a5a6b Signed-off-by: Drew Davenport --- hwc2_device/HwcDisplay.cpp | 21 --------------------- hwc2_device/HwcDisplay.h | 2 -- hwc2_device/hwc2_device.cpp | 32 ++++++++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp index 22556aa..efd2adb 100644 --- a/hwc2_device/HwcDisplay.cpp +++ b/hwc2_device/HwcDisplay.cpp @@ -667,27 +667,6 @@ HWC2::Error HwcDisplay::GetColorModes(uint32_t *num_modes, int32_t *modes) { return HWC2::Error::None; } -HWC2::Error HwcDisplay::LegacyGetDisplayConfigs(uint32_t *num_configs, - hwc2_config_t *configs) { - uint32_t idx = 0; - for (auto &hwc_config : configs_.hwc_configs) { - if (hwc_config.second.disabled) { - continue; - } - - if (configs != nullptr) { - if (idx >= *num_configs) { - break; - } - configs[idx] = hwc_config.second.id; - } - - idx++; - } - *num_configs = idx; - return HWC2::Error::None; -} - HWC2::Error HwcDisplay::GetDisplayName(uint32_t *size, char *name) { std::ostringstream stream; if (IsInHeadlessMode()) { diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h index c4f7d7e..35276e5 100644 --- a/hwc2_device/HwcDisplay.h +++ b/hwc2_device/HwcDisplay.h @@ -152,8 +152,6 @@ class HwcDisplay { // HWC2 Hooks - these should not be used outside of the hwc2 device. HWC2::Error GetColorModes(uint32_t *num_modes, int32_t *modes); - HWC2::Error LegacyGetDisplayConfigs(uint32_t *num_configs, - hwc2_config_t *configs); HWC2::Error GetDisplayName(uint32_t *size, char *name); #if __ANDROID_API__ > 27 HWC2::Error GetRenderIntents(int32_t mode, uint32_t *outNumIntents, diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp index 1b05547..46e725f 100644 --- a/hwc2_device/hwc2_device.cpp +++ b/hwc2_device/hwc2_device.cpp @@ -481,6 +481,33 @@ static int32_t GetDisplayAttribute(hwc2_device_t *device, return 0; } +static int32_t GetDisplayConfigs(hwc2_device_t *device, hwc2_display_t display, + uint32_t *num_configs, + hwc2_config_t *configs) { + ALOGV("GetDisplayConfigs"); + LOCK_COMPOSER(device); + GET_DISPLAY(display); + + uint32_t idx = 0; + for (const auto &hwc_config : idisplay->GetDisplayConfigs().hwc_configs) { + if (hwc_config.second.disabled) { + continue; + } + + if (configs != nullptr) { + if (idx >= *num_configs) { + break; + } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): + configs[idx] = hwc_config.second.id; + } + + idx++; + } + *num_configs = idx; + return 0; +} + static int32_t SetOutputBuffer(hwc2_device_t *device, hwc2_display_t display, buffer_handle_t buffer, int32_t release_fence) { ALOGV("SetOutputBuffer"); @@ -1118,10 +1145,7 @@ static hwc2_function_pointer_t HookDevGetFunction(struct hwc2_device * /*dev*/, case HWC2::FunctionDescriptor::GetDisplayAttribute: return (hwc2_function_pointer_t)GetDisplayAttribute; case HWC2::FunctionDescriptor::GetDisplayConfigs: - return ToHook( - DisplayHook); + return (hwc2_function_pointer_t)GetDisplayConfigs; case HWC2::FunctionDescriptor::GetDisplayName: return ToHook( DisplayHook