aboutsummaryrefslogtreecommitdiffstats
path: root/sway/server.c
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-12-12 15:25:10 +0100
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2023-12-12 10:04:14 -0500
commitff07eab85b5c6b728ad3cc99d02e9f2ae8b9854f (patch)
treefc4aa760eafe3a14c37fd11d8743c3b54e31de9c /sway/server.c
parentDrop fglrx detection (diff)
downloadsway-ff07eab85b5c6b728ad3cc99d02e9f2ae8b9854f.tar.gz
sway-ff07eab85b5c6b728ad3cc99d02e9f2ae8b9854f.tar.zst
sway-ff07eab85b5c6b728ad3cc99d02e9f2ae8b9854f.zip
Detect Nvidia proprietary driver via drmGetVersion()
This is less punishing for users with the Nvidia driver loaded but not used by Sway (e.g. for CUDA).
Diffstat (limited to 'sway/server.c')
-rw-r--r--sway/server.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/server.c b/sway/server.c
index be521621..267e46c0 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -37,6 +37,7 @@
37#include <wlr/types/wlr_xdg_foreign_v1.h> 37#include <wlr/types/wlr_xdg_foreign_v1.h>
38#include <wlr/types/wlr_xdg_foreign_v2.h> 38#include <wlr/types/wlr_xdg_foreign_v2.h>
39#include <wlr/types/wlr_xdg_output_v1.h> 39#include <wlr/types/wlr_xdg_output_v1.h>
40#include <xf86drm.h>
40#include "config.h" 41#include "config.h"
41#include "list.h" 42#include "list.h"
42#include "log.h" 43#include "log.h"
@@ -60,6 +61,8 @@
60#define SWAY_XDG_SHELL_VERSION 2 61#define SWAY_XDG_SHELL_VERSION 2
61#define SWAY_LAYER_SHELL_VERSION 4 62#define SWAY_LAYER_SHELL_VERSION 4
62 63
64bool allow_unsupported_gpu = false;
65
63#if WLR_HAS_DRM_BACKEND 66#if WLR_HAS_DRM_BACKEND
64static void handle_drm_lease_request(struct wl_listener *listener, void *data) { 67static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
65 /* We only offer non-desktop outputs, but in the future we might want to do 68 /* We only offer non-desktop outputs, but in the future we might want to do
@@ -113,6 +116,33 @@ static bool filter_global(const struct wl_client *client,
113 return true; 116 return true;
114} 117}
115 118
119static void detect_proprietary(struct wlr_backend *backend, void *data) {
120 int drm_fd = wlr_backend_get_drm_fd(backend);
121 if (drm_fd < 0) {
122 return;
123 }
124
125 drmVersion *version = drmGetVersion(drm_fd);
126 if (version == NULL) {
127 sway_log(SWAY_ERROR, "drmGetVersion() failed");
128 return;
129 }
130
131 if (strcmp(version->name, "nvidia-drm") == 0) {
132 if (allow_unsupported_gpu) {
133 sway_log(SWAY_ERROR, "!!! Proprietary Nvidia drivers are in use !!!");
134 } else {
135 sway_log(SWAY_ERROR,
136 "Proprietary Nvidia drivers are NOT supported. "
137 "Use Nouveau. To launch sway anyway, launch with "
138 "--unsupported-gpu and DO NOT report issues.");
139 exit(EXIT_FAILURE);
140 }
141 }
142
143 drmFreeVersion(version);
144}
145
116bool server_init(struct sway_server *server) { 146bool server_init(struct sway_server *server) {
117 sway_log(SWAY_DEBUG, "Initializing Wayland server"); 147 sway_log(SWAY_DEBUG, "Initializing Wayland server");
118 server->wl_display = wl_display_create(); 148 server->wl_display = wl_display_create();
@@ -128,6 +158,8 @@ bool server_init(struct sway_server *server) {
128 return false; 158 return false;
129 } 159 }
130 160
161 wlr_multi_for_each_backend(server->backend, detect_proprietary, NULL);
162
131 server->renderer = wlr_renderer_autocreate(server->backend); 163 server->renderer = wlr_renderer_autocreate(server->backend);
132 if (!server->renderer) { 164 if (!server->renderer) {
133 sway_log(SWAY_ERROR, "Failed to create renderer"); 165 sway_log(SWAY_ERROR, "Failed to create renderer");