1 #include <lib/dvb/dvb.h>
2 #include <lib/dvb/sec.h>
3 #include <lib/dvb/rotor_calc.h>
4 #include <lib/dvb/dvbtime.h>
8 #if HAVE_DVB_API_VERSION < 3
9 #define FREQUENCY Frequency
11 #define FREQUENCY frequency
13 #include <lib/base/eerror.h>
18 #define eSecDebug(arg...) eDebug(arg)
20 #define eSecDebug(arg...)
23 DEFINE_REF(eDVBSatelliteEquipmentControl);
25 eDVBSatelliteEquipmentControl *eDVBSatelliteEquipmentControl::instance;
27 int eDVBSatelliteEquipmentControl::m_params[MAX_PARAMS];
29 defaults are set in python lib/python/Components/NimManager.py
30 in InitSecParams function via setParam call
33 void eDVBSatelliteEquipmentControl::setParam(int param, int value)
35 if (param >= 0 && param < MAX_PARAMS)
36 m_params[param]=value;
39 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends)
40 :m_lnbidx(-1), m_curSat(m_lnbs[0].m_satellites.end()), m_avail_frontends(avail_frontends), m_avail_simulate_frontends(avail_simulate_frontends), m_rotorMoving(false)
51 setLNBThreshold(11700000);
53 setDiSEqCMode(eDVBSatelliteDiseqcParameters::V1_0);
54 setToneburst(eDVBSatelliteDiseqcParameters::NO);
56 setCommittedCommand(eDVBSatelliteDiseqcParameters::BB);
57 setCommandOrder(0); // committed, toneburst
61 setVoltageMode(eDVBSatelliteSwitchParameters::HV);
62 setToneMode(eDVBSatelliteSwitchParameters::HILO);
68 setLNBThreshold(11700000);
70 setDiSEqCMode(eDVBSatelliteDiseqcParameters::V1_0);
71 setToneburst(eDVBSatelliteDiseqcParameters::NO);
73 setCommittedCommand(eDVBSatelliteDiseqcParameters::AB);
74 setCommandOrder(0); // committed, toneburst
78 setVoltageMode(eDVBSatelliteSwitchParameters::HV);
79 setToneMode(eDVBSatelliteSwitchParameters::HILO);
85 setLNBThreshold(11700000);
87 setDiSEqCMode(eDVBSatelliteDiseqcParameters::V1_2);
88 setToneburst(eDVBSatelliteDiseqcParameters::NO);
90 setCommittedCommand(eDVBSatelliteDiseqcParameters::AA);
91 setCommandOrder(0); // committed, toneburst
94 setLaDirection(eDVBSatelliteRotorParameters::NORTH);
95 setLoDirection(eDVBSatelliteRotorParameters::EAST);
98 setUseInputpower(true);
99 setInputpowerDelta(50);
102 setVoltageMode(eDVBSatelliteSwitchParameters::HV);
103 setToneMode(eDVBSatelliteSwitchParameters::HILO);
107 setVoltageMode(eDVBSatelliteSwitchParameters::HV);
108 setToneMode(eDVBSatelliteSwitchParameters::HILO);
112 setVoltageMode(eDVBSatelliteSwitchParameters::HV);
113 setToneMode(eDVBSatelliteSwitchParameters::HILO);
114 setRotorPosNum(1); // stored pos 1
117 #define eSecDebugNoSimulate(x...) \
124 // eDebugNoNewLine("SIMULATE:"); \
128 int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int slot_id, int *highest_score_lnb)
130 bool simulate = ((eDVBFrontend*)fe)->is_simulate();
131 int score=0, satcount=0;
133 if (highest_score_lnb)
134 *highest_score_lnb = -1;
136 eSecDebugNoSimulate("canTune %d", slot_id);
138 for (int idx=0; idx <= m_lnbidx; ++idx )
141 eDVBSatelliteLNBParameters &lnb_param = m_lnbs[idx];
142 if ( lnb_param.slot_mask & slot_id ) // lnb for correct tuner?
145 eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
147 eSecDebugNoSimulate("lnb %d found", idx);
149 satcount += lnb_param.m_satellites.size();
151 std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
152 lnb_param.m_satellites.find(sat.orbital_position);
153 if ( sit != lnb_param.m_satellites.end())
156 bool direct_connected = m_not_linked_slot_mask & slot_id;
160 satpos_depends_ptr=-1,
161 csw = di_param.m_committed_cmd,
162 ucsw = di_param.m_uncommitted_cmd,
163 toneburst = di_param.m_toneburst_param,
166 eSecDebugNoSimulate("sat %d found", sat.orbital_position);
167 fe->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
168 fe->getData(eDVBFrontend::SATPOS_DEPENDS_PTR, satpos_depends_ptr);
170 if ( sat.frequency > lnb_param.m_lof_threshold )
172 if (!(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation::Vertical))
175 if (di_param.m_diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
178 if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
179 csw = 0xF0 | (csw << 2);
181 if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO)
184 if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) // ROTOR
195 eSecDebugNoSimulate("ret1 %d", ret);
197 if (direct_connected) // frontend with direct connection?
202 eSecDebugNoSimulate("direct");
203 fe->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
204 fe->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
205 fe->getData(eDVBFrontend::CSW, ocsw);
206 fe->getData(eDVBFrontend::UCSW, oucsw);
207 fe->getData(eDVBFrontend::TONEBURST, oToneburst);
208 while (ret && linked_prev_ptr != -1) // check for linked tuners..
210 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
211 if (linked_fe->m_inuse)
213 if ( (csw != ocsw) ||
214 ( diseqc && (ucsw != oucsw || toneburst != oToneburst) ) ||
215 ( rotor && curRotorPos != sat.orbital_position ) )
220 linked_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
222 eSecDebugNoSimulate("ret2 %d", ret);
223 while (ret && linked_next_ptr != -1) // check for linked tuners..
225 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_next_ptr;
226 if (linked_fe->m_inuse)
228 if ( (csw != ocsw) ||
229 ( diseqc && (ucsw != oucsw || toneburst != oToneburst) ) ||
230 ( rotor && curRotorPos != sat.orbital_position ) )
235 linked_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, (long&)linked_next_ptr);
237 eSecDebugNoSimulate("ret3 %d", ret);
239 else // linked frontend..
244 while (linked_prev_ptr != -1)
246 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
247 linked_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
248 if (linked_prev_ptr == -1)
250 iDVBFrontend *sec_fe = linked_fe->m_frontend;
251 sec_fe->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
252 if (linked_fe->m_inuse)
254 sec_fe->getData(eDVBFrontend::CSW, ocsw);
255 sec_fe->getData(eDVBFrontend::UCSW, oucsw);
256 sec_fe->getData(eDVBFrontend::TONEBURST, oToneburst);
257 eSecDebug("(%ld != %ld) || \n(%d && (%ld != %ld || %ld != %ld) ) ||\n( %d && %ld != %d ) )",
258 csw, ocsw, diseqc, ucsw, oucsw, toneburst, oToneburst, rotor, curRotorPos, sat.orbital_position);
259 if ( (csw != ocsw) ||
260 ( diseqc && (ucsw != oucsw || toneburst != oToneburst) ) ||
261 ( rotor && curRotorPos != sat.orbital_position ) )
268 eSecDebugNoSimulate("ret4 %d", ret);
271 if (ret && rotor && curRotorPos != -1 && direct_connected) {
272 ret -= abs(curRotorPos-sat.orbital_position);
275 eSecDebugNoSimulate("ret5 %d", ret);
278 if (satpos_depends_ptr != -1)
280 eSecDebugNoSimulate("satpos depends");
281 eDVBRegisteredFrontend *satpos_depends_to_fe = (eDVBRegisteredFrontend*) satpos_depends_ptr;
282 if ( satpos_depends_to_fe->m_inuse )
284 if (!direct_connected)
285 satpos_depends_to_fe->m_frontend->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
286 if (!rotor || curRotorPos != sat.orbital_position)
289 eSecDebugNoSimulate("ret6 %d", ret);
294 int lof = sat.frequency > lnb_param.m_lof_threshold ?
295 lnb_param.m_lof_hi : lnb_param.m_lof_lo;
296 int tuner_freq = abs(sat.frequency - lof);
297 if (tuner_freq < 900000 || tuner_freq > 2200000)
301 eSecDebugNoSimulate("ret %d, score old %d", ret, score);
305 if (highest_score_lnb)
306 *highest_score_lnb = idx;
308 eSecDebugNoSimulate("score new %d", score);
312 if (score && satcount)
313 score -= (satcount-1);
314 if (score && m_not_linked_slot_mask & slot_id)
315 score += 5; // increase score for tuners with direct sat connection
316 eSecDebugNoSimulate("final score %d", score);
320 bool need_turn_fast(int turn_speed)
322 if (turn_speed == eDVBSatelliteRotorParameters::FAST)
324 else if (turn_speed != eDVBSatelliteRotorParameters::SLOW)
326 int begin = turn_speed >> 16; // high word is start time
327 int end = turn_speed&0xFFFF; // low word is end time
328 time_t now_time = ::time(0);
330 localtime_r(&now_time, &nowTime);
331 int now = (nowTime.tm_hour + 1) * 60 + nowTime.tm_min + 1;
332 bool neg = end <= begin;
338 if ((now >= begin && now < end) ^ neg)
344 #define VOLTAGE(x) (lnb_param.m_increased_voltage ? iDVBFrontend::voltage##x##_5 : iDVBFrontend::voltage##x)
346 #define eDebugNoSimulate(x...) \
353 // eDebugNoNewLine("SIMULATE:"); \
357 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int slot_id, unsigned int tunetimeout)
359 bool simulate = ((eDVBFrontend*)&frontend)->is_simulate();
361 if (canTune(sat, &frontend, slot_id, &lnb_idx))
363 eDVBSatelliteLNBParameters &lnb_param = m_lnbs[lnb_idx];
364 eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
365 eDVBSatelliteRotorParameters &rotor_param = lnb_param.m_rotor_parameters;
367 std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
368 lnb_param.m_satellites.find(sat.orbital_position);
369 if ( sit != lnb_param.m_satellites.end())
371 eDVBSatelliteSwitchParameters &sw_param = sit->second;
372 bool doSetFrontend = true;
373 bool doSetVoltageToneFrontend = true;
374 bool sendDiSEqC = false;
376 voltage = iDVBFrontend::voltageOff,
377 tone = iDVBFrontend::toneOff,
378 csw = di_param.m_committed_cmd,
379 ucsw = di_param.m_uncommitted_cmd,
380 toneburst = di_param.m_toneburst_param,
386 satposDependPtr = -1;
387 iDVBFrontend *sec_fe=&frontend;
388 eDVBSatelliteDiseqcParameters::t_diseqc_mode diseqc_mode = di_param.m_diseqc_mode;
390 frontend.getData(eDVBFrontend::SATPOS_DEPENDS_PTR, satposDependPtr);
392 if (!(m_not_linked_slot_mask & slot_id)) // frontend with direct connection?
394 long linked_prev_ptr;
395 frontend.getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
396 while (linked_prev_ptr != -1)
398 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
399 sec_fe = linked_fe->m_frontend;
400 sec_fe->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
402 if (satposDependPtr != -1) // we dont need uncommitted switch and rotor cmds on second output of a rotor lnb
403 diseqc_mode = eDVBSatelliteDiseqcParameters::V1_0;
406 sec_fe->getData(eDVBFrontend::CSW, lastcsw);
407 sec_fe->getData(eDVBFrontend::UCSW, lastucsw);
408 sec_fe->getData(eDVBFrontend::TONEBURST, lastToneburst);
409 sec_fe->getData(eDVBFrontend::ROTOR_CMD, lastRotorCmd);
410 sec_fe->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
412 if ( sat.frequency > lnb_param.m_lof_threshold )
416 parm.FREQUENCY = sat.frequency - lnb_param.m_lof_hi;
418 parm.FREQUENCY = sat.frequency - lnb_param.m_lof_lo;
420 parm.FREQUENCY = abs(parm.FREQUENCY);
422 frontend.setData(eDVBFrontend::FREQ_OFFSET, sat.frequency - parm.FREQUENCY);
424 if (!(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation::Vertical))
427 if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_14V
428 || ( sat.polarisation & eDVBFrontendParametersSatellite::Polarisation::Vertical
429 && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
430 voltage = VOLTAGE(13);
431 else if ( sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::_18V
432 || ( !(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation::Vertical)
433 && sw_param.m_voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
434 voltage = VOLTAGE(18);
435 if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::ON)
436 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && (band&1) ) )
437 tone = iDVBFrontend::toneOn;
438 else if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::OFF)
439 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && !(band&1) ) )
440 tone = iDVBFrontend::toneOff;
442 eSecCommandList sec_sequence;
444 if (diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
446 if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
447 csw = 0xF0 | (csw << 2);
449 if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO)
453 (di_param.m_committed_cmd != eDVBSatelliteDiseqcParameters::SENDNO);
454 bool changed_csw = send_csw && csw != lastcsw;
457 (di_param.m_uncommitted_cmd && diseqc_mode > eDVBSatelliteDiseqcParameters::V1_0);
458 bool changed_ucsw = send_ucsw && ucsw != lastucsw;
461 (di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO);
462 bool changed_burst = send_burst && toneburst != lastToneburst;
464 int send_mask = 0; /*
467 4 send toneburst first
468 8 send toneburst at end */
469 if (changed_burst) // toneburst first and toneburst changed
471 if (di_param.m_command_order&1)
485 if ((di_param.m_command_order&4) && send_csw)
487 if (di_param.m_command_order==4 && send_burst)
492 if ( di_param.m_use_fast
493 && di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO
495 && ((csw / 4) == (lastcsw / 4)) )
496 eDebugNoSimulate("dont send committed cmd (fast diseqc)");
500 if (!(di_param.m_command_order&4) && send_ucsw)
502 if (!(di_param.m_command_order&1) && send_burst)
508 eDebugNoNewLine("sendmask: ");
509 for (int i=3; i >= 0; --i)
510 if ( send_mask & (1<<i) )
511 eDebugNoNewLine("1");
513 eDebugNoNewLine("0");
516 if (doSetVoltageToneFrontend)
519 bool useGotoXX = false;
520 if ( diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2
521 && !sat.no_rotor_command_on_tune )
523 if (sw_param.m_rotorPosNum) // we have stored rotor pos?
524 RotorCmd=sw_param.m_rotorPosNum;
525 else // we must calc gotoxx cmd
527 eDebugNoSimulate("Entry for %d,%d? not in Rotor Table found... i try gotoXX?", sat.orbital_position / 10, sat.orbital_position % 10 );
530 double SatLon = abs(sat.orbital_position)/10.00,
531 SiteLat = rotor_param.m_gotoxx_parameters.m_latitude,
532 SiteLon = rotor_param.m_gotoxx_parameters.m_longitude;
534 if ( rotor_param.m_gotoxx_parameters.m_la_direction == eDVBSatelliteRotorParameters::SOUTH )
537 if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST )
538 SiteLon = 360 - SiteLon;
540 eDebugNoSimulate("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
541 double satHourAngle =
542 calcSatHourangle( SatLon, SiteLat, SiteLon );
543 eDebugNoSimulate("PolarmountHourAngle=%lf", satHourAngle );
545 static int gotoXTable[10] =
546 { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
548 if (SiteLat >= 0) // Northern Hemisphere
550 int tmp=(int)round( fabs( 180 - satHourAngle ) * 10.0 );
551 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
553 if (satHourAngle < 180) // the east
558 else // Southern Hemisphere
560 if (satHourAngle < 180) // the east
562 int tmp=(int)round( fabs( satHourAngle ) * 10.0 );
563 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
568 int tmp=(int)round( fabs( 360 - satHourAngle ) * 10.0 );
569 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
573 eDebugNoSimulate("RotorCmd = %04x", RotorCmd);
579 int vlt = iDVBFrontend::voltageOff;
580 eSecCommand::pair compare;
582 compare.tone = iDVBFrontend::toneOff;
583 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
584 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
585 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) );
587 if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
589 if (rotor_param.m_inputpower_parameters.m_use)
590 vlt = VOLTAGE(18); // in input power mode set 18V for measure input power
592 vlt = VOLTAGE(13); // in normal mode start turning with 13V
597 // check if voltage is already correct..
598 compare.voltage = vlt;
600 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
602 // check if voltage is disabled
603 compare.voltage = iDVBFrontend::voltageOff;
605 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
607 // voltage is changed... use DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS
608 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, vlt) );
609 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS]) );
610 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +3) );
612 // voltage was disabled.. use DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS
613 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, vlt) );
614 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS]) );
616 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS) );
617 for (int seq_repeat = 0; seq_repeat < (di_param.m_seq_repeat?2:1); ++seq_repeat)
621 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
622 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_TONEBURST]) );
632 loops <<= di_param.m_repeats;
634 for ( int i = 0; i < loops;) // fill commands...
636 eDVBDiseqcCommand diseqc;
637 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
639 diseqc.data[0] = i ? 0xE1 : 0xE0;
640 diseqc.data[1] = 0x10;
641 if ( (send_mask & 2) && (di_param.m_command_order & 4) )
643 diseqc.data[2] = 0x39;
644 diseqc.data[3] = ucsw;
646 else if ( send_mask & 1 )
648 diseqc.data[2] = 0x38;
649 diseqc.data[3] = csw;
651 else // no committed command confed.. so send uncommitted..
653 diseqc.data[2] = 0x39;
654 diseqc.data[3] = ucsw;
656 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
662 if (diseqc.data[2] == 0x38 && (send_mask & 2))
664 else if (diseqc.data[2] == 0x39 && (send_mask & 1))
666 int tmp = m_params[DELAY_BETWEEN_DISEQC_REPEATS];
669 int delay = di_param.m_repeats ? (tmp - 54) / 2 : tmp; // standard says 100msek between two repeated commands
670 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, delay) );
672 diseqc.data[3]=(cmd==0x38) ? csw : ucsw;
673 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
676 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, delay ) );
678 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
680 else // delay 120msek when no command is in repeat gap
681 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, tmp) );
684 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
687 if ( send_mask & 8 ) // toneburst at end of sequence
689 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
690 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_TONEBURST]) );
696 eDebugNoSimulate("RotorCmd %02x, lastRotorCmd %02lx", RotorCmd, lastRotorCmd);
697 if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
699 eSecCommand::pair compare;
703 compare.tone = iDVBFrontend::toneOff;
704 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
705 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
706 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) );
708 compare.voltage = iDVBFrontend::voltageOff;
710 // the next is a check if voltage is switched off.. then we first set a voltage :)
711 // else we set voltage after all diseqc stuff..
712 sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
714 if (rotor_param.m_inputpower_parameters.m_use)
715 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) ); // set 18V for measure input power
717 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) ); // in normal mode start turning with 13V
719 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD]) ); // wait 750ms when voltage was disabled
720 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +9) ); // no need to send stop rotor cmd and recheck voltage
723 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD]) ); // wait 700ms when diseqc changed
725 eDVBDiseqcCommand diseqc;
726 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
728 diseqc.data[0] = 0xE0;
729 diseqc.data[1] = 0x31; // positioner
730 diseqc.data[2] = 0x60; // stop
731 sec_sequence.push_back( eSecCommand(eSecCommand::IF_ROTORPOS_VALID_GOTO, +5) );
732 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
733 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );
734 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
735 // wait 150msec after send rotor stop cmd
736 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_MOTOR_STOP_CMD]) );
738 diseqc.data[0] = 0xE0;
739 diseqc.data[1] = 0x31; // positioner
743 diseqc.data[2] = 0x6E; // drive to angular position
744 diseqc.data[3] = ((RotorCmd & 0xFF00) / 0x100);
745 diseqc.data[4] = RotorCmd & 0xFF;
750 diseqc.data[2] = 0x6B; // goto stored sat position
751 diseqc.data[3] = RotorCmd;
752 diseqc.data[4] = 0x00;
755 if ( rotor_param.m_inputpower_parameters.m_use )
756 { // use measure rotor input power to detect rotor state
757 bool turn_fast = need_turn_fast(rotor_param.m_inputpower_parameters.m_turning_speed);
758 eSecCommand::rotor cmd;
759 eSecCommand::pair compare;
760 compare.voltage = VOLTAGE(18);
762 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
763 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
764 // measure idle power values
765 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER]) ); // wait 150msec after voltage change
766 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 1) );
769 sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
770 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) );
771 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER]) ); // wait 150msec before measure
772 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 0) );
774 sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
775 ////////////////////////////
776 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_DISEQC_RETRYS, m_params[MOTOR_COMMAND_RETRIES]) ); // 2 retries
777 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_ROTORPARMS) );
778 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
779 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, 40) ); // 2 seconds rotor start timout
781 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) ); // 50msec delay
782 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
783 cmd.direction=1; // check for running rotor
784 cmd.deltaA=rotor_param.m_inputpower_parameters.m_delta;
787 sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) ); // check if rotor has started
788 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +2 ) ); // timeout .. we assume now the rotor is already at the correct position
789 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) ); // goto loop start
790 sec_sequence.push_back( eSecCommand(eSecCommand::IF_NO_MORE_ROTOR_DISEQC_RETRYS_GOTO, turn_fast ? 10 : 9 ) ); // timeout .. we assume now the rotor is already at the correct position
791 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -8) ); // goto loop start
793 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_MOVING) );
795 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) );
796 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, m_params[MOTOR_RUNNING_TIMEOUT]*20) ); // 2 minutes running timeout
797 // rotor running loop
798 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) ); // wait 50msec
799 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
800 cmd.direction=0; // check for stopped rotor
802 sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) );
803 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +2 ) ); // timeout ? this should never happen
804 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) ); // running loop start
805 /////////////////////
806 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
807 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_STOPPED) );
810 { // use normal turning mode
811 doSetVoltageToneFrontend=false;
813 eSecCommand::rotor cmd;
814 eSecCommand::pair compare;
815 compare.voltage = VOLTAGE(13);
817 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
818 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
819 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD]) ); // wait 150msec after voltage change
821 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_ROTORPARMS) );
822 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_MOVING) );
823 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
825 compare.voltage = voltage;
827 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) ); // correct final voltage?
828 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 2000) ); // wait 2 second before set high voltage
829 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
832 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
833 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
834 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) );
835 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
837 cmd.direction=1; // check for running rotor
841 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, m_params[MOTOR_RUNNING_TIMEOUT]*4) ); // 2 minutes running timeout
842 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 250) ); // 250msec delay
843 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TUNER_LOCKED_GOTO, cmd ) );
844 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +3 ) );
845 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -3) ); // goto loop start
846 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
847 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_STOPPED) );
848 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +3) );
849 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
850 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) );
852 sec_fe->setData(eDVBFrontend::NEW_ROTOR_CMD, RotorCmd);
853 sec_fe->setData(eDVBFrontend::NEW_ROTOR_POS, sat.orbital_position);
860 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS) );
865 sec_sequence.push_front( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
867 sec_fe->setData(eDVBFrontend::NEW_CSW, csw);
868 sec_fe->setData(eDVBFrontend::NEW_UCSW, ucsw);
869 sec_fe->setData(eDVBFrontend::NEW_TONEBURST, di_param.m_toneburst_param);
871 if (doSetVoltageToneFrontend)
873 eSecCommand::pair compare;
874 compare.voltage = voltage;
876 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) ); // voltage already correct ?
877 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
878 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_VOLTAGE_CHANGE]) );
880 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
881 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
882 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE]) );
885 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_SWITCHPARMS) );
889 sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, tunetimeout) );
890 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND) );
894 sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeDynamic) );
896 frontend.setSecSequence(sec_sequence);
901 eDebugNoSimulate("found no useable satellite configuration for %s freq %d%s %s on orbital position (%d)",
902 sat.system ? "DVB-S2" : "DVB-S",
904 sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal ? "H" :
905 eDVBFrontendParametersSatellite::Polarisation::Vertical ? "V" :
906 eDVBFrontendParametersSatellite::Polarisation::CircularLeft ? "CL" : "CR",
907 sat.modulation == eDVBFrontendParametersSatellite::Modulation::Auto ? "AUTO" :
908 eDVBFrontendParametersSatellite::Modulation::QPSK ? "QPSK" :
909 eDVBFrontendParametersSatellite::Modulation::M8PSK ? "8PSK" : "QAM16",
910 sat.orbital_position );
914 RESULT eDVBSatelliteEquipmentControl::clear()
916 eSecDebug("eDVBSatelliteEquipmentControl::clear()");
917 for (int i=0; i <= m_lnbidx; ++i)
919 m_lnbs[i].m_satellites.clear();
920 m_lnbs[i].slot_mask = 0;
924 m_not_linked_slot_mask=0;
926 //reset some tuner configuration
927 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
930 if (!strcmp(it->m_frontend->getDescription(), "BCM4501 (internal)") && !it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, tmp) && tmp != -1)
932 FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
933 if (!f || fwrite("B", 1, 1, f) != 1)
934 eDebug("set /proc/stb/tsmux/lnb_b_input to B failed!! (%m)");
937 eDebug("set /proc/stb/tsmux/lnb_b_input to B OK");
941 it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
942 it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
943 it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
944 it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
945 it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
948 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
950 it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
951 it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
952 it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
953 it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
954 it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
960 /* LNB Specific Parameters */
961 RESULT eDVBSatelliteEquipmentControl::addLNB()
963 if ( (m_lnbidx+1) < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)))
964 m_curSat=m_lnbs[++m_lnbidx].m_satellites.end();
967 eDebug("no more LNB free... cnt is %d", m_lnbidx);
970 eSecDebug("eDVBSatelliteEquipmentControl::addLNB(%d)", m_lnbidx);
974 RESULT eDVBSatelliteEquipmentControl::setLNBSlotMask(int slotmask)
976 eSecDebug("eDVBSatelliteEquipmentControl::setLNBSlotMask(%d)", slotmask);
977 if ( currentLNBValid() )
978 m_lnbs[m_lnbidx].slot_mask = slotmask;
984 RESULT eDVBSatelliteEquipmentControl::setLNBLOFL(int lofl)
986 eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFL(%d)", lofl);
987 if ( currentLNBValid() )
988 m_lnbs[m_lnbidx].m_lof_lo = lofl;
994 RESULT eDVBSatelliteEquipmentControl::setLNBLOFH(int lofh)
996 eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFH(%d)", lofh);
997 if ( currentLNBValid() )
998 m_lnbs[m_lnbidx].m_lof_hi = lofh;
1004 RESULT eDVBSatelliteEquipmentControl::setLNBThreshold(int threshold)
1006 eSecDebug("eDVBSatelliteEquipmentControl::setLNBThreshold(%d)", threshold);
1007 if ( currentLNBValid() )
1008 m_lnbs[m_lnbidx].m_lof_threshold = threshold;
1014 RESULT eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(bool onoff)
1016 eSecDebug("eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(%d)", onoff);
1017 if ( currentLNBValid() )
1018 m_lnbs[m_lnbidx].m_increased_voltage = onoff;
1024 /* DiSEqC Specific Parameters */
1025 RESULT eDVBSatelliteEquipmentControl::setDiSEqCMode(int diseqcmode)
1027 eSecDebug("eDVBSatelliteEquipmentControl::setDiSEqcMode(%d)", diseqcmode);
1028 if ( currentLNBValid() )
1029 m_lnbs[m_lnbidx].m_diseqc_parameters.m_diseqc_mode = (eDVBSatelliteDiseqcParameters::t_diseqc_mode)diseqcmode;
1035 RESULT eDVBSatelliteEquipmentControl::setToneburst(int toneburst)
1037 eSecDebug("eDVBSatelliteEquipmentControl::setToneburst(%d)", toneburst);
1038 if ( currentLNBValid() )
1039 m_lnbs[m_lnbidx].m_diseqc_parameters.m_toneburst_param = (eDVBSatelliteDiseqcParameters::t_toneburst_param)toneburst;
1045 RESULT eDVBSatelliteEquipmentControl::setRepeats(int repeats)
1047 eSecDebug("eDVBSatelliteEquipmentControl::setRepeats(%d)", repeats);
1048 if ( currentLNBValid() )
1049 m_lnbs[m_lnbidx].m_diseqc_parameters.m_repeats=repeats;
1055 RESULT eDVBSatelliteEquipmentControl::setCommittedCommand(int command)
1057 eSecDebug("eDVBSatelliteEquipmentControl::setCommittedCommand(%d)", command);
1058 if ( currentLNBValid() )
1059 m_lnbs[m_lnbidx].m_diseqc_parameters.m_committed_cmd=command;
1065 RESULT eDVBSatelliteEquipmentControl::setUncommittedCommand(int command)
1067 eSecDebug("eDVBSatelliteEquipmentControl::setUncommittedCommand(%d)", command);
1068 if ( currentLNBValid() )
1069 m_lnbs[m_lnbidx].m_diseqc_parameters.m_uncommitted_cmd = command;
1075 RESULT eDVBSatelliteEquipmentControl::setCommandOrder(int order)
1077 eSecDebug("eDVBSatelliteEquipmentControl::setCommandOrder(%d)", order);
1078 if ( currentLNBValid() )
1079 m_lnbs[m_lnbidx].m_diseqc_parameters.m_command_order=order;
1085 RESULT eDVBSatelliteEquipmentControl::setFastDiSEqC(bool onoff)
1087 eSecDebug("eDVBSatelliteEquipmentControl::setFastDiSEqc(%d)", onoff);
1088 if ( currentLNBValid() )
1089 m_lnbs[m_lnbidx].m_diseqc_parameters.m_use_fast=onoff;
1095 RESULT eDVBSatelliteEquipmentControl::setSeqRepeat(bool onoff)
1097 eSecDebug("eDVBSatelliteEquipmentControl::setSeqRepeat(%d)", onoff);
1098 if ( currentLNBValid() )
1099 m_lnbs[m_lnbidx].m_diseqc_parameters.m_seq_repeat = onoff;
1105 /* Rotor Specific Parameters */
1106 RESULT eDVBSatelliteEquipmentControl::setLongitude(float longitude)
1108 eSecDebug("eDVBSatelliteEquipmentControl::setLongitude(%f)", longitude);
1109 if ( currentLNBValid() )
1110 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_longitude=longitude;
1116 RESULT eDVBSatelliteEquipmentControl::setLatitude(float latitude)
1118 eSecDebug("eDVBSatelliteEquipmentControl::setLatitude(%f)", latitude);
1119 if ( currentLNBValid() )
1120 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_latitude=latitude;
1126 RESULT eDVBSatelliteEquipmentControl::setLoDirection(int direction)
1128 eSecDebug("eDVBSatelliteEquipmentControl::setLoDirection(%d)", direction);
1129 if ( currentLNBValid() )
1130 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_lo_direction=direction;
1136 RESULT eDVBSatelliteEquipmentControl::setLaDirection(int direction)
1138 eSecDebug("eDVBSatelliteEquipmentControl::setLaDirection(%d)", direction);
1139 if ( currentLNBValid() )
1140 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_la_direction=direction;
1146 RESULT eDVBSatelliteEquipmentControl::setUseInputpower(bool onoff)
1148 eSecDebug("eDVBSatelliteEquipmentControl::setUseInputpower(%d)", onoff);
1149 if ( currentLNBValid() )
1150 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_use=onoff;
1156 RESULT eDVBSatelliteEquipmentControl::setInputpowerDelta(int delta)
1158 eSecDebug("eDVBSatelliteEquipmentControl::setInputpowerDelta(%d)", delta);
1159 if ( currentLNBValid() )
1160 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_delta=delta;
1166 /* Satellite Specific Parameters */
1167 RESULT eDVBSatelliteEquipmentControl::addSatellite(int orbital_position)
1169 eSecDebug("eDVBSatelliteEquipmentControl::addSatellite(%d)", orbital_position);
1170 if ( currentLNBValid() )
1172 std::map<int, eDVBSatelliteSwitchParameters>::iterator it =
1173 m_lnbs[m_lnbidx].m_satellites.find(orbital_position);
1174 if ( it == m_lnbs[m_lnbidx].m_satellites.end() )
1176 std::pair<std::map<int, eDVBSatelliteSwitchParameters>::iterator, bool > ret =
1177 m_lnbs[m_lnbidx].m_satellites.insert(
1178 std::pair<int, eDVBSatelliteSwitchParameters>(orbital_position, eDVBSatelliteSwitchParameters())
1181 m_curSat = ret.first;
1193 RESULT eDVBSatelliteEquipmentControl::setVoltageMode(int mode)
1195 eSecDebug("eDVBSatelliteEquipmentControl::setVoltageMode(%d)", mode);
1196 if ( currentLNBValid() && m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1197 m_curSat->second.m_voltage_mode = (eDVBSatelliteSwitchParameters::t_voltage_mode)mode;
1204 RESULT eDVBSatelliteEquipmentControl::setToneMode(int mode)
1206 eSecDebug("eDVBSatelliteEquipmentControl::setToneMode(%d)", mode);
1207 if ( currentLNBValid() )
1209 if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1210 m_curSat->second.m_22khz_signal = (eDVBSatelliteSwitchParameters::t_22khz_signal)mode;
1219 RESULT eDVBSatelliteEquipmentControl::setRotorPosNum(int rotor_pos_num)
1221 eSecDebug("eDVBSatelliteEquipmentControl::setRotorPosNum(%d)", rotor_pos_num);
1222 if ( currentLNBValid() )
1224 if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1225 m_curSat->second.m_rotorPosNum=rotor_pos_num;
1234 RESULT eDVBSatelliteEquipmentControl::setRotorTurningSpeed(int speed)
1236 eSecDebug("eDVBSatelliteEquipmentControl::setRotorTurningSpeed(%d)", speed);
1237 if ( currentLNBValid() )
1238 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_turning_speed = speed;
1246 int orb_pos, lofl, lofh;
1247 sat_compare(int o, int lofl, int lofh)
1248 :orb_pos(o), lofl(lofl), lofh(lofh)
1250 sat_compare(const sat_compare &x)
1251 :orb_pos(x.orb_pos), lofl(x.lofl), lofh(x.lofh)
1253 bool operator < (const sat_compare & cmp) const
1255 if (orb_pos == cmp.orb_pos)
1257 if ( abs(lofl-cmp.lofl) < 200000 )
1259 if (abs(lofh-cmp.lofh) < 200000)
1261 return lofh<cmp.lofh;
1263 return lofl<cmp.lofl;
1265 return orb_pos < cmp.orb_pos;
1269 RESULT eDVBSatelliteEquipmentControl::setTunerLinked(int tu1, int tu2)
1271 eSecDebug("eDVBSatelliteEquipmentControl::setTunerLinked(%d, %d)", tu1, tu2);
1274 eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
1276 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
1278 if (it->m_frontend->getSlotID() == tu1)
1280 else if (it->m_frontend->getSlotID() == tu2)
1285 p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
1286 p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
1287 if (!strcmp(p1->m_frontend->getDescription(), p2->m_frontend->getDescription()) && !strcmp(p1->m_frontend->getDescription(), "BCM4501 (internal)"))
1289 FILE *f=fopen("/proc/stb/tsmux/lnb_b_input", "w");
1290 if (!f || fwrite("A", 1, 1, f) != 1)
1291 eDebug("set /proc/stb/tsmux/lnb_b_input to A failed!! (%m)");
1294 eDebug("set /proc/stb/tsmux/lnb_b_input to A OK");
1301 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
1303 if (it->m_frontend->getSlotID() == tu1)
1305 else if (it->m_frontend->getSlotID() == tu2)
1310 p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
1311 p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
1318 RESULT eDVBSatelliteEquipmentControl::setTunerDepends(int tu1, int tu2)
1320 eSecDebug("eDVBSatelliteEquipmentControl::setTunerDepends(%d, %d)", tu1, tu2);
1324 eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
1326 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
1328 if (it->m_frontend->getSlotID() == tu1)
1330 else if (it->m_frontend->getSlotID() == tu2)
1335 p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
1336 p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
1340 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
1342 if (it->m_frontend->getSlotID() == tu1)
1344 else if (it->m_frontend->getSlotID() == tu2)
1349 p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
1350 p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
1357 void eDVBSatelliteEquipmentControl::setSlotNotLinked(int slot_no)
1359 eSecDebug("eDVBSatelliteEquipmentControl::setSlotNotLinked(%d)", slot_no);
1360 m_not_linked_slot_mask |= (1 << slot_no);
1363 bool eDVBSatelliteEquipmentControl::isRotorMoving()
1365 return m_rotorMoving;
1368 void eDVBSatelliteEquipmentControl::setRotorMoving(bool b)