Ticket #1945: dvbdevtree_gui_integration.patch

File dvbdevtree_gui_integration.patch, 27.9 KB (added by yeasah@…, 19 years ago)

Patch containing integration of device tree GUI

  • libs/libmythtv/libmythtv.pro

     
    408408
    409409        # Channel stuff
    410410        HEADERS += dvbchannel.h           dvbsignalmonitor.h
    411         HEADERS += dvbdiseqc.h            dvbcam.h
     411        HEADERS += dvbdevtree.h           dvbcam.h
     412        HEADERS += dvbdevtree_cfg.h
    412413        SOURCES += dvbchannel.cpp         dvbsignalmonitor.cpp
    413         SOURCES += dvbdiseqc.cpp          dvbcam.cpp
     414        SOURCES += dvbdevtree.cpp         dvbcam.cpp
     415        SOURCES += dvbdevtree_cfg.cpp
    414416
    415417        # DVB Recorder
    416418        HEADERS += dvbrecorder.h
  • libs/libmythtv/videosource.cpp

     
    3333
    3434#ifdef USING_DVB
    3535#include <linux/dvb/frontend.h>
     36#include "dvbdevtree_cfg.h"
    3637#endif
    3738
    3839#if defined(CONFIG_VIDEO4LINUX)
     
    4546    RecorderOptions(CaptureCard& parent);
    4647};
    4748
    48 class DVBDiSEqCConfigurationWizard: public ConfigurationWizard
    49 {
    50   public:
    51     DVBDiSEqCConfigurationWizard(CaptureCard &parent);
    52 };
    53 
    5449QString VSSetting::whereClause(MSqlBindings& bindings)
    5550{
    5651    QString sourceidTag(":WHERESOURCEID");
     
    785780    };
    786781};
    787782
    788 class DVBDiSEqCType: public ComboBoxSetting, public CCSetting
    789 {
    790   public:
    791     DVBDiSEqCType(const CaptureCard& parent)
    792       : CCSetting(parent, "dvb_diseqc_type")
    793     {
    794         setLabel(QObject::tr("DiSEqC Input Type: (DVB-S)"));
    795         addSelection(QObject::tr("Single LNB / Input"),
    796                      QString::number(DISEQC_SINGLE));
    797         addSelection(QObject::tr("Tone Switch aka Mini DiSEqC (2-Way)"),
    798                      QString::number(DISEQC_MINI_2));
    799         addSelection(QObject::tr("DiSEqC v1.0 Switch (2-Way)"),
    800                      QString::number(DISEQC_SWITCH_2_1_0));
    801         addSelection(QObject::tr("DiSEqC v1.1 Switch (2-Way)"),
    802                      QString::number(DISEQC_SWITCH_2_1_1));
    803         addSelection(QObject::tr("DiSEqC v1.0 Switch (4-Way)"),
    804                      QString::number(DISEQC_SWITCH_4_1_0));
    805         addSelection(QObject::tr("DiSEqC v1.1 Switch (4-Way)"),
    806                      QString::number(DISEQC_SWITCH_4_1_1));
    807         addSelection(QObject::tr("DiSEqC v1.2 Positioner"),
    808                      QString::number(DISEQC_POSITIONER_1_2));
    809         addSelection(QObject::tr("DiSEqC v1.3 Positioner (Goto X)"),
    810                      QString::number(DISEQC_POSITIONER_X));
    811         addSelection(QObject::tr("DiSEqC v1.1 or 2.1 (10-way method2)"),
    812                      QString::number(DISEQC_POSITIONER_1_2_SWITCH_2));
    813         addSelection(QObject::tr("SW21 Switch (2-Way)"),
    814                      QString::number(DISEQC_SW21));
    815         addSelection(QObject::tr("SW64 Switch (3-Way)"),
    816                      QString::number(DISEQC_SW64));
    817         setHelpText(QObject::tr("Select the input type for DVB-S cards. "
    818                     "Leave as Single LNB/Input for DVB-C or DVB-T. "
    819                     "The inputs are mapped from Input Connections option "
    820                     "on the main menu"));
    821     };
    822 };
    823 
    824783class DVBTuningDelay: public SpinBoxSetting, public CCSetting
    825784{
    826785  public:
     
    12961255    }
    12971256}
    12981257
     1258void CaptureCard::save()
     1259{
     1260    ConfigurationWizard::save();
     1261#ifdef USING_DVB
     1262    tree.Store(getCardID());
     1263    DVBDev trees;
     1264    trees.InvalidateTrees();
     1265#endif
     1266}
     1267
    12991268void CaptureCard::loadByID(int cardid)
    13001269{
     1270#ifdef USING_DVB
     1271    tree.Load(cardid);
     1272#endif
    13011273    id->setValue(cardid);
    13021274    load();
    13031275}
     
    14311403    };
    14321404};
    14331405
    1434 class LNBLofSwitch: public LineEditSetting, public CISetting {
    1435   public:
    1436     LNBLofSwitch(const CardInput& parent):
    1437         CISetting(parent, "lnb_lof_switch") {
    1438         setLabel(QObject::tr("LNB LOF Switch"));
    1439         setValue("11700000");
    1440         setHelpText(QObject::tr("This defines at what frequency (in Hz) "
    1441                     "the LNB will do a switch from high to low setting, "
    1442                     "and vice versa."));
    1443     };
    1444 };
    1445 
    1446 class LNBLofHi: public LineEditSetting, public CISetting {
    1447   public:
    1448     LNBLofHi(const CardInput& parent):
    1449         CISetting(parent, "lnb_lof_hi") {
    1450         setLabel(QObject::tr("LNB LOF High"));
    1451         setValue("10600000");
    1452         setHelpText(QObject::tr("This defines the offset (in Hz) the "
    1453                     "frequency coming from the LNB will be in high "
    1454                     "setting."));
    1455     };
    1456 };
    1457 
    1458 class LNBLofLo: public LineEditSetting, public CISetting {
    1459   public:
    1460     LNBLofLo(const CardInput& parent):
    1461         CISetting(parent, "lnb_lof_lo") {
    1462         setLabel(QObject::tr("LNB LOF Low"));
    1463         setValue("9750000");
    1464         setHelpText(QObject::tr("This defines the offset (in Hz) the "
    1465                     "frequency coming from the LNB will be in low "
    1466                     "setting."));
    1467     };
    1468 };
    1469 
    1470 class DiSEqCPos: public LineEditSetting, public CISetting
    1471 {
    1472   public:
    1473     DiSEqCPos(const CardInput& parent)
    1474         : CISetting(parent, "diseqc_pos")
    1475     {
    1476         setLabel(QObject::tr("DiSEqC Satellite Location"));
    1477         setValue("0.0");
    1478         setHelpText(QObject::tr("The longitude of the satellite "
    1479                     "you are aiming at.  For western hemisphere use "
    1480                     "a negative value.  Value is in decimal."));
    1481 //        setVisible(false);
    1482     };
    1483 //    void fillSelections(const QString& pos) {
    1484 //        setValue(pos);
    1485 //    };
    1486 };
    1487 
    1488 
    1489 class DiSEqCPort: public LabelSetting, public CISetting
    1490 {
    1491   public:
    1492     DiSEqCPort(const CardInput& parent)
    1493         : CISetting(parent, "diseqc_port")
    1494     {
    1495         setVisible(false);
    1496     };
    1497     void fillSelections(const QString& port) {
    1498         setValue(port);
    1499     };
    1500 };
    1501 
    1502 
    15031406class FreeToAir: public CheckBoxSetting, public CISetting {
    15041407  public:
    15051408    FreeToAir(const CardInput& parent):
     
    16141517    };
    16151518};
    16161519
    1617 class DVBLNBChooser: public ComboBoxSetting {
    1618   public:
    1619     DVBLNBChooser()
    1620     {
    1621         setLabel("LNB Settings: (DVB-S)");
    1622         addSelection("Universal - 2");
    1623         addSelection("DBS");
    1624         addSelection("Universal - 1");
    1625         addSelection("Custom");
    1626         setHelpText(
    1627             QObject::tr("Select the LNB Settings for DVB-S cards.") + " " +
    1628             QObject::tr("For DVB-C and DVB-T you don't need to "
    1629                         "set these values."));
    1630     };
    1631     void save() {};
    1632     void load() {};
    1633 
    1634 private:
    1635 };
    1636 
    16371520class DishNetEIT: public CheckBoxSetting, public CISetting
    16381521{
    16391522  public:
     
    16501533    };
    16511534};
    16521535
    1653 CardInput::CardInput(bool isDVBcard)
     1536CardInput::CardInput(bool isDVBcard, int _cardid)
    16541537{
    16551538    addChild(id = new ID());
    16561539
     
    16721555        group->addChild(new PresetTuner(*this));
    16731556    }
    16741557
     1558#ifdef USING_DVB
     1559    if (isDVBcard)
     1560    {
     1561        ConfigurationGroup *dvbgroup =
     1562            new HorizontalConfigurationGroup();
     1563        dvbgroup->setLabel(QObject::tr("DVB options"));
     1564
     1565        ConfigurationGroup *chgroup =
     1566            new VerticalConfigurationGroup(false, false, true, true);
     1567
     1568        TransButtonSetting *diseqc = new TransButtonSetting();
     1569        diseqc->setLabel(tr("DVB-S"));
     1570        diseqc->setHelpText(tr("Input and satellite settings."));
     1571        diseqc->setVisible(DTVDeviceNeedsConfiguration(_cardid));
     1572        dvbgroup->addChild(diseqc);
     1573        connect(diseqc, SIGNAL(pressed()), SLOT(diseqcConfig()));
     1574   
     1575        chgroup->addChild(new FreeToAir(*this));
     1576        chgroup->addChild(new RadioServices(*this));
     1577        chgroup->addChild(new DishNetEIT(*this));
     1578        dvbgroup->addChild(chgroup);
     1579        group->addChild(dvbgroup);
     1580    }
     1581#endif
     1582
    16751583    TransButtonSetting *scan = new TransButtonSetting();
    16761584    scan->setLabel(tr("Scan for channels"));
    16771585    scan->setHelpText(
     
    16961604
    16971605    addChild(group);
    16981606
    1699 #ifdef USING_DVB
    1700     if (isDVBcard)
    1701     {
    1702         ConfigurationGroup *dvbgroup =
    1703           new VerticalConfigurationGroup(false, false, true, true);
    1704    
    1705         dvbgroup->addChild(diseqcpos    = new DiSEqCPos(*this));
    1706         dvbgroup->addChild(diseqcport   = new DiSEqCPort(*this));
    1707         dvbgroup->addChild(lnblofswitch = new LNBLofSwitch(*this));
    1708         dvbgroup->addChild(lnblofhi = new LNBLofHi(*this));
    1709         dvbgroup->addChild(lnbloflo = new LNBLofLo(*this));
    1710 
    1711         dvbgroup->addChild(new FreeToAir(*this));
    1712         dvbgroup->addChild(new RadioServices(*this));
    1713         dvbgroup->addChild(new DishNetEIT(*this));
    1714         addChild(dvbgroup);
    1715     }
    1716 #endif
    1717 
    17181607    childid = new ChildID(*this);
    17191608    addChild(childid);
    17201609
     
    17781667    }
    17791668}
    17801669
     1670void CardInput::diseqcConfig(void)
     1671{
     1672#ifdef USING_DVB
     1673    DTVDeviceConfigWizard wizard(settings, cardid->getValue().toUInt());
     1674    wizard.exec();
     1675#endif // USING_DVB
     1676}
     1677
    17811678QString CISetting::whereClause(MSqlBindings& bindings)
    17821679{
    17831680    QString cardinputidTag(":WHERECARDINPUTID");
     
    18061703void CardInput::loadByID(int inputid)
    18071704{
    18081705    id->setValue(inputid);
     1706#ifdef USING_DVB
     1707    settings.Load(inputid);
     1708#endif
    18091709    load();
    18101710}
    18111711
     
    18281728        cardid->setValue(QString::number(_cardid));
    18291729        inputname->setValue(_inputname);
    18301730    }
    1831 
    1832     if (CardUtil::IsDVB(_cardid, _inputname))
    1833     {
    1834         QString subtype = CardUtil::ProbeSubTypeName(_cardid, _inputname);
    1835         CardUtil::CARD_TYPES dvbType = CardUtil::toCardType(subtype);
    1836        
    1837         if ("QPSK" == subtype)
    1838         {
    1839             //Check for DiSEqC type
    1840             diseqcpos->setVisible(true);
    1841             lnblofswitch->setVisible(true);
    1842             lnbloflo->setVisible(true);
    1843             lnblofhi->setVisible(true);
    1844 
    1845             DISEQC_TYPES dt = CardUtil::GetDISEqCType(_cardid);
    1846             bool pos = (dt == DISEQC_POSITIONER_X);
    1847             diseqcpos->setEnabled(pos);
    1848         }
    1849         else if (dvbType > CardUtil::ERROR_PROBE)
    1850         {
    1851             diseqcpos->setVisible(false);
    1852             lnblofswitch->setVisible(false);
    1853             lnbloflo->setVisible(false);
    1854             lnblofhi->setVisible(false);
    1855         }
    1856     }
    18571731}
    18581732
    18591733void CardInput::save()
     
    18701744    else
    18711745    {
    18721746        ConfigurationWizard::save();
     1747#ifdef USING_DVB
     1748        settings.Store(getInputID());
     1749#endif
    18731750    }
    18741751}
    18751752
    1876 void CardInput::fillDiseqcSettingsInput(QString _pos, QString _port)
    1877 {
    1878     if (_port != "")
    1879         diseqcport->setValue(_port);
    1880     if (_pos != "")
    1881         diseqcpos->setValue(_pos);
    1882 }
    1883 
    18841753int CISetting::getInputID(void) const
    18851754{
    18861755    return parent.getInputID();
     
    21402009
    21412010void CardInputEditor::load()
    21422011{
     2012    cardinputs.clear();
    21432013    clearSelections();
    21442014
    21452015    // We do this manually because we want custom labels.  If
     
    23272197
    23282198    last_device = device;
    23292199    QStringList inputs =
    2330         CardUtil::probeInputs(device, last_cardtype, last_diseqct);
     2200        CardUtil::probeInputs(device, last_cardtype);
    23312201
    23322202    for (QStringList::iterator i = inputs.begin(); i != inputs.end(); ++i)
    23332203        addSelection(*i);
    23342204}
    23352205
    2336 void TunerCardInput::diseqcType(const QString &diseqcType)
    2337 {
    2338     bool ok;
    2339     int tmp = diseqcType.toInt(&ok);
    2340     if (ok)
    2341     {
    2342         last_diseqct = tmp;
    2343         fillSelections(last_device);
    2344     }
    2345 }
    2346 
    23472206DVBConfigurationGroup::DVBConfigurationGroup(CaptureCard& a_parent) :
    23482207    ConfigurationGroup(false, true, false, false),
    23492208    VerticalConfigurationGroup(false, true, false, false),
     
    23702229    addChild(new DVBAudioDevice(parent));
    23712230    addChild(new DVBVbiDevice(parent));
    23722231
    2373     TransButtonSetting *buttonDiSEqC = new TransButtonSetting();
    2374     buttonDiSEqC->setLabel(tr("DiSEqC"));
    2375     buttonDiSEqC->setHelpText(tr("Input and satellite settings."));
    2376 
    23772232    buttonAnalog = new TransButtonSetting();
    23782233    buttonAnalog->setLabel(tr("Analog Options"));
    23792234    buttonAnalog->setVisible(false);
     
    23852240           "but the DVB drivers do not yet allow us to "
    23862241           "detect this problem."));
    23872242
     2243    TransButtonSetting *buttonDiSEqC = new TransButtonSetting();
     2244    buttonDiSEqC->setLabel(tr("DVB-S"));
     2245    buttonDiSEqC->setHelpText(tr("Input and satellite settings."));
     2246
    23882247    TransButtonSetting *buttonRecOpt = new TransButtonSetting();
    23892248    buttonRecOpt->setLabel(tr("Recording Options"));   
    2390     buttonDiSEqC->setHelpText(tr("Various additional settings."));
    23912249
    23922250    HorizontalConfigurationGroup *advcfg =
    23932251        new HorizontalConfigurationGroup(false, false, true, true);
     
    23962254    advcfg->addChild(buttonRecOpt);
    23972255    addChild(advcfg);
    23982256
    2399     DVBDiSEqCType  *diseqctype   = new DVBDiSEqCType(parent);
    2400     addChild(diseqctype);
    2401     diseqctype->setVisible(false);
    2402 
    24032257    TunerCardInput *defaultinput = new TunerCardInput(parent, "0", "DVB");
    24042258    addChild(defaultinput);
    24052259    defaultinput->setVisible(false);
     
    24182272            &parent,      SLOT(  analogPanel()));
    24192273    connect(buttonRecOpt, SIGNAL(pressed()),
    24202274            &parent,      SLOT(  recorderOptionsPanel()));
    2421     connect(diseqctype,   SIGNAL(valueChanged(const QString&)),
    2422             defaultinput, SLOT(  diseqcType  (const QString&)));
    24232275
    2424     defaultinput->diseqcType(diseqctype->getValue());
    24252276    cardnum->setValue(0);
    24262277}
    24272278
     
    24662317
    24672318void CaptureCard::DiSEqCPanel()
    24682319{
     2320#ifdef USING_DVB
    24692321    reload();
    24702322
    2471     DVBDiSEqCConfigurationWizard diseqcWiz(*this);
     2323    DTVDeviceTreeWizard diseqcWiz(tree);
    24722324    diseqcWiz.exec();
    24732325    load();
     2326#endif // USING_DVB
    24742327}
    24752328
    24762329RecorderOptions::RecorderOptions(CaptureCard& parent)
     
    24852338
    24862339    addChild(rec);
    24872340}
    2488 
    2489 static GlobalLineEdit *DiSEqCLatitude()
    2490 {
    2491     GlobalLineEdit *gc = new GlobalLineEdit("latitude");
    2492     gc->setLabel("Latitude");
    2493     gc->setHelpText(
    2494         QObject::tr("The Cartesian latitude for your location.") + " " +
    2495         QObject::tr("Use negative numbers for southern "
    2496                     "and western coordinates."));
    2497     return gc;
    2498 }
    2499 
    2500 static GlobalLineEdit *DiSEqCLongitude()
    2501 {
    2502     GlobalLineEdit *gc = new GlobalLineEdit("longitude");
    2503     gc->setLabel("Longitude");
    2504     gc->setHelpText(
    2505         QObject::tr("The Cartesian longitude for your location.") + " " +
    2506         QObject::tr("Use negative numbers for southern "
    2507                     "and western coordinates."));
    2508     return gc;
    2509 }
    2510 
    2511 DVBDiSEqCConfigurationWizard::DVBDiSEqCConfigurationWizard(CaptureCard &parent)
    2512 {
    2513     VerticalConfigurationGroup* rec = new VerticalConfigurationGroup(false);
    2514     rec->setLabel(QObject::tr("DiSEqC Options"));
    2515     rec->setUseLabel(false);
    2516 
    2517     DVBDiSEqCType  *diseqctype   = new DVBDiSEqCType(parent);
    2518     TunerCardInput *defaultinput = new TunerCardInput(parent);
    2519 
    2520     rec->addChild(diseqctype);
    2521     rec->addChild(defaultinput);
    2522     rec->addChild(DiSEqCLatitude());
    2523     rec->addChild(DiSEqCLongitude());
    2524     addChild(rec);
    2525 
    2526     connect(diseqctype,   SIGNAL(valueChanged(const QString&)),
    2527             defaultinput, SLOT(  diseqcType(  const QString&)));
    2528 
    2529     defaultinput->diseqcType(diseqctype->getValue());
    2530 }
  • libs/libmythtv/videosource.h

     
    66
    77#include "settings.h"
    88#include "datadirect.h"
     9#ifdef USING_DVB
     10#include "dvbdevtree.h"
     11#include "dvbdevtree_cfg.h"
     12#endif // USING_DVB
    913
    1014class SignalTimeout;
    1115class ChannelTimeout;
     
    203207
    204208  public slots:
    205209    void fillSelections(const QString &device);
    206     void diseqcType(const QString &diseqcType);
    207210
    208211  private:
    209212    QString last_device;
     
    381384    static void fillSelections(SelectSetting* setting);
    382385    static void fillSelections(SelectSetting* setting, bool no_children);
    383386
    384     void load() {
    385         ConfigurationWizard::load();
    386     };
    387 
     387    virtual void save();
     388   
    388389public slots:
    389390    void DiSEqCPanel();
    390391    void analogPanel();
     
    421422private:
    422423    ID       *id;
    423424    ParentID *parentid;
     425#ifdef USING_DVB
     426    DVBDevTree tree;
     427#endif
    424428};
    425429
    426430class CardInput;
     
    525529class ChildID;
    526530class InputName;
    527531class SourceID;
    528 class DVBLNBChooser;
    529 class DiSEqCPos;
    530 class DiSEqCPort;
    531 class LNBLofSwitch;
    532 class LNBLofLo;
    533 class LNBLofHi;
    534532
    535533class CardInput: public ConfigurationWizard
    536534{
    537535    Q_OBJECT
    538536  public:
    539     CardInput(bool is_dvb_card);
     537    CardInput(bool is_dvb_card, int cardid);
    540538
    541539    int getInputID(void) const { return id->intValue(); };
    542540
     
    544542    void loadByInput(int cardid, QString input);
    545543    QString getSourceName(void) const;
    546544
    547     void fillDiseqcSettingsInput(QString _pos, QString _port);
    548545    void SetChildCardID(uint);
    549546
    550547    virtual void save();
     
    553550  public slots:
    554551    void channelScanner();
    555552    void sourceFetch();
     553    void diseqcConfig();
    556554
    557555  private:
    558556    class ID: virtual public IntegerSetting,
     
    578576    ChildID         *childid;
    579577    InputName       *inputname;
    580578    SourceID        *sourceid;
    581     DVBLNBChooser   *lnbsettings;
    582     DiSEqCPos       *diseqcpos;
    583     DiSEqCPort      *diseqcport;
    584     LNBLofSwitch    *lnblofswitch;
    585     LNBLofLo        *lnbloflo;
    586     LNBLofHi        *lnblofhi;
    587579    StartingChannel *startchan;
     580#ifdef USING_DVB
     581    DVBDevSettings  settings;
     582#endif
    588583};
    589584
    590585#endif
  • libs/libmythtv/cardutil.h

     
    1515class CardInput;
    1616typedef QMap<int,QString> InputNames;
    1717
    18 class DVBDiSEqCInput
    19 {
    20   public:
    21     DVBDiSEqCInput() { clearValues(); }
    22     DVBDiSEqCInput(const QString &in, const QString &prt, const QString &pos)
    23         : input(in), port(prt), position(pos) {}
    24 
    25     void clearValues(void) { input = port = position = ""; }
    26 
    27     QString input;
    28     QString port;
    29     QString position;
    30 };
    31 typedef QValueList<DVBDiSEqCInput> DiSEqCList;
    32 
    33 /// \brief all the different dvb DiSEqC devices
    34 enum DISEQC_TYPES
    35 {
    36     DISEQC_SINGLE                  = 0,
    37     DISEQC_MINI_2                  = 1,
    38     DISEQC_SWITCH_2_1_0            = 2,
    39     DISEQC_SWITCH_2_1_1            = 3,
    40     DISEQC_SWITCH_4_1_0            = 4,
    41     DISEQC_SWITCH_4_1_1            = 5,
    42     DISEQC_POSITIONER_1_2          = 6,
    43     DISEQC_POSITIONER_X            = 7,
    44     DISEQC_POSITIONER_1_2_SWITCH_2 = 8,
    45     DISEQC_POSITIONER_X_SWITCH_2   = 9,
    46     DISEQC_SW21                    = 10,
    47     DISEQC_SW64                    = 11,
    48 };
    49 
    5018QString get_on_source(const QString&, uint, uint);
    5119QString get_on_input(const QString&, uint, const QString&);
    5220
     
    163131    static QString      ProbeSubTypeName(uint cardid, const QString &input);
    164132
    165133    static QStringList  probeInputs(QString device,
    166                                     QString cardtype = QString::null,
    167                                     int diseqctype = -1);
     134                                    QString cardtype = QString::null);
    168135    static void         GetCardInputs(int                 cardid,
    169136                                      QString             device,
    170137                                      QString             cardtype,
     
    188155    static QString      ProbeDVBType(uint device);
    189156    static bool         HasDVBCRCBug(uint device);
    190157    static uint         GetMinSignalMonitoringDelay(uint device);
    191     static DISEQC_TYPES GetDISEqCType(uint cardid);
    192158    static QString      GetDeviceName(dvb_dev_type_t, uint cardnum);
     159    static InputNames   configuredDVBInputs(uint cardid);
    193160
    194161    // V4L info
    195162    static bool         hasV4L2(int videofd);
     
    198165
    199166  private:
    200167    static QStringList  probeV4LInputs(QString device);
    201     static QStringList  probeDVBInputs(QString device, int diseqctype = -1);
     168    static QStringList  probeDVBInputs(QString device);
    202169    static QStringList  probeChildInputs(QString device);
    203 
    204     static QStringList  fillDVBInputs(int dvb_diseqc_type);
    205     static DiSEqCList   fillDVBInputsDiSEqC(int dvb_diseqc_type);
    206170};
    207171
    208172#endif //_CARDUTIL_H_
  • libs/libmythtv/cardutil.cpp

     
    332332    return "DVB" == GetRawCardType(cardid, inputname);
    333333}
    334334
    335 /** \fn CardUtil::GetDISEqCType(uint)
    336  *  \brief Returns the disqec type associated with a DVB card
    337  *  \param nCardID card id to check
    338  *  \return the disqec type
    339  */
    340 enum DISEQC_TYPES CardUtil::GetDISEqCType(uint nCardID)
    341 {
    342     int iRet = 0;
    343     MSqlQuery query(MSqlQuery::InitCon());
    344     query.prepare("SELECT dvb_diseqc_type "
    345                   "FROM capturecard "
    346                   "WHERE capturecard.cardid = :CARDID");
    347     query.bindValue(":CARDID", nCardID);
    348 
    349     if (!query.exec() || !query.isActive())
    350         MythContext::DBError("CardUtil::GetDISEqCType()", query);
    351     else if (query.next())
    352         iRet = query.value(0).toInt();
    353 
    354     return (DISEQC_TYPES)iRet;
    355 }
    356 
    357335/** \fn CardUtil::GetDefaultInput(uint)
    358336 *  \brief Returns the default input for the card
    359337 *  \param nCardID card id to check
     
    564542    return list;
    565543}
    566544
    567 QStringList CardUtil::probeInputs(QString device, QString cardtype,
    568                                   int diseqctype)
     545InputNames CardUtil::configuredDVBInputs(uint cardid)
    569546{
     547    InputNames list;
     548    MSqlQuery query(MSqlQuery::InitCon());
     549    query.prepare("SELECT cardinputid, inputname"
     550                  " FROM cardinput"
     551                  " WHERE cardid = :CARDID");
     552    query.bindValue(":CARDID", cardid);
     553
     554    if (query.exec() && query.isActive() && query.size() > 0)
     555    {
     556        while(query.next())
     557            list[query.value(0).toUInt()] = query.value(1).toString();
     558    }
     559    return list;
     560}
     561
     562QStringList CardUtil::probeInputs(QString device, QString cardtype)
     563{
    570564    QStringList ret;
    571565
    572566    if (("FIREWIRE"  == cardtype) ||
     
    577571        ret += "MPEG2TS";
    578572    }
    579573    else if ("DVB" == cardtype)
    580         ret += probeDVBInputs(device, diseqctype);
     574        ret += probeDVBInputs(device);
    581575    else
    582576        ret += probeV4LInputs(device);
    583577
     
    616610    return ret;
    617611}
    618612
    619 QStringList CardUtil::probeDVBInputs(QString device, int diseqc_type)
     613QStringList CardUtil::probeDVBInputs(QString device)
    620614{
    621615    QStringList ret;
    622616
    623617#ifdef USING_DVB
    624     if (diseqc_type < 0)
     618    int cardid = CardUtil::GetCardID(device);
     619    if (cardid <= 0)
     620        return ret;
     621
     622    InputNames list = configuredDVBInputs(cardid);
     623    InputNames::iterator it;
     624    for (it = list.begin(); it != list.end(); ++it)
    625625    {
    626         int cardid = CardUtil::GetCardID(device);
    627         if (cardid <= 0)
    628             return ret;
    629         diseqc_type = GetDISEqCType(cardid);
     626        if (it.key() >= 0)
     627            ret += *it;
    630628    }
    631 
    632     QValueList<DVBDiSEqCInput> dvbinput;
    633     dvbinput = fillDVBInputsDiSEqC(diseqc_type);
    634 
    635     QValueList<DVBDiSEqCInput>::iterator it;
    636     for (it = dvbinput.begin(); it != dvbinput.end(); ++it)
    637         ret += (*it).input;
    638629#else
    639630    (void) device;
    640     (void) diseqc_type;
    641631    ret += QObject::tr("ERROR, Compile with DVB support to query inputs");
    642632#endif
    643633
     
    668658    return ret;
    669659}
    670660
    671 QValueList<DVBDiSEqCInput>
    672 CardUtil::fillDVBInputsDiSEqC(int dvb_diseqc_type)
    673 {
    674     QValueList<DVBDiSEqCInput> list;
    675 
    676     QString stxt   = "DiSEqC Switch Input %1";
    677     QString mtxt   = "DiSEqC v1.2 Motor Position %1";
    678     QString itxt   = "DiSEqC v1.3 Input %1";
    679     QString l21txt = "SW21 Input %1";
    680     QString l64txt = "SW64 Input %1";
    681 
    682     switch (dvb_diseqc_type)
    683     {
    684         case DISEQC_MINI_2:
    685         case DISEQC_SWITCH_2_1_0:
    686         case DISEQC_SWITCH_2_1_1:
    687             for (uint i = 0; i < 2; ++i)
    688                 list.append(DVBDiSEqCInput(
    689                                 stxt.arg(i+1), QString::number(i), ""));
    690             break;
    691         case DISEQC_SWITCH_4_1_0:
    692         case DISEQC_SWITCH_4_1_1:
    693             for (uint i = 0; i < 4; ++i)
    694                 list.append(DVBDiSEqCInput(
    695                                 stxt.arg(i+1), QString::number(i), ""));
    696             break;
    697         case DISEQC_POSITIONER_1_2:
    698             for (uint i = 1; i < 50; ++i)
    699                 list.append(DVBDiSEqCInput(
    700                                 mtxt.arg(i), "", QString::number(i)));
    701             break;
    702         case DISEQC_POSITIONER_X:
    703             for (uint i = 1; i < 20; ++i)
    704                 list.append(DVBDiSEqCInput(
    705                                 itxt.arg(i), "", QString::number(i)));
    706             break;
    707         case DISEQC_POSITIONER_1_2_SWITCH_2:
    708             for (uint i = 0; i < 10; ++i)
    709                 list.append(DVBDiSEqCInput(
    710                                 stxt.arg(i+1,2), QString::number(i), ""));
    711             break;
    712         case DISEQC_SW21:
    713             for (uint i = 0; i < 2; ++i)
    714                 list.append(DVBDiSEqCInput(
    715                                 l21txt.arg(i+1,2), QString::number(i), ""));
    716             break;
    717         case DISEQC_SW64:
    718             for (uint i = 0; i < 3; ++i)
    719                 list.append(DVBDiSEqCInput(
    720                                 l64txt.arg(i+1,2), QString::number(i), ""));
    721             break;
    722         case DISEQC_SINGLE:
    723         default:
    724             list.append(DVBDiSEqCInput(
    725                             QString("DVBInput"), QString(""), QString("")));
    726     }
    727 
    728     return list;
    729 }
    730 
    731661QString CardUtil::GetDeviceLabel(uint cardid,
    732662                                 QString cardtype,
    733663                                 QString videodevice)
     
    818748    QStringList::iterator it = inputs.begin();
    819749    for (; it != inputs.end(); ++it)
    820750    {
    821         CardInput* cardinput = new CardInput(false);
     751        CardInput* cardinput = new CardInput(false, cardid);
    822752        cardinput->loadByInput(rcardid, (*it));
    823753        cardinput->SetChildCardID((parentid) ? cardid : 0);
    824754        inputLabels.push_back(
     
    827757        cardInputs.push_back(cardinput);
    828758    }
    829759
     760#ifdef USING_DVB
    830761    if ("DVB" == cardtype)
    831762    {
    832         QValueList<DVBDiSEqCInput> dvbinputs;
    833         int diseq_type = GetDISEqCType(cardid);
    834         dvbinputs = fillDVBInputsDiSEqC(diseq_type);
    835         QValueList<DVBDiSEqCInput>::iterator it;
    836         for (it = dvbinputs.begin(); it != dvbinputs.end(); ++it)
     763        InputNames list;
     764        bool needs_conf = DTVDeviceNeedsConfiguration(rcardid);
     765        if(needs_conf)
     766            list = configuredDVBInputs(rcardid);
     767        else
     768            list[0] = "DVBInput";
     769
     770        InputNames::iterator it;
     771        for (it = list.begin(); it != list.end(); ++it)
    837772        {
    838             CardInput* cardinput = new CardInput(true);
    839             cardinput->loadByInput(rcardid, (*it).input);
    840             cardinput->fillDiseqcSettingsInput((*it).position,(*it).port);
    841             cardinput->SetChildCardID((parentid) ? cardid : 0);
     773            CardInput* cardinput = new CardInput(true, rcardid);
     774            cardinput->loadByInput(rcardid, it.data());
     775            cardinput->SetChildCardID(parentid ? cardid : 0);
    842776            inputLabels.push_back(
    843777                dev_label + QString(" (%1) -> %2")
    844                 .arg((*it).input).arg(cardinput->getSourceName()));
     778                .arg(it.data()).arg(cardinput->getSourceName()));
    845779            cardInputs.push_back(cardinput);           
    846780        }
     781       
     782        // plus add one "new" input
     783        if(needs_conf)
     784        {
     785            CardInput* newcard = new CardInput(true, rcardid);
     786            QString newname = QString("DVBInput #%1").arg(list.size()+1);
     787            newcard->loadByInput(rcardid, newname);
     788            newcard->SetChildCardID((parentid) ? cardid : 0);
     789            inputLabels.push_back(
     790                dev_label + QString(" New Input"));
     791            cardInputs.push_back(newcard);
     792        }
    847793    }
     794#endif // USING_DVB
    848795
    849796    if (parentid)
    850797        return;
     
    872819    if (!cardid)
    873820        return true;
    874821
     822#ifdef USING_DVB
     823    // delete device tree
     824    DVBDevTree tree;
     825    tree.Load(cardid);
     826    if(tree.Root() != NULL)
     827    {
     828        tree.SetRoot(NULL);
     829        tree.Store(cardid);
     830    }
     831#endif
     832
    875833    // delete any children
    876834    MSqlQuery query(MSqlQuery::InitCon());
    877835    query.prepare(