+ default:
+ break;
+ }
+ }
+}
+
+void eDVBFrontend::getFrontendData(ePyObject dest)
+{
+ if (dest && PyDict_Check(dest))
+ {
+ const char *tmp=0;
+ PutToDict(dest, "tuner_number", m_dvbid);
+ switch(m_type)
+ {
+ case feSatellite:
+ tmp = "DVB-S";
+ break;
+ case feCable:
+ tmp = "DVB-C";
+ break;
+ case feTerrestrial:
+ tmp = "DVB-T";
+ break;
+ default:
+ tmp = "UNKNOWN";
+ break;
+ }
+ PutToDict(dest, "tuner_type", tmp);
+ }
+}
+
+#ifndef FP_IOCTL_GET_ID
+#define FP_IOCTL_GET_ID 0
+#endif
+int eDVBFrontend::readInputpower()
+{
+ int power=m_slotid; // this is needed for read inputpower from the correct tuner !
+
+ // open front prozessor
+ int fp=::open("/dev/dbox/fp0", O_RDWR);
+ if (fp < 0)
+ {
+ eDebug("couldn't open fp");
+ return -1;
+ }
+ static bool old_fp = (::ioctl(fp, FP_IOCTL_GET_ID) < 0);
+ if ( ioctl( fp, old_fp ? 9 : 0x100, &power ) < 0 )
+ {
+ eDebug("FP_IOCTL_GET_LNB_CURRENT failed (%m)");
+ return -1;
+ }
+ ::close(fp);
+
+ return power;
+}
+
+bool eDVBFrontend::setSecSequencePos(int steps)
+{
+ eDebug("set sequence pos %d", steps);
+ if (!steps)
+ return false;
+ while( steps > 0 )
+ {
+ if (m_sec_sequence.current() != m_sec_sequence.end())
+ ++m_sec_sequence.current();
+ --steps;
+ }
+ while( steps < 0 )
+ {
+ if (m_sec_sequence.current() != m_sec_sequence.begin() && m_sec_sequence.current() != m_sec_sequence.end())
+ --m_sec_sequence.current();
+ ++steps;
+ }
+ return true;
+}
+
+void eDVBFrontend::setRotorData(int pos, int cmd)
+{
+ m_data[ROTOR_CMD] = cmd;
+ m_data[ROTOR_POS] = pos;
+ if ( m_data[SATPOS_DEPENDS_PTR] != -1 )
+ {
+ eDVBRegisteredFrontend *satpos_depends_to_fe = (eDVBRegisteredFrontend*) m_data[SATPOS_DEPENDS_PTR];
+ satpos_depends_to_fe->m_frontend->m_data[ROTOR_CMD] = cmd;
+ satpos_depends_to_fe->m_frontend->m_data[ROTOR_POS] = pos;
+ }
+ else
+ {
+ eDVBRegisteredFrontend *next = (eDVBRegisteredFrontend *)m_data[LINKED_NEXT_PTR];
+ while ( (int)next != -1 )
+ {
+ next->m_frontend->m_data[ROTOR_CMD] = cmd;
+ next->m_frontend->m_data[ROTOR_POS] = pos;
+ next = (eDVBRegisteredFrontend *)next->m_frontend->m_data[LINKED_NEXT_PTR];
+ }
+ eDVBRegisteredFrontend *prev = (eDVBRegisteredFrontend *)m_data[LINKED_PREV_PTR];
+ while ( (int)prev != -1 )
+ {
+ prev->m_frontend->m_data[ROTOR_CMD] = cmd;
+ prev->m_frontend->m_data[ROTOR_POS] = pos;
+ prev = (eDVBRegisteredFrontend *)prev->m_frontend->m_data[LINKED_PREV_PTR];
+ }
+ }
+}
+
+void eDVBFrontend::tuneLoop() // called by m_tuneTimer
+{
+ int delay=0;
+ if ( m_sec_sequence && m_sec_sequence.current() != m_sec_sequence.end() )
+ {
+// eDebug("tuneLoop %d\n", m_sec_sequence.current()->cmd);
+ switch (m_sec_sequence.current()->cmd)
+ {
+ case eSecCommand::SLEEP:
+ delay = m_sec_sequence.current()++->msec;
+ eDebug("[SEC] sleep %dms", delay);
+ break;
+ case eSecCommand::GOTO:
+ if ( !setSecSequencePos(m_sec_sequence.current()->steps) )
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::SET_VOLTAGE:
+ {
+ int voltage = m_sec_sequence.current()++->voltage;
+ eDebug("[SEC] setVoltage %d", voltage);
+ setVoltage(voltage);
+ break;
+ }
+ case eSecCommand::IF_VOLTAGE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.voltage == m_data[CUR_VOLTAGE] && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
+ case eSecCommand::IF_NOT_VOLTAGE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.voltage != m_data[CUR_VOLTAGE] && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
+ case eSecCommand::IF_TONE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.tone == m_data[CUR_TONE] && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
+ case eSecCommand::IF_NOT_TONE_GOTO:
+ {
+ eSecCommand::pair &compare = m_sec_sequence.current()->compare;
+ if ( compare.tone != m_data[CUR_TONE] && setSecSequencePos(compare.steps) )
+ break;
+ ++m_sec_sequence.current();
+ break;
+ }
+ case eSecCommand::SET_TONE:
+ eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone);
+ setTone(m_sec_sequence.current()++->tone);
+ break;
+ case eSecCommand::SEND_DISEQC:
+ 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]);
+ eDebug("");
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::SEND_TONEBURST:
+ eDebug("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
+ sendToneburst(m_sec_sequence.current()++->toneburst);
+ break;
+ case eSecCommand::SET_FRONTEND:
+ eDebug("[SEC] setFrontend");
+ setFrontend();
+ ++m_sec_sequence.current();
+ break;
+ case eSecCommand::START_TUNE_TIMEOUT:
+ m_timeout->start(5000, 1); // 5 sec timeout. TODO: symbolrate dependent