From: Ronny Strutz Date: Fri, 18 Nov 2005 01:23:10 +0000 (+0000) Subject: add stuff to find a slot and call stuff from there X-Git-Tag: 2.6.0~5092 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/ed8f9a4e13e4d4eafbc26048d7b70d3aaa8d1399 add stuff to find a slot and call stuff from there --- diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index 014d51a5..bbea1211 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -1,7 +1,9 @@ #include +#include #include #include +#include #include #include @@ -9,10 +11,14 @@ #include +eDVBCIInterfaces *eDVBCIInterfaces::instance = 0; + eDVBCIInterfaces::eDVBCIInterfaces() { int num_ci = 0; + instance = this; + eDebug("scanning for common interfaces.."); while (1) @@ -39,6 +45,32 @@ eDVBCIInterfaces::~eDVBCIInterfaces() { } +eDVBCIInterfaces *eDVBCIInterfaces::getInstance() +{ + return instance; +} + +eDVBCISlot *eDVBCIInterfaces::getSlot(int slotid) +{ + for(eSmartPtrList::iterator i(m_slots.begin()); i != m_slots.end(); ++i) + if(i->getSlotID() == slotid) + return i; + + return 0; +} + +int eDVBCIInterfaces::reset(int slotid) +{ + eDVBCISlot *slot; + + if( (slot = getSlot(slotid)) == 0 ) { + printf("FIXME: request for unknown slot\n"); + return 0; + } + + return slot->reset(); +} + int eDVBCISlot::send(const unsigned char *data, size_t len) { int res; @@ -109,6 +141,8 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) { char filename[128]; + slotid = nr; + sprintf(filename, "/dev/ci%d", nr); fd = ::open(filename, O_RDWR | O_NONBLOCK); @@ -131,4 +165,18 @@ eDVBCISlot::~eDVBCISlot() { } +int eDVBCISlot::getSlotID() +{ + return slotid; +} + +int eDVBCISlot::reset() +{ + printf("edvbcislot: reset requested\n"); + + ioctl(fd, 0); + + return 0; +} + eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots"); diff --git a/lib/dvb_ci/dvbci.h b/lib/dvb_ci/dvbci.h index eb4b6b04..43952c2f 100644 --- a/lib/dvb_ci/dvbci.h +++ b/lib/dvb_ci/dvbci.h @@ -11,6 +11,7 @@ class eDVBCISlot: public iObject, public Object { DECLARE_REF(eDVBCISlot); private: + int slotid; int fd; void data(int); eSocketNotifier *notifier; @@ -25,16 +26,25 @@ public: eDVBCIApplicationManagerSession *application_manager; eDVBCICAManagerSession *ca_manager; + + int getSlotID(); + int reset(); }; class eDVBCIInterfaces { DECLARE_REF(eDVBCIInterfaces); + static eDVBCIInterfaces *instance; private: eSmartPtrList m_slots; + eDVBCISlot *getSlot(int slotid); public: eDVBCIInterfaces(); ~eDVBCIInterfaces(); + + static eDVBCIInterfaces *getInstance(); + + int reset(int slot); }; #endif