summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2019-03-13 19:05:40 +0000
committerMichael Wright <michaelwr@google.com>2019-03-13 22:05:08 +0000
commit965961d0fca31d11bdc1fcbcfc3c65cebb3d65d0 (patch)
tree5a431a4b2219722e01f39637e57a83fcb3c83e7e
parent3bf5d9ce38d0836668736883d6b5f711ef925604 (diff)
downloadandroid_hardware_qcom_sdm845_display-965961d0fca31d11bdc1fcbcfc3c65cebb3d65d0.tar.gz
android_hardware_qcom_sdm845_display-965961d0fca31d11bdc1fcbcfc3c65cebb3d65d0.tar.bz2
android_hardware_qcom_sdm845_display-965961d0fca31d11bdc1fcbcfc3c65cebb3d65d0.zip
Validate FD when reporting brightness support.
If we fail to open the brightness sysfs node, then we shouldn't report that we support setting the brightness since any attempts fail. Also, fix capabilities count. This was accidentally left in when moving brightness support from a global capability to a display-specific one. Bug: 128496688 Test: manual Change-Id: Ie623b98232481bca3c0f955b259a3b168c83cf2e
-rw-r--r--sdm/libs/hwc2/hwc_session.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 60b719f8..3b13681b 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -310,7 +310,7 @@ void HWCSession::GetCapabilities(struct hwc2_device *device, uint32_t *outCount,
if (Debug::Get()->GetProperty(DISABLE_SKIP_VALIDATE_PROP, &value) == kErrorNone) {
disable_skip_validate = (value == 1);
}
- uint32_t count = 2 + (disable_skip_validate ? 0 : 1);
+ uint32_t count = 1 + (disable_skip_validate ? 0 : 1);
if (outCapabilities != nullptr && (*outCount >= count)) {
outCapabilities[0] = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM;
@@ -948,9 +948,14 @@ int32_t HWCSession::GetDisplayCapabilities(hwc2_device_t* device, hwc2_display_t
return INT32(HWC2::Error::None);
}
- bool brightness_support = display == HWC_DISPLAY_PRIMARY;
+ bool brightness_support = false;
+ auto status = GetDisplayBrightnessSupport(device, display, &brightness_support);
+ if (status != HWC2_ERROR_NONE) {
+ DLOGE("Failed to get display brightness support Error = %d", status);
+ return INT32(status);
+ }
int doze_support = 0;
- auto status = GetDozeSupport(device, display, &doze_support);
+ status = GetDozeSupport(device, display, &doze_support);
if (status != HWC2_ERROR_NONE) {
DLOGE("Failed to get doze support Error = %d", status);
return INT32(status);
@@ -974,13 +979,19 @@ int32_t HWCSession::GetDisplayCapabilities(hwc2_device_t* device, hwc2_display_t
int32_t HWCSession::GetDisplayBrightnessSupport(hwc2_device_t *device, hwc2_display_t display,
bool *out_support) {
- *out_support = display == HWC_DISPLAY_PRIMARY;
+ HWCSession *hwc_session = static_cast<HWCSession *>(device);
+ *out_support = display == HWC_DISPLAY_PRIMARY && hwc_session->brightness_fd_ != -1;
return INT32(HWC2::Error::None);
}
int32_t HWCSession::SetDisplayBrightness(hwc2_device_t *device, hwc2_display_t display,
float brightness) {
- if (display != HWC_DISPLAY_PRIMARY) {
+ bool brightness_support = false;
+ auto status = GetDisplayBrightnessSupport(device, display, &brightness_support);
+ if (status != HWC2_ERROR_NONE) {
+ return INT32(status);
+ }
+ if (!brightness_support) {
return INT32(HWC2::Error::BadDisplay);
}
int backlight = -1;