From 7e1cb7262703c8d873b3838aaf4b5083716b5065 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 24 Mar 2016 11:35:51 +0100 Subject: gfx init and console switching tweaks --- fbi.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'fbi.c') diff --git a/fbi.c b/fbi.c index e25453f..b7edd3b 100644 --- a/fbi.c +++ b/fbi.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -1433,7 +1434,8 @@ int main(int argc, char *argv[]) { int once; int i, arg, key; - char *info, *desc, *filelist, *device; + bool framebuffer = false; + char *info, *desc, *filelist, *device, *mode; char linebuffer[128]; struct flist *fprev = NULL; @@ -1514,17 +1516,39 @@ int main(int argc, char *argv[]) /* gfx device init */ device = cfg_get_str(O_DEVICE); - if (device && strncmp(device, "/dev/dri", 8) == 0) { - gfx = drm_init(device); + mode = cfg_get_str(O_VIDEO_MODE); + if (device) { + /* device specified */ + if (strncmp(device, "/dev/d", 6) == 0) { + gfx = drm_init(device); + } else { + framebuffer = true; + gfx = fb_init(device, mode, GET_VT()); + } } else { - gfx = fb_init(device, - cfg_get_str(O_VIDEO_MODE), - GET_VT()); + /* try drm first, failing that fb */ + gfx = drm_init(NULL); + if (!gfx) { + framebuffer = true; + gfx = fb_init(NULL, mode, GET_VT()); + } + } + if (!gfx) { + fprintf(stderr, "graphics init failed\n"); + exit(1); } exit_signals_init(); - console_switch_init(console_switch_redraw); - shadow_init(gfx); signal(SIGTSTP,SIG_IGN); + if (console_switch_init(console_switch_redraw) < 0) { + fprintf(stderr, "NOTICE: No vt switching available on terminal.\n"); + fprintf(stderr, "NOTICE: Not started from linux console? CONFIG_VT=n?\n"); + if (framebuffer) { + fprintf(stderr, "WARNING: Running on framebuffer and can't manage access.\n"); + fprintf(stderr, "WARNING: Other processes (fbcon too) can write to display.\n"); + fprintf(stderr, "WARNING: Also can't properly cleanup on exit.\n"); + } + } + shadow_init(gfx); /* svga main loop */ tty_raw(); -- cgit