diff options
author | Gurpreet Singh Dhami <gdhami@codeaurora.org> | 2018-08-29 16:51:26 -0400 |
---|---|---|
committer | Gurpreet Singh Dhami <gdhami@codeaurora.org> | 2018-09-04 19:12:31 -0400 |
commit | 425545165353f882abbdd6eac0828d3515ef4186 (patch) | |
tree | c517833d96d829b310b9c53b0aef2515d60eea88 | |
parent | 4796d2bbc6559ecda4951c17468665c0feec6eb6 (diff) | |
download | android_hardware_qcom_sdm710_display-425545165353f882abbdd6eac0828d3515ef4186.tar.gz android_hardware_qcom_sdm710_display-425545165353f882abbdd6eac0828d3515ef4186.tar.bz2 android_hardware_qcom_sdm710_display-425545165353f882abbdd6eac0828d3515ef4186.zip |
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.
Change-Id: Ic56322f56170d2e421161c69ebf4900f86ec554c
-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 aa2c22c7..39c73f85 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -455,6 +455,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); } @@ -700,6 +705,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); } @@ -1524,6 +1534,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; @@ -1538,6 +1553,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) |