remove test cruft, add possibility for a seperator
[enigma2.git] / lib / gdi / fb.cpp
index 96ca4313169aa88cfd6799be0c2f0eb1418af6ad..727042dd81ada0693220fab894537a9df357208e 100644 (file)
@@ -7,9 +7,13 @@
 #include <memory.h>
 #include <linux/kd.h>
 
-#include <lib/base/econfig.h>
 #include <lib/gdi/fb.h>
 
+#ifndef FBIO_WAITFORVSYNC
+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#endif
+
+
 fbClass *fbClass::instance;
 
 fbClass *fbClass::getInstance()
@@ -29,9 +33,6 @@ fbClass::fbClass(const char *fb)
        cmap.blue=blue;
        cmap.transp=trans;
 
-       int state=0;
-       eConfig::getInstance()->getKey("/ezap/osd/showConsoleOnFB", state);
-
        fd=open(fb, O_RDWR);
        if (fd<0)
        {
@@ -62,7 +63,7 @@ fbClass::fbClass(const char *fb)
                goto nolfb;
        }
 
-       showConsole(state);
+       showConsole(0);
        return;
 nolfb:
        lfb=0;
@@ -87,15 +88,29 @@ int fbClass::showConsole(int state)
 int fbClass::SetMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp)
 {
        screeninfo.xres_virtual=screeninfo.xres=nxRes;
-       screeninfo.yres_virtual=screeninfo.yres=nyRes;
+       screeninfo.yres_virtual=(screeninfo.yres=nyRes)*2;
+       screeninfo.height=0;
+       screeninfo.width=0;
        screeninfo.xoffset=screeninfo.yoffset=0;
        screeninfo.bits_per_pixel=nbpp;
+       
        if (ioctl(fd, FBIOPUT_VSCREENINFO, &screeninfo)<0)
        {
-               perror("FBIOPUT_VSCREENINFO");
-               printf("fb failed\n");
-               return -1;
-       }
+               // try single buffering
+               screeninfo.yres_virtual=screeninfo.yres=nyRes;
+               
+               if (ioctl(fd, FBIOPUT_VSCREENINFO, &screeninfo)<0)
+               {
+                       perror("FBIOPUT_VSCREENINFO");
+                       printf("fb failed\n");
+                       return -1;
+               }
+               eDebug(" - double buffering not available.");
+       } else
+               eDebug(" - double buffering available!");
+       
+       m_number_of_pages = screeninfo.yres_virtual / nyRes;
+       
        if ((screeninfo.xres!=nxRes) && (screeninfo.yres!=nyRes) && (screeninfo.bits_per_pixel!=nbpp))
        {
                eDebug("SetMode failed: wanted: %dx%dx%d, got %dx%dx%d",
@@ -116,12 +131,26 @@ int fbClass::SetMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp)
        return 0;
 }
 
+int fbClass::setOffset(int off)
+{
+       screeninfo.xoffset = 0;
+       screeninfo.yoffset = off;
+       return ioctl(fd, FBIOPAN_DISPLAY, &screeninfo);
+}
+
+int fbClass::waitVSync()
+{
+       int c = 0;
+       return ioctl(fd, FBIO_WAITFORVSYNC, &c);
+}
+
 fbClass::~fbClass()
 {
        if (available)
                ioctl(fd, FBIOPUT_VSCREENINFO, &oldscreen);
        if (lfb)
                munmap(lfb, available);
+       showConsole(1);
 }
 
 int fbClass::PutCMAP()
@@ -129,45 +158,6 @@ int fbClass::PutCMAP()
        return ioctl(fd, FBIOPUTCMAP, &cmap);
 }
 
-void fbClass::Box(int x, int y, int width, int height, int color, int backcolor)
-{
-       if (width<=2)
-               return;
-       int offset=y*stride+x/2;
-       int first=0xF0|((color&0xF0)>>4);
-       int last= 0xF0|((backcolor&0xF0)>>4);
-       color=(color&0xF)*0x11;
-       int halfwidth=width/2;
-       for (int ay=y; ay<(y+height); ay++)
-       {
-               lfb[offset]=first;
-               memset(lfb+offset+1, color, halfwidth-2);
-               lfb[offset+halfwidth-1]=last;
-               offset+=stride;
-       }
-}
-
-void fbClass::NBox(int x, int y, int width, int height, int color)
-{
-       int offset=y*stride+x/2;
-       int halfwidth=width/2;
-       for (int ay=y; ay<(y+height); ay++)
-       {
-               memset(lfb+offset, color, halfwidth);
-               offset+=stride;
-       }
-}
-
-void fbClass::VLine(int x, int y, int sy, int color)
-{
-       int offset=y*stride+x/2;
-       while (sy--)
-       {
-               lfb[offset]=color;
-               offset+=stride;
-       }
-}
-
 int fbClass::lock()
 {
        if (locked)