pandora: tripplebuffer fbdev out, refactoring
[libpicofe.git] / pandora / pandora.c
index 92047c2..4019994 100644 (file)
@@ -1,62 +1,39 @@
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <stdarg.h>\r
-#include <string.h>\r
-#include <unistd.h>\r
-#include <sys/mman.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <linux/fb.h>\r
-#include <fcntl.h>\r
-#include <errno.h>\r
 \r
 #include "../linux/sndout_oss.h"\r
-#include "../common/arm_linux.h"\r
+#include "../linux/fbdev.h"\r
 #include "../common/emu.h"\r
 \r
-static int fbdev = -1;\r
-\r
-#define SCREEN_MAP_SIZE (800*480*2)\r
-static void *screen = MAP_FAILED;\r
-\r
 void plat_early_init(void)\r
 {\r
 }\r
 \r
 void plat_init(void)\r
 {\r
-       printf("entering init()\n"); fflush(stdout);\r
+       int ret, w, h;\r
 \r
-       fbdev = open("/dev/fb0", O_RDWR);\r
-       if (fbdev == -1)\r
-       {\r
-               perror("open(\"/dev/fb0\")");\r
+       ret = vout_fbdev_init(&w, &h);\r
+       if (ret != 0) {\r
+               fprintf(stderr, "couldn't init framebuffer\n");\r
                exit(1);\r
        }\r
 \r
-       screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);\r
-       if (screen == MAP_FAILED)\r
-       {\r
-               perror("mmap(fbptr)");\r
+       if (w != g_screen_width || h != g_screen_height) {\r
+               fprintf(stderr, "%dx%d not supported\n", w, h);\r
+               vout_fbdev_finish();\r
                exit(1);\r
        }\r
-       printf("fbptr %p\n", screen);\r
-       g_screen_ptr = screen;\r
 \r
        // snd\r
        sndout_oss_init();\r
-\r
-       printf("exitting init()\n"); fflush(stdout);\r
 }\r
 \r
 void plat_finish(void)\r
 {\r
-       if (screen != MAP_FAILED)\r
-               munmap(screen, SCREEN_MAP_SIZE);\r
-       if (fbdev >= 0)\r
-               close(fbdev);\r
-\r
        sndout_oss_exit();\r
+       vout_fbdev_finish();\r
 \r
        printf("all done");\r
 }\r