From bf1e1a796198e8e220a0bd1cd6a5f346f4f9b3fa Mon Sep 17 00:00:00 2001 From: llyyr Date: Mon, 14 Aug 2023 19:14:16 +0530 Subject: drm_common: skip cards that don't have connected outputs It's possible for systems to have multiple cards, and the first capable card to not have a connected output. Skip such cards and continue iterating until we find one with a connected output. --- video/out/drm_common.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'video') diff --git a/video/out/drm_common.c b/video/out/drm_common.c index b4064879de..0ec0788480 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -816,6 +816,24 @@ static bool card_supports_kms(const char *path) return ret; } +static bool card_has_connection(const char *path) +{ + int fd = open_card_path(path); + bool ret = false; + if (fd != -1) { + drmModeRes *res = drmModeGetResources(fd); + if (res) { + drmModeConnector *connector = get_first_connected_connector(res, fd); + if (connector) + ret = true; + drmModeFreeConnector(connector); + drmModeFreeResources(res); + } + close(fd); + } + return ret; +} + static void get_primary_device_path(struct vo_drm_state *drm) { if (drm->opts->device_path) { @@ -865,6 +883,17 @@ static void get_primary_device_path(struct vo_drm_state *drm) continue; } + if (!card_has_connection(card_path)) { + if (card_no_given) { + MP_ERR(drm, + "DRM card number %d given, but it does not have any " + "connected outputs.\n", i); + break; + } + + continue; + } + MP_VERBOSE(drm, "Picked DRM card %d, primary node %s%s.\n", i, card_path, card_no_given ? "" : " as the default"); -- cgit v1.2.3