From c4c6ac0881cd938b0b1fb73180ddc103d46ce3ad Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 1 Feb 2017 22:07:10 +0100 Subject: [PATCH 01/45] configure.ac: use pkg-config to check freetype version the PKG_CHECK_MODULES macro allows to check for a version -- use it instead of homegrown TUXBOX_APPS_LIB_PKGCONFIG Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2ca807e34abc93e91f6ac0aae4c3326a21036fb9 Author: Stefan Seyfried Date: 2017-02-01 (Wed, 01 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 64e4093a3..be06c84e3 100644 --- a/configure.ac +++ b/configure.ac @@ -90,19 +90,10 @@ AM_CONDITIONAL(USE_TREMOR, test "$TREMOR" = "yes") # TUXBOX_APPS_LIB_PKGCONFIG(OPENSSL,openssl) TUXBOX_APPS_LIB_PKGCONFIG(CURL,libcurl) -TUXBOX_APPS_LIB_PKGCONFIG(FREETYPE,freetype2) -CPPFLAGS+=" $(freetype-config --cflags)" -AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) - AC_TRY_CPP([ - #include - #include FT_FREETYPE_H - #if FREETYPE_MAJOR < 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 5) - #error Freetype version too low. - #endif - ], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR([Need FreeType library version 2.5.0 or higher]) - ]) + +## For the check you must use the corresponding libtool number as version number, +## see freetype source code docs/VERSIONS.TXT +PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 16.2.10], echo "freetype2 >= 2.5.0 found", [echo "freetype2 >= 2.5.0 not found"; exit 1]) # fallback to curl-config (which is ugly for cross-compilation) if test -z "$CURL_LIBS" -a -z "$CURL_CFLAGS"; then @@ -111,6 +102,18 @@ fi # fallback to freetype-config (which is ugly for cross-compilation) if test -z "$FREETYPE_LIBS" -a -z "$FREETYPE_CFLAGS"; then TUXBOX_APPS_LIB_CONFIG(FREETYPE,freetype-config) + CPPFLAGS+="$FREETYPE_CFLAGS" + AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) + AC_TRY_CPP([ + #include + #include FT_FREETYPE_H + #if FREETYPE_MAJOR < 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR < 5) + #error Freetype version too low. + #endif + ], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([Need FreeType library version 2.5.0 or higher]) + ]) fi TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng) From cd2b0ed839c51000cdc897752ecd277930837d78 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sat, 4 Feb 2017 10:23:32 +0100 Subject: [PATCH 02/45] configure.ac: Fix freetype check Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/dccb6ba8f2919adea5d950ba85250d44b0f812a1 Author: Michael Liebmann Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index be06c84e3..3ebe71b4d 100644 --- a/configure.ac +++ b/configure.ac @@ -93,7 +93,14 @@ TUXBOX_APPS_LIB_PKGCONFIG(CURL,libcurl) ## For the check you must use the corresponding libtool number as version number, ## see freetype source code docs/VERSIONS.TXT -PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 16.2.10], echo "freetype2 >= 2.5.0 found", [echo "freetype2 >= 2.5.0 not found"; exit 1]) +PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 16.2.10], + [echo "freetype2 >= 2.5.0 found"], [ + ## If freetype is not found: + ## Activate this line if you want to search with freetype-config instead + [echo "freetype2 >= 2.5.0 not found, use alternative search method with freetype-config"] + ## Activate this line if you want to abort +# AC_MSG_ERROR([freetype2 >= 2.5.0 not found]) + ]) # fallback to curl-config (which is ugly for cross-compilation) if test -z "$CURL_LIBS" -a -z "$CURL_CFLAGS"; then @@ -102,7 +109,7 @@ fi # fallback to freetype-config (which is ugly for cross-compilation) if test -z "$FREETYPE_LIBS" -a -z "$FREETYPE_CFLAGS"; then TUXBOX_APPS_LIB_CONFIG(FREETYPE,freetype-config) - CPPFLAGS+="$FREETYPE_CFLAGS" + CPPFLAGS+=" $FREETYPE_CFLAGS" AC_MSG_CHECKING([whether FreeType version is 2.5.0 or higher]) AC_TRY_CPP([ #include From a6e0fdbccad9f4734398a1f43af8fadeb9db4e27 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Sun, 5 Feb 2017 17:31:24 +0100 Subject: [PATCH 03/45] movieplayer: Fix display filetime Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7d5cbea37d93749b87670ec98b75f78ec00decc8 Author: Michael Liebmann Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/infoclock.cpp | 27 +++++++++++++++------------ src/gui/movieplayer.cpp | 12 ++++++++++++ src/gui/timeosd.cpp | 1 + src/gui/timeosd.h | 5 ++++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 23aa8e290..54b485b09 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -126,19 +126,22 @@ bool CInfoClock::enableInfoClock(bool enable) } } - if (enable) { - if (FileTimeOSD->getRestore()) { - FileTimeOSD->setMode(FileTimeOSD->getTmpMode()); - FileTimeOSD->update(CMoviePlayerGui::getInstance().GetPosition(), - CMoviePlayerGui::getInstance().GetDuration()); + if (!FileTimeOSD->getMpTimeForced()) { + if (enable) { + if (FileTimeOSD->getRestore()) { + FileTimeOSD->setRestore(false); + FileTimeOSD->setMode(FileTimeOSD->getTmpMode()); + FileTimeOSD->update(CMoviePlayerGui::getInstance().GetPosition(), + CMoviePlayerGui::getInstance().GetDuration()); + } } - } - else { - if (FileTimeOSD->getMode() != CTimeOSD::MODE_HIDE) { - FileTimeOSD->setTmpMode(); - FileTimeOSD->setRestore(); - if (FileTimeOSD->getRestore()) - FileTimeOSD->kill(); + else { + if (FileTimeOSD->getMode() != CTimeOSD::MODE_HIDE) { + FileTimeOSD->setTmpMode(); + FileTimeOSD->setRestore(true); + if (FileTimeOSD->getRestore()) + FileTimeOSD->kill(); + } } } diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index eee9d3b19..dfb1b2d02 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -282,6 +282,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) FileTimeOSD->kill(); FileTimeOSD->setMode(CTimeOSD::MODE_HIDE); + FileTimeOSD->setMpTimeForced(false); time_forced = false; if (actionKey == "tsmoviebrowser") { @@ -1100,6 +1101,7 @@ bool CMoviePlayerGui::PlayFileStart(void) { menu_ret = menu_return::RETURN_REPAINT; + FileTimeOSD->setMpTimeForced(false); time_forced = false; position = 0, duration = 0; @@ -1201,6 +1203,7 @@ bool CMoviePlayerGui::PlayFileStart(void) FileTimeOSD->switchMode(position, duration); time_forced = true; } + FileTimeOSD->setMpTimeForced(true); } else if (timeshift == TSHIFT_MODE_OFF || !g_settings.timeshift_pause) { playback->SetSpeed(1); } @@ -1402,6 +1405,7 @@ void CMoviePlayerGui::PlayFileLoop(void) time_forced = false; FileTimeOSD->kill(); } + FileTimeOSD->setMpTimeForced(false); if (playstate > CMoviePlayerGui::PLAY) { playstate = CMoviePlayerGui::PLAY; speed = 1; @@ -1436,6 +1440,11 @@ void CMoviePlayerGui::PlayFileLoop(void) enableOsdElements(MUTE); } } else if (msg == (neutrino_msg_t) g_settings.mpkey_pause) { + if (time_forced) { + time_forced = false; + FileTimeOSD->kill(); + } + FileTimeOSD->setMpTimeForced(false); if (playstate == CMoviePlayerGui::PAUSE) { playstate = CMoviePlayerGui::PLAY; //CVFD::getInstance()->ShowIcon(VFD_ICON_PAUSE, false); @@ -1467,6 +1476,8 @@ void CMoviePlayerGui::PlayFileLoop(void) update_lcd = true; } else if (msg == (neutrino_msg_t) g_settings.mpkey_time) { FileTimeOSD->switchMode(position, duration); + time_forced = false; + FileTimeOSD->setMpTimeForced(false); } else if (msg == (neutrino_msg_t) g_settings.mbkey_cover) { makeScreenShot(false, true); } else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { @@ -1492,6 +1503,7 @@ void CMoviePlayerGui::PlayFileLoop(void) FileTimeOSD->switchMode(position, duration); time_forced = true; } + FileTimeOSD->setMpTimeForced(true); if (timeshift == TSHIFT_MODE_OFF) callInfoViewer(); } else if (msg == CRCInput::RC_1) { // Jump Backwards 1 minute diff --git a/src/gui/timeosd.cpp b/src/gui/timeosd.cpp index 597d2b2b2..32c025f0f 100644 --- a/src/gui/timeosd.cpp +++ b/src/gui/timeosd.cpp @@ -42,6 +42,7 @@ CTimeOSD::CTimeOSD():CComponentsFrmClock( 1, 1, NULL, "%H:%M:%S", NULL, false, 1 m_mode = MODE_HIDE; tmp_mode = MODE_HIDE; m_restore = false; + mp_time_forced = false; Init(); } diff --git a/src/gui/timeosd.h b/src/gui/timeosd.h index c79da7dec..fe2f678f3 100644 --- a/src/gui/timeosd.h +++ b/src/gui/timeosd.h @@ -44,6 +44,7 @@ class CTimeOSD : public CComponentsFrmClock CProgressBar timescale; mode m_mode, tmp_mode; bool m_restore; + bool mp_time_forced; time_t m_time_show; void initTimeString(); @@ -65,7 +66,9 @@ class CTimeOSD : public CComponentsFrmClock mode getTmpMode() { return tmp_mode; }; void setTmpMode () { tmp_mode = m_mode; }; bool getRestore() { return m_restore; }; - void setRestore() { m_restore = (m_mode != MODE_HIDE); }; + void setRestore(bool m) { m_restore = m; }; void setHeight(const int){}//NOTE: dummy member, height is strictly bound to settings + bool getMpTimeForced() { return mp_time_forced; }; + void setMpTimeForced(bool m) { mp_time_forced = m; }; }; #endif From b7ea9d23388a21dbc06042cfcd42e13588d03882 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 6 Feb 2017 21:09:42 +0100 Subject: [PATCH 04/45] hdd_menu: fix hd-idle/hdparm logic; fix small memleaks Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/041135986694282b442277f913af2825b917e739 Author: vanhofen Date: 2017-02-06 (Mon, 06 Feb 2017) Origin message was: ------------------ - hdd_menu: fix hd-idle/hdparm logic; fix small memleaks ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/hdd_menu.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 8205ddae9..0f6b1d058 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -1113,12 +1113,12 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) if (n < 0) return menu_return::RETURN_NONE; - const char hdidle[] = "/sbin/hd-idle"; - bool have_hdidle = !access(hdidle, X_OK); - if (g_settings.hdd_sleep > 0 && g_settings.hdd_sleep < 60) g_settings.hdd_sleep = 60; + const char hdidle[] = "/sbin/hd-idle"; + bool have_hdidle = !access(hdidle, X_OK); + if (have_hdidle) { system("kill $(pidof hd-idle)"); int sleep_seconds = g_settings.hdd_sleep; @@ -1134,12 +1134,22 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) } if (sleep_seconds) my_system(3, hdidle, "-i", to_string(sleep_seconds).c_str()); + + while (n--) + free(namelist[i]); + free(namelist); + return menu_return::RETURN_NONE; } const char hdparm[] = "/sbin/hdparm"; bool have_hdparm = !access(hdparm, X_OK); if (!have_hdparm) + { + while (n--) + free(namelist[i]); + free(namelist); return menu_return::RETURN_NONE; + } struct stat stat_buf; bool have_nonbb_hdparm = !::lstat(hdparm, &stat_buf) && !S_ISLNK(stat_buf.st_mode); @@ -1153,12 +1163,11 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) snprintf(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise); snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); - if (have_hdidle) - my_system(3, hdparm, M_opt, opt); - else if (have_nonbb_hdparm) + if (have_nonbb_hdparm) my_system(4, hdparm, M_opt, S_opt, opt); else // busybox hdparm doesn't support "-M" my_system(3, hdparm, S_opt, opt); + free(namelist[i]); } free(namelist); From 082f209da8da20b15f190e09386a9d11e25003df Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 6 Feb 2017 12:16:50 +0100 Subject: [PATCH 05/45] dont ask which box, if just one is present. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/22b0248d70af37ea41a29fe09d5c385093f49b05 Author: TangoCash Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/timerlist.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 06ef816d8..ab70eb431 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -703,16 +703,19 @@ void CTimerList::updateEvents(void) void CTimerList::RemoteBoxSelect() { int select = 0; - CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - m->addItem(new CMenuForwarder(it->rbname, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + if (g_settings.timer_remotebox_ip.size() > 1) { + CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - m->enableSaveScreen(true); - m->exec(NULL, ""); + for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) + m->addItem(new CMenuForwarder(it->rbname, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); - delete selector; + m->enableSaveScreen(true); + m->exec(NULL, ""); + + delete selector; + } std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); std::advance(it,select); From 1f0a8b1061c7f4eb44bd0f6c71ff1ef068f9c79a Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 6 Feb 2017 14:36:22 +0100 Subject: [PATCH 06/45] fix pre and post times, set menuentry for unavailable boxes inactiv Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/fb5ab7f9ecd74c28a4c658edd041af37a7c31a6e Author: TangoCash Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/timerlist.cpp | 25 ++++++++++++++----------- src/system/settings.h | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index ab70eb431..929ab4bbe 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -439,14 +439,16 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "send_remotetimer") == 0) && RemoteBoxChanExists(timerlist[selected].channel_id)) { + int pre,post; + Timer->getRecordingSafety(pre,post); CHTTPTool httpTool; std::string r_url; r_url = "http://"; r_url += RemoteBoxConnectUrl(timerlist[selected].remotebox_name); r_url += "/control/timer?action=new"; - r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + timerlist[selected].rem_pre); - r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - timerlist[selected].rem_post); - r_url += "&announce=" + to_string((int)timerlist[selected].announceTime); + r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + pre); + r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - post); + r_url += "&announce=" + to_string((int)timerlist[selected].announceTime + pre); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&aj=on"; r_url += "&rs=on"; @@ -458,13 +460,11 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "fetch_remotetimer") == 0) && LocalBoxChanExists(timerlist[selected].channel_id)) { - int pre,post; - Timer->getRecordingSafety(pre,post); std::string remotebox_name = timerlist[selected].remotebox_name; std::string eventID = to_string((int)timerlist[selected].eventID); - int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",false); if (res == -1) @@ -473,8 +473,8 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) if (forceAdd) { - res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",true); } } @@ -709,7 +709,7 @@ void CTimerList::RemoteBoxSelect() CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - m->addItem(new CMenuForwarder(it->rbname, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + m->addItem(new CMenuForwarder(it->rbname, it->online, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); m->enableSaveScreen(true); m->exec(NULL, ""); @@ -804,7 +804,10 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) { printf("Failed to parse JSON\n"); printf("%s\n", reader.getFormattedErrorMessages().c_str()); - } + it->online = false; + } else + it->online = true; + Json::Value delays = root["data"]["timer"][0]; rem_pre = atoi(delays["config"].get("pre_delay","0").asString()); diff --git a/src/system/settings.h b/src/system/settings.h index 8d0e53e71..2d9d302d4 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -160,6 +160,7 @@ struct timer_remotebox_item std::string pass; std::string rbname; std::string rbaddress; + bool online; }; struct SNeutrinoSettings From 81014a595e8d0d41deed2358f0156758cbf9fe96 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 6 Feb 2017 21:53:51 +0100 Subject: [PATCH 07/45] flashtool: allow type U (update-package) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d925655c3b3a5a0529d8c5db0ef1e42610b7ede5 Author: vanhofen Date: 2017-02-06 (Mon, 06 Feb 2017) Origin message was: ------------------ - flashtool: allow type U (update-package) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/flashtool.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 9b21a3ba8..20447b361 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -517,6 +517,8 @@ const char *CFlashVersionInfo::getReleaseCycle(void) const const char *CFlashVersionInfo::getType(void) const { + // TODO: localize it + switch (snapshot) { case '0': @@ -531,6 +533,8 @@ const char *CFlashVersionInfo::getType(void) const return "Settings"; case 'A': return "Addon"; + case 'U': + return "Update"; case 'T': return "Text"; default: From e18792ffbb1c7117eee14d8cfaf74281f229dbbf Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 6 Feb 2017 23:21:01 +0100 Subject: [PATCH 08/45] hdd_menu: fix c/p error Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/aed22b3788681fd99491e32d9b6595455073f7f0 Author: vanhofen Date: 2017-02-06 (Mon, 06 Feb 2017) Origin message was: ------------------ - hdd_menu: fix c/p error ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/hdd_menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 0f6b1d058..d1d7b6233 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -1136,7 +1136,7 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) my_system(3, hdidle, "-i", to_string(sleep_seconds).c_str()); while (n--) - free(namelist[i]); + free(namelist[n]); free(namelist); return menu_return::RETURN_NONE; } @@ -1146,7 +1146,7 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) if (!have_hdparm) { while (n--) - free(namelist[i]); + free(namelist[n]); free(namelist); return menu_return::RETURN_NONE; } From 11d4052f035c94f8e15ff6588a32ae7e64fbd6b5 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Feb 2017 21:25:33 +0100 Subject: [PATCH 09/45] signals: reduce multiple includes for sigc++/bind.h Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e4d0abc7dc37e88e5295740d2d25cdeeded36fc3 Author: Thilo Graf Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_clock.cpp | 2 +- src/gui/components/cc_frm_ext_text.cpp | 1 - src/gui/components/cc_frm_header.cpp | 1 - src/gui/components/cc_item.h | 2 ++ src/gui/components/cc_item_text.cpp | 1 + src/gui/components/cc_signals.h | 1 + 6 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index fcce3647e..c52001eb7 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -30,7 +30,7 @@ #include "cc_frm_clock.h" #include -#include + #include #include #include diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 420ea2775..707d43627 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -29,7 +29,6 @@ #include #include "cc_frm_ext_text.h" -#include #define DEF_HEIGHT 27 #define DEF_LABEL_WIDTH_PERCENT 30 diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index 8a56e24ad..cda9c5628 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -31,7 +31,6 @@ #include "cc_frm_header.h" #include -#include using namespace std; diff --git a/src/gui/components/cc_item.h b/src/gui/components/cc_item.h index dad19d96e..4f5f42da5 100644 --- a/src/gui/components/cc_item.h +++ b/src/gui/components/cc_item.h @@ -27,10 +27,12 @@ #include "cc_types.h" #include "cc_base.h" #include "cc_draw.h" +#include "cc_signals.h" #include #include #include + class CComponentsItem : public CComponents { protected: diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 67ee50401..c31e34f13 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -35,6 +35,7 @@ #include #include #include + using namespace std; //sub class CComponentsText from CComponentsItem diff --git a/src/gui/components/cc_signals.h b/src/gui/components/cc_signals.h index c3c60727e..5c3fdaca1 100644 --- a/src/gui/components/cc_signals.h +++ b/src/gui/components/cc_signals.h @@ -88,6 +88,7 @@ class CYourClass : sigc::trackable //<- not forget, requierd by destructor! #define __CC_SIGNALS_H__ #include +#include #include class CComponentsSignals : public sigc::trackable From 112973c3ae7977e40db74dee1ec3ae96ef695112 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Feb 2017 19:32:25 +0100 Subject: [PATCH 10/45] CComponentsForm: move slots into base classes Usable for all form classes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/06fa3f248885ac76994864c135bfb8d5605dc609 Author: Thilo Graf Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/components/cc_frm.cpp | 17 ----------------- src/gui/components/cc_frm.h | 10 +++------- src/gui/components/cc_frm_clock.cpp | 8 -------- src/gui/components/cc_frm_ext_text.cpp | 8 -------- src/gui/components/cc_frm_header.cpp | 4 ---- src/gui/components/cc_item_text.cpp | 6 ++++++ src/gui/components/cc_item_text.h | 1 - 7 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index 19843a5b9..d124f3395 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -680,20 +680,3 @@ bool CComponentsForm::enableColBodyGradient(const int& enable_mode, const fb_pix } return false; } - -void CComponentsForm::forceItemsPaint(bool force) -{ - for (size_t i = 0; i < v_cc_items.size(); i++){ - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] found item type = [%d] \033[0m\n", __func__, __LINE__, v_cc_items[i]->getItemType()); - if (v_cc_items[i]->getItemType() == CC_ITEMTYPE_TEXT){ - CComponentsText* text = static_cast (v_cc_items[i]); - text->forceTextPaint(force); - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] force repaint of item type CC_ITEMTYPE_TEXT [%u] content [%s]\033[0m\n", __func__, __LINE__, i, text->getText().c_str()); - } - if (v_cc_items[i]->getItemType() == CC_ITEMTYPE_LABEL){ - CComponentsLabel* label = static_cast (v_cc_items[i]); - label ->forceTextPaint(force); - dprintf(DEBUG_DEBUG, "\033[33m[CComponentsForm] [%s - %d] force repaint of item type CC_ITEMTYPE_LABEL [%u] content [%s]\033[0m\n", __func__, __LINE__, i, label->getText().c_str()); - } - } -} diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index b9cab7934..3561e495a 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -65,13 +65,6 @@ class CComponentsForm : public CComponentsItem const fb_pixel_t& color_body, const fb_pixel_t& color_shadow); - ///force repaint of all possible text items - void forceItemsPaint(bool force); - ///slot for background paint event, reserved for forceItemsPaint() - sigc::slot0 sl_items_repaint; - ///slot for repaint event, reserved for actions before repaint if paint() already was done. - sigc::slot0 sl_form_repaint; - public: CComponentsForm( const int x_pos = 0, const int y_pos = 0, const int w = 800, const int h = 600, CComponentsForm *parent = NULL, @@ -223,6 +216,9 @@ class CComponentsForm : public CComponentsItem virtual bool clearPaintCache(); ///cleanup old gradient buffers include from sub items, returns true if any gradient buffer data was removed virtual bool clearFbGradientData(); + + ///slot for repaint event, reserved for actions before repaint if paint() already was done. + sigc::slot0 sl_form_repaint; }; #endif diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index c52001eb7..08a498eb1 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -100,9 +100,6 @@ CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, //init slot for running clock cl_sl_show = sigc::mem_fun0(*this, &CComponentsFrmClock::ShowTime); - //init slot to ensure paint segments after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsFrmClock::forceItemsPaint), true); - //run clock already if required if (activ) startClock(); @@ -300,11 +297,6 @@ void CComponentsFrmClock::initCCLockItems() x_lbl += v_cc_items[i-1]->getWidth(); v_cc_items[i]->setPos(x_lbl, y_lbl); } - - if(!OnAfterPaintBg.empty()) - OnAfterPaintBg.clear(); - //init slot to handle repaint of segments if background was repainted - OnAfterPaintBg.connect(sl_items_repaint); } diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index 707d43627..9cd27aa23 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -113,9 +113,6 @@ void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_p } ccx_label_align = ccx_text_align = CTextBox::NO_AUTO_LINEBREAK; - //init slot to ensure paint text items after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsExtTextForm::forceItemsPaint), true); - initParent(parent); } @@ -221,11 +218,6 @@ void CComponentsExtTextForm::initCCTextItems() { initLabel(); initText(); - - if(!OnAfterPaintBg.empty()) - OnAfterPaintBg.clear(); - //init slot to handle repaint of text if background was repainted - OnAfterPaintBg.connect(sl_items_repaint); } void CComponentsExtTextForm::setLabelWidthPercent(const uint8_t& percent_val) diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index cda9c5628..838f4f35c 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -135,10 +135,6 @@ void CComponentsHeader::initVarHeader( const int& x_pos, const int& y_pos, const cch_cl_sec_format = cch_cl_format; cch_cl_enable_run = false; - //init slot to ensure paint items after painted background - sl_items_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::forceItemsPaint), true); - OnAfterPaintBg.connect(sl_items_repaint); - //init slot before re paint of header, paint() is already done sl_form_repaint = sigc::bind(sigc::mem_fun(*this, &CComponentsHeader::kill), col_body, -1, CC_FBDATA_TYPES, false); OnBeforeRePaint.connect(sl_form_repaint); diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index c31e34f13..8a3897d2d 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -274,6 +274,12 @@ bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int void CComponentsText::paintText(bool do_save_bg) { + if (cc_parent){ + if(!cc_parent->OnAfterPaintBg.empty()) + cc_parent->OnAfterPaintBg.clear(); + //init slot to handle repaint of text if background was repainted + cc_parent->OnAfterPaintBg.connect(sigc::bind(sigc::mem_fun(*this, &CComponentsText::forceTextPaint), true)); + } initCCText(); if (!is_painted) paintInit(do_save_bg); diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 1de07d08c..5e5d53d48 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -196,7 +196,6 @@ class CComponentsText : public CCTextScreen, public CComponentsItem ///force paint of text even if text was changed or not virtual void forceTextPaint(bool force_text_paint = true){ct_force_text_paint = force_text_paint;}; - ///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties virtual CTextBox* getCTextBoxObject() { return ct_textbox; }; From b66ccd6251b4fcedbc318fbbfe71768e9e7d68de Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Feb 2017 21:20:34 +0100 Subject: [PATCH 11/45] Helpbox: fix missing text after page repaint Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9f7605127a83bcab4e41b7c23d101f544790a6ef Author: Thilo Graf Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/helpbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index 4169b5d13..bb5c04829 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -98,9 +98,9 @@ void Helpbox::addLine(const std::string& icon, const std::string& text, const in if (!text.empty()){ int x_text = w_picon + (picon ? OFFSET_INNER_MID : 0); CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, 0, text, text_mode, font); + txt->doPaintBg(false); #if 0 //"contrast agent", if you want to see where the text items are drawn. txt->setColorBody(COL_RED); - txt->doPaintBg(true); #endif int lines = txt->getCTextBoxObject()->getLines(); txt_height = std::max(lines*font->getHeight(), h_line); From f453a2380481ada0fad4d5ebce8c395a12934d5c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Feb 2017 15:04:51 +0100 Subject: [PATCH 12/45] CTextBox: compare condition for text render more precisely Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/95de68c5a5725ac919c40b2092413d2b0fc62d6b Author: Thilo Graf Date: 2017-02-07 (Tue, 07 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/textbox.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 54968c03c..bc2fcac5a 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -657,6 +657,7 @@ void CTextBox::refreshText(void) if (allow_paint_bg){ //TRACE("[CTextBox] %s restore bg %d\r\n", __FUNCTION__, __LINE__); frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf); + m_bg_painted = true; } } } @@ -718,7 +719,7 @@ void CTextBox::refreshText(void) frameBuffer->paintBoxRel(tx, ty-th, tw, th, COL_RED, m_nBgRadius, m_nBgRadiusType); #endif //TRACE("[CTextBox] %s Line %d m_cFrame.iX %d m_cFrameTextRel.iX %d\r\n", __FUNCTION__, __LINE__, m_cFrame.iX, m_cFrameTextRel.iX); - if (m_bg_painted || m_old_cText != m_cText) + if (m_bg_painted || (m_old_cText != m_cText)) m_pcFontText->RenderString(tx, ty, tw, m_cLineArray[i].c_str(), m_textColor, 0, m_renderMode | ((m_utf8_encoded) ? Font::IS_UTF8 : 0)); y += m_nFontTextHeight; } From b2eb4b1889c3a15284336e1fa1ce2c9e2caed667 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 7 Feb 2017 17:06:11 +0100 Subject: [PATCH 13/45] CScreenSaver: ensure full cleanup of infoclock after stopped screensaver This provokes re init of info clock. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/622e7a4dd259ccf1c2b963f354091b59415abae7 Author: Thilo Graf Date: 2017-02-07 (Tue, 07 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/screensaver.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 7c3b50b5a..7532803a0 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -143,10 +143,12 @@ void CScreenSaver::Stop() m_frameBuffer->paintBackground(); //clear entire screen CAudioMute::getInstance()->enableMuteIcon(status_mute); - if (!OnAfterStop.empty()) + if (!OnAfterStop.empty()){ OnAfterStop(); - else + }else{ + CInfoClock::getInstance()->ClearDisplay(); //provokes reinit CInfoClock::getInstance()->enableInfoClock(); + } } void* CScreenSaver::ScreenSaverPrg(void* arg) From 70cbcb6bb5a6cd9150744ecf7d9d42050bbc3402 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:05:07 +0100 Subject: [PATCH 14/45] replace framebuffer.h include with forward declaration instead of including framebuffer.h almost everywhere, replace it with class CFrameBuffer forward declarations and/or generic system includes. Add a hack to define fb_pixel_t to config.h (one reason for framebuffer.h includes was the fb_pixel_t define) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e490f84ea87447941e6814566e8d48bdf8b0867b Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 3 +++ src/driver/colorgradient.h | 3 ++- src/driver/fade.cpp | 1 + src/driver/fade.h | 3 ++- src/driver/fb_window.h | 2 +- src/driver/fontrenderer.cpp | 1 + src/driver/fontrenderer.h | 5 ++--- src/driver/moviecut.h | 2 +- src/driver/pictureviewer/bmp.cpp | 1 + src/driver/pictureviewer/crw.cpp | 1 + src/driver/pictureviewer/gif.cpp | 1 + src/driver/pictureviewer/pictureviewer.h | 4 ++-- src/driver/pictureviewer/png.cpp | 1 + src/driver/radiotext.h | 1 - src/driver/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 86f609bc1717335f5dffb1237b9eda049f88a767 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 13:37:53 +0100 Subject: [PATCH 15/45] replace fontrenderer.h include with forward declaration in order to flatten the build dependency tree further, include fontrenderer.h directly where needed, in header files a forward declaration is enough Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2303d94300444c74a3789cab19660aa30edff71c Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_window.h | 5 ++--- src/driver/radiotext.h | 2 -- src/gui/bookmarkmanager.cpp | 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 2395351f782e1d4383e6deafc419d431be54b81b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 14:49:41 +0100 Subject: [PATCH 16/45] start modularizing framebuffer acceleration architecture This is just copied framebuffer.{h,cpp} => fb_generic.{h,cpp} The idea is to implement CFrameBuffer as generic framebuffer class that does work on almost every hardware without acceleration and / or hardware dependencies. CFbAccel will be a derived class (and different on many architectures) which implements the accelerated functions. This does not yet compile, verbatim copies to track development history. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5c2ee5e137c3ad3e703562057041a83477e290be Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 2200 +++++++++++++++++++++++++++++++++++++ src/driver/fb_generic.h | 332 ++++++ src/driver/framebuffer.h | 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 f3ef901b2c0e95deb5123afecd56157138f046a0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:02:20 +0100 Subject: [PATCH 17/45] fb_generic: add stuff needed for compilation Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3c381cd53bf6dd67781559a4e48df7c6bbd1cc55 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 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 b98cfca434008dc9d528d5274b39faacc4a06c8e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 15:22:22 +0100 Subject: [PATCH 18/45] fb_generic: remove all hardware specific code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3f6308045431fb92e13ca59dcfb86c2c9ff46a94 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 367 +------------------------------------- src/driver/fb_generic.h | 8 - 2 files changed, 3 insertions(+), 372 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 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 36b131ea3063a91c11bd623f13b7ffeffaeae051 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 18:04:15 +0100 Subject: [PATCH 19/45] fb_generic: add pointer for double-buffered fb Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9ba84a629a798948bff5f6813dbeb121c96fbb59 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 6 +++--- src/driver/fb_generic.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 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 17697d3c7007ad7075ed1034602d8bb9d037ca1d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:50:05 +0100 Subject: [PATCH 20/45] move gui/color.h includes from headers to cpp files Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/648c00f26a2eb33b7b985ba7c12320f4b324c40c Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/epgview.h | 1 - src/gui/eventlist.h | 1 - src/gui/filebrowser.h | 1 - src/gui/widget/listframe.cpp | 1 + src/gui/widget/shellwindow.cpp | 1 + src/gui/widget/textbox.cpp | 1 + src/gui/widget/textbox.h | 1 - 7 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/epgview.h b/src/gui/epgview.h index a4116343e..4fe60f9de 100644 --- a/src/gui/epgview.h +++ b/src/gui/epgview.h @@ -36,7 +36,6 @@ #include #include -#include #include #include "widget/menue.h" diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index bbbbb4828..c0c15af52 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -34,7 +34,6 @@ #include #include -#include "color.h" #include "infoviewer.h" #include "widget/menue.h" diff --git a/src/gui/filebrowser.h b/src/gui/filebrowser.h index cb437c7da..3d458125d 100644 --- a/src/gui/filebrowser.h +++ b/src/gui/filebrowser.h @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 66f14dc6b..3d17d46fb 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -52,6 +52,7 @@ #include #include +#include #include "listframe.h" #include #include diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 0404dc45c..480b6df4a 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -30,6 +30,7 @@ #endif +#include #include "shellwindow.h" #include diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 002a4add9..31165abba 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -59,6 +59,7 @@ #include #include +#include #include "textbox.h" #include #include diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index e52dcfb48..0c182eaa8 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -60,7 +60,6 @@ #include #include -#include #include #define TRACE printf #define TRACE_1 printf From 182635f6f5058d7176d801582aadcbb1d69dffb1 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 19:53:29 +0100 Subject: [PATCH 21/45] fb_generic: add fb_name member to identify fb implementation Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a58193dd56d8fe9c7ee0a14ac07b86f75772cfa7 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 4 ++-- src/driver/fb_generic.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 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 bd9ee5bc4510675ad20cb1ca593cc65fe02a182a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 20:45:13 +0100 Subject: [PATCH 22/45] fb_generic: nicer debug output, remove dead code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/beb2a67123fb6b840bc980bf64946e399d839c0e Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 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 6635b24aa0cbcca24eae8a4868fad78d3dcf1359 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 21:35:52 +0100 Subject: [PATCH 23/45] framebuffer: add accelerator for STi framebuffer also add a generic helper class for other accelerated framebuffer implementations Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9fe5dfbe50b9a75feeefa4bef1adc3a8ce166ae8 Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- 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 fa333ddbb05af7186821bed70dfc581503b09b48 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 22:50:23 +0100 Subject: [PATCH 24/45] fb_generic: fix blit2FB call Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ecb6531fd73fcac387cc22445563ec8f4b209dfb Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 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 7d945c2d59ac1c14b7c1cfec4e2dcc6b8a9ec367 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 5 Feb 2017 23:03:22 +0100 Subject: [PATCH 25/45] fb_accel: add accelerated framebuffer for Nevis GXA chips Signed-off-by: M. Liebmann Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0e63e5df3d2bd6580425d93326d5f5367851953b Author: Stefan Seyfried Date: 2017-02-05 (Sun, 05 Feb 2017) ------------------ This commit was generated by Migit --- 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 6aef72348435a46d329d4932262c72370c667475 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 7 Feb 2017 17:18:01 +0100 Subject: [PATCH 26/45] fb_accel: add accelerated framebuffer for Apollo graphic chips Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6ff9ff695b11e7bb0fe9de0d5c6d1ac8cce7eb09 Author: Michael Liebmann Date: 2017-02-07 (Tue, 07 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- 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 a553cc417a44771a8a2d0766b0220cd201158020 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:15:37 +0100 Subject: [PATCH 27/45] fb_accel: add backend for GL framebuffer Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2498ebb314f4d2b98c8eb7989798d7f2d4da422f Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 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 7772bf165e642559a1a0db85054a0ff1e0e1915f Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 11:35:05 +0100 Subject: [PATCH 28/45] framebuffer/configure: remove unused --restore-prev-mode this is unused, untested and most likely not working at all Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c695ae8ea8ef427336d84e02618c9211cda71f56 Author: Stefan Seyfried Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ This commit was generated by Migit --- configure.ac | 4 ---- src/driver/framebuffer.cpp | 5 ----- 2 files changed, 9 deletions(-) diff --git a/configure.ac b/configure.ac index 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 5e76b3eef8a077ba7f0c419c177079d713964431 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 4 Feb 2017 12:12:27 +0100 Subject: [PATCH 29/45] flashtool: make CFlashVersionInfo robust against invalid input Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4134af3d1d7926af0e557986e1fd95c418ce3435 Author: Stefan Seyfried Date: 2017-02-04 (Sat, 04 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/flashtool.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 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 c6eae66341f7762f06eeae36f518cc438fa215e7 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 00:52:16 +0100 Subject: [PATCH 30/45] reduce impact of driver/pictureviewer.h header file before, more than 175 files depended on it, now it's about 35 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/47b1a8b64234cdf7ad4da97acae477de61ba6528 Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/components/cc_item_picture.cpp | 1 + src/gui/components/cc_item_picture.h | 1 - src/gui/moviebrowser/mb.h | 1 - src/gui/screensaver.cpp | 3 ++- src/gui/screensaver.h | 1 + src/gui/upnpbrowser.cpp | 1 + src/gui/upnpbrowser.h | 1 - 7 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 1abad278a..a303038bc 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -34,6 +34,7 @@ #include #include #include +#include extern CPictureViewer * g_PicViewer; diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index 435065fc9..0781b446e 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -34,7 +34,6 @@ #include "cc_base.h" #include "cc_item.h" #include -#include #define NO_SCALE false #define SCALE true diff --git a/src/gui/moviebrowser/mb.h b/src/gui/moviebrowser/mb.h index 176c34f7f..9dee3dbee 100644 --- a/src/gui/moviebrowser/mb.h +++ b/src/gui/moviebrowser/mb.h @@ -56,7 +56,6 @@ #include #include #include -#include #include #define MAX_NUMBER_OF_BOOKMARK_ITEMS MI_MOVIE_BOOK_USER_MAX // we just use the same size as used in Movie info (MAX_NUMBER_OF_BOOKMARK_ITEMS is used for the number of menu items) diff --git a/src/gui/screensaver.cpp b/src/gui/screensaver.cpp index 7c3b50b5a..d4558edd7 100644 --- a/src/gui/screensaver.cpp +++ b/src/gui/screensaver.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include extern cVideo * videoDecoder; @@ -315,4 +316,4 @@ bool CScreenSaver::IsRun() if(thrScreenSaver) return true; return false; -} \ No newline at end of file +} diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index 4f47e3a69..0a9605561 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -30,6 +30,7 @@ #include class CFrameBuffer; +class CPictureViewer; class CScreenSaver : public sigc::trackable { private: diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 92b90d749..dfa79f6c9 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/upnpbrowser.h b/src/gui/upnpbrowser.h index 409b785a8..105ec5fa1 100644 --- a/src/gui/upnpbrowser.h +++ b/src/gui/upnpbrowser.h @@ -24,7 +24,6 @@ #define __upnpplayergui__ #include -#include #include #include #include From b3fcfc287aca5800a27f3f4456e812dbac514f69 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 6 Feb 2017 01:26:43 +0100 Subject: [PATCH 31/45] reduce impact of zapit/frontend_c.h header down from ~217 files to ~57... Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/98b2461da7a2c1519bd3a3b87d8f3450ed619046 Author: Stefan Seyfried Date: 2017-02-06 (Mon, 06 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/record.h | 1 + src/gui/components/cc_frm_signalbars.cpp | 1 + src/gui/components/cc_frm_signalbars.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/driver/record.h b/src/driver/record.h index 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 68a1c5e30ed4bee0203c76e1e9bd6799561053e8 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 06:02:42 +0100 Subject: [PATCH 32/45] neutrino: Replace USE_NEVIS_GXA with hardware-specific macros - Existing USE_NEVIS_GXA definitions in the build system (neutrino configure) can be removed. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/02d85f2ff2657011ecc679aa4839f17e6d8bb01f Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) Origin message was: ------------------ neutrino: Replace USE_NEVIS_GXA with hardware-specific macros - Existing USE_NEVIS_GXA definitions in the build system (neutrino configure) can be removed. ------------------ This commit was generated by Migit --- 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 f1783ad5fa3cbc598d75d61b806eb24dcbb52cf0 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 09:30:22 +0100 Subject: [PATCH 33/45] CFbAccelCSNevis: Add paintHLineRel() & paintVLineRel() functions - Remove unused debug output Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/10e82c0ece74be444b047957204fd7321d55a771 Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ This commit was generated by Migit --- 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 e33fdc1708f74aedd52605ddab982b9a1b67b110 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 09:30:25 +0100 Subject: [PATCH 34/45] CFbAccelCSApollo: Add paintHLineRel() & paintVLineRel() functions - Remove unused debug output Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/35b48372f897f44c309e76bea34439876e0d0065 Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ This commit was generated by Migit --- 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 8872419ed107d80ca7b428b99811c55ca3418f0d Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 8 Feb 2017 09:45:53 +0100 Subject: [PATCH 35/45] fix build; try to port our framebuffer changes (need fixes!) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/fa727d1bff994a932171cae9263bce2453c73413 Author: vanhofen Date: 2017-02-08 (Wed, 08 Feb 2017) Origin message was: ------------------ - fix build; try to port our framebuffer changes (need fixes!) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_accel.h | 4 ++-- src/driver/fb_accel_cs_apollo.cpp | 4 ++-- src/driver/fb_accel_cs_nevis.cpp | 4 ++-- src/driver/fb_accel_glfb.cpp | 4 ++-- src/driver/fb_generic.cpp | 18 ++++++++++++++++-- src/driver/fb_generic.h | 5 ++++- src/driver/pictureviewer/pictureviewer.cpp | 11 ++++++++--- src/driver/pictureviewer/pictureviewer.h | 2 +- src/gui/imdb.h | 1 + 9 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 92f865f32..b98d2344c 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -98,7 +98,7 @@ class CFbAccelCSNevis 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 blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); void waitForIdle(const char *func = NULL); fb_pixel_t * getBackBufferPointer() const; @@ -121,7 +121,7 @@ class CFbAccelCSApollo 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 blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); void setBlendMode(uint8_t); void setBlendLevel(int); diff --git a/src/driver/fb_accel_cs_apollo.cpp b/src/driver/fb_accel_cs_apollo.cpp index 73dc19d7c..4861308e4 100644 --- a/src/driver/fb_accel_cs_apollo.cpp +++ b/src/driver/fb_accel_cs_apollo.cpp @@ -152,7 +152,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 CFbAccelCSApollo::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; xc = (width > xRes) ? xRes : width; @@ -171,7 +171,7 @@ void CFbAccelCSApollo::blit2FB(void *fbbuff, uint32_t width, uint32_t height, ui //printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); return; } - CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI //printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); } diff --git a/src/driver/fb_accel_cs_nevis.cpp b/src/driver/fb_accel_cs_nevis.cpp index d13819675..246529020 100644 --- a/src/driver/fb_accel_cs_nevis.cpp +++ b/src/driver/fb_accel_cs_nevis.cpp @@ -284,7 +284,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 CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; xc = (width > xRes) ? xRes : width; @@ -308,7 +308,7 @@ void CFbAccelCSNevis::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uin //printf(">>>>>[%s:%d] Use HW accel\n", __func__, __LINE__); return; } - CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI //printf(">>>>>[%s:%d] NO HW accel\n", __func__, __LINE__); } diff --git a/src/driver/fb_accel_glfb.cpp b/src/driver/fb_accel_glfb.cpp index f6784c48f..905e83245 100644 --- a/src/driver/fb_accel_glfb.cpp +++ b/src/driver/fb_accel_glfb.cpp @@ -75,9 +75,9 @@ CFbAccelGLFB::~CFbAccelGLFB() } } -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) +void CFbAccelGLFB::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp, uint32_t unscaled_w, uint32_t unscaled_h) //NI { - CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp); + CFrameBuffer::blit2FB(fbbuff, width, height, xoff, yoff, xp, yp, transp, unscaled_w, unscaled_h); //NI blit(); } diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 90ac9ad5f..31fbdca31 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -253,7 +253,7 @@ nolfb: } -CFrameBuffer::~CFrameBuffer() +void CFrameBuffer::clearIconCache() { std::map::iterator it; @@ -262,6 +262,11 @@ CFrameBuffer::~CFrameBuffer() cs_free_uncached(it->second.data); } icon_cache.clear(); +} + +CFrameBuffer::~CFrameBuffer() +{ + clearIconCache(); //NI if (background) { delete[] background; @@ -1677,13 +1682,22 @@ void * CFrameBuffer::convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, uns 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*/) +void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool /*transp*/, uint32_t unscaled_w, uint32_t unscaled_h) //NI { int xc, yc; xc = (width > xRes) ? xRes : width; yc = (height > yRes) ? yRes : height; +//FIXME +#if 0 + //NI + if(unscaled_w != 0 && (int)unscaled_w < xc) + xc = unscaled_w; + if(unscaled_h != 0 && (int)unscaled_h < yc) + yc = unscaled_h; +#endif + fb_pixel_t* data = (fb_pixel_t *) fbbuff; uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + xoff * sizeof(fb_pixel_t) + stride * yoff; diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index a7e24bf85..892e8b2fd 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -266,11 +266,14 @@ class CFrameBuffer : public sigc::trackable void* convertRGB2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y, int transp = 0xFF); void* convertRGBA2FB(unsigned char *rgbbuff, unsigned long x, unsigned long y); void displayRGB(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, bool clearfb = true, int transp = 0xFF); - virtual void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false); + virtual void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp = 0, uint32_t yp = 0, bool transp = false, uint32_t unscaled_w = 0, uint32_t unscaled_h = 0); //NI void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); virtual void mark(int x, int y, int dx, int dy); + //NI + void clearIconCache(); + enum { TM_EMPTY = 0, diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 08e5980b8..eeb4cbfb6 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -644,8 +644,13 @@ bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy, //NI bool CPictureViewer::DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp) { - int fb_w = width; - int fb_h = height; + if(width < 1 || height < 1){ + dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: width %i height %i \n", __func__, __LINE__, width, height); + return false; + } + + int unscaled_w = width; + int unscaled_h = height; CFrameBuffer* frameBuffer = CFrameBuffer::getInstance(); if (transp > CFrameBuffer::TM_EMPTY) @@ -658,7 +663,7 @@ bool CPictureViewer::DisplayImage_unscaled(const std::string & name, int posx, i frameBuffer->SetTransparentDefault(); if(data) { - frameBuffer->blit2FB_unscaled(data, width, height, posx, posy, fb_w, fb_h); + frameBuffer->blit2FB(data, width, height, posx, posy, 0, 0, transp, unscaled_w, unscaled_h); cs_free_uncached(data); return true; } diff --git a/src/driver/pictureviewer/pictureviewer.h b/src/driver/pictureviewer/pictureviewer.h index 92e0cb50f..100441b6f 100644 --- a/src/driver/pictureviewer/pictureviewer.h +++ b/src/driver/pictureviewer/pictureviewer.h @@ -76,7 +76,7 @@ class CPictureViewer void getSupportedImageFormats(std::vector& erw); //NI - bool DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); + bool DisplayImage_unscaled(const std::string & name, int posx, int posy, int width, int height, int transp=0 /*CFrameBuffer::TM_EMPTY*/); private: CFormathandler *fh_root; diff --git a/src/gui/imdb.h b/src/gui/imdb.h index 74296cd30..ffc911ebd 100644 --- a/src/gui/imdb.h +++ b/src/gui/imdb.h @@ -28,6 +28,7 @@ #include #include +#include class CIMDB { From bf4f72f3cc976c59e0a8e5506333ba852a7b2993 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 12:17:09 +0100 Subject: [PATCH 36/45] fb_accel: Rename CFbAccelCSNevis class => CFbAccelCSHD1 Rename fb_accel_cs_nevis.cpp => fb_accel_cs_hd1.cpp Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/58bd8a4a634117bc5577b4127aea8f1694754de4 Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) Origin message was: ------------------ fb_accel: Rename CFbAccelCSNevis class => CFbAccelCSHD1 Rename fb_accel_cs_nevis.cpp => fb_accel_cs_hd1.cpp ------------------ This commit was generated by Migit --- 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 824f78dd3ded0070aa923b51dbe0fd2092ff32cc Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 12:33:45 +0100 Subject: [PATCH 37/45] fb_accel: Rename CFbAccelCSApollo class => CFbAccelCSHD2 Rename fb_accel_cs_apollo.cpp => fb_accel_cs_hd2.cpp Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a4afe1e8e00115cb8b84a772cd6f8fd6cc9c620e Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) Origin message was: ------------------ fb_accel: Rename CFbAccelCSApollo class => CFbAccelCSHD2 Rename fb_accel_cs_apollo.cpp => fb_accel_cs_hd2.cpp ------------------ This commit was generated by Migit --- 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 8cd23f3f8926e0434056291d10cffd2d057746e3 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 8 Feb 2017 13:30:33 +0100 Subject: [PATCH 38/45] fb_accel: Some renaming nevis => hd1 & apollo => hd2 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f94afc1593d0a500694cebf71ca520967c7559b3 Author: Michael Liebmann Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_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 c255a465f356fa92dc0296de36131ec99516e12c Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Feb 2017 18:47:17 +0100 Subject: [PATCH 39/45] fb_accel_cs_hdx: remove dub includes, add includes into common header file Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8fe7504007380551ae421b52b14603877da8aa85 Author: Thilo Graf Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_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 cb34896b6fba566f9c4cf904e5c6075ff473569d Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 8 Feb 2017 19:07:36 +0100 Subject: [PATCH 40/45] fb_accel_cs_hdx_inc.h: remove unused includes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9ddb4fc9c3156eff394d5fe1ffc875510b27b25e Author: Thilo Graf Date: 2017-02-08 (Wed, 08 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_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 602434236c00d3205744b9de02ad91f5f9565610 Mon Sep 17 00:00:00 2001 From: GetAway Date: Tue, 7 Feb 2017 08:39:09 +0100 Subject: [PATCH 41/45] make the webtv directory configurable Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a62d5b7c8edbec32838b99e952a6e54174937894 Author: GetAway Date: 2017-02-07 (Tue, 07 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 3 +++ src/neutrino.cpp | 2 +- src/nhttpd/yhttpd_mods/mod_yparser.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index e50254329..42956bd07 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -155,6 +155,9 @@ TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins, TUXBOX_APPS_DIRECTORY_ONE(plugindir_var,PLUGINDIR_VAR,localstatedir,/var,/tuxbox/plugins, [--with-plugindir_var=PATH ],[where to find the plugins in /var]) +TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/plugins/webtv, + [--with-webtvdir_var=PATH ],[where to find the livestreamScriptPath in /var]) + TUXBOX_APPS_DIRECTORY_ONE(plugindir_mnt,PLUGINDIR_MNT,mntdir,/mnt,/plugins, [--with-plugindir_mnt=PATH ],[where to find the the extern plugins]) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 4e68ed97d..f1416d10d 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -939,7 +939,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.infoClockSeconds = configfile.getInt32("infoClockSeconds", 1); g_settings.livestreamResolution = configfile.getInt32("livestreamResolution", 1920); - g_settings.livestreamScriptPath = configfile.getString("livestreamScriptPath", PLUGINDIR_VAR "/webtv"); + g_settings.livestreamScriptPath = configfile.getString("livestreamScriptPath", WEBTVDIR_VAR); g_settings.version_pseudo = configfile.getString("version_pseudo", "19700101000000"); diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index bcef54ea4..34e1ace67 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -457,6 +457,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { else if (ycmd_name.compare("GAMESDIR")) yresult = GAMESDIR; else if (ycmd_name.compare("PLUGINDIR")) yresult = PLUGINDIR; else if (ycmd_name.compare("PLUGINDIR_VAR")) yresult = PLUGINDIR_VAR; + else if (ycmd_name.compare("WEBTVDIR_VAR")) yresult = WEBTVDIR_VAR; else if (ycmd_name.compare("LUAPLUGINDIR")) yresult = LUAPLUGINDIR; else if (ycmd_name.compare("LOCALEDIR")) yresult = LOCALEDIR; else if (ycmd_name.compare("LOCALEDIR_VAR")) yresult = LOCALEDIR_VAR; From e0531a260734e5d1bf328c0c28a9e468869bd55c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 9 Feb 2017 08:24:20 +0100 Subject: [PATCH 42/45] helpbox: fix display of text after scroll; thx to DboxOldie Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/4b55d2597fd1beed0402a8a1ec2309c4dc22ce22 Author: vanhofen Date: 2017-02-09 (Thu, 09 Feb 2017) Origin message was: ------------------ - helpbox: fix display of text after scroll; thx to DboxOldie ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/helpbox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widget/helpbox.cpp b/src/gui/widget/helpbox.cpp index bb5c04829..bc84a2ee2 100644 --- a/src/gui/widget/helpbox.cpp +++ b/src/gui/widget/helpbox.cpp @@ -99,6 +99,7 @@ void Helpbox::addLine(const std::string& icon, const std::string& text, const in int x_text = w_picon + (picon ? OFFSET_INNER_MID : 0); CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, 0, text, text_mode, font); txt->doPaintBg(false); + txt->forceTextPaint(); #if 0 //"contrast agent", if you want to see where the text items are drawn. txt->setColorBody(COL_RED); #endif From cc37e37e40fd191d0dfcd92b10874948b1c7314a Mon Sep 17 00:00:00 2001 From: GetAway Date: Tue, 7 Feb 2017 22:19:57 +0100 Subject: [PATCH 43/45] change to CURLOPT_CONNECTTIMEOUT_MS and ... use a connect_timeout of 300ms for remote timer Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c1f788ac424c968a624e2aa12a02b7ea27b4a88b Author: GetAway Date: 2017-02-07 (Tue, 07 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/timerlist.cpp | 2 +- src/system/httptool.cpp | 8 ++++---- src/system/httptool.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 929ab4bbe..f54d04c30 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -280,7 +280,7 @@ CTimerList::CTimerList() Timer = new CTimerdClient(); timerNew_message = ""; timerNew_pluginName = ""; - httpConnectTimeout = 3; + httpConnectTimeout = 300; // ms changed = false; /* most probable default */ diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index 2d023c124..c68c84527 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -66,7 +66,7 @@ int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, doubl return 0; } //#define DEBUG -bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -98,7 +98,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); #ifdef DEBUG curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -136,7 +136,7 @@ printf("download code %d\n", res); return res==CURLE_OK; } -std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -162,7 +162,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); #ifdef DEBUG diff --git a/src/system/httptool.h b/src/system/httptool.h index 919cf4dbb..845cc3bf6 100644 --- a/src/system/httptool.h +++ b/src/system/httptool.h @@ -52,8 +52,8 @@ class CHTTPTool CHTTPTool(); void setStatusViewer( CProgressWindow* statusview ); - bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); - std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); + bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); + std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); }; From 40162cdc5d95c4c6cd21528ca8d87f49789ac801 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 9 Feb 2017 09:13:19 +0100 Subject: [PATCH 44/45] acinclude.m4: align to tuxbox code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/96bc77775eb13ffe3adf6969edb67e33bef0a18a Author: vanhofen Date: 2017-02-09 (Thu, 09 Feb 2017) Origin message was: ------------------ - acinclude.m4: align to tuxbox code ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index f4f44ac7a..773b41b72 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -146,12 +146,6 @@ TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts, TUXBOX_APPS_DIRECTORY_ONE(fontdir_var,FONTDIR_VAR,localstatedir,/var,/tuxbox/fonts, [--with-fontdir_var=PATH ],[where to find the fonts in /var]) -TUXBOX_APPS_DIRECTORY_ONE(webtvdir,WEBTVDIR,datadir,/share,/tuxbox/neutrino/webtv, - [--with-webtvdir=PATH ],[where to find the webtv content]) - -TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/webtv, - [--with-webtvdir_var=PATH ],[where to find the webtv content /var]) - TUXBOX_APPS_DIRECTORY_ONE(gamesdir,GAMESDIR,localstatedir,/var,/tuxbox/games, [--with-gamesdir=PATH ],[where games data is stored]) @@ -164,8 +158,11 @@ TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins, TUXBOX_APPS_DIRECTORY_ONE(plugindir_var,PLUGINDIR_VAR,localstatedir,/var,/tuxbox/plugins, [--with-plugindir_var=PATH ],[where to find the plugins in /var]) -TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/plugins/webtv, - [--with-webtvdir_var=PATH ],[where to find the livestreamScriptPath in /var]) +TUXBOX_APPS_DIRECTORY_ONE(webtvdir,WEBTVDIR,datadir,/share,/tuxbox/neutrino/webtv, + [--with-webtvdir=PATH ],[where to find the webtv content]) + +TUXBOX_APPS_DIRECTORY_ONE(webtvdir_var,WEBTVDIR_VAR,localstatedir,/var,/tuxbox/webtv, + [--with-webtvdir_var=PATH ],[where to find the webtv content in /var]) TUXBOX_APPS_DIRECTORY_ONE(plugindir_mnt,PLUGINDIR_MNT,mntdir,/mnt,/plugins, [--with-plugindir_mnt=PATH ],[where to find the the extern plugins]) From c54c5a5776914d51f2f1e3c6cc033fb574fb4658 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 9 Feb 2017 09:13:55 +0100 Subject: [PATCH 45/45] mod_yparser.cpp: add missing defines to define-get function Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/77b1477b4c9b363c4e18f529ee0b2d100f016148 Author: vanhofen Date: 2017-02-09 (Thu, 09 Feb 2017) Origin message was: ------------------ - mod_yparser.cpp: add missing defines to define-get function ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yhttpd_mods/mod_yparser.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index 4dbe7930e..55e765cb8 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -453,10 +453,12 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { if (ycmd_name.compare("CONFIGDIR")) yresult = CONFIGDIR; else if (ycmd_name.compare("DATADIR")) yresult = DATADIR; else if (ycmd_name.compare("FONTDIR")) yresult = FONTDIR; + else if (ycmd_name.compare("FONTDIR_VAR")) yresult = FONTDIR_VAR; //NI else if (ycmd_name.compare("LIBDIR")) yresult = LIBDIR; else if (ycmd_name.compare("GAMESDIR")) yresult = GAMESDIR; else if (ycmd_name.compare("PLUGINDIR")) yresult = PLUGINDIR; else if (ycmd_name.compare("PLUGINDIR_VAR")) yresult = PLUGINDIR_VAR; + else if (ycmd_name.compare("WEBTVDIR")) yresult = WEBTVDIR; //NI else if (ycmd_name.compare("WEBTVDIR_VAR")) yresult = WEBTVDIR_VAR; else if (ycmd_name.compare("LUAPLUGINDIR")) yresult = LUAPLUGINDIR; else if (ycmd_name.compare("LOCALEDIR")) yresult = LOCALEDIR;