fix bug described here -> http://www.dream-multimedia-tv.de/board/thread.php?threadid...
[enigma2.git] / lib / dvb / frontend.cpp
index c4d641226e79b7b58adf796e1ea6a1e0d3597a61..8b21413025b512c905595737de6a38df8f7f9b95 100644 (file)
@@ -383,7 +383,8 @@ RESULT eDVBFrontendParameters::getHash(unsigned long &hash) const
 DEFINE_REF(eDVBFrontend);
 
 eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
-       :m_type(-1), m_fe(fe), m_fd(-1), m_sn(0), m_timeout(0), m_tuneTimer(0)
+       :m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
+       ,m_fd(-1), m_need_rotor_workaround(false), m_sn(0), m_timeout(0), m_tuneTimer(0)
 #if HAVE_DVB_API_VERSION < 3
        ,m_secfd(-1)
 #endif
@@ -418,37 +419,22 @@ int eDVBFrontend::openFrontend()
        m_tuning=0;
 
 #if HAVE_DVB_API_VERSION < 3
-       if (m_secfd < 0)
-       {
-               m_secfd = ::open(m_sec_filename, O_RDWR);
-               if (m_secfd < 0)
-               {
-                       eWarning("failed! (%s) %m", m_sec_filename);
-                       return -1;
-               }
-       }
-       else
-               eWarning("sec %d already opened", m_fe);
        FrontendInfo fe_info;
 #else
        dvb_frontend_info fe_info;
 #endif
-       eDebug("opening frontend %d", m_fe);
+       eDebug("opening frontend %d", m_dvbid);
        if (m_fd < 0)
        {
                m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
                if (m_fd < 0)
                {
                        eWarning("failed! (%s) %m", m_filename);
-#if HAVE_DVB_API_VERSION < 3
-                       ::close(m_secfd);
-                       m_secfd=-1;
-#endif
                        return -1;
                }
        }
        else
-               eWarning("frontend %d already opened", m_fe);
+               eWarning("frontend %d already opened", m_dvbid);
        if (m_type == -1)
        {
                if (::ioctl(m_fd, FE_GET_INFO, &fe_info) < 0)
@@ -456,10 +442,6 @@ int eDVBFrontend::openFrontend()
                        eWarning("ioctl FE_GET_INFO failed");
                        ::close(m_fd);
                        m_fd = -1;
-#if HAVE_DVB_API_VERSION < 3
-                       ::close(m_secfd);
-                       m_secfd=-1;
-#endif
                        return -1;
                }
 
@@ -478,15 +460,30 @@ int eDVBFrontend::openFrontend()
                        eWarning("unknown frontend type.");
                        ::close(m_fd);
                        m_fd = -1;
-#if HAVE_DVB_API_VERSION < 3
-                       ::close(m_secfd);
-                       m_secfd=-1;
-#endif
                        return -1;
                }
                eDebug("detected %s frontend", "satellite\0cable\0    terrestrial"+fe_info.type*10);
        }
 
+#if HAVE_DVB_API_VERSION < 3
+       if (m_type == iDVBFrontend::feSatellite)
+       {
+                       if (m_secfd < 0)
+                       {
+                               m_secfd = ::open(m_sec_filename, O_RDWR);
+                               if (m_secfd < 0)
+                               {
+                                       eWarning("failed! (%s) %m", m_sec_filename);
+                                       ::close(m_fd);
+                                       m_fd=-1;
+                                       return -1;
+                               }
+                       }
+                       else
+                               eWarning("sec %d already opened", m_dvbid);
+       }
+#endif
+
        setTone(iDVBFrontend::toneOff);
        setVoltage(iDVBFrontend::voltageOff);
 
@@ -503,15 +500,15 @@ int eDVBFrontend::closeFrontend()
        {
                if (linked_fe->m_inuse)
                {
-                       eDebug("dont close frontend %d until the linked frontend %d is still in use",
-                               m_fe, linked_fe->m_frontend->getID());
+                       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, (int&)linked_fe);
        }
        if (m_fd >= 0)
        {
-               eDebug("close frontend %d", m_fe);
+               eDebug("close frontend %d", m_dvbid);
                m_tuneTimer->stop();
                setTone(iDVBFrontend::toneOff);
                setVoltage(iDVBFrontend::voltageOff);
@@ -520,7 +517,7 @@ int eDVBFrontend::closeFrontend()
                if (!::close(m_fd))
                        m_fd=-1;
                else
-                       eWarning("couldnt close frontend %d", m_fe);
+                       eWarning("couldnt close frontend %d", m_dvbid);
                m_data[CSW] = m_data[UCSW] = m_data[TONEBURST] = -1;
        }
 #if HAVE_DVB_API_VERSION < 3
@@ -529,7 +526,7 @@ int eDVBFrontend::closeFrontend()
                if (!::close(m_secfd))
                        m_secfd=-1;
                else
-                       eWarning("couldnt close sec %d", m_fe);
+                       eWarning("couldnt close sec %d", m_dvbid);
        }
 #endif
        delete m_sn;
@@ -573,7 +570,7 @@ void eDVBFrontend::feEvent(int w)
 #if HAVE_DVB_API_VERSION < 3
                if (event.type == FE_COMPLETION_EV)
 #else
-               eDebug("(%d)fe event: status %x, inversion %s", m_fe, event.status, (event.parameters.inversion == INVERSION_ON) ? "on" : "off");
+               eDebug("(%d)fe event: status %x, inversion %s", m_dvbid, event.status, (event.parameters.inversion == INVERSION_ON) ? "on" : "off");
                if (event.status & FE_HAS_LOCK)
 #endif
                {
@@ -625,6 +622,56 @@ int eDVBFrontend::readFrontendData(int type)
                                eDebug("FE_READ_SNR failed (%m)");
                        return snr;
                }
+               case signalPowerdB: /* this will move into the driver */
+               {
+                       uint16_t snr=0;
+                       if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
+                               eDebug("FE_READ_SNR failed (%m)");
+                       if (!strcmp(m_description, "BCM4501 (internal)"))
+                       {
+                               unsigned int SDS_SNRE = snr << 16;
+
+                               static float SNR_COEFF[6] = {
+                                       100.0 / 4194304.0,
+                                       -7136.0 / 4194304.0,
+                                       197418.0 / 4194304.0,
+                                       -2602183.0 / 4194304.0,
+                                       20377212.0 / 4194304.0,
+                                       -37791203.0 / 4194304.0,
+                               };
+                       
+                               float fval1, fval2, snr_in_db;
+                               int i;
+                               fval1 = 12.44714 - (2.0 * log10(SDS_SNRE / 256.0));
+                               fval2 = pow(10.0, fval1)-1;
+                               fval1 = 10.0 * log10(fval2);
+                       
+                               if (fval1 < 10.0)
+                               {
+                                       fval2 = SNR_COEFF[0];
+                                       for (i=0; i<6; ++i)
+                                       {
+                                               fval2 *= fval1;
+                                               fval2 += SNR_COEFF[i];
+                                       }
+                                       fval1 = fval2;
+                               }
+                               snr_in_db = fval1;
+                       
+                               return (int)(snr_in_db * 100.0);
+                       }
+                       else if (!strcmp(m_description, "Alps BSBE1 702A") ||  // some frontends with STV0299
+                               !strcmp(m_description, "Alps -S") ||
+                               !strcmp(m_description, "Philips -S") ||
+                               !strcmp(m_description, "LG -S") )
+                       {
+                               float snr_in_db=(snr-39075)/1764.7;
+                               return (int)(snr_in_db * 100.0);
+                       }
+                       else
+                               eDebug("no SNR dB caluclation for frontendtype %s yet", m_description);
+                       return 0x12345678;
+               }
                case signalQuality:
                {
                        uint16_t strength=0;
@@ -655,7 +702,7 @@ int eDVBFrontend::readFrontendData(int type)
                        return !!(status&FE_HAS_SYNC);
                }
                case frontendNumber:
-                       return m_fe;
+                       return m_slotid;
        }
        return 0;
 }
@@ -673,6 +720,18 @@ void PutToDict(ePyObject &dict, const char*key, long value)
                eDebug("could not create PyObject for %s", key);
 }
 
+void PutToDict(ePyObject &dict, const char*key, ePyObject item)
+{
+       if (item)
+       {
+               if (PyDict_SetItemString(dict, key, item))
+                       eDebug("put %s to dict failed", key);
+               Py_DECREF(item);
+       }
+       else
+               eDebug("invalid PyObject for %s", key);
+}
+
 void PutToDict(ePyObject &dict, const char*key, const char *value)
 {
        ePyObject item = PyString_FromString(value);
@@ -971,17 +1030,106 @@ void fillDictWithTerrestrialData(ePyObject dict, const FRONTENDPARAMETERS &parm)
        PutToDict(dict, "hierarchy_information", tmp);
 }
 
-PyObject *eDVBFrontend::readTransponderData(bool original)
+void eDVBFrontend::getFrontendStatus(ePyObject dest)
 {
-       ePyObject ret=PyDict_New();
+       if (dest && PyDict_Check(dest))
+       {
+               const char *tmp = "UNKNOWN";
+               switch(m_state)
+               {
+                       case stateIdle:
+                               tmp="IDLE";
+                               break;
+                       case stateTuning:
+                               tmp="TUNING";
+                               break;
+                       case stateFailed:
+                               tmp="FAILED";
+                               break;
+                       case stateLock:
+                               tmp="LOCKED";
+                               break;
+                       case stateLostLock:
+                               tmp="LOSTLOCK";
+                               break;
+                       default:
+                               break;
+               }
+               PutToDict(dest, "tuner_state", tmp);
+               PutToDict(dest, "tuner_locked", readFrontendData(locked));
+               PutToDict(dest, "tuner_synced", readFrontendData(synced));
+               PutToDict(dest, "tuner_bit_error_rate", readFrontendData(bitErrorRate));
+               PutToDict(dest, "tuner_signal_power", readFrontendData(signalPower));
+               int sigPowerdB = readFrontendData(signalPowerdB);
+               if (sigPowerdB == 0x12345678) // not support yet
+               {
+                       ePyObject obj=Py_None;
+                       Py_INCREF(obj);
+                       PutToDict(dest, "tuner_signal_power_db", obj);
+               }
+               else
+                       PutToDict(dest, "tuner_signal_power_db", sigPowerdB);
+               PutToDict(dest, "tuner_signal_quality", readFrontendData(signalQuality));
+       }
+}
 
-       if (ret)
+void eDVBFrontend::getTransponderData(ePyObject dest, bool original)
+{
+       if (m_fd != -1 && dest && PyDict_Check(dest))
        {
-               bool read=m_fd != -1;
-               const char *tmp=0;
+               switch(m_type)
+               {
+                       case feSatellite:
+                       case feCable:
+                       case feTerrestrial:
+                       {
+                               FRONTENDPARAMETERS front;
+                               if (!original && ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
+                                       eDebug("FE_GET_FRONTEND (%m)");
+                               else
+                               {
+                                       const FRONTENDPARAMETERS &parm = original ? this->parm : front;
+                                       const char *tmp = "INVERSION_AUTO";
+                                       switch(parm_inversion)
+                                       {
+                                               case INVERSION_ON:
+                                                       tmp = "INVERSION_ON";
+                                                       break;
+                                               case INVERSION_OFF:
+                                                       tmp = "INVERSION_OFF";
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       if (tmp)
+                                               PutToDict(dest, "inversion", tmp);
 
-               PutToDict(ret, "tuner_number", m_fe);
+                                       switch(m_type)
+                                       {
+                                               case feSatellite:
+                                                       fillDictWithSatelliteData(dest, original?parm:front, this);
+                                                       break;
+                                               case feCable:
+                                                       fillDictWithCableData(dest, original?parm:front);
+                                                       break;
+                                               case feTerrestrial:
+                                                       fillDictWithTerrestrialData(dest, original?parm:front);
+                                                       break;
+                                       }
+                               }
+                       }
+                       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:
@@ -995,85 +1143,10 @@ PyObject *eDVBFrontend::readTransponderData(bool original)
                                break;
                        default:
                                tmp = "UNKNOWN";
-                               read=false;
                                break;
                }
-               PutToDict(ret, "tuner_type", tmp);
-
-               if (read)
-               {
-                       FRONTENDPARAMETERS front;
-
-                       tmp = "UNKNOWN";
-                       switch(m_state)
-                       {
-                               case stateIdle:
-                                       tmp="IDLE";
-                                       break;
-                               case stateTuning:
-                                       tmp="TUNING";
-                                       break;
-                               case stateFailed:
-                                       tmp="FAILED";
-                                       break;
-                               case stateLock:
-                                       tmp="LOCKED";
-                                       break;
-                               case stateLostLock:
-                                       tmp="LOSTLOCK";
-                                       break;
-                               default:
-                                       break;
-                       }
-                       PutToDict(ret, "tuner_state", tmp);
-
-                       PutToDict(ret, "tuner_locked", readFrontendData(locked));
-                       PutToDict(ret, "tuner_synced", readFrontendData(synced));
-                       PutToDict(ret, "tuner_bit_error_rate", readFrontendData(bitErrorRate));
-                       PutToDict(ret, "tuner_signal_power", readFrontendData(signalPower));
-                       PutToDict(ret, "tuner_signal_quality", readFrontendData(signalQuality));
-
-                       if (!original && ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
-                               eDebug("FE_GET_FRONTEND (%m)");
-                       else
-                       {
-                               const FRONTENDPARAMETERS &parm = original ? this->parm : front;
-                               tmp = "INVERSION_AUTO";
-                               switch(parm_inversion)
-                               {
-                                       case INVERSION_ON:
-                                               tmp = "INVERSION_ON";
-                                               break;
-                                       case INVERSION_OFF:
-                                               tmp = "INVERSION_OFF";
-                                               break;
-                                       default:
-                                               break;
-                               }
-                               if (tmp)
-                                       PutToDict(ret, "inversion", tmp);
-
-                               switch(m_type)
-                               {
-                                       case feSatellite:
-                                               fillDictWithSatelliteData(ret, original?parm:front, this);
-                                               break;
-                                       case feCable:
-                                               fillDictWithCableData(ret, original?parm:front);
-                                               break;
-                                       case feTerrestrial:
-                                               fillDictWithTerrestrialData(ret, original?parm:front);
-                                               break;
-                               }
-                       }
-               }
-       }
-       else
-       {
-               Py_INCREF(Py_None);
-               ret = Py_None;
+               PutToDict(dest, "tuner_type", tmp);
        }
-       return ret;
 }
 
 #ifndef FP_IOCTL_GET_ID
@@ -1081,7 +1154,7 @@ PyObject *eDVBFrontend::readTransponderData(bool original)
 #endif
 int eDVBFrontend::readInputpower()
 {
-       int power=m_fe;  // this is needed for read inputpower from the correct tuner !
+       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);
@@ -1121,6 +1194,35 @@ bool eDVBFrontend::setSecSequencePos(int 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;
@@ -1147,7 +1249,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               if ( compare.voltage == m_curVoltage && setSecSequencePos(compare.steps) )
+                               if ( compare.voltage == m_data[CUR_VOLTAGE] && setSecSequencePos(compare.steps) )
                                        break;
                                ++m_sec_sequence.current();
                                break;
@@ -1155,7 +1257,23 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_NOT_VOLTAGE_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               if ( compare.voltage != m_curVoltage && setSecSequencePos(compare.steps) )
+                               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;
@@ -1214,7 +1332,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                        case eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO:
                        {
                                eSecCommand::pair &compare = m_sec_sequence.current()->compare;
-                               int idx = compare.voltage;
+                               int idx = compare.val;
                                if ( idx == 0 || idx == 1 )
                                {
                                        int idle = readInputpower();
@@ -1261,7 +1379,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                break;
                        case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
                        {
-                               int idleInputpower = m_idleInputpower[ (m_curVoltage&1) ? 0 : 1];
+                               int idleInputpower = m_idleInputpower[ (m_data[CUR_VOLTAGE]&1) ? 0 : 1];
                                eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
                                const char *txt = cmd.direction ? "running" : "stopped";
                                eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
@@ -1300,14 +1418,13 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                        ++m_sec_sequence.current();
                                break;
                        case eSecCommand::INVALIDATE_CURRENT_ROTORPARMS:
-                               m_data[ROTOR_CMD] = m_data[ROTOR_POS] = -1;
                                eDebug("[SEC] invalidate current rotorparams");
+                               setRotorData(-1,-1);    
                                ++m_sec_sequence.current();
                                break;
                        case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
-                               m_data[ROTOR_CMD] = m_data[NEW_ROTOR_CMD];
-                               m_data[ROTOR_POS] = m_data[NEW_ROTOR_POS];
-                               eDebug("[SEC] update current rotorparams %d %04x %d", m_timeoutCount, m_data[5], m_data[6]);
+                               setRotorData(m_data[NEW_ROTOR_POS], m_data[NEW_ROTOR_CMD]);
+                               eDebug("[SEC] update current rotorparams %d %04x %d", m_timeoutCount, m_data[ROTOR_CMD], m_data[ROTOR_POS]);
                                ++m_sec_sequence.current();
                                break;
                        case eSecCommand::SET_ROTOR_DISEQC_RETRYS:
@@ -1325,9 +1442,19 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
                                break;
                        case eSecCommand::SET_POWER_LIMITING_MODE:
                        {
-                               int fd = m_fe ?
-                                       ::open("/dev/i2c/1", O_RDWR) :
-                                       ::open("/dev/i2c/0", O_RDWR);
+                               if (!m_need_rotor_workaround)
+                                       break;
+
+                               char dev[16];
+
+                               // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
+                               if (m_slotid < 2)
+                                       sprintf(dev, "/dev/i2c/%d", m_slotid);
+                               else if (m_slotid == 2)
+                                       sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2
+                               else if (m_slotid == 3)
+                                       sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4
+                               int fd = ::open(dev, O_RDWR);
 
                                unsigned char data[2];
                                ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
@@ -1360,7 +1487,7 @@ void eDVBFrontend::tuneLoop()  // called by m_tuneTimer
 
 void eDVBFrontend::setFrontend()
 {
-       eDebug("setting frontend %d", m_fe);
+       eDebug("setting frontend %d", m_dvbid);
        m_sn->start();
        feEvent(-1);
        if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
@@ -1386,7 +1513,7 @@ RESULT eDVBFrontend::prepare_sat(const eDVBFrontendParametersSatellite &feparm)
                eWarning("no SEC module active!");
                return -ENOENT;
        }
-       res = m_sec->prepare(*this, parm, feparm, 1 << m_fe);
+       res = m_sec->prepare(*this, parm, feparm, 1 << m_slotid);
        if (!res)
        {
                eDebug("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d",
@@ -1717,7 +1844,7 @@ RESULT eDVBFrontend::prepare_terrestrial(const eDVBFrontendParametersTerrestrial
 
 RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
 {
-       eDebug("(%d)tune", m_fe);
+       eDebug("(%d)tune", m_dvbid);
 
        m_timeout->stop();
 
@@ -1788,7 +1915,7 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
 
                std::string enable_5V;
                char configStr[255];
-               snprintf(configStr, 255, "config.Nims.%d.terrestrial_5V", m_fe);
+               snprintf(configStr, 255, "config.Nims.%d.terrestrial_5V", m_slotid);
                m_sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT) );
                ePythonConfigQuery::getConfigValue(configStr, enable_5V);
                if (enable_5V == "True")
@@ -1834,7 +1961,7 @@ RESULT eDVBFrontend::setVoltage(int voltage)
        bool increased=false;
        fe_sec_voltage_t vlt;
 #endif
-       m_curVoltage=voltage;
+       m_data[CUR_VOLTAGE]=voltage;
        switch (voltage)
        {
        case voltageOff:
@@ -1889,7 +2016,7 @@ RESULT eDVBFrontend::setTone(int t)
 #else
        fe_sec_tone_mode_t tone;
 #endif
-
+       m_data[CUR_TONE]=t;
        switch (t)
        {
        case toneOn:
@@ -1992,17 +2119,42 @@ RESULT eDVBFrontend::setData(int num, int val)
 int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
 {
        int type;
-       if (feparm->getSystem(type) || type != m_type)
+       if (feparm->getSystem(type) || type != m_type || !m_enabled)
                return 0;
 
        if (m_type == eDVBFrontend::feSatellite)
        {
                ASSERT(m_sec);
                eDVBFrontendParametersSatellite sat_parm;
-               ASSERT(!feparm->getDVBS(sat_parm));
-               return m_sec->canTune(sat_parm, this, 1 << m_fe);
+               int ret = feparm->getDVBS(sat_parm);
+               ASSERT(!ret);
+               return m_sec->canTune(sat_parm, this, 1 << m_slotid);
        }
        else if (m_type == eDVBFrontend::feCable)
                return 2;  // more prio for cable frontends
        return 1;
 }
+
+bool eDVBFrontend::setSlotInfo(ePyObject obj)
+{
+       ePyObject Id, Descr, Enabled;
+       if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3)
+               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))
+               goto arg_error;
+       strcpy(m_description, PyString_AS_STRING(Descr));
+       m_slotid = PyInt_AsLong(Id);
+       m_enabled = Enabled == Py_True;
+       // HACK.. the rotor workaround is neede for all NIMs with LNBP21 voltage regulator...
+       m_need_rotor_workaround = !!strstr(m_description, "Alps BSBE1") || !!strstr(m_description, "Alps -S");
+       eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s",
+               m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No" );
+       return true;
+arg_error:
+       PyErr_SetString(PyExc_StandardError,
+               "eDVBFrontend::setSlotInfo must get a tuple with first param slotid, second param slot description and third param enabled boolean");
+       return false;
+}