From 48e4e8cba8ec36dd60e38604a67853b6749f2be5 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Fri, 15 Jan 2016 16:19:57 +0100 Subject: [PATCH] Adapt neutrino-mp for CST hardware part #3 - Adapt and extend hw_caps for cst hardware Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/fe9a2c19e4f2ca79126acac6f6dfbcc903816378 Author: Michael Liebmann Date: 2016-01-15 (Fri, 15 Jan 2016) --- configure.ac | 1 + lib/Makefile.am | 8 +- lib/libcoolstream/Makefile.am | 10 +- lib/libcoolstream/hardware_caps.cpp | 69 +++++++++--- lib/libcoolstream/hardware_caps.h | 11 +- lib/libcoolstream2/Makefile.am | 15 +++ lib/libcoolstream2/hardware_caps.cpp | 163 +++++++++++++++++++++++++++ lib/libcoolstream2/hardware_caps.h | 45 ++++++++ src/Makefile.am | 9 +- src/neutrino.cpp | 1 + 10 files changed, 309 insertions(+), 23 deletions(-) create mode 100644 lib/libcoolstream2/Makefile.am create mode 100644 lib/libcoolstream2/hardware_caps.cpp create mode 100644 lib/libcoolstream2/hardware_caps.h diff --git a/configure.ac b/configure.ac index 4ca87e58b..68355fd52 100644 --- a/configure.ac +++ b/configure.ac @@ -323,6 +323,7 @@ lib/jsoncpp/Makefile lib/sectionsdclient/Makefile lib/timerdclient/Makefile lib/libcoolstream/Makefile +lib/libcoolstream2/Makefile lib/libtuxtxt/Makefile lib/libtuxtxt_mp/Makefile lib/libdvbsub/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am index 18e0a0b70..81af5f58f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,8 +18,14 @@ SUBDIRS += \ endif if BOXTYPE_COOL +if BOXMODEL_APOLLO +SUBDIRS += \ + libcoolstream2 +else +SUBDIRS += \ + libcoolstream +endif SUBDIRS += \ - libcoolstream \ libtuxtxt else SUBDIRS += \ diff --git a/lib/libcoolstream/Makefile.am b/lib/libcoolstream/Makefile.am index eaa9c7d79..f1c497147 100644 --- a/lib/libcoolstream/Makefile.am +++ b/lib/libcoolstream/Makefile.am @@ -2,7 +2,15 @@ noinst_LIBRARIES = libhwcaps.a AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing -AM_CPPFLAGS = -I$(top_srcdir)/lib/libcoolstream +AM_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/zapit/include \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/lib/libeventserver \ + -I$(top_srcdir)/lib/libconfigfile \ + -I$(top_srcdir)/lib/libcoolstream \ + @HWLIB_CFLAGS@ libhwcaps_a_SOURCES = \ hardware_caps.cpp diff --git a/lib/libcoolstream/hardware_caps.cpp b/lib/libcoolstream/hardware_caps.cpp index 619029162..66460e8a8 100644 --- a/lib/libcoolstream/hardware_caps.cpp +++ b/lib/libcoolstream/hardware_caps.cpp @@ -3,34 +3,77 @@ * part of libstb-hal * * (C) 2010-2012 Stefan Seyfried + * (C) 2016 M. Liebmann * * License: GPL v2 or later */ + +#include +#include #include "hardware_caps.h" + static int initialized = 0; +static bool frontend_check = false; static hw_caps_t caps; -hw_caps_t *get_hwcaps(void) { - if (initialized) +hw_caps_t *get_hwcaps(void) +{ + + if (initialized && frontend_check) return ∩︀ - caps.has_fan = (cs_get_revision() < 8); + + unsigned int system_rev = cs_get_revision(); + + CFEManager* fem = CFEManager::getInstance(); + int frontendCount = fem->getFrontendCount(); + frontend_check = frontendCount > 0; + + caps.has_fan = (system_rev < 8); caps.has_HDMI = 1; - caps.has_SCART = (cs_get_revision() != 10); + caps.has_SCART = (system_rev != 10); caps.has_SCART_input = 0; caps.has_YUV_cinch = 1; - caps.can_shutdown = (cs_get_revision() > 7); + caps.can_shutdown = (system_rev > 7); caps.can_cec = 1; - caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_type = (system_rev != 10) ? HW_DISPLAY_LINE_TEXT : HW_DISPLAY_NONE; caps.display_xres = 12; caps.display_yres = 0; caps.can_set_display_brightness = 1; - strcpy(caps.boxvendor, "Coolstream"); - if (cs_get_revision() < 8) - strcpy(caps.boxname, "HD1"); - else if (cs_get_revision() == 10) - strcpy(caps.boxname, "ZEE"); - else - strcpy(caps.boxname, "NEO"); + + + strcpy(caps.boxvendor, "CST"); + const char* boxname; + switch (system_rev) { + case 6: + boxname = "HD1"; + break; + case 7: + boxname = "BSE"; + break; + case 8: + boxname = "Neo"; + break; + case 10: + boxname = "Zee"; + break; + default: + char buffer[512]; + snprintf(buffer, sizeof(buffer)-1, "Unknown nr. %u\n", system_rev); + boxname = buffer; + break; + } + strcpy(caps.boxname, boxname); + + CFrontend *frontend = fem->getFE(0); + uint32_t mask = frontend->getSupportedDeliverySystems(); + std::string tuner = ""; + if (frontendCount > 1) + tuner += "Twin "; + tuner += ((mask & DVB_C) == DVB_C) ? g_Locale->getText(LOCALE_SATSETUP_FE_DELSYS_MODE_CABLE) : "Sat"; + strcpy(caps.frontend, tuner.c_str()); + + strcpy(caps.chipset, "Nevis"); + initialized = 1; return ∩︀ } diff --git a/lib/libcoolstream/hardware_caps.h b/lib/libcoolstream/hardware_caps.h index f91821da5..676d9a2de 100644 --- a/lib/libcoolstream/hardware_caps.h +++ b/lib/libcoolstream/hardware_caps.h @@ -3,6 +3,7 @@ * part of libstb-hal * * (C) 2010-2012 Stefan Seyfried + * (C) 2016 M. Liebmann * * License: GPL v2 or later */ @@ -11,9 +12,9 @@ #include "cs_api.h" #include +#include -typedef enum -{ +typedef enum { HW_DISPLAY_NONE, HW_DISPLAY_LED_NUM, /* simple 7 segment LED display */ HW_DISPLAY_LINE_TEXT, /* 1 line text display */ @@ -21,8 +22,7 @@ typedef enum } display_type_t; -typedef struct hw_caps -{ +typedef struct hw_caps { int has_fan; int has_HDMI; int has_SCART; @@ -36,7 +36,10 @@ typedef struct hw_caps int can_set_display_brightness; char boxvendor[64]; char boxname[64]; + char chipset[64]; + char frontend[64]; } hw_caps_t; +std::string getTuner(); hw_caps_t *get_hwcaps(void); #endif diff --git a/lib/libcoolstream2/Makefile.am b/lib/libcoolstream2/Makefile.am new file mode 100644 index 000000000..e96803f29 --- /dev/null +++ b/lib/libcoolstream2/Makefile.am @@ -0,0 +1,15 @@ +noinst_LIBRARIES = libhwcaps.a + +AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing + +AM_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/zapit/include \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/lib/libeventserver \ + -I$(top_srcdir)/lib/libconfigfile \ + -I$(top_srcdir)/lib/libcoolstream2 + +libhwcaps_a_SOURCES = \ + hardware_caps.cpp diff --git a/lib/libcoolstream2/hardware_caps.cpp b/lib/libcoolstream2/hardware_caps.cpp new file mode 100644 index 000000000..dba06de0a --- /dev/null +++ b/lib/libcoolstream2/hardware_caps.cpp @@ -0,0 +1,163 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * (C) 2016 M. Liebmann + * + * License: GPL v2 or later + */ + +#include +#include +#include "hardware_caps.h" + +static int initialized = 0; +static bool frontend_check = false; +static hw_caps_t caps; + +std::string getTuner() +{ + std::string tuner; + char buff1[64]; + CFEManager* fem = CFEManager::getInstance(); + int frontendCount = fem->getFrontendCount(); + frontend_check = frontendCount > 0; + + int satCount = 0; + int cableCount = 0; + int dvbtCount = 0; + int dvbc_tCount = 0; + for (int i = 0; i < frontendCount; i++) { + bool has_dvb_s = false; + bool has_dvb_s2 = false; + bool has_dvb_c = false; + bool has_dvb_t = false; + bool has_dvb_t2 = false; +// bool has_dtmb = false; + + CFrontend *frontend = fem->getFE(i); + uint32_t mask = frontend->getSupportedDeliverySystems(); + + if ((mask & DVB_S) == DVB_S) has_dvb_s = true; + if ((mask & DVB_S2) == DVB_S2) has_dvb_s2 = true; + if ((mask & DVB_C) == DVB_C) has_dvb_c = true; + if ((mask & DVB_T) == DVB_T) has_dvb_t = true; + if ((mask & DVB_T2) == DVB_T2) has_dvb_t2 = true; +// if ((mask & DTMB) == DTMB) has_dtmb = true; + + if (has_dvb_s || has_dvb_s2) satCount++; + if (has_dvb_c && (has_dvb_t || has_dvb_t2)) + dvbc_tCount++; + else { + if (has_dvb_c) cableCount++; + if (has_dvb_t || has_dvb_t2) dvbtCount++; + } + } + + if (satCount > 0) { + memset(buff1, 0, sizeof(buff1)); + snprintf(buff1, sizeof(buff1)-1, "%dx Sat", satCount); + tuner += buff1; + } + if (cableCount > 0) { + if (satCount > 0) tuner += ", "; + memset(buff1, 0, sizeof(buff1)); + snprintf(buff1, sizeof(buff1)-1, "%dx %s", cableCount, g_Locale->getText(LOCALE_SATSETUP_FE_DELSYS_MODE_CABLE)); + tuner += buff1; + } + if (dvbtCount > 0) { + if ((satCount > 0) || (cableCount > 0)) tuner += ", "; + memset(buff1, 0, sizeof(buff1)); + snprintf(buff1, sizeof(buff1)-1, "%dx DVB-T", dvbtCount); + tuner += buff1; + } + if (dvbc_tCount > 0) { + if ((satCount > 0) || (cableCount > 0) || (dvbtCount > 0)) tuner += ", "; + memset(buff1, 0, sizeof(buff1)); + snprintf(buff1, sizeof(buff1)-1, "%dx %s/DVB-T", dvbc_tCount, g_Locale->getText(LOCALE_SATSETUP_FE_DELSYS_MODE_CABLE)); + tuner += buff1; + } + return tuner; +} + +hw_caps_t *get_hwcaps(void) +{ + if (!frontend_check) + strcpy(caps.frontend, getTuner().c_str()); + + if (initialized) + return ∩︀ + + unsigned int system_rev = cs_get_revision(); + + caps.has_fan = 0; + caps.has_HDMI = 1; + caps.has_SCART = (system_rev != 10); + caps.has_SCART_input = 0; + caps.has_YUV_cinch = 1; + caps.can_shutdown = 1; + caps.can_cec = 1; + switch (system_rev) { + case 9: /* Tank */ + case 12: /* Zee2 */ + caps.display_type = HW_DISPLAY_LINE_TEXT; + break; + case 11: /* Trinity */ + caps.display_type = HW_DISPLAY_NONE; + break; + case 13: /* Link */ + caps.display_type = HW_DISPLAY_LED_NUM; + break; + default: + caps.display_type = HW_DISPLAY_NONE; + break; + } + caps.display_xres = 12; + caps.display_yres = 0; + caps.can_set_display_brightness = 1; + + strcpy(caps.boxvendor, "CST"); + const char* boxname; + switch (system_rev) { + case 9: + boxname = "Tank"; + break; + case 11: + boxname = "Trinity"; + break; + case 12: + boxname = "Zee2"; + break; + case 13: + boxname = "Link"; + break; + default: + char buffer[512]; + snprintf(buffer, sizeof(buffer)-1, "Unknown nr. %u\n", system_rev); + boxname = buffer; + break; + } + strcpy(caps.boxname, boxname); + + const char* chipset; + switch (system_rev) { + case 9: + chipset = "Apollo"; + break; + case 11: + chipset = "Shiner"; + break; + case 12: + case 13: + chipset = "Kronos"; + break; + default: + chipset = ""; + break; + } + strcpy(caps.chipset, chipset); + + initialized = 1; + return ∩︀ +} diff --git a/lib/libcoolstream2/hardware_caps.h b/lib/libcoolstream2/hardware_caps.h new file mode 100644 index 000000000..676d9a2de --- /dev/null +++ b/lib/libcoolstream2/hardware_caps.h @@ -0,0 +1,45 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * (C) 2016 M. Liebmann + * + * License: GPL v2 or later + */ +#ifndef __HARDWARE_CAPS_H__ +#define __HARDWARE_CAPS_H__ + +#include "cs_api.h" +#include +#include + +typedef enum { + HW_DISPLAY_NONE, + HW_DISPLAY_LED_NUM, /* simple 7 segment LED display */ + HW_DISPLAY_LINE_TEXT, /* 1 line text display */ + HW_DISPLAY_GFX +} display_type_t; + + +typedef struct hw_caps { + int has_fan; + int has_HDMI; + int has_SCART; + int has_SCART_input; + int has_YUV_cinch; + int can_shutdown; + int can_cec; + display_type_t display_type; + int display_xres; /* x resolution or chars per line */ + int display_yres; + int can_set_display_brightness; + char boxvendor[64]; + char boxname[64]; + char chipset[64]; + char frontend[64]; +} hw_caps_t; + +std::string getTuner(); +hw_caps_t *get_hwcaps(void); +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 054699350..98f8d8472 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -149,14 +149,15 @@ neutrino_LDADD += \ endif if BOXTYPE_COOL -neutrino_LDADD += -lcoolstream-mt -lca-sc \ - $(top_builddir)/lib/libcoolstream/libhwcaps.a +neutrino_LDADD += -lcoolstream-mt -lca-sc if ENABLE_TMSDK else if BOXMODEL_APOLLO -neutrino_LDADD += -lca-ci -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager-cst -ltmpvrIndexStorage -llnxscsUsr +neutrino_LDADD += -lca-ci -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager-cst -ltmpvrIndexStorage -llnxscsUsr \ + $(top_builddir)/lib/libcoolstream2/libhwcaps.a else -neutrino_LDADD += -lnxp +neutrino_LDADD += -lnxp \ + $(top_builddir)/lib/libcoolstream/libhwcaps.a endif endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f35e44fbe..4635f4085 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2025,6 +2025,7 @@ TIMER_START(); InitZapitClient(); g_Zapit->setStandby(false); + g_info.hw_caps = get_hwcaps(); CheckFastScan();