X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/cb0260fc843d3d7386dd79ae977081d0ad082e04..d41938053190e075de41c63acfdcea3e239dcaba:/lib/dvb_ci/dvbci.cpp diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index a4bc4ff3..235b0ac3 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -72,7 +72,9 @@ int eDVBCIInterfaces::reset(int slotid) if( (slot = getSlot(slotid)) == 0 ) return -1; - + + eDVBCISession::deleteSessions(slot); + return slot->reset(); } @@ -82,8 +84,38 @@ int eDVBCIInterfaces::enableTS(int slotid, int enable) if( (slot = getSlot(slotid)) == 0 ) return -1; - - return slot->enableTS(enable); + + int tunernum = 0; + if (enable) + { + tunernum=-1; + PMTHandlerList::iterator it = m_pmt_handlers.begin(); + while (it != m_pmt_handlers.end()) + { + if ( it->cislot == slot ) + { + eDVBServicePMTHandler *pmthandler = it->pmthandler; + eUsePtr channel; + if (!pmthandler->getChannel(channel)) + { + ePtr frontend; + if (!channel->getFrontend(frontend)) + { + eDVBFrontend *fe = (eDVBFrontend*) &(*frontend); + tunernum = fe->getID(); + } + } + break; + } + ++it; + } + if ( tunernum == -1 ) + { + eFatal("couldn't find the correct tuner num in enableTS"); + return -1; + } + } + return slot->enableTS(enable, tunernum); } int eDVBCIInterfaces::initialize(int slotid) @@ -92,10 +124,44 @@ int eDVBCIInterfaces::initialize(int slotid) if( (slot = getSlot(slotid)) == 0 ) return -1; - + + slot->resetPrevSentCAPMTVersion(); + PMTHandlerList::iterator it = m_pmt_handlers.begin(); + while (it != m_pmt_handlers.end()) + { + if ( it->cislot == slot ) + { + slot->sendCAPMT(it->pmthandler); // send capmt + break; + } + ++it; + } + return slot->initialize(); } +int eDVBCIInterfaces::sendCAPMT(int slotid) +{ + eDVBCISlot *slot; + + if( (slot = getSlot(slotid)) == 0 ) + return -1; + + slot->resetPrevSentCAPMTVersion(); + PMTHandlerList::iterator it = m_pmt_handlers.begin(); + while (it != m_pmt_handlers.end()) + { + if ( it->cislot == slot ) + { + slot->sendCAPMT(it->pmthandler); // send capmt + return 0; + } + ++it; + } + + return -1; +} + int eDVBCIInterfaces::startMMI(int slotid) { eDVBCISlot *slot; @@ -192,7 +258,7 @@ void eDVBCIInterfaces::removePMTHandler(eDVBServicePMTHandler *pmthandler) if (it != m_pmt_handlers.end()) { eDVBCISlot *slot = it->cislot; - eDVBServicePMTHandler *pmthandler = it->pmthandler; +// eDVBServicePMTHandler *pmthandler = it->pmthandler; m_pmt_handlers.erase(it); if (slot && !--slot->use_count) { @@ -265,6 +331,7 @@ void eDVBCISlot::data(int what) state = stateRemoved; enableTS(0); printf("ci removed\n"); + eDVBCISession::deleteSessions(this); notifier->setRequested(eSocketNotifier::Read); //HACK eDVBCI_UI::getInstance()->setState(0,0); @@ -341,6 +408,21 @@ eDVBCISlot::~eDVBCISlot() enableTS(0); } +void eDVBCISlot::setAppManager( eDVBCIApplicationManagerSession *session ) +{ + application_manager=session; +} + +void eDVBCISlot::setMMIManager( eDVBCIMMISession *session ) +{ + mmi_session = session; +} + +void eDVBCISlot::setCAManager( eDVBCICAManagerSession *session ) +{ + ca_manager = session; +} + int eDVBCISlot::getSlotID() { return slotid; @@ -419,7 +501,12 @@ int eDVBCISlot::cancelEnq() int eDVBCISlot::sendCAPMT(eDVBServicePMTHandler *pmthandler, const std::vector &ids) { - const std::vector &caids = ids.empty() && ca_manager ? ca_manager->getCAIDs() : ids; + if (!ca_manager) + { + eDebug("no ca_manager (no CI plugged?)"); + return -1; + } + const std::vector &caids = ids.empty() ? ca_manager->getCAIDs() : ids; ePtr > ptr; if (pmthandler->getPMT(ptr)) return -1; @@ -467,41 +554,51 @@ int eDVBCISlot::sendCAPMT(eDVBServicePMTHandler *pmthandler, const std::vectorsendCAPMT(raw_data + hlen, wp - hlen); - prev_sent_capmt_version = pmt_version; - } + //dont need tag and lenfield + ca_manager->sendCAPMT(raw_data + hlen, wp - hlen); + prev_sent_capmt_version = pmt_version; } } - + return 0; } -int eDVBCISlot::enableTS(int enable) +int eDVBCISlot::enableTS(int enable, int tuner) { - printf("eDVBCISlot::enableTS(%d)\n", enable); + printf("eDVBCISlot::enableTS(%d %d)\n", enable, tuner); - FILE *f; - if((f = fopen("/proc/stb/tsmux/input0", "wb")) == NULL) { - printf("cannot open /proc/stb/audio/j1_mute\n"); - return; + FILE *input0, *input1, *ci; + if((input0 = fopen("/proc/stb/tsmux/input0", "wb")) == NULL) { + printf("cannot open /proc/stb/tsmux/input0\n"); + return 0; + } + if((input1 = fopen("/proc/stb/tsmux/input1", "wb")) == NULL) { + printf("cannot open /proc/stb/tsmux/input1\n"); + return 0; + } + if((ci = fopen("/proc/stb/tsmux/input2", "wb")) == NULL) { + printf("cannot open /proc/stb/tsmux/input2\n"); + return 0; } - fprintf(f, "%s", enable?"CI":"A"); + fprintf(ci, "%s", tuner==0 ? "A" : "B"); // configure CI data source (TunerA, TunerB) + fprintf(input0, "%s", tuner==0 && enable ? "CI" : "A"); // configure ATI input 0 data source + fprintf(input1, "%s", tuner==1 && enable ? "CI" : "B"); // configure ATI input 1 data source - fclose(f); + fclose(input0); + fclose(input1); + fclose(ci); return 0; } +void eDVBCISlot::resendCAPMT() +{ + eDVBCIInterfaces::getInstance()->sendCAPMT(slotid); +} eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");