From 0855ea4ed4197c0fc6a8f8fff5820741d80c6d41 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Sat, 19 Jul 2008 17:00:51 +0000 Subject: [PATCH] now link dvb-s frontends to dvb-s2 frontends is possible --- lib/dvb/frontend.cpp | 84 +++++++++++++++++++---------- lib/dvb/frontend.h | 2 +- lib/dvb/idvb.h | 2 +- lib/dvb/sec.cpp | 8 +-- lib/python/Components/NimManager.py | 12 ++--- 5 files changed, 67 insertions(+), 41 deletions(-) diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 47b86575..ca426a7f 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -452,7 +452,7 @@ int eDVBFrontend::openFrontend() if (m_sn) return -1; // already opened - m_state=0; + m_state=stateIdle; m_tuning=0; #if HAVE_DVB_API_VERSION < 3 @@ -524,25 +524,28 @@ int eDVBFrontend::openFrontend() setTone(iDVBFrontend::toneOff); setVoltage(iDVBFrontend::voltageOff); - m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read); + m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read, false); CONNECT(m_sn->activated, eDVBFrontend::feEvent); return 0; } -int eDVBFrontend::closeFrontend() +int eDVBFrontend::closeFrontend(bool force) { - long tmp = m_data[LINKED_NEXT_PTR]; - while (tmp != -1) + if (!force && m_data[CUR_VOLTAGE] != -1 && m_data[CUR_VOLTAGE] != iDVBFrontend::voltageOff) { - eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp; - if (linked_fe->m_inuse) + long tmp = m_data[LINKED_NEXT_PTR]; + while (tmp != -1) { - eDebug("dont close frontend %d until the linked frontend %d in slot %d is still in use", - m_dvbid, linked_fe->m_frontend->getDVBID(), linked_fe->m_frontend->getSlotID()); - return -1; + eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp; + if (linked_fe->m_inuse) + { + eDebug("dont close frontend %d until the linked frontend %d in slot %d is still in use", + m_dvbid, linked_fe->m_frontend->getDVBID(), linked_fe->m_frontend->getSlotID()); + return -1; + } + linked_fe->m_frontend->getData(LINKED_NEXT_PTR, tmp); } - linked_fe->m_frontend->getData(LINKED_NEXT_PTR, tmp); } if (m_fd >= 0) { @@ -569,6 +572,7 @@ int eDVBFrontend::closeFrontend() #endif delete m_sn; m_sn=0; + m_state = stateClosed; return 0; } @@ -1319,8 +1323,32 @@ void eDVBFrontend::setRotorData(int pos, int cmd) void eDVBFrontend::tuneLoop() // called by m_tuneTimer { int delay=0; + eDVBFrontend *fe = this; + eDVBRegisteredFrontend *regFE = 0; + long tmp = m_data[LINKED_PREV_PTR]; + while ( tmp != -1 ) + { + eDVBRegisteredFrontend *prev = (eDVBRegisteredFrontend *)tmp; + fe = prev->m_frontend; + tmp = prev->m_frontend->m_data[LINKED_PREV_PTR]; + if (tmp == -1 && fe != this && !prev->m_inuse) { + int state = fe->m_state; + if (state != eDVBFrontend::stateIdle && state != stateClosed) + { + fe->closeFrontend(true); + state = fe->m_state; + } + if (state == eDVBFrontend::stateClosed) + { + regFE = prev; + prev->inc_use(); + } + } + } + if ( m_sec_sequence && m_sec_sequence.current() != m_sec_sequence.end() ) { + long *m_data = fe->m_data; // eDebug("tuneLoop %d\n", m_sec_sequence.current()->cmd); switch (m_sec_sequence.current()->cmd) { @@ -1336,7 +1364,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer { int voltage = m_sec_sequence.current()++->voltage; eDebug("[SEC] setVoltage %d", voltage); - setVoltage(voltage); + fe->setVoltage(voltage); break; } case eSecCommand::IF_VOLTAGE_GOTO: @@ -1373,10 +1401,10 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer } case eSecCommand::SET_TONE: eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone); - setTone(m_sec_sequence.current()++->tone); + fe->setTone(m_sec_sequence.current()++->tone); break; case eSecCommand::SEND_DISEQC: - sendDiseqc(m_sec_sequence.current()->diseqc); + fe->sendDiseqc(m_sec_sequence.current()->diseqc); eDebugNoNewLine("[SEC] sendDiseqc: "); for (int i=0; i < m_sec_sequence.current()->diseqc.len; ++i) eDebugNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]); @@ -1385,7 +1413,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer break; case eSecCommand::SEND_TONEBURST: eDebug("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst); - sendToneburst(m_sec_sequence.current()++->toneburst); + fe->sendToneburst(m_sec_sequence.current()++->toneburst); break; case eSecCommand::SET_FRONTEND: eDebug("[SEC] setFrontend"); @@ -1417,7 +1445,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer int idx = m_sec_sequence.current()++->val; if ( idx == 0 || idx == 1 ) { - m_idleInputpower[idx] = readInputpower(); + m_idleInputpower[idx] = fe->readInputpower(); eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]); } else @@ -1430,7 +1458,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer int idx = compare.val; if ( idx == 0 || idx == 1 ) { - int idle = readInputpower(); + int idle = fe->readInputpower(); int diff = abs(idle-m_idleInputpower[idx]); if ( diff > 0) { @@ -1468,7 +1496,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer break; } case eSecCommand::MEASURE_RUNNING_INPUTPOWER: - m_runningInputpower = readInputpower(); + m_runningInputpower = fe->readInputpower(); eDebug("[SEC] runningInputpower is %d", m_runningInputpower); ++m_sec_sequence.current(); break; @@ -1514,11 +1542,11 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer break; case eSecCommand::INVALIDATE_CURRENT_ROTORPARMS: eDebug("[SEC] invalidate current rotorparams"); - setRotorData(-1,-1); + fe->setRotorData(-1,-1); ++m_sec_sequence.current(); break; case eSecCommand::UPDATE_CURRENT_ROTORPARAMS: - setRotorData(m_data[NEW_ROTOR_POS], m_data[NEW_ROTOR_CMD]); + fe->setRotorData(m_data[NEW_ROTOR_POS], m_data[NEW_ROTOR_CMD]); eDebug("[SEC] update current rotorparams %d %04lx %ld", m_timeoutCount, m_data[ROTOR_CMD], m_data[ROTOR_POS]); ++m_sec_sequence.current(); break; @@ -1538,7 +1566,7 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer case eSecCommand::SET_POWER_LIMITING_MODE: { char proc_name[64]; - sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", m_dvbid); + sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", fe->m_dvbid); FILE *f=fopen(proc_name, "w"); if (f) // new interface exist? { @@ -1549,16 +1577,16 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer eDebug("[SEC] set %s current limiting", slimiting ? "static" : "dynamic"); fclose(f); } - else if (m_need_rotor_workaround) + else if (fe->m_need_rotor_workaround) { char dev[16]; - + int slotid = fe->m_slotid; // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000 - if (m_slotid < 2) - sprintf(dev, "/dev/i2c/%d", m_slotid); - else if (m_slotid == 2) + if (slotid < 2) + sprintf(dev, "/dev/i2c/%d", slotid); + else if (slotid == 2) sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2 - else if (m_slotid == 3) + else if (slotid == 3) sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4 int fd = ::open(dev, O_RDWR); @@ -1590,6 +1618,8 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer } m_tuneTimer->start(delay,true); } + if (regFE) + regFE->dec_use(); } void eDVBFrontend::setFrontend() diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index 9d9aab71..111e715d 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -133,7 +133,7 @@ public: static int getTypePriorityOrder() { return PriorityOrder; } int openFrontend(); - int closeFrontend(); + int closeFrontend(bool force=false); const char *getDescription() const { return m_description; } }; diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index 11bbbf8e..2aee67e6 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -443,7 +443,7 @@ class iDVBFrontend_ENUMS #endif public: enum { feSatellite, feCable, feTerrestrial }; - enum { stateIdle, stateTuning, stateFailed, stateLock, stateLostLock }; + enum { stateIdle, stateTuning, stateFailed, stateLock, stateLostLock, stateClosed }; enum { toneOff, toneOn }; enum { voltageOff, voltage13, voltage18, voltage13_5, voltage18_5 }; enum { bitErrorRate, signalPower, signalQuality, locked, synced, frontendNumber, signalQualitydB }; diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index 0f43d77f..8a186014 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -296,7 +296,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA { eDVBSatelliteSwitchParameters &sw_param = sit->second; bool doSetFrontend = true; - bool doSetVoltageToneFrontend = m_not_linked_slot_mask & slot_id; + bool doSetVoltageToneFrontend = true; bool allowDiseqc1_2 = true; long band=0, voltage = iDVBFrontend::voltageOff, @@ -318,11 +318,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA frontend.getData(eDVBFrontend::ROTOR_POS, curRotorPos); frontend.getData(eDVBFrontend::SATPOS_DEPENDS_PTR, satposDependPtr); - if (satposDependPtr != -1 && !doSetVoltageToneFrontend) - { + if (satposDependPtr != -1 && !(m_not_linked_slot_mask & slot_id)) allowDiseqc1_2 = false; - doSetVoltageToneFrontend = true; - } if ( sat.frequency > lnb_param.m_lof_threshold ) band |= 1; @@ -428,7 +425,6 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA eDebugNoNewLine("0"); eDebug(""); #endif - if (doSetVoltageToneFrontend) { int RotorCmd=-1; diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 350a6b14..c5a294ed 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -227,9 +227,11 @@ class SecConfigure: tunermask = 1 << slotid if self.equal.has_key(slotid): - tunermask |= (1 << self.equal[slotid]) + for slot in self.equal[slotid]: + tunermask |= (1 << slot) elif self.linked.has_key(slotid): - tunermask |= (1 << self.linked[slotid]) + for slot in self.linked[slotid]: + tunermask |= (1 << slot) if currLnb.lof.value == "universal_lnb": sec.setLNBLOFL(9750000) @@ -625,10 +627,8 @@ class NimManager: slots.append(self.nim_slots[slotid].internallyConnectableTo()) for type in self.nim_slots[slotid].connectableTo(): for slot in self.getNimListOfType(type, exception = slotid): - # FIXME we restrict loopthrough from dvb-s2 to dvb-s, because the c++ part can't handle it - if not (type == "DVB-S" and self.getNimType(slot)): - if self.hasOutputs(slot): - slots.append(slot) + if self.hasOutputs(slot): + slots.append(slot) # remove nims, that have a conntectedTo reference on for testnim in slots[:]: for nim in self.getNimListOfType("DVB-S", slotid): -- 2.30.2