mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
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.
This commit is contained in:
parent
d2074fee0a
commit
bf1e1a7961
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user