Ticket #2473: lnb-reversed.patch

File lnb-reversed.patch, 10.8 KB (added by kenny@…, 18 years ago)

Patch to add in reversal of polarity for circularly polarized LNBs

  • libs/libmythtv/diseqc.h

     
    359359    void SetLOFSwitch(uint lof_switch)    { m_lof_switch = lof_switch; }
    360360    void SetLOFHigh(  uint lof_hi)        { m_lof_hi     = lof_hi;     }
    361361    void SetLOFLow(   uint lof_lo)        { m_lof_lo     = lof_lo;     }
     362    void SetReversed(bool reversed)       { m_reversed   = reversed;   }
    362363
    363364    // Gets
    364365    dvbdev_lnb_t GetType(void)      const { return m_type;             }
    365366    uint         GetLOFSwitch(void) const { return m_lof_switch;       }
    366367    uint         GetLOFHigh(void)   const { return m_lof_hi;           }
    367368    uint         GetLOFLow(void)    const { return m_lof_lo;           }
     369    bool         IsReversed(void)   const { return m_reversed;         }
    368370    bool         IsHighBand(const DVBTuning&) const;
    369371    bool         IsHorizontal(const DVBTuning&) const;
    370372    uint32_t     GetIntermediateFrequency(const DiSEqCDevSettings&,
     
    383385    uint         m_lof_switch;
    384386    uint         m_lof_hi;
    385387    uint         m_lof_lo;
     388    bool         m_reversed;
    386389
    387390    static const TypeTable LNBTypeTable[5];
    388391};
  • libs/libmythtv/dbcheck.cpp

     
    1010#include "mythdbcon.h"
    1111
    1212/// This is the DB schema version expected by the running MythTV instance.
    13 const QString currentDatabaseVersion = "1160";
     13const QString currentDatabaseVersion = "1161";
    1414
    1515static bool UpdateDBVersionNumber(const QString &newnumber);
    1616static bool performActualUpdate(const QString updates[], QString version,
     
    25462546            return false;
    25472547    }
    25482548
     2549    if (dbver == "1160")
     2550    {
     2551        const QString updates[] = {
     2552"ALTER TABLE diseqc_tree ADD COLUMN reversed TINYINT NOT NULL DEFAULT '0';",
     2553""
     2554};
     2555
     2556        if (!performActualUpdate(updates, "1161", dbver))
     2557            return false;
     2558    }
     2559
    25492560//"ALTER TABLE capturecard DROP COLUMN dvb_recordts;" in 0.21
    25502561//"ALTER TABLE capturecard DROP COLUMN dvb_hw_decoder;" in 0.21
    25512562//"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22
  • libs/libmythtv/diseqcsettings.cpp

     
    457457    uint                       lof_sw;
    458458    uint                       lof_lo;
    459459    uint                       lof_hi;
     460    bool                       reversed;
    460461};
    461462
    462463static lnb_preset lnb_presets[] =
    463464{
    464     /* description, type, LOF switch, LOF low, LOF high */
     465    /* description, type, LOF switch, LOF low, LOF high, Reversed Polarity */
    465466    { DeviceTree::tr("Single (Europe)"),
    466       DiSEqCDevLNB::kTypeVoltageControl,               0,  9750000,        0 },
     467      DiSEqCDevLNB::kTypeVoltageControl,
     468             0,  9750000,        0, false },
    467469    { DeviceTree::tr("Universal (Europe)"),
    468       DiSEqCDevLNB::kTypeVoltageAndToneControl, 11700000,  9750000, 10600000 },
     470      DiSEqCDevLNB::kTypeVoltageAndToneControl,
     471      11700000,  9750000, 10600000, false },
    469472    { DeviceTree::tr("Circular (N. America)"),
    470       DiSEqCDevLNB::kTypeVoltageControl,               0, 11250000,        0 },
     473      DiSEqCDevLNB::kTypeVoltageControl,
     474             0, 11250000,        0, false },
     475    { DeviceTree::tr("Reverse Circular (N. America)"),
     476      DiSEqCDevLNB::kTypeVoltageControl,
     477             0, 11250000,        0,  true },
    471478    { DeviceTree::tr("Linear (N. America)"),
    472       DiSEqCDevLNB::kTypeVoltageControl,               0, 10750000,        0 },
     479      DiSEqCDevLNB::kTypeVoltageControl,
     480             0, 10750000,        0, false },
    473481    { DeviceTree::tr("C Band"),
    474       DiSEqCDevLNB::kTypeVoltageControl,               0,  5150000,        0 },
     482      DiSEqCDevLNB::kTypeVoltageControl,
     483             0,  5150000,        0, false },
    475484    { DeviceTree::tr("DishPro Bandstacked"),
    476       DiSEqCDevLNB::kTypeBandstacked,                  0, 11250000, 14350000 },
     485      DiSEqCDevLNB::kTypeBandstacked,
     486             0, 11250000, 14350000, false },
     487    { DeviceTree::tr("Reverse DishPro Bandstacked"),
     488      DiSEqCDevLNB::kTypeBandstacked,
     489             0, 11250000, 14350000,  true },
    477490    { QString::null,
    478       DiSEqCDevLNB::kTypeVoltageControl,               0,        0,        0 },
     491      DiSEqCDevLNB::kTypeVoltageControl,
     492             0,        0,        0, false },
    479493};
    480494
    481495uint FindPreset(const DiSEqCDevLNB &lnb)
     
    483497    uint i;
    484498    for (i = 0; !lnb_presets[i].name.isEmpty(); i++)
    485499    {
    486         if (lnb_presets[i].type   == lnb.GetType()      &&
    487             lnb_presets[i].lof_sw == lnb.GetLOFSwitch() &&
    488             lnb_presets[i].lof_lo == lnb.GetLOFLow()    &&
    489             lnb_presets[i].lof_hi == lnb.GetLOFHigh())
     500        if (lnb_presets[i].type     == lnb.GetType()      &&
     501            lnb_presets[i].lof_sw   == lnb.GetLOFSwitch() &&
     502            lnb_presets[i].lof_lo   == lnb.GetLOFLow()    &&
     503            lnb_presets[i].lof_hi   == lnb.GetLOFHigh()   &&
     504            lnb_presets[i].reversed == lnb.IsReversed())
    490505        {
    491506            break;
    492507        }
     
    645660    DiSEqCDevLNB &m_lnb;
    646661};
    647662
     663class LNBReversedSetting : public CheckBoxSetting
     664{
     665  public:
     666    LNBReversedSetting(DiSEqCDevLNB &lnb) : m_lnb(lnb)
     667    {
     668        setLabel(DeviceTree::tr("LNB Reversed"));
     669        QString help = DeviceTree::tr(
     670            "This defines whether the signal reaching the LNB "
     671            "is reversed from normal polarization. This happens "
     672            "to circular signals bouncing twice on a toroidal "
     673            "dish.");
     674        setHelpText(help);
     675    }
     676
     677    virtual void load(void)
     678    {
     679        setValue(m_lnb.IsReversed());
     680    }
     681
     682    virtual void save(void)
     683    {
     684        m_lnb.SetReversed(getValue());
     685    }
     686  private:
     687    DiSEqCDevLNB &m_lnb;
     688};
     689
    648690//////////////////////////////////////// LNBConfig
    649691
    650692LNBConfig::LNBConfig(DiSEqCDevLNB &lnb)
     
    664706    group->addChild(m_lof_lo);
    665707    m_lof_hi = new LNBLOFHighSetting(lnb);
    666708    group->addChild(m_lof_hi);
     709    m_reversed = new LNBReversedSetting(lnb);
     710    group->addChild(m_reversed);
    667711    connect(m_type, SIGNAL(valueChanged(const QString&)),
    668712            this,   SLOT(  UpdateType(  void)));
    669713    connect(preset, SIGNAL(valueChanged(const QString&)),
     
    690734        m_lof_switch->setValue(QString::number(preset.lof_sw / 1000));
    691735        m_lof_lo->setValue(QString::number(preset.lof_lo / 1000));
    692736        m_lof_hi->setValue(QString::number(preset.lof_hi / 1000));
     737        m_reversed->setValue(preset.reversed);
    693738        m_type->setEnabled(false);
    694739        m_lof_switch->setEnabled(false);
    695740        m_lof_hi->setEnabled(false);
    696741        m_lof_lo->setEnabled(false);
     742        m_reversed->setEnabled(false);
    697743    }
    698744}
    699745
     
    709755            m_lof_switch->setEnabled(false);
    710756            m_lof_hi->setEnabled(false);
    711757            m_lof_lo->setEnabled(true);
     758            m_reversed->setEnabled(true);
    712759            break;
    713760        case DiSEqCDevLNB::kTypeVoltageAndToneControl:
    714761            m_lof_switch->setEnabled(true);
    715762            m_lof_hi->setEnabled(true);
    716763            m_lof_lo->setEnabled(true);
     764            m_reversed->setEnabled(true);
    717765            break;
    718766        case DiSEqCDevLNB::kTypeBandstacked:
    719767            m_lof_switch->setEnabled(false);
    720768            m_lof_hi->setEnabled(true);
    721769            m_lof_lo->setEnabled(true);
     770            m_reversed->setEnabled(true);
    722771            break;
    723772    }
    724773}
  • libs/libmythtv/diseqcsettings.h

     
    7575class LNBLOFSwitchSetting;
    7676class LNBLOFLowSetting;
    7777class LNBLOFHighSetting;
     78class LNBReversedSetting;
    7879
    7980class LNBConfig : public ConfigurationWizard
    8081{
     
    9293    LNBLOFSwitchSetting *m_lof_switch;
    9394    LNBLOFLowSetting    *m_lof_lo;
    9495    LNBLOFHighSetting   *m_lof_hi;
     96    LNBReversedSetting  *m_reversed;
    9597};
    9698
    9799class DeviceTree : public ListBoxSetting
  • libs/libmythtv/diseqc.cpp

     
    18491849DiSEqCDevLNB::DiSEqCDevLNB(DiSEqCDevTree &tree, uint devid)
    18501850    : DiSEqCDevDevice(tree, devid),
    18511851      m_type(kTypeVoltageAndToneControl), m_lof_switch(11700000),
    1852       m_lof_hi(10600000),       m_lof_lo(9750000)
     1852      m_lof_hi(10600000),       m_lof_lo(9750000),
     1853      m_reversed(false)
    18531854{
    18541855    Reset();
    18551856}
     
    18831884    MSqlQuery query(MSqlQuery::InitCon());
    18841885    query.prepare(
    18851886        "SELECT subtype,         lnb_lof_switch, "
    1886         "       lnb_lof_hi,      lnb_lof_lo "
     1887        "       lnb_lof_hi,      lnb_lof_lo, "
     1888        "       reversed "
    18871889        "FROM diseqc_tree "
    18881890        "WHERE diseqcid = :DEVID");
    18891891    query.bindValue(":DEVID", GetDeviceID());
     
    18991901        m_lof_switch = query.value(1).toInt();
    19001902        m_lof_hi     = query.value(2).toInt();
    19011903        m_lof_lo     = query.value(3).toInt();
     1904        m_reversed   = query.value(4).toInt();
    19021905    }
    19031906
    19041907    return true;
     
    19211924            "    subtype         = :TYPE,    "
    19221925            "    lnb_lof_switch  = :LOFSW,   "
    19231926            "    lnb_lof_lo      = :LOFLO,   "
    1924             "    lnb_lof_hi      = :LOFHI    "
     1927            "    lnb_lof_hi      = :LOFHI,   "
     1928            "    reversed        = :REVERSED "
    19251929            "WHERE diseqcid = :DEVID");
    19261930    }
    19271931    else
     
    19301934            "INSERT INTO diseqc_tree"
    19311935            " ( parentid,      ordinal,         type, "
    19321936            "   description,   subtype,         lnb_lof_switch, "
    1933             "   lnb_lof_lo,    lnb_lof_hi ) "
     1937            "   lnb_lof_lo,    lnb_lof_hi,      reversed ) "
    19341938            "VALUES "
    19351939            " (:PARENT,       :ORDINAL,         'lnb', "
    19361940            "  :DESC,         :TYPE,            :LOFSW, "
    1937             "  :LOFLO,        :LOFHI ) ");
     1941            "  :LOFLO,        :LOFHI,           :REVERSED ) ");
    19381942    }
    19391943
    19401944    if (m_parent)
     
    19461950    query.bindValue(":LOFSW",   m_lof_switch);
    19471951    query.bindValue(":LOFLO",   m_lof_lo);
    19481952    query.bindValue(":LOFHI",   m_lof_hi);
     1953    query.bindValue(":REVERSED",m_reversed);
    19491954    query.bindValue(":DEVID",   GetDeviceID());
    19501955
    19511956    // update dev_id
     
    19962001    (void) tuning;
    19972002#ifdef USING_DVB
    19982003    char pol = tuning.PolarityChar();
    1999     return (pol == 'h' || pol == 'l');
     2004    bool horizontal = (pol == 'h' || pol == 'l');
     2005    if (IsReversed())
     2006        horizontal = !horizontal;
     2007    return horizontal;
    20002008#else
    20012009    return false;
    20022010#endif // !USING_DVB