aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-07-21 18:58:16 +0200
committerdec05eba <dec05eba@protonmail.com>2023-07-21 18:58:16 +0200
commita559d9741713713deb40dae661bce5112cfa255f (patch)
tree7807176007d0a8ae6ac3e2393308321fce7ad21d
parentd79ba55d8513536960fb050dc8a3f2e966dbbe74 (diff)
Ignore nouveau cards
-rw-r--r--src/main.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c7ad5b5..4582e0f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -647,20 +647,25 @@ static void for_each_active_monitor_output(void *connection, gsr_connection_type
/* output should be >= 128 bytes */
static bool gsr_get_valid_card_path(char *output) {
for(int i = 0; i < 10; ++i) {
- sprintf(output, "/dev/dri/card%d", i);
+ drmVersion *ver = NULL;
+ drmModePlaneResPtr planes = NULL;
+ bool found_screen_card = false;
+
+ sprintf(output, DRM_DEV_NAME, DRM_DIR_NAME, i);
int fd = open(output, O_RDONLY);
if(fd == -1)
continue;
+ ver = drmGetVersion(fd);
+ if(!ver || strstr(ver->name, "nouveau"))
+ goto next;
+
drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
- drmModePlaneResPtr planes = drmModeGetPlaneResources(fd);
- if(!planes) {
- close(fd);
- continue;
- }
+ planes = drmModeGetPlaneResources(fd);
+ if(!planes)
+ goto next;
- bool found_screen_card = false;
for(uint32_t i = 0; i < planes->count_planes; ++i) {
drmModePlanePtr plane = drmModeGetPlane(fd, planes->planes[i]);
if(!plane)
@@ -674,6 +679,11 @@ static bool gsr_get_valid_card_path(char *output) {
break;
}
+ next:
+ if(planes)
+ drmModeFreePlaneResources(planes);
+ if(ver)
+ drmFreeVersion(ver);
close(fd);
if(found_screen_card)
return true;