summaryrefslogtreecommitdiffstats
path: root/video/out/drm_common.c
diff options
context:
space:
mode:
authorllyyr <llyyr.public@gmail.com>2023-08-14 19:14:16 +0530
committersfan5 <sfan5@live.de>2023-08-20 19:59:36 +0200
commitbf1e1a796198e8e220a0bd1cd6a5f346f4f9b3fa (patch)
tree63d0828113eb9363080d569c5eea3a4e2a15df61 /video/out/drm_common.c
parentd2074fee0a489aba747cd71ee15d5f996230c968 (diff)
downloadmpv-bf1e1a796198e8e220a0bd1cd6a5f346f4f9b3fa.tar.bz2
mpv-bf1e1a796198e8e220a0bd1cd6a5f346f4f9b3fa.tar.xz
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.
Diffstat (limited to 'video/out/drm_common.c')
-rw-r--r--video/out/drm_common.c29
1 files changed, 29 insertions, 0 deletions
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");