Ticket #9726: mythtv-0.26-unicable_all_patches_consolidated.2.patch

File mythtv-0.26-unicable_all_patches_consolidated.2.patch, 31.6 KB (added by warpme@…, 13 years ago)

Single consolidated patch for Unicable in 0.26-fixes

  • mythtv/libs/libmythtv/diseqc.cpp

    diff -Naur mythtv-0.26-20130113-gf35f899-old/mythtv/libs/libmythtv/diseqc.cpp mythtv-0.26-20130113-gf35f899-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
     
    8587
    8688#define LOC      QString("DiSEqCDevTree: ")
    8789
     90bool diseqc_bus_already_reset = false;
     91
    8892QString DiSEqCDevDevice::TableToString(uint type, const TypeTable *table)
    8993{
    9094    for (; !table->name.isEmpty(); table++)
     
    490494        return false;
    491495    }
    492496
    493     // apply any voltage change
    494     ApplyVoltage(settings, tuning);
     497    // apply any voltage change for non-SCR systems
     498    DiSEqCDevSCR *scr = FindSCR(settings);
     499    if (!scr)
     500        ApplyVoltage(settings, tuning);
     501    else
     502        LOG(VB_CHANNEL, LOG_INFO, LOC + "SCR bus->skiping setting LNB Voltage");
     503
    495504
    496505    // turn off tone burst first if commands need to be sent
    497506    if (m_root->IsCommandNeeded(settings, tuning))
     
    563572    return lnb;
    564573}
    565574
     575/** \fn DiSEqCDevTree::FindSCR(const DiSEqCDevSettings&)
     576 *  \brief Returns the SCR device object selected by the configuration chain.
     577 *  \param settings Configuration chain in effect.
     578 *  \return Pointer to SCR object if found, NULL otherwise.
     579 */
     580DiSEqCDevSCR *DiSEqCDevTree::FindSCR(const DiSEqCDevSettings &settings)
     581{
     582    DiSEqCDevDevice *node = m_root;
     583    DiSEqCDevSCR    *scr  = NULL;
     584
     585    while (node)
     586    {
     587        scr = dynamic_cast<DiSEqCDevSCR*>(node);
     588
     589        if (scr)
     590            break;
     591
     592        node = node->GetSelectedChild(settings);
     593    }
     594
     595    return scr;
     596}
     597
    566598
    567599/** \fn DiSEqCDevTree::FindDevice(uint)
    568600 *  \brief Returns a device by ID.
     
    635667        return false;
    636668    }
    637669
     670    bool resend_cmd = false;
     671
    638672#ifndef USING_DVB
    639673
    640674    (void) adr;
     
    661695
    662696    LOG(VB_CHANNEL, LOG_INFO, LOC + "Sending DiSEqC Command: " + cmdstr);
    663697
     698    if (repeats >= 10)
     699    {
     700        repeats = repeats - 10;
     701        resend_cmd = true;
     702    }
     703
    664704    // send the command
    665705    for (uint i = 0; i <= repeats; i++)
    666706    {
     
    670710            return false;
    671711        }
    672712
    673         mcmd.msg[0] |= DISEQC_FRM_REPEAT;
     713        if (!resend_cmd)
     714            mcmd.msg[0] |= DISEQC_FRM_REPEAT;
     715
    674716        usleep(DISEQC_SHORT_WAIT);
    675717    }
    676718
     
    684726 *  \param hard_reset If true, the bus will be power cycled.
    685727 *  \return True if successful.
    686728 */
    687 bool DiSEqCDevTree::ResetDiseqc(bool hard_reset)
     729bool DiSEqCDevTree::ResetDiseqc(bool hard_reset, bool is_SCR)
    688730{
    689731    Reset();
    690732
     
    696738
    697739        SetVoltage(SEC_VOLTAGE_OFF);
    698740        usleep(DISEQC_POWER_OFF_WAIT);
     741        diseqc_bus_already_reset = false;
    699742    }
    700743
    701744    // make sure the bus is powered
     
    704747    // some DiSEqC devices need more time. see #8465
    705748    usleep(DISEQC_POWER_ON_WAIT);
    706749
    707     // issue a global reset command
    708     LOG(VB_CHANNEL, LOG_INFO, LOC + "Resetting DiSEqC Bus");
    709     if (!SendCommand(DISEQC_ADR_ALL, DISEQC_CMD_RESET))
     750
     751    if (!diseqc_bus_already_reset || !is_SCR)
    710752    {
    711         LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO);
    712         return false;
     753
     754        // issue a global reset command
     755        LOG(VB_CHANNEL, LOG_INFO, LOC + "Resetting DiSEqC Bus");
     756        if (!SendCommand(DISEQC_ADR_ALL, DISEQC_CMD_RESET))
     757        {
     758            LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO);
     759            return false;
     760        }
     761
     762        if (is_SCR)
     763            diseqc_bus_already_reset = true;
     764    }
     765    else
     766    {
     767        LOG(VB_CHANNEL, LOG_INFO, LOC + "Skiping reset: already done for this SCR bus");
    713768    }
    714769
    715770    usleep(DISEQC_LONG_WAIT);
     
    717772    return true;
    718773}
    719774
    720 void DiSEqCDevTree::Open(int fd_frontend)
     775void DiSEqCDevTree::Open(int fd_frontend, bool is_SCR)
    721776{
    722777    m_fd_frontend = fd_frontend;
    723778
    724779    // issue reset command
    725     ResetDiseqc(false /* do a soft reset */);
     780    ResetDiseqc(false, is_SCR);
    726781}
    727782
    728783bool DiSEqCDevTree::SetVoltage(uint voltage)
     
    784839 *  \brief Represents a node in a DVB-S device network.
    785840 */
    786841
    787 const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[4] =
     842const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[5] =
    788843{
    789844    { "switch",      kTypeSwitch },
    790845    { "rotor",       kTypeRotor  },
     846    { "scr",         kTypeSCR    },
    791847    { "lnb",         kTypeLNB    },
    792848    { QString::null, kTypeLNB    },
    793849};
     
    891947            if (node)
    892948                node->SetDescription("Rotor");
    893949            break;
     950        case kTypeSCR:
     951            node = new DiSEqCDevSCR(tree, dev_id);
     952            if (node)
     953                node->SetDescription("Unicable");
     954                break;
    894955        case kTypeLNB:
    895956            node = new DiSEqCDevLNB(tree, dev_id);
    896957            if (node)
     
    20522113}
    20532114
    20542115////////////////////////////////////////
     2116
     2117/** \class DiSEqCDevSCR
     2118 *  \brief Unicable / SCR Class.
     2119 */
     2120
     2121const DiSEqCDevDevice::TypeTable DiSEqCDevSCR::SCRPositionTable[3] =
     2122{
     2123    { "A",            kTypeScrPosA },
     2124    { "B",            kTypeScrPosB },
     2125    { QString::null,  kTypeScrPosA },
     2126};
     2127
     2128DiSEqCDevSCR::DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid)
     2129    : DiSEqCDevDevice(tree, devid)
     2130    , m_scr_userband(0)
     2131    , m_scr_frequency(1400)
     2132    , m_scr_pin(-1)
     2133    , m_child(0)
     2134{
     2135    Reset();
     2136}
     2137
     2138DiSEqCDevSCR::~DiSEqCDevSCR()
     2139{
     2140    if (m_child)
     2141        delete m_child;
     2142}
     2143
     2144void DiSEqCDevSCR::Reset(void)
     2145{
     2146    if (m_child)
     2147        m_child->Reset();
     2148}
     2149
     2150bool DiSEqCDevSCR::Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
     2151{
     2152    // retrieve LNB info
     2153    DiSEqCDevLNB *lnb = m_tree.FindLNB(settings);
     2154    if (!lnb)
     2155    {
     2156        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: No LNB for this configuration!");
     2157        return false;
     2158    }
     2159
     2160    bool     high_band  = lnb->IsHighBand(tuning);
     2161    bool     horizontal = lnb->IsHorizontal(tuning);
     2162    uint32_t frequency  = lnb->GetIntermediateFrequency(settings, tuning);
     2163    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2164
     2165    // retrieve position settings
     2166    dvbdev_pos_t scr_position = (dvbdev_pos_t) settings.GetValue(GetDeviceID());
     2167
     2168    // check parameters
     2169    if (m_scr_userband > 8)
     2170    {
     2171        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2172        .arg(m_scr_userband));
     2173    }
     2174
     2175    if (t >= 1024)
     2176    {
     2177        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: T out of range!");
     2178        return false;
     2179    }
     2180
     2181    LOG(VB_GENERAL, LOG_INFO, QString("SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
     2182            .arg(tuning.frequency)
     2183            .arg(high_band ? "HiBand" : "LoBand")
     2184            .arg(horizontal ? "H" : "V")
     2185            .arg(m_scr_userband)
     2186            .arg(m_scr_frequency)
     2187            .arg((scr_position) ? "B" : "A")
     2188            .arg((m_scr_pin >= 0 && m_scr_pin <= 255) ?
     2189                     QString(", PIN=%1").arg(m_scr_pin) : QString("")));
     2190
     2191    // build command
     2192    unsigned char data[3];
     2193    data[0] = t >> 8 | m_scr_userband << 5;
     2194    data[1] = t & 0x00FF;
     2195
     2196    if (high_band)
     2197        data[0] |= (1 << 2);
     2198
     2199    if (horizontal)
     2200        data[0] |= (1 << 3);
     2201
     2202    if (scr_position)
     2203        data[0] |= (1 << 4);
     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::PowerOff(void) const
     2216{
     2217    // check parameters
     2218    if (m_scr_userband > 8)
     2219    {
     2220        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2221        .arg(m_scr_userband));
     2222    }
     2223
     2224    LOG(VB_CHANNEL, LOG_INFO, LOC + QString("SCR: Power off UB=%1%7")
     2225            .arg(m_scr_userband)
     2226            .arg((m_scr_pin >= 0 && m_scr_pin <= 255)
     2227                 ? QString(", PIN=%1").arg(m_scr_pin)
     2228                 : QString("")));
     2229
     2230    // build command
     2231    unsigned char data[3];
     2232    data[0] = (uint8_t) (m_scr_userband << 5);
     2233    data[1] = 0x00;
     2234
     2235    // send command
     2236    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2237    {
     2238        data[2] = m_scr_pin;
     2239        return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data);
     2240    } else {
     2241        return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data);
     2242    }
     2243}
     2244
     2245bool DiSEqCDevSCR::SendCommand(uint cmd, uint repeats, uint data_len,
     2246                               unsigned char *data) const
     2247{
     2248    (void) repeats;
     2249
     2250    // power on bus
     2251//    if (!m_tree.SetVoltage(SEC_VOLTAGE_18))
     2252//        return false;
     2253//    usleep(DISEQC_LONG_WAIT);
     2254
     2255    // send command
     2256    bool ret = m_tree.SendCommand(DISEQC_ADR_SW_ALL, cmd, repeats, data_len, data);
     2257
     2258    // power off bus
     2259//    if (!m_tree.SetVoltage(SEC_VOLTAGE_13))
     2260//        return false;
     2261
     2262    return ret;
     2263}
     2264
     2265uint DiSEqCDevSCR::GetVoltage(const DiSEqCDevSettings &settings,
     2266                              const DTVMultiplex      &tuning) const
     2267{
     2268    return SEC_VOLTAGE_13;
     2269}
     2270
     2271uint32_t DiSEqCDevSCR::GetIntermediateFrequency(const uint32_t frequency) const
     2272{
     2273    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2274    return ((t + 350) * 4) * 1000 - frequency;
     2275}
     2276
     2277bool DiSEqCDevSCR::Load(void)
     2278{
     2279    // populate scr parameters from db
     2280    MSqlQuery query(MSqlQuery::InitCon());
     2281    query.prepare(
     2282        "SELECT scr_userband,    scr_frequency, "
     2283        "       scr_pin,         cmd_repeat "
     2284        "FROM diseqc_tree "
     2285        "WHERE diseqcid = :DEVID");
     2286    query.bindValue(":DEVID", GetDeviceID());
     2287
     2288    if (!query.exec() || !query.isActive())
     2289    {
     2290        MythDB::DBError("DiSEqCDevSCR::Load 1", query);
     2291        return false;
     2292    }
     2293    else if (query.next())
     2294    {
     2295        m_scr_userband  = query.value(0).toUInt();
     2296        m_scr_frequency = query.value(1).toUInt();
     2297        m_scr_pin       = query.value(2).toInt();
     2298        m_repeat        = query.value(3).toUInt();
     2299    }
     2300
     2301    // load children from db
     2302    if (m_child)
     2303    {
     2304        delete m_child;
     2305        m_child = NULL;
     2306    }
     2307
     2308    query.prepare(
     2309        "SELECT diseqcid "
     2310        "FROM diseqc_tree "
     2311        "WHERE parentid = :DEVID");
     2312    query.bindValue(":DEVID", GetDeviceID());
     2313
     2314    if (!query.exec() || !query.isActive())
     2315    {
     2316        MythDB::DBError("DiSEqCDevSCR::Load 2", query);
     2317        return false;
     2318    }
     2319    else if (query.next())
     2320    {
     2321        uint child_dev_id = query.value(0).toUInt();
     2322        SetChild(0, CreateById(m_tree, child_dev_id));
     2323    }
     2324
     2325    return true;
     2326}
     2327
     2328bool DiSEqCDevSCR::Store(void) const
     2329{
     2330    MSqlQuery query(MSqlQuery::InitCon());
     2331
     2332    // insert new or update old
     2333    if (IsRealDeviceID())
     2334    {
     2335        query.prepare(
     2336            "UPDATE diseqc_tree "
     2337            "SET parentid        = :PARENT,  "
     2338            "    ordinal         = :ORDINAL, "
     2339            "    type            = 'scr',    "
     2340            "    description     = :DESC,    "
     2341            "    scr_userband    = :USERBAND, "
     2342            "    scr_frequency   = :FREQUENCY, "
     2343            "    scr_pin         = :PIN, "
     2344            "    cmd_repeat      = :REPEAT   "
     2345            "WHERE diseqcid = :DEVID");
     2346        query.bindValue(":DEVID",   GetDeviceID());
     2347    }
     2348    else
     2349    {
     2350        query.prepare(
     2351            "INSERT INTO diseqc_tree"
     2352            " ( parentid,      ordinal,         type, "
     2353            "   description,   scr_userband,    scr_frequency, "
     2354            "   scr_pin,       cmd_repeat) "
     2355            "VALUES "
     2356            " (:PARENT,       :ORDINAL,         'scr', "
     2357            "  :DESC,         :USERBAND,        :FREQUENCY,"
     2358            "  :PIN,          :REPEAT) ");
     2359    }
     2360
     2361    if (m_parent)
     2362        query.bindValue(":PARENT", m_parent->GetDeviceID());
     2363
     2364    query.bindValue(":ORDINAL",   m_ordinal);
     2365    query.bindValue(":DESC",      GetDescription());
     2366    query.bindValue(":USERBAND",  m_scr_userband);
     2367    query.bindValue(":FREQUENCY", m_scr_frequency);
     2368    query.bindValue(":PIN",       m_scr_pin);
     2369    query.bindValue(":REPEAT",    m_repeat);
     2370
     2371    // update dev_id
     2372    if (!query.exec())
     2373    {
     2374        MythDB::DBError("DiSEqCDevSCR::Store", query);
     2375        return false;
     2376    }
     2377
     2378    // figure out devid if we did an insert
     2379    if (!IsRealDeviceID())
     2380        SetDeviceID(query.lastInsertId().toUInt());
     2381
     2382    // chain to child
     2383    if (m_child)
     2384        return m_child->Store();
     2385
     2386    return true;
     2387}
     2388
     2389bool DiSEqCDevSCR::SetChild(uint ordinal, DiSEqCDevDevice *device)
     2390{
     2391    if (ordinal)
     2392        return false;
     2393
     2394    DiSEqCDevDevice *old_child = m_child;
     2395    m_child = NULL;
     2396    if (old_child)
     2397        delete old_child;
     2398
     2399    m_child = device;
     2400    if (m_child)
     2401    {
     2402        m_child->SetOrdinal(ordinal);
     2403        m_child->SetParent(this);
     2404    }
     2405
     2406    return true;
     2407}
     2408
     2409////////////////////////////////////////
    20552410
    20562411/** \class DiSEqCDevLNB
    20572412 *  \brief LNB Class.
  • mythtv/libs/libmythtv/diseqc.h

    diff -Naur mythtv-0.26-20130113-gf35f899-old/mythtv/libs/libmythtv/diseqc.h mythtv-0.26-20130113-gf35f899-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. */
     
    9496    bool SendCommand(uint adr, uint cmd, uint repeats = 0,
    9597                     uint data_len = 0, unsigned char *data = NULL);
    9698
    97     bool ResetDiseqc(bool hard_reset);
     99    bool ResetDiseqc(bool hard_reset, bool is_SCR);
    98100
    99101    // frontend fd
    100     void Open(int fd_frontend);
     102    void Open(int fd_frontend, bool is_SCR);
    101103    void Close(void) { m_fd_frontend = -1; }
    102104    int  GetFD(void) const { return m_fd_frontend; }
    103105
     
    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.26-20130113-gf35f899-old/mythtv/libs/libmythtv/diseqcsettings.cpp mythtv-0.26-20130113-gf35f899-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    }
     
    109111{
    110112  public:
    111113    DeviceRepeatSetting(DiSEqCDevDevice &device) :
    112         SpinBoxSetting(this, 0, 5, 1), m_device(device)
     114        SpinBoxSetting(this, 0, 15, 1), m_device(device)
    113115    {
    114116        setLabel(DeviceTree::tr("Repeat Count"));
    115117        QString help = DeviceTree::tr(
    116             "Number of times to repeat DiSEqC commands sent to this device. "
    117             "Larger values may help with less reliable devices.");
     118            "Number of repeat (command with repeat flag ON) or resend (the same command) DiSEqC commands."
     119            "If value is higher than 10, command will be resend N-10 times"
     120            "If value is lower than 10, command will be repeated N times"
     121            "Repeat useful for unreliable DiSEqC equipment; resend useful when unreliable DiSEq equipment has broken/unsuported repeat flag support.");
    118122        setHelpText(help);
    119123    }
    120124
     
    558562    config.Save();
    559563}
    560564
     565//////////////////////////////////////// SCRUserBandSetting
     566
     567class SCRUserBandSetting : public SpinBoxSetting, public Storage
     568{
     569  public:
     570    SCRUserBandSetting(DiSEqCDevSCR &scr) :
     571        SpinBoxSetting(this, 0, 8, 1), m_scr(scr)
     572    {
     573        setLabel(DeviceTree::tr("Userband"));
     574        setHelpText(DeviceTree::tr("Unicable userband ID (0-7) or sometimes (1-8)"));
     575    }
     576
     577    virtual void Load(void)
     578    {
     579        setValue(m_scr.GetUserBand());
     580    }
     581
     582    virtual void Save(void)
     583    {
     584        m_scr.SetUserBand(intValue());
     585    }
     586
     587    virtual void Save(QString /*destination*/) { }
     588
     589  private:
     590    DiSEqCDevSCR &m_scr;
     591};
     592
     593//////////////////////////////////////// SCRFrequencySetting
     594
     595class SCRFrequencySetting : public LineEditSetting, public Storage
     596{
     597  public:
     598    SCRFrequencySetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     599    {
     600        setLabel(DeviceTree::tr("Frequency (MHz)"));
     601        setHelpText(DeviceTree::tr("Unicable userband frequency (usually 1210, 1420, 1680 and 2040 MHz)"));
     602    }
     603
     604    virtual void Load(void)
     605    {
     606        setValue(QString::number(m_scr.GetFrequency()));
     607    }
     608
     609    virtual void Save(void)
     610    {
     611        m_scr.SetFrequency(getValue().toUInt());
     612    }
     613
     614    virtual void Save(QString /*destination*/) { }
     615
     616  private:
     617    DiSEqCDevSCR &m_scr;
     618};
     619
     620//////////////////////////////////////// SCRPINSetting
     621
     622class SCRPINSetting : public LineEditSetting, public Storage
     623{
     624  public:
     625    SCRPINSetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     626    {
     627        setLabel(DeviceTree::tr("PIN code"));
     628        setHelpText(DeviceTree::tr("Unicable PIN code (-1 disabled, 0 - 255)"));
     629    }
     630
     631    virtual void Load(void)
     632    {
     633        setValue(QString::number(m_scr.GetPIN()));
     634    }
     635
     636    virtual void Save(void)
     637    {
     638        m_scr.SetPIN(getValue().toInt());
     639    }
     640
     641    virtual void Save(QString /*destination*/) { }
     642
     643  private:
     644    DiSEqCDevSCR &m_scr;
     645};
     646
     647//////////////////////////////////////// SCRConfig
     648
     649SCRConfig::SCRConfig(DiSEqCDevSCR &scr) : m_scr(scr)
     650{
     651    ConfigurationGroup *group =
     652        new VerticalConfigurationGroup(false, false);
     653    group->setLabel(DeviceTree::tr("Unicable Configuration"));
     654
     655    group->addChild(new SCRUserBandSetting(scr));
     656    group->addChild(new SCRFrequencySetting(scr));
     657    group->addChild(new SCRPINSetting(scr));
     658    group->addChild(new DeviceRepeatSetting(scr));
     659
     660    addChild(group);
     661}
     662
    561663//////////////////////////////////////// LnbPresetSetting
    562664
    563665class lnb_preset
     
    9481050        }
    9491051        break;
    9501052
     1053        case DiSEqCDevDevice::kTypeSCR:
     1054        {
     1055            DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(dev);
     1056            if (scr)
     1057            {
     1058                SCRConfig config(*scr);
     1059                changed = (config.exec() == MythDialog::Accepted);
     1060            }
     1061        }
     1062        break;
     1063
    9511064        case DiSEqCDevDevice::kTypeLNB:
    9521065        {
    9531066            DiSEqCDevLNB *lnb = dynamic_cast<DiSEqCDevLNB*>(dev);
     
    9771090    MythListBox *list = new MythListBox(popup);
    9781091    list->insertItem(tr("Switch"));
    9791092    list->insertItem(tr("Rotor"));
     1093    list->insertItem(tr("Unicable"));
    9801094    list->insertItem(tr("LNB"));
    9811095    list->setCurrentRow(0, QItemSelectionModel::Select);
    9821096
     
    12631377    DiSEqCDevSettings    &m_settings;
    12641378};
    12651379
     1380//////////////////////////////////////// SCRPositionSetting
     1381
     1382class SCRPositionSetting : public ComboBoxSetting, public Storage
     1383{
     1384  public:
     1385    SCRPositionSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
     1386        : ComboBoxSetting(this), m_node(node), m_settings(settings)
     1387    {
     1388        setLabel("Position");
     1389        setHelpText(DeviceTree::tr("Unicable satellite position (A/B)"));
     1390        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosA),
     1391                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosA), true);
     1392        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosB),
     1393                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosB), false);
     1394    }
     1395
     1396    virtual void Load(void)
     1397    {
     1398        double value = m_settings.GetValue(m_node.GetDeviceID());
     1399        setValue(getValueIndex(QString::number((uint)value)));
     1400    }
     1401
     1402    virtual void Save(void)
     1403    {
     1404        m_settings.SetValue(m_node.GetDeviceID(), getValue().toDouble());
     1405    }
     1406
     1407    virtual void Save(QString /*destination*/) { }
     1408
     1409  private:
     1410    DiSEqCDevDevice      &m_node;
     1411    DiSEqCDevSettings    &m_settings;
     1412};
     1413
    12661414//////////////////////////////////////// DTVDeviceConfigGroup
    12671415
    12681416DTVDeviceConfigGroup::DTVDeviceConfigGroup(
     
    13051453                setting = new USALSRotorSetting(*node, m_settings);
    13061454            break;
    13071455        }
     1456        case DiSEqCDevDevice::kTypeSCR:
     1457        {
     1458            setting = new SCRPositionSetting(*node, m_settings);
     1459            break;
     1460        }
    13081461        default:
    13091462            break;
    13101463    }
     
    13791532    DISEQC_POSITIONER_X_SWITCH_2   = 9,
    13801533    DISEQC_SW21                    = 10,
    13811534    DISEQC_SW64                    = 11,
     1535    DISEQC_SCR                     = 12,
    13821536};
    13831537
    13841538// import old diseqc configuration into tree
     
    15481702                break;
    15491703            }
    15501704
     1705            case DISEQC_SCR:
     1706            {
     1707                // SCR + LNB
     1708                root = DiSEqCDevDevice::CreateByType(
     1709                    tree, DiSEqCDevDevice::kTypeSCR);
     1710                DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(root);
     1711                if (scr)
     1712                {
     1713                    add_lnbs = 1;
     1714                }
     1715                break;
     1716            }
     1717
    15511718            default:
    15521719            {
    15531720                LOG(VB_GENERAL, LOG_ERR, "Unknown DiSEqC device type " +
     
    16141781
    16151782                case DISEQC_POSITIONER_1_2:
    16161783                case DISEQC_POSITIONER_X:
     1784                case DISEQC_SCR:
    16171785                    lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(0));
    16181786                    set.SetValue(root->GetDeviceID(), pos);
    16191787                    break;
  • mythtv/libs/libmythtv/diseqcsettings.h

    diff -Naur mythtv-0.26-20130113-gf35f899-old/mythtv/libs/libmythtv/diseqcsettings.h mythtv-0.26-20130113-gf35f899-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.26-20130113-gf35f899-old/mythtv/libs/libmythtv/dvbchannel.cpp mythtv-0.26-20130113-gf35f899-new/mythtv/libs/libmythtv/dvbchannel.cpp
    old new  
    267267    // Turn on the power to the LNB
    268268    if (tunerType.IsDiSEqCSupported())
    269269    {
     270
    270271        diseqc_tree = diseqc_dev.FindTree(GetCardID());
    271272        if (diseqc_tree)
    272             diseqc_tree->Open(fd_frontend);
     273        {
     274            bool is_SCR = false;
     275
     276            DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings);
     277            if (scr)
     278            {
     279                is_SCR = true;
     280                LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on SCR system");
     281            }
     282            else
     283                LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on non-SCR system");
     284
     285            diseqc_tree->Open(fd_frontend, is_SCR);
     286        }
    273287    }
    274288
    275289    dvbcam->Start();
     
    678692    // Remove any events in queue before tuning.
    679693    drain_dvb_events(fd_frontend);
    680694
    681     // send DVB-S setup
    682     if (diseqc_tree)
    683     {
    684         // configure for new input
    685         if (!same_input)
    686             diseqc_settings.Load(inputid);
    687 
    688         // execute diseqc commands
    689         if (!diseqc_tree->Execute(diseqc_settings, tuning))
    690         {
    691             LOG(VB_GENERAL, LOG_ERR, LOC +
    692                 "Tune(): Failed to setup DiSEqC devices");
    693             return false;
    694         }
    695 
    696         // retrieve actual intermediate frequency
    697         DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings);
    698         if (!lnb)
    699         {
    700             LOG(VB_GENERAL, LOG_ERR, LOC +
    701                 "Tune(): No LNB for this configuration");
    702             return false;
    703         }
    704 
    705         if (lnb->GetDeviceID() != last_lnb_dev_id)
    706         {
    707             last_lnb_dev_id = lnb->GetDeviceID();
    708             // make sure we tune to frequency, if the lnb has changed
    709             reset = first_tune = true;
    710         }
    711 
    712         intermediate_freq = lnb->GetIntermediateFrequency(
    713             diseqc_settings, tuning);
    714 
    715         // if card can auto-FEC, use it -- sometimes NITs are inaccurate
    716         if (capabilities & FE_CAN_FEC_AUTO)
    717             can_fec_auto = true;
    718 
    719         // Check DVB-S intermediate frequency here since it requires a fully
    720         // initialized diseqc tree
    721         CheckFrequency(intermediate_freq);
    722     }
    723 
    724     LOG(VB_CHANNEL, LOG_INFO, LOC + "Old Params: " + prev_tuning.toString() +
    725             "\n\t\t\t" + LOC + "New Params: " + tuning.toString());
     695    LOG(VB_CHANNEL, LOG_INFO, LOC + "\nOld Params: " + prev_tuning.toString() +
     696            "\nNew Params: " + tuning.toString());
    726697
    727698    // DVB-S is in kHz, other DVB is in Hz
    728699    bool is_dvbs = ((DTVTunerType::kTunerTypeDVBS1 == tunerType) ||
     
    736707                .arg(intermediate_freq ? intermediate_freq : tuning.frequency)
    737708                .arg(suffix));
    738709
     710        // send DVB-S setup
     711        if (diseqc_tree)
     712        {
     713            // configure for new input
     714            if (!same_input)
     715                diseqc_settings.Load(inputid);
     716
     717            // execute diseqc commands
     718            if (!diseqc_tree->Execute(diseqc_settings, tuning))
     719            {
     720                LOG(VB_GENERAL, LOG_ERR, LOC +
     721                    "Tune(): Failed to setup DiSEqC devices");
     722                return false;
     723            }
     724
     725            // retrieve actual intermediate frequency
     726            DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings);
     727            if (!lnb)
     728            {
     729                LOG(VB_GENERAL, LOG_ERR, LOC +
     730                    "Tune(): No LNB for this configuration");
     731                return false;
     732            }
     733
     734            if (lnb->GetDeviceID() != last_lnb_dev_id)
     735            {
     736                last_lnb_dev_id = lnb->GetDeviceID();
     737                // make sure we tune to frequency, if the lnb has changed
     738                reset = first_tune = true;
     739            }
     740
     741            intermediate_freq = lnb->GetIntermediateFrequency(
     742                diseqc_settings, tuning);
     743
     744            // retrieve scr intermediate frequency
     745            DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings);
     746            if (lnb && scr)
     747            {
     748                intermediate_freq = scr->GetIntermediateFrequency(intermediate_freq);
     749            }
     750
     751            // if card can auto-FEC, use it -- sometimes NITs are inaccurate
     752            if (capabilities & FE_CAN_FEC_AUTO)
     753                can_fec_auto = true;
     754
     755            // Check DVB-S intermediate frequency here since it requires a fully
     756            // initialized diseqc tree
     757            CheckFrequency(intermediate_freq);
     758        }
     759
    739760#if DVB_API_VERSION >=5
    740761        if (DTVTunerType::kTunerTypeDVBS2 == tunerType)
    741762        {
  • mythtv/libs/libmythtv/dvbsignalmonitor.cpp

    diff -Naur mythtv-0.26-20130113-gf35f899-old/mythtv/libs/libmythtv/dvbsignalmonitor.cpp mythtv-0.26-20130113-gf35f899-new/mythtv/libs/libmythtv/dvbsignalmonitor.cpp
    old new  
    291291    // Debug output
    292292    if (wasLocked != isLocked)
    293293    {
    294         LOG(VB_CHANNEL, LOG_INFO, LOC + "UpdateValues -- Signal " +
     294        LOG(VB_GENERAL, LOG_INFO, LOC + "Signal " +
    295295                (isLocked ? "Locked" : "Lost"));
    296296    }
    297297