Ticket #7003: 7003-v1.patch

File 7003-v1.patch, 12.6 KB (added by danielk, 10 years ago)
  • libs/libmythtv/channelscan/channelscan_sm.cpp

     
    3131#include <pthread.h>
    3232#include <unistd.h>
    3333
     34// C++ includes
     35#include <algorithm>
     36using namespace std;
     37
    3438// Qt includes
    3539#include <QMutex>
    3640
     
    535539            }
    536540
    537541            mplexid = ChannelUtil::GetMplexID(sourceID, frequency, tsid, netid);
     542            mplexid = max(0, mplexid);
    538543
     544            DTVTunerType tt = DTVTunerType::kTunerTypeOFDM;
     545            if (GetDTVChannel())
     546                tt = GetDTVChannel()->GetCardType();
     547
    539548            DTVMultiplex tuning;
    540             if (mplexid > 0)
     549            if (mplexid)
    541550            {
    542                 if (!tuning.FillFromDB(GetDVBChannel()->GetCardType(), mplexid))
     551                if (!tuning.FillFromDB(tt, mplexid))
    543552                    continue;
    544553            }
    545             else if (!tuning.FillFromDeliverySystemDesc(GetDVBChannel()->GetCardType(), desc))
     554            else if (!tuning.FillFromDeliverySystemDesc(tt, desc))
     555            {
    546556                continue;
     557            }
    547558
    548559            extend_transports[id] = tuning;
    549560            break;
  • libs/libmythtv/hdhrstreamhandler.cpp

     
    106106    _hdhomerun_device(NULL),
    107107    _tuner(-1),
    108108    _devicename(devicename),
     109    _tuner_type(kHDHRTunerTypeUnknown),
    109110
    110111    _start_stop_lock(QMutex::Recursive),
    111112    _running(false),
     
    562563
    563564bool HDHRStreamHandler::Open(void)
    564565{
    565     return Connect();
     566    if (Connect())
     567    {
     568        const char *model = hdhomerun_device_get_model_str(_hdhomerun_device);
     569        bool is_dvb = QString(model).toLower().contains("dvb");
     570        _tuner_type = (is_dvb) ? kHDHRTunerTypeDVBT : kHDHRTunerTypeATSC;
     571        return true;
     572    }
     573    return false;
    566574}
    567575
    568576void HDHRStreamHandler::Close(void)
  • libs/libmythtv/hdhrchannel.cpp

     
    5858
    5959    _stream_handler = HDHRStreamHandler::Get(_device_id);
    6060
     61    if (!_stream_handler)
     62        return false;
     63
     64    switch (_stream_handler->GetTunerType())
     65    {
     66        case kHDHRTunerTypeUnknown:
     67            cardType = DTVTunerType::kTunerTypeUnknown;
     68            break;
     69        case kHDHRTunerTypeATSC:
     70            cardType = DTVTunerType::kTunerTypeATSC;
     71            break;
     72        case kHDHRTunerTypeDVBT:
     73            cardType = DTVTunerType::kTunerTypeOFDM;
     74            break;
     75    }
     76
    6177    if (!InitializeInputs())
    6278    {
    6379        Close();
  • libs/libmythtv/dvbchannel.h

     
    88#ifndef DVBCHANNEL_H
    99#define DVBCHANNEL_H
    1010
    11 #include <qobject.h>
    12 #include <qstring.h>
    13 #include <qmap.h>
     11#include <QObject>
     12#include <QString>
     13#include <QMap>
    1414
    1515#include "mythcontext.h"
    1616#include "mythdbcon.h"
    1717#include "dtvchannel.h"
     18#include "dtvconfparserhelpers.h"
    1819#include "streamlisteners.h"
    1920#include "diseqc.h"
    2021
     
    5253    QString GetCardNum(void)            const { return device; };
    5354    /// Returns frontend name as reported by driver
    5455    QString GetFrontendName(void)       const;
    55     DTVTunerType GetCardType(void)      const { return card_type; }
    5656    bool IsMaster(void)                 const { return master == NULL; }
    5757    /// Returns true iff we have a faulty DVB driver that munges PMT
    5858    bool HasCRCBug(void)                const { return has_crc_bug; }
     
    115115
    116116    // Device info
    117117    QString           frontend_name;
    118     DTVTunerType      card_type;
    119118    uint64_t          capabilities;
    120119    uint64_t          ext_modulations;
    121120    uint64_t          frequency_minimum;
  • libs/libmythtv/dtvchannel.h

     
    2020
    2121// MythTV headers
    2222#include "channelbase.h"
     23#include "dtvconfparserhelpers.h"
    2324
    2425typedef pair<uint,uint> pid_cache_item_t;
    2526typedef vector<pid_cache_item_t> pid_cache_t;
     
    7576    /// \brief Returns tuning mode last set by SetTuningMode().
    7677    QString GetTuningMode(void) const;
    7778
     79    DTVTunerType GetCardType(void) const { return cardType; }
     80
    7881    /** \brief Returns cached MPEG PIDs for last tuned channel.
    7982     *  \param pid_cache List of PIDs with their TableID
    8083     *                   types is returned in pid_cache.
     
    110113  protected:
    111114    mutable QMutex dtvinfo_lock;
    112115
     116    DTVTunerType cardType;
    113117    QString sistandard; ///< PSIP table standard: MPEG, DVB, ATSC, OpenCable
    114118    QString tuningMode;
    115119    int     currentProgramNum;
  • libs/libmythtv/hdhrstreamhandler.h

     
    2727#endif
    2828
    2929typedef QMap<uint,int> FilterMap;
     30typedef enum HDHRTunerType {
     31    kHDHRTunerTypeUnknown,
     32    kHDHRTunerTypeATSC,
     33    kHDHRTunerTypeDVBT
     34} HDHRTunerType;
    3035
    3136//#define RETUNE_TIMEOUT 5000
    3237
     
    4449    bool IsRunning(void) const { return _running; }
    4550    void GetTunerStatus(struct hdhomerun_tuner_status_t *status);
    4651    bool IsConnected(void) const;
     52    HDHRTunerType GetTunerType(void) const { return _tuner_type; }
    4753
    4854    // Commands
    4955    bool TuneChannel(const QString &chanid);
     
    9197    hdhomerun_device_t *_hdhomerun_device;
    9298    uint                _tuner;
    9399    QString             _devicename;
     100    HDHRTunerType       _tuner_type;
    94101
    95102    mutable QMutex    _start_stop_lock;
    96103    bool              _running;
  • libs/libmythtv/dvbchannel.cpp

     
    7070      // Helper classes
    7171      diseqc_tree(NULL),            dvbcam(NULL),
    7272      // Device info
    73       frontend_name(QString::null), card_type(DTVTunerType::kTunerTypeUnknown),
     73      frontend_name(QString::null),
    7474      // Tuning
    7575      tune_lock(),                  hw_lock(),
    7676      last_lnb_dev_id(-1),
     
    166166
    167167        fd_frontend         = master->fd_frontend;
    168168        frontend_name       = master->frontend_name;
    169         card_type           = master->card_type;
     169        cardType            = master->cardType;
    170170        capabilities        = master->capabilities;
    171171        ext_modulations     = master->ext_modulations;
    172172        frequency_minimum   = master->frequency_minimum;
     
    212212    }
    213213
    214214    frontend_name       = info.name;
    215     card_type           = info.type;
     215    cardType            = info.type;
    216216#if HAVE_FE_CAN_2G_MODULATION
    217     if (card_type == DTVTunerType::kTunerTypeQPSK &&
     217    if (cardType == DTVTunerType::kTunerTypeQPSK &&
    218218        (info.caps & FE_CAN_2G_MODULATION))
    219         card_type = DTVTunerType::kTunerTypeDVB_S2;
     219        cardType = DTVTunerType::kTunerTypeDVB_S2;
    220220#endif // HAVE_FE_CAN_2G_MODULATION
    221221    capabilities        = info.caps;
    222222    frequency_minimum   = info.frequency_min;
     
    228228            .arg(device).arg(frontend_name));
    229229
    230230    // Turn on the power to the LNB
    231     if (card_type == DTVTunerType::kTunerTypeQPSK ||
    232         card_type == DTVTunerType::kTunerTypeDVB_S2)
     231    if (cardType == DTVTunerType::kTunerTypeQPSK ||
     232        cardType == DTVTunerType::kTunerTypeDVB_S2)
    233233    {
    234234        diseqc_tree = diseqc_dev.FindTree(GetCardID());
    235235        if (diseqc_tree)
     
    272272bool DVBChannel::TuneMultiplex(uint mplexid, QString inputname)
    273273{
    274274    DTVMultiplex tuning;
    275     if (!tuning.FillFromDB(card_type, mplexid))
     275    if (!tuning.FillFromDB(cardType, mplexid))
    276276        return false;
    277277
    278278    CheckOptions(tuning);
     
    354354
    355355    // Initialize basic the tuning parameters
    356356    DTVMultiplex tuning;
    357     if (!mplexid || !tuning.FillFromDB(card_type, mplexid))
     357    if (!mplexid || !tuning.FillFromDB(cardType, mplexid))
    358358    {
    359359        VERBOSE(VB_IMPORTANT, loc_err +
    360360                "Failed to initialize multiplex options");
     
    457457                .arg(frequency_minimum).arg(frequency_maximum));
    458458    }
    459459
    460     if (card_type.IsFECVariable() &&
     460    if (cardType.IsFECVariable() &&
    461461        symbol_rate_minimum && symbol_rate_maximum &&
    462462        (symbol_rate_minimum <= symbol_rate_maximum) &&
    463463        (tuning.symbolrate < symbol_rate_minimum ||
     
    470470                .arg(symbol_rate_minimum).arg(symbol_rate_maximum));
    471471    }
    472472
    473     if (card_type.IsFECVariable() && !CheckCodeRate(tuning.fec))
     473    if (cardType.IsFECVariable() && !CheckCodeRate(tuning.fec))
    474474    {
    475475        VERBOSE(VB_GENERAL, LOC_WARN + "Unsupported fec_inner parameter.");
    476476    }
    477477
    478     if (card_type.IsModulationVariable() && !CheckModulation(tuning.modulation))
     478    if (cardType.IsModulationVariable() && !CheckModulation(tuning.modulation))
    479479    {
    480480        VERBOSE(VB_GENERAL, LOC_WARN + "Unsupported modulation parameter.");
    481481    }
    482482
    483     if (DTVTunerType::kTunerTypeOFDM != card_type)
     483    if (DTVTunerType::kTunerTypeOFDM != cardType)
    484484    {
    485485        VERBOSE(VB_CHANNEL, LOC + tuning.toString());
    486486        return;
     
    739739    bool can_fec_auto = false;
    740740    bool reset = (force_reset || first_tune);
    741741
    742     bool is_dvbs = (DTVTunerType::kTunerTypeQPSK   == card_type ||
    743                     DTVTunerType::kTunerTypeDVB_S2 == card_type);
     742    bool is_dvbs = (DTVTunerType::kTunerTypeQPSK   == cardType ||
     743                    DTVTunerType::kTunerTypeDVB_S2 == cardType);
    744744
    745745    bool has_diseqc = (diseqc_tree != NULL);
    746746    if (is_dvbs && !has_diseqc)
     
    812812    int     freq_mult = (is_dvbs) ? 1 : 1000;
    813813    QString suffix    = (is_dvbs) ? "kHz" : "Hz";
    814814
    815     if (reset || !prev_tuning.IsEqual(card_type, tuning, 500 * freq_mult))
     815    if (reset || !prev_tuning.IsEqual(cardType, tuning, 500 * freq_mult))
    816816    {
    817817        VERBOSE(VB_CHANNEL, LOC + QString("Tune(): Tuning to %1%2")
    818818                .arg(intermediate_freq ? intermediate_freq : tuning.frequency)
    819819                .arg(suffix));
    820820
    821821#if DVB_API_VERSION >=5
    822         if (DTVTunerType::kTunerTypeDVB_S2 == card_type)
     822        if (DTVTunerType::kTunerTypeDVB_S2 == cardType)
    823823        {
    824824            struct dtv_property p_clear;
    825825            struct dtv_properties cmdseq_clear;
     
    836836            }
    837837
    838838            struct dtv_properties *cmds = dtvmultiplex_to_dtvproperties(
    839                 card_type, tuning, intermediate_freq, can_fec_auto);
     839                cardType, tuning, intermediate_freq, can_fec_auto);
    840840
    841841            if (!cmds) {
    842842                VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to convert "
     
    869869        else
    870870#endif
    871871        {
    872             struct dvb_frontend_parameters params = dtvmultiplex_to_dvbparams(card_type, tuning,
    873                                                                               intermediate_freq,
    874                                                                               can_fec_auto);
     872            struct dvb_frontend_parameters params = dtvmultiplex_to_dvbparams(
     873                cardType, tuning, intermediate_freq, can_fec_auto);
    875874
    876875            if (ioctl(fd_frontend, FE_SET_FRONTEND, &params) < 0)
    877876            {
     
    968967        return false;
    969968    }
    970969
    971     if (card_type == DTVTunerType::kTunerTypeDVB_S2)
     970    if (cardType == DTVTunerType::kTunerTypeDVB_S2)
    972971    {
    973972        // TODO implement probing of tuning parameters with FE_GET_PROPERTY
    974973        return false;
     
    986985    uint    mplex      = tuning.mplex;
    987986    QString sistandard = tuning.sistandard; sistandard.detach();
    988987
    989     tuning = dvbparams_to_dtvmultiplex(card_type, params);
     988    tuning = dvbparams_to_dtvmultiplex(cardType, params);
    990989
    991990    tuning.mplex       = mplex;
    992991    tuning.sistandard  = sistandard;
  • libs/libmythtv/dtvchannel.cpp

     
    1313
    1414DTVChannel::DTVChannel(TVRec *parent)
    1515    : ChannelBase(parent),
     16      cardType(DTVTunerType::kTunerTypeUnknown),
    1617      sistandard("mpeg"),         tuningMode(QString::null),
    1718      currentProgramNum(-1),
    1819      currentATSCMajorChannel(0), currentATSCMinorChannel(0),