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

File mythtv-0.26-unicable_all_patches_consolidated.3.patch, 30.7 KB (added by warpme@…, 11 years ago)

0007,0028,00028,0037 in single patch

  • mythtv/libs/libmythtv/diseqc.cpp

    diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqc.cpp mythtv-0.26-20130424-g5f45c0b-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++)
     
    563567    return lnb;
    564568}
    565569
     570/** \fn DiSEqCDevTree::FindSCR(const DiSEqCDevSettings&)
     571 *  \brief Returns the SCR device object selected by the configuration chain.
     572 *  \param settings Configuration chain in effect.
     573 *  \return Pointer to SCR object if found, NULL otherwise.
     574 */
     575DiSEqCDevSCR *DiSEqCDevTree::FindSCR(const DiSEqCDevSettings &settings)
     576{
     577    DiSEqCDevDevice *node = m_root;
     578    DiSEqCDevSCR    *scr  = NULL;
     579
     580    while (node)
     581    {
     582        scr = dynamic_cast<DiSEqCDevSCR*>(node);
     583
     584        if (scr)
     585            break;
     586
     587        node = node->GetSelectedChild(settings);
     588    }
     589
     590    return scr;
     591}
     592
    566593
    567594/** \fn DiSEqCDevTree::FindDevice(uint)
    568595 *  \brief Returns a device by ID.
     
    635662        return false;
    636663    }
    637664
     665    bool resend_cmd = false;
     666
    638667#ifndef USING_DVB
    639668
    640669    (void) adr;
     
    661690
    662691    LOG(VB_CHANNEL, LOG_INFO, LOC + "Sending DiSEqC Command: " + cmdstr);
    663692
     693    if (repeats >= 10)
     694    {
     695        repeats = repeats - 10;
     696        resend_cmd = true;
     697    }
     698
    664699    // send the command
    665700    for (uint i = 0; i <= repeats; i++)
    666701    {
     
    670705            return false;
    671706        }
    672707
    673         mcmd.msg[0] |= DISEQC_FRM_REPEAT;
     708        if (!resend_cmd)
     709            mcmd.msg[0] |= DISEQC_FRM_REPEAT;
     710
    674711        usleep(DISEQC_SHORT_WAIT);
    675712    }
    676713
     
    684721 *  \param hard_reset If true, the bus will be power cycled.
    685722 *  \return True if successful.
    686723 */
    687 bool DiSEqCDevTree::ResetDiseqc(bool hard_reset)
     724bool DiSEqCDevTree::ResetDiseqc(bool hard_reset, bool is_SCR)
    688725{
    689726    Reset();
    690727
     
    696733
    697734        SetVoltage(SEC_VOLTAGE_OFF);
    698735        usleep(DISEQC_POWER_OFF_WAIT);
     736        diseqc_bus_already_reset = false;
    699737    }
    700738
    701     // make sure the bus is powered
    702     SetVoltage(SEC_VOLTAGE_18);
    703     usleep(DISEQC_POWER_ON_WAIT);
    704     // some DiSEqC devices need more time. see #8465
    705     usleep(DISEQC_POWER_ON_WAIT);
    706 
    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))
     739    if (!diseqc_bus_already_reset || !is_SCR)
    710740    {
    711         LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO);
    712         return false;
     741        // make sure the bus is powered
     742        SetVoltage(SEC_VOLTAGE_18);
     743        usleep(DISEQC_POWER_ON_WAIT);
     744        // some DiSEqC devices need more time. see #8465
     745        usleep(DISEQC_POWER_ON_WAIT);
     746
     747        // issue a global reset command
     748        LOG(VB_CHANNEL, LOG_INFO, LOC + "Resetting DiSEqC Bus");
     749        if (!SendCommand(DISEQC_ADR_ALL, DISEQC_CMD_RESET))
     750        {
     751            LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO);
     752            return false;
     753        }
     754       
     755        if (is_SCR)
     756            diseqc_bus_already_reset = true;
     757    }
     758    else
     759    {
     760        LOG(VB_CHANNEL, LOG_INFO, LOC + "Skiping reset: already done for this SCR bus");
    713761    }
    714762
    715763    usleep(DISEQC_LONG_WAIT);
     
    717765    return true;
    718766}
    719767
    720 void DiSEqCDevTree::Open(int fd_frontend)
     768void DiSEqCDevTree::Open(int fd_frontend, bool is_SCR)
    721769{
    722770    m_fd_frontend = fd_frontend;
    723771
    724772    // issue reset command
    725     ResetDiseqc(false /* do a soft reset */);
     773    ResetDiseqc(false, is_SCR);
    726774}
    727775
    728776bool DiSEqCDevTree::SetVoltage(uint voltage)
     
    784832 *  \brief Represents a node in a DVB-S device network.
    785833 */
    786834
    787 const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[4] =
     835const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[5] =
    788836{
    789837    { "switch",      kTypeSwitch },
    790838    { "rotor",       kTypeRotor  },
     839    { "scr",         kTypeSCR    },
    791840    { "lnb",         kTypeLNB    },
    792841    { QString::null, kTypeLNB    },
    793842};
     
    891940            if (node)
    892941                node->SetDescription("Rotor");
    893942            break;
     943        case kTypeSCR:
     944            node = new DiSEqCDevSCR(tree, dev_id);
     945            if (node)
     946                node->SetDescription("Unicable");
     947                break;
    894948        case kTypeLNB:
    895949            node = new DiSEqCDevLNB(tree, dev_id);
    896950            if (node)
     
    20522106}
    20532107
    20542108////////////////////////////////////////
     2109
     2110/** \class DiSEqCDevSCR
     2111 *  \brief Unicable / SCR Class.
     2112 */
     2113
     2114const DiSEqCDevDevice::TypeTable DiSEqCDevSCR::SCRPositionTable[3] =
     2115{
     2116    { "A",            kTypeScrPosA },
     2117    { "B",            kTypeScrPosB },
     2118    { QString::null,  kTypeScrPosA },
     2119};
     2120
     2121DiSEqCDevSCR::DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid)
     2122    : DiSEqCDevDevice(tree, devid)
     2123    , m_scr_userband(0)
     2124    , m_scr_frequency(1400)
     2125    , m_scr_pin(-1)
     2126    , m_child(0)
     2127{
     2128    Reset();
     2129}
     2130
     2131DiSEqCDevSCR::~DiSEqCDevSCR()
     2132{
     2133    if (m_child)
     2134        delete m_child;
     2135}
     2136
     2137void DiSEqCDevSCR::Reset(void)
     2138{
     2139    if (m_child)
     2140        m_child->Reset();
     2141}
     2142
     2143bool DiSEqCDevSCR::Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
     2144{
     2145    // retrieve LNB info
     2146    DiSEqCDevLNB *lnb = m_tree.FindLNB(settings);
     2147    if (!lnb)
     2148    {
     2149        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: No LNB for this configuration!");
     2150        return false;
     2151    }
     2152
     2153    bool     high_band  = lnb->IsHighBand(tuning);
     2154    bool     horizontal = lnb->IsHorizontal(tuning);
     2155    uint32_t frequency  = lnb->GetIntermediateFrequency(settings, tuning);
     2156    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2157
     2158    // retrieve position settings
     2159    dvbdev_pos_t scr_position = (dvbdev_pos_t) settings.GetValue(GetDeviceID());
     2160
     2161    // check parameters
     2162    if (m_scr_userband > 8)
     2163    {
     2164        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2165        .arg(m_scr_userband));
     2166    }
     2167
     2168    if (t >= 1024)
     2169    {
     2170        LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: T out of range!");
     2171        return false;
     2172    }
     2173
     2174    LOG(VB_GENERAL, LOG_INFO, QString("SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7")
     2175            .arg(tuning.frequency)
     2176            .arg(high_band ? "HiBand" : "LoBand")
     2177            .arg(horizontal ? "H" : "V")
     2178            .arg(m_scr_userband)
     2179            .arg(m_scr_frequency)
     2180            .arg((scr_position) ? "B" : "A")
     2181            .arg((m_scr_pin >= 0 && m_scr_pin <= 255) ?
     2182                     QString(", PIN=%1").arg(m_scr_pin) : QString("")));
     2183
     2184    // build command
     2185    unsigned char data[3];
     2186    data[0] = t >> 8 | m_scr_userband << 5;
     2187    data[1] = t & 0x00FF;
     2188
     2189    if (high_band)
     2190        data[0] |= (1 << 2);
     2191
     2192    if (horizontal)
     2193        data[0] |= (1 << 3);
     2194
     2195    if (scr_position)
     2196        data[0] |= (1 << 4);
     2197
     2198    // send command
     2199    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2200    {
     2201        data[2] = m_scr_pin;
     2202        return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data);
     2203    } else {
     2204        return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data);
     2205    }
     2206}
     2207
     2208bool DiSEqCDevSCR::PowerOff(void) const
     2209{
     2210    // check parameters
     2211    if (m_scr_userband > 8)
     2212    {
     2213        LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!")
     2214        .arg(m_scr_userband));
     2215    }
     2216
     2217    LOG(VB_CHANNEL, LOG_INFO, LOC + QString("SCR: Power off UB=%1%7")
     2218            .arg(m_scr_userband)
     2219            .arg((m_scr_pin >= 0 && m_scr_pin <= 255)
     2220                 ? QString(", PIN=%1").arg(m_scr_pin)
     2221                 : QString("")));
     2222
     2223    // build command
     2224    unsigned char data[3];
     2225    data[0] = (uint8_t) (m_scr_userband << 5);
     2226    data[1] = 0x00;
     2227
     2228    // send command
     2229    if (m_scr_pin >= 0 && m_scr_pin <= 255)
     2230    {
     2231        data[2] = m_scr_pin;
     2232        return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data);
     2233    } else {
     2234        return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data);
     2235    }
     2236}
     2237
     2238bool DiSEqCDevSCR::SendCommand(uint cmd, uint repeats, uint data_len,
     2239                               unsigned char *data) const
     2240{
     2241    (void) repeats;
     2242
     2243    // power on bus
     2244    if (!m_tree.SetVoltage(SEC_VOLTAGE_18))
     2245        return false;
     2246    usleep(DISEQC_LONG_WAIT);
     2247
     2248    // send command
     2249    bool ret = m_tree.SendCommand(DISEQC_ADR_SW_ALL, cmd, repeats, data_len, data);
     2250
     2251    // power off bus
     2252    if (!m_tree.SetVoltage(SEC_VOLTAGE_13))
     2253        return false;
     2254
     2255    return ret;
     2256}
     2257
     2258uint DiSEqCDevSCR::GetVoltage(const DiSEqCDevSettings &settings,
     2259                              const DTVMultiplex      &tuning) const
     2260{
     2261    return SEC_VOLTAGE_13;
     2262}
     2263
     2264uint32_t DiSEqCDevSCR::GetIntermediateFrequency(const uint32_t frequency) const
     2265{
     2266    uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350;
     2267    return ((t + 350) * 4) * 1000 - frequency;
     2268}
     2269
     2270bool DiSEqCDevSCR::Load(void)
     2271{
     2272    // populate scr parameters from db
     2273    MSqlQuery query(MSqlQuery::InitCon());
     2274    query.prepare(
     2275        "SELECT scr_userband,    scr_frequency, "
     2276        "       scr_pin,         cmd_repeat "
     2277        "FROM diseqc_tree "
     2278        "WHERE diseqcid = :DEVID");
     2279    query.bindValue(":DEVID", GetDeviceID());
     2280
     2281    if (!query.exec() || !query.isActive())
     2282    {
     2283        MythDB::DBError("DiSEqCDevSCR::Load 1", query);
     2284        return false;
     2285    }
     2286    else if (query.next())
     2287    {
     2288        m_scr_userband  = query.value(0).toUInt();
     2289        m_scr_frequency = query.value(1).toUInt();
     2290        m_scr_pin       = query.value(2).toInt();
     2291        m_repeat        = query.value(3).toUInt();
     2292    }
     2293
     2294    // load children from db
     2295    if (m_child)
     2296    {
     2297        delete m_child;
     2298        m_child = NULL;
     2299    }
     2300
     2301    query.prepare(
     2302        "SELECT diseqcid "
     2303        "FROM diseqc_tree "
     2304        "WHERE parentid = :DEVID");
     2305    query.bindValue(":DEVID", GetDeviceID());
     2306
     2307    if (!query.exec() || !query.isActive())
     2308    {
     2309        MythDB::DBError("DiSEqCDevSCR::Load 2", query);
     2310        return false;
     2311    }
     2312    else if (query.next())
     2313    {
     2314        uint child_dev_id = query.value(0).toUInt();
     2315        SetChild(0, CreateById(m_tree, child_dev_id));
     2316    }
     2317
     2318    return true;
     2319}
     2320
     2321bool DiSEqCDevSCR::Store(void) const
     2322{
     2323    MSqlQuery query(MSqlQuery::InitCon());
     2324
     2325    // insert new or update old
     2326    if (IsRealDeviceID())
     2327    {
     2328        query.prepare(
     2329            "UPDATE diseqc_tree "
     2330            "SET parentid        = :PARENT,  "
     2331            "    ordinal         = :ORDINAL, "
     2332            "    type            = 'scr',    "
     2333            "    description     = :DESC,    "
     2334            "    scr_userband    = :USERBAND, "
     2335            "    scr_frequency   = :FREQUENCY, "
     2336            "    scr_pin         = :PIN, "
     2337            "    cmd_repeat      = :REPEAT   "
     2338            "WHERE diseqcid = :DEVID");
     2339        query.bindValue(":DEVID",   GetDeviceID());
     2340    }
     2341    else
     2342    {
     2343        query.prepare(
     2344            "INSERT INTO diseqc_tree"
     2345            " ( parentid,      ordinal,         type, "
     2346            "   description,   scr_userband,    scr_frequency, "
     2347            "   scr_pin,       cmd_repeat) "
     2348            "VALUES "
     2349            " (:PARENT,       :ORDINAL,         'scr', "
     2350            "  :DESC,         :USERBAND,        :FREQUENCY,"
     2351            "  :PIN,          :REPEAT) ");
     2352    }
     2353
     2354    if (m_parent)
     2355        query.bindValue(":PARENT", m_parent->GetDeviceID());
     2356
     2357    query.bindValue(":ORDINAL",   m_ordinal);
     2358    query.bindValue(":DESC",      GetDescription());
     2359    query.bindValue(":USERBAND",  m_scr_userband);
     2360    query.bindValue(":FREQUENCY", m_scr_frequency);
     2361    query.bindValue(":PIN",       m_scr_pin);
     2362    query.bindValue(":REPEAT",    m_repeat);
     2363
     2364    // update dev_id
     2365    if (!query.exec())
     2366    {
     2367        MythDB::DBError("DiSEqCDevSCR::Store", query);
     2368        return false;
     2369    }
     2370
     2371    // figure out devid if we did an insert
     2372    if (!IsRealDeviceID())
     2373        SetDeviceID(query.lastInsertId().toUInt());
     2374
     2375    // chain to child
     2376    if (m_child)
     2377        return m_child->Store();
     2378
     2379    return true;
     2380}
     2381
     2382bool DiSEqCDevSCR::SetChild(uint ordinal, DiSEqCDevDevice *device)
     2383{
     2384    if (ordinal)
     2385        return false;
     2386
     2387    DiSEqCDevDevice *old_child = m_child;
     2388    m_child = NULL;
     2389    if (old_child)
     2390        delete old_child;
     2391
     2392    m_child = device;
     2393    if (m_child)
     2394    {
     2395        m_child->SetOrdinal(ordinal);
     2396        m_child->SetParent(this);
     2397    }
     2398
     2399    return true;
     2400}
     2401
     2402////////////////////////////////////////
    20552403
    20562404/** \class DiSEqCDevLNB
    20572405 *  \brief LNB Class.
  • mythtv/libs/libmythtv/diseqc.h

    diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqc.h mythtv-0.26-20130424-g5f45c0b-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-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqcsettings.cpp mythtv-0.26-20130424-g5f45c0b-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-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqcsettings.h mythtv-0.26-20130424-g5f45c0b-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-20130424-g5f45c0b-old/mythtv/libs/libmythtv/dvbchannel.cpp mythtv-0.26-20130424-g5f45c0b-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        {