diff options
author | Gurpreet Singh Dhami <gdhami@codeaurora.org> | 2018-08-29 16:51:26 -0400 |
---|---|---|
committer | Valerie Hau <vhau@google.com> | 2018-09-05 10:55:41 -0700 |
commit | 14f67c1ee21fd501019b5836ea77bcef786b3339 (patch) | |
tree | 370cdaf90633bd1c2762feb1191c8a9ad581cffb /sdm | |
parent | c6f78ae7619550ddbb924f7bfb569ce3c093b3a0 (diff) | |
download | display-14f67c1ee21fd501019b5836ea77bcef786b3339.tar.gz |
hwc2: Fix error handling for invalid ColorMode and RenderIntent
Fix to return BAD_PARAMETER for invalid RenderIntent value in
GetRenderIntents api and invalid ColorMode in
SetColorModeWithRenderIntent api. Currently they return
Unsupported error.
Bug: 113347082
Bug: 113339753
Test: ./VtsHalGraphicsComposerV2_2TargetTest
Change-Id: Ic56322f56170d2e421161c69ebf4900f86ec554c
Diffstat (limited to 'sdm')
-rw-r--r-- | sdm/libs/hwc2/hwc_session.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 6ce78bf7..556acef7 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -436,6 +436,11 @@ static int32_t GetRenderIntents(hwc2_device_t *device, hwc2_display_t display, if (out_num_intents == nullptr) { return HWC2_ERROR_BAD_PARAMETER; } + + if (mode < ColorMode::NATIVE || mode > ColorMode::BT2100_HLG) { + DLOGE("Invalid ColorMode: %d", mode); + return HWC2_ERROR_BAD_PARAMETER; + } return HWCSession::CallDisplayFunction(device, display, &HWCDisplay::GetRenderIntents, mode, out_num_intents, out_intents); } @@ -681,6 +686,11 @@ int32_t HWCSession::SetColorModeWithRenderIntent(hwc2_device_t *device, hwc2_dis return HWC2_ERROR_BAD_PARAMETER; } auto render_intent = static_cast<RenderIntent>(int_render_intent); + if ((render_intent < RenderIntent::COLORIMETRIC) || + (render_intent > RenderIntent::TONE_MAP_ENHANCE)) { + DLOGE("Invalid RenderIntent: %d", render_intent); + return HWC2_ERROR_BAD_PARAMETER; + } return HWCSession::CallDisplayFunction(device, display, &HWCDisplay::SetColorModeWithRenderIntent, mode, render_intent); } @@ -1492,6 +1502,11 @@ android::status_t HWCSession::SetColorModeOverride(const android::Parcel *input_ auto mode = static_cast<ColorMode>(input_parcel->readInt32()); auto device = static_cast<hwc2_device_t *>(this); + if (mode < ColorMode::NATIVE || mode > ColorMode::BT2100_HLG) { + DLOGE("Invalid ColorMode: %d", mode); + return HWC2_ERROR_BAD_PARAMETER; + } + auto err = CallDisplayFunction(device, display, &HWCDisplay::SetColorMode, mode); if (err != HWC2_ERROR_NONE) return -EINVAL; @@ -1506,6 +1521,16 @@ android::status_t HWCSession::SetColorModeWithRenderIntentOverride( auto intent = static_cast<RenderIntent>(input_parcel->readInt32()); auto device = static_cast<hwc2_device_t *>(this); + if (mode < ColorMode::NATIVE || mode > ColorMode::BT2100_HLG) { + DLOGE("Invalid ColorMode: %d", mode); + return HWC2_ERROR_BAD_PARAMETER; + } + + if (intent < RenderIntent::COLORIMETRIC || intent > RenderIntent::TONE_MAP_ENHANCE) { + DLOGE("Invalid RenderIntent: %d", intent); + return HWC2_ERROR_BAD_PARAMETER; + } + auto err = CallDisplayFunction(device, display, &HWCDisplay::SetColorModeWithRenderIntent, mode, intent); if (err != HWC2_ERROR_NONE) |