- fix when not enough framebuffer memory available
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 31 Aug 2005 14:19:02 +0000 (14:19 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 31 Aug 2005 14:19:02 +0000 (14:19 +0000)
lib/gdi/fb.cpp
lib/gdi/fb.h
lib/gdi/gfbdc.cpp
lib/gdi/gfbdc.h
main/enigma.cpp

index 4a801bfedcaaf539e9fadd341389c5d16e842e88..c8fd94be286567f4946825d69a5ed915bb20a278 100644 (file)
@@ -94,12 +94,24 @@ int fbClass::SetMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp)
        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",
index f29c859573e0a9c02a786b52cae1740777ddc4ee..332819fd1238451bb9e6dfb743457474fc74a34c 100644 (file)
@@ -15,11 +15,15 @@ class fbClass
        static fbClass *instance;
        int locked;
        
+       int m_number_of_pages;
 public:
        unsigned char *lfb;
        int showConsole(int state);
        int SetMode(unsigned int xRes, unsigned int yRes, unsigned int bpp);
        int Available() { return available; }
+       
+       int getNumPages() { return m_number_of_pages; }
+       
        int setOffset(int off);
        int waitVSync();
        unsigned int Stride() { return stride; }
index a1f4c981adff3309b401a62ed868f6b95ff4881d..ee2227cfabcbef1b4b80ed3d460ca73f7cd7d91a 100644 (file)
@@ -34,20 +34,24 @@ gFBDC::gFBDC()
        
        surface.data_phys = 50*1024*1024; // FIXME
        
-       surface_back.type = 0;
-       surface_back.x = 720;
-       surface_back.y = 576;
-       surface_back.bpp = 32;
-       surface_back.bypp = 4;
-       surface_back.stride = fb->Stride();
-       surface_back.offset = surface.y;
-
        int fb_size = surface.stride * surface.y;
 
-       surface_back.data = fb->lfb + fb_size;
-       surface_back.data_phys = surface.data_phys + fb_size;
+       if (fb->getNumPages() > 1)
+       {
+               m_enable_double_buffering = 1;
+               surface_back.type = 0;
+               surface_back.x = 720;
+               surface_back.y = 576;
+               surface_back.bpp = 32;
+               surface_back.bypp = 4;
+               surface_back.stride = fb->Stride();
+               surface_back.offset = surface.y;
+               surface_back.data = fb->lfb + fb_size;
+               surface_back.data_phys = surface.data_phys + fb_size;
        
-       fb_size *= 2;
+               fb_size *= 2;
+       } else
+               m_enable_double_buffering = 0;
        
        eDebug("%dkB available for acceleration surfaces.", (fb->Available() - fb_size)/1024);
        
@@ -139,11 +143,14 @@ void gFBDC::exec(gOpcode *o)
        }
        case gOpcode::flip:
        {
-               gSurface s(surface);
-               surface = surface_back;
-               surface_back = s;
+               if (m_enable_double_buffering)
+               {
+                       gSurface s(surface);
+                       surface = surface_back;
+                       surface_back = s;
                
-               fb->setOffset(surface_back.offset);
+                       fb->setOffset(surface_back.offset);
+               }
                break;
        }
        case gOpcode::waitVSync:
index b8ba4c7f35a6f41c38e2964a92e0ebb3bb6c2869..16260fb202c5349fb5bbe835370caa560f22ef88 100644 (file)
@@ -15,6 +15,7 @@ class gFBDC: public gDC
        void calcRamp();
        void setPalette();
        gSurface surface, surface_back;
+       int m_enable_double_buffering;
 public:
        void reloadSettings();
        void setAlpha(int alpha);
@@ -25,6 +26,8 @@ public:
        int getBrightness() { return brightness; }
        int getGamma() { return gamma; }
        
+       int haveDoubleBuffering() { return m_enable_double_buffering; }
+       
        void saveSettings();
        
        gFBDC();
index 16bbcbce681aaf02959e093cc390f95512aa13ac..f81a3c28f7ddf0a0f4ee870464599b8daa6c249b 100644 (file)
@@ -148,6 +148,8 @@ int main(int argc, char **argv)
 
        ePython python;
        eMain main;
+       
+       int double_buffer = 0;
 
 #if 1
 #ifdef SDLDC
@@ -156,13 +158,19 @@ int main(int argc, char **argv)
 #else
        ePtr<gFBDC> my_dc;
        gFBDC::getInstance(my_dc);
+       
+       double_buffer = my_dc->haveDoubleBuffering();
 #endif
 
        fontRenderClass::getInstance()->AddFont(FONTDIR "/arial.ttf", "Arial", 100);
 
        eWidgetDesktop dsk(eSize(720, 576));
        
-       dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
+       if (double_buffer)
+       {
+               eDebug(" - double buffering found, enable buffered graphics mode.");
+               dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
+       }
        
        wdsk = &dsk;