+ if ( lnb_param.tuner_mask & frontend_id ) // lnb for correct tuner?
+ {
+ eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
+
+ std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
+ lnb_param.m_satellites.find(sat.orbital_position);
+ if ( sit != lnb_param.m_satellites.end())
+ {
+ int band=0,
+ linked_to=-1, // linked tuner
+ satpos_depends_to=-1,
+ csw = di_param.m_committed_cmd,
+ ucsw = di_param.m_uncommitted_cmd,
+ toneburst = di_param.m_toneburst_param,
+ curRotorPos;
+
+ fe->getData(6, curRotorPos);
+ fe->getData(7, linked_to);
+ fe->getData(8, satpos_depends_to);
+
+ if ( sat.frequency > lnb_param.m_lof_threshold )
+ band |= 1;
+ if (sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal)
+ band |= 2;
+
+ bool rotor=false;
+ bool diseqc=false;
+
+ if (di_param.m_diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
+ {
+ diseqc=true;
+ if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
+ csw = 0xF0 | (csw << 2);
+
+ if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO)
+ csw |= band;
+
+ if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) // ROTOR
+ {
+ rotor=true;
+ if ( curRotorPos == sat.orbital_position )
+ ret=20; // rotor on correct orbpos = prio 20
+ else
+ ret=10; // rotor must turn to correct orbpos = prio 10
+ }
+ else
+ ret = 30; // no rotor = prio 30
+ }
+ else
+ {
+ csw = band;
+ ret = 40; // no diseqc = prio 40
+ }
+
+ if (linked_to != -1) // check for linked tuners..
+ {
+ eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_to;
+ if (linked_fe->m_inuse)
+ {
+ int ocsw = -1,
+ oucsw = -1,
+ oToneburst = -1,
+ oRotorPos = -1;
+ linked_fe->m_frontend->getData(0, ocsw);
+ linked_fe->m_frontend->getData(1, oucsw);
+ linked_fe->m_frontend->getData(2, oToneburst);
+ linked_fe->m_frontend->getData(6, oRotorPos);
+#if 0
+ eDebug("compare csw %02x == lcsw %02x",
+ csw, ocsw);
+ if ( diseqc )
+ eDebug("compare ucsw %02x == lucsw %02x\ncompare toneburst %02x == oToneburst %02x",
+ ucsw, oucsw, toneburst, oToneburst);
+ if ( rotor )
+ eDebug("compare pos %d == current pos %d",
+ sat.orbital_position, oRotorPos);
+#endif
+ if ( (csw != ocsw) ||
+ ( diseqc && (ucsw != oucsw || toneburst != oToneburst) ) ||
+ ( rotor && oRotorPos != sat.orbital_position ) )
+ {
+// eDebug("can not tune this transponder with linked tuner in use!!");
+ ret=0;
+ }
+// else
+// eDebug("OK .. can tune this transponder with linked tuner in use :)");
+ }
+ }
+
+ if (satpos_depends_to != -1) // check for linked tuners..
+ {
+ eDVBRegisteredFrontend *satpos_depends_to_fe = (eDVBRegisteredFrontend*) satpos_depends_to;
+ if ( satpos_depends_to_fe->m_inuse )
+ {
+ int oRotorPos = -1;
+ satpos_depends_to_fe->m_frontend->getData(6, oRotorPos);
+ if (!rotor || oRotorPos != sat.orbital_position)
+ {
+// eDebug("can not tune this transponder ... rotor on other tuner is positioned to %d", oRotorPos);
+ ret=0;
+ }
+ }
+// else
+// eDebug("OK .. can tune this transponder satpos is correct :)");
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+#define VOLTAGE(x) (lnb_param.m_increased_voltage ? iDVBFrontend::voltage##x##_5 : iDVBFrontend::voltage##x)
+
+RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat, int frontend_id)
+{
+ bool linked=false;
+ bool depend_satpos_mode=false;
+
+ for (int idx=0; idx <= m_lnbidx; ++idx )
+ {
+ eDVBSatelliteLNBParameters &lnb_param = m_lnbs[idx];
+ if (!(lnb_param.tuner_mask & frontend_id)) // lnb for correct tuner?
+ continue;