From e768f7667ec5da0e331725de8a582365358cf7e3 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Wed, 16 Nov 2005 16:50:27 +0000 Subject: [PATCH] auto tuner selection is now working (this breaks allocateRawChannel..) TODO: handling for linked tuners (loop through) --- lib/dvb/dvb.cpp | 57 +++++++++++++++++++++----------------------- lib/dvb/dvb.h | 4 ++-- lib/dvb/frontend.cpp | 13 ++++++++-- lib/dvb/frontend.h | 2 +- lib/dvb/idvb.h | 3 ++- lib/dvb/sec.cpp | 34 ++++++++++++++++++++++++++ lib/dvb/sec.h | 1 + 7 files changed, 78 insertions(+), 36 deletions(-) diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 89e2bdf3..5ede1e38 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -206,15 +206,15 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter) } } -RESULT eDVBResourceManager::allocateFrontend(const eDVBChannelID &chid, ePtr &fe) +RESULT eDVBResourceManager::allocateFrontend(ePtr &feparm, ePtr &fe) { ePtr best; int bestval = 0; - + for (eSmartPtrList::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i) if (!i->m_inuse) { - int c = i->m_frontend->isCompatibleWith(chid); + int c = i->m_frontend->isCompatibleWith(feparm); if (c > bestval) { c = bestval; @@ -298,13 +298,26 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse } } - /* no currently available channel is tuned to this channelid. create a new one, if possible. */ - - /* allocate a frontend. */ + /* no currently available channel is tuned to this channelid. create a new one, if possible. */ + + if (!m_list) + { + eDebug("no channel list set!"); + return -ENOENT; + } + + ePtr feparm; + if (m_list->getChannelFrontendData(channelid, feparm)) + { + eDebug("channel not found!"); + return -ENOENT; + } + + /* allocate a frontend. */ ePtr fe; - if (allocateFrontend(channelid, fe)) + if (allocateFrontend(feparm, fe)) return errNoFrontend; // will be allocated on demand: @@ -312,12 +325,12 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse // // if (allocateDemux(*fe, demux)) // return errNoDemux; - + RESULT res; ePtr ch; ch = new eDVBChannel(this, fe); - res = ch->setChannel(channelid); + res = ch->setChannel(channelid, feparm); if (res) { channel = 0; @@ -331,8 +344,10 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse RESULT eDVBResourceManager::allocateRawChannel(eUsePtr &channel) { ePtr fe; - - if (allocateFrontend(eDVBChannelID(), fe)) + +#warning FIXME allocateRawChannel + +// if (allocateFrontend(eDVBChannelID(), fe)) return errNoFrontend; // ePtr demux; @@ -470,7 +485,7 @@ void eDVBChannel::ReleaseUse() } } -RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid) +RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid, ePtr &feparm) { if (m_channel_id) m_mgr->removeChannel(this); @@ -478,24 +493,6 @@ RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid) if (!channelid) return 0; - ePtr list; - - if (m_mgr->getChannelList(list)) - { - eDebug("no channel list set!"); - return -ENOENT; - } - - eDebug("tuning to chid: ns: %08x tsid %04x onid %04x", - channelid.dvbnamespace.get(), channelid.transport_stream_id.get(), channelid.original_network_id.get()); - - ePtr feparm; - if (list->getChannelFrontendData(channelid, feparm)) - { - eDebug("channel not found!"); - return -ENOENT; - } - if (!m_frontend) { eDebug("no frontend to tune!"); diff --git a/lib/dvb/dvb.h b/lib/dvb/dvb.h index b739f0ae..03702db2 100644 --- a/lib/dvb/dvb.h +++ b/lib/dvb/dvb.h @@ -114,7 +114,7 @@ class eDVBResourceManager: public iObject there might be a priority given to certain frontend/chid combinations. this will be evaluated here. */ - RESULT allocateFrontend(const eDVBChannelID &chid, ePtr &fe); + RESULT allocateFrontend(ePtr &feparm, ePtr &fe); /* allocate a demux able to filter on the selected frontend. */ RESULT allocateDemux(eDVBRegisteredFrontend *fe, ePtr &demux, int cap); @@ -178,7 +178,7 @@ public: /* only for managed channels - effectively tunes to the channelid. should not be used... */ /* cannot be used for PVR channels. */ - RESULT setChannel(const eDVBChannelID &id); + RESULT setChannel(const eDVBChannelID &id, ePtr &feparam); eDVBChannelID getChannelID() { return m_channel_id; } RESULT connectStateChange(const Slot1 &stateChange, ePtr &connection); diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 79b56e1e..2cb1c7d9 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -908,7 +908,16 @@ RESULT eDVBFrontend::setData(int num, int val) return -EINVAL; } -int eDVBFrontend::isCompatibleWith(const eDVBChannelID &chid) +int eDVBFrontend::isCompatibleWith(ePtr &feparm) { - return 1; + if (m_type != eDVBFrontend::feSatellite) + return 1; + + ASSERT(m_sec); + + eDVBFrontendParametersSatellite sat_parm; + + ASSERT(!feparm->getDVBS(sat_parm)); + + return m_sec->canTune(sat_parm, this, m_fe ? m_fe << 1 : 1); } diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index 764d6b3f..d3e257f1 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -91,7 +91,7 @@ public: RESULT getData(int num, int &data); RESULT setData(int num, int val); - int isCompatibleWith(const eDVBChannelID &chid); + int isCompatibleWith(ePtr &feparm); int getID() { return m_fe; } }; diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index ad5da21e..c57fae9a 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -346,13 +346,14 @@ public: virtual RESULT setData(int num, int val)=0; /* 0 means: not compatible. other values are a priority. */ - virtual int isCompatibleWith(const eDVBChannelID &chid)=0; + virtual int isCompatibleWith(ePtr &feparm)=0; }; class iDVBSatelliteEquipmentControl: public iObject { public: virtual RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat)=0; + virtual int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *fe, int frontend_id)=0; }; struct eDVBCIRouting diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index e3fbf26f..aaf459fb 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -62,6 +62,40 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl() setToneMode(eDVBSatelliteSwitchParameters::HILO); } +int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int frontend_id ) +{ + int ret=0; + + for (int idx=0; idx <= m_lnbidx; ++idx ) + { + eDVBSatelliteLNBParameters &lnb_param = m_lnbs[idx]; + if ( lnb_param.tuner_mask & frontend_id ) // lnb for correct tuner? + { + eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters; + eDVBSatelliteRotorParameters &rotor_param = lnb_param.m_rotor_parameters; + + std::map::iterator sit = + lnb_param.m_satellites.find(sat.orbital_position); + if ( sit != lnb_param.m_satellites.end()) + { + int curRotorPos = -1; + fe->getData(6, curRotorPos); + + if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) // ROTOR + { + if ( curRotorPos == sat.orbital_position ) + ret=20; + else + ret=10; + } + else if (!ret) + ret=40; + } + } + } + return ret; +} + RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat) { for (int idx=0; idx <= m_lnbidx; ++idx ) diff --git a/lib/dvb/sec.h b/lib/dvb/sec.h index 68add398..901e4e2e 100644 --- a/lib/dvb/sec.h +++ b/lib/dvb/sec.h @@ -214,6 +214,7 @@ public: DECLARE_REF(eDVBSatelliteEquipmentControl); eDVBSatelliteEquipmentControl(); RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat); + int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id); bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); } #endif static eDVBSatelliteEquipmentControl *getInstance() { return instance; } -- 2.30.2