diff --git a/acinclude.m4 b/acinclude.m4 index 6a32a428a..20a6c9373 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -148,12 +148,6 @@ TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts, TUXBOX_APPS_DIRECTORY_ONE(fontdir_var,FONTDIR_VAR,localstatedir,/var,/tuxbox/fonts, [--with-fontdir_var=PATH ],[where to find the fonts in /var]) -TUXBOX_APPS_DIRECTORY_ONE(webtvdir,WEBTVDIR,datadir,/share,/tuxbox/neutrino/webtv, - [--with-webtvdir=PATH ],[where to find the webtv content]) - -TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/webtv, - [--with-webtvdir_var=PATH ],[where to find the webtv content /var]) - TUXBOX_APPS_DIRECTORY_ONE(gamesdir,GAMESDIR,localstatedir,/var,/tuxbox/games, [--with-gamesdir=PATH ],[where games data is stored]) @@ -166,6 +160,12 @@ TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins, TUXBOX_APPS_DIRECTORY_ONE(plugindir_var,PLUGINDIR_VAR,localstatedir,/var,/tuxbox/plugins, [--with-plugindir_var=PATH ],[where to find the plugins in /var]) +TUXBOX_APPS_DIRECTORY_ONE(webtvdir,WEBTVDIR,datadir,/share,/tuxbox/neutrino/webtv, + [--with-webtvdir=PATH ],[where to find the webtv content]) + +TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/webtv, + [--with-webtvdir_var=PATH ],[where to find the webtv content in /var]) + TUXBOX_APPS_DIRECTORY_ONE(plugindir_mnt,PLUGINDIR_MNT,mntdir,/mnt,/plugins, [--with-plugindir_mnt=PATH ],[where to find the the extern plugins]) diff --git a/configure.ac b/configure.ac index c108b1cd1..453675aa1 100644 --- a/configure.ac +++ b/configure.ac @@ -98,7 +98,6 @@ AM_CONDITIONAL(USE_TREMOR, test "$TREMOR" = "yes") # TUXBOX_APPS_LIB_PKGCONFIG(OPENSSL,openssl) TUXBOX_APPS_LIB_PKGCONFIG(CURL,libcurl) -PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.5.0], echo "freetype2 >= 2.5.0 found") # fallback to curl-config (which is ugly for cross-compilation) if test -z "$CURL_LIBS" -a -z "$CURL_CFLAGS"; then @@ -107,7 +106,7 @@ fi # fallback to freetype-config (which is ugly for cross-compilation) if test -z "$FREETYPE_LIBS" -a -z "$FREETYPE_CFLAGS"; then TUXBOX_APPS_LIB_CONFIG(FREETYPE,freetype-config) - CPPFLAGS+="$FREETYPE_CFLAGS" + CPPFLAGS+=" $FREETYPE_CFLAGS" AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) AC_TRY_CPP([ #include @@ -153,10 +152,6 @@ AC_ARG_ENABLE(keyboard-no-rc, [ --enable-keyboard-no-rc enable keyboard control, disable rc control], [AC_DEFINE(KEYBOARD_INSTEAD_OF_REMOTE_CONTROL,1,[enable keyboard control, disable rc control])]) -AC_ARG_ENABLE(restore-prev-mode, - [ --enable-restore-prev-mode enable return from graphics mode], - [AC_DEFINE(RETURN_FROM_GRAPHICS_MODE,1,[enable return from graphics mode])]) - AC_ARG_ENABLE(mdev, [ --enable-mdev disable broken neutrino mount hack, use with mdev], [AC_DEFINE(ASSUME_MDEV,1,[disable broken neutrino mount hack, use with mdev])]) @@ -288,6 +283,9 @@ HWLIB_CFLAGS='-I$(top_srcdir)/lib/libcoolstream2 -I$(top_srcdir)/src/zapit/inclu fi fi +# hack, so that framebuffer.h does not need to be included everywhere... +AC_DEFINE(fb_pixel_t, uint32_t, [hack, so that framebuffer.h does not need to be included everywhere...]) + # hack to define a short filename also for out-of-tree build if test `dirname $0` = `pwd` || test "$0" = ./configure; then HWLIB_CFLAGS="$HWLIB_CFLAGS "'-D__file__=__FILE__' diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index cf228beda..1be17c512 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -26,11 +26,11 @@ libneutrino_driver_a_SOURCES = \ audioplay.cpp \ colorgradient.cpp \ fade.cpp \ + fb_accel.cpp \ fb_window.cpp \ - fbaccel.cpp \ + fb_generic.cpp \ file.cpp \ fontrenderer.cpp \ - framebuffer_ng.cpp \ genpsi.cpp \ moviecut.cpp \ neutrinofonts.cpp \ @@ -46,8 +46,15 @@ libneutrino_driver_a_SOURCES = \ volume.cpp if BOXTYPE_COOL +if BOXMODEL_APOLLO libneutrino_driver_a_SOURCES += \ + fb_accel_cs_hd2.cpp \ vfd.cpp +else +libneutrino_driver_a_SOURCES += \ + fb_accel_cs_hd1.cpp \ + vfd.cpp +endif endif if BOXTYPE_TRIPLE @@ -58,6 +65,7 @@ endif if BOXTYPE_SPARK libneutrino_driver_a_SOURCES += \ + fb_accel_sti.cpp \ simple_display.cpp endif if BOXTYPE_AZBOX @@ -66,6 +74,7 @@ libneutrino_driver_a_SOURCES += \ endif if BOXTYPE_GENERIC libneutrino_driver_a_SOURCES += \ + fb_accel_glfb.cpp \ simple_display.cpp endif if USE_STB_HAL diff --git a/src/driver/colorgradient.h b/src/driver/colorgradient.h index 6569f64b4..b4e80b029 100644 --- a/src/driver/colorgradient.h +++ b/src/driver/colorgradient.h @@ -23,8 +23,9 @@ #ifndef __CCOLORGRADIENT__ #define __CCOLORGRADIENT__ -#include +#include +class CFrameBuffer; class CColorGradient { private: diff --git a/src/driver/fade.cpp b/src/driver/fade.cpp index a0c2f45f7..a7bd27acf 100644 --- a/src/driver/fade.cpp +++ b/src/driver/fade.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #if HAVE_COOL_HARDWARE diff --git a/src/driver/fade.h b/src/driver/fade.h index 83c81ef60..e6bc250bb 100644 --- a/src/driver/fade.h +++ b/src/driver/fade.h @@ -22,8 +22,9 @@ #ifndef __fade_f__ #define __fade_f__ -#include +#include +class CFrameBuffer; class COSDFader { private: diff --git a/src/driver/fb_accel.cpp b/src/driver/fb_accel.cpp new file mode 100644 index 000000000..d8391ab34 --- /dev/null +++ b/src/driver/fb_accel.cpp @@ -0,0 +1,97 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The infrastructure for hardware dependent framebuffer acceleration + functions are implemented in this class, hardware specific stuff + is in derived classes. + + (C) 2017 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +CFbAccel::CFbAccel() +{ +}; + +CFbAccel::~CFbAccel() +{ +}; + +void CFbAccel::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +{ + /* draw a filled rectangle (with additional round corners) */ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + + if (!type || !radius) + { + paintRect(x, y, dx, dy, col); + checkFbArea(x, y, dx, dy, false); + return; + } + + setCornerFlags(type); + /* limit the radius */ + radius = limitRadius(dx, dy, radius); + if (radius < 1) /* dx or dy = 0... */ + radius = 1; /* avoid div by zero below */ + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + int height = dy - ((corner_tl || corner_tr)?radius: 0 ) - ((corner_bl || corner_br) ? radius : 0); + paintRect(x, y + line, dx, height, col); + line += height; + continue; + } + if (dx - ofr - ofl < 1) { + //printf("FB-NG::%s:%d x %d y %d dx %d dy %d l %d r %d\n", __func__, __LINE__, x,y,dx,dy, ofl, ofr); + line++; + continue; + } + paintLine(x + ofl, y + line, x + dx - ofr, y + line, col); + line++; + } + checkFbArea(x, y, dx, dy, false); + mark(x, y, x+dx, y+dy); +} + +void CFbAccel::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) +{ + int line = 0; + int swidth = stride / sizeof(fb_pixel_t); + fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); + int pos; + while (line < dy) + { + for (pos = x; pos < x + dx; pos++) + *(fbp + pos) = col; + fbp += swidth; + line++; + } + mark(x, y, x+dx, y+dy); + blit(); +} diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h new file mode 100644 index 000000000..da7af9e9b --- /dev/null +++ b/src/driver/fb_accel.h @@ -0,0 +1,153 @@ +/* + Copyright (C) 2007-2013 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + private functions for the fbaccel class (only used in CFrameBuffer) +*/ + + +#ifndef __fbaccel__ +#define __fbaccel__ +#include +#include +#include +#include +#include +#include "fb_generic.h" + +#if HAVE_SPARK_HARDWARE +#define PARTIAL_BLIT 1 +#endif + +class CFbAccel + : public CFrameBuffer +{ + public: + CFbAccel(); + ~CFbAccel(); + void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type); + virtual void paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col); +}; + +class CFbAccelSTi + : public OpenThreads::Thread, public CFbAccel +{ + private: + void run(void); + void blit(void); + void _blit(void); + bool blit_thread; + bool blit_pending; + OpenThreads::Condition blit_cond; + OpenThreads::Mutex blit_mutex; + fb_pixel_t *backbuffer; +#ifdef PARTIAL_BLIT + struct { + int xs; + int ys; + int xe; + int ye; + } to_blit; + uint32_t last_xres; +#endif + public: + CFbAccelSTi(); + ~CFbAccelSTi(); + void init(const char * const); + int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + void paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp); + void waitForIdle(const char *func = NULL); + void mark(int x, int y, int dx, int dy); + fb_pixel_t * getBackBufferPointer() const; + void setBlendMode(uint8_t); + void setBlendLevel(int); +}; + +class CFbAccelCSHD1 + : public CFbAccel +{ + private: + fb_pixel_t lastcol; + int devmem_fd; /* to access the GXA register we use /dev/mem */ + unsigned int smem_start; /* as aquired from the fbdev, the framebuffers physical start address */ + volatile uint8_t *gxa_base; /* base address for the GXA's register access */ + void setColor(fb_pixel_t col); + void run(void); + fb_pixel_t *backbuffer; + public: + CFbAccelCSHD1(); + ~CFbAccelCSHD1(); + void init(const char * const); + int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + void paintPixel(int x, int y, const fb_pixel_t col); + void paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col); + void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); + inline void paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { paintLine(x, y, x+dx, y, col); }; + inline void paintVLineRel(int x, int y, int dy, const fb_pixel_t col) { paintLine(x, y, x, y+dy, col); }; + void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + void waitForIdle(const char *func = NULL); + fb_pixel_t * getBackBufferPointer() const; + void setBlendMode(uint8_t); + void setBlendLevel(int); + void add_gxa_sync_marker(void); + void setupGXA(void); +}; + +class CFbAccelCSHD2 + : public CFbAccel +{ + private: + fb_pixel_t *backbuffer; + + public: + CFbAccelCSHD2(); +// ~CFbAccelCSHD2(); + int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + void paintHLineRel(int x, int dx, int y, const fb_pixel_t col); + void paintVLineRel(int x, int y, int dy, const fb_pixel_t col); + void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + void setBlendMode(uint8_t); + void setBlendLevel(int); +}; + +class CFbAccelGLFB + : public OpenThreads::Thread, public CFbAccel +{ + private: + void run(void); + void blit(void); + void _blit(void); + bool blit_thread; + bool blit_pending; + OpenThreads::Condition blit_cond; + OpenThreads::Mutex blit_mutex; + fb_pixel_t *backbuffer; + public: + CFbAccelGLFB(); + ~CFbAccelGLFB(); + void init(const char * const); + int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp); + fb_pixel_t * getBackBufferPointer() const; +}; + +#endif diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp new file mode 100644 index 000000000..a85072808 --- /dev/null +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -0,0 +1,378 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent acceleration functions for coolstream GXA chips + are represented in this class. + + (C) 2017 Stefan Seyfried + Derived from old neutrino-hd framebuffer code + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "fb_accel_cs_hdx_inc.h" + +/*******************************************************************************/ +#define GXA_POINT(x, y) (((y) & 0x0FFF) << 16) | ((x) & 0x0FFF) +#define GXA_SRC_BMP_SEL(x) (x << 8) +#define GXA_DST_BMP_SEL(x) (x << 5) +#define GXA_PARAM_COUNT(x) (x << 2) + +#define GXA_CMD_REG 0x001C +#define GXA_FG_COLOR_REG 0x0020 +#define GXA_BG_COLOR_REG 0x0024 +#define GXA_LINE_CONTROL_REG 0x0038 +#define GXA_BMP1_TYPE_REG 0x0048 +#define GXA_BMP1_ADDR_REG 0x004C +#define GXA_BMP2_TYPE_REG 0x0050 +#define GXA_BMP2_ADDR_REG 0x0054 +#define GXA_BMP3_TYPE_REG 0x0058 +#define GXA_BMP3_ADDR_REG 0x005C +#define GXA_BMP4_TYPE_REG 0x0060 +#define GXA_BMP4_ADDR_REG 0x0064 +#define GXA_BMP5_TYPE_REG 0x0068 +#define GXA_BMP5_ADDR_REG 0x006C +#define GXA_BMP6_TYPE_REG 0x0070 +#define GXA_BMP7_TYPE_REG 0x0078 +#define GXA_DEPTH_REG 0x00F4 +#define GXA_CONTENT_ID_REG 0x0144 +#define GXA_BLT_CONTROL_REG 0x0034 + +#define GXA_CMD_BLT 0x00010800 +#define GXA_CMD_NOT_ALPHA 0x00011000 +#define GXA_CMD_NOT_TEXT 0x00018000 +#define GXA_CMD_QMARK 0x00001000 + +#define GXA_BLEND_CFG_REG 0x003C +#define GXA_CFG_REG 0x0030 +#define GXA_CFG2_REG 0x00FC + +#define LOGTAG "[fb_accel_cs_hd1] " +/* +static unsigned int _read_gxa(volatile unsigned char *base_addr, unsigned int offset) +{ + return *(volatile unsigned int *)(base_addr + offset); +} +*/ +static unsigned int _mark = 0; + +static void _write_gxa(volatile unsigned char *base_addr, unsigned int offset, unsigned int value) +{ + while ((*(volatile unsigned int *)(base_addr + GXA_DEPTH_REG)) & 0x40000000) {}; + *(volatile unsigned int *)(base_addr + offset) = value; +} + +/* this adds a tagged marker into the GXA queue. Once this comes out + of the other end of the queue, all commands before it are finished */ +void CFbAccelCSHD1::add_gxa_sync_marker(void) +{ + unsigned int cmd = GXA_CMD_QMARK | GXA_PARAM_COUNT(1); + // TODO: locking? + _mark++; + _mark &= 0x0000001F; /* bit 0x20 crashes the kernel, if set */ + _write_gxa(gxa_base, cmd, _mark); + //fprintf(stderr, "%s: wrote %02x\n", __FUNCTION__, _mark); +} + +/* wait until the current marker comes out of the GXA command queue */ +void CFbAccelCSHD1::waitForIdle(const char *func) +{ + unsigned int cfg, count = 0; + do { + cfg = *(volatile unsigned int *)(gxa_base + GXA_CMD_REG); + cfg >>= 24; /* the token is stored in bits 31...24 */ + if (cfg == _mark) + break; + /* usleep is too coarse, because of CONFIG_HZ=100 in kernel + so use sched_yield to at least give other threads a chance to run */ + sched_yield(); + //fprintf(stderr, "%s: read %02x, expected %02x\n", __FUNCTION__, cfg, _mark); + } while(++count < 8192); /* don't deadlock here if there is an error */ + + if (count > 2048) /* more than 2000 are unlikely, even for large BMP6 blits */ + fprintf(stderr, LOGTAG "waitForIdle: count is big (%d) [%s]!\n", count, func?func:""); +} + +CFbAccelCSHD1::CFbAccelCSHD1() +{ + fb_name = "Coolstream HD1 framebuffer"; +} + +void CFbAccelCSHD1::init(const char * const) +{ +fprintf(stderr, ">FBACCEL::INIT\n"); + CFrameBuffer::init(); + if (lfb == NULL) { + printf(LOGTAG "CFrameBuffer::init() failed.\n"); + return; /* too bad... */ + } + available = fix.smem_len; + printf(LOGTAG "%dk video mem\n", available / 1024); + memset(lfb, 0, available); + lastcol = 0xffffffff; + lbb = lfb; /* the memory area to draw to... */ + + /* Open /dev/mem for HW-register access */ + devmem_fd = open("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC); + if (devmem_fd < 0) { + perror("CFbAccel open /dev/mem"); + goto error; + } + + /* mmap the GXA's base address */ + gxa_base = (volatile unsigned char*)mmap(0, 0x00040000, PROT_READ|PROT_WRITE, MAP_SHARED, devmem_fd, 0xE0600000); + if (gxa_base == (void *)-1) { + perror("CFbAccel mmap /dev/mem"); + goto error; + } + + setupGXA(); + error: + /* TODO: what to do here? does this really happen? */ + ; +}; + +CFbAccelCSHD1::~CFbAccelCSHD1() +{ + if (gxa_base != MAP_FAILED) + munmap((void *)gxa_base, 0x40000); + if (devmem_fd != -1) + close(devmem_fd); + if (lfb) + munmap(lfb, available); + if (fd > -1) + close(fd); +} + +void CFbAccelCSHD1::setColor(fb_pixel_t col) +{ + if (col == lastcol) + return; + _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int)col); /* setup the drawing color */ + lastcol = col; +} + +void CFbAccelCSHD1::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) +{ + OpenThreads::ScopedLock m_lock(mutex); + unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_CMD_NOT_ALPHA | + GXA_SRC_BMP_SEL(6) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2); + + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)col); /* setup the drawing color */ + _write_gxa(gxa_base, GXA_BMP6_TYPE_REG, (3 << 16) | (1 << 27)); /* 3 == 32bpp, 1<<27 == fill */ + _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* destination pos */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy)); /* destination size */ + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)backgroundColor); + + /* the GXA seems to do asynchronous rendering, so we add a sync marker + to which the fontrenderer code can synchronize */ + add_gxa_sync_marker(); +} + +void CFbAccelCSHD1::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + paintLine(x, y, x + 1, y, col); +} + +void CFbAccelCSHD1::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +{ + if (!getActive()) + return; + OpenThreads::ScopedLock m_lock(mutex); + /* draw a single vertical line from point xa/ya to xb/yb */ + unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; + + setColor(col); + _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ + _write_gxa(gxa_base, cmd, GXA_POINT(xb, yb)); /* end point */ + _write_gxa(gxa_base, cmd, GXA_POINT(xa, ya)); /* start point */ +} + +void CFbAccelCSHD1::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +{ + /* draw a filled rectangle (with additional round corners) */ + + if (!getActive()) + return; + + if (dx == 0 || dy == 0) { + dprintf(DEBUG_DEBUG, "[CFbAccelCSHD1] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + return; + } + if (radius < 0) + dprintf(DEBUG_NORMAL, "[CFbAccelCSHD1] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + + checkFbArea(x, y, dx, dy, true); + + if (!fb_no_check) + OpenThreads::ScopedLock m_lock(mutex); + /* solid fill with background color */ + unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(7) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x, y + line)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy - (radius * rect_height_mult))); /* width/height */ + line += dy - (radius * rect_height_mult); + continue; + } + + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0){ + dprintf(DEBUG_INFO, "[CFbAccelCSHD1] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx-ofr-ofl, y+line); + }else{ + dprintf(DEBUG_INFO, "[CFbAccelCSHD1] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x + ofl, y + line)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx-ofl-ofr, 1)); /* width/height */ + line++; + } + } else { + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy)); /* width/height */ + } + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) backgroundColor); //FIXME needed ? + /* the GXA seems to do asynchronous rendering, so we add a sync marker + * to which the fontrenderer code can synchronize + */ + add_gxa_sync_marker(); + checkFbArea(x, y, dx, dy, false); +} + +void CFbAccelCSHD1::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI +{ + int xc, yc; + xc = (width > xRes) ? xRes : width; + yc = (height > yRes) ? yRes : height; + u32 cmd; + void *uKva; + + uKva = cs_phys_addr(fbbuff); + + if (uKva != NULL) { + OpenThreads::ScopedLock m_lock(mutex); + cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(1) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(3); + + _write_gxa(gxa_base, GXA_BMP1_TYPE_REG, (3 << 16) | width); + _write_gxa(gxa_base, GXA_BMP1_ADDR_REG, (unsigned int)uKva); + + _write_gxa(gxa_base, cmd, GXA_POINT(xoff, yoff)); /* destination pos */ + _write_gxa(gxa_base, cmd, GXA_POINT(xc, yc)); /* source width, FIXME real or adjusted xc, yc ? */ + _write_gxa(gxa_base, cmd, GXA_POINT(xp, yp)); /* source pos */ + return; + } + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI +} + +void CFbAccelCSHD1::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +{ + if(width <1 || height <1 || !boxBuf ) + return; + + uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; + uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; + + void* uKva = cs_phys_addr((void*)boxBuf); + if(uKva != NULL) { + OpenThreads::ScopedLock m_lock(mutex); + u32 cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(1) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(3); + _write_gxa(gxa_base, GXA_BMP1_TYPE_REG, (3 << 16) | width); + _write_gxa(gxa_base, GXA_BMP1_ADDR_REG, (unsigned int) uKva); + _write_gxa(gxa_base, cmd, GXA_POINT(xoff, yoff)); + _write_gxa(gxa_base, cmd, GXA_POINT(xc, yc)); + _write_gxa(gxa_base, cmd, GXA_POINT(0, 0)); + add_gxa_sync_marker(); + return; + } + CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); +} + +void CFbAccelCSHD1::setupGXA() +{ + // We (re)store the GXA regs here in case DFB override them and was not + // able to restore them. + _write_gxa(gxa_base, GXA_BMP2_TYPE_REG, (3 << 16) | (unsigned int)screeninfo.xres); + _write_gxa(gxa_base, GXA_BMP2_ADDR_REG, (unsigned int) fix.smem_start); + _write_gxa(gxa_base, GXA_BLEND_CFG_REG, 0x00089064); + // TODO check mono-flip, bit 8 + _write_gxa(gxa_base, GXA_CFG_REG, 0x100 | (1 << 12) | (1 << 29)); + _write_gxa(gxa_base, GXA_CFG2_REG, 0x1FF); + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)backgroundColor); + _write_gxa(gxa_base, GXA_BMP7_TYPE_REG, (3 << 16) | (unsigned int)screeninfo.xres | (1 << 27)); + add_gxa_sync_marker(); +} + +/* wrong name... */ +int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) +{ + fb_fix_screeninfo _fix; + + if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { + perror("FBIOGET_FSCREENINFO"); + return -1; + } + stride = _fix.line_length; + if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) + printf("screen unblanking failed\n"); + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + printf(LOGTAG "%dx%dx%d line length %d. using hd1 graphics accelerator.\n", xRes, yRes, bpp, stride); + int needmem = stride * yRes * 2; + if (available >= needmem) + { + backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + return 0; + } + fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); + backbuffer = lfb; /* will not work well, but avoid crashes */ + return 0; /* dont fail because of this */ +} + +fb_pixel_t * CFbAccelCSHD1::getBackBufferPointer() const +{ + return backbuffer; +} + +void CFbAccelCSHD1::setBlendMode(uint8_t mode) +{ + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +} + +void CFbAccelCSHD1::setBlendLevel(int level) +{ + unsigned char value = 0xFF; + if (level >= 0 && level <= 100) + value = convertSetupAlpha2Alpha(level); + + if (ioctl(fd, FBIO_SETOPACITY, value)) + printf("FBIO_SETOPACITY failed.\n"); +} diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp new file mode 100644 index 000000000..0cf8a31a6 --- /dev/null +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -0,0 +1,230 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent acceleration functions for coolstream hd2 graphic chips + are represented in this class. + + (C) 2017 M. Liebmann + Derived from old neutrino-hd framebuffer code + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "fb_accel_cs_hdx_inc.h" + +#define LOGTAG "[fb_accel_cs_hd2] " + +CFbAccelCSHD2::CFbAccelCSHD2() +{ + fb_name = "Coolstream HD2 framebuffer"; +} + +/* +CFbAccelCSHD2::~CFbAccelCSHD2() +{ +} +*/ + +void CFbAccelCSHD2::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) +{ + if (!getActive()) + return; + + if (dx >= 10) { + fb_fillrect fillrect; + fillrect.dx = x; + fillrect.dy = y; + fillrect.width = dx; + fillrect.height = 1; + fillrect.color = col; + fillrect.rop = ROP_COPY; + ioctl(fd, FBIO_FILL_RECT, &fillrect); + return; + } + CFrameBuffer::paintHLineRelInternal(x, dx, y, col); +} + +void CFbAccelCSHD2::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) +{ + if (!getActive()) + return; + + fb_fillrect fillrect; + fillrect.dx = x; + fillrect.dy = y; + fillrect.width = 1; + fillrect.height = dy; + fillrect.color = col; + fillrect.rop = ROP_COPY; + ioctl(fd, FBIO_FILL_RECT, &fillrect); +} + +void CFbAccelCSHD2::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +{ + if (!getActive()) + return; + + if (dx == 0 || dy == 0) { + dprintf(DEBUG_DEBUG, "[CFbAccelCSHD2] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + return; + } + if (radius < 0) + dprintf(DEBUG_NORMAL, "[CFbAccelCSHD2] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + + checkFbArea(x, y, dx, dy, true); + + fb_fillrect fillrect; + fillrect.color = col; + fillrect.rop = ROP_COPY; + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; + fillrect.dx = x; + fillrect.dy = y + line; + fillrect.width = dx; + fillrect.height = dy - (radius * rect_height_mult); + + ioctl(fd, FBIO_FILL_RECT, &fillrect); + line += dy - (radius * rect_height_mult); + continue; + } + + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0){ + dprintf(DEBUG_INFO, "[CFbAccelCSHD2] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx-ofr-ofl, y+line); + }else{ + dprintf(DEBUG_INFO, "[CFbAccelCSHD2] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + paintHLineRel(x+ofl, dx-ofl-ofr, y+line, col); + line++; + } + } else { + /* FIXME small size faster to do by software */ + if (dx > 10 || dy > 10) { + fillrect.dx = x; + fillrect.dy = y; + fillrect.width = dx; + fillrect.height = dy; + ioctl(fd, FBIO_FILL_RECT, &fillrect); + checkFbArea(x, y, dx, dy, false); + return; + } + int line = 0; + while (line < dy) { + CFrameBuffer::paintHLineRelInternal(x, dx, y+line, col); + line++; + } + } + checkFbArea(x, y, dx, dy, false); +} + +void CFbAccelCSHD2::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI +{ + int xc, yc; + xc = (width > xRes) ? xRes : width; + yc = (height > yRes) ? yRes : height; + + if(!(width%4)) { + fb_image image; + image.dx = xoff; + image.dy = yoff; + image.width = xc; + image.height = yc; + image.cmap.len = 0; + image.depth = 32; + image.data = (const char*)fbbuff; + ioctl(fd, FBIO_IMAGE_BLT, &image); + return; + } + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI +} + +void CFbAccelCSHD2::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +{ + if(width <1 || height <1 || !boxBuf ) + return; + + uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; + uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; + + if (!(width%4)) { + fb_image image; + image.dx = xoff; + image.dy = yoff; + image.width = xc; + image.height = yc; + image.cmap.len = 0; + image.depth = 32; + image.data = (const char*)boxBuf; + ioctl(fd, FBIO_IMAGE_BLT, &image); + return; + } + CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); +} + +int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) +{ + fb_fix_screeninfo _fix; + + if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { + perror("FBIOGET_FSCREENINFO"); + return -1; + } + stride = _fix.line_length; + if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) + printf("screen unblanking failed\n"); + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + printf(LOGTAG "%dx%dx%d line length %d. using hd2 graphics accelerator.\n", xRes, yRes, bpp, stride); + int needmem = stride * yRes * 2; + if (available >= needmem) + { + backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + return 0; + } + fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); + backbuffer = lfb; /* will not work well, but avoid crashes */ + return 0; /* dont fail because of this */ +} + +void CFbAccelCSHD2::setBlendMode(uint8_t mode) +{ + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +} + +void CFbAccelCSHD2::setBlendLevel(int level) +{ + unsigned char value = 0xFF; + if (level >= 0 && level <= 100) + value = convertSetupAlpha2Alpha(level); + + if (ioctl(fd, FBIO_SETOPACITY, value)) + printf("FBIO_SETOPACITY failed.\n"); + if (level == 100) // TODO: sucks. + usleep(20000); +} diff --git a/src/driver/fb_accel_cs_hdx_inc.h b/src/driver/fb_accel_cs_hdx_inc.h new file mode 100644 index 000000000..cd38baa72 --- /dev/null +++ b/src/driver/fb_accel_cs_hdx_inc.h @@ -0,0 +1,38 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent acceleration functions for coolstream hdx graphic chips + are represented in this class. + + (C) 2017 M. Liebmann + (C) 2017 Thilo Graf 'dbt' + Derived from old neutrino-hd framebuffer code + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include diff --git a/src/driver/fb_accel_glfb.cpp b/src/driver/fb_accel_glfb.cpp new file mode 100644 index 000000000..905e83245 --- /dev/null +++ b/src/driver/fb_accel_glfb.cpp @@ -0,0 +1,149 @@ +/* + Framebuffer acceleration hardware abstraction functions. + This implements stuff needed by the GL Framebuffer. + Not really accelerated ;-) + + (C) 2017 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include + +#include +extern GLFramebuffer *glfb; + +#include +#include + +#define LOGTAG "[fb_glfb] " + +CFbAccelGLFB::CFbAccelGLFB() +{ + fb_name = "GL ramebuffer"; +} + +void CFbAccelGLFB::init(const char *) +{ + fd = -1; + if (!glfb) { + fprintf(stderr, LOGTAG "init: GL Framebuffer is not set up? we are doomed...\n"); + return; + } + screeninfo = glfb->getScreenInfo(); + stride = 4 * screeninfo.xres; + available = glfb->getOSDBuffer()->size(); /* allocated in glfb constructor */ + lbb = lfb = reinterpret_cast(glfb->getOSDBuffer()->data()); + + memset(lfb, 0, available); + setMode(720, 576, 8 * sizeof(fb_pixel_t)); + + blit_thread = false; + /* start the autoblit-thread (run() function) */ + OpenThreads::Thread::start(); +}; + +CFbAccelGLFB::~CFbAccelGLFB() +{ + if (blit_thread) + { + blit_thread = false; + blit(); /* wakes up the thread */ + OpenThreads::Thread::join(); + } +} + +void CFbAccelGLFB::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI +{ + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI + blit(); +} + +#define BLIT_INTERVAL_MIN 40 +#define BLIT_INTERVAL_MAX 250 +void CFbAccelGLFB::run() +{ + printf(LOGTAG "run start\n"); + time_t last_blit = 0; + blit_pending = false; + blit_thread = true; + blit_mutex.lock(); + set_threadname("glfb::autoblit"); + while (blit_thread) { + blit_cond.wait(&blit_mutex, blit_pending ? BLIT_INTERVAL_MIN : BLIT_INTERVAL_MAX); + time_t now = time_monotonic_ms(); + if (now - last_blit < BLIT_INTERVAL_MIN) + { + blit_pending = true; + //printf(LOGTAG "run: skipped, time %ld\n", now - last_blit); + } + else + { + blit_pending = false; + blit_mutex.unlock(); + _blit(); + blit_mutex.lock(); + last_blit = now; + } + } + blit_mutex.unlock(); + printf(LOGTAG "run end\n"); +} + +void CFbAccelGLFB::blit() +{ + //printf(LOGTAG "blit\n"); + blit_mutex.lock(); + blit_cond.signal(); + blit_mutex.unlock(); +} + +void CFbAccelGLFB::_blit() +{ + if (glfb) + glfb->blit(); +} + +/* wrong name... */ +int CFbAccelGLFB::setMode(unsigned int, unsigned int, unsigned int) +{ + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + int needmem = stride * yRes * 2; + if (available >= needmem) + { + backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + return 0; + } + fprintf(stderr, LOGTAG " not enough FB memory (have %d, need %d)\n", available, needmem); + backbuffer = lfb; /* will not work well, but avoid crashes */ + return 0; +} + +fb_pixel_t * CFbAccelGLFB::getBackBufferPointer() const +{ + return backbuffer; +} diff --git a/src/driver/fb_accel_sti.cpp b/src/driver/fb_accel_sti.cpp new file mode 100644 index 000000000..446fc3828 --- /dev/null +++ b/src/driver/fb_accel_sti.cpp @@ -0,0 +1,655 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent framebuffer acceleration functions for STi chips + are represented in this class. + + (C) 2017 Stefan Seyfried + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include +#include + +/* note that it is *not* enough to just change those values */ +#define DEFAULT_XRES 1280 +#define DEFAULT_YRES 720 +#define DEFAULT_BPP 32 + +#define LOGTAG "[fb_accel_sti] " +static int bpafd = -1; +static size_t lbb_sz = 1920 * 1080; /* offset from fb start in 'pixels' */ +static size_t lbb_off = lbb_sz * sizeof(fb_pixel_t); /* same in bytes */ +static int backbuf_sz = 0; + +void CFbAccelSTi::waitForIdle(const char *) +{ +#if 0 /* blits too often and does not seem to be necessary */ + blit_mutex.lock(); + if (blit_pending) + { + blit_mutex.unlock(); + _blit(); + return; + } + blit_mutex.unlock(); +#endif + OpenThreads::ScopedLock m_lock(mutex); + ioctl(fd, STMFBIO_SYNC_BLITTER); +} + +CFbAccelSTi::CFbAccelSTi() +{ + fb_name = "STx7xxx framebuffer"; +} + +void CFbAccelSTi::init(const char * const) +{ + blit_thread = false; + CFrameBuffer::init(); + if (lfb == NULL) { + printf(LOGTAG "CFrameBuffer::init() failed.\n"); + return; /* too bad... */ + } + available = fix.smem_len; + printf(LOGTAG "%dk video mem\n", available / 1024); + memset(lfb, 0, available); + + lbb = lfb; /* the memory area to draw to... */ + if (available < 12*1024*1024) + { + /* for old installations that did not upgrade their module config + * it will still work good enough to display the message below */ + fprintf(stderr, "[neutrino] WARNING: not enough framebuffer memory available!\n"); + fprintf(stderr, "[neutrino] I need at least 12MB.\n"); + FILE *f = fopen("/tmp/infobar.txt", "w"); + if (f) { + fprintf(f, "NOT ENOUGH FRAMEBUFFER MEMORY!"); + fclose(f); + } + lbb_sz = 0; + lbb_off = 0; + } + lbb = lfb + lbb_sz; + bpafd = open("/dev/bpamem0", O_RDWR | O_CLOEXEC); + if (bpafd < 0) + { + fprintf(stderr, "[neutrino] FB: cannot open /dev/bpamem0: %m\n"); + return; + } + backbuf_sz = 1280 * 720 * sizeof(fb_pixel_t); + BPAMemAllocMemData bpa_data; + bpa_data.bpa_part = (char *)"LMI_VID"; + bpa_data.mem_size = backbuf_sz; + int res; + res = ioctl(bpafd, BPAMEMIO_ALLOCMEM, &bpa_data); + if (res) + { + fprintf(stderr, "[neutrino] FB: cannot allocate from bpamem: %m\n"); + fprintf(stderr, "backbuf_sz: %d\n", backbuf_sz); + close(bpafd); + bpafd = -1; + return; + } + close(bpafd); + + char bpa_mem_device[30]; + sprintf(bpa_mem_device, "/dev/bpamem%d", bpa_data.device_num); + bpafd = open(bpa_mem_device, O_RDWR | O_CLOEXEC); + if (bpafd < 0) + { + fprintf(stderr, "[neutrino] FB: cannot open secondary %s: %m\n", bpa_mem_device); + return; + } + + backbuffer = (fb_pixel_t *)mmap(0, bpa_data.mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, bpafd, 0); + if (backbuffer == MAP_FAILED) + { + fprintf(stderr, "[neutrino] FB: cannot map from bpamem: %m\n"); + ioctl(bpafd, BPAMEMIO_FREEMEM); + close(bpafd); + bpafd = -1; + return; + } +#ifdef PARTIAL_BLIT + to_blit.xs = to_blit.ys = INT_MAX; + to_blit.xe = to_blit.ye = 0; + last_xres = 0; +#endif + + /* start the autoblit-thread (run() function) */ + OpenThreads::Thread::start(); +}; + +CFbAccelSTi::~CFbAccelSTi() +{ + if (blit_thread) + { + blit_thread = false; + blit(); /* wakes up the thread */ + OpenThreads::Thread::join(); + } + if (backbuffer) + { + fprintf(stderr, LOGTAG "unmap backbuffer\n"); + munmap(backbuffer, backbuf_sz); + } + if (bpafd != -1) + { + fprintf(stderr, LOGTAG "BPAMEMIO_FREEMEM\n"); + ioctl(bpafd, BPAMEMIO_FREEMEM); + close(bpafd); + } + if (lfb) + munmap(lfb, available); + if (fd > -1) + close(fd); +} + +void CFbAccelSTi::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) +{ + if (dx <= 0 || dy <= 0) + return; + + // The STM blitter introduces considerable overhead probably not worth for single lines. --martii + if (dx == 1) { + waitForIdle(); + fb_pixel_t *fbs = getFrameBufferPointer() + (DEFAULT_XRES * y) + x; + fb_pixel_t *fbe = fbs + DEFAULT_XRES * dy; + while (fbs < fbe) { + *fbs = col; + fbs += DEFAULT_XRES; + } + mark(x , y, x + 1, y + dy); + return; + } + if (dy == 1) { + waitForIdle(); + fb_pixel_t *fbs = getFrameBufferPointer() + (DEFAULT_XRES * y) + x; + fb_pixel_t *fbe = fbs + dx; + while (fbs < fbe) + *fbs++ = col; + mark(x , y, x + dx, y + 1); + return; + } + + /* function has const parameters, so copy them here... */ + int width = dx; + int height = dy; + int xx = x; + int yy = y; + /* maybe we should just return instead of fixing this up... */ + if (x < 0) { + fprintf(stderr, "[neutrino] fb::%s: x < 0 (%d)\n", __func__, x); + width += x; + if (width <= 0) + return; + xx = 0; + } + + if (y < 0) { + fprintf(stderr, "[neutrino] fb::%s: y < 0 (%d)\n", __func__, y); + height += y; + if (height <= 0) + return; + yy = 0; + } + + int right = xx + width; + int bottom = yy + height; + + if (right > (int)xRes) { + if (xx >= (int)xRes) { + fprintf(stderr, "[neutrino] fb::%s: x >= xRes (%d > %d)\n", __func__, xx, xRes); + return; + } + fprintf(stderr, "[neutrino] fb::%s: x+w > xRes! (%d+%d > %d)\n", __func__, xx, width, xRes); + right = xRes; + } + if (bottom > (int)yRes) { + if (yy >= (int)yRes) { + fprintf(stderr, "[neutrino] fb::%s: y >= yRes (%d > %d)\n", __func__, yy, yRes); + return; + } + fprintf(stderr, "[neutrino] fb::%s: y+h > yRes! (%d+%d > %d)\n", __func__, yy, height, yRes); + bottom = yRes; + } + + STMFBIO_BLT_DATA bltData; + memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); + + bltData.operation = BLT_OP_FILL; + bltData.dstOffset = lbb_off; + bltData.dstPitch = stride; + + bltData.dst_left = xx; + bltData.dst_top = yy; + bltData.dst_right = right; + bltData.dst_bottom = bottom; + + bltData.dstFormat = SURF_ARGB8888; + bltData.srcFormat = SURF_ARGB8888; + bltData.dstMemBase = STMFBGP_FRAMEBUFFER; + bltData.srcMemBase = STMFBGP_FRAMEBUFFER; + bltData.colour = col; + + mark(xx, yy, bltData.dst_right, bltData.dst_bottom); + OpenThreads::ScopedLock m_lock(mutex); + if (ioctl(fd, STMFBIO_BLT, &bltData ) < 0) + fprintf(stderr, "blitRect FBIO_BLIT: %m x:%d y:%d w:%d h:%d s:%d\n", xx,yy,width,height,stride); + blit(); +} + +void CFbAccelSTi::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) +{ + int x, y, dw, dh; + x = xoff; + y = yoff; + dw = width - xp; + dh = height - yp; + + size_t mem_sz = width * height * sizeof(fb_pixel_t); + unsigned long ulFlags = 0; + if (!transp) /* transp == false (default): use transparency from source alphachannel */ + ulFlags = BLT_OP_FLAGS_BLEND_SRC_ALPHA|BLT_OP_FLAGS_BLEND_DST_MEMORY; // we need alpha blending + + STMFBIO_BLT_EXTERN_DATA blt_data; + memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); + blt_data.operation = BLT_OP_COPY; + blt_data.ulFlags = ulFlags; + blt_data.srcOffset = 0; + blt_data.srcPitch = width * 4; + blt_data.dstOffset = lbb_off; + blt_data.dstPitch = stride; + blt_data.src_left = xp; + blt_data.src_top = yp; + blt_data.src_right = width; + blt_data.src_bottom = height; + blt_data.dst_left = x; + blt_data.dst_top = y; + blt_data.dst_right = x + dw; + blt_data.dst_bottom = y + dh; + blt_data.srcFormat = SURF_ARGB8888; + blt_data.dstFormat = SURF_ARGB8888; + blt_data.srcMemBase = (char *)backbuffer; + blt_data.dstMemBase = (char *)lfb; + blt_data.srcMemSize = mem_sz; + blt_data.dstMemSize = stride * yRes + lbb_off; + + mark(x, y, blt_data.dst_right, blt_data.dst_bottom); + OpenThreads::ScopedLock m_lock(mutex); + ioctl(fd, STMFBIO_SYNC_BLITTER); + if (fbbuff != backbuffer) + memmove(backbuffer, fbbuff, mem_sz); + // icons are so small that they will still be in cache + msync(backbuffer, backbuf_sz, MS_SYNC); + + if (ioctl(fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) + perror(LOGTAG "blit2FB STMFBIO_BLT_EXTERN"); + return; +} + +#define BLIT_INTERVAL_MIN 40 +#define BLIT_INTERVAL_MAX 250 +void CFbAccelSTi::run() +{ + printf(LOGTAG "::run start\n"); + time_t last_blit = 0; + blit_pending = false; + blit_thread = true; + blit_mutex.lock(); + set_threadname("stifb::autoblit"); + while (blit_thread) { + blit_cond.wait(&blit_mutex, blit_pending ? BLIT_INTERVAL_MIN : BLIT_INTERVAL_MAX); + time_t now = time_monotonic_ms(); + if (now - last_blit < BLIT_INTERVAL_MIN) + { + blit_pending = true; + //printf(LOGTAG "::run: skipped, time %ld\n", now - last_blit); + } + else + { + blit_pending = false; + blit_mutex.unlock(); + _blit(); + blit_mutex.lock(); + last_blit = now; + } + } + blit_mutex.unlock(); + printf(LOGTAG "::run end\n"); +} + +void CFbAccelSTi::blit() +{ + //printf(LOGTAG "::blit\n"); + blit_mutex.lock(); + blit_cond.signal(); + blit_mutex.unlock(); +} + +void CFbAccelSTi::_blit() +{ +#if 0 + static time_t last = 0; + time_t now = time_monotonic_ms(); + printf("%s %ld\n", __func__, now - last); + last = now; +#endif + OpenThreads::ScopedLock m_lock(mutex); +#ifdef PARTIAL_BLIT + if (to_blit.xs == INT_MAX) + return; + + int srcXa = to_blit.xs; + int srcYa = to_blit.ys; + int srcXb = to_blit.xe; + int srcYb = to_blit.ye; +#else + const int srcXa = 0; + const int srcYa = 0; + int srcXb = xRes; + int srcYb = yRes; +#endif + STMFBIO_BLT_DATA bltData; + memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); + + bltData.operation = BLT_OP_COPY; + //bltData.ulFlags = BLT_OP_FLAGS_BLEND_SRC_ALPHA | BLT_OP_FLAGS_BLEND_DST_MEMORY; // we need alpha blending + // src + bltData.srcOffset = lbb_off; + bltData.srcPitch = stride; + + bltData.src_left = srcXa; + bltData.src_top = srcYa; + bltData.src_right = srcXb; + bltData.src_bottom = srcYb; + + bltData.srcFormat = SURF_BGRA8888; + bltData.srcMemBase = STMFBGP_FRAMEBUFFER; + + /* calculate dst/blit factor */ + fb_var_screeninfo s; + if (ioctl(fd, FBIOGET_VSCREENINFO, &s) == -1) + perror("CFbAccel "); + +#ifdef PARTIAL_BLIT + if (s.xres != last_xres) /* fb resolution has changed -> clear artifacts */ + { + last_xres = s.xres; + bltData.src_left = 0; + bltData.src_top = 0; + bltData.src_right = xRes; + bltData.src_bottom = yRes; + } + + double xFactor = (double)s.xres/(double)xRes; + double yFactor = (double)s.yres/(double)yRes; + + int desXa = xFactor * bltData.src_left; + int desYa = yFactor * bltData.src_top; + int desXb = xFactor * bltData.src_right; + int desYb = yFactor * bltData.src_bottom; +#else + const int desXa = 0; + const int desYa = 0; + int desXb = s.xres; + int desYb = s.yres; +#endif + + /* dst */ + bltData.dstOffset = 0; + bltData.dstPitch = s.xres * 4; + + bltData.dst_left = desXa; + bltData.dst_top = desYa; + bltData.dst_right = desXb; + bltData.dst_bottom = desYb; + + bltData.dstFormat = SURF_BGRA8888; + bltData.dstMemBase = STMFBGP_FRAMEBUFFER; + + //printf("CFbAccelSTi::blit: sx:%d sy:%d sxe:%d sye: %d dx:%d dy:%d dxe:%d dye:%d\n", srcXa, srcYa, srcXb, srcYb, desXa, desYa, desXb, desYb); + if ((bltData.dst_right > s.xres) || (bltData.dst_bottom > s.yres)) + printf(LOGTAG "blit: values out of range desXb:%d desYb:%d\n", + bltData.dst_right, bltData.dst_bottom); + + if(ioctl(fd, STMFBIO_SYNC_BLITTER) < 0) + perror(LOGTAG "blit ioctl STMFBIO_SYNC_BLITTER 1"); + msync(lbb, xRes * 4 * yRes, MS_SYNC); + if (ioctl(fd, STMFBIO_BLT, &bltData ) < 0) + perror(LOGTAG "STMFBIO_BLT"); + if(ioctl(fd, STMFBIO_SYNC_BLITTER) < 0) + perror(LOGTAG "blit ioctl STMFBIO_SYNC_BLITTER 2"); + +#ifdef PARTIAL_BLIT + to_blit.xs = to_blit.ys = INT_MAX; + to_blit.xe = to_blit.ye = 0; +#endif +} + +/* not really used yet */ +#ifdef PARTIAL_BLIT +void CFbAccelSTi::mark(int xs, int ys, int xe, int ye) +{ + OpenThreads::ScopedLock m_lock(mutex); + if (xs < to_blit.xs) + to_blit.xs = xs; + if (ys < to_blit.ys) + to_blit.ys = ys; + if (xe > to_blit.xe) { + if (xe >= (int)xRes) + to_blit.xe = xRes - 1; + else + to_blit.xe = xe; + } + if (ye > to_blit.ye) { + if (ye >= (int)xRes) + to_blit.ye = yRes - 1; + else + to_blit.ye = ye; + } +#if 0 + /* debug code that kills neutrino right away if the blit area is invalid + * only enable this for creating a coredump for debugging */ + fb_var_screeninfo s; + if (ioctl(fd, FBIOGET_VSCREENINFO, &s) == -1) + perror("CFbAccel "); + if ((xe > s.xres) || (ye > s.yres)) { + fprintf(stderr, LOGTAG "mark: values out of range xe:%d ye:%d\n", xe, ye); + int *kill = NULL; + *kill = 1; /* oh my */ + } +#endif +} +#else +void CFbAccelSTi::mark(int, int, int, int) +{ +} +#endif + +/* wrong name... */ +int CFbAccelSTi::setMode(unsigned int, unsigned int, unsigned int) +{ + /* it's all fake... :-) */ + xRes = screeninfo.xres = screeninfo.xres_virtual = DEFAULT_XRES; + yRes = screeninfo.yres = screeninfo.yres_virtual = DEFAULT_YRES; + bpp = screeninfo.bits_per_pixel = DEFAULT_BPP; + stride = screeninfo.xres * screeninfo.bits_per_pixel / 8; + return 0; +} + +fb_pixel_t *CFbAccelSTi::getBackBufferPointer() const +{ + return backbuffer; +} + +/* original interfaceL: 1 == pixel alpha, 2 == global alpha premultiplied */ +void CFbAccelSTi::setBlendMode(uint8_t mode) +{ + /* mode = 1 => reset to no extra transparency */ + if (mode == 1) + setBlendLevel(0); +} + +/* level = 100 -> transparent, level = 0 -> nontransperent */ +void CFbAccelSTi::setBlendLevel(int level) +{ + struct stmfbio_var_screeninfo_ex v; + memset(&v, 0, sizeof(v)); + /* set to 0 already... + v.layerid = 0; + v.activate = STMFBIO_ACTIVATE_IMMEDIATE; // == 0 + v.premultiplied_alpha = 0; + */ + v.caps = STMFBIO_VAR_CAPS_OPACITY | STMFBIO_VAR_CAPS_PREMULTIPLIED; + v.opacity = 0xff - (level * 0xff / 100); + if (ioctl(fd, STMFBIO_SET_VAR_SCREENINFO_EX, &v) < 0) + perror(LOGTAG "setBlendLevel STMFBIO"); +} + +#if 0 +/* this is not accelerated... */ +void CFbAccelSTi::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + fb_pixel_t *pos = getFrameBufferPointer(); + pos += (stride / sizeof(fb_pixel_t)) * y; + pos += x; + *pos = col; +} + +/* unused, because horizontal and vertical line are not acceleratedn in paintRect anyway + * and everything else is identical to fb_generic code */ +void CFbAccelSTi::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +{ + int dx = abs (xa - xb); + int dy = abs (ya - yb); + if (dy == 0) /* horizontal line */ + { + /* paintRect actually is 1 pixel short to the right, + * but that's bug-compatibility with the GXA code */ + paintRect(xa, ya, xb - xa, 1, col); + return; + } + if (dx == 0) /* vertical line */ + { + paintRect(xa, ya, 1, yb - ya, col); + return; + } + int x; + int y; + int End; + int step; + + if (dx > dy) + { + int p = 2 * dy - dx; + int twoDy = 2 * dy; + int twoDyDx = 2 * (dy-dx); + + if (xa > xb) + { + x = xb; + y = yb; + End = xa; + step = ya < yb ? -1 : 1; + } + else + { + x = xa; + y = ya; + End = xb; + step = yb < ya ? -1 : 1; + } + + paintPixel(x, y, col); + + while (x < End) + { + x++; + if (p < 0) + p += twoDy; + else + { + y += step; + p += twoDyDx; + } + paintPixel(x, y, col); + } + } + else + { + int p = 2 * dx - dy; + int twoDx = 2 * dx; + int twoDxDy = 2 * (dx-dy); + + if (ya > yb) + { + x = xb; + y = yb; + End = ya; + step = xa < xb ? -1 : 1; + } + else + { + x = xa; + y = ya; + End = yb; + step = xb < xa ? -1 : 1; + } + + paintPixel(x, y, col); + + while (y < End) + { + y++; + if (p < 0) + p += twoDx; + else + { + x += step; + p += twoDxDy; + } + paintPixel(x, y, col); + } + } + mark(xa, ya, xb, yb); + blit(); +} +#endif diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp new file mode 100644 index 000000000..39c44e0cd --- /dev/null +++ b/src/driver/fb_generic.cpp @@ -0,0 +1,1883 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + 2003 thegoodguy + + Copyright (C) 2009-2012,2017 Stefan Seyfried + mute icon & info clock handling + Copyright (C) 2013 M. Liebmann (micha-bbg) + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +extern cVideo * videoDecoder; + +extern CPictureViewer * g_PicViewer; +#define ICON_CACHE_SIZE 1024*1024*2 // 2mb + +#define BACKGROUNDIMAGEWIDTH 720 + +void CFrameBuffer::waitForIdle(const char *) +{ +} + +/*******************************************************************************/ + +static uint8_t * virtual_fb = NULL; +inline unsigned int make16color(uint16_t r, uint16_t g, uint16_t b, uint16_t t, + uint32_t /*rl*/ = 0, uint32_t /*ro*/ = 0, + uint32_t /*gl*/ = 0, uint32_t /*go*/ = 0, + uint32_t /*bl*/ = 0, uint32_t /*bo*/ = 0, + uint32_t /*tl*/ = 0, uint32_t /*to*/ = 0) +{ + return ((t << 24) & 0xFF000000) | ((r << 8) & 0xFF0000) | ((g << 0) & 0xFF00) | (b >> 8 & 0xFF); +} + +CFrameBuffer::CFrameBuffer() +: active ( true ) +{ + fb_name = "generic framebuffer"; + iconBasePath = ""; + available = 0; + cmap.start = 0; + cmap.len = 256; + cmap.red = red; + cmap.green = green; + cmap.blue = blue; + cmap.transp = trans; + backgroundColor = 0; + useBackgroundPaint = false; + background = NULL; + backupBackground = NULL; + backgroundFilename = ""; + fd = 0; + tty = 0; + m_transparent_default = CFrameBuffer::TM_BLACK; // TM_BLACK: Transparency when black content ('pseudo' transparency) + // TM_NONE: No 'pseudo' transparency + // TM_INI: Transparency depends on g_settings.infobar_alpha ??? + m_transparent = m_transparent_default; + q_circle = NULL; + initQCircle(); + corner_tl = false; + corner_tr = false; + corner_bl = false; + corner_br = false; +//FIXME: test + memset(red, 0, 256*sizeof(__u16)); + memset(green, 0, 256*sizeof(__u16)); + memset(blue, 0, 256*sizeof(__u16)); + memset(trans, 0, 256*sizeof(__u16)); + fbAreaActiv = false; + fb_no_check = false; + do_paint_mute_icon = true; +} + +CFrameBuffer* CFrameBuffer::getInstance() +{ + static CFrameBuffer* frameBuffer = NULL; + + if (!frameBuffer) { +#if HAVE_SPARK_HARDWARE + frameBuffer = new CFbAccelSTi(); +#endif +#if HAVE_COOL_HARDWARE +#ifdef BOXMODEL_NEVIS + frameBuffer = new CFbAccelCSHD1(); +#endif +#ifdef BOXMODEL_APOLLO + frameBuffer = new CFbAccelCSHD2(); +#endif +#endif +#if HAVE_GENERIC_HARDWARE + frameBuffer = new CFbAccelGLFB(); +#endif + if (!frameBuffer) + frameBuffer = new CFrameBuffer(); + printf("[neutrino] %s Instance created\n", frameBuffer->fb_name); + } + return frameBuffer; +} + +void CFrameBuffer::init(const char * const fbDevice) +{ + int tr = 0xFF; + + fd = open(fbDevice, O_RDWR); + + if (fd<0) { + perror(fbDevice); + goto nolfb; + } + + if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo)<0) { + perror("FBIOGET_VSCREENINFO"); + goto nolfb; + } + + memmove(&oldscreen, &screeninfo, sizeof(screeninfo)); + + if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0) { + perror("FBIOGET_FSCREENINFO"); + goto nolfb; + } + + available=fix.smem_len; + printf("[fb_generic] %dk video mem\n", available/1024); + lbb = lfb = (fb_pixel_t*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); + + if (!lfb) { + perror("mmap"); + goto nolfb; + } + + cache_size = 0; + + /* Windows Colors */ + paletteSetColor(0x1, 0x010101, tr); + paletteSetColor(0x2, 0x800000, tr); + paletteSetColor(0x3, 0x008000, tr); + paletteSetColor(0x4, 0x808000, tr); + paletteSetColor(0x5, 0x000080, tr); + paletteSetColor(0x6, 0x800080, tr); + paletteSetColor(0x7, 0x008080, tr); + paletteSetColor(0x8, 0xA0A0A0, tr); + paletteSetColor(0x9, 0x505050, tr); + paletteSetColor(0xA, 0xFF0000, tr); + paletteSetColor(0xB, 0x00FF00, tr); + paletteSetColor(0xC, 0xFFFF00, tr); + paletteSetColor(0xD, 0x0000FF, tr); + paletteSetColor(0xE, 0xFF00FF, tr); + paletteSetColor(0xF, 0x00FFFF, tr); + paletteSetColor(0x10, 0xFFFFFF, tr); + paletteSetColor(0x11, 0x000000, tr); + paletteSetColor(COL_BACKGROUND, 0x000000, 0x0); + + paletteSet(); + + useBackground(false); + m_transparent = m_transparent_default; +#if 0 + if ((tty=open("/dev/vc/0", O_RDWR))<0) { + perror("open (tty)"); + goto nolfb; + } + + struct sigaction act; + + memset(&act,0,sizeof(act)); + act.sa_handler = switch_signal; + sigemptyset(&act.sa_mask); + sigaction(SIGUSR1,&act,NULL); + sigaction(SIGUSR2,&act,NULL); + + struct vt_mode mode; + + if (-1 == ioctl(tty,KDGETMODE, &kd_mode)) { + perror("ioctl KDGETMODE"); + goto nolfb; + } + + if (-1 == ioctl(tty,VT_GETMODE, &vt_mode)) { + perror("ioctl VT_GETMODE"); + goto nolfb; + } + + if (-1 == ioctl(tty,VT_GETMODE, &mode)) { + perror("ioctl VT_GETMODE"); + goto nolfb; + } + + mode.mode = VT_PROCESS; + mode.waitv = 0; + mode.relsig = SIGUSR1; + mode.acqsig = SIGUSR2; + + if (-1 == ioctl(tty,VT_SETMODE, &mode)) { + perror("ioctl VT_SETMODE"); + goto nolfb; + } + + if (-1 == ioctl(tty,KDSETMODE, KD_GRAPHICS)) { + perror("ioctl KDSETMODE"); + goto nolfb; + } +#endif + + return; + +nolfb: + printf("framebuffer not available.\n"); + lbb = lfb = NULL; +} + + +void CFrameBuffer::clearIconCache() +{ + std::map::iterator it; + + for(it = icon_cache.begin(); it != icon_cache.end(); ++it) { + /* printf("FB: delete cached icon %s: %x\n", it->first.c_str(), (int) it->second.data); */ + cs_free_uncached(it->second.data); + } + icon_cache.clear(); +} + +CFrameBuffer::~CFrameBuffer() +{ + clearIconCache(); //NI + + if (background) { + delete[] background; + background = NULL; + } + + if (backupBackground) { + delete[] backupBackground; + backupBackground = NULL; + } + + if (q_circle) { + delete[] q_circle; + q_circle = NULL; + } + +#if 0 + if (-1 == ioctl(tty,VT_SETMODE, &vt_mode)) + perror("ioctl VT_SETMODE"); + + if (available) + ioctl(fd, FBIOPUT_VSCREENINFO, &oldscreen); +#endif + if (lfb) + munmap(lfb, available); + + if (virtual_fb){ + delete[] virtual_fb; + virtual_fb = NULL; + } + close(fd); + close(tty); + + v_fbarea.clear(); +} + +int CFrameBuffer::getFileHandle() const +{ + return fd; +} + +unsigned int CFrameBuffer::getStride() const +{ + return stride; +} + +unsigned int CFrameBuffer::getScreenWidth(bool real) +{ + if(real) + return xRes; + else + return g_settings.screen_EndX - g_settings.screen_StartX; +} + +unsigned int CFrameBuffer::getScreenHeight(bool real) +{ + if(real) + return yRes; + else + return g_settings.screen_EndY - g_settings.screen_StartY; +} + +unsigned int CFrameBuffer::getScreenWidthRel(bool force_small) +{ + int percent = force_small ? WINDOW_SIZE_MIN_FORCED : g_settings.window_width; + // always reduce a possible detailline + return (g_settings.screen_EndX - g_settings.screen_StartX - 2*ConnectLineBox_Width) * percent / 100; +} + +unsigned int CFrameBuffer::getScreenHeightRel(bool force_small) +{ + int percent = force_small ? WINDOW_SIZE_MIN_FORCED : g_settings.window_height; + return (g_settings.screen_EndY - g_settings.screen_StartY) * percent / 100; +} + +unsigned int CFrameBuffer::getScreenX() +{ + return g_settings.screen_StartX; +} + +unsigned int CFrameBuffer::getScreenY() +{ + return g_settings.screen_StartY; +} + +fb_pixel_t * CFrameBuffer::getFrameBufferPointer() const +{ + if (active || (virtual_fb == NULL)) + return lbb; + else + return (fb_pixel_t *) virtual_fb; +} + +/* dummy if not implemented in CFbAccel */ +fb_pixel_t * CFrameBuffer::getBackBufferPointer() const +{ + return getFrameBufferPointer(); +} + +bool CFrameBuffer::getActive() const +{ + return (active || (virtual_fb != NULL)); +} + +void CFrameBuffer::setActive(bool enable) +{ + active = enable; +} + +t_fb_var_screeninfo *CFrameBuffer::getScreenInfo() +{ + return &screeninfo; +} + +int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsigned int /*nbpp*/) +{ + if (!available&&!active) + return -1; + +#if 0 + screeninfo.xres_virtual=screeninfo.xres=nxRes; + screeninfo.yres_virtual=screeninfo.yres=nyRes; + 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"); + } + + if(1) { + printf("SetMode: %dbits, red %d:%d green %d:%d blue %d:%d transp %d:%d\n", + screeninfo.bits_per_pixel, screeninfo.red.length, screeninfo.red.offset, screeninfo.green.length, screeninfo.green.offset, screeninfo.blue.length, screeninfo.blue.offset, screeninfo.transp.length, screeninfo.transp.offset); + } + if ((screeninfo.xres!=nxRes) && (screeninfo.yres!=nyRes) && (screeninfo.bits_per_pixel!=nbpp)) + { + printf("SetMode failed: wanted: %dx%dx%d, got %dx%dx%d\n", + nxRes, nyRes, nbpp, + screeninfo.xres, screeninfo.yres, screeninfo.bits_per_pixel); + return -1; + } +#endif + + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + fb_fix_screeninfo _fix; + + if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix)<0) { + perror("FBIOGET_FSCREENINFO"); + return -1; + } + + stride = _fix.line_length; + printf("FB: %dx%dx%d line length %d. %s accelerator.\n", xRes, yRes, bpp, stride, + "Not using graphics" + ); + + //memset(getFrameBufferPointer(), 0, stride * yRes); + paintBackground(); + if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) { + printf("screen unblanking failed\n"); + } + return 0; +} +#if 0 +//never used +void CFrameBuffer::setTransparency( int /*tr*/ ) +{ +} +#endif +void CFrameBuffer::setBlendMode(uint8_t /*mode*/) +{ +} + +void CFrameBuffer::setBlendLevel(int /*level*/) +{ +} + +#if 0 +//never used +void CFrameBuffer::setAlphaFade(int in, int num, int tr) +{ + for (int i=0; i>16)*level; + *g= ((rgb2&0x00FF00)>>8 )*level; + *b= ((rgb2&0x0000FF) )*level; + *r+=((rgb1&0xFF0000)>>16)*(255-level); + *g+=((rgb1&0x00FF00)>>8 )*(255-level); + *b+=((rgb1&0x0000FF) )*(255-level); +} + +void CFrameBuffer::paletteGenFade(int in, __u32 rgb1, __u32 rgb2, int num, int tr) +{ + for (int i=0; i>8; + cmap.green[i] =(rgb&0x00FF00) ; + cmap.blue[i] =(rgb&0x0000FF)<<8; + cmap.transp[i] = tr; +} + +void CFrameBuffer::paletteSet(struct fb_cmap *map) +{ + if (!active) + return; + + if(map == NULL) + map = &cmap; + + if(bpp == 8) { + //printf("Set palette for %dbit\n", bpp); + ioctl(fd, FBIOPUTCMAP, map); + } + + uint32_t rl, ro, gl, go, bl, bo, tl, to; + + rl = screeninfo.red.length; + ro = screeninfo.red.offset; + gl = screeninfo.green.length; + go = screeninfo.green.offset; + bl = screeninfo.blue.length; + bo = screeninfo.blue.offset; + tl = screeninfo.transp.length; + to = screeninfo.transp.offset; + for (int i = 0; i < 256; i++) { + realcolor[i] = make16color(cmap.red[i], cmap.green[i], cmap.blue[i], cmap.transp[i], + rl, ro, gl, go, bl, bo, tl, to); + } + OnAfterSetPallette(); +} + +void CFrameBuffer::paintHLineRelInternal2Buf(const int& x, const int& dx, const int& y, const int& box_dx, const fb_pixel_t& col, fb_pixel_t* buf) +{ + uint8_t * pos = ((uint8_t *)buf) + x * sizeof(fb_pixel_t) + box_dx * sizeof(fb_pixel_t) * y; + fb_pixel_t * dest = (fb_pixel_t *)pos; + for (int i = 0; i < dx; i++) + *(dest++) = col; +} + +fb_pixel_t* CFrameBuffer::paintBoxRel2Buf(const int dx, const int dy, const int w_align, const int offs_align, const fb_pixel_t col, fb_pixel_t* buf/* = NULL*/, int radius/* = 0*/, int type/* = CORNER_ALL*/) +{ + if (!getActive()) + return buf; + if (dx < 1 || dy < 1) { + dprintf(DEBUG_INFO, "[CFrameBuffer] [%s - %d]: radius %d, dx %d dy %d\n", __func__, __LINE__, radius, dx, dy); + return buf; + } + + fb_pixel_t* pixBuf = buf; + if (pixBuf == NULL) { + pixBuf = (fb_pixel_t*) cs_malloc_uncached(w_align*dy*sizeof(fb_pixel_t)); + if (pixBuf == NULL) { + dprintf(DEBUG_NORMAL, "[%s #%d] Error cs_malloc_uncached\n", __func__, __LINE__); + return NULL; + } + } + memset((void*)pixBuf, '\0', w_align*dy*sizeof(fb_pixel_t)); + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + calcCorners(NULL, &ofl, &ofr, dy, line, radius, type); + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0) { + dprintf(DEBUG_INFO, "[%s - %d]: radius %d, end x %d y %d\n", __func__, __LINE__, radius, dx-ofr-ofl, line); + } + else { + dprintf(DEBUG_INFO, "[%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + paintHLineRelInternal2Buf(ofl+offs_align, dx-ofl-ofr, line, w_align, col, pixBuf); + line++; + } + } else { + fb_pixel_t *bp = pixBuf; + int line = 0; + while (line < dy) { + for (int pos = offs_align; pos < dx+offs_align; pos++) + *(bp + pos) = col; + bp += w_align; + line++; + } + } + return pixBuf; +} + +fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int dy, + const fb_pixel_t /*col*/, gradientData_t *gradientData, + int radius, int type) +{ + if (!getActive()) + return NULL; + + checkFbArea(x, y, dx, dy, true); + + fb_pixel_t MASK = 0xFFFFFFFF; + int _dx = dx; + int w_align; + int offs_align; + +#ifdef BOXMODEL_APOLLO + if (_dx%4 != 0) { + w_align = GetWidth4FB_HW_ACC(x, _dx, true); + if (w_align < _dx) + _dx = w_align; + offs_align = w_align - _dx; + if ((x - offs_align) < 0) + offs_align = 0; + } + else { + w_align = _dx; + offs_align = 0; + } +#else + w_align = _dx; + offs_align = 0; +#endif + + fb_pixel_t* boxBuf = paintBoxRel2Buf(_dx, dy, w_align, offs_align, MASK, NULL, radius, type); + if (boxBuf == NULL) { + checkFbArea(x, y, dx, dy, false); + return NULL; + } + fb_pixel_t *bp = boxBuf; + fb_pixel_t *gra = gradientData->gradientBuf; + gradientData->boxBuf = boxBuf; + gradientData->x = x - offs_align; + gradientData->dx = w_align; + + if (gradientData->direction == gradientVertical) { + // vertical + for (int pos = offs_align; pos < _dx+offs_align; pos++) { + for(int count = 0; count < dy; count++) { + if (*(bp + pos) == MASK) + *(bp + pos) = (fb_pixel_t)(*(gra + count)); + bp += w_align; + } + bp = boxBuf; + } + } else { + // horizontal + for (int line = 0; line < dy; line++) { + int gra_pos = 0; + for (int pos = 0; pos < w_align; pos++) { + if ((*(bp + pos) == MASK) && (pos >= offs_align) && (gra_pos < _dx)) { + *(bp + pos) = (fb_pixel_t)(*(gra + gra_pos)); + gra_pos++; + } + } + bp += w_align; + } + } + + if ((gradientData->mode & pbrg_noPaint) == pbrg_noPaint) { + checkFbArea(x, y, dx, dy, false); + return boxBuf; + } + + blitBox2FB(boxBuf, w_align, dy, x-offs_align, y); + + if ((gradientData->mode & pbrg_noFree) == pbrg_noFree) { + checkFbArea(x, y, dx, dy, false); + return boxBuf; + } + + cs_free_uncached(boxBuf); + + checkFbArea(x, y, dx, dy, false); + return NULL; +} + +void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +{ + /* draw a filled rectangle (with additional round corners) */ + + if (!getActive()) + return; + + if (dx == 0 || dy == 0) { + dprintf(DEBUG_DEBUG, "[CFrameBuffer] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + return; + } + if (radius < 0) + dprintf(DEBUG_NORMAL, "[CFrameBuffer] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + + checkFbArea(x, y, dx, dy, true); + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + //printf("3: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line); + } + + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0){ + dprintf(DEBUG_INFO, "[CFrameBuffer] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx-ofr-ofl, y+line); + }else{ + dprintf(DEBUG_INFO, "[CFrameBuffer] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col); + line++; + } + } else { + int swidth = stride / sizeof(fb_pixel_t); + fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); + int line = 0; + while (line < dy) { + for (int pos = x; pos < x + dx; pos++) + *(fbp + pos) = col; + + fbp += swidth; + line++; + } + } + checkFbArea(x, y, dx, dy, false); +} + +void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col) +{ + uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + + for(int count=0;count::iterator it; + + + /* if code ask for size, lets cache it. assume we have enough ram for cache */ + /* FIXME offset seems never used in code, always default = 1 ? */ + + it = icon_cache.find(filename); + if(it == icon_cache.end()) { + if(paintIcon(filename, 0, 0, 0, 1, false)) { + it = icon_cache.find(filename); + } + } + if(it != icon_cache.end()) { + *width = it->second.width; + *height = it->second.height; + } +} + +bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset) +{ + if (!getActive()) + return false; + +//printf("%s(file, %d, %d, %d)\n", __FUNCTION__, x, y, offset); + + struct rawHeader header; + uint16_t width, height; + int lfd; + + lfd = open((iconBasePath + "/" + filename).c_str(), O_RDONLY); + + if (lfd == -1) { + printf("paintIcon8: error while loading icon: %s/%s\n", iconBasePath.c_str(), filename.c_str()); + return false; + } + + read(lfd, &header, sizeof(struct rawHeader)); + + width = (header.width_hi << 8) | header.width_lo; + height = (header.height_hi << 8) | header.height_lo; + + unsigned char pixbuf[768]; + + uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * d2; + for (int count=0; count::iterator it; + + if (!getActive()) + return false; + + int yy = y; + //printf("CFrameBuffer::paintIcon: load %s\n", filename.c_str());fflush(stdout); + + /* we cache and check original name */ + it = icon_cache.find(filename); + if(it == icon_cache.end()) { + std::string newname = getIconPath(filename); + //printf("CFrameBuffer::paintIcon: check for %s\n", newname.c_str());fflush(stdout); + + data = g_PicViewer->getIcon(newname, &width, &height); + + if(data) { //TODO: intercepting of possible full icon cache, that could cause strange behavior while painting of uncached icons + int dsize = width*height*sizeof(fb_pixel_t); + //printf("CFrameBuffer::paintIcon: %s found, data %x size %d x %d\n", newname.c_str(), data, width, height);fflush(stdout); + if(cache_size+dsize < ICON_CACHE_SIZE) { + cache_size += dsize; + tmpIcon.width = width; + tmpIcon.height = height; + tmpIcon.data = data; + icon_cache.insert(std::pair (filename, tmpIcon)); + //printf("Cached %s, cache size %d\n", newname.c_str(), cache_size); + } + goto _display; + } + + newname = getIconPath(filename, "raw"); + + int lfd = open(newname.c_str(), O_RDONLY); + + if (lfd == -1) { + //printf("paintIcon: error while loading icon: %s\n", newname.c_str()); + return false; + } + + ssize_t s = read(lfd, &header, sizeof(struct rawHeader)); + if (s < 0) { + perror("read"); + return false; + } + + if (s < (ssize_t) sizeof(rawHeader)){ + printf("paintIcon: error while loading icon: %s, header too small\n", newname.c_str()); + return false; + } + + + tmpIcon.width = width = (header.width_hi << 8) | header.width_lo; + tmpIcon.height = height = (header.height_hi << 8) | header.height_lo; + if (!width || !height) { + printf("paintIcon: error while loading icon: %s, wrong dimensions (%dHx%dW)\n", newname.c_str(), height, width); + return false; + } + + int dsize = width*height*sizeof(fb_pixel_t); + + tmpIcon.data = (fb_pixel_t*) cs_malloc_uncached(dsize); + data = tmpIcon.data; + + unsigned char pixbuf[768]; + for (int count = 0; count < height; count ++ ) { + read(lfd, &pixbuf[0], width >> 1 ); + unsigned char *pixpos = &pixbuf[0]; + for (int count2 = 0; count2 < width >> 1; count2 ++ ) { + unsigned char compressed = *pixpos; + unsigned char pix1 = (compressed & 0xf0) >> 4; + unsigned char pix2 = (compressed & 0x0f); + if (pix1 != header.transp) + *data++ = realcolor[pix1+offset]; + else + *data++ = 0; + if (pix2 != header.transp) + *data++ = realcolor[pix2+offset]; + else + *data++ = 0; + pixpos++; + } + } + close(lfd); + + data = tmpIcon.data; + + if(cache_size+dsize < ICON_CACHE_SIZE) { + cache_size += dsize; + icon_cache.insert(std::pair (filename, tmpIcon)); + //printf("Cached %s, cache size %d\n", newname.c_str(), cache_size); + } + } else { + data = it->second.data; + width = it->second.width; + height = it->second.height; + //printf("paintIcon: already cached %s %d x %d\n", newname.c_str(), width, height); + } +_display: + if(!paint) + return true; + + if (h != 0) + yy += (h - height) / 2; + + checkFbArea(x, yy, width, height, true); + if (paintBg) + paintBoxRel(x, yy, width, height, colBg); + blit2FB(data, width, height, x, yy); + checkFbArea(x, yy, width, height, false); + return true; +} + +void CFrameBuffer::loadPal(const std::string & filename, const unsigned char offset, const unsigned char endidx) +{ + if (!getActive()) + return; + +//printf("%s()\n", __FUNCTION__); + + struct rgbData rgbdata; + int lfd; + + lfd = open((iconBasePath + "/" + filename).c_str(), O_RDONLY); + + if (lfd == -1) { + printf("error while loading palette: %s/%s\n", iconBasePath.c_str(), filename.c_str()); + return; + } + + int pos = 0; + int readb = read(lfd, &rgbdata, sizeof(rgbdata) ); + while(readb) { + __u32 rgb = (rgbdata.r<<16) | (rgbdata.g<<8) | (rgbdata.b); + int colpos = offset+pos; + if( colpos>endidx) + break; + + paletteSetColor(colpos, rgb, 0xFF); + readb = read(lfd, &rgbdata, sizeof(rgbdata) ); + pos++; + } + paletteSet(&cmap); + close(lfd); +} + +void CFrameBuffer::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + if (!getActive()) + return; + + fb_pixel_t * pos = getFrameBufferPointer(); + pos += (stride / sizeof(fb_pixel_t)) * y; + pos += x; + + *pos = col; +} + +void CFrameBuffer::paintShortHLineRelInternal(const int& x, const int& dx, const int& y, const fb_pixel_t& col) +{ + uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * dest = (fb_pixel_t *)pos; + for (int i = 0; i < dx; i++) + *(dest++) = col; +} + +int CFrameBuffer::limitRadius(const int& dx, const int& dy, int& radius) +{ + if (radius > dx) + return dx; + if (radius > dy) + return dy; + if (radius > 540) + return 540; + return radius; +} + +void CFrameBuffer::setCornerFlags(const int& type) +{ + corner_tl = (type & CORNER_TOP_LEFT) == CORNER_TOP_LEFT; + corner_tr = (type & CORNER_TOP_RIGHT) == CORNER_TOP_RIGHT; + corner_bl = (type & CORNER_BOTTOM_LEFT) == CORNER_BOTTOM_LEFT; + corner_br = (type & CORNER_BOTTOM_RIGHT) == CORNER_BOTTOM_RIGHT; +} + +void CFrameBuffer::initQCircle() +{ + /* this table contains the x coordinates for a quarter circle (the bottom right quarter) with fixed + radius of 540 px which is the half of the max HD graphics size of 1080 px. So with that table we + ca draw boxes with round corners and als circles by just setting dx = dy = radius (max 540). */ + static const int _q_circle[541] = { + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, + 539, 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 536, 536, 536, 536, 536, 536, 536, 536, 535, 535, 535, 535, 535, 535, 535, 535, 534, 534, + 534, 534, 534, 534, 533, 533, 533, 533, 533, 533, 532, 532, 532, 532, 532, 532, 531, 531, 531, 531, + 531, 531, 530, 530, 530, 530, 529, 529, 529, 529, 529, 529, 528, 528, 528, 528, 527, 527, 527, 527, + 527, 526, 526, 526, 526, 525, 525, 525, 525, 524, 524, 524, 524, 523, 523, 523, 523, 522, 522, 522, + 522, 521, 521, 521, 521, 520, 520, 520, 519, 519, 519, 518, 518, 518, 518, 517, 517, 517, 516, 516, + 516, 515, 515, 515, 515, 514, 514, 514, 513, 513, 513, 512, 512, 512, 511, 511, 511, 510, 510, 510, + 509, 509, 508, 508, 508, 507, 507, 507, 506, 506, 506, 505, 505, 504, 504, 504, 503, 503, 502, 502, + 502, 501, 501, 500, 500, 499, 499, 499, 498, 498, 498, 497, 497, 496, 496, 496, 495, 495, 494, 494, + 493, 493, 492, 492, 491, 491, 490, 490, 490, 489, 489, 488, 488, 487, 487, 486, 486, 485, 485, 484, + 484, 483, 483, 482, 482, 481, 481, 480, 480, 479, 479, 478, 478, 477, 477, 476, 476, 475, 475, 474, + 473, 473, 472, 472, 471, 471, 470, 470, 469, 468, 468, 467, 466, 466, 465, 465, 464, 464, 463, 462, + 462, 461, 460, 460, 459, 459, 458, 458, 457, 456, 455, 455, 454, 454, 453, 452, 452, 451, 450, 450, + 449, 449, 448, 447, 446, 446, 445, 445, 444, 443, 442, 441, 441, 440, 440, 439, 438, 437, 436, 436, + 435, 435, 434, 433, 432, 431, 431, 430, 429, 428, 427, 427, 426, 425, 425, 424, 423, 422, 421, 421, + 420, 419, 418, 417, 416, 416, 415, 414, 413, 412, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, + 403, 402, 401, 400, 399, 398, 397, 397, 395, 394, 393, 393, 392, 391, 390, 389, 388, 387, 386, 385, + 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, 373, 372, 371, 369, 368, 367, 367, 365, 364, + 363, 362, 361, 360, 358, 357, 356, 355, 354, 353, 352, 351, 350, 348, 347, 346, 345, 343, 342, 341, + 340, 339, 337, 336, 335, 334, 332, 331, 329, 328, 327, 326, 324, 323, 322, 321, 319, 317, 316, 315, + 314, 312, 310, 309, 308, 307, 305, 303, 302, 301, 299, 297, 296, 294, 293, 291, 289, 288, 287, 285, + 283, 281, 280, 278, 277, 275, 273, 271, 270, 268, 267, 265, 263, 261, 259, 258, 256, 254, 252, 250, + 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 225, 223, 221, 219, 217, 215, 212, 210, 207, + 204, 202, 200, 197, 195, 192, 190, 187, 184, 181, 179, 176, 173, 170, 167, 164, 160, 157, 154, 150, + 147, 144, 140, 136, 132, 128, 124, 120, 115, 111, 105, 101, 95, 89, 83, 77, 69, 61, 52, 40, + 23}; + if (q_circle == NULL) + q_circle = new int[sizeof(_q_circle) / sizeof(int)]; + memcpy(q_circle, _q_circle, sizeof(_q_circle)); +} + +bool CFrameBuffer::calcCorners(int *ofs, int *ofl, int *ofr, const int& dy, const int& line, const int& radius, const int& type) +{ +/* just an multiplicator for all math to reduce rounding errors */ +#define MUL 32768 + int scl, _ofs = 0; + bool ret = false; + if (ofl != NULL) *ofl = 0; + if (ofr != NULL) *ofr = 0; + int scf = (540 * MUL) / ((radius < 1) ? 1 : radius); + /* one of the top corners */ + if (line < radius && (type & CORNER_TOP)) { + /* uper round corners */ + scl = scf * (radius - line) / MUL; + if ((scf * (radius - line) % MUL) >= (MUL / 2)) /* round up */ + scl++; + _ofs = radius - (q_circle[scl] * MUL / scf); + if (ofl != NULL) *ofl = corner_tl ? _ofs : 0; + if (ofr != NULL) *ofr = corner_tr ? _ofs : 0; + } + /* one of the bottom corners */ + else if ((line >= dy - radius) && (type & CORNER_BOTTOM)) { + /* lower round corners */ + scl = scf * (radius - (dy - (line + 1))) / MUL; + if ((scf * (radius - (dy - (line + 1))) % MUL) >= (MUL / 2)) /* round up */ + scl++; + _ofs = radius - (q_circle[scl] * MUL / scf); + if (ofl != NULL) *ofl = corner_bl ? _ofs : 0; + if (ofr != NULL) *ofr = corner_br ? _ofs : 0; + } + else + ret = true; + if (ofs != NULL) *ofs = _ofs; + return ret; +} + +void CFrameBuffer::paintBoxFrame(const int x, const int y, const int dx, const int dy, const int px, const fb_pixel_t col, int radius, int type) +{ + if (!getActive()) + return; + + if (dx == 0 || dy == 0) { + dprintf(DEBUG_NORMAL, "[CFrameBuffer] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + return; + } + if (radius < 0) + dprintf(DEBUG_NORMAL, "[CFrameBuffer] [%s - %d]: WARNING! radius < 0 [%d] FIXIT\n", __func__, __LINE__, radius); + + setCornerFlags(type); + int rad_tl = 0, rad_tr = 0, rad_bl = 0, rad_br = 0; + if (type && radius) { + int x_rad = radius - 1; + if (corner_tl) rad_tl = x_rad; + if (corner_tr) rad_tr = x_rad; + if (corner_bl) rad_bl = x_rad; + if (corner_br) rad_br = x_rad; + } + paintBoxRel(x + rad_tl , y , dx - rad_tl - rad_tr, px , col); // top horizontal + paintBoxRel(x + rad_bl , y + dy - px, dx - rad_bl - rad_br, px , col); // bottom horizontal + paintBoxRel(x , y + rad_tl , px , dy - rad_tl - rad_bl, col); // left vertical + paintBoxRel(x + dx - px, y + rad_tr , px , dy - rad_tr - rad_br, col); // right vertical + + if (type && radius) { + radius = limitRadius(dx, dy, radius); + int line = 0; + waitForIdle("CFrameBuffer::paintBoxFrame"); + while (line < dy) { + int ofs = 0, ofs_i = 0; + // inner box + if ((line >= px) && (line < (dy - px))) + ofs_i = calcCornersOffset(dy - 2*px, line-px, radius-px, type); + // outer box + ofs = calcCornersOffset(dy, line, radius, type); + + int _x = x + ofs; + int _x_end = x + dx; + int _y = y + line; + if ((line < px) || (line >= (dy - px))) { + // left + if (((corner_tl) && (line < radius)) || ((corner_bl) && (line >= dy - radius))) + paintShortHLineRelInternal(_x, radius - ofs, _y, col); + // right + if (((corner_tr) && (line < radius)) || ((corner_br) && (line >= dy - radius))) + paintShortHLineRelInternal(_x_end - radius, radius - ofs, _y, col); + } + else if (line < (dy - px)) { + int _dx = (ofs_i-ofs) + px; + // left + if (((corner_tl) && (line < radius)) || ((corner_bl) && (line >= dy - radius))) + paintShortHLineRelInternal(_x, _dx, _y, col); + // right + if (((corner_tr) && (line < radius)) || ((corner_br) && (line >= dy - radius))) + paintShortHLineRelInternal(_x_end - ofs_i - px, _dx, _y, col); + } + if ((line == radius) && (dy > 2*radius)) + // line outside the rounded corners + line = dy - radius; + else + line++; + } + } +} + +void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +{ + if (!getActive()) + return; + + int dx = abs (xa - xb); + int dy = abs (ya - yb); + int x; + int y; + int End; + int step; + + if ( dx > dy ) + { + int p = 2 * dy - dx; + int twoDy = 2 * dy; + int twoDyDx = 2 * (dy-dx); + + if ( xa > xb ) + { + x = xb; + y = yb; + End = xa; + step = ya < yb ? -1 : 1; + } + else + { + x = xa; + y = ya; + End = xb; + step = yb < ya ? -1 : 1; + } + + paintPixel (x, y, col); + + while( x < End ) + { + x++; + if ( p < 0 ) + p += twoDy; + else + { + y += step; + p += twoDyDx; + } + paintPixel (x, y, col); + } + } + else + { + int p = 2 * dx - dy; + int twoDx = 2 * dx; + int twoDxDy = 2 * (dx-dy); + + if ( ya > yb ) + { + x = xb; + y = yb; + End = ya; + step = xa < xb ? -1 : 1; + } + else + { + x = xa; + y = ya; + End = yb; + step = xb < xa ? -1 : 1; + } + + paintPixel (x, y, col); + + while( y < End ) + { + y++; + if ( p < 0 ) + p += twoDx; + else + { + x += step; + p += twoDxDy; + } + paintPixel (x, y, col); + } + } + mark(xa, ya, xb, yb); +} +#if 0 +//never used +void CFrameBuffer::setBackgroundColor(const fb_pixel_t color) +{ + backgroundColor = color; +} + +bool CFrameBuffer::loadPictureToMem(const std::string & filename, const uint16_t width, const uint16_t height, const uint16_t pstride, fb_pixel_t * memp) +{ + struct rawHeader header; + int lfd; + +//printf("%s(%d, %d, memp)\n", __FUNCTION__, width, height); + + lfd = open((iconBasePath + "/" + filename).c_str(), O_RDONLY ); + + if (lfd == -1) + { + printf("error while loading icon: %s/%s\n", iconBasePath.c_str(), filename.c_str()); + return false; + } + + read(lfd, &header, sizeof(struct rawHeader)); + + if ((width != ((header.width_hi << 8) | header.width_lo)) || + (height != ((header.height_hi << 8) | header.height_lo))) + { + printf("error while loading icon: %s - invalid resolution = %hux%hu\n", filename.c_str(), width, height); + close(lfd); + return false; + } + + if ((pstride == 0) || (pstride == width * sizeof(fb_pixel_t))) + read(lfd, memp, height * width * sizeof(fb_pixel_t)); + else + for (int i = 0; i < height; i++) + read(lfd, ((uint8_t *)memp) + i * pstride, width * sizeof(fb_pixel_t)); + + close(lfd); + return true; +} + +bool CFrameBuffer::loadPicture2Mem(const std::string & filename, fb_pixel_t * memp) +{ + return loadPictureToMem(filename, BACKGROUNDIMAGEWIDTH, 576, 0, memp); +} + +bool CFrameBuffer::loadPicture2FrameBuffer(const std::string & filename) +{ + if (!getActive()) + return false; + + return loadPictureToMem(filename, BACKGROUNDIMAGEWIDTH, 576, getStride(), getFrameBufferPointer()); +} + +bool CFrameBuffer::savePictureFromMem(const std::string & filename, const fb_pixel_t * const memp) +{ + struct rawHeader header; + uint16_t width, height; + int lfd; + + width = BACKGROUNDIMAGEWIDTH; + height = 576; + + header.width_lo = width & 0xFF; + header.width_hi = width >> 8; + header.height_lo = height & 0xFF; + header.height_hi = height >> 8; + header.transp = 0; + + lfd = open((iconBasePath + "/" + filename).c_str(), O_WRONLY | O_CREAT, 0644); + + if (lfd==-1) + { + printf("error while saving icon: %s/%s", iconBasePath.c_str(), filename.c_str() ); + return false; + } + + write(lfd, &header, sizeof(struct rawHeader)); + + write(lfd, memp, width * height * sizeof(fb_pixel_t)); + + close(lfd); + return true; +} + +bool CFrameBuffer::loadBackground(const std::string & filename, const unsigned char offset) +{ + if ((backgroundFilename == filename) && (background)) + return true; + + if (background) + delete[] background; + + background = new fb_pixel_t[BACKGROUNDIMAGEWIDTH * 576]; + + if (!loadPictureToMem(filename, BACKGROUNDIMAGEWIDTH, 576, 0, background)) + { + delete[] background; + background=0; + return false; + } + + if (offset != 0)//pic-offset + { + fb_pixel_t * bpos = background; + int pos = BACKGROUNDIMAGEWIDTH * 576; + while (pos > 0) + { + *bpos += offset; + bpos++; + pos--; + } + } + + fb_pixel_t * dest = background + BACKGROUNDIMAGEWIDTH * 576; + uint8_t * src = ((uint8_t * )background)+ BACKGROUNDIMAGEWIDTH * 576; + for (int i = 576 - 1; i >= 0; i--) + for (int j = BACKGROUNDIMAGEWIDTH - 1; j >= 0; j--) + { + dest--; + src--; + paintPixel(dest, *src); + } + backgroundFilename = filename; + + return true; +} + +bool CFrameBuffer::loadBackgroundPic(const std::string & filename, bool show) +{ + if ((backgroundFilename == filename) && (background)) + return true; + +//printf("loadBackgroundPic: %s\n", filename.c_str()); + if (background){ + delete[] background; + background = NULL; + } + background = g_PicViewer->getImage(iconBasePath + "/" + filename, BACKGROUNDIMAGEWIDTH, 576); + + if (background == NULL) { + background=0; + return false; + } + + backgroundFilename = filename; + if(show) { + useBackgroundPaint = true; + paintBackground(); + } + return true; +} +#endif +void CFrameBuffer::useBackground(bool ub) +{ + useBackgroundPaint = ub; + if(!useBackgroundPaint) { + delete[] background; + background=0; + } +} + +bool CFrameBuffer::getuseBackground(void) +{ + return useBackgroundPaint; +} + +void CFrameBuffer::saveBackgroundImage(void) +{ + if (backupBackground != NULL){ + delete[] backupBackground; + backupBackground = NULL; + } + backupBackground = background; + //useBackground(false); // <- necessary since no background is available + useBackgroundPaint = false; + background = NULL; +} + +void CFrameBuffer::restoreBackgroundImage(void) +{ + fb_pixel_t * tmp = background; + + if (backupBackground != NULL) + { + background = backupBackground; + backupBackground = NULL; + } + else + useBackground(false); // <- necessary since no background is available + + if (tmp != NULL){ + delete[] tmp; + tmp = NULL; + } +} + +void CFrameBuffer::paintBackgroundBoxRel(int x, int y, int dx, int dy) +{ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + if(!useBackgroundPaint) + { + paintBoxRel(x, y, dx, dy, backgroundColor); + } + else + { + uint8_t * fbpos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * bkpos = background + x + BACKGROUNDIMAGEWIDTH * y; + for(int count = 0;count < dy; count++) + { + memmove(fbpos, bkpos, dx * sizeof(fb_pixel_t)); + fbpos += stride; + bkpos += BACKGROUNDIMAGEWIDTH; + } + } + checkFbArea(x, y, dx, dy, false); +} + +void CFrameBuffer::paintBackground() +{ + if (!getActive()) + return; + + checkFbArea(0, 0, xRes, yRes, true); + if (useBackgroundPaint && (background != NULL)) + { + for (int i = 0; i < 576; i++) + memmove(((uint8_t *)getFrameBufferPointer()) + i * stride, (background + i * BACKGROUNDIMAGEWIDTH), BACKGROUNDIMAGEWIDTH * sizeof(fb_pixel_t)); + } + else + { + paintBoxRel(0, 0, xRes, yRes, backgroundColor); + } + checkFbArea(0, 0, xRes, yRes, false); +} + +void CFrameBuffer::SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) +{ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * bkpos = memp; + for (int count = 0; count < dy; count++) { + fb_pixel_t * dest = (fb_pixel_t *)pos; + for (int i = 0; i < dx; i++) + //*(dest++) = col; + *(bkpos++) = *(dest++); + pos += stride; + } +#if 0 //FIXME test to flush cache + if (ioctl(fd, 1, FB_BLANK_UNBLANK) < 0); +#endif + //RestoreScreen(x, y, dx, dy, memp); //FIXME +#if 0 + uint8_t * fbpos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * bkpos = memp; + for (int count = 0; count < dy; count++) + { + memmove(bkpos, fbpos, dx * sizeof(fb_pixel_t)); + fbpos += stride; + bkpos += dx; + } +#endif + checkFbArea(x, y, dx, dy, false); + +} + +void CFrameBuffer::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) +{ + if (!getActive()) + return; + + checkFbArea(x, y, dx, dy, true); + uint8_t * fbpos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t * bkpos = memp; + for (int count = 0; count < dy; count++) + { + memmove(fbpos, bkpos, dx * sizeof(fb_pixel_t)); + fbpos += stride; + bkpos += dx; + } + mark(x, y, x + dx, y + dy); + checkFbArea(x, y, dx, dy, false); +} +#if 0 +//never used +void CFrameBuffer::switch_signal (int signal) +{ + CFrameBuffer * thiz = CFrameBuffer::getInstance(); + if (signal == SIGUSR1) { + if (virtual_fb != NULL) + delete[] virtual_fb; + virtual_fb = new uint8_t[thiz->stride * thiz->yRes]; + thiz->active = false; + if (virtual_fb != NULL) + memmove(virtual_fb, thiz->lfb, thiz->stride * thiz->yRes); + ioctl(thiz->tty, VT_RELDISP, 1); + printf ("release display\n"); + } + else if (signal == SIGUSR2) { + ioctl(thiz->tty, VT_RELDISP, VT_ACKACQ); + thiz->active = true; + printf ("acquire display\n"); + thiz->paletteSet(NULL); + if (virtual_fb != NULL) + memmove(thiz->lfb, virtual_fb, thiz->stride * thiz->yRes); + else + memset(thiz->lfb, 0, thiz->stride * thiz->yRes); + } +} +#endif + +void CFrameBuffer::Clear() +{ + paintBackground(); + //memset(getFrameBufferPointer(), 0, stride * yRes); +} + +void CFrameBuffer::showFrame(const std::string & filename) +{ + std::string picture = std::string(ICONSDIR_VAR) + "/" + filename; + if (access(picture.c_str(), F_OK)) + picture = iconBasePath + "/" + filename; + if (filename.find("/", 0) != std::string::npos) + picture = filename; + + videoDecoder->ShowPicture(picture.c_str()); +} + +void CFrameBuffer::stopFrame() +{ + videoDecoder->StopPicture(); +} + +bool CFrameBuffer::Lock() +{ + if(locked) + return false; + locked = true; + return true; +} + +void CFrameBuffer::Unlock() +{ + locked = false; +} + +void * CFrameBuffer::int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp, bool alpha) +{ + unsigned long i; + unsigned int *fbbuff; + unsigned long count; + + if (!x || !y) { + printf("convertRGB2FB%s: Error: invalid dimensions (%luX x %luY)\n", + ((alpha) ? " (Alpha)" : ""), x, y); + return NULL; + } + + count = x * y; + + fbbuff = (unsigned int *) cs_malloc_uncached(count * sizeof(unsigned int)); + if(fbbuff == NULL) { + printf("convertRGB2FB%s: Error: cs_malloc_uncached\n", ((alpha) ? " (Alpha)" : "")); + return NULL; + } + + if (alpha) { + for(i = 0; i < count ; i++) + fbbuff[i] = ((rgbbuff[i*4+3] << 24) & 0xFF000000) | + ((rgbbuff[i*4] << 16) & 0x00FF0000) | + ((rgbbuff[i*4+1] << 8) & 0x0000FF00) | + ((rgbbuff[i*4+2]) & 0x000000FF); + } else { + switch (m_transparent) { + case CFrameBuffer::TM_BLACK: + for(i = 0; i < count ; i++) { + transp = 0; + if(rgbbuff[i*3] || rgbbuff[i*3+1] || rgbbuff[i*3+2]) + transp = 0xFF; + fbbuff[i] = (transp << 24) | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + } + break; + case CFrameBuffer::TM_INI: + for(i = 0; i < count ; i++) + fbbuff[i] = (transp << 24) | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + break; + case CFrameBuffer::TM_NONE: + default: + for(i = 0; i < count ; i++) + fbbuff[i] = 0xFF000000 | ((rgbbuff[i*3] << 16) & 0xFF0000) | ((rgbbuff[i*3+1] << 8) & 0xFF00) | (rgbbuff[i*3+2] & 0xFF); + break; + } + } + return (void *) fbbuff; +} + +void * CFrameBuffer::convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp) +{ + return int_convertRGB2FB(rgbbuff, x, y, transp, false); +} + +void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y) +{ + return int_convertRGB2FB(rgbbuff, x, y, 0, true); +} + +void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool /*transp*/, uint32_t unscaled_w, uint32_t unscaled_h) //NI +{ + int xc, yc; + + xc = (width > xRes) ? xRes : width; + yc = (height > yRes) ? yRes : height; + +//FIXME +#if 0 + //NI + if(unscaled_w != 0 && (int)unscaled_w < xc) + xc = unscaled_w; + if(unscaled_h != 0 && (int)unscaled_h < yc) + yc = unscaled_h; +#endif + + fb_pixel_t* data = (fb_pixel_t *) fbbuff; + + uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + xoff * sizeof(fb_pixel_t) + stride * yoff; + fb_pixel_t * d2; + + for (int count = 0; count < yc; count++ ) { + fb_pixel_t *pixpos = &data[(count + yp) * width]; + d2 = (fb_pixel_t *) d; + for (int count2 = 0; count2 < xc; count2++ ) { + fb_pixel_t pix = *(pixpos + xp); + if ((pix & 0xff000000) == 0xff000000) + *d2 = pix; + else { + uint8_t *in = (uint8_t *)(pixpos + xp); + uint8_t *out = (uint8_t *)d2; + int a = in[3]; /* TODO: big/little endian */ + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + in++; out++; + *out = (*out + ((*in - *out) * a) / 256); + } + d2++; + pixpos++; + } + d += stride; + } +} + +void CFrameBuffer::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +{ + if(width <1 || height <1 || !boxBuf ) + return; + + uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; + uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; + + uint32_t swidth = stride / sizeof(fb_pixel_t); + fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * yoff); + fb_pixel_t* data = (fb_pixel_t*)boxBuf; + + uint32_t line = 0; + while (line < yc) { + fb_pixel_t *pixpos = &data[line * xc]; + for (uint32_t pos = xoff; pos < xoff + xc; pos++) { + //don't paint backgroundcolor (*pixpos = 0x00000000) + if (*pixpos) + *(fbp + pos) = *pixpos; + pixpos++; + } + fbp += swidth; + line++; + } +} + +void CFrameBuffer::displayRGB(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, bool clearfb, int transp) +{ + void *fbbuff = NULL; + + if(rgbbuff == NULL) + return; + + /* correct panning */ + if(x_pan > x_size - (int)xRes) x_pan = 0; + if(y_pan > y_size - (int)yRes) y_pan = 0; + + /* correct offset */ + if(x_offs + x_size > (int)xRes) x_offs = 0; + if(y_offs + y_size > (int)yRes) y_offs = 0; + + /* blit buffer 2 fb */ + fbbuff = convertRGB2FB(rgbbuff, x_size, y_size, transp); + if(fbbuff==NULL) + return; + + /* ClearFB if image is smaller */ + /* if(x_size < (int)xRes || y_size < (int)yRes) */ + if(clearfb) + CFrameBuffer::getInstance()->Clear(); + + blit2FB(fbbuff, x_size, y_size, x_offs, y_offs, x_pan, y_pan); + cs_free_uncached(fbbuff); +} + +// ## AudioMute / Clock ###################################### + +void CFrameBuffer::setFbArea(int element, int _x, int _y, int _dx, int _dy) +{ + if (_x == 0 && _y == 0 && _dx == 0 && _dy == 0) { + // delete area + for (fbarea_iterator_t it = v_fbarea.begin(); it != v_fbarea.end(); ++it) { + if (it->element == element) { + v_fbarea.erase(it); + break; + } + } + if (v_fbarea.empty()) { + fbAreaActiv = false; + } + } + else { + // change area + bool found = false; + for (unsigned int i = 0; i < v_fbarea.size(); i++) { + if (v_fbarea[i].element == element) { + v_fbarea[i].x = _x; + v_fbarea[i].y = _y; + v_fbarea[i].dx = _dx; + v_fbarea[i].dy = _dy; + found = true; + break; + } + } + // set new area + if (!found) { + fb_area_t area; + area.x = _x; + area.y = _y; + area.dx = _dx; + area.dy = _dy; + area.element = element; + v_fbarea.push_back(area); + } + fbAreaActiv = true; + } +} + +int CFrameBuffer::checkFbAreaElement(int _x, int _y, int _dx, int _dy, fb_area_t *area) +{ + if (fb_no_check) + return FB_PAINTAREA_MATCH_NO; + + if (_y > area->y + area->dy) + return FB_PAINTAREA_MATCH_NO; + if (_x + _dx < area->x) + return FB_PAINTAREA_MATCH_NO; + if (_x > area->x + area->dx) + return FB_PAINTAREA_MATCH_NO; + if (_y + _dy < area->y) + return FB_PAINTAREA_MATCH_NO; + return FB_PAINTAREA_MATCH_OK; +} + +bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) +{ + if (v_fbarea.empty()) + return true; + + static bool firstMutePaint = true; + + for (unsigned int i = 0; i < v_fbarea.size(); i++) { + int ret = checkFbAreaElement(_x, _y, _dx, _dy, &v_fbarea[i]); + if (ret == FB_PAINTAREA_MATCH_OK) { + switch (v_fbarea[i].element) { + case FB_PAINTAREA_MUTEICON1: + if (!do_paint_mute_icon) + break; +// waitForIdle(); + fb_no_check = true; + if (prev) { + firstMutePaint = false; + CAudioMute::getInstance()->hide(); + } + else { + if (!firstMutePaint) + CAudioMute::getInstance()->paint(); + } + fb_no_check = false; + break; + default: + break; + } + } + } + + return true; +} + +/* dummy, can be implemented in CFbAccel */ +void CFrameBuffer::mark(int , int , int , int ) +{ +} diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h new file mode 100644 index 000000000..892e8b2fd --- /dev/null +++ b/src/driver/fb_generic.h @@ -0,0 +1,330 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __framebuffer__ +#define __framebuffer__ +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#define fb_pixel_t uint32_t + +typedef struct fb_var_screeninfo t_fb_var_screeninfo; + +typedef struct gradientData_t +{ + fb_pixel_t* gradientBuf; + fb_pixel_t* boxBuf; + bool direction; + int mode; + int x; + int dx; +} gradientData_struct_t; + +#define CORNER_NONE 0x0 +#define CORNER_TOP_LEFT 0x1 +#define CORNER_TOP_RIGHT 0x2 +#define CORNER_TOP 0x3 +#define CORNER_BOTTOM_RIGHT 0x4 +#define CORNER_RIGHT 0x6 +#define CORNER_BOTTOM_LEFT 0x8 +#define CORNER_LEFT 0x9 +#define CORNER_BOTTOM 0xC +#define CORNER_ALL 0xF + +#define FADE_TIME 5000 +#define FADE_STEP 5 +#define FADE_RESET 0xFFFF + +#define WINDOW_SIZE_MAX 100 // % +#define WINDOW_SIZE_MIN 50 // % +#define WINDOW_SIZE_MIN_FORCED 80 // % +#define ConnectLineBox_Width 16 // px + +/** Ausfuehrung als Singleton */ +class CFrameBuffer : public sigc::trackable +{ + protected: + + CFrameBuffer(); + OpenThreads::Mutex mutex; + + struct rgbData + { + uint8_t r; + uint8_t g; + uint8_t b; + } __attribute__ ((packed)); + + struct rawHeader + { + uint8_t width_lo; + uint8_t width_hi; + uint8_t height_lo; + uint8_t height_hi; + uint8_t transp; + } __attribute__ ((packed)); + + struct rawIcon + { + uint16_t width; + uint16_t height; + uint8_t transp; + fb_pixel_t * data; + }; + + std::string iconBasePath; + + int fd, tty; + fb_pixel_t * lfb; + fb_pixel_t * lbb; + int available; + fb_pixel_t * background; + fb_pixel_t * backupBackground; + fb_pixel_t backgroundColor; + std::string backgroundFilename; + bool useBackgroundPaint; + unsigned int xRes, yRes, stride, bpp; + t_fb_var_screeninfo screeninfo, oldscreen; + fb_cmap cmap; + __u16 red[256], green[256], blue[256], trans[256]; + + void paletteFade(int i, __u32 rgb1, __u32 rgb2, int level); + + int kd_mode; + struct vt_mode vt_mode; + bool active; + bool fb_no_check; + static void switch_signal (int); + fb_fix_screeninfo fix; + bool locked; + std::map icon_cache; + int cache_size; + + int *q_circle; + bool corner_tl, corner_tr, corner_bl, corner_br; + + void * int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp, bool alpha); + int m_transparent_default, m_transparent; + // Unlocked versions (no mutex) + void paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col); + void paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col); + + inline void paintHLineRelInternal2Buf(const int& x, const int& dx, const int& y, const int& box_dx, const fb_pixel_t& col, fb_pixel_t* buf); + void paintShortHLineRelInternal(const int& x, const int& dx, const int& y, const fb_pixel_t& col); + int limitRadius(const int& dx, const int& dy, int& radius); + void setCornerFlags(const int& type); + void initQCircle(); + inline int calcCornersOffset(const int& dy, const int& line, const int& radius, const int& type) { int ofs = 0; calcCorners(&ofs, NULL, NULL, dy, line, radius, type); return ofs; } + bool calcCorners(int *ofs, int *ofl, int *ofr, const int& dy, const int& line, const int& radius, const int& type); + + public: + ///gradient direction + enum { + gradientHorizontal, + gradientVertical + }; + + enum { + pbrg_noOption = 0x00, + pbrg_noPaint = 0x01, + pbrg_noFree = 0x02 + }; + + fb_pixel_t realcolor[256]; + + virtual ~CFrameBuffer(); + + static CFrameBuffer* getInstance(); + + virtual void init(const char * const fbDevice = "/dev/fb0"); + virtual int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + + + int getFileHandle() const; //only used for plugins (games) !! + t_fb_var_screeninfo *getScreenInfo(); + + fb_pixel_t * getFrameBufferPointer() const; // pointer to framebuffer + virtual fb_pixel_t * getBackBufferPointer() const; // pointer to backbuffer + virtual unsigned int getStride() const; // size of a single line in the framebuffer (in bytes) + unsigned int getScreenWidth(bool real = false); + unsigned int getScreenHeight(bool real = false); + unsigned int getScreenWidthRel(bool force_small = false); + unsigned int getScreenHeightRel(bool force_small = false); + unsigned int getScreenX(); + unsigned int getScreenY(); + + bool getActive() const; // is framebuffer active? + void setActive(bool enable); // is framebuffer active? +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS + virtual void setupGXA() {}; + virtual void add_gxa_sync_marker() {}; +#endif + + void setTransparency( int tr = 0 ); + virtual void setBlendMode(uint8_t mode = 1); + virtual void setBlendLevel(int level); + + //Palette stuff + void setAlphaFade(int in, int num, int tr); + void paletteGenFade(int in, __u32 rgb1, __u32 rgb2, int num, int tr=0); + void paletteSetColor(int i, __u32 rgb, int tr); + void paletteSet(struct fb_cmap *map = NULL); + + //paint functions + inline void paintPixel(fb_pixel_t * const dest, const uint8_t color) const + { + *dest = realcolor[color]; + }; + virtual void paintPixel(int x, int y, const fb_pixel_t col); + + fb_pixel_t* paintBoxRel2Buf(const int dx, const int dy, const int w_align, const int offs_align, const fb_pixel_t col, fb_pixel_t* buf = NULL, int radius = 0, int type = CORNER_ALL); + fb_pixel_t* paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, gradientData_t *gradientData, int radius = 0, int type = CORNER_ALL); + + virtual void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col) { paintBoxRel(xa, ya, xb - xa, yb - ya, col); } + inline void paintBox(int xa, int ya, int xb, int yb, const fb_pixel_t col, int radius, int type) { paintBoxRel(xa, ya, xb - xa, yb - ya, col, radius, type); } + + void paintBoxFrame(const int x, const int y, const int dx, const int dy, const int px, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); + + inline void paintVLine(int x, int ya, int yb, const fb_pixel_t col) { paintVLineRel(x, ya, yb - ya, col); } + virtual void paintVLineRel(int x, int y, int dy, const fb_pixel_t col); + + inline void paintHLine(int xa, int xb, int y, const fb_pixel_t col) { paintHLineRel(xa, xb - xa, y, col); } + virtual void paintHLineRel(int x, int dx, int y, const fb_pixel_t col); + + void setIconBasePath(const std::string & iconPath); + std::string getIconBasePath(){return iconBasePath;}; + std::string getIconPath(std::string icon_name, std::string file_type = "png"); + + void getIconSize(const char * const filename, int* width, int *height); + /* h is the height of the target "window", if != 0 the icon gets centered in that window */ + bool paintIcon (const std::string & filename, const int x, const int y, + const int h = 0, const unsigned char offset = 1, bool paint = true, bool paintBg = false, const fb_pixel_t colBg = 0); + bool paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset = 0); + void loadPal (const std::string & filename, const unsigned char offset = 0, const unsigned char endidx = 255); + + bool loadPicture2Mem (const std::string & filename, fb_pixel_t * const memp); + bool loadPicture2FrameBuffer(const std::string & filename); + bool loadPictureToMem (const std::string & filename, const uint16_t width, const uint16_t height, const uint16_t stride, fb_pixel_t * const memp); + bool savePictureFromMem (const std::string & filename, const fb_pixel_t * const memp); + + int getBackgroundColor() { return backgroundColor;} + void setBackgroundColor(const fb_pixel_t color); + bool loadBackground(const std::string & filename, const unsigned char col = 0); + void useBackground(bool); + bool getuseBackground(void); + + void saveBackgroundImage(void); // <- implies useBackground(false); + void restoreBackgroundImage(void); + + void paintBackgroundBoxRel(int x, int y, int dx, int dy); + inline void paintBackgroundBox(int xa, int ya, int xb, int yb) { paintBackgroundBoxRel(xa, ya, xb - xa, yb - ya); } + + void paintBackground(); + + void SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp); + void RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp); + + void Clear(); + void showFrame(const std::string & filename); + void stopFrame(); + bool loadBackgroundPic(const std::string & filename, bool show = true); + bool Lock(void); + void Unlock(void); + bool Locked(void) { return locked; }; + virtual void waitForIdle(const char* func=NULL); + void* convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp = 0xFF); + void* convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y); + void displayRGB(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, bool clearfb = true, int transp = 0xFF); + virtual void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + + virtual void mark(int x, int y, int dx, int dy); + + //NI + void clearIconCache(); + + enum + { + TM_EMPTY = 0, + TM_NONE = 1, + TM_BLACK = 2, + TM_INI = 3 + }; + void SetTransparent(int t){ m_transparent = t; } + void SetTransparentDefault(){ m_transparent = m_transparent_default; } + +// ## AudioMute / Clock ###################################### + private: + enum { + FB_PAINTAREA_MATCH_NO, + FB_PAINTAREA_MATCH_OK + }; + + typedef struct fb_area_t + { + int x; + int y; + int dx; + int dy; + int element; + } fb_area_struct_t; + + bool fbAreaActiv; + typedef std::vector v_fbarea_t; + typedef v_fbarea_t::iterator fbarea_iterator_t; + v_fbarea_t v_fbarea; + bool do_paint_mute_icon; + + bool _checkFbArea(int _x, int _y, int _dx, int _dy, bool prev); + int checkFbAreaElement(int _x, int _y, int _dx, int _dy, fb_area_t *area); + + public: + enum { + FB_PAINTAREA_INFOCLOCK, + FB_PAINTAREA_MUTEICON1, + FB_PAINTAREA_MUTEICON2, + + FB_PAINTAREA_MAX + }; + + inline bool checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) { return (fbAreaActiv && !fb_no_check) ? _checkFbArea(_x, _y, _dx, _dy, prev) : true; } + void setFbArea(int element, int _x=0, int _y=0, int _dx=0, int _dy=0); + void fbNoCheck(bool noCheck) { fb_no_check = noCheck; } + void doPaintMuteIcon(bool mode) { do_paint_mute_icon = mode; } + void blit(void) {} + sigc::signal OnAfterSetPallette; + const char *fb_name; +}; + +#endif diff --git a/src/driver/fb_window.h b/src/driver/fb_window.h index 5d9efc0f7..f0a991669 100644 --- a/src/driver/fb_window.h +++ b/src/driver/fb_window.h @@ -21,10 +21,9 @@ #ifndef __fb_window_h__ #define __fb_window_h__ +#include -#include -#include - +class CFrameBuffer; class CFBWindow { public: @@ -47,7 +46,7 @@ class CFBWindow void paintVLineRel(int _x, int _y, int _dy, const color_t _col); void paintHLineRel(int _x, int _dx, int _y, const color_t _col); bool paintIcon(const char * const _filename, const int _x, const int _y, const int _h = 0, const color_t _offset = 1); - void RenderString(const font_t _font, const int _x, const int _y, const int _width, const char * const _text, const color_t _color, const int _boxheight = 0, const unsigned int _flags = Font::IS_UTF8); + void RenderString(const font_t _font, const int _x, const int _y, const int _width, const char * const _text, const color_t _color, const int _boxheight = 0, const unsigned int _flags = 1 /*Font::IS_UTF8*/); fb_pixel_t* saveScreen(const int _x, const int _y, const int _dx, const int _dy); void restoreScreen(const int _x, const int _y, const int _dx, const int _dy, fb_pixel_t* buf, bool delBuf); diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 36f4b1736..99cd2e8f4 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -33,6 +33,7 @@ #include #include FT_FREETYPE_H +#include #include #include diff --git a/src/driver/fontrenderer.h b/src/driver/fontrenderer.h index 416ca6da1..ed4506e13 100644 --- a/src/driver/fontrenderer.h +++ b/src/driver/fontrenderer.h @@ -28,6 +28,7 @@ #include #include +#include #include #include FT_FREETYPE_H @@ -36,9 +37,7 @@ #include FT_CACHE_IMAGE_H #include FT_CACHE_SMALL_BITMAPS_H -#include "framebuffer.h" - - +class CFrameBuffer; class FBFontRenderClass; class Font { diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 7bfee346a..92f61fbbb 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -415,11 +415,6 @@ CFrameBuffer::~CFrameBuffer() } #if 0 -#ifdef RETURN_FROM_GRAPHICS_MODE - if (-1 == ioctl(tty,KDSETMODE, kd_mode)) - perror("ioctl KDSETMODE"); -#endif - if (-1 == ioctl(tty,VT_SETMODE, &vt_mode)) perror("ioctl VT_SETMODE"); diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index 103ee6d01..08fa7f038 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -21,7 +21,7 @@ Boston, MA 02110-1301, USA. */ -#include "framebuffer_ng.h" +#include "fb_generic.h" #if 0 #ifndef __framebuffer__ diff --git a/src/driver/moviecut.h b/src/driver/moviecut.h index f95aa58f4..4202238af 100644 --- a/src/driver/moviecut.h +++ b/src/driver/moviecut.h @@ -22,8 +22,8 @@ #include #include -#include +class CFrameBuffer; class CMovieCut { private: diff --git a/src/driver/pictureviewer/bmp.cpp b/src/driver/pictureviewer/bmp.cpp index 966517f07..cef39838b 100644 --- a/src/driver/pictureviewer/bmp.cpp +++ b/src/driver/pictureviewer/bmp.cpp @@ -1,3 +1,4 @@ +#include #include "pv_config.h" #ifdef FBV_SUPPORT_BMP #include "pictureviewer.h" diff --git a/src/driver/pictureviewer/crw.cpp b/src/driver/pictureviewer/crw.cpp index be7c0783c..e081aba57 100644 --- a/src/driver/pictureviewer/crw.cpp +++ b/src/driver/pictureviewer/crw.cpp @@ -1,3 +1,4 @@ +#include #include "pv_config.h" #include #include diff --git a/src/driver/pictureviewer/gif.cpp b/src/driver/pictureviewer/gif.cpp index 0e082b902..7502e9430 100644 --- a/src/driver/pictureviewer/gif.cpp +++ b/src/driver/pictureviewer/gif.cpp @@ -1,3 +1,4 @@ +#include #include "pv_config.h" #include diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 08e5980b8..eeb4cbfb6 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -644,8 +644,13 @@ bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, //NI bool CPictureViewer::DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp) { - int fb_w = width; - int fb_h = height; + if(width < 1 || height < 1){ + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: width %i height %i \n", __func__, __LINE__, width, height); + return false; + } + + int unscaled_w = width; + int unscaled_h = height; CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); if (transp > CFrameBuffer::TM_EMPTY) @@ -658,7 +663,7 @@ bool CPictureViewer::DisplayImage_unscaled(const std::string & name, int posx, i frameBuffer->SetTransparentDefault(); if(data) { - frameBuffer->blit2FB_unscaled(data, width, height, posx, posy, fb_w, fb_h); + frameBuffer->blit2FB(data, width, height, posx, posy, 0, 0, transp, unscaled_w, unscaled_h); cs_free_uncached(data); return true; } diff --git a/src/driver/pictureviewer/pictureviewer.h b/src/driver/pictureviewer/pictureviewer.h index 232dce5fc..100441b6f 100644 --- a/src/driver/pictureviewer/pictureviewer.h +++ b/src/driver/pictureviewer/pictureviewer.h @@ -30,7 +30,7 @@ #include #include /* printf */ #include /* gettimeofday */ -#include +#include class CPictureViewer { struct cformathandler @@ -64,7 +64,7 @@ class CPictureViewer void Cleanup(); void SetVisible(int startx, int endx, int starty, int endy); static double m_aspect_ratio_correction; - bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); + bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=0 /*CFrameBuffer::TM_EMPTY*/); // bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height); bool GetLogoName(const uint64_t& channel_id, const std::string& ChanName, std::string & name, int *width = NULL, int *height = NULL); fb_pixel_t * getImage (const std::string & name, int width, int height); @@ -76,7 +76,7 @@ class CPictureViewer void getSupportedImageFormats(std::vector& erw); //NI - bool DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); + bool DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp=0 /*CFrameBuffer::TM_EMPTY*/); private: CFormathandler *fh_root; diff --git a/src/driver/pictureviewer/png.cpp b/src/driver/pictureviewer/png.cpp index a87ad6fa3..ab0fb7155 100644 --- a/src/driver/pictureviewer/png.cpp +++ b/src/driver/pictureviewer/png.cpp @@ -1,3 +1,4 @@ +#include #include "pv_config.h" #ifdef FBV_SUPPORT_PNG diff --git a/src/driver/radiotext.h b/src/driver/radiotext.h index 0a2b64ae9..d5758e48d 100644 --- a/src/driver/radiotext.h +++ b/src/driver/radiotext.h @@ -46,9 +46,6 @@ #ifndef __RADIO_AUDIO_H #define __RADIO_AUDIO_H -#include -#include - #if 0 #include #include diff --git a/src/driver/record.h b/src/driver/record.h index 34c3378e2..e4481205a 100644 --- a/src/driver/record.h +++ b/src/driver/record.h @@ -63,6 +63,7 @@ extern "C" { #define TSHIFT_MODE_REWIND 3 class CFrontend; +class CZapitChannel; //FIXME enum record_error_msg_t diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index ede15cb12..5f3f14f69 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -78,7 +78,7 @@ bool CScreenShot::GetData() bool res = false; mutex.lock(); -#ifdef USE_NEVIS_GXA +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS CFrameBuffer::getInstance()->setActive(false); #endif if (videoDecoder->getBlank()) @@ -87,7 +87,7 @@ bool CScreenShot::GetData() res = videoDecoder->GetScreenImage(pixel_data, xres, yres, get_video, get_osd, scale_to_video); #endif -#ifdef USE_NEVIS_GXA +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS /* sort of hack. GXA used to transfer/convert live image to RGB, * so setup GXA back */ CFrameBuffer::getInstance()->setupGXA(); diff --git a/src/driver/volume.h b/src/driver/volume.h index 430ed7444..c01f9293b 100644 --- a/src/driver/volume.h +++ b/src/driver/volume.h @@ -26,9 +26,9 @@ #ifndef __CVOLUME__ #define __CVOLUME__ -#include #include +class CFramebuffer; class CVolume : public CChangeObserver { private: diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h index 297f5605a..7905d6e1c 100644 --- a/src/gui/audioplayer.h +++ b/src/gui/audioplayer.h @@ -34,7 +34,6 @@ #define __audioplayergui__ -#include #include #include #include @@ -53,6 +52,7 @@ typedef std::set CPosList; typedef std::map CTitle2Pos; typedef std::pair CTitle2PosItem; +class CFrameBuffer; class CAudiofileExt : public CAudiofile { public: diff --git a/src/gui/bedit/bouqueteditor_bouquets.h b/src/gui/bedit/bouqueteditor_bouquets.h index 256bd25bb..0fa55f470 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.h +++ b/src/gui/bedit/bouqueteditor_bouquets.h @@ -32,7 +32,6 @@ #ifndef __bouqueteditor_bouquets__ #define __bouqueteditor_bouquets__ -#include #include #include @@ -42,6 +41,7 @@ #include #include +class CFrameBuffer; /* class for handling when bouquets changed. */ /* This class should be a temporarily work around */ /* and should be replaced by standard neutrino event handlers */ diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h index d13b9aa74..09394fc64 100644 --- a/src/gui/bedit/bouqueteditor_channels.h +++ b/src/gui/bedit/bouqueteditor_channels.h @@ -33,7 +33,6 @@ #ifndef __bouqueteditor_channels__ #define __bouqueteditor_channels__ -#include #include #include #include @@ -43,6 +42,7 @@ #include #include +class CFrameBuffer; class CBEChannelWidget : public CMenuTarget, public CListHelpers { diff --git a/src/gui/bedit/bouqueteditor_chanselect.h b/src/gui/bedit/bouqueteditor_chanselect.h index a4d2ccaeb..91ed9fdb3 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.h +++ b/src/gui/bedit/bouqueteditor_chanselect.h @@ -32,7 +32,6 @@ #ifndef __bouqueteditor_chanselect__ #define __bouqueteditor_chanselect__ -#include #include #include #include diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index bc5a1daea..3c6aa9112 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gui/bookmarkmanager.h b/src/gui/bookmarkmanager.h index 9003c71ca..8e996895c 100644 --- a/src/gui/bookmarkmanager.h +++ b/src/gui/bookmarkmanager.h @@ -39,12 +39,12 @@ #include #include -#include #include #define MAXBOOKMARKS 10 #define BOOKMARKFILE CONFIGDIR "/bookmarks" +class CFramebuffer; class CBookmark { private: diff --git a/src/gui/bouquetlist.h b/src/gui/bouquetlist.h index 0682242c2..04043e34e 100644 --- a/src/gui/bouquetlist.h +++ b/src/gui/bouquetlist.h @@ -36,12 +36,12 @@ #include #include -#include #include #include #include +class CFrameBuffer; typedef enum bouquetSwitchMode { diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index d27ca88cc..7f8cf6b99 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/channellist.h b/src/gui/channellist.h index 2a4058bff..aa9933030 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -33,7 +33,6 @@ Boston, MA 02110-1301, USA. */ -#include #include #include #include @@ -65,6 +64,7 @@ enum { CHANLIST_NO_RESTORE = -4 }; +class CFrameBuffer; class CBouquet; class CChannelList : public CListHelpers diff --git a/src/gui/color.cpp b/src/gui/color.cpp index cbc0873e0..519674667 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -37,6 +37,8 @@ #include #include +#include + #ifndef FLT_EPSILON #define FLT_EPSILON 1E-5 #endif diff --git a/src/gui/components/cc_draw.h b/src/gui/components/cc_draw.h index a7d442e86..a144433ec 100644 --- a/src/gui/components/cc_draw.h +++ b/src/gui/components/cc_draw.h @@ -29,6 +29,7 @@ #include "cc_signals.h" #include "cc_timer.h" #include +#include #include #include diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 7442352e7..dd414b5fb 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -680,20 +680,3 @@ bool CComponentsForm::enableColBodyGradient(const int& enable_mode, const fb_pix } return false; } - -void CComponentsForm::forceItemsPaint(bool force) -{ - for (size_t i = 0; i < v_cc_items.size(); i++){ - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] found item type = [%d] \033[0m\n", __func__, __LINE__, v_cc_items[i]->getItemType()); - if (v_cc_items[i]->getItemType() == CC_ITEMTYPE_TEXT){ - CComponentsText* text = static_cast (v_cc_items[i]); - text->forceTextPaint(force); - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] force repaint of item type CC_ITEMTYPE_TEXT [%u] content [%s]\033[0m\n", __func__, __LINE__, i, text->getText().c_str()); - } - if (v_cc_items[i]->getItemType() == CC_ITEMTYPE_LABEL){ - CComponentsLabel* label = static_cast (v_cc_items[i]); - label ->forceTextPaint(force); - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] force repaint of item type CC_ITEMTYPE_LABEL [%u] content [%s]\033[0m\n", __func__, __LINE__, i, label->getText().c_str()); - } - } -} diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index b9cab7934..3561e495a 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -65,13 +65,6 @@ class CComponentsForm : public CComponentsItem const fb_pixel_t& color_body, const fb_pixel_t& color_shadow); - ///force repaint of all possible text items - void forceItemsPaint(bool force); - ///slot for background paint event, reserved for forceItemsPaint() - sigc::slot0 sl_items_repaint; - ///slot for repaint event, reserved for actions before repaint if paint() already was done. - sigc::slot0 sl_form_repaint; - public: CComponentsForm( const int x_pos = 0, const int y_pos = 0, const int w = 800, const int h = 600, CComponentsForm *parent = NULL, @@ -223,6 +216,9 @@ class CComponentsForm : public CComponentsItem virtual bool clearPaintCache(); ///cleanup old gradient buffers include from sub items, returns true if any gradient buffer data was removed virtual bool clearFbGradientData(); + + ///slot for repaint event, reserved for actions before repaint if paint() already was done. + sigc::slot0 sl_form_repaint; }; #endif diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index 3ec7ce20b..b7bba8f93 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -32,6 +32,7 @@ #include #include #include "cc_frm_button.h" +#include using namespace std; diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index fcce3647e..b52180456 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -30,12 +30,13 @@ #include "cc_frm_clock.h" #include -#include + #include #include #include #include #include +#include using namespace std; @@ -100,9 +101,6 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, //init slot for running clock cl_sl_show = sigc::mem_fun0(*this, &CComponentsFrmClock::ShowTime); - //init slot to ensure paint segments after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsFrmClock::forceItemsPaint), true); - //run clock already if required if (activ) startClock(); @@ -300,11 +298,6 @@ void CComponentsFrmClock::initCCLockItems() x_lbl += v_cc_items[i-1]->getWidth(); v_cc_items[i]->setPos(x_lbl, y_lbl); } - - if(!OnAfterPaintBg.empty()) - OnAfterPaintBg.clear(); - //init slot to handle repaint of segments if background was repainted - OnAfterPaintBg.connect(sl_items_repaint); } diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 420ea2775..864336d91 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -28,8 +28,8 @@ #include #include #include "cc_frm_ext_text.h" +#include -#include #define DEF_HEIGHT 27 #define DEF_LABEL_WIDTH_PERCENT 30 @@ -114,9 +114,6 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p } ccx_label_align = ccx_text_align = CTextBox::NO_AUTO_LINEBREAK; - //init slot to ensure paint text items after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsExtTextForm::forceItemsPaint), true); - initParent(parent); } @@ -222,11 +219,6 @@ void CComponentsExtTextForm::initCCTextItems() { initLabel(); initText(); - - if(!OnAfterPaintBg.empty()) - OnAfterPaintBg.clear(); - //init slot to handle repaint of text if background was repainted - OnAfterPaintBg.connect(sl_items_repaint); } void CComponentsExtTextForm::setLabelWidthPercent(const uint8_t& percent_val) diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 20c11dce3..f125231f6 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -29,6 +29,7 @@ #include #include "cc_frm_footer.h" #include +#include using namespace std; diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 3a0f530a4..429f468d0 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -30,8 +30,8 @@ #include #include "cc_frm_header.h" #include +#include -#include using namespace std; @@ -136,10 +136,6 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_cl_sec_format = cch_cl_format; cch_cl_enable_run = false; - //init slot to ensure paint items after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::forceItemsPaint), true); - OnAfterPaintBg.connect(sl_items_repaint); - //init slot before re paint of header, paint() is already done sl_form_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::kill), col_body, -1, CC_FBDATA_TYPES, false); OnBeforeRePaint.connect(sl_form_repaint); diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index 28728c6bf..018ad066f 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -30,6 +30,8 @@ #include #include #include "cc_frm_signalbars.h" +#include +#include #include #define SB_MIN_HEIGHT 12 diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index 69ce46e09..3a4cde963 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -36,7 +36,6 @@ #include #include #include -#include #include /// Basic class for signalbars @@ -48,6 +47,7 @@ CSignalBar() and their sub classes based up CComponentsForm() and are usable lik CSignalBar() is intended to show signal rate. */ +class CFrontend; class CSignalBar : public CComponentsForm, public CCTextScreen { public: diff --git a/src/gui/components/cc_item.h b/src/gui/components/cc_item.h index dad19d96e..4f5f42da5 100644 --- a/src/gui/components/cc_item.h +++ b/src/gui/components/cc_item.h @@ -27,10 +27,12 @@ #include "cc_types.h" #include "cc_base.h" #include "cc_draw.h" +#include "cc_signals.h" #include #include #include + class CComponentsItem : public CComponents { protected: diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 1abad278a..a303038bc 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -34,6 +34,7 @@ #include #include #include +#include extern CPictureViewer * g_PicViewer; diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index 435065fc9..0781b446e 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -34,7 +34,6 @@ #include "cc_base.h" #include "cc_item.h" #include -#include #define NO_SCALE false #define SCALE true diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 67ee50401..4ca37258c 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -31,10 +31,12 @@ #include #include #include "cc_item_text.h" +#include #include #include #include #include + using namespace std; //sub class CComponentsText from CComponentsItem @@ -273,6 +275,12 @@ bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int void CComponentsText::paintText(bool do_save_bg) { + if (cc_parent){ + if(!cc_parent->OnAfterPaintBg.empty()) + cc_parent->OnAfterPaintBg.clear(); + //init slot to handle repaint of text if background was repainted + cc_parent->OnAfterPaintBg.connect(sigc::bind(sigc::mem_fun(*this, &CComponentsText::forceTextPaint), true)); + } initCCText(); if (!is_painted) paintInit(do_save_bg); diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 1de07d08c..5e5d53d48 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -196,7 +196,6 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///force paint of text even if text was changed or not virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;}; - ///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties virtual CTextBox* getCTextBoxObject() { return ct_textbox; }; diff --git a/src/gui/components/cc_signals.h b/src/gui/components/cc_signals.h index c3c60727e..5c3fdaca1 100644 --- a/src/gui/components/cc_signals.h +++ b/src/gui/components/cc_signals.h @@ -88,6 +88,7 @@ class CYourClass : sigc::trackable //<- not forget, requierd by destructor! #define __CC_SIGNALS_H__ #include +#include #include class CComponentsSignals : public sigc::trackable diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 12a42cf7c..c76520bb8 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -26,12 +26,12 @@ #ifndef __CC_TYPES__ #define __CC_TYPES__ -#include #include -#include #include #include +struct gradientData_t; +class Font; class CComponentsForm; class CComponentsScrollBar; diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 5d92fa138..1db13d966 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -34,11 +34,11 @@ #define __dboxinfo__ #include -#include -#include #include #include +class Font; +class CFrameBuffer; class CDBoxInfoWidget : public CMenuTarget { private: diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 9b2f2026b..a5e075a91 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index ccab231f5..6f1cb0e93 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 0e2bc0801..9477c2f3e 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -33,13 +33,10 @@ #ifndef __epgview__ #define __epgview__ -#include #include -#include #include #include //NI -#include #include #include "widget/menue.h" @@ -51,6 +48,7 @@ #define BIG_FONT_FAKTOR 1.5 +class CFrameBuffer; class CEpgData { private: diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 8c88a47cc..670577ef6 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 2c47b63e3..c0c15af52 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -30,13 +30,10 @@ #include #include -#include -#include #include #include #include -#include "color.h" #include "infoviewer.h" #include "widget/menue.h" @@ -44,7 +41,7 @@ #include - +class CFramebuffer; class CEventList : public CListHelpers { // Eventfinder start diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 90fadd48f..9b43c9fbe 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index 16e13b916..3d458125d 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -38,11 +38,8 @@ #endif #include -#include -#include #include -#include #include #include @@ -58,6 +55,8 @@ bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str, bool allow_tmp = false); bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng, bool allow_tmp = false); +class Font; +class CFrameBuffer; /** * Converts input of numeric keys to SMS style char input. */ diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 24cf5db2e..a392c45cd 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -1393,12 +1393,12 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) if (n < 0) return menu_return::RETURN_NONE; - const char hdidle[] = "/sbin/hd-idle"; - bool have_hdidle = !access(hdidle, X_OK); - if (g_settings.hdd_sleep > 0 && g_settings.hdd_sleep < 60) g_settings.hdd_sleep = 60; + const char hdidle[] = "/sbin/hd-idle"; + bool have_hdidle = !access(hdidle, X_OK); + if (have_hdidle) { system("kill $(pidof hd-idle)"); int sleep_seconds = g_settings.hdd_sleep; @@ -1414,12 +1414,22 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) } if (sleep_seconds) my_system(3, hdidle, "-i", to_string(sleep_seconds).c_str()); + + while (n--) + free(namelist[n]); + free(namelist); + return menu_return::RETURN_NONE; } const char hdparm[] = "/sbin/hdparm"; bool have_hdparm = !access(hdparm, X_OK); if (!have_hdparm) + { + while (n--) + free(namelist[n]); + free(namelist); return menu_return::RETURN_NONE; + } struct stat stat_buf; bool have_nonbb_hdparm = !::lstat(hdparm, &stat_buf) && !S_ISLNK(stat_buf.st_mode); @@ -1433,12 +1443,11 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) snprintf(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise); snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); - if (have_hdidle) - my_system(3, hdparm, M_opt, opt); - else if (have_nonbb_hdparm) + if (have_nonbb_hdparm) my_system(4, hdparm, M_opt, S_opt, opt); else // busybox hdparm doesn't support "-M" my_system(3, hdparm, S_opt, opt); + free(namelist[i]); } free(namelist); diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 017205bc7..99a3cace5 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/src/gui/imdb.h b/src/gui/imdb.h index 74296cd30..ffc911ebd 100644 --- a/src/gui/imdb.h +++ b/src/gui/imdb.h @@ -28,6 +28,7 @@ #include #include +#include class CIMDB { diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 23aa8e290..54b485b09 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -126,19 +126,22 @@ bool CInfoClock::enableInfoClock(bool enable) } } - if (enable) { - if (FileTimeOSD->getRestore()) { - FileTimeOSD->setMode(FileTimeOSD->getTmpMode()); - FileTimeOSD->update(CMoviePlayerGui::getInstance().GetPosition(), - CMoviePlayerGui::getInstance().GetDuration()); + if (!FileTimeOSD->getMpTimeForced()) { + if (enable) { + if (FileTimeOSD->getRestore()) { + FileTimeOSD->setRestore(false); + FileTimeOSD->setMode(FileTimeOSD->getTmpMode()); + FileTimeOSD->update(CMoviePlayerGui::getInstance().GetPosition(), + CMoviePlayerGui::getInstance().GetDuration()); + } } - } - else { - if (FileTimeOSD->getMode() != CTimeOSD::MODE_HIDE) { - FileTimeOSD->setTmpMode(); - FileTimeOSD->setRestore(); - if (FileTimeOSD->getRestore()) - FileTimeOSD->kill(); + else { + if (FileTimeOSD->getMode() != CTimeOSD::MODE_HIDE) { + FileTimeOSD->setTmpMode(); + FileTimeOSD->setRestore(true); + if (FileTimeOSD->getRestore()) + FileTimeOSD->kill(); + } } } diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 03528354b..e556a0d87 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 25f1f0d3d..7539c8712 100644 --- a/src/gui/infoviewer.h +++ b/src/gui/infoviewer.h @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index b7ef1af46..a59ebef5c 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index 202296d38..a763848f1 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -36,14 +36,13 @@ #include #include -#include -#include #include #include #include "widget/menue.h" #include #include +class CFrameBuffer; class CInfoViewerBB { public: diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp index c570bb2c6..cc31a00ff 100644 --- a/src/gui/lua/luainstance.cpp +++ b/src/gui/lua/luainstance.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/lua/luainstance_helpers.h b/src/gui/lua/luainstance_helpers.h index fa54bb690..98a1ebbef 100644 --- a/src/gui/lua/luainstance_helpers.h +++ b/src/gui/lua/luainstance_helpers.h @@ -21,6 +21,7 @@ #ifndef _LUAINSTANCEHELPERS_H #define _LUAINSTANCEHELPERS_H +#include //#define LUA_DEBUG printf #define LUA_DEBUG(...) @@ -45,6 +46,8 @@ #define lua_unboxpointer(L, i) \ (*(void **)(lua_touserdata(L, i))) +class Font; + typedef std::pair fontmap_pair_t; typedef std::map fontmap_t; typedef fontmap_t::iterator fontmap_iterator_t; diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index ed159f368..67adbf805 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h index 96fc16fdf..a70f217ed 100644 --- a/src/gui/motorcontrol.h +++ b/src/gui/motorcontrol.h @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -44,6 +43,7 @@ #define STEP_MODE_ON 2 #define STEP_MODE_TIMED 3 +class CFrameBuffer; class CMotorControl : public CMenuTarget { private: diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index d0fff5726..efed8124f 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -74,6 +74,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 22b982a87..18f8ee91c 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -56,7 +56,6 @@ #include #include #include -#include #include #include //NI diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index d17f7215e..3d30d3812 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -329,6 +330,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) FileTimeOSD->kill(); FileTimeOSD->setMode(CTimeOSD::MODE_HIDE); + FileTimeOSD->setMpTimeForced(false); time_forced = false; if (actionKey == "tsmoviebrowser") { @@ -1164,6 +1166,7 @@ bool CMoviePlayerGui::PlayFileStart(void) { menu_ret = menu_return::RETURN_REPAINT; + FileTimeOSD->setMpTimeForced(false); time_forced = false; position = 0, duration = 0; @@ -1265,6 +1268,7 @@ bool CMoviePlayerGui::PlayFileStart(void) FileTimeOSD->switchMode(position, duration); time_forced = true; } + FileTimeOSD->setMpTimeForced(true); } else if (timeshift == TSHIFT_MODE_OFF || !g_settings.timeshift_pause) { playback->SetSpeed(1); } @@ -1470,6 +1474,7 @@ void CMoviePlayerGui::PlayFileLoop(void) time_forced = false; FileTimeOSD->kill(); } + FileTimeOSD->setMpTimeForced(false); if (playstate > CMoviePlayerGui::PLAY) { playstate = CMoviePlayerGui::PLAY; speed = 1; @@ -1504,6 +1509,11 @@ void CMoviePlayerGui::PlayFileLoop(void) enableOsdElements(MUTE); } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { + if (time_forced) { + time_forced = false; + FileTimeOSD->kill(); + } + FileTimeOSD->setMpTimeForced(false); if (playstate == CMoviePlayerGui::PAUSE) { playstate = CMoviePlayerGui::PLAY; //CVFD::getInstance()->ShowIcon(VFD_ICON_PAUSE, false); @@ -1535,6 +1545,8 @@ void CMoviePlayerGui::PlayFileLoop(void) update_lcd = true; } else if (msg == (neutrino_msg_t) g_settings.mpkey_time) { FileTimeOSD->switchMode(position, duration); + time_forced = false; + FileTimeOSD->setMpTimeForced(false); } else if (msg == (neutrino_msg_t) g_settings.mbkey_cover) { makeScreenShot(false, true); } else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { @@ -1560,6 +1572,7 @@ void CMoviePlayerGui::PlayFileLoop(void) FileTimeOSD->switchMode(position, duration); time_forced = true; } + FileTimeOSD->setMpTimeForced(true); if (timeshift == TSHIFT_MODE_OFF) callInfoViewer(); } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index ab78c0049..6dde745a2 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -59,6 +58,7 @@ extern "C" { #include } +class CFrameBuffer; class CMoviePlayerGui : public CMenuTarget { public: diff --git a/src/gui/opkg_manager.h b/src/gui/opkg_manager.h index a01894c75..b66f5208e 100644 --- a/src/gui/opkg_manager.h +++ b/src/gui/opkg_manager.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index db87fc152..cc8dce29c 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -34,13 +34,12 @@ #include #include -#include - #include #include #include +class CFrameBuffer; class COsdSetup : public CMenuTarget, public CChangeObserver { private: diff --git a/src/gui/pictureviewer.h b/src/gui/pictureviewer.h index 6b17ec2dd..6e89ccbcd 100644 --- a/src/gui/pictureviewer.h +++ b/src/gui/pictureviewer.h @@ -33,7 +33,6 @@ #define __pictureviewergui__ -#include #include #include #include @@ -41,6 +40,7 @@ #include +class CFrameBuffer; class CPicture { public: diff --git a/src/gui/pictureviewer_setup.h b/src/gui/pictureviewer_setup.h index 99ae6c06c..f4b6d9505 100644 --- a/src/gui/pictureviewer_setup.h +++ b/src/gui/pictureviewer_setup.h @@ -33,9 +33,6 @@ #include -#include - - #include class CPictureViewerSetup : public CMenuTarget diff --git a/src/gui/pipsetup.h b/src/gui/pipsetup.h index 0111569d8..138924cc1 100644 --- a/src/gui/pipsetup.h +++ b/src/gui/pipsetup.h @@ -2,9 +2,9 @@ #define __PIP_SETUP_H_ #include -#include #include +class CFrameBuffer; class CPipSetup : public CMenuTarget { private: diff --git a/src/gui/pluginlist.h b/src/gui/pluginlist.h index be528d278..37477366f 100644 --- a/src/gui/pluginlist.h +++ b/src/gui/pluginlist.h @@ -34,7 +34,6 @@ #include -#include #include #include diff --git a/src/gui/plugins.h b/src/gui/plugins.h index 76f50adda..169e26381 100644 --- a/src/gui/plugins.h +++ b/src/gui/plugins.h @@ -32,7 +32,6 @@ #ifndef __plugins__ #define __plugins__ -#include #include #include @@ -40,6 +39,7 @@ #include #include +class CFrameBuffer; class CPlugins { diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index e921e53eb..6dd9f232e 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include diff --git a/src/gui/scan.h b/src/gui/scan.h index f5610a2c5..40d13dbd7 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -34,11 +34,11 @@ #include #include -#include #include #include #include +class CFrameBuffer; class CScanTs : public CMenuTarget { private: diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index e1c78228f..7eca091ec 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -51,6 +51,7 @@ #include #include +#include #include #include #include diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index eba44e81a..5c17e517d 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include extern cVideo * videoDecoder; @@ -153,10 +154,12 @@ void CScreenSaver::Stop() InfoIcons->enableInfoIcons(status_icons); //NI CAudioMute::getInstance()->enableMuteIcon(status_mute); - if (!OnAfterStop.empty()) + if (!OnAfterStop.empty()){ OnAfterStop(); - else + }else{ + CInfoClock::getInstance()->ClearDisplay(); //provokes reinit CInfoClock::getInstance()->enableInfoClock(); + } } void* CScreenSaver::ScreenSaverPrg(void* arg) @@ -325,4 +328,4 @@ bool CScreenSaver::IsRun() if(thrScreenSaver) return true; return false; -} \ No newline at end of file +} diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index 67ed3aaf4..638d915e9 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -25,11 +25,12 @@ #ifndef __CSCREENSAVER_H__ #define __CSCREENSAVER_H__ -#include #include #include #include +class CFrameBuffer; +class CPictureViewer; class CScreenSaver : public sigc::trackable { private: diff --git a/src/gui/screensetup.h b/src/gui/screensetup.h index 1a3d2f429..db272ce94 100644 --- a/src/gui/screensetup.h +++ b/src/gui/screensetup.h @@ -35,11 +35,9 @@ #include -#include - #include - +class CFrameBuffer; class CScreenSetup : public CMenuTarget { private: diff --git a/src/gui/streaminfo2.h b/src/gui/streaminfo2.h index ca7019659..20d934604 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -25,12 +25,11 @@ #include -#include #include #include #include - +class CFrameBuffer; class COSDFader; class CStreamInfo2 : public CMenuTarget { diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 7bf9a3e9d..6471856cd 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index b10de2a8d..94976844a 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -46,6 +46,7 @@ CTimeOSD::CTimeOSD():CComponentsFrmClock( 1, 1, NULL, "%H:%M:%S", NULL, false, 1 m_mode = MODE_HIDE; tmp_mode = MODE_HIDE; m_restore = false; + mp_time_forced = false; Init(); } diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index c79da7dec..fe2f678f3 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -44,6 +44,7 @@ class CTimeOSD : public CComponentsFrmClock CProgressBar timescale; mode m_mode, tmp_mode; bool m_restore; + bool mp_time_forced; time_t m_time_show; void initTimeString(); @@ -65,7 +66,9 @@ class CTimeOSD : public CComponentsFrmClock mode getTmpMode() { return tmp_mode; }; void setTmpMode () { tmp_mode = m_mode; }; bool getRestore() { return m_restore; }; - void setRestore() { m_restore = (m_mode != MODE_HIDE); }; + void setRestore(bool m) { m_restore = m; }; void setHeight(const int){}//NOTE: dummy member, height is strictly bound to settings + bool getMpTimeForced() { return mp_time_forced; }; + void setMpTimeForced(bool m) { mp_time_forced = m; }; }; #endif diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 28229c7de..9ffb5764f 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -280,7 +280,7 @@ CTimerList::CTimerList() Timer = new CTimerdClient(); timerNew_message = ""; timerNew_pluginName = ""; - httpConnectTimeout = 3; + httpConnectTimeout = 300; // ms changed = false; /* most probable default */ @@ -439,14 +439,16 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "send_remotetimer") == 0) && RemoteBoxChanExists(timerlist[selected].channel_id)) { + int pre,post; + Timer->getRecordingSafety(pre,post); CHTTPTool httpTool; std::string r_url; r_url = "http://"; r_url += RemoteBoxConnectUrl(timerlist[selected].remotebox_name); r_url += "/control/timer?action=new"; - r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + timerlist[selected].rem_pre); - r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - timerlist[selected].rem_post); - r_url += "&announce=" + to_string((int)timerlist[selected].announceTime); + r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + pre); + r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - post); + r_url += "&announce=" + to_string((int)timerlist[selected].announceTime + pre); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&aj=on"; r_url += "&rs=on"; @@ -458,13 +460,11 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "fetch_remotetimer") == 0) && LocalBoxChanExists(timerlist[selected].channel_id)) { - int pre,post; - Timer->getRecordingSafety(pre,post); std::string remotebox_name = timerlist[selected].remotebox_name; std::string eventID = to_string((int)timerlist[selected].eventID); - int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",false); if (res == -1) @@ -473,8 +473,8 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) if (forceAdd) { - res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",true); } } @@ -704,16 +704,19 @@ void CTimerList::updateEvents(void) void CTimerList::RemoteBoxSelect() { int select = 0; - CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - m->addItem(new CMenuForwarder(it->rbname, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + if (g_settings.timer_remotebox_ip.size() > 1) { + CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - m->enableSaveScreen(true); - m->exec(NULL, ""); + for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) + m->addItem(new CMenuForwarder(it->rbname, it->online, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); - delete selector; + m->enableSaveScreen(true); + m->exec(NULL, ""); + + delete selector; + } std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); std::advance(it,select); @@ -802,7 +805,10 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) { printf("Failed to parse JSON\n"); printf("%s\n", reader.getFormattedErrorMessages().c_str()); - } + it->online = false; + } else + it->online = true; + Json::Value delays = root["data"]["timer"][0]; rem_pre = atoi(delays["config"].get("pre_delay","0").asString()); diff --git a/src/gui/timerlist.h b/src/gui/timerlist.h index 32f2500ff..d58b0a8a9 100644 --- a/src/gui/timerlist.h +++ b/src/gui/timerlist.h @@ -38,12 +38,10 @@ #include #include -#include - #include #include - +class CFrameBuffer; class CTimerdClient; class CTimerList : public CMenuTarget, public CListHelpers { diff --git a/src/gui/update.h b/src/gui/update.h index 608951e09..7de87180a 100644 --- a/src/gui/update.h +++ b/src/gui/update.h @@ -38,7 +38,6 @@ #include -#include #ifdef BOXMODEL_APOLLO #include #endif diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index d3c9a1921..928566353 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/upnpbrowser.h b/src/gui/upnpbrowser.h index 2ab2df4e5..105ec5fa1 100644 --- a/src/gui/upnpbrowser.h +++ b/src/gui/upnpbrowser.h @@ -23,9 +23,7 @@ #ifndef __upnpplayergui__ #define __upnpplayergui__ -#include #include -#include #include #include #include @@ -58,6 +56,7 @@ struct UPnPEntry int type; }; +class CFrameBuffer; class CUpnpBrowserGui : public CMenuTarget, public CListHelpers { public: diff --git a/src/gui/videosettings.h b/src/gui/videosettings.h index 2b07076a6..9c0e7e628 100644 --- a/src/gui/videosettings.h +++ b/src/gui/videosettings.h @@ -31,10 +31,9 @@ #define __video_setup__ #include -#include - #include +class CFrameBuffer; class CVideoSettings : public CMenuWidget, CChangeObserver { private: diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 42550393c..92d8a7354 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include extern CTimeOSD *FileTimeOSD; diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index f94cfc237..5b509c31d 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -29,8 +29,8 @@ #include #include -#include - +//#include +#include /* paintButtons usage, diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index 2f1e75395..6cbfeaced 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -22,8 +22,6 @@ * */ -#include -#include #include #include diff --git a/src/gui/widget/colorchooser.h b/src/gui/widget/colorchooser.h index 5ecc64ec6..1a0503a6e 100644 --- a/src/gui/widget/colorchooser.h +++ b/src/gui/widget/colorchooser.h @@ -33,12 +33,12 @@ #ifndef __colorchooser__ #define __colorchooser__ -#include #include #include #include +class CFrameBuffer; class CColorChooser : public CMenuTarget { private: diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index d900ed5ad..a2be659f5 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; @@ -98,9 +99,10 @@ void Helpbox::addLine(const std::string& icon, const std::string& text, const in if (!text.empty()){ int x_text = w_picon + (picon ? OFFSET_INNER_MID : 0); CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, 0, text, text_mode, font); + txt->doPaintBg(false); + txt->forceTextPaint(); #if 0 //"contrast agent", if you want to see where the text items are drawn. txt->setColorBody(COL_RED); - txt->doPaintBg(true); #endif int lines = txt->getCTextBoxObject()->getLines(); txt_height = std::max(lines*font->getHeight(), h_line); diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 8e513756a..9e367f4d2 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -34,6 +34,7 @@ #include #include #include "hintbox.h" +#include #include #define MSG_FONT g_Font[SNeutrinoSettings::FONT_TYPE_MESSAGE_TEXT] diff --git a/src/gui/widget/keyboard_input.h b/src/gui/widget/keyboard_input.h index 23a3b3601..31e0b94a2 100644 --- a/src/gui/widget/keyboard_input.h +++ b/src/gui/widget/keyboard_input.h @@ -26,7 +26,6 @@ #include "menue.h" -#include #include #include @@ -41,6 +40,7 @@ struct keyboard_layout std::string (*keys)[KEY_ROWS][KEY_COLUMNS]; }; +class CFrameBuffer; class CInputString { private: diff --git a/src/gui/widget/keychooser.cpp b/src/gui/widget/keychooser.cpp index bdc701db8..4daf7bce0 100644 --- a/src/gui/widget/keychooser.cpp +++ b/src/gui/widget/keychooser.cpp @@ -40,6 +40,7 @@ #include #include +#include class CKeyValue : public CMenuSeparator diff --git a/src/gui/widget/keychooser.h b/src/gui/widget/keychooser.h index d7495dc45..8c89140c7 100644 --- a/src/gui/widget/keychooser.h +++ b/src/gui/widget/keychooser.h @@ -35,14 +35,12 @@ #include -#include -#include #include #include #include "menue.h" - +class CFrameBuffer; class CKeyChooserItem; class CKeyChooserItemNoKey; class CKeyChooser : public CMenuWidget diff --git a/src/gui/widget/listbox.cpp b/src/gui/widget/listbox.cpp index fb10993c8..82bdabc75 100644 --- a/src/gui/widget/listbox.cpp +++ b/src/gui/widget/listbox.cpp @@ -32,6 +32,7 @@ #include #include +#include CListBox::CListBox(const char * const Caption) { diff --git a/src/gui/widget/listbox.h b/src/gui/widget/listbox.h index 26a27f8e6..1d46a028c 100644 --- a/src/gui/widget/listbox.h +++ b/src/gui/widget/listbox.h @@ -28,10 +28,9 @@ #include "menue.h" #include "listhelpers.h" -#include - #include +class CFrameBuffer; class CListBox : public CMenuTarget, public CListHelpers { protected: diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 92669a324..05045212c 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -52,8 +52,10 @@ #include #include +#include #include "listframe.h" #include +#include #define SCROLL_FRAME_WIDTH 10 diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 5cfa58da2..de5908e7f 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -36,12 +36,10 @@ #ifndef __MENU__ #define __MENU__ -#include #include #include #include #include -#include #include #include #include @@ -58,6 +56,8 @@ extern "C" { typedef int mn_widget_id_t; typedef int menu_item_disable_cond_t; + +class CFrameBuffer; class CMenuWidget; struct menu_return { diff --git a/src/gui/widget/mountchooser.h b/src/gui/widget/mountchooser.h index 98966eb4b..78c0af607 100644 --- a/src/gui/widget/mountchooser.h +++ b/src/gui/widget/mountchooser.h @@ -33,7 +33,6 @@ #ifndef __mountchooser__ #define __mountchooser__ -#include #include #include diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index 852b3b5f2..f91584872 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -32,6 +32,7 @@ #include #include +#include #include CProgressWindow::CProgressWindow(CComponentsForm *parent) diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 931390243..480b6df4a 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -30,6 +30,7 @@ #endif +#include #include "shellwindow.h" #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/widget/stringinput.h b/src/gui/widget/stringinput.h index b01d65c09..f57b13628 100644 --- a/src/gui/widget/stringinput.h +++ b/src/gui/widget/stringinput.h @@ -28,11 +28,11 @@ #include "menue.h" -#include #include #include +class CFrameBuffer; class CStringInput : public CMenuTarget { protected: diff --git a/src/gui/widget/stringinput_ext.h b/src/gui/widget/stringinput_ext.h index 78440df27..099583f83 100644 --- a/src/gui/widget/stringinput_ext.h +++ b/src/gui/widget/stringinput_ext.h @@ -35,12 +35,12 @@ #include "menue.h" -#include #include #include #include +class CFrameBuffer; class CExtendedInput_Item; class CExtendedInput : public CMenuTarget { diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 54968c03c..f8ed60af4 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -59,8 +59,10 @@ #include #include +#include #include "textbox.h" #include +#include #ifdef VISUAL_DEBUG #include #endif @@ -657,6 +659,7 @@ void CTextBox::refreshText(void) if (allow_paint_bg){ //TRACE("[CTextBox] %s restore bg %d\r\n", __FUNCTION__, __LINE__); frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf); + m_bg_painted = true; } } } @@ -718,7 +721,7 @@ void CTextBox::refreshText(void) frameBuffer->paintBoxRel(tx, ty-th, tw, th, COL_RED, m_nBgRadius, m_nBgRadiusType); #endif //TRACE("[CTextBox] %s Line %d m_cFrame.iX %d m_cFrameTextRel.iX %d\r\n", __FUNCTION__, __LINE__, m_cFrame.iX, m_cFrameTextRel.iX); - if (m_bg_painted || m_old_cText != m_cText) + if (m_bg_painted || (m_old_cText != m_cText)) m_pcFontText->RenderString(tx, ty, tw, m_cLineArray[i].c_str(), m_textColor, 0, m_renderMode | ((m_utf8_encoded) ? Font::IS_UTF8 : 0)); y += m_nFontTextHeight; } diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index afb4e3912..0c182eaa8 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -60,11 +60,11 @@ #include #include -#include #include #define TRACE printf #define TRACE_1 printf +class Font; class CBox { public: @@ -190,7 +190,7 @@ class CTextBox : public sigc::trackable void setTextBorderWidth(int Hborder, int Vborder); void setTextFont(Font* font_text); void setTextMode(const int text_mode){m_nMode = text_mode;}; - void setTextRenderModeFullBG(bool mode){ m_renderMode = (mode) ? Font::FULLBG : 0; }; + void setTextRenderModeFullBG(bool mode){ m_renderMode = (mode) ? 2 /*Font::FULLBG*/ : 0; }; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; void setWindowPos(const CBox* position){m_cFrame = *position;}; void setWindowMaxDimensions(const int width, const int height); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 81d326616..1c637abda 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1031,7 +1031,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.infoClockSeconds = configfile.getInt32("infoClockSeconds", 0); //NI g_settings.livestreamResolution = configfile.getInt32("livestreamResolution", 1920); - g_settings.livestreamScriptPath = configfile.getString("livestreamScriptPath", PLUGINDIR_VAR "/webtv"); + g_settings.livestreamScriptPath = configfile.getString("livestreamScriptPath", WEBTVDIR_VAR); g_settings.version_pseudo = configfile.getString("version_pseudo", "19700101000000"); diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index 72cbae5f7..55e765cb8 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -453,10 +453,13 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { if (ycmd_name.compare("CONFIGDIR")) yresult = CONFIGDIR; else if (ycmd_name.compare("DATADIR")) yresult = DATADIR; else if (ycmd_name.compare("FONTDIR")) yresult = FONTDIR; + else if (ycmd_name.compare("FONTDIR_VAR")) yresult = FONTDIR_VAR; //NI else if (ycmd_name.compare("LIBDIR")) yresult = LIBDIR; else if (ycmd_name.compare("GAMESDIR")) yresult = GAMESDIR; else if (ycmd_name.compare("PLUGINDIR")) yresult = PLUGINDIR; else if (ycmd_name.compare("PLUGINDIR_VAR")) yresult = PLUGINDIR_VAR; + else if (ycmd_name.compare("WEBTVDIR")) yresult = WEBTVDIR; //NI + else if (ycmd_name.compare("WEBTVDIR_VAR")) yresult = WEBTVDIR_VAR; else if (ycmd_name.compare("LUAPLUGINDIR")) yresult = LUAPLUGINDIR; else if (ycmd_name.compare("LOCALEDIR")) yresult = LOCALEDIR; else if (ycmd_name.compare("LOCALEDIR_VAR")) yresult = LOCALEDIR_VAR; diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 107300fe8..89e2bb8fe 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -467,10 +467,14 @@ void CFlashTool::reboot() } //----------------------------------------------------------------------------------------------------------------- -CFlashVersionInfo::CFlashVersionInfo(const std::string & versionString) +CFlashVersionInfo::CFlashVersionInfo(const std::string & _versionString) { //SBBBYYYYMMTTHHMM -- formatsting - + std::string versionString = _versionString; + /* just to make sure the string is long enough for the following code + * trailing chars don't matter -- will just be ignored */ + if (versionString.size() < 16) + versionString.append(16, '0'); // recover type snapshot = versionString[0]; @@ -543,6 +547,8 @@ const char *CFlashVersionInfo::getReleaseCycle(void) const const char *CFlashVersionInfo::getType(void) const { + // TODO: localize it + switch (snapshot) { case '0': @@ -557,6 +563,8 @@ const char *CFlashVersionInfo::getType(void) const return "Settings"; case 'A': return "Addon"; + case 'U': + return "Update"; case 'T': return "Text"; default: diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 0cc1db2fe..395910d81 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include using namespace std; diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index 18f7eeaa9..4d81dd131 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -18,10 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA */ -#ifdef HAVE_CONFIG_H #include -#endif - #include #include @@ -70,7 +67,7 @@ int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, doubl return 0; } //#define DEBUG -bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -103,7 +100,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); //NI #ifdef DEBUG @@ -142,7 +139,7 @@ printf("download code %d\n", res); return res==CURLE_OK; } -std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -168,7 +165,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); #ifdef DEBUG diff --git a/src/system/httptool.h b/src/system/httptool.h index 919cf4dbb..845cc3bf6 100644 --- a/src/system/httptool.h +++ b/src/system/httptool.h @@ -52,8 +52,8 @@ class CHTTPTool CHTTPTool(); void setStatusViewer( CProgressWindow* statusview ); - bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); - std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); + bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); + std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); }; diff --git a/src/system/settings.h b/src/system/settings.h index 5d73f3e9e..73a084692 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -172,6 +172,7 @@ struct timer_remotebox_item std::string pass; std::string rbname; std::string rbaddress; + bool online; }; struct SNeutrinoSettings