remove fake answer
[enigma2.git] / lib / dvb_ci / dvbci.cpp
index 8f1fcac92c6ad7f1aef3cc8179ef36a747deea5c..9a551df0e5ddfa81ab16e59ba7d083cb3b33c106 100644 (file)
@@ -72,17 +72,48 @@ int eDVBCIInterfaces::reset(int slotid)
 
        if( (slot = getSlot(slotid)) == 0 )
                return -1;
-       
+
        return slot->reset();
 }
 
+int eDVBCIInterfaces::enableTS(int slotid, int enable)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+
+       if (enable)
+       {
+               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
+                       ++it;
+               }
+       }
+
+       return slot->enableTS(enable);
+}
+
 int eDVBCIInterfaces::initialize(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
+               ++it;
+       }
+
        return slot->initialize();
 }
 
@@ -253,6 +284,7 @@ void eDVBCISlot::data(int what)
        if(what == eSocketNotifier::Priority) {
                if(state != stateRemoved) {
                        state = stateRemoved;
+                       enableTS(0);
                        printf("ci removed\n");
                        notifier->setRequested(eSocketNotifier::Read);
                        //HACK
@@ -327,6 +359,7 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
 
 eDVBCISlot::~eDVBCISlot()
 {
+       enableTS(0);
 }
 
 int eDVBCISlot::getSlotID()
@@ -338,6 +371,8 @@ int eDVBCISlot::reset()
 {
        printf("edvbcislot: reset requested\n");
 
+       enableTS(0);
+
        ioctl(fd, 0);
 
        return 0;
@@ -405,6 +440,11 @@ int eDVBCISlot::cancelEnq()
 
 int eDVBCISlot::sendCAPMT(eDVBServicePMTHandler *pmthandler, const std::vector<uint16_t> &ids)
 {
+       if (!ca_manager)
+       {
+               eDebug("no ca_manager (no CI plugged?)");
+               return -1;
+       }
        const std::vector<uint16_t> &caids = ids.empty() && ca_manager ? ca_manager->getCAIDs() : ids;
        ePtr<eTable<ProgramMapSection> > ptr;
        if (pmthandler->getPMT(ptr))
@@ -453,23 +493,35 @@ int eDVBCISlot::sendCAPMT(eDVBServicePMTHandler *pmthandler, const std::vector<u
                                hlen = 4;
                        }
 // end calc capmt length
-                       if (!ca_manager)
-                               eDebug("no ca_manager !!! dump unfiltered capmt:");
-                       else
-                               eDebug("ca_manager %p dump capmt:", ca_manager);
+                       eDebug("ca_manager %p dump capmt:", ca_manager);
                        for(int i=0;i<wp;i++)
                                eDebugNoNewLine("%02x ", raw_data[i]);
                        eDebug("");
 #endif
-                       if (ca_manager)
-                       {
-                               //dont need tag and lenfield
-                               ca_manager->sendCAPMT(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;
                }
        }
        
 }
 
+int eDVBCISlot::enableTS(int enable)
+{
+       printf("eDVBCISlot::enableTS(%d)\n", enable);
+
+       FILE *f;
+       if((f = fopen("/proc/stb/tsmux/input0", "wb")) == NULL) {
+               printf("cannot open /proc/stb/tsmux/input0\n");
+               return 0;
+       }
+
+       fprintf(f, "%s", enable?"CI":"A");
+
+       fclose(f);
+
+       return 0;
+}
+
+
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");