terrestrial.code_rate_HP != eDVBFrontendParametersTerrestrial::FEC_Auto)
diff = 1 << 30;
else
- diff = abs(terrestrial.frequency - oterrestrial.frequency);
+ diff = abs(terrestrial.frequency - oterrestrial.frequency) / 1000;
return 0;
default:
return -1;
return 0;
case iDVBFrontend::feTerrestrial:
hash = 0xEEEE0000;
- hash |= (terrestrial.frequency/1000)&0xFFFF;
+ hash |= (terrestrial.frequency/1000000)&0xFFFF;
return 0;
default:
return -1;
eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate)
:m_simulate(simulate), m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
,m_fd(-1), m_need_rotor_workaround(false), m_can_handle_dvbs2(false)
- , m_timeout(0), m_tuneTimer(0)
+ ,m_state(stateClosed), m_timeout(0), m_tuneTimer(0)
#if HAVE_DVB_API_VERSION < 3
,m_secfd(-1)
#endif
int eDVBFrontend::openFrontend()
{
- if (m_sn)
+ if (m_state != stateClosed)
return -1; // already opened
m_state=stateIdle;
if (res && (errno == EAGAIN))
break;
- if (res)
- {
- eWarning("FE_GET_EVENT failed! %m");
- return;
- }
-
if (w < 0)
continue;
if (snr != 0)
ret = 10 * (int)(-100 * (log10(snr) - log10(255)));
}
+ else if (!strcmp(m_description, "BCM4506"))
+ ret = (snr * 100) >> 8;
if (type == signalQuality)
{
state = sec_fe->m_state;
}
// sec_fe is closed... we must reopen it here..
- if (state == eDVBFrontend::stateClosed)
+ if (state == stateClosed)
{
regFE = prev;
prev->inc_use();
sec_fe->sendToneburst(m_sec_sequence.current()++->toneburst);
break;
case eSecCommand::SET_FRONTEND:
- eDebugNoSimulate("[SEC] setFrontend");
- setFrontend();
- ++m_sec_sequence.current();
+ {
+ int enableEvents = (m_sec_sequence.current()++)->val;
+ eDebugNoSimulate("[SEC] setFrontend %d", enableEvents);
+ setFrontend(enableEvents);
break;
+ }
case eSecCommand::START_TUNE_TIMEOUT:
{
+ int tuneTimeout = m_sec_sequence.current()->timeout;
+ eDebugNoSimulate("[SEC] startTuneTimeout %d", tuneTimeout);
if (!m_simulate)
- m_timeout->start(m_sec_sequence.current()->timeout, 1);
+ m_timeout->start(tuneTimeout, 1);
++m_sec_sequence.current();
break;
}
int signal = 0;
int isLocked = readFrontendData(locked);
m_idleInputpower[0] = m_idleInputpower[1] = 0;
- if (isLocked && ((abs((signal = readFrontendData(signalQualitydB)) - cmd.lastSignal) < 50) || !cmd.lastSignal))
+ --m_timeoutCount;
+ if (!m_timeoutCount && m_retryCount > 0)
+ --m_retryCount;
+ if (isLocked && ((abs((signal = readFrontendData(signalQualitydB)) - cmd.lastSignal) < 40) || !cmd.lastSignal))
{
if (cmd.lastSignal)
eDebugNoSimulate("[SEC] locked step %d ok (%d %d)", cmd.okcount, signal, cmd.lastSignal);
else
{
eDebugNoSimulate("[SEC] locked step %d ok", cmd.okcount);
- cmd.lastSignal = signal;
+ if (!cmd.okcount)
+ cmd.lastSignal = signal;
}
++cmd.okcount;
if (cmd.okcount > 4)
{
- eDebugNoSimulate("ok > 4 .. goto %d\n",cmd.steps);
+ eDebugNoSimulate("ok > 4 .. goto %d\n", cmd.steps);
setSecSequencePos(cmd.steps);
m_state = stateLock;
m_stateChanged(this);
- feEvent(-1);
+ feEvent(-1); // flush events
m_sn->start();
break;
}
eDebugNoSimulate("[SEC] rotor locked step %d failed (oldSignal %d, curSignal %d)", cmd.okcount, signal, cmd.lastSignal);
else
eDebugNoSimulate("[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;
}
}
int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1];
const char *txt = cmd.direction ? "running" : "stopped";
+ --m_timeoutCount;
+ if (!m_timeoutCount && m_retryCount > 0)
+ --m_retryCount;
eDebugNoSimulate("[SEC] waiting for rotor %s %d, idle %d, delta %d",
txt,
m_runningInputpower,
else
{
eDebugNoSimulate("[SEC] rotor not %s... reset counter.. increase timeout", txt);
- --m_timeoutCount;
- if (!m_timeoutCount && m_retryCount > 0)
- --m_retryCount;
cmd.okcount=0;
}
++m_sec_sequence.current();
tuneLoop();
}
-void eDVBFrontend::setFrontend()
+void eDVBFrontend::setFrontend(bool recvEvents)
{
if (!m_simulate)
{
eDebug("setting frontend %d", m_dvbid);
- m_sn->start();
- feEvent(-1);
+ if (recvEvents)
+ m_sn->start();
+ feEvent(-1); // flush events
if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
{
perror("FE_SET_FRONTEND failed");
goto tune_error;
m_sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, timeout) );
- m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+ m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
break;
}
case feTerrestrial:
m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
else
m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltageOff) );
- m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
+ m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
break;
}