mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
[DRM] Use a GFX card with connected monitors
This commit is contained in:
parent
2503b00299
commit
1d12c56332
26
extlibs/headers/drm/drm-common.c
vendored
26
extlibs/headers/drm/drm-common.c
vendored
@ -170,6 +170,26 @@ static int get_resources(int fd, drmModeRes **resources)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int has_monitor_connected(int fd, drmModeRes* resources)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
drmModeConnector *connector;
|
||||||
|
for (i = 0; i < resources->count_connectors; i++)
|
||||||
|
{
|
||||||
|
connector = drmModeGetConnector(fd, resources->connectors[i]);
|
||||||
|
if (connector->connection == DRM_MODE_CONNECTED)
|
||||||
|
{
|
||||||
|
/* There is a monitor connected */
|
||||||
|
drmModeFreeConnector(connector);
|
||||||
|
connector = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
drmModeFreeConnector(connector);
|
||||||
|
connector = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define MAX_DRM_DEVICES 64
|
#define MAX_DRM_DEVICES 64
|
||||||
|
|
||||||
static int find_drm_device(drmModeRes **resources)
|
static int find_drm_device(drmModeRes **resources)
|
||||||
@ -199,7 +219,11 @@ static int find_drm_device(drmModeRes **resources)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
continue;
|
continue;
|
||||||
ret = get_resources(fd, resources);
|
ret = get_resources(fd, resources);
|
||||||
if (!ret)
|
if(getenv("SFML_DRM_DEBUG"))
|
||||||
|
{
|
||||||
|
printf("DRM device used: %d\n", i);
|
||||||
|
}
|
||||||
|
if(!ret && has_monitor_connected(fd, *resources) != 0)
|
||||||
break;
|
break;
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user