neutrino: start to use hardware_caps

Use hardware_caps instead of cs_get_revision() and #ifdef HAVE_FOO_HW
to distinguish between different boxtypes.
This commit is contained in:
Stefan Seyfried
2012-09-23 21:32:40 +02:00
parent 1a62480581
commit 04ee2e87f3
5 changed files with 104 additions and 44 deletions

View File

@@ -0,0 +1,73 @@
/*
* determine the capabilities of the hardware.
* part of libstb-hal
*
* (C) 2010-2012 Stefan Seyfried
*
* License: GPL v2 or later
*/
#ifndef __HARDWARE_CAPS_H__
#define __HARDWARE_CAPS_H__
#include "cs_api.h"
#ifdef __cplusplus
extern "C" {
#endif
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];
} hw_caps_t;
hw_caps_t *get_hwcaps(void) {
static int initialized = 0;
static hw_caps_t caps;
if (initialized)
return ∩︀
caps.has_fan = (cs_get_revision() < 8);
caps.has_HDMI = 1;
caps.has_SCART = (cs_get_revision() != 10);
caps.has_SCART_input = 0;
caps.has_YUV_cinch = 1;
caps.can_shutdown = (cs_get_revision() > 7);
caps.can_cec = 1;
caps.display_type = HW_DISPLAY_LINE_TEXT;
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");
initialized = 1;
return &caps;
}
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -38,7 +38,6 @@
#include <global.h> #include <global.h>
#include <neutrino.h> #include <neutrino.h>
#include <mymenu.h> #include <mymenu.h>
#include <cs_api.h>
#include <gui/widget/icons.h> #include <gui/widget/icons.h>
#include <gui/widget/stringinput.h> #include <gui/widget/stringinput.h>
@@ -128,7 +127,6 @@ const CMenuOptionChooser::keyval AUDIOMENU_HDMI_DD_OPTIONS[AUDIOMENU_HDMI_DD_OPT
/* audio settings menu */ /* audio settings menu */
int CAudioSetup::showAudioSetup() int CAudioSetup::showAudioSetup()
{ {
unsigned int system_rev = cs_get_revision();
//menue init //menue init
CMenuWidget* audioSettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width); CMenuWidget* audioSettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width);
audioSettings->setSelected(selected); audioSettings->setSelected(selected);
@@ -142,11 +140,7 @@ int CAudioSetup::showAudioSetup()
//dd via hdmi //dd via hdmi
CMenuOptionChooser *as_oj_dd_hdmi = NULL; CMenuOptionChooser *as_oj_dd_hdmi = NULL;
/* system_rev == 0x01 is a hack: no Coolstream box has this value, but libtriple if (g_info.hw_caps->has_HDMI)
defines it for the Tripledragon, so 0x01 identifies the TD. */
#ifndef HAVE_SPARK_HARDWARE
if (system_rev != 0x01)
#endif
as_oj_dd_hdmi = new CMenuOptionChooser(LOCALE_AUDIOMENU_HDMI_DD, &g_settings.hdmi_dd, AUDIOMENU_HDMI_DD_OPTIONS, AUDIOMENU_HDMI_DD_OPTION_COUNT, true, audioSetupNotifier); as_oj_dd_hdmi = new CMenuOptionChooser(LOCALE_AUDIOMENU_HDMI_DD, &g_settings.hdmi_dd, AUDIOMENU_HDMI_DD_OPTIONS, AUDIOMENU_HDMI_DD_OPTION_COUNT, true, audioSetupNotifier);
//dd via spdif //dd via spdif
@@ -161,6 +155,8 @@ int CAudioSetup::showAudioSetup()
//clock rec //clock rec
// CMenuOptionChooser * as_oj_clockrec new CMenuOptionChooser(LOCALE_AUDIOMENU_CLOCKREC, &g_settings.clockrec, AUDIOMENU_CLOCKREC_OPTIONS, AUDIOMENU_CLOCKREC_OPTION_COUNT, true, audioSetupNotifier); // CMenuOptionChooser * as_oj_clockrec new CMenuOptionChooser(LOCALE_AUDIOMENU_CLOCKREC, &g_settings.clockrec, AUDIOMENU_CLOCKREC_OPTIONS, AUDIOMENU_CLOCKREC_OPTION_COUNT, true, audioSetupNotifier);
#if HAVE_COOL_HARDWARE
/* only coolstream has SRS stuff, so only compile it there */
//SRS //SRS
//SRS algo //SRS algo
CMenuOptionChooser * as_oj_algo = new CMenuOptionChooser(LOCALE_AUDIO_SRS_ALGO, &g_settings.srs_algo, AUDIOMENU_SRS_OPTIONS, AUDIOMENU_SRS_OPTION_COUNT, g_settings.srs_enable, audioSetupNotifier); CMenuOptionChooser * as_oj_algo = new CMenuOptionChooser(LOCALE_AUDIO_SRS_ALGO, &g_settings.srs_algo, AUDIOMENU_SRS_OPTIONS, AUDIOMENU_SRS_OPTION_COUNT, g_settings.srs_enable, audioSetupNotifier);
@@ -174,6 +170,7 @@ int CAudioSetup::showAudioSetup()
//SRS on/off //SRS on/off
CTruVolumeNotifier truevolSetupNotifier(as_oj_algo, as_oj_noise, as_oj_volrev); CTruVolumeNotifier truevolSetupNotifier(as_oj_algo, as_oj_noise, as_oj_volrev);
CMenuOptionChooser * as_oj_srsonoff = new CMenuOptionChooser(LOCALE_AUDIO_SRS_IQ, &g_settings.srs_enable, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, &truevolSetupNotifier); CMenuOptionChooser * as_oj_srsonoff = new CMenuOptionChooser(LOCALE_AUDIO_SRS_IQ, &g_settings.srs_enable, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, &truevolSetupNotifier);
#endif
#if 0 #if 0
CStringInput * audio_PCMOffset = new CStringInput(LOCALE_AUDIOMENU_PCMOFFSET, g_settings.audio_PCMOffset, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 ", audioSetupNotifier); CStringInput * audio_PCMOffset = new CStringInput(LOCALE_AUDIOMENU_PCMOFFSET, g_settings.audio_PCMOffset, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 ", audioSetupNotifier);
@@ -186,9 +183,7 @@ int CAudioSetup::showAudioSetup()
audioSettings->addItem(as_oj_analogmode); audioSettings->addItem(as_oj_analogmode);
audioSettings->addItem(GenericMenuSeparatorLine); audioSettings->addItem(GenericMenuSeparatorLine);
//--------------------------------------------------------- //---------------------------------------------------------
#ifndef HAVE_SPARK_HARDWARE if (g_info.hw_caps->has_HDMI)
if (system_rev != 0x01)
#endif
audioSettings->addItem(as_oj_dd_hdmi); audioSettings->addItem(as_oj_dd_hdmi);
audioSettings->addItem(as_oj_dd_spdif); audioSettings->addItem(as_oj_dd_spdif);
audioSettings->addItem(as_oj_ddsubchn); audioSettings->addItem(as_oj_ddsubchn);
@@ -198,19 +193,14 @@ int CAudioSetup::showAudioSetup()
audioSettings->addItem(as_oj_vsteps); audioSettings->addItem(as_oj_vsteps);
// audioSettings->addItem(as_clockrec); // audioSettings->addItem(as_clockrec);
//--------------------------------------------------------- //---------------------------------------------------------
if (system_rev != 0x01) { #if HAVE_COOL_HARDWARE
audioSettings->addItem(GenericMenuSeparatorLine); /* only coolstream has SRS stuff, so only compile it there */
audioSettings->addItem(as_oj_srsonoff); audioSettings->addItem(GenericMenuSeparatorLine);
audioSettings->addItem(as_oj_algo); audioSettings->addItem(as_oj_srsonoff);
audioSettings->addItem(as_oj_noise); audioSettings->addItem(as_oj_algo);
audioSettings->addItem(as_oj_volrev); audioSettings->addItem(as_oj_noise);
} else { audioSettings->addItem(as_oj_volrev);
/* if it's not added, we need to delete it manually */ #endif
delete as_oj_srsonoff;
delete as_oj_algo;
delete as_oj_noise;
delete as_oj_volrev;
}
#if 0 #if 0
audioSettings->addItem(mf); audioSettings->addItem(mf);
#endif #endif

View File

@@ -50,8 +50,6 @@
#include <system/debug.h> #include <system/debug.h>
#include <cs_api.h>
//#define ONE_KEY_PLUGIN //#define ONE_KEY_PLUGIN
extern CPlugins * g_PluginList; extern CPlugins * g_PluginList;
@@ -172,9 +170,7 @@ int CMiscMenue::showMiscSettingsMenu()
misc_menue.addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_GENERAL, true, NULL, &misc_menue_general, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED)); misc_menue.addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_GENERAL, true, NULL, &misc_menue_general, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
//energy, shutdown //energy, shutdown
#if !defined(HAVE_SPARK_HARDWARE) && !defined(HAVE_AZBOX_HARDWARE) if (g_info.hw_caps->can_shutdown)
if(cs_get_revision() > 7)
#endif
{ {
CMenuWidget *misc_menue_energy = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ENERGY); CMenuWidget *misc_menue_energy = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ENERGY);
showMiscSettingsMenuEnergy(misc_menue_energy); showMiscSettingsMenuEnergy(misc_menue_energy);
@@ -194,14 +190,16 @@ int CMiscMenue::showMiscSettingsMenu()
misc_menue.addItem(GenericMenuSeparatorLine); misc_menue.addItem(GenericMenuSeparatorLine);
//cec settings //cec settings
#if !HAVE_TRIPLEDRAGON if (g_info.hw_caps->can_cec) {
CCECSetup cecsetup; CCECSetup cecsetup;
misc_menue.addItem(new CMenuForwarder(LOCALE_VIDEOMENU_HDMI_CEC, true, NULL, &cecsetup, NULL, CRCInput::RC_1)); misc_menue.addItem(new CMenuForwarder(LOCALE_VIDEOMENU_HDMI_CEC, true, NULL, &cecsetup, NULL, CRCInput::RC_1));
#else }
CSleepTimerWidget sleeptimer;
misc_menue->addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, g_settings.shutdown_min, &sleeptimer, "permanent", CRCInput::RC_1));
#endif
if (!g_info.hw_caps->can_shutdown) {
/* we don't have the energy menu, but put the sleeptimer directly here */
CSleepTimerWidget sleeptimer;
misc_menue.addItem(new CMenuForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, g_settings.shutdown_min, &sleeptimer, "permanent", CRCInput::RC_1));
}
//channellist //channellist
CMenuWidget misc_menue_chanlist(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_CHANNELLIST); CMenuWidget misc_menue_chanlist(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_CHANNELLIST);
showMiscSettingsMenuChanlist(&misc_menue_chanlist); showMiscSettingsMenuChanlist(&misc_menue_chanlist);

View File

@@ -220,12 +220,10 @@ static void initGlobals(void)
g_Radiotext = NULL; g_Radiotext = NULL;
g_volume = NULL; g_volume = NULL;
#if HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE g_info.hw_caps = get_hwcaps();
/* spark has revision == 1 like tripledragon for now */
can_deepstandby = true; can_deepstandby = g_info.hw_caps->can_shutdown;
#else g_info.has_fan = g_info.hw_caps->has_fan;
can_deepstandby = (cs_get_revision() > 7);
#endif
} }
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -1866,9 +1864,7 @@ fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms
cpuFreq = new cCpuFreqManager(); cpuFreq = new cCpuFreqManager();
cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000); cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000);
g_info.delivery_system = CFEManager::getInstance()->getLiveFE()->getInfo()->type == FE_QPSK ? DVB_S : DVB_C; g_info.delivery_system = CFEManager::getInstance()->getLiveFE()->getInfo()->type == FE_QPSK ? DVB_S : DVB_C;
#if !HAVE_COOL_HARDWARE #if HAVE_COOL_HARDWARE
g_info.has_fan = 0;
#else
/* only SAT-hd1 before rev 8 has fan */ /* only SAT-hd1 before rev 8 has fan */
g_info.has_fan = (cs_get_revision() < 8 && g_info.delivery_system == DVB_S); g_info.has_fan = (cs_get_revision() < 8 && g_info.delivery_system == DVB_S);
#endif #endif

View File

@@ -40,6 +40,8 @@
#include <zapit/client/zapitclient.h> #include <zapit/client/zapitclient.h>
#include <zapit/client/zapittools.h> #include <zapit/client/zapittools.h>
#include <hardware_caps.h>
#include <string> #include <string>
#if HAVE_COOL_HARDWARE #if HAVE_COOL_HARDWARE
@@ -662,6 +664,7 @@ struct SglobalInfo
unsigned char box_Type; unsigned char box_Type;
delivery_system_t delivery_system; delivery_system_t delivery_system;
bool has_fan; bool has_fan;
hw_caps_t *hw_caps;
}; };
const int RECORDING_OFF = 0; const int RECORDING_OFF = 0;