Ticket #4133: myth_tone_switch_r14623.diff

File myth_tone_switch_r14623.diff, 6.5 KB (added by anonymous, 16 years ago)
  • libs/libmythtv/diseqc.h

     
    224224        kTypeLegacySW21        = 3,
    225225        kTypeLegacySW42        = 4,
    226226        kTypeLegacySW64        = 5,
     227        kTypeVoltage           = 6,
     228        kTypeMiniDiSEqC        = 7,
    227229    };
    228230    void SetType(dvbdev_switch_t type)        { m_type = type;      }
    229231    void SetNumPorts(uint num_ports);
     
    252254
    253255
    254256  protected:
    255     bool ExecuteLegacy(const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
    256     bool ExecuteTone(  const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
    257     bool ExecuteDiseqc(const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
     257    bool ExecuteLegacy(    const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
     258    bool ExecuteTone(      const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
     259    bool ExecuteVoltage(   const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
     260    bool ExecuteMiniDiSEqC(const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
     261    bool ExecuteDiseqc(    const DiSEqCDevSettings&, const DTVMultiplex&, uint pos);
    258262
    259     int  GetPosition(  const DiSEqCDevSettings&) const;
     263    int  GetPosition(      const DiSEqCDevSettings&) const;
    260264
    261265  private:
    262266    dvbdev_switch_t m_type;
     
    266270    uint            m_last_horizontal;
    267271    dvbdev_vec_t    m_children;
    268272
    269     static const TypeTable SwitchTypeTable[7];
     273    static const TypeTable SwitchTypeTable[9];
    270274};
    271275
    272276class DiSEqCDevRotor : public DiSEqCDevDevice
  • libs/libmythtv/diseqcsettings.cpp

     
    147147
    148148        addSelection(DeviceTree::tr("Tone"),
    149149                     QString::number((uint) DiSEqCDevSwitch::kTypeTone));
     150        addSelection(DeviceTree::tr("Voltage"),
     151                     QString::number((uint) DiSEqCDevSwitch::kTypeVoltage));
     152        addSelection(DeviceTree::tr("Mini DiSEqC"),
     153                     QString::number((uint) DiSEqCDevSwitch::kTypeMiniDiSEqC));
    150154        addSelection(DeviceTree::tr("DiSEqC"),
    151155                     QString::number((uint)
    152156                                     DiSEqCDevSwitch::kTypeDiSEqCCommitted));
     
    232236    switch ((DiSEqCDevSwitch::dvbdev_switch_t) m_type->getValue().toUInt())
    233237    {
    234238        case DiSEqCDevSwitch::kTypeTone:
     239        case DiSEqCDevSwitch::kTypeVoltage:
     240        case DiSEqCDevSwitch::kTypeMiniDiSEqC:
    235241        case DiSEqCDevSwitch::kTypeLegacySW21:
    236242        case DiSEqCDevSwitch::kTypeLegacySW42:
    237243            m_ports->setValue("2");
  • libs/libmythtv/diseqc.cpp

     
    936936 *  \brief Switch class, including tone, legacy and DiSEqC switches.
    937937 */
    938938
    939 const DiSEqCDevDevice::TypeTable DiSEqCDevSwitch::SwitchTypeTable[7] =
     939const DiSEqCDevDevice::TypeTable DiSEqCDevSwitch::SwitchTypeTable[9] =
    940940{
    941941    { "legacy_sw21",  kTypeLegacySW21        },
    942942    { "legacy_sw42",  kTypeLegacySW42        },
     
    944944    { "tone",         kTypeTone          },
    945945    { "diseqc",       kTypeDiSEqCCommitted   },
    946946    { "diseqc_uncom", kTypeDiSEqCUncommitted },
     947    { "voltage",      kTypeVoltage       },
     948    { "mini_diseqc",  kTypeMiniDiSEqC    },
    947949    { QString::null,  kTypeTone          },
    948950};
    949951
     
    987989            case kTypeTone:
    988990                success = ExecuteTone(settings, tuning, pos);
    989991                break;
     992            case kTypeVoltage:
     993                success = ExecuteVoltage(settings, tuning, pos);
     994                break;
     995            case kTypeMiniDiSEqC:
     996                success = ExecuteMiniDiSEqC(settings, tuning, pos);
     997               break;
    990998            case kTypeDiSEqCCommitted:
    991999            case kTypeDiSEqCUncommitted:
    9921000                success = ExecuteDiseqc(settings, tuning, pos);
     
    13201328}
    13211329
    13221330#ifdef USING_DVB
     1331static bool set_tone(int fd, fe_sec_tone_mode tone)
     1332{
     1333    (void) fd;
     1334    (void) tone;
     1335
     1336    bool success = false;
     1337
     1338    for (uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
     1339    {
     1340        if(ioctl(fd, FE_SET_TONE, tone) == 0)
     1341           success = true;
     1342       else
     1343           usleep(TIMEOUT_WAIT);
     1344    }
     1345
     1346    if(!success)
     1347    {
     1348        VERBOSE(VB_IMPORTANT, "set_tone failed" + ENO);
     1349    }
     1350
     1351    return success;
     1352}
     1353
     1354static bool set_voltage(int fd, fe_sec_voltage volt)
     1355{
     1356    (void) fd;
     1357    (void) volt;
     1358
     1359    bool success = false;
     1360
     1361    for (uint retry = 0; !success && (retry < TIMEOUT_RETRIES); retry++)
     1362    {
     1363        if (ioctl(fd, FE_SET_VOLTAGE, volt) == 0)
     1364            success = true;
     1365        else
     1366            usleep(TIMEOUT_WAIT);
     1367    }
     1368
     1369    if (!success)
     1370    {
     1371        VERBOSE(VB_IMPORTANT, "FE_SET_VOLTAGE failed" + ENO);
     1372    }
     1373
     1374    return success;
     1375}
     1376
    13231377static bool mini_diseqc(int fd, fe_sec_mini_cmd cmd)
    13241378{
    13251379    (void) fd;
     
    13521406            QString("%1/2").arg(pos + 1));
    13531407
    13541408#ifdef USING_DVB
    1355     if (mini_diseqc(m_tree.GetFD(), pos == 0 ? SEC_MINI_A : SEC_MINI_B))
     1409    if (set_tone(m_tree.GetFD(), pos == 0 ? SEC_TONE_OFF : SEC_TONE_ON))
    13561410        return true;
    13571411#endif // USING_DVB
    13581412
     
    13601414    return false;
    13611415}
    13621416
     1417bool DiSEqCDevSwitch::ExecuteVoltage(const DiSEqCDevSettings &/*settings*/,
     1418                                  const DTVMultiplex &/*tuning*/,
     1419                                  uint pos)
     1420{
     1421    VERBOSE(VB_CHANNEL, LOC + "Changing to Voltage Switch port " +
     1422            QString("%1/2").arg(pos + 1));
     1423
     1424#ifdef USING_DVB
     1425    if (set_voltage(m_tree.GetFD(), pos == 0 ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18))
     1426        return true;
     1427#endif // USING_DVB
     1428    VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting Voltage Switch failed." + ENO);
     1429    return false;
     1430}
     1431
     1432bool DiSEqCDevSwitch::ExecuteMiniDiSEqC(const DiSEqCDevSettings &/*settings*/,
     1433                                  const DTVMultiplex &/*tuning*/,
     1434                                  uint pos)
     1435{
     1436    VERBOSE(VB_CHANNEL, LOC + "Changing to MiniDiSEqC Switch port " +
     1437            QString("%1/2").arg(pos + 1));
     1438
     1439#ifdef USING_DVB
     1440    if (mini_diseqc(m_tree.GetFD(), pos == 0 ? SEC_MINI_A : SEC_MINI_B))
     1441        return true;
     1442#endif // USING_DVB
     1443    VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting Mini DiSEqC Switch failed." + ENO);
     1444    return false;
     1445}
     1446
    13631447bool DiSEqCDevSwitch::ShouldSwitch(const DiSEqCDevSettings &settings,
    13641448                                   const DTVMultiplex &tuning) const
    13651449{