drm_hwcomposer: Set display config on initialization
We shouldn't wait for surfaceflinger to set active config, initialize
the display with a config. For now we just choose the first config in
the list. This should change to a more sane choice, such as the preferred
mode or something similar.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: Ib063080c282cec28c9b0218c0ba5151d48b367ce
diff --git a/hwcomposer.cpp b/hwcomposer.cpp
index 214b40d..2ed2073 100644
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -1116,6 +1116,36 @@
return ret;
}
+/*
+ * TODO: This function sets the active config to the first one in the list. This
+ * should be fixed such that it selects the preferred mode for the display, or
+ * some other, saner, method of choosing the config.
+ */
+static int hwc_set_initial_config(struct hwc_drm_display *hd)
+{
+ int ret;
+ uint32_t config;
+ size_t num_configs = 1;
+
+ ret = hwc_get_display_configs(&hd->ctx->device, hd->display, &config,
+ &num_configs);
+ if (ret) {
+ ALOGE("Failed to get display configs d=%d ret=%d", hd->display,
+ ret);
+ }
+ if (!num_configs)
+ return 0;
+
+ ret = hwc_set_active_config(&hd->ctx->device, hd->display, 0);
+ if (ret) {
+ ALOGE("Failed to set active config d=%d ret=%d", hd->display,
+ ret);
+ return ret;
+ }
+
+ return ret;
+}
+
static int hwc_initialize_display(struct hwc_context_t *ctx, int display,
uint32_t connector_id)
{
@@ -1139,6 +1169,13 @@
}
hd->timeline_fd = ret;
+ ret = hwc_set_initial_config(hd);
+ if (ret) {
+ ALOGE("Failed to set initial config for d=%d ret=%d", display,
+ ret);
+ return ret;
+ }
+
ret = hwc_initialize_worker(hd, &hd->set_worker, hwc_set_worker);
if (ret) {
ALOGE("Failed to create set worker %d\n", ret);