Ticket #9726: 0001-libmythtv-Unicable-SCR-DIN-EN-50494.patch

File 0001-libmythtv-Unicable-SCR-DIN-EN-50494.patch, 23.3 KB (added by twoof7@…, 13 years ago)
  • mythtv/libs/libmythtv/diseqc.cpp

    From e784aabca97756d87a159ae943c493b78cd1f4de Mon Sep 17 00:00:00 2001
    From: Matthias Benesch <twoof7@freenet.de>
    Date: Tue, 12 Apr 2011 23:16:09 +0200
    Subject: [PATCH] libmythtv: Unicable / SCR / DIN EN 50494
    
    Add support for Unicable / Satellite Channel Router / DIN EN 50494 standard.
    ---
     mythtv/libs/libmythtv/diseqc.cpp         |  194 ++++++++++++++++++++++++++----
     mythtv/libs/libmythtv/diseqc.h           |   55 +++++++--
     mythtv/libs/libmythtv/diseqcsettings.cpp |  168 +++++++++++++++++++++++++-
     mythtv/libs/libmythtv/diseqcsettings.h   |    8 ++
     4 files changed, 392 insertions(+), 33 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/diseqc.cpp b/mythtv/libs/libmythtv/diseqc.cpp
    index 7446a8f..83e180c 100644
    a b  
    6868#define DISEQC_CMD_WRITE_N0   0x38
    6969#define DISEQC_CMD_WRITE_N1   0x39
    7070#define DISEQC_CMD_WRITE_FREQ 0x58
     71#define DISEQC_CMD_ODU        0x5A
     72#define DISEQC_CMD_ODU_MDU    0x5C
    7173#define DISEQC_CMD_HALT       0x60
    7274#define DISEQC_CMD_LMT_OFF    0x63
    7375#define DISEQC_CMD_LMT_E      0x66
    void DiSEqCDevRotor::RotationComplete(void) const 
    20662068 *  \brief LNB Class.
    20672069 */
    20682070
    2069 const DiSEqCDevDevice::TypeTable DiSEqCDevLNB::LNBTypeTable[5] =
     2071const DiSEqCDevDevice::TypeTable DiSEqCDevLNB::LNBTypeTable[6] =
    20702072{
    20712073    { "fixed",        kTypeFixed                 },
    20722074    { "voltage",      kTypeVoltageControl        },
    20732075    { "voltage_tone", kTypeVoltageAndToneControl },
    20742076    { "bandstacked",  kTypeBandstacked           },
     2077    { "scr",          kTypeSCR                   },
    20752078    { QString::null,  kTypeVoltageAndToneControl },
    20762079};
    20772080
     2081const DiSEqCDevDevice::TypeTable DiSEqCDevLNB::SCRPositionTable[3] =
     2082{
     2083    { "A",            kTypeScrPosA },
     2084    { "B",            kTypeScrPosB },
     2085    { QString::null,  kTypeScrPosA },
     2086};
     2087
    20782088DiSEqCDevLNB::DiSEqCDevLNB(DiSEqCDevTree &tree, uint devid)
    2079     : DiSEqCDevDevice(tree, devid),
    2080       m_type(kTypeVoltageAndToneControl), m_lof_switch(11700000),
    2081       m_lof_hi(10600000),       m_lof_lo(9750000),
    2082       m_pol_inv(false)
     2089    : DiSEqCDevDevice(tree, devid)
     2090    , m_type(kTypeVoltageAndToneControl)
     2091    , m_lof_switch(11700000)
     2092    , m_lof_hi(10600000)
     2093    , m_lof_lo(9750000)
     2094    , m_pol_inv(false)
     2095    , m_scr_userband(0)
     2096    , m_scr_frequency(1400)
     2097    , m_scr_position(kTypeScrPosA)
     2098    , m_scr_pin(-1)
    20832099{
    20842100    Reset();
    20852101}
    bool DiSEqCDevLNB::Execute(const DiSEqCDevSettings&, const DTVMultiplex &tuning) 
    20902106    if (m_type == kTypeVoltageAndToneControl)
    20912107        m_tree.SetTone(IsHighBand(tuning));
    20922108
     2109    if (m_type == kTypeSCR)
     2110        return ExecuteSCR(tuning);
     2111
    20932112    return true;
    20942113}
    20952114
    uint DiSEqCDevLNB::GetVoltage(const DiSEqCDevSettings&, 
    21032122    {
    21042123        voltage = (IsHorizontal(tuning) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13);
    21052124    }
     2125    else if (kTypeSCR == m_type)
     2126    {
     2127        voltage = SEC_VOLTAGE_13;
     2128    }
    21062129
    21072130    return voltage;
    21082131}
    bool DiSEqCDevLNB::Load(void) 
    21142137    query.prepare(
    21152138        "SELECT subtype,         lnb_lof_switch, "
    21162139        "       lnb_lof_hi,      lnb_lof_lo, "
    2117         "       lnb_pol_inv,     cmd_repeat "
     2140        "       lnb_pol_inv,     cmd_repeat, "
     2141        "       scr_userband,    scr_frequency, "
     2142        "       scr_position,    scr_pin "
    21182143        "FROM diseqc_tree "
    21192144        "WHERE diseqcid = :DEVID");
    21202145    query.bindValue(":DEVID", GetDeviceID());
    bool DiSEqCDevLNB::Load(void) 
    21262151    }
    21272152    else if (query.next())
    21282153    {
    2129         m_type       = LNBTypeFromString(query.value(0).toString());
    2130         m_lof_switch = query.value(1).toInt();
    2131         m_lof_hi     = query.value(2).toInt();
    2132         m_lof_lo     = query.value(3).toInt();
    2133         m_pol_inv    = query.value(4).toUInt();
    2134         m_repeat     = query.value(5).toUInt();
     2154        m_type          = LNBTypeFromString(query.value(0).toString());
     2155        m_lof_switch    = query.value(1).toInt();
     2156        m_lof_hi        = query.value(2).toInt();
     2157        m_lof_lo        = query.value(3).toInt();
     2158        m_pol_inv       = query.value(4).toUInt();
     2159        m_repeat        = query.value(5).toUInt();
     2160        m_scr_userband  = query.value(6).toUInt();
     2161        m_scr_frequency = query.value(7).toUInt();
     2162        m_scr_position  = SCRPositionFromString(query.value(8).toString());
     2163        m_scr_pin       = query.value(9).toInt();
    21352164    }
    21362165
    21372166    return true;
    bool DiSEqCDevLNB::Store(void) const 
    21562185            "    lnb_lof_lo      = :LOFLO,   "
    21572186            "    lnb_lof_hi      = :LOFHI,   "
    21582187            "    lnb_pol_inv     = :POLINV,  "
    2159             "    cmd_repeat      = :REPEAT   "
     2188            "    cmd_repeat      = :REPEAT,   "
     2189            "    scr_userband    = :USERBAND, "
     2190            "    scr_frequency   = :FREQUENCY, "
     2191            "    scr_position    = :POSITION, "
     2192            "    scr_pin         = :PIN "
    21602193            "WHERE diseqcid = :DEVID");
    21612194        query.bindValue(":DEVID",   GetDeviceID());
    21622195    }
    bool DiSEqCDevLNB::Store(void) const 
    21672200            " ( parentid,      ordinal,         type, "
    21682201            "   description,   subtype,         lnb_lof_switch, "
    21692202            "   lnb_lof_lo,    lnb_lof_hi,      lnb_pol_inv, "
    2170             "   cmd_repeat ) "
     2203            "   cmd_repeat,    scr_userband,    scr_frequency, "
     2204            "   scr_position,  scr_pin) "
    21712205            "VALUES "
    21722206            " (:PARENT,       :ORDINAL,         'lnb', "
    21732207            "  :DESC,         :TYPE,            :LOFSW, "
    21742208            "  :LOFLO,        :LOFHI,           :POLINV, "
    2175             "  :REPEAT ) ");
     2209            "  :REPEAT,       :USERBAND,        :FREQUENCY,"
     2210            "  :POSITION,     :PIN ) ");
    21762211    }
    21772212
    21782213    if (m_parent)
    21792214        query.bindValue(":PARENT", m_parent->GetDeviceID());
    21802215
    2181     query.bindValue(":ORDINAL", m_ordinal);
    2182     query.bindValue(":DESC",    GetDescription());
    2183     query.bindValue(":TYPE",    type);
    2184     query.bindValue(":LOFSW",   m_lof_switch);
    2185     query.bindValue(":LOFLO",   m_lof_lo);
    2186     query.bindValue(":LOFHI",   m_lof_hi);
    2187     query.bindValue(":POLINV",  m_pol_inv);
    2188     query.bindValue(":REPEAT",  m_repeat);
     2216    query.bindValue(":ORDINAL",   m_ordinal);
     2217    query.bindValue(":DESC",      GetDescription());
     2218    query.bindValue(":TYPE",      type);
     2219    query.bindValue(":LOFSW",     m_lof_switch);
     2220    query.bindValue(":LOFLO",     m_lof_lo);
     2221    query.bindValue(":LOFHI",     m_lof_hi);
     2222    query.bindValue(":POLINV",    m_pol_inv);
     2223    query.bindValue(":REPEAT",    m_repeat);
     2224    query.bindValue(":USERBAND",  m_scr_userband);
     2225    query.bindValue(":FREQUENCY", m_scr_frequency);
     2226    query.bindValue(":POSITION",  SCRPositionToString(m_scr_position));
     2227    query.bindValue(":PIN",       m_scr_pin);
    21892228
    21902229    // update dev_id
    21912230    if (!query.exec())
    bool DiSEqCDevLNB::IsHighBand(const DTVMultiplex &tuning) const 
    22112250{
    22122251    switch (m_type)
    22132252    {
     2253        case kTypeSCR:
    22142254        case kTypeVoltageAndToneControl:
    22152255            return (tuning.frequency > m_lof_switch);
    22162256        case kTypeBandstacked:
    bool DiSEqCDevLNB::IsHorizontal(const DTVMultiplex &tuning) const 
    22442284uint32_t DiSEqCDevLNB::GetIntermediateFrequency(
    22452285    const DiSEqCDevSettings&, const DTVMultiplex &tuning) const
    22462286{
     2287    uint32_t frequency = GetFrequency(tuning);
     2288
     2289    if (m_type == kTypeSCR)
     2290    {
     2291        uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2292        frequency = ((t + 350) * 4) * 1000 - frequency;
     2293    }
     2294
     2295    return frequency;
     2296}
     2297
     2298uint32_t DiSEqCDevLNB::GetFrequency(const DTVMultiplex& tuning) const
     2299{
    22472300    (void) tuning;
    22482301
    22492302    uint64_t abs_freq = tuning.frequency;
    uint32_t DiSEqCDevLNB::GetIntermediateFrequency( 
    22512304
    22522305    return (lof > abs_freq) ? (lof - abs_freq) : (abs_freq - lof);
    22532306}
     2307
     2308bool DiSEqCDevLNB::ExecuteSCR(const DTVMultiplex &tuning) const
     2309{
     2310    VERBOSE(VB_CHANNEL, LOC + QString("SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
     2311            .arg(tuning.frequency)
     2312            .arg(IsHighBand(tuning) ? "HiBand" : "LoBand")
     2313            .arg(IsHorizontal(tuning) ? "H" : "V")
     2314            .arg(m_scr_userband)
     2315            .arg(m_scr_frequency)
     2316            .arg((m_scr_position == kTypeScrPosA) ? "A" : "B")
     2317            .arg((m_scr_pin >= 0 && m_scr_pin <= 255) ? QString(", PIN=%1").arg(m_scr_pin) : QString("")));
     2318
     2319    if (m_scr_userband > 7)
     2320    {
     2321        VERBOSE(VB_IMPORTANT, LOC_ERR + "SCR: Userband ID configuration out of range!");
     2322        return false;
     2323    }
     2324
     2325    uint32_t frequency = GetFrequency(tuning);
     2326    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2327    if (t >= 1024)
     2328    {
     2329        VERBOSE(VB_IMPORTANT, LOC_ERR + "SCR: T out of range!");
     2330        return false;
     2331    }
     2332
     2333    // build command
     2334    unsigned char data[3];
     2335    data[0] = t >> 8 | m_scr_userband << 5;
     2336    data[1] = t & 0x00FF;
     2337
     2338    if (IsHighBand(tuning))
     2339        data[0] |= (1 << 2);
     2340
     2341    if (IsHorizontal(tuning))
     2342        data[0] |= (1 << 3);
     2343
     2344    if (m_scr_position == kTypeScrPosB)
     2345        data[0] |= (1 << 4);
     2346
     2347    // send command
     2348    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2349    {
     2350        data[2] = m_scr_pin;
     2351        return SendSCRCommand(DISEQC_CMD_ODU_MDU, 3, data);
     2352    } else {
     2353        return SendSCRCommand(DISEQC_CMD_ODU, 2, data);
     2354    }
     2355}
     2356
     2357bool DiSEqCDevLNB::PowerOffSCR() const
     2358{
     2359    VERBOSE(VB_CHANNEL, LOC + QString("SCR: Power off UB=%1%7")
     2360            .arg(m_scr_userband)
     2361            .arg((m_scr_pin >= 0 && m_scr_pin <= 255)
     2362                 ? QString(", PIN=%1").arg(m_scr_pin)
     2363                 : QString("")));
     2364
     2365    if (m_scr_userband > 7)
     2366    {
     2367        VERBOSE(VB_IMPORTANT, LOC_ERR + "SCR: Userband ID configuration out of range!");
     2368        return false;
     2369    }
     2370
     2371    // build command
     2372    unsigned char data[3];
     2373    data[0] = (uint8_t) (m_scr_userband << 5);
     2374    data[1] = 0x00;
     2375
     2376    // send command
     2377    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2378    {
     2379        data[2] = m_scr_pin;
     2380        return SendSCRCommand(DISEQC_CMD_ODU_MDU, 3, data);
     2381    } else {
     2382        return SendSCRCommand(DISEQC_CMD_ODU, 2, data);
     2383    }
     2384}
     2385
     2386bool DiSEqCDevLNB::SendSCRCommand(uint cmd, uint data_len, unsigned char *data) const
     2387{
     2388    // power on bus
     2389    if (!m_tree.SetVoltage(SEC_VOLTAGE_18))
     2390        return false;
     2391    usleep(DISEQC_SHORT_WAIT);
     2392
     2393    // send command
     2394    bool ret = m_tree.SendCommand(DISEQC_ADR_SW_ALL, cmd, 1, data_len, data);
     2395
     2396    // power off bus
     2397    if (!m_tree.SetVoltage(SEC_VOLTAGE_13))
     2398        return false;
     2399
     2400    return ret;
     2401}
  • mythtv/libs/libmythtv/diseqc.h

    diff --git a/mythtv/libs/libmythtv/diseqc.h b/mythtv/libs/libmythtv/diseqc.h
    index 643dcc8..f418dfd 100644
    a b class DiSEqCDevDevice 
    142142    virtual bool Store(void) const = 0;
    143143
    144144    // Sets
    145     enum dvbdev_t { kTypeSwitch = 0, kTypeRotor = 1, kTypeLNB = 2, };
     145    enum dvbdev_t
     146    {
     147        kTypeSwitch = 0,
     148        kTypeRotor = 1,
     149        kTypeLNB = 2,
     150    };
    146151    void SetDeviceType(dvbdev_t type)        { m_dev_type = type;    }
    147152    void SetParent(DiSEqCDevDevice* parent)  { m_parent   = parent;  }
    148153    void SetOrdinal(uint ordinal)            { m_ordinal  = ordinal; }
    class DiSEqCDevLNB : public DiSEqCDevDevice 
    376381        kTypeVoltageControl        = 1,
    377382        kTypeVoltageAndToneControl = 2,
    378383        kTypeBandstacked           = 3,
     384        kTypeSCR                   = 4,
    379385    };
    380     void SetType(dvbdev_lnb_t type)       { m_type       = type;       }
    381     void SetLOFSwitch(uint lof_switch)    { m_lof_switch = lof_switch; }
    382     void SetLOFHigh(  uint lof_hi)        { m_lof_hi     = lof_hi;     }
    383     void SetLOFLow(   uint lof_lo)        { m_lof_lo     = lof_lo;     }
    384     void SetPolarityInverted(bool inv)    { m_pol_inv    = inv;        }
     386    enum dvbdev_pos_t
     387    {
     388        kTypeScrPosA               = 0,
     389        kTypeScrPosB               = 1,
     390    };
     391    void SetType(dvbdev_lnb_t type)       { m_type          = type;       }
     392    void SetLOFSwitch(uint lof_switch)    { m_lof_switch    = lof_switch; }
     393    void SetLOFHigh(  uint lof_hi)        { m_lof_hi        = lof_hi;     }
     394    void SetLOFLow(   uint lof_lo)        { m_lof_lo        = lof_lo;     }
     395    void SetPolarityInverted(bool inv)    { m_pol_inv       = inv;        }
     396    void SetUserBand(uint userband)       { m_scr_userband  = userband;   }
     397    void SetFrequency(uint freq)          { m_scr_frequency = freq;       }
     398    void SetPosition(dvbdev_pos_t pos)    { m_scr_position  = pos;        }
     399    void SetPIN(int pin)                  { m_scr_pin       = pin;        }
    385400
    386401    // Gets
    387402    dvbdev_lnb_t GetType(void)      const { return m_type;             }
    class DiSEqCDevLNB : public DiSEqCDevDevice 
    389404    uint         GetLOFHigh(void)   const { return m_lof_hi;           }
    390405    uint         GetLOFLow(void)    const { return m_lof_lo;           }
    391406    bool         IsPolarityInverted(void) const { return m_pol_inv;    }
     407    uint         GetUserBand(void) const  { return m_scr_userband;     }
     408    uint         GetFrequency(void) const { return m_scr_frequency;    }
     409    dvbdev_pos_t GetPosition(void) const  { return m_scr_position;     }
     410    int          GetPIN(void) const       { return m_scr_pin;          }
     411
    392412    bool         IsHighBand(const DTVMultiplex&) const;
    393413    bool         IsHorizontal(const DTVMultiplex&) const;
    394414    uint32_t     GetIntermediateFrequency(const DiSEqCDevSettings&,
    class DiSEqCDevLNB : public DiSEqCDevDevice 
    403423    static dvbdev_lnb_t LNBTypeFromString(const QString &type)
    404424        { return (dvbdev_lnb_t) TableFromString(type, LNBTypeTable); }
    405425
     426    static QString SCRPositionToString(dvbdev_pos_t pos)
     427        { return TableToString((uint)pos, SCRPositionTable); }
     428
     429    static dvbdev_pos_t SCRPositionFromString(const QString &pos)
     430        { return (dvbdev_pos_t) TableFromString(pos, SCRPositionTable); }
     431
     432  protected:
     433    uint32_t     GetFrequency(const DTVMultiplex&) const;
     434    bool         ExecuteSCR(const DTVMultiplex&) const;
     435    bool         PowerOffSCR() const;
     436    bool         SendSCRCommand(uint cmd, uint data_len = 0,
     437                                unsigned char *data = NULL) const;
     438
    406439  private:
    407440    dvbdev_lnb_t m_type;
    408441    uint         m_lof_switch;
    class DiSEqCDevLNB : public DiSEqCDevDevice 
    412445    /// on each reflection, so antenna systems with an even number
    413446    /// of reflectors will need to set this value.
    414447    bool         m_pol_inv;
    415 
    416     static const TypeTable LNBTypeTable[5];
     448    /// Satellite channel router (SCR)
     449    uint         m_scr_userband;  /* 0-7 */
     450    uint         m_scr_frequency;
     451    dvbdev_pos_t m_scr_position;  /* A|B */
     452    int          m_scr_pin;       /* 0-255, -1=disabled */
     453
     454    static const TypeTable LNBTypeTable[6];
     455    static const TypeTable SCRPositionTable[3];
    417456};
    418457
    419458#endif // _DISEQC_H_
  • mythtv/libs/libmythtv/diseqcsettings.cpp

    diff --git a/mythtv/libs/libmythtv/diseqcsettings.cpp b/mythtv/libs/libmythtv/diseqcsettings.cpp
    index f01b857..32d5046 100644
    a b class LNBTypeSetting : public ComboBoxSetting, public Storage 
    668668                                     kTypeVoltageAndToneControl));
    669669        addSelection(DeviceTree::tr("Bandstacked"),
    670670                     QString::number((uint) DiSEqCDevLNB::kTypeBandstacked));
     671        addSelection(DeviceTree::tr("Unicable / SCR"),
     672                     QString::number((uint) DiSEqCDevLNB::kTypeSCR));
    671673    }
    672674
    673675    virtual void Load(void)
    class LNBPolarityInvertedSetting : public CheckBoxSetting, public Storage 
    809811    DiSEqCDevLNB &m_lnb;
    810812};
    811813
     814//////////////////////////////////////// LNBSCRUserBandSetting
     815
     816class LNBSCRUserBandSetting : public SpinBoxSetting, public Storage
     817{
     818  public:
     819    LNBSCRUserBandSetting(DiSEqCDevLNB &lnb) :
     820        SpinBoxSetting(this, 0, 7, 1), m_lnb(lnb)
     821    {
     822        setLabel(DeviceTree::tr("SCR ID"));
     823        QString help = DeviceTree::tr(
     824            "Unicable / SCR userband ID (0-7)");
     825        setHelpText(help);
     826    }
     827
     828    virtual void Load(void)
     829    {
     830        setValue(m_lnb.GetUserBand());
     831    }
     832
     833    virtual void Save(void)
     834    {
     835        m_lnb.SetUserBand(intValue());
     836    }
     837
     838    virtual void Save(QString /*destination*/) { }
     839
     840  private:
     841    DiSEqCDevLNB &m_lnb;
     842};
     843
     844//////////////////////////////////////// LNBSCRFrequencySetting
     845
     846class LNBSCRFrequencySetting : public LineEditSetting, public Storage
     847{
     848  public:
     849    LNBSCRFrequencySetting(DiSEqCDevLNB &lnb) : LineEditSetting(this), m_lnb(lnb)
     850    {
     851        setLabel(DeviceTree::tr("SCR frequency (MHz)"));
     852        QString help = DeviceTree::tr(
     853            "Unicable / SCR userband frequency (950 - 2150MHz)");
     854        setHelpText(help);
     855    }
     856
     857    virtual void Load(void)
     858    {
     859        setValue(QString::number(m_lnb.GetFrequency()));
     860    }
     861
     862    virtual void Save(void)
     863    {
     864        m_lnb.SetFrequency(getValue().toUInt());
     865    }
     866
     867    virtual void Save(QString /*destination*/) { }
     868
     869  private:
     870    DiSEqCDevLNB &m_lnb;
     871};
     872
     873//////////////////////////////////////// LNBSCRPositionSetting
     874
     875class LNBSCRPositionSetting : public ComboBoxSetting, public Storage
     876{
     877  public:
     878    LNBSCRPositionSetting(DiSEqCDevLNB &lnb) : ComboBoxSetting(this), m_lnb(lnb)
     879    {
     880        setLabel(DeviceTree::tr("SCR Position"));
     881        QString help = DeviceTree::tr(
     882            "Unicable / SCR userband satellite position (A/B)");
     883        setHelpText(help);
     884        addSelection(DiSEqCDevLNB::SCRPositionToString(DiSEqCDevLNB::kTypeScrPosA),
     885                     QString::number((uint) DiSEqCDevLNB::kTypeScrPosA));
     886        addSelection(DiSEqCDevLNB::SCRPositionToString(DiSEqCDevLNB::kTypeScrPosB),
     887                     QString::number((uint) DiSEqCDevLNB::kTypeScrPosB));
     888    }
     889
     890    virtual void Load(void)
     891    {
     892        setValue(getValueIndex(QString::number((uint)m_lnb.GetPosition())));
     893    }
     894
     895    virtual void Save(void)
     896    {
     897        m_lnb.SetPosition((DiSEqCDevLNB::dvbdev_pos_t)getValue().toUInt());
     898    }
     899
     900    virtual void Save(QString /*destination*/) { }
     901
     902  private:
     903    DiSEqCDevLNB &m_lnb;
     904};
     905
     906//////////////////////////////////////// LNBSCRPINSetting
     907
     908class LNBSCRPINSetting : public LineEditSetting, public Storage
     909{
     910  public:
     911    LNBSCRPINSetting(DiSEqCDevLNB &lnb) : LineEditSetting(this), m_lnb(lnb)
     912    {
     913        setLabel(DeviceTree::tr("SCR PIN code"));
     914        QString help = DeviceTree::tr(
     915            "Unicable / SCR PIN code (-1 disabled, 0 - 255)");
     916        setHelpText(help);
     917    }
     918
     919    virtual void Load(void)
     920    {
     921        setValue(QString::number(m_lnb.GetPIN()));
     922    }
     923
     924    virtual void Save(void)
     925    {
     926        m_lnb.SetPIN(getValue().toInt());
     927    }
     928
     929    virtual void Save(QString /*destination*/) { }
     930
     931  private:
     932    DiSEqCDevLNB &m_lnb;
     933};
     934
    812935//////////////////////////////////////// LNBConfig
    813936
    814937LNBConfig::LNBConfig(DiSEqCDevLNB &lnb)
    LNBConfig::LNBConfig(DiSEqCDevLNB &lnb) 
    830953    group->addChild(m_lof_hi);
    831954    m_pol_inv = new LNBPolarityInvertedSetting(lnb);
    832955    group->addChild(m_pol_inv);
     956    m_scr_ub = new LNBSCRUserBandSetting(lnb);
     957    group->addChild(m_scr_ub);
     958    m_scr_freq = new LNBSCRFrequencySetting(lnb);
     959    group->addChild(m_scr_freq);
     960    m_scr_pos = new LNBSCRPositionSetting(lnb);
     961    group->addChild(m_scr_pos);
     962    m_scr_pin = new LNBSCRPINSetting(lnb);
     963    group->addChild(m_scr_pin);
     964
    833965    connect(m_type, SIGNAL(valueChanged(const QString&)),
    834966            this,   SLOT(  UpdateType(  void)));
    835967    connect(preset, SIGNAL(valueChanged(const QString&)),
    void LNBConfig::SetPreset(const QString &value) 
    862994        m_lof_hi->setEnabled(false);
    863995        m_lof_lo->setEnabled(false);
    864996        m_pol_inv->setEnabled(false);
     997        m_scr_ub->setEnabled(false);
     998        m_scr_freq->setEnabled(false);
     999        m_scr_pos->setEnabled(false);
     1000        m_scr_pin->setEnabled(false);
    8651001    }
    8661002}
    8671003
    void LNBConfig::UpdateType(void) 
    8781014            m_lof_hi->setEnabled(false);
    8791015            m_lof_lo->setEnabled(true);
    8801016            m_pol_inv->setEnabled(true);
     1017            m_scr_ub->setEnabled(false);
     1018            m_scr_freq->setEnabled(false);
     1019            m_scr_pos->setEnabled(false);
     1020            m_scr_pin->setEnabled(false);
    8811021            break;
    8821022        case DiSEqCDevLNB::kTypeVoltageAndToneControl:
    8831023            m_lof_switch->setEnabled(true);
    8841024            m_lof_hi->setEnabled(true);
    8851025            m_lof_lo->setEnabled(true);
    8861026            m_pol_inv->setEnabled(true);
     1027            m_scr_ub->setEnabled(false);
     1028            m_scr_freq->setEnabled(false);
     1029            m_scr_pos->setEnabled(false);
     1030            m_scr_pin->setEnabled(false);
    8871031            break;
    8881032        case DiSEqCDevLNB::kTypeBandstacked:
    8891033            m_lof_switch->setEnabled(false);
    8901034            m_lof_hi->setEnabled(true);
    8911035            m_lof_lo->setEnabled(true);
    8921036            m_pol_inv->setEnabled(true);
     1037            m_scr_ub->setEnabled(false);
     1038            m_scr_freq->setEnabled(false);
     1039            m_scr_pos->setEnabled(false);
     1040            m_scr_pin->setEnabled(false);
     1041            break;
     1042        case DiSEqCDevLNB::kTypeSCR:
     1043            m_lof_switch->setEnabled(true);
     1044            m_lof_hi->setEnabled(true);
     1045            m_lof_lo->setEnabled(true);
     1046            m_pol_inv->setEnabled(true);
     1047            m_scr_ub->setEnabled(true);
     1048            m_scr_freq->setEnabled(true);
     1049            m_scr_pos->setEnabled(true);
     1050            m_scr_pin->setEnabled(true);
    8931051            break;
    8941052    }
    8951053}
    bool convert_diseqc_db(void) 
    13971555
    13981556    MSqlQuery iquery(MSqlQuery::InitCon());
    13991557    iquery.prepare(
    1400         "SELECT cardinputid,    diseqc_port, diseqc_pos, "
    1401         "       lnb_lof_switch, lnb_lof_hi,  lnb_lof_lo  "
     1558        "SELECT cardinputid,    diseqc_port,   diseqc_pos, "
     1559        "       lnb_lof_switch, lnb_lof_hi,    lnb_lof_lo,  "
     1560        "       scr_userband,   scr_frequency, scr_position,"
     1561        "       scr_pin "
    14021562        "FROM cardinput "
    14031563        "WHERE cardinput.cardid = :CARDID");
    14041564
    bool convert_diseqc_db(void) 
    16281788                lnb->SetLOFSwitch(iquery.value(3).toUInt());
    16291789                lnb->SetLOFHigh(iquery.value(4).toUInt());
    16301790                lnb->SetLOFLow(iquery.value(5).toUInt());
     1791                lnb->SetUserBand(iquery.value(6).toUInt());
     1792                lnb->SetFrequency(iquery.value(7).toUInt());
     1793                lnb->SetPosition(DiSEqCDevLNB::SCRPositionFromString(iquery.value(8).toString()));
     1794                lnb->SetPIN(iquery.value(9).toInt());
    16311795            }
    16321796
    16331797            // save settings
  • mythtv/libs/libmythtv/diseqcsettings.h

    diff --git a/mythtv/libs/libmythtv/diseqcsettings.h b/mythtv/libs/libmythtv/diseqcsettings.h
    index de78a71..973efea 100644
    a b class LNBLOFSwitchSetting; 
    7878class LNBLOFLowSetting;
    7979class LNBLOFHighSetting;
    8080class LNBPolarityInvertedSetting;
     81class LNBSCRUserBandSetting;
     82class LNBSCRFrequencySetting;
     83class LNBSCRPositionSetting;
     84class LNBSCRPINSetting;
    8185
    8286class LNBConfig : public QObject, public ConfigurationWizard
    8387{
    class LNBConfig : public QObject, public ConfigurationWizard 
    96100    LNBLOFLowSetting    *m_lof_lo;
    97101    LNBLOFHighSetting   *m_lof_hi;
    98102    LNBPolarityInvertedSetting *m_pol_inv;
     103    LNBSCRUserBandSetting  *m_scr_ub;
     104    LNBSCRFrequencySetting *m_scr_freq;
     105    LNBSCRPositionSetting  *m_scr_pos;
     106    LNBSCRPINSetting       *m_scr_pin;
    99107};
    100108
    101109class DeviceTree : public ListBoxSetting, public Storage