summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGurpreet Singh Dhami <gdhami@codeaurora.org>2018-08-21 12:19:47 -0400
committerGurpreet Singh Dhami <gdhami@codeaurora.org>2018-08-23 12:57:47 -0400
commit08f7a64fd5b9a9a7779322d50eca8c9c380129c2 (patch)
tree1bc6a7f20f0b7742fe7b404e8f7959264ca50b97
parent9ec9547d998cd5f4af4226593930bba53d8c66e1 (diff)
downloadandroid_hardware_qcom_sdm710_display-08f7a64fd5b9a9a7779322d50eca8c9c380129c2.tar.gz
android_hardware_qcom_sdm710_display-08f7a64fd5b9a9a7779322d50eca8c9c380129c2.tar.bz2
android_hardware_qcom_sdm710_display-08f7a64fd5b9a9a7779322d50eca8c9c380129c2.zip
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
-rw-r--r--sdm/libs/hwc2/hwc_session.cpp19
-rw-r--r--sdm/libs/hwc2/hwc_session.h2
2 files changed, 14 insertions, 7 deletions
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<HWCSession *>(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];