misc: do not hang if graphics backend is not available
This commit is contained in:
parent
ba3f08698e
commit
23e24f7f89
4 changed files with 38 additions and 63 deletions
|
|
@ -12,6 +12,7 @@ If a change only affects particular applications, they are listed in parentheses
|
||||||
|
|
||||||
- misc: Use standard C library instead of builtin functions (!49, thanks @vstoiakin)
|
- misc: Use standard C library instead of builtin functions (!49, thanks @vstoiakin)
|
||||||
- feat: Add support for split packaging of buffyboard and unl0kr (!54, thanks @vstoiakin)
|
- feat: Add support for split packaging of buffyboard and unl0kr (!54, thanks @vstoiakin)
|
||||||
|
- fix: Do not hang if graphics backend is not available (!57, thanks @vstoiakin)
|
||||||
|
|
||||||
## 3.3.0 (2025-04-15)
|
## 3.3.0 (2025-04-15)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,10 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* Initialise display */
|
/* Initialise display */
|
||||||
lv_display_t *disp = lv_linux_fbdev_create();
|
lv_display_t *disp = lv_linux_fbdev_create();
|
||||||
|
if (access("/dev/fb0", F_OK) != 0) {
|
||||||
|
bbx_log(BBX_LOG_LEVEL_ERROR, "/dev/fb0 is not available");
|
||||||
|
sigaction_handler(SIGTERM);
|
||||||
|
}
|
||||||
lv_linux_fbdev_set_file(disp, "/dev/fb0");
|
lv_linux_fbdev_set_file(disp, "/dev/fb0");
|
||||||
if (conf_opts.quirks.fbdev_force_refresh) {
|
if (conf_opts.quirks.fbdev_force_refresh) {
|
||||||
lv_linux_fbdev_set_force_refresh(disp, true);
|
lv_linux_fbdev_set_force_refresh(disp, true);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -193,6 +192,11 @@ static void shutdown(void);
|
||||||
*/
|
*/
|
||||||
static void sigaction_handler(int signum);
|
static void sigaction_handler(int signum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore the terminal and exit from the program with EXIT_FAILURE.
|
||||||
|
*/
|
||||||
|
static void exit_failure();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static functions
|
* Static functions
|
||||||
|
|
@ -372,6 +376,11 @@ static void sigaction_handler(int signum) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void exit_failure() {
|
||||||
|
ul_terminal_reset_current_terminal();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main
|
* Main
|
||||||
|
|
@ -423,6 +432,10 @@ int main(int argc, char *argv[]) {
|
||||||
case UL_BACKENDS_BACKEND_FBDEV:
|
case UL_BACKENDS_BACKEND_FBDEV:
|
||||||
bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using framebuffer backend");
|
bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using framebuffer backend");
|
||||||
disp = lv_linux_fbdev_create();
|
disp = lv_linux_fbdev_create();
|
||||||
|
if (access("/dev/fb0", F_OK) != 0) {
|
||||||
|
bbx_log(BBX_LOG_LEVEL_ERROR, "/dev/fb0 is not available");
|
||||||
|
exit_failure();
|
||||||
|
}
|
||||||
lv_linux_fbdev_set_file(disp, "/dev/fb0");
|
lv_linux_fbdev_set_file(disp, "/dev/fb0");
|
||||||
if (conf_opts.quirks.fbdev_force_refresh) {
|
if (conf_opts.quirks.fbdev_force_refresh) {
|
||||||
lv_linux_fbdev_set_force_refresh(disp, true);
|
lv_linux_fbdev_set_force_refresh(disp, true);
|
||||||
|
|
@ -434,27 +447,28 @@ int main(int argc, char *argv[]) {
|
||||||
bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using DRM backend");
|
bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using DRM backend");
|
||||||
disp = lv_linux_drm_create();
|
disp = lv_linux_drm_create();
|
||||||
|
|
||||||
char *format_string = "/dev/dri/card%d";
|
char drm_path[16];
|
||||||
char drm_path[16] = {0};
|
bool found = false;
|
||||||
struct stat buffer;
|
for (int i = 0; i < 9; i++) {
|
||||||
|
sprintf(drm_path, "/dev/dri/card%d", i);
|
||||||
|
|
||||||
for (size_t i = 0; i < 9; i++) {
|
if (access(drm_path, F_OK) == 0) {
|
||||||
sprintf(drm_path, format_string, i);
|
found = true;
|
||||||
|
break;
|
||||||
if (stat(drm_path, &buffer) != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_linux_drm_set_file(disp, drm_path, -1);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (!found) {
|
||||||
|
bbx_log(BBX_LOG_LEVEL_ERROR, "/dev/dri/card* are not available");
|
||||||
|
exit_failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_linux_drm_set_file(disp, drm_path, -1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif /* LV_USE_LINUX_DRM */
|
#endif /* LV_USE_LINUX_DRM */
|
||||||
default:
|
default:
|
||||||
bbx_log(BBX_LOG_LEVEL_ERROR, "Unable to find suitable backend");
|
bbx_log(BBX_LOG_LEVEL_ERROR, "Unable to find suitable backend");
|
||||||
exit(EXIT_FAILURE);
|
exit_failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Override display properties with command line options if necessary */
|
/* Override display properties with command line options if necessary */
|
||||||
|
|
|
||||||
|
|
@ -26,50 +26,6 @@ static int current_fd = -1;
|
||||||
static int original_mode = -1;
|
static int original_mode = -1;
|
||||||
static int original_kb_mode = -1;
|
static int original_kb_mode = -1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static prototypes
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the current file descriptor and reopen /dev/tty0.
|
|
||||||
*
|
|
||||||
* @return true if opening was successful, false otherwise
|
|
||||||
*/
|
|
||||||
static bool reopen_current_terminal(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the current file descriptor.
|
|
||||||
*/
|
|
||||||
static void close_current_terminal(void);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
static bool reopen_current_terminal(void) {
|
|
||||||
close_current_terminal();
|
|
||||||
|
|
||||||
current_fd = open("/dev/tty0", O_RDWR);
|
|
||||||
if (current_fd < 0) {
|
|
||||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Could not open /dev/tty0");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void close_current_terminal(void) {
|
|
||||||
if (current_fd < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(current_fd);
|
|
||||||
current_fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public functions
|
* Public functions
|
||||||
*/
|
*/
|
||||||
|
|
@ -80,11 +36,10 @@ void ul_terminal_prepare_current_terminal(bool enable_graphics_mode, bool disabl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reopen the current terminal */
|
/* Open the current terminal */
|
||||||
reopen_current_terminal();
|
current_fd = open("/dev/tty0", O_RDWR);
|
||||||
|
|
||||||
if (current_fd < 0) {
|
if (current_fd < 0) {
|
||||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Could not prepare current terminal");
|
bbx_log(BBX_LOG_LEVEL_WARNING, "Could not open /dev/tty0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,5 +83,6 @@ void ul_terminal_reset_current_terminal(void) {
|
||||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Could not reset terminal keyboard mode");
|
bbx_log(BBX_LOG_LEVEL_WARNING, "Could not reset terminal keyboard mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
close_current_terminal();
|
close(current_fd);
|
||||||
|
current_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue