From 99e6feec1546d5fa2ff8e5cdfdf84438db4281b3 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Mon, 12 Nov 2007 18:42:54 +0000 Subject: [PATCH] add possibility to set tuner priority for alternative services in Customize menu (just with expert usage level) --- data/setup.xml | 1 + lib/dvb/dvb.cpp | 35 ++++++++++++++++++++++++++++++----- lib/dvb/frontend.cpp | 2 ++ lib/dvb/frontend.h | 3 +++ lib/python/Components/UsageConfig.py | 14 +++++++++++++- lib/python/enigma_python.i | 8 ++++++++ lib/service/servicedvb.cpp | 25 +++++++++++++++++++++++++ 7 files changed, 82 insertions(+), 6 deletions(-) diff --git a/data/setup.xml b/data/setup.xml index 894a2b8..1ba4123 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -32,6 +32,7 @@ config.usage.show_infobar_on_event_change config.usage.self_defined_seek config.usage.pip_zero_button + config.usage.alternatives_priority config.usage.hdd_standby diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 03c2aab..b7d278c 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -597,14 +597,41 @@ int eDVBResourceManager::canAllocateFrontend(ePtr &fepar return bestval; } +int tuner_type_channel_default(ePtr &channellist, const eDVBChannelID &chid) +{ + if (channellist) + { + ePtr feparm; + if (!channellist->getChannelFrontendData(chid, feparm)) + { + int system; + if (!feparm->getSystem(system)) + { + switch(system) + { + case iDVBFrontend::feSatellite: + return 50000; + case iDVBFrontend::feCable: + return 40000; + case iDVBFrontend::feTerrestrial: + return 30000; + default: + break; + } + } + } + } + return 0; +} + int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore) { - int ret=30000; + int ret=0; if (m_cached_channel) { eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel); if(channelid==cache_chan->getChannelID()) - return ret; + return tuner_type_channel_default(m_list, channelid); } /* first, check if a channel is already existing. */ @@ -615,7 +642,7 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons if (i->m_channel_id == channelid) { // eDebug("found shared channel.."); - return ret; + return tuner_type_channel_default(m_list, channelid); } } @@ -685,14 +712,12 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons if (!m_list) { eDebug("no channel list set!"); - ret = 0; goto error; } if (m_list->getChannelFrontendData(channelid, feparm)) { eDebug("channel not found!"); - ret = 0; goto error; } diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 8b21413..6a26ae9 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -382,6 +382,8 @@ RESULT eDVBFrontendParameters::getHash(unsigned long &hash) const DEFINE_REF(eDVBFrontend); +int eDVBFrontend::PriorityOrder=0; + eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok) :m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe) ,m_fd(-1), m_need_rotor_workaround(false), m_sn(0), m_timeout(0), m_tuneTimer(0) diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index 2a180ba..5821e54 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -97,6 +97,7 @@ class eDVBFrontend: public iDVBFrontend, public Object int readInputpower(); bool setSecSequencePos(int steps); void setRotorData(int pos, int cmd); + static int PriorityOrder; public: eDVBFrontend(int adap, int fe, int &ok); virtual ~eDVBFrontend(); @@ -126,6 +127,8 @@ public: int getDVBID() { return m_dvbid; } int getSlotID() { return m_slotid; } bool setSlotInfo(ePyObject obj); // get a tuple (slotid, slotdescr) + static void setTypePriorityOrder(int val) { PriorityOrder = val; } + static int getTypePriorityOrder() { return PriorityOrder; } int openFrontend(); int closeFrontend(); diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index b365801..71b0b60 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -1,5 +1,5 @@ from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigInteger -from enigma import Misc_Options +from enigma import Misc_Options, setTunerTypePriorityOrder; import os def InitUsageConfig(): @@ -38,6 +38,18 @@ def InitUsageConfig(): ("show_menu", _("show shutdown menu")), ("shutdown", _("immediate shutdown")) ] ) + config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [ + ("0", "DVB-S/-C/-T"), + ("1", "DVB-S/-T/-C"), + ("2", "DVB-C/-S/-T"), + ("3", "DVB-C/-T/-S"), + ("4", "DVB-T/-C/-S"), + ("5", "DVB-T/-S/-C") ]) + + def TunerTypePriorityOrderChanged(configElement): + setTunerTypePriorityOrder(int(configElement.value)) + config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged) + def setHDDStandby(configElement): os.system("hdparm -S" + configElement.value + " /dev/ide/host0/bus0/target0/lun0/disc") config.usage.hdd_standby.addNotifier(setHDDStandby) diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index bc2d550..9ef269b 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -297,6 +297,14 @@ PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, } %} +void setTunerTypePriorityOrder(int); +%{ +void setTunerTypePriorityOrder(int order) +{ + eDVBFrontend::setTypePriorityOrder(order); +} +%} + /************** temp *****************/ /* need a better place for this, i agree. */ diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index c66b3da..53bc17a 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -428,13 +428,38 @@ int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref return 0; } + int prio_order = eDVBFrontend::getTypePriorityOrder(); int cur=0; eDVBChannelID chid, chid_ignore; ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore); for (std::list::iterator it(bouquet->m_services.begin()); it != bouquet->m_services.end(); ++it) { + static unsigned char prio_map[6][3] = { + { 3, 2, 1 }, // -S -C -T + { 3, 1, 2 }, // -S -T -C + { 2, 3, 1 }, // -C -S -T + { 1, 3, 2 }, // -C -T -S + { 1, 2, 3 }, // -T -C -S + { 2, 1, 3 } // -T -S -C + }; ((const eServiceReferenceDVB&)*it).getChannelID(chid); int tmp=res->canAllocateChannel(chid, chid_ignore); + switch(tmp) + { + case 0: + break; + case 30000: // cached DVB-T channel + case 1: // DVB-T frontend + tmp = prio_map[prio_order][2]; + break; + case 40000: // cached DVB-C channel + case 2: + tmp = prio_map[prio_order][1]; + break; + default: // DVB-S + tmp = prio_map[prio_order][0]; + break; + } if (tmp > cur) { m_playable_service = *it; -- 2.7.4