X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/69725af53d310026a1d773f35f13b141269b3edc..5da80a9996efc261b128ffc98d1847b5aa183817:/lib/dvb/frontend.cpp diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index af821cdb..5f28a829 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -506,7 +506,7 @@ int eDVBFrontend::closeFrontend() 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); + linked_fe->m_frontend->getData(LINKED_NEXT_PTR, (long&)linked_fe); } if (m_fd >= 0) { @@ -617,14 +617,14 @@ int eDVBFrontend::readFrontendData(int type) eDebug("FE_READ_BER failed (%m)"); return ber; } - case signalPower: + case signalQuality: { uint16_t snr=0; if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE) eDebug("FE_READ_SNR failed (%m)"); return snr; } - case signalPowerdB: /* this will move into the driver */ + case signalQualitydB: /* this will move into the driver */ { uint16_t snr=0; if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE) @@ -669,11 +669,14 @@ int eDVBFrontend::readFrontendData(int type) { float snr_in_db=(snr-39075)/1764.7; return (int)(snr_in_db * 100.0); + } else if (!strcmp(m_description, "Alps BSBE2")) + { + return (int)((snr >> 7) * 10.0); } /* else eDebug("no SNR dB calculation for frontendtype %s yet", m_description); */ return 0x12345678; } - case signalQuality: + case signalPower: { uint16_t strength=0; if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE) @@ -748,8 +751,8 @@ void PutToDict(ePyObject &dict, const char*key, const char *value) void fillDictWithSatelliteData(ePyObject dict, const FRONTENDPARAMETERS &parm, eDVBFrontend *fe) { - int freq_offset=0; - int csw=0; + long freq_offset=0; + long csw=0; const char *tmp=0; fe->getData(eDVBFrontend::CSW, csw); fe->getData(eDVBFrontend::FREQ_OFFSET, freq_offset); @@ -1060,17 +1063,17 @@ void eDVBFrontend::getFrontendStatus(ePyObject dest) 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 + PutToDict(dest, "tuner_signal_quality", readFrontendData(signalQuality)); + int sigQualitydB = readFrontendData(signalQualitydB); + if (sigQualitydB == 0x12345678) // not support yet { ePyObject obj=Py_None; Py_INCREF(obj); - PutToDict(dest, "tuner_signal_power_db", obj); + PutToDict(dest, "tuner_signal_quality_db", obj); } else - PutToDict(dest, "tuner_signal_power_db", sigPowerdB); - PutToDict(dest, "tuner_signal_quality", readFrontendData(signalQuality)); + PutToDict(dest, "tuner_signal_quality_db", sigQualitydB); + PutToDict(dest, "tuner_signal_power", readFrontendData(signalPower)); } } @@ -1156,21 +1159,34 @@ void eDVBFrontend::getFrontendData(ePyObject dest) 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) + char proc_name[64]; + sprintf(proc_name, "/proc/stb/fp/lnb_sense%d", m_slotid); + FILE *f=fopen(proc_name, "r"); + if (f) { - eDebug("couldn't open fp"); - return -1; + if (fscanf(f, "%08x", &power) != 1) + eDebug("read %s failed!! (%m)", proc_name); + else + eDebug("%s is %d\n", proc_name, power); + fclose(f); } - static bool old_fp = (::ioctl(fp, FP_IOCTL_GET_ID) < 0); - if ( ioctl( fp, old_fp ? 9 : 0x100, &power ) < 0 ) + else { - eDebug("FP_IOCTL_GET_LNB_CURRENT failed (%m)"); - return -1; + // 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); } - ::close(fp); return power; } @@ -1208,14 +1224,14 @@ void eDVBFrontend::setRotorData(int pos, int cmd) else { eDVBRegisteredFrontend *next = (eDVBRegisteredFrontend *)m_data[LINKED_NEXT_PTR]; - while ( (int)next != -1 ) + while ( (long)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 ) + while ( (long)prev != -1 ) { prev->m_frontend->m_data[ROTOR_CMD] = cmd; prev->m_frontend->m_data[ROTOR_POS] = pos; @@ -1443,37 +1459,37 @@ void eDVBFrontend::tuneLoop() // called by m_tuneTimer break; case eSecCommand::SET_POWER_LIMITING_MODE: { - 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); - if(::read(fd, data, 1) != 1) - eDebug("[SEC] error read lnbp (%m)"); - if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic ) + if (m_need_rotor_workaround) { - data[0] |= 0x80; // enable static current limiting - eDebug("[SEC] set static current limiting"); - } - else - { - data[0] &= ~0x80; // enable dynamic current limiting - eDebug("[SEC] set dynamic current limiting"); + 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); + if(::read(fd, data, 1) != 1) + eDebug("[SEC] error read lnbp (%m)"); + if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic ) + { + data[0] |= 0x80; // enable static current limiting + eDebug("[SEC] set static current limiting"); + } + else + { + data[0] &= ~0x80; // enable dynamic current limiting + eDebug("[SEC] set dynamic current limiting"); + } + if(::write(fd, data, 1) != 1) + eDebug("[SEC] error write lnbp (%m)"); + ::close(fd); } - if(::write(fd, data, 1) != 1) - eDebug("[SEC] error write lnbp (%m)"); - ::close(fd); ++m_sec_sequence.current(); break; } @@ -2097,7 +2113,7 @@ RESULT eDVBFrontend::setSecSequence(const eSecCommandList &list) return 0; } -RESULT eDVBFrontend::getData(int num, int &data) +RESULT eDVBFrontend::getData(int num, long &data) { if ( num < NUM_DATA_ENTRIES ) { @@ -2107,7 +2123,7 @@ RESULT eDVBFrontend::getData(int num, int &data) return -EINVAL; } -RESULT eDVBFrontend::setData(int num, int val) +RESULT eDVBFrontend::setData(int num, long val) { if ( num < NUM_DATA_ENTRIES ) {