From ae768a1e141eb88243e46757d41ca0cada9502b4 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 2 Aug 2022 18:55:22 +0200 Subject: drm_common: skip cards that don't support KMS for autodetection Avoids another pitfall on systems where the first card has a primary node but is not capable of KMS. With this change --drm-context=drm should work correctly out-of-the-box in all cases. --- video/out/drm_common.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'video/out') diff --git a/video/out/drm_common.c b/video/out/drm_common.c index 7ba9636edb..b2bbc03ceb 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -558,6 +558,21 @@ static char *get_primary_device_path(struct mp_log *log, int *card_no) const char *primary_node_path = dev->nodes[DRM_NODE_PRIMARY]; + int fd = open_card_path(primary_node_path); + const int is_kms = fd != -1 && drmIsKMS(fd); + if (fd != -1) + close(fd); + if (!is_kms) { + if (card_no_given) { + mp_err(log, + "DRM card number %d given, yet it does not support " + "KMS!\n", i); + break; + } + + continue; + } + mp_verbose(log, "Picked DRM card %d, primary node %s%s.\n", i, primary_node_path, card_no_given ? "" : " as the default"); -- cgit v1.2.3