}
}
-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;
}
}
- /* 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:
//
// 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;
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;
}
}
-RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid)
+RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid, ePtr<iDVBFrontendParameters> &feparm)
{
if (m_channel_id)
m_mgr->removeChannel(this);
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!");
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);
/* 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);
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);
}
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; }
};
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
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 )
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; }