From c8ace00f91756209f034374f27e5c2ef0d37d98b Mon Sep 17 00:00:00 2001 From: Drew Davenport Date: Sun, 6 Apr 2025 11:42:53 -0600 Subject: [PATCH] drm_hwcomposer: Remove HWC2 SetActiveConfig Move the function to the HWC2 frontend, and implement the function in terms of HwcDisplay::QueueConfig Change-Id: Ia47503ac7463041c36ed4e6ad5374b3491019c2d Signed-off-by: Drew Davenport --- hwc2_device/HwcDisplay.cpp | 12 ----------- hwc2_device/HwcDisplay.h | 1 - hwc2_device/hwc2_device.cpp | 41 +++++++++++++++++++++++++------------ 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp index f58e72f..65016dc 100644 --- a/hwc2_device/HwcDisplay.cpp +++ b/hwc2_device/HwcDisplay.cpp @@ -1017,18 +1017,6 @@ HWC2::Error HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) { return HWC2::Error::None; } -HWC2::Error HwcDisplay::SetActiveConfig(hwc2_config_t config) { - if (configs_.hwc_configs.count(config) == 0) { - ALOGE("Could not find active mode for %u", config); - return HWC2::Error::BadConfig; - } - - staged_mode_change_time_ = ResourceManager::GetTimeMonotonicNs(); - staged_mode_config_id_ = config; - - return HWC2::Error::None; -} - HWC2::Error HwcDisplay::SetColorMode(int32_t mode) { /* Maps to the Colorspace DRM connector property: * https://elixir.bootlin.com/linux/v6.11/source/include/drm/drm_connector.h#L538 diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h index ac01781..8aaba07 100644 --- a/hwc2_device/HwcDisplay.h +++ b/hwc2_device/HwcDisplay.h @@ -166,7 +166,6 @@ class HwcDisplay { float *max_luminance, float *max_average_luminance, float *min_luminance); - HWC2::Error SetActiveConfig(hwc2_config_t config); HWC2::Error SetColorMode(int32_t mode); HWC2::Error SetColorTransform(const float *matrix, int32_t hint); HwcLayer *get_layer(ILayerId layer) { diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp index d876c83..026537a 100644 --- a/hwc2_device/hwc2_device.cpp +++ b/hwc2_device/hwc2_device.cpp @@ -33,6 +33,19 @@ namespace android { +static int32_t ConfigErrorToHWC2(HwcDisplay::ConfigError result) { + switch (result) { + case HwcDisplay::ConfigError::kBadConfig: + return static_cast(HWC2::Error::BadConfig); + case HwcDisplay::ConfigError::kSeamlessNotAllowed: + return static_cast(HWC2::Error::SeamlessNotAllowed); + case HwcDisplay::ConfigError::kSeamlessNotPossible: + return static_cast(HWC2::Error::SeamlessNotPossible); + case HwcDisplay::ConfigError::kNone: + return static_cast(HWC2::Error::None); + } +} + /* Converts long __PRETTY_FUNCTION__ result, e.g.: * "int32_t android::LayerHook(hwc2_device_t *, hwc2_display_t, hwc2_layer_t," * "Args...) [HookType = HWC2::Error (android::HwcLayer::*)(const native_handle" @@ -582,6 +595,19 @@ static int32_t PresentDisplay(hwc2_device_t *device, hwc2_display_t display, return 0; } +static int32_t SetActiveConfig(hwc2_device_t *device, hwc2_display_t display, + hwc2_config_t config) { + ALOGV("SetActiveConfig"); + LOCK_COMPOSER(device); + GET_DISPLAY(display); + + QueuedConfigTiming out_timing{}; + auto result = idisplay->QueueConfig(config, + ResourceManager::GetTimeMonotonicNs(), + false, &out_timing); + return ConfigErrorToHWC2(result); +} + #if __ANDROID_API__ >= 28 static int32_t GetDisplayBrightnessSupport(hwc2_device_t * /*device*/, @@ -714,16 +740,7 @@ static int32_t SetActiveConfigWithConstraints( out_timeline->refreshTimeNanos = out_timing.refresh_time_ns; out_timeline->refreshRequired = 1; - switch (result) { - case HwcDisplay::ConfigError::kBadConfig: - return static_cast(HWC2::Error::BadConfig); - case HwcDisplay::ConfigError::kSeamlessNotAllowed: - return static_cast(HWC2::Error::SeamlessNotAllowed); - case HwcDisplay::ConfigError::kSeamlessNotPossible: - return static_cast(HWC2::Error::SeamlessNotPossible); - case HwcDisplay::ConfigError::kNone: - return static_cast(HWC2::Error::None); - } + return ConfigErrorToHWC2(result); } static int32_t SetAutoLowLatencyMode(hwc2_device_t * /*device*/, @@ -1063,9 +1080,7 @@ static hwc2_function_pointer_t HookDevGetFunction(struct hwc2_device * /*dev*/, case HWC2::FunctionDescriptor::PresentDisplay: return (hwc2_function_pointer_t)PresentDisplay; case HWC2::FunctionDescriptor::SetActiveConfig: - return ToHook( - DisplayHook); + return (hwc2_function_pointer_t)SetActiveConfig; case HWC2::FunctionDescriptor::SetClientTarget: return (hwc2_function_pointer_t)SetClientTarget; case HWC2::FunctionDescriptor::SetColorMode: