Пример #1
0
void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t frequency, uint8_t polarization)
{
	sat_iterator_t sit = satellites.find(satellitePosition);

	/* unicable uses diseqc parameter for input selection */
	config.uni_lnb = sit->second.diseqc;

	setLnbOffsets(sit->second.lnbOffsetLow, sit->second.lnbOffsetHigh, sit->second.lnbSwitch);
	if (config.diseqcType == DISEQC_UNICABLE)
		return;

	if (config.diseqcType != DISEQC_ADVANCED) {
		setDiseqc(sit->second.diseqc, polarization, frequency);
		return;
	}
	if (config.diseqc_order /*sit->second.diseqc_order*/ == COMMITED_FIRST) {
		if (setDiseqcSimple(sit->second.commited, polarization, frequency))
			uncommitedInput = 255;
		sendUncommittedSwitchesCommand(sit->second.uncommited);
	} else {
		if (sendUncommittedSwitchesCommand(sit->second.uncommited))
			currentTransponder.diseqc = -1;
		setDiseqcSimple(sit->second.commited, polarization, frequency);
	}
}
Пример #2
0
void CFrontend::setSec(const uint8_t sat_no, const uint8_t pol, const bool high_band, const uint32_t frequency)
{
	uint8_t repeats = diseqcRepeats;

	fe_sec_voltage_t v = (pol & 1) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18;
	fe_sec_tone_mode_t t = high_band ? SEC_TONE_ON : SEC_TONE_OFF;
	fe_sec_mini_cmd_t b = (sat_no & 1) ? SEC_MINI_B : SEC_MINI_A;

	/*
	 * [0] from master, no reply, 1st transmission
	 * [1] any lnb switcher or smatv
	 * [2] write to port group 0 (committed switches)
	 * [3] high nibble: reset bits, low nibble set bits
	 *     bits are: option, position, polarizaion, band
	 */

	struct dvb_diseqc_master_cmd cmd = {
		{ 0xe0, 0x10, 0x38, 0x00, 0x00, 0x00 }, 4
	};

	cmd.msg[3] = 0xf0 | (((sat_no * 4) & 0x0f) | (high_band ? 1 : 0) | ((pol & 1) ? 0 : 2));

	/*
	 * set all SEC / DiSEqC parameters
	 */

	secSetTone(SEC_TONE_OFF, 15);
	secSetVoltage(v, 15);

	if ((diseqcType == DISEQC_1_1) && (uncommitted_switch_mode > 0))
	{
		static uint8_t prevSatNo = 255; // initialised with greater than max Satellites (64)
		// because we only want to send uncommitted switch
		// command if necessary to save zap time
		DBG("new Sat %d previous Sat %d", sat_no, prevSatNo);
		//DBG("new Sat/4 %d previous Sat/4 %d", sat_no/4, prevSatNo/4);

		if ((prevSatNo/4 != sat_no/4) && (1 == uncommitted_switch_mode))
		{
			sendUncommittedSwitchesCommand(0xF0 + sat_no/4);
		}
		else if ((prevSatNo != sat_no) && (2 == uncommitted_switch_mode))
		{
			sendUncommittedSwitchesCommand(0xF0 + sat_no);
		}
		prevSatNo = sat_no;
	}

	if (diseqcType >= SMATV_REMOTE_TUNING) {
#if HAVE_DVB_API_VERSION >= 3
		if (diseqcType >= DISEQC_2_0)
			cmd.msg[0] |= 0x02;	/* reply required */

		sendDiseqcCommand(&cmd, 15);

		if (diseqcType >= DISEQC_2_0)
			repeats += getDiseqcReply(50);
#else
		sendDiseqcCommand(&cmd, 15);
#endif
	}

	if ((diseqcType >= DISEQC_1_1) && (repeats)) {
		for (uint16_t i = 0; i < repeats; i++) {

			usleep(1000 * 100);	/* wait at least 100ms before retransmission */

			if (0 == uncommitted_switch_mode) {
				cmd.msg[2] |= 0x01;	/* uncommitted switches */
				sendDiseqcCommand(&cmd, 15);
			}

#if HAVE_DVB_API_VERSION >= 3
			uint8_t again = 0;
			if (diseqcType >= DISEQC_2_0)
				again += getDiseqcReply(50);

			cmd.msg[0] |= 0x01;	/* repeated transmission */
			cmd.msg[2] &= 0xFE;	/* committed switches */
			sendDiseqcCommand(&cmd, 15);

			if (diseqcType >= DISEQC_2_0)
				again += getDiseqcReply(50);

			if (again == 2)
				repeats++;
#else
			cmd.msg[0] |= 0x01;	/* repeated transmission */
			cmd.msg[2] &= 0xFE;	/* committed switches */
			sendDiseqcCommand(&cmd, 15);
#endif
		}
	}

	if (diseqcType == SMATV_REMOTE_TUNING)
		sendDiseqcSmatvRemoteTuningCommand(frequency);

	if (diseqcType == MINI_DISEQC)
		sendToneBurst(b, 15);

	secSetTone(t, 15);

	currentTransponder.diseqc = sat_no;
}