mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
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.
This commit is contained in:
parent
5551bf92a9
commit
88d042ec49
1 changed files with 24 additions and 0 deletions
24
sway/main.c
24
sway/main.c
|
@ -135,6 +135,29 @@ void detect_proprietary() {
|
||||||
"You need nvidia, nvidia_modeset, nvidia_uvm, and nvidia_drm."
|
"You need nvidia, nvidia_modeset, nvidia_uvm, and nvidia_drm."
|
||||||
"\x1B[0m\n");
|
"\x1B[0m\n");
|
||||||
}
|
}
|
||||||
|
#ifdef __linux__
|
||||||
|
f = fopen("/sys/module/nvidia_drm/parameters/modeset", "r");
|
||||||
|
if (f) {
|
||||||
|
char *line = read_line(f);
|
||||||
|
if (line && strstr(line, "Y")) {
|
||||||
|
// nvidia-drm.modeset is set to 0
|
||||||
|
fprintf(stderr, "\x1B[1;31mWarning: You must load "
|
||||||
|
"nvidia-drm with the modeset option on to use "
|
||||||
|
"the proprietary driver. Consider adding "
|
||||||
|
"nvidia-drm.modeset=1 to your kernel command line "
|
||||||
|
"parameters.\x1B[0m\n");
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
free(line);
|
||||||
|
} else {
|
||||||
|
// nvidia-drm.modeset is not set
|
||||||
|
fprintf(stderr, "\x1B[1;31mWarning: You must load "
|
||||||
|
"nvidia-drm with the modeset option on to use "
|
||||||
|
"the proprietary driver. Consider adding "
|
||||||
|
"nvidia-drm.modeset=1 to your kernel command line "
|
||||||
|
"parameters.\x1B[0m\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
f = fopen("/proc/cmdline", "r");
|
f = fopen("/proc/cmdline", "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
char *line = read_line(f);
|
char *line = read_line(f);
|
||||||
|
@ -146,6 +169,7 @@ void detect_proprietary() {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue