From 9bc92cbd0be7b1973960e88808feaca26a00aecd Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Wed, 31 Aug 2005 14:19:02 +0000 Subject: [PATCH] - fix when not enough framebuffer memory available --- lib/gdi/fb.cpp | 20 ++++++++++++++++---- lib/gdi/fb.h | 4 ++++ lib/gdi/gfbdc.cpp | 37 ++++++++++++++++++++++--------------- lib/gdi/gfbdc.h | 3 +++ main/enigma.cpp | 10 +++++++++- 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/lib/gdi/fb.cpp b/lib/gdi/fb.cpp index 4a801bfe..c8fd94be 100644 --- a/lib/gdi/fb.cpp +++ b/lib/gdi/fb.cpp @@ -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", diff --git a/lib/gdi/fb.h b/lib/gdi/fb.h index f29c8595..332819fd 100644 --- a/lib/gdi/fb.h +++ b/lib/gdi/fb.h @@ -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; } diff --git a/lib/gdi/gfbdc.cpp b/lib/gdi/gfbdc.cpp index a1f4c981..ee2227cf 100644 --- a/lib/gdi/gfbdc.cpp +++ b/lib/gdi/gfbdc.cpp @@ -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: diff --git a/lib/gdi/gfbdc.h b/lib/gdi/gfbdc.h index b8ba4c7f..16260fb2 100644 --- a/lib/gdi/gfbdc.h +++ b/lib/gdi/gfbdc.h @@ -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(); diff --git a/main/enigma.cpp b/main/enigma.cpp index 16bbcbce..f81a3c28 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -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 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; -- 2.30.2