add satconfig part
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 2 May 2005 11:57:01 +0000 (11:57 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 2 May 2005 11:57:01 +0000 (11:57 +0000)
lib/dvb/frontend.cpp
lib/dvb/idvb.h
lib/dvb/sec.cpp
lib/dvb/sec.h

index 00886ee..6e8bcaa 100644 (file)
@@ -613,20 +613,26 @@ RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
        secCmdSequence seq;
        secCommand cmd;
 
-       cmd.type = SEC_CMDTYPE_DISEQC_RAW;
-       cmd.u.diseqc.cmdtype = diseqc.data[0];
-       eDebug("cmdtype is %02x", diseqc.data[0]);
-       cmd.u.diseqc.addr = diseqc.data[1];
-       eDebug("cmdaddr is %02x", diseqc.data[1]);
-       cmd.u.diseqc.cmd = diseqc.data[2];
-       eDebug("cmd is %02x", diseqc.data[2]);
-       cmd.u.diseqc.numParams = diseqc.len-3;
-       eDebug("numparams %d", diseqc.len-3);
-
-       memcpy(cmd.u.diseqc.params, diseqc.data+3, diseqc.len-3);
-       for (int i=0; i < diseqc.len-3; ++i )
-               eDebugNoNewLine("%02x ", diseqc.data[3+i]);
-       eDebug("");
+       if ( len > 3 )
+       {
+               seq.numCommands=1;
+               cmd.type = SEC_CMDTYPE_DISEQC_RAW;
+               cmd.u.diseqc.cmdtype = diseqc.data[0];
+               eDebug("cmdtype is %02x", diseqc.data[0]);
+               cmd.u.diseqc.addr = diseqc.data[1];
+               eDebug("cmdaddr is %02x", diseqc.data[1]);
+               cmd.u.diseqc.cmd = diseqc.data[2];
+               eDebug("cmd is %02x", diseqc.data[2]);
+               cmd.u.diseqc.numParams = diseqc.len-3;
+               eDebug("numparams %d", diseqc.len-3);
+
+               memcpy(cmd.u.diseqc.params, diseqc.data+3, diseqc.len-3);
+               for (int i=0; i < diseqc.len-3; ++i )
+                       eDebugNoNewLine("%02x ", diseqc.data[3+i]);
+               eDebug("");
+       }
+       else
+               seq.numCommands=0;
 
        seq.continuousTone = diseqc.tone == toneOn ? SEC_TONE_ON : SEC_TONE_OFF;
        switch ( diseqc.voltage )
@@ -643,7 +649,6 @@ RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
        }
        seq.miniCommand = SEC_MINI_NONE;
        seq.commands=&cmd;
-       seq.numCommands=1;
 
        if ( ioctl(m_secfd, SEC_SEND_SEQUENCE, &seq) < 0 )
        {
@@ -652,6 +657,8 @@ RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
        }
        return 0;
 #else
+       if ( !diseqc.len )
+               return 0;
        struct dvb_diseqc_master_cmd cmd;
        if (::ioctl(m_fd, FE_SET_TONE, SEC_TONE_OFF))
                return -EINVAL;
index 0dc5ce5..ef052d4 100644 (file)
@@ -349,8 +349,9 @@ public:
 
 #define MAX_DISEQC_LENGTH  16
 
-struct eDVBDiseqcCommand
+class eDVBDiseqcCommand
 {
+public:
        int len;
        __u8 data[MAX_DISEQC_LENGTH];
 #if HAVE_DVB_API_VERSION < 3
index a668ebe..a90e1c0 100644 (file)
@@ -19,64 +19,120 @@ DEFINE_REF(eDVBSatelliteEquipmentControl);
 
 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl()
 {
+       m_lnblist.push_back(eDVBSatelliteLNBParameters());
+       eDVBSatelliteLNBParameters &lnb_ref = m_lnblist.front();
+       eDVBSatelliteParameters &astra1 = lnb_ref.m_satellites[192];
+       eDVBSatelliteDiseqcParameters &diseqc_ref = astra1.m_diseqc_parameters;
+       eDVBSatelliteSwitchParameters &switch_ref = astra1.m_switch_parameters;
+
+       lnb_ref.m_lof_hi = 10600000;
+       lnb_ref.m_lof_lo = 9750000;
+       lnb_ref.m_lof_threshold = 11700000;
+
+       diseqc_ref.m_diseqc_mode = eDVBSatelliteDiseqcParameters::V1_0;
+       diseqc_ref.m_commited_cmd = eDVBSatelliteDiseqcParameters::BB;
+       diseqc_ref.m_repeats = 0;
+       diseqc_ref.m_seq_repeat = false;
+       diseqc_ref.m_swap_cmds = false;
+       diseqc_ref.m_toneburst_param = eDVBSatelliteDiseqcParameters::NO;
+       diseqc_ref.m_uncommitted_cmd = 0;
+       diseqc_ref.m_use_fast = 1;
+
+       switch_ref.m_22khz_signal = eDVBSatelliteSwitchParameters::HILO;
+       switch_ref.m_voltage_mode = eDVBSatelliteSwitchParameters::HV;
 }
 
 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat)
 {
-       int hi;
-       eDebug("(very) ugly and hardcoded eDVBSatelliteEquipmentControl");
-
-       if (sat.frequency > 11700000)
-               hi = 1;
-       else
-               hi = 0;
-       
-       if (hi)
-               parm.FREQUENCY = sat.frequency - 10600000;
-       else
-               parm.FREQUENCY = sat.frequency -  9750000;
-       
-//     frontend.sentDiseqc(...);
-
-       parm.INVERSION = (!sat.inversion) ? INVERSION_ON : INVERSION_OFF;
-
-       switch (sat.fec)
+       std::list<eDVBSatelliteLNBParameters>::iterator it = m_lnblist.begin();
+       for (;it != m_lnblist.end(); ++it )
        {
-//             case 1:
-//             case ...:
-       default:
-               parm.u.qpsk.FEC_INNER = FEC_AUTO;
-               break;
-       }
-       parm.u.qpsk.SYMBOLRATE = sat.symbol_rate;
+               eDVBSatelliteLNBParameters &lnb_param = *it;
+               std::map<int, eDVBSatelliteParameters>::iterator sit =
+                       lnb_param.m_satellites.find(sat.orbital_position);
+               if ( sit != lnb_param.m_satellites.end())
+               {
+                       int hi=0;
+                       int voltage = iDVBFrontend::voltageOff;
+                       int tone = iDVBFrontend::toneOff;
+
+                       eDVBSatelliteDiseqcParameters &di_param = sit->second.m_diseqc_parameters;
+                       eDVBSatelliteSwitchParameters &sw_param = sit->second.m_switch_parameters;
+
+                       if ( sat.frequency > lnb_param.m_lof_threshold )
+                               hi = 1;
+
+                       if (hi)
+                               parm.FREQUENCY = sat.frequency - lnb_param.m_lof_hi;
+                       else
+                               parm.FREQUENCY = sat.frequency - lnb_param.m_lof_lo;
 
-       eDVBDiseqcCommand diseqc;
+                       parm.INVERSION = (!sat.inversion) ? INVERSION_ON : INVERSION_OFF;
+
+                       switch (sat.fec)
+                       {
+               //              case 1:
+               //              case ...:
+                       default:
+                               parm.u.qpsk.FEC_INNER = FEC_AUTO;
+                               break;
+                       }
+
+                       parm.u.qpsk.SYMBOLRATE = sat.symbol_rate;
+
+                       if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_14V
+                               || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical
+                                       && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV )  )
+                               voltage = iDVBFrontend::voltage13;
+                       else if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_18V
+                               || ( sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal
+                                       && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV )  )
+                               voltage = iDVBFrontend::voltage18;
+
+                       if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::ON)
+                               || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && hi ) )
+                               tone = iDVBFrontend::toneOn;
+                       else if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::OFF)
+                               || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && !hi ) )
+                               tone = iDVBFrontend::toneOff;
+
+                       eDVBDiseqcCommand diseqc;
 
 #if HAVE_DVB_API_VERSION < 3
-       diseqc.voltage = sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18;
-       diseqc.tone = hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff;
+                       diseqc.voltage = voltage;
+                       diseqc.tone = tone;
 #else
-       frontend.setVoltage(sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Vertical ? iDVBFrontend::voltage13 : iDVBFrontend::voltage18);
+                       frontend.setVoltage(voltage);
 #endif
 
-       diseqc.len = 4;
-       diseqc.data[0] = 0xe0;
-       diseqc.data[1] = 0x10;
-       diseqc.data[2] = 0x38;
-       diseqc.data[3] = 0xF0;
+                       if ( di_param.m_commited_cmd < eDVBSatelliteDiseqcParameters::NO )
+                       {
+                               diseqc.len = 4;
+                               diseqc.data[0] = 0xe0;
+                               diseqc.data[1] = 0x10;
+                               diseqc.data[2] = 0x38;
+                               diseqc.data[3] = di_param.m_commited_cmd;
 
-       if (hi)
-               diseqc.data[3] |= 1;
+                               if (hi)
+                                       diseqc.data[3] |= 1;
 
-       if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
-               diseqc.data[3] |= 2;
+                               if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
+                                       diseqc.data[3] |= 2;
+                       }
+                       else
+                               diseqc.len = 0;
 
-       frontend.sendDiseqc(diseqc);
+                       frontend.sendDiseqc(diseqc);
 
 #if HAVE_DVB_API_VERSION > 2
-       frontend.setTone(hi ? iDVBFrontend::toneOn : iDVBFrontend::toneOff);
+                       frontend.setTone(tone);
 #endif
+                       return 0;
+               }
+       }
+
+       eDebug("not found satellite configuration for orbital position (%d)", sat.orbital_position );
 
-       return 0;
+       return -1;
 }
 
index ea01108..6ce1349 100644 (file)
@@ -4,8 +4,95 @@
 #include <config.h>
 #include <lib/dvb/idvb.h>
 
+class eDVBSatelliteDiseqcParameters
+{
+public:
+       enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/  };       // DiSEqC Parameter
+       int m_commited_cmd;
+
+       enum t_diseqc_mode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
+       t_diseqc_mode m_diseqc_mode;
+
+       enum t_toneburst_param { NO=0, A=1, B=2 };
+       t_toneburst_param m_toneburst_param;
+
+       int m_repeats;  // for cascaded switches
+       bool m_use_fast;        // send no DiSEqC on H/V or Lo/Hi change
+       bool m_seq_repeat;      // send the complete DiSEqC Sequence twice...
+       bool m_swap_cmds;       // swaps the committed & uncommitted cmd
+       int m_uncommitted_cmd;  // state of the 4 uncommitted switches..
+};
+
+class eDVBSatelliteSwitchParameters
+{
+public:
+       enum t_22khz_signal {   HILO=0, ON=1, OFF=2     }; // 22 Khz
+       enum t_voltage_mode     {       HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
+       t_voltage_mode m_voltage_mode;
+       t_22khz_signal m_22khz_signal;
+};
+
+class eDVBSatelliteRotorParameters
+{
+public:
+       enum { NORTH, SOUTH, EAST, WEST };
+
+       struct eDVBSatelliteRotorInputpowerParameters
+       {
+               bool m_use;     // can we use rotor inputpower to detect rotor running state ?
+               int m_threshold;        // threshold between running and stopped rotor
+       };
+       eDVBSatelliteRotorInputpowerParameters m_inputpower_parameters;
+
+       struct eDVBSatelliteRotorGotoxxParameters
+       {
+               bool m_can_use; // rotor support gotoXX cmd ?
+               int m_lo_direction;     // EAST, WEST
+               int m_la_direction;     // NORT, SOUTH
+               double m_longitude;     // longitude for gotoXX┬░ function
+               double m_latitude;      // latitude for gotoXX┬░ function
+       };
+       eDVBSatelliteRotorGotoxxParameters m_gotoxx_parameters;
+
+       struct Orbital_Position_Compare
+       {
+               inline bool operator()(const int &i1, const int &i2) const
+               {
+                       return abs(i1-i2) < 6 ? false: i1 < i2;
+               }
+       };
+       std::map< int, int, Orbital_Position_Compare > m_rotor_position_table;
+       /* mapping orbitalposition <-> number stored in rotor */
+
+       void setDefaultOptions(); // set default rotor options
+};
+
+class eDVBSatelliteParameters
+{
+public:
+       eDVBSatelliteDiseqcParameters m_diseqc_parameters;
+       eDVBSatelliteRotorParameters m_rotor_parameters;
+       eDVBSatelliteSwitchParameters m_switch_parameters;
+};
+
+class eDVBSatelliteLNBParameters
+{
+public:
+       enum t_12V_relais_state { OFF=0, ON };
+       t_12V_relais_state m_12V_relais_state;  // 12V relais output on/off
+
+       unsigned int m_lof_hi,  // for 2 band universal lnb 10600 Mhz (high band offset frequency)
+                               m_lof_lo,       // for 2 band universal lnb  9750 Mhz (low band offset frequency)
+                               m_lof_threshold;        // for 2 band universal lnb 11750 Mhz (band switch frequency)
+
+       bool m_increased_voltage; // use increased voltage ( 14/18V )
+
+       std::map<int, eDVBSatelliteParameters> m_satellites;
+};
+
 class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
 {
+       std::list<eDVBSatelliteLNBParameters> m_lnblist;
 public:
        DECLARE_REF(eDVBSatelliteEquipmentControl);
        eDVBSatelliteEquipmentControl();