diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 10:45:11 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 10:45:11 +0100 |
commit | 19c335cd7f53d759ec04e96e0d96ed7258f4521c (patch) | |
tree | df8b7c68932407313dcbfbf3867e6c4656a9fe48 | |
parent | 0aa8fef0aeca565aa87fb658fcfdc3e5f713079b (diff) | |
download | fbida-19c335cd7f53d759ec04e96e0d96ed7258f4521c.tar.gz |
add drm support, console switching fixes
-rw-r--r-- | GNUmakefile | 8 | ||||
-rw-r--r-- | fbi.c | 18 | ||||
-rw-r--r-- | fbtools.c | 18 | ||||
-rw-r--r-- | vt.c | 31 | ||||
-rw-r--r-- | vt.h | 1 |
5 files changed, 50 insertions, 26 deletions
diff --git a/GNUmakefile b/GNUmakefile index 82bf42d..4366677 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -172,16 +172,16 @@ ida.o: Ida.ad.h logo.h # object files OBJS_FBI := \ - fbi.o vt.o fbtools.o fb-gui.o desktop.o \ + fbi.o vt.o fbtools.o drmtools.o fb-gui.o desktop.o \ parseconfig.o fbiconfig.o \ jpegtools.o jpeg/$(JPEG_VER)/transupp.o \ dither.o filter.o op.o OBJS_FBI += $(filter-out wr/%,$(call ac_lib_mkvar,$(fbi_libs),OBJS)) -# jpeg/exif libs -fbi : CFLAGS += $(shell $(PKG_CONFIG) --cflags freetype2 fontconfig) -fbi : LDLIBS += $(shell $(PKG_CONFIG) --libs freetype2 fontconfig) +# font + drm + jpeg/exif libs +fbi : CFLAGS += $(shell $(PKG_CONFIG) --cflags freetype2 fontconfig libdrm) +fbi : LDLIBS += $(shell $(PKG_CONFIG) --libs freetype2 fontconfig libdrm) fbi : LDLIBS += -ljpeg -lexif -lm fbi: $(OBJS_FBI) $(OBJS_READER) @@ -38,6 +38,7 @@ #include "readers.h" #include "vt.h" #include "fbtools.h" +#include "drmtools.h" #include "fb-gui.h" #include "filter.h" #include "desktop.h" @@ -1404,6 +1405,7 @@ static void exit_signals_init(void) /* cleanup */ gfx->cleanup_display(); + console_switch_cleanup(); fprintf(stderr,"Oops: %s\n",strsignal(termsig)); exit(42); } @@ -1415,6 +1417,7 @@ static void cleanup_and_exit(int code) shadow_fini(); tty_restore(); gfx->cleanup_display(); + console_switch_cleanup(); flist_print_tagged(stdout); exit(code); } @@ -1430,7 +1433,7 @@ int main(int argc, char *argv[]) { int once; int i, arg, key; - char *info, *desc, *filelist; + char *info, *desc, *filelist, *device; char linebuffer[128]; struct flist *fprev = NULL; @@ -1508,9 +1511,16 @@ int main(int argc, char *argv[]) fprintf(stderr,"can't open font: %s\n",fontname); exit(1); } - gfx = fb_init(cfg_get_str(O_DEVICE), - cfg_get_str(O_VIDEO_MODE), - GET_VT()); + + /* gfx device init */ + device = cfg_get_str(O_DEVICE); + if (device && strncmp(device, "/dev/dri", 8) == 0) { + gfx = drm_init(device); + } else { + gfx = fb_init(device, + cfg_get_str(O_VIDEO_MODE), + GET_VT()); + } exit_signals_init(); console_switch_init(console_switch_redraw); shadow_init(gfx); @@ -42,8 +42,6 @@ static int fb_mem_offset = 0; static int fb; -static int kd_mode; -static struct vt_mode vt_omode; static struct termios term; static struct fb_var_screeninfo fb_ovar; static unsigned short ored[256], ogreen[256], oblue[256]; @@ -212,8 +210,6 @@ static void fb_restore_display(void) static void fb_cleanup_display(void) { /* restore console */ - if (-1 == ioctl(STDIN_FILENO, KDSETMODE, kd_mode)) - perror("ioctl KDSETMODE"); if (-1 == ioctl(fb, FBIOPUT_VSCREENINFO, &fb_ovar)) perror("ioctl FBIOPUT_VSCREENINFO"); if (-1 == ioctl(fb, FBIOGET_FSCREENINFO, &fb_fix)) @@ -225,8 +221,6 @@ static void fb_cleanup_display(void) } close(fb); - if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_omode)) - perror("ioctl VT_SETMODE"); console_restore_vt(); tcsetattr(STDIN_FILENO, TCSANOW, &term); } @@ -291,14 +285,6 @@ gfxstate* fb_init(char *device, char *mode, int vt) exit(1); } } - if (-1 == ioctl(STDIN_FILENO, KDGETMODE, &kd_mode)) { - perror("ioctl KDGETMODE"); - exit(1); - } - if (-1 == ioctl(STDIN_FILENO, VT_GETMODE, &vt_omode)) { - perror("ioctl VT_GETMODE"); - exit(1); - } tcgetattr(STDIN_FILENO, &term); /* switch mode */ @@ -330,10 +316,6 @@ gfxstate* fb_init(char *device, char *mode, int vt) goto err; } } - if (-1 == ioctl(STDIN_FILENO, KDSETMODE, KD_GRAPHICS)) { - perror("ioctl KDSETMODE"); - goto err; - } console_activate_current(); /* cls */ @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include <string.h> #include <fcntl.h> @@ -25,7 +26,10 @@ extern int debug; static int switch_last; static int console_switch_state = CONSOLE_ACTIVE; +static bool console_switching_active; +static int kd_mode; static struct vt_mode vt_mode; +static struct vt_mode vt_omode; static int orig_vt_no = 0; static void (*console_redraw)(void); @@ -82,15 +86,42 @@ int console_switch_init(void (*redraw)(void)) vt_mode.relsig = SIGUSR1; vt_mode.acqsig = SIGUSR2; + if (-1 == ioctl(STDIN_FILENO, VT_GETMODE, &vt_omode)) { + perror("ioctl VT_GETMODE"); + exit(1); + } if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_mode)) { perror("ioctl VT_SETMODE"); exit(1); } + if (-1 == ioctl(STDIN_FILENO, KDGETMODE, &kd_mode)) { + perror("ioctl KDGETMODE"); + exit(1); + } + if (-1 == ioctl(STDIN_FILENO, KDSETMODE, KD_GRAPHICS)) { + perror("ioctl KDSETMODE"); + exit(1); + } + console_switching_active = true; return 0; } +void console_switch_cleanup(void) +{ + if (!console_switching_active) + return; + + if (-1 == ioctl(STDIN_FILENO, KDSETMODE, kd_mode)) + perror("ioctl KDSETMODE"); + if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_omode)) + perror("ioctl VT_SETMODE"); + console_switching_active = false; +} + int check_console_switch(void) { + if (!console_switching_active) + return 0; if (switch_last == console_switch_state) return 0; @@ -1,6 +1,7 @@ extern int console_visible; int console_switch_init(void (*redraw)(void)); +void console_switch_cleanup(void); int check_console_switch(void); void console_set_vt(int vtno); |