zapit: improve unicable support

* support the LNB input parameter (bank)
* save config per position in sat.conf
This commit is contained in:
Stefan Seyfried
2012-07-08 15:56:03 +02:00
parent b23b15b796
commit ab3ac9a4c3
6 changed files with 36 additions and 22 deletions

View File

@@ -181,6 +181,7 @@ typedef struct Zapit_config {
double gotoXXLongitude;
int uni_scr;
int uni_qrg;
int uni_lnb;
} t_zapit_config;
typedef std::map <uint32_t, TP_map> TP_map_t;

View File

@@ -109,7 +109,8 @@ class CFrontend
/* variables for EN 50494 (a.k.a Unicable) */
int uni_scr; /* the unicable SCR address, -1 == no unicable */
int uni_qrg; /* the unicable frequency in MHz, 0 == from spec */
int uni_qrg; /* the unicable frequency in MHz */
int uni_lnb; /* the input (0/1) of a twin-position switch */
int motorRotationSpeed; //in 0.1 degrees per second
bool highVoltage;
@@ -192,7 +193,6 @@ class CFrontend
};
void configRotor(int _motorRotationSpeed, bool _highVoltage)
{ motorRotationSpeed = _motorRotationSpeed; highVoltage = _highVoltage; };
void configUnicable(int scr, int qrg) { uni_scr = scr; uni_qrg = qrg; };
int setParameters(TP_params *TP, bool nowait = 0);
int tuneFrequency (struct dvb_frontend_parameters * feparams, uint8_t polarization, bool nowait = false);

View File

@@ -16,6 +16,9 @@ typedef struct sat_config {
int have_channels;
t_satellite_position position;
int input;
int unicable_scr;
int unicable_qrg;
int unicable_lnb;
} sat_config_t;
typedef enum diseqc_cmd_order {

View File

@@ -3,6 +3,8 @@
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* (C) 2007-2012 Stefan Seyfried
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -170,7 +172,8 @@ CFrontend::CFrontend(int Number, int Adapter)
currentTransponder.diseqc = 255;
uni_scr = -1; /* the unicable SCR address, -1 == no unicable */
uni_qrg = 0; /* the unicable frequency in MHz, 0 == from spec */
uni_qrg = 0; /* the unicable frequency in MHz */
uni_lnb = 0; /* for two-position switches */
feTimeout = 40;
highVoltage = false;
@@ -698,7 +701,7 @@ bool CFrontend::buildProperties(const struct dvb_frontend_parameters *feparams,
cmdseq.props[FREQUENCY].u.data = sendEN50494TuningCommand(feparams->frequency,
currentToneMode == SEC_TONE_ON,
currentVoltage == SEC_VOLTAGE_18,
0); /* bank 0/1, like mini-diseqc a/b, not impl.*/
uni_lnb);
cmdseq.num += nrOfProps;
@@ -980,6 +983,11 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque
if (currentSatellitePosition != satellitePosition)
#endif
setLnbOffsets(sit->second.lnbOffsetLow, sit->second.lnbOffsetHigh, sit->second.lnbSwitch);
/* unicable */
uni_scr = sit->second.unicable_scr;
uni_qrg = sit->second.unicable_qrg;
uni_lnb = sit->second.unicable_lnb;
if (diseqcType != DISEQC_ADVANCED) {
setDiseqc(sit->second.diseqc, polarization, frequency);
return;
@@ -1001,12 +1009,7 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque
uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int high_band,
const int horizontal, const int bank)
{
uint32_t uni_qrgs[] = { 1284, 1400, 1516, 1632, 1748, 1864, 1980, 2096 };
uint32_t bpf;
if (uni_qrg == 0)
bpf = uni_qrgs[uni_scr];
else
bpf = uni_qrg;
uint32_t bpf = uni_qrg;
struct dvb_diseqc_master_cmd cmd = {
{0xe0, 0x10, 0x5a, 0x00, 0x00, 0x00}, 5
@@ -1014,7 +1017,7 @@ uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int
unsigned int t = (frequency / 1000 + bpf + 2) / 4 - 350;
if (t < 1024 && uni_scr >= 0 && uni_scr < 8)
{
fprintf(stderr, "VOLT18=%d TONE_ON=%d, freq=%d bpf=%d ret=%d\n", currentVoltage == SEC_VOLTAGE_18, currentToneMode == SEC_TONE_ON, frequency, bpf, (t + 350) * 4000 - frequency);
fprintf(stderr, "[unicable] VOLT18=%d TONE_ON=%d, freq=%d bpf=%d uni_scr=%d bank=%d ret=%d\n", currentVoltage == SEC_VOLTAGE_18, currentToneMode == SEC_TONE_ON, frequency, bpf, uni_scr, bank, (t + 350) * 4000 - frequency);
cmd.msg[3] = (t >> 8) | /* highest 3 bits of t */
(uni_scr << 5) | /* adress */
(bank << 4) | /* not implemented yet */

View File

@@ -3,6 +3,8 @@
*
* (C) 2002, 2003 by Andreas Oberritter <obi@tuxbox.org>
*
* (C) 2007-2012 Stefan Seyfried
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -484,6 +486,7 @@ int CServiceManager::LoadMotorPositions(void)
char buffer[256] = "";
t_satellite_position satellitePosition;
int spos = 0, mpos = 0, diseqc = 0, uncom = 0, com = 0, usals = 0, inuse, input = 0;
int uniscr = -1, uniqrg = 0, unilnb = 0;
int offH = 10600, offL = 9750, sw = 11700;
printf("[getservices] loading motor positions...\n");
@@ -491,7 +494,12 @@ int CServiceManager::LoadMotorPositions(void)
if ((fd = fopen(SATCONFIG, "r"))) {
fgets(buffer, 255, fd);
while(!feof(fd)) {
sscanf(buffer, "%d %d %d %d %d %d %d %d %d %d %d", &spos, &mpos, &diseqc, &com, &uncom, &offL, &offH, &sw, &inuse, &usals, &input);
if (sscanf(buffer, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d",
&spos, &mpos, &diseqc, &com, &uncom, &offL, &offH,
&sw, &inuse, &usals, &input, &uniscr, &uniqrg, &unilnb) < 14) {
uniqrg = unilnb = 0;
uniscr = -1;
}
satellitePosition = spos;
sat_iterator_t sit = satellitePositions.find(satellitePosition);
@@ -507,6 +515,9 @@ int CServiceManager::LoadMotorPositions(void)
sit->second.use_usals = usals;
sit->second.input = input;
sit->second.position = satellitePosition;
sit->second.unicable_scr = uniscr;
sit->second.unicable_qrg = uniqrg;
sit->second.unicable_lnb = unilnb;
}
fgets(buffer, 255, fd);
}
@@ -529,11 +540,12 @@ void CServiceManager::SaveMotorPositions()
printf("[zapit] cannot open %s\n", SATCONFIG);
return;
}
fprintf(fd, "# sat position, stored rotor, diseqc, commited, uncommited, low, high, switch, use in full scan, use usals, input\n");
fprintf(fd, "# sat position, stored rotor, diseqc, commited, uncommited, low, high, switch, use in full scan, use usals, input, unicable_scr, unicable_freq, unicable_lnb\n");
for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) {
fprintf(fd, "%d %d %d %d %d %d %d %d %d %d %d\n", sit->first, sit->second.motor_position,
fprintf(fd, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", sit->first, sit->second.motor_position,
sit->second.diseqc, sit->second.commited, sit->second.uncommited, sit->second.lnbOffsetLow,
sit->second.lnbOffsetHigh, sit->second.lnbSwitch, sit->second.use_in_scan, sit->second.use_usals, sit->second.input);
sit->second.lnbOffsetHigh, sit->second.lnbSwitch, sit->second.use_in_scan, sit->second.use_usals, sit->second.input,
sit->second.unicable_scr, sit->second.unicable_qrg, sit->second.unicable_lnb);
}
fdatasync(fileno(fd));
fclose(fd);
@@ -553,6 +565,8 @@ void CServiceManager::InitSatPosition(t_satellite_position position)
satellitePositions[position].use_in_scan = 0;
satellitePositions[position].use_usals = 0;
satellitePositions[position].input = 0;
satellitePositions[position].unicable_scr = -1;
satellitePositions[position].unicable_qrg = 0;
}
bool CServiceManager::LoadServices(bool only_current)

View File

@@ -186,9 +186,6 @@ void CZapit::SaveSettings(bool write, bool write_a)
configfile.setInt32("repeatUsals", config.repeatUsals);
configfile.setInt32("scanSDT", config.scanSDT);
configfile.setInt32("uni_scr", config.uni_scr);
configfile.setInt32("uni_qrg", config.uni_qrg);
configfile.setInt32("cam_ci", cam_ci);
#if 0 // unused
@@ -267,9 +264,6 @@ void CZapit::LoadSettings()
config.scanSDT = configfile.getInt32("scanSDT", 0);
config.uni_scr = configfile.getInt32("uni_scr", -1);
config.uni_qrg = configfile.getInt32("uni_qrg", 0);
cam_ci = configfile.getInt32("cam_ci", 2);
diseqcType = (diseqc_t)configfile.getInt32("diseqcType", NO_DISEQC);
@@ -300,7 +294,6 @@ void CZapit::ConfigFrontend()
CFrontend::getInstance()->configUsals(config.gotoXXLatitude, config.gotoXXLongitude,
config.gotoXXLaDirection, config.gotoXXLoDirection, config.repeatUsals);
CFrontend::getInstance()->configRotor(config.motorRotationSpeed, config.highVoltage);
CFrontend::getInstance()->configUnicable(config.uni_scr, config.uni_qrg);
}
void CZapit::SendPMT(bool forupdate)