update build, use common fb code
authornotaz <notaz@pixelinis>
Tue, 13 Jul 2010 12:43:12 +0000 (15:43 +0300)
committernotaz <notaz@pixelinis>
Wed, 28 Jul 2010 13:01:41 +0000 (16:01 +0300)
loader/Makefile
loader/emu.c
loader/header.h
loader/host_fb.c [deleted file]

index 225012f..49cf11f 100644 (file)
@@ -20,11 +20,14 @@ ASFLAGS += -mfloat-abi=soft
 OBJ += sys_cacheflush.o
 endif
 
+vpath %.c = ../common/
+
 OBJ += loader.o loader_$(ARCH).o patches.o emu.o host_fb.o host_pnd.o
 
-loader: $(OBJ)
+ginge_sloader: LDFLAGS += -Wl,-T script_$(ARCH).lds
 
-loader: LDFLAGS += -Wl,-T script_$(ARCH).lds
+ginge_sloader: $(OBJ)
+       $(CC) -o $@ $^ $(LDFLAGS)
 
 clean:
        $(RM) loader $(OBJ)
index b425308..a180d61 100644 (file)
@@ -496,11 +496,12 @@ void emu_init(void *map_bottom)
   init_linkpage();
 
   // host stuff
-  host_screen = host_video_init(&host_stride);
-  if (host_screen == NULL) {
+  ret = host_video_init(&host_stride, 0);
+  if (ret != 0) {
     printf("can't alloc screen\n");
     exit(1);
   }
+  host_screen = host_video_flip();
 }
 
 int emu_read_gpiodev(void *buf, int count)
index 8e245c8..3791bfc 100644 (file)
@@ -1,3 +1,4 @@
+#include "../common/host_fb.h"
 
 void do_entry(unsigned long entry, void *stack_frame, int stack_frame_cnt, void *exitf);
 
@@ -7,8 +8,6 @@ void  emu_init(void *map_bottom);
 void *emu_mmap_dev(unsigned int length, int prot, int flags, unsigned int offset);
 int   emu_read_gpiodev(void *buf, int count);
 
-void *host_video_init(int *stride);
-void *host_video_flip(void);
 int   host_read_btns(void);
 
 enum  { GP2X_UP = 0,      GP2X_LEFT = 2,      GP2X_DOWN = 4,  GP2X_RIGHT = 6,
diff --git a/loader/host_fb.c b/loader/host_fb.c
deleted file mode 100644 (file)
index 8529f36..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/* copy-paste from PD */
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <linux/fb.h>
-#include <linux/matroxfb.h>
-
-#define FBDEV_MAX_BUFFERS 3
-
-static int fbdev = -1;
-static void *fbdev_mem = MAP_FAILED;
-static int fbdev_mem_size;
-static struct fb_var_screeninfo fbvar_old;
-static struct fb_var_screeninfo fbvar_new;
-static int fbdev_buffer_write;
-
-static void *fbdev_buffers[FBDEV_MAX_BUFFERS];
-static int fbdev_buffer_count;
-static void *g_screen_ptr;
-
-void plat_video_flip(void)
-{
-       int draw_buf;
-
-       if (fbdev_buffer_count < 2)
-               return;
-
-       draw_buf = fbdev_buffer_write;
-       fbdev_buffer_write++;
-       if (fbdev_buffer_write >= fbdev_buffer_count)
-               fbdev_buffer_write = 0;
-
-       fbvar_new.yoffset = fbvar_old.yres * draw_buf;
-       g_screen_ptr = fbdev_buffers[fbdev_buffer_write];
-
-       ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar_new);
-}
-
-void plat_video_wait_vsync(void)
-{
-       int arg = 0;
-       ioctl(fbdev, FBIO_WAITFORVSYNC, &arg);
-}
-
-int vout_fbdev_init(int *w, int *h)
-{
-       static const char *fbdev_name = "/dev/fb0";
-       int i, ret;
-
-       fbdev = open(fbdev_name, O_RDWR);
-       if (fbdev == -1) {
-               fprintf(stderr, "%s: ", fbdev_name);
-               perror("open");
-               return -1;
-       }
-
-       ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar_old);
-       if (ret == -1) {
-               perror("FBIOGET_VSCREENINFO ioctl");
-               goto fail;
-       }
-
-       fbvar_new = fbvar_old;
-       printf("%s: %ix%i@%d\n", fbdev_name, fbvar_old.xres, fbvar_old.yres, fbvar_old.bits_per_pixel);
-       *w = fbvar_old.xres;
-       *h = fbvar_old.yres;
-       fbdev_buffer_count = FBDEV_MAX_BUFFERS; // be optimistic
-
-       if (fbvar_new.bits_per_pixel != 16) {
-               printf(" switching to 16bpp\n");
-               fbvar_new.bits_per_pixel = 16;
-               ret = ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_new);
-               if (ret == -1) {
-                       perror("FBIOPUT_VSCREENINFO ioctl");
-                       goto fail;
-               }
-       }
-
-       if (fbvar_new.yres_virtual < fbvar_old.yres * fbdev_buffer_count) {
-               fbvar_new.yres_virtual = fbvar_old.yres * fbdev_buffer_count;
-               ret = ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_new);
-               if (ret == -1) {
-                       fbdev_buffer_count = 1;
-                       fprintf(stderr, "Warning: failed to increase virtual resolution, "
-                                       "doublebuffering disabled\n");
-               }
-       }
-
-       fbdev_mem_size = *w * *h * 2 * fbdev_buffer_count;
-       fbdev_mem = mmap(0, fbdev_mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
-       if (fbdev_mem == MAP_FAILED && fbdev_buffer_count > 1) {
-               fbdev_mem_size = *w * *h * 2;
-               fbdev_buffer_count = 1;
-               fprintf(stderr, "Warning: can't map %d bytes, doublebuffering disabled\n", fbdev_mem_size);
-               fbdev_mem = mmap(0, fbdev_mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
-       }
-       if (fbdev_mem == MAP_FAILED) {
-               perror("mmap framebuffer");
-               goto fail;
-       }
-       memset(fbdev_mem, 0, fbdev_mem_size);
-       for (i = 0; i < fbdev_buffer_count; i++)
-               fbdev_buffers[i] = (char *)fbdev_mem + i * *w * *h * 2;
-       g_screen_ptr = fbdev_buffers[0];
-
-       // some checks
-       ret = 0;
-       ret = ioctl(fbdev, FBIO_WAITFORVSYNC, &ret);
-       if (ret != 0)
-               fprintf(stderr, "Warning: vsync doesn't seem to be supported\n");
-
-       if (fbdev_buffer_count > 1) {
-               fbdev_buffer_write = 0;
-               fbvar_new.yoffset = fbvar_old.yres * (fbdev_buffer_count - 1);
-               ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar_new);
-               if (ret != 0) {
-                       fbdev_buffer_count = 1;
-                       fprintf(stderr, "Warning: can't pan display, doublebuffering disabled\n");
-               }
-       }
-
-       printf("fbdev initialized.\n");
-       return 0;
-
-fail:
-       close(fbdev);
-       return -1;
-}
-
-void vout_fbdev_finish(void)
-{
-       ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_old);
-       if (fbdev_mem != MAP_FAILED)
-               munmap(fbdev_mem, fbdev_mem_size);
-       if (fbdev >= 0)
-               close(fbdev);
-       fbdev_mem = NULL;
-       fbdev = -1;
-}
-
-#include "header.h"
-
-void *host_video_init(int *stride)
-{
-       int ret, w, h;
-       
-       ret = vout_fbdev_init(&w, &h);
-       if (ret != 0)
-               return NULL;
-
-       *stride = w * 2;
-       return g_screen_ptr;
-}
-
-void *host_video_flip(void)
-{
-       plat_video_flip();
-       return g_screen_ptr;
-}