From 08f7a64fd5b9a9a7779322d50eca8c9c380129c2 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Dhami Date: Tue, 21 Aug 2018 12:19:47 -0400 Subject: hwc2: Fix GetDozeSupport api to handle failure case Fix for GetDozeSupport api to return BAD_DISPLAY error, if that display doesn't exist. Change-Id: I53c61d0d0adc3850ef9e82da189c4d8141466c93 --- sdm/libs/hwc2/hwc_session.cpp | 19 ++++++++++++------- sdm/libs/hwc2/hwc_session.h | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'sdm/libs') diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 6520c3ee..d8c633e0 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -557,12 +557,14 @@ static int32_t GetDisplayType(hwc2_device_t *device, hwc2_display_t display, int return HWCSession::CallDisplayFunction(device, display, &HWCDisplay::GetDisplayType, out_type); } -static int32_t GetDozeSupport(hwc2_device_t *device, hwc2_display_t display, int32_t *out_support) { +int32_t HWCSession::GetDozeSupport(hwc2_device_t *device, hwc2_display_t display, + int32_t *out_support) { if (!device || !out_support) { return HWC2_ERROR_BAD_PARAMETER; } - if (display >= HWC_NUM_DISPLAY_TYPES) { + HWCSession *hwc_session = static_cast(device); + if (display >= HWC_NUM_DISPLAY_TYPES || (hwc_session->hwc_display_[display] == nullptr) ) { return HWC2_ERROR_BAD_DISPLAY; } @@ -606,7 +608,7 @@ int32_t HWCSession::PresentDisplay(hwc2_device_t *device, hwc2_display_t display auto status = HWC2::Error::BadDisplay; DTRACE_SCOPED(); - if (display >= HWC_NUM_DISPLAY_TYPES) { + if (display >= HWC_NUM_DISPLAY_TYPES || (hwc_session->hwc_display_[display] == nullptr)) { return HWC2_ERROR_BAD_DISPLAY; } @@ -621,9 +623,7 @@ int32_t HWCSession::PresentDisplay(hwc2_device_t *device, hwc2_display_t display } // TODO(user): Handle virtual display/HDMI concurrency - if (hwc_session->hwc_display_[display]) { - status = hwc_session->PresentDisplayInternal(display, out_retire_fence); - } + status = hwc_session->PresentDisplayInternal(display, out_retire_fence); } if (status != HWC2::Error::None && status != HWC2::Error::NotValidated) { @@ -837,7 +837,12 @@ int32_t HWCSession::SetPowerMode(hwc2_device_t *device, hwc2_display_t display, // all displays support on/off. Check for doze modes int support = 0; - GetDozeSupport(device, display, &support); + + auto status = GetDozeSupport(device, display, &support); + if (status != HWC2_ERROR_NONE) { + return INT32(status); + } + if (!support && (mode == HWC2::PowerMode::Doze || mode == HWC2::PowerMode::DozeSuspend)) { return HWC2_ERROR_UNSUPPORTED; } diff --git a/sdm/libs/hwc2/hwc_session.h b/sdm/libs/hwc2/hwc_session.h index 725e9836..b499e8d9 100644 --- a/sdm/libs/hwc2/hwc_session.h +++ b/sdm/libs/hwc2/hwc_session.h @@ -169,6 +169,8 @@ class HWCSession : hwc2_device_t, HWCUEventListener, IDisplayConfig, public qCli const native_handle_t *buffer, int32_t acquire_fence); static int32_t GetReadbackBufferFence(hwc2_device_t *device, hwc2_display_t display, int32_t *release_fence); + static int32_t GetDozeSupport(hwc2_device_t *device, hwc2_display_t display, + int32_t *out_support); static Locker locker_[HWC_NUM_DISPLAY_TYPES]; -- cgit v1.2.3