OSDN Git Service

gralloc_drm_kms: try to find more primary display
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 4 Jan 2018 02:36:19 +0000 (10:36 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 4 Jan 2018 02:36:19 +0000 (10:36 +0800)
Consider DSI as the primary display as well as LVDS.

gralloc_drm_kms.c

index 667b500..a5fd3ee 100644 (file)
@@ -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++) {