From e490f84ea87447941e6814566e8d48bdf8b0867b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:05:07 +0100 Subject: [PATCH 01/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) --- 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/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 + 59 files changed, 59 insertions(+), 63 deletions(-) diff --git a/configure.ac b/configure.ac index 3ebe71b4d..762575ba8 100644 --- a/configure.ac +++ b/configure.ac @@ -256,6 +256,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 a9a547cdb..e974757d3 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 83b01976b..28cea1670 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/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 a78878570..958a27eb7 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 8f3ac8dd6..599e761c6 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 a9441dcda..bf2457c31 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 50a93901c..46ae17fa0 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -47,6 +47,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 2303d94300444c74a3789cab19660aa30edff71c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:37:53 +0100 Subject: [PATCH 02/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 --- src/driver/fb_window.h | 5 ++--- src/driver/radiotext.h | 2 -- src/gui/bookmarkmanager.cpp | 2 +- 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/test_menu.cpp | 1 + src/gui/volumebar.cpp | 1 + src/gui/widget/buttons.cpp | 4 ++-- 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 ++- 46 files changed, 43 insertions(+), 18 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 8d7f21453..f88736107 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -37,7 +37,7 @@ #include #include #include - +#include #include #include #include diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index efa09a771..3ae141a60 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 fcce3647e..adf696566 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 420ea2775..fc584486e 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 6653d6616..2b1c568ff 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 8a56e24ad..d07f5523e 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 958a27eb7..f3a04a31a 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 9b2f2026b..a5e075a91 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 02bbb504b..a75a29a26 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 5187baf14..7ecdcf00e 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -41,6 +41,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 da61e5cea..c32a4e9e2 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 44465c389..69d1ce595 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 1545c2baf..6cdd0d85b 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 b0b669518..9e08c01c5 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 dfb1b2d02..f57e84352 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index e22733be7..6f894ffe3 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 17017c48f..8970ea014 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 44c9b3722..7e0098b96 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/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 a5536f234..e0095b45e 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -29,8 +29,8 @@ #include #include -// #include - +//#include +#include /* paintButtons usage, diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index 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 5139865b3..6443e028f 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 c7decf8fa..f7c84e024 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -30,6 +30,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 5c2ee5e137c3ad3e703562057041a83477e290be Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 14:49:41 +0100 Subject: [PATCH 03/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. --- src/driver/fb_generic.cpp | 2200 +++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.h | 332 ++++++ src/driver/framebuffer.h | 3 + 3 files changed, 2535 insertions(+) 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..39b797ea6 --- /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..3436f4cfa --- /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 9ed2ca839..87d6375f0 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -21,6 +21,8 @@ Boston, MA 02110-1301, USA. */ +#include "fb_generic.h" +#if 0 #ifndef __framebuffer__ #define __framebuffer__ @@ -330,3 +332,4 @@ class CFrameBuffer : public sigc::trackable }; #endif +#endif From 3c381cd53bf6dd67781559a4e48df7c6bbd1cc55 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:02:20 +0100 Subject: [PATCH 04/40] fb_generic: add stuff needed for compilation --- src/driver/Makefile.am | 2 +- src/driver/fb_generic.cpp | 15 +++++++++++++++ src/driver/fb_generic.h | 35 ++++++++++++++++------------------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 965e9083d..bb7bf09df 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -27,9 +27,9 @@ libneutrino_driver_a_SOURCES = \ colorgradient.cpp \ fade.cpp \ fb_window.cpp \ + fb_generic.cpp \ file.cpp \ fontrenderer.cpp \ - framebuffer.cpp \ genpsi.cpp \ moviecut.cpp \ neutrinofonts.cpp \ diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 39b797ea6..fcf6ea5e0 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 3436f4cfa..f3a4de650 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 3f6308045431fb92e13ca59dcfb86c2c9ff46a94 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:22:22 +0100 Subject: [PATCH 05/40] fb_generic: remove all hardware specific code --- 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 fcf6ea5e0..f8d5effbc 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 f3a4de650..e480f79b4 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 9ba84a629a798948bff5f6813dbeb121c96fbb59 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 18:04:15 +0100 Subject: [PATCH 06/40] fb_generic: add pointer for double-buffered fb --- 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 f8d5effbc..92ebc759e 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 e480f79b4..004835110 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 648c00f26a2eb33b7b985ba7c12320f4b324c40c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:50:05 +0100 Subject: [PATCH 07/40] move gui/color.h includes from headers to cpp files --- 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 a58193dd56d8fe9c7ee0a14ac07b86f75772cfa7 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:53:29 +0100 Subject: [PATCH 08/40] fb_generic: add fb_name member to identify fb implementation --- 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 92ebc759e..27308eda3 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 004835110..393c48419 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 beb2a67123fb6b840bc980bf64946e399d839c0e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 20:45:13 +0100 Subject: [PATCH 09/40] fb_generic: nicer debug output, remove dead code --- 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 27308eda3..69066e7bc 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 9fe5dfbe50b9a75feeefa4bef1adc3a8ce166ae8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 21:35:52 +0100 Subject: [PATCH 10/40] framebuffer: add accelerator for STi framebuffer also add a generic helper class for other accelerated framebuffer implementations --- src/driver/Makefile.am | 7 + 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, 852 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 bb7bf09df..3d1c9b216 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 \ @@ -55,4 +56,10 @@ libneutrino_driver_a_SOURCES += \ lcdd.cpp endif +#if BOXTYPE_SPARK +#libneutrino_driver_a_SOURCES += \ +# fb_accel_sti.cpp \ +# simple_display.cpp +#endif + libneutrino_driver_netfile_a_SOURCES = netfile.cpp 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 69066e7bc..5607aef16 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 ecb6531fd73fcac387cc22445563ec8f4b209dfb Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 22:50:23 +0100 Subject: [PATCH 11/40] fb_generic: fix blit2FB call --- 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 5607aef16..8a1958547 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 0e63e5df3d2bd6580425d93326d5f5367851953b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 23:03:22 +0100 Subject: [PATCH 12/40] fb_accel: add accelerated framebuffer for Nevis GXA chips Signed-off-by: M. Liebmann --- src/driver/Makefile.am | 1 + src/driver/fb_accel.h | 35 +++ src/driver/fb_accel_cs_nevis.cpp | 401 +++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 3 + src/driver/fb_generic.h | 6 +- 5 files changed, 445 insertions(+), 1 deletion(-) create mode 100644 src/driver/fb_accel_cs_nevis.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 3d1c9b216..a9e85a6a6 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_nevis.cpp \ vfd.cpp endif diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index af73b76ef..40438c778 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -33,6 +33,11 @@ #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 +83,34 @@ class CFbAccelSTi void setBlendLevel(int); }; +class CFbAccelCSNevis + : public CFbAccel +{ + private: + fb_pixel_t lastcol; + int devmem_fd; /* to access the GXA register we use /dev/mem */ + unsigned int smem_start; /* as aquired from the fbdev, the framebuffers physical start address */ + volatile uint8_t *gxa_base; /* base address for the GXA's register access */ + void setColor(fb_pixel_t col); + void run(void); + fb_pixel_t *backbuffer; + public: + CFbAccelCSNevis(); + ~CFbAccelCSNevis(); + 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 paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + void waitForIdle(const char *func = NULL); + fb_pixel_t * getBackBufferPointer() const; + void setBlendMode(uint8_t); + void setBlendLevel(int); + void add_gxa_sync_marker(void); + void setupGXA(void); +}; + #endif diff --git a/src/driver/fb_accel_cs_nevis.cpp b/src/driver/fb_accel_cs_nevis.cpp new file mode 100644 index 000000000..d13819675 --- /dev/null +++ b/src/driver/fb_accel_cs_nevis.cpp @@ -0,0 +1,401 @@ +/* + 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 +#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_BLT_CONTROL_REG 0x0034 + +#define GXA_CMD_BLT 0x00010800 +#define GXA_CMD_NOT_ALPHA 0x00011000 +#define GXA_CMD_NOT_TEXT 0x00018000 +#define GXA_CMD_QMARK 0x00001000 + +#define GXA_BLEND_CFG_REG 0x003C +#define GXA_CFG_REG 0x0030 +#define GXA_CFG2_REG 0x00FC + +#define LOGTAG "[fb_accel_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 CFbAccelCSNevis::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 CFbAccelCSNevis::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:""); +} + +CFbAccelCSNevis::CFbAccelCSNevis() +{ + fb_name = "Coolstream NEVIS GXA framebuffer"; +} + +void CFbAccelCSNevis::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? */ + ; +}; + +CFbAccelCSNevis::~CFbAccelCSNevis() +{ + 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 CFbAccelCSNevis::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 CFbAccelCSNevis::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 CFbAccelCSNevis::paintPixel(const int x, const int y, const fb_pixel_t col) +{ + paintLine(x, y, x + 1, y, col); +} + +void CFbAccelCSNevis::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 CFbAccelCSNevis::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, "[CFbAccelCSNevis] [%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, "[CFbAccelCSNevis] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + + checkFbArea(x, y, dx, dy, true); + + if (!fb_no_check) + OpenThreads::ScopedLock m_lock(mutex); + /* solid fill with background color */ + unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(7) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) col); /* setup the drawing color */ + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + //printf("3: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line); + int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x, y + line)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy - (radius * rect_height_mult))); /* width/height */ + line += dy - (radius * rect_height_mult); + continue; + } + + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0){ + dprintf(DEBUG_INFO, "[CFbAccelCSNevis] [%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, "[CFbAccelCSNevis] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x + ofl, y + line)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx-ofl-ofr, 1)); /* width/height */ + line++; + } + } else { + _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); + _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* destination x/y */ + _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy)); /* width/height */ + } + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int) backgroundColor); //FIXME needed ? + /* the GXA seems to do asynchronous rendering, so we add a sync marker + * to which the fontrenderer code can synchronize + */ + add_gxa_sync_marker(); + checkFbArea(x, y, dx, dy, false); +} + +void CFbAccelCSNevis::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; + u32 cmd; + void *uKva; + + uKva = cs_phys_addr(fbbuff); + //printf("CFbAccelCSNevis::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 */ +//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); + return; + } + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); +//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); +} + +void CFbAccelCSNevis::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +{ + if(width <1 || height <1 || !boxBuf ) + return; + + uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; + uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; + + void* uKva = cs_phys_addr((void*)boxBuf); + if(uKva != NULL) { + OpenThreads::ScopedLock m_lock(mutex); + u32 cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(1) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(3); + _write_gxa(gxa_base, GXA_BMP1_TYPE_REG, (3 << 16) | width); + _write_gxa(gxa_base, GXA_BMP1_ADDR_REG, (unsigned int) uKva); + _write_gxa(gxa_base, cmd, GXA_POINT(xoff, yoff)); + _write_gxa(gxa_base, cmd, GXA_POINT(xc, yc)); + _write_gxa(gxa_base, cmd, GXA_POINT(0, 0)); + add_gxa_sync_marker(); +//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); + return; + } + CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); +//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); +} + +void CFbAccelCSNevis::setupGXA() +{ + // We (re)store the GXA regs here in case DFB override them and was not + // able to restore them. + _write_gxa(gxa_base, GXA_BMP2_TYPE_REG, (3 << 16) | (unsigned int)screeninfo.xres); + _write_gxa(gxa_base, GXA_BMP2_ADDR_REG, (unsigned int) fix.smem_start); + _write_gxa(gxa_base, GXA_BLEND_CFG_REG, 0x00089064); + // TODO check mono-flip, bit 8 + _write_gxa(gxa_base, GXA_CFG_REG, 0x100 | (1 << 12) | (1 << 29)); + _write_gxa(gxa_base, GXA_CFG2_REG, 0x1FF); + _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)backgroundColor); + _write_gxa(gxa_base, GXA_BMP7_TYPE_REG, (3 << 16) | (unsigned int)screeninfo.xres | (1 << 27)); + add_gxa_sync_marker(); +} + +/* wrong name... */ +int CFbAccelCSNevis::setMode(unsigned int, unsigned int, unsigned int) +{ + fb_fix_screeninfo _fix; + + if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { + perror("FBIOGET_FSCREENINFO"); + return -1; + } + stride = _fix.line_length; + if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) + printf("screen unblanking failed\n"); + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + printf(LOGTAG "%dx%dx%d line length %d. using nevis gxa graphics accelerator.\n", xRes, yRes, bpp, stride); + int needmem = stride * yRes * 2; + if (available >= needmem) + { + backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + return 0; + } + fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); + backbuffer = lfb; /* will not work well, but avoid crashes */ + return 0; /* dont fail because of this */ +} + +fb_pixel_t * CFbAccelCSNevis::getBackBufferPointer() const +{ + return backbuffer; +} + +void CFbAccelCSNevis::setBlendMode(uint8_t mode) +{ + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +} + +void CFbAccelCSNevis::setBlendLevel(int level) +{ + unsigned char value = 0xFF; + if (level >= 0 && level <= 100) + value = convertSetupAlpha2Alpha(level); + + if (ioctl(fd, FBIO_SETOPACITY, value)) + printf("FBIO_SETOPACITY failed.\n"); +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 8a1958547..00ed39fef 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 CFbAccelCSNevis(); #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 393c48419..1f48274dc 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -122,6 +122,7 @@ class CFrameBuffer : public sigc::trackable int kd_mode; struct vt_mode vt_mode; bool active; + bool fb_no_check; static void switch_signal (int); fb_fix_screeninfo fix; bool locked; @@ -183,6 +184,10 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? +#ifdef USE_NEVIS_GXA + virtual void setupGXA() {}; + virtual void add_gxa_sync_marker() {}; +#endif void setTransparency( int tr = 0 ); virtual void setBlendMode(uint8_t mode = 1); @@ -296,7 +301,6 @@ class CFrameBuffer : public sigc::trackable 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); From 6ff9ff695b11e7bb0fe9de0d5c6d1ac8cce7eb09 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Tue, 7 Feb 2017 17:18:01 +0100 Subject: [PATCH 13/40] fb_accel: add accelerated framebuffer for Apollo graphic chips --- src/driver/Makefile.am | 6 + src/driver/fb_accel.h | 21 +++ src/driver/fb_accel_cs_apollo.cpp | 245 ++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 4 + 4 files changed, 276 insertions(+) create mode 100644 src/driver/fb_accel_cs_apollo.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index a9e85a6a6..5c41feb9c 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -46,10 +46,16 @@ libneutrino_driver_a_SOURCES = \ volume.cpp if BOXTYPE_COOL +if BOXMODEL_APOLLO +libneutrino_driver_a_SOURCES += \ + fb_accel_cs_apollo.cpp \ + vfd.cpp +else libneutrino_driver_a_SOURCES += \ fb_accel_cs_nevis.cpp \ vfd.cpp endif +endif if BOXTYPE_TRIPLE libneutrino_driver_a_SOURCES += \ diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 40438c778..de4d3270f 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -34,9 +34,11 @@ #endif #if HAVE_COOL_HARDWARE +#ifndef BOXMODEL_APOLLO /* not needed -- if you don't want acceleration, don't call CFbAccel ;) */ #define USE_NEVIS_GXA 1 #endif +#endif class CFbAccel : public CFrameBuffer @@ -113,4 +115,23 @@ class CFbAccelCSNevis void setupGXA(void); }; +class CFbAccelCSApollo + : public CFbAccel +{ + private: + fb_pixel_t *backbuffer; + + public: + CFbAccelCSApollo(); +// ~CFbAccelCSApollo(); + int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); + + void paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col); + void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); + void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); + void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); + void setBlendMode(uint8_t); + void setBlendLevel(int); +}; + #endif diff --git a/src/driver/fb_accel_cs_apollo.cpp b/src/driver/fb_accel_cs_apollo.cpp new file mode 100644 index 000000000..73dc19d7c --- /dev/null +++ b/src/driver/fb_accel_cs_apollo.cpp @@ -0,0 +1,245 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent acceleration functions for coolstream apollo graphic chips + are represented in this class. + + (C) 2017 M. Liebmann + Derived from old neutrino-hd framebuffer code + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define LOGTAG "[fb_accel_apollo] " + +CFbAccelCSApollo::CFbAccelCSApollo() +{ + fb_name = "Coolstream APOLLO framebuffer"; +} + +/* +CFbAccelCSApollo::~CFbAccelCSApollo() +{ +} +*/ + +void CFbAccelCSApollo::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col) +{ + 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; + } + 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; +} + +void CFbAccelCSApollo::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, "[CFbAccelCSApollo] [%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, "[CFbAccelCSApollo] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + + checkFbArea(x, y, dx, dy, true); + + fb_fillrect fillrect; + fillrect.color = col; + fillrect.rop = ROP_COPY; + + if (type && radius) { + setCornerFlags(type); + radius = limitRadius(dx, dy, radius); + + int line = 0; + while (line < dy) { + int ofl, ofr; + if (calcCorners(NULL, &ofl, &ofr, dy, line, radius, type)) { + //printf("3: x %d y %d dx %d dy %d rad %d line %d\n", x, y, dx, dy, radius, line); + int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; + fillrect.dx = x; + fillrect.dy = y + line; + fillrect.width = dx; + fillrect.height = dy - (radius * rect_height_mult); + + ioctl(fd, FBIO_FILL_RECT, &fillrect); + line += dy - (radius * rect_height_mult); + continue; + } + + if (dx-ofr-ofl < 1) { + if (dx-ofr-ofl == 0){ + dprintf(DEBUG_INFO, "[CFbAccelCSApollo] [%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, "[CFbAccelCSApollo] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); + } + line++; + continue; + } + paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col); + line++; + } + } else { + /* FIXME small size faster to do by software */ + if (dx > 10 || dy > 10) { + fillrect.dx = x; + fillrect.dy = y; + fillrect.width = dx; + fillrect.height = dy; + ioctl(fd, FBIO_FILL_RECT, &fillrect); + checkFbArea(x, y, dx, dy, false); + return; + } + int swidth = stride / sizeof(fb_pixel_t); + fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); + int line = 0; + while (line < dy) { + for (int pos = x; pos < x + dx; pos++) + *(fbp + pos) = col; + fbp += swidth; + line++; + } + } + checkFbArea(x, y, dx, dy, false); +} + +void CFbAccelCSApollo::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(!(width%4)) { + fb_image image; + image.dx = xoff; + image.dy = yoff; + image.width = xc; + image.height = yc; + image.cmap.len = 0; + image.depth = 32; + image.data = (const char*)fbbuff; + ioctl(fd, FBIO_IMAGE_BLT, &image); +//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); + return; + } + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); +//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); +} + +void CFbAccelCSApollo::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +{ + if(width <1 || height <1 || !boxBuf ) + return; + + uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; + uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; + + if (!(width%4)) { + fb_image image; + image.dx = xoff; + image.dy = yoff; + image.width = xc; + image.height = yc; + image.cmap.len = 0; + image.depth = 32; + image.data = (const char*)boxBuf; + ioctl(fd, FBIO_IMAGE_BLT, &image); +//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; + } + CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); +//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); +} + +int CFbAccelCSApollo::setMode(unsigned int, unsigned int, unsigned int) +{ + fb_fix_screeninfo _fix; + + if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { + perror("FBIOGET_FSCREENINFO"); + return -1; + } + stride = _fix.line_length; + if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) + printf("screen unblanking failed\n"); + xRes = screeninfo.xres; + yRes = screeninfo.yres; + bpp = screeninfo.bits_per_pixel; + printf(LOGTAG "%dx%dx%d line length %d. using apollo graphics accelerator.\n", xRes, yRes, bpp, stride); + int needmem = stride * yRes * 2; + if (available >= needmem) + { + backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + return 0; + } + fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); + backbuffer = lfb; /* will not work well, but avoid crashes */ + return 0; /* dont fail because of this */ +} + +void CFbAccelCSApollo::setBlendMode(uint8_t mode) +{ + if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + printf("FBIO_SETBLENDMODE failed.\n"); +} + +void CFbAccelCSApollo::setBlendLevel(int level) +{ + unsigned char value = 0xFF; + if (level >= 0 && level <= 100) + value = convertSetupAlpha2Alpha(level); + + if (ioctl(fd, FBIO_SETOPACITY, value)) + printf("FBIO_SETOPACITY failed.\n"); + if (level == 100) // TODO: sucks. + usleep(20000); +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 00ed39fef..ec1dc1540 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -124,7 +124,11 @@ CFrameBuffer* CFrameBuffer::getInstance() frameBuffer = new CFbAccelSTi(); #endif #if HAVE_COOL_HARDWARE +#ifdef BOXMODEL_APOLLO + frameBuffer = new CFbAccelCSApollo(); +#else frameBuffer = new CFbAccelCSNevis(); +#endif #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); From 2498ebb314f4d2b98c8eb7989798d7f2d4da422f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:15:37 +0100 Subject: [PATCH 14/40] fb_accel: add backend for GL framebuffer --- src/driver/Makefile.am | 6 ++ src/driver/fb_accel.h | 21 +++++ src/driver/fb_accel_glfb.cpp | 149 +++++++++++++++++++++++++++++++++++ src/driver/fb_generic.cpp | 3 + 4 files changed, 179 insertions(+) create mode 100644 src/driver/fb_accel_glfb.cpp diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 5c41feb9c..5cc0574bf 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -69,4 +69,10 @@ endif # simple_display.cpp #endif +if BOXTYPE_GENERIC +libneutrino_driver_a_SOURCES += \ + fb_accel_glfb.cpp \ + simple_display.cpp +endif + libneutrino_driver_netfile_a_SOURCES = netfile.cpp diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index de4d3270f..67225d44a 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -134,4 +134,25 @@ class CFbAccelCSApollo 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 ec1dc1540..90ac9ad5f 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -129,6 +129,9 @@ CFrameBuffer* CFrameBuffer::getInstance() #else frameBuffer = new CFbAccelCSNevis(); #endif +#endif +#if HAVE_GENERIC_HARDWARE + frameBuffer = new CFbAccelGLFB(); #endif if (!frameBuffer) frameBuffer = new CFrameBuffer(); From c695ae8ea8ef427336d84e02618c9211cda71f56 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 11:35:05 +0100 Subject: [PATCH 15/40] framebuffer/configure: remove unused --restore-prev-mode this is unused, untested and most likely not working at all --- configure.ac | 4 ---- src/driver/framebuffer.cpp | 5 ----- 2 files changed, 9 deletions(-) diff --git a/configure.ac b/configure.ac index 762575ba8..d2dcfbe26 100644 --- a/configure.ac +++ b/configure.ac @@ -146,10 +146,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 4134af3d1d7926af0e557986e1fd95c418ce3435 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 12:12:27 +0100 Subject: [PATCH 16/40] flashtool: make CFlashVersionInfo robust against invalid input --- 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 20447b361..2f1b576f6 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -441,10 +441,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 47b1a8b64234cdf7ad4da97acae477de61ba6528 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:52:16 +0100 Subject: [PATCH 17/40] reduce impact of driver/pictureviewer.h header file before, more than 175 files depended on it, now it's about 35 --- 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 98b2461da7a2c1519bd3a3b87d8f3450ed619046 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 01:26:43 +0100 Subject: [PATCH 18/40] reduce impact of zapit/frontend_c.h header down from ~217 files to ~57... --- 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 1683346b3..59cf668c5 100644 --- a/src/driver/record.h +++ b/src/driver/record.h @@ -58,6 +58,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 02d85f2ff2657011ecc679aa4839f17e6d8bb01f Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 06:02:42 +0100 Subject: [PATCH 19/40] neutrino: Replace USE_NEVIS_GXA with hardware-specific macros - Existing USE_NEVIS_GXA definitions in the build system (neutrino configure) can be removed. --- src/driver/fb_accel.h | 7 ------- src/driver/fb_generic.h | 2 +- src/driver/screenshot.cpp | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 67225d44a..92f865f32 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -33,13 +33,6 @@ #define PARTIAL_BLIT 1 #endif -#if HAVE_COOL_HARDWARE -#ifndef BOXMODEL_APOLLO -/* not needed -- if you don't want acceleration, don't call CFbAccel ;) */ -#define USE_NEVIS_GXA 1 -#endif -#endif - class CFbAccel : public CFrameBuffer { diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 1f48274dc..a7e24bf85 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -184,7 +184,7 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? -#ifdef USE_NEVIS_GXA +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS virtual void setupGXA() {}; virtual void add_gxa_sync_marker() {}; #endif diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index e438f924b..b6b2fafdc 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -77,7 +77,7 @@ bool CScreenShot::GetData() bool res = false; mutex.lock(); -#ifdef USE_NEVIS_GXA +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS CFrameBuffer::getInstance()->setActive(false); #endif if (videoDecoder->getBlank()) @@ -86,7 +86,7 @@ bool CScreenShot::GetData() res = videoDecoder->GetScreenImage(pixel_data, xres, yres, get_video, get_osd, scale_to_video); #endif -#ifdef USE_NEVIS_GXA +#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS /* sort of hack. GXA used to transfer/convert live image to RGB, * so setup GXA back */ CFrameBuffer::getInstance()->setupGXA(); From 10e82c0ece74be444b047957204fd7321d55a771 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 09:30:22 +0100 Subject: [PATCH 20/40] CFbAccelCSNevis: Add paintHLineRel() & paintVLineRel() functions - Remove unused debug output --- src/driver/fb_accel.h | 2 ++ src/driver/fb_accel_cs_nevis.cpp | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 92f865f32..f1ef8bbd5 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -97,6 +97,8 @@ class CFbAccelCSNevis void paintPixel(int x, int y, const fb_pixel_t col); void paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col); void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); + inline void paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { paintLine(x, y, x+dx, y, col); }; + inline void paintVLineRel(int x, int y, int dy, const fb_pixel_t col) { paintLine(x, y, x, y+dy, col); }; void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); diff --git a/src/driver/fb_accel_cs_nevis.cpp b/src/driver/fb_accel_cs_nevis.cpp index d13819675..c083d0629 100644 --- a/src/driver/fb_accel_cs_nevis.cpp +++ b/src/driver/fb_accel_cs_nevis.cpp @@ -207,6 +207,8 @@ void CFbAccelCSNevis::paintPixel(const int x, const int y, const fb_pixel_t col) void CFbAccelCSNevis::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) { + if (!getActive()) + return; OpenThreads::ScopedLock m_lock(mutex); /* draw a single vertical line from point xa/ya to xb/yb */ unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; @@ -247,7 +249,6 @@ void CFbAccelCSNevis::paintBoxRel(const int x, const int y, const int dx, const 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); int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; _write_gxa(gxa_base, GXA_BLT_CONTROL_REG, 0); _write_gxa(gxa_base, cmd, GXA_POINT(x, y + line)); /* destination x/y */ @@ -293,7 +294,6 @@ void CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uin void *uKva; uKva = cs_phys_addr(fbbuff); - //printf("CFbAccelCSNevis::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); if (uKva != NULL) { OpenThreads::ScopedLock m_lock(mutex); @@ -305,11 +305,9 @@ void CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uin _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 */ -//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); return; } CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); -//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); } void CFbAccelCSNevis::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) @@ -330,11 +328,9 @@ void CFbAccelCSNevis::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint3 _write_gxa(gxa_base, cmd, GXA_POINT(xc, yc)); _write_gxa(gxa_base, cmd, GXA_POINT(0, 0)); add_gxa_sync_marker(); -//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); return; } CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); -//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); } void CFbAccelCSNevis::setupGXA() From 35b48372f897f44c309e76bea34439876e0d0065 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 09:30:25 +0100 Subject: [PATCH 21/40] CFbAccelCSApollo: Add paintHLineRel() & paintVLineRel() functions - Remove unused debug output --- src/driver/fb_accel.h | 4 ++-- src/driver/fb_accel_cs_apollo.cpp | 40 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index f1ef8bbd5..fe085b759 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -120,8 +120,8 @@ class CFbAccelCSApollo CFbAccelCSApollo(); // ~CFbAccelCSApollo(); int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); - - void paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col); + void paintHLineRel(int x, int dx, int y, const fb_pixel_t col); + void paintVLineRel(int x, int y, int dy, const fb_pixel_t col); void paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius = 0, int type = CORNER_ALL); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); diff --git a/src/driver/fb_accel_cs_apollo.cpp b/src/driver/fb_accel_cs_apollo.cpp index 73dc19d7c..34a07c447 100644 --- a/src/driver/fb_accel_cs_apollo.cpp +++ b/src/driver/fb_accel_cs_apollo.cpp @@ -56,8 +56,11 @@ CFbAccelCSApollo::~CFbAccelCSApollo() } */ -void CFbAccelCSApollo::paintHLineRelInternal(int x, int dx, int y, const fb_pixel_t col) +void CFbAccelCSApollo::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { + if (!getActive()) + return; + if (dx >= 10) { fb_fillrect fillrect; fillrect.dx = x; @@ -69,16 +72,26 @@ void CFbAccelCSApollo::paintHLineRelInternal(int x, int dx, int y, const fb_pixe ioctl(fd, FBIO_FILL_RECT, &fillrect); return; } - 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; + CFrameBuffer::paintHLineRelInternal(x, dx, y, col); +} + +void CFbAccelCSApollo::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) +{ + if (!getActive()) + return; + + fb_fillrect fillrect; + fillrect.dx = x; + fillrect.dy = y; + fillrect.width = 1; + fillrect.height = dy; + fillrect.color = col; + fillrect.rop = ROP_COPY; + ioctl(fd, FBIO_FILL_RECT, &fillrect); } void CFbAccelCSApollo::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; @@ -103,7 +116,6 @@ void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const 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); int rect_height_mult = ((type & CORNER_TOP) && (type & CORNER_BOTTOM)) ? 2 : 1; fillrect.dx = x; fillrect.dy = y + line; @@ -125,7 +137,7 @@ void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const line++; continue; } - paintHLineRelInternal(x+ofl, dx-ofl-ofr, y+line, col); + paintHLineRel(x+ofl, dx-ofl-ofr, y+line, col); line++; } } else { @@ -139,13 +151,9 @@ void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const checkFbArea(x, y, dx, dy, false); return; } - 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; + CFrameBuffer::paintHLineRelInternal(x, dx, y+line, col); line++; } } @@ -168,11 +176,9 @@ void CFbAccelCSApollo::blit2FB(void *fbbuff, uint32_t width, uint32_t height, ui image.depth = 32; image.data = (const char*)fbbuff; ioctl(fd, FBIO_IMAGE_BLT, &image); -//printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); return; } CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); -//printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); } void CFbAccelCSApollo::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) @@ -193,11 +199,9 @@ void CFbAccelCSApollo::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint 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; } CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); -//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); } int CFbAccelCSApollo::setMode(unsigned int, unsigned int, unsigned int) From 58bd8a4a634117bc5577b4127aea8f1694754de4 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 12:17:09 +0100 Subject: [PATCH 22/40] fb_accel: Rename CFbAccelCSNevis class => CFbAccelCSHD1 Rename fb_accel_cs_nevis.cpp => fb_accel_cs_hd1.cpp --- src/driver/Makefile.am | 2 +- src/driver/fb_accel.h | 6 +-- ...accel_cs_nevis.cpp => fb_accel_cs_hd1.cpp} | 42 +++++++++---------- src/driver/fb_generic.cpp | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) rename src/driver/{fb_accel_cs_nevis.cpp => fb_accel_cs_hd1.cpp} (87%) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 5cc0574bf..8418b9ed9 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -52,7 +52,7 @@ libneutrino_driver_a_SOURCES += \ vfd.cpp else libneutrino_driver_a_SOURCES += \ - fb_accel_cs_nevis.cpp \ + fb_accel_cs_hd1.cpp \ vfd.cpp endif endif diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index fe085b759..dd2072ce2 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -78,7 +78,7 @@ class CFbAccelSTi void setBlendLevel(int); }; -class CFbAccelCSNevis +class CFbAccelCSHD1 : public CFbAccel { private: @@ -90,8 +90,8 @@ class CFbAccelCSNevis void run(void); fb_pixel_t *backbuffer; public: - CFbAccelCSNevis(); - ~CFbAccelCSNevis(); + CFbAccelCSHD1(); + ~CFbAccelCSHD1(); void init(const char * const); int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); void paintPixel(int x, int y, const fb_pixel_t col); diff --git a/src/driver/fb_accel_cs_nevis.cpp b/src/driver/fb_accel_cs_hd1.cpp similarity index 87% rename from src/driver/fb_accel_cs_nevis.cpp rename to src/driver/fb_accel_cs_hd1.cpp index c083d0629..3cac06001 100644 --- a/src/driver/fb_accel_cs_nevis.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -95,7 +95,7 @@ static void _write_gxa(volatile unsigned char *base_addr, unsigned int offset, u /* 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 CFbAccelCSNevis::add_gxa_sync_marker(void) +void CFbAccelCSHD1::add_gxa_sync_marker(void) { unsigned int cmd = GXA_CMD_QMARK | GXA_PARAM_COUNT(1); // TODO: locking? @@ -106,7 +106,7 @@ void CFbAccelCSNevis::add_gxa_sync_marker(void) } /* wait until the current marker comes out of the GXA command queue */ -void CFbAccelCSNevis::waitForIdle(const char *func) +void CFbAccelCSHD1::waitForIdle(const char *func) { unsigned int cfg, count = 0; do { @@ -124,12 +124,12 @@ void CFbAccelCSNevis::waitForIdle(const char *func) fprintf(stderr, LOGTAG "waitForIdle: count is big (%d) [%s]!\n", count, func?func:""); } -CFbAccelCSNevis::CFbAccelCSNevis() +CFbAccelCSHD1::CFbAccelCSHD1() { fb_name = "Coolstream NEVIS GXA framebuffer"; } -void CFbAccelCSNevis::init(const char * const) +void CFbAccelCSHD1::init(const char * const) { fprintf(stderr, ">FBACCEL::INIT\n"); CFrameBuffer::init(); @@ -163,7 +163,7 @@ fprintf(stderr, ">FBACCEL::INIT\n"); ; }; -CFbAccelCSNevis::~CFbAccelCSNevis() +CFbAccelCSHD1::~CFbAccelCSHD1() { if (gxa_base != MAP_FAILED) munmap((void *)gxa_base, 0x40000); @@ -175,7 +175,7 @@ CFbAccelCSNevis::~CFbAccelCSNevis() close(fd); } -void CFbAccelCSNevis::setColor(fb_pixel_t col) +void CFbAccelCSHD1::setColor(fb_pixel_t col) { if (col == lastcol) return; @@ -183,7 +183,7 @@ void CFbAccelCSNevis::setColor(fb_pixel_t col) lastcol = col; } -void CFbAccelCSNevis::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) +void CFbAccelCSHD1::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) { OpenThreads::ScopedLock m_lock(mutex); unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_CMD_NOT_ALPHA | @@ -200,12 +200,12 @@ void CFbAccelCSNevis::paintRect(const int x, const int y, const int dx, const in add_gxa_sync_marker(); } -void CFbAccelCSNevis::paintPixel(const int x, const int y, const fb_pixel_t col) +void CFbAccelCSHD1::paintPixel(const int x, const int y, const fb_pixel_t col) { paintLine(x, y, x + 1, y, col); } -void CFbAccelCSNevis::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) +void CFbAccelCSHD1::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) { if (!getActive()) return; @@ -219,7 +219,7 @@ void CFbAccelCSNevis::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t _write_gxa(gxa_base, cmd, GXA_POINT(xa, ya)); /* start point */ } -void CFbAccelCSNevis::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +void CFbAccelCSHD1::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) { /* draw a filled rectangle (with additional round corners) */ @@ -227,11 +227,11 @@ void CFbAccelCSNevis::paintBoxRel(const int x, const int y, const int dx, const return; if (dx == 0 || dy == 0) { - dprintf(DEBUG_DEBUG, "[CFbAccelCSNevis] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + dprintf(DEBUG_DEBUG, "[CFbAccelCSHD1] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); return; } if (radius < 0) - dprintf(DEBUG_NORMAL, "[CFbAccelCSNevis] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + dprintf(DEBUG_NORMAL, "[CFbAccelCSHD1] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); checkFbArea(x, y, dx, dy, true); @@ -259,9 +259,9 @@ void CFbAccelCSNevis::paintBoxRel(const int x, const int y, const int dx, const if (dx-ofr-ofl < 1) { if (dx-ofr-ofl == 0){ - dprintf(DEBUG_INFO, "[CFbAccelCSNevis] [%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); + dprintf(DEBUG_INFO, "[CFbAccelCSHD1] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx-ofr-ofl, y+line); }else{ - dprintf(DEBUG_INFO, "[CFbAccelCSNevis] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + dprintf(DEBUG_INFO, "[CFbAccelCSHD1] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); } line++; @@ -285,7 +285,7 @@ void CFbAccelCSNevis::paintBoxRel(const int x, const int y, const int dx, const checkFbArea(x, y, dx, dy, false); } -void CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) +void CFbAccelCSHD1::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) { int xc, yc; xc = (width > xRes) ? xRes : width; @@ -310,7 +310,7 @@ void CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uin CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); } -void CFbAccelCSNevis::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +void CFbAccelCSHD1::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) { if(width <1 || height <1 || !boxBuf ) return; @@ -333,7 +333,7 @@ void CFbAccelCSNevis::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint3 CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); } -void CFbAccelCSNevis::setupGXA() +void CFbAccelCSHD1::setupGXA() { // We (re)store the GXA regs here in case DFB override them and was not // able to restore them. @@ -349,7 +349,7 @@ void CFbAccelCSNevis::setupGXA() } /* wrong name... */ -int CFbAccelCSNevis::setMode(unsigned int, unsigned int, unsigned int) +int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) { fb_fix_screeninfo _fix; @@ -375,18 +375,18 @@ int CFbAccelCSNevis::setMode(unsigned int, unsigned int, unsigned int) return 0; /* dont fail because of this */ } -fb_pixel_t * CFbAccelCSNevis::getBackBufferPointer() const +fb_pixel_t * CFbAccelCSHD1::getBackBufferPointer() const { return backbuffer; } -void CFbAccelCSNevis::setBlendMode(uint8_t mode) +void CFbAccelCSHD1::setBlendMode(uint8_t mode) { if (ioctl(fd, FBIO_SETBLENDMODE, mode)) printf("FBIO_SETBLENDMODE failed.\n"); } -void CFbAccelCSNevis::setBlendLevel(int level) +void CFbAccelCSHD1::setBlendLevel(int level) { unsigned char value = 0xFF; if (level >= 0 && level <= 100) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 90ac9ad5f..4fa47fa8e 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -127,7 +127,7 @@ CFrameBuffer* CFrameBuffer::getInstance() #ifdef BOXMODEL_APOLLO frameBuffer = new CFbAccelCSApollo(); #else - frameBuffer = new CFbAccelCSNevis(); + frameBuffer = new CFbAccelCSHD1(); #endif #endif #if HAVE_GENERIC_HARDWARE From a4afe1e8e00115cb8b84a772cd6f8fd6cc9c620e Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 12:33:45 +0100 Subject: [PATCH 23/40] fb_accel: Rename CFbAccelCSApollo class => CFbAccelCSHD2 Rename fb_accel_cs_apollo.cpp => fb_accel_cs_hd2.cpp --- src/driver/Makefile.am | 2 +- src/driver/fb_accel.h | 6 ++-- ...ccel_cs_apollo.cpp => fb_accel_cs_hd2.cpp} | 28 +++++++++---------- src/driver/fb_generic.cpp | 7 +++-- 4 files changed, 22 insertions(+), 21 deletions(-) rename src/driver/{fb_accel_cs_apollo.cpp => fb_accel_cs_hd2.cpp} (78%) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 8418b9ed9..cb2a5ef11 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -48,7 +48,7 @@ libneutrino_driver_a_SOURCES = \ if BOXTYPE_COOL if BOXMODEL_APOLLO libneutrino_driver_a_SOURCES += \ - fb_accel_cs_apollo.cpp \ + fb_accel_cs_hd2.cpp \ vfd.cpp else libneutrino_driver_a_SOURCES += \ diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index dd2072ce2..148c9f591 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -110,15 +110,15 @@ class CFbAccelCSHD1 void setupGXA(void); }; -class CFbAccelCSApollo +class CFbAccelCSHD2 : public CFbAccel { private: fb_pixel_t *backbuffer; public: - CFbAccelCSApollo(); -// ~CFbAccelCSApollo(); + CFbAccelCSHD2(); +// ~CFbAccelCSHD2(); int setMode(unsigned int xRes, unsigned int yRes, unsigned int bpp); void paintHLineRel(int x, int dx, int y, const fb_pixel_t col); void paintVLineRel(int x, int y, int dy, const fb_pixel_t col); diff --git a/src/driver/fb_accel_cs_apollo.cpp b/src/driver/fb_accel_cs_hd2.cpp similarity index 78% rename from src/driver/fb_accel_cs_apollo.cpp rename to src/driver/fb_accel_cs_hd2.cpp index 34a07c447..912a83bbe 100644 --- a/src/driver/fb_accel_cs_apollo.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -45,18 +45,18 @@ #define LOGTAG "[fb_accel_apollo] " -CFbAccelCSApollo::CFbAccelCSApollo() +CFbAccelCSHD2::CFbAccelCSHD2() { fb_name = "Coolstream APOLLO framebuffer"; } /* -CFbAccelCSApollo::~CFbAccelCSApollo() +CFbAccelCSHD2::~CFbAccelCSHD2() { } */ -void CFbAccelCSApollo::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) +void CFbAccelCSHD2::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) { if (!getActive()) return; @@ -75,7 +75,7 @@ void CFbAccelCSApollo::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) CFrameBuffer::paintHLineRelInternal(x, dx, y, col); } -void CFbAccelCSApollo::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) +void CFbAccelCSHD2::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) { if (!getActive()) return; @@ -90,17 +90,17 @@ void CFbAccelCSApollo::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) ioctl(fd, FBIO_FILL_RECT, &fillrect); } -void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) +void CFbAccelCSHD2::paintBoxRel(const int x, const int y, const int dx, const int dy, const fb_pixel_t col, int radius, int type) { if (!getActive()) return; if (dx == 0 || dy == 0) { - dprintf(DEBUG_DEBUG, "[CFbAccelCSApollo] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); + dprintf(DEBUG_DEBUG, "[CFbAccelCSHD2] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx, y+dy); return; } if (radius < 0) - dprintf(DEBUG_NORMAL, "[CFbAccelCSApollo] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); + dprintf(DEBUG_NORMAL, "[CFbAccelCSHD2] [%s - %d]: WARNING! radius < 0 [%d] FIXME\n", __func__, __LINE__, radius); checkFbArea(x, y, dx, dy, true); @@ -129,9 +129,9 @@ void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const if (dx-ofr-ofl < 1) { if (dx-ofr-ofl == 0){ - dprintf(DEBUG_INFO, "[CFbAccelCSApollo] [%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); + dprintf(DEBUG_INFO, "[CFbAccelCSHD2] [%s - %d]: radius %d, start x %d y %d end x %d y %d\n", __func__, __LINE__, radius, x, y, x+dx-ofr-ofl, y+line); }else{ - dprintf(DEBUG_INFO, "[CFbAccelCSApollo] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", + dprintf(DEBUG_INFO, "[CFbAccelCSHD2] [%s - %04d]: Calculated width: %d\n (radius %d, dx %d, offsetLeft %d, offsetRight %d).\n Width can not be less than 0, abort.\n", __func__, __LINE__, dx-ofr-ofl, radius, dx, ofl, ofr); } line++; @@ -160,7 +160,7 @@ void CFbAccelCSApollo::paintBoxRel(const int x, const int y, const int dx, const checkFbArea(x, y, dx, dy, false); } -void CFbAccelCSApollo::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) +void CFbAccelCSHD2::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) { int xc, yc; xc = (width > xRes) ? xRes : width; @@ -181,7 +181,7 @@ void CFbAccelCSApollo::blit2FB(void *fbbuff, uint32_t width, uint32_t height, ui CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); } -void CFbAccelCSApollo::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) +void CFbAccelCSHD2::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff) { if(width <1 || height <1 || !boxBuf ) return; @@ -204,7 +204,7 @@ void CFbAccelCSApollo::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); } -int CFbAccelCSApollo::setMode(unsigned int, unsigned int, unsigned int) +int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) { fb_fix_screeninfo _fix; @@ -230,13 +230,13 @@ int CFbAccelCSApollo::setMode(unsigned int, unsigned int, unsigned int) return 0; /* dont fail because of this */ } -void CFbAccelCSApollo::setBlendMode(uint8_t mode) +void CFbAccelCSHD2::setBlendMode(uint8_t mode) { if (ioctl(fd, FBIO_SETBLENDMODE, mode)) printf("FBIO_SETBLENDMODE failed.\n"); } -void CFbAccelCSApollo::setBlendLevel(int level) +void CFbAccelCSHD2::setBlendLevel(int level) { unsigned char value = 0xFF; if (level >= 0 && level <= 100) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 4fa47fa8e..b7b989373 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -124,11 +124,12 @@ CFrameBuffer* CFrameBuffer::getInstance() frameBuffer = new CFbAccelSTi(); #endif #if HAVE_COOL_HARDWARE -#ifdef BOXMODEL_APOLLO - frameBuffer = new CFbAccelCSApollo(); -#else +#ifdef BOXMODEL_NEVIS frameBuffer = new CFbAccelCSHD1(); #endif +#ifdef BOXMODEL_APOLLO + frameBuffer = new CFbAccelCSHD2(); +#endif #endif #if HAVE_GENERIC_HARDWARE frameBuffer = new CFbAccelGLFB(); From f94afc1593d0a500694cebf71ca520967c7559b3 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 8 Feb 2017 13:30:33 +0100 Subject: [PATCH 24/40] fb_accel: Some renaming nevis => hd1 & apollo => hd2 --- src/driver/fb_accel_cs_hd1.cpp | 6 +++--- src/driver/fb_accel_cs_hd2.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index 3cac06001..aae21d3ed 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -78,7 +78,7 @@ #define GXA_CFG_REG 0x0030 #define GXA_CFG2_REG 0x00FC -#define LOGTAG "[fb_accel_gxa] " +#define LOGTAG "[fb_accel_cs_hd1] " /* static unsigned int _read_gxa(volatile unsigned char *base_addr, unsigned int offset) { @@ -126,7 +126,7 @@ void CFbAccelCSHD1::waitForIdle(const char *func) CFbAccelCSHD1::CFbAccelCSHD1() { - fb_name = "Coolstream NEVIS GXA framebuffer"; + fb_name = "Coolstream HD1 framebuffer"; } void CFbAccelCSHD1::init(const char * const) @@ -363,7 +363,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; - printf(LOGTAG "%dx%dx%d line length %d. using nevis gxa graphics accelerator.\n", xRes, yRes, bpp, stride); + printf(LOGTAG "%dx%dx%d line length %d. using hd1 graphics accelerator.\n", xRes, yRes, bpp, stride); int needmem = stride * yRes * 2; if (available >= needmem) { diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 912a83bbe..6cb115dfc 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -1,6 +1,6 @@ /* Framebuffer acceleration hardware abstraction functions. - The hardware dependent acceleration functions for coolstream apollo graphic chips + The hardware dependent acceleration functions for coolstream hd2 graphic chips are represented in this class. (C) 2017 M. Liebmann @@ -43,11 +43,11 @@ #include #include -#define LOGTAG "[fb_accel_apollo] " +#define LOGTAG "[fb_accel_cs_hd2] " CFbAccelCSHD2::CFbAccelCSHD2() { - fb_name = "Coolstream APOLLO framebuffer"; + fb_name = "Coolstream HD2 framebuffer"; } /* @@ -218,7 +218,7 @@ int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; - printf(LOGTAG "%dx%dx%d line length %d. using apollo graphics accelerator.\n", xRes, yRes, bpp, stride); + printf(LOGTAG "%dx%dx%d line length %d. using hd2 graphics accelerator.\n", xRes, yRes, bpp, stride); int needmem = stride * yRes * 2; if (available >= needmem) { From 8fe7504007380551ae421b52b14603877da8aa85 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Feb 2017 18:47:17 +0100 Subject: [PATCH 25/40] fb_accel_cs_hdx: remove dub includes, add includes into common header file --- src/driver/fb_accel_cs_hd1.cpp | 21 +-------------- src/driver/fb_accel_cs_hd2.cpp | 21 +-------------- src/driver/fb_accel_cs_hdx_inc.h | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 40 deletions(-) create mode 100644 src/driver/fb_accel_cs_hdx_inc.h diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index aae21d3ed..0fc772ab9 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -22,26 +22,7 @@ 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 "fb_accel_cs_hdx_inc.h" /*******************************************************************************/ #define GXA_POINT(x, y) (((y) & 0x0FFF) << 16) | ((x) & 0x0FFF) diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 6cb115dfc..393e6396c 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -22,26 +22,7 @@ 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 "fb_accel_cs_hdx_inc.h" #define LOGTAG "[fb_accel_cs_hd2] " diff --git a/src/driver/fb_accel_cs_hdx_inc.h b/src/driver/fb_accel_cs_hdx_inc.h new file mode 100644 index 000000000..b1d31988e --- /dev/null +++ b/src/driver/fb_accel_cs_hdx_inc.h @@ -0,0 +1,45 @@ +/* + Framebuffer acceleration hardware abstraction functions. + The hardware dependent acceleration functions for coolstream hdx graphic chips + are represented in this class. + + (C) 2017 M. Liebmann + (C) 2017 Thilo Graf 'dbt' + Derived from old neutrino-hd framebuffer code + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include From 9ddb4fc9c3156eff394d5fe1ffc875510b27b25e Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Feb 2017 19:07:36 +0100 Subject: [PATCH 26/40] fb_accel_cs_hdx_inc.h: remove unused includes --- src/driver/fb_accel_cs_hdx_inc.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/driver/fb_accel_cs_hdx_inc.h b/src/driver/fb_accel_cs_hdx_inc.h index b1d31988e..cd38baa72 100644 --- a/src/driver/fb_accel_cs_hdx_inc.h +++ b/src/driver/fb_accel_cs_hdx_inc.h @@ -23,21 +23,14 @@ 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 From 1500716fcffba4ae0a3b2a42f5aec5d22932f7eb Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:37:19 +0100 Subject: [PATCH 27/40] fb_generic: make paintLine virtual --- 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 a7e24bf85..c0e53c69e 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -214,7 +214,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 8441a719cbd1e00b5b35605f11b29d4a9284feeb Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:38:00 +0100 Subject: [PATCH 28/40] fb_generic: open device O_CLOEXEC, better diagnostic output --- 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 b7b989373..1ded80c78 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -145,7 +145,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); @@ -165,9 +165,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 b04b1d7f8c1faec98c4cd808a991b859f31a203f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 8 Feb 2017 23:53:54 +0100 Subject: [PATCH 29/40] fb_accel: add TripleDragon framebuffer code --- 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 cb2a5ef11..393a5bf8e 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -59,6 +59,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 148c9f591..d67dc75d0 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -150,4 +150,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 1ded80c78..3453fee1e 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -133,6 +133,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 d498917594f7ee443d293c4b3cf9a660263a2a07 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 9 Feb 2017 00:01:08 +0100 Subject: [PATCH 30/40] fb_generic: remove unused VT switching / restoring code --- 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 3453fee1e..427bdc75f 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -160,8 +160,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; @@ -201,52 +199,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; @@ -281,13 +233,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); @@ -384,31 +329,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; @@ -1557,33 +1477,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 c0e53c69e..d451cdb9e 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 dec601a9dc9ce2c858247ca034a4abff28a7176a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 9 Feb 2017 00:01:50 +0100 Subject: [PATCH 31/40] fontrenderer: add hack to work around broken fullBG code --- src/driver/fontrenderer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/driver/fontrenderer.cpp b/src/driver/fontrenderer.cpp index e974757d3..5d4ee16b7 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 0b7bb32813531d313e1fd54ae333f200ef6ea815 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Thu, 9 Feb 2017 12:38:51 +0100 Subject: [PATCH 32/40] CFbAccelCSHD1::~CFbAccelCSHD1: Remove unnecessary entries... ...that are processed in the CFrameBuffer destructor --- src/driver/fb_accel_cs_hd1.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index 0fc772ab9..4b3df3d20 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -150,10 +150,6 @@ CFbAccelCSHD1::~CFbAccelCSHD1() munmap((void *)gxa_base, 0x40000); if (devmem_fd != -1) close(devmem_fd); - if (lfb) - munmap(lfb, available); - if (fd > -1) - close(fd); } void CFbAccelCSHD1::setColor(fb_pixel_t col) @@ -344,7 +340,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; - printf(LOGTAG "%dx%dx%d line length %d. using hd1 graphics accelerator.\n", xRes, yRes, bpp, stride); + printf(LOGTAG "%dx%dx%d line length %d. using %s graphics accelerator.\n", xRes, yRes, bpp, stride, _fix.id); int needmem = stride * yRes * 2; if (available >= needmem) { From aeec37af895e17b9f8edc922b6a951b8dd38fafc Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 12 Jan 2017 22:30:41 +0100 Subject: [PATCH 33/40] - rename screen_x/yres to font_scaling_x/y --- src/driver/neutrinofonts.cpp | 2 +- src/gui/osd_setup.cpp | 12 ++++++------ src/neutrino.cpp | 20 ++++++++++++++++---- src/system/settings.h | 6 ++++-- version_pseudo.h | 2 +- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index 2f4a3722c..80b40377e 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -142,7 +142,7 @@ void CNeutrinoFonts::SetupNeutrinoFonts(bool initRenderClass/*=true*/) if (initRenderClass) { if (g_fontRenderer != NULL) delete g_fontRenderer; - g_fontRenderer = new FBFontRenderClass(72 * g_settings.screen_xres / 100, 72 * g_settings.screen_yres / 100); + g_fontRenderer = new FBFontRenderClass(72 * g_settings.font_scaling_x / 100, 72 * g_settings.font_scaling_y / 100); old_fontDescr.size_offset = fontDescr.size_offset; old_fontDescr.filename = fontDescr.filename; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index a45a0ca5f..8a31cf3c2 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -267,26 +267,26 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) return res; } else if (actionKey == "font_scaling") { - int xre = g_settings.screen_xres; - int yre = g_settings.screen_yres; + int fs_x = g_settings.font_scaling_x; + int fs_y = g_settings.font_scaling_y; CMenuWidget fontscale(LOCALE_FONTMENU_HEAD, NEUTRINO_ICON_COLORS, width, MN_WIDGET_ID_OSDSETUP_FONTSCALE); fontscale.addIntroItems(LOCALE_FONTMENU_SCALING); - CMenuOptionNumberChooser* mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_X, &g_settings.screen_xres, true, 50, 200, this); + CMenuOptionNumberChooser* mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_X, &g_settings.font_scaling_x, true, 50, 200, this); mc->setNumericInput(true); mc->setNumberFormat("%d%%"); fontscale.addItem(mc); - mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_Y, &g_settings.screen_yres, true, 50, 200, this); + mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_Y, &g_settings.font_scaling_y, true, 50, 200, this); mc->setNumericInput(true); mc->setNumberFormat("%d%%"); fontscale.addItem(mc); res = fontscale.exec(NULL, ""); - if (xre != g_settings.screen_xres || yre != g_settings.screen_yres) { - printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", g_settings.screen_xres, g_settings.screen_yres); + if (fs_x != g_settings.font_scaling_x || fs_y != g_settings.font_scaling_y) { + printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", g_settings.font_scaling_x, g_settings.font_scaling_y); CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT | CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT_INST | CNeutrinoFonts::FONTSETUP_DYN_FONT); if (CNeutrinoApp::getInstance()->channelList) CNeutrinoApp::getInstance()->channelList->ResetModules(); //force re init of all modules diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f1416d10d..d449a78f2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -721,8 +721,6 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.channellist_show_numbers = configfile.getInt32("channellist_show_numbers", 1); //screen configuration - g_settings.screen_xres = configfile.getInt32("screen_xres", 100); - g_settings.screen_yres = configfile.getInt32("screen_yres", 100); g_settings.screen_StartX_crt = configfile.getInt32( "screen_StartX_crt", DEFAULT_X_START_SD); g_settings.screen_StartY_crt = configfile.getInt32( "screen_StartY_crt", DEFAULT_Y_START_SD ); g_settings.screen_EndX_crt = configfile.getInt32( "screen_EndX_crt", DEFAULT_X_END_SD); @@ -783,6 +781,9 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.ttx_font_file = configfile.getString( "ttx_font_file", FONTDIR"/DejaVuLGCSansMono-Bold.ttf"); ttx_font_file = g_settings.ttx_font_file.c_str(); + g_settings.font_scaling_x = configfile.getInt32("font_scaling_x", 100); + g_settings.font_scaling_y = configfile.getInt32("font_scaling_y", 100); + g_settings.update_dir = configfile.getString("update_dir", "/tmp"); g_settings.update_dir_opkg = configfile.getString("update_dir_opkg", g_settings.update_dir); @@ -987,6 +988,16 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.deleteKey("progressbar_timescale_yellow"); configfile.deleteKey("progressbar_timescale_invert"); } + if (g_settings.version_pseudo < "20170209181001") + { + //convert screen_x/yres keys to font_scaling_x/y + + g_settings.font_scaling_x = configfile.getInt32("screen_xres", 100); + g_settings.font_scaling_y = configfile.getInt32("screen_yres", 100); + + configfile.deleteKey("screen_xres"); + configfile.deleteKey("screen_yres"); + } g_settings.version_pseudo = NEUTRINO_VERSION_PSEUDO; configfile.setString("version_pseudo", g_settings.version_pseudo); @@ -1297,8 +1308,6 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("channellist_show_numbers", g_settings.channellist_show_numbers); //screen configuration - configfile.setInt32( "screen_xres", g_settings.screen_xres); - configfile.setInt32( "screen_yres", g_settings.screen_yres); configfile.setInt32( "screen_StartX_lcd", g_settings.screen_StartX_lcd ); configfile.setInt32( "screen_StartY_lcd", g_settings.screen_StartY_lcd ); configfile.setInt32( "screen_EndX_lcd", g_settings.screen_EndX_lcd ); @@ -1338,6 +1347,9 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setString("font_file", g_settings.font_file); configfile.setString("ttx_font_file", g_settings.ttx_font_file); + configfile.setInt32( "font_scaling_x", g_settings.font_scaling_x); + configfile.setInt32( "font_scaling_y", g_settings.font_scaling_y); + //parentallock configfile.setInt32( "parentallock_prompt", g_settings.parentallock_prompt ); configfile.setInt32( "parentallock_lockage", g_settings.parentallock_lockage ); diff --git a/src/system/settings.h b/src/system/settings.h index 2d9d302d4..f352cefc7 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -619,8 +619,6 @@ struct SNeutrinoSettings int screen_preset; int screen_width; int screen_height; - int screen_xres; - int screen_yres; //Software-update int softupdate_mode; @@ -778,9 +776,13 @@ struct SNeutrinoSettings int zap_cycle; int sms_channel; int sms_movie; + std::string font_file; std::string ttx_font_file; + int font_scaling_x; + int font_scaling_y; + int livestreamResolution; std::string livestreamScriptPath; diff --git a/version_pseudo.h b/version_pseudo.h index bdfc25f5d..6f6e6e9a0 100644 --- a/version_pseudo.h +++ b/version_pseudo.h @@ -1 +1 @@ -#define NEUTRINO_VERSION_PSEUDO "20162912080000" +#define NEUTRINO_VERSION_PSEUDO "20170209181001" From abb76c2efb7891c473fec84ac48042ffa7ce9016 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Thu, 12 Jan 2017 23:08:02 +0100 Subject: [PATCH 34/40] - remove screen_width/height from neutrino.conf; ... it's just for internal usage --- src/neutrino.cpp | 24 +++++++++--------------- version_pseudo.h | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index d449a78f2..c0644bd4e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -736,8 +736,8 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.screen_EndX = g_settings.screen_preset ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt; g_settings.screen_EndY = g_settings.screen_preset ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt; - g_settings.screen_width = configfile.getInt32("screen_width", 0); - g_settings.screen_height = configfile.getInt32("screen_height", 0); + g_settings.screen_width = frameBuffer->getScreenWidth(true); + g_settings.screen_height = frameBuffer->getScreenHeight(true); g_settings.bigFonts = configfile.getInt32("bigFonts", 0); g_settings.window_size = configfile.getInt32("window_size", 100); @@ -906,17 +906,6 @@ int CNeutrinoApp::loadSetup(const char * fname) erg = 2; } - /* in case FB resolution changed */ - if((g_settings.screen_width && g_settings.screen_width != (int) frameBuffer->getScreenWidth(true)) - || (g_settings.screen_height && g_settings.screen_height != (int) frameBuffer->getScreenHeight(true))) { - g_settings.screen_StartX = g_settings.screen_preset ? DEFAULT_X_START_HD : DEFAULT_X_START_SD; - g_settings.screen_StartY = g_settings.screen_preset ? DEFAULT_Y_START_HD : DEFAULT_Y_START_SD; - g_settings.screen_EndX = g_settings.screen_preset ? DEFAULT_X_END_HD : DEFAULT_X_END_SD; - g_settings.screen_EndY = g_settings.screen_preset ? DEFAULT_Y_END_HD : DEFAULT_Y_END_SD; - - g_settings.screen_width = frameBuffer->getScreenWidth(true); - g_settings.screen_height = frameBuffer->getScreenHeight(true); - } #ifdef BOXMODEL_APOLLO g_settings.brightness = configfile.getInt32("brightness", 0); g_settings.contrast = configfile.getInt32("contrast", 0); @@ -998,6 +987,13 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.deleteKey("screen_xres"); configfile.deleteKey("screen_yres"); } + if (g_settings.version_pseudo < "20170209181002") + { + //remove screen_width/height keys + + configfile.deleteKey("screen_width"); + configfile.deleteKey("screen_height"); + } g_settings.version_pseudo = NEUTRINO_VERSION_PSEUDO; configfile.setString("version_pseudo", g_settings.version_pseudo); @@ -1317,8 +1313,6 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "screen_EndX_crt", g_settings.screen_EndX_crt ); configfile.setInt32( "screen_EndY_crt", g_settings.screen_EndY_crt ); configfile.setInt32( "screen_preset", g_settings.screen_preset ); - configfile.setInt32( "screen_width", g_settings.screen_width); - configfile.setInt32( "screen_height", g_settings.screen_height); //Software-update configfile.setInt32 ("softupdate_mode" , g_settings.softupdate_mode ); diff --git a/version_pseudo.h b/version_pseudo.h index 6f6e6e9a0..f72f31607 100644 --- a/version_pseudo.h +++ b/version_pseudo.h @@ -1 +1 @@ -#define NEUTRINO_VERSION_PSEUDO "20170209181001" +#define NEUTRINO_VERSION_PSEUDO "20170209181002" From ad8e6180aa7c6e4b1245bc6bcd77d153cd0ac046 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Fri, 13 Jan 2017 08:25:56 +0100 Subject: [PATCH 35/40] - avoid configuration mismatch in screen settings --- src/neutrino.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c0644bd4e..e86cbb05f 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -739,6 +739,12 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.screen_width = frameBuffer->getScreenWidth(true); g_settings.screen_height = frameBuffer->getScreenHeight(true); + // avoid configuration mismatch + if (g_settings.screen_EndX > g_settings.screen_width) + g_settings.screen_EndX = g_settings.screen_width; + if (g_settings.screen_EndY > g_settings.screen_height) + g_settings.screen_EndY = g_settings.screen_height; + g_settings.bigFonts = configfile.getInt32("bigFonts", 0); g_settings.window_size = configfile.getInt32("window_size", 100); g_settings.window_width = configfile.getInt32("window_width", g_settings.window_size); From 274b117f3457f8a5f73c695f4aaeff3b433d36d2 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sat, 11 Feb 2017 11:15:09 +0100 Subject: [PATCH 36/40] - pluginlist: add default timeout to plugin-output ... to avoid a blocked system. Without timeout all upcoming timers will be ignored, if user doesn't confirm the plugin-output. --- src/gui/pluginlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 18db834ec..f44432096 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -77,7 +77,7 @@ int CPluginList::run() g_PluginList->startPlugin(number); if (!g_PluginList->getScriptOutput().empty()) { hide(); - ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_SHELL, 320, g_settings.timing[SNeutrinoSettings::TIMING_STATIC_MESSAGES]); } return menu_return::RETURN_REPAINT; } From e15f31fee48dfc9bea91fd892621fdd36df5a0d7 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 11 Feb 2017 21:08:25 +0100 Subject: [PATCH 37/40] src/driver/pictureviewer/pictureviewer.cpp Picviewer need double image bufferSize for avoid segfault --- src/driver/pictureviewer/pictureviewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 4bb9a63cf..84f2fc7a6 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -856,7 +856,7 @@ bool CPictureViewer::checkfreemem(size_t bufsize) { struct sysinfo info; sysinfo( &info ); - if(bufsize + 4096 > (size_t)info.freeram + (size_t)info.freeswap){ + if(bufsize*2 + 4096 > (size_t)info.freeram + (size_t)info.freeswap){ dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Out of memory\n", __func__, __LINE__); return false; } From bb2a848ae1fa721250ceccadfbf4c802e758809f Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sun, 12 Feb 2017 07:32:58 +0100 Subject: [PATCH 38/40] configure: Rename hardware defined macros for coolstream stb BOXMODEL_NEVIS => BOXMODEL_CS_HD1 configure parameter: --with-boxmodel=hd1 --with-boxmodel=nevis is deprecated, but still valid BOXMODEL_APOLLO => BOXMODEL_CS_HD2 configure parameter: --with-boxmodel=hd2 --with-boxmodel=apollo is deprecated, but still valid --- acinclude.m4 | 30 +++++++++++++++++++++--------- configure.ac | 2 +- data/fonts/Makefile.am | 2 +- src/Makefile.am | 6 +++--- src/system/Makefile.am | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 42956bd07..3eadaaff4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -471,17 +471,29 @@ AC_ARG_WITH(boxtype, esac], [BOXTYPE="coolstream"]) AC_ARG_WITH(boxmodel, - [ --with-boxmodel valid for coolstream: nevis, apollo + [ --with-boxmodel valid for coolstream: hd1, hd2 valid for dreambox: dm500, dm500plus, dm600pvr, dm56x0, dm7000, dm7020, dm7025 valid for ipbox: ip200, ip250, ip350, ip400], [case "${withval}" in - nevis|apollo) + hd1|hd2) if test "$BOXTYPE" = "coolstream"; then BOXMODEL="$withval" else AC_MSG_ERROR([unknown model $withval for boxtype $BOXTYPE]) fi ;; + nevis|apollo) + if test "$BOXTYPE" = "coolstream"; then + if test "$withval" = "nevis"; then + BOXMODEL="hd1" + fi + if test "$withval" = "apollo"; then + BOXMODEL="hd2" + fi + else + AC_MSG_ERROR([unknown model $withval for boxtype $BOXTYPE]) + fi + ;; dm500|dm500plus|dm600pvr|dm56x0|dm7000|dm7020|dm7025) if test "$BOXTYPE" = "dreambox"; then BOXMODEL="$withval" @@ -499,7 +511,7 @@ AC_ARG_WITH(boxmodel, *) AC_MSG_ERROR([unsupported value $withval for --with-boxmodel]) ;; - esac], [BOXMODEL="nevis"] + esac], [BOXMODEL="hd1"] [if test "$BOXTYPE" = "dreambox" -o "$BOXTYPE" = "ipbox" && test -z "$BOXMODEL"; then AC_MSG_ERROR([Dreambox/IPBox needs --with-boxmodel]) fi]) @@ -514,8 +526,8 @@ AM_CONDITIONAL(BOXTYPE_IPBOX, test "$BOXTYPE" = "ipbox") AM_CONDITIONAL(BOXTYPE_COOL, test "$BOXTYPE" = "coolstream") AM_CONDITIONAL(BOXTYPE_GENERIC, test "$BOXTYPE" = "generic") -AM_CONDITIONAL(BOXMODEL_NEVIS,test "$BOXMODEL" = "nevis") -AM_CONDITIONAL(BOXMODEL_APOLLO,test "$BOXMODEL" = "apollo") +AM_CONDITIONAL(BOXMODEL_CS_HD1,test "$BOXMODEL" = "hd1") +AM_CONDITIONAL(BOXMODEL_CS_HD2,test "$BOXMODEL" = "hd2") AM_CONDITIONAL(BOXMODEL_DM500,test "$BOXMODEL" = "dm500") AM_CONDITIONAL(BOXMODEL_DM500PLUS,test "$BOXMODEL" = "dm500plus") @@ -543,10 +555,10 @@ elif test "$BOXTYPE" = "generic"; then fi # TODO: do we need more defines? -if test "$BOXMODEL" = "nevis"; then - AC_DEFINE(BOXMODEL_NEVIS, 1, [coolstream hd1/neo/neo2/zee]) -elif test "$BOXMODEL" = "apollo"; then - AC_DEFINE(BOXMODEL_APOLLO, 1, [coolstream tank]) +if test "$BOXMODEL" = "hd1"; then + AC_DEFINE(BOXMODEL_CS_HD1, 1, [coolstream hd1/neo/neo2/zee]) +elif test "$BOXMODEL" = "hd2"; then + AC_DEFINE(BOXMODEL_CS_HD2, 1, [coolstream tank/trinity/trinity v2/trinity duo/zeeČ/link]) elif test "$BOXMODEL" = "dm500"; then AC_DEFINE(BOXMODEL_DM500, 1, [dreambox 500]) elif test "$BOXMODEL" = "ip200"; then diff --git a/configure.ac b/configure.ac index 3ebe71b4d..b1616b075 100644 --- a/configure.ac +++ b/configure.ac @@ -245,7 +245,7 @@ if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then fi HWLIB_CFLAGS='-I$(top_srcdir)/lib/libcoolstream -I$(top_srcdir)/src/zapit/include/private' -if test "$BOXMODEL" = "apollo"; then +if test "$BOXMODEL" = "hd2"; then if test -e ${srcdir}/lib/libcoolstream2/cs_ir_generic.h; then AC_DEFINE(HAVE_COOLSTREAM_CS_IR_GENERIC_H,1,[Define to 1 if you have the header file.]) fi diff --git a/data/fonts/Makefile.am b/data/fonts/Makefile.am index 7f822c6b1..6325ef80f 100644 --- a/data/fonts/Makefile.am +++ b/data/fonts/Makefile.am @@ -11,6 +11,6 @@ install_DATA = \ tuxtxt.ttf \ tuxtxt.otb -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 install_DATA += UnDotum.ttf endif diff --git a/src/Makefile.am b/src/Makefile.am index dcf9c8196..1d452bd8f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,7 +61,7 @@ neutrino_SOURCES = neutrino_menue.cpp neutrino.cpp AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64 -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 MTDUTILSLIBS = \ system/mtdutils/libneutrino_system_mtdutils.a \ system/mtdutils/lib/libneutrino_system_mtdutils_lib.a @@ -145,14 +145,14 @@ if BOXTYPE_COOL neutrino_LDADD += -lcoolstream-mt -lca-sc if ENABLE_TMSDK else -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 neutrino_LDADD += -lca-ci -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager-cst -ltmpvrIndexStorage -llnxscsUsr else neutrino_LDADD += -lnxp endif endif -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 neutrino_LDADD += -liconv endif diff --git a/src/system/Makefile.am b/src/system/Makefile.am index c0c5df8eb..4fdf2e4d7 100644 --- a/src/system/Makefile.am +++ b/src/system/Makefile.am @@ -1,4 +1,4 @@ -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 SUBDIRS = mtdutils endif From 0d66899cbdf6ea0f96bd991720c4658beccb7e46 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sun, 12 Feb 2017 07:33:01 +0100 Subject: [PATCH 39/40] neutrino: Rename hardware defined macros for coolstream stb BOXMODEL_NEVIS => BOXMODEL_CS_HD1 BOXMODEL_APOLLO => BOXMODEL_CS_HD2 --- src/driver/fade.cpp | 14 +++++------ src/driver/framebuffer.cpp | 6 ++--- src/driver/rcinput.h | 2 +- src/driver/screenshot.cpp | 2 +- src/driver/vfd.cpp | 8 +++---- src/driver/vfd.h | 2 +- src/drivertool.c | 2 +- src/eitd/edvbstring.cpp | 8 +++---- src/gui/audio_setup.cpp | 8 +++---- src/gui/cam_menu.cpp | 4 ++-- src/gui/components/cc_item_picture.cpp | 2 +- src/gui/movieplayer.cpp | 2 +- src/gui/update.cpp | 30 ++++++++++++------------ src/gui/update.h | 10 ++++---- src/gui/update_ext.cpp | 2 +- src/gui/update_menue.cpp | 2 +- src/gui/update_settings.cpp | 4 ++-- src/gui/videosettings.cpp | 22 ++++++++--------- src/neutrino.cpp | 4 ++-- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 8 +++---- src/system/flashtool.cpp | 4 ++-- src/system/setting_helpers.cpp | 6 ++--- src/system/settings.h | 4 ++-- src/zapit/src/capmt.cpp | 4 ++-- src/zapit/src/frontend.cpp | 2 +- src/zapit/src/zapit.cpp | 4 ++-- 26 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/driver/fade.cpp b/src/driver/fade.cpp index a0c2f45f7..39da5d0ac 100644 --- a/src/driver/fade.cpp +++ b/src/driver/fade.cpp @@ -54,14 +54,14 @@ void COSDFader::StartFadeIn() fadeIn = true; fadeOut = false; fadeValue = 100; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_UNIFORM_ALPHA); // Global alpha multiplied with pixel alpha #else frameBuffer->setBlendMode(2); // Global alpha multiplied with pixel alpha #endif frameBuffer->setBlendLevel(fadeValue); -#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_APOLLO)) +#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) usleep(60000); #endif fadeTimer = g_RCInput->addTimer( FADE_TIME, false ); @@ -78,7 +78,7 @@ bool COSDFader::StartFadeOut() if ((!fadeOut) && g_settings.widget_fade) { fadeOut = true; fadeTimer = g_RCInput->addTimer( FADE_TIME, false ); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_UNIFORM_ALPHA); // Global alpha multiplied with pixel alpha #else frameBuffer->setBlendMode(2); // Global alpha multiplied with pixel alpha @@ -92,12 +92,12 @@ void COSDFader::StopFade() { if ( fadeIn || fadeOut ) { g_RCInput->killTimer(fadeTimer); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_PER_PIXEL); // Global alpha multiplied with pixel alpha #else frameBuffer->setBlendMode(1); // Global alpha multiplied with pixel alpha #endif -#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_APOLLO)) +#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) usleep(60000); #endif fadeIn = fadeOut = false; @@ -123,12 +123,12 @@ bool COSDFader::FadeDone() fadeValue = max_alpha; g_RCInput->killTimer (fadeTimer); fadeIn = false; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_PER_PIXEL); // Global alpha multiplied with pixel alpha #else frameBuffer->setBlendMode(1); // Global alpha multiplied with pixel alpha #endif -#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_APOLLO)) +#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) usleep(60000); #endif } else diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index aba573365..8f88a1b02 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -63,7 +63,7 @@ extern CPictureViewer * g_PicViewer; #define BACKGROUNDIMAGEWIDTH 720 -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #ifndef FB_HW_ACCELERATION #define FB_HW_ACCELERATION #endif @@ -587,7 +587,7 @@ void CFrameBuffer::setBlendLevel(int level) if (ioctl(fd, FBIO_SETOPACITY, value)) printf("FBIO_SETOPACITY failed.\n"); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 if(level == 100) // TODO: sucks. usleep(20000); #endif @@ -740,7 +740,7 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co int w_align; int offs_align; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (_dx%4 != 0) { w_align = GetWidth4FB_HW_ACC(x, _dx, true); if (w_align < _dx) diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 0f7869e43..5c6458506 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -39,7 +39,7 @@ #include #include -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #ifdef HAVE_COOLSTREAM_CS_IR_GENERIC_H #include #endif diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index e438f924b..7ea887b49 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -218,7 +218,7 @@ bool CScreenShot::SavePng() png_set_compression_level(png_ptr, Z_BEST_SPEED); png_set_bgr(png_ptr); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 png_set_invert_alpha(png_ptr); #endif png_write_info(png_ptr, info_ptr); diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index daf603e82..b0dc73f50 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -71,7 +71,7 @@ CVFD::CVFD() has_led_segment = false; } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (fd >= 0) { int ret = ioctl(fd, IOC_FP_GET_DISPLAY_CAPS, &caps); if (ret < 0) { @@ -372,7 +372,7 @@ void CVFD::showTime(bool force) ShowText(timestr); } else if (support_numbers && has_led_segment) { ShowNumber((t->tm_hour*100) + t->tm_min); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 ioctl(fd, IOC_FP_SET_COLON, 0x01); #endif } @@ -564,7 +564,7 @@ void CVFD::setMode(const MODES m, const char * const title) if(fd < 0) return; // Clear colon in display if it is still there -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (support_numbers && has_led_segment) ioctl(fd, IOC_FP_SET_COLON, 0x00); #endif @@ -815,7 +815,7 @@ void CVFD::ShowNumber(int number) if (number < 0) return; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 int ret = ioctl(fd, IOC_FP_SET_NUMBER, number); if(ret < 0) { support_numbers = false; diff --git a/src/driver/vfd.h b/src/driver/vfd.h index 5f1c374a7..4a3ec64c0 100644 --- a/src/driver/vfd.h +++ b/src/driver/vfd.h @@ -76,7 +76,7 @@ class CVFD private: -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 fp_display_caps_t caps; #endif MODES mode; diff --git a/src/drivertool.c b/src/drivertool.c index 80432d776..4e753e868 100644 --- a/src/drivertool.c +++ b/src/drivertool.c @@ -32,7 +32,7 @@ #include -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #ifdef HAVE_COOLSTREAM_CS_IR_GENERIC_H #include #endif diff --git a/src/eitd/edvbstring.cpp b/src/eitd/edvbstring.cpp index 9267630da..3ddff948a 100644 --- a/src/eitd/edvbstring.cpp +++ b/src/eitd/edvbstring.cpp @@ -198,7 +198,7 @@ static unsigned long iso6937[96]={ 0x0138, 0x00E6, 0x0111, 0x00F0, 0x0127, 0x0131, 0x0133, 0x0140, 0x0142, 0x00F8, 0x0153, 0x00DF, 0x00FE, 0x0167, 0x014B, 0x00AD }; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 const unsigned short cGB2312UNI[] = { // Start at 0xA100.so index have to be reduced. Maybe this can be optimized by removing the starts but for // now just 'make it work' :). @@ -2020,7 +2020,7 @@ std::string convertDVBUTF8(const char *data, int len, int table, int tsidonid) { int newtable = 0; bool twochar = false; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 bool gb2312 = false; #endif if (!len) @@ -2070,7 +2070,7 @@ std::string convertDVBUTF8(const char *data, int len, int table, int tsidonid) break; case 0x13: ++i; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 //printf("GB-2312-1980 enc.\n"); gb2312 = true; #endif @@ -2116,7 +2116,7 @@ std::string convertDVBUTF8(const char *data, int len, int table, int tsidonid) //dprintf("recode:::: doVideoTexSuppl code %lX\n", code); } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 // GB2312 -> Unicode if (gb2312 && !code) { if (data[i] >= 0xA1) { diff --git a/src/gui/audio_setup.cpp b/src/gui/audio_setup.cpp index 27f8cb3a4..848a747e3 100644 --- a/src/gui/audio_setup.cpp +++ b/src/gui/audio_setup.cpp @@ -94,7 +94,7 @@ const CMenuOptionChooser::keyval AUDIOMENU_ANALOGOUT_OPTIONS[AUDIOMENU_ANALOGOUT { 2, LOCALE_AUDIOMENU_MONORIGHT } }; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #define AUDIOMENU_SRS_OPTION_COUNT 3 #else #define AUDIOMENU_SRS_OPTION_COUNT 2 @@ -103,7 +103,7 @@ const CMenuOptionChooser::keyval AUDIOMENU_SRS_OPTIONS[AUDIOMENU_SRS_OPTION_COUN { { 0 , LOCALE_AUDIO_SRS_ALGO_LIGHT }, { 1 , LOCALE_AUDIO_SRS_ALGO_NORMAL }, -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 { 2 , LOCALE_AUDIO_SRS_ALGO_HEAVY } #endif }; @@ -229,7 +229,7 @@ int CAudioSetup::showAudioSetup() audioSettings->addItem(GenericMenuSeparatorLine); audioSettings->addItem(as_oj_srsonoff); audioSettings->addItem(as_oj_algo); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 audioSettings->addItem(as_oj_noise); #endif audioSettings->addItem(as_oj_volrev); @@ -246,7 +246,7 @@ int CAudioSetup::showAudioSetup() int res = audioSettings->exec(NULL, ""); selected = audioSettings->getSelected(); delete audioSettings; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 delete as_oj_noise; #endif if (!g_settings.easymenu) diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index 28c195ee5..1ea62fc18 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -108,7 +108,7 @@ int CCAMMenuHandler::doMainMenu() CMenuWidget* cammenu = new CMenuWidget(LOCALE_CI_SETTINGS, NEUTRINO_ICON_SETTINGS); cammenu->addIntroItems(); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 int fecount = CFEManager::getInstance()->getFrontendCount(); char fename[fecount+1][255]; #endif @@ -120,7 +120,7 @@ int CCAMMenuHandler::doMainMenu() cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_IGNORE_MSG, &g_settings.ci_ignore_messages, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_SAVE_PINCODE, &g_settings.ci_save_pincode, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this)); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 CMenuOptionChooser::keyval_ext feselect[fecount+1]; feselect[0].key = -1; feselect[0].value = NONEXISTANT_LOCALE; diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 1abad278a..2d0fb1555 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -221,7 +221,7 @@ void CComponentsPicture::initCCItem() { float h_ratio = float(height)*100/(float)dy; width = int(h_ratio*(float)dx/100); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (do_scale && (width > 10 || height > 10)) width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; #endif diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index dfb1b2d02..16301f46b 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1788,7 +1788,7 @@ void CMoviePlayerGui::addAudioFormat(int count, std::string &apidtitle, bool& en case 6: /*DTS*/ if (apidtitle.find("DTS") == std::string::npos) apidtitle.append(" (DTS)"); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 enabled = false; #endif break; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 3bb5e4894..eeca7c65c 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -90,7 +90,7 @@ extern int allow_flash; #define FILEBROWSER_UPDATE_FILTER "img" #define MTD_OF_WHOLE_IMAGE 0 -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #define MTD_DEVICE_OF_UPDATE_PART "/dev/mtd0" #else #define MTD_DEVICE_OF_UPDATE_PART "/dev/mtd3" @@ -321,7 +321,7 @@ bool CFlashUpdate::selectHttpImage(void) newVersion = versions[selected]; file_md5 = md5s[selected]; fileType = fileTypes[selected]; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if(fileType < '3') { int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs); printf("[update] erase size is %x\n", esize); @@ -556,7 +556,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) #endif if(fileType < '3') { //flash it... -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 if (g_settings.apply_settings) { if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE) == CMsgBox::mbrYes) if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) { @@ -624,7 +624,7 @@ CFlashExpert::CFlashExpert() { selectedMTD = -1; width = 40; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 forceOtherFilename = false; otherFilename = ""; createimage_other = 0; @@ -641,7 +641,7 @@ CFlashExpert* CFlashExpert::getInstance() bool CFlashExpert::checkSize(int mtd, std::string &backupFile) { -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 if (mtd < 0) return false; #endif char errMsg[1024] = {0}; @@ -655,7 +655,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) uint64_t btotal = 0, bused = 0; long bsize = 0; uint64_t backupRequiredSize = 0; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (mtd == -1) { // check disk space for image creation if (!get_fs_usage("/", btotal, bused, &bsize)) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0"); @@ -691,7 +691,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) return true; } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 bool CFlashExpert::readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable) { FILE *fd = fopen(devtableFile.c_str(), "r"); @@ -775,7 +775,7 @@ void CFlashExpert::readmtd(int preadmtd) netGetHostname(hostName); std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M"); std::string tankStr = ""; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem()); if (preadmtd == 0) { if (createimage_other == 0) { @@ -793,7 +793,7 @@ void CFlashExpert::readmtd(int preadmtd) else filename = (std::string)g_settings.update_dir + "/" + mtdInfo->getMTDName(preadmtd) + timeStr + tankStr + ".img"; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 std::string title = " (" + CMTDInfo::getInstance()->getMTDName(preadmtd) + ")"; std::string mountp = getJFFS2MountPoint(preadmtd); if (preadmtd == 0) { @@ -817,7 +817,7 @@ void CFlashExpert::readmtd(int preadmtd) } bool skipCheck = false; -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 if ((std::string)g_settings.update_dir == "/tmp") skipCheck = true; #else @@ -845,7 +845,7 @@ void CFlashExpert::readmtd(int preadmtd) sprintf(message, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str()); sleep(1); hide(); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (!forceOtherFilename) ShowHint(LOCALE_MESSAGEBOX_INFO, message); #else @@ -907,7 +907,7 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) for(int lx=0;lxgetMTDCount();lx++) { char sActionKey[20]; bool enabled = true; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 // disable write uboot / uldr / env if ((actionkey == "writemtd") && (lx == mtdInfo->findMTDNumberFromName("u-boot") || lx == mtdInfo->findMTDNumberFromName("uldr") || @@ -930,7 +930,7 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) sprintf(sActionKey, "%s%d", actionkey.c_str(), lx); mtdselector->addItem(new CMenuForwarder(mtdInfo->getMTDName(lx).c_str(), enabled, NULL, this, sActionKey, CRCInput::convertDigitToKey(shortcut++))); } -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 if (actionkey == "writemtd") mtdselector->addItem(new CMenuForwarder("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++))); #endif @@ -1019,7 +1019,7 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey) return res; } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 CFlashExpertSetup::CFlashExpertSetup() { width = 40; @@ -1187,4 +1187,4 @@ g_settings.flashupdate_createimage_add_spare = 0; cfe->createimage_other = 0; return res; } -#endif // BOXMODEL_APOLLO +#endif // BOXMODEL_CS_HD2 diff --git a/src/gui/update.h b/src/gui/update.h index 2302ad3e6..1a8107c61 100644 --- a/src/gui/update.h +++ b/src/gui/update.h @@ -39,7 +39,7 @@ #include #include -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #include #endif @@ -81,13 +81,13 @@ class CFlashExpert : public CProgressWindow int showFileSelector(const std::string & actionkey); bool checkSize(int mtd, std::string &backupFile); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 bool readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable); void readmtdJFFS2(std::string &filename, std::string title="", std::string path="/", bool makeDevTable=true); #endif public: -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 bool forceOtherFilename; std::string otherFilename; int createimage_other; @@ -100,7 +100,7 @@ class CFlashExpert : public CProgressWindow }; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 class CFlashExpertSetup : public CMenuTarget { private: @@ -115,6 +115,6 @@ class CFlashExpertSetup : public CMenuTarget int exec(CMenuTarget* parent, const std::string &actionKey); }; -#endif // BOXMODEL_APOLLO +#endif // BOXMODEL_CS_HD2 #endif diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index f92df2c7d..0792a90f4 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -233,7 +233,7 @@ bool CExtUpdate::applySettings() if (mtdFilename.empty()) return ErrorReset(0, "error system mtd not found"); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 uint64_t mtdSize = 65536*1024; // FIXME hack, mtd size more than free RAM #else uint64_t mtdSize = mtdInfo->getMTDSize(mtdFilename); diff --git a/src/gui/update_menue.cpp b/src/gui/update_menue.cpp index e0af074e7..598ecdc10 100644 --- a/src/gui/update_menue.cpp +++ b/src/gui/update_menue.cpp @@ -124,7 +124,7 @@ int CSoftwareUpdate::showSoftwareUpdate() #endif } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 softUpdate.addItem(GenericMenuSeparatorLine); if (g_settings.easymenu) diff --git a/src/gui/update_settings.cpp b/src/gui/update_settings.cpp index 9497add6a..1092b54f5 100644 --- a/src/gui/update_settings.cpp +++ b/src/gui/update_settings.cpp @@ -131,7 +131,7 @@ int CUpdateSettings::initMenu() CMenuOptionChooser *name_backup = new CMenuOptionChooser(LOCALE_FLASHUPDATE_NAMEMODE2, &g_settings.softupdate_name_mode_backup, SOFTUPDATE_NAME_MODE2_OPTIONS, SOFTUPDATE_NAME_MODE2_OPTION_COUNT, true); // name_backup->setHint("", LOCALE_MENU_HINT_XXX); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 CMenuOptionChooser *apply_settings = new CMenuOptionChooser(LOCALE_FLASHUPDATE_MENU_APPLY_SETTINGS, &g_settings.apply_settings, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, OnOffNotifier); // apply_settings->setHint("", LOCALE_MENU_HINT_XXX); @@ -152,7 +152,7 @@ int CUpdateSettings::initMenu() w_upsettings.addItem(fw_update_dir); w_upsettings.addItem(fw_url); w_upsettings.addItem(name_backup); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 w_upsettings.addItem(GenericMenuSeparatorLine); w_upsettings.addItem(apply_settings); w_upsettings.addItem(name_apply); diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 5bfeeabe4..6515f171e 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -105,7 +105,7 @@ int CVideoSettings::exec(CMenuTarget* parent, const std::string &/*actionKey*/) const CMenuOptionChooser::keyval VIDEOMENU_43MODE_OPTIONS[] = { { DISPLAY_AR_MODE_PANSCAN, LOCALE_VIDEOMENU_PANSCAN }, -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 { DISPLAY_AR_MODE_PANSCAN2, LOCALE_VIDEOMENU_PANSCAN2 }, #endif { DISPLAY_AR_MODE_LETTERBOX, LOCALE_VIDEOMENU_LETTERBOX }, @@ -197,7 +197,7 @@ CMenuOptionChooser::keyval_ext VIDEOMENU_VIDEOMODE_OPTIONS[VIDEOMENU_VIDEOMODE_O { VIDEO_STD_576P, NONEXISTANT_LOCALE, "576p" }, { VIDEO_STD_720P50, NONEXISTANT_LOCALE, "720p 50Hz" }, { VIDEO_STD_1080I50, NONEXISTANT_LOCALE, "1080i 50Hz" }, -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 { VIDEO_STD_1080P50, NONEXISTANT_LOCALE, "1080p 50Hz" }, #endif { VIDEO_STD_1080P24, NONEXISTANT_LOCALE, "1080p 24Hz" }, @@ -206,7 +206,7 @@ CMenuOptionChooser::keyval_ext VIDEOMENU_VIDEOMODE_OPTIONS[VIDEOMENU_VIDEOMODE_O { VIDEO_STD_480P, NONEXISTANT_LOCALE, "480p" }, { VIDEO_STD_720P60, NONEXISTANT_LOCALE, "720p 60Hz" }, { VIDEO_STD_1080I60, NONEXISTANT_LOCALE, "1080i 60Hz" }, -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 { VIDEO_STD_1080P60, NONEXISTANT_LOCALE, "1080p 60Hz" }, { VIDEO_STD_1080P2397, NONEXISTANT_LOCALE, "1080p 23.97Hz"}, { VIDEO_STD_1080P2997, NONEXISTANT_LOCALE, "1080p 29.97Hz"}, @@ -249,7 +249,7 @@ int CVideoSettings::showVideoSetup() } else if (system_rev > 0x06) { -#if defined(BOXMODEL_APOLLO) && defined(ANALOG_MODE) +#if defined(BOXMODEL_CS_HD2) && defined(ANALOG_MODE) vs_analg_ch = new CMenuOptionChooser(LOCALE_VIDEOMENU_ANALOG_MODE, &g_settings.analog_mode1, VIDEOMENU_VIDEOSIGNAL_HD2_OPTIONS, VIDEOMENU_VIDEOSIGNAL_HD2_OPTION_COUNT, true, this); vs_analg_ch->setHint("", LOCALE_MENU_HINT_VIDEO_ANALOG_MODE); #else @@ -277,7 +277,7 @@ int CVideoSettings::showVideoSetup() CMenuOptionChooser * vs_dbdropt_ch = NULL; CMenuForwarder * vs_videomodes_fw = NULL; CMenuWidget videomodes(LOCALE_MAINSETTINGS_VIDEO, NEUTRINO_ICON_SETTINGS); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 CMenuForwarder * vs_automodes_fw = NULL; CMenuWidget automodes(LOCALE_MAINSETTINGS_VIDEO, NEUTRINO_ICON_SETTINGS); #endif @@ -296,7 +296,7 @@ int CVideoSettings::showVideoSetup() vs_videomodes_fw = new CMenuForwarder(LOCALE_VIDEOMENU_ENABLED_MODES, true, NULL, &videomodes, NULL, CRCInput::RC_red); vs_videomodes_fw->setHint("", LOCALE_MENU_HINT_VIDEO_MODES); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 automodes.addIntroItems(LOCALE_VIDEOMENU_ENABLED_MODES_AUTO); for (int i = 0; i < VIDEOMENU_VIDEOMODE_OPTION_COUNT - 1; i++) @@ -325,12 +325,12 @@ int CVideoSettings::showVideoSetup() if (!g_settings.easymenu) { videosetup->addItem(vs_dbdropt_ch); //dbdr options videosetup->addItem(vs_videomodes_fw); //video modes submenue -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 videosetup->addItem(vs_automodes_fw); //video auto modes submenue #endif } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (!g_settings.easymenu) { /* values are from -128 to 127, but brightness really no sense after +/- 40. changeNotify multiply contrast and saturation to 3 */ CMenuOptionNumberChooser * bcont = new CMenuOptionNumberChooser(LOCALE_VIDEOMENU_BRIGHTNESS, &g_settings.brightness, true, -42, 42, this); @@ -373,7 +373,7 @@ void CVideoSettings::setVideoSettings() videoDecoder->SetVideoMode((analog_mode_t) g_settings.analog_mode1); videoDecoder->SetVideoMode((analog_mode_t) g_settings.analog_mode2); #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 changeNotify(LOCALE_VIDEOMENU_ANALOG_MODE, NULL); #else unsigned int system_rev = cs_get_revision(); @@ -398,7 +398,7 @@ void CVideoSettings::setVideoSettings() videoDecoder->SetDBDR(g_settings.video_dbdr); CAutoModeNotifier anotify; anotify.changeNotify(NONEXISTANT_LOCALE, 0); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 changeNotify(LOCALE_VIDEOMENU_BRIGHTNESS, NULL); changeNotify(LOCALE_VIDEOMENU_CONTRAST, NULL); changeNotify(LOCALE_VIDEOMENU_SATURATION, NULL); @@ -472,7 +472,7 @@ bool CVideoSettings::changeNotify(const neutrino_locale_t OptionName, void * /* setupVideoSystem(true/*ask*/); return true; } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_VIDEOMENU_BRIGHTNESS)) { videoDecoder->SetControl(VIDEO_CONTROL_BRIGHTNESS, g_settings.brightness); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f1416d10d..beb2441a3 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -916,7 +916,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.screen_width = frameBuffer->getScreenWidth(true); g_settings.screen_height = frameBuffer->getScreenHeight(true); } -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 g_settings.brightness = configfile.getInt32("brightness", 0); g_settings.contrast = configfile.getInt32("contrast", 0); g_settings.saturation = configfile.getInt32("saturation", 0); @@ -1424,7 +1424,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("window_size", g_settings.window_size); configfile.setInt32("window_width", g_settings.window_width); configfile.setInt32("window_height", g_settings.window_height); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 configfile.setInt32("brightness", g_settings.brightness ); configfile.setInt32("contrast", g_settings.contrast ); configfile.setInt32("enable_sd_osd", g_settings.enable_sd_osd ); diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index ce7537673..7b142a2ef 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -851,7 +851,7 @@ std::string CNeutrinoYParser::func_get_boxtype(CyhookHandler *, std::string) if( boxname == "Armas ") boxname += "TripleDragon"; break; -#ifdef BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 case 6: boxname += "HD1"; break; @@ -867,7 +867,7 @@ std::string CNeutrinoYParser::func_get_boxtype(CyhookHandler *, std::string) boxname += "Zee"; break; #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 case 9: boxname += "Tank"; break; @@ -906,7 +906,7 @@ std::string CNeutrinoYParser::func_get_boxmodel(CyhookHandler *, std::string) switch(system_rev) { -#ifdef BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 case 6: case 7: case 8: @@ -914,7 +914,7 @@ std::string CNeutrinoYParser::func_get_boxmodel(CyhookHandler *, std::string) boxmodel = "Nevis"; break; #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 case 9: boxmodel = "Apollo"; break; diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 20447b361..34a534792 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -177,7 +177,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra std::string flashfile; bool skipCopy = false; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (strcmp(dn, "/tmp") != 0) { uint64_t btotal = 0, bused = 0; long bsize = 0; @@ -680,7 +680,7 @@ int CMTDInfo::getMTDEraseSize( const std::string & filename ) std::string CMTDInfo::findMTDsystem() { -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 std::string sysfs = "root0"; #else std::string sysfs = "systemFS"; diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 08d3af362..e177a3a34 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -528,7 +528,7 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK CServiceManager::getInstance()->SatelliteList().clear(); CZapit::getInstance()->LoadSettings(); CZapit::getInstance()->GetConfig(zapitCfg); -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 /* flag file to erase /var partition on factory reset, will be done by init scripts */ FILE * fp = fopen("/var_init/etc/.reset", "w"); @@ -566,7 +566,7 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK void CFanControlNotifier::setSpeed(unsigned int speed) { printf("FAN Speed %d\n", speed); -#ifndef BOXMODEL_APOLLO +#ifndef BOXMODEL_CS_HD2 int cfd = open("/dev/cs_control", O_RDONLY); if(cfd < 0) { perror("Cannot open /dev/cs_control"); @@ -607,7 +607,7 @@ bool CAutoModeNotifier::changeNotify(const neutrino_locale_t /*OptionName*/, voi memset(modes, 0, sizeof(int)*VIDEO_STD_MAX+1); for(i = 0; i < VIDEOMENU_VIDEOMODE_OPTION_COUNT; i++) -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 modes[VIDEOMENU_VIDEOMODE_OPTIONS[i].key] = g_settings.enabled_auto_modes[i]; #else modes[VIDEOMENU_VIDEOMODE_OPTIONS[i].key] = g_settings.enabled_video_modes[i]; diff --git a/src/system/settings.h b/src/system/settings.h index 2d9d302d4..7ba0ed573 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -42,7 +42,7 @@ #include #include -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 #define VIDEOMENU_VIDEOMODE_OPTION_COUNT 16 #else #define VIDEOMENU_VIDEOMODE_OPTION_COUNT 12 @@ -173,7 +173,7 @@ struct SNeutrinoSettings int analog_mode1; int analog_mode2; int video_43mode; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 int brightness; int contrast; int saturation; diff --git a/src/zapit/src/capmt.cpp b/src/zapit/src/capmt.cpp index 31fe1af3f..ce8dc7de1 100644 --- a/src/zapit/src/capmt.cpp +++ b/src/zapit/src/capmt.cpp @@ -281,7 +281,7 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start if (channel_map.size() > 1) list = CCam::CAPMT_ADD; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 int ci_use_count = 0; for (it = channel_map.begin(); it != channel_map.end(); ++it) { @@ -338,7 +338,7 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start void CCamManager::SetCITuner(int tuner) { tunerno = tuner; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (tunerno >= 0) cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)tunerno); #endif diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index dcad640e0..f0b5b5599 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -308,7 +308,7 @@ void CFrontend::getFEInfo(void) switch (info.type) { case FE_QPSK: deliverySystemMask |= DVB_S; -#ifndef BOXMODEL_NEVIS +#ifndef BOXMODEL_CS_HD1 if (info.caps & FE_CAN_2G_MODULATION) #endif deliverySystemMask |= DVB_S2; diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 3d7242db0..e8682ba1b 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -584,7 +584,7 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay StopPip(); #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (CCamManager::getInstance()->GetCITuner() < 0) cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)live_fe->getNumber()); #endif @@ -2362,7 +2362,7 @@ bool CZapit::Start(Z_start_arg *ZapStart_arg) /* FIXME until proper demux management */ int dnum = 1; #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 videoDecoder = cVideo::GetDecoder(0); audioDecoder = cAudio::GetDecoder(0); From 987dbe7f1d6c728e891e688ad62e9bcdfaa34d06 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Sun, 12 Feb 2017 08:18:18 +0100 Subject: [PATCH 40/40] pu/fb-modules: Rename hardware defined macros for coolstream stb BOXMODEL_NEVIS => BOXMODEL_CS_HD1 BOXMODEL_APOLLO => BOXMODEL_CS_HD2 --- src/driver/Makefile.am | 2 +- src/driver/fb_generic.cpp | 6 +++--- src/driver/fb_generic.h | 2 +- src/driver/screenshot.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 393a5bf8e..b915465ee 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -46,7 +46,7 @@ libneutrino_driver_a_SOURCES = \ volume.cpp if BOXTYPE_COOL -if BOXMODEL_APOLLO +if BOXMODEL_CS_HD2 libneutrino_driver_a_SOURCES += \ fb_accel_cs_hd2.cpp \ vfd.cpp diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 427bdc75f..0c7df12e4 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -124,10 +124,10 @@ CFrameBuffer* CFrameBuffer::getInstance() frameBuffer = new CFbAccelSTi(); #endif #if HAVE_COOL_HARDWARE -#ifdef BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 frameBuffer = new CFbAccelCSHD1(); #endif -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 frameBuffer = new CFbAccelCSHD2(); #endif #endif @@ -511,7 +511,7 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co int w_align; int offs_align; -#ifdef BOXMODEL_APOLLO +#ifdef BOXMODEL_CS_HD2 if (_dx%4 != 0) { w_align = GetWidth4FB_HW_ACC(x, _dx, true); if (w_align < _dx) diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index d451cdb9e..5b2a24402 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -184,7 +184,7 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? -#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 virtual void setupGXA() {}; virtual void add_gxa_sync_marker() {}; #endif diff --git a/src/driver/screenshot.cpp b/src/driver/screenshot.cpp index ec1118fae..98b873ca0 100644 --- a/src/driver/screenshot.cpp +++ b/src/driver/screenshot.cpp @@ -77,7 +77,7 @@ bool CScreenShot::GetData() bool res = false; mutex.lock(); -#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 CFrameBuffer::getInstance()->setActive(false); #endif if (videoDecoder->getBlank()) @@ -86,7 +86,7 @@ bool CScreenShot::GetData() res = videoDecoder->GetScreenImage(pixel_data, xres, yres, get_video, get_osd, scale_to_video); #endif -#if HAVE_COOL_HARDWARE && BOXMODEL_NEVIS +#ifdef BOXMODEL_CS_HD1 /* sort of hack. GXA used to transfer/convert live image to RGB, * so setup GXA back */ CFrameBuffer::getInstance()->setupGXA();