Skip to content

Commit

Permalink
Add: Ability to turn off power to LNB on teardown #172
Browse files Browse the repository at this point in the history
  • Loading branch information
Barracuda09 committed Nov 15, 2022
1 parent 2a5899a commit 414f5fc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/input/dvb/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ bool Frontend::teardown() {
// Close active PIDs
closeActivePIDFilters();
_tuned = false;
// Do teardown of frontends before closing FE
for (const input::dvb::delivery::UpSystem &deliverySystem : _deliverySystem) {
deliverySystem->teardown(_fd_fe);
}
closeDMX();
closeFE();
_frontendData.initialize();
Expand Down
15 changes: 14 additions & 1 deletion src/input/dvb/delivery/DVBS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace input::dvb::delivery {
DVBS::DVBS(const FeIndex index, const FeID id, const std::string &fePath, unsigned int dvbVersion) :
input::dvb::delivery::System(index, id, fePath, dvbVersion),
_diseqcType(DiseqcType::Lnb),
_diseqc(new DiSEqcLnb) {
_diseqc(new DiSEqcLnb),
_turnoffLNBPower(false) {

// Only DVB-S2 have special handling for FBC tuners
_fbcSetID = readProcData(index, "fbc_set_id");
Expand Down Expand Up @@ -107,6 +108,8 @@ namespace input::dvb::delivery {
ADD_XML_ELEMENT(xml, "type", "DVB-S(2)");
}

ADD_XML_CHECKBOX(xml, "turnoffLNBPower", (_turnoffLNBPower ? "true" : "false"));

ADD_XML_BEGIN_ELEMENT(xml, "diseqcType");
ADD_XML_ELEMENT(xml, "inputtype", "selectionlist");
ADD_XML_ELEMENT(xml, "value", asInteger(_diseqcType));
Expand All @@ -125,6 +128,9 @@ namespace input::dvb::delivery {

void DVBS::doFromXML(const std::string &xml) {
std::string element;
if (findXMLElement(xml, "turnoffLNBPower.value", element)) {
_turnoffLNBPower = (element == "true") ? true : false;
}
if (findXMLElement(xml, "diseqcType.value", element)) {
const DiseqcType type = static_cast<DiseqcType>(std::stoi(element));
switch (type) {
Expand Down Expand Up @@ -231,6 +237,13 @@ namespace input::dvb::delivery {
return true;
}

void DVBS::teardown(int feFD) const {
if (_turnoffLNBPower) {
SI_LOG_INFO("Frontend: @#1, Turning off LNB Power", _feID);
_diseqc->turnOffLNBPower(feFD);
}
}

// =========================================================================
// -- Other member functions ----------------------------------------------
// =========================================================================
Expand Down
4 changes: 4 additions & 0 deletions src/input/dvb/delivery/DVBS.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class DVBS :
system == input::InputSystem::DVBS;
}

///
virtual void teardown(int feFD) const;

// =========================================================================
// -- Other member functions -----------------------------------------------
// =========================================================================
Expand Down Expand Up @@ -102,6 +105,7 @@ class DVBS :
};
DiseqcType _diseqcType;
UpDiSEqc _diseqc;
bool _turnoffLNBPower;

// =========================================================================
// -- FBC Data members -----------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/input/dvb/delivery/DiSEqc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ namespace input::dvb::delivery {
// -- Other member functions ------------------------------------------------
// ===========================================================================

void DiSEqc::turnOffLNBPower(int feFD) const {
if (ioctl(feFD, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF) == -1) {
SI_LOG_PERROR("FE_SET_VOLTAGE failed to switch off");
}
}

void DiSEqc::sendDiseqcResetCommand(int feFD, FeID id) {
dvb_diseqc_master_cmd cmd = {{0xe0, 0x00, 0x00}, 3};

Expand Down
4 changes: 4 additions & 0 deletions src/input/dvb/delivery/DiSEqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ namespace input::dvb::delivery {
virtual bool sendDiseqc(int feFD, FeID id, uint32_t &freq,
int src, Lnb::Polarization pol) = 0;

/// This will turn off the power to the LNB
/// @param feFD
virtual void turnOffLNBPower(int feFD) const;

protected:

///
Expand Down
4 changes: 4 additions & 0 deletions src/input/dvb/delivery/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE

#include <FwDecl.h>
#include <Unused.h>
#include <base/XMLSupport.h>
#include <input/InputSystem.h>

Expand Down Expand Up @@ -61,6 +62,9 @@ class System :
///
virtual bool isCapableOf(input::InputSystem system) const = 0;

///
virtual void teardown(int UNUSED(feFD)) const {}

// =======================================================================
// -- Data members -------------------------------------------------------
// =======================================================================
Expand Down
1 change: 1 addition & 0 deletions web/frontend.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
page += addTableLineEntry("RTCP Signal Update Freq", xmlDoc, streamID + "rtcpSignalUpdate");
page += addTableLineEntry("Internal Software Pid Filtering", xmlDoc, streamID + "internalPidFiltering");
page += addTableLineEntry("Wait On Tuning Lock Timeout (ms)", xmlDoc, streamID + "waitOnLockTimeout");
page += addTableLineEntry("Turn off LNB Power during teardown", xmlDoc, streamID + "turnoffLNBPower");

var transformation = visibleStream.getElementsByTagName("transformation");
if (transformation.length > 0) {
Expand Down

0 comments on commit 414f5fc

Please sign in to comment.