2 #include <lib/dvb/dvb.h>
3 #include <lib/base/eerror.h>
9 #ifndef I2C_SLAVE_FORCE
10 #define I2C_SLAVE_FORCE 0x0706
13 #if HAVE_DVB_API_VERSION < 3
14 #include <ost/frontend.h>
16 #define QAM_AUTO (Modulation)6
17 #define TRANSMISSION_MODE_AUTO (TransmitMode)2
18 #define BANDWIDTH_AUTO (BandWidth)3
19 #define GUARD_INTERVAL_AUTO (GuardInterval)4
20 #define HIERARCHY_AUTO (Hierarchy)4
21 #define constellation Constellation
22 #define guard_interval guardInterval
23 #define hierarchy_information HierarchyInformation
24 #define code_rate_HP HP_CodeRate
25 #define code_rate_LP LP_CodeRate
27 #include <linux/dvb/frontend.h>
30 #include <dvbsi++/satellite_delivery_system_descriptor.h>
31 #include <dvbsi++/cable_delivery_system_descriptor.h>
32 #include <dvbsi++/terrestrial_delivery_system_descriptor.h>
34 void eDVBFrontendParametersSatellite::set(const SatelliteDeliverySystemDescriptor &descriptor)
36 frequency = descriptor.getFrequency() * 10;
37 symbol_rate = descriptor.getSymbolRate() * 100;
38 switch (descriptor.getPolarization())
41 polarisation = Polarisation::Horizontal;
44 polarisation = Polarisation::Vertical;
47 polarisation = Polarisation::CircularLeft;
50 polarisation = Polarisation::CircularRight;
53 switch (descriptor.getFecInner())
77 inversion = Inversion::Unknown;
78 orbital_position = ((descriptor.getOrbitalPosition() >> 12) & 0xF) * 1000;
79 orbital_position += ((descriptor.getOrbitalPosition() >> 8) & 0xF) * 100;
80 orbital_position += ((descriptor.getOrbitalPosition() >> 4) & 0xF) * 10;
81 orbital_position += ((descriptor.getOrbitalPosition()) & 0xF);
82 if (orbital_position && (!descriptor.getWestEastFlag()))
83 orbital_position = 3600 - orbital_position;
86 void eDVBFrontendParametersCable::set(const CableDeliverySystemDescriptor &descriptor)
91 void eDVBFrontendParametersTerrestrial::set(const TerrestrialDeliverySystemDescriptor &)
96 eDVBFrontendParameters::eDVBFrontendParameters(): m_type(-1)
100 DEFINE_REF(eDVBFrontendParameters);
102 RESULT eDVBFrontendParameters::getSystem(int &t) const
110 RESULT eDVBFrontendParameters::getDVBS(eDVBFrontendParametersSatellite &p) const
112 if (m_type != iDVBFrontend::feSatellite)
118 RESULT eDVBFrontendParameters::getDVBC(eDVBFrontendParametersCable &p) const
120 if (m_type != iDVBFrontend::feCable)
126 RESULT eDVBFrontendParameters::getDVBT(eDVBFrontendParametersTerrestrial &p) const
128 if (m_type != iDVBFrontend::feTerrestrial)
134 RESULT eDVBFrontendParameters::setDVBS(const eDVBFrontendParametersSatellite &p)
137 m_type = iDVBFrontend::feSatellite;
141 RESULT eDVBFrontendParameters::setDVBC(const eDVBFrontendParametersCable &p)
144 m_type = iDVBFrontend::feCable;
148 RESULT eDVBFrontendParameters::setDVBT(const eDVBFrontendParametersTerrestrial &p)
151 m_type = iDVBFrontend::feTerrestrial;
155 RESULT eDVBFrontendParameters::calculateDifference(const iDVBFrontendParameters *parm, int &diff) const
160 if (parm->getSystem(type))
164 diff = 1<<30; // big difference
170 case iDVBFrontend::feSatellite:
172 eDVBFrontendParametersSatellite osat;
173 if (parm->getDVBS(osat))
176 if (sat.orbital_position != osat.orbital_position)
178 else if (sat.polarisation != osat.polarisation)
182 diff = abs(sat.frequency - osat.frequency);
183 diff += abs(sat.symbol_rate - osat.symbol_rate);
187 case iDVBFrontend::feCable:
188 case iDVBFrontend::feTerrestrial:
195 RESULT eDVBFrontendParameters::getHash(unsigned long &hash) const
199 case iDVBFrontend::feSatellite:
201 hash = (sat.orbital_position << 16);
202 hash |= ((sat.frequency/1000)&0xFFFF)|((sat.polarisation&1) << 15);
205 case iDVBFrontend::feCable:
206 case iDVBFrontend::feTerrestrial:
212 DEFINE_REF(eDVBFrontend);
214 eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
215 :m_type(-1), m_fe(fe), m_fd(-1), m_timeout(0), m_tuneTimer(0)
216 #if HAVE_DVB_API_VERSION < 3
220 #if HAVE_DVB_API_VERSION < 3
221 sprintf(m_filename, "/dev/dvb/card%d/frontend%d", adap, fe);
222 sprintf(m_sec_filename, "/dev/dvb/card%d/sec%d", adap, fe);
224 sprintf(m_filename, "/dev/dvb/adapter%d/frontend%d", adap, fe);
226 m_timeout = new eTimer(eApp);
227 CONNECT(m_timeout->timeout, eDVBFrontend::timeout);
229 m_tuneTimer = new eTimer(eApp);
230 CONNECT(m_tuneTimer->timeout, eDVBFrontend::tuneLoop);
232 int entries = sizeof(m_data) / sizeof(int);
233 for (int i=0; i<entries; ++i)
236 m_idleInputpower[0]=m_idleInputpower[1]=0;
238 ok = !openFrontend();
242 int eDVBFrontend::openFrontend()
245 return -1; // already opened
248 m_curVoltage=voltageOff;
251 #if HAVE_DVB_API_VERSION < 3
252 m_secfd = ::open(m_sec_filename, O_RDWR);
255 eWarning("failed! (%s) %m", m_sec_filename);
258 FrontendInfo fe_info;
260 dvb_frontend_info fe_info;
262 eDebug("opening frontend %d", m_fe);
263 m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
266 eWarning("failed! (%s) %m", m_filename);
267 #if HAVE_DVB_API_VERSION < 3
276 if (::ioctl(m_fd, FE_GET_INFO, &fe_info) < 0)
278 eWarning("ioctl FE_GET_INFO failed");
281 #if HAVE_DVB_API_VERSION < 3
288 switch (fe_info.type)
291 m_type = iDVBFrontend::feSatellite;
294 m_type = iDVBFrontend::feCable;
297 m_type = iDVBFrontend::feTerrestrial;
300 eWarning("unknown frontend type.");
303 #if HAVE_DVB_API_VERSION < 3
309 eDebug("detected %s frontend", "satellite\0cable\0 terrestrial"+fe_info.type*10);
312 setTone(iDVBFrontend::toneOff);
313 setVoltage(iDVBFrontend::voltageOff);
315 m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read);
316 CONNECT(m_sn->activated, eDVBFrontend::feEvent);
322 int eDVBFrontend::closeFrontend()
324 if (!m_fe && m_data[7] != -1)
326 // try to close the first frontend.. but the second is linked to the first
327 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)m_data[7];
328 if (linked_fe->m_inuse)
330 eDebug("dont close frontend %d until the linked frontend %d is still in use",
331 m_fe, linked_fe->m_frontend->getID());
337 eDebug("close frontend %d", m_fe);
338 setTone(iDVBFrontend::toneOff);
339 setVoltage(iDVBFrontend::voltageOff);
343 #if HAVE_DVB_API_VERSION < 3
356 eDVBFrontend::~eDVBFrontend()
363 void eDVBFrontend::feEvent(int w)
367 #if HAVE_DVB_API_VERSION < 3
370 dvb_frontend_event event;
374 res = ::ioctl(m_fd, FE_GET_EVENT, &event);
376 if (res && (errno == EAGAIN))
381 eWarning("FE_GET_EVENT failed! %m");
388 #if HAVE_DVB_API_VERSION < 3
389 if (event.type == FE_COMPLETION_EV)
391 eDebug("(%d)fe event: status %x, inversion %s", m_fe, event.status, (event.parameters.inversion == INVERSION_ON) ? "on" : "off");
392 if (event.status & FE_HAS_LOCK)
402 state = stateLostLock;
404 if (m_state != stateLostLock)
405 eDebug("FIXME: we lost lock, so we might have to retune.");
408 if (m_state != state)
411 m_stateChanged(this);
416 void eDVBFrontend::timeout()
419 if (m_state == stateTuning)
422 eDebug("DVBFrontend: timeout");
423 if (m_state != state)
426 m_stateChanged(this);
433 int eDVBFrontend::readFrontendData(int type)
440 if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
441 eDebug("FE_READ_BER failed (%m)");
447 if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
448 eDebug("FE_READ_SNR failed (%m)");
454 if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
455 eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
462 #ifndef FP_IOCTL_GET_ID
463 #define FP_IOCTL_GET_ID 0
465 int eDVBFrontend::readInputpower()
467 int power=m_fe; // this is needed for read inputpower from the correct tuner !
469 // open front prozessor
470 int fp=::open("/dev/dbox/fp0", O_RDWR);
473 eDebug("couldn't open fp");
476 static bool old_fp = (::ioctl(fp, FP_IOCTL_GET_ID) < 0);
477 if ( ioctl( fp, old_fp ? 9 : 0x100, &power ) < 0 )
479 eDebug("FP_IOCTL_GET_LNB_CURRENT failed (%m)");
487 bool eDVBFrontend::setSecSequencePos(int steps)
489 eDebug("set sequence pos %d", steps);
494 if (m_sec_sequence.current() != m_sec_sequence.end())
495 ++m_sec_sequence.current();
500 if (m_sec_sequence.current() != m_sec_sequence.begin() && m_sec_sequence.current() != m_sec_sequence.end())
501 --m_sec_sequence.current();
507 void eDVBFrontend::tuneLoop() // called by m_tuneTimer
510 if ( m_sec_sequence && m_sec_sequence.current() != m_sec_sequence.end() )
512 switch (m_sec_sequence.current()->cmd)
514 case eSecCommand::SLEEP:
515 delay = m_sec_sequence.current()++->msec;
516 eDebug("[SEC] sleep %dms", delay);
518 case eSecCommand::GOTO:
519 if ( !setSecSequencePos(m_sec_sequence.current()->steps) )
520 ++m_sec_sequence.current();
522 case eSecCommand::SET_VOLTAGE:
523 int voltage = m_sec_sequence.current()++->voltage;
524 eDebug("[SEC] setVoltage %d", voltage);
527 case eSecCommand::SET_TONE:
528 eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone);
529 setTone(m_sec_sequence.current()++->tone);
531 case eSecCommand::SEND_DISEQC:
532 sendDiseqc(m_sec_sequence.current()->diseqc);
533 eDebugNoNewLine("[SEC] sendDiseqc: ");
534 for (int i=0; i < m_sec_sequence.current()->diseqc.len; ++i)
535 eDebugNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]);
537 ++m_sec_sequence.current();
539 case eSecCommand::SEND_TONEBURST:
540 eDebug("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
541 sendToneburst(m_sec_sequence.current()++->toneburst);
543 case eSecCommand::SET_FRONTEND:
544 eDebug("[SEC] setFrontend");
546 ++m_sec_sequence.current();
548 case eSecCommand::MEASURE_IDLE_INPUTPOWER:
550 int idx = m_sec_sequence.current()++->val;
551 if ( idx == 0 || idx == 1 )
553 m_idleInputpower[idx] = readInputpower();
554 eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
557 eDebug("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
560 case eSecCommand::MEASURE_RUNNING_INPUTPOWER:
561 m_runningInputpower = readInputpower();
562 eDebug("[SEC] runningInputpower is %d", m_runningInputpower);
563 ++m_sec_sequence.current();
565 case eSecCommand::SET_TIMEOUT:
566 m_timeoutCount = m_sec_sequence.current()++->val;
567 eDebug("[SEC] set timeout %d", m_timeoutCount);
569 case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
570 m_data[5] = m_data[3];
571 m_data[6] = m_data[4];
572 eDebug("[SEC] update current rotorparams %d %04x %d", m_timeoutCount, m_data[5], m_data[6]);
573 ++m_sec_sequence.current();
575 case eSecCommand::IF_TIMEOUT_GOTO:
578 eDebug("[SEC] rotor timout");
579 m_sec->setRotorMoving(false);
580 setSecSequencePos(m_sec_sequence.current()->steps);
583 ++m_sec_sequence.current();
585 case eSecCommand::SET_POWER_LIMITING_MODE:
588 ::open("/dev/i2c/1", O_RDWR) :
589 ::open("/dev/i2c/0", O_RDWR);
591 unsigned char data[2];
592 ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
593 if(::read(fd, data, 1) != 1)
594 eDebug("[SEC] error read lnbp (%m)");
595 if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
597 data[0] |= 0x80; // enable static current limiting
598 eDebug("[SEC] set static current limiting");
602 data[0] &= ~0x80; // enable dynamic current limiting
603 eDebug("[SEC] set dynamic current limiting");
605 if(::write(fd, data, 1) != 1)
606 eDebug("[SEC] error write lnbp (%m)");
608 ++m_sec_sequence.current();
611 case eSecCommand::IF_IDLE_INPUTPOWER_AVAIL_GOTO:
612 if (m_idleInputpower[0] && m_idleInputpower[1] && setSecSequencePos(m_sec_sequence.current()->steps))
614 ++m_sec_sequence.current();
616 case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
618 int idleInputpower = m_idleInputpower[ (m_curVoltage&1) ? 0 : 1];
619 eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
620 const char *txt = cmd.direction ? "running" : "stopped";
621 eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
626 if ( (cmd.direction && abs(m_runningInputpower - idleInputpower) >= cmd.deltaA)
627 || (!cmd.direction && abs(m_runningInputpower - idleInputpower) <= cmd.deltaA) )
630 eDebug("[SEC] rotor %s step %d ok", txt, cmd.okcount);
631 if ( cmd.okcount > 6 )
633 m_sec->setRotorMoving(cmd.direction);
634 eDebug("[SEC] rotor is %s", txt);
635 if (setSecSequencePos(cmd.steps))
641 eDebug("[SEC] rotor not %s... reset counter.. increase timeout", txt);
645 ++m_sec_sequence.current();
648 case eSecCommand::IF_VOLTAGE_GOTO:
650 eSecCommand::pair &compare = m_sec_sequence.current()->compare;
651 if ( compare.voltage == m_curVoltage && setSecSequencePos(compare.steps) )
653 ++m_sec_sequence.current();
657 ++m_sec_sequence.current();
658 eDebug("[SEC] unhandled sec command");
660 m_tuneTimer->start(delay,true);
664 void eDVBFrontend::setFrontend()
666 eDebug("setting frontend %d", m_fe);
667 if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
669 perror("FE_SET_FRONTEND failed");
673 if (m_state != stateTuning)
676 m_state = stateTuning;
677 m_stateChanged(this);
679 m_timeout->start(5000, 1); // 5 sec timeout. TODO: symbolrate dependent
682 RESULT eDVBFrontend::getFrontendType(int &t)
690 RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
692 eDebug("(%d)tune", m_fe);
699 m_sec_sequence.clear();
706 eDVBFrontendParametersSatellite feparm;
707 if (where.getDVBS(feparm))
709 eDebug("no dvbs data!");
714 eWarning("no SEC module active!");
718 res = m_sec->prepare(*this, parm, feparm, 1 << m_fe);
721 #if HAVE_DVB_API_VERSION < 3
722 eDebug("tuning to %d mhz", parm.Frequency/1000);
724 eDebug("tuning to %d mhz", parm.frequency/1000);
730 #if HAVE_DVB_API_VERSION >= 3
731 eDVBFrontendParametersCable feparm;
732 if (where.getDVBC(feparm))
734 #if HAVE_DVB_API_VERSION < 3
735 parm.Frequency = feparm.frequency * 1000;
736 parm.u.qam.SymbolRate = feparm.symbol_rate;
738 parm.frequency = feparm.frequency * 1000;
739 parm.u.qam.symbol_rate = feparm.symbol_rate;
741 fe_modulation_t mod=QAM_AUTO;
742 switch (feparm.modulation)
744 case eDVBFrontendParametersCable::Modulation::QAM16:
747 case eDVBFrontendParametersCable::Modulation::QAM32:
750 case eDVBFrontendParametersCable::Modulation::QAM64:
753 case eDVBFrontendParametersCable::Modulation::QAM128:
756 case eDVBFrontendParametersCable::Modulation::QAM256:
759 case eDVBFrontendParametersCable::Modulation::Auto:
763 #if HAVE_DVB_API_VERSION < 3
764 parm.u.qam.QAM = mod;
766 parm.u.qam.modulation = mod;
768 switch (feparm.inversion)
770 case eDVBFrontendParametersCable::Inversion::On:
771 #if HAVE_DVB_API_VERSION < 3
778 case eDVBFrontendParametersCable::Inversion::Off:
779 #if HAVE_DVB_API_VERSION < 3
786 case eDVBFrontendParametersCable::Inversion::Unknown:
787 #if HAVE_DVB_API_VERSION < 3
796 fe_code_rate_t fec_inner=FEC_AUTO;
797 switch (feparm.fec_inner)
799 case eDVBFrontendParametersCable::FEC::fNone:
800 fec_inner = FEC_NONE;
802 case eDVBFrontendParametersCable::FEC::f1_2:
805 case eDVBFrontendParametersCable::FEC::f2_3:
808 case eDVBFrontendParametersCable::FEC::f3_4:
811 case eDVBFrontendParametersCable::FEC::f4_5:
814 case eDVBFrontendParametersCable::FEC::f5_6:
817 case eDVBFrontendParametersCable::FEC::f6_7:
820 case eDVBFrontendParametersCable::FEC::f7_8:
823 case eDVBFrontendParametersCable::FEC::f8_9:
826 case eDVBFrontendParametersCable::FEC::fAuto:
827 fec_inner = FEC_AUTO;
830 #if HAVE_DVB_API_VERSION < 3
831 parm.u.qam.FEC_inner = fec_inner;
833 parm.u.qam.fec_inner = fec_inner;
836 eFatal("Old API not fully supported");
842 eDVBFrontendParametersTerrestrial feparm;
843 if (where.getDVBT(feparm))
845 eDebug("no -T data");
848 #if HAVE_DVB_API_VERSION < 3
849 parm.Frequency = feparm.frequency;
851 parm.frequency = feparm.frequency;
854 switch (feparm.bandwidth)
856 case eDVBFrontendParametersTerrestrial::Bandwidth::Bw8MHz:
857 #if HAVE_DVB_API_VERSION < 3
858 parm.u.ofdm.bandWidth =
860 parm.u.ofdm.bandwidth =
864 case eDVBFrontendParametersTerrestrial::Bandwidth::Bw7MHz:
865 #if HAVE_DVB_API_VERSION < 3
866 parm.u.ofdm.bandWidth =
868 parm.u.ofdm.bandwidth =
872 case eDVBFrontendParametersTerrestrial::Bandwidth::Bw6MHz:
873 #if HAVE_DVB_API_VERSION < 3
874 parm.u.ofdm.bandWidth =
876 parm.u.ofdm.bandwidth =
880 case eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto:
881 #if HAVE_DVB_API_VERSION < 3
882 parm.u.ofdm.bandWidth =
884 parm.u.ofdm.bandwidth =
889 eWarning("invalid OFDM bandwith");
893 parm.u.ofdm.code_rate_HP = FEC_AUTO;
894 parm.u.ofdm.code_rate_LP = FEC_AUTO;
896 switch (feparm.modulation)
898 case eDVBFrontendParametersTerrestrial::Modulation::QPSK:
899 parm.u.ofdm.constellation = QPSK;
901 case eDVBFrontendParametersTerrestrial::Modulation::QAM16:
902 parm.u.ofdm.constellation = QAM_16;
904 case eDVBFrontendParametersTerrestrial::Modulation::Auto:
905 parm.u.ofdm.constellation = QAM_AUTO;
909 switch (feparm.transmission_mode)
911 case eDVBFrontendParametersTerrestrial::TransmissionMode::TM2k:
912 #if HAVE_DVB_API_VERSION < 3
913 parm.u.ofdm.TransmissionMode =
915 parm.u.ofdm.transmission_mode =
917 TRANSMISSION_MODE_2K;
919 case eDVBFrontendParametersTerrestrial::TransmissionMode::TM8k:
920 #if HAVE_DVB_API_VERSION < 3
921 parm.u.ofdm.TransmissionMode =
923 parm.u.ofdm.transmission_mode =
925 TRANSMISSION_MODE_8K;
927 case eDVBFrontendParametersTerrestrial::TransmissionMode::TMAuto:
928 #if HAVE_DVB_API_VERSION < 3
929 parm.u.ofdm.TransmissionMode =
931 parm.u.ofdm.transmission_mode =
933 TRANSMISSION_MODE_AUTO;
937 parm.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
938 parm.u.ofdm.hierarchy_information = HIERARCHY_AUTO;
939 #if HAVE_DVB_API_VERSION < 3
949 m_sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
950 m_tuneTimer->start(0,true);
951 m_sec_sequence.current() = m_sec_sequence.begin();
956 RESULT eDVBFrontend::connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection)
958 connection = new eConnection(this, m_stateChanged.connect(stateChange));
962 RESULT eDVBFrontend::setVoltage(int voltage)
964 if (m_type != feSatellite)
966 #if HAVE_DVB_API_VERSION < 3
969 bool increased=false;
970 fe_sec_voltage_t vlt;
972 m_curVoltage=voltage;
976 for (int i=0; i < 3; ++i) // reset diseqc
978 vlt = SEC_VOLTAGE_OFF;
981 #if HAVE_DVB_API_VERSION < 3
982 vlt = SEC_VOLTAGE_13_5;
988 vlt = SEC_VOLTAGE_13;
991 #if HAVE_DVB_API_VERSION < 3
992 vlt = SEC_VOLTAGE_18_5;
998 vlt = SEC_VOLTAGE_18;
1003 #if HAVE_DVB_API_VERSION < 3
1004 return ::ioctl(m_secfd, SEC_SET_VOLTAGE, vlt);
1006 if (::ioctl(m_fd, FE_ENABLE_HIGH_LNB_VOLTAGE, increased) < 0)
1007 perror("FE_ENABLE_HIGH_LNB_VOLTAGE");
1008 return ::ioctl(m_fd, FE_SET_VOLTAGE, vlt);
1012 RESULT eDVBFrontend::getState(int &state)
1018 RESULT eDVBFrontend::setTone(int t)
1020 if (m_type != feSatellite)
1022 #if HAVE_DVB_API_VERSION < 3
1025 fe_sec_tone_mode_t tone;
1034 tone = SEC_TONE_OFF;
1039 #if HAVE_DVB_API_VERSION < 3
1040 return ::ioctl(m_secfd, SEC_SET_TONE, tone);
1042 return ::ioctl(m_fd, FE_SET_TONE, tone);
1046 #if HAVE_DVB_API_VERSION < 3 && !defined(SEC_DISEQC_SEND_MASTER_CMD)
1047 #define SEC_DISEQC_SEND_MASTER_CMD _IOW('o', 97, struct secCommand *)
1050 RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
1052 #if HAVE_DVB_API_VERSION < 3
1053 struct secCommand cmd;
1054 cmd.type = SEC_CMDTYPE_DISEQC_RAW;
1055 cmd.u.diseqc.cmdtype = diseqc.data[0];
1056 cmd.u.diseqc.addr = diseqc.data[1];
1057 cmd.u.diseqc.cmd = diseqc.data[2];
1058 cmd.u.diseqc.numParams = diseqc.len-3;
1059 memcpy(cmd.u.diseqc.params, diseqc.data+3, diseqc.len-3);
1060 if (::ioctl(m_secfd, SEC_DISEQC_SEND_MASTER_CMD, &cmd))
1062 struct dvb_diseqc_master_cmd cmd;
1063 memcpy(cmd.msg, diseqc.data, diseqc.len);
1064 cmd.msg_len = diseqc.len;
1065 if (::ioctl(m_fd, FE_DISEQC_SEND_MASTER_CMD, &cmd))
1071 #if HAVE_DVB_API_VERSION < 3 && !defined(SEC_DISEQC_SEND_BURST)
1072 #define SEC_DISEQC_SEND_BURST _IO('o', 96)
1074 RESULT eDVBFrontend::sendToneburst(int burst)
1076 #if HAVE_DVB_API_VERSION < 3
1077 secMiniCmd cmd = SEC_MINI_NONE;
1078 if ( burst == eDVBSatelliteDiseqcParameters::A )
1080 else if ( burst == eDVBSatelliteDiseqcParameters::B )
1082 if (::ioctl(m_secfd, SEC_DISEQC_SEND_BURST, cmd))
1085 fe_sec_mini_cmd_t cmd = SEC_MINI_A;
1086 if ( burst == eDVBSatelliteDiseqcParameters::A )
1088 else if ( burst == eDVBSatelliteDiseqcParameters::B )
1092 eDebug("unknown toneburst!");
1095 if (::ioctl(m_fd, FE_DISEQC_SEND_BURST, cmd))
1101 RESULT eDVBFrontend::setSEC(iDVBSatelliteEquipmentControl *sec)
1107 RESULT eDVBFrontend::setSecSequence(const eSecCommandList &list)
1109 m_sec_sequence = list;
1113 RESULT eDVBFrontend::getData(int num, int &data)
1115 if ( num < (int)(sizeof(m_data)/sizeof(int)) )
1123 RESULT eDVBFrontend::setData(int num, int val)
1125 if ( num < (int)(sizeof(m_data)/sizeof(int)) )
1133 int eDVBFrontend::isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)
1136 if (feparm->getSystem(type) || type != m_type)
1139 if (m_type == eDVBFrontend::feSatellite)
1142 eDVBFrontendParametersSatellite sat_parm;
1143 ASSERT(!feparm->getDVBS(sat_parm));
1144 return m_sec->canTune(sat_parm, this, 1 << m_fe);