Skip to content

Commit

Permalink
JESS: patch #1 by adenin, baseline code.
Browse files Browse the repository at this point in the history
Cherry-picked from Huevos/enigma2@0e4db95
  • Loading branch information
arn354 authored and eriksl committed Aug 5, 2016
1 parent a1f313b commit b764910
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 62 deletions.
112 changes: 91 additions & 21 deletions lib/dvb/sec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB
// calc Frequency
int local= abs(sat.frequency
- lof);
frequency = ((((local * 2) / 125) + 1) / 2) * 125;
volatile unsigned int tmp= (125 + 2 * local) / (2 * 125); //round to multiple of 125
frequency = 125 * tmp;
frontend.setData(eDVBFrontend::FREQ_OFFSET, sat.frequency - frequency);

/* Dishpro bandstacking HACK */
Expand All @@ -417,21 +418,47 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB
}
else
{
int tmp1 = abs(sat.frequency
-lof)
+ lnb_param.SatCRvco
- 1400000
+ lnb_param.guard_offset;
int tmp2 = ((((tmp1 * 2) / 4000) + 1) / 2) * 4000;
frequency = lnb_param.SatCRvco - (tmp1-tmp2) + lnb_param.guard_offset;
lnb_param.UnicableTuningWord = ((tmp2 / 4000)
| ((band & 1) ? 0x400 : 0) //HighLow
| ((band & 2) ? 0x800 : 0) //VertHor
| ((lnb_param.LNBNum & 1) ? 0 : 0x1000) //Umschaltung LNB1 LNB2
| (lnb_param.SatCR_idx << 13)); //Adresse des SatCR
eDebug("[eDVBSatelliteEquipmentControl] [prepare] UnicableTuningWord %#04x, guard_offset %d",lnb_param.UnicableTuningWord ,lnb_param.guard_offset);
frontend.setData(eDVBFrontend::FREQ_OFFSET, (lnb_param.UnicableTuningWord & 0x3FF) *4000 + 1400000 + lof - (2 * (lnb_param.SatCRvco - (tmp1-tmp2))) );
switch(lnb_param.SatCR_format)
{
case 1:
{
//eDebug("[prepare] JESS");
int tmp1 = abs(sat.frequency
-lof)
- 100000;
volatile unsigned int tmp2 = (1000 + 2 * tmp1) / (2 *1000); //round to multiple of 4000
frequency = lnb_param.SatCRvco - (tmp1 - (1000 * tmp2));
lnb_param.UnicableTuningWord =
(band & 0x3) //Bit0:HighLow Bit1:VertHor
| (((lnb_param.LNBNum - 1) & 0x3F) << 2) //position number (max. 63)
| ((tmp2 & 0x7FF)<< 8) //frequency (-100MHz Offset)
| ((lnb_param.SatCR_idx & 0x1F) << 19); //adresse of SatCR (max. 32)
//eDebug("[prepare] UnicableTuningWord %#06x",lnb_param.UnicableTuningWord);
frontend.setData(eDVBFrontend::FREQ_OFFSET, lnb_param.SatCRvco);
}
break;
case 0:
default:
{
//eDebug("[prepare] Unicable");
int tmp1 = abs(sat.frequency
-lof)
+ lnb_param.SatCRvco
- 1400000
+ lnb_param.guard_offset;
volatile unsigned int tmp2 = (4000 + 2 * tmp1) / (2 *4000); //round to multiple of 4000
frequency = lnb_param.SatCRvco - (tmp1 - (4000 * tmp2)) + lnb_param.guard_offset;
lnb_param.UnicableTuningWord = tmp2
| ((band & 1) ? 0x400 : 0) //HighLow
| ((band & 2) ? 0x800 : 0) //VertHor
| ((lnb_param.LNBNum & 1) ? 0 : 0x1000) //Umschaltung LNB1 LNB2
| (lnb_param.SatCR_idx << 13); //Adresse des SatCR
//eDebug("[prepare] UnicableTuningWord %#04x",lnb_param.UnicableTuningWord);
//eDebug("[prepare] guard_offset %d",lnb_param.guard_offset);
frontend.setData(eDVBFrontend::FREQ_OFFSET, (lnb_param.UnicableTuningWord & 0x3FF) *4000 + 1400000 + lof - (2 * (lnb_param.SatCRvco - (tmp1 - (4000 * tmp2)))) );
}
voltage = VOLTAGE(13);
}
}

if (diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
Expand Down Expand Up @@ -722,12 +749,24 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB

eDVBDiseqcCommand diseqc;
memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
diseqc.len = 5;
diseqc.data[0] = 0xE0;
diseqc.data[1] = 0x10;
diseqc.data[2] = 0x5A;
diseqc.data[3] = lnb_param.UnicableTuningWord >> 8;
diseqc.data[4] = lnb_param.UnicableTuningWord;
switch(lnb_param.SatCR_format)
{
case 1: //JESS
diseqc.len = 4;
diseqc.data[0] = 0x70;
diseqc.data[1] = lnb_param.UnicableTuningWord >> 16;
diseqc.data[2] = lnb_param.UnicableTuningWord >> 8;
diseqc.data[3] = lnb_param.UnicableTuningWord;
break;
case 0: //DiSEqC
default:
diseqc.len = 5;
diseqc.data[0] = 0xE0;
diseqc.data[1] = 0x10;
diseqc.data[2] = 0x5A;
diseqc.data[3] = lnb_param.UnicableTuningWord >> 8;
diseqc.data[4] = lnb_param.UnicableTuningWord;
}

sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
Expand Down Expand Up @@ -992,6 +1031,18 @@ void eDVBSatelliteEquipmentControl::prepareTurnOffSatCR(iDVBFrontend &frontend,

sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
//>>> HACK (adenin20150413)
eDVBDiseqcCommand jess;
memset(jess.data, 0, MAX_DISEQC_LENGTH);
jess.len = 4;
jess.data[0] = 0x70;
jess.data[1] = satcr << 3;
jess.data[2] = 0x00;
jess.data[3] = 0x00;

sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, jess) );
sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
//<<< End of HACK (adenin20150413)
sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
sec_sequence.push_back( eSecCommand(eSecCommand::DELAYED_CLOSE_FRONTEND) );

Expand Down Expand Up @@ -1270,6 +1321,18 @@ RESULT eDVBSatelliteEquipmentControl::setInputpowerDelta(int delta)
}

/* Unicable Specific Parameters */
RESULT eDVBSatelliteEquipmentControl::setLNBSatCRformat(int SatCR_format)
{
eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCRformat(%d)", SatCR_format);
if(!((SatCR_format >-1) && (SatCR_format < 2)))
return -EPERM;
if ( currentLNBValid() )
m_lnbs[m_lnbidx].SatCR_format = SatCR_format;
else
return -ENOENT;
return 0;
}

RESULT eDVBSatelliteEquipmentControl::setLNBSatCR(int SatCR_idx)
{
eSecDebug("[eDVBSatelliteEquipmentControl::setLNBSatCR] idx=%d", SatCR_idx);
Expand Down Expand Up @@ -1315,6 +1378,13 @@ RESULT eDVBSatelliteEquipmentControl::getLNBSatCRpositions()
return -ENOENT;
}

RESULT eDVBSatelliteEquipmentControl::getLNBSatCRformat()
{
if ( currentLNBValid() )
return m_lnbs[m_lnbidx].SatCR_format;
return -ENOENT;
}

RESULT eDVBSatelliteEquipmentControl::getLNBSatCR()
{
if ( currentLNBValid() )
Expand Down
7 changes: 5 additions & 2 deletions lib/dvb/sec.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ class eDVBSatelliteLNBParameters
#define guard_offset_min -8000
#define guard_offset_max 8000
#define guard_offset_step 8000
#define MAX_SATCR 8
#define MAX_LNBNUM 32
#define MAX_SATCR 32
#define MAX_LNBNUM 64

int SatCR_positions;
int SatCR_idx;
int SatCR_format;
unsigned int SatCRvco;
unsigned int UnicableTuningWord;
unsigned int UnicableConfigWord;
Expand Down Expand Up @@ -360,9 +361,11 @@ class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl
RESULT setInputpowerDelta(int delta); // delta between running and stopped rotor
RESULT setRotorTurningSpeed(int speed); // set turning speed..
/* Unicable Specific Parameters */
RESULT setLNBSatCRformat(int SatCR_format); //DiSEqc or JESS (or ...)
RESULT setLNBSatCR(int SatCR_idx);
RESULT setLNBSatCRvco(int SatCRvco);
RESULT setLNBSatCRpositions(int SatCR_positions);
RESULT getLNBSatCRformat(); //DiSEqc or JESS (or ...)
RESULT getLNBSatCR();
RESULT getLNBSatCRvco();
RESULT getLNBSatCRpositions();
Expand Down
Loading

0 comments on commit b764910

Please sign in to comment.