move dvb-t 5V antenna switching to better place
[enigma2.git] / lib / dvb / frontend.cpp
index e3bd5bc68b6d70b67c99d91316186f1861653340..352f3388ec66684aec4e485cf00f8a63dbcfaccf 100644 (file)
@@ -1,5 +1,6 @@
 #include <lib/dvb/dvb.h>
 #include <lib/base/eerror.h>
+#include <lib/base/nconfig.h> // access to python config
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -1680,6 +1681,12 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
 
        int res=0;
 
+       if (!m_sn)
+       {
+               eDebug("no frontend device opened... do not try to tune !!!");
+               return -ENODEV;
+       }
+
        if (m_type == -1)
                return -ENODEV;
 
@@ -1724,7 +1731,15 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
                res=prepare_terrestrial(feparm);
                if (!res)
                {
+                       std::string enable_5V;
+                       char configStr[255];
+                       snprintf(configStr, 255, "config.Nim%c.terrestrial_5V", 'A'+m_fe);
                        m_sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT) );
+                       ePythonConfigQuery::getConfigValue(configStr, enable_5V);
+                       if (enable_5V == "on")
+                               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) );
                }
                break;
@@ -1755,7 +1770,7 @@ RESULT eDVBFrontend::connectStateChange(const Slot1<void,iDVBFrontend*> &stateCh
 
 RESULT eDVBFrontend::setVoltage(int voltage)
 {
-       if (m_type != feSatellite)
+       if (m_type == feCable)
                return -1;
 #if HAVE_DVB_API_VERSION < 3
        secVoltage vlt;
@@ -1797,7 +1812,7 @@ RESULT eDVBFrontend::setVoltage(int voltage)
 #if HAVE_DVB_API_VERSION < 3
        return ::ioctl(m_secfd, SEC_SET_VOLTAGE, vlt);
 #else
-       if (::ioctl(m_fd, FE_ENABLE_HIGH_LNB_VOLTAGE, increased) < 0)
+       if (m_type == feSatellite && ::ioctl(m_fd, FE_ENABLE_HIGH_LNB_VOLTAGE, increased) < 0)
                perror("FE_ENABLE_HIGH_LNB_VOLTAGE");
        return ::ioctl(m_fd, FE_SET_VOLTAGE, vlt);
 #endif