diff options
author | Valerie Hau <vhau@google.com> | 2018-11-19 14:11:09 -0800 |
---|---|---|
committer | Valerie Hau <vhau@google.com> | 2018-11-26 08:49:10 -0800 |
commit | 7aee402474fb1ca5efa68baf11d08f9ea07c3884 (patch) | |
tree | bf641d18227ec4e1a4e84e49205e555a1b47dfdf /msm8996 | |
parent | f198d2aea012dcf502c0879ea5dfbccb2c5ccfa7 (diff) | |
download | display-7aee402474fb1ca5efa68baf11d08f9ea07c3884.tar.gz |
Fixing Error handling in MSM8996 and MSM8998
Bug: 118713045
Test: ./VtsHalGraphicsComposerV2_1TargetTest on Pixel 1 and Pixel 2
Change-Id: Iac3302918af70dbb6566255d243a6a85012d8e57
Diffstat (limited to 'msm8996')
-rw-r--r-- | msm8996/sdm/libs/hwc2/hwc_display.cpp | 4 | ||||
-rw-r--r-- | msm8996/sdm/libs/hwc2/hwc_session.cpp | 12 | ||||
-rw-r--r-- | msm8996/sdm/libs/hwc2/hwc_session.h | 6 |
3 files changed, 16 insertions, 6 deletions
diff --git a/msm8996/sdm/libs/hwc2/hwc_display.cpp b/msm8996/sdm/libs/hwc2/hwc_display.cpp index 507eff5e..49edbc86 100644 --- a/msm8996/sdm/libs/hwc2/hwc_display.cpp +++ b/msm8996/sdm/libs/hwc2/hwc_display.cpp @@ -90,6 +90,10 @@ HWC2::Error HWCColorMode::GetColorModes(uint32_t *out_num_modes, } HWC2::Error HWCColorMode::SetColorMode(android_color_mode_t mode) { + if (color_mode_transform_map_.find(mode) == color_mode_transform_map_.end()) { + DLOGE("mode %d is not a valid color mode", mode); + return HWC2::Error::BadParameter; + } // first mode in 2D matrix is the mode (identity) auto status = HandleColorModeTransform(mode, current_color_transform_, color_matrix_); if (status != HWC2::Error::None) { diff --git a/msm8996/sdm/libs/hwc2/hwc_session.cpp b/msm8996/sdm/libs/hwc2/hwc_session.cpp index a0ff5254..c7d55d73 100644 --- a/msm8996/sdm/libs/hwc2/hwc_session.cpp +++ b/msm8996/sdm/libs/hwc2/hwc_session.cpp @@ -267,7 +267,7 @@ int32_t HWCSession::DestroyVirtualDisplay(hwc2_device_t *device, hwc2_display_t DLOGI("Destroying virtual display id:%" PRIu64, display); auto *hwc_session = static_cast<HWCSession *>(device); - if (hwc_session->hwc_display_[display]) { + if (display < HWC_NUM_DISPLAY_TYPES && hwc_session->hwc_display_[display]) { HWCDisplayVirtual::Destroy(hwc_session->hwc_display_[display]); hwc_session->hwc_display_[display] = nullptr; return HWC2_ERROR_NONE; @@ -359,7 +359,11 @@ 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) { + HWCSession * hwc_session = static_cast<HWCSession *>(device); + if (display >= HWC_NUM_DISPLAY_TYPES || !hwc_session->hwc_display_[display]) { + return HWC2_ERROR_BAD_DISPLAY; + } // TODO(user): Check if it is an HDMI as primary display and disable support for it if (display == HWC_DISPLAY_PRIMARY) { *out_support = 1; @@ -399,7 +403,7 @@ int32_t HWCSession::PresentDisplay(hwc2_device_t *device, hwc2_display_t display auto status = HWC2::Error::BadDisplay; // TODO(user): Handle virtual display/HDMI concurrency - if (hwc_session->hwc_display_[display]) { + if (display < HWC_NUM_DISPLAY_TYPES && hwc_session->hwc_display_[display]) { status = hwc_session->hwc_display_[display]->Present(out_retire_fence); // This is only indicative of how many times SurfaceFlinger posts // frames to the display. @@ -568,7 +572,7 @@ int32_t HWCSession::ValidateDisplay(hwc2_device_t *device, hwc2_display_t displa // TODO(user): Handle secure session, handle QDCM solid fill // Handle external_pending_connect_ in CreateVirtualDisplay auto status = HWC2::Error::BadDisplay; - if (hwc_session->hwc_display_[display]) { + if (display < HWC_NUM_DISPLAY_TYPES && hwc_session->hwc_display_[display]) { SEQUENCE_ENTRY_SCOPE_LOCK(locker_); if (display == HWC_DISPLAY_PRIMARY) { // TODO(user): This can be moved to HWCDisplayPrimary diff --git a/msm8996/sdm/libs/hwc2/hwc_session.h b/msm8996/sdm/libs/hwc2/hwc_session.h index ad767dab..51404317 100644 --- a/msm8996/sdm/libs/hwc2/hwc_session.h +++ b/msm8996/sdm/libs/hwc2/hwc_session.h @@ -53,7 +53,7 @@ class HWCSession : hwc2_device_t, public qClient::BnQClient { HWCSession *hwc_session = static_cast<HWCSession *>(device); auto status = HWC2::Error::BadDisplay; - if (hwc_session->hwc_display_[display]) { + if (display < HWC_NUM_DISPLAY_TYPES && hwc_session->hwc_display_[display]) { auto hwc_display = hwc_session->hwc_display_[display]; status = (hwc_display->*member)(std::forward<Args>(args)...); } @@ -70,7 +70,7 @@ class HWCSession : hwc2_device_t, public qClient::BnQClient { HWCSession *hwc_session = static_cast<HWCSession *>(device); auto status = HWC2::Error::BadDisplay; - if (hwc_session->hwc_display_[display]) { + if (display < HWC_NUM_DISPLAY_TYPES && hwc_session->hwc_display_[display]) { status = HWC2::Error::BadLayer; auto hwc_layer = hwc_session->hwc_display_[display]->GetHWCLayer(layer); if (hwc_layer != nullptr) { @@ -109,6 +109,8 @@ class HWCSession : hwc2_device_t, public qClient::BnQClient { int32_t /*android_color_mode_t*/ int_mode); static int32_t SetColorTransform(hwc2_device_t *device, hwc2_display_t display, const float *matrix, int32_t /*android_color_transform_t*/ hint); + static int32_t GetDozeSupport(hwc2_device_t *device, hwc2_display_t display, + int32_t *outSupported); private: static const int kExternalConnectionTimeoutMs = 500; |