Ticket #9726: mythtv-0.27-unicable.patch

File mythtv-0.27-unicable.patch, 30.4 KB (added by k_straussberger@…, 12 years ago)

I ported the patch to 0.27

  • .27/mythtv/libs/libmythtv/diseqc.cpp

    diff -Naur mythtv-orig-0.27/mythtv/libs/libmythtv/diseqc.cpp mythtv-fixes-0.27/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.
  • .27/mythtv/libs/libmythtv/diseqc.h

    diff -Naur mythtv-orig-0.27/mythtv/libs/libmythtv/diseqc.h mythtv-fixes-0.27/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:
  • .27/mythtv/libs/libmythtv/diseqcsettings.cpp

    diff -Naur mythtv-orig-0.27/mythtv/libs/libmythtv/diseqcsettings.cpp mythtv-fixes-0.27/mythtv/libs/libmythtv/diseqcsettings.cpp
    old new  
    4747                     QString::number((uint) DiSEqCDevDevice::kTypeSwitch));
    4848        addSelection(DeviceTree::tr("Rotor"),
    4949                     QString::number((uint) DiSEqCDevDevice::kTypeRotor));
     50        addSelection(DeviceTree::tr("Unicable"),
     51                     QString::number((uint) DiSEqCDevDevice::kTypeSCR));
    5052        addSelection(DeviceTree::tr("LNB"),
    5153                     QString::number((uint) DiSEqCDevDevice::kTypeLNB));
    5254    }
     
    107109{
    108110  public:
    109111    DeviceRepeatSetting(DiSEqCDevDevice &device) :
    110         SpinBoxSetting(this, 0, 5, 1), m_device(device)
     112        SpinBoxSetting(this, 0, 15, 1), m_device(device)
    111113    {
    112114        setLabel(DeviceTree::tr("Repeat Count"));
    113115        QString help = DeviceTree::tr(
    114             "Number of times to repeat DiSEqC commands sent to this device. "
    115             "Larger values may help with less reliable devices.");
     116            "Number of repeat (command with repeat flag ON) or resend (the same command) DiSEqC commands."
     117            "If value is higher than 10, command will be resend N-10 times"
     118            "If value is lower than 10, command will be repeated N times"
     119            "Repeat useful for unreliable DiSEqC equipment; resend useful when unreliable DiSEq equipment has broken/unsuported repeat flag support.");
    116120        setHelpText(help);
    117121    }
    118122
     
    559563    config.Save();
    560564}
    561565
     566//////////////////////////////////////// SCRUserBandSetting
     567
     568class SCRUserBandSetting : public SpinBoxSetting, public Storage
     569{
     570  public:
     571    SCRUserBandSetting(DiSEqCDevSCR &scr) :
     572        SpinBoxSetting(this, 0, 8, 1), m_scr(scr)
     573    {
     574        setLabel(DeviceTree::tr("Userband"));
     575        setHelpText(DeviceTree::tr("Unicable userband ID (0-7) or sometimes (1-8)"));
     576    }
     577
     578    virtual void Load(void)
     579    {
     580        setValue(m_scr.GetUserBand());
     581    }
     582
     583    virtual void Save(void)
     584    {
     585        m_scr.SetUserBand(intValue());
     586    }
     587
     588    virtual void Save(QString /*destination*/) { }
     589
     590  private:
     591    DiSEqCDevSCR &m_scr;
     592};
     593
     594//////////////////////////////////////// SCRFrequencySetting
     595
     596class SCRFrequencySetting : public LineEditSetting, public Storage
     597{
     598  public:
     599    SCRFrequencySetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     600    {
     601        setLabel(DeviceTree::tr("Frequency (MHz)"));
     602        setHelpText(DeviceTree::tr("Unicable userband frequency (usually 1210, 1420, 1680 and 2040 MHz)"));
     603    }
     604
     605    virtual void Load(void)
     606    {
     607        setValue(QString::number(m_scr.GetFrequency()));
     608    }
     609
     610    virtual void Save(void)
     611    {
     612        m_scr.SetFrequency(getValue().toUInt());
     613    }
     614
     615    virtual void Save(QString /*destination*/) { }
     616
     617  private:
     618    DiSEqCDevSCR &m_scr;
     619};
     620
     621//////////////////////////////////////// SCRPINSetting
     622
     623class SCRPINSetting : public LineEditSetting, public Storage
     624{
     625  public:
     626    SCRPINSetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr)
     627    {
     628        setLabel(DeviceTree::tr("PIN code"));
     629        setHelpText(DeviceTree::tr("Unicable PIN code (-1 disabled, 0 - 255)"));
     630    }
     631
     632    virtual void Load(void)
     633    {
     634        setValue(QString::number(m_scr.GetPIN()));
     635    }
     636
     637    virtual void Save(void)
     638    {
     639        m_scr.SetPIN(getValue().toInt());
     640    }
     641
     642    virtual void Save(QString /*destination*/) { }
     643
     644  private:
     645    DiSEqCDevSCR &m_scr;
     646};
     647
     648//////////////////////////////////////// SCRConfig
     649
     650SCRConfig::SCRConfig(DiSEqCDevSCR &scr) : m_scr(scr)
     651{
     652    ConfigurationGroup *group =
     653        new VerticalConfigurationGroup(false, false);
     654    group->setLabel(DeviceTree::tr("Unicable Configuration"));
     655
     656    group->addChild(new SCRUserBandSetting(scr));
     657    group->addChild(new SCRFrequencySetting(scr));
     658    group->addChild(new SCRPINSetting(scr));
     659    group->addChild(new DeviceRepeatSetting(scr));
     660
     661    addChild(group);
     662}
     663
    562664//////////////////////////////////////// LnbPresetSetting
    563665
    564666class lnb_preset
     
    9491051        }
    9501052        break;
    9511053
     1054        case DiSEqCDevDevice::kTypeSCR:
     1055        {
     1056            DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(dev);
     1057            if (scr)
     1058            {
     1059                SCRConfig config(*scr);
     1060                changed = (config.exec() == MythDialog::Accepted);
     1061            }
     1062        }
     1063        break;
     1064
    9521065        case DiSEqCDevDevice::kTypeLNB:
    9531066        {
    9541067            DiSEqCDevLNB *lnb = dynamic_cast<DiSEqCDevLNB*>(dev);
     
    9781091    MythListBox *list = new MythListBox(popup);
    9791092    list->insertItem(tr("Switch"));
    9801093    list->insertItem(tr("Rotor"));
     1094    list->insertItem(tr("Unicable"));
    9811095    list->insertItem(tr("LNB"));
    9821096    list->setCurrentRow(0, QItemSelectionModel::Select);
    9831097
     
    12641378    DiSEqCDevSettings    &m_settings;
    12651379};
    12661380
     1381//////////////////////////////////////// SCRPositionSetting
     1382
     1383class SCRPositionSetting : public ComboBoxSetting, public Storage
     1384{
     1385  public:
     1386    SCRPositionSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
     1387        : ComboBoxSetting(this), m_node(node), m_settings(settings)
     1388    {
     1389        setLabel("Position");
     1390        setHelpText(DeviceTree::tr("Unicable satellite position (A/B)"));
     1391        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosA),
     1392                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosA), true);
     1393        addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosB),
     1394                     QString::number((uint)DiSEqCDevSCR::kTypeScrPosB), false);
     1395    }
     1396
     1397    virtual void Load(void)
     1398    {
     1399        double value = m_settings.GetValue(m_node.GetDeviceID());
     1400        setValue(getValueIndex(QString::number((uint)value)));
     1401    }
     1402
     1403    virtual void Save(void)
     1404    {
     1405        m_settings.SetValue(m_node.GetDeviceID(), getValue().toDouble());
     1406    }
     1407
     1408    virtual void Save(QString /*destination*/) { }
     1409
     1410  private:
     1411    DiSEqCDevDevice      &m_node;
     1412    DiSEqCDevSettings    &m_settings;
     1413};
     1414
    12671415//////////////////////////////////////// DTVDeviceConfigGroup
    12681416
    12691417DTVDeviceConfigGroup::DTVDeviceConfigGroup(
     
    13061454                setting = new USALSRotorSetting(*node, m_settings);
    13071455            break;
    13081456        }
     1457        case DiSEqCDevDevice::kTypeSCR:
     1458        {
     1459            setting = new SCRPositionSetting(*node, m_settings);
     1460            break;
     1461        }
    13091462        default:
    13101463            break;
    13111464    }
     
    13801533    DISEQC_POSITIONER_X_SWITCH_2   = 9,
    13811534    DISEQC_SW21                    = 10,
    13821535    DISEQC_SW64                    = 11,
     1536    DISEQC_SCR                     = 12,
    13831537};
    13841538
    13851539// import old diseqc configuration into tree
     
    15491703                break;
    15501704            }
    15511705
     1706            case DISEQC_SCR:
     1707            {
     1708                // SCR + LNB
     1709                root = DiSEqCDevDevice::CreateByType(
     1710                    tree, DiSEqCDevDevice::kTypeSCR);
     1711                DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(root);
     1712                if (scr)
     1713                {
     1714                    add_lnbs = 1;
     1715                }
     1716                break;
     1717            }
     1718
    15521719            default:
    15531720            {
    15541721                LOG(VB_GENERAL, LOG_ERR, "Unknown DiSEqC device type " +
     
    16151782
    16161783                case DISEQC_POSITIONER_1_2:
    16171784                case DISEQC_POSITIONER_X:
     1785                case DISEQC_SCR:
    16181786                    lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(0));
    16191787                    set.SetValue(root->GetDeviceID(), pos);
    16201788                    break;
  • .27/mythtv/libs/libmythtv/diseqcsettings.h

    diff -Naur mythtv-orig-0.27/mythtv/libs/libmythtv/diseqcsettings.h mythtv-fixes-0.27/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;
  • .27/mythtv/libs/libmythtv/recorders/dvbchannel.cpp

    diff -Naur mythtv-orig-0.27/mythtv/libs/libmythtv/recorders/dvbchannel.cpp mythtv-fixes-0.27/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
    old new  
    269269    // Turn on the power to the LNB
    270270    if (tunerType.IsDiSEqCSupported())
    271271    {
     272
    272273        diseqc_tree = diseqc_dev.FindTree(GetCardID());
    273274        if (diseqc_tree)
    274             diseqc_tree->Open(fd_frontend);
     275        {
     276            bool is_SCR = false;
     277
     278            DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings);
     279            if (scr)
     280            {
     281                is_SCR = true;
     282                LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on SCR system");
     283            }
     284            else
     285                LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on non-SCR system");
     286
     287            diseqc_tree->Open(fd_frontend, is_SCR);
     288        }
    275289    }
    276290
    277291    first_tune = true;
     
    685699    // Remove any events in queue before tuning.
    686700    drain_dvb_events(fd_frontend);
    687701
    688     // send DVB-S setup
    689     if (diseqc_tree)
    690     {
    691         // configure for new input
    692         if (!same_input)
    693             diseqc_settings.Load(inputid);
    694 
    695         // execute diseqc commands
    696         if (!diseqc_tree->Execute(diseqc_settings, tuning))
    697         {
    698             LOG(VB_GENERAL, LOG_ERR, LOC +
    699                 "Tune(): Failed to setup DiSEqC devices");
    700             return false;
    701         }
    702 
    703         // retrieve actual intermediate frequency
    704         DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings);
    705         if (!lnb)
    706         {
    707             LOG(VB_GENERAL, LOG_ERR, LOC +
    708                 "Tune(): No LNB for this configuration");
    709             return false;
    710         }
    711 
    712         if (lnb->GetDeviceID() != last_lnb_dev_id)
    713         {
    714             last_lnb_dev_id = lnb->GetDeviceID();
    715             // make sure we tune to frequency, if the lnb has changed
    716             reset = first_tune = true;
    717         }
    718 
    719         intermediate_freq = lnb->GetIntermediateFrequency(
    720             diseqc_settings, tuning);
    721 
    722         // if card can auto-FEC, use it -- sometimes NITs are inaccurate
    723         if (capabilities & FE_CAN_FEC_AUTO)
    724             can_fec_auto = true;
    725 
    726         // Check DVB-S intermediate frequency here since it requires a fully
    727         // initialized diseqc tree
    728         CheckFrequency(intermediate_freq);
    729     }
    730 
    731     LOG(VB_CHANNEL, LOG_INFO, LOC + "Old Params: " + prev_tuning.toString() +
    732             "\n\t\t\t" + LOC + "New Params: " + tuning.toString());
     702    LOG(VB_CHANNEL, LOG_INFO, LOC + "\nOld Params: " + prev_tuning.toString() +
     703            "\nNew Params: " + tuning.toString());
    733704
    734705    // DVB-S is in kHz, other DVB is in Hz
    735706    bool is_dvbs = ((DTVTunerType::kTunerTypeDVBS1 == tunerType) ||
     
    743714                .arg(intermediate_freq ? intermediate_freq : tuning.frequency)
    744715                .arg(suffix));
    745716
     717        // send DVB-S setup
     718        if (diseqc_tree)
     719        {
     720            // configure for new input
     721            if (!same_input)
     722                diseqc_settings.Load(inputid);
     723
     724            // execute diseqc commands
     725            if (!diseqc_tree->Execute(diseqc_settings, tuning))
     726            {
     727                LOG(VB_GENERAL, LOG_ERR, LOC +
     728                    "Tune(): Failed to setup DiSEqC devices");
     729                return false;
     730            }
     731
     732            // retrieve actual intermediate frequency
     733            DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings);
     734            if (!lnb)
     735            {
     736                LOG(VB_GENERAL, LOG_ERR, LOC +
     737                    "Tune(): No LNB for this configuration");
     738                return false;
     739            }
     740
     741            if (lnb->GetDeviceID() != last_lnb_dev_id)
     742            {
     743                last_lnb_dev_id = lnb->GetDeviceID();
     744                // make sure we tune to frequency, if the lnb has changed
     745                reset = first_tune = true;
     746            }
     747
     748            intermediate_freq = lnb->GetIntermediateFrequency(
     749                diseqc_settings, tuning);
     750
     751            // retrieve scr intermediate frequency
     752            DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings);
     753            if (lnb && scr)
     754            {
     755                intermediate_freq = scr->GetIntermediateFrequency(intermediate_freq);
     756            }
     757
     758            // if card can auto-FEC, use it -- sometimes NITs are inaccurate
     759            if (capabilities & FE_CAN_FEC_AUTO)
     760                can_fec_auto = true;
     761
     762            // Check DVB-S intermediate frequency here since it requires a fully
     763            // initialized diseqc tree
     764            CheckFrequency(intermediate_freq);
     765        }
     766
    746767#if DVB_API_VERSION >=5
    747768        if (DTVTunerType::kTunerTypeDVBS2 == tunerType)
    748769        {