X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pandora%2Fpicorestore.c;fp=pandora%2Fpicorestore.c;h=6a327552a458ff6edbf0998c824440a36594674b;hb=f6eaae4f09c6abab99692900a31c1df2a06b99af;hp=0000000000000000000000000000000000000000;hpb=0c9ae59222a6fa9af18dcc072fdfb06cfca124d6;p=libpicofe.git diff --git a/pandora/picorestore.c b/pandora/picorestore.c new file mode 100644 index 0000000..6a32755 --- /dev/null +++ b/pandora/picorestore.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + struct fb_var_screeninfo fbvar; + struct termios kbd_termios; + int ret, fbdev, kbdfd; + FILE *tios_f; + + fbdev = open("/dev/fb0", O_RDWR); + if (fbdev == -1) { + perror("open"); + return 1; + } + + ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar); + if (ret == -1) { + perror("FBIOGET_VSCREENINFO ioctl"); + goto end_fb; + } + + if (fbvar.yoffset != 0) { + printf("fixing yoffset.. "); + fbvar.yoffset = 0; + ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar); + if (ret < 0) + perror("ioctl FBIOPAN_DISPLAY"); + else + printf("ok\n"); + } + +end_fb: + close(fbdev); + + tios_f = fopen("/tmp/pico_tios", "rb"); + if (tios_f != NULL) { + kbdfd = open("/dev/tty", O_RDWR); + if (kbdfd == -1) { + perror("open /dev/tty"); + return 1; + } + + if (fread(&kbd_termios, sizeof(kbd_termios), 1, tios_f) == 1) { + if (ioctl(kbdfd, KDSETMODE, KD_TEXT) == -1) + perror("KDSETMODE KD_TEXT"); + + printf("restoring termios.. "); + if (tcsetattr(kbdfd, TCSAFLUSH, &kbd_termios) == -1) + perror("tcsetattr"); + else + printf("ok\n"); + } + + close(kbdfd); + fclose(tios_f); + } + + return 0; +}