sdm: Don't block draw-cycle thread during SetDisplayBrightness
Driver makes sure that Panel commands are serialized to any frame
update on Panel. SetDisplayBrightness API doesn't need to acquire
locker_ lock which blocks draw-cycle thread and causes frame drops.
Define brightness_lock_ to serialize Set and Get Panel brightness.
CRs-Fixed: 2446089
Change-Id: I963f1b3ddcd4765ddff805a373f70cdd550fa993
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index d2f61c5..40a21d7 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -2910,7 +2910,15 @@
}
int32_t HWCSession::SetDisplayBrightness(hwc2_display_t display, float brightness) {
- return CallDisplayFunction(display, &HWCDisplay::SetPanelBrightness, brightness);
+ if (display >= HWCCallbacks::kNumDisplays) {
+ return HWC2_ERROR_BAD_DISPLAY;
+ }
+
+ if (!hwc_display_[display]) {
+ return HWC2_ERROR_BAD_PARAMETER;
+ }
+
+ return INT32(hwc_display_[display]->SetPanelBrightness(brightness));
}
android::status_t HWCSession::SetQSyncMode(const android::Parcel *input_parcel) {
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 8d7529a..267a4d7 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -285,7 +285,7 @@
}
DisplayError DisplayBuiltIn::SetPanelBrightness(float brightness) {
- lock_guard<recursive_mutex> obj(recursive_mutex_);
+ lock_guard<recursive_mutex> obj(brightness_lock_);
if (brightness != -1.0f && !(0.0f <= brightness && brightness <= 1.0f)) {
DLOGE("Bad brightness value = %f", brightness);
@@ -441,7 +441,7 @@
}
DisplayError DisplayBuiltIn::GetPanelBrightness(float *brightness) {
- lock_guard<recursive_mutex> obj(recursive_mutex_);
+ lock_guard<recursive_mutex> obj(brightness_lock_);
DisplayError err = kErrorNone;
int level = 0;
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index 6fe7b34..3a0e887 100644
--- a/sdm/libs/core/display_builtin.h
+++ b/sdm/libs/core/display_builtin.h
@@ -112,6 +112,7 @@
float level_remainder_ = 0.0f;
float cached_brightness_ = 0.0f;
bool pending_brightness_ = false;
+ recursive_mutex brightness_lock_;
};
} // namespace sdm