aboutsummaryrefslogtreecommitdiffstats
path: root/sway/main.c
diff options
context:
space:
mode:
authorLibravatar Dan Robertson <dan.robertson@anidata.org>2017-10-24 22:35:31 +0000
committerLibravatar Dan Robertson <dan.robertson@anidata.org>2017-10-24 22:35:31 +0000
commit88d042ec498b0edf480d36f737da93160b2c9a2c (patch)
tree4210724a73677c96984ab11c63a91a8aa2bb5f18 /sway/main.c
parentMerge pull request #1427 from ranisalt/patch-1 (diff)
downloadsway-88d042ec498b0edf480d36f737da93160b2c9a2c.tar.gz
sway-88d042ec498b0edf480d36f737da93160b2c9a2c.tar.zst
sway-88d042ec498b0edf480d36f737da93160b2c9a2c.zip
nvidia: Validate the nvidia_drm module options
When the proprietary nvidia driver is used, ensure the modeset option is set instead of checking /proc/cmdline for nvidia-drm.modeset=1.
Diffstat (limited to 'sway/main.c')
-rw-r--r--sway/main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/main.c b/sway/main.c
index 6d13955c..cc9147b8 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -135,6 +135,29 @@ void detect_proprietary() {
135 "You need nvidia, nvidia_modeset, nvidia_uvm, and nvidia_drm." 135 "You need nvidia, nvidia_modeset, nvidia_uvm, and nvidia_drm."
136 "\x1B[0m\n"); 136 "\x1B[0m\n");
137 } 137 }
138#ifdef __linux__
139 f = fopen("/sys/module/nvidia_drm/parameters/modeset", "r");
140 if (f) {
141 char *line = read_line(f);
142 if (line && strstr(line, "Y")) {
143 // nvidia-drm.modeset is set to 0
144 fprintf(stderr, "\x1B[1;31mWarning: You must load "
145 "nvidia-drm with the modeset option on to use "
146 "the proprietary driver. Consider adding "
147 "nvidia-drm.modeset=1 to your kernel command line "
148 "parameters.\x1B[0m\n");
149 }
150 fclose(f);
151 free(line);
152 } else {
153 // nvidia-drm.modeset is not set
154 fprintf(stderr, "\x1B[1;31mWarning: You must load "
155 "nvidia-drm with the modeset option on to use "
156 "the proprietary driver. Consider adding "
157 "nvidia-drm.modeset=1 to your kernel command line "
158 "parameters.\x1B[0m\n");
159 }
160#else
138 f = fopen("/proc/cmdline", "r"); 161 f = fopen("/proc/cmdline", "r");
139 if (f) { 162 if (f) {
140 char *line = read_line(f); 163 char *line = read_line(f);
@@ -146,6 +169,7 @@ void detect_proprietary() {
146 fclose(f); 169 fclose(f);
147 free(line); 170 free(line);
148 } 171 }
172#endif
149 } 173 }
150} 174}
151 175