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 <neutrino.h>
#include <mymenu.h>
#include <cs_api.h>
#include <gui/widget/icons.h>
#include <gui/widget/stringinput.h>
@@ -128,7 +127,6 @@ const CMenuOptionChooser::keyval AUDIOMENU_HDMI_DD_OPTIONS[AUDIOMENU_HDMI_DD_OPT
/* audio settings menu */
int CAudioSetup::showAudioSetup()
{
unsigned int system_rev = cs_get_revision();
//menue init
CMenuWidget* audioSettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width);
audioSettings->setSelected(selected);
@@ -142,11 +140,7 @@ int CAudioSetup::showAudioSetup()
//dd via hdmi
CMenuOptionChooser *as_oj_dd_hdmi = NULL;
/* system_rev == 0x01 is a hack: no Coolstream box has this value, but libtriple
defines it for the Tripledragon, so 0x01 identifies the TD. */
#ifndef HAVE_SPARK_HARDWARE
if (system_rev != 0x01)
#endif
if (g_info.hw_caps->has_HDMI)
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
@@ -161,6 +155,8 @@ int CAudioSetup::showAudioSetup()
//clock rec
// 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 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);
@@ -174,6 +170,7 @@ int CAudioSetup::showAudioSetup()
//SRS on/off
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);
#endif
#if 0
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(GenericMenuSeparatorLine);
//---------------------------------------------------------
#ifndef HAVE_SPARK_HARDWARE
if (system_rev != 0x01)
#endif
if (g_info.hw_caps->has_HDMI)
audioSettings->addItem(as_oj_dd_hdmi);
audioSettings->addItem(as_oj_dd_spdif);
audioSettings->addItem(as_oj_ddsubchn);
@@ -198,19 +193,14 @@ int CAudioSetup::showAudioSetup()
audioSettings->addItem(as_oj_vsteps);
// audioSettings->addItem(as_clockrec);
//---------------------------------------------------------
if (system_rev != 0x01) {
audioSettings->addItem(GenericMenuSeparatorLine);
audioSettings->addItem(as_oj_srsonoff);
audioSettings->addItem(as_oj_algo);
audioSettings->addItem(as_oj_noise);
audioSettings->addItem(as_oj_volrev);
} else {
/* if it's not added, we need to delete it manually */
delete as_oj_srsonoff;
delete as_oj_algo;
delete as_oj_noise;
delete as_oj_volrev;
}
#if HAVE_COOL_HARDWARE
/* only coolstream has SRS stuff, so only compile it there */
audioSettings->addItem(GenericMenuSeparatorLine);
audioSettings->addItem(as_oj_srsonoff);
audioSettings->addItem(as_oj_algo);
audioSettings->addItem(as_oj_noise);
audioSettings->addItem(as_oj_volrev);
#endif
#if 0
audioSettings->addItem(mf);
#endif

View File

@@ -50,8 +50,6 @@
#include <system/debug.h>
#include <cs_api.h>
//#define ONE_KEY_PLUGIN
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));
//energy, shutdown
#if !defined(HAVE_SPARK_HARDWARE) && !defined(HAVE_AZBOX_HARDWARE)
if(cs_get_revision() > 7)
#endif
if (g_info.hw_caps->can_shutdown)
{
CMenuWidget *misc_menue_energy = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ENERGY);
showMiscSettingsMenuEnergy(misc_menue_energy);
@@ -194,14 +190,16 @@ int CMiscMenue::showMiscSettingsMenu()
misc_menue.addItem(GenericMenuSeparatorLine);
//cec settings
#if !HAVE_TRIPLEDRAGON
CCECSetup cecsetup;
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_cec) {
CCECSetup cecsetup;
misc_menue.addItem(new CMenuForwarder(LOCALE_VIDEOMENU_HDMI_CEC, true, NULL, &cecsetup, NULL, CRCInput::RC_1));
}
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
CMenuWidget misc_menue_chanlist(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_CHANNELLIST);
showMiscSettingsMenuChanlist(&misc_menue_chanlist);

View File

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

View File

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