From 6963f5a3793cd41add831fe5b09dfdf81521f681 Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Thu, 4 Jan 2018 10:36:19 +0800 Subject: [PATCH] gralloc_drm_kms: try to find more primary display Consider DSI as the primary display as well as LVDS. --- gralloc_drm_kms.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gralloc_drm_kms.c b/gralloc_drm_kms.c index 667b500..a5fd3ee 100644 --- a/gralloc_drm_kms.c +++ b/gralloc_drm_kms.c @@ -1245,9 +1245,6 @@ static void *extcon_observer(void *data) */ int gralloc_drm_init_kms(struct gralloc_drm_t *drm) { - drmModeConnectorPtr lvds; - int i, ret; - if (drm->resources) return 0; @@ -1285,18 +1282,26 @@ int gralloc_drm_init_kms(struct gralloc_drm_t *drm) drm->output_capacity = drm->resources->count_connectors; drm->output_count = 0; - drm->outputs = malloc(sizeof(*drm->outputs) * drm->output_capacity); - memset(drm->outputs, 0, sizeof(*drm->outputs) * drm->output_capacity); + drm->outputs = calloc(sizeof(*drm->outputs), drm->output_capacity); /* find the crtc/connector/mode to use */ - lvds = fetch_connector(drm, DRM_MODE_CONNECTOR_LVDS); - if (lvds) { - drm_kms_init_with_new_connector(drm, lvds); - drmModeFreeConnector(lvds); + uint32_t internal_connectors[] = { + DRM_MODE_CONNECTOR_LVDS, + DRM_MODE_CONNECTOR_DSI, + }; + for (size_t i = 0; i < sizeof(internal_connectors) / sizeof(uint32_t); i++) { + drmModeConnectorPtr connector; + connector = fetch_connector(drm, internal_connectors[i]); + if (connector) { + drm_kms_init_with_new_connector(drm, connector); + drmModeFreeConnector(connector); + break; + } } /* if still no connector, find first connected connector and try it */ if (!drm->primary) { + int i; ALOGI("Try to find the first connected connector"); for (i = 0; i < drm->resources->count_connectors; i++) { -- 2.11.0