X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d58968e5ca43995658257b6e89f092c7572cde0a..a1595050bc43d70aa8df213c0c7ac8217d61b778:/lib/dvb/frontend.cpp diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 255efd08..af627e26 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -204,7 +204,8 @@ void eDVBFrontendParametersTerrestrial::set(const TerrestrialDeliverySystemDescr guard_interval, hierarchy, modulation); } -eDVBFrontendParameters::eDVBFrontendParameters(): m_type(-1) +eDVBFrontendParameters::eDVBFrontendParameters() + :m_type(-1), m_flags(0) { } @@ -586,6 +587,14 @@ eDVBFrontend::~eDVBFrontend() void eDVBFrontend::feEvent(int w) { + eDVBFrontend *sec_fe = this; + long tmp = m_data[LINKED_PREV_PTR]; + while (tmp != -1) + { + eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp; + sec_fe = linked_fe->m_frontend; + sec_fe->getData(LINKED_NEXT_PTR, tmp); + } while (1) { #if HAVE_DVB_API_VERSION < 3 @@ -623,18 +632,8 @@ void eDVBFrontend::feEvent(int w) state = stateTuning; else { - eDVBFrontend *sec_fe = this; - long tmp = m_data[LINKED_PREV_PTR]; - eDebug("stateLostLock"); state = stateLostLock; - - while (tmp != -1) - { - eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp; - sec_fe = linked_fe->m_frontend; - sec_fe->getData(LINKED_NEXT_PTR, tmp); - } sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = -1; // reset diseqc } } @@ -656,6 +655,8 @@ void eDVBFrontend::timeout() } } +#define INRANGE(X,Y,Z) (((X<=Y) && (Y<=Z))||((Z<=Y) && (Y<=X)) ? 1 : 0) + int eDVBFrontend::readFrontendData(int type) { switch(type) @@ -712,6 +713,50 @@ int eDVBFrontend::readFrontendData(int type) return (int)(snr_in_db * 100.0); } + else if (strstr(m_description, "Alps BSBE1 C01A") || + !strcmp(m_description, "Alps -S(STV0288)")) + { + if (snr == 0) + return 0; + else if (snr == 0xFFFF) // i think this should not happen + return 100*100; + else + { + enum { REALVAL, REGVAL }; + const long CN_lookup[31][2] = { + {20,8900}, {25,8680}, {30,8420}, {35,8217}, {40,7897}, + {50,7333}, {60,6747}, {70,6162}, {80,5580}, {90,5029}, + {100,4529}, {110,4080}, {120,3685}, {130,3316}, {140,2982}, + {150,2688}, {160,2418}, {170,2188}, {180,1982}, {190,1802}, + {200,1663}, {210,1520}, {220,1400}, {230,1295}, {240,1201}, + {250,1123}, {260,1058}, {270,1004}, {280,957}, {290,920}, + {300,890} + }; + int add=strchr(m_description, '.') ? 0xA250 : 0xA100; + long regval = 0xFFFF - ((snr / 3) + add), // revert some dvb api calulations to get the real register value + Imin=0, + Imax=30, + i; + if(INRANGE(CN_lookup[Imin][REGVAL],regval,CN_lookup[Imax][REGVAL])) + { + long val; + while((Imax-Imin)>1) + { + i=(Imax+Imin)/2; + if(INRANGE(CN_lookup[Imin][REGVAL],regval,CN_lookup[i][REGVAL])) + Imax = i; + else + Imin = i; + } + return (((regval - CN_lookup[Imin][REGVAL]) + * (CN_lookup[Imax][REALVAL] - CN_lookup[Imin][REALVAL]) + / (CN_lookup[Imax][REGVAL] - CN_lookup[Imin][REGVAL])) + + CN_lookup[Imin][REALVAL]) * 10; + } + return 100; + } + return 0; + } else if (!strcmp(m_description, "Alps BSBE1 702A") || // some frontends with STV0299 !strcmp(m_description, "Alps -S") || !strcmp(m_description, "Philips -S") || @@ -1412,7 +1457,6 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer if (!m_timeoutCount) { eDebug("[SEC] rotor timout"); - m_sec->setRotorMoving(false); setSecSequencePos(m_sec_sequence.current()->steps); } else @@ -1450,25 +1494,42 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer } case eSecCommand::IF_TUNER_LOCKED_GOTO: { + int signal = 0; + int isLocked = readFrontendData(locked); + m_idleInputpower[0] = m_idleInputpower[1] = 0; eSecCommand::rotor &cmd = m_sec_sequence.current()->measure; - if (readFrontendData(locked)) + if (isLocked && ((abs((signal = readFrontendData(signalQualitydB)) - cmd.lastSignal) < 50) || !cmd.lastSignal)) { - eDebug("[SEC] locked step %d ok", cmd.okcount); + if (cmd.lastSignal) + eDebug("[SEC] locked step %d ok (%d %d)", cmd.okcount, signal, cmd.lastSignal); + else + { + eDebug("[SEC] locked step %d ok", cmd.okcount); + cmd.lastSignal = signal; + } ++cmd.okcount; - if (cmd.okcount > 12) + if (cmd.okcount > 4) { - eDebug("ok > 12 .. goto %d\n",m_sec_sequence.current()->steps); + eDebug("ok > 4 .. goto %d\n",cmd.steps); setSecSequencePos(cmd.steps); + m_state = stateLock; + m_stateChanged(this); + feEvent(-1); + m_sn->start(); break; } } else { - eDebug("[SEC] rotor locked step %d failed", cmd.okcount); + if (isLocked) + eDebug("[SEC] rotor locked step %d failed (oldSignal %d, curSignal %d)", cmd.okcount, signal, cmd.lastSignal); + else + eDebug("[SEC] rotor locked step %d failed (not locked)", cmd.okcount); --m_timeoutCount; if (!m_timeoutCount && m_retryCount > 0) --m_retryCount; cmd.okcount=0; + cmd.lastSignal=0; } ++m_sec_sequence.current(); break; @@ -1478,6 +1539,14 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer eDebug("[SEC] runningInputpower is %d", m_runningInputpower); ++m_sec_sequence.current(); break; + case eSecCommand::SET_ROTOR_MOVING: + m_sec->setRotorMoving(true); + ++m_sec_sequence.current(); + break; + case eSecCommand::SET_ROTOR_STOPPED: + m_sec->setRotorMoving(false); + ++m_sec_sequence.current(); + break; case eSecCommand::IF_INPUTPOWER_DELTA_GOTO: { int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1]; @@ -1495,7 +1564,6 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer eDebug("[SEC] rotor %s step %d ok", txt, cmd.okcount); if ( cmd.okcount > 6 ) { - m_sec->setRotorMoving(cmd.direction); eDebug("[SEC] rotor is %s", txt); if (setSecSequencePos(cmd.steps)) break; @@ -2283,13 +2351,14 @@ int eDVBFrontend::isCompatibleWith(ePtr &feparm) bool eDVBFrontend::setSlotInfo(ePyObject obj) { - ePyObject Id, Descr, Enabled; - if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3) + ePyObject Id, Descr, Enabled, IsDVBS2; + if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 4) goto arg_error; Id = PyTuple_GET_ITEM(obj, 0); Descr = PyTuple_GET_ITEM(obj, 1); Enabled = PyTuple_GET_ITEM(obj, 2); - if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled)) + IsDVBS2 = PyTuple_GET_ITEM(obj, 3); + if (!PyInt_Check(Id) || !PyString_Check(Descr) || !PyBool_Check(Enabled) || !PyBool_Check(IsDVBS2)) goto arg_error; strcpy(m_description, PyString_AS_STRING(Descr)); m_slotid = PyInt_AsLong(Id); @@ -2299,7 +2368,7 @@ bool eDVBFrontend::setSlotInfo(ePyObject obj) !!strstr(m_description, "Alps BSBE2") || !!strstr(m_description, "Alps -S") || !!strstr(m_description, "BCM4501"); - m_can_handle_dvbs2 = !!strstr(m_description, "Alps BSBE2") || !!strstr(m_description, "BCM4501"); + m_can_handle_dvbs2 = IsDVBS2 == Py_True; eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s, DVB-S2 %s", m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No", m_can_handle_dvbs2 ? "Yes" : "No" ); return true;