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

File 0006-libmythtv-Unicable-SCR-DIN-EN-50494.patch, 22.6 KB (added by warpme@…, 12 years ago)

v6 of patch with cosmetic changes

  • mythtv/libs/libmythtv/diseqc.cpp

    diff -Naur mythtv-0.25-20120711-ge330593-old/mythtv/libs/libmythtv/diseqc.cpp mythtv-0.25-20120711-ge330593-new/mythtv/libs/libmythtv/diseqc.cpp
    old new  
    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
     
    563565    return lnb;
    564566}
    565567
     568/** \fn DiSEqCDevTree::FindSCR(const DiSEqCDevSettings&)
     569 *  \brief Returns the SCR device object selected by the configuration chain.
     570 *  \param settings Configuration chain in effect.
     571 *  \return Pointer to SCR object if found, NULL otherwise.
     572 */
     573DiSEqCDevSCR *DiSEqCDevTree::FindSCR(const DiSEqCDevSettings &settings)
     574{
     575    DiSEqCDevDevice *node = m_root;
     576    DiSEqCDevSCR    *scr  = NULL;
     577
     578    while (node)
     579    {
     580        scr = dynamic_cast<DiSEqCDevSCR*>(node);
     581
     582        if (scr)
     583            break;
     584
     585        node = node->GetSelectedChild(settings);
     586    }
     587
     588    return scr;
     589}
     590
    566591
    567592/** \fn DiSEqCDevTree::FindDevice(uint)
    568593 *  \brief Returns a device by ID.
     
    784809 *  \brief Represents a node in a DVB-S device network.
    785810 */
    786811
    787 const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[4] =
     812const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[5] =
    788813{
    789814    { "switch",      kTypeSwitch },
    790815    { "rotor",       kTypeRotor  },
     816    { "scr",         kTypeSCR    },
    791817    { "lnb",         kTypeLNB    },
    792818    { QString::null, kTypeLNB    },
    793819};
     
    891917            if (node)
    892918                node->SetDescription("Rotor");
    893919            break;
     920        case kTypeSCR:
     921            node = new DiSEqCDevSCR(tree, dev_id);
     922            if (node)
     923                node->SetDescription("Unicable");
     924                break;
    894925        case kTypeLNB:
    895926            node = new DiSEqCDevLNB(tree, dev_id);
    896927            if (node)
     
    20522083}
    20532084
    20542085////////////////////////////////////////
     2086
     2087/** \class DiSEqCDevSCR
     2088 *  \brief Unicable / SCR Class.
     2089 */
     2090
     2091const DiSEqCDevDevice::TypeTable DiSEqCDevSCR::SCRPositionTable[3] =
     2092{
     2093    { "A",            kTypeScrPosA },
     2094    { "B",            kTypeScrPosB },
     2095    { QString::null,  kTypeScrPosA },
     2096};
     2097
     2098DiSEqCDevSCR::DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid)
     2099    : DiSEqCDevDevice(tree, devid)
     2100    , m_scr_userband(0)
     2101    , m_scr_frequency(1400)
     2102    , m_scr_pin(-1)
     2103    , m_child(0)
     2104{
     2105    Reset();
     2106}
     2107
     2108DiSEqCDevSCR::~DiSEqCDevSCR()
     2109{
     2110    if (m_child)
     2111        delete m_child;
     2112}
     2113
     2114void DiSEqCDevSCR::Reset(void)
     2115{
     2116    if (m_child)
     2117        m_child->Reset();
     2118}
     2119
     2120bool DiSEqCDevSCR::Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
     2121{
     2122    // retrieve LNB info
     2123    DiSEqCDevLNB *lnb = m_tree.FindLNB(settings);
     2124    if (!lnb)
     2125    {
     2126        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: No LNB for this configuration!");
     2127        return false;
     2128    }
     2129
     2130    bool     high_band  = lnb->IsHighBand(tuning);
     2131    bool     horizontal = lnb->IsHorizontal(tuning);
     2132    uint32_t frequency  = lnb->GetIntermediateFrequency(settings, tuning);
     2133    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2134
     2135    // retrieve position settings
     2136    dvbdev_pos_t scr_position = (dvbdev_pos_t) settings.GetValue(GetDeviceID());
     2137
     2138    // check parameters
     2139    if (m_scr_userband > 8)
     2140    {
     2141        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2142        .arg(m_scr_userband));
     2143    }
     2144
     2145    if (t >= 1024)
     2146    {
     2147        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: T out of range!");
     2148        return false;
     2149    }
     2150
     2151    LOG(VB_GENERAL, LOG_INFO, QString("SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
     2152            .arg(tuning.frequency)
     2153            .arg(high_band ? "HiBand" : "LoBand")
     2154            .arg(horizontal ? "H" : "V")
     2155            .arg(m_scr_userband)
     2156            .arg(m_scr_frequency)
     2157            .arg((scr_position) ? "B" : "A")
     2158            .arg((m_scr_pin >= 0 && m_scr_pin <= 255) ?
     2159                     QString(", PIN=%1").arg(m_scr_pin) : QString("")));
     2160
     2161    // build command
     2162    unsigned char data[3];
     2163    data[0] = t >> 8 | m_scr_userband << 5;
     2164    data[1] = t & 0x00FF;
     2165
     2166    if (high_band)
     2167        data[0] |= (1 << 2);
     2168
     2169    if (horizontal)
     2170        data[0] |= (1 << 3);
     2171
     2172    if (scr_position)
     2173        data[0] |= (1 << 4);
     2174
     2175    // send command
     2176    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2177    {
     2178        data[2] = m_scr_pin;
     2179        return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data);
     2180    } else {
     2181        return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data);
     2182    }
     2183}
     2184
     2185bool DiSEqCDevSCR::PowerOff(void) const
     2186{
     2187    // check parameters
     2188    if (m_scr_userband > 8)
     2189    {
     2190        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2191        .arg(m_scr_userband));
     2192    }
     2193
     2194    LOG(VB_CHANNEL, LOG_INFO, LOC + QString("SCR: Power off UB=%1%7")
     2195            .arg(m_scr_userband)
     2196            .arg((m_scr_pin >= 0 && m_scr_pin <= 255)
     2197                 ? QString(", PIN=%1").arg(m_scr_pin)
     2198                 : QString("")));
     2199
     2200    // build command
     2201    unsigned char data[3];
     2202    data[0] = (uint8_t) (m_scr_userband << 5);
     2203    data[1] = 0x00;
     2204
     2205    // send command
     2206    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2207    {
     2208        data[2] = m_scr_pin;
     2209        return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data);
     2210    } else {
     2211        return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data);
     2212    }
     2213}
     2214
     2215bool DiSEqCDevSCR::SendCommand(uint cmd, uint repeats, uint data_len,
     2216                               unsigned char *data) const
     2217{
     2218    (void) repeats;
     2219
     2220    // power on bus
     2221    if (!m_tree.SetVoltage(SEC_VOLTAGE_18))
     2222        return false;
     2223    usleep(DISEQC_LONG_WAIT);
     2224
     2225    // send command
     2226    bool ret = m_tree.SendCommand(DISEQC_ADR_SW_ALL, cmd, repeats, data_len, data);
     2227
     2228    // power off bus
     2229    if (!m_tree.SetVoltage(SEC_VOLTAGE_13))
     2230        return false;
     2231
     2232    return ret;
     2233}
     2234
     2235uint DiSEqCDevSCR::GetVoltage(const DiSEqCDevSettings &settings,
     2236                              const DTVMultiplex      &tuning) const
     2237{
     2238    return SEC_VOLTAGE_13;
     2239}
     2240
     2241uint32_t DiSEqCDevSCR::GetIntermediateFrequency(const uint32_t frequency) const
     2242{
     2243    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2244    return ((t + 350) * 4) * 1000 - frequency;
     2245}
     2246
     2247bool DiSEqCDevSCR::Load(void)
     2248{
     2249    // populate scr parameters from db
     2250    MSqlQuery query(MSqlQuery::InitCon());
     2251    query.prepare(
     2252        "SELECT scr_userband,    scr_frequency, "
     2253        "       scr_pin,         cmd_repeat "
     2254        "FROM diseqc_tree "
     2255        "WHERE diseqcid = :DEVID");
     2256    query.bindValue(":DEVID", GetDeviceID());
     2257
     2258    if (!query.exec() || !query.isActive())
     2259    {
     2260        MythDB::DBError("DiSEqCDevSCR::Load 1", query);
     2261        return false;
     2262    }
     2263    else if (query.next())
     2264    {
     2265        m_scr_userband  = query.value(0).toUInt();
     2266        m_scr_frequency = query.value(1).toUInt();
     2267        m_scr_pin       = query.value(2).toInt();
     2268        m_repeat        = query.value(3).toUInt();
     2269    }
     2270
     2271    // load children from db
     2272    if (m_child)
     2273    {
     2274        delete m_child;
     2275        m_child = NULL;
     2276    }
     2277
     2278    query.prepare(
     2279        "SELECT diseqcid "
     2280        "FROM diseqc_tree "
     2281        "WHERE parentid = :DEVID");
     2282    query.bindValue(":DEVID", GetDeviceID());
     2283
     2284    if (!query.exec() || !query.isActive())
     2285    {
     2286        MythDB::DBError("DiSEqCDevSCR::Load 2", query);
     2287        return false;
     2288    }
     2289    else if (query.next())
     2290    {
     2291        uint child_dev_id = query.value(0).toUInt();
     2292        SetChild(0, CreateById(m_tree, child_dev_id));
     2293    }
     2294
     2295    return true;
     2296}
     2297
     2298bool DiSEqCDevSCR::Store(void) const
     2299{
     2300    MSqlQuery query(MSqlQuery::InitCon());
     2301
     2302    // insert new or update old
     2303    if (IsRealDeviceID())
     2304    {
     2305        query.prepare(
     2306            "UPDATE diseqc_tree "
     2307            "SET parentid        = :PARENT,  "
     2308            "    ordinal         = :ORDINAL, "
     2309            "    type            = 'scr',    "
     2310            "    description     = :DESC,    "
     2311            "    scr_userband    = :USERBAND, "
     2312            "    scr_frequency   = :FREQUENCY, "
     2313            "    scr_pin         = :PIN, "
     2314            "    cmd_repeat      = :REPEAT   "
     2315            "WHERE diseqcid = :DEVID");
     2316        query.bindValue(":DEVID",   GetDeviceID());
     2317    }
     2318    else
     2319    {
     2320        query.prepare(
     2321            "INSERT INTO diseqc_tree"
     2322            " ( parentid,      ordinal,         type, "
     2323            "   description,   scr_userband,    scr_frequency, "
     2324            "   scr_pin,       cmd_repeat) "
     2325            "VALUES "
     2326            " (:PARENT,       :ORDINAL,         'scr', "
     2327            "  :DESC,         :USERBAND,        :FREQUENCY,"
     2328            "  :PIN,          :REPEAT) ");
     2329    }
     2330
     2331    if (m_parent)
     2332        query.bindValue(":PARENT", m_parent->GetDeviceID());
     2333
     2334    query.bindValue(":ORDINAL",   m_ordinal);
     2335    query.bindValue(":DESC",      GetDescription());
     2336    query.bindValue(":USERBAND",  m_scr_userband);
     2337    query.bindValue(":FREQUENCY", m_scr_frequency);
     2338    query.bindValue(":PIN",       m_scr_pin);
     2339    query.bindValue(":REPEAT",    m_repeat);
     2340
     2341    // update dev_id
     2342    if (!query.exec())
     2343    {
     2344        MythDB::DBError("DiSEqCDevSCR::Store", query);
     2345        return false;
     2346    }
     2347
     2348    // figure out devid if we did an insert
     2349    if (!IsRealDeviceID())
     2350        SetDeviceID(query.lastInsertId().toUInt());
     2351
     2352    // chain to child
     2353    if (m_child)
     2354        return m_child->Store();
     2355
     2356    return true;
     2357}
     2358
     2359bool DiSEqCDevSCR::SetChild(uint ordinal, DiSEqCDevDevice *device)
     2360{
     2361    if (ordinal)
     2362        return false;
     2363
     2364    DiSEqCDevDevice *old_child = m_child;
     2365    m_child = NULL;
     2366    if (old_child)
     2367        delete old_child;
     2368
     2369    m_child = device;
     2370    if (m_child)
     2371    {
     2372        m_child->SetOrdinal(ordinal);
     2373        m_child->SetParent(this);
     2374    }
     2375
     2376    return true;
     2377}
     2378
     2379////////////////////////////////////////
    20552380
    20562381/** \class DiSEqCDevLNB
    20572382 *  \brief LNB Class.
  • mythtv/libs/libmythtv/diseqc.h

    diff -Naur mythtv-0.25-20120711-ge330593-old/mythtv/libs/libmythtv/diseqc.h mythtv-0.25-20120711-ge330593-new/mythtv/libs/libmythtv/diseqc.h
    old new  
    2727class DiSEqCDevDevice;
    2828class DiSEqCDevRotor;
    2929class DiSEqCDevLNB;
     30class DiSEqCDevSCR;
    3031
    3132typedef QMap<uint, double>         uint_to_dbl_t;
    3233typedef QMap<double, uint>         dbl_to_uint_t;
     
    8586
    8687    DiSEqCDevRotor  *FindRotor(const DiSEqCDevSettings &settings, uint index = 0);
    8788    DiSEqCDevLNB    *FindLNB(const DiSEqCDevSettings &settings);
     89    DiSEqCDevSCR    *FindSCR(const DiSEqCDevSettings &settings);
    8890    DiSEqCDevDevice *FindDevice(uint dev_id);
    8991
    9092    /** \brief Retrieves the root node in the tree. */
     
    142144    virtual bool Store(void) const = 0;
    143145
    144146    // Sets
    145     enum dvbdev_t { kTypeSwitch = 0, kTypeRotor = 1, kTypeLNB = 2, };
     147    enum dvbdev_t
     148    {
     149        kTypeSwitch = 0,
     150        kTypeRotor = 1,
     151        kTypeSCR = 2,
     152        kTypeLNB = 3,
     153    };
    146154    void SetDeviceType(dvbdev_t type)        { m_dev_type = type;    }
    147155    void SetParent(DiSEqCDevDevice* parent)  { m_parent   = parent;  }
    148156    void SetOrdinal(uint ordinal)            { m_ordinal  = ordinal; }
     
    201209                                   const TypeTable *table);
    202210
    203211  private:
    204     static const TypeTable dvbdev_lookup[4];
     212    static const TypeTable dvbdev_lookup[5];
    205213};
    206214
    207215class DiSEqCDevSwitch : public DiSEqCDevDevice
     
    359367    static const TypeTable RotorTypeTable[3];
    360368};
    361369
     370class DiSEqCDevSCR : public DiSEqCDevDevice
     371{
     372  public:
     373    DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid);
     374    ~DiSEqCDevSCR();
     375
     376    // Commands
     377    virtual void Reset(void);
     378    virtual bool Execute(const DiSEqCDevSettings&, const DTVMultiplex&);
     379    bool         PowerOff(void) const;
     380    virtual bool Load(void);
     381    virtual bool Store(void) const;
     382
     383    // Sets
     384    enum dvbdev_pos_t
     385    {
     386        kTypeScrPosA               = 0,
     387        kTypeScrPosB               = 1,
     388    };
     389    void SetUserBand(uint userband)        { m_scr_userband  = userband;   }
     390    void SetFrequency(uint freq)           { m_scr_frequency = freq;       }
     391    void SetPIN(int pin)                   { m_scr_pin       = pin;        }
     392    virtual bool SetChild(uint ordinal, DiSEqCDevDevice* device);
     393
     394    // Gets
     395    uint         GetUserBand(void) const   { return m_scr_userband;        }
     396    uint         GetFrequency(void) const  { return m_scr_frequency;       }
     397    int          GetPIN(void) const        { return m_scr_pin;             }
     398    virtual uint GetChildCount(void) const { return 1;                     }
     399    virtual bool IsCommandNeeded(const DiSEqCDevSettings&,
     400                                 const DTVMultiplex&) const { return false; }
     401    virtual uint GetVoltage(const DiSEqCDevSettings&,
     402                            const DTVMultiplex&) const;
     403    uint32_t     GetIntermediateFrequency(const uint32_t frequency) const;
     404
     405    // Non-const Gets
     406    virtual DiSEqCDevDevice *GetSelectedChild(const DiSEqCDevSettings&) const
     407                                            { return m_child;              }
     408    virtual DiSEqCDevDevice *GetChild(uint) { return m_child;              }
     409
     410    // statics
     411    static QString SCRPositionToString(dvbdev_pos_t pos)
     412        { return TableToString((uint)pos, SCRPositionTable); }
     413
     414    static dvbdev_pos_t SCRPositionFromString(const QString &pos)
     415        { return (dvbdev_pos_t) TableFromString(pos, SCRPositionTable); }
     416
     417  protected:
     418    bool         SendCommand(uint cmd, uint repeats, uint data_len = 0,
     419                             unsigned char *data = NULL) const;
     420
     421  private:
     422    uint         m_scr_userband;  /* 0-7 */
     423    uint         m_scr_frequency;
     424    int          m_scr_pin;       /* 0-255, -1=disabled */
     425
     426    DiSEqCDevDevice *m_child;
     427
     428    static const TypeTable SCRPositionTable[3];
     429};
     430
    362431class DiSEqCDevLNB : public DiSEqCDevDevice
    363432{
    364433  public:
  • mythtv/libs/libmythtv/diseqcsettings.cpp

    diff -Naur mythtv-0.25-20120711-ge330593-old/mythtv/libs/libmythtv/diseqcsettings.cpp mythtv-0.25-20120711-ge330593-new/mythtv/libs/libmythtv/diseqcsettings.cpp
    old new  
    4949                     QString::number((uint) DiSEqCDevDevice::kTypeSwitch));
    5050        addSelection(DeviceTree::tr("Rotor"),
    5151                     QString::number((uint) DiSEqCDevDevice::kTypeRotor));
     52        addSelection(DeviceTree::tr("Unicable"),
     53                     QString::number((uint) DiSEqCDevDevice::kTypeSCR));
    5254        addSelection(DeviceTree::tr("LNB"),
    5355                     QString::number((uint) DiSEqCDevDevice::kTypeLNB));
    5456    }
     
    558560    config.Save();
    559561}
    560562
     563//////////////////////////////////////// SCRUserBandSetting
     564
     565class SCRUserBandSetting : public SpinBoxSetting, public Storage
     566{
     567  public:
     568    SCRUserBandSetting(DiSEqCDevSCR &scr) :
     569        SpinBoxSetting(this, 0, 8, 1), m_scr(scr)
     570    {
     571        setLabel(DeviceTree::tr("Userband"));
     572        setHelpText(DeviceTree::tr("Unicable userband ID (0-7) or sometimes (1-8)"));
     573    }
     574
     575    virtual void Load(void)
     576    {
     577        setValue(m_scr.GetUserBand());
     578    }
     579
     580    virtual void Save(void)
     581    {
     582        m_scr.SetUserBand(intValue());
     583    }
     584
     585    virtual void Save(QString /*destination*/) { }
     586
     587  private:
     588    DiSEqCDevSCR &m_scr;
     589};
     590
     591//////////////////////////////////////// SCRFrequencySetting
     592
     593class SCRFrequencySetting : public LineEditSetting, public Storage
     594{
     595  public:
     596    SCRFrequencySetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     597    {
     598        setLabel(DeviceTree::tr("Frequency (MHz)"));
     599        setHelpText(DeviceTree::tr("Unicable userband frequency (usually 1210, 1420, 1680 and 2040 MHz)"));
     600    }
     601
     602    virtual void Load(void)
     603    {
     604        setValue(QString::number(m_scr.GetFrequency()));
     605    }
     606
     607    virtual void Save(void)
     608    {
     609        m_scr.SetFrequency(getValue().toUInt());
     610    }
     611
     612    virtual void Save(QString /*destination*/) { }
     613
     614  private:
     615    DiSEqCDevSCR &m_scr;
     616};
     617
     618//////////////////////////////////////// SCRPINSetting
     619
     620class SCRPINSetting : public LineEditSetting, public Storage
     621{
     622  public:
     623    SCRPINSetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     624    {
     625        setLabel(DeviceTree::tr("PIN code"));
     626        setHelpText(DeviceTree::tr("Unicable PIN code (-1 disabled, 0 - 255)"));
     627    }
     628
     629    virtual void Load(void)
     630    {
     631        setValue(QString::number(m_scr.GetPIN()));
     632    }
     633
     634    virtual void Save(void)
     635    {
     636        m_scr.SetPIN(getValue().toInt());
     637    }
     638
     639    virtual void Save(QString /*destination*/) { }
     640
     641  private:
     642    DiSEqCDevSCR &m_scr;
     643};
     644
     645//////////////////////////////////////// SCRConfig
     646
     647SCRConfig::SCRConfig(DiSEqCDevSCR &scr) : m_scr(scr)
     648{
     649    ConfigurationGroup *group =
     650        new VerticalConfigurationGroup(false, false);
     651    group->setLabel(DeviceTree::tr("Unicable Configuration"));
     652
     653    group->addChild(new SCRUserBandSetting(scr));
     654    group->addChild(new SCRFrequencySetting(scr));
     655    group->addChild(new SCRPINSetting(scr));
     656    group->addChild(new DeviceRepeatSetting(scr));
     657
     658    addChild(group);
     659}
     660
    561661//////////////////////////////////////// LnbPresetSetting
    562662
    563663class lnb_preset
     
    9481048        }
    9491049        break;
    9501050
     1051        case DiSEqCDevDevice::kTypeSCR:
     1052        {
     1053            DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(dev);
     1054            if (scr)
     1055            {
     1056                SCRConfig config(*scr);
     1057                changed = (config.exec() == MythDialog::Accepted);
     1058            }
     1059        }
     1060        break;
     1061
    9511062        case DiSEqCDevDevice::kTypeLNB:
    9521063        {
    9531064            DiSEqCDevLNB *lnb = dynamic_cast<DiSEqCDevLNB*>(dev);
     
    9771088    MythListBox *list = new MythListBox(popup);
    9781089    list->insertItem(tr("Switch"));
    9791090    list->insertItem(tr("Rotor"));
     1091    list->insertItem(tr("Unicable"));
    9801092    list->insertItem(tr("LNB"));
    9811093    list->setCurrentRow(0, QItemSelectionModel::Select);
    9821094
     
    12631375    DiSEqCDevSettings    &m_settings;
    12641376};
    12651377
     1378//////////////////////////////////////// SCRPositionSetting
     1379
     1380class SCRPositionSetting : public ComboBoxSetting, public Storage
     1381{
     1382  public:
     1383    SCRPositionSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
     1384        : ComboBoxSetting(this), m_node(node), m_settings(settings)
     1385    {
     1386        setLabel("Position");
     1387        setHelpText(DeviceTree::tr("Unicable satellite position (A/B)"));
     1388        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosA),
     1389                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosA), true);
     1390        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosB),
     1391                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosB), false);
     1392    }
     1393
     1394    virtual void Load(void)
     1395    {
     1396        double value = m_settings.GetValue(m_node.GetDeviceID());
     1397        setValue(getValueIndex(QString::number((uint)value)));
     1398    }
     1399
     1400    virtual void Save(void)
     1401    {
     1402        m_settings.SetValue(m_node.GetDeviceID(), getValue().toDouble());
     1403    }
     1404
     1405    virtual void Save(QString /*destination*/) { }
     1406
     1407  private:
     1408    DiSEqCDevDevice      &m_node;
     1409    DiSEqCDevSettings    &m_settings;
     1410};
     1411
    12661412//////////////////////////////////////// DTVDeviceConfigGroup
    12671413
    12681414DTVDeviceConfigGroup::DTVDeviceConfigGroup(
     
    13051451                setting = new USALSRotorSetting(*node, m_settings);
    13061452            break;
    13071453        }
     1454        case DiSEqCDevDevice::kTypeSCR:
     1455        {
     1456            setting = new SCRPositionSetting(*node, m_settings);
     1457            break;
     1458        }
    13081459        default:
    13091460            break;
    13101461    }
     
    13791530    DISEQC_POSITIONER_X_SWITCH_2   = 9,
    13801531    DISEQC_SW21                    = 10,
    13811532    DISEQC_SW64                    = 11,
     1533    DISEQC_SCR                     = 12,
    13821534};
    13831535
    13841536// import old diseqc configuration into tree
     
    15481700                break;
    15491701            }
    15501702
     1703            case DISEQC_SCR:
     1704            {
     1705                // SCR + LNB
     1706                root = DiSEqCDevDevice::CreateByType(
     1707                    tree, DiSEqCDevDevice::kTypeSCR);
     1708                DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(root);
     1709                if (scr)
     1710                {
     1711                    add_lnbs = 1;
     1712                }
     1713                break;
     1714            }
     1715
    15511716            default:
    15521717            {
    15531718                LOG(VB_GENERAL, LOG_ERR, "Unknown DiSEqC device type " +
     
    16141779
    16151780                case DISEQC_POSITIONER_1_2:
    16161781                case DISEQC_POSITIONER_X:
     1782                case DISEQC_SCR:
    16171783                    lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(0));
    16181784                    set.SetValue(root->GetDeviceID(), pos);
    16191785                    break;
  • mythtv/libs/libmythtv/diseqcsettings.h

    diff -Naur mythtv-0.25-20120711-ge330593-old/mythtv/libs/libmythtv/diseqcsettings.h mythtv-0.25-20120711-ge330593-new/mythtv/libs/libmythtv/diseqcsettings.h
    old new  
    7373    TransButtonSetting *m_pos;
    7474};
    7575
     76class SCRConfig : public QObject, public ConfigurationWizard
     77{
     78    Q_OBJECT
     79
     80  public:
     81    SCRConfig(DiSEqCDevSCR &scr);
     82
     83  private:
     84    DiSEqCDevSCR &m_scr;
     85};
     86
    7687class LNBTypeSetting;
    7788class LNBLOFSwitchSetting;
    7889class LNBLOFLowSetting;
  • mythtv/libs/libmythtv/dvbchannel.cpp

    diff -Naur mythtv-0.25-20120711-ge330593-old/mythtv/libs/libmythtv/dvbchannel.cpp mythtv-0.25-20120711-ge330593-new/mythtv/libs/libmythtv/dvbchannel.cpp
    old new  
    712712        intermediate_freq = lnb->GetIntermediateFrequency(
    713713            diseqc_settings, tuning);
    714714
     715        // retrieve scr intermediate frequency
     716        DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings);
     717        if (lnb && scr)
     718        {
     719            intermediate_freq = scr->GetIntermediateFrequency(intermediate_freq);
     720        }
     721
    715722        // if card can auto-FEC, use it -- sometimes NITs are inaccurate
    716723        if (capabilities & FE_CAN_FEC_AUTO)
    717724            can_fec_auto = true;