From 0f783a671d1d7062ef1aa439439c6830c30a9d46 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 11:35:05 +0100 Subject: [PATCH 01/40] framebuffer/configure: remove unused --restore-prev-mode this is unused, untested and most likely not working at all Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ffa3fdd6c83977b4c9db035124929094356d6277 Author: Stefan Seyfried Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 4 ---- src/driver/framebuffer.cpp | 5 ----- 2 files changed, 9 deletions(-) diff --git a/configure.ac b/configure.ac index d0f8034a1..f230f451a 100644 --- a/configure.ac +++ b/configure.ac @@ -153,10 +153,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])]) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index aba573365..7911f22df 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -409,11 +409,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"); From 4761d15f7b51c8cabb955051ccbb5b85fe2141c5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 12:09:47 +0100 Subject: [PATCH 02/40] add --enable-fastscan configure option The #define in src/gui/scan_setup.h did not work (undefining ENABLE_FASTSCAN caused really strange side effects wrt background scanning in standby mode), and all the unused code was still built. With this configure option, people who really want this obscure feature can enable it for their builds. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6525d1164a98e57c9aa9bebcd5daa29a6c646eec Author: Stefan Seyfried Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 6 ++++++ src/gui/scan.cpp | 11 ++++++++++- src/gui/scan_setup.h | 2 -- src/neutrino.cpp | 8 +++++++- src/zapit/include/zapit/scan.h | 5 ++++- src/zapit/src/Makefile.am | 6 +++++- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index f230f451a..122c42dce 100644 --- a/configure.ac +++ b/configure.ac @@ -165,6 +165,12 @@ AC_ARG_ENABLE(viasatepg, [ --enable-viasatepg enable ViaSat EPG code (experimental)], [AC_DEFINE(ENABLE_VIASATEPG,1,[enable ViaSat EPG code])]) +AC_ARG_ENABLE(fastscan, + [ --enable-fastscan enable Fastscan code)], + [AC_DEFINE(ENABLE_FASTSCAN,1,[enable fastscan code])]) + +AM_CONDITIONAL(ENABLE_FASTSCAN, test "$enable_fastscan" = "yes") + AC_ARG_ENABLE(giflib, AS_HELP_STRING(--enable-giflib,use giflib instead of libungif), ,[enable_giflib=no]) diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index e921e53eb..0b917b1c4 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -2,7 +2,7 @@ Neutrino-GUI - DBoxII-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Copyright (C) 2011-2012 Stefan Seyfried + Copyright (C) 2011-2013,2015,2017 Stefan Seyfried License: GPL @@ -169,6 +169,13 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) bool test = actionKey == "test"; bool manual = (actionKey == "manual") || test; bool fast = (actionKey == "fast"); +#if !ENABLE_FASTSCAN + if (fast) { + /* popup message? But this *should* be impossible to happen anyway */ + fprintf(stderr, "CScanTs::exec: fastscan disabled at build-time!\n"); + return menu_return::RETURN_REPAINT; + } +#endif if (CFrontend::isSat(delsys)) pname = scansettings.satName; @@ -299,8 +306,10 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) } else if(manual) success = g_Zapit->scan_TP(TP); else if(fast) { +#if ENABLE_FASTSCAN CServiceScan::getInstance()->QuietFastScan(false); success = CZapit::getInstance()->StartFastScan(scansettings.fast_type, scansettings.fast_op); +#endif } else success = g_Zapit->startScan(scan_flags); diff --git a/src/gui/scan_setup.h b/src/gui/scan_setup.h index f7110ccb9..f281de2f3 100644 --- a/src/gui/scan_setup.h +++ b/src/gui/scan_setup.h @@ -42,8 +42,6 @@ #define scansettings CNeutrinoApp::getInstance()->getScanSettings() -//#define ENABLE_FASTSCAN //don't define this to remove fast scan menu - class CScanSetup : public CMenuTarget, public CChangeObserver { protected: diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1798b1631..06c766e04 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4,7 +4,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' and some other guys - Copyright (C) 2006-2016 Stefan Seyfried + Copyright (C) 2006-2017 Stefan Seyfried Copyright (C) 2011 CoolStream International Ltd @@ -4852,6 +4852,7 @@ void CNeutrinoApp::Cleanup() #endif } +#if ENABLE_FASTSCAN void CNeutrinoApp::CheckFastScan(bool standby, bool reload) { if (scansettings.fst_update) { @@ -4883,6 +4884,11 @@ void CNeutrinoApp::CheckFastScan(bool standby, bool reload) } } } +#else +void CNeutrinoApp::CheckFastScan(bool, bool) +{ +} +#endif bool CNeutrinoApp::adjustToChannelID(const t_channel_id channel_id) { diff --git a/src/zapit/include/zapit/scan.h b/src/zapit/include/zapit/scan.h index 0a100bd97..cc117cddf 100644 --- a/src/zapit/include/zapit/scan.h +++ b/src/zapit/include/zapit/scan.h @@ -109,6 +109,7 @@ class CServiceScan : public OpenThreads::Thread uint32_t tune_tp_index; unsigned char fst_version; +#if ENABLE_FASTSCAN bool quiet_fastscan; void InitFastscanLnb(int id); bool FastscanTune(int id); @@ -120,7 +121,7 @@ class CServiceScan : public OpenThreads::Thread void process_satellite_delivery_system_descriptor(const unsigned char * const buffer, FrontendParameters * feparams, t_satellite_position * satellitePosition); bool ScanFast(); void ReportFastScan(FrontendParameters &feparams, t_satellite_position satellitePosition); - +#endif void run(); CFrontend * frontend; @@ -151,12 +152,14 @@ class CServiceScan : public OpenThreads::Thread bool isFtaOnly() { return flags & SCAN_FTA; } int GetFlags() { return flags; } bool SatHaveChannels() { return satHaveChannels; } +#if ENABLE_FASTSCAN /* fast-scan */ bool TestDiseqcConfig(int num); bool ReadFstVersion(int num); unsigned char GetFstVersion() { return fst_version; } void QuietFastScan(bool enable) { quiet_fastscan = enable; } bool ScanFast(int num, bool reload = true); +#endif }; #endif /* __scan_h__ */ diff --git a/src/zapit/src/Makefile.am b/src/zapit/src/Makefile.am index 0130f3a8a..af2c71f3c 100644 --- a/src/zapit/src/Makefile.am +++ b/src/zapit/src/Makefile.am @@ -20,7 +20,6 @@ libzapit_a_SOURCES = \ bouquets.cpp \ capmt.cpp \ channel.cpp \ - fastscan.cpp \ femanager.cpp \ frontend.cpp \ getservices.cpp \ @@ -33,6 +32,11 @@ libzapit_a_SOURCES = \ transponder.cpp \ zapit.cpp +if ENABLE_FASTSCAN +libzapit_a_SOURCES += \ + fastscan.cpp +endif + bin_PROGRAMS = pzapit sbin_PROGRAMS = udpstreampes From 750253663dcacb26a4ca3cb4a11259a916cef7e9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 12:12:27 +0100 Subject: [PATCH 03/40] flashtool: make CFlashVersionInfo robust against invalid input Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2cf2a3ed52466a4ab1fe031b5a0fb3c9002f5eba Author: Stefan Seyfried Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/flashtool.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 5f669d1c3..d246af2c9 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -446,10 +446,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]; From bb57d3d10f62000b14485712d1ec63898bbf20c2 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 10:20:08 +0100 Subject: [PATCH 04/40] remove unused fader.h Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/dcd9b982ad72fe47dd233af7de2be2651e4c3c73 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fader.h | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 src/driver/fader.h diff --git a/src/driver/fader.h b/src/driver/fader.h deleted file mode 100644 index fa386010b..000000000 --- a/src/driver/fader.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Neutrino-HD GUI, COSDFader implementation - Copyright (C) 2011 Stefan Seyfried - - 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 3 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 . -*/ - -#ifndef __FADER_H__ -#define __FADER_H__ - -#include - -class COSDFader -{ - private: - CFrameBuffer *fb; - int step; - int target_trans; - int transparency; - uint32_t timer; - public: - COSDFader(int trans); - ~COSDFader(); - - void StartFadeIn(); - bool StartFadeOut(); - void Stop(); - bool Fade(); - uint32_t GetTimer(){ return timer; }; -}; -#endif From 3dcee88f80c04a9bcd2316e19bef976aa5c54664 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:05:07 +0100 Subject: [PATCH 05/40] replace framebuffer.h include with forward declaration instead of including framebuffer.h almost everywhere, replace it with class CFrameBuffer forward declarations and/or generic system includes. Add a hack to define fb_pixel_t to config.h (one reason for framebuffer.h includes was the fb_pixel_t define) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/63b6efd1f58615803e2dab5195b631cbf28d81c5 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 3 +++ src/driver/colorgradient.h | 3 ++- src/driver/fade.cpp | 1 + src/driver/fade.h | 3 ++- src/driver/fb_window.h | 2 +- src/driver/fontrenderer.cpp | 1 + src/driver/fontrenderer.h | 5 ++--- src/driver/moviecut.h | 2 +- src/driver/pictureviewer/bmp.cpp | 1 + src/driver/pictureviewer/crw.cpp | 1 + src/driver/pictureviewer/gif.cpp | 1 + src/driver/pictureviewer/pictureviewer.h | 4 ++-- src/driver/pictureviewer/png.cpp | 1 + src/driver/radiotext.h | 1 - src/driver/simple_display.cpp | 1 - src/driver/volume.h | 2 +- src/gui/audioplayer.h | 2 +- src/gui/bedit/bouqueteditor_bouquets.h | 2 +- src/gui/bedit/bouqueteditor_channels.h | 2 +- src/gui/bedit/bouqueteditor_chanselect.h | 1 - src/gui/bookmarkmanager.h | 2 +- src/gui/bouquetlist.h | 2 +- src/gui/channellist.h | 2 +- src/gui/color.cpp | 2 ++ src/gui/components/cc_draw.h | 1 + src/gui/components/cc_types.h | 2 +- src/gui/dboxinfo.h | 2 +- src/gui/epgview.h | 2 +- src/gui/eventlist.h | 3 +-- src/gui/filebrowser.h | 2 +- src/gui/infoviewer_bb.h | 2 +- src/gui/lua/luainstance_helpers.h | 1 + src/gui/motorcontrol.h | 2 +- src/gui/movieplayer.h | 2 +- src/gui/opkg_manager.h | 1 - src/gui/osd_setup.h | 3 +-- src/gui/pictureviewer.h | 2 +- src/gui/pictureviewer_setup.h | 3 --- src/gui/pipsetup.h | 2 +- src/gui/pluginlist.h | 1 - src/gui/plugins.h | 2 +- src/gui/scan.h | 2 +- src/gui/screensaver.h | 2 +- src/gui/screensetup.h | 4 +--- src/gui/streaminfo2.h | 3 +-- src/gui/timerlist.h | 4 +--- src/gui/update.h | 1 - src/gui/upnpbrowser.h | 2 +- src/gui/videosettings.h | 3 +-- src/gui/widget/buttons.h | 1 - src/gui/widget/colorchooser.h | 2 +- src/gui/widget/keyboard_input.h | 2 +- src/gui/widget/keychooser.h | 3 +-- src/gui/widget/listbox.h | 3 +-- src/gui/widget/menue.h | 4 ++-- src/gui/widget/mountchooser.h | 1 - src/gui/widget/stringinput.h | 2 +- src/gui/widget/stringinput_ext.h | 2 +- src/system/helpers.cpp | 1 + src/system/httptool.cpp | 1 + 60 files changed, 59 insertions(+), 64 deletions(-) diff --git a/configure.ac b/configure.ac index 122c42dce..37216b765 100644 --- a/configure.ac +++ b/configure.ac @@ -290,6 +290,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/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_window.h b/src/driver/fb_window.h index 5d9efc0f7..7f7c00ec9 100644 --- a/src/driver/fb_window.h +++ b/src/driver/fb_window.h @@ -23,8 +23,8 @@ #define __fb_window_h__ #include -#include +class CFrameBuffer; class CFBWindow { public: diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index 460f9640f..f15ad5297 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/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.h b/src/driver/pictureviewer/pictureviewer.h index 8183f1943..bdddb6f25 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); 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..b822ebd67 100644 --- a/src/driver/radiotext.h +++ b/src/driver/radiotext.h @@ -46,7 +46,6 @@ #ifndef __RADIO_AUDIO_H #define __RADIO_AUDIO_H -#include #include #if 0 diff --git a/src/driver/simple_display.cpp b/src/driver/simple_display.cpp index ac3f6323e..1eeb1100e 100644 --- a/src/driver/simple_display.cpp +++ b/src/driver/simple_display.cpp @@ -25,7 +25,6 @@ #endif #include -#include #include #include 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.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.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_types.h b/src/gui/components/cc_types.h index 12a42cf7c..fd966a2f1 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 CComponentsForm; class CComponentsScrollBar; diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 5d92fa138..9d28506f2 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -34,11 +34,11 @@ #define __dboxinfo__ #include -#include #include #include #include +class CFrameBuffer; class CDBoxInfoWidget : public CMenuTarget { private: diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 051efff92..877e80638 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -33,7 +33,6 @@ #ifndef __epgview__ #define __epgview__ -#include #include #include #include @@ -50,6 +49,7 @@ #define BIG_FONT_FAKTOR 1.5 +class CFrameBuffer; class CEpgData { private: diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 2c47b63e3..c4de68955 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -44,7 +43,7 @@ #include - +class CFramebuffer; class CEventList : public CListHelpers { // Eventfinder start diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index 16e13b916..b6958f3b1 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -38,7 +38,6 @@ #endif #include -#include #include #include @@ -58,6 +57,7 @@ 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 CFrameBuffer; /** * Converts input of numeric keys to SMS style char input. */ diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index f0f7cf658..5c32896a1 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include #include +class CFrameBuffer; class CInfoViewerBB { public: diff --git a/src/gui/lua/luainstance_helpers.h b/src/gui/lua/luainstance_helpers.h index fa54bb690..32253228e 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(...) 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/movieplayer.h b/src/gui/movieplayer.h index 3d59912c1..5da4da4d2 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 a5e0d09a2..18adc6311 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 1f4c1095e..96c47aaa5 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.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/screensaver.h b/src/gui/screensaver.h index 6bad49d29..4f47e3a69 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -25,11 +25,11 @@ #ifndef __CSCREENSAVER_H__ #define __CSCREENSAVER_H__ -#include #include #include #include +class CFrameBuffer; 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/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 2302ad3e6..94da38ea2 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.h b/src/gui/upnpbrowser.h index 2ab2df4e5..409b785a8 100644 --- a/src/gui/upnpbrowser.h +++ b/src/gui/upnpbrowser.h @@ -23,7 +23,6 @@ #ifndef __upnpplayergui__ #define __upnpplayergui__ -#include #include #include #include @@ -58,6 +57,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/widget/buttons.h b/src/gui/widget/buttons.h index 2f1e75395..efdff09d6 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -23,7 +23,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/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.h b/src/gui/widget/keychooser.h index d7495dc45..fc881db6c 100644 --- a/src/gui/widget/keychooser.h +++ b/src/gui/widget/keychooser.h @@ -35,14 +35,13 @@ #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.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/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/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/system/helpers.cpp b/src/system/helpers.cpp index 2f207ac2b..8c0ddf67f 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -49,6 +49,7 @@ #include "debug.h" #include #include +#include #include #include using namespace std; diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index 2d023c124..29e58fdf5 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA */ +#include #include #include From 7e25a8dacefc8e0ed1de1d42060166daf8c694ab Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:37:53 +0100 Subject: [PATCH 06/40] replace fontrenderer.h include with forward declaration in order to flatten the build dependency tree further, include fontrenderer.h directly where needed, in header files a forward declaration is enough Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9082ddf28708d23df7347aae1459c9548760af76 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_window.h | 5 ++--- src/driver/radiotext.h | 2 -- src/gui/bookmarkmanager.cpp | 1 + src/gui/channellist.cpp | 1 + src/gui/components/cc_frm_button.cpp | 1 + src/gui/components/cc_frm_clock.cpp | 1 + src/gui/components/cc_frm_ext_text.cpp | 1 + src/gui/components/cc_frm_footer.cpp | 1 + src/gui/components/cc_frm_header.cpp | 1 + src/gui/components/cc_frm_signalbars.cpp | 1 + src/gui/components/cc_item_text.cpp | 1 + src/gui/components/cc_types.h | 2 +- src/gui/dboxinfo.h | 2 +- src/gui/epgplus.cpp | 1 + src/gui/epgview.cpp | 1 + src/gui/epgview.h | 1 - src/gui/eventlist.cpp | 1 + src/gui/eventlist.h | 1 - src/gui/filebrowser.cpp | 1 + src/gui/filebrowser.h | 2 +- src/gui/imageinfo.cpp | 1 + src/gui/infoviewer.cpp | 1 + src/gui/infoviewer.h | 1 - src/gui/infoviewer_bb.cpp | 1 + src/gui/infoviewer_bb.h | 1 - src/gui/lua/luainstance.cpp | 1 + src/gui/lua/luainstance_helpers.h | 2 ++ src/gui/motorcontrol.cpp | 1 + src/gui/moviebrowser/mb.cpp | 1 + src/gui/movieplayer.cpp | 1 + src/gui/scan.cpp | 1 + src/gui/scan_setup.cpp | 1 + src/gui/volumebar.cpp | 1 + src/gui/widget/buttons.cpp | 1 + src/gui/widget/buttons.h | 1 - src/gui/widget/helpbox.cpp | 1 + src/gui/widget/hintbox.cpp | 1 + src/gui/widget/keychooser.cpp | 1 + src/gui/widget/keychooser.h | 1 - src/gui/widget/listbox.cpp | 1 + src/gui/widget/listframe.cpp | 1 + src/gui/widget/progresswindow.cpp | 1 + src/gui/widget/shellwindow.cpp | 1 + src/gui/widget/textbox.cpp | 1 + src/gui/widget/textbox.h | 3 ++- 45 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/driver/fb_window.h b/src/driver/fb_window.h index 7f7c00ec9..f0a991669 100644 --- a/src/driver/fb_window.h +++ b/src/driver/fb_window.h @@ -21,8 +21,7 @@ #ifndef __fb_window_h__ #define __fb_window_h__ - -#include +#include class CFrameBuffer; class CFBWindow @@ -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/radiotext.h b/src/driver/radiotext.h index b822ebd67..d5758e48d 100644 --- a/src/driver/radiotext.h +++ b/src/driver/radiotext.h @@ -46,8 +46,6 @@ #ifndef __RADIO_AUDIO_H #define __RADIO_AUDIO_H -#include - #if 0 #include #include diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index bc5a1daea..420cc0be6 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 048db8f00..be339d7d1 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/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 c3995318d..ca8769a2b 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -36,6 +36,7 @@ #include #include #include +#include using namespace std; diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 3abf816f4..0a3f9873d 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -28,6 +28,7 @@ #include #include #include "cc_frm_ext_text.h" +#include #include 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 dcc22dfc2..0bd85e7dc 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -30,6 +30,7 @@ #include #include "cc_frm_header.h" #include +#include #include diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index 28728c6bf..e120ed758 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -30,6 +30,7 @@ #include #include #include "cc_frm_signalbars.h" +#include #include #define SB_MIN_HEIGHT 12 diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 67ee50401..d0346dc7e 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -31,6 +31,7 @@ #include #include #include "cc_item_text.h" +#include #include #include #include diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index fd966a2f1..c76520bb8 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -27,11 +27,11 @@ #define __CC_TYPES__ #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 9d28506f2..1db13d966 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -34,10 +34,10 @@ #define __dboxinfo__ #include -#include #include #include +class Font; class CFrameBuffer; class CDBoxInfoWidget : public CMenuTarget { diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index ffed6510c..39c3bd265 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 c3d065f36..7f6ca78c0 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 877e80638..a4116343e 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -34,7 +34,6 @@ #define __epgview__ #include -#include #include #include diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 76c771559..315acf576 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 c4de68955..bbbbb4828 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 52e2153bb..823562a27 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index b6958f3b1..cb437c7da 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -38,7 +38,6 @@ #endif #include -#include #include #include @@ -57,6 +56,7 @@ 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/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/infoviewer.cpp b/src/gui/infoviewer.cpp index 658c2e763..30847237f 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/infoviewer.h b/src/gui/infoviewer.h index 3187d4c35..415f84f8c 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 cf35a8d03..d82f08267 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 5c32896a1..e664e516d 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -36,7 +36,6 @@ #include #include -#include #include #include #include "widget/menue.h" diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp index ea7eb8bb3..e3ac5aa40 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 32253228e..98a1ebbef 100644 --- a/src/gui/lua/luainstance_helpers.h +++ b/src/gui/lua/luainstance_helpers.h @@ -46,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/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 7bb7694bc..df99c29d7 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/movieplayer.cpp b/src/gui/movieplayer.cpp index e1786f0d3..48a46b7e4 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 0b917b1c4..f9d24c9ae 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_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/volumebar.cpp b/src/gui/volumebar.cpp index be6e5a3cb..9f9921ad6 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..1dbabe9ba 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -30,6 +30,7 @@ #include #include #include +#include diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index efdff09d6..6cbfeaced 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -22,7 +22,6 @@ * */ -#include #include #include diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index 4169b5d13..09c014261 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; 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/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 fc881db6c..8c89140c7 100644 --- a/src/gui/widget/keychooser.h +++ b/src/gui/widget/keychooser.h @@ -35,7 +35,6 @@ #include -#include #include #include diff --git a/src/gui/widget/listbox.cpp b/src/gui/widget/listbox.cpp index 4698459bb..e836412fc 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/listframe.cpp b/src/gui/widget/listframe.cpp index 4b9495fba..66f14dc6b 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -54,6 +54,7 @@ #include #include "listframe.h" #include +#include #define SCROLL_FRAME_WIDTH 10 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..0404dc45c 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 54968c03c..002a4add9 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -61,6 +61,7 @@ #include #include "textbox.h" #include +#include #ifdef VISUAL_DEBUG #include #endif diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index afb4e3912..e52dcfb48 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -65,6 +65,7 @@ #define TRACE printf #define TRACE_1 printf +class Font; class CBox { public: @@ -190,7 +191,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); From 295352759e6ff8e081b2e319b9d069f992d79583 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 14:49:41 +0100 Subject: [PATCH 07/40] start modularizing framebuffer acceleration architecture This is just copied framebuffer.{h,cpp} => fb_generic.{h,cpp} The idea is to implement CFrameBuffer as generic framebuffer class that does work on almost every hardware without acceleration and / or hardware dependencies. CFbAccel will be a derived class (and different on many architectures) which implements the accelerated functions. This does not yet compile, verbatim copies to track development history. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3256978c583395d4d9e2a11ac43292a8e32ce7c1 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 2200 +++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.h | 332 ++++++ src/driver/framebuffer.h | 2 +- 3 files changed, 2533 insertions(+), 1 deletion(-) create mode 100644 src/driver/fb_generic.cpp create mode 100644 src/driver/fb_generic.h diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp new file mode 100644 index 000000000..7911f22df --- /dev/null +++ b/src/driver/fb_generic.cpp @@ -0,0 +1,2200 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + 2003 thegoodguy + + mute icon handling from tuxbox project + Copyright (C) 2009 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 +#ifdef HAVE_COOL_HARDWARE +#include +#endif + +extern cVideo * videoDecoder; + +extern CPictureViewer * g_PicViewer; +#define ICON_CACHE_SIZE 1024*1024*2 // 2mb + +#define BACKGROUNDIMAGEWIDTH 720 + +#ifdef BOXMODEL_APOLLO +#ifndef FB_HW_ACCELERATION +#define FB_HW_ACCELERATION +#endif +#endif +#if defined(FB_HW_ACCELERATION) && defined(USE_NEVIS_GXA) +#error +#endif +//#undef USE_NEVIS_GXA //FIXME +/*******************************************************************************/ +#ifdef USE_NEVIS_GXA + +#ifdef GXA_FG_COLOR_REG +#undef GXA_FG_COLOR_REG +#endif +#ifdef GXA_BG_COLOR_REG +#undef GXA_BG_COLOR_REG +#endif +#ifdef GXA_LINE_CONTROL_REG +#undef GXA_LINE_CONTROL_REG +#endif +#ifdef GXA_DEPTH_REG +#undef GXA_DEPTH_REG +#endif +#ifdef GXA_CONTENT_ID_REG +#undef GXA_CONTENT_ID_REG +#endif + +#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_BMP2_TYPE_REG 0x0050 +#define GXA_BMP2_ADDR_REG 0x0054 +#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_BMP1_TYPE_REG 0x0048 +#define GXA_BMP1_ADDR_REG 0x004C +#define GXA_BMP7_TYPE_REG 0x0078 + +#define GXA_BLEND_CFG_REG 0x003C +#define GXA_CFG_REG 0x0030 +#define GXA_CFG2_REG 0x00FC +/* +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 CFrameBuffer::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 CFrameBuffer::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 < 2048); /* don't deadlock here if there is an error */ + + if (count > 512) /* more than 100 are unlikely, */{ + if (func != NULL) + fprintf(stderr, "CFrameBuffer::waitForIdle: count is big (%04u) [%s]!\n", count, func); + else + fprintf(stderr, "CFrameBuffer::waitForIdle: count is big (%u)!\n", count); + } +} +#endif /* USE_NEVIS_GXA */ + +/*******************************************************************************/ + +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 ) +{ + 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) { + frameBuffer = new CFrameBuffer(); + printf("[neutrino] frameBuffer Instance created\n"); + } else { + //printf("[neutrino] frameBuffer Instace requested\n"); + } + return frameBuffer; +} + +#ifdef USE_NEVIS_GXA +void CFrameBuffer::setupGXA(void) +{ + // 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) | 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) | screeninfo.xres | (1 << 27)); +} +#endif +void CFrameBuffer::init(const char * const fbDevice) +{ + int tr = 0xFF; + + fd = open(fbDevice, O_RDWR); + if(!fd) 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("%dk video mem\n", available/1024); + lfb=(fb_pixel_t*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); + + if (!lfb) { + perror("mmap"); + goto nolfb; + } + +#ifdef USE_NEVIS_GXA + /* Open /dev/mem for HW-register access */ + devmem_fd = open("/dev/mem", O_RDWR | O_SYNC); + if (devmem_fd < 0) { + perror("Unable to open /dev/mem"); + goto nolfb; + } + + /* 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("Unable to mmap /dev/mem"); + goto nolfb; + } + + /* tell the GXA where the framebuffer to draw on starts */ + smem_start = (unsigned int) fix.smem_start; + printf("smem_start %x\n", smem_start); + + setupGXA(); +#endif + 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"); + lfb=0; +} + + +CFrameBuffer::~CFrameBuffer() +{ + 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(); + + 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 lfb; + else + return (fb_pixel_t *) virtual_fb; +} + +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, +#if defined(USE_NEVIS_GXA) + "Using nevis GXA" +#elif defined(FB_HW_ACCELERATION) + "Using fb hw graphics" +#else + "Not using graphics" +#endif + ); + + //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) +{ +#ifdef HAVE_COOL_HARDWARE + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +#endif +} + +void CFrameBuffer::setBlendLevel(int level) +{ +#ifdef HAVE_COOL_HARDWARE + //printf("CFrameBuffer::setBlendLevel %d\n", level); + unsigned char value = 0xFF; + if((level >= 0) && (level <= 100)) + value = convertSetupAlpha2Alpha(level); + + if (ioctl(fd, FBIO_SETOPACITY, value)) + printf("FBIO_SETOPACITY failed.\n"); +#ifndef BOXMODEL_APOLLO + if(level == 100) // TODO: sucks. + usleep(20000); +#endif +#endif +} + +#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 defined(FB_HW_ACCELERATION) + fb_fillrect fillrect; + fillrect.color = col; + fillrect.rop = ROP_COPY; +#elif defined(USE_NEVIS_GXA) + 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 */ +#endif + + 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 defined(FB_HW_ACCELERATION) || defined(USE_NEVIS_GXA) + int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; +#if defined(FB_HW_ACCELERATION) + fillrect.dx = x; + fillrect.dy = y + line; + fillrect.width = dx; + fillrect.height = dy - (radius * rect_height_mult); + + ioctl(fd, FBIO_FILL_RECT, &fillrect); +#elif defined(USE_NEVIS_GXA) + _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 */ +#endif + line += dy - (radius * rect_height_mult); + continue; +#endif + } + + 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; + } +#ifdef USE_NEVIS_GXA + _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 */ +#else + paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col); +#endif + line++; + } + } else { +#if defined(FB_HW_ACCELERATION) + /* 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; + } +#endif +#if defined(USE_NEVIS_GXA) + _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 */ +#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++; + } +#endif + } +#ifdef USE_NEVIS_GXA + _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(); +#endif + checkFbArea(x, y, dx, dy, false); +} + +void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col) +{ + +#if defined(FB_HW_ACCELERATION) + 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); +#elif defined(USE_NEVIS_GXA) + /* draw a single vertical line from point x/y with hight dx */ + 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; + + _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ + _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ + _write_gxa(gxa_base, cmd, GXA_POINT(x, y + dy)); /* end point */ + _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* start point */ +#else /* USE_NEVIS_GXA */ + uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + + for(int count=0;count m_lock(mutex); +#endif + paintVLineRelInternal(x, y, dy, col); +} + +void CFrameBuffer::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col) +{ +#if defined(FB_HW_ACCELERATION) + 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; + } +#endif +#if defined(USE_NEVIS_GXA) + /* draw a single horizontal line from point x/y with width dx */ + 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; + + _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ + _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ + _write_gxa(gxa_base, cmd, GXA_POINT(x + dx, y)); /* end point */ + _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* start point */ +#else /* USE_NEVIS_GXA */ + 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; +#endif /* USE_NEVIS_GXA */ +} + +void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) +{ + if (!getActive()) + return; + +#if defined(USE_NEVIS_GXA) + OpenThreads::ScopedLock m_lock(mutex); +#endif + paintHLineRelInternal(x, dx, y, col); +} + +void CFrameBuffer::setIconBasePath(const std::string & iconPath) +{ + iconBasePath = iconPath; +} + +std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_type) +{ + std::string path, filetype; + filetype = "." + file_type; + path = std::string(ICONSDIR_VAR) + "/" + icon_name + filetype; + if (access(path.c_str(), F_OK)) + path = iconBasePath + "/" + icon_name + filetype; + if (icon_name.find("/", 0) != std::string::npos) + path = icon_name; + return path; +} + +void CFrameBuffer::getIconSize(const char * const filename, int* width, int *height) +{ + *width = 0; + *height = 0; + + if(filename == NULL) + return; + //check for full path, icon don't have full path, or ? + if (filename[0]== '/'){ + return; + } + + std::map::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, 0, 0, true); + 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; + + #ifdef USE_NEVIS_GXA + paintHLineRel(x, 1, y, col); + #else + fb_pixel_t * pos = getFrameBufferPointer(); + pos += (stride / sizeof(fb_pixel_t)) * y; + pos += x; + + *pos = col; + #endif +} + +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; + +//printf("%s(%d, %d, %d, %d, %.8X)\n", __FUNCTION__, xa, ya, xb, yb, col); + + 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); + } + } +} +#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; + } + 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*/) +{ + int xc, yc; + + xc = (width > xRes) ? xRes : width; + yc = (height > yRes) ? yRes : height; + +#if defined(FB_HW_ACCELERATION) + 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; +#if 1 + image.data = (const char*)fbbuff; + ioctl(fd, FBIO_IMAGE_BLT, &image); +#else + for (int count = 0; count < yc; count++ ) { + fb_pixel_t* data = (fb_pixel_t *) fbbuff; + fb_pixel_t *pixpos = &data[(count + yp) * width]; + image.data = (const char*) pixpos; //fbbuff +(count + yp)*width; + image.dy = yoff+count; + image.height = 1; + ioctl(fd, FBIO_IMAGE_BLT, &image); + } +#endif + //printf("\033[34m>>>>\033[0m [%s:%s:%d] FB_HW_ACCELERATION (image) x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); + return; + } + +#elif defined(USE_NEVIS_GXA) + u32 cmd; + void * uKva; + + uKva = cs_phys_addr(fbbuff); + //printf("CFrameBuffer::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); + + 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; + } +#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; + +#if defined(FB_HW_ACCELERATION) + 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); + //printf("\033[33m>>>>\033[0m [%s:%s:%d] FB_HW_ACCELERATION x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); + return; + } + printf("\033[31m>>>>\033[0m [%s:%s:%d] Not use FB_HW_ACCELERATION x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); +#elif defined(USE_NEVIS_GXA) + 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)); + //printf("\033[33m>>>>\033[0m [%s:%s:%d] USE_NEVIS_GXA x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); + add_gxa_sync_marker(); + return; + } + printf("\033[31m>>>>\033[0m [%s:%s:%d] Not use USE_NEVIS_GXA x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); +#endif + 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; +} diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h new file mode 100644 index 000000000..9ed2ca839 --- /dev/null +++ b/src/driver/fb_generic.h @@ -0,0 +1,332 @@ +/* + 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 +{ + private: + + 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; + 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; + static void switch_signal (int); + fb_fix_screeninfo fix; +#ifdef USE_NEVIS_GXA + 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 */ +#endif /* USE_NEVIS_GXA */ + 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]; + + ~CFrameBuffer(); + + static CFrameBuffer* getInstance(); +#ifdef USE_NEVIS_GXA + void setupGXA(void); +#endif + + void init(const char * const fbDevice = "/dev/fb/0"); + 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 + 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? + + void setTransparency( int tr = 0 ); + void setBlendMode(uint8_t mode = 1); + 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]; + }; + 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); + + 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); } + 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); } + 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; }; +#ifdef USE_NEVIS_GXA + void add_gxa_sync_marker(void); + void waitForIdle(const char* func=NULL); +#else + inline void waitForIdle(const char*) {}; +#endif + 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); + 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); + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + + 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 fb_no_check; + 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; +}; + +#endif diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index ca19f3d75..87d6375f0 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__ From 92bb894b58540c2047d7a49a29fd82143f752eb0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:02:20 +0100 Subject: [PATCH 08/40] fb_generic: add stuff needed for compilation Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ceb82a4b4726ab22b18282e9d6b8588cfd8d8c39 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 3 +-- src/driver/fb_generic.cpp | 15 +++++++++++++++ src/driver/fb_generic.h | 35 ++++++++++++++++------------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index cf228beda..b75ba886b 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -27,10 +27,9 @@ libneutrino_driver_a_SOURCES = \ colorgradient.cpp \ fade.cpp \ fb_window.cpp \ - fbaccel.cpp \ + fb_generic.cpp \ file.cpp \ fontrenderer.cpp \ - framebuffer_ng.cpp \ genpsi.cpp \ moviecut.cpp \ neutrinofonts.cpp \ diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 7911f22df..369e8e0b7 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -168,6 +168,10 @@ void CFrameBuffer::waitForIdle(const char* func) fprintf(stderr, "CFrameBuffer::waitForIdle: count is big (%u)!\n", count); } } +#else +void CFrameBuffer::waitForIdle(const char *) +{ +} #endif /* USE_NEVIS_GXA */ /*******************************************************************************/ @@ -485,6 +489,12 @@ fb_pixel_t * CFrameBuffer::getFrameBufferPointer() const 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)); @@ -2198,3 +2208,8 @@ bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) 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 index 9ed2ca839..dcadb7f22 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -21,7 +21,6 @@ Boston, MA 02110-1301, USA. */ - #ifndef __framebuffer__ #define __framebuffer__ #include @@ -73,7 +72,7 @@ typedef struct gradientData_t /** Ausfuehrung als Singleton */ class CFrameBuffer : public sigc::trackable { - private: + protected: CFrameBuffer(); OpenThreads::Mutex mutex; @@ -165,22 +164,23 @@ class CFrameBuffer : public sigc::trackable fb_pixel_t realcolor[256]; - ~CFrameBuffer(); + virtual ~CFrameBuffer(); static CFrameBuffer* getInstance(); #ifdef USE_NEVIS_GXA void setupGXA(void); #endif - void init(const char * const fbDevice = "/dev/fb/0"); - int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + 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 - unsigned int getStride() const; // size of a single line in the framebuffer (in bytes) + 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); @@ -192,8 +192,8 @@ class CFrameBuffer : public sigc::trackable void setActive(bool enable); // is framebuffer active? void setTransparency( int tr = 0 ); - void setBlendMode(uint8_t mode = 1); - void setBlendLevel(int level); + virtual void setBlendMode(uint8_t mode = 1); + virtual void setBlendLevel(int level); //Palette stuff void setAlphaFade(int in, int num, int tr); @@ -206,12 +206,12 @@ class CFrameBuffer : public sigc::trackable { *dest = realcolor[color]; }; - void paintPixel(int x, int y, const fb_pixel_t col); + 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); - 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); + 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); } @@ -219,10 +219,10 @@ class CFrameBuffer : public sigc::trackable 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); } - void paintVLineRel(int x, int y, int dy, const fb_pixel_t 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); } - void paintHLineRel(int x, int dx, int y, const fb_pixel_t 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;}; @@ -264,18 +264,15 @@ class CFrameBuffer : public sigc::trackable bool Lock(void); void Unlock(void); bool Locked(void) { return locked; }; -#ifdef USE_NEVIS_GXA - void add_gxa_sync_marker(void); - void waitForIdle(const char* func=NULL); -#else - inline void waitForIdle(const char*) {}; -#endif + 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); - 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); + 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); 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); + enum { TM_EMPTY = 0, From 3d2f2dbda40a4ad0c15cbae4923d343feab33147 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:22:22 +0100 Subject: [PATCH 09/40] fb_generic: remove all hardware specific code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1034642093a89d654dbcb429ce270e3cc757cb98 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 367 +------------------------------------- src/driver/fb_generic.h | 8 - 2 files changed, 3 insertions(+), 372 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 369e8e0b7..f4f1b10be 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -5,7 +5,7 @@ 2003 thegoodguy mute icon handling from tuxbox project - Copyright (C) 2009 Stefan Seyfried + Copyright (C) 2009-2012,2017 Stefan Seyfried mute icon & info clock handling Copyright (C) 2013 M. Liebmann (micha-bbg) @@ -52,9 +52,6 @@ #include #include #include -#ifdef HAVE_COOL_HARDWARE -#include -#endif extern cVideo * videoDecoder; @@ -63,116 +60,9 @@ extern CPictureViewer * g_PicViewer; #define BACKGROUNDIMAGEWIDTH 720 -#ifdef BOXMODEL_APOLLO -#ifndef FB_HW_ACCELERATION -#define FB_HW_ACCELERATION -#endif -#endif -#if defined(FB_HW_ACCELERATION) && defined(USE_NEVIS_GXA) -#error -#endif -//#undef USE_NEVIS_GXA //FIXME -/*******************************************************************************/ -#ifdef USE_NEVIS_GXA - -#ifdef GXA_FG_COLOR_REG -#undef GXA_FG_COLOR_REG -#endif -#ifdef GXA_BG_COLOR_REG -#undef GXA_BG_COLOR_REG -#endif -#ifdef GXA_LINE_CONTROL_REG -#undef GXA_LINE_CONTROL_REG -#endif -#ifdef GXA_DEPTH_REG -#undef GXA_DEPTH_REG -#endif -#ifdef GXA_CONTENT_ID_REG -#undef GXA_CONTENT_ID_REG -#endif - -#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_BMP2_TYPE_REG 0x0050 -#define GXA_BMP2_ADDR_REG 0x0054 -#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_BMP1_TYPE_REG 0x0048 -#define GXA_BMP1_ADDR_REG 0x004C -#define GXA_BMP7_TYPE_REG 0x0078 - -#define GXA_BLEND_CFG_REG 0x003C -#define GXA_CFG_REG 0x0030 -#define GXA_CFG2_REG 0x00FC -/* -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 CFrameBuffer::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 CFrameBuffer::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 < 2048); /* don't deadlock here if there is an error */ - - if (count > 512) /* more than 100 are unlikely, */{ - if (func != NULL) - fprintf(stderr, "CFrameBuffer::waitForIdle: count is big (%04u) [%s]!\n", count, func); - else - fprintf(stderr, "CFrameBuffer::waitForIdle: count is big (%u)!\n", count); - } -} -#else void CFrameBuffer::waitForIdle(const char *) { } -#endif /* USE_NEVIS_GXA */ /*******************************************************************************/ @@ -237,21 +127,6 @@ CFrameBuffer* CFrameBuffer::getInstance() return frameBuffer; } -#ifdef USE_NEVIS_GXA -void CFrameBuffer::setupGXA(void) -{ - // 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) | 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) | screeninfo.xres | (1 << 27)); -} -#endif void CFrameBuffer::init(const char * const fbDevice) { int tr = 0xFF; @@ -285,27 +160,6 @@ void CFrameBuffer::init(const char * const fbDevice) goto nolfb; } -#ifdef USE_NEVIS_GXA - /* Open /dev/mem for HW-register access */ - devmem_fd = open("/dev/mem", O_RDWR | O_SYNC); - if (devmem_fd < 0) { - perror("Unable to open /dev/mem"); - goto nolfb; - } - - /* 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("Unable to mmap /dev/mem"); - goto nolfb; - } - - /* tell the GXA where the framebuffer to draw on starts */ - smem_start = (unsigned int) fix.smem_start; - printf("smem_start %x\n", smem_start); - - setupGXA(); -#endif cache_size = 0; /* Windows Colors */ @@ -552,13 +406,7 @@ int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsign stride = _fix.line_length; printf("FB: %dx%dx%d line length %d. %s accelerator.\n", xRes, yRes, bpp, stride, -#if defined(USE_NEVIS_GXA) - "Using nevis GXA" -#elif defined(FB_HW_ACCELERATION) - "Using fb hw graphics" -#else "Not using graphics" -#endif ); //memset(getFrameBufferPointer(), 0, stride * yRes); @@ -574,29 +422,12 @@ void CFrameBuffer::setTransparency( int /*tr*/ ) { } #endif -void CFrameBuffer::setBlendMode(uint8_t mode) +void CFrameBuffer::setBlendMode(uint8_t /*mode*/) { -#ifdef HAVE_COOL_HARDWARE - if (ioctl(fd, FBIO_SETBLENDMODE, mode)) - printf("FBIO_SETBLENDMODE failed.\n"); -#endif } -void CFrameBuffer::setBlendLevel(int level) +void CFrameBuffer::setBlendLevel(int /*level*/) { -#ifdef HAVE_COOL_HARDWARE - //printf("CFrameBuffer::setBlendLevel %d\n", level); - unsigned char value = 0xFF; - if((level >= 0) && (level <= 100)) - value = convertSetupAlpha2Alpha(level); - - if (ioctl(fd, FBIO_SETOPACITY, value)) - printf("FBIO_SETOPACITY failed.\n"); -#ifndef BOXMODEL_APOLLO - if(level == 100) // TODO: sucks. - usleep(20000); -#endif -#endif } #if 0 @@ -832,18 +663,6 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int checkFbArea(x, y, dx, dy, true); -#if defined(FB_HW_ACCELERATION) - fb_fillrect fillrect; - fillrect.color = col; - fillrect.rop = ROP_COPY; -#elif defined(USE_NEVIS_GXA) - 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 */ -#endif - if (type && radius) { setCornerFlags(type); radius = limitRadius(dx, dy, radius); @@ -853,23 +672,6 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int 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 defined(FB_HW_ACCELERATION) || defined(USE_NEVIS_GXA) - int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; -#if defined(FB_HW_ACCELERATION) - fillrect.dx = x; - fillrect.dy = y + line; - fillrect.width = dx; - fillrect.height = dy - (radius * rect_height_mult); - - ioctl(fd, FBIO_FILL_RECT, &fillrect); -#elif defined(USE_NEVIS_GXA) - _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 */ -#endif - line += dy - (radius * rect_height_mult); - continue; -#endif } if (dx-ofr-ofl < 1) { @@ -882,33 +684,10 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int line++; continue; } -#ifdef USE_NEVIS_GXA - _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 */ -#else paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col); -#endif line++; } } else { -#if defined(FB_HW_ACCELERATION) - /* 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; - } -#endif -#if defined(USE_NEVIS_GXA) - _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 */ -#else int swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); int line = 0; @@ -919,46 +698,18 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int fbp += swidth; line++; } -#endif } -#ifdef USE_NEVIS_GXA - _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(); -#endif checkFbArea(x, y, dx, dy, false); } void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col) { - -#if defined(FB_HW_ACCELERATION) - 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); -#elif defined(USE_NEVIS_GXA) - /* draw a single vertical line from point x/y with hight dx */ - 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; - - _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ - _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ - _write_gxa(gxa_base, cmd, GXA_POINT(x, y + dy)); /* end point */ - _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* start point */ -#else /* USE_NEVIS_GXA */ uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; for(int count=0;count m_lock(mutex); -#endif paintVLineRelInternal(x, y, dy, col); } void CFrameBuffer::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col) { -#if defined(FB_HW_ACCELERATION) - 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; - } -#endif -#if defined(USE_NEVIS_GXA) - /* draw a single horizontal line from point x/y with width dx */ - 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; - - _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ - _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ - _write_gxa(gxa_base, cmd, GXA_POINT(x + dx, y)); /* end point */ - _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* start point */ -#else /* USE_NEVIS_GXA */ 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; -#endif /* USE_NEVIS_GXA */ } void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) @@ -1009,9 +733,6 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) if (!getActive()) return; -#if defined(USE_NEVIS_GXA) - OpenThreads::ScopedLock m_lock(mutex); -#endif paintHLineRelInternal(x, dx, y, col); } @@ -1268,15 +989,11 @@ void CFrameBuffer::paintPixel(const int x, const int y, const fb_pixel_t col) if (!getActive()) return; - #ifdef USE_NEVIS_GXA - paintHLineRel(x, 1, y, col); - #else fb_pixel_t * pos = getFrameBufferPointer(); pos += (stride / sizeof(fb_pixel_t)) * y; pos += x; *pos = col; - #endif } void CFrameBuffer::paintShortHLineRelInternal(const int& x, const int& dx, const int& y, const fb_pixel_t& col) @@ -1953,53 +1670,6 @@ void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32 xc = (width > xRes) ? xRes : width; yc = (height > yRes) ? yRes : height; -#if defined(FB_HW_ACCELERATION) - 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; -#if 1 - image.data = (const char*)fbbuff; - ioctl(fd, FBIO_IMAGE_BLT, &image); -#else - for (int count = 0; count < yc; count++ ) { - fb_pixel_t* data = (fb_pixel_t *) fbbuff; - fb_pixel_t *pixpos = &data[(count + yp) * width]; - image.data = (const char*) pixpos; //fbbuff +(count + yp)*width; - image.dy = yoff+count; - image.height = 1; - ioctl(fd, FBIO_IMAGE_BLT, &image); - } -#endif - //printf("\033[34m>>>>\033[0m [%s:%s:%d] FB_HW_ACCELERATION (image) x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); - return; - } - -#elif defined(USE_NEVIS_GXA) - u32 cmd; - void * uKva; - - uKva = cs_phys_addr(fbbuff); - //printf("CFrameBuffer::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); - - 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; - } -#endif fb_pixel_t* data = (fb_pixel_t *) fbbuff; uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + xoff * sizeof(fb_pixel_t) + stride * yoff; @@ -2037,37 +1707,6 @@ void CFrameBuffer::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; -#if defined(FB_HW_ACCELERATION) - 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); - //printf("\033[33m>>>>\033[0m [%s:%s:%d] FB_HW_ACCELERATION x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); - return; - } - printf("\033[31m>>>>\033[0m [%s:%s:%d] Not use FB_HW_ACCELERATION x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); -#elif defined(USE_NEVIS_GXA) - 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)); - //printf("\033[33m>>>>\033[0m [%s:%s:%d] USE_NEVIS_GXA x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); - add_gxa_sync_marker(); - return; - } - printf("\033[31m>>>>\033[0m [%s:%s:%d] Not use USE_NEVIS_GXA x: %d, y: %d, w: %d, h: %d\n", __file__, __func__, __LINE__, xoff, yoff, xc, yc); -#endif uint32_t swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * yoff); fb_pixel_t* data = (fb_pixel_t*)boxBuf; diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index dcadb7f22..6041a3a8f 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -123,11 +123,6 @@ class CFrameBuffer : public sigc::trackable bool active; static void switch_signal (int); fb_fix_screeninfo fix; -#ifdef USE_NEVIS_GXA - 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 */ -#endif /* USE_NEVIS_GXA */ bool locked; std::map icon_cache; int cache_size; @@ -167,9 +162,6 @@ class CFrameBuffer : public sigc::trackable virtual ~CFrameBuffer(); static CFrameBuffer* getInstance(); -#ifdef USE_NEVIS_GXA - void setupGXA(void); -#endif virtual void init(const char * const fbDevice = "/dev/fb0"); virtual int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); From 49592c98cd15eaa1b238f3e2a0c2b343d3c2b3ee Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 18:04:15 +0100 Subject: [PATCH 10/40] fb_generic: add pointer for double-buffered fb Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b767d1ef41e9de57abf4d91275ff72139f476fde Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 6 +++--- src/driver/fb_generic.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index f4f1b10be..fbdad4ecd 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -153,7 +153,7 @@ void CFrameBuffer::init(const char * const fbDevice) available=fix.smem_len; printf("%dk video mem\n", available/1024); - lfb=(fb_pixel_t*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); + lbb = lfb = (fb_pixel_t*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); if (!lfb) { perror("mmap"); @@ -237,7 +237,7 @@ void CFrameBuffer::init(const char * const fbDevice) nolfb: printf("framebuffer not available.\n"); - lfb=0; + lbb = lfb = NULL; } @@ -338,7 +338,7 @@ unsigned int CFrameBuffer::getScreenY() fb_pixel_t * CFrameBuffer::getFrameBufferPointer() const { if (active || (virtual_fb == NULL)) - return lfb; + return lbb; else return (fb_pixel_t *) virtual_fb; } diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 6041a3a8f..3526ecd0e 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -105,6 +105,7 @@ class CFrameBuffer : public sigc::trackable int fd, tty; fb_pixel_t * lfb; + fb_pixel_t * lbb; int available; fb_pixel_t * background; fb_pixel_t * backupBackground; From a9d2bbeeef2edbf99f5d9d332625642d6bec0647 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:50:05 +0100 Subject: [PATCH 11/40] move gui/color.h includes from headers to cpp files Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6a2b59015b734e4efc6b8cc5e525cadef265ca25 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/epgview.h | 1 - src/gui/eventlist.h | 1 - src/gui/filebrowser.h | 1 - src/gui/widget/listframe.cpp | 1 + src/gui/widget/shellwindow.cpp | 1 + src/gui/widget/textbox.cpp | 1 + src/gui/widget/textbox.h | 1 - 7 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/epgview.h b/src/gui/epgview.h index a4116343e..4fe60f9de 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -36,7 +36,6 @@ #include #include -#include #include #include "widget/menue.h" diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index bbbbb4828..c0c15af52 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -34,7 +34,6 @@ #include #include -#include "color.h" #include "infoviewer.h" #include "widget/menue.h" diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index cb437c7da..3d458125d 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 66f14dc6b..3d17d46fb 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -52,6 +52,7 @@ #include #include +#include #include "listframe.h" #include #include diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 0404dc45c..480b6df4a 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -30,6 +30,7 @@ #endif +#include #include "shellwindow.h" #include diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 002a4add9..31165abba 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -59,6 +59,7 @@ #include #include +#include #include "textbox.h" #include #include diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index e52dcfb48..0c182eaa8 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -60,7 +60,6 @@ #include #include -#include #include #define TRACE printf #define TRACE_1 printf From cdfb1da8ec54aae78fe94170b0a9a73103e52d5b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:53:29 +0100 Subject: [PATCH 12/40] fb_generic: add fb_name member to identify fb implementation Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/257ffd9ee3d93280281e3ba33ee723809ac00256 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 4 ++-- src/driver/fb_generic.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index fbdad4ecd..5f4b854dd 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -4,7 +4,6 @@ Copyright (C) 2001 Steffen Hehn 'McClean' 2003 thegoodguy - mute icon handling from tuxbox project Copyright (C) 2009-2012,2017 Stefan Seyfried mute icon & info clock handling Copyright (C) 2013 M. Liebmann (micha-bbg) @@ -79,6 +78,7 @@ inline unsigned int make16color(uint16_t r, uint16_t g, uint16_t b, uint16_t t, CFrameBuffer::CFrameBuffer() : active ( true ) { + fb_name = "generic framebuffer"; iconBasePath = ""; available = 0; cmap.start = 0; @@ -120,7 +120,7 @@ CFrameBuffer* CFrameBuffer::getInstance() if(!frameBuffer) { frameBuffer = new CFrameBuffer(); - printf("[neutrino] frameBuffer Instance created\n"); + printf("[neutrino] %s Instance created\n", frameBuffer->fb_name); } else { //printf("[neutrino] frameBuffer Instace requested\n"); } diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 3526ecd0e..40541e0fa 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -317,6 +317,7 @@ class CFrameBuffer : public sigc::trackable void doPaintMuteIcon(bool mode) { do_paint_mute_icon = mode; } void blit(void) {} sigc::signal OnAfterSetPallette; + const char *fb_name; }; #endif From 7c0f816f51976afcaa9db2bbafc2ed75e88dd405 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 20:45:13 +0100 Subject: [PATCH 13/40] fb_generic: nicer debug output, remove dead code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2d57ea34f45b76ceda8c91e443e29a93f2620bce Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 5f4b854dd..66397701f 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -121,8 +121,6 @@ CFrameBuffer* CFrameBuffer::getInstance() if(!frameBuffer) { frameBuffer = new CFrameBuffer(); printf("[neutrino] %s Instance created\n", frameBuffer->fb_name); - } else { - //printf("[neutrino] frameBuffer Instace requested\n"); } return frameBuffer; } @@ -132,7 +130,6 @@ void CFrameBuffer::init(const char * const fbDevice) int tr = 0xFF; fd = open(fbDevice, O_RDWR); - if(!fd) fd = open(fbDevice, O_RDWR); if (fd<0) { perror(fbDevice); @@ -152,7 +149,7 @@ void CFrameBuffer::init(const char * const fbDevice) } available=fix.smem_len; - printf("%dk video mem\n", available/1024); + 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) { @@ -1169,8 +1166,6 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co if (!getActive()) return; -//printf("%s(%d, %d, %d, %d, %.8X)\n", __FUNCTION__, xa, ya, xb, yb, col); - int dx = abs (xa - xb); int dy = abs (ya - yb); int x; From febeb710a05b78dade7b6e332be0f36030cf9854 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 21:35:52 +0100 Subject: [PATCH 14/40] framebuffer: add accelerator for STi framebuffer also add a generic helper class for other accelerated framebuffer implementations Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e56fde40828b079e1df3ef457ea3d0a511c34dea Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 2 + src/driver/fb_accel.cpp | 97 ++++++ src/driver/fb_accel.h | 81 +++++ src/driver/fb_accel_sti.cpp | 655 ++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 15 +- 5 files changed, 847 insertions(+), 3 deletions(-) create mode 100644 src/driver/fb_accel.cpp create mode 100644 src/driver/fb_accel.h create mode 100644 src/driver/fb_accel_sti.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index b75ba886b..b5e3e7012 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -26,6 +26,7 @@ libneutrino_driver_a_SOURCES = \ audioplay.cpp \ colorgradient.cpp \ fade.cpp \ + fb_accel.cpp \ fb_window.cpp \ fb_generic.cpp \ file.cpp \ @@ -57,6 +58,7 @@ endif if BOXTYPE_SPARK libneutrino_driver_a_SOURCES += \ + fb_accel_sti.cpp \ simple_display.cpp endif if BOXTYPE_AZBOX 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..af73b76ef --- /dev/null +++ b/src/driver/fb_accel.h @@ -0,0 +1,81 @@ +/* + 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); +}; + +#endif 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 index 66397701f..883e24d28 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -30,7 +30,8 @@ #include #endif -#include +#include +#include #include #include @@ -118,8 +119,12 @@ CFrameBuffer* CFrameBuffer::getInstance() { static CFrameBuffer* frameBuffer = NULL; - if(!frameBuffer) { - frameBuffer = new CFrameBuffer(); + if (!frameBuffer) { +#if HAVE_SPARK_HARDWARE + frameBuffer = new CFbAccelSTi(); +#endif + if (!frameBuffer) + frameBuffer = new CFrameBuffer(); printf("[neutrino] %s Instance created\n", frameBuffer->fb_name); } return frameBuffer; @@ -715,6 +720,7 @@ void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) return; paintVLineRelInternal(x, y, dy, col); + mark(x, y, x, y + dy); } void CFrameBuffer::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col) @@ -731,6 +737,7 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) return; paintHLineRelInternal(x, dx, y, col); + mark(x, y, x + dx, y); } void CFrameBuffer::setIconBasePath(const std::string & iconPath) @@ -1245,6 +1252,7 @@ void CFrameBuffer::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t co paintPixel (x, y, col); } } + mark(xa, ya, xb, yb); } #if 0 //never used @@ -1533,6 +1541,7 @@ void CFrameBuffer::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * cons fbpos += stride; bkpos += dx; } + mark(x, y, x + dx, y + dy); checkFbArea(x, y, dx, dy, false); } #if 0 From cdd5767f6fa0ed07c55e2bc7edc3d406fa39bc9f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 22:50:23 +0100 Subject: [PATCH 15/40] fb_generic: fix blit2FB call Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f372d56e4183b8e9549186c3bcd3866e25b4fa1b Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 883e24d28..c9eb623a6 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -950,7 +950,7 @@ _display: checkFbArea(x, yy, width, height, true); if (paintBg) paintBoxRel(x, yy, width, height, colBg); - blit2FB(data, width, height, x, yy, 0, 0, true); + blit2FB(data, width, height, x, yy); checkFbArea(x, yy, width, height, false); return true; } From 7f0278a15836fde67c7d08c0a718e273acb8ab4c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 22:55:00 +0100 Subject: [PATCH 16/40] neutrino: initialize api before setting up framebuffer Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7504fe264eb8234f6f5c6598d04511b856d3fc36 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/neutrino.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 06c766e04..f7f43df83 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -227,14 +227,14 @@ CNeutrinoApp::CNeutrinoApp() : configfile('\t') { standby_pressed_at.tv_sec = 0; - - frameBuffer = CFrameBuffer::getInstance(); - frameBuffer->setIconBasePath(ICONSDIR); #if HAVE_TRIPLEDRAGON || USE_STB_HAL /* this needs to happen before the framebuffer is set up */ init_td_api(); // shutdown_td_api(); #endif + + frameBuffer = CFrameBuffer::getInstance(); + frameBuffer->setIconBasePath(ICONSDIR); SetupFrameBuffer(); mode = mode_unknown; From a5e26c170e4d93e76543647cdfcd589c35405dc4 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 23:03:22 +0100 Subject: [PATCH 17/40] fb_accel: add accelerated framebuffer for Nevis GXA chips Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9fffbef19da443a7ba343d50115fe2dc7e8063eb Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 1 + src/driver/fb_accel.h | 32 ++++ src/driver/fb_accel_cs.cpp | 313 +++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 3 + 4 files changed, 349 insertions(+) create mode 100644 src/driver/fb_accel_cs.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index b5e3e7012..96ca329eb 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -47,6 +47,7 @@ libneutrino_driver_a_SOURCES = \ if BOXTYPE_COOL libneutrino_driver_a_SOURCES += \ + fb_accel_cs.cpp \ vfd.cpp endif diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index af73b76ef..5e041fd88 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -32,6 +32,10 @@ #if HAVE_SPARK_HARDWARE #define PARTIAL_BLIT 1 #endif +#if HAVE_COOL_HARDWARE +/* not needed -- if you don't want acceleration, don't call CFbAccel ;) */ +#define USE_NEVIS_GXA 1 +#endif class CFbAccel : public CFrameBuffer @@ -78,4 +82,32 @@ class CFbAccelSTi void setBlendLevel(int); }; +class CFbAccelCS + : 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 add_gxa_sync_marker(void); + void setupGXA(void); + void setColor(fb_pixel_t col); + void run(void); + fb_pixel_t *backbuffer; + public: + CFbAccelCS(); + ~CFbAccelCS(); + 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); + 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); + fb_pixel_t * getBackBufferPointer() const; + void setBlendMode(uint8_t); + void setBlendLevel(int); +}; + #endif diff --git a/src/driver/fb_accel_cs.cpp b/src/driver/fb_accel_cs.cpp new file mode 100644 index 000000000..c4aeb21e4 --- /dev/null +++ b/src/driver/fb_accel_cs.cpp @@ -0,0 +1,313 @@ +/* + 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 . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/*******************************************************************************/ +#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_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_gxa] " +/* +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 CFbAccelCS::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 CFbAccelCS::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:""); +} + +CFbAccelCS::CFbAccelCS() +{ + fb_name = "Coolstream NEVIS GXA framebuffer"; +} + +void CFbAccelCS::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? */ + ; +}; + +CFbAccelCS::~CFbAccelCS() +{ + 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 CFbAccelCS::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 CFbAccelCS::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 CFbAccelCS::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + paintLine(x, y, x + 1, y, col); +} + +void CFbAccelCS::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +{ + 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 CFbAccelCS::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) +{ + int xc, yc; + xc = (width > xRes) ? xRes : width; + yc = (height > yRes) ? yRes : height; + (void)transp; + u32 cmd; + void *uKva; + + uKva = cs_phys_addr(fbbuff); + //printf("CFbAccelCS::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); + + 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; + } +#if 0 + for(int i = 0; i < yc; i++){ + memmove(clfb + (i + yoff)*stride + xoff*4, ip + (i + yp)*width + xp, xc*4); + } +#endif +} + +void CFbAccelCS::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); + add_gxa_sync_marker(); +} + +/* wrong name... */ +int CFbAccelCS::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; + 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 * CFbAccelCS::getBackBufferPointer() const +{ + return backbuffer; +} + +void CFbAccelCS::setBlendMode(uint8_t mode) +{ + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +} + +void CFbAccelCS::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"); +#ifndef BOXMODEL_APOLLO + if (level == 100) // TODO: sucks. + usleep(20000); +#endif +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index c9eb623a6..0096c5518 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -122,6 +122,9 @@ CFrameBuffer* CFrameBuffer::getInstance() if (!frameBuffer) { #if HAVE_SPARK_HARDWARE frameBuffer = new CFbAccelSTi(); +#endif +#if HAVE_COOL_HARDWARE + frameBuffer = new CFbAccelCS(); #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); From 23da2a34ef9d4233ddbf6c42c0f07b00bba2eeee Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:15:37 +0100 Subject: [PATCH 18/40] fb_accel: add backend for GL framebuffer Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/05d4017b36151d1cf9d1d4a97a9b006559fd7738 Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 1 + src/driver/fb_accel.h | 21 +++++ src/driver/fb_accel_glfb.cpp | 149 +++++++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 3 + 4 files changed, 174 insertions(+) create mode 100644 src/driver/fb_accel_glfb.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 96ca329eb..799bce061 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -68,6 +68,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/fb_accel.h b/src/driver/fb_accel.h index 5e041fd88..ee5604aa1 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -110,4 +110,25 @@ class CFbAccelCS 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_glfb.cpp b/src/driver/fb_accel_glfb.cpp new file mode 100644 index 000000000..f6784c48f --- /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) +{ + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); + 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_generic.cpp b/src/driver/fb_generic.cpp index 0096c5518..16409b2e7 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -125,6 +125,9 @@ CFrameBuffer* CFrameBuffer::getInstance() #endif #if HAVE_COOL_HARDWARE frameBuffer = new CFbAccelCS(); +#endif +#if HAVE_GENERIC_HARDWARE + frameBuffer = new CFbAccelGLFB(); #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); From 85ddd35ae0a38ddc4c1451e05d3350d2e8a4c2cd Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:52:16 +0100 Subject: [PATCH 19/40] reduce impact of driver/pictureviewer.h header file before, more than 175 files depended on it, now it's about 35 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3cbfacc360f2cf8d549b6cf862d565b9850f765e Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/components/cc_item_picture.cpp | 1 + src/gui/components/cc_item_picture.h | 1 - src/gui/moviebrowser/mb.h | 1 - src/gui/screensaver.cpp | 3 ++- src/gui/screensaver.h | 1 + src/gui/upnpbrowser.cpp | 1 + src/gui/upnpbrowser.h | 1 - 7 files changed, 5 insertions(+), 4 deletions(-) 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/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 176c34f7f..9dee3dbee 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -56,7 +56,6 @@ #include #include #include -#include #include #define MAX_NUMBER_OF_BOOKMARK_ITEMS MI_MOVIE_BOOK_USER_MAX // we just use the same size as used in Movie info (MAX_NUMBER_OF_BOOKMARK_ITEMS is used for the number of menu items) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 7c3b50b5a..d4558edd7 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include extern cVideo * videoDecoder; @@ -315,4 +316,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 4f47e3a69..0a9605561 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -30,6 +30,7 @@ #include class CFrameBuffer; +class CPictureViewer; class CScreenSaver : public sigc::trackable { private: diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 92b90d749..dfa79f6c9 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 409b785a8..105ec5fa1 100644 --- a/src/gui/upnpbrowser.h +++ b/src/gui/upnpbrowser.h @@ -24,7 +24,6 @@ #define __upnpplayergui__ #include -#include #include #include #include From ac9b04ab06b4792156d7ee8d7e7eaeffdc62b371 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 01:26:43 +0100 Subject: [PATCH 20/40] reduce impact of zapit/frontend_c.h header down from ~217 files to ~57... Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5f5369b7ad4d8803ee02131c165ae5c4e57a0a53 Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/record.h | 1 + src/gui/components/cc_frm_signalbars.cpp | 1 + src/gui/components/cc_frm_signalbars.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/driver/record.h b/src/driver/record.h index 7bd07e3d6..b377a6625 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/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index e120ed758..018ad066f 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -31,6 +31,7 @@ #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: From b23b11e91ca3a12c8bf13484043e93e2d4c9269f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:37:19 +0100 Subject: [PATCH 21/40] fb_generic: make paintLine virtual Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7e9dddeabda2f1c67313278f8bbb7f2099fdf292 Author: Stefan Seyfried Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 40541e0fa..d9ca28d46 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -209,7 +209,7 @@ class CFrameBuffer : public sigc::trackable 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); + virtual 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); From 8e9247b329ba97b9e2946e1b79129da39e217da8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:38:00 +0100 Subject: [PATCH 22/40] fb_generic: open device O_CLOEXEC, better diagnostic output Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2c015102660e6ca98c9f0a7c757e004d3e08f832 Author: Stefan Seyfried Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 16409b2e7..657f2e6e2 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -140,7 +140,7 @@ void CFrameBuffer::init(const char * const fbDevice) { int tr = 0xFF; - fd = open(fbDevice, O_RDWR); + fd = open(fbDevice, O_RDWR|O_CLOEXEC); if (fd<0) { perror(fbDevice); @@ -160,9 +160,8 @@ void CFrameBuffer::init(const char * const fbDevice) } available=fix.smem_len; - printf("[fb_generic] %dk video mem\n", available/1024); + printf("[fb_generic] [%s] framebuffer %dk video mem\n", fix.id, available/1024); lbb = lfb = (fb_pixel_t*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0); - if (!lfb) { perror("mmap"); goto nolfb; From acf341ee6a9c225a8fac71c5216332314ea1c9bf Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:53:54 +0100 Subject: [PATCH 23/40] fb_accel: add TripleDragon framebuffer code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ec1f030393d5e084dd4a595de86d68fec17e98f2 Author: Stefan Seyfried Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 1 + src/driver/fb_accel.h | 21 +++++ src/driver/fb_accel_td.cpp | 176 +++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 3 + 4 files changed, 201 insertions(+) create mode 100644 src/driver/fb_accel_td.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 799bce061..68bc2ed46 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -53,6 +53,7 @@ endif if BOXTYPE_TRIPLE libneutrino_driver_a_SOURCES += \ + fb_accel_td.cpp \ newclock.cpp \ lcdd.cpp endif diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index ee5604aa1..d84474d16 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -131,4 +131,25 @@ class CFbAccelGLFB fb_pixel_t * getBackBufferPointer() const; }; +class CFbAccelTD + : public CFbAccel +{ + private: + fb_pixel_t lastcol; + void setColor(fb_pixel_t col); + fb_pixel_t *backbuffer; + public: + CFbAccelTD(); + ~CFbAccelTD(); + 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 paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { paintLine(x, y, x + dx, y, col); }; + void paintVLineRel(int x, int y, int dy, const fb_pixel_t col) { paintLine(x, y, x, y + dy, col); }; + void paintLine(int xa, int ya, int xb, int yb, 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); +}; + #endif diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp new file mode 100644 index 000000000..7cddcfa3c --- /dev/null +++ b/src/driver/fb_accel_td.cpp @@ -0,0 +1,176 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent framebuffer acceleration functions for the + TripleDragon are represented in this class using DirectFB. + + License: GPL + + (C) 2017 Stefan Seyfried + + 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 + +#define LOGTAG "[fb_accel_td] " + +#include +#include +extern IDirectFB *dfb; +extern IDirectFBSurface *dfbdest; +extern int gfxfd; +void CFbAccelTD::waitForIdle(const char *) +{ +#if 0 + struct timeval ts, te; + gettimeofday(&ts, NULL); +#endif + /* does not work: DFBResult r = dfb->WaitForSync(dfb); */ + ioctl(gfxfd, STB04GFX_ENGINE_SYNC); +#if 0 + gettimeofday(&te, NULL); + printf("STB04GFX_ENGINE_SYNC took %lld us\n", (te.tv_sec * 1000000LL + te.tv_usec) - (ts.tv_sec * 1000000LL + ts.tv_usec)); +#endif +} + +CFbAccelTD::CFbAccelTD() +{ + fb_name = "TripleDragon framebuffer"; + lastcol = 0xffffffff; + lbb = lfb; /* the memory area to draw to... */ +}; + +CFbAccelTD::~CFbAccelTD() +{ + if (lfb) + munmap(lfb, available); + if (fd > -1) + close(fd); +} + +void CFbAccelTD::setColor(fb_pixel_t col) +{ + if (col == lastcol) + return; + char *c = (char *)&col; + dfbdest->SetColor(dfbdest, c[1], c[2], c[3], c[0]); + lastcol = col; +} + +void CFbAccelTD::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) +{ + setColor(col); + dfbdest->FillRectangle(dfbdest, x, y, dx, dy); +} + +void CFbAccelTD::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + setColor(col); + dfbdest->DrawLine(dfbdest, x, y, x, y); +} + +void CFbAccelTD::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +{ + setColor(col); + dfbdest->DrawLine(dfbdest, xa, ya, xb, yb); +} + +void CFbAccelTD::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) +{ + DFBRectangle src; + DFBResult err; + IDirectFBSurface *surf; + DFBSurfaceDescription dsc; + + src.x = xp; + src.y = yp; + src.w = width - xp; + src.h = height - yp; + + dsc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PREALLOCATED); + dsc.caps = DSCAPS_NONE; + dsc.width = width; + dsc.height = height; + dsc.preallocated[0].data = fbbuff; + dsc.preallocated[0].pitch = width * sizeof(fb_pixel_t); + err = dfb->CreateSurface(dfb, &dsc, &surf); + /* TODO: maybe we should not die if this fails? */ + if (err != DFB_OK) { + fprintf(stderr, LOGTAG "blit2FB: "); + DirectFBErrorFatal("dfb->CreateSurface(dfb, &dsc, &surf)", err); + } + + if (transp) + { + surf->SetSrcColorKey(surf, 0, 0, 0); + dfbdest->SetBlittingFlags(dfbdest, DSBLIT_SRC_COLORKEY); + } + else + dfbdest->SetBlittingFlags(dfbdest, DSBLIT_BLEND_ALPHACHANNEL); + + dfbdest->Blit(dfbdest, surf, &src, xoff, yoff); + surf->Release(surf); + return; +} + +void CFbAccelTD::init(const char *) +{ + 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... */ + available = fix.smem_len; + stride = fix.line_length; + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + + return; +} + +/* wrong name... */ +int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int) +{ + 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; +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 657f2e6e2..53ccf5be6 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -128,6 +128,9 @@ CFrameBuffer* CFrameBuffer::getInstance() #endif #if HAVE_GENERIC_HARDWARE frameBuffer = new CFbAccelGLFB(); +#endif +#if HAVE_TRIPLEDRAGON + frameBuffer = new CFbAccelTD(); #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); From 237bcba91bb5e8882a5aacdc02aea171498393a3 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 9 Feb 2017 00:01:08 +0100 Subject: [PATCH 24/40] fb_generic: remove unused VT switching / restoring code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/cb3710eaed9880bea57cf3dc2185c54e4a5c349a Author: Stefan Seyfried Date: 2017-02-09 (Thu, 09 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 107 -------------------------------------- src/driver/fb_generic.h | 2 +- 2 files changed, 1 insertion(+), 108 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 53ccf5be6..6a89a789d 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -155,8 +155,6 @@ void CFrameBuffer::init(const char * const fbDevice) goto nolfb; } - memmove(&oldscreen, &screeninfo, sizeof(screeninfo)); - if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0) { perror("FBIOGET_FSCREENINFO"); goto nolfb; @@ -196,52 +194,6 @@ void CFrameBuffer::init(const char * const fbDevice) 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; @@ -276,13 +228,6 @@ CFrameBuffer::~CFrameBuffer() 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); @@ -379,31 +324,6 @@ int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsign 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; @@ -1552,33 +1472,6 @@ void CFrameBuffer::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * cons 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() { diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index d9ca28d46..67ef515f6 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -113,7 +113,7 @@ class CFrameBuffer : public sigc::trackable std::string backgroundFilename; bool useBackgroundPaint; unsigned int xRes, yRes, stride, bpp; - t_fb_var_screeninfo screeninfo, oldscreen; + t_fb_var_screeninfo screeninfo; fb_cmap cmap; __u16 red[256], green[256], blue[256], trans[256]; From 3cad7ad4be6b5f2ca80a411a70eb19c7d8ffe40d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 9 Feb 2017 00:01:50 +0100 Subject: [PATCH 25/40] fontrenderer: add hack to work around broken fullBG code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0f4e6298c8e1a0dbb6e63cfb61054092cd070f49 Author: Stefan Seyfried Date: 2017-02-09 (Thu, 09 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fontrenderer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index f15ad5297..bf36f897a 100644 --- a/src/driver/fontrenderer.cpp +++ b/src/driver/fontrenderer.cpp @@ -425,7 +425,13 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f return; const bool utf8_encoded = flags & IS_UTF8; +#if HAVE_TRIPLEDRAGON + /* the TD Framebufffer is ARGB; the others are BGRA. The fullbg code does not handle that + * the quick workaround is to just disable the fullbg flag */ + useFullBG = false; +#else useFullBG = flags & FULLBG; +#endif /* useFullBg = false fetch bgcolor from framebuffer, using lower left edge of the font From 4df9cc95bbb1440209d3204c6da568c04401b717 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 Feb 2017 11:25:24 +0100 Subject: [PATCH 26/40] remove udpstreampes from build, it's unlikely to work anyway Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/04789c385183fd67434a4ed27e190c5784b23d62 Author: Stefan Seyfried Date: 2017-02-11 (Sat, 11 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/zapit/src/Makefile.am | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/zapit/src/Makefile.am b/src/zapit/src/Makefile.am index af2c71f3c..a8e7a9cdb 100644 --- a/src/zapit/src/Makefile.am +++ b/src/zapit/src/Makefile.am @@ -38,7 +38,6 @@ libzapit_a_SOURCES += \ endif bin_PROGRAMS = pzapit -sbin_PROGRAMS = udpstreampes pzapit_SOURCES = \ pzapit.cpp @@ -48,12 +47,3 @@ pzapit_LDADD = \ $(top_builddir)/lib/connection/libtuxbox-connection.a \ -lOpenThreads \ -lpthread - -udpstreampes_SOURCES = \ - udpstreampes.cpp - -udpstreampes_LDADD = \ - $(top_builddir)/src/zapit/lib/libzapitclient.a \ - $(top_builddir)/lib/connection/libtuxbox-connection.a \ - -lOpenThreads \ - -lpthread From d4861ff1660359ff651123040f186e2586734ffb Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 Feb 2017 14:42:15 +0100 Subject: [PATCH 27/40] remove unnecessary sectionsdclient.h includes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4226ba01d2f077dde0089f069be86dd733aa3f34 Author: Stefan Seyfried Date: 2017-02-11 (Sat, 11 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/epgview.h | 2 -- src/gui/eventlist.h | 1 - src/gui/infoviewer_bb.h | 2 -- src/nhttpd/tuxboxapi/neutrinoapi.h | 1 - 4 files changed, 6 deletions(-) diff --git a/src/gui/epgview.h b/src/gui/epgview.h index 4fe60f9de..b66360d44 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -39,8 +39,6 @@ #include #include "widget/menue.h" -#include - #include #include diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index c0c15af52..90542ba26 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -28,7 +28,6 @@ #define __EVENTLIST_HPP__ #include -#include #include #include diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index e664e516d..753e32a2e 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -33,8 +33,6 @@ #ifndef __infoview_bb__ #define __infoview_bb__ -#include - #include #include #include diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.h b/src/nhttpd/tuxboxapi/neutrinoapi.h index 82c9abbf3..5936e194b 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.h +++ b/src/nhttpd/tuxboxapi/neutrinoapi.h @@ -7,7 +7,6 @@ // tuxbox #include -#include #include #include From 039d221849e276ffcecfaa4a6952277804ce9a98 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 Feb 2017 14:45:37 +0100 Subject: [PATCH 28/40] sectionsdclient: remove unused scanMode variable Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6d73a4465d3d828882e6364e4d56cecfc2324357 Author: Stefan Seyfried Date: 2017-02-11 (Sat, 11 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/sectionsdclient/sectionsdMsg.h | 2 -- lib/sectionsdclient/sectionsdclient.cpp | 1 - lib/sectionsdclient/sectionsdclient.h | 1 - 3 files changed, 4 deletions(-) diff --git a/lib/sectionsdclient/sectionsdMsg.h b/lib/sectionsdclient/sectionsdMsg.h index 440feabae..fb71f8322 100644 --- a/lib/sectionsdclient/sectionsdMsg.h +++ b/lib/sectionsdclient/sectionsdMsg.h @@ -92,7 +92,6 @@ struct sectionsd struct commandSetConfig { - int scanMode; int epg_cache; int epg_old_events; unsigned int epg_max_events; @@ -327,7 +326,6 @@ struct sectionsd // // setConfig // data of request: -// int scanMode; -> updating of services and bouquets -> saved in auto_scanning // int epg_cache; -> in days -> saved in secondsToCache // int epg_old_events; -> in hours -> saved in oldEventsAre // unsigned int epg_max_events; -> #of saved events -> saved in max_events diff --git a/lib/sectionsdclient/sectionsdclient.cpp b/lib/sectionsdclient/sectionsdclient.cpp index 5628b9ab5..cd5769996 100644 --- a/lib/sectionsdclient/sectionsdclient.cpp +++ b/lib/sectionsdclient/sectionsdclient.cpp @@ -208,7 +208,6 @@ void CSectionsdClient::setConfig(const epg_config config) char* pData = new char[sizeof(sectionsd::commandSetConfig) + config.network_ntpserver.length() + 1 + config.epg_dir.length() + 1]; msg = (sectionsd::commandSetConfig *)pData; - msg->scanMode = config.scanMode; msg->epg_cache = config.epg_cache; msg->epg_old_events = config.epg_old_events; msg->epg_max_events = config.epg_max_events; diff --git a/lib/sectionsdclient/sectionsdclient.h b/lib/sectionsdclient/sectionsdclient.h index f0ca63a88..e9d8b16a3 100644 --- a/lib/sectionsdclient/sectionsdclient.h +++ b/lib/sectionsdclient/sectionsdclient.h @@ -163,7 +163,6 @@ class CSectionsdClient : private CBasicClient typedef struct { - int scanMode; int epg_cache; int epg_old_events; int epg_max_events; From 665c00a1bc33f0ea61ac3039e9b527e8566cfaaf Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 Feb 2017 18:52:39 +0100 Subject: [PATCH 29/40] fb_accel_td: implement setBlendMode/Level Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3d2b56713f79e28c9b2e475077fe8f81f09105cb Author: Stefan Seyfried Date: 2017-02-11 (Sat, 11 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_accel.h | 2 ++ src/driver/fb_accel_td.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index d84474d16..b0a11a334 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -150,6 +150,8 @@ class CFbAccelTD void paintLine(int xa, int ya, int xb, int yb, 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 setBlendMode(uint8_t); + void setBlendLevel(int); }; #endif diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp index 7cddcfa3c..af3bf8f60 100644 --- a/src/driver/fb_accel_td.cpp +++ b/src/driver/fb_accel_td.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -143,6 +144,7 @@ void CFbAccelTD::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t void CFbAccelTD::init(const char *) { CFrameBuffer::init(); + fcntl(fd, F_SETFD, FD_CLOEXEC); if (lfb == NULL) { printf(LOGTAG "CFrameBuffer::init() failed.\n"); return; /* too bad... */ @@ -174,3 +176,29 @@ int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int) backbuffer = lfb; /* will not work well, but avoid crashes */ return 0; } + +void CFbAccelTD::setBlendMode(uint8_t mode) +{ + Stb04GFXOsdControl g; + ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g); + g.use_global_alpha = (mode == 2); /* 1 == pixel alpha, 2 == global alpha */ + ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g); +} + +void CFbAccelTD::setBlendLevel(int level) +{ + /* this is bypassing directfb, but faster and easier */ + Stb04GFXOsdControl g; + ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g); + if (g.use_global_alpha == 0) + return; + + if (level < 0 || level > 100) + return; + + /* this is the same as convertSetupAlpha2Alpha(), but non-float */ + g.global_alpha = 255 - (255 * level / 100); + ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g); + if (level == 100) // sucks + usleep(20000); +} From 9a6e8fecc380c65b6aaa1aab001c6c929428d708 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 11 Feb 2017 18:54:50 +0100 Subject: [PATCH 30/40] fb_generic: initialization and deinitialization fixes * initialize variables locked and cache_size in constructor * set lfb pointer to NULL after munmap(), fd to -1 after close * remove unused tty fd close() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/821c6a490d376c4b95ae0c2a4274c72f1bc7c983 Author: Stefan Seyfried Date: 2017-02-11 (Sat, 11 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 6a89a789d..9fbfffd09 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -82,6 +82,7 @@ CFrameBuffer::CFrameBuffer() fb_name = "generic framebuffer"; iconBasePath = ""; available = 0; + cache_size = 0; cmap.start = 0; cmap.len = 256; cmap.red = red; @@ -93,6 +94,7 @@ CFrameBuffer::CFrameBuffer() background = NULL; backupBackground = NULL; backgroundFilename = ""; + locked = false; fd = 0; tty = 0; m_transparent_default = CFrameBuffer::TM_BLACK; // TM_BLACK: Transparency when black content ('pseudo' transparency) @@ -168,8 +170,6 @@ void CFrameBuffer::init(const char * const fbDevice) goto nolfb; } - cache_size = 0; - /* Windows Colors */ paletteSetColor(0x1, 0x010101, tr); paletteSetColor(0x2, 0x800000, tr); @@ -230,13 +230,14 @@ CFrameBuffer::~CFrameBuffer() if (lfb) munmap(lfb, available); + lfb = NULL; if (virtual_fb){ delete[] virtual_fb; virtual_fb = NULL; } close(fd); - close(tty); + fd = -1; v_fbarea.clear(); } From c35236e9b5b23bf592f1e3ab3c78dc6f24b727d4 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 11:48:01 +0100 Subject: [PATCH 31/40] zapit: speed up scan by skipping unsupported delivery systems Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/736828f56c7d794ef9bc798d76f6f5d703574fbf Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/zapit/src/scan.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/zapit/src/scan.cpp b/src/zapit/src/scan.cpp index 32d6c3088..6c190c330 100644 --- a/src/zapit/src/scan.cpp +++ b/src/zapit/src/scan.cpp @@ -141,6 +141,11 @@ void CServiceScan::CleanAllMaps() bool CServiceScan::tuneFrequency(FrontendParameters *feparams, t_satellite_position satellitePosition) { + if (! frontend->supportsDelivery(feparams->delsys)) { + printf("[scan] [fe%d] does not support delivery system %d, skipping\n", + frontend->getNumber(), feparams->delsys); + return false; + } frontend->setInput(satellitePosition, feparams->frequency, feparams->polarization); int ret = frontend->driveToSatellitePosition(satellitePosition, false); //true); if(ret > 0) { From 872745ffe264b23e48f17b127f7b7c7e3deaf85d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 12:05:03 +0100 Subject: [PATCH 32/40] getservices: don't update channels if only scrambling changed Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a68f2f73b6ea1d1441c5986bb1f1ee570a267113 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/zapit/src/getservices.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index a9544bb73..ff9e3477a 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -1109,7 +1109,11 @@ bool CServiceManager::CopyCurrentServices(transponder_id_t tpid) updated = true; printf("CServiceManager::CopyCurrentServices: [%s] add\n", cI->second.getName().c_str()); } else { - if(cI->second.scrambled != aI->second.scrambled || cI->second.getName() != aI->second.getName()) { + if (cI->second.getName() != aI->second.getName() +#ifdef UPDATE_CHANNELS_ON_SCRAMBLED_CHANGE + || cI->second.scrambled != aI->second.scrambled +#endif + ) { aI->second.setName(cI->second.getName()); aI->second.scrambled = cI->second.scrambled; aI->second.flags = CZapitChannel::UPDATED; @@ -1217,7 +1221,11 @@ bool CServiceManager::SaveCurrentServices(transponder_id_t tpid) if(ccI == allchans.end()) { WriteCurrentService(fd, satfound, tpdone, updated, satstr, tI->second, cI->second, "add"); } else { - if(strcmp(cI->second.getRealname().c_str(), ccI->second.getRealname().c_str()) || cI->second.scrambled != ccI->second.scrambled) { + if (strcmp(cI->second.getRealname().c_str(), ccI->second.getRealname().c_str()) +#ifdef UPDATE_CHANNELS_ON_SCRAMBLED_CHANGE + || cI->second.scrambled != ccI->second.scrambled +#endif + ) { cI->second.number = ccI->second.number; WriteCurrentService(fd, satfound, tpdone, updated, satstr, tI->second, cI->second, "replace"); } From 0650172ae3cef64196fd1a083eb607840f6721cd Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 14:09:40 +0100 Subject: [PATCH 33/40] cc: reduce impact of cc_draw header from 161 to 4 files Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f576cb075e666b7188ba59957614071df4d79658 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_draw.cpp | 3 ++- src/gui/components/cc_draw.h | 2 +- src/gui/components/cc_frm_clock.cpp | 1 + src/gui/components/cc_frm_clock.h | 2 +- src/gui/widget/hintbox.cpp | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index b9035e8db..cedebc332 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -25,6 +25,7 @@ #include #include #include "cc_draw.h" +#include "cc_timer.h" #include #include @@ -794,4 +795,4 @@ bool CCDraw::cancelBlink(bool keep_on_screen) return res; -} \ No newline at end of file +} diff --git a/src/gui/components/cc_draw.h b/src/gui/components/cc_draw.h index a144433ec..50be8a71d 100644 --- a/src/gui/components/cc_draw.h +++ b/src/gui/components/cc_draw.h @@ -27,7 +27,6 @@ #include "cc_types.h" #include "cc_signals.h" -#include "cc_timer.h" #include #include #include @@ -38,6 +37,7 @@ Basic paint attributes and member functions for component classes */ +class CComponentsTimer; class CCDraw : public COSDFader, public CComponentsSignals { protected: diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index b52180456..531c1af89 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -29,6 +29,7 @@ #include #include "cc_frm_clock.h" +#include "cc_timer.h" #include #include diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 22da0af26..23eb726ce 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -34,13 +34,13 @@ #include #include "cc_base.h" #include "cc_frm.h" -#include "cc_timer.h" #include "cc_text_screen.h" //! Sub class of CComponents. Show clock with digits on screen. /*! Usable as simple fixed display or as ticking clock. */ +class CComponentsTimer; class CComponentsFrmClock : public CComponentsForm, public CCTextScreen { private: diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 9e367f4d2..4b61201ce 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -34,6 +34,7 @@ #include #include #include "hintbox.h" +#include #include #include From 4a8dcb3a08b405ffe17e15b503e94671da70f718 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 14:46:42 +0100 Subject: [PATCH 34/40] CComponentsTimer: allow to set a thread name Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/cece5efac48a8933ff0f1891eb12c0ebe7501b93 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_timer.cpp | 5 ++++- src/gui/components/cc_timer.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index 11ae9b35e..a7b7e13ca 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -33,11 +33,13 @@ #include #include #include +#include using namespace std; CComponentsTimer::CComponentsTimer(const int& interval, bool is_nano) { + name = "unnamed"; tm_thread = 0; tm_interval = interval; tm_enable_nano = is_nano; @@ -56,7 +58,8 @@ CComponentsTimer::~CComponentsTimer() void CComponentsTimer::runSharedTimerAction() { //start loop - + string tn = "cc:"+name; + set_threadname(tn.c_str()); while(tm_enable && tm_interval > 0) { tm_mutex.lock(); OnTimer(); diff --git a/src/gui/components/cc_timer.h b/src/gui/components/cc_timer.h index 530224f40..c7e2d21cd 100644 --- a/src/gui/components/cc_timer.h +++ b/src/gui/components/cc_timer.h @@ -63,6 +63,9 @@ class CComponentsTimer : public sigc::trackable ///flag to control thread state bool tm_enable; + ///name for the thread + std::string name; + ///mutex for timer OpenThreads::Mutex tm_mutex; ///slot for restart signals @@ -120,6 +123,13 @@ class CComponentsTimer : public sigc::trackable */ void setTimerInterval(const int& interval, bool is_nano = false); + /**set thread name + * @param[in] thread name + * @return + * void + */ + void setThreadName(const std::string& n) { name = n; }; + /**Provides a signal handler to receive any function or methode. * Use this in your class where ever you need time controled actions. * From b8cc9f3d5cd8c2139c15dc2ea2b33f387afe75cd Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 15:17:32 +0100 Subject: [PATCH 35/40] set useful thread names for all spawned threads Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b9da7f01bf9e3cc22d970f8f69f79f657490153e Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libdvbsub/dvbsub.cpp | 4 +++- lib/libtuxtxt/tuxtxt.cpp | 2 ++ lib/libtuxtxt/tuxtxt_common.h | 2 ++ src/driver/audioplay.cpp | 2 ++ src/driver/lcdd.cpp | 2 ++ src/driver/netfile.cpp | 2 ++ src/driver/shutdown_count.cpp | 2 ++ src/driver/simple_display.cpp | 3 +++ src/eitd/sectionsd.cpp | 1 + src/gui/components/cc_draw.cpp | 1 + src/gui/components/cc_frm_clock.cpp | 1 + src/gui/widget/hintbox.cpp | 5 +++-- src/nhttpd/yhttpd_core/ywebserver.cpp | 2 +- src/timerd/timerd.cpp | 3 ++- src/timerd/timermanager.cpp | 3 ++- 15 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/libdvbsub/dvbsub.cpp b/lib/libdvbsub/dvbsub.cpp index 648735757..b8e945c59 100644 --- a/lib/libdvbsub/dvbsub.cpp +++ b/lib/libdvbsub/dvbsub.cpp @@ -15,6 +15,7 @@ #include "PacketQueue.hpp" #include "helpers.hpp" #include "dvbsubtitle.h" +#include #define Log2File printf #define RECVBUFFER_STEPSIZE 1024 @@ -244,6 +245,7 @@ static void* reader_thread(void * /*arg*/) uint16_t packlen; uint8_t* buf; bool bad_startcode = false; + set_threadname("dvbsub:reader"); dmx = new cDemux(0); #if HAVE_TRIPLEDRAGON @@ -347,7 +349,7 @@ static void* dvbsub_thread(void* /*arg*/) { struct timespec restartWait; struct timeval now; - + set_threadname("dvbsub:main"); sub_debug.print(Debug::VERBOSE, "%s started\n", __FUNCTION__); if (!dvbSubtitleConverter) dvbSubtitleConverter = new cDvbSubtitleConverter; diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index b26e48e37..c6f5f4ce9 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -22,6 +22,7 @@ #include #include #include +#include /* same as in rcinput.h... */ #define KEY_TTTV KEY_FN_1 @@ -1545,6 +1546,7 @@ static void cleanup_fb_pan() static void* reader_thread(void * /*arg*/) { printf("TuxTxt subtitle thread started\n"); + set_threadname("tuxtxt:reader"); reader_running = 1; //ttx_paused = 0; while(reader_running) { diff --git a/lib/libtuxtxt/tuxtxt_common.h b/lib/libtuxtxt/tuxtxt_common.h index a7f1eede8..0abbf87c1 100644 --- a/lib/libtuxtxt/tuxtxt_common.h +++ b/lib/libtuxtxt/tuxtxt_common.h @@ -14,6 +14,7 @@ #endif #include +#include tuxtxt_cache_struct tuxtxt_cache; static pthread_mutex_t tuxtxt_cache_lock = PTHREAD_MUTEX_INITIALIZER; @@ -593,6 +594,7 @@ void *tuxtxt_CacheThread(void * /*arg*/) unsigned char pagedata[9][23*40]; tstPageinfo *pageinfo_thread; + set_threadname("tuxtxt:cache"); printf("TuxTxt running thread...(%04x)\n",tuxtxt_cache.vtxtpid); tuxtxt_cache.receiving = 1; nice(3); diff --git a/src/driver/audioplay.cpp b/src/driver/audioplay.cpp index 4359956ba..956319297 100644 --- a/src/driver/audioplay.cpp +++ b/src/driver/audioplay.cpp @@ -43,6 +43,7 @@ #include #include #include // UTF8 +#include void CAudioPlayer::stop() { @@ -88,6 +89,7 @@ CAudioPlayer* CAudioPlayer::getInstance() void* CAudioPlayer::PlayThread( void* /*dummy*/ ) { int soundfd = -1; + set_threadname("audio:play"); g_RCInput->close_click(); /* Decode stdin to stdout. */ CBaseDec::RetCode Status = diff --git a/src/driver/lcdd.cpp b/src/driver/lcdd.cpp index 1b28ec365..982780144 100644 --- a/src/driver/lcdd.cpp +++ b/src/driver/lcdd.cpp @@ -47,6 +47,7 @@ #include #include +#include #include extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ @@ -154,6 +155,7 @@ void CLCD::wake_up() { #ifndef BOXMODEL_DM500 void* CLCD::TimeThread(void *p) { + set_threadname("lcd:time"); ((CLCD *)p)->thread_started = true; while (((CLCD *)p)->thread_started) { diff --git a/src/driver/netfile.cpp b/src/driver/netfile.cpp index 458e4dabf..9b9add628 100644 --- a/src/driver/netfile.cpp +++ b/src/driver/netfile.cpp @@ -108,6 +108,7 @@ #include #include #include +#include /* TODO: - ICECAST support @@ -1603,6 +1604,7 @@ void CacheFillThread(void *c) if(scache->closed) return; + set_threadname("netfile:cache"); dprintf(stderr, "CacheFillThread: thread started, using stream %p\n", scache->fd); buf = (char*)malloc(CACHEBTRANS); diff --git a/src/driver/shutdown_count.cpp b/src/driver/shutdown_count.cpp index 43d55f22c..e8e4ac9ce 100644 --- a/src/driver/shutdown_count.cpp +++ b/src/driver/shutdown_count.cpp @@ -37,6 +37,7 @@ #include #include #include +#include SHTDCNT::SHTDCNT() @@ -68,6 +69,7 @@ SHTDCNT* SHTDCNT::getInstance() void* SHTDCNT::TimeThread(void *) { + set_threadname("n:shtdcnt"); while(1) { sleep(1); diff --git a/src/driver/simple_display.cpp b/src/driver/simple_display.cpp index 1eeb1100e..df158909a 100644 --- a/src/driver/simple_display.cpp +++ b/src/driver/simple_display.cpp @@ -45,6 +45,8 @@ #define DISPLAY_DEV "/dev/null" #endif +#include + static char volume = 0; //static char percent = 0; static bool power = true; @@ -149,6 +151,7 @@ void CLCD::wake_up() void* CLCD::TimeThread(void *) { + set_threadname("n:boxdisplay"); /* to not confuse with TV display */ while (CLCD::getInstance()->thread_running) { sleep(1); CLCD::getInstance()->showTime(); diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 962b950df..cd32f66be 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -2110,6 +2110,7 @@ static void print_meminfo(void) static void *houseKeepingThread(void *) { int count = 0, scount = 0, ecount = 0; + set_threadname("sd:housekeeping"); dprintf("housekeeping-thread started.\n"); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index cedebc332..9ca52c03c 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -775,6 +775,7 @@ bool CCDraw::paintBlink(const int& interval, bool is_nano) { if (cc_draw_timer == NULL) cc_draw_timer = new CComponentsTimer(interval, is_nano); + cc_draw_timer->setThreadName(__func__); return paintBlink(cc_draw_timer); } diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 531c1af89..0f4329ea3 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -321,6 +321,7 @@ bool CComponentsFrmClock::startClock() if (cl_timer == NULL){ cl_timer = new CComponentsTimer(0); + cl_timer->setThreadName("frmClock"); if (cl_timer->OnTimer.empty()){ dprintf(DEBUG_INFO,"\033[33m[CComponentsFrmClock]\t[%s] init slot...\033[0m\n", __func__); cl_timer->OnTimer.connect(cl_sl_show); diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 4b61201ce..45ef2b6ed 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -188,8 +188,10 @@ void CHintBox::enableTimeOutBar(bool enable) timeout_pb = new CProgressBar(); timeout_pb->setDimensionsAll(ccw_body->getRealXPos(), ccw_body->getRealYPos(), ccw_body->getWidth(), TIMEOUT_BAR_HEIGHT); timeout_pb->setValues(0, 100*timeout); - if (!timeout_pb_timer) + if (!timeout_pb_timer) { timeout_pb_timer = new CComponentsTimer(1, true); + timeout_pb_timer->setThreadName("hb:tmoutbar"); + } timeout_pb_timer->OnTimer.connect(sigc::mem_fun0(this, &CHintBox::showTimeOutBar)); timeout_pb_timer->startTimer(); } @@ -200,7 +202,6 @@ int CHintBox::exec() neutrino_msg_t msg; neutrino_msg_data_t data; int res = messages_return::none; - if (timeout == NO_TIMEOUT || timeout == DEFAULT_TIMEOUT) timeout = HINTBOX_DEFAULT_TIMEOUT; diff --git a/src/nhttpd/yhttpd_core/ywebserver.cpp b/src/nhttpd/yhttpd_core/ywebserver.cpp index 0a8b4d77a..e1a5f149d 100644 --- a/src/nhttpd/yhttpd_core/ywebserver.cpp +++ b/src/nhttpd/yhttpd_core/ywebserver.cpp @@ -118,7 +118,7 @@ CWebserver::~CWebserver() { #define MAX_TIMEOUTS_TO_CLOSE 10 #define MAX_TIMEOUTS_TO_TEST 100 bool CWebserver::run(void) { - set_threadname(__func__); + set_threadname("ywebsrv::run"); if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) { if (port != 80) { fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port); diff --git a/src/timerd/timerd.cpp b/src/timerd/timerd.cpp index f113f3dba..7b98bfd43 100644 --- a/src/timerd/timerd.cpp +++ b/src/timerd/timerd.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "debug.h" #include "timermanager.h" @@ -480,7 +481,7 @@ bool timerd_parse_command(CBasicMessage::Header &rmsg, int connfd) int timerd_main_thread(void *data) { pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); - + set_threadname("n:timerd"); printf("timerd startup, tid %ld\n", syscall(__NR_gettid)); CBasicServer timerd_server; diff --git a/src/timerd/timermanager.cpp b/src/timerd/timermanager.cpp index fec447b79..8998ea2d2 100644 --- a/src/timerd/timermanager.cpp +++ b/src/timerd/timermanager.cpp @@ -42,7 +42,7 @@ #include "debug.h" #include "timermanager.h" - +#include extern bool timeset; time_t timer_minutes; @@ -89,6 +89,7 @@ void* CTimerManager::timerThread(void *arg) pthread_mutex_t dummy_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t dummy_cond = PTHREAD_COND_INITIALIZER; struct timespec wait; + set_threadname("n:timermanager"); CTimerManager *timerManager = (CTimerManager*) arg; From f028e0d9419f51ac3f718c7886e3d45e3e8b1473 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 15:18:35 +0100 Subject: [PATCH 36/40] remove spurious newlines from debug output Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1fa91ad1369d8b6e14836f99168b20320eb8b441 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/scanepg.cpp | 2 +- src/zapit/src/femanager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driver/scanepg.cpp b/src/driver/scanepg.cpp index 3cd7e0280..2ea208d61 100644 --- a/src/driver/scanepg.cpp +++ b/src/driver/scanepg.cpp @@ -91,7 +91,7 @@ void CEpgScan::ConfigureEIT() count++; } } - INFO("added %d channels to EIT white list\n", count); + INFO("added %d channels to EIT white list", count); } void CEpgScan::Clear() diff --git a/src/zapit/src/femanager.cpp b/src/zapit/src/femanager.cpp index 001987184..ad6db6b83 100644 --- a/src/zapit/src/femanager.cpp +++ b/src/zapit/src/femanager.cpp @@ -113,7 +113,7 @@ bool CFEManager::Init() for (unsigned i = 0; i < MAX_DMX_UNITS; i++) dmap.push_back(CFeDmx(i)); - INFO("found %d frontends, %d demuxes\n", (int)femap.size(), (int)dmap.size()); + INFO("found %d frontends, %d demuxes", (int)femap.size(), (int)dmap.size()); /* for testing without a frontend, export SIMULATE_FE=1 */ if (femap.empty() && getenv("SIMULATE_FE")) { INFO("SIMULATE_FE is set, adding dummy frontend for testing"); @@ -477,7 +477,7 @@ void CFEManager::linkFrontends(bool init) for(unsigned i = 0; i < MAX_DMX_UNITS; i++) { if (demuxes[i] == 0) { unused_demux = i; - INFO("pip demux: %d\n", unused_demux); + INFO("pip demux: %d", unused_demux); break; } } From 98d1d74640eadfc8d794fcdb9a5d869b3d3077ed Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 15:19:51 +0100 Subject: [PATCH 37/40] neutrino: move start of standby epgscan forward this avoids that cpufreq is set to standby value before epgscan is started, resulting in poor performance Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4f23baae1e8f264c0c8097f77db887d4a08dd2f2 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ This commit was generated by Migit --- src/neutrino.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index a14afa8d0..1e5bce7b6 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -3975,6 +3975,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) puts("[neutrino.cpp] executing " NEUTRINO_ENTER_STANDBY_SCRIPT "."); if (my_system(NEUTRINO_ENTER_STANDBY_SCRIPT) != 0) perror(NEUTRINO_ENTER_STANDBY_SCRIPT " failed"); + CEpgScan::getInstance()->Start(true); bool alive = recordingstatus || CEpgScan::getInstance()->Running() || CStreamManager::getInstance()->StreamStatus(); if(!alive) @@ -3987,7 +3988,6 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby ) frameBuffer->setActive(false); // Active standby on powerManager->SetStandby(false, false); - CEpgScan::getInstance()->Start(true); if (scansettings.fst_update) fst_timer = g_RCInput->addTimer(30*1000*1000, true); } else { From 7412207ebfea86ba0cae4116171fd4a43e865c8e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 15:25:58 +0100 Subject: [PATCH 38/40] zapit: disable spark hack, seems no longer necessary Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6c46b8fc370fa574cbd0d039104e651a5a48ed37 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/zapit/src/zapit.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index d6b260cf3..2dd528e43 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -2611,7 +2611,8 @@ static bool zapit_parse_command(CBasicMessage::Header &rmsg, int connfd) void CZapit::run() { -#if HAVE_SPARK_HARDWARE +//if HAVE_SPARK_HARDWARE +#if 0 bool v_stopped = false; #endif set_threadname("zap:main"); @@ -2659,7 +2660,8 @@ void CZapit::run() SendEvent(CZapitClient::EVT_PMT_CHANGED, &channel_id, sizeof(channel_id)); } } -#if HAVE_SPARK_HARDWARE +//if HAVE_SPARK_HARDWARE +#if 0 /* hack: stop videodecoder if the tuner looses lock * at least the h264 decoder seems unhappy if he runs out of data... * ...until we fix the driver, let's work around it here. From 0c2a23bb2214d35984b51d153d010f491373073f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 16:56:10 +0100 Subject: [PATCH 39/40] streamts: don't overflow receive buffer, better diag message Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ec3201ab044b68c5f39ef64f9e00af85b1128432 Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/streamts.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index 8db18c81c..8af0fb449 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -371,9 +371,11 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro bp = &cbuf[0]; /* read one line */ - while (bp - &cbuf[0] < (int) sizeof(cbuf)) { + while (bp - &cbuf[0] < (int) sizeof(cbuf) - 1) { unsigned char c; int res = read(fd, &c, 1); + if (res == 0) + break; if (res < 0) { perror("read"); return false; @@ -381,12 +383,11 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid, CFro if ((*bp++ = c) == '\n') break; } + *bp = 0; - *bp++ = 0; + printf("CStreamManager::Parse: got %d bytes '%s'", (int)(bp-&cbuf[0]), cbuf); bp = &cbuf[0]; - printf("CStreamManager::Parse: got %s\n", cbuf); - /* send response to http client */ if (!strncmp(cbuf, "GET /", 5)) { fprintf(fp, "HTTP/1.1 200 OK\r\nServer: streamts (%s)\r\n\r\n", "ts" /*&argv[1][1]*/); From 223df234c4127f0dafa74c637792285e52d14a09 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 18:10:11 +0100 Subject: [PATCH 40/40] fb_generic: add sanity check and missing mark() to painIcon8 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c266891a713d99ce408716aa3bce3ddfc5f97cce Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 9fbfffd09..999b3d2b5 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -739,6 +739,12 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i width = (header.width_hi << 8) | header.width_lo; height = (header.height_hi << 8) | header.height_lo; + if (width > 768) { + /* this is not going to happen, but check anyway */ + printf("%s: icon %s too wide (%d)\n", __func__, filename.c_str(), (int)width); + close(lfd); + return false; + } unsigned char pixbuf[768]; uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; @@ -759,6 +765,7 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i d += stride; } close(lfd); + mark(x, y, x + width, y + height); return true; }