auto tuner selection is now working (this breaks allocateRawChannel..)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 16 Nov 2005 16:50:27 +0000 (16:50 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 16 Nov 2005 16:50:27 +0000 (16:50 +0000)
TODO: handling for linked tuners (loop through)

lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/idvb.h
lib/dvb/sec.cpp
lib/dvb/sec.h

index 89e2bdf..5ede1e3 100644 (file)
@@ -206,15 +206,15 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter)
        }
 }
 
-RESULT eDVBResourceManager::allocateFrontend(const eDVBChannelID &chid, ePtr<eDVBAllocatedFrontend> &fe)
+RESULT eDVBResourceManager::allocateFrontend(ePtr<iDVBFrontendParameters> &feparm, ePtr<eDVBAllocatedFrontend> &fe)
 {
        ePtr<eDVBRegisteredFrontend> best;
        int bestval = 0;
-       
+
        for (eSmartPtrList<eDVBRegisteredFrontend>::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<iDVBFrontendParameters> feparm;
+       if (m_list->getChannelFrontendData(channelid, feparm))
+       {
+               eDebug("channel not found!");
+               return -ENOENT;
+       }
+
+       /* allocate a frontend. */
        
        ePtr<eDVBAllocatedFrontend> 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<eDVBChannel> 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<iDVBChannel> &channel)
 {
        ePtr<eDVBAllocatedFrontend> fe;
-       
-       if (allocateFrontend(eDVBChannelID(), fe))
+
+#warning FIXME allocateRawChannel
+
+//     if (allocateFrontend(eDVBChannelID(), fe))
                return errNoFrontend;
        
 //     ePtr<eDVBAllocatedDemux> demux;
@@ -470,7 +485,7 @@ void eDVBChannel::ReleaseUse()
        }
 }
 
-RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid)
+RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid, ePtr<iDVBFrontendParameters> &feparm)
 {
        if (m_channel_id)
                m_mgr->removeChannel(this);
@@ -478,24 +493,6 @@ RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid)
        if (!channelid)
                return 0;
 
-       ePtr<iDVBChannelList> 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<iDVBFrontendParameters> feparm;
-       if (list->getChannelFrontendData(channelid, feparm))
-       {
-               eDebug("channel not found!");
-               return -ENOENT;
-       }
-       
        if (!m_frontend)
        {
                eDebug("no frontend to tune!");
index b739f0a..03702db 100644 (file)
@@ -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<eDVBAllocatedFrontend> &fe);
+       RESULT allocateFrontend(ePtr<iDVBFrontendParameters> &feparm, ePtr<eDVBAllocatedFrontend> &fe);
        
                        /* allocate a demux able to filter on the selected frontend. */
        RESULT allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBAllocatedDemux> &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<iDVBFrontendParameters> &feparam);
        eDVBChannelID getChannelID() { return m_channel_id; }
 
        RESULT connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection);
index 79b56e1..2cb1c7d 100644 (file)
@@ -908,7 +908,16 @@ RESULT eDVBFrontend::setData(int num, int val)
        return -EINVAL;
 }
 
-int eDVBFrontend::isCompatibleWith(const eDVBChannelID &chid)
+int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &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);
 }
index 764d6b3..d3e257f 100644 (file)
@@ -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<iDVBFrontendParameters> &feparm);
        
        int getID() { return m_fe; }
 };
index ad5da21..c57fae9 100644 (file)
@@ -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<iDVBFrontendParameters> &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
index e3fbf26..aaf459f 100644 (file)
@@ -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<int, eDVBSatelliteSwitchParameters>::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 )
index 68add39..901e4e2 100644 (file)
@@ -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; }