add support for 24bpp mode
authornotaz <notasas@gmail.com>
Wed, 8 Dec 2010 00:10:06 +0000 (02:10 +0200)
committernotaz <notasas@gmail.com>
Tue, 14 Dec 2010 13:25:04 +0000 (15:25 +0200)
frontend/arm_utils.s
frontend/linux/fbdev.c
frontend/linux/fbdev.h
frontend/plugin_lib.c
plugins/dfxvideo/draw_fb.c

index edaafb8..d74c8b3 100644 (file)
@@ -45,4 +45,25 @@ bgr555_to_rgb565:
 
     bx          lr
 
 
     bx          lr
 
+
+.global bgr888_to_rgb888
+bgr888_to_rgb888:
+    @ r2 /= 48
+    mov         r2, r2, lsr #4
+    movw        r3, #0x5556
+    movt        r3, #0x5555
+    umull       r12,r2, r3, r2
+0:
+    vld3.8      {d0-d2}, [r1, :64]!
+    vld3.8      {d3-d5}, [r1, :64]!
+    vswp        d0, d2
+    vswp        d3, d5
+    vst3.8      {d0-d2}, [r0, :64]!
+    vst3.8      {d3-d5}, [r0, :64]!
+    subs        r2, r2, #1
+    bne         0b
+
+    bx          lr
+
+
 @ vim:filetype=armasm
 @ vim:filetype=armasm
index 6ae0c77..fffe979 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "fbdev.h"
 
 
 #include "fbdev.h"
 
-#define FBDEV_MAX_BUFFERS 3
-
 struct vout_fbdev {
        int     fd;
        void    *mem;
 struct vout_fbdev {
        int     fd;
        void    *mem;
@@ -60,8 +58,8 @@ void vout_fbdev_wait_vsync(struct vout_fbdev *fbdev)
        ioctl(fbdev->fd, FBIO_WAITFORVSYNC, &arg);
 }
 
        ioctl(fbdev->fd, FBIO_WAITFORVSYNC, &arg);
 }
 
-int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
-                     int left_border, int right_border, int top_border, int bottom_border, int no_dblbuf)
+int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp,
+                     int left_border, int right_border, int top_border, int bottom_border, int buffer_cnt)
 {
        int w_total = left_border + w + right_border;
        int h_total = top_border + h + bottom_border;
 {
        int w_total = left_border + w + right_border;
        int h_total = top_border + h + bottom_border;
@@ -71,7 +69,7 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
        // unblank to be sure the mode is really accepted
        ioctl(fbdev->fd, FBIOBLANK, FB_BLANK_UNBLANK);
 
        // unblank to be sure the mode is really accepted
        ioctl(fbdev->fd, FBIOBLANK, FB_BLANK_UNBLANK);
 
-       if (fbdev->fbvar_new.bits_per_pixel != 16 ||
+       if (fbdev->fbvar_new.bits_per_pixel != bpp ||
                        w != fbdev->fbvar_new.xres ||
                        h != fbdev->fbvar_new.yres ||
                        w_total != fbdev->fbvar_new.xres_virtual ||
                        w != fbdev->fbvar_new.xres ||
                        h != fbdev->fbvar_new.yres ||
                        w_total != fbdev->fbvar_new.xres_virtual ||
@@ -82,8 +80,8 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
                fbdev->fbvar_new.xres_virtual = w_total;
                fbdev->fbvar_new.yres_virtual = h_total;
                fbdev->fbvar_new.xoffset = left_border;
                fbdev->fbvar_new.xres_virtual = w_total;
                fbdev->fbvar_new.yres_virtual = h_total;
                fbdev->fbvar_new.xoffset = left_border;
-               fbdev->fbvar_new.bits_per_pixel = 16;
-               printf(" switching to %dx%d@16\n", w, h);
+               fbdev->fbvar_new.bits_per_pixel = bpp;
+               printf(" switching to %dx%d@%d\n", w, h, bpp);
                ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new);
                if (ret == -1) {
                        perror("FBIOPUT_VSCREENINFO ioctl");
                ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new);
                if (ret == -1) {
                        perror("FBIOPUT_VSCREENINFO ioctl");
@@ -91,9 +89,7 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
                }
        }
 
                }
        }
 
-       fbdev->buffer_count = FBDEV_MAX_BUFFERS; // be optimistic
-       if (no_dblbuf)
-               fbdev->buffer_count = 1;
+       fbdev->buffer_count = buffer_cnt;
 
        if (fbdev->fbvar_new.yres_virtual < h_total * fbdev->buffer_count) {
                fbdev->fbvar_new.yres_virtual = h_total * fbdev->buffer_count;
 
        if (fbdev->fbvar_new.yres_virtual < h_total * fbdev->buffer_count) {
                fbdev->fbvar_new.yres_virtual = h_total * fbdev->buffer_count;
@@ -105,7 +101,7 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
                }
        }
 
                }
        }
 
-       fbdev->fb_size = w_total * h_total * 2;
+       fbdev->fb_size = w_total * h_total * bpp / 8;
        fbdev->top_border = top_border;
        fbdev->bottom_border = bottom_border;
 
        fbdev->top_border = top_border;
        fbdev->bottom_border = bottom_border;
 
@@ -157,7 +153,7 @@ int vout_fbdev_get_fd(struct vout_fbdev *fbdev)
        return fbdev->fd;
 }
 
        return fbdev->fd;
 }
 
-struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int no_dblbuf)
+struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int bpp, int buffer_cnt)
 {
        struct vout_fbdev *fbdev;
        int req_w, req_h;
 {
        struct vout_fbdev *fbdev;
        int req_w, req_h;
@@ -189,7 +185,7 @@ struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int n
        if (*h != 0)
                req_h = *h;
 
        if (*h != 0)
                req_h = *h;
 
-       ret = vout_fbdev_resize(fbdev, req_w, req_h, 0, 0, 0, 0, no_dblbuf);
+       ret = vout_fbdev_resize(fbdev, req_w, req_h, bpp, 0, 0, 0, 0, buffer_cnt);
        if (ret != 0)
                goto fail;
 
        if (ret != 0)
                goto fail;
 
index fa163aa..ddbfdab 100644 (file)
@@ -1,11 +1,11 @@
 struct vout_fbdev;
 
 struct vout_fbdev;
 
-struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int no_dblbuf);
+struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int bpp, int buffer_count);
 void *vout_fbdev_flip(struct vout_fbdev *fbdev);
 void  vout_fbdev_wait_vsync(struct vout_fbdev *fbdev);
 void *vout_fbdev_flip(struct vout_fbdev *fbdev);
 void  vout_fbdev_wait_vsync(struct vout_fbdev *fbdev);
-int   vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h,
+int   vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp,
                        int left_border, int right_border, int top_border, int bottom_border,
                        int left_border, int right_border, int top_border, int bottom_border,
-                       int no_dblbuf);
+                       int buffer_count);
 void  vout_fbdev_clear(struct vout_fbdev *fbdev);
 void  vout_fbdev_clear_lines(struct vout_fbdev *fbdev, int y, int count);
 int   vout_fbdev_get_fd(struct vout_fbdev *fbdev);
 void  vout_fbdev_clear(struct vout_fbdev *fbdev);
 void  vout_fbdev_clear_lines(struct vout_fbdev *fbdev, int y, int count);
 int   vout_fbdev_get_fd(struct vout_fbdev *fbdev);
index 5fd80cd..92c2b53 100644 (file)
@@ -24,7 +24,7 @@ int pl_fbdev_init(void)
 
   w = 640;
   h = 512; // ??
 
   w = 640;
   h = 512; // ??
-  fbdev = vout_fbdev_init(fbdev_name, &w, &h, 0);
+  fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, 3);
   if (fbdev == NULL)
     return -1;
 
   if (fbdev == NULL)
     return -1;
 
@@ -36,7 +36,7 @@ int pl_fbdev_init(void)
 int pl_fbdev_set_mode(int w, int h, int bpp)
 {
   printf("set mode %dx%d@%d\n", w, h, bpp);
 int pl_fbdev_set_mode(int w, int h, int bpp)
 {
   printf("set mode %dx%d@%d\n", w, h, bpp);
-  return vout_fbdev_resize(fbdev, w, h, 0, 0, 0, 0, 0);
+  return vout_fbdev_resize(fbdev, w, h, bpp, 0, 0, 0, 0, 3);
 }
 
 void *pl_fbdev_flip(void)
 }
 
 void *pl_fbdev_flip(void)
index e251071..b48b487 100644 (file)
@@ -38,16 +38,19 @@ char *         pCaptionText;
 
 #ifndef __arm__
 #define bgr555_to_rgb565 memcpy
 
 #ifndef __arm__
 #define bgr555_to_rgb565 memcpy
+#define bgr888_to_rgb888 memcpy
 #endif
 
 static void blit(void)
 {
  extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
 #endif
 
 static void blit(void)
 {
  extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
+ extern void bgr888_to_rgb888(void *dst, void *src, int bytes);
  int x = PSXDisplay.DisplayPosition.x;
  int y = PSXDisplay.DisplayPosition.y;
  int w = PreviousPSXDisplay.Range.x1;
  int h = PreviousPSXDisplay.DisplayMode.y;
  int x = PSXDisplay.DisplayPosition.x;
  int y = PSXDisplay.DisplayPosition.y;
  int w = PreviousPSXDisplay.Range.x1;
  int h = PreviousPSXDisplay.DisplayMode.y;
- int pitch = PreviousPSXDisplay.DisplayMode.x * 2;
+ int pitch = PreviousPSXDisplay.DisplayMode.x;
+ unsigned short *srcs = psxVuw + y * 1024 + x;
  unsigned char *dest = pl_fbdev_buf;
 
  if (w <= 0)
  unsigned char *dest = pl_fbdev_buf;
 
  if (w <= 0)
@@ -55,13 +58,22 @@ static void blit(void)
 
  // TODO: clear border if centering
 
 
  // TODO: clear border if centering
 
+ pitch *= PSXDisplay.RGB24 ? 3 : 2;
+
  // account for centering
  h -= PreviousPSXDisplay.Range.y0;
  dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
  dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
 
  // account for centering
  h -= PreviousPSXDisplay.Range.y0;
  dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
  dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
 
+ if (PSXDisplay.RGB24)
+ {
+   for (; h-- > 0; dest += pitch, srcs += 1024)
+   {
+     bgr888_to_rgb888(dest, srcs, w * 3);
+   }
+ }
+ else
  {
  {
-   unsigned short *srcs = psxVuw + y * 1024 + x;
    for (; h-- > 0; dest += pitch, srcs += 1024)
    {
      bgr555_to_rgb565(dest, srcs, w * 2);
    for (; h-- > 0; dest += pitch, srcs += 1024)
    {
      bgr555_to_rgb565(dest, srcs, w * 2);