drm_hwcomposer: Configuring Composer HAL to use sequential IDs
Implement Google guidelines from [1]
1. The supported display config IDs are:
id=1, 1080x1920 60hz
id=2, 1080x1920 50hz
2. When a change of display configs is processed, the next set of config IDs
are assigned starting from the next unused integer, shown as follows:
id=3, 2160x3840 60hz
id=4, 2160x3840 50hz
id=5, 1080x1920 60hz
id=6, 1080x1920 50hz
+ Don't update modes in GetDisplayConfigs() . Modes is now updated at init or
after every hotplug event.
[1]: https://source.android.com/devices/graphics/hotplug#configuring-composer-hal-sequential-ids
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index c8f5e69..0ceafed 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -329,15 +329,6 @@
HWC2::Error HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
hwc2_config_t *configs) {
- // Since this callback is normally invoked twice (once to get the count, and
- // once to populate configs), we don't really want to read the edid
- // redundantly. Instead, only update the modes on the first invocation. While
- // it's possible this will result in stale modes, it'll all come out in the
- // wash when we try to set the active config later.
- if (!configs) {
- configs_.Update(*connector_);
- }
-
uint32_t idx = 0;
for (auto &hwc_config : configs_.hwc_configs) {
if (hwc_config.second.disabled) {
diff --git a/hwc2_device/HwcDisplayConfigs.cpp b/hwc2_device/HwcDisplayConfigs.cpp
index d1a8d4c..e3d17a2 100644
--- a/hwc2_device/HwcDisplayConfigs.cpp
+++ b/hwc2_device/HwcDisplayConfigs.cpp
@@ -33,16 +33,16 @@
return HWC2::Error::BadDisplay;
}
- hwc_configs.clear();
- preferred_config_id = 0;
- int preferred_config_group_id = 0;
-
if (connector.modes().empty()) {
ALOGE("No modes reported by KMS");
return HWC2::Error::BadDisplay;
}
- int last_config_id = 1;
+ hwc_configs.clear();
+ preferred_config_id = 0;
+ int preferred_config_group_id = 0;
+
+ int first_config_id = last_config_id;
int last_group_id = 1;
/* Group modes */
@@ -87,7 +87,7 @@
/* We must have preferred mode. Set first mode as preferred
* in case KMS haven't reported anything. */
if (preferred_config_id == 0) {
- preferred_config_id = 1;
+ preferred_config_id = first_config_id;
preferred_config_group_id = 1;
}
@@ -142,8 +142,8 @@
* otherwise android.graphics.cts.SetFrameRateTest CTS will fail
*/
constexpr float kMinFpsDelta = 1.0; // FPS
- for (int m1 = 1; m1 < last_config_id; m1++) {
- for (int m2 = 1; m2 < last_config_id; m2++) {
+ for (int m1 = first_config_id; m1 < last_config_id; m1++) {
+ for (int m2 = first_config_id; m2 < last_config_id; m2++) {
if (m1 != m2 && hwc_configs[m1].group_id == hwc_configs[m2].group_id &&
!hwc_configs[m1].disabled && !hwc_configs[m2].disabled &&
fabsf(hwc_configs[m1].mode.v_refresh() -
diff --git a/hwc2_device/HwcDisplayConfigs.h b/hwc2_device/HwcDisplayConfigs.h
index cb38625..7450b8d 100644
--- a/hwc2_device/HwcDisplayConfigs.h
+++ b/hwc2_device/HwcDisplayConfigs.h
@@ -45,6 +45,8 @@
int active_config_id = 0;
int preferred_config_id = 0;
+
+ int last_config_id = 1;
};
} // namespace android