Skip to content

Commit

Permalink
kmsdrm: settle with first card that has a connected connector
Browse files Browse the repository at this point in the history
Previously the first card with non-empty connectors, encoders
and crtcs would be selected, however KMSDRM_VideoInit could still reject
it if the connector was not connected. This allow finding the first card
(in a multi GPU setup) that is actually connected to a display.
  • Loading branch information
RALOVICH, Kristof committed Jul 20, 2020
1 parent b78b88f commit 155fdc7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/video/kmsdrm/SDL_kmsdrmvideo.c
Expand Up @@ -56,6 +56,7 @@ check_modesetting(int devindex)
int drm_fd;

SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_DRI_PATH, devindex);
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "check_modesetting: probing \"%s\"", device);

drm_fd = open(device, O_RDWR | O_CLOEXEC);
if (drm_fd >= 0) {
Expand All @@ -67,7 +68,20 @@ check_modesetting(int devindex)
resources->count_connectors, resources->count_encoders, resources->count_crtcs);

if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) {
available = SDL_TRUE;
for (int i = 0; i < resources->count_connectors; i++) {
drmModeConnector *conn = KMSDRM_drmModeGetConnector(drm_fd, resources->connectors[i]);

if (!conn) {
continue;
}

if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) {
available = SDL_TRUE;
break;
}

KMSDRM_drmModeFreeConnector(conn);
}
}
KMSDRM_drmModeFreeResources(resources);
}
Expand Down

0 comments on commit 155fdc7

Please sign in to comment.