aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2016-03-23 16:28:10 +0100
committerGerd Hoffmann <kraxel@redhat.com>2016-03-23 16:28:10 +0100
commit5e7572dd3b05e5c5e76ab185dd77367f8ae738e5 (patch)
treef6277283a55ee6c5073fe26c800c9e410a56fcf8
parenta80c7e0c5a22c303bc24c97f01f61466eb94b03e (diff)
downloadfbida-5e7572dd3b05e5c5e76ab185dd77367f8ae738e5.tar.gz
gfx: move over cleanup function
-rw-r--r--fbi.c2
-rw-r--r--fbtools.c60
-rw-r--r--fbtools.h1
-rw-r--r--gfx.h1
4 files changed, 33 insertions, 31 deletions
diff --git a/fbi.c b/fbi.c
index ae5d7e7..3436113 100644
--- a/fbi.c
+++ b/fbi.c
@@ -1403,7 +1403,7 @@ static void cleanup_and_exit(int code)
shadow_fini();
fb_clear_screen(gfx);
tty_restore();
- fb_cleanup();
+ gfx->cleanup_display();
flist_print_tagged(stdout);
exit(code);
}
diff --git a/fbtools.c b/fbtools.c
index 9618e7a..4bb08bf 100644
--- a/fbtools.c
+++ b/fbtools.c
@@ -389,6 +389,34 @@ static void fb_restore_display(void)
fb_set_palette();
}
+static void fb_cleanup_display(void)
+{
+ /* restore console */
+ if (-1 == ioctl(tty,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))
+ perror("ioctl FBIOGET_FSCREENINFO");
+ if (fb_ovar.bits_per_pixel == 8 ||
+ fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
+ if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
+ perror("ioctl FBIOPUTCMAP");
+ }
+ close(fb);
+
+ if (-1 == ioctl(tty,VT_SETMODE, &vt_omode))
+ perror("ioctl VT_SETMODE");
+ if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no))
+ perror("ioctl VT_ACTIVATE");
+ if (orig_vt_no && -1 == ioctl(tty, VT_WAITACTIVE, orig_vt_no))
+ perror("ioctl VT_WAITACTIVE");
+ tcsetattr(tty, TCSANOW, &term);
+ close(tty);
+}
+
+/* -------------------------------------------------------------------- */
+
gfxstate* fb_init(char *device, char *mode, int vt)
{
char fbdev[16];
@@ -537,42 +565,16 @@ gfxstate* fb_init(char *device, char *mode, int vt)
gfx->bits_per_pixel = fb_var.bits_per_pixel;
gfx->restore_display = fb_restore_display;
+ gfx->cleanup_display = fb_cleanup_display;
gfx->fb_fd = fb;
return gfx;
err:
- fb_cleanup();
+ fb_cleanup_display();
exit(1);
}
-void
-fb_cleanup(void)
-{
- /* restore console */
- if (-1 == ioctl(tty,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))
- perror("ioctl FBIOGET_FSCREENINFO");
- if (fb_ovar.bits_per_pixel == 8 ||
- fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
- if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
- perror("ioctl FBIOPUTCMAP");
- }
- close(fb);
-
- if (-1 == ioctl(tty,VT_SETMODE, &vt_omode))
- perror("ioctl VT_SETMODE");
- if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no))
- perror("ioctl VT_ACTIVATE");
- if (orig_vt_no && -1 == ioctl(tty, VT_WAITACTIVE, orig_vt_no))
- perror("ioctl VT_WAITACTIVE");
- tcsetattr(tty, TCSANOW, &term);
- close(tty);
-}
-
/* -------------------------------------------------------------------- */
/* handle fatal errors */
@@ -608,7 +610,7 @@ fb_catch_exit_signals(void)
return;
/* cleanup */
- fb_cleanup();
+ fb_cleanup_display();
fprintf(stderr,"Oops: %s\n",strsignal(termsig));
exit(42);
}
diff --git a/fbtools.h b/fbtools.h
index 363a163..1636654 100644
--- a/fbtools.h
+++ b/fbtools.h
@@ -10,7 +10,6 @@ extern int fb_switch_state;
/* init + cleanup */
gfxstate *fb_init(char *device, char *mode, int vt);
-void fb_cleanup(void);
void fb_catch_exit_signals(void);
void fb_memset(void *addr, int c, size_t len);
diff --git a/gfx.h b/gfx.h
index 817664c..a64b1e8 100644
--- a/gfx.h
+++ b/gfx.h
@@ -15,6 +15,7 @@ struct gfxstate {
/* calls */
void (*restore_display)(void);
+ void (*cleanup_display)(void);
/* FIXME: legacy */
int fb_fd;